public void testIsReified() {
   ReifiedStatement rs = model.createReifiedStatement(aURI, SPO);
   Resource BS = model.createResource(anchor + "BS");
   Property BP = model.createProperty(anchor + "BP");
   RDFNode BO = model.createProperty(anchor + "BO");
   model.add(rs, P, O);
   assertTrue("st should be reified now", SPO.isReified());
   assertTrue("m should have st reified now", model.isReified(SPO));
   assertFalse(
       "this new statement should not be reified", model.createStatement(BS, BP, BO).isReified());
 }
 public void setUp() {
   model = getModel();
   Resource S2 = model.createResource(anchor + "subject2");
   S = model.createResource(anchor + "subject");
   P = model.createProperty(anchor + "predicate");
   O = model.createLiteral(anchor + "object");
   SPO = model.createStatement(S, P, O);
   SPO2 = model.createStatement(S2, P, O);
 }
 public void testQuintetOfQuadlets() {
   Resource rs = model.createResource();
   rs.addProperty(RDF.type, RDF.Statement);
   model.createResource().addProperty(RDF.value, rs);
   rs.addProperty(RDF.subject, model.createResource());
   rs.addProperty(RDF.predicate, model.createProperty("http://example.org/foo"));
   rs.addProperty(RDF.object, model.createResource());
   rs.addProperty(RDF.object, model.createResource());
   StmtIterator it = model.listStatements();
   while (it.hasNext()) {
     Statement s = it.nextStatement();
     assertFalse(s.getObject().equals(s.getSubject()));
   }
 }
Esempio n. 4
0
  /**
   * Check that a predicate for which no shortnames are defined in name map still gets a term
   * binding in the metadata.
   */
  @Test
  public void testTermBindingsCoverAllPredicates() throws URISyntaxException {
    Resource thisPage = ResourceFactory.createResource("elda:thisPage");
    String pageNumber = "1";
    Bindings cc = new Bindings();
    URI reqURI = new URI("");
    //
    EndpointDetails spec =
        new EndpointDetails() {

          @Override
          public boolean isListEndpoint() {
            return true;
          }

          @Override
          public boolean hasParameterBasedContentNegotiation() {
            return false;
          }
        };
    EndpointMetadata em = new EndpointMetadata(spec, thisPage, pageNumber, cc, reqURI);
    //
    PrefixMapping pm =
        PrefixMapping.Factory.create().setNsPrefix("this", "http://example.com/root#");
    Model toScan = ModelIOUtils.modelFromTurtle(":a <http://example.com/root#predicate> :b.");
    toScan.setNsPrefixes(pm);
    Resource predicate = toScan.createProperty("http://example.com/root#predicate");
    Model meta = ModelFactory.createDefaultModel();
    Resource exec = meta.createResource("fake:exec");
    ShortnameService sns = new StandardShortnameService();
    //		APIEndpoint.Request r = new APIEndpoint.Request( new Controls(), reqURI, cc );

    CompleteContext c =
        new CompleteContext(CompleteContext.Mode.PreferPrefixes, sns.asContext(), pm)
            .include(toScan);

    em.addTermBindings(toScan, meta, exec, c);

    @SuppressWarnings("unused")
    Map<String, String> termBindings = c.Do();
    Resource tb = meta.listStatements(null, API.termBinding, Any).nextStatement().getResource();
    assertTrue(meta.contains(tb, API.label, "this_predicate"));
    assertTrue(meta.contains(tb, API.property, predicate));
  }
Esempio n. 5
0
  void runTestAsk(Query query, QueryExecution qe) throws Exception {
    boolean result = qe.execAsk();
    if (results != null) {
      if (results.isBoolean()) {
        boolean b = results.getBooleanResult();
        assertEquals("ASK test results do not match", b, result);
      } else {
        Model resultsAsModel = results.getModel();
        StmtIterator sIter =
            results.getModel().listStatements(null, RDF.type, ResultSetGraphVocab.ResultSet);
        if (!sIter.hasNext()) throw new QueryTestException("Can't find the ASK result");
        Statement s = sIter.nextStatement();
        if (sIter.hasNext()) throw new QueryTestException("Too many result sets in ASK result");
        Resource r = s.getSubject();
        Property p = resultsAsModel.createProperty(ResultSetGraphVocab.getURI() + "boolean");

        boolean x = r.getRequiredProperty(p).getBoolean();
        if (x != result) assertEquals("ASK test results do not match", x, result);
      }
    }
    return;
  }