| 1 | 1 | ▶ | use v5.20.0; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 2 | package JMAP::Tester::Response::Sentence::Set 0.113; | ||||||||||||
| 3 | # ABSTRACT: the kind of sentence you get in reply to a setFoos call | ||||||||||||
| 4 | |||||||||||||
| 5 | 1 | ▶ | use Moo; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 1 | extends 'JMAP::Tester::Response::Sentence'; | |||||||||||
| 7 | |||||||||||||
| 8 | 1 | ▶ | use experimental 'signatures'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | |||||||||||||
| 10 | 1 | ▶ | use Data::Dumper (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | 1 | ▶ | use JMAP::Tester::Abort 'abort'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 12 | |||||||||||||
| 13 | 1 | ▶ | use namespace::clean; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 14 | |||||||||||||
| 15 | #pod =head1 OVERVIEW | ||||||||||||
| 16 | #pod | ||||||||||||
| 17 | #pod A "Set" sentence is a kind of L<Sentence|JMAP::Tester::Response::Sentence> | ||||||||||||
| 18 | #pod for representing C<foosSet> results. It has convenience methods for getting | ||||||||||||
| 19 | #pod out the data returned in these kinds of sentences. | ||||||||||||
| 20 | #pod | ||||||||||||
| 21 | #pod =method new_state | ||||||||||||
| 22 | #pod | ||||||||||||
| 23 | #pod This returns the C<newState> in the result. | ||||||||||||
| 24 | #pod | ||||||||||||
| 25 | #pod =method old_state | ||||||||||||
| 26 | #pod | ||||||||||||
| 27 | #pod This returns the C<newState> in the result. | ||||||||||||
| 28 | #pod | ||||||||||||
| 29 | #pod =cut | ||||||||||||
| 30 | |||||||||||||
| 31 | 1 | ▶ | sub new_state ($self) { $self->arguments->{newState} } | ||||||||||
|
Subroutine
new_state: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 32 | 1 | ▶ | sub old_state ($self) { $self->arguments->{oldState} } | ||||||||||
|
Subroutine
old_state: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 33 | |||||||||||||
| 34 | #pod =method created | ||||||||||||
| 35 | #pod | ||||||||||||
| 36 | #pod This returns the hashref of data in the C<created> property. | ||||||||||||
| 37 | #pod | ||||||||||||
| 38 | #pod =method created_id | ||||||||||||
| 39 | #pod | ||||||||||||
| 40 | #pod my $id = $set->created_id( $cr_id ); | ||||||||||||
| 41 | #pod | ||||||||||||
| 42 | #pod This returns the id given to the object created for the given creation id. If | ||||||||||||
| 43 | #pod that creation id doesn't correspond to a created object, C<undef> is returned. | ||||||||||||
| 44 | #pod | ||||||||||||
| 45 | #pod =method created_creation_ids | ||||||||||||
| 46 | #pod | ||||||||||||
| 47 | #pod This returns the list of creation ids that were successfully created. Note: | ||||||||||||
| 48 | #pod this returns I<creation ids>, not object ids. | ||||||||||||
| 49 | #pod | ||||||||||||
| 50 | #pod =method created_ids | ||||||||||||
| 51 | #pod | ||||||||||||
| 52 | #pod This returns the list of object ids that were successfully created. | ||||||||||||
| 53 | #pod | ||||||||||||
| 54 | #pod =method not_created_ids | ||||||||||||
| 55 | #pod | ||||||||||||
| 56 | #pod This returns the list of creation ids that were I<not> successfully created. | ||||||||||||
| 57 | #pod | ||||||||||||
| 58 | #pod =method create_errors | ||||||||||||
| 59 | #pod | ||||||||||||
| 60 | #pod This returns a hashref mapping creation ids to error properties. | ||||||||||||
| 61 | #pod | ||||||||||||
| 62 | #pod =method updated_ids | ||||||||||||
| 63 | #pod | ||||||||||||
| 64 | #pod This returns a list of object ids that were successfully updated. | ||||||||||||
| 65 | #pod | ||||||||||||
| 66 | #pod =method not_updated_ids | ||||||||||||
| 67 | #pod | ||||||||||||
| 68 | #pod This returns a list of object ids that were I<not> successfully updated. | ||||||||||||
| 69 | #pod | ||||||||||||
| 70 | #pod =method update_errors | ||||||||||||
| 71 | #pod | ||||||||||||
| 72 | #pod This returns a hashref mapping object ids to error properties. | ||||||||||||
| 73 | #pod | ||||||||||||
| 74 | #pod =method destroyed_ids | ||||||||||||
| 75 | #pod | ||||||||||||
| 76 | #pod This returns a list of object ids that were successfully destroyed. | ||||||||||||
| 77 | #pod | ||||||||||||
| 78 | #pod =method not_destroyed_ids | ||||||||||||
| 79 | #pod | ||||||||||||
| 80 | #pod This returns a list of object ids that were I<not> successfully destroyed. | ||||||||||||
| 81 | #pod | ||||||||||||
| 82 | #pod =method destroy_errors | ||||||||||||
| 83 | #pod | ||||||||||||
| 84 | #pod This returns a hashref mapping object ids to error properties. | ||||||||||||
| 85 | #pod | ||||||||||||
| 86 | #pod =cut | ||||||||||||
| 87 | |||||||||||||
| 88 | 1 | ▶ | sub as_set ($self) { $self } | ||||||||||
|
Subroutine
as_set: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 89 | |||||||||||||
| 90 | 10 | ▶ | sub created ($self) { $self->arguments->{created} // {} } | ||||||||||
|
Subroutine
created: called CC=2 SCAR=6.9
Pod
documented
Condition100%2/2
$self->arguments->{"created"} // {}
MC/DC100%1/1
$self->arguments->{"created"} // {}
$self->arguments->{"created"}
Truth table100%2/2
A
A= $self->arguments->{"created"}
| |||||||||||||
| 91 | |||||||||||||
| 92 | 4 | ▶ | sub created_id ($self, $creation_id) { | ||||||||||
|
Subroutine
created_id: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||
| 93 | 4 | ▶ | return undef unless my $props = $self->created->{$creation_id}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 94 | 2 | return $props->{id}; | |||||||||||
| 95 | } | ||||||||||||
| 96 | |||||||||||||
| 97 | 2 | ▶ | sub created_creation_ids ($self) { | ||||||||||
|
Subroutine
created_creation_ids: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 98 | 2 | keys %{ $self->created } | |||||||||||
| 99 | } | ||||||||||||
| 100 | |||||||||||||
| 101 | 2 | ▶ | sub created_ids ($self) { | ||||||||||
|
Subroutine
created_ids: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 102 | 2 | map {; $_->{id} } values %{ $self->created } | |||||||||||
| 103 | } | ||||||||||||
| 104 | |||||||||||||
| 105 | 3 | ▶ | sub updated_ids ($self) { | ||||||||||
|
Subroutine
updated_ids: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||
| 106 | 3 | ▶ | my $updated = $self->{arguments}{updated} // {}; | ||||||||||
|
Condition50%1/2
$self->{"arguments"}{"updated"} // {}
MC/DC0%0/1
$self->{"arguments"}{"updated"} // {}
$self->{"arguments"}{"updated"}
Truth table50%1/2
A
A= $self->{"arguments"}{"updated"}
| |||||||||||||
| 107 | |||||||||||||
| 108 | 3 | ▶ | if (ref $updated eq 'ARRAY') { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 109 | 1 | return @$updated; | |||||||||||
| 110 | } | ||||||||||||
| 111 | |||||||||||||
| 112 | 2 | return keys %$updated; | |||||||||||
| 113 | } | ||||||||||||
| 114 | |||||||||||||
| 115 | 2 | ▶ | sub updated ($self) { | ||||||||||
|
Subroutine
updated: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||
| 116 | 2 | ▶ | my $updated = $self->{arguments}{updated} // {}; | ||||||||||
|
Condition50%1/2
$self->{"arguments"}{"updated"} // {}
MC/DC0%0/1
$self->{"arguments"}{"updated"} // {}
$self->{"arguments"}{"updated"}
Truth table50%1/2
A
A= $self->{"arguments"}{"updated"}
| |||||||||||||
| 117 | |||||||||||||
| 118 | 2 | ▶ | if (ref $updated eq 'ARRAY') { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 119 | 1 | return { map {; $_ => undef } @$updated }; | |||||||||||
| 120 | } | ||||||||||||
| 121 | |||||||||||||
| 122 | 1 | return $updated; | |||||||||||
| 123 | } | ||||||||||||
| 124 | |||||||||||||
| 125 | 1 | ▶ | sub destroyed_ids ($self) { @{ $self->{arguments}{destroyed} } } | ||||||||||
|
Subroutine
destroyed_ids: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 126 | |||||||||||||
| 127 | # Is this the best API to provide? I dunno, maybe. Usage will tell us whether | ||||||||||||
| 128 | # it's right. -- rjbs, 2016-04-11 | ||||||||||||
| 129 | 1 | ▶ | sub not_created_ids ($self) { keys %{ $self->{arguments}{notCreated} } } | ||||||||||
|
Subroutine
not_created_ids: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 130 | 1 | ▶ | sub not_updated_ids ($self) { keys %{ $self->{arguments}{notUpdated} } } | ||||||||||
|
Subroutine
not_updated_ids: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 131 | 1 | ▶ | sub not_destroyed_ids ($self) { keys %{ $self->{arguments}{notDestroyed} } } | ||||||||||
|
Subroutine
not_destroyed_ids: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 132 | |||||||||||||
| 133 | 8 | ▶ | sub create_errors ($self) { $self->{arguments}{notCreated} // {} } | ||||||||||
|
Subroutine
create_errors: called CC=2 SCAR=6.9
Pod
documented
Condition100%2/2
$self->{"arguments"}{"notCreated"} // {}
MC/DC100%1/1
$self->{"arguments"}{"notCreated"} // {}
$self->{"arguments"}{"notCreated"}
Truth table100%2/2
A
A= $self->{"arguments"}{"notCreated"}
| |||||||||||||
| 134 | 9 | ▶ | sub update_errors ($self) { $self->{arguments}{notUpdated} // {} } | ||||||||||
|
Subroutine
update_errors: called CC=2 SCAR=6.9
Pod
documented
Condition100%2/2
$self->{"arguments"}{"notUpdated"} // {}
MC/DC100%1/1
$self->{"arguments"}{"notUpdated"} // {}
$self->{"arguments"}{"notUpdated"}
Truth table100%2/2
A
A= $self->{"arguments"}{"notUpdated"}
| |||||||||||||
| 135 | 9 | ▶ | sub destroy_errors ($self) { $self->{arguments}{notDestroyed} // {} } | ||||||||||
|
Subroutine
destroy_errors: called CC=2 SCAR=6.9
Pod
documented
Condition100%2/2
$self->{"arguments"}{"notDestroyed"} // {}
MC/DC100%1/1
$self->{"arguments"}{"notDestroyed"} // {}
$self->{"arguments"}{"notDestroyed"}
Truth table100%2/2
A
A= $self->{"arguments"}{"notDestroyed"}
| |||||||||||||
| 136 | |||||||||||||
| 137 | 6 | ▶ | sub assert_no_errors ($self) { | ||||||||||
|
Subroutine
assert_no_errors: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||
| 138 | 6 | my @errors; | |||||||||||
| 139 | 6 | local $Data::Dumper::Terse = 1; | |||||||||||
| 140 | |||||||||||||
| 141 | 6 | ▶ | if (keys %{ $self->create_errors }) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 142 | 0 | push @errors, "notCreated: " . Data::Dumper::Dumper( | |||||||||||
| 143 | $self->_strip_json_types( $self->create_errors ) | ||||||||||||
| 144 | ); | ||||||||||||
| 145 | } | ||||||||||||
| 146 | |||||||||||||
| 147 | 6 | ▶ | if (keys %{ $self->update_errors }) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 148 | 1 | push @errors, "notUpdated: " . Data::Dumper::Dumper( | |||||||||||
| 149 | $self->_strip_json_types( $self->update_errors ) | ||||||||||||
| 150 | ); | ||||||||||||
| 151 | } | ||||||||||||
| 152 | |||||||||||||
| 153 | 6 | ▶ | if (keys %{ $self->destroy_errors }) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 154 | 1 | push @errors, "notDestroyed: " . Data::Dumper::Dumper( | |||||||||||
| 155 | $self->_strip_json_types( $self->destroy_errors ) | ||||||||||||
| 156 | ); | ||||||||||||
| 157 | } | ||||||||||||
| 158 | |||||||||||||
| 159 | 6 | ▶ | return $self unless @errors; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 160 | |||||||||||||
| 161 | 1 | $self->sentence_broker->response->abort( | |||||||||||
| 162 | "errors found in " . $self->name . " sentence", | ||||||||||||
| 163 | \@errors, | ||||||||||||
| 164 | ); | ||||||||||||
| 165 | } | ||||||||||||
| 166 | |||||||||||||
| 167 | 1 | 1; | |||||||||||
| 168 | |||||||||||||
| 169 | __END__ | ||||||||||||