return likedPostIds;
}
+ public Set<String> parseLikedPostReplyIds() {
+ Set<String> likedPostReplyIds = new HashSet<String>();
+ while (true) {
+ String likedReplyId = getString(
+ "/Likes/Reply/" + likedPostReplyIds.size() + "/ID", null);
+ if (likedReplyId == null) {
+ break;
+ }
+ likedPostReplyIds.add(likedReplyId);
+ }
+ return likedPostReplyIds;
+ }
+
public static class InvalidPostFound extends RuntimeException { }
public static class InvalidPostReplyFound extends RuntimeException { }
configurationSoneParser.parseLikedPostIds();
/* load reply likes. */
- Set<String> likedReplyIds = new HashSet<String>();
- while (true) {
- String likedReplyId = configuration.getStringValue(sonePrefix + "/Likes/Reply/" + likedReplyIds.size() + "/ID").getValue(null);
- if (likedReplyId == null) {
- break;
- }
- likedReplyIds.add(likedReplyId);
- }
+ Set<String> likedReplyIds =
+ configurationSoneParser.parseLikedPostReplyIds();
/* load friends. */
Set<String> friends = new HashSet<String>();
setupString("Sone/1/Likes/Post/3/ID", null);
}
+ @Test
+ public void likedPostReplyIdsAreParsedCorrectly() {
+ setupLikedPostReplyIds();
+ Set<String> likedPostReplyIds =
+ configurationSoneParser.parseLikedPostReplyIds();
+ assertThat(likedPostReplyIds, containsInAnyOrder("R1", "R2", "R3"));
+ }
+
+ private void setupLikedPostReplyIds() {
+ setupString("Sone/1/Likes/Reply/0/ID", "R1");
+ setupString("Sone/1/Likes/Reply/1/ID", "R2");
+ setupString("Sone/1/Likes/Reply/2/ID", "R3");
+ setupString("Sone/1/Likes/Reply/3/ID", null);
+ }
+
private static class TestValue<T> implements Value<T> {
private final AtomicReference<T> value = new AtomicReference<T>();