Skip to content

Commit

Permalink
Added some junits for recent bug that slipped through
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Cuddihy committed Feb 8, 2021
1 parent d25c0ae commit 3079211
Show file tree
Hide file tree
Showing 5 changed files with 272 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,19 @@ public void basicSelectQuery() throws Exception {
assertEquals(4, tab.getNumColumns());
}

@Test
public void selectSuperSubClass() throws Exception {
Table tab;
tab = TestGraph.execSelectFromResource(this.getClass(), "animalQuery.json");
assertEquals("Unexpected number of Animals", 12, tab.getNumRows());

tab = TestGraph.execSelectFromResource(this.getClass(), "animalQueryCat.json");
assertEquals("Unexpected number of Cats", 10, tab.getNumRows());

tab = TestGraph.execSelectFromResource(this.getClass(), "animalQueryTiger.json");
assertEquals("Unexpected number of Tigers", 4, tab.getNumRows());
}

@Test
public void returnTypeSelectQuery() throws Exception {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,43 @@ public void doLookupBatteryIdAddDesc(boolean cacheFlag) throws Exception {

}

@Test
public void test_LookupSuperBatteryIdAddDesc() throws Exception {
doLookupSuperBatteryIdAddDesc(true);
doLookupSuperBatteryIdAddDesc(false);
}

/**
* Lookup is performed by superclass
* @param cacheFlag
* @throws Exception
*/
public void doLookupSuperBatteryIdAddDesc(boolean cacheFlag) throws Exception {
// setup
TestGraph.clearGraph();

// ==== pre set some data =====
TestGraph.uploadOwlResource(this, "/loadTestDuraBattery.owl");
SparqlGraphJson sgJson0 = TestGraph.getSparqlGraphJsonFromFile("src/test/resources/loadTestDuraBattery.json");
Dataset ds0 = new CSVDataset("src/test/resources/loadTestDuraBatteryData.csv", false);

DataLoader dl0 = new DataLoader(sgJson0, ds0, TestGraph.getUsername(), TestGraph.getPassword());

loadData(dl0, "doLookupBatteryIdAddDesc PRELOAD", cacheFlag);

// Try URI lookup
SparqlGraphJson sgJson = TestGraph.getSparqlGraphJsonFromFile("src/test/resources/lookupSuperclassIdAddDesc.json");

Dataset ds = new CSVDataset("src/test/resources/lookupBatteryIdAddDescData.csv", false);

// import
DataLoader dl = new DataLoader(sgJson, ds, TestGraph.getUsername(), TestGraph.getPassword());
loadData(dl, "doLookupBatteryIdAddDesc LOOKUP", cacheFlag);

sgJson = TestGraph.getSparqlGraphJsonFromFile("src/test/resources/lookupBatteryIdAddDesc.json");
TestGraph.queryAndCheckResults(sgJson, this, "/lookupBatteryIdAddDescResults.csv");

}
@Test
public void test_LookupBatteryIdAddDescShort() throws Exception {
doLookupBatteryIdAddDescShort(false);
Expand Down
74 changes: 74 additions & 0 deletions sparqlGraphLibrary/src/test/resources/animalQuery.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"version": 2,
"sparqlConn": {
"name": "Junit localhost virt",
"domain": "",
"enableOwlImports": true,
"model": [
{
"type": "virtuoso",
"url": "http://localhost:8890/sparql",
"graph": "http://junit/GG2NQYY2E/200001934/both"
}
],
"data": [
{
"type": "virtuoso",
"url": "http://localhost:8890/sparql",
"graph": "http://junit/GG2NQYY2E/200001934/both"
}
]
},
"sNodeGroup": {
"version": 12,
"limit": 0,
"offset": 0,
"sNodeList": [
{
"propList": [
{
"KeyName": "name",
"ValueType": "string",
"relationship": "http://www.w3.org/2001/XMLSchema#string",
"UriRelationship": "http://AnimalSubProps#name",
"Constraints": "",
"fullURIName": "",
"SparqlID": "?name",
"isReturned": true,
"optMinus": 0,
"isRuntimeConstrained": false,
"instanceValues": [],
"isMarkedForDeletion": false
}
],
"nodeList": [],
"NodeName": "Animal",
"fullURIName": "http://AnimalSubProps#Animal",
"SparqlID": "?Animal",
"isReturned": false,
"isRuntimeConstrained": false,
"valueConstraint": "",
"instanceValue": null,
"deletionMode": "NO_DELETE"
}
],
"orderBy": [],
"unionHash": {}
},
"importSpec": {
"version": "1",
"baseURI": "",
"columns": [],
"dataValidator": [],
"texts": [],
"transforms": [],
"nodes": [
{
"sparqlID": "?Animal",
"type": "http://AnimalSubProps#Animal",
"mapping": [],
"props": []
}
]
}
}
74 changes: 74 additions & 0 deletions sparqlGraphLibrary/src/test/resources/animalQueryCat.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"version": 2,
"sparqlConn": {
"name": "Junit localhost virt",
"domain": "",
"enableOwlImports": true,
"model": [
{
"type": "virtuoso",
"url": "http://localhost:8890/sparql",
"graph": "http://junit/GG2NQYY2E/200001934/both"
}
],
"data": [
{
"type": "virtuoso",
"url": "http://localhost:8890/sparql",
"graph": "http://junit/GG2NQYY2E/200001934/both"
}
]
},
"sNodeGroup": {
"version": 12,
"limit": 0,
"offset": 0,
"sNodeList": [
{
"propList": [
{
"KeyName": "name",
"ValueType": "string",
"relationship": "http://www.w3.org/2001/XMLSchema#string",
"UriRelationship": "http://AnimalSubProps#name",
"Constraints": "",
"fullURIName": "",
"SparqlID": "?catName",
"isReturned": true,
"optMinus": 0,
"isRuntimeConstrained": false,
"instanceValues": [],
"isMarkedForDeletion": false
}
],
"nodeList": [],
"NodeName": "Cat",
"fullURIName": "http://AnimalSubProps#Cat",
"SparqlID": "?Cat",
"isReturned": false,
"isRuntimeConstrained": false,
"valueConstraint": "",
"instanceValue": null,
"deletionMode": "NO_DELETE"
}
],
"orderBy": [],
"unionHash": {}
},
"importSpec": {
"version": "1",
"baseURI": "",
"columns": [],
"dataValidator": [],
"texts": [],
"transforms": [],
"nodes": [
{
"sparqlID": "?Cat",
"type": "http://AnimalSubProps#Cat",
"mapping": [],
"props": []
}
]
}
}
74 changes: 74 additions & 0 deletions sparqlGraphLibrary/src/test/resources/animalQueryTiger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"version": 2,
"sparqlConn": {
"name": "Junit localhost virt",
"domain": "",
"enableOwlImports": true,
"model": [
{
"type": "virtuoso",
"url": "http://localhost:8890/sparql",
"graph": "http://junit/GG2NQYY2E/200001934/both"
}
],
"data": [
{
"type": "virtuoso",
"url": "http://localhost:8890/sparql",
"graph": "http://junit/GG2NQYY2E/200001934/both"
}
]
},
"sNodeGroup": {
"version": 12,
"limit": 0,
"offset": 0,
"sNodeList": [
{
"propList": [
{
"KeyName": "name",
"ValueType": "string",
"relationship": "http://www.w3.org/2001/XMLSchema#string",
"UriRelationship": "http://AnimalSubProps#name",
"Constraints": "",
"fullURIName": "",
"SparqlID": "?name",
"isReturned": true,
"optMinus": 0,
"isRuntimeConstrained": false,
"instanceValues": [],
"isMarkedForDeletion": false
}
],
"nodeList": [],
"NodeName": "Tiger",
"fullURIName": "http://AnimalSubProps#Tiger",
"SparqlID": "?Tiger",
"isReturned": false,
"isRuntimeConstrained": false,
"valueConstraint": "",
"instanceValue": null,
"deletionMode": "NO_DELETE"
}
],
"orderBy": [],
"unionHash": {}
},
"importSpec": {
"version": "1",
"baseURI": "",
"columns": [],
"dataValidator": [],
"texts": [],
"transforms": [],
"nodes": [
{
"sparqlID": "?Tiger",
"type": "http://AnimalSubProps#Tiger",
"mapping": [],
"props": []
}
]
}
}

0 comments on commit 3079211

Please sign in to comment.