From 1ccb96fd9c48b92dba84a26ffbe80f89c3291239 Mon Sep 17 00:00:00 2001 From: Axel Bonnet Date: Thu, 11 Jul 2024 11:22:46 +0200 Subject: [PATCH] correct wrapper template with test --- vip-portal/src/main/resources/vm/wrapper.vm | 11 +++-- .../WrapperTemplateTest.java | 45 +++++++++++++++++++ 2 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 vip-portal/src/test/java/fr/insalyon/creatis/applicationimporter/WrapperTemplateTest.java diff --git a/vip-portal/src/main/resources/vm/wrapper.vm b/vip-portal/src/main/resources/vm/wrapper.vm index d8c4d491d..e424af8d6 100644 --- a/vip-portal/src/main/resources/vm/wrapper.vm +++ b/vip-portal/src/main/resources/vm/wrapper.vm @@ -167,9 +167,6 @@ JSONPARAMETERS # Command-line execution # ########################## -TOOLNAME="$tool.getName()" -JSONFILE="${TOOLNAME}.json" - # BOSH_CVMFS_PATH is defined by GASW from the settings file checkBosh $BOSH_CVMFS_PATH @@ -204,10 +201,12 @@ TMP_FOLDER=../$TMP_FOLDER #end mkdir -p $TMP_FOLDER -#if($imagepath == "") -PYTHONPATH=".:$PYTHONPATH" $BOSHEXEC exec launch $JSONFILE input_param_file.json -v $PWD/../cache:$PWD/../cache -v $TMP_FOLDER:/tmp +#set($jsonFile="${tool.getName()}.json") + +#if($imagepath) +PYTHONPATH=".:$PYTHONPATH" $BOSHEXEC exec launch --imagepath $imagepath $jsonFile input_param_file.json -v $PWD/../cache:$PWD/../cache -v $TMP_FOLDER:/tmp #else -PYTHONPATH=".:$PYTHONPATH" $BOSHEXEC exec launch --imagepath $imagepath $JSONFILE input_param_file.json -v $PWD/../cache:$PWD/../cache -v $TMP_FOLDER:/tmp +PYTHONPATH=".:$PYTHONPATH" $BOSHEXEC exec launch $jsonFile input_param_file.json -v $PWD/../cache:$PWD/../cache -v $TMP_FOLDER:/tmp #end if [ $? != 0 ] diff --git a/vip-portal/src/test/java/fr/insalyon/creatis/applicationimporter/WrapperTemplateTest.java b/vip-portal/src/test/java/fr/insalyon/creatis/applicationimporter/WrapperTemplateTest.java new file mode 100644 index 000000000..4f10c5ad4 --- /dev/null +++ b/vip-portal/src/test/java/fr/insalyon/creatis/applicationimporter/WrapperTemplateTest.java @@ -0,0 +1,45 @@ +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.hamcrest.CoreMatchers; +import org.hamcrest.MatcherAssert; +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; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.not; + +/* +This needs te be here to use the production velocity templates + */ +public class WrapperTemplateTest { + + final protected String WRAPPER_TEMPLATE = "vm/wrapper.vm"; + + @Test + public void testImagePathInWrapperTemplate() throws IOException, InvalidBoutiquesDescriptorException, SAXException { + BoutiquesApplication boutiquesApp = new BoutiquesApplication("testApp", "test app desc", "42.43"); + VelocityUtils sut = new VelocityUtils(); + // if null + String wrapperString = sut.createDocument(null, boutiquesApp, false, WRAPPER_TEMPLATE); + MatcherAssert.assertThat(wrapperString, containsString("exec launch testApp.json input_param_file.json")); + // if present + boutiquesApp.setVipContainer("testContainer"); + wrapperString = sut.createDocument(null, boutiquesApp, false, WRAPPER_TEMPLATE); + MatcherAssert.assertThat(wrapperString, containsString("exec launch --imagepath testContainer testApp.json input_param_file.json")); + } + +}