Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…shared-library into bugifx/jiraReleaseTest
  • Loading branch information
Peter Durisin committed Nov 11, 2021
2 parents b77c848 + 8005e9b commit f851a8e
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
- Add support for ods-saas-service components ([#607](https://github.com/opendevstack/ods-jenkins-shared-library/pull/607))
- Automatically change the date_created by Wiremock with a Wiremock wildcard ([#743](https://github.com/opendevstack/ods-jenkins-shared-library/pull/743))
- Refactor and create unit test for LeVADocumentUseCase.getReferencedDocumentsVersion ([#744](https://github.com/opendevstack/ods-jenkins-shared-library/pull/744))
- Remove non breakable white space from Json response of JiraService ([760](https://github.com/opendevstack/ods-jenkins-shared-library/pull/760))

## [3.0] - 2020-08-11

Expand Down
3 changes: 2 additions & 1 deletion src/org/ods/orchestration/FinalizeStage.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ class FinalizeStage extends Stage {
def flattenedRepos = repos.flatten()
def repoIntegrateTasks = flattenedRepos
.findAll { it.type?.toLowerCase() != MROPipelineUtil.PipelineConfig.REPO_TYPE_ODS_TEST &&
it.type?.toLowerCase() != MROPipelineUtil.PipelineConfig.REPO_TYPE_ODS_INFRA }
it.type?.toLowerCase() != MROPipelineUtil.PipelineConfig.REPO_TYPE_ODS_INFRA &&
it.type?.toLowerCase() != MROPipelineUtil.PipelineConfig.REPO_TYPE_ODS_SAAS_SERVICE }
.collectEntries { repo ->
[
(repo.id): {
Expand Down
12 changes: 9 additions & 3 deletions src/org/ods/orchestration/service/JiraService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.cloudbees.groovy.cps.NonCPS

import groovy.json.JsonOutput
import groovy.json.JsonSlurperClassic
import org.ods.orchestration.util.StringCleanup

import java.net.URI

Expand All @@ -16,6 +17,10 @@ import org.apache.http.client.utils.URIBuilder
@SuppressWarnings(['LineLength', 'ParameterName'])
class JiraService {

protected static Map CHARACTER_REMOVEABLE = [
'\u00A0': ' ',
]

URI baseURL

String username
Expand Down Expand Up @@ -260,7 +265,7 @@ class JiraService {
throw new RuntimeException(message)
}

return new JsonSlurperClassic().parseText(response.getBody())
return new JsonSlurperClassic().parseText(StringCleanup.removeCharacters(response.getBody(), CHARACTER_REMOVEABLE))
}

@NonCPS
Expand Down Expand Up @@ -289,7 +294,7 @@ class JiraService {
throw new RuntimeException(message)
}

return new JsonSlurperClassic().parseText(response.getBody())
return new JsonSlurperClassic().parseText(StringCleanup.removeCharacters(response.getBody(), CHARACTER_REMOVEABLE))
}

@NonCPS
Expand Down Expand Up @@ -548,7 +553,7 @@ class JiraService {
throw new RuntimeException(message)
}

return new JsonSlurperClassic().parseText(response.getBody())
return new JsonSlurperClassic().parseText(StringCleanup.removeCharacters(response.getBody(), CHARACTER_REMOVEABLE))
}

@NonCPS
Expand Down Expand Up @@ -718,4 +723,5 @@ class JiraService {
}
return true
}

}
15 changes: 15 additions & 0 deletions src/org/ods/orchestration/util/StringCleanup.groovy
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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ import com.github.tomakehurst.wiremock.client.*

import groovy.json.JsonOutput
import groovy.json.JsonSlurperClassic
import org.apache.http.client.utils.URIBuilder

import spock.lang.*

import static util.FixtureHelper.*

import util.*

class JiraServiceSpec extends SpecHelper {
Expand Down Expand Up @@ -2358,4 +2352,5 @@ class JiraServiceSpec extends SpecHelper {
cleanup:
stopServer(server)
}

}
20 changes: 20 additions & 0 deletions test/groovy/org/ods/orchestration/util/StringCleanupSpec.groovy
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 '
}
}

0 comments on commit f851a8e

Please sign in to comment.