@Test public void testComputeDefaultInterAreaRouteToInject() { OspfArea.Builder areaBuilder = OspfArea.builder().setNumber(1L); Ip nextHopIp = Ip.parse("1.1.1.1"); assertFalse(computeDefaultInterAreaRouteToInject(areaBuilder.build(), nextHopIp).isPresent()); assertFalse( computeDefaultInterAreaRouteToInject( areaBuilder .setStubType(StubType.NSSA) .setNssa(NssaSettings.builder().build()) .build(), nextHopIp) .isPresent()); assertThat( computeDefaultInterAreaRouteToInject( areaBuilder .setStubType(StubType.NSSA) .setNssa( NssaSettings.builder() .setDefaultOriginateType(OspfDefaultOriginateType.INTER_AREA) .build()) .build(), nextHopIp) .get(), allOf( hasRoute(allOf(hasPrefix(Prefix.ZERO), hasNextHopIp(equalTo(nextHopIp)))), hasReason(ADD))); assertThat( computeDefaultInterAreaRouteToInject( areaBuilder .setStubType(StubType.STUB) .setStubSettings(StubSettings.builder().build()) .build(), nextHopIp) .get(), allOf( hasRoute(allOf(hasPrefix(Prefix.ZERO), hasNextHopIp(equalTo(nextHopIp)))), hasReason(ADD))); }
@VisibleForTesting Stream<RouteAdvertisement<OspfInterAreaRoute>> computeDefaultInterAreaRouteToInject( OspfTopology.EdgeId edge, OspfArea areaConfig, Ip nextHopIp) { if (_neighborsWhereDefaultIARouteWasInjected.contains(edge.getTail())) { return Stream.empty(); } _neighborsWhereDefaultIARouteWasInjected.add(edge.getTail()); return computeDefaultInterAreaRouteToInject(areaConfig, nextHopIp) .map(Stream::of) .orElse(Stream.empty()); }
OspfRoutingProcess implements RoutingProcess<OspfTopology, OspfRoute> { @VisibleForTesting Stream<RouteAdvertisement<OspfInterAreaRoute>> computeDefaultInterAreaRouteToInject( OspfTopology.EdgeId edge, OspfArea areaConfig, Ip nextHopIp) { if (_neighborsWhereDefaultIARouteWasInjected.contains(edge.getTail())) { return Stream.empty(); } _neighborsWhereDefaultIARouteWasInjected.add(edge.getTail()); return computeDefaultInterAreaRouteToInject(areaConfig, nextHopIp) .map(Stream::of) .orElse(Stream.empty()); } }
OspfRoutingProcess implements RoutingProcess<OspfTopology, OspfRoute> { @VisibleForTesting Stream<RouteAdvertisement<OspfInterAreaRoute>> computeDefaultInterAreaRouteToInject( OspfTopology.EdgeId edge, OspfArea areaConfig, Ip nextHopIp) { if (_neighborsWhereDefaultIARouteWasInjected.contains(edge.getTail())) { return Stream.empty(); } _neighborsWhereDefaultIARouteWasInjected.add(edge.getTail()); return computeDefaultInterAreaRouteToInject(areaConfig, nextHopIp) .map(Stream::of) .orElse(Stream.empty()); } OspfRoutingProcess(
      OspfProcess process, String vrfName, Configuration configuration, OspfTopology topology); }
OspfRoutingProcess implements RoutingProcess<OspfTopology, OspfRoute> { @VisibleForTesting Stream<RouteAdvertisement<OspfInterAreaRoute>> computeDefaultInterAreaRouteToInject( OspfTopology.EdgeId edge, OspfArea areaConfig, Ip nextHopIp) { if (_neighborsWhereDefaultIARouteWasInjected.contains(edge.getTail())) { return Stream.empty(); } _neighborsWhereDefaultIARouteWasInjected.add(edge.getTail()); return computeDefaultInterAreaRouteToInject(areaConfig, nextHopIp) .map(Stream::of) .orElse(Stream.empty()); } 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 Stream<RouteAdvertisement<OspfInterAreaRoute>> computeDefaultInterAreaRouteToInject( OspfTopology.EdgeId edge, OspfArea areaConfig, Ip nextHopIp) { if (_neighborsWhereDefaultIARouteWasInjected.contains(edge.getTail())) { return Stream.empty(); } _neighborsWhereDefaultIARouteWasInjected.add(edge.getTail()); return computeDefaultInterAreaRouteToInject(areaConfig, nextHopIp) .map(Stream::of) .orElse(Stream.empty()); } 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();  }