use of com.sequenceiq.environment.network.dao.domain.AzureNetwork in project cloudbreak by hortonworks.
the class AzureEnvironmentNetworkConverterTest method testConvertToNetwork.
@Test
void testConvertToNetwork() {
AzureNetwork azureNetwork = new AzureNetwork();
azureNetwork.setNetworkId(NETWORK_ID);
azureNetwork.setResourceGroupName(RESOURCE_GROUP_NAME);
Network network = underTest.convertToNetwork(azureNetwork);
assertEquals(RESOURCE_GROUP_NAME, network.getStringParameter(AzureUtils.RG_NAME));
assertEquals(NETWORK_ID, network.getStringParameter(AzureUtils.NETWORK_ID));
}
use of com.sequenceiq.environment.network.dao.domain.AzureNetwork in project cloudbreak by hortonworks.
the class AzureEnvironmentNetworkConverterTest method testConvertToDtoShouldConvertABaseNetworkWithEndpointSubnetsIntoANetworkDto.
@Test
void testConvertToDtoShouldConvertABaseNetworkWithEndpointSubnetsIntoANetworkDto() {
AzureNetwork azureNetwork = createAzureNetwork();
azureNetwork.setPublicEndpointAccessGateway(PublicEndpointAccessGateway.ENABLED);
azureNetwork.setEndpointGatewaySubnetMetas(createEndpointSubnetMetas());
NetworkDto actual = underTest.convertToDto(azureNetwork);
assertEquals(azureNetwork.getId(), actual.getId());
assertEquals(azureNetwork.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(azureNetwork.getNetworkCidr(), actual.getNetworkCidr());
assertEquals(azureNetwork.getResourceCrn(), actual.getResourceCrn());
assertEquals(azureNetwork.getNetworkId(), actual.getAzure().getNetworkId());
}
use of com.sequenceiq.environment.network.dao.domain.AzureNetwork in project cloudbreak by hortonworks.
the class AzureEnvironmentNetworkConverterTest method createAzureNetwork.
private AzureNetwork createAzureNetwork() {
AzureNetwork azureNetwork = new AzureNetwork();
azureNetwork.setId(1L);
azureNetwork.setName("network-1");
azureNetwork.setSubnetMetas(createSubnetMetas());
azureNetwork.setNetworkCidr(NETWORK_CIDR);
azureNetwork.setResourceCrn("crn");
azureNetwork.setNetworkId(NETWORK_ID);
azureNetwork.setResourceGroupName(RESOURCE_GROUP_NAME);
azureNetwork.setNoPublicIp(true);
return azureNetwork;
}
use of com.sequenceiq.environment.network.dao.domain.AzureNetwork in project cloudbreak by hortonworks.
the class AzureEnvironmentNetworkConverterTest method testConvertToDtoShouldConvertABaseNetworkIntoANetworkDto.
@Test
void testConvertToDtoShouldConvertABaseNetworkIntoANetworkDto() {
AzureNetwork azureNetwork = createAzureNetwork();
NetworkDto actual = underTest.convertToDto(azureNetwork);
assertEquals(azureNetwork.getId(), actual.getId());
assertEquals(azureNetwork.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(azureNetwork.getNetworkCidr(), actual.getNetworkCidr());
assertEquals(azureNetwork.getResourceCrn(), actual.getResourceCrn());
assertEquals(azureNetwork.getNetworkId(), actual.getAzure().getNetworkId());
}
use of com.sequenceiq.environment.network.dao.domain.AzureNetwork in project cloudbreak by hortonworks.
the class AzureEnvironmentNetworkConverterTest method testConvertShouldCreateABaseNetworkFromAnEnvironmentAndANetworkDtoWhenOptionalFieldsAreNotPresent.
@Test
void testConvertShouldCreateABaseNetworkFromAnEnvironmentAndANetworkDtoWhenOptionalFieldsAreNotPresent() {
Environment environment = createEnvironment();
NetworkDto networkDto = NetworkDto.builder().withNetworkCidr(NETWORK_CIDR).withSubnetMetas(createSubnetMetas()).build();
AzureNetwork actual = (AzureNetwork) underTest.convert(environment, networkDto, Map.of(), Map.of());
assertEquals(environment.getName(), actual.getName());
assertNull(actual.getNetworkId());
assertNull(actual.getResourceGroupName());
assertFalse(actual.getNoPublicIp());
assertEquals(NETWORK_CIDR, actual.getNetworkCidr());
assertEquals(RegistrationType.CREATE_NEW, actual.getRegistrationType());
assertTrue(SUBNET_IDS.containsAll(actual.getSubnetMetas().keySet()));
verify(environmentViewConverter).convert(environment);
}
Aggregations