Attean
view release on metacpan or search on metacpan
lib/Test/Attean/TestIDPQueryPlanner.pm view on Meta::CPAN
shift; # model
my $model = $self->model;
my $plan = $self->plan;
my $result = eval { $plan->impl($model, @_) };
if ($@ and not $self->silent) {
die $@;
}
return $result;
}
}
package Test::Attean::TestIDPQueryPlanner 0.033 {
use Moo;
use Data::Dumper;
use Types::Standard qw(HashRef);
use namespace::clean;
extends 'Attean::IDPQueryPlanner';
has 'endpoints' => (is => 'rw', isa => HashRef, default => sub { +{} });
sub register_test_endpoint {
my $self = shift;
my $endpoint = shift;
my $data = shift;
$self->endpoints->{$endpoint} = $data;
}
sub plans_for_algebra {
my $self = shift;
my $algebra = shift;
my $model = shift;
my $active_graphs = shift;
my $default_graphs = shift;
my %args = @_;
my @children = @{ $algebra->children };
my ($child) = $children[0];
if ($algebra->isa('Attean::Algebra::Service')) {
my $endpoint = $algebra->endpoint->value;
# warn "Looking for endpoint $endpoint ...\n";
if (my $data = $self->endpoints->{$endpoint}) {
# warn "... found.\n";
my ($mock_model, $dg) = @$data;
my @plans = $self->plans_for_algebra($child, $mock_model, $active_graphs, $default_graphs, %args);
my @vars = $child->in_scope_variables;
my $silent = $algebra->silent;
my $sparql = sprintf('SELECT * WHERE { %s }', $child->as_sparql);
my $plan = Test::Attean::Plan::TestService->new(
in_scope_variables => \@vars,
plan => shift(@plans),
model => $mock_model,
silent => $silent,
);
return $plan;
} else {
# warn "... not found.\n";
}
}
return $self->SUPER::plans_for_algebra($algebra, $model, $active_graphs, $default_graphs, %args);
}
}
1;
( run in 1.600 second using v1.01-cache-2.11-cpan-98e64b0badf )