use of com.sequenceiq.environment.network.dto.NetworkDto in project cloudbreak by hortonworks.
the class AwsEnvironmentNetworkValidatorTest method testValidateDuringFlowWhenNetworkTypeIsNewThenNoValidationHappensEvenIfTheActualNetworkDtoIsInvalid.
@Test
void testValidateDuringFlowWhenNetworkTypeIsNewThenNoValidationHappensEvenIfTheActualNetworkDtoIsInvalid() {
NetworkDto networkDto = NetworkTestUtils.getNetworkDto(null, null, null, null, null, 999, RegistrationType.CREATE_NEW);
ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
underTest.validateDuringFlow(new EnvironmentValidationDto(), networkDto, validationResultBuilder);
verify(cloudNetworkService, times(0)).retrieveSubnetMetadata(any(EnvironmentDto.class), any(NetworkDto.class));
verify(cloudNetworkService, times(0)).retrieveSubnetMetadata(any(Environment.class), any(NetworkDto.class));
ValidationResult validationResult = validationResultBuilder.build();
assertFalse(validationResult.hasError());
}
use of com.sequenceiq.environment.network.dto.NetworkDto in project cloudbreak by hortonworks.
the class AwsEnvironmentNetworkValidatorTest method testValidateDuringFlowWhenTheNetworkDoesNotContainAwsNetworkParams.
@Test
void testValidateDuringFlowWhenTheNetworkDoesNotContainAwsNetworkParams() {
ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
NetworkDto networkDto = NetworkDto.builder().withId(1L).withName("networkName").withResourceCrn("aResourceCRN").withAws(null).build();
underTest.validateDuringRequest(networkDto, validationResultBuilder);
ValidationResult validationResult = validationResultBuilder.build();
assertTrue(validationResult.hasError());
String actual = validationResult.getErrors().get(0);
assertEquals("The 'AWS' related network parameters should be specified!", actual);
}
use of com.sequenceiq.environment.network.dto.NetworkDto in project cloudbreak by hortonworks.
the class AwsEnvironmentNetworkValidatorTest method testValidateDuringRequestWhenNetworkHasTwoSubnetSubnetMetasHasThreeSubnets.
@Test
void testValidateDuringRequestWhenNetworkHasTwoSubnetSubnetMetasHasThreeSubnets() {
AwsParams awsParams = getAwsParams();
NetworkDto networkDto = NetworkTestUtils.getNetworkDto(null, getAwsParams(), null, awsParams.getVpcId(), null, 2, RegistrationType.EXISTING);
ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
EnvironmentDto environmentDto = new EnvironmentDto();
environmentDto.setName(ENV_NAME);
environmentDto.setNetwork(networkDto);
EnvironmentValidationDto environmentValidationDto = EnvironmentValidationDto.builder().withEnvironmentDto(environmentDto).build();
when(cloudNetworkService.retrieveSubnetMetadata(environmentDto, networkDto)).thenReturn(new LinkedHashMap<>());
underTest.validateDuringFlow(environmentValidationDto, networkDto, validationResultBuilder);
NetworkTestUtils.checkErrorsPresent(validationResultBuilder, List.of("Subnets of the environment (someenv) are not found in the VPC (key1, key0). All subnets are expected to belong to the same VPC"));
}
use of com.sequenceiq.environment.network.dto.NetworkDto in project cloudbreak by hortonworks.
the class AwsEnvironmentNetworkValidatorTest method testValidateDuringRequestWhenNetworkHasTwoSubnetsWithSameAvailabilityZone.
@Test
void testValidateDuringRequestWhenNetworkHasTwoSubnetsWithSameAvailabilityZone() {
AwsParams awsParams = getAwsParams();
NetworkDto networkDto = NetworkTestUtils.getNetworkDto(null, awsParams, null, awsParams.getVpcId(), null, 2, RegistrationType.EXISTING);
Map<String, CloudSubnet> subnetMetas = new HashMap<>();
for (int i = 0; i < 2; i++) {
subnetMetas.put("key" + i, NetworkTestUtils.getCloudSubnet("eu-west-1-a"));
}
ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
EnvironmentDto environmentDto = new EnvironmentDto();
environmentDto.setNetwork(networkDto);
EnvironmentValidationDto environmentValidationDto = EnvironmentValidationDto.builder().withEnvironmentDto(environmentDto).build();
when(cloudNetworkService.retrieveSubnetMetadata(environmentDto, networkDto)).thenReturn(subnetMetas);
underTest.validateDuringFlow(environmentValidationDto, networkDto, validationResultBuilder);
NetworkTestUtils.checkErrorsPresent(validationResultBuilder, List.of("The Subnets in the VPC (eu-west-1-a) should be present at least in two different availability zones, " + "but they are present only in availability zone name, name. Please add subnets to the environment " + "from the required number of different availability zones."));
}
use of com.sequenceiq.environment.network.dto.NetworkDto in project cloudbreak by hortonworks.
the class AwsEnvironmentNetworkValidatorTest method testValidateDuringRequestWhenNetworkHasNoNetworkIdAndNoCidr.
@Test
void testValidateDuringRequestWhenNetworkHasNoNetworkIdAndNoCidr() {
NetworkDto networkDto = NetworkTestUtils.getNetworkDto(null, getAwsParams(), null, null, null, 1, RegistrationType.EXISTING);
ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
EnvironmentDto environmentDto = new EnvironmentDto();
environmentDto.setNetwork(networkDto);
EnvironmentValidationDto environmentValidationDto = EnvironmentValidationDto.builder().withEnvironmentDto(environmentDto).build();
underTest.validateDuringFlow(environmentValidationDto, networkDto, validationResultBuilder);
NetworkTestUtils.checkErrorsPresent(validationResultBuilder, List.of("Either the AWS network id or cidr needs to be defined!"));
}
Aggregations