|
| 1 | +package hudson.plugins.jira.versionparameter; |
| 2 | + |
| 3 | +import static org.hamcrest.MatcherAssert.assertThat; |
| 4 | +import static org.hamcrest.Matchers.*; |
| 5 | + |
| 6 | +import hudson.model.ParametersDefinitionProperty; |
| 7 | +import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition; |
| 8 | +import org.jenkinsci.plugins.workflow.job.WorkflowJob; |
| 9 | +import org.junit.jupiter.api.Test; |
| 10 | +import org.jvnet.hudson.test.JenkinsRule; |
| 11 | +import org.jvnet.hudson.test.junit.jupiter.WithJenkins; |
| 12 | + |
| 13 | +@WithJenkins |
| 14 | +class JiraReleaseVersionParameterTest { |
| 15 | + |
| 16 | + @Test |
| 17 | + void scriptedPipeline(JenkinsRule r) throws Exception { |
| 18 | + WorkflowJob p = r.createProject(WorkflowJob.class); |
| 19 | + p.setDefinition(new CpsFlowDefinition( |
| 20 | + """ |
| 21 | + properties([ |
| 22 | + parameters([ |
| 23 | + jiraReleaseVersion(name: 'JIRA', description: 'Jira Test Description', jiraProjectKey: 'PRJ', jiraReleasePattern: 'v[0-9]+', jiraShowReleased: 'true', jiraShowArchived: 'true') |
| 24 | + ]) |
| 25 | + ])""", |
| 26 | + true)); |
| 27 | + r.buildAndAssertSuccess(p); |
| 28 | + |
| 29 | + ParametersDefinitionProperty parameters = p.getProperty(ParametersDefinitionProperty.class); |
| 30 | + assertThat(parameters, is(notNullValue())); |
| 31 | + assertThat( |
| 32 | + parameters.getParameterDefinitions(), |
| 33 | + hasItem(allOf( |
| 34 | + instanceOf(JiraVersionParameterDefinition.class), |
| 35 | + hasProperty("name", is("JIRA")), |
| 36 | + hasProperty("description", is("Jira Test Description")), |
| 37 | + hasProperty("jiraProjectKey", is("PRJ"))))); |
| 38 | + } |
| 39 | +} |
0 commit comments