Search in sources :

Example 16 with AwsNetwork

use of com.sequenceiq.environment.network.dao.domain.AwsNetwork in project cloudbreak by hortonworks.

the class AwsEnvironmentNetworkConverterTest method createAwsNetwork.

private AwsNetwork createAwsNetwork() {
    AwsNetwork awsNetwork = new AwsNetwork();
    awsNetwork.setId(1L);
    awsNetwork.setName("network-1");
    awsNetwork.setSubnetMetas(createSubnetMetas());
    awsNetwork.setNetworkCidr(NETWORK_CIDR);
    awsNetwork.setResourceCrn("crn");
    awsNetwork.setVpcId(VPC_ID);
    return awsNetwork;
}
Also used : AwsNetwork(com.sequenceiq.environment.network.dao.domain.AwsNetwork)

Example 17 with AwsNetwork

use of com.sequenceiq.environment.network.dao.domain.AwsNetwork in project cloudbreak by hortonworks.

the class AwsEnvironmentNetworkConverterTest method createEnvironment.

private Environment createEnvironment() {
    Environment environment = new Environment();
    environment.setName(ENV_NAME);
    environment.setId(1L);
    environment.setAccountId("2");
    environment.setDescription("description");
    environment.setCloudPlatform("AWS");
    environment.setCredential(new Credential());
    environment.setLatitude(2.4);
    environment.setLongitude(3.5);
    environment.setLocation(LOCATION);
    environment.setLocationDisplayName("London");
    environment.setNetwork(new AwsNetwork());
    environment.setRegions(Collections.singleton(new Region()));
    return environment;
}
Also used : Credential(com.sequenceiq.environment.credential.domain.Credential) AwsNetwork(com.sequenceiq.environment.network.dao.domain.AwsNetwork) Environment(com.sequenceiq.environment.environment.domain.Environment) Region(com.sequenceiq.environment.environment.domain.Region)

Example 18 with AwsNetwork

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

Example 19 with AwsNetwork

use of com.sequenceiq.environment.network.dao.domain.AwsNetwork in project cloudbreak by hortonworks.

the class AwsEnvironmentNetworkConverterTest method testConvertToNetwork.

@Test
void testConvertToNetwork() {
    EnvironmentView environment = new EnvironmentView();
    environment.setLocation(LOCATION);
    AwsNetwork awsNetwork = new AwsNetwork();
    awsNetwork.setVpcId(VPC_ID);
    awsNetwork.setEnvironments(Set.of(environment));
    Network network = underTest.convertToNetwork(awsNetwork);
    assertEquals(VPC_ID, network.getStringParameter(NetworkConstants.VPC_ID));
}
Also used : EnvironmentView(com.sequenceiq.environment.environment.domain.EnvironmentView) AwsNetwork(com.sequenceiq.environment.network.dao.domain.AwsNetwork) CreatedCloudNetwork(com.sequenceiq.cloudbreak.cloud.model.network.CreatedCloudNetwork) AwsNetwork(com.sequenceiq.environment.network.dao.domain.AwsNetwork) Network(com.sequenceiq.cloudbreak.cloud.model.Network) BaseNetwork(com.sequenceiq.environment.network.dao.domain.BaseNetwork) Test(org.junit.jupiter.api.Test)

Example 20 with AwsNetwork

use of com.sequenceiq.environment.network.dao.domain.AwsNetwork in project cloudbreak by hortonworks.

the class EnvironmentResourceServiceTest method createAndSetNetwork.

@Test
void createAndSetNetwork() {
    Environment environment = new Environment();
    NetworkDto networkDto = null;
    BaseNetwork network = new AwsNetwork();
    when(networkService.saveNetwork(eq(environment), eq(networkDto), eq(ACCOUNT_ID), any(), any())).thenReturn(network);
    assertEquals(network, environmentResourceServiceUnderTest.createAndSetNetwork(environment, networkDto, ACCOUNT_ID, Map.of(), Map.of()));
}
Also used : NetworkDto(com.sequenceiq.environment.network.dto.NetworkDto) BaseNetwork(com.sequenceiq.environment.network.dao.domain.BaseNetwork) AwsNetwork(com.sequenceiq.environment.network.dao.domain.AwsNetwork) Environment(com.sequenceiq.environment.environment.domain.Environment) Test(org.junit.jupiter.api.Test)

Aggregations

AwsNetwork (com.sequenceiq.environment.network.dao.domain.AwsNetwork)22 Test (org.junit.jupiter.api.Test)15 Environment (com.sequenceiq.environment.environment.domain.Environment)12 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)9 BaseNetwork (com.sequenceiq.environment.network.dao.domain.BaseNetwork)8 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)5 Network (com.sequenceiq.cloudbreak.cloud.model.Network)4 CreatedCloudNetwork (com.sequenceiq.cloudbreak.cloud.model.network.CreatedCloudNetwork)4 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 Credential (com.sequenceiq.environment.credential.domain.Credential)3 EnvironmentEditDto (com.sequenceiq.environment.environment.dto.EnvironmentEditDto)3 NetworkTest (com.sequenceiq.environment.environment.service.network.NetworkTest)3 CreatedSubnet (com.sequenceiq.cloudbreak.cloud.model.network.CreatedSubnet)2 Region (com.sequenceiq.environment.environment.domain.Region)2 GcpNetwork (com.sequenceiq.environment.network.dao.domain.GcpNetwork)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 CloudPlatformVariant (com.sequenceiq.cloudbreak.cloud.model.CloudPlatformVariant)1 Subnet (com.sequenceiq.cloudbreak.cloud.model.Subnet)1 NetworkCreationRequest (com.sequenceiq.cloudbreak.cloud.model.network.NetworkCreationRequest)1