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());
}
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());
}
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());
}
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());
}
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;
}
Aggregations