Skip to content

Commit

Permalink
feat: Remove usePrefix and useSuffix properties (#90)
Browse files Browse the repository at this point in the history
* feat: Remove usePrefix and useSuffix attributes

* docs: Remove usePrefix and useSuffix from examples

* test: Fix unit tests that use usePrefix and useSuffix properties

* test: Fix unit tests that use usePrefix and useSuffix properties

* test: Keep unit tests with original behaviour for usePrefix and useSuffix

* test: Keep unit tests with original behaviour for usePrefix and useSuffix
  • Loading branch information
talyssoncastro authored Jan 17, 2024
1 parent f0cd0a2 commit 8d0c6e9
Show file tree
Hide file tree
Showing 26 changed files with 111 additions and 201 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,8 @@ muleDeploy {
environment 'DEV'
applicationName {
baseAppName 'the-app'
prefix 'AVI'
suffix 'xxx'
usePrefix false
useSuffix false
prefix ''
suffix ''
}
appVersion '1.2.3'
file '${builtFile}'
Expand Down Expand Up @@ -176,10 +174,8 @@ muleDeploy {
environment 'DEV'
applicationName {
baseAppName 'the-app'
prefix 'AVI'
suffix 'xxx'
usePrefix false
useSuffix false
prefix ''
suffix ''
}
appVersion '1.2.3'
file '${builtFile}'
Expand Down Expand Up @@ -238,8 +234,6 @@ muleDeploy {
baseAppName 'the-app'
prefix 'AVI'
suffix 'xxx'
usePrefix false
useSuffix false
}
appVersion '1.2.3'
file '${builtFile}'
Expand Down Expand Up @@ -292,8 +286,6 @@ muleDeploy {
baseAppName 'the-app'
prefix 'AVI'
suffix 'xxx'
usePrefix true
useSuffix false
}
appVersion '1.2.3'
workerSpecs {
Expand Down Expand Up @@ -391,8 +383,6 @@ muleDeploy {
baseAppName 'the-app'
prefix 'AVI'
suffix 'xxx'
usePrefix false
useSuffix false
}
appVersion '1.2.3'
file '${builtFile}'
Expand Down
4 changes: 0 additions & 4 deletions library/examples/allOptions.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ muleDeploy {
environment 'DEV'
applicationName {
baseAppName 'the-app'
usePrefix true
useSuffix true
prefix params.env
suffix params.env
}
Expand All @@ -96,8 +94,6 @@ muleDeploy {
environment 'DEV'
applicationName {
baseAppName 'the-app'
usePrefix true
useSuffix true
prefix params.env
suffix params.env
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ class ApplicationName {
private static final String EMPTY_STRING=''
private static final MAX_SIZE_APPLICATION_NAME = 42

ApplicationName(String baseAppName, Boolean usePrefix, Boolean useSuffix, String prefix, String suffix) {
ApplicationName(String baseAppName, String prefix, String suffix) {
this.baseAppName = baseAppName
this.usePrefix = usePrefix
this.useSuffix = useSuffix
this.usePrefix = prefix != null && !prefix.isBlank()
this.useSuffix = suffix != null && !suffix.isBlank()
this.prefix = prefix
this.suffix = suffix
// getNormalizedAppName()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ abstract class FileBasedAppDeploymentRequest extends AppDeploymentRequest {

// Properties are not passed then extract the artifactId and version from the pom.xml
if(!applicationName) {
setAppName(new ApplicationName(this.parsedPomProperties.artifactId,false,false,null,null))
setAppName(new ApplicationName(this.parsedPomProperties.artifactId, null, null))
}
if(!appVersion) {
setAppVersion(parsedPomProperties.version)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ import com.avioconsulting.mule.deployment.api.models.deployment.ApplicationName
class ApplicationNameContext extends BaseContext{

String baseAppName
Boolean usePrefix
Boolean useSuffix
String prefix
String suffix


ApplicationName createApplicationName(){
return new ApplicationName(baseAppName,usePrefix,useSuffix,prefix,suffix)
return new ApplicationName(baseAppName, prefix, suffix)
}

@Override
Expand Down
2 changes: 0 additions & 2 deletions library/src/main/resources/evaluate.gdsl.vm
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,6 @@ contributor([closureScopeContext]) {
call = enclosingCall('applicationName')
if (call) {
#stringParam('baseAppName')
#boolParam('usePrefix')
#boolParam('useSuffix')
#stringParam('prefix')
#stringParam('suffix')
#stringParam('normalizedAppName')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class DeployerTest {
'theKey',
'theClientId',
'theSecret',
new ApplicationName('new-app',true,true,'client','DEV'),
new ApplicationName('new-app', 'client', 'DEV'),
'1.2.3',)
def apiSpec = new ApiSpecification('Hello API',
simpleRamlFiles)
Expand Down Expand Up @@ -216,7 +216,7 @@ class DeployerTest {
'theKey',
'theClientId',
'theSecret',
new ApplicationName('new-app-mule3',true,true,'client','DEV'),
new ApplicationName('new-app-mule3', 'client', 'DEV'),
'1.2.3')
def apiSpec = new ApiSpecification('Hello API',
simpleRamlFiles,
Expand Down Expand Up @@ -297,7 +297,7 @@ class DeployerTest {
'theKey',
'theClientId',
'theSecret',
new ApplicationName('new-app-mule4',true,true,'client','DEV'),
new ApplicationName('new-app-mule4', 'client', 'DEV'),
'1.2.3')
def apiSpec = new ApiSpecification('Hello API',
simpleRamlFiles,
Expand Down Expand Up @@ -334,7 +334,7 @@ class DeployerTest {
'theKey',
'theClientId',
'theSecret',
new ApplicationName('new-app',true,true,'client','DEV'),
new ApplicationName('new-app', 'client', 'DEV'),
'1.2.3')
def apiSpec = new ApiSpecification('Hello API',
simpleRamlFiles)
Expand All @@ -360,7 +360,7 @@ class DeployerTest {
def request = new OnPremDeploymentRequest('DEV',
'clustera',
file,
new ApplicationName('new-app-mule3',false,false,null,null),
new ApplicationName('new-app-mule3', null, null),
'1.2.3')

// act
Expand Down Expand Up @@ -391,7 +391,7 @@ class DeployerTest {
def request = new OnPremDeploymentRequest('DEV',
'clustera',
file,
new ApplicationName('new-app-mule4',true,true,'client','DEV'),
new ApplicationName('new-app-mule4', 'client', 'DEV'),
'1.2.3')

// act
Expand Down Expand Up @@ -427,7 +427,7 @@ class DeployerTest {
'theKey',
'theClientId',
'theSecret',
new ApplicationName('new-app',true,true,'client','DEV'),
new ApplicationName('new-app', 'client', 'DEV'),
'1.2.3')

// act
Expand Down Expand Up @@ -462,7 +462,7 @@ class DeployerTest {
'theKey',
'theClientId',
'theSecret',
new ApplicationName('new-app',true,true,'client','DEV'),
new ApplicationName('new-app', 'client', 'DEV'),
'1.2.3')
def apiSpec = new ApiSpecification('Hello API',
simpleRamlFiles)
Expand Down Expand Up @@ -498,7 +498,7 @@ class DeployerTest {
'theKey',
'theClientId',
'theSecret',
new ApplicationName('new-app',true,true,'client','DEV'),
new ApplicationName('new-app', 'client', 'DEV'),
'1.2.3')
def apiSpec = new ApiSpecification('Hello API',
simpleRamlFiles)
Expand Down Expand Up @@ -534,7 +534,7 @@ class DeployerTest {
'theKey',
'theClientId',
'theSecret',
new ApplicationName('new-app',true,true,'client','DEV'),
new ApplicationName('new-app', 'client', 'DEV'),
'1.2.3')
def apiSpec = new ApiSpecification('Hello SOAP API',
'v1')
Expand Down Expand Up @@ -568,7 +568,7 @@ class DeployerTest {
'theKey',
'theClientId',
'theSecret',
new ApplicationName('new-app-mule4',true,true,'client','DEV'),
new ApplicationName('new-app-mule4', 'client', 'DEV'),
'1.2.3')
def apiSpec1 = new ApiSpecification('Hello API v1',
simpleRamlFiles)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ApplicationNameTest {
// arrange

// act
def name = (new ApplicationName('avio-consulting', true, true, 'app-prefix', 'app-suffix')).normalizedAppName
def name = (new ApplicationName('avio-consulting', 'app-prefix', 'app-suffix')).normalizedAppName
// assert
assert name == 'app-prefix-avio-consulting-app-suffix'
}
Expand All @@ -24,7 +24,7 @@ class ApplicationNameTest {

// act
def exception = shouldFail {
(new ApplicationName('avio consulting', true, true, 'app-prefix', 'app-suffix')).normalizedAppName
(new ApplicationName('avio consulting', 'app-prefix', 'app-suffix')).normalizedAppName
}
// assert
MatcherAssert.assertThat('fail', exception.message.contains("Name must be alphanumeric with dashes allowed within"))
Expand All @@ -36,7 +36,7 @@ class ApplicationNameTest {

// act
def exception = shouldFail {
(new ApplicationName(null, false, false, null, null)).normalizedAppName
(new ApplicationName(null, null, null)).normalizedAppName
}
// assert
MatcherAssert.assertThat('fail', exception.message.contains("Name must be alphanumeric with dashes allowed within"))
Expand All @@ -48,7 +48,7 @@ class ApplicationNameTest {

// act
def exception = shouldFail {
(new ApplicationName('-avio-consulting', true, true, 'app-prefix', 'app-suffix')).normalizedAppName
(new ApplicationName('-avio-consulting', 'app-prefix', 'app-suffix')).normalizedAppName
}
// assert
MatcherAssert.assertThat('fail', exception.message.contains("Name must be alphanumeric with dashes allowed within"))
Expand All @@ -60,7 +60,7 @@ class ApplicationNameTest {

// act
def exception = shouldFail {
(new ApplicationName('avio-consulting-', true, true, 'app-prefix', 'app-suffix')).normalizedAppName
(new ApplicationName('avio-consulting-', 'app-prefix', 'app-suffix')).normalizedAppName
}
// assert
MatcherAssert.assertThat('fail', exception.message.contains("Name must be alphanumeric with dashes allowed within"))
Expand All @@ -72,7 +72,7 @@ class ApplicationNameTest {

// act
def exception = shouldFail {
(new ApplicationName('avio-consulting', true, true, 'app@prefix', 'app-suffix')).normalizedAppName
(new ApplicationName('avio-consulting', 'app@prefix', 'app-suffix')).normalizedAppName
}
// assert
MatcherAssert.assertThat('fail', exception.message.contains("Prefix must be alphanumeric with dashes allowed within"))
Expand All @@ -84,7 +84,7 @@ class ApplicationNameTest {

// act
def exception = shouldFail {
(new ApplicationName('avio-consulting', true, true, 'app-prefix', 'app$suffix')).normalizedAppName
(new ApplicationName('avio-consulting', 'app-prefix', 'app$suffix')).normalizedAppName
}
// assert
MatcherAssert.assertThat('fail', exception.message.contains("Suffix must be alphanumeric with dashes allowed within"))
Expand Down
Loading

0 comments on commit 8d0c6e9

Please sign in to comment.