use of com.sequenceiq.environment.parameters.dao.domain.AwsParameters in project cloudbreak by hortonworks.
the class S3GuardTableDeleteHandlerTest method acceptTestEnvironmentSuccess.
@Test
void acceptTestEnvironmentSuccess() {
when(cloudPlatformConnectors.get(any(), any())).thenReturn(cloudConnector);
when(cloudConnector.noSql()).thenReturn(noSql);
CloudCredential cloudCredential = new CloudCredential();
when(credentialToCloudCredentialConverter.convert(any())).thenReturn(cloudCredential);
AwsParameters awsParameters = getAwsParameters(S3GuardTableCreation.CREATE_NEW);
when(environmentService.findEnvironmentById(ENVIRONMENT_ID)).thenReturn(Optional.of(createEnvironment(awsParameters)));
when(noSql.getNoSqlTableMetaData(any(NoSqlTableMetadataRequest.class))).thenReturn(NoSqlTableMetadataResponse.builder().withStatus(ResponseStatus.OK).build());
when(noSql.deleteNoSqlTable(any(NoSqlTableDeleteRequest.class))).thenReturn(NoSqlTableDeleteResponse.builder().withStatus(ResponseStatus.OK).build());
underTest.accept(environmentDtoEvent);
NoSqlTableDeleteRequest request = getNoSqlTableDeleteRequest(cloudCredential);
verify(cloudPlatformConnectors).get(any(), any());
verify(noSql).deleteNoSqlTable(request);
verify(eventSender).sendEvent(eventArgumentCaptor.capture(), headersArgumentCaptor.capture());
verifyEnvDeleteEvent();
}
use of com.sequenceiq.environment.parameters.dao.domain.AwsParameters in project cloudbreak by hortonworks.
the class S3GuardTableDeleteHandlerTest method acceptTestEnvironmentPreExistingTable.
@Test
void acceptTestEnvironmentPreExistingTable() {
AwsParameters awsParameters = getAwsParameters(S3GuardTableCreation.USE_EXISTING);
when(environmentService.findEnvironmentById(ENVIRONMENT_ID)).thenReturn(Optional.of(createEnvironment(awsParameters)));
underTest.accept(environmentDtoEvent);
verify(cloudPlatformConnectors, never()).get(any());
verify(cloudPlatformConnectors, never()).get(any(), any());
verify(eventSender).sendEvent(eventArgumentCaptor.capture(), headersArgumentCaptor.capture());
verifyEnvDeleteEvent();
}
use of com.sequenceiq.environment.parameters.dao.domain.AwsParameters in project cloudbreak by hortonworks.
the class EnvironmentModificationService method editEnvironmentParameters.
private void editEnvironmentParameters(EnvironmentEditDto editDto, Environment environment) {
ParametersDto parametersDto = editDto.getParameters();
if (parametersDto != null) {
Optional<BaseParameters> original = parametersService.findByEnvironment(environment.getId());
if (original.isPresent()) {
BaseParameters originalParameters = original.get();
parametersDto.setId(originalParameters.getId());
if (originalParameters instanceof AwsParameters) {
AwsParameters awsOriginalParameters = (AwsParameters) originalParameters;
parametersDto.getAwsParametersDto().setFreeIpaSpotPercentage(awsOriginalParameters.getFreeIpaSpotPercentage());
validateAwsParameters(environment, parametersDto);
}
}
if (parametersDto.getGcpParametersDto() != null) {
String encryptionKey = Optional.of(parametersDto.getGcpParametersDto()).map(GcpParametersDto::getGcpResourceEncryptionParametersDto).map(GcpResourceEncryptionParametersDto::getEncryptionKey).orElse(null);
ValidationResult validationResult = environmentService.getValidatorService().validateEncryptionKey(encryptionKey, editDto.getAccountId());
if (validationResult.hasError()) {
throw new BadRequestException(validationResult.getFormattedErrors());
}
}
BaseParameters parameters = parametersService.saveParameters(environment, parametersDto);
if (parameters != null) {
environment.setParameters(parameters);
}
}
}
use of com.sequenceiq.environment.parameters.dao.domain.AwsParameters in project cloudbreak by hortonworks.
the class AwsEnvironmentParametersConverterTest method convertToDtoTest.
@Test
void convertToDtoTest() {
EnvironmentView environmentView = ENVIRONMENT_VIEW;
AwsParameters parameters = new AwsParameters();
parameters.setAccountId(ACCOUNT_ID);
parameters.setEnvironment(environmentView);
parameters.setId(ID);
parameters.setName(ENV_NAME);
parameters.setS3guardTableName(TABLE_NAME);
parameters.setS3guardTableCreation(S3GuardTableCreation.CREATE_NEW);
parameters.setFreeIpaSpotPercentage(null);
parameters.setFreeIpaSpotMaxPrice(0.9);
parameters.setEncryptionKeyArn(ENCRYPTION_KEY_ARN);
ParametersDto result = underTest.convertToDto(parameters);
assertEquals(ACCOUNT_ID, result.getAccountId());
assertEquals(ID, result.getId());
assertEquals(ENV_NAME, result.getName());
assertEquals(TABLE_NAME, result.getAwsParametersDto().getS3GuardTableName());
assertEquals(S3GuardTableCreation.CREATE_NEW, result.getAwsParametersDto().getDynamoDbTableCreation());
assertEquals(0, result.getAwsParametersDto().getFreeIpaSpotPercentage());
assertEquals(0.9, result.getAwsParametersDto().getFreeIpaSpotMaxPrice());
assertEquals(ENCRYPTION_KEY_ARN, result.getAwsParametersDto().getAwsDiskEncryptionParametersDto().getEncryptionKeyArn());
}
use of com.sequenceiq.environment.parameters.dao.domain.AwsParameters in project cloudbreak by hortonworks.
the class AwsEnvironmentParametersConverterTest method convertTest.
@Test
void convertTest() {
when(environmentViewConverter.convert(any(Environment.class))).thenReturn(ENVIRONMENT_VIEW);
ParametersDto parameters = ParametersDto.builder().withId(ID).withAwsParameters(AwsParametersDto.builder().withDynamoDbTableName(TABLE_NAME).withDynamoDbTableCreation(S3GuardTableCreation.CREATE_NEW).withAwsDiskEncryptionParameters(AwsDiskEncryptionParametersDto.builder().withEncryptionKeyArn(ENCRYPTION_KEY_ARN).build()).build()).build();
Environment environment = new Environment();
environment.setName(ENV_NAME);
environment.setAccountId(ACCOUNT_ID);
BaseParameters result = underTest.convert(environment, parameters);
assertEquals(AwsParameters.class, result.getClass());
AwsParameters awsResult = (AwsParameters) result;
assertEquals(ENV_NAME, awsResult.getName());
assertEquals(ACCOUNT_ID, awsResult.getAccountId());
assertEquals(ENVIRONMENT_VIEW, awsResult.getEnvironment());
assertEquals(ID, awsResult.getId());
assertEquals(TABLE_NAME, awsResult.getS3guardTableName());
assertEquals(S3GuardTableCreation.CREATE_NEW, awsResult.getS3guardTableCreation());
}
Aggregations