private void printAllFollowing(final List<SocialUser> users) { allfollowing.clear(); followingBadge.setText(String.valueOf(socialLoggedUser.getFollowingName().size())); if (socialLoggedUser.getFollowingName().isEmpty()) { final ListGroupItem user = new ListGroupItem(); user.setText(constants.CurrentlyNotFollowingAnyUser()); allfollowing.add(user); } else { for (final SocialUser following : users) { if (socialLoggedUser.getFollowingName().contains(following.getUserName())) { allfollowing.add(createUserItem(following, true)); } } } }
private void printAllFollowing(final List<SocialUser> users) { allfollowing.clear(); followingBadge.setText(String.valueOf(socialLoggedUser.getFollowingName().size())); if (socialLoggedUser.getFollowingName().isEmpty()) { final ListGroupItem user = new ListGroupItem(); user.setText(constants.CurrentlyNotFollowingAnyUser()); allfollowing.add(user); } else { for (final SocialUser following : users) { if (socialLoggedUser.getFollowingName().contains(following.getUserName())) { allfollowing.add(createUserItem(following, true)); } } } }
@Override public JsonElement serialize(SocialUser socialUser, Type type, JsonSerializationContext jsonSerializationContext) { final JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("userName", socialUser.getUserName()); jsonObject.addProperty("realName", socialUser.getRealName()); jsonObject.addProperty("email", socialUser.getEmail()); serializeList(socialUser, "following", socialUser.getFollowingName(), jsonObject); serializeList(socialUser, "followers", socialUser.getFollowersName(), jsonObject); return jsonObject; }
@Override public JsonElement serialize(SocialUser socialUser, Type type, JsonSerializationContext jsonSerializationContext) { final JsonObject jsonObject = new JsonObject(); jsonObject.addProperty("userName", socialUser.getUserName()); jsonObject.addProperty("realName", socialUser.getRealName()); jsonObject.addProperty("email", socialUser.getEmail()); serializeList(socialUser, "following", socialUser.getFollowingName(), jsonObject); serializeList(socialUser, "followers", socialUser.getFollowersName(), jsonObject); return jsonObject; }
@Test public void userCannotFollowHimself() { SocialUser user1 = new SocialUser("user1"); user1.follow(user1); assertTrue(user1.getFollowersName().isEmpty()); assertTrue(user1.getFollowingName().isEmpty()); }
@Test public void userCannotFollowHimself() { SocialUser user1 = new SocialUser("user1"); user1.follow(user1); assertTrue(user1.getFollowersName().isEmpty()); assertTrue(user1.getFollowingName().isEmpty()); }
@Test public void unfollowTest() { SocialUser user1 = new SocialUser("user1"); SocialUser user2 = new SocialUser("user2"); user1.follow(user2); assertTrue(user1.getFollowingName().contains(user2.getUserName())); assertTrue(user2.getFollowersName().contains(user1.getUserName())); user1.unfollow(user2); assertTrue(user1.getFollowingName().isEmpty()); assertTrue(user2.getFollowersName().isEmpty()); } }
@Test public void unfollowTest() { SocialUser user1 = new SocialUser("user1"); SocialUser user2 = new SocialUser("user2"); user1.follow(user2); assertTrue(user1.getFollowingName().contains(user2.getUserName())); assertTrue(user2.getFollowersName().contains(user1.getUserName())); user1.unfollow(user2); assertTrue(user1.getFollowingName().isEmpty()); assertTrue(user2.getFollowersName().isEmpty()); } }
@Test public void user_toJSON_fromJson_Test() { SocialUser user = new SocialUser("user1"); SocialUser user2 = new SocialUser("user2"); SocialUser user3 = new SocialUser("user3"); SocialUser user4 = new SocialUser("user4"); user.follow(user2); user.follow(user3); user4.follow(user); String json = gson.toJson(user); SocialUser jsonUser = gson.fromJson(json, SocialUser.class); assertEquals("user1", jsonUser.getUserName()); assertEquals("user4", jsonUser.getFollowersName().get(0)); assertEquals("user2", jsonUser.getFollowingName().get(0)); assertEquals("user3", jsonUser.getFollowingName().get(1)); }
@Test public void user_toJSON_fromJson_Test() { SocialUser user = new SocialUser("user1"); SocialUser user2 = new SocialUser("user2"); SocialUser user3 = new SocialUser("user3"); SocialUser user4 = new SocialUser("user4"); user.follow(user2); user.follow(user3); user4.follow(user); String json = gson.toJson(user); SocialUser jsonUser = gson.fromJson(json, SocialUser.class); assertEquals("user1", jsonUser.getUserName()); assertEquals("user4", jsonUser.getFollowersName().get(0)); assertEquals("user2", jsonUser.getFollowingName().get(0)); assertEquals("user3", jsonUser.getFollowingName().get(1)); }
@Test public void followBasicTest() { SocialUser user1 = new SocialUser("user1"); SocialUser user2 = new SocialUser("user2"); user1.follow(user2); assertTrue(user1.getFollowingName().contains(user2.getUserName())); assertTrue(user2.getFollowersName().contains(user1.getUserName())); }
@Test public void followBasicTest() { SocialUser user1 = new SocialUser("user1"); SocialUser user2 = new SocialUser("user2"); user1.follow(user2); assertTrue(user1.getFollowingName().contains(user2.getUserName())); assertTrue(user2.getFollowersName().contains(user1.getUserName())); }