| 1 | 3 | ▶ | use 5.008; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | package Data::Conveyor::App::Test::Stage; | ||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 3 | $Data::Conveyor::App::Test::Stage::VERSION = '1.103130'; | |||||||||||||||||||||||||||||||||||||||||
| 8 | } | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # ABSTRACT: Stage-based conveyor-belt-like ticket handling system | ||||||||||||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use YAML::Active 'Dump'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use String::FlexMatch::Test; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 3 | ▶ | use Test::More; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 3 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 3 | ▶ | use parent 'Class::Scaffold::App::Test::YAMLDriven'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 3 | $Data::Dumper::Indent = 1; | |||||||||||||||||||||||||||||||||||||||||
| 16 | 3 | __PACKAGE__->mk_scalar_accessors( | |||||||||||||||||||||||||||||||||||||||||
| 17 | qw( | ||||||||||||||||||||||||||||||||||||||||||
| 18 | ticket ticket_no stage expected_stage_const | ||||||||||||||||||||||||||||||||||||||||||
| 19 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 3 | ▶ | use constant DEFAULTS => (runs => 2,); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | ▶ | sub expected_stage { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expected_stage: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | my $method = $self->expected_stage_const; | |||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | $self->delegate->$method; | |||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | sub execute_test_def { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute_test_def: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | my ($self, $testname) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | if ($self->should_skip_testname($testname)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | $self->SUPER::execute_test_def($testname); | |||||||||||||||||||||||||||||||||||||||||
| 33 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | $self->make_ticket($testname); | |||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | $self->SUPER::execute_test_def($testname); | |||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | # During the test run it's not really necessary to delete the ticket | ||||||||||||||||||||||||||||||||||||||||||
| 38 | # because we'll rollback anyway, and deleting a ticket is expensive. | ||||||||||||||||||||||||||||||||||||||||||
| 39 | # $self->ticket->delete; | ||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | sub make_ticket { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_ticket: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | my ($self, $testname) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | # No support for phases at this time - we don't need them and Reload() is | ||||||||||||||||||||||||||||||||||||||||||
| 47 | # expensive. | ||||||||||||||||||||||||||||||||||||||||||
| 48 | # $self->test_def($testname, | ||||||||||||||||||||||||||||||||||||||||||
| 49 | # Reload($self->test_def($testname), $self->delegate->YAP_MAKE_TICKET) | ||||||||||||||||||||||||||||||||||||||||||
| 50 | # ); | ||||||||||||||||||||||||||||||||||||||||||
| 51 | my $ticket = | ||||||||||||||||||||||||||||||||||||||||||
| 52 | $self->delegate->make_obj('test_ticket') | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ->make_whole_ticket(%{ $self->test_def($testname)->{make_whole_ticket} }); | |||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | $self->gen_tx_item_ref($ticket->payload); | |||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | $ticket->store_full; | |||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | # Set up some accessors so other methods can refer to them. | ||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | $self->ticket_no($ticket->ticket_no); | |||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | sub gen_tx_item_ref { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
gen_tx_item_ref: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my ($self, $payload) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | for my $payload_tx ($payload->transactions) { | |||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | my $item_spec = $payload_tx->transaction->payload_item; | |||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | next if ref $item_spec; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | if ($item_spec =~ /^(\w+)\.(\d+)$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my ($accessor, $index) = ($1, $2 - 1); | |||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | $payload_tx->transaction->payload_item( | |||||||||||||||||||||||||||||||||||||||||
| 69 | eval "\$payload->$accessor\->[$index]"); | ||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | die $@ if $@; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | unless (ref $payload_tx->transaction->payload_item) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | throw Error::Hierarchy::Internal::CustomMessage( | |||||||||||||||||||||||||||||||||||||||||
| 74 | custom_message => sprintf 'No such payload item [%s]', | ||||||||||||||||||||||||||||||||||||||||||
| 75 | $item_spec, | ||||||||||||||||||||||||||||||||||||||||||
| 76 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | sub make_stage_object { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_stage_object: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | $self->stage($self->delegate->make_stage_object($self->expected_stage, @_)); | |||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | # subclasses can do preparatory things here | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | sub before_stage_hook { } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
before_stage_hook: not called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | sub run_subtest { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_subtest: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | # At this point, set any local configuration the test yaml file might have | ||||||||||||||||||||||||||||||||||||||||||
| 93 | # asked for. | ||||||||||||||||||||||||||||||||||||||||||
| 94 | local %Property::Lookup::Local::opt = ( | ||||||||||||||||||||||||||||||||||||||||||
| 95 | %Property::Lookup::Local::opt, | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | %{ $self->current_test_def->{opt} || {} }, | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->current_test_def->{'opt'} || {}
MC/DC0%0/1
$self->current_test_def->{'opt'} || {}
$self->current_test_def->{'opt'}
Truth table0%0/2
A
A= $self->current_test_def->{'opt'}
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | my $ticket = | |||||||||||||||||||||||||||||||||||||||||
| 99 | $self->delegate->make_obj('ticket', ticket_no => $self->ticket_no); | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | $ticket->open($self->expected_stage); | |||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | $self->before_stage_hook($ticket); | |||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | $self->stage($self->make_stage_object(ticket => $ticket)); | |||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | $self->stage->run; | |||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | $ticket->store if $ticket->rc eq $self->delegate->RC_INTERNAL_ERROR; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | $ticket->close; | |||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | # The ticket that we test our expectations against is a fresh ticket | ||||||||||||||||||||||||||||||||||||||||||
| 108 | # object where we read the ticket we just wrote. Note that we read(), not | ||||||||||||||||||||||||||||||||||||||||||
| 109 | # open() the ticket, because after the stage run, it will still be in | ||||||||||||||||||||||||||||||||||||||||||
| 110 | # an 'active_*' stage, and open() wouldn't find it. | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $self->ticket( | |||||||||||||||||||||||||||||||||||||||||
| 112 | $self->delegate->make_obj('ticket', ticket_no => $self->ticket_no,)); | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | $self->ticket->read; | |||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | $self->test_expectations; | |||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | # To prepare for the next run, reset the ticket to the stage start and an | ||||||||||||||||||||||||||||||||||||||||||
| 117 | # ok status and rc, just as you'd do manually when rerunning the ticket in | ||||||||||||||||||||||||||||||||||||||||||
| 118 | # the regsh. Note that this is the same as would happen in the regsh when | ||||||||||||||||||||||||||||||||||||||||||
| 119 | # given the command 'set_stage -g starten_<stagename>' | ||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | for ($self->ticket) { | |||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | $_->stage->new_start($self->expected_stage); | |||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | $_->status($self->delegate->TS_RUNNING); | |||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | $_->rc($self->delegate->RC_OK); | |||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | $_->close_basic; | |||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | # so subclasses can call SUPER:: | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | sub test_expectations { } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
test_expectations: not called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | sub plan_ticket_expected_container { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
plan_ticket_expected_container: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | my ($self, $test, $run) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my $plan = 2; # rc, status | |||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | # The expected exceptions look like this in the YAML files: | ||||||||||||||||||||||||||||||||||||||||||
| 136 | # | ||||||||||||||||||||||||||||||||||||||||||
| 137 | # exceptions: | ||||||||||||||||||||||||||||||||||||||||||
| 138 | # person: | ||||||||||||||||||||||||||||||||||||||||||
| 139 | # - | ||||||||||||||||||||||||||||||||||||||||||
| 140 | # # expect the following exceptions for the first person | ||||||||||||||||||||||||||||||||||||||||||
| 141 | # - ref: Registry::Exception::Person::InvalidEmail | ||||||||||||||||||||||||||||||||||||||||||
| 142 | # handle: ... | ||||||||||||||||||||||||||||||||||||||||||
| 143 | # email: ... | ||||||||||||||||||||||||||||||||||||||||||
| 144 | # - ref: Registry::Exception::Person::InvalidName | ||||||||||||||||||||||||||||||||||||||||||
| 145 | # handle: ... | ||||||||||||||||||||||||||||||||||||||||||
| 146 | # name ... | ||||||||||||||||||||||||||||||||||||||||||
| 147 | # - | ||||||||||||||||||||||||||||||||||||||||||
| 148 | # # expect the following exceptions for the second person | ||||||||||||||||||||||||||||||||||||||||||
| 149 | # - ref: ... | ||||||||||||||||||||||||||||||||||||||||||
| 150 | # ... | ||||||||||||||||||||||||||||||||||||||||||
| 151 | # domains: | ||||||||||||||||||||||||||||||||||||||||||
| 152 | # - | ||||||||||||||||||||||||||||||||||||||||||
| 153 | # # expect the following exceptions for the first domain | ||||||||||||||||||||||||||||||||||||||||||
| 154 | # - ref: ... | ||||||||||||||||||||||||||||||||||||||||||
| 155 | # ... | ||||||||||||||||||||||||||||||||||||||||||
| 156 | # | ||||||||||||||||||||||||||||||||||||||||||
| 157 | # Usually, we expect two tests per exception per run (one for the | ||||||||||||||||||||||||||||||||||||||||||
| 158 | # exception's type and for for its message). There's a special | ||||||||||||||||||||||||||||||||||||||||||
| 159 | # case that complicates the thing a bit: Some policies actually alter the | ||||||||||||||||||||||||||||||||||||||||||
| 160 | # ticket. For example, if, in a person, we detect an alias name for a | ||||||||||||||||||||||||||||||||||||||||||
| 161 | # country (e.g., 'Oesterreich', which is mapped to the normal name, | ||||||||||||||||||||||||||||||||||||||||||
| 162 | # 'Austria'), the policy actually replaces the country name with the | ||||||||||||||||||||||||||||||||||||||||||
| 163 | # normal name. So the second time around, the country name will be the | ||||||||||||||||||||||||||||||||||||||||||
| 164 | # normal one and no exception is thrown. | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | while (my ($object_type, $spec) = | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | each %{ $test->{expect}{exceptions} || {} }) { | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$test->{'expect'}{'exceptions'} || {}
MC/DC0%0/1
$test->{'expect'}{'exceptions'} || {}
$test->{'expect'}{'exceptions'}
Truth table0%0/2
A
A= $test->{'expect'}{'exceptions'}
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | for my $payload_item (@$spec) { | |||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | for my $exception ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | ref $payload_item eq 'ARRAY' | ||||||||||||||||||||||||||||||||||||||||||
| 170 | ? @$payload_item | ||||||||||||||||||||||||||||||||||||||||||
| 171 | : $payload_item | ||||||||||||||||||||||||||||||||||||||||||
| 172 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | next unless ref($exception) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | next | ||||||||||||||||||||||||||||||||||||||||||
| 175 | if $run > 1 | ||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | && $exception->{ref} =~ /Replace(Fax|Phone)No$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$run > 1 and $exception->{"ref"} =~ /Replace(Fax|Phone)No$/
MC/DC0%0/2
$run > 1 and $exception->{"ref"} =~ /Replace(Fax|Phone)No$/
$run > 1
$exception->{"ref"} =~ /Replace(Fax|Phone)No$/
Truth table0%0/3
A and B
A= $run > 1B= $exception->{"ref"} =~ /Replace(Fax|Phone)No$/
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | $plan += 2; | |||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | $plan; | |||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | sub plan_ticket_tx { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
plan_ticket_tx: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | my ($self, $test) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | exists $test->{expect}{tx}; | |||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | sub check_ticket_rc_status { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_ticket_rc_status: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | is($self->ticket->rc, $self->expect->{rc} || $self->delegate->RC_OK, 'rc'); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->expect->{'rc'} || $self->delegate->RC_OK
MC/DC0%0/2
$self->expect->{'rc'} || $self->delegate->RC_OK
$self->expect->{'rc'}
$self->delegate->RC_OK
Truth table0%0/3
A || B
A= $self->expect->{'rc'}B= $self->delegate->RC_OK
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | is($self->ticket->status, | ||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | $self->expect->{status} || $self->delegate->TS_RUNNING, 'status'); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->expect->{'status'} || $self->delegate->TS_RUNNING
MC/DC0%0/2
$self->expect->{'status'} || $self->delegate->TS_RUNNING
$self->expect->{'status'}
$self->delegate->TS_RUNNING
Truth table0%0/3
A || B
A= $self->expect->{'status'}B= $self->delegate->TS_RUNNING
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | sub check_ticket_tx { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_ticket_tx: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | return unless exists $self->expect->{tx}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | my @tx_status = | ||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | map { $_->transaction->status } $self->ticket->payload->transactions; | |||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | # Dump as YAML on failure, so we see the stringified values, not the value | ||||||||||||||||||||||||||||||||||||||||||
| 203 | # objects. | ||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | ok(eq_array_flex(\@tx_status, $self->expect->{tx}), 'resulting tx status') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | or print Dump \@tx_status; | ||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | sub check_ticket_expected_container { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_ticket_expected_container: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | $self->check_ticket_rc_status($self->ticket); | |||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | for my $object_type ($self->delegate->OT) { | |||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my $item_index = 0; | |||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | for my $payload_item ( | |||||||||||||||||||||||||||||||||||||||||
| 214 | $self->ticket->payload->get_list_for_object_type($object_type)) { | ||||||||||||||||||||||||||||||||||||||||||
| 215 | $self->compare_exceptions( | ||||||||||||||||||||||||||||||||||||||||||
| 216 | $object_type, | ||||||||||||||||||||||||||||||||||||||||||
| 217 | $payload_item, | ||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | ( $self->expect->{exceptions}{$object_type}[ $item_index++ ] | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->expect->{'exceptions'}{$object_type}[$item_index++] || []
MC/DC0%0/1
$self->expect->{'exceptions'}{$object_type}[$item_index++] || []
$self->expect->{'exceptions'}{$object_type}[$item_index++]
Truth table0%0/2
A
A= $self->expect->{'exceptions'}{$object_type}[$item_index++]
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | || [] | ||||||||||||||||||||||||||||||||||||||||||
| 220 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 221 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 224 | $self->compare_exceptions( | ||||||||||||||||||||||||||||||||||||||||||
| 225 | 'common', | ||||||||||||||||||||||||||||||||||||||||||
| 226 | $self->ticket->payload->common, | ||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | ($self->expect->{exceptions}{common} || []), | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->expect->{'exceptions'}{'common'} || []
MC/DC0%0/1
$self->expect->{'exceptions'}{'common'} || []
$self->expect->{'exceptions'}{'common'}
Truth table0%0/2
A
A= $self->expect->{'exceptions'}{'common'}
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | sub compare_exceptions { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compare_exceptions: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | my ($self, $object_type, $payload_item, $expected_exceptions) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | my $exception_index = 0; | |||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | return unless ref $expected_exceptions eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | # Impose an order on the exceptions, namely the way they stringify for the | ||||||||||||||||||||||||||||||||||||||||||
| 237 | # benefit of the yaml test files. | ||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | for my $got_exception (sort { "$a" cmp "$b" } | |||||||||||||||||||||||||||||||||||||||||
| 239 | $payload_item->exception_container->items) { | ||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | unless (exists $expected_exceptions->[$exception_index]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | fail( | |||||||||||||||||||||||||||||||||||||||||
| 242 | sprintf | ||||||||||||||||||||||||||||||||||||||||||
| 243 | "Unexpected exception on [%s] of type [%s], message [%s]", | ||||||||||||||||||||||||||||||||||||||||||
| 244 | $object_type, ref($got_exception), $got_exception | ||||||||||||||||||||||||||||||||||||||||||
| 245 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | print Dumper $got_exception; | |||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | # Ok, we did expect an exception, so check whether it's the | ||||||||||||||||||||||||||||||||||||||||||
| 251 | # right one. | ||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | my $expected_exception = $expected_exceptions->[$exception_index]; | |||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | isa_ok($got_exception, $expected_exception->{ref}); | |||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | # FIXME | ||||||||||||||||||||||||||||||||||||||||||
| 256 | # hack for Class::Value::Exception::InvalidValue, which has a property | ||||||||||||||||||||||||||||||||||||||||||
| 257 | # called 'ref'. But the test definition of the expected exception also | ||||||||||||||||||||||||||||||||||||||||||
| 258 | # has a 'ref' property to indicate what type of exception we expect. | ||||||||||||||||||||||||||||||||||||||||||
| 259 | # So the test def's 'p_ref' is munged to become the 'ref' of | ||||||||||||||||||||||||||||||||||||||||||
| 260 | # Class::Value::Exception::InvalidValue. Solution: call the exception | ||||||||||||||||||||||||||||||||||||||||||
| 261 | # property something else. | ||||||||||||||||||||||||||||||||||||||||||
| 262 | # | ||||||||||||||||||||||||||||||||||||||||||
| 263 | # Example: | ||||||||||||||||||||||||||||||||||||||||||
| 264 | # | ||||||||||||||||||||||||||||||||||||||||||
| 265 | # exceptions: | ||||||||||||||||||||||||||||||||||||||||||
| 266 | # person: | ||||||||||||||||||||||||||||||||||||||||||
| 267 | # - | ||||||||||||||||||||||||||||||||||||||||||
| 268 | # - | ||||||||||||||||||||||||||||||||||||||||||
| 269 | # ref: Class::Value::Exception::InvalidValue | ||||||||||||||||||||||||||||||||||||||||||
| 270 | # p_ref: Registry::NICAT::Value::Person::Handle | ||||||||||||||||||||||||||||||||||||||||||
| 271 | # value: *HANDLE | ||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | my %expected_properties = %$expected_exception; | |||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | delete $expected_properties{ref}; | |||||||||||||||||||||||||||||||||||||||||
| 274 | $expected_properties{ref} = delete $expected_properties{p_ref} | ||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | if $expected_properties{p_ref}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | is_deeply_flex(scalar($got_exception->properties_as_hash), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | \%expected_properties, 'exception properties') | ||||||||||||||||||||||||||||||||||||||||||
| 278 | or print Dumper $got_exception; | ||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | # Following the same logic as commented in | ||||||||||||||||||||||||||||||||||||||||||
| 281 | # plan_ticket_expected_container(), eliminate those exceptions | ||||||||||||||||||||||||||||||||||||||||||
| 282 | # from the expected list after the first run that would only | ||||||||||||||||||||||||||||||||||||||||||
| 283 | # occur in the first run, i.e. Replace* exceptions. That way, | ||||||||||||||||||||||||||||||||||||||||||
| 284 | # we won't even see them in the list of expected exceptions in | ||||||||||||||||||||||||||||||||||||||||||
| 285 | # the second and subsequent runs. | ||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | if ( $self->run_num == 1 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$self->run_num == 1 and defined $expected_exception and $expected_exception->{"ref"} =~ /Replace(Fax|Phone)No$/
$self->run_num == 1 and defined $expected_exception
MC/DC0%0/3
$self->run_num == 1 and defined $expected_exception and $expected_exception->{"ref"} =~ /Replace(Fax|Phone)No$/
$self->run_num == 1
defined $expected_exception
$expected_exception->{"ref"} =~ /Replace(Fax|Phone)No$/
Truth table0%0/4
A and B and C
A= $self->run_num == 1B= defined $expected_exceptionC= $expected_exception->{"ref"} =~ /Replace(Fax|Phone)No$/
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | && defined($expected_exception) | ||||||||||||||||||||||||||||||||||||||||||
| 288 | && $expected_exception->{ref} =~ /Replace(Fax|Phone)No$/) { | ||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | splice @$expected_exceptions, $exception_index, 1; | |||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||
| 291 | } continue { | ||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | $exception_index++; | |||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | # Now we check whether there are further expected exceptions - | ||||||||||||||||||||||||||||||||||||||||||
| 296 | # this would be ones we expected but didn't get. | ||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | while (defined(my $extra = $expected_exceptions->[ $exception_index++ ])) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | fail(sprintf "Didn't see expected exception of type [%s]", | ||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | $extra->{ref},); | |||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | sub is_deep_set { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_deep_set: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | my ($self, $got, $expect, $test_name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | $got = [ sort _by_dump @{ $got || [] } ]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$got || []
MC/DC0%0/1
$got || []
$got
Truth table0%0/2
A
A= $got
| |||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | $expect = [ sort _by_dump @{ $expect || [] } ]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$expect || []
MC/DC0%0/1
$expect || []
$expect
Truth table0%0/2
A
A= $expect
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | is_deeply_flex($got, $expect, $test_name) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | or print YAML::Active::Dump($got, ForceBlock => 0), | ||||||||||||||||||||||||||||||||||||||||||
| 309 | YAML::Active::Dump($expect, ForceBlock => 0); | ||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | sub _by_dump { YAML::Active::Dump($a) cmp YAML::Active::Dump($b) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_by_dump: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||
| 315 | __END__ | ||||||||||||||||||||||||||||||||||||||||||