Search in sources :

Example 16 with ResourceResults

use of com.inova8.intelligentgraph.results.ResourceResults in project com.inova8.intelligentgraph by peterjohnlawrence.

the class Local_GetPath_Tests method test_7.

/**
 * Test 7.
 */
@Test
@Order(7)
void test_7() {
    try {
        Thing _this = source.getThing(iri("http://inova8.com/calc2graph/id/Equipment_1"), null);
        ResourceResults results = _this.getFacts(":connectedTo{1,3}");
        ArrayList<String> resultsArrayList = new ArrayList<String>();
        for (Resource result : results) {
            resultsArrayList.add(result.stringValue());
        }
        assertEquals("[http://inova8.com/calc2graph/id/Equipment_2, http://inova8.com/calc2graph/id/Equipment_2_1, http://inova8.com/calc2graph/id/Equipment_3, http://inova8.com/calc2graph/id/Equipment_2_2, http://inova8.com/calc2graph/id/Equipment_4, http://inova8.com/calc2graph/id/Equipment_2_3]", resultsArrayList.toString());
        PathResults paths = _this.getPaths(":connectedTo{1,3}");
        ArrayList<String> pathArrayList = new ArrayList<String>();
        for (Path path : paths) {
            pathArrayList.add(path.toString());
        }
        assertEquals("[Path=[[http://inova8.com/calc2graph/id/Equipment_1,http://inova8.com/calc2graph/def/connectedTo,http://inova8.com/calc2graph/id/Equipment_2,DIRECT]\r\n" + "]\r\n" + ", Path=[[http://inova8.com/calc2graph/id/Equipment_1,http://inova8.com/calc2graph/def/connectedTo,http://inova8.com/calc2graph/id/Equipment_2_1,DIRECT]\r\n" + "]\r\n" + ", Path=[[http://inova8.com/calc2graph/id/Equipment_1,http://inova8.com/calc2graph/def/connectedTo,http://inova8.com/calc2graph/id/Equipment_2,DIRECT]\r\n" + "[http://inova8.com/calc2graph/id/Equipment_2,http://inova8.com/calc2graph/def/connectedTo,http://inova8.com/calc2graph/id/Equipment_3,DIRECT]\r\n" + "]\r\n" + ", Path=[[http://inova8.com/calc2graph/id/Equipment_1,http://inova8.com/calc2graph/def/connectedTo,http://inova8.com/calc2graph/id/Equipment_2_1,DIRECT]\r\n" + "[http://inova8.com/calc2graph/id/Equipment_2_1,http://inova8.com/calc2graph/def/connectedTo,http://inova8.com/calc2graph/id/Equipment_2_2,DIRECT]\r\n" + "]\r\n" + ", Path=[[http://inova8.com/calc2graph/id/Equipment_1,http://inova8.com/calc2graph/def/connectedTo,http://inova8.com/calc2graph/id/Equipment_2,DIRECT]\r\n" + "[http://inova8.com/calc2graph/id/Equipment_2,http://inova8.com/calc2graph/def/connectedTo,http://inova8.com/calc2graph/id/Equipment_3,DIRECT]\r\n" + "[http://inova8.com/calc2graph/id/Equipment_3,http://inova8.com/calc2graph/def/connectedTo,http://inova8.com/calc2graph/id/Equipment_4,DIRECT]\r\n" + "]\r\n" + ", Path=[[http://inova8.com/calc2graph/id/Equipment_1,http://inova8.com/calc2graph/def/connectedTo,http://inova8.com/calc2graph/id/Equipment_2_1,DIRECT]\r\n" + "[http://inova8.com/calc2graph/id/Equipment_2_1,http://inova8.com/calc2graph/def/connectedTo,http://inova8.com/calc2graph/id/Equipment_2_2,DIRECT]\r\n" + "[http://inova8.com/calc2graph/id/Equipment_2_2,http://inova8.com/calc2graph/def/connectedTo,http://inova8.com/calc2graph/id/Equipment_2_3,DIRECT]\r\n" + "]\r\n" + "]", pathArrayList.toString());
    } catch (Exception e) {
        assertEquals("", e.getMessage());
        e.printStackTrace();
    }
}
Also used : Path(com.inova8.intelligentgraph.path.Path) ArrayList(java.util.ArrayList) Resource(com.inova8.intelligentgraph.model.Resource) PathResults(com.inova8.intelligentgraph.results.PathResults) Thing(com.inova8.intelligentgraph.model.Thing) ResourceResults(com.inova8.intelligentgraph.results.ResourceResults) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 17 with ResourceResults

