X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Ffcp%2FGetPostFeedCommandTest.java;h=46f21f3b9c1942504fa46abb2a0fe0df5ac79432;hb=2d37242d19f2e726cd402b99f935a0eba282f630;hp=97e9e81d7111bd7528bc8da3c46c0c9d7a86f283;hpb=f479ac8ae786d02c07a14bd0cce5e09776ca9c35;p=Sone.git diff --git a/src/test/java/net/pterodactylus/sone/fcp/GetPostFeedCommandTest.java b/src/test/java/net/pterodactylus/sone/fcp/GetPostFeedCommandTest.java index 97e9e81..46f21f3 100644 --- a/src/test/java/net/pterodactylus/sone/fcp/GetPostFeedCommandTest.java +++ b/src/test/java/net/pterodactylus/sone/fcp/GetPostFeedCommandTest.java @@ -20,12 +20,11 @@ package net.pterodactylus.sone.fcp; import static java.lang.System.currentTimeMillis; import static java.util.Arrays.asList; import static java.util.concurrent.TimeUnit.DAYS; -import static net.pterodactylus.sone.fcp.Verifiers.verifyPost; -import static net.pterodactylus.sone.fcp.Verifiers.verifyPostReplies; +import static net.pterodactylus.sone.Verifiers.verifyAnswer; +import static net.pterodactylus.sone.Verifiers.verifyPostsWithReplies; import static net.pterodactylus.sone.freenet.fcp.Command.AccessType.DIRECT; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.notNullValue; + +import java.util.Collections; import net.pterodactylus.sone.data.Mocks; import net.pterodactylus.sone.data.Post; @@ -79,14 +78,8 @@ public class GetPostFeedCommandTest { .put("Sone", "LSone") .get(); Response response = getPostFeedCommand.execute(getPostFeedFieldSet, null, DIRECT); - assertThat(response, notNullValue()); - assertThat(response.getReplyParameters(), notNullValue()); - assertThat(response.getReplyParameters().get("Message"), is("PostFeed")); - assertThat(response.getReplyParameters().getInt("Posts.Count"), is(3)); - verifyPost(response.getReplyParameters(), "Posts.0.", localPost); - verifyPostReplies(response.getReplyParameters(), "Posts.0.Replies.", asList(friendReplyToLocalPost, remoteReplyToLocalPost)); - verifyPost(response.getReplyParameters(), "Posts.1.", friendPost); - verifyPost(response.getReplyParameters(), "Posts.2.", remotePost); + verifyAnswer(response, "PostFeed"); + verifyPostsWithReplies(response.getReplyParameters(), "Posts.", asList(localPost, friendPost, remotePost)); } @Test @@ -97,12 +90,8 @@ public class GetPostFeedCommandTest { .put("StartPost", "1") .get(); Response response = getPostFeedCommand.execute(getPostFeedFieldSet, null, DIRECT); - assertThat(response, notNullValue()); - assertThat(response.getReplyParameters(), notNullValue()); - assertThat(response.getReplyParameters().get("Message"), is("PostFeed")); - assertThat(response.getReplyParameters().getInt("Posts.Count"), is(2)); - verifyPost(response.getReplyParameters(), "Posts.0.", friendPost); - verifyPost(response.getReplyParameters(), "Posts.1.", remotePost); + verifyAnswer(response, "PostFeed"); + verifyPostsWithReplies(response.getReplyParameters(), "Posts.", asList(friendPost, remotePost)); } @Test @@ -113,13 +102,8 @@ public class GetPostFeedCommandTest { .put("MaxPosts", "2") .get(); Response response = getPostFeedCommand.execute(getPostFeedFieldSet, null, DIRECT); - assertThat(response, notNullValue()); - assertThat(response.getReplyParameters(), notNullValue()); - assertThat(response.getReplyParameters().get("Message"), is("PostFeed")); - assertThat(response.getReplyParameters().getInt("Posts.Count"), is(2)); - verifyPost(response.getReplyParameters(), "Posts.0.", localPost); - verifyPostReplies(response.getReplyParameters(), "Posts.0.Replies.", asList(friendReplyToLocalPost, remoteReplyToLocalPost)); - verifyPost(response.getReplyParameters(), "Posts.1.", friendPost); + verifyAnswer(response, "PostFeed"); + verifyPostsWithReplies(response.getReplyParameters(), "Posts.", asList(localPost, friendPost)); } @Test @@ -131,11 +115,8 @@ public class GetPostFeedCommandTest { .put("StartPost", "1") .get(); Response response = getPostFeedCommand.execute(getPostFeedFieldSet, null, DIRECT); - assertThat(response, notNullValue()); - assertThat(response.getReplyParameters(), notNullValue()); - assertThat(response.getReplyParameters().get("Message"), is("PostFeed")); - assertThat(response.getReplyParameters().getInt("Posts.Count"), is(1)); - verifyPost(response.getReplyParameters(), "Posts.0.", friendPost); + verifyAnswer(response, "PostFeed"); + verifyPostsWithReplies(response.getReplyParameters(), "Posts.", asList(friendPost)); } @Test @@ -146,10 +127,8 @@ public class GetPostFeedCommandTest { .put("StartPost", "10") .get(); Response response = getPostFeedCommand.execute(getPostFeedFieldSet, null, DIRECT); - assertThat(response, notNullValue()); - assertThat(response.getReplyParameters(), notNullValue()); - assertThat(response.getReplyParameters().get("Message"), is("PostFeed")); - assertThat(response.getReplyParameters().getInt("Posts.Count"), is(0)); + verifyAnswer(response, "PostFeed"); + verifyPostsWithReplies(response.getReplyParameters(), "Posts.", Collections.emptyList()); } @Test(expected = FcpException.class)