@Test public void testUnionLayer1PhysicalTopologiesBothPresent() { Layer1Edge edge1 = new Layer1Edge("n1", "i1", "n2", "i2"); Layer1Edge edge2 = new Layer1Edge("n1", "i1", "n3", "i3"); Layer1Edge edge3 = new Layer1Edge("n3", "i3", "n1", "i1"); Layer1Topology topology1 = new Layer1Topology(ImmutableSet.of(edge1, edge2)); Layer1Topology topology2 = new Layer1Topology(ImmutableSet.of(edge1, edge3)); assertThat( unionLayer1PhysicalTopologies(Optional.of(topology1), Optional.of(topology2)), equalTo(Optional.of(new Layer1Topology(ImmutableSet.of(edge1, edge2, edge3))))); }
public static @Nonnull Optional<Layer1Topology> unionLayer1PhysicalTopologies( Optional<Layer1Topology> topology1, Optional<Layer1Topology> topology2) { if (!topology1.isPresent()) { return topology2; } if (!topology2.isPresent()) { return topology1; } return Optional.of( new Layer1Topology( Sets.union(topology1.get().getGraph().edges(), topology2.get().getGraph().edges()))); }
TopologyUtil { public static @Nonnull Optional<Layer1Topology> unionLayer1PhysicalTopologies( Optional<Layer1Topology> topology1, Optional<Layer1Topology> topology2) { if (!topology1.isPresent()) { return topology2; } if (!topology2.isPresent()) { return topology1; } return Optional.of( new Layer1Topology( Sets.union(topology1.get().getGraph().edges(), topology2.get().getGraph().edges()))); } }
TopologyUtil { public static @Nonnull Optional<Layer1Topology> unionLayer1PhysicalTopologies( Optional<Layer1Topology> topology1, Optional<Layer1Topology> topology2) { if (!topology1.isPresent()) { return topology2; } if (!topology2.isPresent()) { return topology1; } return Optional.of( new Layer1Topology( Sets.union(topology1.get().getGraph().edges(), topology2.get().getGraph().edges()))); } private  TopologyUtil(); }
TopologyUtil { public static @Nonnull Optional<Layer1Topology> unionLayer1PhysicalTopologies( Optional<Layer1Topology> topology1, Optional<Layer1Topology> topology2) { if (!topology1.isPresent()) { return topology2; } if (!topology2.isPresent()) { return topology1; } return Optional.of( new Layer1Topology( Sets.union(topology1.get().getGraph().edges(), topology2.get().getGraph().edges()))); } private  TopologyUtil(); static @Nonnull Layer1Topology cleanLayer1PhysicalTopology(
      @Nonnull Layer1Topology rawLayer1Topology,
      @Nonnull Map<String, Configuration> configurations); static @Nonnull Optional<Layer1Topology> unionLayer1PhysicalTopologies(
      Optional<Layer1Topology> topology1, Optional<Layer1Topology> topology2); static @Nonnull Layer2Topology computeLayer2Topology(
      @Nonnull Layer1Topology layer1LogicalTopology,
      VxlanTopology vxlanTopology,
      @Nonnull Map<String, Configuration> configurations); static @Nonnull Topology computeRawLayer3Topology(
      @Nonnull Optional<Layer1Topology> rawLayer1PhysicalTopology,
      @Nonnull Optional<Layer1Topology> layer1LogicalTopology,
      @Nonnull Optional<Layer2Topology> layer2Topology,
      @Nonnull Map<String, Configuration> configurations); static @Nonnull Topology computeLayer3Topology(
      Topology rawLayer3Topology, Set<Edge> overlayEdges); static @Nullable Interface getInterface(
      @Nonnull Layer1Node layer1Node, @Nonnull Map<String, Configuration> configurations); static @Nullable Interface getInterface(
      @Nonnull Layer2Node layer2Node, @Nonnull Map<String, Configuration> configurations); static IpsecTopology computeIpsecTopology(Map<String, Configuration> configurations); static Map<String, Set<Interface>> computeNodeInterfaces(
      Map<String, Configuration> configurations); static Topology synthesizeL3Topology(Map<String, Configuration> configurations); static @Nonnull Layer1Topology computeLayer1LogicalTopology(
      Layer1Topology layer1PhysicalTopology, Map<String, Configuration> configurations); @Nonnull static TunnelTopology computeInitialTunnelTopology(
      Map<String, Configuration> configurations); @Nonnull static TunnelTopology pruneUnreachableTunnelEdges(
      TunnelTopology initialTunnelTopology,
      NetworkConfigurations configurations,
      TracerouteEngine tracerouteEngine); }
TopologyUtil { public static @Nonnull Optional<Layer1Topology> unionLayer1PhysicalTopologies( Optional<Layer1Topology> topology1, Optional<Layer1Topology> topology2) { if (!topology1.isPresent()) { return topology2; } if (!topology2.isPresent()) { return topology1; } return Optional.of( new Layer1Topology( Sets.union(topology1.get().getGraph().edges(), topology2.get().getGraph().edges()))); } private  TopologyUtil(); static @Nonnull Layer1Topology cleanLayer1PhysicalTopology(
      @Nonnull Layer1Topology rawLayer1Topology,
      @Nonnull Map<String, Configuration> configurations); static @Nonnull Optional<Layer1Topology> unionLayer1PhysicalTopologies(
      Optional<Layer1Topology> topology1, Optional<Layer1Topology> topology2); static @Nonnull Layer2Topology computeLayer2Topology(
      @Nonnull Layer1Topology layer1LogicalTopology,
      VxlanTopology vxlanTopology,
      @Nonnull Map<String, Configuration> configurations); static @Nonnull Topology computeRawLayer3Topology(
      @Nonnull Optional<Layer1Topology> rawLayer1PhysicalTopology,
      @Nonnull Optional<Layer1Topology> layer1LogicalTopology,
      @Nonnull Optional<Layer2Topology> layer2Topology,
      @Nonnull Map<String, Configuration> configurations); static @Nonnull Topology computeLayer3Topology(
      Topology rawLayer3Topology, Set<Edge> overlayEdges); static @Nullable Interface getInterface(
      @Nonnull Layer1Node layer1Node, @Nonnull Map<String, Configuration> configurations); static @Nullable Interface getInterface(
      @Nonnull Layer2Node layer2Node, @Nonnull Map<String, Configuration> configurations); static IpsecTopology computeIpsecTopology(Map<String, Configuration> configurations); static Map<String, Set<Interface>> computeNodeInterfaces(
      Map<String, Configuration> configurations); static Topology synthesizeL3Topology(Map<String, Configuration> configurations); static @Nonnull Layer1Topology computeLayer1LogicalTopology(
      Layer1Topology layer1PhysicalTopology, Map<String, Configuration> configurations); @Nonnull static TunnelTopology computeInitialTunnelTopology(
      Map<String, Configuration> configurations); @Nonnull static TunnelTopology pruneUnreachableTunnelEdges(
      TunnelTopology initialTunnelTopology,
      NetworkConfigurations configurations,
      TracerouteEngine tracerouteEngine);  }