RST/Plan.pm untested

filter: Statementstmt 0.0% 0 / 62 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 9 totaltotal 0.0% 0 / 96 CC 6 SCAR 14.7
CC
6
Cov
0%
suites
6.0
cases
6.0
inputs
6.0
CRAP 4.4
1 package ICANN::RST::Plan;
2 # ABSTRACT: an object representing an RST test plan.
3 use base qw(ICANN::RST::Base);
4 use GraphViz2;
5 use strict;
6  
7 sub name { $_[0]->{'Name'} }
8 sub description { ICANN::RST::Text->new($_[0]->{'Description'}) }
9 sub oteOnly { $_[0]->{'OTE-Only'} }
10  
11 sub suites {
12 my $self = shift;
13  
14 my %suites;
15  
16 foreach my $suite ($self->spec->suites) {
17 foreach my $id (@{$self->{'Test-Suites'}}) {
18 $suites{$suite->id} = $suite if ($id eq $suite->id && !defined($suites{$suite->id}));
19 }
20 }
21  
22 return sort { $a->order <=> $b->order } values(%suites);
23 }
24  
25 sub cases {
26 my $self = shift;
27  
28 my %cases;
29  
30 foreach my $suite ($self->suites) {
31 foreach my $case ($suite->cases) {
32 $cases{$case->id} = $case unless (defined($cases{$case->id}));
33 }
34 }
35  
36 return sort { $a->id cmp $b->id } values(%cases);
37 }
38  
39 sub inputs {
40 my $self = shift;
41  
42 my %inputs;
43  
44 foreach my $suite ($self->suites) {
45 foreach my $input ($suite->inputs) {
46 $inputs{$input->id} = $input unless (defined($inputs{$input->id}));
47 }
48 }
49  
50 return sort { $a->id cmp $b->id } values(%inputs);
51 }
52  
53 sub resources {
54 my $self = shift;
55  
56 my %resources;
57  
58 foreach my $suite ($self->suites) {
59 foreach my $resource ($suite->resources) {
60 $resources{$resource->id} = $resource unless (defined($resources{$resource->id}));
61 }
62 }
63  
64 return sort { $a->id cmp $b->id } values(%resources);
65 }
66  
67 sub errors {
68 my $self = shift;
69  
70 my %errors;
71  
72 foreach my $suite ($self->suites) {
73 foreach my $error ($suite->errors) {
74 $errors{$error->id} = $error unless (defined($errors{$error->id}));
75 }
76 }
77  
78 return sort { $a->id cmp $b->id } values(%errors);
79 }
80  
81 sub graph {
82 my $self = shift;
83  
84 my $graph = ICANN::RST::Graph->new;
85  
86 $graph->add_node(
87 'name' => 'START',
88 'shape' => 'box',
89 );
90  
91 foreach my $suite ($self->suites) {
92 $graph->add_node(
93 'name' => $suite->id,
94 'shape' => 'box',
95 );
96  
97 $graph->add_edge(
98 'from' => 'START',
99 'to' => $suite->id,
100 );
101  
102 $graph->push_subgraph(
103 'name' => 'cluster_'.$suite->id,
104 'graph' => {'bgcolor' => '#F8F8F8'},
105 );
106  
107 my @cases = $suite->cases;
108  
109 $graph->add_edge(
110 'from' => $suite->id,
111 'to' => $cases[0]->id,
112 );
113  
114 $graph->add_cases(@cases);
115  
116 $graph->pop_subgraph;
117 }
118  
119 return $graph;
120 }
121  
122 1;
123  
124 __END__
125  
126 =pod
127  
128 =encoding UTF-8
129  
130 =head1 NAME
131  
132 ICANN::RST::Plan - an object representing an RST test plan.
133  
134 =head1 VERSION
135  
136 version 0.03
137  
138 =head1 DESCRIPTION
139  
140 This class inherits from L<ICANN::RST::Base> (so it has the C<id()>,
141 C<order()> and C<spec()> methods).
142  
143 =head1 METHODS
144  
145 =head2 name()
146  
147 The name of the plan.
148  
149 =head2 description()
150  
151 A L<ICANN::RST::Text> object containing the long textual description of the
152 plan.
153  
154 =head2 suites()
155  
156 A list of L<ICANN::RST::Suite> objects used by this plan.
157  
158 =head2 cases()
159  
160 A list of L<ICANN::RST::Case> objects used by the suites used by this plan.
161  
162 =head2 inputs()
163  
164 A list of L<ICANN::RST::Inputs> objects used by the test cases used by the
165 suites used by this plan.
166  
167 =head2 resources()
168  
169 A list of L<ICANN::RST::Resource> objects relevant to this plan.
170  
171 =head2 errors()
172  
173 A list of L<ICANN::RST::Error> objects which may be produced by this plan.
174  
175 =head2 graph()
176  
177 Returns a L<ICANN::RST::Graph> object representing the sequence diagram for this
178 plan.
179  
180 =head2 oteOnly()
181  
182 Returns a boolean indicating whether this plan is only available in the OT&E
183 environment.
184  
185 =head1 AUTHOR
186  
187 Gavin Brown <gavin.brown@icann.org>
188  
189 =head1 COPYRIGHT AND LICENSE
190  
191 This software is copyright (c) 2025 by Internet Corporation for Assigned Names and Number (ICANN).
192  
193 This is free software; you can redistribute it and/or modify it under
194 the same terms as the Perl 5 programming language system itself.
195  
196 =cut