use of com.inova8.intelligentgraph.model.Thing in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Example1_Tests method example1_1.
/**
* Example 1 1.
*/
@Test
@Order(1)
void example1_1() {
try {
Thing aPerson = source.getThing(":aPerson");
Trace trace = aPerson.traceFact(":hasBMI");
assertEquals(" 1. Getting facts ':hasBMI' of aPerson <http://inova8.com/intelligentgraph/example1/aPerson>\n" + " 2. ...within contexts: [http://default, file://src/test/resources/example1.ttl]\n" + " 1. Evaluating predicate hasBMI <http://inova8.com/intelligentgraph/example1/hasBMI> of aPerson <http://inova8.com/intelligentgraph/example1/aPerson> , by invoking groovy script\n" + " 2. double height=_this.getFact(':hasHeight').doubleValue(); _this.getFact(':hasWeight').doubleValue()/(height*height)\n" + "\n" + " 1. Getting facts ':hasHeight' of aPerson <http://inova8.com/intelligentgraph/example1/aPerson>\n" + " 2. Next fact 'http://inova8.com/intelligentgraph/example1/hasHeight' of aPerson <http://inova8.com/intelligentgraph/example1/aPerson> = 1.7\n" + " 3. Returned fact ':hasHeight' of aPerson <http://inova8.com/intelligentgraph/example1/aPerson> = 1.7^^decimal <http://www.w3.org/2001/XMLSchema#decimal>\n" + "\n" + " 4. Getting facts ':hasWeight' of aPerson <http://inova8.com/intelligentgraph/example1/aPerson>\n" + " 5. Next fact 'http://inova8.com/intelligentgraph/example1/hasWeight' of aPerson <http://inova8.com/intelligentgraph/example1/aPerson> = 62\n" + " 6. Returned fact ':hasWeight' of aPerson <http://inova8.com/intelligentgraph/example1/aPerson> = 62^^decimal <http://www.w3.org/2001/XMLSchema#decimal>\n" + "\n" + " 3. Evaluated hasBMI <http://inova8.com/intelligentgraph/example1/hasBMI> of aPerson <http://inova8.com/intelligentgraph/example1/aPerson> = 21.453287197231838^^double <http://www.w3.org/2001/XMLSchema#double>\n" + " 3. Calculated hasBMI <http://inova8.com/intelligentgraph/example1/hasBMI> of aPerson <http://inova8.com/intelligentgraph/example1/aPerson> = 21.453287197231838^^double <http://www.w3.org/2001/XMLSchema#double>\n" + " 4. Retrieved cached value hasBMI <http://inova8.com/intelligentgraph/example1/hasBMI> of aPerson <http://inova8.com/intelligentgraph/example1/aPerson> = 21.453287197231838^^double <http://www.w3.org/2001/XMLSchema#double>\n" + " 5. Returned fact 'http://inova8.com/intelligentgraph/example1/hasBMI' of aPerson <http://inova8.com/intelligentgraph/example1/aPerson> = 21.453287197231838^^double <http://www.w3.org/2001/XMLSchema#double>", trace.asText());
} catch (Exception e) {
assertEquals("", e.getMessage());
e.printStackTrace();
}
}
use of com.inova8.intelligentgraph.model.Thing in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Example2_Tests method example2_4.
/**
* Example 2 4.
*/
@Test
@Order(4)
void example2_4() {
try {
Thing person = source.getThing(":Person");
Resource averagebmi = person.getFact(":averageBMI");
assertEquals("21.523052847377123", averagebmi.stringValue());
} catch (Exception e) {
assertEquals("", e.getCause().getMessage());
}
}
use of com.inova8.intelligentgraph.model.Thing 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());
}
}
use of com.inova8.intelligentgraph.model.Thing in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Example2_Tests method example2_1.
/**
* Example 2 1.
*/
@Test
@Order(1)
void example2_1() {
try {
Thing aPerson = source.getThing(":aPerson");
Resource bmi = aPerson.getFact(":hasBMI");
assertEquals("21.453287197231838", bmi.stringValue());
Thing another1 = source.getThing(":Another1");
Resource another1bmi = another1.getFact(":hasBMI");
assertEquals("19.94459833795014", another1bmi.stringValue());
} catch (Exception e) {
assertEquals("", e.getCause().getMessage());
}
}
use of com.inova8.intelligentgraph.model.Thing in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Example2_Tests method example2_6.
/**
* Example 2 6.
*/
@Test
@Order(6)
void example2_6() {
try {
Thing person = source.getThing(":Person");
Double bmi = person.getFacts("^rdf:type[:hasHeight [ ge '1.9'^^xsd:double ]]/:hasBMI").average();
assertEquals("17.197368421052634", bmi.toString());
} catch (Exception e) {
assertEquals("", e.getCause().getMessage());
}
}
Aggregations