@Test public void testTransformInterAreaRouteOnImport() { final OspfInterAreaRoute.Builder builder = OspfInterAreaRoute.builder() .setArea(0) .setNetwork(Prefix.ZERO) .setMetric(1) .setNonRouting(true) .setNonForwarding(true) .setNextHopIp(Ip.parse("8.8.8.8")); Optional<OspfInterAreaRoute.Builder> transformedBuilder = _routingProcess.transformInterAreaRouteOnImport(builder.build(), 10); assertFalse("Default route rejected by ABR", transformedBuilder.isPresent()); builder.setNetwork(Prefix.parse("1.1.1.1/29")); transformedBuilder = _routingProcess.transformInterAreaRouteOnImport(builder.build(), 10); assertTrue(transformedBuilder.isPresent()); assertThat( transformedBuilder.get().build(), equalTo( builder .setMetric(11L) .setAdmin(200) .setNonRouting(false) .setNonForwarding(false) .build())); }
@Nonnull @VisibleForTesting Optional<OspfInterAreaRoute.Builder> transformInterAreaRouteOnImport( OspfInterAreaRoute route, long incrementalCost) { if (isABR() && route.getNetwork().equals(Prefix.ZERO)) { return Optional.empty(); } return Optional.of( route .toBuilder() .setMetric(route.getMetric() + incrementalCost) .setAdmin(_process.getAdminCosts().get(route.getProtocol())) .setNonRouting(false) .setNonForwarding(false)); }
OspfRoutingProcess implements RoutingProcess<OspfTopology, OspfRoute> { @Nonnull @VisibleForTesting Optional<OspfInterAreaRoute.Builder> transformInterAreaRouteOnImport( OspfInterAreaRoute route, long incrementalCost) { if (isABR() && route.getNetwork().equals(Prefix.ZERO)) { return Optional.empty(); } return Optional.of( route .toBuilder() .setMetric(route.getMetric() + incrementalCost) .setAdmin(_process.getAdminCosts().get(route.getProtocol())) .setNonRouting(false) .setNonForwarding(false)); } }
OspfRoutingProcess implements RoutingProcess<OspfTopology, OspfRoute> { @Nonnull @VisibleForTesting Optional<OspfInterAreaRoute.Builder> transformInterAreaRouteOnImport( OspfInterAreaRoute route, long incrementalCost) { if (isABR() && route.getNetwork().equals(Prefix.ZERO)) { return Optional.empty(); } return Optional.of( route .toBuilder() .setMetric(route.getMetric() + incrementalCost) .setAdmin(_process.getAdminCosts().get(route.getProtocol())) .setNonRouting(false) .setNonForwarding(false)); } OspfRoutingProcess(
      OspfProcess process, String vrfName, Configuration configuration, OspfTopology topology); }
OspfRoutingProcess implements RoutingProcess<OspfTopology, OspfRoute> { @Nonnull @VisibleForTesting Optional<OspfInterAreaRoute.Builder> transformInterAreaRouteOnImport( OspfInterAreaRoute route, long incrementalCost) { if (isABR() && route.getNetwork().equals(Prefix.ZERO)) { return Optional.empty(); } return Optional.of( route .toBuilder() .setMetric(route.getMetric() + incrementalCost) .setAdmin(_process.getAdminCosts().get(route.getProtocol())) .setNonRouting(false) .setNonForwarding(false)); } 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 Optional<OspfInterAreaRoute.Builder> transformInterAreaRouteOnImport( OspfInterAreaRoute route, long incrementalCost) { if (isABR() && route.getNetwork().equals(Prefix.ZERO)) { return Optional.empty(); } return Optional.of( route .toBuilder() .setMetric(route.getMetric() + incrementalCost) .setAdmin(_process.getAdminCosts().get(route.getProtocol())) .setNonRouting(false) .setNonForwarding(false)); } 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();  }