Search in sources :

Example 46 with ValidationResultBuilder

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();
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.jupiter.api.Test)

Example 47 with ValidationResultBuilder

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());
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) Test(org.junit.jupiter.api.Test)

Example 48 with ValidationResultBuilder

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();
}
Also used : ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.jupiter.api.Test)

Example 49 with ValidationResultBuilder

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());
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) AzureParams(com.sequenceiq.environment.network.dto.AzureParams) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.jupiter.api.Test)

Example 50 with ValidationResultBuilder

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();
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder)

Aggregations

ValidationResultBuilder (com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder)169 Test (org.junit.jupiter.api.Test)107 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)67 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)62 EnvironmentValidationDto (com.sequenceiq.environment.environment.dto.EnvironmentValidationDto)35 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)33 AzureParams (com.sequenceiq.environment.network.dto.AzureParams)33 Test (org.junit.Test)20 SpiFileSystem (com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem)16 Environment (com.sequenceiq.environment.environment.domain.Environment)11 ObjectStorageMetadataRequest (com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataRequest)10 ObjectStorageMetadataResponse (com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataResponse)10 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)10 Credential (com.sequenceiq.environment.credential.domain.Credential)10 Region (com.sequenceiq.environment.environment.domain.Region)9 PlatformResourceRequest (com.sequenceiq.environment.platformresource.PlatformResourceRequest)9 EnvironmentCreationDto (com.sequenceiq.environment.environment.dto.EnvironmentCreationDto)7 InstanceProfile (com.amazonaws.services.identitymanagement.model.InstanceProfile)6 Role (com.amazonaws.services.identitymanagement.model.Role)6 GatewayTopologyV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.topology.GatewayTopologyV4Request)6