use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.
the class YarnEnvironmentNetworkValidatorTest method testCheckNullableWhenNetworkIsNotNull.
@Test
public void testCheckNullableWhenNetworkIsNotNull() {
ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
NetworkDto networkDto = mock(NetworkDto.class);
underTest.checkNullable(CloudPlatform.YARN, 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 YarnEnvironmentNetworkValidatorTest method testValidateWhenNoNetworkCidrAndNoNetworkId.
@Test
void testValidateWhenNoNetworkCidrAndNoNetworkId() {
NetworkDto networkDto = NetworkTestUtils.getNetworkDto(null, null, YarnParams.builder().build(), null, null, 1);
ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
underTest.validateDuringRequest(networkDto, resultBuilder);
assertFalse(resultBuilder.build().hasError());
}
use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.
the class YarnEnvironmentNetworkValidatorTest method testCheckNullableWhenNetworkIsNull.
@Test
public void testCheckNullableWhenNetworkIsNull() {
ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
underTest.checkNullable(CloudPlatform.YARN, null, 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 NetworkCreationValidatorTest method testValidateWhenNoNetworkCidrAndNetworkIdOnAzure.
@Test
void testValidateWhenNoNetworkCidrAndNetworkIdOnAzure() {
AzureParams azureParams = NetworkTestUtils.getAzureParams(true, true, true);
NetworkDto networkDto = NetworkTestUtils.getNetworkDto(azureParams, null, null, azureParams.getNetworkId(), null, 1);
environment.setCloudPlatform(CloudPlatform.AZURE.name());
environment.setCidr(null);
ValidationResultBuilder resultBuilder = underTest.validateNetworkCreation(environment, networkDto);
ValidationResult validationResult = resultBuilder.build();
assertFalse(validationResult.hasError());
}
use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.
the class EnvironmentValidatorService method validateStorageLocation.
public ValidationResult validateStorageLocation(String storageLocation, String storageType) {
ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
if (storageLocation != null) {
Pattern pattern = Pattern.compile(".*\\s.*");
Matcher matcher = pattern.matcher(storageLocation.trim());
if (matcher.find()) {
resultBuilder.error("You have added some whitespace to the storage location: " + storageLocation);
}
} else {
String message = "You don't add a(n) %s storage location, please provide a valid storage location.";
resultBuilder.error(String.format(message, storageType));
}
return resultBuilder.build();
}
Aggregations