Conveyor/Test/Ticket.pm

filter: Statementstmt 37.2% 19 / 51 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 14 MC/DCmcdc 0.0% 0 / 9 Subroutinesub 77.7% 7 / 9 Podpod 100% 2 / 2 totaltotal 27.1% 28 / 103 CC 16 SCAR 46.3
CC
16
Cov
23%
make_whole_ticket
182.0
gen_temp_ticket_no
20.0
BEGIN
1.0
CRAP 102.2
↑ Summary Conveyor/Control/File.pm »
1 1 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Data::Conveyor::Test::Ticket;
6 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 $Data::Conveyor::Test::Ticket::VERSION = '1.103130';
8 }
9 # ABSTRACT: Stage-based conveyor-belt-like ticket handling system
10  
11 # Utilities for writing tests pertaining to tickets.
12 1 ▶use Error::Hierarchy::Util 'assert_defined';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use parent 'Class::Scaffold::Storable';
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use constant TST_EMAIL => 'fh@univie.ac.at';
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 0 ▶sub make_whole_ticket {
Subroutine make_whole_ticket: not called CC=13 SCAR=52.0
Pod documented
17 0 my $self = shift;
18 0 ▶ my %args = @_ == 1 ? %{ $_[0] } : @_;
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 0 0 0
19 0 assert_defined $self->delegate, 'called without delegate.';
20 0 our $cnt;
21 0 $cnt++;
22 my $ticket_args = {
23 $self->delegate->DEFAULT_TICKET_PROPERTIES,
24 ticket_no => $args{ticket_no}
25 || $self->gen_temp_ticket_no(suffix => $cnt),
26 type => $self->delegate->TT_PERSCREATE,
27 origin => $self->delegate->OR_TEST,
28 cltid => $self->gen_temp_ticket_no(suffix => $cnt),
29 0 ▶ %{ $args{ticket} },
Condition0%0/3
$args{'ticket_no'} || $self->gen_temp_ticket_no('suffix', $Data::Conveyor::Test::Ticket::cnt)
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{'ticket_no'} || $self->gen_temp_ticket_no('suffix', $Data::Conveyor::Test::Ticket::cnt)
$args{'ticket_no'} $self->gen_temp_ticket_no('suffix', $Data::Conveyor::Test::Ticket::cnt)
Truth table0%0/3
A || B
A= $args{'ticket_no'}B= $self->gen_temp_ticket_no('suffix', $Data::Conveyor::Test::Ticket::cnt)
ABresult
1X1
011
000
30 };
31 0 my $ticket = $self->delegate->make_obj('ticket', %$ticket_args);
32 0 ▶ if ($args{facets}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"facets"}) 0 0 0
33  
34 0 ▶ while (my ($key, $value) = each %{ $args{facets} }) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$args{"facets"};}) 0 0 0
35 0 $ticket->facets->$key($value);
36 }
37 }
38 0 ▶ if ($args{default_rc}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"default_rc"}) 0 0 0
39 0 $ticket->set_default_rc($args{default_rc});
40 }
41 0 ▶ if ($args{default_status}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"default_status"}) 0 0 0
42 0 $ticket->set_default_status($args{default_status});
43 }
44 0 ▶ if (exists $args{payload} && exists $args{payload}{transactions}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{"payload"} and exists $args{"payload"}{"transactions"}) 0 0 0
Condition0%0/3
exists $args{"payload"} and exists $args{"payload"}{"transactions"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $args{"payload"} and exists $args{"payload"}{"transactions"}
exists $args{"payload"} exists $args{"payload"}{"transactions"}
Truth table0%0/3
A and B
A= exists $args{"payload"}B= exists $args{"payload"}{"transactions"}
ABresult
0X0
100
111
45 0 for my $payload_tx ($args{payload}->transactions) {
46 0 my $item_spec = $payload_tx->transaction->payload_item;
47 0 ▶ next if ref $item_spec;
Branch: 1 branch
BranchTrueFalseTotal
if ref $item_spec 0 0 0
48 0 ▶ if ($item_spec =~ /^(\w+)\.(\d+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($item_spec =~ /^(\w+)\.(\d+)$/) 0 0 0
49 0 my ($accessor, $index) = ($1, $2 - 1);
50 next
51 0 ▶ unless $payload_tx->transaction->status eq
Branch: 1 branch
BranchTrueFalseTotal
unless $payload_tx->transaction->status eq $self->delegate->TXS_ERROR 0 0 0
52 $self->delegate->TXS_ERROR;
53 0 $args{payload}->$accessor->[$index]
54 ->exception_container->record(
55 'Class::Value::Contact::Exception::Email',
56 email => 'exception set by make_whole_ticket',
57 is_optional => 1,
58 );
59 }
60 }
61 }
62 0 $ticket->payload($args{payload});
63 0 $ticket;
64 }
65  
66 0 ▶sub gen_temp_ticket_no {
Subroutine gen_temp_ticket_no: not called CC=4 SCAR=30.0
Pod documented
67 0 my $self = shift;
68 0 my %args = @_;
69  
70 # Make sure the pid has a maxlen of 5 digits and is zero-padded.
71 # Also the suffix has to be a number and has a maxlen of 4, also
72 # zero-padded.
73 0 ▶ our $temp_ticket_no_prefix ||= '200101010101';
Condition0%0/2
our $temp_ticket_no_prefix ||= "200101010101"
l!l
00
MC/DC0%0/1
our $temp_ticket_no_prefix ||= "200101010101"
our $temp_ticket_no_prefix
Truth table0%0/2
A
A= our $temp_ticket_no_prefix
Aresult
11
00
74 0 ▶ $args{prefix} ||= $temp_ticket_no_prefix++;
Condition0%0/3
$args{"prefix"} ||= $Data::Conveyor::Test::Ticket::temp_ticket_no_prefix++
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{"prefix"} ||= $Data::Conveyor::Test::Ticket::temp_ticket_no_prefix++
$args{"prefix"} $Data::Conveyor::Test::Ticket::temp_ticket_no_prefix++
Truth table0%0/3
A ||= B
A= $args{"prefix"}B= $Data::Conveyor::Test::Ticket::temp_ticket_no_prefix++
ABresult
1X1
011
000
75 sprintf "%s.%05d%04d", $args{prefix}, substr($$, -5),
76 0 ▶ substr($args{suffix} || int(rand 10000), -4);
Condition0%0/3
$args{'suffix'} || int rand 10000
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{'suffix'} || int rand 10000
$args{'suffix'} int rand 10000
Truth table0%0/3
A || B
A= $args{'suffix'}B= int rand 10000
ABresult
1X1
011
000
77 }
78 1 1;
79  
80  
81 __END__
↑ Summary Conveyor/Control/File.pm »