@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(); }
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 { 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 { 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); }
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(); }
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();  }