@Test void validate_WillFail_WhenAnyEveryUserBelongsToDifferentOrganization() { assertThrows(IllegalArgumentException.class, () -> usersBelongToOrganizationValidator.validate(createValidatableCommand(Set.of(USER_ID_1, USER_ID_2, USER_ID_3)))); }
@Override public void validate(UsersBelongToOrganizationValidatableCommand validatable) { for (UUID userId : validatable.getUserIds()) { Validate.isTrue(validatable.getOrganizationId().equals(usersReadService.getById(userId).getOrganizationId()), "User %s does not belong to organization", userId); } }
UsersBelongToOrganizationValidator implements Validates<UsersBelongToOrganizationValidatableCommand> { @Override public void validate(UsersBelongToOrganizationValidatableCommand validatable) { for (UUID userId : validatable.getUserIds()) { Validate.isTrue(validatable.getOrganizationId().equals(usersReadService.getById(userId).getOrganizationId()), "User %s does not belong to organization", userId); } } }
UsersBelongToOrganizationValidator implements Validates<UsersBelongToOrganizationValidatableCommand> { @Override public void validate(UsersBelongToOrganizationValidatableCommand validatable) { for (UUID userId : validatable.getUserIds()) { Validate.isTrue(validatable.getOrganizationId().equals(usersReadService.getById(userId).getOrganizationId()), "User %s does not belong to organization", userId); } } @Autowired  UsersBelongToOrganizationValidator(UsersReadService usersReadService); }
UsersBelongToOrganizationValidator implements Validates<UsersBelongToOrganizationValidatableCommand> { @Override public void validate(UsersBelongToOrganizationValidatableCommand validatable) { for (UUID userId : validatable.getUserIds()) { Validate.isTrue(validatable.getOrganizationId().equals(usersReadService.getById(userId).getOrganizationId()), "User %s does not belong to organization", userId); } } @Autowired  UsersBelongToOrganizationValidator(UsersReadService usersReadService); @Override void validate(UsersBelongToOrganizationValidatableCommand validatable); }
UsersBelongToOrganizationValidator implements Validates<UsersBelongToOrganizationValidatableCommand> { @Override public void validate(UsersBelongToOrganizationValidatableCommand validatable) { for (UUID userId : validatable.getUserIds()) { Validate.isTrue(validatable.getOrganizationId().equals(usersReadService.getById(userId).getOrganizationId()), "User %s does not belong to organization", userId); } } @Autowired  UsersBelongToOrganizationValidator(UsersReadService usersReadService); @Override void validate(UsersBelongToOrganizationValidatableCommand validatable);  }