@Test void createValidationError() { CreateFreeIpaRequest freeIpaRequest = new CreateFreeIpaRequest(); when(createFreeIpaRequestValidatior.validate(freeIpaRequest)).thenReturn(ValidationResult.builder().error("error").build()); BadRequestException badRequestException = assertThrows(BadRequestException.class, () -> underTest.create(freeIpaRequest)); assertEquals("1. error", badRequestException.getMessage()); verify(creationService, never()).launchFreeIpa(freeIpaRequest, ACCOUNT_ID); }
@Override @CheckPermissionByResourceObject public DescribeFreeIpaResponse create(@ResourceObject @Valid CreateFreeIpaRequest request) { ValidationResult validationResult = createFreeIpaRequestValidator.validate(request); if (validationResult.getState() == State.ERROR) { LOGGER.debug("FreeIPA request has validation error(s): {}.", validationResult.getFormattedErrors()); throw new BadRequestException(validationResult.getFormattedErrors()); } String accountId = crnService.getCurrentAccountId(); return freeIpaCreationService.launchFreeIpa(request, accountId); }
FreeIpaV1Controller implements FreeIpaV1Endpoint { @Override @CheckPermissionByResourceObject public DescribeFreeIpaResponse create(@ResourceObject @Valid CreateFreeIpaRequest request) { ValidationResult validationResult = createFreeIpaRequestValidator.validate(request); if (validationResult.getState() == State.ERROR) { LOGGER.debug("FreeIPA request has validation error(s): {}.", validationResult.getFormattedErrors()); throw new BadRequestException(validationResult.getFormattedErrors()); } String accountId = crnService.getCurrentAccountId(); return freeIpaCreationService.launchFreeIpa(request, accountId); } }
FreeIpaV1Controller implements FreeIpaV1Endpoint { @Override @CheckPermissionByResourceObject public DescribeFreeIpaResponse create(@ResourceObject @Valid CreateFreeIpaRequest request) { ValidationResult validationResult = createFreeIpaRequestValidator.validate(request); if (validationResult.getState() == State.ERROR) { LOGGER.debug("FreeIPA request has validation error(s): {}.", validationResult.getFormattedErrors()); throw new BadRequestException(validationResult.getFormattedErrors()); } String accountId = crnService.getCurrentAccountId(); return freeIpaCreationService.launchFreeIpa(request, accountId); }  }
FreeIpaV1Controller implements FreeIpaV1Endpoint { @Override @CheckPermissionByResourceObject public DescribeFreeIpaResponse create(@ResourceObject @Valid CreateFreeIpaRequest request) { ValidationResult validationResult = createFreeIpaRequestValidator.validate(request); if (validationResult.getState() == State.ERROR) { LOGGER.debug("FreeIPA request has validation error(s): {}.", validationResult.getFormattedErrors()); throw new BadRequestException(validationResult.getFormattedErrors()); } String accountId = crnService.getCurrentAccountId(); return freeIpaCreationService.launchFreeIpa(request, accountId); }  @Override @CheckPermissionByResourceObject DescribeFreeIpaResponse create(@ResourceObject @Valid CreateFreeIpaRequest request); @Override @CheckPermissionByResourceObject void attachChildEnvironment(@ResourceObject @Valid AttachChildEnvironmentRequest request); @Override @CheckPermissionByResourceObject void detachChildEnvironment(@ResourceObject @Valid DetachChildEnvironmentRequest request); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_ENVIRONMENT) DescribeFreeIpaResponse describe(@ResourceCrn String environmentCrn); @Override @DisableCheckPermissions List<ListFreeIpaResponse> list(); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_ENVIRONMENT) @Retryable(value = RetryableFreeIpaClientException.class, maxAttemptsExpression = RetryableFreeIpaClientException.MAX_RETRIES_EXPRESSION, backoff = @Backoff(delayExpression = RetryableFreeIpaClientException.DELAY_EXPRESSION, multiplierExpression = RetryableFreeIpaClientException.MULTIPLIER_EXPRESSION)) HealthDetailsFreeIpaResponse healthDetails(@ResourceCrn String environmentCrn); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_ENVIRONMENT) @Retryable(value = RetryableFreeIpaClientException.class, maxAttemptsExpression = RetryableFreeIpaClientException.MAX_RETRIES_EXPRESSION, backoff = @Backoff(delayExpression = RetryableFreeIpaClientException.DELAY_EXPRESSION, multiplierExpression = RetryableFreeIpaClientException.MULTIPLIER_EXPRESSION)) String getRootCertificate(@ResourceCrn String environmentCrn); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DELETE_ENVIRONMENT) void delete(@ResourceCrn String environmentCrn, boolean forced); @Override @CheckPermissionByResourceObject OperationStatus cleanup(@ResourceObject @Valid CleanupRequest request); @Override @InternalOnly OperationStatus internalCleanup(@Valid CleanupRequest request, @AccountId String accountId); @Override @CheckPermissionByResourceObject OperationStatus rebootInstances(@ResourceObject @Valid RebootInstancesRequest request); @Override @CheckPermissionByResourceObject OperationStatus repairInstances(@ResourceObject @Valid RepairInstancesRequest request); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.START_ENVIRONMENT) void start(@ResourceCrn @NotEmpty String environmentCrn); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.STOP_ENVIRONMENT) void stop(@ResourceCrn @NotEmpty String environmentCrn); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.EDIT_ENVIRONMENT) String registerWithClusterProxy(@ResourceCrn @NotEmpty String environmentCrn); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.EDIT_ENVIRONMENT) void deregisterWithClusterProxy(@ResourceCrn @NotEmpty String environmentCrn); }
FreeIpaV1Controller implements FreeIpaV1Endpoint { @Override @CheckPermissionByResourceObject public DescribeFreeIpaResponse create(@ResourceObject @Valid CreateFreeIpaRequest request) { ValidationResult validationResult = createFreeIpaRequestValidator.validate(request); if (validationResult.getState() == State.ERROR) { LOGGER.debug("FreeIPA request has validation error(s): {}.", validationResult.getFormattedErrors()); throw new BadRequestException(validationResult.getFormattedErrors()); } String accountId = crnService.getCurrentAccountId(); return freeIpaCreationService.launchFreeIpa(request, accountId); }  @Override @CheckPermissionByResourceObject DescribeFreeIpaResponse create(@ResourceObject @Valid CreateFreeIpaRequest request); @Override @CheckPermissionByResourceObject void attachChildEnvironment(@ResourceObject @Valid AttachChildEnvironmentRequest request); @Override @CheckPermissionByResourceObject void detachChildEnvironment(@ResourceObject @Valid DetachChildEnvironmentRequest request); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_ENVIRONMENT) DescribeFreeIpaResponse describe(@ResourceCrn String environmentCrn); @Override @DisableCheckPermissions List<ListFreeIpaResponse> list(); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_ENVIRONMENT) @Retryable(value = RetryableFreeIpaClientException.class, maxAttemptsExpression = RetryableFreeIpaClientException.MAX_RETRIES_EXPRESSION, backoff = @Backoff(delayExpression = RetryableFreeIpaClientException.DELAY_EXPRESSION, multiplierExpression = RetryableFreeIpaClientException.MULTIPLIER_EXPRESSION)) HealthDetailsFreeIpaResponse healthDetails(@ResourceCrn String environmentCrn); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DESCRIBE_ENVIRONMENT) @Retryable(value = RetryableFreeIpaClientException.class, maxAttemptsExpression = RetryableFreeIpaClientException.MAX_RETRIES_EXPRESSION, backoff = @Backoff(delayExpression = RetryableFreeIpaClientException.DELAY_EXPRESSION, multiplierExpression = RetryableFreeIpaClientException.MULTIPLIER_EXPRESSION)) String getRootCertificate(@ResourceCrn String environmentCrn); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.DELETE_ENVIRONMENT) void delete(@ResourceCrn String environmentCrn, boolean forced); @Override @CheckPermissionByResourceObject OperationStatus cleanup(@ResourceObject @Valid CleanupRequest request); @Override @InternalOnly OperationStatus internalCleanup(@Valid CleanupRequest request, @AccountId String accountId); @Override @CheckPermissionByResourceObject OperationStatus rebootInstances(@ResourceObject @Valid RebootInstancesRequest request); @Override @CheckPermissionByResourceObject OperationStatus repairInstances(@ResourceObject @Valid RepairInstancesRequest request); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.START_ENVIRONMENT) void start(@ResourceCrn @NotEmpty String environmentCrn); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.STOP_ENVIRONMENT) void stop(@ResourceCrn @NotEmpty String environmentCrn); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.EDIT_ENVIRONMENT) String registerWithClusterProxy(@ResourceCrn @NotEmpty String environmentCrn); @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.EDIT_ENVIRONMENT) void deregisterWithClusterProxy(@ResourceCrn @NotEmpty String environmentCrn);  }