Added intensive tests from queries
This commit is contained in:
parent
a51405c843
commit
49c361a342
|
@ -1,12 +1,15 @@
|
|||
package org.gcube.informationsystem.resourceregistry.query;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.net.URL;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.gcube.informationsystem.resourceregistry.ContextTest;
|
||||
import org.gcube.informationsystem.resourceregistry.query.json.JsonQuery;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -18,18 +21,42 @@ public class JsonQueryTest extends ContextTest {
|
|||
|
||||
private static Logger logger = LoggerFactory.getLogger(JsonQueryTest.class);
|
||||
|
||||
public File getQueriesDirectory() throws Exception {
|
||||
URL logbackFileURL = JsonQueryTest.class.getClassLoader().getResource("logback-test.xml");
|
||||
File logbackFile = new File(logbackFileURL.toURI());
|
||||
File resourcesDirectory = logbackFile.getParentFile();
|
||||
return new File(resourcesDirectory, "queries");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCreateQuery() throws Exception {
|
||||
URL url = JsonQueryTest.class.getResource("query.json");
|
||||
File queryFile = new File(url.toURI());
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
JsonNode jsonNode = objectMapper.readTree(queryFile);
|
||||
logger.info("Going to test the following JSON query {}", jsonNode.toString());
|
||||
File queriesDirectory = getQueriesDirectory();
|
||||
|
||||
JsonQuery jsonQuery = new JsonQuery();
|
||||
StringBuffer stringBuffer = jsonQuery.createQuery(jsonNode);
|
||||
|
||||
logger.info(stringBuffer.toString());
|
||||
for(int i=1; i<4; i++) {
|
||||
File jsonQueryFile = new File(queriesDirectory, "query" + i + ".json");
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
JsonNode jsonNode = objectMapper.readTree(jsonQueryFile);
|
||||
logger.info("Going to test the following JSON query {}", jsonNode.toString());
|
||||
|
||||
JsonQuery jsonQuery = new JsonQuery();
|
||||
StringBuffer createdStringBuffer = jsonQuery.createQuery(jsonNode);
|
||||
|
||||
logger.info("Created Query from JSON: {}", createdStringBuffer.toString());
|
||||
|
||||
StringBuffer expectedStringBuffer = new StringBuffer();
|
||||
File expectedQueryFile = new File(queriesDirectory, "query" + i + ".query");
|
||||
try(BufferedReader br = new BufferedReader(new FileReader(expectedQueryFile))) {
|
||||
for(String line; (line = br.readLine()) != null; ) {
|
||||
expectedStringBuffer.append(line);
|
||||
}
|
||||
}
|
||||
|
||||
logger.info("Expected Query from JSON: {}", createdStringBuffer.toString());
|
||||
|
||||
Assert.assertTrue(createdStringBuffer.toString().compareTo(expectedStringBuffer.toString())==0);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
SELECT FROM ( TRAVERSE outV("EService") FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM ( TRAVERSE inV("AccessPointFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( TRAVERSE outV("EService") FROM ( TRAVERSE inE("IsIdentifiedBy") FROM ( SELECT FROM ( TRAVERSE inV("SoftwareFacet") FROM ( TRAVERSE outE("IsIdentifiedBy") FROM ( TRAVERSE outV("EService") FROM ( SELECT FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM ( TRAVERSE inV("StateFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( TRAVERSE inV("EService") FROM ( TRAVERSE outE("Activates") FROM ( SELECT FROM ( TRAVERSE outV("HostingNode") FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM ( TRAVERSE inV("CPUFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( TRAVERSE outV("HostingNode") FROM ( SELECT FROM Activates WHERE header.uuid="d3f58e52-5346-47bc-b736-9d77a0b554ce")))) WHERE vendor="GenuineIntel"))) WHERE header.uuid="5fbc1a56-d450-4f0f-85c1-9b1684581717"))))) WHERE value="down")) WHERE propagationConstraint.add="propagate")))) WHERE name="data-transfer-service" AND group="DataTransfer"))))) WHERE endpoint="http://pc-frosini.isti.cnr.it:8080/data-transfer-service/gcube/service"))) WHERE header.uuid="0255b7ec-e3da-4071-b456-9a2907ece1db"
|
|
@ -0,0 +1,44 @@
|
|||
{
|
||||
"@class": "EService",
|
||||
"consistsOf": [
|
||||
{
|
||||
"@class": "ConsistsOf",
|
||||
"propagationConstraint" : {
|
||||
"add": "propagate"
|
||||
},
|
||||
"target": {
|
||||
"@class": "StateFacet",
|
||||
"value": "down"
|
||||
}
|
||||
},
|
||||
{
|
||||
"@class": "IsIdentifiedBy",
|
||||
"target": {
|
||||
"@class": "SoftwareFacet",
|
||||
"name": "data-transfer-service",
|
||||
"group": "DataTransfer"
|
||||
}
|
||||
},
|
||||
{
|
||||
"@class": "ConsistsOf",
|
||||
"target": {
|
||||
"@class": "AccessPointFacet",
|
||||
"endpoint": "http://pc-frosini.isti.cnr.it:8080/data-transfer-service/gcube/service"
|
||||
}
|
||||
}
|
||||
],
|
||||
"isRelatedTo" : [
|
||||
{
|
||||
"@class": "Activates",
|
||||
"header": {
|
||||
"uuid": "d3f58e52-5346-47bc-b736-9d77a0b554ce"
|
||||
},
|
||||
"source": {
|
||||
"@class": "HostingNode",
|
||||
"header": {
|
||||
"uuid" : "5fbc1a56-d450-4f0f-85c1-9b1684581717"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
TRAVERSE outV("EService") FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM ( TRAVERSE inV("AccessPointFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( TRAVERSE outV("EService") FROM ( TRAVERSE inE("IsIdentifiedBy") FROM ( SELECT FROM ( TRAVERSE inV("SoftwareFacet") FROM ( TRAVERSE outE("IsIdentifiedBy") FROM ( TRAVERSE outV("EService") FROM ( SELECT FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM ( TRAVERSE inV("StateFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( TRAVERSE inV("EService") FROM ( TRAVERSE outE("Activates") FROM ( SELECT FROM ( TRAVERSE outV("HostingNode") FROM ( SELECT FROM Activates WHERE header.uuid="d3f58e52-5346-47bc-b736-9d77a0b554ce")) WHERE header.uuid="5fbc1a56-d450-4f0f-85c1-9b1684581717"))))) WHERE value="down")) WHERE propagationConstraint.add="propagate")))) WHERE name="data-transfer-service" AND group="DataTransfer"))))) WHERE endpoint="http://pc-frosini.isti.cnr.it:8080/data-transfer-service/gcube/service"))
|
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
"@class": "EService",
|
||||
"consistsOf": [
|
||||
{
|
||||
"@class": "ConsistsOf",
|
||||
"propagationConstraint" : {
|
||||
"add": "propagate"
|
||||
},
|
||||
"target": {
|
||||
"@class": "StateFacet",
|
||||
"value": "down"
|
||||
}
|
||||
},
|
||||
{
|
||||
"@class": "IsIdentifiedBy",
|
||||
"target": {
|
||||
"@class": "SoftwareFacet",
|
||||
"name": "data-transfer-service",
|
||||
"group": "DataTransfer"
|
||||
}
|
||||
},
|
||||
{
|
||||
"@class": "ConsistsOf",
|
||||
"target": {
|
||||
"@class": "AccessPointFacet",
|
||||
"endpoint": "http://pc-frosini.isti.cnr.it:8080/data-transfer-service/gcube/service"
|
||||
}
|
||||
}
|
||||
],
|
||||
"isRelatedTo" : [
|
||||
{
|
||||
"@class": "Activates",
|
||||
"source": {
|
||||
"@class": "HostingNode",
|
||||
"consistsOf": [
|
||||
{
|
||||
"@class": "ConsistsOf",
|
||||
"target": {
|
||||
"@class": "CPUFacet",
|
||||
"vendor": "GenuineIntel"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
TRAVERSE outV("EService") FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM ( TRAVERSE inV("AccessPointFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( TRAVERSE outV("EService") FROM ( TRAVERSE inE("IsIdentifiedBy") FROM ( SELECT FROM ( TRAVERSE inV("SoftwareFacet") FROM ( TRAVERSE outE("IsIdentifiedBy") FROM ( TRAVERSE outV("EService") FROM ( SELECT FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM ( TRAVERSE inV("StateFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( TRAVERSE inV("EService") FROM ( TRAVERSE outE("Activates") FROM ( TRAVERSE outV("HostingNode") FROM ( TRAVERSE inE("ConsistsOf") FROM ( SELECT FROM ( TRAVERSE inV("CPUFacet") FROM ( TRAVERSE outE("ConsistsOf") FROM ( TRAVERSE outV("HostingNode") FROM ( SELECT FROM Activates)))) WHERE vendor="GenuineIntel"))))))) WHERE value="down")) WHERE propagationConstraint.add="propagate")))) WHERE name="data-transfer-service" AND group="DataTransfer"))))) WHERE endpoint="http://pc-frosini.isti.cnr.it:8080/data-transfer-service/gcube/service"))
|
Loading…
Reference in New Issue