### Question:
AuditWhitelistManager { Map<String, String> getRoleWhitelist(RoleResource role) { Map<IResource, Set<Permission>> whitelist = whitelistDataAccess.getWhitelist(role); return whitelist.entrySet() .stream() .collect(Collectors.toMap(e -> ResourceFactory.toPrintableName(e.getKey()), e -> OperationFactory.toOperationNameCsv(e.getValue()))); } AuditWhitelistManager(); @VisibleForTesting  AuditWhitelistManager(WhitelistDataAccess whitelistDataAccess); void setup();  }### Answer:
@Test public void testGetWhitelist() { Map<IResource, Set<Permission>> daoWhitelist = ImmutableMap.of(DataResource.fromName("data/someks/sometable"), EnumSet.of(Permission.SELECT), ConnectionResource.fromName("connections"), EnumSet.of(Permission.EXECUTE)); when(mockWhitelistDataAccess.getWhitelist(eq(role))) .thenReturn(daoWhitelist); Map<String, String> whitelistOptions = whitelistManager.getRoleWhitelist(role); verify(mockWhitelistDataAccess, times(1)).getWhitelist(eq(role)); assertThat(whitelistOptions.keySet()).containsExactlyInAnyOrder("AUDIT WHITELIST ON data/someks/sometable", "AUDIT WHITELIST ON connections"); assertThat(whitelistOptions.get("AUDIT WHITELIST ON data/someks/sometable")).isEqualTo(Permission.SELECT.name()); assertThat(whitelistOptions.get("AUDIT WHITELIST ON connections")).isEqualTo(Permission.EXECUTE.name()); }
@Test public void testGetEmptyWhitelist() { Map<IResource, Set<Permission>> daoWhitelist = Collections.emptyMap(); when(mockWhitelistDataAccess.getWhitelist(eq(role))) .thenReturn(daoWhitelist); Map<String, String> whitelistOptions = whitelistManager.getRoleWhitelist(role); verify(mockWhitelistDataAccess, times(1)).getWhitelist(eq(role)); assertThat(whitelistOptions.keySet()).isEmpty(); }