use of com.inova8.intelligentgraph.results.ResourceResults in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Local_GetContextFact_Tests method test_1.
/**
* Test 1.
*/
@Test
@Order(1)
void test_1() {
try {
IntelligentGraphRepository source = IntelligentGraphRepository.create(workingRep);
// source.prefix("<http://inova8.com/calc2graph/def/>");
// source.prefix("rdfs", "<http://www.w3.org/2000/01/rdf-schema#>");
source.removeGraph("<http://inova8.com/calc2graph/contextGraph>");
// source.prefix("xsd", "<http://www.w3.org/2001/XMLSchema#>");
Graph graph = source.addGraph("<http://inova8.com/calc2graph/contextGraph>");
Thing myCountry = graph.getThing(":myCountry");
myCountry.addFact(":myOption", "_customQueryOptions.get(\"time\").integerValue() ;", SCRIPT.GROOVY);
CustomQueryOptions customQueryOptions1 = new CustomQueryOptions();
customQueryOptions1.add("time", 42);
customQueryOptions1.add("name", "Peter");
Thing myCountry1 = graph.getThing(":myCountry");
Resource result;
result = myCountry1.getFact("<http://inova8.com/calc2graph/def/myOption>", customQueryOptions1);
assertEquals("42", result.stringValue());
CustomQueryOptions customQueryOptions2 = new CustomQueryOptions();
customQueryOptions2.add("time", 43);
result = myCountry1.getFact("<http://inova8.com/calc2graph/def/myOption>", customQueryOptions2);
assertEquals("43", result.stringValue());
CustomQueryOptions customQueryOptions3 = new CustomQueryOptions();
customQueryOptions3.add("time", 2019);
result = myCountry.getFact(":myOption&time='2019'^^xsd:int", customQueryOptions3);
assertEquals("2019", result.stringValue());
ResourceResults results = myCountry.getFacts("<http://inova8.com/calc2graph/def/myOption>&time='2020'^^xsd:int");
for (Resource result1 : results) {
assertEquals("2020", result1.stringValue());
}
} catch (Exception e) {
assertEquals("", e.getMessage());
e.printStackTrace();
}
}
use of com.inova8.intelligentgraph.results.ResourceResults in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Local_GetFact_Tests method test_30.
/**
* Test 30.
*/
@Test
@Order(30)
void test_30() {
try {
source.addGraph("http://inova8.com/calc2graph/testGraph");
Thing _this = source.getThing(iri("http://inova8.com/calc2graph/id/BatteryLimit1"), null);
ResourceResults results = _this.getFacts("(:Attribute@:density |:density)");
for (Resource result : results) {
assertEquals(".42", result.stringValue());
}
} catch (Exception e) {
assertEquals("", e.getMessage());
}
}
use of com.inova8.intelligentgraph.results.ResourceResults in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Local_GetFact_Tests method test_3.
/**
* Test 3.
*/
@Test
@Order(3)
void test_3() {
try {
Thing _this = Thing.create(source, iri("http://inova8.com/calc2graph/id/Unit1"), null);
Double fact = 0.0;
for (Resource batterylimit : _this.getFacts(":hasProductBatteryLimit")) {
fact += batterylimit.getFact(":massFlow").doubleValue();
}
ResourceResults batterylimits = _this.getFacts(":hasProductBatteryLimit");
Resource batterylimit;
while (batterylimits.hasNext()) {
batterylimit = batterylimits.next();
fact -= batterylimit.getFact(":massFlow").doubleValue();
}
;
assertEquals(0.0, fact);
} catch (Exception e) {
assertEquals("", e.getMessage());
e.printStackTrace();
}
}
Aggregations