From 39d23d29fd8690a5db816b4c0b9c600dbf3cf5ab Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Fri, 20 Apr 2018 12:23:26 +0200 Subject: [PATCH 1/3] [refactoring] increase readability: deployMode --- test/groovy/NeoDeployTest.groovy | 2 +- vars/neoDeploy.groovy | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/test/groovy/NeoDeployTest.groovy b/test/groovy/NeoDeployTest.groovy index cbd689fe8..4270716a6 100644 --- a/test/groovy/NeoDeployTest.groovy +++ b/test/groovy/NeoDeployTest.groovy @@ -366,7 +366,7 @@ class NeoDeployTest extends BasePipelineTest { void illegalDeployModeTest() { thrown.expect(Exception) - thrown.expectMessage("[neoDeploy] Invalid deployMode = 'illegalMode'. Valid 'deployMode' values are: 'mta', 'warParams' and 'warPropertiesFile'") + thrown.expectMessage("[neoDeploy] Invalid deployMode = 'illegalMode'. Valid 'deployMode' values are: [mta, warParams, warPropertiesFile]") jsr.step.call(script: [commonPipelineEnvironment: jer.env], archivePath: warArchiveName, diff --git a/vars/neoDeploy.groovy b/vars/neoDeploy.groovy index 7c4a24cd4..5194e16ba 100644 --- a/vars/neoDeploy.groovy +++ b/vars/neoDeploy.groovy @@ -110,11 +110,12 @@ def call(parameters = [:]) { def runtimeVersion def vmSize - if (deployMode != 'mta' && deployMode != 'warParams' && deployMode != 'warPropertiesFile') { - throw new Exception("[neoDeploy] Invalid deployMode = '${deployMode}'. Valid 'deployMode' values are: 'mta', 'warParams' and 'warPropertiesFile'") + def deployModes = ['mta', 'warParams', 'warPropertiesFile'] + if (! (deployMode in deployModes)) { + throw new Exception("[neoDeploy] Invalid deployMode = '${deployMode}'. Valid 'deployMode' values are: ${deployModes}.") } - if (deployMode == 'warPropertiesFile' || deployMode == 'warParams') { + if (deployMode in ['warPropertiesFile', 'warParams']) { warAction = utils.getMandatoryParameter(configuration, 'warAction') if (warAction != 'deploy' && warAction != 'rolling-update') { throw new Exception("[neoDeploy] Invalid warAction = '${warAction}'. Valid 'warAction' values are: 'deploy' and 'rolling-update'.") @@ -138,7 +139,7 @@ def call(parameters = [:]) { } } - if (deployMode.equals('mta') || deployMode.equals('warParams')) { + if (deployMode in ['mta','warParams']) { deployHost = utils.getMandatoryParameter(configuration, 'host') deployAccount = utils.getMandatoryParameter(configuration, 'account') } From 73abb0ee9948313c3de322531efdb9802a5ab27f Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Fri, 20 Apr 2018 12:24:37 +0200 Subject: [PATCH 2/3] [refactoring] increase readability: vmSize --- test/groovy/NeoDeployTest.groovy | 2 +- vars/neoDeploy.groovy | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/test/groovy/NeoDeployTest.groovy b/test/groovy/NeoDeployTest.groovy index 4270716a6..2c5c4f3ec 100644 --- a/test/groovy/NeoDeployTest.groovy +++ b/test/groovy/NeoDeployTest.groovy @@ -382,7 +382,7 @@ class NeoDeployTest extends BasePipelineTest { void illegalVMSizeTest() { thrown.expect(Exception) - thrown.expectMessage("[neoDeploy] Invalid vmSize = 'illegalVM'. Valid 'vmSize' values are: 'lite', 'pro', 'prem' and 'prem-plus'.") + thrown.expectMessage("[neoDeploy] Invalid vmSize = 'illegalVM'. Valid 'vmSize' values are: [lite, pro, prem, prem-plus].") jsr.step.call(script: [commonPipelineEnvironment: jer.env], archivePath: warArchiveName, diff --git a/vars/neoDeploy.groovy b/vars/neoDeploy.groovy index 5194e16ba..13c0513d3 100644 --- a/vars/neoDeploy.groovy +++ b/vars/neoDeploy.groovy @@ -133,9 +133,10 @@ def call(parameters = [:]) { applicationName = utils.getMandatoryParameter(configuration, 'applicationName') runtime = utils.getMandatoryParameter(configuration, 'runtime') runtimeVersion = utils.getMandatoryParameter(configuration, 'runtimeVersion') + def vmSizes = ['lite', 'pro', 'prem', 'prem-plus'] vmSize = configuration.vmSize - if (vmSize != 'lite' && vmSize !='pro' && vmSize != 'prem' && vmSize != 'prem-plus') { - throw new Exception("[neoDeploy] Invalid vmSize = '${vmSize}'. Valid 'vmSize' values are: 'lite', 'pro', 'prem' and 'prem-plus'.") + if (! (vmSize in vmSizes)) { + throw new Exception("[neoDeploy] Invalid vmSize = '${vmSize}'. Valid 'vmSize' values are: ${vmSizes}.") } } From 62fee7a63c2e0c27de8fbb33ee33e4ccdd3eb774 Mon Sep 17 00:00:00 2001 From: Marcus Holl Date: Fri, 20 Apr 2018 12:25:15 +0200 Subject: [PATCH 3/3] [refactoring] increase readability: warAction --- test/groovy/NeoDeployTest.groovy | 2 +- vars/neoDeploy.groovy | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/test/groovy/NeoDeployTest.groovy b/test/groovy/NeoDeployTest.groovy index 2c5c4f3ec..e4ea699e1 100644 --- a/test/groovy/NeoDeployTest.groovy +++ b/test/groovy/NeoDeployTest.groovy @@ -398,7 +398,7 @@ class NeoDeployTest extends BasePipelineTest { void illegalWARActionTest() { thrown.expect(Exception) - thrown.expectMessage("[neoDeploy] Invalid warAction = 'illegalWARAction'. Valid 'warAction' values are: 'deploy' and 'rolling-update'.") + thrown.expectMessage("[neoDeploy] Invalid warAction = 'illegalWARAction'. Valid 'warAction' values are: [deploy, rolling-update].") jsr.step.call(script: [commonPipelineEnvironment: jer.env], archivePath: warArchiveName, diff --git a/vars/neoDeploy.groovy b/vars/neoDeploy.groovy index 13c0513d3..907644966 100644 --- a/vars/neoDeploy.groovy +++ b/vars/neoDeploy.groovy @@ -117,8 +117,9 @@ def call(parameters = [:]) { if (deployMode in ['warPropertiesFile', 'warParams']) { warAction = utils.getMandatoryParameter(configuration, 'warAction') - if (warAction != 'deploy' && warAction != 'rolling-update') { - throw new Exception("[neoDeploy] Invalid warAction = '${warAction}'. Valid 'warAction' values are: 'deploy' and 'rolling-update'.") + def warActions = ['deploy', 'rolling-update'] + if (! (warAction in warActions)) { + throw new Exception("[neoDeploy] Invalid warAction = '${warAction}'. Valid 'warAction' values are: ${warActions}.") } }