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

    // 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> collection1Documents = Arrays.asList(DOCUMENT_1);
    final Iterator<Document> colleciton1DocumentsIt = collection1Documents.iterator();
    final MongoCursor<Document> collection1DocumentIterator = mock(MongoCursor.class);
    when(collection1DocumentIterator.hasNext()).thenAnswer((final InvocationOnMock invocation) -> colleciton1DocumentsIt.hasNext());
    when(collection1DocumentIterator.next()).thenAnswer((final InvocationOnMock invocation) -> colleciton1DocumentsIt.next());
    doAnswer((final InvocationOnMock invocation) -> {
        final Consumer<Document> c = (Consumer<Document>) invocation.getArguments()[0];
        for (final Document doc : collection1Documents) {
            c.accept(doc);
        }
        return null;
    }).when(collection1DocumentIterator).forEachRemaining(any(Consumer.class));
    final FindIterable<Document> collection1Iterable = mock(FindIterable.class);
    when(collection1Iterable.iterator()).thenReturn(collection1DocumentIterator);
    final MongoCollection<Document> collection1 = mock(MongoCollection.class);
    when(collection1.count()).thenReturn(1l);
    when(collection1.find(any(Document.class))).thenReturn(collection1Iterable);
    when(collection1.find()).thenReturn(collection1Iterable);
    when(mongoDatabase.getCollection(eq(COLLECTION_NAME_1))).thenReturn(collection1);
    final List<Document> collection2Documents = Arrays.asList(DOCUMENT_2);
    final Iterator<Document> colleciton2DocumentsIt = collection2Documents.iterator();
    final MongoCursor<Document> collection2DocumentIterator = mock(MongoCursor.class);
    when(collection2DocumentIterator.hasNext()).thenAnswer((final InvocationOnMock invocation) -> colleciton2DocumentsIt.hasNext());
    when(collection2DocumentIterator.next()).thenAnswer((final InvocationOnMock invocation) -> colleciton2DocumentsIt.next());
    doAnswer((final InvocationOnMock invocation) -> {
        final Consumer<Document> c = (Consumer<Document>) invocation.getArguments()[0];
        for (final Document doc : collection2Documents) {
            c.accept(doc);
        }
        return null;
    }).when(collection2DocumentIterator).forEachRemaining(any(Consumer.class));
    final FindIterable<Document> collection2Iterable = mock(FindIterable.class);
    when(collection2Iterable.iterator()).thenReturn(collection2DocumentIterator);
    final MongoCollection<Document> collection2 = mock(MongoCollection.class);
    when(collection1.count()).thenReturn(1l);
    when(collection1.find(any(Document.class))).thenReturn(collection2Iterable);
    when(collection1.find()).thenReturn(collection2Iterable);
    when(mongoDatabase.getCollection(eq(COLLECTION_NAME_2))).thenReturn(collection2);
    final String[] toExclude = new String[] {};
    final Document expectedDataSet = new Document().append(COLLECTION_NAME_1, Arrays.asList(DOCUMENT_1));
    final DataSetComparator comparator = new DataSetComparator(toExclude, false);
    // WHEN
    comparator.compare(mongoDatabase, expectedDataSet, errorCollector);
    // THEN
    assertThat(errorCollector.amountOfErrors(), equalTo(0));
    errorCollector.report();
}