1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
|
use Test::More;
use Test::RDF 1.10;
use FindBin qw($Bin);
use URI;
use RDF::Trine qw(literal statement iri variable);
use RDF::Trine::Parser;
my $base_uri = 'http://localhost';
my $testdata = $Bin . '/data/basic.ttl';
my $expected = $Bin . '/data/basic-expected.ttl';
use_ok("RDF::Generator::Void");
my $expected_void_model = RDF::Trine::Model->temporary_model;
my $data_model = RDF::Trine::Model->temporary_model;
my $parser = RDF::Trine::Parser->new( 'turtle' );
$parser->parse_file_into_model( $base_uri, $testdata, $data_model );
my $void = RDF::Trine::Namespace->new('http://rdfs.org/ns/void#');
my $xsd = RDF::Trine::Namespace->new('http://www.w3.org/2001/XMLSchema#');
note "No level set";
{
my $void_gen = RDF::Generator::Void->new(dataset_uri => $base_uri . '/dataset',
inmodel => $data_model);
$void_gen->urispace($base_uri);
isa_ok($void_gen, 'RDF::Generator::Void');
my $test_model = $void_gen->generate;
isa_ok($test_model, 'RDF::Trine::Model');
note(RDF::Trine::Serializer::Turtle->new->serialize_model_to_string($test_model));
has_predicate('http://rdfs.org/ns/void#triples', $test_model, 'Has got the triples predicate');
has_predicate('http://rdfs.org/ns/void#entities', $test_model, 'Has got the entities predicate');
has_predicate('http://rdfs.org/ns/void#classPartition', $test_model, 'Has got the classPartition predicate');
pattern_target($test_model);
pattern_ok(statement(iri($base_uri . '/dataset'), $void->propertyPartition, variable('propart')),
statement(variable('propart'), $void->property, iri('http://www.w3.org/2000/01/rdf-schema#label')),
statement(variable('propart'), $void->triples, literal(2, undef, $xsd->integer)),
statement(variable('propart'), $void->distinctObjects, literal(2, undef, $xsd->integer)),
statement(variable('propart'), $void->distinctSubjects, literal(2, undef, $xsd->integer)),
'rdfs:label propertyPartitions OK');
}
note "Level set to 0";
{
my $void_gen = RDF::Generator::Void->new(dataset_uri => $base_uri . '/dataset',
inmodel => $data_model, level => 0);
$void_gen->urispace($base_uri);
isa_ok($void_gen, 'RDF::Generator::Void');
my $test_model = $void_gen->generate;
isa_ok($test_model, 'RDF::Trine::Model');
note(RDF::Trine::Serializer::Turtle->new->serialize_model_to_string($test_model));
has_predicate('http://rdfs.org/ns/void#triples', $test_model, 'Has got the triples predicate');
hasnt_uri('http://rdfs.org/ns/void#entities', $test_model, 'Hasnt got the entities predicate');
hasnt_uri('http://rdfs.org/ns/void#classPartition', $test_model, 'Hasnt got the classPartition predicate');
hasnt_uri('http://rdfs.org/ns/void#propertyPartition', $test_model, 'Hasnt got the propertyPartition predicate');
hasnt_uri('http://rdfs.org/ns/void#distinctObjects', $test_model, 'Hasnt got the distinctObjects predicate');
}
note "Level set to 1";
{
my $void_gen = RDF::Generator::Void->new(dataset_uri => $base_uri . '/dataset',
inmodel => $data_model, level => 1);
$void_gen->urispace($base_uri);
isa_ok($void_gen, 'RDF::Generator::Void');
my $test_model = $void_gen->generate;
isa_ok($test_model, 'RDF::Trine::Model');
note(RDF::Trine::Serializer::Turtle->new->serialize_model_to_string($test_model));
has_predicate('http://rdfs.org/ns/void#triples', $test_model, 'Has got the triples predicate');
has_predicate('http://rdfs.org/ns/void#entities', $test_model, 'Has got the entities predicate');
hasnt_uri('http://rdfs.org/ns/void#classPartition', $test_model, 'Hasnt got the classPartition predicate');
hasnt_uri('http://rdfs.org/ns/void#propertyPartition', $test_model, 'Hasnt got the propertyPartition predicate');
has_predicate('http://rdfs.org/ns/void#distinctObjects', $test_model, 'Has got the distinctObjects predicate');
pattern_target($test_model);
pattern_fail(statement(iri($base_uri . '/dataset'), $void->propertyPartition, variable('propart')),
statement(variable('propart'), $void->property, iri('http://www.w3.org/2000/01/rdf-schema#label')),
statement(variable('propart'), $void->triples, variable('whatever1')),
statement(variable('propart'), $void->distinctObjects, variable('whatever2')),
statement(variable('propart'), $void->distinctSubjects, variable('whatever3')),
'rdfs:label propertyPartitions not present');
}
note "Level set to 2";
{
my $void_gen = RDF::Generator::Void->new(dataset_uri => $base_uri . '/dataset',
inmodel => $data_model, level => 2);
$void_gen->urispace($base_uri);
isa_ok($void_gen, 'RDF::Generator::Void');
my $test_model = $void_gen->generate;
isa_ok($test_model, 'RDF::Trine::Model');
note(RDF::Trine::Serializer::Turtle->new->serialize_model_to_string($test_model));
has_predicate('http://rdfs.org/ns/void#triples', $test_model, 'Has got the triples predicate');
has_predicate('http://rdfs.org/ns/void#entities', $test_model, 'Has got the entities predicate');
has_predicate('http://rdfs.org/ns/void#classPartition', $test_model, 'Has got the classPartition predicate');
pattern_target($test_model);
pattern_ok(statement(iri($base_uri . '/dataset'), $void->propertyPartition, variable('propart')),
statement(variable('propart'), $void->property, iri('http://www.w3.org/2000/01/rdf-schema#label')),
statement(variable('propart'), $void->triples, literal(2, undef, $xsd->integer)),
'rdfs:label propertyPartitions OK');
pattern_fail(statement(iri($base_uri . '/dataset'), $void->propertyPartition, variable('propart')),
statement(variable('propart'), $void->property, iri('http://www.w3.org/2000/01/rdf-schema#label')),
statement(variable('propart'), $void->distinctObjects, variable('whatever1')),
statement(variable('propart'), $void->distinctSubjects, variable('whatever2')),
'rdfs:label propertyPartitions without distinct* not present');
}
note "Level set to 3";
{
my $void_gen = RDF::Generator::Void->new(dataset_uri => $base_uri . '/dataset',
inmodel => $data_model, level => 3);
$void_gen->urispace($base_uri);
isa_ok($void_gen, 'RDF::Generator::Void');
my $test_model = $void_gen->generate;
isa_ok($test_model, 'RDF::Trine::Model');
note(RDF::Trine::Serializer::Turtle->new->serialize_model_to_string($test_model));
has_predicate('http://rdfs.org/ns/void#triples', $test_model, 'Has got the triples predicate');
has_predicate('http://rdfs.org/ns/void#entities', $test_model, 'Has got the entities predicate');
has_predicate('http://rdfs.org/ns/void#classPartition', $test_model, 'Has got the classPartition predicate');
pattern_target($test_model);
pattern_ok(statement(iri($base_uri . '/dataset'), $void->propertyPartition, variable('propart')),
statement(variable('propart'), $void->property, iri('http://www.w3.org/2000/01/rdf-schema#label')),
statement(variable('propart'), $void->triples, literal(2, undef, $xsd->integer)),
statement(variable('propart'), $void->distinctObjects, literal(2, undef, $xsd->integer)),
statement(variable('propart'), $void->distinctSubjects, literal(2, undef, $xsd->integer)),
'rdfs:label propertyPartitions OK');
}
done_testing;
|