@Test public void testDecoratorWhenClusterToAttachIsNotNullAndThereIsNoLdapConfiguredButRangerAndHiveRdsHaveThenExceptionWouldCome() { when(validationResult.hasError()).thenReturn(Boolean.TRUE); when(validationResult.getFormattedErrors()).thenReturn(MISCONFIGURED_STACK_FOR_SHARED_SERVICE); thrown.expect(BadRequestException.class); thrown.expectMessage(MISCONFIGURED_STACK_FOR_SHARED_SERVICE); underTest.decorate(subject, request, user, workspace); }
@Measure(StackDecorator.class) public Stack decorate(@Nonnull Stack subject, @Nonnull StackV4Request request, User user, Workspace workspace) { String stackName = request.getName(); DetailedEnvironmentResponse environment = measure(() -> environmentClientService.getByCrn(subject.getEnvironmentCrn()), LOGGER, "Environment properties were queried under {} ms for environment {}", request.getEnvironmentCrn()); Credential credential = measure(() -> prepareCredential(environment), LOGGER, "Credential was prepared under {} ms for stack {}", stackName); measure(() -> preparePlacement(subject, request, environment), LOGGER, "Placement was prepared under {} ms for stack {}, stackName"); measure(() -> prepareParameters(subject, environment), LOGGER, "Parameters were prepared under {} ms for stack {}", stackName); measure(() -> prepareDomainIfDefined(subject, credential), LOGGER, "Domain was prepared under {} ms for stack {}", stackName); subject.setCloudPlatform(credential.cloudPlatform()); if (subject.getInstanceGroups() == null) { throw new BadRequestException("Instance groups must be specified!"); } measure(() -> { PlatformParameters pps = cloudParameterCache.getPlatformParameters().get(Platform.platform(subject.cloudPlatform())); Boolean mandatoryNetwork = pps.specialParameters().getSpecialParameters().get(PlatformParametersConsts.NETWORK_IS_MANDATORY); if (BooleanUtils.isTrue(mandatoryNetwork) && subject.getNetwork() == null) { throw new BadRequestException("Network must be specified!"); } }, LOGGER, "Network was prepared and validated under {} ms for stack {}", stackName); measure(() -> prepareOrchestratorIfNotExist(subject, credential), LOGGER, "Orchestrator was prepared under {} ms for stack {}", stackName); if (subject.getFailurePolicy() != null) { measure(() -> validatFailurePolicy(subject, subject.getFailurePolicy()), LOGGER, "Failure policy was validated under {} ms for stack {}", stackName); } measure(() -> prepareInstanceGroups(subject, request, credential, user), LOGGER, "Instance groups were prepared under {} ms for stack {}", stackName); measure(() -> validateInstanceGroups(subject), LOGGER, "Validation of gateway instance groups has been finished in {} ms for stack {}", stackName); measure(() -> { ValidationResult validationResult = sharedServiceValidator.checkSharedServiceStackRequirements(request, workspace); if (validationResult.hasError()) { throw new BadRequestException(validationResult.getFormattedErrors()); } }, LOGGER, "Validation of shared services requirements has been finished in {} ms for stack {}", stackName); return subject; }
StackDecorator { @Measure(StackDecorator.class) public Stack decorate(@Nonnull Stack subject, @Nonnull StackV4Request request, User user, Workspace workspace) { String stackName = request.getName(); DetailedEnvironmentResponse environment = measure(() -> environmentClientService.getByCrn(subject.getEnvironmentCrn()), LOGGER, "Environment properties were queried under {} ms for environment {}", request.getEnvironmentCrn()); Credential credential = measure(() -> prepareCredential(environment), LOGGER, "Credential was prepared under {} ms for stack {}", stackName); measure(() -> preparePlacement(subject, request, environment), LOGGER, "Placement was prepared under {} ms for stack {}, stackName"); measure(() -> prepareParameters(subject, environment), LOGGER, "Parameters were prepared under {} ms for stack {}", stackName); measure(() -> prepareDomainIfDefined(subject, credential), LOGGER, "Domain was prepared under {} ms for stack {}", stackName); subject.setCloudPlatform(credential.cloudPlatform()); if (subject.getInstanceGroups() == null) { throw new BadRequestException("Instance groups must be specified!"); } measure(() -> { PlatformParameters pps = cloudParameterCache.getPlatformParameters().get(Platform.platform(subject.cloudPlatform())); Boolean mandatoryNetwork = pps.specialParameters().getSpecialParameters().get(PlatformParametersConsts.NETWORK_IS_MANDATORY); if (BooleanUtils.isTrue(mandatoryNetwork) && subject.getNetwork() == null) { throw new BadRequestException("Network must be specified!"); } }, LOGGER, "Network was prepared and validated under {} ms for stack {}", stackName); measure(() -> prepareOrchestratorIfNotExist(subject, credential), LOGGER, "Orchestrator was prepared under {} ms for stack {}", stackName); if (subject.getFailurePolicy() != null) { measure(() -> validatFailurePolicy(subject, subject.getFailurePolicy()), LOGGER, "Failure policy was validated under {} ms for stack {}", stackName); } measure(() -> prepareInstanceGroups(subject, request, credential, user), LOGGER, "Instance groups were prepared under {} ms for stack {}", stackName); measure(() -> validateInstanceGroups(subject), LOGGER, "Validation of gateway instance groups has been finished in {} ms for stack {}", stackName); measure(() -> { ValidationResult validationResult = sharedServiceValidator.checkSharedServiceStackRequirements(request, workspace); if (validationResult.hasError()) { throw new BadRequestException(validationResult.getFormattedErrors()); } }, LOGGER, "Validation of shared services requirements has been finished in {} ms for stack {}", stackName); return subject; } }
StackDecorator { @Measure(StackDecorator.class) public Stack decorate(@Nonnull Stack subject, @Nonnull StackV4Request request, User user, Workspace workspace) { String stackName = request.getName(); DetailedEnvironmentResponse environment = measure(() -> environmentClientService.getByCrn(subject.getEnvironmentCrn()), LOGGER, "Environment properties were queried under {} ms for environment {}", request.getEnvironmentCrn()); Credential credential = measure(() -> prepareCredential(environment), LOGGER, "Credential was prepared under {} ms for stack {}", stackName); measure(() -> preparePlacement(subject, request, environment), LOGGER, "Placement was prepared under {} ms for stack {}, stackName"); measure(() -> prepareParameters(subject, environment), LOGGER, "Parameters were prepared under {} ms for stack {}", stackName); measure(() -> prepareDomainIfDefined(subject, credential), LOGGER, "Domain was prepared under {} ms for stack {}", stackName); subject.setCloudPlatform(credential.cloudPlatform()); if (subject.getInstanceGroups() == null) { throw new BadRequestException("Instance groups must be specified!"); } measure(() -> { PlatformParameters pps = cloudParameterCache.getPlatformParameters().get(Platform.platform(subject.cloudPlatform())); Boolean mandatoryNetwork = pps.specialParameters().getSpecialParameters().get(PlatformParametersConsts.NETWORK_IS_MANDATORY); if (BooleanUtils.isTrue(mandatoryNetwork) && subject.getNetwork() == null) { throw new BadRequestException("Network must be specified!"); } }, LOGGER, "Network was prepared and validated under {} ms for stack {}", stackName); measure(() -> prepareOrchestratorIfNotExist(subject, credential), LOGGER, "Orchestrator was prepared under {} ms for stack {}", stackName); if (subject.getFailurePolicy() != null) { measure(() -> validatFailurePolicy(subject, subject.getFailurePolicy()), LOGGER, "Failure policy was validated under {} ms for stack {}", stackName); } measure(() -> prepareInstanceGroups(subject, request, credential, user), LOGGER, "Instance groups were prepared under {} ms for stack {}", stackName); measure(() -> validateInstanceGroups(subject), LOGGER, "Validation of gateway instance groups has been finished in {} ms for stack {}", stackName); measure(() -> { ValidationResult validationResult = sharedServiceValidator.checkSharedServiceStackRequirements(request, workspace); if (validationResult.hasError()) { throw new BadRequestException(validationResult.getFormattedErrors()); } }, LOGGER, "Validation of shared services requirements has been finished in {} ms for stack {}", stackName); return subject; }  }
StackDecorator { @Measure(StackDecorator.class) public Stack decorate(@Nonnull Stack subject, @Nonnull StackV4Request request, User user, Workspace workspace) { String stackName = request.getName(); DetailedEnvironmentResponse environment = measure(() -> environmentClientService.getByCrn(subject.getEnvironmentCrn()), LOGGER, "Environment properties were queried under {} ms for environment {}", request.getEnvironmentCrn()); Credential credential = measure(() -> prepareCredential(environment), LOGGER, "Credential was prepared under {} ms for stack {}", stackName); measure(() -> preparePlacement(subject, request, environment), LOGGER, "Placement was prepared under {} ms for stack {}, stackName"); measure(() -> prepareParameters(subject, environment), LOGGER, "Parameters were prepared under {} ms for stack {}", stackName); measure(() -> prepareDomainIfDefined(subject, credential), LOGGER, "Domain was prepared under {} ms for stack {}", stackName); subject.setCloudPlatform(credential.cloudPlatform()); if (subject.getInstanceGroups() == null) { throw new BadRequestException("Instance groups must be specified!"); } measure(() -> { PlatformParameters pps = cloudParameterCache.getPlatformParameters().get(Platform.platform(subject.cloudPlatform())); Boolean mandatoryNetwork = pps.specialParameters().getSpecialParameters().get(PlatformParametersConsts.NETWORK_IS_MANDATORY); if (BooleanUtils.isTrue(mandatoryNetwork) && subject.getNetwork() == null) { throw new BadRequestException("Network must be specified!"); } }, LOGGER, "Network was prepared and validated under {} ms for stack {}", stackName); measure(() -> prepareOrchestratorIfNotExist(subject, credential), LOGGER, "Orchestrator was prepared under {} ms for stack {}", stackName); if (subject.getFailurePolicy() != null) { measure(() -> validatFailurePolicy(subject, subject.getFailurePolicy()), LOGGER, "Failure policy was validated under {} ms for stack {}", stackName); } measure(() -> prepareInstanceGroups(subject, request, credential, user), LOGGER, "Instance groups were prepared under {} ms for stack {}", stackName); measure(() -> validateInstanceGroups(subject), LOGGER, "Validation of gateway instance groups has been finished in {} ms for stack {}", stackName); measure(() -> { ValidationResult validationResult = sharedServiceValidator.checkSharedServiceStackRequirements(request, workspace); if (validationResult.hasError()) { throw new BadRequestException(validationResult.getFormattedErrors()); } }, LOGGER, "Validation of shared services requirements has been finished in {} ms for stack {}", stackName); return subject; }  @Measure(StackDecorator.class) Stack decorate(@Nonnull Stack subject, @Nonnull StackV4Request request, User user, Workspace workspace); }
StackDecorator { @Measure(StackDecorator.class) public Stack decorate(@Nonnull Stack subject, @Nonnull StackV4Request request, User user, Workspace workspace) { String stackName = request.getName(); DetailedEnvironmentResponse environment = measure(() -> environmentClientService.getByCrn(subject.getEnvironmentCrn()), LOGGER, "Environment properties were queried under {} ms for environment {}", request.getEnvironmentCrn()); Credential credential = measure(() -> prepareCredential(environment), LOGGER, "Credential was prepared under {} ms for stack {}", stackName); measure(() -> preparePlacement(subject, request, environment), LOGGER, "Placement was prepared under {} ms for stack {}, stackName"); measure(() -> prepareParameters(subject, environment), LOGGER, "Parameters were prepared under {} ms for stack {}", stackName); measure(() -> prepareDomainIfDefined(subject, credential), LOGGER, "Domain was prepared under {} ms for stack {}", stackName); subject.setCloudPlatform(credential.cloudPlatform()); if (subject.getInstanceGroups() == null) { throw new BadRequestException("Instance groups must be specified!"); } measure(() -> { PlatformParameters pps = cloudParameterCache.getPlatformParameters().get(Platform.platform(subject.cloudPlatform())); Boolean mandatoryNetwork = pps.specialParameters().getSpecialParameters().get(PlatformParametersConsts.NETWORK_IS_MANDATORY); if (BooleanUtils.isTrue(mandatoryNetwork) && subject.getNetwork() == null) { throw new BadRequestException("Network must be specified!"); } }, LOGGER, "Network was prepared and validated under {} ms for stack {}", stackName); measure(() -> prepareOrchestratorIfNotExist(subject, credential), LOGGER, "Orchestrator was prepared under {} ms for stack {}", stackName); if (subject.getFailurePolicy() != null) { measure(() -> validatFailurePolicy(subject, subject.getFailurePolicy()), LOGGER, "Failure policy was validated under {} ms for stack {}", stackName); } measure(() -> prepareInstanceGroups(subject, request, credential, user), LOGGER, "Instance groups were prepared under {} ms for stack {}", stackName); measure(() -> validateInstanceGroups(subject), LOGGER, "Validation of gateway instance groups has been finished in {} ms for stack {}", stackName); measure(() -> { ValidationResult validationResult = sharedServiceValidator.checkSharedServiceStackRequirements(request, workspace); if (validationResult.hasError()) { throw new BadRequestException(validationResult.getFormattedErrors()); } }, LOGGER, "Validation of shared services requirements has been finished in {} ms for stack {}", stackName); return subject; }  @Measure(StackDecorator.class) Stack decorate(@Nonnull Stack subject, @Nonnull StackV4Request request, User user, Workspace workspace);  }