Search in sources :

Example 11 with RepositoryContext

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

the class PathPatternQueryExpressionTests method test_27.

/**
 * Test 27.
 */
@Test
@Order(27)
void test_27() {
    try {
        /**
         ************************************************Negation not yet supported
         */
        PathElement element = PathParser.parsePathPattern(repositoryContext, "(* | !^:hasProductBatteryLimit)/(* | !(:massFlow |:volumeFlow  |:density))");
        // Query.assertEqualsWOSpaces
        assertEquals("Join\r\n" + "   Union\r\n" + "      StatementPattern\r\n" + "         Variable (name=n0)\r\n" + "         Variable (name=p_n0_n1_alt_L)\r\n" + "         Variable (name=n1)\r\n" + "      Filter\r\n" + "         Compare (!=)\r\n" + "            Variable (name=p0_1)\r\n" + "            Variable (name=p2, value=http://default/hasProductBatteryLimit)\r\n" + "         StatementPattern\r\n" + "            Variable (name=n1)\r\n" + "            Variable (name=p0_1)\r\n" + "            Variable (name=n0)\r\n" + "   Union\r\n" + "      StatementPattern\r\n" + "         Variable (name=n1)\r\n" + "         Variable (name=p_n1_n2_alt_L)\r\n" + "         Variable (name=n2)\r\n" + "      Union\r\n" + "         Union\r\n" + "            StatementPattern\r\n" + "               Variable (name=n1)\r\n" + "               Variable (name=p_n1_n2_alt_LRLL, value=http://default/massFlow)\r\n" + "               Variable (name=n2)\r\n" + "            StatementPattern\r\n" + "               Variable (name=n1)\r\n" + "               Variable (name=p_n1_n2_alt_LRLLR, value=http://default/volumeFlow)\r\n" + "               Variable (name=n2)\r\n" + "         StatementPattern\r\n" + "            Variable (name=n1)\r\n" + "            Variable (name=p_n1_n2_alt_LRLR, value=http://default/density)\r\n" + "            Variable (name=n2)\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 12 with RepositoryContext

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

the class PathPatternQueryExpressionTests method test_24.

/**
 * Test 24.
 */
@Test
@Order(24)
void test_24() {
    try {
        PathElement element = PathParser.parsePathPattern(repositoryContext, "^:hasProductBatteryLimit/(:massFlow |:volumeFlow  |:density)");
        // Query.assertEqualsWOSpaces
        assertEquals("Join\r\n" + "   StatementPattern\r\n" + "      Variable (name=n1)\r\n" + "      Variable (name=p_n0_n1, value=http://default/hasProductBatteryLimit)\r\n" + "      Variable (name=n0)\r\n" + "   Union\r\n" + "      Union\r\n" + "         StatementPattern\r\n" + "            Variable (name=n1)\r\n" + "            Variable (name=p_n1_n2_alt_LL, value=http://default/massFlow)\r\n" + "            Variable (name=n2)\r\n" + "         StatementPattern\r\n" + "            Variable (name=n1)\r\n" + "            Variable (name=p_n1_n2_alt_LLR, value=http://default/volumeFlow)\r\n" + "            Variable (name=n2)\r\n" + "      StatementPattern\r\n" + "         Variable (name=n1)\r\n" + "         Variable (name=p_n1_n2_alt_LR, value=http://default/density)\r\n" + "         Variable (name=n2)\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 13 with RepositoryContext

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

the class PathPatternSPARQLTests method test_35.

/**
 * Test 35.
 */
@Test
@Order(35)
void test_35() {
    try {
        PathElement element = PathParser.parsePathPattern(repositoryContext, ":hasProductBatteryLimit[a  :BatteryLimit]");
        assertEquals("?n0 <http://default/hasProductBatteryLimit> ?n1 .\r\n" + "?n1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://default/BatteryLimit> .\r\n" + "", element.toSPARQL());
    } catch (Exception e) {
        assertEquals("", e.getMessage());
    }
}
Also used : PathElement(com.inova8.pathql.element.PathElement) PathPatternException(com.inova8.pathql.processor.PathPatternException) 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 14 with RepositoryContext

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

the class PathPatternPathTests method test_3.

/**
 * Test 3.
 *
 * @throws RecognitionException the recognition exception
 * @throws PathPatternException the path pattern exception
 */
@Test
@Order(3)
void test_3() throws RecognitionException, PathPatternException {
    PathElement element = PathParser.parsePathPattern(repositoryContext, "^:hasProductBatteryLimit>:massThroughput");
    PathBinding pathBinding = new PathBinding();
    pathBinding = element.visitPathBinding(pathBinding, 0);
    assertEquals("[n0,http://default/hasProductBatteryLimit,n1,INVERSE]\r\n" + "[n1,http://default/massThroughput,n2,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 15 with RepositoryContext

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

the class PathPatternPathTests method test_1.

/**
 * Test 1.
 *
 * @throws RecognitionException the recognition exception
 * @throws PathPatternException the path pattern exception
 */
@Test
@Order(1)
void test_1() throws RecognitionException, PathPatternException {
    PathElement element = PathParser.parsePathPattern(repositoryContext, ":parent1/:parent2/:parent3");
    PathBinding pathBinding = new PathBinding();
    pathBinding = element.visitPathBinding(pathBinding, 0);
    assertEquals("[n0,http://default/parent1,n1,DIRECT]\r\n" + "[n1,http://default/parent2,n2,DIRECT]\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)

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