✅ Add more tests for FreenetTemplatePage
[Sone.git] / src / test / java / net / pterodactylus / sone / text / PostPartTest.java
1 package net.pterodactylus.sone.text;
2
3 import static org.hamcrest.MatcherAssert.assertThat;
4 import static org.hamcrest.Matchers.is;
5 import static org.mockito.Mockito.mock;
6 import static org.mockito.Mockito.when;
7
8 import net.pterodactylus.sone.data.Post;
9
10 import org.junit.Test;
11
12 /**
13  * Unit test for {@link PostPart}.
14  */
15 public class PostPartTest {
16
17         private final Post post = mock(Post.class);
18         private final PostPart part = new PostPart(post);
19
20         @Test
21         public void postIsRetainedCorrectly() {
22                 assertThat(part.getPost(), is(post));
23         }
24
25         @Test
26         public void textIsTakenFromPost() {
27                 when(post.getText()).thenReturn("text");
28                 assertThat(part.getText(), is("text"));
29         }
30
31         @Test(expected = NullPointerException.class)
32         public void nullIsNotAllowedForPost() {
33             new PostPart(null);
34         }
35
36 }