use of com.sequenceiq.environment.network.dto.NetworkDto in project cloudbreak by hortonworks.
the class EnvironmentDetailsToCDPNetworkDetailsConverterTest method testConversionNetworkShouldReturnNetworkRelatedFields.
@Test
public void testConversionNetworkShouldReturnNetworkRelatedFields() {
CloudSubnet privateSubnet = new CloudSubnet();
privateSubnet.setType(SubnetType.PRIVATE);
CloudSubnet dwxSubnet = new CloudSubnet();
dwxSubnet.setType(SubnetType.DWX);
CloudSubnet mlxSubnet = new CloudSubnet();
mlxSubnet.setType(SubnetType.MLX);
CloudSubnet publicSubnet1 = new CloudSubnet();
publicSubnet1.setType(SubnetType.PUBLIC);
CloudSubnet publicSubnet2 = new CloudSubnet();
publicSubnet2.setType(SubnetType.PUBLIC);
NetworkDto networkDto = NetworkDto.builder().withRegistrationType(RegistrationType.EXISTING).withServiceEndpointCreation(ServiceEndpointCreation.ENABLED).withSubnetMetas(Map.of("1", dwxSubnet, "2", mlxSubnet, "3", publicSubnet1, "4", publicSubnet2, "5", privateSubnet)).build();
when(environmentDetails.getNetwork()).thenReturn(networkDto);
when(environmentDetails.getSecurityAccessType()).thenReturn("CIDR_WIDE_OPEN");
when(environmentDetails.getTunnel()).thenReturn(Tunnel.CCM);
when(environmentDetails.getDomain()).thenReturn("cldr.com");
when(environmentDetails.getTlsType()).thenReturn(CcmV2TlsType.ONE_WAY_TLS);
UsageProto.CDPNetworkDetails networkDetails = underTest.convert(environmentDetails);
Assert.assertEquals("EXISTING", networkDetails.getNetworkType());
Assert.assertEquals("ENABLED", networkDetails.getServiceEndpointCreation());
Assert.assertEquals("EXISTING", networkDetails.getNetworkType());
Assert.assertEquals(3, networkDetails.getNumberPrivateSubnets());
Assert.assertEquals(2, networkDetails.getNumberPublicSubnets());
Assert.assertEquals("DISABLED", networkDetails.getPublicEndpointAccessGateway());
Assert.assertEquals("CIDR_WIDE_OPEN", networkDetails.getSecurityAccessType());
Assert.assertEquals("CCM", networkDetails.getConnectivity());
Assert.assertEquals("ONE_WAY_TLS", networkDetails.getControlPlaneAndCCMAgentConnectionSecurity());
Assert.assertEquals("cldr.com", networkDetails.getDomain());
}
use of com.sequenceiq.environment.network.dto.NetworkDto in project cloudbreak by hortonworks.
the class EnvironmentDetailsToCDPNetworkDetailsConverterTest method testSettingSubnetNumbersWhenSubnetMetasIsEmpty.
@Test
public void testSettingSubnetNumbersWhenSubnetMetasIsEmpty() {
NetworkDto networkDto = NetworkDto.builder().withRegistrationType(RegistrationType.EXISTING).withServiceEndpointCreation(ServiceEndpointCreation.ENABLED).withSubnetMetas(null).build();
when(environmentDetails.getNetwork()).thenReturn(networkDto);
UsageProto.CDPNetworkDetails networkDetails = underTest.convert(environmentDetails);
assertEquals(0, networkDetails.getNumberPrivateSubnets());
assertEquals(0, networkDetails.getNumberPublicSubnets());
}
use of com.sequenceiq.environment.network.dto.NetworkDto in project cloudbreak by hortonworks.
the class EnvironmentDetailsToCDPNetworkDetailsConverterTest method testSettingSubnetNumbersWhenSubnetTypeIsEmpty.
@Test
public void testSettingSubnetNumbersWhenSubnetTypeIsEmpty() {
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.CDPNetworkDetails networkDetails = underTest.convert(environmentDetails);
assertEquals(-1, networkDetails.getNumberPrivateSubnets());
assertEquals(-1, networkDetails.getNumberPublicSubnets());
}
use of com.sequenceiq.environment.network.dto.NetworkDto in project cloudbreak by hortonworks.
the class EnvironmentDetailsToCDPNetworkDetailsConverterTest method testSettingSubnetNumbersWhenSubnetTypeIsNotEmpty.
@Test
public void testSettingSubnetNumbersWhenSubnetTypeIsNotEmpty() {
CloudSubnet publicSubnet = new CloudSubnet();
publicSubnet.setType(SubnetType.PUBLIC);
NetworkDto networkDto = NetworkDto.builder().withRegistrationType(RegistrationType.EXISTING).withServiceEndpointCreation(ServiceEndpointCreation.ENABLED).withSubnetMetas(Map.of("1", publicSubnet)).build();
when(environmentDetails.getNetwork()).thenReturn(networkDto);
UsageProto.CDPNetworkDetails networkDetails = underTest.convert(environmentDetails);
assertEquals(0, networkDetails.getNumberPrivateSubnets());
assertEquals(1, networkDetails.getNumberPublicSubnets());
}
use of com.sequenceiq.environment.network.dto.NetworkDto in project cloudbreak by hortonworks.
the class NetworkServiceTest method testSaveNetworkIfNewNetwork.
@Test
public void testSaveNetworkIfNewNetwork() {
NetworkDto networkDto = mock(NetworkDto.class);
EnvironmentNetworkConverter environmentNetworkConverter = mock(EnvironmentNetworkConverter.class);
Network network = mock(Network.class);
Credential credential = mock(Credential.class);
BaseNetwork baseNetwork = new AwsNetwork();
baseNetwork.setRegistrationType(RegistrationType.CREATE_NEW);
Environment environment = new Environment();
environment.setCloudPlatform("AWS");
environment.setCredential(credential);
when(environmentNetworkConverterMap.get(any(CloudPlatform.class))).thenReturn(environmentNetworkConverter);
when(environmentNetworkConverter.convert(environment, networkDto, Map.of(), Map.of())).thenReturn(baseNetwork);
when(networkRepository.save(baseNetwork)).thenReturn(baseNetwork);
BaseNetwork result = underTest.saveNetwork(environment, networkDto, "accountId", Map.of(), Map.of());
Assertions.assertNull(result.getNetworkCidr());
verify(environmentNetworkService, times(0)).getNetworkCidr(eq(network), anyString(), eq(credential));
}
Aggregations