return likedPostReplyIds;
}
+ public Set<String> parseFriends() {
+ Set<String> friends = new HashSet<String>();
+ while (true) {
+ String friendId =
+ getString("/Friends/" + friends.size() + "/ID", null);
+ if (friendId == null) {
+ break;
+ }
+ friends.add(friendId);
+ }
+ return friends;
+ }
+
public static class InvalidPostFound extends RuntimeException { }
public static class InvalidPostReplyFound extends RuntimeException { }
configurationSoneParser.parseLikedPostReplyIds();
/* load friends. */
- Set<String> friends = new HashSet<String>();
- while (true) {
- String friendId = configuration.getStringValue(sonePrefix + "/Friends/" + friends.size() + "/ID").getValue(null);
- if (friendId == null) {
- break;
- }
- friends.add(friendId);
- }
+ Set<String> friends = configurationSoneParser.parseFriends();
/* load albums. */
List<Album> topLevelAlbums = new ArrayList<Album>();
setupString("Sone/1/Likes/Reply/3/ID", null);
}
+ @Test
+ public void friendsAreParsedCorrectly() {
+ setupFriends();
+ Set<String> friends = configurationSoneParser.parseFriends();
+ assertThat(friends, containsInAnyOrder("F1", "F2", "F3"));
+ }
+
+ private void setupFriends() {
+ setupString("Sone/1/Friends/0/ID", "F1");
+ setupString("Sone/1/Friends/1/ID", "F2");
+ setupString("Sone/1/Friends/2/ID", "F3");
+ setupString("Sone/1/Friends/3/ID", null);
+ }
+
private static class TestValue<T> implements Value<T> {
private final AtomicReference<T> value = new AtomicReference<T>();