ShellBasedUnixGroupsMapping implements GroupMappingServiceProvider { @Override public List<String> getGroups(String userName) throws IOException { return getUnixGroups(userName); }  @Override List<String> getGroups(String userName); @Override void cacheGroupsRefresh(); @Override void cacheGroupsAdd(List<String> groups);  }
@Test public void testGetGroupsNonexistentUser() throws Exception { TestGroupUserNotExist mapping = new TestGroupUserNotExist(); List<String> groups = mapping.getGroups("foobarusernotexist"); assertTrue(groups.isEmpty()); }
@Test public void testGetGroupsNotResolvable() throws Exception { TestGroupNotResolvable mapping = new TestGroupNotResolvable(); List<String> groups = mapping.getGroups("user"); assertTrue(groups.size() == 2); assertTrue(groups.contains("abc")); assertTrue(groups.contains("def")); }
@Test public void testGetNumericGroupsResolvable() throws Exception { TestNumericGroupResolvable mapping = new TestNumericGroupResolvable(); List<String> groups = mapping.getGroups("user"); assertTrue(groups.size() == 3); assertTrue(groups.contains("23")); assertTrue(groups.contains("groupname")); assertTrue(groups.contains("zzz")); }
@Test public void testGetGroupsResolvable() throws Exception { TestGroupResolvable mapping = new TestGroupResolvable(); List<String> groups = mapping.getGroups("user"); assertTrue(groups.size() == 3); assertTrue(groups.contains("abc")); assertTrue(groups.contains("def")); assertTrue(groups.contains("hij")); }