Search in sources :

Example 6 with EnvironmentNetworkRequest

use of com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentNetworkRequest in project cloudbreak by hortonworks.

the class NetworkRequestToDtoConverterTest method createNetworkRequest.

private EnvironmentNetworkRequest createNetworkRequest() {
    EnvironmentNetworkRequest request = new EnvironmentNetworkRequest();
    request.setNetworkCidr("10.10.10.10/16");
    request.setSubnetIds(Set.of(SUBNET_ID));
    request.setPrivateSubnetCreation(PrivateSubnetCreation.ENABLED);
    request.setServiceEndpointCreation(ServiceEndpointCreation.ENABLED);
    request.setServiceEndpointCreation(ServiceEndpointCreation.DISABLED);
    return request;
}
Also used : EnvironmentNetworkRequest(com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentNetworkRequest)

Example 7 with EnvironmentNetworkRequest

use of com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentNetworkRequest in project cloudbreak by hortonworks.

the class NetworkCidrValidatorTest method testValidatorShouldPassWhenCidrMaskIs16.

@Test
void testValidatorShouldPassWhenCidrMaskIs16() {
    EnvironmentNetworkRequest request = new EnvironmentNetworkRequest();
    request.setNetworkCidr("172.16.0.0/16");
    Set<ConstraintViolation<EnvironmentNetworkRequest>> violation = validator.validate(request);
    MatcherAssert.assertThat(violation, empty());
}
Also used : ConstraintViolation(javax.validation.ConstraintViolation) EnvironmentNetworkRequest(com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentNetworkRequest) Test(org.junit.jupiter.api.Test)

Example 8 with EnvironmentNetworkRequest

use of com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentNetworkRequest in project cloudbreak by hortonworks.

the class NetworkCidrValidatorTest method testValidatorShouldPassWhenCidrIsNull.

@Test
void testValidatorShouldPassWhenCidrIsNull() {
    EnvironmentNetworkRequest request = new EnvironmentNetworkRequest();
    request.setSubnetIds(Set.of("subnet-id"));
    Set<ConstraintViolation<EnvironmentNetworkRequest>> violation = validator.validate(request);
    MatcherAssert.assertThat(violation, empty());
}
Also used : ConstraintViolation(javax.validation.ConstraintViolation) EnvironmentNetworkRequest(com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentNetworkRequest) Test(org.junit.jupiter.api.Test)

Example 9 with EnvironmentNetworkRequest

use of com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentNetworkRequest in project cloudbreak by hortonworks.

the class NetworkCidrValidatorTest method testValidatorShouldFailWhenCidrIsNotRfcCompliant.

@Test
void testValidatorShouldFailWhenCidrIsNotRfcCompliant() {
    EnvironmentNetworkRequest request = new EnvironmentNetworkRequest();
    request.setNetworkCidr("0.0.0.0/16");
    Set<ConstraintViolation<EnvironmentNetworkRequest>> violation = validator.validate(request);
    MatcherAssert.assertThat(violation, hasSize(1));
    MatcherAssert.assertThat(violation, hasItem(hasProperty("message", is("The field should contain a valid CIDR definition."))));
}
Also used : ConstraintViolation(javax.validation.ConstraintViolation) EnvironmentNetworkRequest(com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentNetworkRequest) Test(org.junit.jupiter.api.Test)

Example 10 with EnvironmentNetworkRequest

use of com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentNetworkRequest in project cloudbreak by hortonworks.

the class NetworkCidrValidatorTest method testValidatorShouldPassWhenCidrIsEmptySinceCliCanProduceThat.

@Test
void testValidatorShouldPassWhenCidrIsEmptySinceCliCanProduceThat() {
    EnvironmentNetworkRequest request = new EnvironmentNetworkRequest();
    request.setNetworkCidr(EMPTY_STRING);
    Set<ConstraintViolation<EnvironmentNetworkRequest>> violation = validator.validate(request);
    MatcherAssert.assertThat(violation, hasSize(0));
}
Also used : ConstraintViolation(javax.validation.ConstraintViolation) EnvironmentNetworkRequest(com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentNetworkRequest) Test(org.junit.jupiter.api.Test)

Aggregations

EnvironmentNetworkRequest (com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentNetworkRequest)18 Test (org.junit.jupiter.api.Test)12 ConstraintViolation (javax.validation.ConstraintViolation)6 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)5 TelemetryRequest (com.sequenceiq.common.api.telemetry.request.TelemetryRequest)2 EnvironmentRequest (com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentRequest)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 EnvironmentEditRequest (com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentEditRequest)1