From 3cae6a5fed8f538212bd81af81023cb5bc3519bb Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 30 Oct 2013 22:32:45 +0100 Subject: [PATCH] Use verify* methods from Verifiers. --- .../pterodactylus/sone/fcp/GetPostCommandTest.java | 28 ++++------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/src/test/java/net/pterodactylus/sone/fcp/GetPostCommandTest.java b/src/test/java/net/pterodactylus/sone/fcp/GetPostCommandTest.java index 6cd74a1..b248fef 100644 --- a/src/test/java/net/pterodactylus/sone/fcp/GetPostCommandTest.java +++ b/src/test/java/net/pterodactylus/sone/fcp/GetPostCommandTest.java @@ -18,12 +18,10 @@ package net.pterodactylus.sone.fcp; import static com.google.common.base.Optional.of; -import static java.lang.String.format; import static java.util.Arrays.asList; import static net.pterodactylus.sone.fcp.Verifiers.verifyAnswer; +import static net.pterodactylus.sone.fcp.Verifiers.verifyPostWithReplies; 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.mockito.Mockito.when; import net.pterodactylus.sone.data.Mocks; @@ -60,7 +58,7 @@ public class GetPostCommandTest { .get(); Response response = getPostCommand.execute(getPostFieldSet, null, DIRECT); verifyAnswer(response, "Post"); - verifyPost(post, response); + verifyPostWithReplies(response.getReplyParameters(), "Post.", post); } @Test @@ -74,7 +72,7 @@ public class GetPostCommandTest { .get(); Response response = getPostCommand.execute(getPostFieldSet, null, DIRECT); verifyAnswer(response, "Post"); - verifyPost(post, response); + verifyPostWithReplies(response.getReplyParameters(), "Post.", post); } @Test @@ -93,10 +91,7 @@ public class GetPostCommandTest { .get(); Response response = getPostCommand.execute(getPostFieldSet, null, DIRECT); verifyAnswer(response, "Post"); - verifyPost(post, response); - assertThat(response.getReplyParameters().getInt("Post.Replies.Count"), is(post.getReplies().size())); - verifyReply(response.getReplyParameters(), "Post.Replies.0.", postReply1); - verifyReply(response.getReplyParameters(), "Post.Replies.1.", postReply2); + verifyPostWithReplies(response.getReplyParameters(), "Post.", post); } @Test(expected = FcpException.class) @@ -138,19 +133,4 @@ public class GetPostCommandTest { return post; } - private void verifyReply(SimpleFieldSet replyParameters, String prefix, PostReply postReply) throws FSParseException { - assertThat(replyParameters.get(format("%sID", prefix)), is(postReply.getId())); - assertThat(replyParameters.get(format("%sSone", prefix)), is(postReply.getSone().getId())); - assertThat(replyParameters.getLong(format("%sTime", prefix)), is(postReply.getTime())); - assertThat(replyParameters.get(format("%sText", prefix)), is(postReply.getText())); - } - - private void verifyPost(Post post, Response response) throws FSParseException { - assertThat(response.getReplyParameters().get("Post.ID"), is(post.getId())); - assertThat(response.getReplyParameters().get("Post.Sone"), is(post.getSone().getId())); - assertThat(response.getReplyParameters().get("Post.Recipient"), is(post.getRecipientId().orNull())); - assertThat(response.getReplyParameters().getLong("Post.Time"), is(post.getTime())); - assertThat(response.getReplyParameters().get("Post.Text"), is(post.getText())); - } - } -- 2.7.4