Search in sources :

Example 21 with ResourceResults

use of com.inova8.intelligentgraph.results.ResourceResults in project com.inova8.intelligentgraph by peterjohnlawrence.

the class Example4_Tests method example4_7.

@Test
@Order(7)
void example4_7() {
    try {
        ResourceResults classes = source.getFacts("[ a owl:Class; eq :Person]/^a[:hasLocation :Maidstone]/:hasHeight");
        assertEquals("[ {s=http://inova8.com/intelligentgraph/example4/Another2, p=http://inova8.com/intelligentgraph/example4/hasHeight, o=\"1.7\"^^<http://www.w3.org/2001/XMLSchema#decimal>}; {s=http://inova8.com/intelligentgraph/example4/Another3, p=http://inova8.com/intelligentgraph/example4/hasHeight, o=\"2\"^^<http://www.w3.org/2001/XMLSchema#integer>}; {s=http://inova8.com/intelligentgraph/example4/Another4, p=http://inova8.com/intelligentgraph/example4/hasHeight, o=\"1.8\"^^<http://www.w3.org/2001/XMLSchema#decimal>}; {s=http://inova8.com/intelligentgraph/example4/Another5, p=http://inova8.com/intelligentgraph/example4/hasHeight, o=\"1.5\"^^<http://www.w3.org/2001/XMLSchema#decimal>}; {s=http://inova8.com/intelligentgraph/example4/Another6, p=http://inova8.com/intelligentgraph/example4/hasHeight, o=\"1.5\"^^<http://www.w3.org/2001/XMLSchema#decimal>}; {s=http://inova8.com/intelligentgraph/example4/Another7, p=http://inova8.com/intelligentgraph/example4/hasHeight, o=\"1.7\"^^<http://www.w3.org/2001/XMLSchema#decimal>}; {s=http://inova8.com/intelligentgraph/example4/Another8, p=http://inova8.com/intelligentgraph/example4/hasHeight, o=\"1.6\"^^<http://www.w3.org/2001/XMLSchema#decimal>}; {s=http://inova8.com/intelligentgraph/example4/Another9, p=http://inova8.com/intelligentgraph/example4/hasHeight, o=\"1.7\"^^<http://www.w3.org/2001/XMLSchema#decimal>};]", classes.toString());
    } catch (Exception e) {
        assertEquals("", e.getCause().getMessage());
    }
}
Also used : 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 22 with ResourceResults

use of com.inova8.intelligentgraph.results.ResourceResults in project com.inova8.intelligentgraph by peterjohnlawrence.

the class Example4_Tests method example4_10.

@Test
@Order(10)
void example4_10() {
    try {
        ResourceResults facts = source.getFacts("[  eq :Another1]/:hasLocation/*");
        assertEquals("[ {s=http://inova8.com/intelligentgraph/example4/Tideswell, p=http://www.w3.org/1999/02/22-rdf-syntax-ns#type, o=http://inova8.com/intelligentgraph/example4/Location}; {s=http://inova8.com/intelligentgraph/example4/Tideswell, p=http://www.w3.org/2000/01/rdf-schema#label, o=\"Tideswell\"}; {s=http://inova8.com/intelligentgraph/example4/Tideswell, p=http://inova8.com/intelligentgraph/example4/averageBMI, o=\"21.7109303439298\"^^<http://www.w3.org/2001/XMLSchema#double>}; {s=http://inova8.com/intelligentgraph/example4/Tideswell, p=http://inova8.com/intelligentgraph/example4/total, o=\"7\"^^<http://www.w3.org/2001/XMLSchema#int>};]", facts.toString());
    } catch (Exception e) {
        assertEquals("", e.getCause().getMessage());
    }
}
Also used : 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 23 with ResourceResults

use of com.inova8.intelligentgraph.results.ResourceResults in project com.inova8.intelligentgraph by peterjohnlawrence.

the class Example4_Tests method example4_6.

@Test
@Order(6)
void example4_6() {
    try {
        ResourceResults classes = source.getFacts("[ a owl:Class]/rdfs:label");
        assertEquals("[ {s=http://inova8.com/intelligentgraph/example4/Person, p=http://www.w3.org/2000/01/rdf-schema#label, o=\"Person\"}; {s=http://inova8.com/intelligentgraph/example4/Gender, p=http://www.w3.org/2000/01/rdf-schema#label, o=\"Gender\"}; {s=http://inova8.com/intelligentgraph/example4/Gender_Location, p=http://www.w3.org/2000/01/rdf-schema#label, o=\"Gender Location\"}; {s=http://inova8.com/intelligentgraph/example4/Location, p=http://www.w3.org/2000/01/rdf-schema#label, o=\"Location\"};]", classes.toString());
    } catch (Exception e) {
        assertEquals("", e.getCause().getMessage());
    }
}
Also used : 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 24 with ResourceResults

