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