Search in sources :

Example 76 with NetworkDto

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

the class AwsEnvironmentNetworkConverterTest method testConvertToDtoShouldConvertABaseNetworkIntoANetworkDto.

@Test
void testConvertToDtoShouldConvertABaseNetworkIntoANetworkDto() {
    AwsNetwork awsNetwork = createAwsNetwork();
    NetworkDto actual = underTest.convertToDto(awsNetwork);
    assertEquals(awsNetwork.getId(), actual.getId());
    assertEquals(awsNetwork.getName(), actual.getNetworkName());
    assertEquals(SUBNET_IDS, actual.getSubnetIds());
    assertTrue(actual.getSubnetMetas().containsKey(SUBNET_1));
    assertTrue(actual.getSubnetMetas().containsKey(SUBNET_2));
    assertTrue(actual.getSubnetMetas().containsKey(SUBNET_3));
    assertNull(actual.getPublicEndpointAccessGateway());
    assertEquals(0, actual.getEndpointGatewaySubnetIds().size());
    assertEquals(awsNetwork.getNetworkCidr(), actual.getNetworkCidr());
    assertEquals(awsNetwork.getResourceCrn(), actual.getResourceCrn());
    assertEquals(awsNetwork.getVpcId(), actual.getAws().getVpcId());
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) AwsNetwork(com.sequenceiq.environment.network.dao.domain.AwsNetwork) Test(org.junit.jupiter.api.Test)

Example 77 with NetworkDto

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

the class AwsEnvironmentNetworkConverterTest method testConvertToDtoShouldConvertABaseNetworkWithEndpointSubnetsIntoANetworkDto.

@Test
void testConvertToDtoShouldConvertABaseNetworkWithEndpointSubnetsIntoANetworkDto() {
    AwsNetwork awsNetwork = createAwsNetwork();
    awsNetwork.setPublicEndpointAccessGateway(PublicEndpointAccessGateway.ENABLED);
    awsNetwork.setEndpointGatewaySubnetMetas(createEndpointSubnetMetas());
    NetworkDto actual = underTest.convertToDto(awsNetwork);
    assertEquals(awsNetwork.getId(), actual.getId());
    assertEquals(awsNetwork.getName(), actual.getNetworkName());
    assertEquals(SUBNET_IDS, actual.getSubnetIds());
    assertTrue(actual.getSubnetMetas().containsKey(SUBNET_1));
    assertTrue(actual.getSubnetMetas().containsKey(SUBNET_2));
    assertTrue(actual.getSubnetMetas().containsKey(SUBNET_3));
    assertEquals(PublicEndpointAccessGateway.ENABLED, actual.getPublicEndpointAccessGateway());
    assertEquals(PUBLIC_SUBNET_IDS, actual.getEndpointGatewaySubnetIds());
    assertTrue(actual.getEndpointGatewaySubnetMetas().containsKey(PUBLIC_SUBNET_1));
    assertTrue(actual.getEndpointGatewaySubnetMetas().containsKey(PUBLIC_SUBNET_2));
    assertTrue(actual.getEndpointGatewaySubnetMetas().containsKey(PUBLIC_SUBNET_3));
    assertEquals(awsNetwork.getNetworkCidr(), actual.getNetworkCidr());
    assertEquals(awsNetwork.getResourceCrn(), actual.getResourceCrn());
    assertEquals(awsNetwork.getVpcId(), actual.getAws().getVpcId());
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) AwsNetwork(com.sequenceiq.environment.network.dao.domain.AwsNetwork) Test(org.junit.jupiter.api.Test)

Example 78 with NetworkDto

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

the class AwsEnvironmentNetworkConverterTest method testConvertShouldCreateABaseNetworkFromAnEnvironmentAndANetworkDtoWhenOptionalFieldsAreNotPresent.

@Test
void testConvertShouldCreateABaseNetworkFromAnEnvironmentAndANetworkDtoWhenOptionalFieldsAreNotPresent() {
    Environment environment = createEnvironment();
    NetworkDto networkDto = NetworkDto.builder().withNetworkCidr(NETWORK_CIDR).withSubnetMetas(createSubnetMetas()).build();
    AwsNetwork actual = (AwsNetwork) underTest.convert(environment, networkDto, Map.of(), Map.of());
    assertEquals(environment.getName(), actual.getName());
    assertNull(actual.getVpcId());
    assertEquals(NETWORK_CIDR, actual.getNetworkCidr());
    assertEquals(RegistrationType.CREATE_NEW, actual.getRegistrationType());
    assertTrue(SUBNET_IDS.containsAll(actual.getSubnetMetas().keySet()));
    verify(environmentViewConverter).convert(environment);
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) AwsNetwork(com.sequenceiq.environment.network.dao.domain.AwsNetwork) Environment(com.sequenceiq.environment.environment.domain.Environment) Test(org.junit.jupiter.api.Test)

Example 79 with NetworkDto

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

the class NetworkDtoToResponseConverterTest method testConvertWithMockParams.

@Test
void testConvertWithMockParams() {
    NetworkDto network = createNetworkDto().withMock(createMockParams()).build();
    ProvidedSubnetIds providedSubnetIds = new ProvidedSubnetIds(PREFERRED_SUBNET_ID, Set.of(PREFERRED_SUBNET_ID));
    when(subnetIdProvider.subnets(network, TUNNEL, network.getCloudPlatform(), true)).thenReturn(providedSubnetIds);
    EnvironmentNetworkResponse actual = underTest.convert(network, TUNNEL, true);
    assertCommonFields(network, actual);
    assertEquals(network.getMock().getVpcId(), actual.getMock().getVpcId());
    assertEquals(network.getMock().getInternetGatewayId(), actual.getMock().getInternetGatewayId());
    assertNull(actual.getAws());
    assertNull(actual.getYarn());
    assertNull(actual.getAzure());
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) ProvidedSubnetIds(com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) Test(org.junit.jupiter.api.Test)

Example 80 with NetworkDto

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

the class NetworkDtoToResponseConverterTest method testConvertWithAzureParams.

@Test
void testConvertWithAzureParams() {
    NetworkDto network = createNetworkDto().withAzure(createAzureParams()).build();
    ProvidedSubnetIds providedSubnetIds = new ProvidedSubnetIds(PREFERRED_SUBNET_ID, Set.of(PREFERRED_SUBNET_ID));
    when(subnetIdProvider.subnets(network, TUNNEL, network.getCloudPlatform(), true)).thenReturn(providedSubnetIds);
    EnvironmentNetworkResponse actual = underTest.convert(network, TUNNEL, true);
    assertCommonFields(network, actual);
    assertEquals(network.getAzure().isNoPublicIp(), actual.getAzure().getNoPublicIp());
    assertEquals(network.getAzure().getNetworkId(), actual.getAzure().getNetworkId());
    assertEquals(network.getAzure().getResourceGroupName(), actual.getAzure().getResourceGroupName());
    assertNull(actual.getAws());
    assertNull(actual.getYarn());
    assertNull(actual.getMock());
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) ProvidedSubnetIds(com.sequenceiq.environment.network.service.domain.ProvidedSubnetIds) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) 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