use of com.inova8.intelligentgraph.results.ResourceResults in project com.inova8.intelligentgraph by peterjohnlawrence.

the class Remote_PathQL_GetFactTests method test_30.

/**
 * Test 30.
 */
@Test
@Order(30)
void test_30() {
    try {
        @SuppressWarnings("unused") Graph graph = source.addGraph("<http://inova8.com/calc2graph/testGraph>");
        source.removeGraph("<http://inova8.com/calc2graph/testGraph1>");
        Graph graph1 = source.openGraph("<http://inova8.com/calc2graph/testGraph1>");
        Thing myCountry = graph1.getThing(":Country1");
        String performanceCalculation = "2*3";
        myCountry.addFact(":salesPerformance", performanceCalculation, SCRIPT.GROOVY);
        ResourceResults results = myCountry.getFacts(":salesPerformance");
        for (Resource result : results) {
            result.getValue();
            assertEquals("6", result.getValue().stringValue());
        }
        source.removeGraph("<http://inova8.com/calc2graph/testGraph>");
    } catch (Exception e) {
        fail();
    }
}
Also used : Graph(com.inova8.intelligentgraph.intelligentGraphRepository.Graph) Resource(com.inova8.intelligentgraph.model.Resource) Thing(com.inova8.intelligentgraph.model.Thing) ResourceResults(com.inova8.intelligentgraph.results.ResourceResults) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 18 with ResourceResults

use of com.inova8.intelligentgraph.results.ResourceResults in project com.inova8.intelligentgraph by peterjohnlawrence.

the class Remote_PathQL_MultiGraphTests method test_10.

/**
 * Test 10.
 */
@Test
@Order(10)
void test_10() {
    try {
        // Graph graph = source.addGraph("<http://inova8.com/calc2graph/testGraph>");
        // source.removeGraph("<http://inova8.com/calc2graph/testGraph1>");
        Graph graph1 = source.openGraph("<http://inova8.com/calc2graph/testGraph1>");
        Thing myCountry = graph1.getThing(":Country1");
        String performanceCalculation = "2*3";
        myCountry.addFact(":salesPerformance", performanceCalculation, SCRIPT.GROOVY);
        ResourceResults results = myCountry.getFacts(":salesPerformance");
        for (Resource result : results) {
            assertEquals("6", result.getValue().stringValue());
        }
        // source.removeGraph("<http://inova8.com/calc2graph/testGraph1>");
        source.closeGraph("<http://inova8.com/calc2graph/testGraph1>");
    } catch (Exception e) {
        fail();
    }
}
Also used : Resource(com.inova8.intelligentgraph.model.Resource) Thing(com.inova8.intelligentgraph.model.Thing) ResourceResults(com.inova8.intelligentgraph.results.ResourceResults) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 19 with ResourceResults

use of com.inova8.intelligentgraph.results.ResourceResults in project com.inova8.intelligentgraph by peterjohnlawrence.

the class Remote_CRUD_Test method ig_0.

/**
 * Ig 0.
 */
