Search in sources :

Example 81 with Thing

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

the class Remote_PathQL_MultiGraphTests method ig_70.

/**
 * Ig 70.
 */
@Test
@Order(70)
void ig_70() {
    try {
        Graph graph = source.addGraph("<http://inova8.com/calc2graph/testGraph3>");
        Thing myCountry = graph.getThing(":Country1");
        myCountry.addFact(":sales", "100");
        myCountry.addFact(":sales", "200");
        myCountry.addFact(":sales", "300");
        myCountry.addFact(":sales", "400");
        myCountry.addFact(":sales", "500");
        RepositoryConnection conn = source.getRepository().getConnection();
        String totalSalesScript = "return _this.getFacts(\"<http://inova8.com/calc2graph/def/sales>\").total();";
        myCountry.addFact(":totalSales", totalSalesScript, SCRIPT.GROOVY);
        String queryString1 = "PREFIX : <http://inova8.com/calc2graph/def/> select ?s ?o " + "FROM <http://inova8.com/calc2graph/testGraph3>\r\n" + "FROM <http://default>\n" + // + "FROM <file://calc2graph.def.ttl>\r\n"
        "{\r\n" + "  ?s  :totalSales  ?o} limit 10";
        String result = Query.runSPARQL(conn, queryString1);
        assertEquals("s=http://inova8.com/calc2graph/def/Country;o=150.0;", result);
        source.removeGraph("<http://inova8.com/calc2graph/testGraph3>");
        result = Query.runSPARQL(conn, queryString1);
        assertEquals("", result);
    } catch (Exception e) {
        fail();
        e.printStackTrace();
    } finally {
        source.removeGraph("<http://inova8.com/calc2graph/testGraph3>");
    }
}
Also used : RepositoryConnection(org.eclipse.rdf4j.repository.RepositoryConnection) Thing(com.inova8.intelligentgraph.model.Thing) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 82 with Thing

use of com.inova8.intelligentgraph.model.Thing 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 83 with Thing

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

the class Remote_GettingStartedTests method test_40.

/**
 * Test 40.
 */
@Test
@Order(40)
void test_40() {
    try {
        IntelligentGraphRepository source = IntelligentGraphRepository.create("http://localhost:8080/rdf4j-server", "tutorial");
        source.prefix("<http://inova8.com/calc2graph/testGraph4/>");
        source.removeGraph("<http://inova8.com/calc2graph/testGraph4>");
        Graph graph = source.addGraph("<http://inova8.com/calc2graph/testGraph4>");
        Thing myCountry = graph.getThing(":Country1");
        myCountry.addFact(":sales", "100");
        myCountry.addFact(":sales", "200");
        myCountry.addFact(":sales", "300");
        myCountry.addFact(":sales", "400");
        myCountry.addFact(":sales", "500");
        String averageSalesScript = "return _this.getFacts(\":sales\").average();";
        myCountry.addFact(":averageSales", averageSalesScript, SCRIPT.GROOVY);
        Double averageCountrySales;
        averageCountrySales = myCountry.getFact(":averageSales").doubleValue();
        assertEquals(300.0, averageCountrySales);
        averageCountrySales = myCountry.getFact(":averageSales").doubleValue();
        assertEquals(300.0, averageCountrySales);
        myCountry.addFact(":sales", "600");
        averageCountrySales = myCountry.getFact(":averageSales").doubleValue();
        assertEquals(350, averageCountrySales);
        source.closeGraph("<http://inova8.com/calc2graph/testGraph4>");
    } catch (Exception e) {
        assertEquals("", e.getMessage());
    }
}
Also used : IntelligentGraphRepository(com.inova8.intelligentgraph.intelligentGraphRepository.IntelligentGraphRepository) Graph(com.inova8.intelligentgraph.intelligentGraphRepository.Graph) Thing(com.inova8.intelligentgraph.model.Thing) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 84 with Thing

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

the class Remote_PathQL_GetFactTests method test_13.

/**
 * Test 13.
 */
@Test
@Order(13)
void test_13() {
    try {
        Thing $this = source.getThing(iri("http://inova8.com/calc2graph/id/BatteryLimit1"), null);
        Resource result = $this.getFact(":Location@:appearsOn[eq id:Calc2Graph1]#").getFact(":lat");
        assertEquals("400", result.stringValue());
    } catch (Exception e) {
        fail();
        e.printStackTrace();
    }
}
Also used : Resource(com.inova8.intelligentgraph.model.Resource) Thing(com.inova8.intelligentgraph.model.Thing) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 85 with Thing

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

the class Remote_PathQL_GetFactTests method test_15.

/**
 * Test 15.
 */
@Test
@Order(15)
void test_15() {
    try {
        Thing $this = source.getThing(iri("http://inova8.com/calc2graph/id/BatteryLimit1"), null);
        Resource result = $this.getFact("<http://inova8.com/calc2graph/def/long>");
        assertEquals("501", result.stringValue());
    } catch (Exception e) {
        fail();
        e.printStackTrace();
    }
}
Also used : Resource(com.inova8.intelligentgraph.model.Resource) Thing(com.inova8.intelligentgraph.model.Thing) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Aggregations

Thing (com.inova8.intelligentgraph.model.Thing)211 Order (org.junit.jupiter.api.Order)189 Test (org.junit.jupiter.api.Test)189 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)189 Resource (com.inova8.intelligentgraph.model.Resource)112 Graph (com.inova8.intelligentgraph.intelligentGraphRepository.Graph)45 IntelligentGraphRepository (com.inova8.intelligentgraph.intelligentGraphRepository.IntelligentGraphRepository)36 ResourceResults (com.inova8.intelligentgraph.results.ResourceResults)33 PathResults (com.inova8.intelligentgraph.results.PathResults)29 CustomQueryOptions (com.inova8.intelligentgraph.context.CustomQueryOptions)20 IRI (org.eclipse.rdf4j.model.IRI)13 Value (org.eclipse.rdf4j.model.Value)13 Path (com.inova8.intelligentgraph.path.Path)11 PathPatternException (com.inova8.pathql.processor.PathPatternException)11 RecognitionException (org.antlr.v4.runtime.RecognitionException)11 Trace (com.inova8.intelligentgraph.evaluator.Trace)10 QueryEvaluationException (org.eclipse.rdf4j.query.QueryEvaluationException)9 RepositoryConnection (org.eclipse.rdf4j.repository.RepositoryConnection)9 EvaluationContext (com.inova8.intelligentgraph.evaluator.EvaluationContext)8 SimpleLiteral (org.eclipse.rdf4j.model.impl.SimpleLiteral)8