Search in sources :

Example 6 with Statement

use of org.apache.jena.rdf.model.Statement in project jena by apache.

the class TestModelEvents method testDeleteStatementIterator.

public void testDeleteStatementIterator() {
    model.register(SL);
    final Statement[] sa = ModelHelper.statements(model, "x R y; a P b; x R y");
    final StmtIterator it = asIterator(sa);
    model.remove(it);
    SL.assertHas(new Object[] { "removeIterator", Arrays.asList(sa) });
}
Also used : StmtIterator(org.apache.jena.rdf.model.StmtIterator) Statement(org.apache.jena.rdf.model.Statement)

Example 7 with Statement

use of org.apache.jena.rdf.model.Statement in project jena by apache.

the class TestModelEvents method testAddStatementIterator.

public void testAddStatementIterator() {
    model.register(SL);
    final Statement[] sa = ModelHelper.statements(model, "x R y; a P b; x R y");
    final StmtIterator it = asIterator(sa);
    model.add(it);
    SL.assertHas(new Object[] { "addIterator", Arrays.asList(sa) });
}
Also used : StmtIterator(org.apache.jena.rdf.model.StmtIterator) Statement(org.apache.jena.rdf.model.Statement)

Example 8 with Statement

use of org.apache.jena.rdf.model.Statement in project jena by apache.

the class SecuredContainerTest method testRemove.

@Test
public void testRemove() {
    final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] { Action.Update, Action.Delete });
    final Statement s = baseModel.listStatements().next();
    try {
        getSecuredContainer().remove(s);
        if (!securityEvaluator.evaluate(perms)) {
            Assert.fail("Should have thrown AccessDeniedException");
        }
    } catch (final AccessDeniedException e) {
        if (securityEvaluator.evaluate(perms)) {
            Assert.fail(String.format("Should not have thrown AccessDeniedException: %s - %s", e, e.getTriple()));
        }
    }
}
Also used : Action(org.apache.jena.permissions.SecurityEvaluator.Action) AccessDeniedException(org.apache.jena.shared.AccessDeniedException) Statement(org.apache.jena.rdf.model.Statement) Test(org.junit.Test)

Example 9 with Statement

use of org.apache.jena.rdf.model.Statement in project jena by apache.

the class AbstractTestModel method testIsEmpty.

public void testIsEmpty() {
    Statement S1 = statement(model, "model rdf:type nonEmpty");
    Statement S2 = statement(model, "pinky rdf:type Pig");
    assertTrue(model.isEmpty());
    model.add(S1);
    assertFalse(model.isEmpty());
    model.add(S2);
    assertFalse(model.isEmpty());
    model.remove(S1);
    assertFalse(model.isEmpty());
    model.remove(S2);
    assertTrue(model.isEmpty());
}
Also used : Statement(org.apache.jena.rdf.model.Statement)

Example 10 with Statement

use of org.apache.jena.rdf.model.Statement in project jena by apache.

the class AbstractTestModel method testToStatement.

public void testToStatement() {
    Triple t = triple("a P b");
    Statement s = model.asStatement(t);
    assertEquals(node("a"), s.getSubject().asNode());
    assertEquals(node("P"), s.getPredicate().asNode());
    assertEquals(node("b"), s.getObject().asNode());
}
Also used : Triple(org.apache.jena.graph.Triple) Statement(org.apache.jena.rdf.model.Statement)

Aggregations

Statement (org.apache.jena.rdf.model.Statement)37 Model (org.apache.jena.rdf.model.Model)17 Resource (org.apache.jena.rdf.model.Resource)14 Test (org.junit.Test)9 StmtIterator (org.apache.jena.rdf.model.StmtIterator)7 ArrayList (java.util.ArrayList)6 BaseTest (org.apache.jena.atlas.junit.BaseTest)6 Triple (org.apache.jena.graph.Triple)6 RDFNode (org.apache.jena.rdf.model.RDFNode)4 Property (org.apache.jena.rdf.model.Property)3 IOException (java.io.IOException)2 Dataset (org.apache.jena.query.Dataset)2 TextIndexException (org.apache.jena.query.text.TextIndexException)2 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 URL (java.net.URL)1 Files.createTempFile (java.nio.file.Files.createTempFile)1 Path (java.nio.file.Path)1