public static void add(String group, List<String> users) {
    for (String user : users) {
      Set<String> userGroups = userToNetgroupsMap.get(user);
      // ConcurrentHashMap does not allow null values; 
      // So null value check can be used to check if the key exists
      if (userGroups == null) {
        //Generate a ConcurrentHashSet (backed by the keyset of the ConcurrentHashMap)
        userGroups =
            Collections.newSetFromMap(new ConcurrentHashMap<String,Boolean>());
        Set<String> currentSet = userToNetgroupsMap.putIfAbsent(user, userGroups);
        if (currentSet != null) {
          userGroups = currentSet;
        }
      }
      userGroups.add(group);
    }
  }
@Test
  public void testMembership() {
    List<String> users = new ArrayList<String>();
    users.add(USER1);
    users.add(USER2);
    NetgroupCache.add(GROUP1, users);
    users = new ArrayList<String>();
    users.add(USER1);
    users.add(USER3);
    NetgroupCache.add(GROUP2, users);
    verifyGroupMembership(USER1, 2, GROUP1);
    verifyGroupMembership(USER1, 2, GROUP2);
    verifyGroupMembership(USER2, 1, GROUP1);
    verifyGroupMembership(USER3, 1, GROUP2);
  }