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>");
}
}
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());
}
}
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());
}
}
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();
}
}
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();
}
}
Aggregations