Search in sources :

Example 6 with Subnet

use of org.onap.so.openstack.beans.Subnet in project so by onap.

the class ContrailSubnetMappersTest method createContrailSubnetPoolInvalidTest.

@Test
public void createContrailSubnetPoolInvalidTest() {
    List<Pool> pools = new ArrayList<>();
    Pool pool1 = new Pool();
    pool1.setStart("start1");
    pool1.setEnd("end1");
    Pool pool2 = new Pool();
    pool2.setStart("start2");
    pools.add(pool1);
    pools.add(pool2);
    Subnet subnet = new Subnet();
    subnet.setAllocationPools(pools);
    ContrailSubnetMapper mapper = new ContrailSubnetMapper(subnet);
    ContrailSubnet result = mapper.map();
    List<ContrailSubnetPool> cspools = result.getAllocationPools();
    assertEquals(1, cspools.size());
    assertEquals("start1", cspools.get(0).getStart());
    assertEquals("end1", cspools.get(0).getEnd());
}
Also used : ContrailSubnet(org.onap.so.adapters.network.beans.ContrailSubnet) ContrailSubnetPool(org.onap.so.adapters.network.beans.ContrailSubnetPool) ArrayList(java.util.ArrayList) ContrailSubnetPool(org.onap.so.adapters.network.beans.ContrailSubnetPool) Pool(org.onap.so.openstack.beans.Pool) Subnet(org.onap.so.openstack.beans.Subnet) ContrailSubnet(org.onap.so.adapters.network.beans.ContrailSubnet) Test(org.junit.Test)

Example 7 with Subnet

use of org.onap.so.openstack.beans.Subnet in project so by onap.

the class ContrailSubnetMappersTest method createContrailSubnetPoolTest.

@Test
public void createContrailSubnetPoolTest() {
    List<Pool> pools = new ArrayList<>();
    Pool pool1 = new Pool();
    pool1.setStart("start1");
    pool1.setEnd("end1");
    Pool pool2 = new Pool();
    pool2.setStart("start2");
    pool2.setEnd("end2");
    pools.add(pool1);
    pools.add(pool2);
    Subnet subnet = new Subnet();
    subnet.setAllocationPools(pools);
    ContrailSubnetMapper mapper = new ContrailSubnetMapper(subnet);
    ContrailSubnet result = mapper.map();
    List<ContrailSubnetPool> cspools = result.getAllocationPools();
    assertEquals(2, cspools.size());
    assertEquals("start2", cspools.get(1).getStart());
    assertEquals("end2", cspools.get(1).getEnd());
}
Also used : ContrailSubnet(org.onap.so.adapters.network.beans.ContrailSubnet) ContrailSubnetPool(org.onap.so.adapters.network.beans.ContrailSubnetPool) ArrayList(java.util.ArrayList) ContrailSubnetPool(org.onap.so.adapters.network.beans.ContrailSubnetPool) Pool(org.onap.so.openstack.beans.Pool) Subnet(org.onap.so.openstack.beans.Subnet) ContrailSubnet(org.onap.so.adapters.network.beans.ContrailSubnet) Test(org.junit.Test)

Example 8 with Subnet

use of org.onap.so.openstack.beans.Subnet in project so by onap.

the class ContrailSubnetMappersTest method mapRemainingFields.

@Test
public void mapRemainingFields() {
    Subnet subnet = new Subnet();
    subnet.setEnableDHCP(true);
    subnet.setGatewayIp("gateway-ip");
    ContrailSubnetMapper mapper = new ContrailSubnetMapper(subnet);
    ContrailSubnet result = mapper.map();
    assertEquals(true, result.isEnableDhcp());
    assertEquals("gateway-ip", result.getDefaultGateway());
}
Also used : ContrailSubnet(org.onap.so.adapters.network.beans.ContrailSubnet) Subnet(org.onap.so.openstack.beans.Subnet) ContrailSubnet(org.onap.so.adapters.network.beans.ContrailSubnet) Test(org.junit.Test)

Example 9 with Subnet

use of org.onap.so.openstack.beans.Subnet in project so by onap.

the class ContrailSubnetMappersTest method createContrailSubnetHostRoutesEmptyTest.

@Test
public void createContrailSubnetHostRoutesEmptyTest() {
    List<HostRoute> hostRoutes = new ArrayList<>();
    Subnet subnet = new Subnet();
    subnet.setHostRoutes(hostRoutes);
    ContrailSubnetMapper mapper = new ContrailSubnetMapper(subnet);
    ContrailSubnet result = mapper.map();
    ContrailSubnetHostRoutes routes = result.getHostRoutes();
    assertEquals(true, routes.getHostRoutes().isEmpty());
}
Also used : ContrailSubnet(org.onap.so.adapters.network.beans.ContrailSubnet) ArrayList(java.util.ArrayList) ContrailSubnetHostRoutes(org.onap.so.adapters.network.beans.ContrailSubnetHostRoutes) HostRoute(org.onap.so.openstack.beans.HostRoute) ContrailSubnetHostRoute(org.onap.so.adapters.network.beans.ContrailSubnetHostRoute) Subnet(org.onap.so.openstack.beans.Subnet) ContrailSubnet(org.onap.so.adapters.network.beans.ContrailSubnet) Test(org.junit.Test)

Example 10 with Subnet

use of org.onap.so.openstack.beans.Subnet in project so by onap.

the class ContrailSubnetMappersTest method getSubnetNameTest.

@Test
public void getSubnetNameTest() {
    Subnet subnet = new Subnet();
    subnet.setSubnetName("name");
    ContrailSubnetMapper mapper = new ContrailSubnetMapper(subnet);
    assertEquals("if subnetName is populated map", "name", mapper.getSubnetName(subnet));
    subnet = new Subnet();
    subnet.setSubnetId("id");
    mapper = new ContrailSubnetMapper(subnet);
    assertEquals("choose id when name is null", "id", mapper.getSubnetName(subnet));
    subnet = new Subnet();
    mapper = new ContrailSubnetMapper(subnet);
    assertEquals("expect null", null, mapper.getSubnetName(subnet));
}
Also used : Subnet(org.onap.so.openstack.beans.Subnet) ContrailSubnet(org.onap.so.adapters.network.beans.ContrailSubnet) Test(org.junit.Test)

Aggregations

Subnet (org.onap.so.openstack.beans.Subnet)15 ContrailSubnet (org.onap.so.adapters.network.beans.ContrailSubnet)14 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)7 ContrailSubnetHostRoute (org.onap.so.adapters.network.beans.ContrailSubnetHostRoute)3 ContrailSubnetHostRoutes (org.onap.so.adapters.network.beans.ContrailSubnetHostRoutes)3 ContrailSubnetPool (org.onap.so.adapters.network.beans.ContrailSubnetPool)3 HostRoute (org.onap.so.openstack.beans.HostRoute)3 Pool (org.onap.so.openstack.beans.Pool)3 MsoAdapterException (org.onap.so.openstack.exceptions.MsoAdapterException)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 NetworkException (org.onap.so.adapters.network.exceptions.NetworkException)2 MsoException (org.onap.so.openstack.exceptions.MsoException)2 HashMap (java.util.HashMap)1 PropertyMap (org.modelmapper.PropertyMap)1 ContrailSubnetMapper (org.onap.so.adapters.network.mappers.ContrailSubnetMapper)1