use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder 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.cloudbreak.validation.ValidationResult.ValidationResultBuilder 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.cloudbreak.validation.ValidationResult.ValidationResultBuilder 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!"));
}
use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.
the class AwsEnvironmentNetworkValidatorTest method testCheckNullableWhenNetworkIsNotNull.
@Test
public void testCheckNullableWhenNetworkIsNotNull() {
ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
NetworkDto networkDto = mock(NetworkDto.class);
underTest.checkNullable(CloudPlatform.AWS, networkDto, resultBuilder);
ValidationResult actual = resultBuilder.build();
Assertions.assertThat(actual.hasError()).isFalse();
}
use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.
the class AzureEnvironmentNetworkValidatorTest method testValidateDuringRequestWhenNetworkIdWithNoSubnets.
@Test
void testValidateDuringRequestWhenNetworkIdWithNoSubnets() {
AzureParams azureParams = NetworkTestUtils.getAzureParams(true, true, true);
NetworkDto networkDto = NetworkTestUtils.getNetworkDto(azureParams, null, null, azureParams.getNetworkId(), null, null);
ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
underTest.validateDuringRequest(networkDto, resultBuilder);
NetworkTestUtils.checkErrorsPresent(resultBuilder, List.of("If networkId (aNetworkId) and resourceGroupName (aResourceGroupId) are specified then subnet ids must be specified as well."));
}
Aggregations