Add test for PostPart
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 5 Oct 2016 19:12:21 +0000 (21:12 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 5 Oct 2016 19:12:21 +0000 (21:12 +0200)
src/test/java/net/pterodactylus/sone/text/PostPartTest.java [new file with mode: 0644]

diff --git a/src/test/java/net/pterodactylus/sone/text/PostPartTest.java b/src/test/java/net/pterodactylus/sone/text/PostPartTest.java
new file mode 100644 (file)
index 0000000..6666d61
--- /dev/null
@@ -0,0 +1,33 @@
+package net.pterodactylus.sone.text;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import net.pterodactylus.sone.data.Post;
+
+import org.junit.Test;
+
+/**
+ * Unit test for {@link PostPart}.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class PostPartTest {
+
+       private final Post post = mock(Post.class);
+       private final PostPart part = new PostPart(post);
+
+       @Test
+       public void postIsRetainedCorrectly() {
+               assertThat(part.getPost(), is(post));
+       }
+
+       @Test
+       public void textIsTakenFromPost() {
+               when(post.getText()).thenReturn("text");
+               assertThat(part.getText(), is("text"));
+       }
+
+}