Search in sources :

Example 11 with AwsParameters

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);
}
Also used : Environment(com.sequenceiq.environment.environment.domain.Environment) AwsParameters(com.sequenceiq.environment.parameters.dao.domain.AwsParameters) ParametersDto(com.sequenceiq.environment.parameter.dto.ParametersDto) AzureResourceEncryptionParametersDto(com.sequenceiq.environment.parameter.dto.AzureResourceEncryptionParametersDto) GcpResourceEncryptionParametersDto(com.sequenceiq.environment.parameter.dto.GcpResourceEncryptionParametersDto) AwsParametersDto(com.sequenceiq.environment.parameter.dto.AwsParametersDto) GcpParametersDto(com.sequenceiq.environment.parameter.dto.GcpParametersDto) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) EnvironmentEditDto(com.sequenceiq.environment.environment.dto.EnvironmentEditDto) BaseParameters(com.sequenceiq.environment.parameters.dao.domain.BaseParameters) Test(org.junit.jupiter.api.Test)

Example 12 with AwsParameters

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());
}
Also used : Environment(com.sequenceiq.environment.environment.domain.Environment) AwsParameters(com.sequenceiq.environment.parameters.dao.domain.AwsParameters) ParametersDto(com.sequenceiq.environment.parameter.dto.ParametersDto) AzureResourceEncryptionParametersDto(com.sequenceiq.environment.parameter.dto.AzureResourceEncryptionParametersDto) GcpResourceEncryptionParametersDto(com.sequenceiq.environment.parameter.dto.GcpResourceEncryptionParametersDto) AwsParametersDto(com.sequenceiq.environment.parameter.dto.AwsParametersDto) GcpParametersDto(com.sequenceiq.environment.parameter.dto.GcpParametersDto) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) EnvironmentEditDto(com.sequenceiq.environment.environment.dto.EnvironmentEditDto) BaseParameters(com.sequenceiq.environment.parameters.dao.domain.BaseParameters) Test(org.junit.jupiter.api.Test)

Example 13 with AwsParameters

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;
}
Also used : AwsParameters(com.sequenceiq.environment.parameters.dao.domain.AwsParameters)

Example 14 with 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;
}
Also used : AwsParameters(com.sequenceiq.environment.parameters.dao.domain.AwsParameters)

Example 15 with 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();
}
Also used : CloudCredential(com.sequenceiq.cloudbreak.cloud.model.CloudCredential) AwsParameters(com.sequenceiq.environment.parameters.dao.domain.AwsParameters) NoSqlTableMetadataRequest(com.sequenceiq.cloudbreak.cloud.model.nosql.NoSqlTableMetadataRequest) NoSqlTableDeleteRequest(com.sequenceiq.cloudbreak.cloud.model.nosql.NoSqlTableDeleteRequest) Test(org.junit.jupiter.api.Test)

Aggregations

AwsParameters (com.sequenceiq.environment.parameters.dao.domain.AwsParameters)21 Test (org.junit.jupiter.api.Test)13 Environment (com.sequenceiq.environment.environment.domain.Environment)8 ParametersDto (com.sequenceiq.environment.parameter.dto.ParametersDto)8 BaseParameters (com.sequenceiq.environment.parameters.dao.domain.BaseParameters)7 AwsParametersDto (com.sequenceiq.environment.parameter.dto.AwsParametersDto)6 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5 EnvironmentEditDto (com.sequenceiq.environment.environment.dto.EnvironmentEditDto)4 AzureResourceEncryptionParametersDto (com.sequenceiq.environment.parameter.dto.AzureResourceEncryptionParametersDto)4 GcpParametersDto (com.sequenceiq.environment.parameter.dto.GcpParametersDto)4 GcpResourceEncryptionParametersDto (com.sequenceiq.environment.parameter.dto.GcpResourceEncryptionParametersDto)4 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)3 NoSqlTableDeleteRequest (com.sequenceiq.cloudbreak.cloud.model.nosql.NoSqlTableDeleteRequest)3 NoSqlTableMetadataRequest (com.sequenceiq.cloudbreak.cloud.model.nosql.NoSqlTableMetadataRequest)3 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)3 AwsDiskEncryptionParametersDto (com.sequenceiq.environment.parameter.dto.AwsDiskEncryptionParametersDto)3 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)2 UpdateAwsDiskEncryptionParametersDto (com.sequenceiq.environment.environment.dto.UpdateAwsDiskEncryptionParametersDto)2 BadRequestException (javax.ws.rs.BadRequestException)2 CloudConnectorException (com.sequenceiq.cloudbreak.cloud.exception.CloudConnectorException)1