@Test public void testAddRemoveClearUsers() { final AccessPolicy.Builder builder = new AccessPolicy.Builder() .identifier("1") .resource(TEST_RESOURCE) .addUser("user1") .action(RequestAction.READ); final AccessPolicy policy1 = builder.build(); assertEquals(1, policy1.getUsers().size()); assertTrue(policy1.getUsers().contains("user1")); final Set<String> moreEntities = new HashSet<>(); moreEntities.add("user2"); moreEntities.add("user3"); moreEntities.add("user4"); final AccessPolicy policy2 = builder.addUsers(moreEntities).build(); assertEquals(4, policy2.getUsers().size()); assertTrue(policy2.getUsers().contains("user1")); assertTrue(policy2.getUsers().contains("user2")); assertTrue(policy2.getUsers().contains("user3")); assertTrue(policy2.getUsers().contains("user4")); final AccessPolicy policy3 = builder.removeUser("user3").build(); assertEquals(3, policy3.getUsers().size()); assertTrue(policy3.getUsers().contains("user1")); assertTrue(policy3.getUsers().contains("user2")); assertTrue(policy3.getUsers().contains("user4")); final Set<String> removeEntities = new HashSet<>(); removeEntities.add("user1"); removeEntities.add("user4"); final AccessPolicy policy4 = builder.removeUsers(removeEntities).build(); assertEquals(1, policy4.getUsers().size()); assertTrue(policy4.getUsers().contains("user2")); final AccessPolicy policy5 = builder.clearUsers().build(); assertEquals(0, policy5.getUsers().size()); }
public Set<String> getUsers() { return users; }
AccessPolicy { public Set<String> getUsers() { return users; } }
AccessPolicy { public Set<String> getUsers() { return users; } private  AccessPolicy(final Builder builder); }
AccessPolicy { public Set<String> getUsers() { return users; } private  AccessPolicy(final Builder builder); String getIdentifier(); String getResource(); Set<String> getUsers(); Set<String> getGroups(); RequestAction getAction(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); }
AccessPolicy { public Set<String> getUsers() { return users; } private  AccessPolicy(final Builder builder); String getIdentifier(); String getResource(); Set<String> getUsers(); Set<String> getGroups(); RequestAction getAction(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString();  }