@Test
@Order(0)
void ig_0() {
    try {
        source.removeGraph("<http://inova8.com/calc2graph/testGraph1>");
        Graph graph = source.addGraph("<http://inova8.com/calc2graph/testGraph1>");
        source.prefix("<http://inova8.com/calc2graph/testGraph1/>");
        Thing myCountry = graph.getThing(":Country1");
        myCountry.addFact(":sales", "1");
        myCountry.addFact(":sales", "2");
        myCountry.addFact(":sales", "3");
        myCountry.addFact(":sales", "4");
        ResourceResults facts = myCountry.getFacts(":sales[ge '2';lt '4']");
        Integer factsinrange = facts.count();
        assertEquals(2, factsinrange);
        myCountry.deleteFacts(":sales[eq '3']");
        factsinrange = myCountry.getFacts(":sales[ge '2';lt '4']").count();
        assertEquals(1, factsinrange);
        Boolean closed = source.closeGraph("<http://inova8.com/calc2graph/testGraph1>");
        assertEquals(true, closed);
    } catch (Exception e) {
        assertEquals("", e.getMessage());
    }
}
Also used : Graph(com.inova8.intelligentgraph.intelligentGraphRepository.Graph) Thing(com.inova8.intelligentgraph.model.Thing) ResourceResults(com.inova8.intelligentgraph.results.ResourceResults) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 20 with ResourceResults

use of com.inova8.intelligentgraph.results.ResourceResults in project com.inova8.intelligentgraph by peterjohnlawrence.

the class Example2_Tests method example2_3.

/**
 * Example 2 3.
 */
@Test
@Order(3)
void example2_3() {
    try {
        Thing personType = source.getThing(":Person");
        ResourceResults persons = personType.getFacts("^rdf:type/:hasBMI");
        ArrayList<String> personValues = new ArrayList<String>();
        ;
        for (Resource person : persons) {
            personValues.add(person.getValue().stringValue());
        }
        assertEquals("[19.94459833795014, 16.897506925207757, 27.11111111111111, 23.148148148148145, 22.49134948096886, 14.75, 14.506172839506172, 31.11111111111111, 24.88888888888889, 21.79930795847751, 25.781249999999996, 15.91695501730104, 21.453287197231838]", personValues.toString());
    } catch (Exception e) {
        assertEquals("", e.getCause().getMessage());
    }
}
Also used : ArrayList(java.util.ArrayList) Resource(com.inova8.intelligentgraph.model.Resource) Thing(com.inova8.intelligentgraph.model.Thing) ResourceResults(com.inova8.intelligentgraph.results.ResourceResults) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Aggregations

ResourceResults (com.inova8.intelligentgraph.results.ResourceResults)46 Order (org.junit.jupiter.api.Order)42 Test (org.junit.jupiter.api.Test)42 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)42 Thing (com.inova8.intelligentgraph.model.Thing)33 Resource (com.inova8.intelligentgraph.model.Resource)23 Graph (com.inova8.intelligentgraph.intelligentGraphRepository.Graph)12 IntelligentGraphRepository (com.inova8.intelligentgraph.intelligentGraphRepository.IntelligentGraphRepository)7 ArrayList (java.util.ArrayList)7 NullValueReturnedException (com.inova8.intelligentgraph.exceptions.NullValueReturnedException)4 CustomQueryOptions (com.inova8.intelligentgraph.context.CustomQueryOptions)3 Path (com.inova8.intelligentgraph.path.Path)3 PathResults (com.inova8.intelligentgraph.results.PathResults)3 Trace (com.inova8.intelligentgraph.evaluator.Trace)2 ResourceStatementResults (com.inova8.intelligentgraph.results.ResourceStatementResults)2 PathPatternException (com.inova8.pathql.processor.PathPatternException)2 RecognitionException (org.antlr.v4.runtime.RecognitionException)2 IRI (org.eclipse.rdf4j.model.IRI)2 Statement (org.eclipse.rdf4j.model.Statement)2 QueryEvaluationException (org.eclipse.rdf4j.query.QueryEvaluationException)2