diff --git a/vip-portal/src/main/resources/vm/gwendia-dot-inputs.vm b/vip-portal/src/main/resources/vm/gwendia-dot-inputs.vm index 8aa16401c..59bd99437 100644 --- a/vip-portal/src/main/resources/vm/gwendia-dot-inputs.vm +++ b/vip-portal/src/main/resources/vm/gwendia-dot-inputs.vm @@ -11,10 +11,18 @@ #set($type="URI") #end #if($input.getType().getCamelName()=="Flag") - + #if($input.getDefaultValue() && $input.getDefaultValue()!="") + + #else + + #end #else #if($input.getDefaultValue() && $input.getDefaultValue()!="") - + #if($input.getType().getCamelName()=="Number" && $input.isInteger()) + + #else + + #end #else #if($input.isOptional()==true) @@ -73,7 +81,7 @@ if ( result.startsWith("/") || result.startsWith("lfn:") ) { - + diff --git a/vip-portal/src/main/resources/vm/gwendia-standalone.vm b/vip-portal/src/main/resources/vm/gwendia-standalone.vm index 77d6389f2..98400e423 100644 --- a/vip-portal/src/main/resources/vm/gwendia-standalone.vm +++ b/vip-portal/src/main/resources/vm/gwendia-standalone.vm @@ -11,10 +11,18 @@ #set($type="URI") #end #if($input.getType().getCamelName()=="Flag") - + #if($input.getDefaultValue() && $input.getDefaultValue()!="") + + #else + + #end #else #if($input.getDefaultValue() && $input.getDefaultValue()!="") - + #if($input.getType().getCamelName()=="Number" && $input.isInteger()) + + #else + + #end #else #if($input.isOptional()==true) diff --git a/vip-portal/src/main/resources/vm/wrapper.vm b/vip-portal/src/main/resources/vm/wrapper.vm index f47b41bc1..1807008c6 100644 --- a/vip-portal/src/main/resources/vm/wrapper.vm +++ b/vip-portal/src/main/resources/vm/wrapper.vm @@ -177,7 +177,18 @@ fi # Change PYTHONPATH to make all strings unicode by default in python2 (as in python3) # Otherwise `bosh exec` fails on any non-ascii characters in outputs echo "import sys; sys.setdefaultencoding(\"UTF8\")" > sitecustomize.py -PYTHONPATH=".:$PYTHONPATH" $BOSHEXEC exec launch $JSONFILE input_param_file.json -v $PWD/../cache:$PWD/../cache +#creating a temporary directory for bindmount /tmp of containers +mkdir -p tmp +#TMP_FOLDER is created differently for execution on GRID and execution on LOCAL +#TMP of the container is bind mounted on TMP_FOLDER to avoid creating temporary files on container. +TMP_FOLDER=tmp_$(basename $PWD) +#if($isRunOnGrid == false) +TMP_FOLDER=/tmp/$TMP_FOLDER +#else +TMP_FOLDER=../$TMP_FOLDER +#end + +PYTHONPATH=".:$PYTHONPATH" $BOSHEXEC exec launch $JSONFILE input_param_file.json -v $PWD/../cache:$PWD/../cache -v $TMP_FOLDER:/tmp if [ $? != 0 ] then diff --git a/vip-portal/src/test/java/fr/insalyon/creatis/application/client/GwendiaTemplateTest.java b/vip-portal/src/test/java/fr/insalyon/creatis/application/client/GwendiaTemplateTest.java deleted file mode 100644 index bd91ad47b..000000000 --- a/vip-portal/src/test/java/fr/insalyon/creatis/application/client/GwendiaTemplateTest.java +++ /dev/null @@ -1,56 +0,0 @@ -package fr.insalyon.creatis.application.client; - -import fr.insalyon.creatis.vip.application.client.ApplicationConstants; -import fr.insalyon.creatis.vip.application.client.bean.Descriptor; -import fr.insalyon.creatis.vip.application.client.bean.boutiquesTools.BoutiquesApplication; -import fr.insalyon.creatis.vip.application.client.bean.boutiquesTools.BoutiquesInput; -import fr.insalyon.creatis.vip.application.client.bean.boutiquesTools.BoutiquesStringInput; -import fr.insalyon.creatis.vip.application.client.view.boutiquesParsing.InvalidBoutiquesDescriptorException; -import fr.insalyon.creatis.vip.application.server.business.simulation.parser.GwendiaParser; -import fr.insalyon.creatis.vip.applicationimporter.server.business.VelocityUtils; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.xml.sax.SAXException; - -import java.io.IOException; - -/* -This needs te be here to use the production velocity templates - */ -public class GwendiaTemplateTest { - - @Test - public void testDotGwendiaTemplate() throws IOException, InvalidBoutiquesDescriptorException, SAXException { - testStandaloneGwendiaTemplate("test input desc", "vm/gwendia-dot-inputs.vm"); - } - - @Test - public void testStandaloneGwendiaTemplate() throws IOException, InvalidBoutiquesDescriptorException, SAXException { - testStandaloneGwendiaTemplate("test input desc", "vm/gwendia-standalone.vm"); - } - - @Test - public void testDotGwendiaTemplateWithoutInputDesc() throws IOException, InvalidBoutiquesDescriptorException, SAXException { - testStandaloneGwendiaTemplate(null, "vm/gwendia-dot-inputs.vm"); - } - - @Test - public void testStandaloneGwendiaTemplateWithoutInputDesc() throws IOException, InvalidBoutiquesDescriptorException, SAXException { - testStandaloneGwendiaTemplate(null, "vm/gwendia-standalone.vm"); - } - - public void testStandaloneGwendiaTemplate(String inputDescription, String templateFile) throws IOException, InvalidBoutiquesDescriptorException, SAXException { - BoutiquesApplication boutiquesApp = new BoutiquesApplication("testApp", "test app desc", "42.43"); - boutiquesApp.addInput(new BoutiquesStringInput( - "testInputId", "test input", inputDescription, BoutiquesInput.InputType.FILE, - true, null, null, null, null, null, null));; - - - VelocityUtils sut = new VelocityUtils(); - String gwendiaString = sut.createDocument(boutiquesApp, "lnf:", templateFile); - Descriptor gwendiaApp = new GwendiaParser().parseString(gwendiaString); - Assertions.assertEquals(ApplicationConstants.INPUT_WITHOUT_VALUE, gwendiaApp.getSources().get(1).getDefaultValue()); - Assertions.assertEquals(inputDescription == null ? "" : inputDescription, gwendiaApp.getSources().get(1).getDescription()); - } - -} diff --git a/vip-portal/src/test/java/fr/insalyon/creatis/applicationimporter/GwendiaTemplateTest.java b/vip-portal/src/test/java/fr/insalyon/creatis/applicationimporter/GwendiaTemplateTest.java new file mode 100644 index 000000000..2b36d85f8 --- /dev/null +++ b/vip-portal/src/test/java/fr/insalyon/creatis/applicationimporter/GwendiaTemplateTest.java @@ -0,0 +1,93 @@ +package fr.insalyon.creatis.applicationimporter; + +import fr.insalyon.creatis.vip.application.client.ApplicationConstants; +import fr.insalyon.creatis.vip.application.client.bean.Descriptor; +import fr.insalyon.creatis.vip.application.client.bean.boutiquesTools.BoutiquesApplication; +import fr.insalyon.creatis.vip.application.client.bean.boutiquesTools.BoutiquesInput; +import fr.insalyon.creatis.vip.application.client.bean.boutiquesTools.BoutiquesNumberInput; +import fr.insalyon.creatis.vip.application.client.bean.boutiquesTools.BoutiquesStringInput; +import fr.insalyon.creatis.vip.application.client.view.boutiquesParsing.InvalidBoutiquesDescriptorException; +import fr.insalyon.creatis.vip.application.server.business.simulation.parser.GwendiaParser; +import fr.insalyon.creatis.vip.applicationimporter.server.business.VelocityUtils; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.xml.sax.SAXException; + +import java.io.IOException; + +/* +This needs te be here to use the production velocity templates + */ +public class GwendiaTemplateTest { + + final protected String DOT_TEMPLATE = "vm/gwendia-dot-inputs.vm"; + final protected String STANDALONE_TEMPLATE = "vm/gwendia-standalone.vm"; + + @ParameterizedTest + @ValueSource(strings = {DOT_TEMPLATE, STANDALONE_TEMPLATE}) + public void testTemplateWithNonNullDescription(String template) throws IOException, InvalidBoutiquesDescriptorException, SAXException { + String inputDescription = "test input description"; + Descriptor gwendiaDesc = testGwendiaTemplate( + template, + getBasicFileInput(1, inputDescription, null)); + Assertions.assertEquals(ApplicationConstants.INPUT_WITHOUT_VALUE, gwendiaDesc.getSources().get(1).getDefaultValue()); + Assertions.assertEquals(inputDescription, gwendiaDesc.getSources().get(1).getDescription()); + } + + @ParameterizedTest + @ValueSource(strings = {DOT_TEMPLATE, STANDALONE_TEMPLATE}) + public void testTemplateWithNullDescription(String template) throws IOException, InvalidBoutiquesDescriptorException, SAXException { + // when the description is not in boutiques, it must be an empty string in gwendia + Descriptor gwendiaDesc = testGwendiaTemplate( + template, + getBasicFileInput(1, null, null)); + Assertions.assertEquals(ApplicationConstants.INPUT_WITHOUT_VALUE, gwendiaDesc.getSources().get(1).getDefaultValue()); + Assertions.assertEquals("", gwendiaDesc.getSources().get(1).getDescription()); + } + + @ParameterizedTest + @ValueSource(strings = {DOT_TEMPLATE, STANDALONE_TEMPLATE}) + public void testTemplateWithAIntegerInput(String template) throws IOException, InvalidBoutiquesDescriptorException, SAXException { + Descriptor gwendiaDesc = testGwendiaTemplate( + template, + getIntegerInput(1, 42.)); + Assertions.assertEquals("42", gwendiaDesc.getSources().get(1).getDefaultValue()); + } + + @ParameterizedTest + @ValueSource(strings = {DOT_TEMPLATE, STANDALONE_TEMPLATE}) + public void testTemplateWithANumberInput(String template) throws IOException, InvalidBoutiquesDescriptorException, SAXException { + Descriptor gwendiaDesc = testGwendiaTemplate( + template, + getNumberInput(1, false, 42.)); + Assertions.assertEquals("42.0", gwendiaDesc.getSources().get(1).getDefaultValue()); + } + + protected BoutiquesInput getIntegerInput(Object id, Double defaultValue) { + return getNumberInput(1, true, 42.); + } + + protected BoutiquesInput getNumberInput(Object id, boolean isInteger, Double defaultValue) { + return new BoutiquesNumberInput("testNumberInput" + id, "test number input " + id, "test number description", + true, null, null, null, null, null, defaultValue, isInteger, false, false, null, null); + } + + protected BoutiquesInput getBasicFileInput(Object id, String description, String defaultValue) { + return new BoutiquesStringInput( + "testFileInput" + id, "test file input " +id, description, BoutiquesInput.InputType.FILE, + true, null, null, null, null, null, defaultValue); + } + + protected Descriptor testGwendiaTemplate(String templateFile, BoutiquesInput... inputs) throws IOException, SAXException { + BoutiquesApplication boutiquesApp = new BoutiquesApplication("testApp", "test app desc", "42.43"); + for (BoutiquesInput input : inputs) { + boutiquesApp.addInput(input); + } + VelocityUtils sut = new VelocityUtils(); + String gwendiaString = sut.createDocument(boutiquesApp, "lnf:", templateFile); + return new GwendiaParser().parseString(gwendiaString); + } + +}