Source

p5-moosex-semantic / t / rdf_metabuilder / from_foaf.t

use Test::More tests=>4;
use Test::Moose;
use RDF::Trine::Namespace qw(rdf);
use Data::Dumper;
use MooseX::Semantic::Test qw(ser ser_dump diff_models);
use MooseX::Semantic::Test::Person;
use MooseX::Semantic::MetaBuilder;
use MooseX::Semantic::Test::MetaPerson;

my $x = MooseX::Semantic::Test::MetaPerson->new(
    firstName => 'mister x',
    lastName => 'X',
);
my $p = MooseX::Semantic::Test::MetaPerson->new(
    firstName => 'Jim',
    lastName => 'Powers',
    knows => [ $x ],
);
# warn Dumper $p->knows->[0];
ok($p->meta->get_attribute('firstName'), 'Attribute "firstName" was added from RDF');
is($p->firstName, 'Jim' );
isa_ok($p->knows->[0], 'MooseX::Semantic::Test::MetaPerson', '"knows" is multi-valued object attribute');
is($p->knows->[0]->firstName, 'mister x');




# # my $base_uri = 'http://myapp/';
# my $foaf = RDF::Trine::Namespace->new('http://xmlns.com/foaf/0.1/');
# my $ont_foaf = RDF::Trine::Model->temporary_model;
# RDF::Trine::Parser->parse_file_into_model(
#     "http://example.org/",
#     't/data/ontologies/foaf.rdf',
#     $ont_foaf,
# );
# warn Dumper (
#     MooseX::Semantic::MetaBuilder->_build_attributes_for(
#         $ont_foaf, 
#         $foaf->Person,
#         {
#             $foaf->Person => 'MooseX::Semantic::Test::FoafPerson',
#         }
#     )
# );
# warn Dumper ser_dump($ont_foaf);