@Test public void testUnknownOption() { WhitelistOperation invalidOperation = Mockito.mock(WhitelistOperation.class); assertThatExceptionOfType(InvalidRequestException.class) .isThrownBy(() -> whitelistManager.dispatchOperation(invalidOperation, performer, role, null)); }
@VisibleForTesting void dispatchOperation(WhitelistOperation whitelistOperation, AuthenticatedUser performer, RoleResource role, Map.Entry<String, String> optionEntry) { if (whitelistOperation == WhitelistOperation.GRANT) { addToWhitelist(performer, role, optionEntry); } else if (whitelistOperation == WhitelistOperation.REVOKE) { removeFromWhitelist(performer, role, optionEntry); } else if (whitelistOperation == WhitelistOperation.DROP_LEGACY) { dropRoleOption(performer, role, optionEntry); } else { throw new InvalidRequestException(String.format("Illegal whitelist option [%s]", whitelistOperation)); } }
AuditWhitelistManager { @VisibleForTesting void dispatchOperation(WhitelistOperation whitelistOperation, AuthenticatedUser performer, RoleResource role, Map.Entry<String, String> optionEntry) { if (whitelistOperation == WhitelistOperation.GRANT) { addToWhitelist(performer, role, optionEntry); } else if (whitelistOperation == WhitelistOperation.REVOKE) { removeFromWhitelist(performer, role, optionEntry); } else if (whitelistOperation == WhitelistOperation.DROP_LEGACY) { dropRoleOption(performer, role, optionEntry); } else { throw new InvalidRequestException(String.format("Illegal whitelist option [%s]", whitelistOperation)); } } }
AuditWhitelistManager { @VisibleForTesting void dispatchOperation(WhitelistOperation whitelistOperation, AuthenticatedUser performer, RoleResource role, Map.Entry<String, String> optionEntry) { if (whitelistOperation == WhitelistOperation.GRANT) { addToWhitelist(performer, role, optionEntry); } else if (whitelistOperation == WhitelistOperation.REVOKE) { removeFromWhitelist(performer, role, optionEntry); } else if (whitelistOperation == WhitelistOperation.DROP_LEGACY) { dropRoleOption(performer, role, optionEntry); } else { throw new InvalidRequestException(String.format("Illegal whitelist option [%s]", whitelistOperation)); } } AuditWhitelistManager(); @VisibleForTesting  AuditWhitelistManager(WhitelistDataAccess whitelistDataAccess); }
AuditWhitelistManager { @VisibleForTesting void dispatchOperation(WhitelistOperation whitelistOperation, AuthenticatedUser performer, RoleResource role, Map.Entry<String, String> optionEntry) { if (whitelistOperation == WhitelistOperation.GRANT) { addToWhitelist(performer, role, optionEntry); } else if (whitelistOperation == WhitelistOperation.REVOKE) { removeFromWhitelist(performer, role, optionEntry); } else if (whitelistOperation == WhitelistOperation.DROP_LEGACY) { dropRoleOption(performer, role, optionEntry); } else { throw new InvalidRequestException(String.format("Illegal whitelist option [%s]", whitelistOperation)); } } AuditWhitelistManager(); @VisibleForTesting  AuditWhitelistManager(WhitelistDataAccess whitelistDataAccess); void setup(); }
AuditWhitelistManager { @VisibleForTesting void dispatchOperation(WhitelistOperation whitelistOperation, AuthenticatedUser performer, RoleResource role, Map.Entry<String, String> optionEntry) { if (whitelistOperation == WhitelistOperation.GRANT) { addToWhitelist(performer, role, optionEntry); } else if (whitelistOperation == WhitelistOperation.REVOKE) { removeFromWhitelist(performer, role, optionEntry); } else if (whitelistOperation == WhitelistOperation.DROP_LEGACY) { dropRoleOption(performer, role, optionEntry); } else { throw new InvalidRequestException(String.format("Illegal whitelist option [%s]", whitelistOperation)); } } AuditWhitelistManager(); @VisibleForTesting  AuditWhitelistManager(WhitelistDataAccess whitelistDataAccess); void setup();  }