| 1 | 2 | ▶ | use v5.36; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | ▶ | use feature 'class'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | no warnings 'experimental::class'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | class Azure::SDK::AppConfiguration::CreateSnapshotOperation { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Time::HiRes (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | field $snapshot :param :reader; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | field $poll_operation :param; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | field $get_snapshot :param; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | field $clock :param = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | field $sleeper :param = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | field $completed :reader = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 3 | ▶ | ADJUST { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=12 SCAR=28.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 3 | ▶ | croak 'CreateSnapshotOperation requires a ConfigurationSnapshot' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($snapshot) and $snapshot->isa("Azure::SDK::AppConfiguration::ConfigurationSnapshot")
MC/DC0%0/2
builtin::blessed($snapshot) and $snapshot->isa("Azure::SDK::AppConfiguration::ConfigurationSnapshot")
builtin::blessed($snapshot)
$snapshot->isa("Azure::SDK::AppConfiguration::ConfigurationSnapshot")
Truth table33%1/3
A and B
A= builtin::blessed($snapshot)B= $snapshot->isa("Azure::SDK::AppConfiguration::ConfigurationSnapshot")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | unless blessed($snapshot) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | && $snapshot->isa('Azure::SDK::AppConfiguration::ConfigurationSnapshot'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 3 | ▶ | croak 'CreateSnapshotOperation poll_operation must be a code reference' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | unless ref $poll_operation eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 3 | ▶ | croak 'CreateSnapshotOperation get_snapshot must be a code reference' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | unless ref $get_snapshot eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 3 | ▶ | croak 'CreateSnapshotOperation clock must be a code reference' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $clock and ref $clock ne "CODE"
MC/DC0%0/2
defined $clock and ref $clock ne "CODE"
defined $clock
ref $clock ne "CODE"
Truth table66%2/3
A and B
A= defined $clockB= ref $clock ne "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | if defined $clock && ref $clock ne 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 3 | ▶ | croak 'CreateSnapshotOperation sleeper must be a code reference' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $sleeper and ref $sleeper ne "CODE"
MC/DC0%0/2
defined $sleeper and ref $sleeper ne "CODE"
defined $sleeper
ref $sleeper ne "CODE"
Truth table66%2/3
A and B
A= defined $sleeperB= ref $sleeper ne "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | if defined $sleeper && ref $sleeper ne 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 3 | ▶ | $clock //= sub { Time::HiRes::time() }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$clock //= sub {
&Time::HiRes::time();
}
MC/DC0%0/2
$clock //= sub {
&Time::HiRes::time();
}
$clock
sub {
&Time::HiRes::time();
}
Truth table66%2/3
A //= B
A= $clockB= sub {
&Time::HiRes::time();
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 3 | ▶ | $sleeper //= sub ($seconds) { Time::HiRes::sleep($seconds) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$sleeper //= sub ($seconds) {
&Time::HiRes::sleep($seconds);
}
MC/DC0%0/2
$sleeper //= sub ($seconds) {
&Time::HiRes::sleep($seconds);
}
$sleeper
sub ($seconds) {
&Time::HiRes::sleep($seconds);
}
Truth table66%2/3
A //= B
A= $sleeperB= sub ($seconds) {
&Time::HiRes::sleep($seconds);
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 3 | ▶ | $completed = 1 if $snapshot->status eq 'ready'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 3 | ▶ | method update_status () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update_status: called CC=12 SCAR=27.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 3 | ▶ | return $snapshot if $completed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 3 | my $result = $poll_operation->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 3 | ▶ | croak 'Snapshot operation poll result must be a hash reference' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | unless ref $result eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 3 | ▶ | my $status = $result->{status} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$result->{"status"} // ""
MC/DC0%0/1
$result->{"status"} // ""
$result->{"status"}
Truth table50%1/2
A
A= $result->{"status"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 3 | ▶ | if (lc($status) eq 'succeeded') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 1 | $snapshot = $get_snapshot->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | $completed = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 1 | return $snapshot; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 2 | ▶ | if (lc($status) eq 'failed' || lc($status) eq 'canceled') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
lc $status eq "failed" or lc $status eq "canceled"
MC/DC50%1/2
lc $status eq "failed" or lc $status eq "canceled"
lc $status eq "failed"
lc $status eq "canceled"
Truth table66%2/3
A or B
A= lc $status eq "failed"B= lc $status eq "canceled"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | ▶ | my $error = ref $result->{error} eq 'HASH' ? $result->{error} : {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | my $canceled = lc($status) eq 'canceled'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 1 | require Azure::SDK::Core::Error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | Azure::SDK::Core::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | message => $error->{message} // ($canceled | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | ? 'App Configuration snapshot creation was canceled' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | : 'App Configuration snapshot creation failed'), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 1 | ▶ | code => $error->{code} // ($canceled ? 'Canceled' : undef), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition50%2/4
$error->{"message"} // ($canceled ? "App Configuration snapshot creation was canceled" : "App Configuration snapshot creation failed")
$error->{"code"} // ($canceled ? "Canceled" : undef)
MC/DC0%0/1
$error->{"message"} // ($canceled ? "App Configuration snapshot creation was canceled" : "App Configuration snapshot creation failed")
$error->{"message"}
MC/DC0%0/1
$error->{"code"} // ($canceled ? "Canceled" : undef)
$error->{"code"}
Truth table50%1/2
A
A= $error->{"message"}
Truth table50%1/2
A
A= $error->{"code"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | )->throw; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 1 | return $snapshot; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 2 | ▶ | method wait_for_completion (%options) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
wait_for_completion: called CC=17 SCAR=33.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 2 | my %allowed = map { $_ => 1 } qw(poll_interval timeout); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 2 | my @unknown = sort grep { !$allowed{$_} } keys %options; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 2 | ▶ | croak 'Unknown snapshot wait option(s): ' . join(', ', @unknown) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | if @unknown; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 2 | ▶ | my $poll_interval = $options{poll_interval} // 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$options{"poll_interval"} // 1
MC/DC0%0/1
$options{"poll_interval"} // 1
$options{"poll_interval"}
Truth table50%1/2
A
A= $options{"poll_interval"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 2 | ▶ | my $timeout = $options{timeout} // 60; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$options{"timeout"} // 60
MC/DC0%0/1
$options{"timeout"} // 60
$options{"timeout"}
Truth table50%1/2
A
A= $options{"timeout"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 2 | ▶ | croak 'Snapshot poll_interval must be a non-negative number' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $poll_interval and not ref $poll_interval and $poll_interval =~ /\A(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)\z/u
defined $poll_interval and not ref $poll_interval
MC/DC0%0/3
defined $poll_interval and not ref $poll_interval and $poll_interval =~ /\A(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)\z/u
defined $poll_interval
not ref $poll_interval
$poll_interval =~ /\A(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)\z/u
Truth table25%1/4
A and not(B) and C
A= defined $poll_intervalB= not ref $poll_intervalC= $poll_interval =~ /\A(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)\z/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | unless defined $poll_interval && !ref $poll_interval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | && $poll_interval =~ /\A(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 2 | ▶ | croak 'Snapshot timeout must be a positive number' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
defined $timeout and not ref $timeout and $timeout =~ /\A(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)\z/u and $timeout > 0
defined $timeout and not ref $timeout and $timeout =~ /\A(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)\z/u
defined $timeout and not ref $timeout
MC/DC0%0/4
defined $timeout and not ref $timeout and $timeout =~ /\A(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)\z/u and $timeout > 0
defined $timeout
not ref $timeout
$timeout =~ /\A(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)\z/u
$timeout > 0
Truth table20%1/5
A and not(B) and C and D
A= defined $timeoutB= not ref $timeoutC= $timeout =~ /\A(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)\z/uD= $timeout > 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | unless defined $timeout && !ref $timeout | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | && $timeout =~ /\A(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+)\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | && $timeout > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 2 | my $deadline = $clock->() + $timeout; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 2 | ▶ | while (!$completed) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 3 | ▶ | croak 'App Configuration snapshot creation timed out' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | if $clock->() >= $deadline; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 2 | $self->update_status; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 2 | ▶ | last if $completed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | my $remaining = $deadline - $clock->(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | ▶ | croak 'App Configuration snapshot creation timed out' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | if $remaining <= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 1 | ▶ | my $delay = $poll_interval < $remaining | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | ? $poll_interval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | : $remaining; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | ▶ | $sleeper->($delay) if $delay > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 1 | return $snapshot; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||