use of com.inova8.intelligentgraph.results.ResourceResults in project com.inova8.intelligentgraph by peterjohnlawrence.

the class Example5_Tests method example5_6.

/**
 * Example 5 6.
 */
@Test
@Order(6)
void example5_6() {
    try {
        Thing aPerson = source.getThing(":aPerson");
        ResourceResults bmis = aPerson.getFacts("^:measurementOf[:hasDate [lt %1]]/:hasBMI", literal(LocalDate.parse("2021-08-03")));
        assertEquals("[ {s=http://inova8.com/intelligentgraph/example5/aPerson_Measurement_1, p=http://inova8.com/intelligentgraph/example5/hasBMI, o=\"21.453287197231838\"^^<http://www.w3.org/2001/XMLSchema#double>}; {s=http://inova8.com/intelligentgraph/example5/aPerson_Measurement_2, p=http://inova8.com/intelligentgraph/example5/hasBMI, o=\"22.03856749311295\"^^<http://www.w3.org/2001/XMLSchema#double>};]", bmis.toString());
    } catch (Exception e) {
        fail();
        e.printStackTrace();
    }
}
Also used : 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 25 with ResourceResults

use of com.inova8.intelligentgraph.results.ResourceResults in project com.inova8.intelligentgraph by peterjohnlawrence.

the class Example6_Tests method example6_3.

/**
 * Example 6 3.
 */
@Test
@Order(3)
void example6_3() {
    try {
        Thing aPerson = source.getThing(":aPerson");
        ResourceResults bmis = aPerson.getFacts(":Observation@:BMIObservation/:hasBMI");
        assertEquals("[ {s=http://inova8.com/intelligentgraph/example6/Measurement_1, p=http://inova8.com/intelligentgraph/example6/hasBMI, o=\"21.453287197231838\"^^<http://www.w3.org/2001/XMLSchema#double>}; {s=http://inova8.com/intelligentgraph/example6/Measurement_2, p=http://inova8.com/intelligentgraph/example6/hasBMI, o=\"22.03856749311295\"^^<http://www.w3.org/2001/XMLSchema#double>}; {s=http://inova8.com/intelligentgraph/example6/Measurement_3, p=http://inova8.com/intelligentgraph/example6/hasBMI, o=\"22.49134948096886\"^^<http://www.w3.org/2001/XMLSchema#double>}; {s=http://inova8.com/intelligentgraph/example6/Measurement_4, p=http://inova8.com/intelligentgraph/example6/hasBMI, o=\"19.723183391003463\"^^<http://www.w3.org/2001/XMLSchema#double>}; {s=http://inova8.com/intelligentgraph/example6/Measurement_5, p=http://inova8.com/intelligentgraph/example6/hasBMI, o=\"19.918367346938776\"^^<http://www.w3.org/2001/XMLSchema#double>}; {s=http://inova8.com/intelligentgraph/example6/Measurement_6, p=http://inova8.com/intelligentgraph/example6/hasBMI, o=\"20.571428571428573\"^^<http://www.w3.org/2001/XMLSchema#double>};]", bmis.toString());
    } catch (Exception e) {
        assertEquals("", e.getMessage());
        e.printStackTrace();
    }
}
Also used : 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)

Aggregations

ResourceResults (com.inova8.intelligentgraph.results.ResourceResults)46 Order (org.junit.jupiter.api.Order)42 Test (org.junit.jupiter.api.Test)42 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)42 Thing (com.inova8.intelligentgraph.model.Thing)33 Resource (com.inova8.intelligentgraph.model.Resource)23 Graph (com.inova8.intelligentgraph.intelligentGraphRepository.Graph)12 IntelligentGraphRepository (com.inova8.intelligentgraph.intelligentGraphRepository.IntelligentGraphRepository)7 ArrayList (java.util.ArrayList)7 NullValueReturnedException (com.inova8.intelligentgraph.exceptions.NullValueReturnedException)4 CustomQueryOptions (com.inova8.intelligentgraph.context.CustomQueryOptions)3 Path (com.inova8.intelligentgraph.path.Path)3 PathResults (com.inova8.intelligentgraph.results.PathResults)3 Trace (com.inova8.intelligentgraph.evaluator.Trace)2 ResourceStatementResults (com.inova8.intelligentgraph.results.ResourceStatementResults)2 PathPatternException (com.inova8.pathql.processor.PathPatternException)2 RecognitionException (org.antlr.v4.runtime.RecognitionException)2 IRI (org.eclipse.rdf4j.model.IRI)2 Statement (org.eclipse.rdf4j.model.Statement)2 QueryEvaluationException (org.eclipse.rdf4j.query.QueryEvaluationException)2