- private Post preparePostWithoutRecipient(Sone sone) {
- Post post = preparePost(sone);
- when(post.getRecipientId()).thenReturn(Optional.<String>absent());
- when(post.getRecipient()).thenReturn(Optional.<Sone>absent());
- return post;
- }
-
- private Post preparePostWithRecipient(Sone sone, Sone otherSone) {
- Post post = preparePost(sone);
- String otherSoneId = otherSone.getId();
- when(post.getRecipientId()).thenReturn(of(otherSoneId));
- when(post.getRecipient()).thenReturn(of(otherSone));
- return post;
- }
-
- private Post preparePost(Sone sone) {
- Post post = mocks.mockPost(sone, "PostId");
- when(post.getText()).thenReturn("Text of the post.");
- when(post.getTime()).thenReturn(1000L);
- return post;
- }
-
- private void verifyAnswer(Response response) {
- assertThat(response, notNullValue());
- assertThat(response.getReplyParameters(), notNullValue());
- assertThat(response.getReplyParameters().get("Message"), is("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()));
- }
-