Search in sources :

Example 6 with ContrailSubnet

use of org.onap.so.adapters.network.beans.ContrailSubnet in project so by onap.

the class ContrailSubnetMappersTest method createSubnetTestNullCidr.

@Test
public void createSubnetTestNullCidr() {
    Subnet subnet = new Subnet();
    ContrailSubnetMapper mapper = new ContrailSubnetMapper(subnet);
    ContrailSubnet result = mapper.map();
    assertEquals(null, result.getSubnet().getIpPrefix());
    assertEquals(null, result.getSubnet().getIpPrefixLen());
}
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 7 with ContrailSubnet

use of org.onap.so.adapters.network.beans.ContrailSubnet in project so by onap.

the class ContrailSubnetMappersTest method createSubnetTestInvalidCidr.

@Test
public void createSubnetTestInvalidCidr() {
    Subnet subnet = new Subnet();
    subnet.setCidr("test");
    ContrailSubnetMapper mapper = new ContrailSubnetMapper(subnet);
    ContrailSubnet result = mapper.map();
    assertEquals(null, result.getSubnet().getIpPrefix());
    assertEquals(null, result.getSubnet().getIpPrefixLen());
}
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 8 with ContrailSubnet

use of org.onap.so.adapters.network.beans.ContrailSubnet in project so by onap.

the class ContrailSubnetMappersTest method createContrailSubnetPoolEmptyTest.

@Test
public void createContrailSubnetPoolEmptyTest() {
    Subnet subnet = new Subnet();
    ContrailSubnetMapper mapper = new ContrailSubnetMapper(subnet);
    ContrailSubnet result = mapper.map();
    List<ContrailSubnetPool> cspools = result.getAllocationPools();
    assertEquals(true, cspools.isEmpty());
}
Also used : ContrailSubnet(org.onap.so.adapters.network.beans.ContrailSubnet) ContrailSubnetPool(org.onap.so.adapters.network.beans.ContrailSubnetPool) Subnet(org.onap.so.openstack.beans.Subnet) ContrailSubnet(org.onap.so.adapters.network.beans.ContrailSubnet) Test(org.junit.Test)

Example 9 with ContrailSubnet

use of org.onap.so.adapters.network.beans.ContrailSubnet 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 10 with ContrailSubnet

use of org.onap.so.adapters.network.beans.ContrailSubnet in project so by onap.

the class ContrailSubnetMappersTest method createContrailSubnetHostRoutesTest.

@Test
public void createContrailSubnetHostRoutesTest() {
    List<HostRoute> hostRoutes = new ArrayList<>();
    HostRoute hostRoute1 = new HostRoute();
    hostRoute1.setNextHop("next-hop1");
    hostRoute1.setPrefix("prefix1");
    HostRoute hostRoute2 = new HostRoute();
    hostRoute2.setNextHop("next-hop2");
    hostRoute2.setPrefix("prefix2");
    hostRoutes.add(hostRoute1);
    hostRoutes.add(hostRoute2);
    Subnet subnet = new Subnet();
    subnet.setHostRoutes(hostRoutes);
    ContrailSubnetMapper mapper = new ContrailSubnetMapper(subnet);
    ContrailSubnet result = mapper.map();
    ContrailSubnetHostRoutes routes = result.getHostRoutes();
    assertEquals(2, routes.getHostRoutes().size());
    assertEquals("next-hop2", routes.getHostRoutes().get(1).getNextHop());
    assertEquals("prefix2", routes.getHostRoutes().get(1).getPrefix());
}
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)

Aggregations

ContrailSubnet (org.onap.so.adapters.network.beans.ContrailSubnet)12 Subnet (org.onap.so.openstack.beans.Subnet)11 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)7 ContrailSubnetHostRoutes (org.onap.so.adapters.network.beans.ContrailSubnetHostRoutes)4 ContrailSubnetHostRoute (org.onap.so.adapters.network.beans.ContrailSubnetHostRoute)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)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 List (java.util.List)1 ContrailSubnetIp (org.onap.so.adapters.network.beans.ContrailSubnetIp)1 NetworkException (org.onap.so.adapters.network.exceptions.NetworkException)1 ContrailSubnetMapper (org.onap.so.adapters.network.mappers.ContrailSubnetMapper)1 MsoAdapterException (org.onap.so.openstack.exceptions.MsoAdapterException)1 MsoException (org.onap.so.openstack.exceptions.MsoException)1