Search in sources :

Example 51 with NetworkDto

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

the class EnvironmentDetailsToCDPEnvironmentDetailsConverterTest method testSettingAvailabilityZonesWhenSubnetMetasIsEmpty.

@Test
public void testSettingAvailabilityZonesWhenSubnetMetasIsEmpty() {
    NetworkDto networkDto = NetworkDto.builder().withRegistrationType(RegistrationType.EXISTING).withServiceEndpointCreation(ServiceEndpointCreation.ENABLED).withSubnetMetas(null).build();
    when(environmentDetails.getNetwork()).thenReturn(networkDto);
    UsageProto.CDPEnvironmentDetails cdpEnvironmentDetails = underTest.convert(environmentDetails);
    Assertions.assertEquals(0, cdpEnvironmentDetails.getNumberOfAvailabilityZones());
    Assertions.assertEquals("", cdpEnvironmentDetails.getAvailabilityZones());
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto) Test(org.junit.jupiter.api.Test)

Example 52 with NetworkDto

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

the class EnvironmentDetailsToCDPEnvironmentDetailsConverterTest method testSettingAvailabilityZonesWhenSubnetAvailabilityZoneIsEmpty.

@Test
public void testSettingAvailabilityZonesWhenSubnetAvailabilityZoneIsEmpty() {
    CloudSubnet publicSubnet = new CloudSubnet();
    NetworkDto networkDto = NetworkDto.builder().withRegistrationType(RegistrationType.EXISTING).withServiceEndpointCreation(ServiceEndpointCreation.ENABLED).withSubnetMetas(Map.of("1", publicSubnet)).build();
    when(environmentDetails.getNetwork()).thenReturn(networkDto);
    UsageProto.CDPEnvironmentDetails cdpEnvironmentDetails = underTest.convert(environmentDetails);
    Assertions.assertEquals(-1, cdpEnvironmentDetails.getNumberOfAvailabilityZones());
    Assertions.assertEquals("", cdpEnvironmentDetails.getAvailabilityZones());
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Test(org.junit.jupiter.api.Test)

Example 53 with NetworkDto

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

the class EnvironmentDetailsToCDPNetworkDetailsConverterTest method testConversionPublicEndpointAccessGateway.

@Test
public void testConversionPublicEndpointAccessGateway() {
    NetworkDto networkDto = NetworkDto.builder().withRegistrationType(RegistrationType.EXISTING).withServiceEndpointCreation(ServiceEndpointCreation.ENABLED).withUsePublicEndpointAccessGateway(PublicEndpointAccessGateway.ENABLED).build();
    when(environmentDetails.getNetwork()).thenReturn(networkDto);
    UsageProto.CDPNetworkDetails networkDetails = underTest.convert(environmentDetails);
    Assert.assertEquals("ENABLED", networkDetails.getPublicEndpointAccessGateway());
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto) Test(org.junit.jupiter.api.Test)

Example 54 with NetworkDto

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

the class EnvironmentDetailsToCDPNetworkDetailsConverterTest method testSettingSubnetNumbersWhenSubnetMetasIsNull.

@Test
public void testSettingSubnetNumbersWhenSubnetMetasIsNull() {
    NetworkDto networkDto = NetworkDto.builder().withRegistrationType(RegistrationType.EXISTING).withServiceEndpointCreation(ServiceEndpointCreation.ENABLED).build();
    networkDto.setSubnetMetas(null);
    when(environmentDetails.getNetwork()).thenReturn(networkDto);
    UsageProto.CDPNetworkDetails networkDetails = underTest.convert(environmentDetails);
    assertEquals(-1, networkDetails.getNumberPrivateSubnets());
    assertEquals(-1, networkDetails.getNumberPublicSubnets());
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto) Test(org.junit.jupiter.api.Test)

Example 55 with NetworkDto

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

the class EnvironmentDetailsToCDPNetworkDetailsConverterTest method testSetOwnDnsZoneWhenAzurePrivateDnsZonePresent.

@Test
public void testSetOwnDnsZoneWhenAzurePrivateDnsZonePresent() {
    NetworkDto networkDto = NetworkDto.builder().withAzure(AzureParams.builder().withDatabasePrivateDnsZoneId("privateDnsZoneId").build()).withRegistrationType(RegistrationType.EXISTING).withServiceEndpointCreation(ServiceEndpointCreation.ENABLED_PRIVATE_ENDPOINT).build();
    when(environmentDetails.getNetwork()).thenReturn(networkDto);
    when(environmentDetails.getCloudPlatform()).thenReturn("AZURE");
    UsageProto.CDPNetworkDetails networkDetails = underTest.convert(environmentDetails);
    assertNotNull(networkDetails.getOwnDnsZones());
    assertTrue(networkDetails.getOwnDnsZones().getPostgres());
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) UsageProto(com.cloudera.thunderhead.service.common.usage.UsageProto) 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