@SuppressWarnings("unchecked")
@Test
public void testCompareGivenGraphBuildsIntersectionWithTheExpectedGraphInStrictMode() 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 Node a4 = graphElementFactory.createNode("a4", Arrays.asList("A"),
            ImmutableMap.<String, Object>builder().put("id", 4l).build());
    final Node b1 = graphElementFactory.createNode("b1", Arrays.asList("B"),
            ImmutableMap.<String, Object>builder().put("id", 1l).build());
    final Node b2 = graphElementFactory.createNode("b2", Arrays.asList("B"),
            ImmutableMap.<String, Object>builder().put("id", 2l).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 Edge e3 = graphElementFactory.createEdge(a4, a2, "e3", Arrays.asList("E"), Collections.emptyMap());
    final Edge f1 = graphElementFactory.createEdge(b1, b2, "f1", Arrays.asList("F"), Collections.emptyMap());
    final Edge f2 = graphElementFactory.createEdge(b2, a1, "f2", Arrays.asList("F"), 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(a1, a2, a4, b1, b2), Arrays.asList(e1, e3, f1, f2));
    final GraphComparator comparator = new GraphComparator(graphElementFactory, new String[] {}, true);
    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(e2.asString() + " was expected, but is not present"),
                    containsString(e3.asString() + " was not expected, but is present"),
                    containsString(a4.asString() + " was not expected, but is present"),
                    containsString(a3.asString() + " was expected, but is not present"),
                    containsString("Nodes with B labels were not expected, but are present")));
}