Search in sources :

Example 21 with Predicate

use of com.inova8.intelligentgraph.model.Predicate in project com.inova8.intelligentgraph by peterjohnlawrence.

the class PathPatternQueryExpressionTests method test_28.

/**
 * Test 28.
 */
@Test
@Order(28)
void test_28() {
    try {
        PathElement element = PathParser.parsePathPattern(repositoryContext, "(:Attribute@:density  |:density)");
        // Query.assertEqualsWOSpaces
        assertEquals("Union\r\n" + "   Join\r\n" + "      Join\r\n" + "         Union\r\n" + "            StatementPattern\r\n" + "               Variable (name=r1)\r\n" + "               Variable (name=subject1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#subject)\r\n" + "               Variable (name=n0)\r\n" + "            StatementPattern\r\n" + "               Variable (name=n0)\r\n" + "               Variable (name=isSubjectOf1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#subject)\r\n" + "               Variable (name=r1)\r\n" + "         Union\r\n" + "            StatementPattern\r\n" + "               Variable (name=r1)\r\n" + "               Variable (name=property1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate)\r\n" + "               Variable (name=p_n0_n1_alt_L, value=http://default/density)\r\n" + "            StatementPattern\r\n" + "               Variable (name=p_n0_n1_alt_L, value=http://default/density)\r\n" + "               Variable (name=isPropertyOf1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate)\r\n" + "               Variable (name=r1)\r\n" + "      Union\r\n" + "         StatementPattern\r\n" + "            Variable (name=r1)\r\n" + "            Variable (name=object1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#object)\r\n" + "            Variable (name=n1)\r\n" + "         StatementPattern\r\n" + "            Variable (name=n1)\r\n" + "            Variable (name=isObjectOf1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#object)\r\n" + "            Variable (name=r1)\r\n" + "   StatementPattern\r\n" + "      Variable (name=n0)\r\n" + "      Variable (name=p_n0_n1_alt_LR, value=http://default/density)\r\n" + "      Variable (name=n1)\r\n" + "", element.pathPatternQuery().toString());
    } catch (Exception e) {
        assertEquals("", e.getMessage());
    }
}
Also used : PathElement(com.inova8.pathql.element.PathElement) RecognitionException(org.antlr.v4.runtime.RecognitionException) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 22 with Predicate

use of com.inova8.intelligentgraph.model.Predicate in project com.inova8.intelligentgraph by peterjohnlawrence.

the class PathPatternQueryExpressionTests method test_12.

/**
 * Test 12.
 */
@Test
@Order(12)
void test_12() {
    try {
        PathElement element = PathParser.parsePathPattern(repositoryContext, ":Location@:appearsOn[eq id:Calc2Graph1]#");
        assertEquals("Join\r\n" + "   Join\r\n" + "      StatementPattern\r\n" + "         Variable (name=r1)\r\n" + "         Variable (name=subject1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#subject)\r\n" + "         Variable (name=n0)\r\n" + "      StatementPattern\r\n" + "         Variable (name=r1)\r\n" + "         Variable (name=property1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate)\r\n" + "         Variable (name=p_n0_n1, value=http://default/appearsOn)\r\n" + "   StatementPattern\r\n" + "      Variable (name=r1)\r\n" + "      Variable (name=object1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#object)\r\n" + "      Variable (name=n1, value=http://id/Calc2Graph1)\r\n" + "", element.pathPatternQuery().toString());
    } catch (Exception e) {
        assertEquals("", e.getMessage());
    }
}
Also used : PathElement(com.inova8.pathql.element.PathElement) RecognitionException(org.antlr.v4.runtime.RecognitionException) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 23 with Predicate

use of com.inova8.intelligentgraph.model.Predicate in project com.inova8.intelligentgraph by peterjohnlawrence.

the class PathPatternQueryExpressionTests method test_5.

/**
 * Test 5.
 */
