Search in sources :

Example 76 with Graph

use of org.apache.jena.graph.Graph in project jena by apache.

the class TestDifference method testAdd.

public void testAdd() {
    Graph l = graphWith("x R y");
    Graph r = graphWith("x R y; x R z");
    Difference diff = new Difference(l, r);
    assertIsomorphic(graphWith(""), diff);
    // case 1: add to the left operand
    diff.add(triple("p S q"));
    assertIsomorphic(graphWith("p S q"), diff);
    assertIsomorphic(graphWith("x R y; p S q"), l);
    assertIsomorphic(graphWith("x R y; x R z"), r);
    // case 2: remove from the right, and add to the left operand
    diff.add(triple("x R z"));
    assertIsomorphic(graphWith("x R z; p S q"), diff);
    assertIsomorphic(graphWith("x R y; x R z; p S q"), l);
    assertIsomorphic(graphWith("x R y"), r);
    // case 3: remove from the right operand
    diff.add(triple("x R y"));
    assertIsomorphic(graphWith("x R y; x R z; p S q"), diff);
    assertIsomorphic(graphWith("x R y; x R z; p S q"), l);
    assertIsomorphic(graphWith(""), r);
}
Also used : Graph(org.apache.jena.graph.Graph) Difference(org.apache.jena.graph.compose.Difference)

Example 77 with Graph

use of org.apache.jena.graph.Graph in project jena by apache.

the class TestDisjointUnion method testRightUnion.

public void testRightUnion() {
    Graph g = graphWith("");
    testSingleComponent(g, new DisjointUnion(Graph.emptyGraph, g));
}
Also used : Graph(org.apache.jena.graph.Graph) DisjointUnion(org.apache.jena.graph.compose.DisjointUnion)

Example 78 with Graph

use of org.apache.jena.graph.Graph in project jena by apache.

the class TestDisjointUnion method testBothComponents.

public void testBothComponents() {
    Graph L = graphWith(""), R = graphWith("");
    Graph du = new DisjointUnion(L, R);
    assertIsomorphic(Graph.emptyGraph, du);
    L.add(triple("x P y"));
    assertIsomorphic(graphWith("x P y"), du);
    R.add(triple("A rdf:type Route"));
    assertIsomorphic(graphWith("x P y; A rdf:type Route"), du);
}
Also used : Graph(org.apache.jena.graph.Graph) DisjointUnion(org.apache.jena.graph.compose.DisjointUnion)

Example 79 with Graph

use of org.apache.jena.graph.Graph in project jena by apache.

the class TestDisjointUnion method testLeftUnion.

public void testLeftUnion() {
    Graph g = graphWith("");
    testSingleComponent(g, new DisjointUnion(g, Graph.emptyGraph));
}
Also used : Graph(org.apache.jena.graph.Graph) DisjointUnion(org.apache.jena.graph.compose.DisjointUnion)

Example 80 with Graph

use of org.apache.jena.graph.Graph in project jena by apache.

the class TestDisjointUnion method testAddLeftOnlyIfNecessary.

public void testAddLeftOnlyIfNecessary() {
    Graph L = graphWith(""), R = graphWith("x R y");
    Graph du = new DisjointUnion(L, R);
    graphAdd(du, "x R y");
    assertEquals(true, L.isEmpty());
    graphAdd(du, " a P b");
    assertIsomorphic(graphWith("a P b"), L);
    assertIsomorphic(graphWith("x R y"), R);
}
Also used : Graph(org.apache.jena.graph.Graph) DisjointUnion(org.apache.jena.graph.compose.DisjointUnion)

Aggregations

Graph (org.apache.jena.graph.Graph)247 Test (org.junit.Test)90 BaseTest (org.apache.jena.atlas.junit.BaseTest)56 Triple (org.apache.jena.graph.Triple)56 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)54 Node (org.apache.jena.graph.Node)46 AbstractTestGraph (org.apache.jena.graph.test.AbstractTestGraph)16 InfGraph (org.apache.jena.reasoner.InfGraph)16 ContractTest (org.xenei.junit.contract.ContractTest)16 Model (org.apache.jena.rdf.model.Model)14 MultiUnion (org.apache.jena.graph.compose.MultiUnion)9 Delta (org.apache.jena.graph.compose.Delta)8 BuilderGraph (org.apache.jena.sparql.sse.builders.BuilderGraph)8 StreamRDF (org.apache.jena.riot.system.StreamRDF)7 PrefixMapping (org.apache.jena.shared.PrefixMapping)7 GraphUnionRead (org.apache.jena.sparql.graph.GraphUnionRead)7 IOException (java.io.IOException)6 Dataset (org.apache.jena.query.Dataset)6 Rule (org.apache.jena.reasoner.rulesys.Rule)6 ConfigTest (org.apache.jena.tdb.ConfigTest)6