@Test public void testTransformType2RouteOnExport() { final OspfExternalRoute.Builder builder = OspfExternalType2Route.builder() .setNetwork(Prefix.parse("2.2.2.2/32")) .setLsaMetric(0L) .setCostToAdvertiser(0L) .setAdvertiser("someNode") .setArea(1L) .setAdmin(0) .setNextHopIp(Ip.parse("1.1.1.1")); Stream<RouteAdvertisement<OspfExternalType2Route>> routes = Stream.of(new RouteAdvertisement<>((OspfExternalType2Route) builder.build())); assertThat( OspfRoutingProcess.transformType2RoutesOnExport(routes, AREA0_CONFIG), contains(new RouteAdvertisement<>(builder.setArea(1).build()))); assertThat( OspfRoutingProcess.transformType2RoutesOnExport( Stream.of( new RouteAdvertisement<>( (OspfExternalType2Route) builder.setArea(OspfRoute.NO_AREA).build())), AREA0_CONFIG), contains(new RouteAdvertisement<>(builder.setArea(0).build()))); }
@Nonnull @VisibleForTesting static Collection<RouteAdvertisement<OspfExternalType2Route>> transformType2RoutesOnExport( Stream<RouteAdvertisement<OspfExternalType2Route>> routeAdvertisements, OspfArea areaConfig) { return routeAdvertisements .map( r -> { final OspfExternalType2Route route = r.getRoute(); return r.toBuilder() .setRoute( (OspfExternalType2Route) route .toBuilder() .setArea( route.getArea() == OspfRoute.NO_AREA ? areaConfig.getAreaNumber() : route.getArea()) .build()) .build(); }) .collect(ImmutableSet.toImmutableSet()); }
OspfRoutingProcess implements RoutingProcess<OspfTopology, OspfRoute> { @Nonnull @VisibleForTesting static Collection<RouteAdvertisement<OspfExternalType2Route>> transformType2RoutesOnExport( Stream<RouteAdvertisement<OspfExternalType2Route>> routeAdvertisements, OspfArea areaConfig) { return routeAdvertisements .map( r -> { final OspfExternalType2Route route = r.getRoute(); return r.toBuilder() .setRoute( (OspfExternalType2Route) route .toBuilder() .setArea( route.getArea() == OspfRoute.NO_AREA ? areaConfig.getAreaNumber() : route.getArea()) .build()) .build(); }) .collect(ImmutableSet.toImmutableSet()); } }
OspfRoutingProcess implements RoutingProcess<OspfTopology, OspfRoute> { @Nonnull @VisibleForTesting static Collection<RouteAdvertisement<OspfExternalType2Route>> transformType2RoutesOnExport( Stream<RouteAdvertisement<OspfExternalType2Route>> routeAdvertisements, OspfArea areaConfig) { return routeAdvertisements .map( r -> { final OspfExternalType2Route route = r.getRoute(); return r.toBuilder() .setRoute( (OspfExternalType2Route) route .toBuilder() .setArea( route.getArea() == OspfRoute.NO_AREA ? areaConfig.getAreaNumber() : route.getArea()) .build()) .build(); }) .collect(ImmutableSet.toImmutableSet()); } OspfRoutingProcess(
      OspfProcess process, String vrfName, Configuration configuration, OspfTopology topology); }
OspfRoutingProcess implements RoutingProcess<OspfTopology, OspfRoute> { @Nonnull @VisibleForTesting static Collection<RouteAdvertisement<OspfExternalType2Route>> transformType2RoutesOnExport( Stream<RouteAdvertisement<OspfExternalType2Route>> routeAdvertisements, OspfArea areaConfig) { return routeAdvertisements .map( r -> { final OspfExternalType2Route route = r.getRoute(); return r.toBuilder() .setRoute( (OspfExternalType2Route) route .toBuilder() .setArea( route.getArea() == OspfRoute.NO_AREA ? areaConfig.getAreaNumber() : route.getArea()) .build()) .build(); }) .collect(ImmutableSet.toImmutableSet()); } 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> { @Nonnull @VisibleForTesting static Collection<RouteAdvertisement<OspfExternalType2Route>> transformType2RoutesOnExport( Stream<RouteAdvertisement<OspfExternalType2Route>> routeAdvertisements, OspfArea areaConfig) { return routeAdvertisements .map( r -> { final OspfExternalType2Route route = r.getRoute(); return r.toBuilder() .setRoute( (OspfExternalType2Route) route .toBuilder() .setArea( route.getArea() == OspfRoute.NO_AREA ? areaConfig.getAreaNumber() : route.getArea()) .build()) .build(); }) .collect(ImmutableSet.toImmutableSet()); } 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();  }