1 package net.pterodactylus.sone;
3 import static java.util.UUID.randomUUID;
4 import static org.mockito.Mockito.mock;
5 import static org.mockito.Mockito.when;
7 import net.pterodactylus.sone.data.Image;
8 import net.pterodactylus.sone.data.Sone;
9 import net.pterodactylus.sone.database.ImageBuilder;
12 * {@link ImageBuilder} implementation that returns a mocked {@link Image}.
14 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
16 public class TestImageBuilder implements ImageBuilder {
18 private final Image image;
20 public TestImageBuilder() {
21 image = mock(Image.class);
22 Image.Modifier imageModifier = new Image.Modifier() {
23 private Sone sone = image.getSone();
24 private long creationTime = image.getCreationTime();
25 private String key = image.getKey();
26 private String title = image.getTitle();
27 private String description = image.getDescription();
28 private int width = image.getWidth();
29 private int height = image.getHeight();
32 public Image.Modifier setSone(Sone sone) {
38 public Image.Modifier setCreationTime(long creationTime) {
39 this.creationTime = creationTime;
44 public Image.Modifier setKey(String key) {
50 public Image.Modifier setTitle(String title) {
56 public Image.Modifier setDescription(String description) {
57 this.description = description;
62 public Image.Modifier setWidth(int width) {
68 public Image.Modifier setHeight(int height) {
74 public Image update() throws IllegalStateException {
75 when(image.getSone()).thenReturn(sone);
76 when(image.getCreationTime()).thenReturn(creationTime);
77 when(image.getKey()).thenReturn(key);
78 when(image.getTitle()).thenReturn(title);
79 when(image.getDescription()).thenReturn(description);
80 when(image.getWidth()).thenReturn(width);
81 when(image.getHeight()).thenReturn(height);
85 when(image.modify()).thenReturn(imageModifier);
89 public ImageBuilder randomId() {
90 when(image.getId()).thenReturn(randomUUID().toString());
95 public ImageBuilder withId(String id) {
96 when(image.getId()).thenReturn(id);
101 public Image build() throws IllegalStateException {