Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/non gxp doc cleanup #1049

Merged
merged 11 commits into from
Nov 7, 2023
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## Unreleased
* Add done boolean flag to data passed to the document template service ([#1048](https://github.com/opendevstack/ods-jenkins-shared-library/issues/1048))
* Remove drift alignment code and pause deploy mechanism ([#1054](https://github.com/opendevstack/ods-jenkins-shared-library/pull/1054))
* Add better documentation for Helm ([#1027](https://github.com/opendevstack/ods-jenkins-shared-library/issues/1027))
* Avoid Groovy string interpolation [#1030](https://github.com/opendevstack/ods-jenkins-shared-library/issues/1030)
Expand Down
20 changes: 5 additions & 15 deletions src/org/ods/orchestration/usecase/LeVADocumentUseCase.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ import java.time.LocalDateTime
'PublicMethodsBeforeNonPublicMethods'])
class LeVADocumentUseCase extends DocGenUseCase {

private static final String NOT_MANDATORY_CONTENT = '<p><em>Not mandatory.</em></p>'

protected static Map DOCUMENT_TYPE_NAMES = [
(DocumentType.CSD as String) : 'Combined Specification Document',
(DocumentType.DIL as String) : 'Discrepancy Log',
Expand Down Expand Up @@ -1688,33 +1686,25 @@ class LeVADocumentUseCase extends DocGenUseCase {
'Could not obtain document chapter data from Jira.')
}

def sectionCollection = sections.collectEntries { sec ->
String content = sec.content
if (!this.project.isDocChapterMandatory(sec) && !this.project.isIssueDone(sec)) {
content = NOT_MANDATORY_CONTENT
} else {
content = this.convertImages(content)
}
[(sec.section): sec + [content: content]]
return sections.collectEntries { sec ->
[(sec.section): sec + [content: this.convertImages(sec.content), show: this.project.isIssueToBeShown(sec)]]
}

// Extract-out the section, as needed for the DocGen interface
return sectionCollection
}

protected Map getDocumentSectionsFileOptional(String documentType) {
def sections = this.project.getDocumentChaptersForDocument(documentType)
sections = sections?.collectEntries { sec ->
[(sec.section): sec + [content: this.convertImages(sec.content)]]
[(sec.section): sec + [content: this.convertImages(sec.content), show: this.project.isIssueToBeShown(sec)]]
}

if (!sections || sections.isEmpty() ) {
sections = this.levaFiles.getDocumentChapterData(documentType)
if (!this.project.data.jira.undoneDocChapters) {
this.project.data.jira.undoneDocChapters = [:]
}
this.project.data.jira.undoneDocChapters[documentType] = this.computeSectionsNotDone(sections)
sections = sections?.collectEntries { key, sec ->
[(key): sec + [content: this.convertImages(sec.content)]]
[(key): sec + [content: this.convertImages(sec.content), show: true]]
}
}

Expand Down
9 changes: 9 additions & 0 deletions src/org/ods/orchestration/util/Project.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,15 @@ class Project {
return issue.status?.equalsIgnoreCase(JiraDataItem.ISSUE_STATUS_DONE)
}

@NonCPS
boolean isIssueToBeShown(Map issue) {
if (isGxp()) {
return !issue.status?.equalsIgnoreCase(JiraDataItem.ISSUE_STATUS_CANCELLED)
} else {
return issue.status?.equalsIgnoreCase(JiraDataItem.ISSUE_STATUS_DONE)
}
}

@NonCPS
boolean isDocChapterMandatory(Map doc) {
if (this.isGxp()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ class LeVADocumentUseCaseSpec extends SpecHelper {
expectedModules = null
}

def expectedDocs = ["number":"1", "documents":["SSDS"], "section":"sec1", "version":"1.0", "key":"DOC-1", "name": "name", "content":"myContent"]
def expectedDocs = ["number":"1", "documents":["SSDS"], "section":"sec1", "version":"1.0", "key":"DOC-1", "name": "name", "content":"myContent", "show": true]

log.info "Using temporal folder:${tempFolder.getRoot()}"
steps.env.BUILD_ID = "1"
Expand Down Expand Up @@ -1921,7 +1921,7 @@ class LeVADocumentUseCaseSpec extends SpecHelper {
}

@Unroll
def "replace content for non-mandatory open issues"() {
def "add correct show flag for issues"() {
given:
jiraUseCase = Spy(new JiraUseCase(project, steps, util, Mock(JiraService), logger))
usecase = Spy(new LeVADocumentUseCase(project, steps, util, docGen, jenkins, jiraUseCase, junit, levaFiles, nexus, os, pdf, sq, bbt, logger))
Expand All @@ -1937,24 +1937,24 @@ class LeVADocumentUseCaseSpec extends SpecHelper {
def result = usecase.getDocumentSections(documentType)

then:
result["sec1"].content == expected
result["sec1"].show == expected

where:
isGxp | documentType | status | number || expected
false | CSD as String | "IN PROGRESS" | "2" || "<p><em>Not mandatory.</em></p>"
false | SSDS as String | "IN PROGRESS" | "2" || "<p><em>Not mandatory.</em></p>"
false | CSD as String | "DONE" | "2" || "Original content"
false | SSDS as String | "DONE" | "2" || "Original content"
false | CSD as String | "DONE" | "1" || "Original content"
false | CSD as String | "CANCELLED" | "2" || "<p><em>Not mandatory.</em></p>"
false | SSDS as String | "CANCELLED" | "2" || "<p><em>Not mandatory.</em></p>"
false | CSD as String | "IN PROGRESS" | "1" || "Original content"
false | CSD as String | "IN PROGRESS" | "3.1" || "Original content"
false | SSDS as String | "IN PROGRESS" | "1" || "Original content"
false | SSDS as String | "IN PROGRESS" | "2.1" || "Original content"
false | SSDS as String | "IN PROGRESS" | "3.1" || "Original content"
false | SSDS as String | "IN PROGRESS" | "5.4" || "Original content"
true | CSD as String | "IN PROGRESS" | "2" || "Original content"
false | CSD as String | "IN PROGRESS" | "2" || false
false | SSDS as String | "IN PROGRESS" | "2" || false
false | CSD as String | "DONE" | "2" || true
false | SSDS as String | "DONE" | "2" || true
false | CSD as String | "DONE" | "1" || true
false | CSD as String | "CANCELLED" | "2" || false
false | SSDS as String | "CANCELLED" | "2" || false
false | CSD as String | "IN PROGRESS" | "1" || false
false | CSD as String | "IN PROGRESS" | "3.1" || false
false | SSDS as String | "IN PROGRESS" | "1" || false
false | SSDS as String | "IN PROGRESS" | "2.1" || false
false | SSDS as String | "IN PROGRESS" | "3.1" || false
false | SSDS as String | "IN PROGRESS" | "5.4" || false
true | CSD as String | "IN PROGRESS" | "2" || true
}

}