SqlDbFeatureExecutor extends AbstractDbFeatureExecutor<IDataSet, IDatabaseConnection> { @Override protected DbFeature<IDatabaseConnection> createVerifyDataAfterFeature(final ExpectedDataSets expectedDataSets) { return (final IDatabaseConnection connection) -> { try { final IDataSet currentDataSet = connection.createDataSet(); final IDataSet expectedDataSet = mergeDataSets(loadDataSets(Arrays.asList(expectedDataSets.value()))); final DataSetComparator dataSetComparator = new DataSetComparator(expectedDataSets.orderBy(), expectedDataSets.excludeColumns(), expectedDataSets.strict(), getColumnFilter(expectedDataSets)); final AssertionErrorCollector errorCollector = new AssertionErrorCollector(); dataSetComparator.compare(currentDataSet, expectedDataSet, errorCollector); errorCollector.report(); } catch (final SQLException | DatabaseUnitException e) { throw new DbFeatureException("Could not execute DB contents verification feature", e); } }; } SqlDbFeatureExecutor(final FeatureResolver featureResolver);   }
@Test public void testVerifyDataAfterFeatureExecution() throws DbFeatureException, SQLException, DataSetException { final IDataSet currentDs = mock(IDataSet.class); when(currentDs.getTableNames()).thenReturn(new String[] {}); when(connection.createDataSet()).thenReturn(currentDs); when(expectedDataSets.strict()).thenReturn(Boolean.FALSE); when(expectedDataSets.value()).thenReturn(new String[] {}); when(expectedDataSets.orderBy()).thenReturn(new String[] {}); when(expectedDataSets.excludeColumns()).thenReturn(new String[] {}); final DbFeature<IDatabaseConnection> feature = featureExecutor.createVerifyDataAfterFeature(expectedDataSets); assertThat(feature, notNullValue()); feature.execute(connection); verify(connection).createDataSet(); verifyNoMoreInteractions(connection); }