Search in sources :

Example 41 with Resource

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

the class Local_MultiGraphAddGetFact_Tests method test_10.

/**
 * Test 10.
 */
@Test
@Order(10)
void test_10() {
    try {
        Graph graph1 = source.openGraph("<http://inova8.com/calc2graph/testGraph1>");
        Thing myCountry = graph1.getThing(":Country");
        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.closeGraph("<http://inova8.com/calc2graph/testGraph1>");
        source.removeGraph("<http://inova8.com/calc2graph/testGraph1>");
    } catch (Exception e) {
        assertEquals("", e.getMessage());
    }
}
Also used : Graph(com.inova8.intelligentgraph.intelligentGraphRepository.Graph) Resource(com.inova8.intelligentgraph.model.Resource) Thing(com.inova8.intelligentgraph.model.Thing) ResourceResults(com.inova8.intelligentgraph.results.ResourceResults) PathPatternException(com.inova8.pathql.processor.PathPatternException) RecognitionException(org.antlr.v4.runtime.RecognitionException) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 42 with Resource

use of com.inova8.intelligentgraph.model.Resource 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();
    }
}
Also used : Path(com.inova8.intelligentgraph.path.Path) ArrayList(java.util.ArrayList) Resource(com.inova8.intelligentgraph.model.Resource) PathResults(com.inova8.intelligentgraph.results.PathResults) 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 43 with Resource

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

the class Local_GetFact_Tests method test_16.

/**
 * Test 16.
 */
@Test
@Order(16)
void test_16() {
    try {
        Thing _this = source.getThing(iri("http://inova8.com/calc2graph/id/Calc2Graph1"), null);
        Resource result = _this.getFact("^:Location@:appearsOn[eq id:BatteryLimit2]#");
        assertEquals("http://inova8.com/calc2graph/id/Location_BL2", result.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 44 with Resource

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

the class Local_GetFact_Tests method test_4.

/**
 * Test 4.
 */
@Test
@Order(4)
void test_4() {
    try {
        Thing _this = source.getThing(iri("http://inova8.com/calc2graph/id/Unit1"), null);
        Resource result = _this.getFact(":massThroughput");
        assertEquals("37.99999952316284", result.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 45 with Resource

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

the class Local_GetFact_Tests method test_34.

/**
 * Test 34.
 */
@Test
@Order(34)
void test_34() {
    try {
        source = IntelligentGraphRepository.create(workingRep);
        Thing _this = source.getThing(iri("http://inova8.com/calc2graph/id/BatteryLimit3"), null);
        Resource result = _this.getFact("<http://inova8.com/calc2graph/def/massYield>");
        assertEquals("0.26315789803903855", result.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)

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