The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

LRpt::CollEADiff - A module for comparing collection of expectations with a collection of actual data taken from the database.

DESCRIPTION

This class is a part of LRpt library. Object of this class is used to compare a set of expected rows with a set of actual rows from the database. It subclasses LRpt::CollDiff. However, there are some important differences. During that type of comparison only columns which are present in 'expected' collection are compared. If there is a column, which is not present in 'expected' but is present in 'actual', the comparison of a column is skipped.

Since this class inherits from LRpt::CollDiff, in its core it uses the notion of 'before' and 'after' collection. In its interface with the user it uses notions of:

expected collection

Collection of expected rows. When using LRpt::CollDiff functions it is treated as 'before' collection

actual collection

Collection of actual rows. When using LRpt::CollDiff functions it is treated as 'after' collection

The class also use a notion of comparing rules. Comparing rules help to specify what to do, when some expectations are not defined. Sometimes a defualt value may be used. Sometimes the comparison should be terminated (if a value of important column is missing).

METHODS

new

  my $cdiff = LRpt::CollEADiff->new( expected => $exp_coll,
                                     actual   => $act_coll,
                                     key      => $key,
                                     comparing_rules_file => $rules_fname,
                                     comparing_rules      => $rules,
                                     logger_stream => *STREAM );

Constructor. Initializes internal structures. Meaning of parameters:

expected

Reference to a LRpt::Collection object, which contain expectations for rows.

actual

Reference to a LRpt::Collection object, which contain actual rows.

key

Name of a LRpt::Collection key used for rows ordering

comparing_rules_file

Name of the file containing comparing rules. Does not have to be specified if comparing_rules parameter is given.

comparing_rules

Reference to a structure containing comparing rules. Does not have to be specified if comparing_rules_file parameter is given.

logger_stream [optional]

Reference to an output logger stream

init_rules

  $ceadiff->init_rules( comparing_rules       => $cmp_rules,
                        comparing_rules_file  => $cmp_rules_file );

Initializes comparing rules structure. If comparing_rules parameter is given, $cmp_rules should point to a compring rules structure. If comparing_rules_file is given, rules are loaded from the file $cmp_rules_file

compare_rows

  $ceadiff->compare_rows( $key_name );

Compare expected and actual rows, which have the same key value given in $key_value. If a difference is found for any column, 'not_equal' type of difference is reported.

compare_collections

  $ceadiff->compare_collections();

Main public function. Runs the whole comparing machinery.

compare_with_unkeyed_rows

  $ceadiff->compare_with_unkeyed_rows();

Called when keyed comparison is done and there are still some actual rows left. Compares those actual rows with expectation rows, for which key is not defined.

get_unkeyed_coll

  my @unk_colls = $ceadiff->get_unkeyed_coll();

Returns collection of expectation rows, for which not have whole key populated

get_diffs_missing_unkeyed

  my @rows_info = $ceadiff->get_diffs_missing_unkeyed();

Returns information about all expected, 'unkeyed' rows for which there is no actual rows.

add_diff_missing_unkeyed

  $ceadiff->add_diff_missing_unkeyed( $row_info );

Stores information that there is no match for an 'unkeyed' expected row.

set_expectations

  $ceadiff->set_expecations();

Using comparing rules and a set of expectations, creates a set of row, which will be used in further processing as a expected collection

create_exp_row

  my $exp_row = $ceadiff->create_exp_row( $existing_values );

Basing on comparison rules and given expected values, creates a row of expected values.

descr_row_location

  my $loc_str = $ceadiff->descr_row_location( $row );

Creates a string describing a row - collection name and row's key value.

get_expected_row

  my $row = $ceadiff->get_expected_row( $key_value );

Returns expected row with a given key value.

get_actual_row

  my $row = $ceadiff->get_actual_row( $key_value );

Returns actual row with a given key value.

set_log_stream

  $ceadiff->set_log_stream( $fh );

Sets a logging stream.

log_msg

  $ceadiff->log_msg( $message );

Puts a message in the log file.

create_xml_report

  $ceadiff->create_xml_report( $indent );

Creates a report of comparison in XML format. $indent is a number of indentation spaces.

missing_to_xml

  $ceadiff->missing_to_xml( $indent );

converts to XML format report on missing rows. $indent is a number of indentation spaces.

additional_to_xml

  $ceadiff->additional_to_xml( $indent );

converts to XML format report on additional rows. $indent is a number of indentation spaces.

not_equal_to_xml

  $ceadiff->not_equal_to_xml( $indent );

converts to XML format report on not equal rows. $indent is a number of indentation spaces.

xmlize_row

  $ceadiff->xmlize_row( $row, $cols, $indent );

Converts to XML format contents of a given row. $indent is a number of indentation spaces.

xmlize_row_pair

  $ceadiff->xmlize_row_pair( $exp_row, $act_row, $cols, $diff_cols, $indent );

Converts to XML format contents of expected-actual rows. $indent is a number of indentation spaces.

unmatched_to_xml

  $ceadiff->unmatched_to_xml( $indent );

Converts to XML format contents of unmatched rows. $indent is a number of indentation spaces.

SEE ALSO

The project is maintained on Source Forge http://lreport.sourceforge.net. You can find there links to some helpful documentation like tutorial.

AUTHORS

Piotr Kaluski <pkaluski@piotrkaluski.com>

COPYRIGHT

Copyright (c) 2004-2006 Piotr Kaluski. Poland. All rights reserved.

You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file.