@Test
@Order(5)
void test_5() {
    CharStream input = CharStreams.fromString(":Location@:appearsOn[ rdfs:label \"eastman3d\" ]#/:lat");
    PathElement element = prepareElement(input);
    // Query.assertEqualsWOSpaces
    assertEquals("Join\r\n" + "   Join\r\n" + "      Join\r\n" + "         Join\r\n" + "            StatementPattern\r\n" + "               Variable (name=r1)\r\n" + "               Variable (name=subject1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#subject)\r\n" + "               Variable (name=n0)\r\n" + "            StatementPattern\r\n" + "               Variable (name=r1)\r\n" + "               Variable (name=property1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate)\r\n" + "               Variable (name=p_n0_n1, value=http://default/appearsOn)\r\n" + "         StatementPattern\r\n" + "            Variable (name=r1)\r\n" + "            Variable (name=object1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#object)\r\n" + "            Variable (name=n1)\r\n" + "      StatementPattern\r\n" + "         Variable (name=n1)\r\n" + "         Variable (name=p_n1_n1_1, value=http://rdfs/label)\r\n" + "         Variable (name=n1_1, value=\"eastman3d\")\r\n" + "   StatementPattern\r\n" + "      Variable (name=r1)\r\n" + "      Variable (name=p_r1_n2, value=http://default/lat)\r\n" + "      Variable (name=n2)\r\n" + "", element.pathPatternQuery().toString());
}
Also used : PathElement(com.inova8.pathql.element.PathElement) CharStream(org.antlr.v4.runtime.CharStream) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 24 with Predicate

use of com.inova8.intelligentgraph.model.Predicate in project com.inova8.intelligentgraph by peterjohnlawrence.

the class PathPatternQueryExpressionTests method test_10.

/**
 * Test 10.
 */
@Test
@Order(10)
void test_10() {
    CharStream input = CharStreams.fromString(":Location@:appearsOn[eq [ rdfs:label 'Calc2Graph1']]#/:lat");
    PathElement element = prepareElement(input);
    // Query.assertEqualsWOSpaces
    assertEquals("Join\r\n" + "   Join\r\n" + "      Join\r\n" + "         StatementPattern\r\n" + "            Variable (name=r1)\r\n" + "            Variable (name=subject1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#subject)\r\n" + "            Variable (name=n0)\r\n" + "         StatementPattern\r\n" + "            Variable (name=r1)\r\n" + "            Variable (name=property1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate)\r\n" + "            Variable (name=p_n0_n1, value=http://default/appearsOn)\r\n" + "      StatementPattern\r\n" + "         Variable (name=r1)\r\n" + "         Variable (name=object1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#object)\r\n" + "         Variable (name=n1)\r\n" + "   StatementPattern\r\n" + "      Variable (name=r1)\r\n" + "      Variable (name=p_r1_n2, value=http://default/lat)\r\n" + "      Variable (name=n2)\r\n" + "", element.pathPatternQuery().toString());
}
Also used : PathElement(com.inova8.pathql.element.PathElement) CharStream(org.antlr.v4.runtime.CharStream) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 25 with Predicate

use of com.inova8.intelligentgraph.model.Predicate in project com.inova8.intelligentgraph by peterjohnlawrence.

the class MultiPathPatternQueryExpressionTests method test_4.

/**
 * Test 4.
 */
