From 7dff6271f5716d4aa506dd856966967d53b55c32 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Tue, 26 Oct 2021 21:44:19 +0200 Subject: [PATCH] Fixed test --- .../QueryTemplateManagementTest.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/queries/templates/QueryTemplateManagementTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/queries/templates/QueryTemplateManagementTest.java index db8f84d..112dc25 100644 --- a/src/test/java/org/gcube/informationsystem/resourceregistry/queries/templates/QueryTemplateManagementTest.java +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/queries/templates/QueryTemplateManagementTest.java @@ -5,10 +5,12 @@ import java.net.URL; import org.gcube.com.fasterxml.jackson.databind.JsonNode; import org.gcube.com.fasterxml.jackson.databind.ObjectMapper; +import org.gcube.com.fasterxml.jackson.databind.node.ObjectNode; import org.gcube.informationsystem.queries.templates.impl.entities.QueryTemplateImpl; import org.gcube.informationsystem.queries.templates.impl.properties.TemplateVariableImpl; import org.gcube.informationsystem.queries.templates.reference.entities.QueryTemplate; import org.gcube.informationsystem.queries.templates.reference.properties.TemplateVariable; +import org.gcube.informationsystem.resourceregistry.ContextTest; import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException; import org.gcube.informationsystem.resourceregistry.queries.JsonQueryTest; import org.gcube.informationsystem.utils.ElementMapper; @@ -16,7 +18,7 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class QueryTemplateManagementTest { +public class QueryTemplateManagementTest extends ContextTest { private static Logger logger = LoggerFactory.getLogger(QueryTemplateManagementTest.class); @@ -42,19 +44,22 @@ public class QueryTemplateManagementTest { queryTemplate.setTemplate(jsonNode); TemplateVariable stateTemplateVariable = new TemplateVariableImpl(); - stateTemplateVariable.setName("$state"); + String stateVariableName = "$state"; + stateTemplateVariable.setName(stateVariableName); stateTemplateVariable.setDescription("StateFacet value"); stateTemplateVariable.setDefaultValue("running"); queryTemplate.addTemplateVariable(stateTemplateVariable); TemplateVariable nameTemplateVariable = new TemplateVariableImpl(); - nameTemplateVariable.setName("$name"); + String nameVariableName = "$name"; + nameTemplateVariable.setName(nameVariableName); nameTemplateVariable.setDescription("SoftwareFacet name"); nameTemplateVariable.setDefaultValue("resource-registry"); queryTemplate.addTemplateVariable(nameTemplateVariable); TemplateVariable groupTemplateVariable = new TemplateVariableImpl(); - groupTemplateVariable.setName("$group"); + String groupVariableName = "$group"; + groupTemplateVariable.setName(groupVariableName); groupTemplateVariable.setDescription("SoftwareFacet group"); groupTemplateVariable.setDefaultValue("information-system"); queryTemplate.addTemplateVariable(groupTemplateVariable); @@ -117,9 +122,14 @@ public class QueryTemplateManagementTest { queryTemplateManagement = new QueryTemplateManagement(); queryTemplateManagement.setName(name); - // TODO Set Values - queryTemplateManagement.run(); + ObjectNode params = objectMapper.createObjectNode(); + params.put(stateVariableName, "running"); + params.put(groupVariableName, "DataAccess"); + params.put(nameVariableName, "StorageHub"); + queryTemplateManagement.setParams(params); + + queryTemplateManagement.run(); }finally { queryTemplateManagement.delete();