@Test public void testTransformIntraAreaRoutesOnExport() { OspfIntraAreaRoute route0 = OspfIntraAreaRoute.builder() .setArea(0) .setNetwork(Prefix.ZERO) .setMetric(1) .setNextHopIp(Ip.parse("8.8.8.8")) .build(); OspfIntraAreaRoute route1 = OspfIntraAreaRoute.builder() .setArea(1) .setNetwork(Prefix.parse("1.0.0.0/8")) .setMetric(42) .setNextHopIp(Ip.parse("8.8.8.8")) .build(); final Ip nextHopIp = Ip.parse("9.9.9.9"); final RibDelta<OspfIntraAreaRoute> delta = RibDelta.<OspfIntraAreaRoute>builder().add(route0).add(route1).build(); Collection<RouteAdvertisement<OspfIntraAreaRoute>> transformed = transformIntraAreaRoutesOnExport(delta, AREA0_CONFIG, nextHopIp) .collect(Collectors.toList()); assertThat( transformed, contains( hasRoute( allOf( hasPrefix(route0.getNetwork()), hasNextHopIp(equalTo(nextHopIp)), hasMetric(route0.getMetric()))))); }
@VisibleForTesting static Stream<RouteAdvertisement<OspfIntraAreaRoute>> transformIntraAreaRoutesOnExport( RibDelta<OspfIntraAreaRoute> delta, OspfArea areaConfig, Ip nextHopIp) { return delta .getActions() .filter(r -> r.getRoute().getArea() == areaConfig.getAreaNumber()) .map( r -> r.toBuilder() .setRoute(r.getRoute().toBuilder().setNextHopIp(nextHopIp).build()) .build()) .distinct(); }
OspfRoutingProcess implements RoutingProcess<OspfTopology, OspfRoute> { @VisibleForTesting static Stream<RouteAdvertisement<OspfIntraAreaRoute>> transformIntraAreaRoutesOnExport( RibDelta<OspfIntraAreaRoute> delta, OspfArea areaConfig, Ip nextHopIp) { return delta .getActions() .filter(r -> r.getRoute().getArea() == areaConfig.getAreaNumber()) .map( r -> r.toBuilder() .setRoute(r.getRoute().toBuilder().setNextHopIp(nextHopIp).build()) .build()) .distinct(); } }
OspfRoutingProcess implements RoutingProcess<OspfTopology, OspfRoute> { @VisibleForTesting static Stream<RouteAdvertisement<OspfIntraAreaRoute>> transformIntraAreaRoutesOnExport( RibDelta<OspfIntraAreaRoute> delta, OspfArea areaConfig, Ip nextHopIp) { return delta .getActions() .filter(r -> r.getRoute().getArea() == areaConfig.getAreaNumber()) .map( r -> r.toBuilder() .setRoute(r.getRoute().toBuilder().setNextHopIp(nextHopIp).build()) .build()) .distinct(); } OspfRoutingProcess(
      OspfProcess process, String vrfName, Configuration configuration, OspfTopology topology); }
OspfRoutingProcess implements RoutingProcess<OspfTopology, OspfRoute> { @VisibleForTesting static Stream<RouteAdvertisement<OspfIntraAreaRoute>> transformIntraAreaRoutesOnExport( RibDelta<OspfIntraAreaRoute> delta, OspfArea areaConfig, Ip nextHopIp) { return delta .getActions() .filter(r -> r.getRoute().getArea() == areaConfig.getAreaNumber()) .map( r -> r.toBuilder() .setRoute(r.getRoute().toBuilder().setNextHopIp(nextHopIp).build()) .build()) .distinct(); } OspfRoutingProcess(
      OspfProcess process, String vrfName, Configuration configuration, OspfTopology topology); @Override void initialize(Node n); @Override void executeIteration(Map<String, Node> allNodes); @Override void updateTopology(OspfTopology topology); @Nonnull @Override RibDelta<OspfRoute> getUpdatesForMainRib(); @Override void redistribute(RibDelta<? extends AnnotatedRoute<AbstractRoute>> mainRibDelta); @Override boolean isDirty(); }
OspfRoutingProcess implements RoutingProcess<OspfTopology, OspfRoute> { @VisibleForTesting static Stream<RouteAdvertisement<OspfIntraAreaRoute>> transformIntraAreaRoutesOnExport( RibDelta<OspfIntraAreaRoute> delta, OspfArea areaConfig, Ip nextHopIp) { return delta .getActions() .filter(r -> r.getRoute().getArea() == areaConfig.getAreaNumber()) .map( r -> r.toBuilder() .setRoute(r.getRoute().toBuilder().setNextHopIp(nextHopIp).build()) .build()) .distinct(); } OspfRoutingProcess(
      OspfProcess process, String vrfName, Configuration configuration, OspfTopology topology); @Override void initialize(Node n); @Override void executeIteration(Map<String, Node> allNodes); @Override void updateTopology(OspfTopology topology); @Nonnull @Override RibDelta<OspfRoute> getUpdatesForMainRib(); @Override void redistribute(RibDelta<? extends AnnotatedRoute<AbstractRoute>> mainRibDelta); @Override boolean isDirty();  }