use of com.sequenceiq.environment.parameter.dto.ParametersDto in project cloudbreak by hortonworks.
the class AwsParameterValidatorTest method validateFreeIpaSpotPercentage.
@ParameterizedTest(name = "FreeIpa Spot percentage {0} is validated as {1}")
@MethodSource("freeIpaSpotPercentageParameters")
void validateFreeIpaSpotPercentage(int percentage, boolean hasError) {
AwsParametersDto awsParameters = AwsParametersDto.builder().withFreeIpaSpotPercentage(percentage).build();
ParametersDto parametersDto = ParametersDto.builder().withAwsParameters(awsParameters).build();
ValidationResult validationResult = underTest.validate(environmentValidationDto, parametersDto, ValidationResult.builder());
assertEquals(hasError, validationResult.hasError());
if (hasError) {
assertEquals("FreeIpa spot percentage must be between 0 and 100.", validationResult.getErrors().get(0));
}
}
use of com.sequenceiq.environment.parameter.dto.ParametersDto in project cloudbreak by hortonworks.
the class AwsParameterValidatorTest method validateAndDetermineAwsParametersAttached.
@Test
void validateAndDetermineAwsParametersAttached() {
AwsParametersDto awsParameters = AwsParametersDto.builder().withDynamoDbTableName("tablename").build();
ParametersDto parametersDto = ParametersDto.builder().withAwsParameters(awsParameters).build();
when(parametersService.isS3GuardTableUsed(any(), any(), any(), any())).thenReturn(true);
ValidationResult validationResult = underTest.validate(environmentValidationDto, parametersDto, ValidationResult.builder());
assertTrue(validationResult.hasError());
assertEquals(1L, validationResult.getErrors().size());
assertEquals("S3Guard Dynamo table 'tablename' is already attached to another active environment. " + "Please select another unattached table or specify a non-existing name to create it. Refer to " + "Cloudera documentation at https://docs.cloudera.com/cdp/latest/requirements-aws/topics/mc-aws-req-dynamodb.html " + "for the required setup.", validationResult.getErrors().get(0));
verify(noSqlTableCreationModeDeterminerService, never()).determineCreationMode(any(), any());
}
use of com.sequenceiq.environment.parameter.dto.ParametersDto in project cloudbreak by hortonworks.
the class AwsEnvironmentParametersConverter method postConvert.
@Override
protected void postConvert(BaseParameters baseParameters, Environment environment, ParametersDto parametersDto) {
super.postConvert(baseParameters, environment, parametersDto);
AwsParameters awsParameters = (AwsParameters) baseParameters;
Optional<AwsParametersDto> awsParametersDto = Optional.of(parametersDto).map(ParametersDto::getAwsParametersDto);
awsParameters.setS3guardTableName(awsParametersDto.map(AwsParametersDto::getS3GuardTableName).orElse(null));
awsParameters.setS3guardTableCreation(awsParametersDto.map(AwsParametersDto::getDynamoDbTableCreation).orElse(null));
awsParameters.setFreeIpaSpotPercentage(awsParametersDto.map(AwsParametersDto::getFreeIpaSpotPercentage).orElse(0));
awsParameters.setFreeIpaSpotMaxPrice(awsParametersDto.map(AwsParametersDto::getFreeIpaSpotMaxPrice).orElse(null));
awsParameters.setEncryptionKeyArn(awsParametersDto.map(AwsParametersDto::getAwsDiskEncryptionParametersDto).map(AwsDiskEncryptionParametersDto::getEncryptionKeyArn).orElse(null));
}
use of com.sequenceiq.environment.parameter.dto.ParametersDto in project cloudbreak by hortonworks.
the class AzureEnvironmentParametersConverter method postConvert.
@Override
protected void postConvert(BaseParameters baseParameters, Environment environment, ParametersDto parametersDto) {
super.postConvert(baseParameters, environment, parametersDto);
AzureParameters azureParameters = (AzureParameters) baseParameters;
Optional<AzureParametersDto> azureParametersDto = Optional.of(parametersDto).map(ParametersDto::getAzureParametersDto);
azureParameters.setResourceGroupName(azureParametersDto.map(AzureParametersDto::getAzureResourceGroupDto).map(AzureResourceGroupDto::getName).orElse(null));
azureParameters.setResourceGroupCreation(azureParametersDto.map(AzureParametersDto::getAzureResourceGroupDto).map(AzureResourceGroupDto::getResourceGroupCreation).orElse(null));
azureParameters.setResourceGroupUsagePattern(azureParametersDto.map(AzureParametersDto::getAzureResourceGroupDto).map(AzureResourceGroupDto::getResourceGroupUsagePattern).orElse(null));
azureParameters.setEncryptionKeyUrl(azureParametersDto.map(AzureParametersDto::getAzureResourceEncryptionParametersDto).map(AzureResourceEncryptionParametersDto::getEncryptionKeyUrl).orElse(null));
azureParameters.setEncryptionKeyResourceGroupName(azureParametersDto.map(AzureParametersDto::getAzureResourceEncryptionParametersDto).map(AzureResourceEncryptionParametersDto::getEncryptionKeyResourceGroupName).orElse(null));
}
use of com.sequenceiq.environment.parameter.dto.ParametersDto in project cloudbreak by hortonworks.
the class EnvironmentDetailsToCDPEnvironmentDetailsConverterTest method testConversionResourceEncryptionEnabledWhenAWSUsingResourceEncryptionEnabledShouldReturnResourceEncryptionEnabledTrue.
@Test
public void testConversionResourceEncryptionEnabledWhenAWSUsingResourceEncryptionEnabledShouldReturnResourceEncryptionEnabledTrue() {
ParametersDto parametersDto = ParametersDto.builder().withAwsParameters(AwsParametersDto.builder().withAwsDiskEncryptionParameters(AwsDiskEncryptionParametersDto.builder().withEncryptionKeyArn("dummyEncryptionKeyArn").build()).build()).build();
when(environmentDetails.getParameters()).thenReturn(parametersDto);
UsageProto.CDPEnvironmentDetails cdpEnvironmentDetails = underTest.convert(environmentDetails);
Assertions.assertTrue(cdpEnvironmentDetails.getAwsDetails().getResourceEncryptionEnabled());
}
Aggregations