use of com.sequenceiq.environment.parameter.dto.ParametersDto in project cloudbreak by hortonworks.
the class EnvironmentDetailsToCDPEnvironmentDetailsConverterTest method testConversionSingleResourceGroupWhenAwsShouldReturnSingleResourceGroupFalse.
@Test
public void testConversionSingleResourceGroupWhenAwsShouldReturnSingleResourceGroupFalse() {
ParametersDto parametersDto = ParametersDto.builder().withAwsParameters(AwsParametersDto.builder().build()).build();
when(environmentDetails.getParameters()).thenReturn(parametersDto);
UsageProto.CDPEnvironmentDetails cdpEnvironmentDetails = underTest.convert(environmentDetails);
Assertions.assertFalse(cdpEnvironmentDetails.getAzureDetails().getSingleResourceGroup());
}
use of com.sequenceiq.environment.parameter.dto.ParametersDto in project cloudbreak by hortonworks.
the class NetworkServiceTest method testRefreshMetadataFromAwsCloudProviderMustUseSubnetId.
@Test
public void testRefreshMetadataFromAwsCloudProviderMustUseSubnetId() {
NetworkDto networkDto = mock(NetworkDto.class);
AuthenticationDto authenticationDto = mock(AuthenticationDto.class);
EnvironmentTelemetry environmentTelemetry = mock(EnvironmentTelemetry.class);
EnvironmentBackup environmentBackup = mock(EnvironmentBackup.class);
SecurityAccessDto securityAccessDto = mock(SecurityAccessDto.class);
ParametersDto parametersDto = mock(ParametersDto.class);
EnvironmentNetworkConverter environmentNetworkConverter = mock(EnvironmentNetworkConverter.class);
Network network = mock(Network.class);
Credential credential = mock(Credential.class);
BaseNetwork baseNetwork = new GcpNetwork();
baseNetwork.setRegistrationType(RegistrationType.EXISTING);
Environment environment = new Environment();
environment.setCloudPlatform("AWS");
environment.setCredential(credential);
EnvironmentEditDto environmentEditDto = new EnvironmentEditDto("description", "accountId", networkDto, authenticationDto, environmentTelemetry, environmentBackup, securityAccessDto, Tunnel.CCMV2, IdBrokerMappingSource.MOCK, CloudStorageValidation.ENABLED, "adminGroupName", parametersDto);
when(environmentNetworkConverterMap.get(any(CloudPlatform.class))).thenReturn(environmentNetworkConverter);
when(environmentNetworkConverter.convertToDto(baseNetwork)).thenReturn(networkDto);
when(cloudNetworkService.retrieveSubnetMetadata(any(Environment.class), any(NetworkDto.class))).thenReturn(Map.of("s1", cloudSubnet("s1", "subnet1")));
when(cloudNetworkService.retrieveEndpointGatewaySubnetMetadata(any(Environment.class), any(NetworkDto.class))).thenReturn(Map.of("s1", cloudSubnet("s1", "subnet1")));
when(environmentNetworkConverter.convertToNetwork(any(BaseNetwork.class))).thenReturn(network);
when(environmentNetworkService.getNetworkCidr(any(Network.class), anyString(), any(Credential.class))).thenReturn(new NetworkCidr("10.0.0.0", new ArrayList<>()));
BaseNetwork result = underTest.refreshMetadataFromCloudProvider(baseNetwork, environmentEditDto, environment);
Assertions.assertEquals(result.getSubnetMetas().keySet().stream().findFirst().get(), "s1");
Assertions.assertEquals(result.getSubnetMetas().keySet().size(), 1);
}
use of com.sequenceiq.environment.parameter.dto.ParametersDto in project cloudbreak by hortonworks.
the class GcpEnvironmentParametersConverterTest method convertTest.
@Test
void convertTest() {
when(environmentViewConverter.convert(any(Environment.class))).thenReturn(ENVIRONMENT_VIEW);
ParametersDto parameters = ParametersDto.builder().withId(ID).withGcpParameters(GcpParametersDto.builder().withEncryptionParameters(GcpResourceEncryptionParametersDto.builder().withEncryptionKey(ENCRYPTION_KEY).build()).build()).build();
Environment environment = new Environment();
environment.setName(ENV_NAME);
environment.setAccountId(ACCOUNT_ID);
BaseParameters result = underTest.convert(environment, parameters);
assertEquals(GcpParameters.class, result.getClass());
GcpParameters gcpResult = (GcpParameters) result;
assertEquals(ENV_NAME, gcpResult.getName());
assertEquals(ACCOUNT_ID, gcpResult.getAccountId());
assertEquals(ENVIRONMENT_VIEW, gcpResult.getEnvironment());
assertEquals(ID, gcpResult.getId());
assertEquals(ENCRYPTION_KEY, gcpResult.getEncryptionKey());
}
use of com.sequenceiq.environment.parameter.dto.ParametersDto in project cloudbreak by hortonworks.
the class GcpEnvironmentParametersConverterTest method convertToDtoTest.
@Test
void convertToDtoTest() {
EnvironmentView environmentView = ENVIRONMENT_VIEW;
GcpParameters parameters = new GcpParameters();
parameters.setAccountId(ACCOUNT_ID);
parameters.setEnvironment(environmentView);
parameters.setId(ID);
parameters.setName(ENV_NAME);
parameters.setEncryptionKey(ENCRYPTION_KEY);
ParametersDto result = underTest.convertToDto(parameters);
assertEquals(ACCOUNT_ID, result.getAccountId());
assertEquals(ID, result.getId());
assertEquals(ENV_NAME, result.getName());
assertEquals(ENCRYPTION_KEY, result.getGcpParametersDto().getGcpResourceEncryptionParametersDto().getEncryptionKey());
}
use of com.sequenceiq.environment.parameter.dto.ParametersDto in project cloudbreak by hortonworks.
the class AwsParameterValidatorTest method validateAndDetermineAwsParametersUseExisting.
@ParameterizedTest
@EnumSource(value = S3GuardTableCreation.class, names = { "USE_EXISTING", "CREATE_NEW" })
void validateAndDetermineAwsParametersUseExisting(S3GuardTableCreation creation) {
AwsParametersDto awsParameters = AwsParametersDto.builder().withDynamoDbTableName("tablename").build();
ParametersDto parametersDto = ParametersDto.builder().withAwsParameters(awsParameters).build();
when(parametersService.isS3GuardTableUsed(any(), any(), any(), any())).thenReturn(false);
when(noSqlTableCreationModeDeterminerService.determineCreationMode(any(), any())).thenReturn(creation);
ValidationResult validationResult = underTest.validate(environmentValidationDto, parametersDto, ValidationResult.builder());
assertFalse(validationResult.hasError());
verify(noSqlTableCreationModeDeterminerService).determineCreationMode(any(), any());
assertEquals(creation, awsParameters.getDynamoDbTableCreation());
verify(parametersService, times(1)).saveParameters(ENV_ID, parametersDto);
}
Aggregations