Search in sources :

Example 51 with RepositoryContext

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

the class PathPatternSPARQLTests method test_13.

// @Test
// @Order(12)
// void test_12() {
// try {
// 
// PathProcessor2 pathProcessor = new PathProcessor2();
// PathElement element = PathProcessor2.parsePathPattern(repositoryContext, ":Location@:appearsOn][eq id:Calc2Graph2]#");
// }catch(Exception e){
// assertEquals ("[line 1:20 in \":Location@:appearsOn][eq id:Calc2Graph2]#\": mismatched input ']' expecting {<EOF>, '|', '/', '{', '[', '#'}]"
// ,e.getMessage() );
// }
/**
 * Test 13.
 */
// }
@Test
@Order(13)
void test_13() {
    try {
        PathElement element = PathParser.parsePathPattern(repositoryContext, ":Location@:appearsOn[eq id:Calc2Graph1, id:Calc2Graph2]#");
        assertEquals("?r1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> ?n0\r\n" + "?r1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate> <http://default/appearsOn>\r\n" + "?r1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#object> <http://id/Calc2Graph1>\r\n" + "BIND(<http://id/Calc2Graph1> as <http://id/Calc2Graph1>)\r\n" + "?r1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#object> <http://id/Calc2Graph2>\r\n" + "BIND(<http://id/Calc2Graph1> as <http://id/Calc2Graph2>)\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 52 with RepositoryContext

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

the class PathPatternSPARQLTests method test_34.

/**
 * Test 34.
 */
@Test
@Order(34)
void test_34() {
    try {
        PathElement element = PathParser.parsePathPattern(repositoryContext, ":hasProductBatteryLimit");
        assertEquals("?n0 <http://default/hasProductBatteryLimit> ?n1 .\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 53 with RepositoryContext

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

the class PathPatternSPARQLTests method test_23.

/**
 * Test 23.
 */
@Test
@Order(23)
void test_23() {
    try {
        PathElement element = PathParser.parsePathPattern(repositoryContext, "^:hasProductBatteryLimit/(:massFlow |:volumeFlow)");
        assertEquals("?n1 <http://default/hasProductBatteryLimit> ?n0 .\r\n" + "{{?n1 <http://default/massFlow> ?n2 .\r\n" + "}UNION{\r\n" + "?n1 <http://default/volumeFlow> ?n2 .\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 54 with RepositoryContext

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

the class PathPatternSPARQLTests method test_20.

/**
 * Test 20.
 */
@Test
@Order(20)
void test_20() {
    try {
        PathElement element = PathParser.parsePathPattern(repositoryContext, "(^:hasProductBatteryLimit/*){1, 2}/:massThroughput");
        assertEquals("#{1\r\n" + "?n1 <http://default/hasProductBatteryLimit> ?n0 .\r\n" + "?n1 ?p1_2 ?n2 .\r\n" + "#,2}\r\n" + "?n2 <http://default/massThroughput> ?n3 .\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 55 with RepositoryContext

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

the class PathPatternSPARQLTests method test_17.

/**
 * Test 17.
 */
@Test
@Order(17)
void test_17() {
    try {
        PathElement element = PathParser.parsePathPattern(repositoryContext, "(^:hasProductBatteryLimit/:massThroughput){1, 2}/:massThroughput");
        assertEquals("#{1\r\n" + "?n1 <http://default/hasProductBatteryLimit> ?n0 .\r\n" + "?n1 <http://default/massThroughput> ?n2 .\r\n" + "#,2}\r\n" + "?n2 <http://default/massThroughput> ?n3 .\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)

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