-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Change valid characters logic in the application name (#87)
* feat: Change valid characters logic in the application name * test: Fix and add unit tests for application name feature * Improve regex to validate application name Co-authored-by: Manik Magar <manik.magar@gmail.com> * feat: Use the new validateName method to validate application name * test: Fix unit tests for the new message about invalid application name --------- Co-authored-by: Manik Magar <manik.magar@gmail.com>
- Loading branch information
1 parent
1ee6ade
commit 9f57339
Showing
6 changed files
with
93 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
...ry/src/test/java/com/avioconsulting/mule/deployment/api/models/ApplicationNameTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package com.avioconsulting.mule.deployment.api.models | ||
|
||
import com.avioconsulting.mule.deployment.api.models.deployment.ApplicationName | ||
import org.hamcrest.MatcherAssert | ||
import org.junit.jupiter.api.Test | ||
|
||
import static groovy.test.GroovyAssert.shouldFail | ||
|
||
class ApplicationNameTest { | ||
|
||
@Test | ||
void valid_name() { | ||
// arrange | ||
|
||
// act | ||
def name = (new ApplicationName('avio-consulting', true, true, 'app-prefix', 'app-suffix')).normalizedAppName | ||
// assert | ||
assert name == 'app-prefix-avio-consulting-app-suffix' | ||
} | ||
|
||
@Test | ||
void name_with_spaces() { | ||
// arrange | ||
|
||
// act | ||
def exception = shouldFail { | ||
(new ApplicationName('avio consulting', true, true, 'app-prefix', 'app-suffix')).normalizedAppName | ||
} | ||
// assert | ||
MatcherAssert.assertThat('fail', exception.message.contains("Name must be alphanumeric with dashes allowed within")) | ||
} | ||
|
||
@Test | ||
void name_starting_with_dash() { | ||
// arrange | ||
|
||
// act | ||
def exception = shouldFail { | ||
(new ApplicationName('-avio-consulting', true, true, 'app-prefix', 'app-suffix')).normalizedAppName | ||
} | ||
// assert | ||
MatcherAssert.assertThat('fail', exception.message.contains("Name must be alphanumeric with dashes allowed within")) | ||
} | ||
|
||
@Test | ||
void name_ending_with_dash() { | ||
// arrange | ||
|
||
// act | ||
def exception = shouldFail { | ||
(new ApplicationName('avio-consulting-', true, true, 'app-prefix', 'app-suffix')).normalizedAppName | ||
} | ||
// assert | ||
MatcherAssert.assertThat('fail', exception.message.contains("Name must be alphanumeric with dashes allowed within")) | ||
} | ||
|
||
@Test | ||
void prefix_with_special_char() { | ||
// arrange | ||
|
||
// act | ||
def exception = shouldFail { | ||
(new ApplicationName('avio-consulting', true, true, 'app@prefix', 'app-suffix')).normalizedAppName | ||
} | ||
// assert | ||
MatcherAssert.assertThat('fail', exception.message.contains("Prefix must be alphanumeric with dashes allowed within")) | ||
} | ||
|
||
@Test | ||
void suffix_with_special_char() { | ||
// arrange | ||
|
||
// act | ||
def exception = shouldFail { | ||
(new ApplicationName('avio-consulting', true, true, 'app-prefix', 'app$suffix')).normalizedAppName | ||
} | ||
// assert | ||
MatcherAssert.assertThat('fail', exception.message.contains("Suffix must be alphanumeric with dashes allowed within")) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters