use of com.sequenceiq.environment.parameters.dao.domain.AwsParameters in project cloudbreak by hortonworks.
the class EnvironmentModificationServiceTest method editByNameParametersExistedAndNotValid.
@Test
void editByNameParametersExistedAndNotValid() {
String dynamotable = "dynamotable";
ParametersDto parameters = ParametersDto.builder().withAccountId(ACCOUNT_ID).withAwsParameters(AwsParametersDto.builder().withDynamoDbTableName(dynamotable).build()).build();
EnvironmentEditDto environmentDto = EnvironmentEditDto.builder().withAccountId(ACCOUNT_ID).withParameters(parameters).build();
Environment environment = new Environment();
environment.setAccountId(ACCOUNT_ID);
AwsParameters awsParameters = new AwsParameters();
awsParameters.setS3guardTableName("existingTable");
BaseParameters baseParameters = awsParameters;
when(environmentService.getValidatorService()).thenReturn(validatorService);
when(environmentFlowValidatorService.validateParameters(any(), any())).thenReturn(validationResult);
when(validationResult.hasError()).thenReturn(true);
when(parametersService.findByEnvironment(any())).thenReturn(Optional.of(baseParameters));
when(environmentService.findByNameAndAccountIdAndArchivedIsFalse(eq(ENVIRONMENT_NAME), eq(ACCOUNT_ID))).thenReturn(Optional.of(environment));
when(parametersService.saveParameters(environment, parameters)).thenReturn(baseParameters);
assertThrows(BadRequestException.class, () -> environmentModificationServiceUnderTest.editByName(ENVIRONMENT_NAME, environmentDto));
verify(parametersService, never()).saveParameters(environment, parameters);
}
use of com.sequenceiq.environment.parameters.dao.domain.AwsParameters in project cloudbreak by hortonworks.
the class EnvironmentModificationServiceTest method editByNameParametersNotExisted.
@Test
void editByNameParametersNotExisted() {
String dynamotable = "dynamotable";
ParametersDto parameters = ParametersDto.builder().withAccountId(ACCOUNT_ID).withAwsParameters(AwsParametersDto.builder().withDynamoDbTableName(dynamotable).build()).build();
EnvironmentEditDto environmentDto = EnvironmentEditDto.builder().withAccountId(ACCOUNT_ID).withParameters(parameters).build();
Environment environment = new Environment();
environment.setAccountId(ACCOUNT_ID);
BaseParameters baseParameters = new AwsParameters();
when(environmentService.findByNameAndAccountIdAndArchivedIsFalse(eq(ENVIRONMENT_NAME), eq(ACCOUNT_ID))).thenReturn(Optional.of(environment));
when(parametersService.saveParameters(environment, parameters)).thenReturn(baseParameters);
environmentModificationServiceUnderTest.editByName(ENVIRONMENT_NAME, environmentDto);
verify(parametersService).saveParameters(environment, parameters);
assertEquals(baseParameters, environment.getParameters());
}
use of com.sequenceiq.environment.parameters.dao.domain.AwsParameters in project cloudbreak by hortonworks.
the class EnvironmentTestData method newAwsParameters.
private static AwsParameters newAwsParameters() {
AwsParameters awsParameters = new AwsParameters();
awsParameters.setAccountId(TestConstants.ACCOUNT_ID);
awsParameters.setId(10L);
awsParameters.setName(ENVIRONMENT_NAME);
awsParameters.setS3guardTableName(S3_GUARD_TABLE_NAME);
awsParameters.setS3guardTableCreation(S3GuardTableCreation.CREATE_NEW);
return awsParameters;
}
use of com.sequenceiq.environment.parameters.dao.domain.AwsParameters in project cloudbreak by hortonworks.
the class S3GuardTableDeleteHandlerTest method getAwsParameters.
private AwsParameters getAwsParameters(S3GuardTableCreation useExisting) {
AwsParameters awsParameters = new AwsParameters();
awsParameters.setS3guardTableCreation(useExisting);
awsParameters.setS3guardTableName(DYNAMO_TABLE_NAME);
return awsParameters;
}
use of com.sequenceiq.environment.parameters.dao.domain.AwsParameters in project cloudbreak by hortonworks.
the class S3GuardTableDeleteHandlerTest method acceptTestEnvironmentSuccessWhenDynamoDbTableMissingOnAwsSide.
@Test
void acceptTestEnvironmentSuccessWhenDynamoDbTableMissingOnAwsSide() {
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.RESOURCE_NOT_FOUND).build());
underTest.accept(environmentDtoEvent);
NoSqlTableDeleteRequest request = getNoSqlTableDeleteRequest(cloudCredential);
verify(cloudPlatformConnectors).get(any(), any());
verify(noSql, times(0)).deleteNoSqlTable(request);
verify(eventSender).sendEvent(eventArgumentCaptor.capture(), headersArgumentCaptor.capture());
verifyEnvDeleteEvent();
}
Aggregations