Move name of message into method parameter.
[Sone.git] / src / test / java / net / pterodactylus / sone / fcp / GetPostCommandTest.java
index 09c21ec..2c72cdf 100644 (file)
@@ -52,38 +52,38 @@ public class GetPostCommandTest {
 
        @Test
        public void verifyThatGettingAPostWithoutRepliesAndRecipientWorks() throws FcpException, FSParseException {
-               Sone sone = mocks.mockRemoteSone("SoneId");
+               Sone sone = mocks.mockSone("SoneId").create();
                Post post = preparePostWithoutRecipient(sone);
                SimpleFieldSet getPostFieldSet = new SimpleFieldSetBuilder()
                                .put("Message", "GetPost")
                                .put("Post", "PostId")
                                .get();
                Response response = getPostCommand.execute(getPostFieldSet, null, DIRECT);
-               verifyAnswer(response);
+               verifyAnswer(response, "Post");
                verifyPost(post, response);
        }
 
        @Test
        public void verifyThatGettingAPostWithoutRepliesAndWithRecipientWorks() throws FcpException, FSParseException {
-               Sone sone = mocks.mockRemoteSone("SoneId");
-               Sone otherSone = mocks.mockRemoteSone("OtherSoneId");
+               Sone sone = mocks.mockSone("SoneId").create();
+               Sone otherSone = mocks.mockSone("OtherSoneId").create();
                Post post = preparePostWithRecipient(sone, otherSone);
                SimpleFieldSet getPostFieldSet = new SimpleFieldSetBuilder()
                                .put("Message", "GetPost")
                                .put("Post", "PostId")
                                .get();
                Response response = getPostCommand.execute(getPostFieldSet, null, DIRECT);
-               verifyAnswer(response);
+               verifyAnswer(response, "Post");
                verifyPost(post, response);
        }
 
        @Test
        public void verifyThatGettingAPostWithRepliesWorks() throws FcpException, FSParseException {
-               Sone sone = mocks.mockRemoteSone("SoneId");
+               Sone sone = mocks.mockSone("SoneId").create();
                Post post = preparePostWithoutRecipient(sone);
-               PostReply postReply1 = mocks.mockPostReply(sone, "Reply1");
+               PostReply postReply1 = mocks.mockPostReply(sone, "Reply1").create();
                when(postReply1.getText()).thenReturn("Reply 1.");
-               PostReply postReply2 = mocks.mockPostReply(sone, "Reply2");
+               PostReply postReply2 = mocks.mockPostReply(sone, "Reply2").create();
                when(postReply2.getText()).thenReturn("Reply 2.");
                when(post.getReplies()).thenReturn(asList(postReply1, postReply2));
                SimpleFieldSet getPostFieldSet = new SimpleFieldSetBuilder()
@@ -92,7 +92,7 @@ public class GetPostCommandTest {
                                .put("IncludeReplies", "true")
                                .get();
                Response response = getPostCommand.execute(getPostFieldSet, null, DIRECT);
-               verifyAnswer(response);
+               verifyAnswer(response, "Post");
                verifyPost(post, response);
                assertThat(response.getReplyParameters().getInt("Post.Replies.Count"), is(post.getReplies().size()));
                verifyReply(response.getReplyParameters(), "Post.Replies.0.", postReply1);
@@ -132,16 +132,16 @@ public class GetPostCommandTest {
        }
 
        private Post preparePost(Sone sone) {
-               Post post = mocks.mockPost(sone, "PostId");
+               Post post = mocks.mockPost(sone, "PostId").create();
                when(post.getText()).thenReturn("Text of the post.");
                when(post.getTime()).thenReturn(1000L);
                return post;
        }
 
-       private void verifyAnswer(Response response) {
+       private void verifyAnswer(Response response, String messageName) {
                assertThat(response, notNullValue());
                assertThat(response.getReplyParameters(), notNullValue());
-               assertThat(response.getReplyParameters().get("Message"), is("Post"));
+               assertThat(response.getReplyParameters().get("Message"), is(messageName));
        }
 
        private void verifyReply(SimpleFieldSet replyParameters, String prefix, PostReply postReply) throws FSParseException {