@Test
@Order(4)
void test_4() {
    try {
        PathElement element = PathParser.parsePathPattern(repositoryContext, ":Attribute@:density{1, 42}");
        PathTupleExpr pathTupleExpr = element.pathPatternQuery(1, null);
        // Query.assertEqualsWOSpaces
        assertEquals("Join\r\n" + "   Join\r\n" + "      Join\r\n" + "         Union\r\n" + "            StatementPattern\r\n" + "               Variable (name=r1_i1)\r\n" + "               Variable (name=subject1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#subject)\r\n" + "               Variable (name=n0)\r\n" + "            StatementPattern\r\n" + "               Variable (name=n0)\r\n" + "               Variable (name=isSubjectOf1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#subject)\r\n" + "               Variable (name=r1_i1)\r\n" + "         Union\r\n" + "            StatementPattern\r\n" + "               Variable (name=r1_i1)\r\n" + "               Variable (name=property1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate)\r\n" + "               Variable (name=p_n0_n1, value=http://default/density)\r\n" + "            StatementPattern\r\n" + "               Variable (name=p_n0_n1, value=http://default/density)\r\n" + "               Variable (name=isPropertyOf1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate)\r\n" + "               Variable (name=r1_i1)\r\n" + "      Union\r\n" + "         StatementPattern\r\n" + "            Variable (name=r1_i1)\r\n" + "            Variable (name=object1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#object)\r\n" + "            Variable (name=n1_i1)\r\n" + "         StatementPattern\r\n" + "            Variable (name=n1_i1)\r\n" + "            Variable (name=isObjectOf1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#object)\r\n" + "            Variable (name=r1_i1)\r\n" + "   Join\r\n" + "      Join\r\n" + "         Union\r\n" + "            StatementPattern\r\n" + "               Variable (name=r1)\r\n" + "               Variable (name=subject1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#subject)\r\n" + "               Variable (name=n1_i1)\r\n" + "            StatementPattern\r\n" + "               Variable (name=n1_i1)\r\n" + "               Variable (name=isSubjectOf1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#subject)\r\n" + "               Variable (name=r1)\r\n" + "         Union\r\n" + "            StatementPattern\r\n" + "               Variable (name=r1)\r\n" + "               Variable (name=property1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate)\r\n" + "               Variable (name=p_n0_n1, value=http://default/density)\r\n" + "            StatementPattern\r\n" + "               Variable (name=p_n0_n1, value=http://default/density)\r\n" + "               Variable (name=isPropertyOf1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate)\r\n" + "               Variable (name=r1)\r\n" + "      Union\r\n" + "         StatementPattern\r\n" + "            Variable (name=r1)\r\n" + "            Variable (name=object1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#object)\r\n" + "            Variable (name=n1)\r\n" + "         StatementPattern\r\n" + "            Variable (name=n1)\r\n" + "            Variable (name=isObjectOf1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#object)\r\n" + "            Variable (name=r1)\r\n" + "", pathTupleExpr.toString());
        assertEquals("[n0,r1_i1:<http://default/Attribute>@http://default/density,n1_i1,DIRECT,false]\r\n" + "[n1_i1,r1:<http://default/Attribute>@http://default/density,n1,DIRECT,false]\r\n" + "", pathTupleExpr.pathToString());
    } catch (Exception e) {
        assertEquals("", e.getMessage());
    }
}
Also used : PathElement(com.inova8.pathql.element.PathElement) PathTupleExpr(com.inova8.intelligentgraph.path.PathTupleExpr) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Aggregations

Order (org.junit.jupiter.api.Order)26 Test (org.junit.jupiter.api.Test)26 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)26 PathElement (com.inova8.pathql.element.PathElement)22 IRI (org.eclipse.rdf4j.model.IRI)15 Thing (com.inova8.intelligentgraph.model.Thing)12 PathTupleExpr (com.inova8.intelligentgraph.path.PathTupleExpr)10 QueryEvaluationException (org.eclipse.rdf4j.query.QueryEvaluationException)10 RecognitionException (org.antlr.v4.runtime.RecognitionException)9 IntelligentGraphRepository (com.inova8.intelligentgraph.intelligentGraphRepository.IntelligentGraphRepository)8 CharStream (org.antlr.v4.runtime.CharStream)8 Statement (org.eclipse.rdf4j.model.Statement)8 Value (org.eclipse.rdf4j.model.Value)8 EvaluationContext (com.inova8.intelligentgraph.evaluator.EvaluationContext)7 SimpleLiteral (org.eclipse.rdf4j.model.impl.SimpleLiteral)7 CustomQueryOptions (com.inova8.intelligentgraph.context.CustomQueryOptions)6 Resource (com.inova8.intelligentgraph.model.Resource)6 Join (org.eclipse.rdf4j.query.algebra.Join)6 RepositoryException (org.eclipse.rdf4j.repository.RepositoryException)6 PathPatternException (com.inova8.pathql.processor.PathPatternException)5