Search in sources :

Example 71 with RepositoryContext

use of com.inova8.pathql.context.RepositoryContext in project com.inova8.intelligentgraph by peterjohnlawrence.

the class PathIterationTests method setUpBeforeClass.

/**
 * Sets the up before class.
 *
 * @throws Exception the exception
 */
@BeforeAll
static void setUpBeforeClass() throws Exception {
    repositoryContext = new RepositoryContext();
    repositoryContext.prefix("http://default/").prefix("local", "http://local/").prefix("rdfs", "http://rdfs/").prefix("id", "http://id/").prefix("xsd", "http://www.w3.org/2001/XMLSchema#");
}
Also used : RepositoryContext(com.inova8.pathql.context.RepositoryContext) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 72 with RepositoryContext

use of com.inova8.pathql.context.RepositoryContext in project com.inova8.intelligentgraph by peterjohnlawrence.

the class PathPatternPathTests method test_4.

/**
 * Test 4.
 *
 * @throws RecognitionException the recognition exception
 * @throws PathPatternException the path pattern exception
 */
@Test
@Order(4)
void test_4() throws RecognitionException, PathPatternException {
    PathElement element = PathParser.parsePathPattern(repositoryContext, ":Location@:appearsOn[ eq [ rdfs:label \"Calc2Graph1\"] ]#/^:lat/:long/^:left/:right");
    PathBinding pathBinding = new PathBinding();
    pathBinding = element.visitPathBinding(pathBinding, 0);
    assertEquals("[n0,r1:<http://default/Location>@http://default/appearsOn,r1,DIRECT,true]\r\n" + "[r1,http://default/lat,n2,INVERSE]\r\n" + "[n2,http://default/long,n3,DIRECT]\r\n" + "[n3,http://default/left,n4,INVERSE]\r\n" + "[n4,http://default/right,n5,DIRECT]\r\n" + "", pathBinding.toString());
}
Also used : PathElement(com.inova8.pathql.element.PathElement) PathBinding(com.inova8.intelligentgraph.path.PathBinding) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 73 with RepositoryContext

use of com.inova8.pathql.context.RepositoryContext in project com.inova8.intelligentgraph by peterjohnlawrence.

the class PathPatternPathTests method test_2.

/**
 * Test 2.
 *
 * @throws RecognitionException the recognition exception
 * @throws PathPatternException the path pattern exception
 */
@Test
@Order(2)
void test_2() throws RecognitionException, PathPatternException {
    PathElement element = PathParser.parsePathPattern(repositoryContext, ":parent1[:gender :female]/^:child2[:gender :male; :birthplace [rdfs:label 'Maidstone']]/:parent3");
    PathBinding pathBinding = new PathBinding();
    pathBinding = element.visitPathBinding(pathBinding, 0);
    assertEquals("[n0,http://default/parent1,n1,DIRECT]\r\n" + "[n1,http://default/child2,n2,INVERSE]\r\n" + "[n2,http://default/parent3,n3,DIRECT]\r\n" + "", pathBinding.toString());
}
Also used : PathElement(com.inova8.pathql.element.PathElement) PathBinding(com.inova8.intelligentgraph.path.PathBinding) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 74 with RepositoryContext

use of com.inova8.pathql.context.RepositoryContext in project com.inova8.intelligentgraph by peterjohnlawrence.

the class PathPatternQueryExpressionTests method test_35.

/**
 * Test 35.
 */
@Test
@Order(35)
void test_35() {
    try {
        PathElement element = PathParser.parsePathPattern(repositoryContext, ":hasProductBatteryLimit[a  :BatteryLimit]");
        // Query.assertEqualsWOSpaces
        assertEquals("Join\r\n" + "   StatementPattern\r\n" + "      Variable (name=n0)\r\n" + "      Variable (name=p_n0_n1, value=http://default/hasProductBatteryLimit)\r\n" + "      Variable (name=n1)\r\n" + "   StatementPattern\r\n" + "      Variable (name=n1)\r\n" + "      Variable (name=p_n1_n1_1, value=http://www.w3.org/1999/02/22-rdf-syntax-ns#type)\r\n" + "      Variable (name=n1_1, value=http://default/BatteryLimit)\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 75 with RepositoryContext

use of com.inova8.pathql.context.RepositoryContext in project com.inova8.intelligentgraph by peterjohnlawrence.

the class PathPatternQueryExpressionTests method test_18.

/**
 * Test 18.
 */
@Test
@Order(18)
void test_18() {
    try {
        PathElement element = PathParser.parsePathPattern(repositoryContext, "*");
        // Query.assertEqualsWOSpaces
        assertEquals("StatementPattern\r\n" + "   Variable (name=n0)\r\n" + "   Variable (name=p_n0_n1)\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)

Aggregations

PathElement (com.inova8.pathql.element.PathElement)116 Order (org.junit.jupiter.api.Order)110 Test (org.junit.jupiter.api.Test)110 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)110 RecognitionException (org.antlr.v4.runtime.RecognitionException)78 PathPatternException (com.inova8.pathql.processor.PathPatternException)26 PathTupleExpr (com.inova8.intelligentgraph.path.PathTupleExpr)10 PathPatternVisitor (com.inova8.pathql.processor.PathPatternVisitor)8 RepositoryContext (com.inova8.pathql.context.RepositoryContext)7 Iterations (com.inova8.pathql.element.Iterations)7 PathPatternLexer (com.inova8.pathql.pathPattern.PathPatternLexer)7 PathPatternParser (com.inova8.pathql.pathPattern.PathPatternParser)7 CommonTokenStream (org.antlr.v4.runtime.CommonTokenStream)7 BeforeAll (org.junit.jupiter.api.BeforeAll)7 PathBinding (com.inova8.intelligentgraph.path.PathBinding)5 PathPatternContext (com.inova8.pathql.pathPattern.PathPatternParser.PathPatternContext)4 CharStream (org.antlr.v4.runtime.CharStream)4 PathErrorListener (com.inova8.pathql.processor.PathErrorListener)2 IriRefValueElement (com.inova8.pathql.element.IriRefValueElement)1 PredicateElement (com.inova8.pathql.element.PredicateElement)1