Search in sources :

Example 81 with NetworkDto

use of com.sequenceiq.environment.network.dto.NetworkDto in project cloudbreak by hortonworks.

the class NetworkRequestToDtoConverterTest method testConvertGcp.

@Test
void testConvertGcp() {
    EnvironmentNetworkRequest network = createNetworkRequest();
    network.setGcp(createGcpParams());
    NetworkDto actual = underTest.convert(network);
    assertEquals(network.getGcp().getNetworkId(), actual.getGcp().getNetworkId());
    assertEquals(network.getGcp().getNetworkId(), actual.getNetworkId());
    assertCommonFields(network, actual);
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) EnvironmentNetworkRequest(com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentNetworkRequest) Test(org.junit.jupiter.api.Test)

Example 82 with NetworkDto

use of com.sequenceiq.environment.network.dto.NetworkDto in project cloudbreak by hortonworks.

the class NetworkRequestToDtoConverterTest method testConvertAzure.

@Test
void testConvertAzure() {
    EnvironmentNetworkRequest network = createNetworkRequest();
    network.setAzure(createAzureParams());
    NetworkDto actual = underTest.convert(network);
    assertEquals(network.getAzure().getNetworkId(), actual.getAzure().getNetworkId());
    assertEquals(network.getAzure().getResourceGroupName(), actual.getAzure().getResourceGroupName());
    assertEquals(network.getAzure().getNoPublicIp(), actual.getAzure().isNoPublicIp());
    assertCommonFields(network, actual);
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) EnvironmentNetworkRequest(com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentNetworkRequest) Test(org.junit.jupiter.api.Test)

Example 83 with NetworkDto

use of com.sequenceiq.environment.network.dto.NetworkDto in project cloudbreak by hortonworks.

the class NetworkRequestToDtoConverterTest method testConvertMock.

@Test
void testConvertMock() {
    EnvironmentNetworkRequest network = createNetworkRequest();
    network.setMock(createMockParams());
    NetworkDto actual = underTest.convert(network);
    assertEquals(network.getMock().getVpcId(), actual.getMock().getVpcId());
    assertEquals(network.getMock().getInternetGatewayId(), actual.getMock().getInternetGatewayId());
    assertCommonFields(network, actual);
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) EnvironmentNetworkRequest(com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentNetworkRequest) Test(org.junit.jupiter.api.Test)

Example 84 with NetworkDto

use of com.sequenceiq.environment.network.dto.NetworkDto 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"));
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) AwsParams(com.sequenceiq.environment.network.dto.AwsParams) EnvironmentValidationDto(com.sequenceiq.environment.environment.dto.EnvironmentValidationDto) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Test(org.junit.jupiter.api.Test)

Example 85 with NetworkDto

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

Aggregations

NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)144 Test (org.junit.jupiter.api.Test)124 ValidationResultBuilder (com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder)59 AzureParams (com.sequenceiq.environment.network.dto.AzureParams)40 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)31 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)27 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)21 EnvironmentValidationDto (com.sequenceiq.environment.environment.dto.EnvironmentValidationDto)21 UsageProto (com.cloudera.thunderhead.service.common.usage.UsageProto)15 Environment (com.sequenceiq.environment.environment.domain.Environment)15 ProvidedSubnetIds (com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds)14 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)13 AwsNetwork (com.sequenceiq.environment.network.dao.domain.AwsNetwork)12 EnvironmentTelemetry (com.sequenceiq.environment.environment.dto.telemetry.EnvironmentTelemetry)10 AwsParams (com.sequenceiq.environment.network.dto.AwsParams)9 Features (com.sequenceiq.common.api.telemetry.model.Features)8 CloudPlatform (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform)7 EnvironmentRequest (com.sequenceiq.environment.api.v1.environment.model.request.EnvironmentRequest)7 ExperimentalFeatures (com.sequenceiq.environment.environment.domain.ExperimentalFeatures)7 BaseNetwork (com.sequenceiq.environment.network.dao.domain.BaseNetwork)7