+ @Test
+ public void postRepliesAreParsedCorrectly() {
+ setupPostReplies();
+ PostReplyBuilderFactory postReplyBuilderFactory =
+ new PostReplyBuilderFactory() {
+ @Override
+ public PostReplyBuilder newPostReplyBuilder() {
+ return new TestPostReplyBuilder();
+ }
+ };
+ Collection<PostReply> postReplies =
+ configurationSoneParser.parsePostReplies(
+ postReplyBuilderFactory);
+ assertThat(postReplies, hasSize(2));
+ assertThat(postReplies,
+ containsInAnyOrder(isPostReply("R0", "P0", 1000L, "T0"),
+ isPostReply("R1", "P1", 1001L, "T1")));
+ }
+
+ private void setupPostReplies() {
+ setupPostReply("0", "R0", "P0", 1000L, "T0");
+ setupPostReply("1", "R1", "P1", 1001L, "T1");
+ setupPostReply("2", null, null, 0L, null);
+ }
+
+ private void setupPostReply(String postReplyNumber, String postReplyId,
+ String postId, long time, String text) {
+ setupString("Sone/1/Replies/" + postReplyNumber + "/ID", postReplyId);
+ setupString("Sone/1/Replies/" + postReplyNumber + "/Post/ID", postId);
+ setupLong("Sone/1/Replies/" + postReplyNumber + "/Time", time);
+ setupString("Sone/1/Replies/" + postReplyNumber + "/Text", text);
+ }
+
+ @Test(expected = InvalidPostReplyFound.class)
+ public void missingPostIdIsRecognized() {
+ setupPostReplyWithMissingPostId();
+ configurationSoneParser.parsePostReplies(null);
+ }
+
+ private void setupPostReplyWithMissingPostId() {
+ setupPostReply("0", "R0", null, 1000L, "T0");
+ }
+
+ @Test(expected = InvalidPostReplyFound.class)
+ public void missingPostReplyTimeIsRecognized() {
+ setupPostReplyWithMissingPostReplyTime();
+ configurationSoneParser.parsePostReplies(null);
+ }
+
+ private void setupPostReplyWithMissingPostReplyTime() {
+ setupPostReply("0", "R0", "P0", 0L, "T0");
+ }
+
+ @Test(expected = InvalidPostReplyFound.class)
+ public void missingPostReplyTextIsRecognized() {
+ setupPostReplyWithMissingPostReplyText();
+ configurationSoneParser.parsePostReplies(null);
+ }
+
+ private void setupPostReplyWithMissingPostReplyText() {
+ setupPostReply("0", "R0", "P0", 1000L, null);
+ }