Search in sources :

Example 1 with ContrailSubnetHostRoute

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

the class ContrailSubnetHostRouteMapper method map.

public ContrailSubnetHostRoute map() {
    final ContrailSubnetHostRoute contrailSubnetHostRoute = new ContrailSubnetHostRoute();
    if (hostRoute != null) {
        contrailSubnetHostRoute.setNextHop(hostRoute.getNextHop());
        contrailSubnetHostRoute.setPrefix(hostRoute.getPrefix());
    }
    return contrailSubnetHostRoute;
}
Also used : ContrailSubnetHostRoute(org.onap.so.adapters.network.beans.ContrailSubnetHostRoute)

Example 2 with ContrailSubnetHostRoute

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

use of org.onap.so.adapters.network.beans.ContrailSubnetHostRoute 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)3 HostRoute (org.onap.so.openstack.beans.HostRoute)2 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 ContrailSubnetHostRoutes (org.onap.so.adapters.network.beans.ContrailSubnetHostRoutes)1