use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.
the class AwsEnvironmentSecurityGroupValidatorTest method testValidationWhenGroupsWhenGroupHasMoreGroupIdInTheSameVpcReturnIsValid.
@Test
public void testValidationWhenGroupsWhenGroupHasMoreGroupIdInTheSameVpcReturnIsValid() {
Region region = getRegion();
String sec1 = "sec-1,sec-2";
String sec2 = "sec-2,sec-1";
String requestVpcId = "vpc-124";
when(platformParameterService.getSecurityGroups(any(PlatformResourceRequest.class))).thenReturn(cloudSecurityGroups(region.getName(), requestVpcId, "sec-1", "sec-2"));
EnvironmentDto environmentDto = EnvironmentDto.builder().withRegions(Set.of(region)).withSecurityAccess(getSecurityAccessDto(sec1, sec2)).withNetwork(getNetworkDto(requestVpcId)).withCredential(getCredential()).build();
EnvironmentValidationDto environmentValidationDto = EnvironmentValidationDto.builder().withEnvironmentDto(environmentDto).build();
ValidationResultBuilder builder = ValidationResult.builder();
underTest.validate(environmentValidationDto, builder);
requestIsValid(builder);
}
use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.
the class AzureEnvironmentSecurityGroupValidatorTest method testValidationWhenGroupsInTheSameRegionReturnValid.
@Test
public void testValidationWhenGroupsInTheSameRegionReturnValid() {
Region region = getRegion();
when(platformParameterService.getSecurityGroups(any(PlatformResourceRequest.class))).thenReturn(cloudSecurityGroups(REGION, SECURITY_GROUP_1, SECURITY_GROUP_2));
EnvironmentDto environmentDto = EnvironmentDto.builder().withRegions(Set.of(region)).withSecurityAccess(getSecurityAccessDto(SECURITY_GROUP_1, SECURITY_GROUP_2)).withCredential(getCredential()).build();
EnvironmentValidationDto environmentValidationDto = EnvironmentValidationDto.builder().withEnvironmentDto(environmentDto).build();
ValidationResultBuilder builder = ValidationResult.builder();
underTest.validate(environmentValidationDto, builder);
requestIsValid(builder);
}
use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.
the class AwsEnvironmentNetworkValidatorTest method testValidateDuringRequestWhenNetworkHasCidr.
@Test
void testValidateDuringRequestWhenNetworkHasCidr() {
NetworkDto networkDto = NetworkTestUtils.getNetworkDto(null, null, null, null, "1.2.3.4/16", 1, RegistrationType.CREATE_NEW);
ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
EnvironmentDto environmentDto = new EnvironmentDto();
environmentDto.setNetwork(networkDto);
EnvironmentValidationDto environmentValidationDto = EnvironmentValidationDto.builder().withEnvironmentDto(environmentDto).build();
underTest.validateDuringFlow(environmentValidationDto, networkDto, validationResultBuilder);
assertFalse(validationResultBuilder.build().hasError());
}
use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.
the class AwsEnvironmentNetworkValidatorTest method testValidateDuringFlowWhenTheNetworkIsNull.
@Test
void testValidateDuringFlowWhenTheNetworkIsNull() {
ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
underTest.validateDuringFlow(mock(EnvironmentValidationDto.class), null, validationResultBuilder);
assertFalse(validationResultBuilder.build().hasError());
}
use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.
the class AwsEnvironmentNetworkValidatorTest method testValidateDuringFlowWhenTheAwsNetworkParamsContainsVPCId.
@Test
void testValidateDuringFlowWhenTheAwsNetworkParamsContainsVPCId() {
ValidationResultBuilder validationResultBuilder = new ValidationResultBuilder();
AwsParams awsParams = AwsParams.builder().withVpcId("aVPCResourceIDFromAWS").build();
NetworkDto networkDto = NetworkDto.builder().withId(1L).withName("networkName").withResourceCrn("aResourceCRN").withAws(awsParams).build();
underTest.validateDuringRequest(networkDto, validationResultBuilder);
assertFalse(validationResultBuilder.build().hasError());
}
Aggregations