@Test public void testGenerateRules_PreOutVrf_PreOutEdge() { Map<String, Map<String, Map<org.batfish.datamodel.Edge, BDD>>> arpTrueEdgeBDDs = ImmutableMap.of( NODE1, ImmutableMap.of( VRF1, ImmutableMap.of( org.batfish.datamodel.Edge.of(NODE1, IFACE1, NODE2, IFACE2), DSTIP1)), NODE2, ImmutableMap.of( VRF1, ImmutableMap.of( org.batfish.datamodel.Edge.of(NODE2, IFACE2, NODE1, IFACE1), DSTIP2))); BDDFibGenerator generator = new BDDFibGenerator( arpTrueEdgeBDDs, ImmutableMap.of(), ImmutableMap.of(), ImmutableMap.of(), ImmutableMap.of(), ImmutableMap.of(), ImmutableMap.of(), ImmutableMap.of(), ImmutableMap.of(), ImmutableMap.of()); Edge expectedEdge = new Edge( new TestPreOutVrf(NODE1, VRF1), new TestPreOutEdge(NODE1, IFACE1, NODE2, IFACE2), DSTIP1); assertThat( generator .generateRules_PreOutVrf_PreOutEdge( NODE1::equals, TestPreOutVrf::new, TestPreOutEdge::new) .collect(ImmutableList.toImmutableList()), contains(expectedEdge)); assertThat( generator .generateForwardingEdges( NODE1::equals, TestPostInVrf::new, TestPreOutEdge::new, TestPreOutVrf::new, TestPreOutInterfaceDeliveredToSubnet::new, TestPreOutInterfaceExitsNetwork::new, TestPreOutInterfaceInsufficientInfo::new, TestPreOutInterfaceNeighborUnreachable::new) .collect(ImmutableList.toImmutableList()), hasItem(expectedEdge)); }
@Nonnull @VisibleForTesting Stream<Edge> generateRules_PreOutVrf_PreOutEdge( Predicate<String> includedNode, StateExprConstructor2 preOutVrf, StateExprConstructor4 preOutEdge) { return _arpTrueEdgeBDDs.entrySet().stream() .filter(byNodeEntry -> includedNode.test(byNodeEntry.getKey())) .flatMap( nodeEntry -> nodeEntry.getValue().entrySet().stream() .flatMap( vrfEntry -> vrfEntry.getValue().entrySet().stream() .map( edgeEntry -> { org.batfish.datamodel.Edge edge = edgeEntry.getKey(); BDD arpTrue = edgeEntry.getValue(); String node1 = edge.getNode1(); String iface1 = edge.getInt1(); String vrf1 = vrfEntry.getKey(); String node2 = edge.getNode2(); String iface2 = edge.getInt2(); return new Edge( preOutVrf.apply(node1, vrf1), preOutEdge.apply(node1, iface1, node2, iface2), arpTrue); }))); }
BDDFibGenerator { @Nonnull @VisibleForTesting Stream<Edge> generateRules_PreOutVrf_PreOutEdge( Predicate<String> includedNode, StateExprConstructor2 preOutVrf, StateExprConstructor4 preOutEdge) { return _arpTrueEdgeBDDs.entrySet().stream() .filter(byNodeEntry -> includedNode.test(byNodeEntry.getKey())) .flatMap( nodeEntry -> nodeEntry.getValue().entrySet().stream() .flatMap( vrfEntry -> vrfEntry.getValue().entrySet().stream() .map( edgeEntry -> { org.batfish.datamodel.Edge edge = edgeEntry.getKey(); BDD arpTrue = edgeEntry.getValue(); String node1 = edge.getNode1(); String iface1 = edge.getInt1(); String vrf1 = vrfEntry.getKey(); String node2 = edge.getNode2(); String iface2 = edge.getInt2(); return new Edge( preOutVrf.apply(node1, vrf1), preOutEdge.apply(node1, iface1, node2, iface2), arpTrue); }))); } }
BDDFibGenerator { @Nonnull @VisibleForTesting Stream<Edge> generateRules_PreOutVrf_PreOutEdge( Predicate<String> includedNode, StateExprConstructor2 preOutVrf, StateExprConstructor4 preOutEdge) { return _arpTrueEdgeBDDs.entrySet().stream() .filter(byNodeEntry -> includedNode.test(byNodeEntry.getKey())) .flatMap( nodeEntry -> nodeEntry.getValue().entrySet().stream() .flatMap( vrfEntry -> vrfEntry.getValue().entrySet().stream() .map( edgeEntry -> { org.batfish.datamodel.Edge edge = edgeEntry.getKey(); BDD arpTrue = edgeEntry.getValue(); String node1 = edge.getNode1(); String iface1 = edge.getInt1(); String vrf1 = vrfEntry.getKey(); String node2 = edge.getNode2(); String iface2 = edge.getInt2(); return new Edge( preOutVrf.apply(node1, vrf1), preOutEdge.apply(node1, iface1, node2, iface2), arpTrue); }))); } BDDFibGenerator(
      Map<String, Map<String, Map<org.batfish.datamodel.Edge, BDD>>> arpTrueEdgeBDDs,
      Map<String, Map<String, Map<String, BDD>>> neighborUnreachableBDDs,
      Map<String, Map<String, Map<String, BDD>>> deliveredToSubnetBDDs,
      Map<String, Map<String, Map<String, BDD>>> exitsNetworkBDDs,
      Map<String, Map<String, Map<String, BDD>>> insufficientInfoBDDs,
      Map<String, Map<String, Map<String, BDD>>> ifaceAcceptBDDs,
      Map<String, Map<String, BDD>> vrfAcceptBDDs,
      Map<String, Map<String, BDD>> routableBDDs,
      Map<String, Map<String, Map<String, BDD>>> nextVrfBDDs,
      Map<String, Map<String, BDD>> nullRoutedBDDs); }
