@Test void testValidateParametersBadEnv() { UserSyncRequestFilter filter = new UserSyncRequestFilter(Set.of(), Set.of(), Optional.empty()); Assertions.assertThrows(BadRequestException.class, () -> { underTest.validateParameters(ACCOUNT_ID, USER_CRN, Set.of(OTHER_CRN), filter); }); }
public void validateParameters(String accountId, String actorCrn, Set<String> environmentCrnFilter, UserSyncRequestFilter userSyncRequestFilter) { requireNonNull(accountId, "accountId must not be null"); requireNonNull(actorCrn, "actorCrn must not be null"); requireNonNull(environmentCrnFilter, "environmentCrnFilter must not be null"); requireNonNull(userSyncRequestFilter); ImmutableSet<String> userCrnFilter = userSyncRequestFilter.getUserCrnFilter(); ImmutableSet<String> machineUserCrnFilter = userSyncRequestFilter.getMachineUserCrnFilter(); Optional<String> deletedWorkoadUser = userSyncRequestFilter.getDeletedWorkloadUser(); requireNonNull(userCrnFilter, "userCrnFilter must not be null"); requireNonNull(machineUserCrnFilter, "machineUserCrnFilter must not be null"); requireNonNull(deletedWorkoadUser, "deletedWorkoadUser must not be null"); validateCrnFilter(environmentCrnFilter, Crn.ResourceType.ENVIRONMENT); validateCrnFilter(userCrnFilter, Crn.ResourceType.USER); validateCrnFilter(machineUserCrnFilter, Crn.ResourceType.MACHINE_USER); validateSameAccount(accountId, Iterables.concat(environmentCrnFilter, userCrnFilter, machineUserCrnFilter)); validateDeletedWorkloadUser(deletedWorkoadUser, userCrnFilter, machineUserCrnFilter); }
UserSyncRequestValidator { public void validateParameters(String accountId, String actorCrn, Set<String> environmentCrnFilter, UserSyncRequestFilter userSyncRequestFilter) { requireNonNull(accountId, "accountId must not be null"); requireNonNull(actorCrn, "actorCrn must not be null"); requireNonNull(environmentCrnFilter, "environmentCrnFilter must not be null"); requireNonNull(userSyncRequestFilter); ImmutableSet<String> userCrnFilter = userSyncRequestFilter.getUserCrnFilter(); ImmutableSet<String> machineUserCrnFilter = userSyncRequestFilter.getMachineUserCrnFilter(); Optional<String> deletedWorkoadUser = userSyncRequestFilter.getDeletedWorkloadUser(); requireNonNull(userCrnFilter, "userCrnFilter must not be null"); requireNonNull(machineUserCrnFilter, "machineUserCrnFilter must not be null"); requireNonNull(deletedWorkoadUser, "deletedWorkoadUser must not be null"); validateCrnFilter(environmentCrnFilter, Crn.ResourceType.ENVIRONMENT); validateCrnFilter(userCrnFilter, Crn.ResourceType.USER); validateCrnFilter(machineUserCrnFilter, Crn.ResourceType.MACHINE_USER); validateSameAccount(accountId, Iterables.concat(environmentCrnFilter, userCrnFilter, machineUserCrnFilter)); validateDeletedWorkloadUser(deletedWorkoadUser, userCrnFilter, machineUserCrnFilter); } }
UserSyncRequestValidator { public void validateParameters(String accountId, String actorCrn, Set<String> environmentCrnFilter, UserSyncRequestFilter userSyncRequestFilter) { requireNonNull(accountId, "accountId must not be null"); requireNonNull(actorCrn, "actorCrn must not be null"); requireNonNull(environmentCrnFilter, "environmentCrnFilter must not be null"); requireNonNull(userSyncRequestFilter); ImmutableSet<String> userCrnFilter = userSyncRequestFilter.getUserCrnFilter(); ImmutableSet<String> machineUserCrnFilter = userSyncRequestFilter.getMachineUserCrnFilter(); Optional<String> deletedWorkoadUser = userSyncRequestFilter.getDeletedWorkloadUser(); requireNonNull(userCrnFilter, "userCrnFilter must not be null"); requireNonNull(machineUserCrnFilter, "machineUserCrnFilter must not be null"); requireNonNull(deletedWorkoadUser, "deletedWorkoadUser must not be null"); validateCrnFilter(environmentCrnFilter, Crn.ResourceType.ENVIRONMENT); validateCrnFilter(userCrnFilter, Crn.ResourceType.USER); validateCrnFilter(machineUserCrnFilter, Crn.ResourceType.MACHINE_USER); validateSameAccount(accountId, Iterables.concat(environmentCrnFilter, userCrnFilter, machineUserCrnFilter)); validateDeletedWorkloadUser(deletedWorkoadUser, userCrnFilter, machineUserCrnFilter); }  }
UserSyncRequestValidator { public void validateParameters(String accountId, String actorCrn, Set<String> environmentCrnFilter, UserSyncRequestFilter userSyncRequestFilter) { requireNonNull(accountId, "accountId must not be null"); requireNonNull(actorCrn, "actorCrn must not be null"); requireNonNull(environmentCrnFilter, "environmentCrnFilter must not be null"); requireNonNull(userSyncRequestFilter); ImmutableSet<String> userCrnFilter = userSyncRequestFilter.getUserCrnFilter(); ImmutableSet<String> machineUserCrnFilter = userSyncRequestFilter.getMachineUserCrnFilter(); Optional<String> deletedWorkoadUser = userSyncRequestFilter.getDeletedWorkloadUser(); requireNonNull(userCrnFilter, "userCrnFilter must not be null"); requireNonNull(machineUserCrnFilter, "machineUserCrnFilter must not be null"); requireNonNull(deletedWorkoadUser, "deletedWorkoadUser must not be null"); validateCrnFilter(environmentCrnFilter, Crn.ResourceType.ENVIRONMENT); validateCrnFilter(userCrnFilter, Crn.ResourceType.USER); validateCrnFilter(machineUserCrnFilter, Crn.ResourceType.MACHINE_USER); validateSameAccount(accountId, Iterables.concat(environmentCrnFilter, userCrnFilter, machineUserCrnFilter)); validateDeletedWorkloadUser(deletedWorkoadUser, userCrnFilter, machineUserCrnFilter); }  void validateParameters(String accountId, String actorCrn, Set<String> environmentCrnFilter, UserSyncRequestFilter userSyncRequestFilter); }
UserSyncRequestValidator { public void validateParameters(String accountId, String actorCrn, Set<String> environmentCrnFilter, UserSyncRequestFilter userSyncRequestFilter) { requireNonNull(accountId, "accountId must not be null"); requireNonNull(actorCrn, "actorCrn must not be null"); requireNonNull(environmentCrnFilter, "environmentCrnFilter must not be null"); requireNonNull(userSyncRequestFilter); ImmutableSet<String> userCrnFilter = userSyncRequestFilter.getUserCrnFilter(); ImmutableSet<String> machineUserCrnFilter = userSyncRequestFilter.getMachineUserCrnFilter(); Optional<String> deletedWorkoadUser = userSyncRequestFilter.getDeletedWorkloadUser(); requireNonNull(userCrnFilter, "userCrnFilter must not be null"); requireNonNull(machineUserCrnFilter, "machineUserCrnFilter must not be null"); requireNonNull(deletedWorkoadUser, "deletedWorkoadUser must not be null"); validateCrnFilter(environmentCrnFilter, Crn.ResourceType.ENVIRONMENT); validateCrnFilter(userCrnFilter, Crn.ResourceType.USER); validateCrnFilter(machineUserCrnFilter, Crn.ResourceType.MACHINE_USER); validateSameAccount(accountId, Iterables.concat(environmentCrnFilter, userCrnFilter, machineUserCrnFilter)); validateDeletedWorkloadUser(deletedWorkoadUser, userCrnFilter, machineUserCrnFilter); }  void validateParameters(String accountId, String actorCrn, Set<String> environmentCrnFilter, UserSyncRequestFilter userSyncRequestFilter);  }