@SuppressWarnings("unchecked")
@Test
public void testCurrentDataSetAndExpectedDataSetHaveOnlyOneCollectionInCommonUsingNotStrictMode() {

    // GIVEN
    final List<String> currentCollectionNames = Arrays.asList(COLLECTION_NAME_1, COLLECTION_NAME_2);
    final Iterator<String> currentCollectionNamesIt = currentCollectionNames.iterator();
    final MongoCursor<String> currentCollectionNamesCursor = mock(MongoCursor.class);
    when(currentCollectionNamesCursor.hasNext()).thenAnswer((final InvocationOnMock invocation) -> currentCollectionNamesIt.hasNext());
    when(currentCollectionNamesCursor.next()).thenAnswer((final InvocationOnMock invocation) -> currentCollectionNamesIt.next());
    doAnswer((final InvocationOnMock invocation) -> {
        final Consumer<String> c = (Consumer<String>) invocation.getArguments()[0];
        for (final String name : currentCollectionNames) {
            c.accept(name);
        }
        return null;
    }).when(currentCollectionNamesCursor).forEachRemaining(any(Consumer.class));
    final MongoIterable<String> collectionIterable = mock(MongoIterable.class);
    when(collectionIterable.iterator()).thenReturn(currentCollectionNamesCursor);
    when(mongoDatabase.listCollectionNames()).thenReturn(collectionIterable);
    final MongoCursor<Document> documentIteratorWithoutEntries = mock(MongoCursor.class);
    when(documentIteratorWithoutEntries.hasNext()).thenReturn(Boolean.FALSE);
    final FindIterable<Document> findIterableWithoutEntries = mock(FindIterable.class);
    when(findIterableWithoutEntries.iterator()).thenReturn(documentIteratorWithoutEntries);
    final MongoCollection<Document> collectionWithoutEntries = mock(MongoCollection.class);
    when(collectionWithoutEntries.count()).thenReturn(0l);
    when(collectionWithoutEntries.find(any(Document.class))).thenReturn(findIterableWithoutEntries);
    when(collectionWithoutEntries.find()).thenReturn(findIterableWithoutEntries);
    when(mongoDatabase.getCollection(anyString())).thenReturn(collectionWithoutEntries);
    final List<Document> currentDocuments = Arrays.asList(DOCUMENT_1, DOCUMENT_2);
    final Iterator<Document> currentDocumentsIt = currentDocuments.iterator();
    final MongoCursor<Document> documentIteratorWithEntries = mock(MongoCursor.class);
    when(documentIteratorWithEntries.hasNext()).thenAnswer((final InvocationOnMock invocation) -> currentDocumentsIt.hasNext());
    when(documentIteratorWithEntries.next()).thenAnswer((final InvocationOnMock invocation) -> currentDocumentsIt.next());
    final FindIterable<Document> findIterableWithEntries = mock(FindIterable.class);
    when(findIterableWithEntries.iterator()).thenReturn(documentIteratorWithEntries);
    final MongoCollection<Document> collectionWithEntries = mock(MongoCollection.class);
    when(collectionWithEntries.count()).thenReturn(1l);
    when(collectionWithEntries.find(any(Document.class))).thenReturn(findIterableWithEntries);
    when(collectionWithEntries.find()).thenReturn(findIterableWithEntries);
    when(mongoDatabase.getCollection(eq(COLLECTION_NAME_1))).thenReturn(collectionWithEntries);
    final String[] toExclude = new String[] {};
    final Document expectedDataSet = new Document().append(COLLECTION_NAME_2, Arrays.asList(DOCUMENT_2)).append(COLLECTION_NAME_3,
            Arrays.asList(DOCUMENT_3));
    final DataSetComparator comparator = new DataSetComparator(toExclude, false);
    // WHEN
    comparator.compare(mongoDatabase, expectedDataSet, errorCollector);
    // THEN
    assertThat(errorCollector.amountOfErrors(), equalTo(3));
    try {
        errorCollector.report();
        fail("AssertionError expected");
    } catch (final AssertionError e) {
        assertThat(e.getMessage(), containsString("failed in 3 case"));
        assertThat(e.getMessage(), containsString(COLLECTION_NAME_3 + " was expected to be present, but not found"));
        assertThat(e.getMessage(), containsString(DOCUMENT_2 + " was expected in [" + COLLECTION_NAME_2 + "], but is not present"));
        assertThat(e.getMessage(), containsString(DOCUMENT_3 + " was expected in [" + COLLECTION_NAME_3 + "], but is not present"));
    }
}