BDDFibGenerator { @Nonnull @VisibleForTesting Stream<Edge> generateRules_PreOutVrf_PreOutEdge( Predicate<String> includedNode, StateExprConstructor2 preOutVrf, StateExprConstructor4 preOutEdge) { return _arpTrueEdgeBDDs.entrySet().stream() .filter(byNodeEntry -> includedNode.test(byNodeEntry.getKey())) .flatMap( nodeEntry -> nodeEntry.getValue().entrySet().stream() .flatMap( vrfEntry -> vrfEntry.getValue().entrySet().stream() .map( edgeEntry -> { org.batfish.datamodel.Edge edge = edgeEntry.getKey(); BDD arpTrue = edgeEntry.getValue(); String node1 = edge.getNode1(); String iface1 = edge.getInt1(); String vrf1 = vrfEntry.getKey(); String node2 = edge.getNode2(); String iface2 = edge.getInt2(); return new Edge( preOutVrf.apply(node1, vrf1), preOutEdge.apply(node1, iface1, node2, iface2), arpTrue); }))); } BDDFibGenerator(
      Map<String, Map<String, Map<org.batfish.datamodel.Edge, BDD>>> arpTrueEdgeBDDs,
      Map<String, Map<String, Map<String, BDD>>> neighborUnreachableBDDs,
      Map<String, Map<String, Map<String, BDD>>> deliveredToSubnetBDDs,
      Map<String, Map<String, Map<String, BDD>>> exitsNetworkBDDs,
      Map<String, Map<String, Map<String, BDD>>> insufficientInfoBDDs,
      Map<String, Map<String, Map<String, BDD>>> ifaceAcceptBDDs,
      Map<String, Map<String, BDD>> vrfAcceptBDDs,
      Map<String, Map<String, BDD>> routableBDDs,
      Map<String, Map<String, Map<String, BDD>>> nextVrfBDDs,
      Map<String, Map<String, BDD>> nullRoutedBDDs); @Nonnull Stream<Edge> generateForwardingEdges(
      Predicate<String> includedNode,
      StateExprConstructor2 postInVrf,
      StateExprConstructor4 preOutEdge,
      StateExprConstructor2 preOutVrf,
      StateExprConstructor2 preOutInterfaceDeliveredToSubnet,
      StateExprConstructor2 preOutInterfaceExitsNetwork,
      StateExprConstructor2 preOutInterfaceInsufficientInfo,
      StateExprConstructor2 preOutInterfaceNeighborUnreachable); }
BDDFibGenerator { @Nonnull @VisibleForTesting Stream<Edge> generateRules_PreOutVrf_PreOutEdge( Predicate<String> includedNode, StateExprConstructor2 preOutVrf, StateExprConstructor4 preOutEdge) { return _arpTrueEdgeBDDs.entrySet().stream() .filter(byNodeEntry -> includedNode.test(byNodeEntry.getKey())) .flatMap( nodeEntry -> nodeEntry.getValue().entrySet().stream() .flatMap( vrfEntry -> vrfEntry.getValue().entrySet().stream() .map( edgeEntry -> { org.batfish.datamodel.Edge edge = edgeEntry.getKey(); BDD arpTrue = edgeEntry.getValue(); String node1 = edge.getNode1(); String iface1 = edge.getInt1(); String vrf1 = vrfEntry.getKey(); String node2 = edge.getNode2(); String iface2 = edge.getInt2(); return new Edge( preOutVrf.apply(node1, vrf1), preOutEdge.apply(node1, iface1, node2, iface2), arpTrue); }))); } BDDFibGenerator(
      Map<String, Map<String, Map<org.batfish.datamodel.Edge, BDD>>> arpTrueEdgeBDDs,
      Map<String, Map<String, Map<String, BDD>>> neighborUnreachableBDDs,
      Map<String, Map<String, Map<String, BDD>>> deliveredToSubnetBDDs,
      Map<String, Map<String, Map<String, BDD>>> exitsNetworkBDDs,
      Map<String, Map<String, Map<String, BDD>>> insufficientInfoBDDs,
      Map<String, Map<String, Map<String, BDD>>> ifaceAcceptBDDs,
      Map<String, Map<String, BDD>> vrfAcceptBDDs,
      Map<String, Map<String, BDD>> routableBDDs,
      Map<String, Map<String, Map<String, BDD>>> nextVrfBDDs,
      Map<String, Map<String, BDD>> nullRoutedBDDs); @Nonnull Stream<Edge> generateForwardingEdges(
      Predicate<String> includedNode,
      StateExprConstructor2 postInVrf,
      StateExprConstructor4 preOutEdge,
      StateExprConstructor2 preOutVrf,
      StateExprConstructor2 preOutInterfaceDeliveredToSubnet,
      StateExprConstructor2 preOutInterfaceExitsNetwork,
      StateExprConstructor2 preOutInterfaceInsufficientInfo,
      StateExprConstructor2 preOutInterfaceNeighborUnreachable);  }