From df2161c04cb78a6472f4c5e3b0a384faeb65be28 Mon Sep 17 00:00:00 2001 From: mateii Date: Sun, 7 Feb 2021 20:59:40 +0200 Subject: [PATCH 1/4] test use_jython --- content/io/cloudslang/base/math/add_numbers.sl | 1 + 1 file changed, 1 insertion(+) diff --git a/content/io/cloudslang/base/math/add_numbers.sl b/content/io/cloudslang/base/math/add_numbers.sl index de552b9aa9..374918838c 100644 --- a/content/io/cloudslang/base/math/add_numbers.sl +++ b/content/io/cloudslang/base/math/add_numbers.sl @@ -36,6 +36,7 @@ operation: - value2 python_action: + use_jython: true script: | try: from java.math import BigDecimal,MathContext From fa35ac173619c6b0632d090f4468e61a1ecb977d Mon Sep 17 00:00:00 2001 From: mateii Date: Mon, 8 Feb 2021 22:50:33 +0200 Subject: [PATCH 2/4] test use_jython 2 --- .../io/cloudslang/base/math/add_numbers.sl | 32 ++++--------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/content/io/cloudslang/base/math/add_numbers.sl b/content/io/cloudslang/base/math/add_numbers.sl index 374918838c..8e9f185269 100644 --- a/content/io/cloudslang/base/math/add_numbers.sl +++ b/content/io/cloudslang/base/math/add_numbers.sl @@ -30,32 +30,14 @@ namespace: io.cloudslang.base.math operation: name: add_numbers - inputs: - - value1 - - value2 - + - value python_action: - use_jython: true - script: | - try: - from java.math import BigDecimal,MathContext - from java.lang import Exception as JavaException - value1 = BigDecimal(value1, MathContext.DECIMAL64) - value2 = BigDecimal(value2, MathContext.DECIMAL64) - result = value1.add(value2, MathContext.DECIMAL64).stripTrailingZeros().toPlainString() - return_code = '0' - except JavaException as je: - return_code = '-1' - result = "Invalid number format" - except Exception as e: - return_code = '-1' - result = e - + use_jython: false + script: "# do not remove the execute function \ndef execute(value): \n x = int(value)\n if x > 5:\n return{\"return_code\":\"1\", \"exception\":'x should not exceed 5.'}\n else:\n return{\"return_code\":\"0\"}\n# you can add additional helper methods below." outputs: - - result - - return_code - + - return_code + - exception results: - - SUCCESS: ${return_code == '0'} - - FAILURE \ No newline at end of file + - SUCCESS: '${return_code==0}' + - FAILURE From 2c8edd49c1ddf7c1b27cbe1d1da920fd8362f6ba Mon Sep 17 00:00:00 2001 From: mateii Date: Tue, 9 Feb 2021 12:59:03 +0200 Subject: [PATCH 3/4] changed the version of cloudslang --- .travis.yml | 2 +- content/io/cloudslang/base/math/add_numbers.sl | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 031f632e18..0838d2644b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,7 +40,7 @@ script: - docker info - docker version - df -kh - - wget https://github.com/CloudSlang/cloud-slang/releases/download/cloudslang-1.0.96/cslang-builder.zip + - wget https://github.com/CloudSlang/cloud-slang/releases/download/cloudslang-1.0.243/cslang-builder.zip - unzip -q cslang-builder.zip - chmod +x cslang-builder/bin/cslang-builder - ./cslang-builder/bin/cslang-builder -ts ${SUITE},\!default -cov -des -cs diff --git a/content/io/cloudslang/base/math/add_numbers.sl b/content/io/cloudslang/base/math/add_numbers.sl index 8e9f185269..dbe13d9e62 100644 --- a/content/io/cloudslang/base/math/add_numbers.sl +++ b/content/io/cloudslang/base/math/add_numbers.sl @@ -15,10 +15,9 @@ #!! #! @description: Adds two numbers as floating point values. #! -#! @input value1: First value as number or string. -#! @input value2: Second value as number or string. +#! @input value: First value as number or string. #! -#! @output result: Operation result or reason for failure. +#! @output exception: Operation result or reason for failure. #! @output return_code: Operation return code ('0' or '-1'). #! #! @result SUCCESS: The operation completed successfully. @@ -26,8 +25,12 @@ #!!# ######################################################################################################################## + + namespace: io.cloudslang.base.math + + operation: name: add_numbers inputs: @@ -40,4 +43,4 @@ operation: - exception results: - SUCCESS: '${return_code==0}' - - FAILURE + - FAILURE \ No newline at end of file From b532e33ae1995063eae2225636c0246e60753ab6 Mon Sep 17 00:00:00 2001 From: mateii Date: Tue, 9 Feb 2021 14:35:22 +0200 Subject: [PATCH 4/4] changed the version of cloudslang --- .../io/cloudslang/base/math/add_numbers.sl | 1 - content/io/cloudslang/base/math/test.sl | 41 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 content/io/cloudslang/base/math/test.sl diff --git a/content/io/cloudslang/base/math/add_numbers.sl b/content/io/cloudslang/base/math/add_numbers.sl index 374918838c..de552b9aa9 100644 --- a/content/io/cloudslang/base/math/add_numbers.sl +++ b/content/io/cloudslang/base/math/add_numbers.sl @@ -36,7 +36,6 @@ operation: - value2 python_action: - use_jython: true script: | try: from java.math import BigDecimal,MathContext diff --git a/content/io/cloudslang/base/math/test.sl b/content/io/cloudslang/base/math/test.sl new file mode 100644 index 0000000000..15b259fda7 --- /dev/null +++ b/content/io/cloudslang/base/math/test.sl @@ -0,0 +1,41 @@ +# (c) Copyright 2019 EntIT Software LLC, a Micro Focus company, L.P. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License v2.0 which accompany this distribution. +# +# The Apache License is available at +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +######################################################################################################################## +#!! +#! @description: test. +#! +#! @input value: test. +#! +#! @output return_code: test. +#! @output exception: test. +#! +#! @result SUCCESS: test. +#! @result FAILURE: test. +#!!# +######################################################################################################################## +namespace: io.cloudslang.base.math +operation: + name: test + inputs: + - value + python_action: + use_jython: false + script: "# do not remove the execute function \ndef execute(value): \n x = int(value)\n if x > 5:\n return{\"return_code\":\"1\", \"exception\":'x should not exceed 5.'}\n else:\n return{\"return_code\":\"0\"}\n# you can add additional helper methods below." + outputs: + - return_code + - exception + results: + - SUCCESS: "${return_code == '0'}" + - FAILURE +