class DataSetComparator {

    public void compare(final IDataSet currentDataSet, final IDataSet expectedDataSet, final AssertionErrorCollector errorCollector)
            throws DatabaseUnitException {
        if (expectedDataSet.getTableNames().length == 0) {
            shouldBeEmpty(currentDataSet, errorCollector);
        } else {
            compareContent(currentDataSet, expectedDataSet, errorCollector);
        }
    }

}

class DataSetComparatorTest {

    private static final String TABLE_1_NAME;
    private static final int TABLE_1_ENTRIES;
    private static final Column TABLE_1_COLUMN_1;
    private static final Column TABLE_1_COLUMN_2;
    private static final String TABLE_2_NAME;
    private static final int TABLE_2_ENTRIES;
    private static final Column TABLE_2_COLUMN_1;
    private static final Column TABLE_2_COLUMN_2;
    private static final Column TABLE_2_COLUMN_3;
    private static final String TABLE_3_NAME;
    private static final int TABLE_3_ENTRIES;
    private static final Column TABLE_3_COLUMN_1;
    private static final Column TABLE_3_COLUMN_2;
    private static final Column TABLE_3_COLUMN_3;
    private static final Column TABLE_3_COLUMN_4;
    private static final Column TABLE_4_COLUMN_1;
    private static final Column TABLE_4_COLUMN_2;
    @Mock
    private IDataSet currentDataSet;
    @Mock
    private IDataSet expectedDataSet;
    @Mock
    private ITable table1;
    @Mock
    private ITable table2;
    @Mock
    private ITable table3;
    @Mock
    private ITable table4;
    @Mock
    private ITableMetaData table1MetaData;
    @Mock
    private ITableMetaData table2MetaData;
    @Mock
    private ITableMetaData table3MetaData;
    @Mock
    private ITableMetaData table4MetaData;
    private AssertionErrorCollector errorCollector;

    @Test
    public void testExpectedDataSetIsASubsetOfCurrentDataSetUsingNotStringMode() throws Exception {

        // GIVEN
        final String[] orderBy = new String[] {};
        final String[] toExclude = new String[] {};
        final Set<Class<? extends IColumnFilter>> columnFilters = Collections.emptySet();
        final DataSetComparator comparator = new DataSetComparator(orderBy, toExclude, false, columnFilters);

        when(expectedDataSet.getTableNames()).thenReturn(new String[] {
                TABLE_2_NAME
        });
        when(expectedDataSet.getTable(any(String.class))).thenAnswer((final InvocationOnMock invocation) -> {
            final String tableName = (String) invocation.getArguments()[0];
            if (tableName == TABLE_2_NAME) {
                return table2;
            } else {
                throw new NoSuchTableException(tableName);
            }
        });

        when(currentDataSet.getTableNames()).thenReturn(new String[] {
                TABLE_1_NAME, TABLE_2_NAME
        });
        when(currentDataSet.getTable(any(String.class))).thenAnswer((final InvocationOnMock invocation) -> {
            final String tableName = (String) invocation.getArguments()[0];
            if (tableName == TABLE_1_NAME) {
                return table1;
            } else if (tableName == TABLE_2_NAME) {
                return table2;
            } else {
                throw new NoSuchTableException(tableName);
            }
        });

        // WHEN
        comparator.compare(currentDataSet, expectedDataSet, errorCollector);

        // THEN
        assertThat(errorCollector.amountOfErrors(), equalTo(0));

        errorCollector.report();
    }

}