Search in sources :

Example 71 with Thing

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

the class Remote_PathQL_GetFactTests method test_33.

/**
 * Test 33.
 */
@Test
@Order(33)
void test_33() {
    try {
        source.removeGraph("<http://inova8.com/calc2graph/testGraph>");
        Graph graph = source.addGraph("<http://inova8.com/calc2graph/testGraph>");
        Thing myCountry = graph.getThing(":Country1");
        myCountry.addFact(":sales", "1");
        myCountry.addFact(":sales", "2");
        myCountry.addFact(":sales", "3");
        myCountry.addFact(":sales", "4");
        myCountry.addFact(":sales", "5");
        String averageSalesScript = "return $this.getFacts(\":sales\").average();";
        myCountry.addFact(":averageSales", averageSalesScript, SCRIPT.GROOVY);
        Value averageCountrySales = myCountry.getFact(":averageSales").getValue();
        assertEquals("3.0", averageCountrySales.stringValue());
    } catch (Exception e) {
        fail();
    }
}
Also used : Graph(com.inova8.intelligentgraph.intelligentGraphRepository.Graph) Value(org.eclipse.rdf4j.model.Value) 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 72 with Thing

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

the class Remote_PathQL_GetFactTests method test_1.

// /**
// * Search 1.
// */
// @Test
// @Order(1)
// void search_1() {
// 
// try {
// MatchResults searchResultsIterator = match.entityMatch("Unit2");
// while(searchResultsIterator.hasNext()) {
// BindingSet nextSearchResultBindingSet = searchResultsIterator.nextBindingSet();
// int i=1;
// }
// int i=1;
// } catch (Exception e) {
// fail();
// e.printStackTrace();
// }
// }
/**
 * Test 1.
 */
@Test
@Order(1)
// literal("$this.prefix(\"<http://inova8.com/calc2graph/def/>\");var result= $this.getFact(\":volumeFlow\").floatValue()* $this.getFact(\":Attribute@:density\").floatValue();  result;",
void test_1() {
    try {
        // Thing $this = new Thing(source, iri("http://inova8.com/calc2graph/id/BatteryLimit1"), null);
        Thing $this = source.getThing(iri("http://inova8.com/calc2graph/id/BatteryLimit1"), null);
        Resource result = $this.getFact("<http://inova8.com/calc2graph/def/volumeFlow>");
        assertEquals("59", 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 73 with Thing

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

the class Remote_PathQL_GetFactTests method test_2_1.

/**
 * Test 2 1.
 */
@Test
@Order(21)
void test_2_1() {
    try {
        Thing $this = source.getThing(iri("http://inova8.com/calc2graph/id/Unit1"), null);
        Resource result = $this.getFact(":hasFeedBatteryLimit/:volumeFlow");
        assertEquals("59", 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 74 with Thing

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

the class Remote_PathQL_GetFactTests method test_9.

/**
 * Test 9.
 */
@Test
@Order(9)
void test_9() {
    try {
        Thing $this = source.getThing(iri("http://inova8.com/calc2graph/id/BatteryLimit2"), null);
        Float result = $this.getFact(":massFlow").floatValue() / $this.getFact("^:hasProductBatteryLimit").getFact(":massThroughput").floatValue();
        assertEquals("0.5", result.toString());
    } catch (Exception e) {
        fail();
        e.printStackTrace();
    }
}
Also used : 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 75 with Thing

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

the class Remote_PathQL_GetFactTests method test_20.

/**
 * Test 20.
 */
@Test
@Order(20)
void test_20() {
    try {
        Thing $this = source.getThing(iri("http://inova8.com/calc2graph/id/BatteryLimit1"), null);
        Resource result = $this.getFact(":Location@:appearsOn[eq [ rdfs:label 'Calc2Graph2']]#/:lat");
        assertEquals("400", result.stringValue());
    } catch (Exception e) {
        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