RST/Plan.pm untested

filter: Statementstmt 0.0% 0 / 62 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 9 totaltotal 0.0% 0 / 98 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__