Add test for javascript filter
[Sone.git] / src / test / java / net / pterodactylus / sone / TestPostReplyBuilder.java
1 package net.pterodactylus.sone;
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  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
16  */
17 public class TestPostReplyBuilder implements PostReplyBuilder {
18
19         private final PostReply postReply = mock(PostReply.class);
20
21         @Override
22         public PostReplyBuilder to(String postId) {
23                 when(postReply.getPostId()).thenReturn(postId);
24                 return this;
25         }
26
27         @Override
28         public PostReply build() throws IllegalStateException {
29                 return postReply;
30         }
31
32         @Override
33         public PostReplyBuilder randomId() {
34                 when(postReply.getId()).thenReturn(randomUUID().toString());
35                 return this;
36         }
37
38         @Override
39         public PostReplyBuilder withId(String id) {
40                 when(postReply.getId()).thenReturn(id);
41                 return this;
42         }
43
44         @Override
45         public PostReplyBuilder from(String senderId) {
46                 Sone sone = mock(Sone.class);
47                 when(sone.getId()).thenReturn(senderId);
48                 when(postReply.getSone()).thenReturn(sone);
49                 return this;
50         }
51
52         @Override
53         public PostReplyBuilder currentTime() {
54                 when(postReply.getTime()).thenReturn(currentTimeMillis());
55                 return this;
56         }
57
58         @Override
59         public PostReplyBuilder withTime(long time) {
60                 when(postReply.getTime()).thenReturn(time);
61                 return this;
62         }
63
64         @Override
65         public PostReplyBuilder withText(String text) {
66                 when(postReply.getText()).thenReturn(text);
67                 return this;
68         }
69
70 }