Package org.ontoware.rdf2go.model.node

Examples of org.ontoware.rdf2go.model.node.BlankNode


   * Class under test for void addStatement(Object, URI, Object) and
   * removeStatement(Object, URI, Object)
   */
  @Test
  public void testAddRemoveStatementURIObjectURIObject() throws Exception {
    BlankNode blankNodeSubject = this.model.createBlankNode();
    BlankNode blankNodeObject = this.model.createBlankNode();
   
    this.model.addStatement(blankNodeSubject, predicate, blankNodeObject);
    ClosableIterator<? extends Statement> sit = this.model.findStatements(blankNodeSubject,
            predicate, blankNodeObject);
    assertTrue(sit.hasNext());
View Full Code Here


   * 'org.ontoware.rdf2go.Model.getStatementWithLiteralAndNoLanguageTag(Object,
   * URI, String)'
   */
  @Test
  public void testGetStatementWithLiteralAndNoLanguageTagObjectURIString() throws Exception {
    BlankNode blankNodeSubject1 = this.model.createBlankNode();
    BlankNode blankNodeSubject2 = this.model.createBlankNode();
    this.model.addStatement(blankNodeSubject1, predicate, "Test");
    this.model.addStatement(blankNodeSubject2, predicate, "Test", "DE");
   
    ClosableIterator<? extends Statement> sit = this.model.findStatements(Variable.ANY,
            predicate, Variable.ANY);
View Full Code Here

   */
  @Test
  public void testSparqlConstruct() throws Exception {
    String query = "PREFIX \t:\t<test://test/>\n"
            + "CONSTRUCT { ?s ?p \"Test2\" } WHERE { ?s ?p \"Test2\" }";
    BlankNode bNode = this.model.createBlankNode();
    this.model.addStatement(subject, predicate, "Test1");
    this.model.addStatement(subject, predicate, "Test2");
    this.model.addStatement(bNode, predicate, "Test2");
    ClosableIterator<? extends Statement> iter = this.model.sparqlConstruct(query).iterator();
   
View Full Code Here

 
  @Test
  public void testSelectQuery() throws Exception {
    String query = "PREFIX \t:\t<test://test/>\n" + "SELECT  ?s ?p \n"
            + "WHERE { ?s ?p \"Test2\" }";
    BlankNode bNode = this.model.createBlankNode();
    this.model.addStatement(subject, predicate, "Test1");
    this.model.addStatement(subject, predicate, "Test2");
    this.model.addStatement(bNode, predicate, "Test2");
    QueryResultTable result = this.model.sparqlSelect(query);
    ClosableIterator<QueryRow> it = result.iterator();
    assertTrue(it.hasNext());
    QueryRow row = it.next();
    assertTrue(result.getVariables().size() == 2);
    assertEquals(predicate, row.getValue("p"));
    assertTrue(subject.equals(row.getValue("s")) || bNode.equals(row.getValue("s")));
    row = it.next();
    assertEquals(predicate, row.getValue("p"));
    assertTrue(subject.equals(row.getValue("s")) || bNode.equals(row.getValue("s")));
    it.close();
  }
View Full Code Here

 
  /** test {@link ReificationSupport} */
  @Test
  public void testAddReificationOf() {
    Statement stmt = this.model.createStatement(a, b, c);
    BlankNode blankNode = this.model.addReificationOf(stmt);
    assertTrue(this.model.contains(blankNode, RDF.subject, a));
    assertTrue(this.model.contains(blankNode, RDF.predicate, b));
    assertTrue(this.model.contains(blankNode, RDF.object, c));
    assertTrue(this.model.contains(blankNode, RDF.type, RDF.Statement));
   
View Full Code Here

  }
 
  @Test
  public void testGetAllReificationsOf() {
    Statement s = this.model.createStatement(a, b, c);
    BlankNode reificationBlankNode = this.model.addReificationOf(s);
   
    Collection<Resource> reifications = this.model.getAllReificationsOf(s);
    assertTrue(reifications.contains(reificationBlankNode));
    assertEquals(1, reifications.size());
  }
View Full Code Here

    assertEquals(1, this.model.countStatements(this.model.createTriplePattern(subject,
            predicate, object)));
  }
 
  public void testCreateBlankNode() {
    BlankNode node = this.model.createBlankNode();
    assertEquals(node, node.asBlankNode());
  }
View Full Code Here

    assertEquals(c, uri);
  }
 
  public void testDeleteReification() {
    Statement stmt = this.model.createStatement(a, b, c);
    BlankNode blankNode = this.model.addReificationOf(stmt);
    assertTrue(this.model.contains(blankNode, RDF.subject, a));
    assertTrue(this.model.contains(blankNode, RDF.predicate, b));
    assertTrue(this.model.contains(blankNode, RDF.object, c));
    assertTrue(this.model.contains(blankNode, RDF.type, RDF.Statement));
    this.model.deleteReification(blankNode);
View Full Code Here

  }
 
  /* fast, no need to override */
  @Override
  public BlankNode addReificationOf(Statement statement) {
    BlankNode bnode = createBlankNode();
    return (BlankNode)addReificationOf(statement, bnode);
  }
View Full Code Here

 
  /** test {@link ReificationSupport} */
  @Test
  public void testReification() {
    Statement stmt = this.modelset.createStatement(a, b, c);
    BlankNode blankNode = this.modelset.addReificationOf(stmt);
    assertTrue(this.modelset.contains(this.modelset.createStatement(blankNode, RDF.subject, a)));
    assertTrue(this.modelset.contains(this.modelset
            .createStatement(blankNode, RDF.predicate, b)));
    assertTrue(this.modelset.contains(this.modelset.createStatement(blankNode, RDF.object, c)));
    assertTrue(this.modelset.contains(this.modelset.createStatement(blankNode, RDF.type,
View Full Code Here

TOP

Related Classes of org.ontoware.rdf2go.model.node.BlankNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.