@Test public void addGraph_overlap() { DirectedGraph<Integer, String> graph = Graphs.createDirected(directedGraph.config()); populateInputGraph(graph); // Add an edge that is in 'graph' (overlap) builder.addEdge(E12, N1, N2); builder.addGraph(graph); assertThat(builder.build()).isEqualTo(graph); }
@Test public void addGraph_incompatibleMultigraphConfig() { try { DirectedGraph multigraph = Graphs.createDirected(Graphs.MULTIGRAPH); ImmutableDirectedGraph.Builder immutableGraphBuilder = ImmutableDirectedGraph.builder(); immutableGraphBuilder.addGraph(multigraph); fail("Should have rejected a graph with an incompatible multigraph configuration"); } catch (IllegalArgumentException expected) { } }
@Test public void addGraph_incompatibleSelfLoopConfig() { try { DirectedGraph graph = Graphs.createDirected(Graphs.config().noSelfLoops()); ImmutableDirectedGraph.Builder immutableGraphBuilder = ImmutableDirectedGraph.builder(); immutableGraphBuilder.addGraph(graph); fail("Should have rejected a graph with an incompatible self-loop configuration"); } catch (IllegalArgumentException expected) { } }
@Test public void addGraph_inconsistentEdges() { DirectedGraph<Integer, String> graph = Graphs.createDirected(directedGraph.config()); populateInputGraph(graph); builder.addEdge(E21, N3, N1); try { builder.addGraph(graph); fail( "Should have rejected a graph whose edge definitions were inconsistent with existing" + "builder state"); } catch (IllegalArgumentException expected) { } }
@Test public void addGraph() { DirectedGraph<Integer, String> graph = Graphs.createDirected(directedGraph.config()); populateInputGraph(graph); assertThat(builder.addGraph(graph).build()).isEqualTo(graph); }