Search in sources :

Example 66 with Resource

use of com.inova8.intelligentgraph.model.Resource 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());
    }
}
Also used : ArrayList(java.util.ArrayList) Resource(com.inova8.intelligentgraph.model.Resource) Thing(com.inova8.intelligentgraph.model.Thing) ResourceResults(com.inova8.intelligentgraph.results.ResourceResults) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 67 with Resource

use of com.inova8.intelligentgraph.model.Resource 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());
    }
}
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 68 with Resource

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

the class Example2_Tests method example2_5.

/**
 * Example 2 5.
 */
@Test
@Order(5)
void example2_5() {
    try {
        Thing person = source.getThing(":aPerson");
        Resource relativeBMI = person.getFact(":hasRelativeBMI");
        assertEquals("0.9967585615925397", relativeBMI.stringValue());
    } catch (Exception e) {
        assertEquals("", e.getCause().getMessage());
    }
}
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 69 with Resource

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

the class Example5_Tests method example5_1.

/**
 * Example 5 1.
 */
@Test
@Order(1)
void example5_1() {
    try {
        Thing aPerson_Measurement = source.getThing(":aPerson_Measurement_1");
        Resource bmi = aPerson_Measurement.getFact(":hasBMI");
        assertEquals("21.453287197231838", bmi.stringValue());
    } catch (Exception e) {
        assertEquals("", e.getMessage());
        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 70 with Resource

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

the class Example5_Tests method example5_4.

/**
 * Example 5 4.
 */
@Test
@Order(4)
void example5_4() {
    try {
        Resource bmi = source.getThing(":aPerson").getFact("^:measurementOf[:hasOrdinal %1]/:hasBMI", literal(2));
        assertEquals("22.03856749311295", bmi.stringValue());
    } catch (Exception e) {
        fail();
        e.printStackTrace();
    }
}
Also used : Resource(com.inova8.intelligentgraph.model.Resource) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Aggregations

Resource (com.inova8.intelligentgraph.model.Resource)140 Order (org.junit.jupiter.api.Order)135 Test (org.junit.jupiter.api.Test)135 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)135 Thing (com.inova8.intelligentgraph.model.Thing)113 ResourceResults (com.inova8.intelligentgraph.results.ResourceResults)26 IntelligentGraphRepository (com.inova8.intelligentgraph.intelligentGraphRepository.IntelligentGraphRepository)20 Graph (com.inova8.intelligentgraph.intelligentGraphRepository.Graph)19 QueryEvaluationException (org.eclipse.rdf4j.query.QueryEvaluationException)11 CustomQueryOptions (com.inova8.intelligentgraph.context.CustomQueryOptions)9 PathPatternException (com.inova8.pathql.processor.PathPatternException)8 RecognitionException (org.antlr.v4.runtime.RecognitionException)8 ArrayList (java.util.ArrayList)7 IRI (org.eclipse.rdf4j.model.IRI)7 RepositoryException (org.eclipse.rdf4j.repository.RepositoryException)7 Repository (org.eclipse.rdf4j.repository.Repository)6 RepositoryConnection (org.eclipse.rdf4j.repository.RepositoryConnection)6 NullValueReturnedException (com.inova8.intelligentgraph.exceptions.NullValueReturnedException)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)5 BindingSet (org.eclipse.rdf4j.query.BindingSet)5