🎨 Replace test for default option with Kotlin version
[Sone.git] / src / test / java / net / pterodactylus / sone / test / TestPostReplyBuilder.java
1 package net.pterodactylus.sone.test;
2
3 import static java.lang.System.currentTimeMillis;
4 import static java.util.UUID.randomUUID;
5 import static org.mockito.Mockito.mock;
6 import static org.mockito.Mockito.when;
7
8 import net.pterodactylus.sone.data.PostReply;
9 import net.pterodactylus.sone.data.Sone;
10 import net.pterodactylus.sone.database.PostReplyBuilder;
11
12 /**
13  * {@link PostReplyBuilder} that returns a mocked {@link PostReply}.
14  */
15 public class TestPostReplyBuilder implements PostReplyBuilder {
16
17         private final PostReply postReply = mock(PostReply.class);
18
19         @Override
20         public PostReplyBuilder to(String postId) {
21                 when(postReply.getPostId()).thenReturn(postId);
22                 return this;
23         }
24
25         @Override
26         public PostReply build() throws IllegalStateException {
27                 return postReply;
28         }
29
30         @Override
31         public PostReplyBuilder randomId() {
32                 when(postReply.getId()).thenReturn(randomUUID().toString());
33                 return this;
34         }
35
36         @Override
37         public PostReplyBuilder withId(String id) {
38                 when(postReply.getId()).thenReturn(id);
39                 return this;
40         }
41
42         @Override
43         public PostReplyBuilder from(String senderId) {
44                 Sone sone = mock(Sone.class);
45                 when(sone.getId()).thenReturn(senderId);
46                 when(postReply.getSone()).thenReturn(sone);
47                 return this;
48         }
49
50         @Override
51         public PostReplyBuilder currentTime() {
52                 when(postReply.getTime()).thenReturn(currentTimeMillis());
53                 return this;
54         }
55
56         @Override
57         public PostReplyBuilder withTime(long time) {
58                 when(postReply.getTime()).thenReturn(time);
59                 return this;
60         }
61
62         @Override
63         public PostReplyBuilder withText(String text) {
64                 when(postReply.getText()).thenReturn(text);
65                 return this;
66         }
67
68 }