@Test public void arnoldSchwarzeneggerIsAFilmActor() throws IOException, InterruptedException { Context mockContext = mock(Context.class); pse3mapper.map( new LongWritable(944L), new Text( "<http://rdf.basekb.com/ns/m.0tc7> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>\t<http://rdf.basekb.com/ns/film.actor>."), mockContext); verify(pse3mapper.accepted) .write( new WritableTriple( Node_URI.createURI("http://rdf.basekb.com/ns/m.0tc7"), Node_URI.createURI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), Node_URI.createURI("http://rdf.basekb.com/ns/film.actor")), new LongWritable(1), mockContext); verifyNoMoreInteractions(pse3mapper.accepted); }
@Test public void acceptsAGoodTriple() throws IOException, InterruptedException { Context mockContext = mock(Context.class); pse3mapper.map( new LongWritable(944L), new Text("<http://example.com/A>\t<http://example.com/B>\t<http://example.com/C>."), mockContext); verify(pse3mapper.accepted) .write( new WritableTriple( Node_URI.createURI("http://example.com/A"), Node_URI.createURI("http://example.com/B"), Node_URI.createURI("http://example.com/C")), new LongWritable(1), mockContext); verifyNoMoreInteractions(pse3mapper.accepted); verifyNoMoreInteractions(pse3mapper.rejected); }
@Test public void acceptsARealFreebaseTriple() throws IOException, InterruptedException { Context mockContext = mock(Context.class); pse3mapper.map( new LongWritable(944L), new Text( "<http://rdf.basekb.com/ns/m.06fm3lj>\t<http://rdf.basekb.com/ns/book.written_work.author>\t<http://rdf.basekb.com/ns/m.03qp7yf>."), mockContext); verify(pse3mapper.accepted) .write( new WritableTriple( Node_URI.createURI("http://rdf.basekb.com/ns/m.06fm3lj"), Node_URI.createURI("http://rdf.basekb.com/ns/book.written_work.author"), Node_URI.createURI("http://rdf.basekb.com/ns/m.03qp7yf")), new LongWritable(1), mockContext); verifyNoMoreInteractions(pse3mapper.accepted); }
/** * Builds the predicate and object of a data type definition like [] rr:dataType xsd:date * * @param type a Node_URI object containing the type resource URI * @return a PredicateAndObject object containing the predicate (rr:dataType) and the object (e.g. * xsd:string) of the rr:dataType expression */ private PredicateAndObject buildDataTypePredAndObj(Node_URI type) { Property rrDataTypePredicate = ResourceFactory.createProperty(rrNamespace, "dataType"); // FIXME: there must be a better way of converting Node_URI to Resource Resource rrDataTypeObject = ResourceFactory.createResource(type.toString()); PredicateAndObject rrDataType = new PredicateAndObject(rrDataTypePredicate, rrDataTypeObject); return rrDataType; }
@Test public void rejects$Escapes() throws IOException, InterruptedException { Context mockContext = mock(Context.class); pse3mapper.map( new LongWritable(944L), new Text( "<http://rdf.basekb.com/ns/m.0tc7> <http://rdf.basekb.com/ns/common.topic.topic_equivalent_webpage> <http://www.ranker.com/review/arnold-schwarzenegger$002F493404> ."), mockContext); verify(pse3mapper.accepted) .write( new WritableTriple( Node_URI.createURI("http://rdf.basekb.com/ns/m.0tc7"), Node_URI.createURI( "http://rdf.basekb.com/ns/common.topic.topic_equivalent_webpage"), Node_URI.createURI("http://www.ranker.com/review/arnold-schwarzenegger/493404")), new LongWritable(1), mockContext); verifyNoMoreInteractions(pse3mapper.accepted); }