use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.
the class CloudStorageLocationValidatorTest method validateS3.
@Test
public void validateS3() {
when(environmentLogging.getS3()).thenReturn(s3);
when(s3.getType()).thenReturn(FileSystemType.S3);
ObjectStorageMetadataRequest request = ObjectStorageMetadataRequest.builder().withCloudPlatform(CLOUD_PLATFORM).withCredential(CLOUD_CREDENTIAL).withObjectStoragePath(BUCKET_NAME).build();
ObjectStorageMetadataResponse response = ObjectStorageMetadataResponse.builder().withRegion(ENV_REGION).withStatus(ResponseStatus.OK).build();
when(cloudProviderServicesEndpoint.getObjectStorageMetaData(eq(request))).thenReturn(response);
when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn:cdp:datahub:us-west-1:altus:user:__internal__actor__");
when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
underTest.validate(S3_OBJECT_PATH, environment, validationResultBuilder);
assertFalse(validationResultBuilder.build().hasError());
}
use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.
the class AwsEnvironmentNetworkValidatorTest method testValidateDuringRequestWhenNetworkHasOneSubnet.
@Test
void testValidateDuringRequestWhenNetworkHasOneSubnet() {
int amountOfSubnets = 1;
AwsParams awsParams = getAwsParams();
NetworkDto networkDto = NetworkTestUtils.getNetworkDto(null, getAwsParams(), null, awsParams.getVpcId(), null, amountOfSubnets, RegistrationType.EXISTING);
ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
EnvironmentDto environmentDto = new EnvironmentDto();
environmentDto.setNetwork(networkDto);
EnvironmentValidationDto environmentValidationDto = EnvironmentValidationDto.builder().withEnvironmentDto(environmentDto).build();
Map<String, CloudSubnet> subnetMetas = new HashMap<>();
for (int i = 0; i < amountOfSubnets; i++) {
subnetMetas.put("key" + i, NetworkTestUtils.getCloudSubnet("eu-west-1-a"));
}
when(cloudNetworkService.retrieveSubnetMetadata(environmentDto, networkDto)).thenReturn(subnetMetas);
underTest.validateDuringFlow(environmentValidationDto, networkDto, validationResultBuilder);
NetworkTestUtils.checkErrorsPresent(validationResultBuilder, List.of("There should be at least two Subnets in the environment network configuration"));
}
use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.
the class AwsEnvironmentNetworkValidatorTest method testValidateDuringRequestWhenNetworkHasTwoSubnet.
@Test
void testValidateDuringRequestWhenNetworkHasTwoSubnet() {
AwsParams awsParams = getAwsParams();
NetworkDto networkDto = NetworkTestUtils.getNetworkDto(null, getAwsParams(), null, awsParams.getVpcId(), null, 2);
ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
underTest.validateDuringRequest(networkDto, validationResultBuilder);
ValidationResult validationResult = validationResultBuilder.build();
assertFalse(validationResult.hasError(), validationResult.getFormattedErrors());
}
use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder 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.cloudbreak.validation.ValidationResult.ValidationResultBuilder 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);
}
Aggregations