line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Paws::Net::FileMockCaller; |
2
|
4
|
|
|
4
|
|
6896
|
use Moose; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
28
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
with 'Paws::Net::RetryCallerRole', 'Paws::Net::CallerRole'; |
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
28155
|
use File::Slurper qw(read_text write_text); |
|
4
|
|
|
|
|
9513
|
|
|
4
|
|
|
|
|
248
|
|
7
|
4
|
|
|
4
|
|
27
|
use JSON::MaybeXS; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
204
|
|
8
|
4
|
|
|
4
|
|
26
|
use Moose::Util::TypeConstraints; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
37
|
|
9
|
4
|
|
|
4
|
|
10400
|
use Path::Tiny; |
|
4
|
|
|
|
|
7956
|
|
|
4
|
|
|
|
|
2559
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has file => (is => 'rw', isa => 'Str', trigger => \&_set_file); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has real_caller => ( |
14
|
|
|
|
|
|
|
is => 'ro', |
15
|
|
|
|
|
|
|
does => 'Paws::Net::CallerRole', |
16
|
|
|
|
|
|
|
default => sub { |
17
|
|
|
|
|
|
|
require Paws::Net::Caller; |
18
|
|
|
|
|
|
|
Paws::Net::Caller->new; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub _set_file { |
23
|
90
|
|
|
90
|
|
26290
|
my $self = shift; |
24
|
90
|
|
|
|
|
2790
|
$self->_clear_file_contents; |
25
|
90
|
|
|
|
|
2650
|
$self->_clear_method; |
26
|
90
|
|
|
|
|
2571
|
$self->_clear_service; |
27
|
90
|
|
|
|
|
2425
|
$self->_clear_params; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has file_contents => ( |
31
|
|
|
|
|
|
|
is => 'ro', |
32
|
|
|
|
|
|
|
isa => 'HashRef', |
33
|
|
|
|
|
|
|
lazy => 1, |
34
|
|
|
|
|
|
|
clearer => '_clear_file_contents', |
35
|
|
|
|
|
|
|
default => sub { |
36
|
|
|
|
|
|
|
my $self = shift; |
37
|
|
|
|
|
|
|
my $content = read_text($self->file); |
38
|
|
|
|
|
|
|
my $hash = $self->_encoder->decode($content); |
39
|
|
|
|
|
|
|
return $hash; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
has service => ( |
44
|
|
|
|
|
|
|
is => 'ro', |
45
|
|
|
|
|
|
|
isa => 'Str', |
46
|
|
|
|
|
|
|
clearer => '_clear_service', |
47
|
|
|
|
|
|
|
lazy => 1, |
48
|
|
|
|
|
|
|
default => sub { shift->file_contents->{ request }->{ service } } |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
has method => ( |
51
|
|
|
|
|
|
|
is => 'ro', |
52
|
|
|
|
|
|
|
isa => 'Str', |
53
|
|
|
|
|
|
|
clearer => '_clear_method', |
54
|
|
|
|
|
|
|
lazy => 1, |
55
|
|
|
|
|
|
|
default => sub { shift->file_contents->{ request }->{ call } } |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
has params => ( |
58
|
|
|
|
|
|
|
is => 'ro', |
59
|
|
|
|
|
|
|
isa => 'HashRef', |
60
|
|
|
|
|
|
|
clearer => '_clear_params', |
61
|
|
|
|
|
|
|
lazy => 1, |
62
|
|
|
|
|
|
|
default => sub { shift->file_contents->{ request }->{ params } } |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
has _encoder => (is => 'ro', default => sub { JSON::MaybeXS->new(canonical => 1) }); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub send_request { |
68
|
90
|
|
|
90
|
0
|
260
|
my ($self, $service, $call_object) = @_; |
69
|
|
|
|
|
|
|
|
70
|
90
|
|
|
|
|
2195
|
my $actual_call = $self->_encoder->encode($service->to_hash($call_object)); |
71
|
90
|
|
|
|
|
2255
|
my $recorded_call = $self->_encoder->encode($self->params); |
72
|
|
|
|
|
|
|
|
73
|
90
|
50
|
|
|
|
300
|
if ($actual_call ne $recorded_call) { |
74
|
0
|
|
|
|
|
0
|
warn "CALL: $actual_call"; |
75
|
0
|
|
|
|
|
0
|
warn "RECORDED: $recorded_call"; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
0
|
Paws::Exception->throw( |
78
|
|
|
|
|
|
|
request_id => '', |
79
|
|
|
|
|
|
|
code => 'ReplayInvalid', |
80
|
|
|
|
|
|
|
message => 'The calling parameters and the parameters used to generate the call are not equal' |
81
|
|
|
|
|
|
|
) |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
90
|
|
|
|
|
2231
|
my $response = $self->file_contents; |
85
|
90
|
|
|
|
|
710
|
return ($response->{response}{status}, $response->{response}{content}, $response->{response}{headers}); |
86
|
|
|
|
|
|
|
}; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub caller_to_response { |
89
|
29
|
|
|
29
|
0
|
105
|
my ($self, $service, $call_object, $status, $content, $headers) = @_; |
90
|
|
|
|
|
|
|
|
91
|
29
|
|
|
|
|
725
|
return $self->real_caller->caller_to_response($service, $call_object, $status, $content, $headers); |
92
|
|
|
|
|
|
|
}; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |