Package org.dbunit
Class DefaultExpectedDataSetAndVerifyTableDefinitionVerifier
java.lang.Object
org.dbunit.DefaultExpectedDataSetAndVerifyTableDefinitionVerifier
- All Implemented Interfaces:
ExpectedDataSetAndVerifyTableDefinitionVerifier
public class DefaultExpectedDataSetAndVerifyTableDefinitionVerifier
extends Object
implements ExpectedDataSetAndVerifyTableDefinitionVerifier
Default implementation for
ExpectedDataSetAndVerifyTableDefinitionVerifier which logs the
mismatches and fails the test when an expected table does not have a
VerifyTableDefinition.
Can disable failing the test on mismatch with property
DatabaseConfig.PROPERTY_ALLOW_VERIFYTABLEDEFINITION_EXPECTEDTABLE_COUNT_MISMATCH
, setting it to false.
Can change the implementation by extending this class or implementing
ExpectedDataSetAndVerifyTableDefinitionVerifier and calling
DefaultPrepAndExpectedTestCase.setExpectedDataSetAndVerifyTableDefinitionVerifier(org.dbunit.ExpectedDataSetAndVerifyTableDefinitionVerifier)
.- Author:
- Jeff Jensen
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidfailOnMismatch(DatabaseConfig config, Set<String> mismatchCountTables) Fails with aDataSetExceptionlisting the mismatched tables, unlessDatabaseConfig.PROPERTY_ALLOW_VERIFYTABLEDEFINITION_EXPECTEDTABLE_COUNT_MISMATCHis set.protected voidhandleCountMismatch(VerifyTableDefinition[] verifyTableDefinitions, String[] expectedTableNames, DatabaseConfig config) Logs the mismatch and delegates tofailOnMismatch(DatabaseConfig, Set).protected booleanisVerifyTableDefinitionsHasTable(VerifyTableDefinition[] verifyTableDefinitions, String expectedTableName) Returns whether the given expected table name has a correspondingVerifyTableDefinition.makeMismatchedTableNamesList(VerifyTableDefinition[] verifyTableDefinitions, String[] expectedTableNames) Returns the expected table names that have no correspondingVerifyTableDefinition.voidverify(VerifyTableDefinition[] verifyTableDefinitions, IDataSet expectedDataSet, DatabaseConfig config) VerifyVerifyTableDefinitions and expectedDataSet configurations agree.
-
Constructor Details
-
DefaultExpectedDataSetAndVerifyTableDefinitionVerifier
public DefaultExpectedDataSetAndVerifyTableDefinitionVerifier()
-
-
Method Details
-
verify
public void verify(VerifyTableDefinition[] verifyTableDefinitions, IDataSet expectedDataSet, DatabaseConfig config) throws DataSetException Description copied from interface:ExpectedDataSetAndVerifyTableDefinitionVerifierVerifyVerifyTableDefinitions and expectedDataSet configurations agree.- Specified by:
verifyin interfaceExpectedDataSetAndVerifyTableDefinitionVerifier- Parameters:
verifyTableDefinitions- the table definitions to verify.expectedDataSet- the expected dataset to verify against.config- the database configuration in effect.- Throws:
DataSetException- if the verify table definitions and expected dataset disagree.
-
handleCountMismatch
protected void handleCountMismatch(VerifyTableDefinition[] verifyTableDefinitions, String[] expectedTableNames, DatabaseConfig config) throws DataSetException Logs the mismatch and delegates tofailOnMismatch(DatabaseConfig, Set).- Parameters:
verifyTableDefinitions- the configured table definitions to verify.expectedTableNames- the table names present in the expected dataset.config- the database configuration in effect.- Throws:
DataSetException- if the mismatch is not allowed to be suppressed.
-
makeMismatchedTableNamesList
protected Set<String> makeMismatchedTableNamesList(VerifyTableDefinition[] verifyTableDefinitions, String[] expectedTableNames) Returns the expected table names that have no correspondingVerifyTableDefinition.- Parameters:
verifyTableDefinitions- the configured table definitions to verify.expectedTableNames- the table names present in the expected dataset.- Returns:
- the expected table names with no corresponding
VerifyTableDefinition.
-
isVerifyTableDefinitionsHasTable
protected boolean isVerifyTableDefinitionsHasTable(VerifyTableDefinition[] verifyTableDefinitions, String expectedTableName) Returns whether the given expected table name has a correspondingVerifyTableDefinition.- Parameters:
verifyTableDefinitions- the configured table definitions to search.expectedTableName- the expected table name to look for.- Returns:
trueif a correspondingVerifyTableDefinitionexists.
-
failOnMismatch
protected void failOnMismatch(DatabaseConfig config, Set<String> mismatchCountTables) throws DataSetException Fails with aDataSetExceptionlisting the mismatched tables, unlessDatabaseConfig.PROPERTY_ALLOW_VERIFYTABLEDEFINITION_EXPECTEDTABLE_COUNT_MISMATCHis set.- Parameters:
config- the database configuration in effect.mismatchCountTables- the expected table names with no correspondingVerifyTableDefinition.- Throws:
DataSetException- if the mismatch is not allowed to be suppressed.
-