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());
}
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());
}
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);
}
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());
}
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());
}
Aggregations