Skip to content

Commit

Permalink
Retrieve version id from Project data in Zephyr support (opendevstack…
Browse files Browse the repository at this point in the history
  • Loading branch information
metmajer authored Mar 26, 2020
2 parents 4c0e333 + d1f197f commit 214795b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 25 deletions.
10 changes: 1 addition & 9 deletions src/org/ods/usecase/JiraUseCaseZephyrSupport.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class JiraUseCaseZephyrSupport extends AbstractJiraUseCaseSupport {
if (!testIssues?.isEmpty()) {
def buildParams = this.project.buildParams

def versionId = this.getProjectVersion(this.project.jiraProjectKey)?.id ?: "-1"
def versionId = this.project.version?.id ?: "-1"
def testCycles = this.zephyr.getTestCycles(this.project.id, versionId)

// Zephyr test cycle properties
Expand Down Expand Up @@ -69,12 +69,4 @@ class JiraUseCaseZephyrSupport extends AbstractJiraUseCaseSupport {
this.usecase.applyXunitTestResultsAsTestIssueLabels(testIssues, testResults)
this.applyXunitTestResultsAsTestExecutionStatii(testIssues, testResults)
}

private Map getProjectVersion(String projectKey) {
List versions = this.zephyr.getProjectVersions(projectKey)

return versions.find { version ->
this.project.buildParams?.version == version.name
}
}
}
4 changes: 4 additions & 0 deletions src/org/ods/util/Project.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,10 @@ class Project {
return this.data.jira.project.id
}

Map getVersion() {
return this.data.jira.project.version
}

Map getJiraFieldsForIssueType(String issueTypeName) {
return this.data.jira.issueTypes[issueTypeName]?.fields ?: [:]
}
Expand Down
18 changes: 2 additions & 16 deletions test/groovy/org/ods/usecase/JiraUseCaseZephyrSupportSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ class JiraUseCaseZephyrSupportSpec extends SpecHelper {
support.applyXunitTestResultsAsTestExecutionStatii(testIssues, testResults)

then:
1 * zephyr.getProjectVersions(project.jiraProjectKey) >> []
1 * zephyr.getTestCycles(project.id, "-1")
1 * zephyr.createTestCycle(project.id, "-1", project.buildParams.targetEnvironmentToken + ": Build " + steps.env.BUILD_ID, steps.env.BUILD_URL, project.buildParams.targetEnvironment) >> [id: "111"]
1 * zephyr.getTestCycles(project.id, "11100")
1 * zephyr.createTestCycle(project.id, "11100", project.buildParams.targetEnvironmentToken + ": Build " + steps.env.BUILD_ID, steps.env.BUILD_URL, project.buildParams.targetEnvironment) >> [id: "111"]

then:
1 * zephyr.createTestExecutionForIssue("1", project.id, "111") >> ["11": []]
Expand Down Expand Up @@ -80,7 +79,6 @@ class JiraUseCaseZephyrSupportSpec extends SpecHelper {
support.applyXunitTestResultsAsTestExecutionStatii(testIssues, testResults)

then:
0 * zephyr.getProjectVersions(project.jiraProjectKey)
0 * zephyr.createTestCycle(project.id, "-1", null, steps.env.BUILD_URL, project.buildParams.targetEnvironment)
}

Expand All @@ -98,16 +96,4 @@ class JiraUseCaseZephyrSupportSpec extends SpecHelper {
_ * zephyr.createTestExecutionForIssue(*_) >> ["1": []]
1 * support.applyXunitTestResultsAsTestExecutionStatii(testIssues, testResults)
}

def "get project version"() {
given:
project.buildParams.version = "0.1"

when:
def result = support.getProjectVersion(project.jiraProjectKey)

then:
1 * zephyr.getProjectVersions(project.jiraProjectKey) >> [ [id: "1234", name: "0.1"] ]
result == [id: "1234", name: "0.1"]
}
}

0 comments on commit 214795b

Please sign in to comment.