Search in sources :

Example 1 with HostRoute

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

the class ContrailSubnetMappersTest method createContrailSubnetHostRoutesMissingFieldTest.

@Test
public void createContrailSubnetHostRoutesMissingFieldTest() {
    List<HostRoute> hostRoutes = new ArrayList<>();
    HostRoute hostRoute1 = new HostRoute();
    hostRoute1.setNextHop("next-hop1");
    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-hop1", routes.getHostRoutes().get(0).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)

Example 2 with HostRoute

use of org.onap.so.openstack.beans.HostRoute 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 3 with HostRoute

use of org.onap.so.openstack.beans.HostRoute 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)

Example 4 with HostRoute

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

the class ContrailSubnetMappersTest method contrailSubnetHostRouteMapperTest.

@Test
public void contrailSubnetHostRouteMapperTest() {
    HostRoute hostRoute = new HostRoute();
    hostRoute.setNextHop("hop");
    hostRoute.setPrefix("prefix");
    ContrailSubnetHostRouteMapper mapper = new ContrailSubnetHostRouteMapper(hostRoute);
    ContrailSubnetHostRoute cshr = mapper.map();
    assertEquals("hop", cshr.getNextHop());
    assertEquals("prefix", cshr.getPrefix());
}
Also used : HostRoute(org.onap.so.openstack.beans.HostRoute) ContrailSubnetHostRoute(org.onap.so.adapters.network.beans.ContrailSubnetHostRoute) ContrailSubnetHostRoute(org.onap.so.adapters.network.beans.ContrailSubnetHostRoute) Test(org.junit.Test)

Example 5 with HostRoute

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

the class ContrailSubnetMapper method createContrailSubnetHostRoutes.

protected Optional<ContrailSubnetHostRoutes> createContrailSubnetHostRoutes(final Subnet subnet) {
    Optional<ContrailSubnetHostRoutes> result = Optional.empty();
    if (subnet.getHostRoutes() != null) {
        ContrailSubnetHostRoutes hostRoutesObj = new ContrailSubnetHostRoutes();
        List<ContrailSubnetHostRoute> hrList = new ArrayList<>();
        for (HostRoute hr : subnet.getHostRoutes()) {
            if (!isNullOrEmpty(hr.getPrefix()) || !isNullOrEmpty(hr.getNextHop())) {
                hrList.add(new ContrailSubnetHostRouteMapper(hr).map());
            }
        }
        if (!hrList.isEmpty()) {
            hostRoutesObj.setHostRoutes(hrList);
            result = Optional.of(hostRoutesObj);
        }
    }
    return result;
}
Also used : ContrailSubnetHostRoutes(org.onap.so.adapters.network.beans.ContrailSubnetHostRoutes) ArrayList(java.util.ArrayList) ContrailSubnetHostRoute(org.onap.so.adapters.network.beans.ContrailSubnetHostRoute) HostRoute(org.onap.so.openstack.beans.HostRoute) ContrailSubnetHostRoute(org.onap.so.adapters.network.beans.ContrailSubnetHostRoute)

Aggregations

ContrailSubnetHostRoute (org.onap.so.adapters.network.beans.ContrailSubnetHostRoute)5 HostRoute (org.onap.so.openstack.beans.HostRoute)5 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 ContrailSubnetHostRoutes (org.onap.so.adapters.network.beans.ContrailSubnetHostRoutes)4 ContrailSubnet (org.onap.so.adapters.network.beans.ContrailSubnet)3 Subnet (org.onap.so.openstack.beans.Subnet)3