@Test public void testAddRemoveClearUsers() { final Group.Builder builder = new Group.Builder() .identifier("1") .name("group1") .addUser("user1"); final Group group1 = builder.build(); assertNotNull(group1.getUsers()); assertEquals(1, group1.getUsers().size()); assertTrue(group1.getUsers().contains("user1")); final Set<String> moreUsers = new HashSet<>(); moreUsers.add("user2"); moreUsers.add("user3"); moreUsers.add("user4"); final Group group2 = builder.addUsers(moreUsers).build(); assertEquals(4, group2.getUsers().size()); assertTrue(group2.getUsers().contains("user1")); assertTrue(group2.getUsers().contains("user2")); assertTrue(group2.getUsers().contains("user3")); assertTrue(group2.getUsers().contains("user4")); final Group group3 = builder.removeUser("user2").build(); assertEquals(3, group3.getUsers().size()); assertTrue(group3.getUsers().contains("user1")); assertTrue(group3.getUsers().contains("user3")); assertTrue(group3.getUsers().contains("user4")); final Set<String> removeUsers = new HashSet<>(); removeUsers.add("user1"); removeUsers.add("user4"); final Group group4 = builder.removeUsers(removeUsers).build(); assertEquals(1, group4.getUsers().size()); assertTrue(group4.getUsers().contains("user3")); final Group group5 = builder.clearUsers().build(); assertEquals(0, group5.getUsers().size()); }
public Set<String> getUsers() { return users; }
Group { public Set<String> getUsers() { return users; } }
Group { public Set<String> getUsers() { return users; } private  Group(final Builder builder); }
Group { public Set<String> getUsers() { return users; } private  Group(final Builder builder); String getIdentifier(); String getName(); Set<String> getUsers(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); }
Group { public Set<String> getUsers() { return users; } private  Group(final Builder builder); String getIdentifier(); String getName(); Set<String> getUsers(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString();  }