@SuppressWarnings("unchecked")
@Test
public void testCompareGraphsWithAmbiguitiesOnEdgeLevelGivenByFieldsToBeExcluded() throws Exception {

    // GIVEN
    final Node a1 = graphElementFactory.createNode("a1", Arrays.asList("A"),
            ImmutableMap.<String, Object>builder().put("id", 1l).build());
    final Node a2 = graphElementFactory.createNode("a2", Arrays.asList("A"),
            ImmutableMap.<String, Object>builder().put("id", 2l).build());
    final Node a3 = graphElementFactory.createNode("a3", Arrays.asList("A"),
            ImmutableMap.<String, Object>builder().put("id", 3l).build());
    final Edge e1 = graphElementFactory.createEdge(a1, a2, "e1", Arrays.asList("E"), Collections.emptyMap());
    final Edge e2 = graphElementFactory.createEdge(a2, a3, "e2", Arrays.asList("E"), Collections.emptyMap());
    final Node b1 = graphElementFactory.createNode("b1", Arrays.asList("A"),
            ImmutableMap.<String, Object>builder().put("id", 1l).build());
    final Node b2 = graphElementFactory.createNode("b2", Arrays.asList("A"),
            ImmutableMap.<String, Object>builder().put("id", 2l).build());
    final Node b3 = graphElementFactory.createNode("b3", Arrays.asList("A"),
            ImmutableMap.<String, Object>builder().put("id", 3l).build());
    final Edge f1 = graphElementFactory.createEdge(b1, b2, "f1", Arrays.asList("E"), Collections.emptyMap());
    final Edge f2 = graphElementFactory.createEdge(b2, b3, "f2", Arrays.asList("E"), Collections.emptyMap());
    final Graph<Node, Edge> expectedGraph = createGraph(Arrays.asList(a1, a2, a3), Arrays.asList(e1, e2));
    final Graph<Node, Edge> givenGraph = createGraph(Arrays.asList(b1, b2, b3), Arrays.asList(f1, f2));
    final GraphComparator comparator = new GraphComparator(graphElementFactory, new String[] {
            "id"
    }, false);
    when(dbReader.readGraph(connection)).thenReturn(givenGraph);
    // WHEN
    comparator.compare(connection, expectedGraph, errorCollector);
    // THEN
    final ArgumentCaptor<String> stringCaptor = ArgumentCaptor.forClass(String.class);
    verify(errorCollector, times(5)).collect(stringCaptor.capture());
    final List<String> capturedMessages = stringCaptor.getAllValues();
    assertThat(capturedMessages,
            hasItems(containsString("Ambiguouty detected for node " + a1.asString()),
                    containsString("Ambiguouty detected for node " + a2.asString()),
                    containsString("Ambiguouty detected for node " + a3.asString()),
                    containsString("Ambiguouty detected for edge " + e1.asString()),
                    containsString("Ambiguouty detected for edge " + e2.asString())));
}