Search in sources :

Example 6 with AzureNetwork

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));
}
Also used : CreatedCloudNetwork(com.sequenceiq.cloudbreak.cloud.model.network.CreatedCloudNetwork) Network(com.sequenceiq.cloudbreak.cloud.model.Network) AzureNetwork(com.sequenceiq.environment.network.dao.domain.AzureNetwork) AzureNetwork(com.sequenceiq.environment.network.dao.domain.AzureNetwork) Test(org.junit.jupiter.api.Test)

Example 7 with AzureNetwork

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());
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) AzureNetwork(com.sequenceiq.environment.network.dao.domain.AzureNetwork) Test(org.junit.jupiter.api.Test)

Example 8 with AzureNetwork

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;
}
Also used : AzureNetwork(com.sequenceiq.environment.network.dao.domain.AzureNetwork)

Example 9 with 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());
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) AzureNetwork(com.sequenceiq.environment.network.dao.domain.AzureNetwork) Test(org.junit.jupiter.api.Test)

Example 10 with AzureNetwork

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);
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) Environment(com.sequenceiq.environment.environment.domain.Environment) AzureNetwork(com.sequenceiq.environment.network.dao.domain.AzureNetwork) Test(org.junit.jupiter.api.Test)

Aggregations

AzureNetwork (com.sequenceiq.environment.network.dao.domain.AzureNetwork)15 Test (org.junit.jupiter.api.Test)7 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)4 CreatedCloudNetwork (com.sequenceiq.cloudbreak.cloud.model.network.CreatedCloudNetwork)3 Environment (com.sequenceiq.environment.environment.domain.Environment)3 Network (com.sequenceiq.cloudbreak.cloud.model.Network)2 CreatedSubnet (com.sequenceiq.cloudbreak.cloud.model.network.CreatedSubnet)2 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)1 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)1 Credential (com.sequenceiq.environment.credential.domain.Credential)1 Region (com.sequenceiq.environment.environment.domain.Region)1 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)1 BaseNetwork (com.sequenceiq.environment.network.dao.domain.BaseNetwork)1 AzureParams (com.sequenceiq.environment.network.dto.AzureParams)1 HashMap (java.util.HashMap)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1