06.05 - Asserts

'dataset.dbunit' does 'contain' 'dataset.dbunit'

What: Asserts that the first dataset contains the second one. 
ASSERT {dataset1<Res:dataset.dbunit>} DOES contain THE {dataset2<Res:dataset.dbunit>} [USING [{<Res:filter.dbunit>}],[{<Res:conf.dbunit.ppk>}] ]

VERIFY {dataset1<Res:dataset.dbunit>} DOES contain THE {dataset2<Res:dataset.dbunit>} [USING [{<Res:filter.dbunit>}],[{<Res:conf.dbunit.ppk>}] ]
Note: For differences between ASSERT and VERIFY assertion mode see this page this page

Input:
  • dataset1<Res:dataset.dbunit>: The name of the resource which references the first DbUnit dataset (Resource of category dataset.dbunit).
  • dataset2<Res:dataset.dbunit>: The name of the resource which references the second DbUnit dataset (Resource of category dataset.dbunit).
  • <Res:filter.dbunit> (Optional): This resource contains a filter DbUnit (Resource of category filter.dbunit)
  • <Res:conf.dbunit.ppk> (Optional): The name of the resource which references a configuration file to define the pseudo primary keys. (Resource of category conf.dbunit.ppk)

Example:

LOAD path/to/dataset1.xml AS dataset1_file
CONVERT dataset1_file TO xml (structured) AS dataset1_xml
CONVERT dataset1_xml TO dataset.dbunit (dataset) AS dataset1_dbu

LOAD path/to/dataset1.xml AS dataset2_file
CONVERT dataset2_file TO xml (structured) AS dataset2_xml
CONVERT dataset2_xml TO dataset.dbunit (dataset) AS dataset2_dbu

// Get the pseudo primary keys
LOAD path/to/my_ppk.properties AS ppk_file
CONVERT ppk_file TO properties (structured) AS ppk_properties
CONVERT ppk_properties TO conf.dbunit.ppk (from.properties) AS ppk_dbu

// Load the DbUnit filter
LOAD path/to/filter-name.xml AS filter_file
CONVERT filter_file TO filter.dbunit AS filter_dbu

// Compare the two datasets
ASSERT dataset1_dbu DOES contain THE dataset2_dbu USING ppk_dbu,filter_dbu
Remarks:
  • During the assertion, if the first dataset contains primary keys they are used for the assertion else if the second dataset contains primary keys, those one are used for the assertion.
  • If for a given table, a primary key and a pseudo primary key are defined, pseudo primary key overrides the primary key.
  • If for a given table a pseudo primary key is defined with one or several columns excluded of the assertion by the intermediary of a DbUnit filter, the command failes.


'dataset.dbunit' is 'equal' 'dataset.dbunit'

What: Asserts that the first dataset is equal to the second one. (same number of tables, for each table same number of lines / columns and same data)
ASSERT {dataset1<Res:dataset.dbunit>} IS equal THE {dataset2<Res:dataset.dbunit>} [USING [{<Res:filter.dbunit>}],[{<Res:conf.dbunit.ppk>}] ]

VERIFY {dataset1<Res:dataset.dbunit>} IS equal THE {dataset2<Res:dataset.dbunit>} [USING [{<Res:filter.dbunit>}],[{<Res:conf.dbunit.ppk>}] ]
Note: For differences between ASSERT and VERIFY assertion mode see this page this page

Input:
  • dataset1<Res:dataset.dbunit>: The name of the resource which references the first DbUnit dataset.(Resource of category dataset.dbunit).
  • dataset2<Res:dataset.dbunit>: The name of the resource which references the second DbUnit dataset.(Resource of category dataset.dbunit).
  • <Res:filter.dbunit> (Optional): This resource contains a filter DbUnit (Resource of category filter.dbunit).
  • <Res:conf.dbunit.ppk> (Optional): The name of the resource which references a configuration file to define the pseudo primary keys.(Resource of category conf.dbunit.ppk).

Example:

LOAD path/to/dataset1.xml AS dataset1_file
CONVERT dataset1_file TO xml (structured) AS dataset1_xml
CONVERT dataset1_xml TO dataset.dbunit (dataset) AS dataset1_dbu

LOAD path/to/dataset1.xml AS dataset2_file
CONVERT dataset2_file TO xml (structured) AS dataset2_xml
CONVERT dataset2_xml TO dataset.dbunit (dataset) AS dataset2_dbu

// Get the pseudo primary keys
LOAD path/to/my_ppk.properties AS ppk_file
CONVERT ppk_file TO properties (structured) AS ppk_properties
CONVERT ppk_properties TO conf.dbunit.ppk (from.properties) AS ppk_dbu

// Load the DbUnit filter
LOAD path/to/filter-name.xml AS filter_file
CONVERT filter_file TO filter.dbunit AS filter_dbu

// Compare the two datasets
ASSERT dataset1_dbu IS equal THE dataset2_dbu USING ppk_dbu,filter_dbu
Remarks :
  • During the assertion, if the first dataset contains primary keys they are used for the assertion else if the second dataset contains primary keys, those one are used for the assertion.
  • If for a given table, a primary key and a pseudo primary key are defined, pseudo primary key overloads the primary key.
  • If for a given table a pseudo primary key is defined with one or several columns excluded of the assertion by the intermediary of a DbUnit filter, the command failes.