-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/opendevstack/ods-jenkins-…
…shared-library into bugifx/jiraReleaseTest
- Loading branch information
Showing
6 changed files
with
48 additions
and
10 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.ods.orchestration.util | ||
|
||
import com.cloudbees.groovy.cps.NonCPS | ||
|
||
class StringCleanup { | ||
|
||
@NonCPS | ||
static removeCharacters(inputString, characters) { | ||
def outputString = inputString | ||
characters.forEach { k, v -> | ||
outputString = outputString.replaceAll(k, v) | ||
} | ||
return outputString | ||
} | ||
} |
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
20 changes: 20 additions & 0 deletions
20
test/groovy/org/ods/orchestration/util/StringCleanupSpec.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,20 @@ | ||
package org.ods.orchestration.util | ||
|
||
import spock.lang.Specification | ||
|
||
class StringCleanupSpec extends Specification { | ||
|
||
def "Remove nonbreakable white space"() { | ||
given: 'String with nonbreakable white space' | ||
def inputString = '\u00A0This\u00A0string\u00A0has\u00A0wrong\u00A0spaces\u00A0' | ||
def CHARACTER_REMOVEABLE = [ | ||
'\u00A0': ' ', | ||
] | ||
|
||
when: 'We remove the characters' | ||
def outputString = StringCleanup.removeCharacters(inputString, CHARACTER_REMOVEABLE) | ||
|
||
then: 'The characters were removed' | ||
outputString == ' This string has wrong spaces ' | ||
} | ||
} |