Skip to content

Commit

Permalink
[JENKINS-34464] Test for Result working in Snippet Generator
Browse files Browse the repository at this point in the history
  • Loading branch information
abayer committed May 24, 2017
1 parent 0f5fae9 commit ec7abe9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Expand Up @@ -80,6 +80,11 @@ THE SOFTWARE.
<artifactId>workflow-job</artifactId>
<version>2.10</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
<version>1.7-20170522.160448-1</version> <!-- TODO: Switch to release after https://github.com/jenkinsci/structs-plugin/pull/19 is merged and released -->
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
Expand Down
Expand Up @@ -29,6 +29,7 @@
import hudson.model.JobProperty;
import hudson.model.ParametersAction;
import hudson.model.ParametersDefinitionProperty;
import hudson.model.Result;
import hudson.model.StringParameterDefinition;
import hudson.model.StringParameterValue;
import hudson.model.queue.QueueTaskFuture;
Expand All @@ -50,6 +51,7 @@
import jenkins.model.BuildDiscarderProperty;
import jenkins.plugins.git.GitSCMSource;
import jenkins.plugins.git.GitSampleRepoRule;
import jenkins.triggers.ReverseBuildTrigger;
import org.jenkinsci.Symbol;
import jenkins.scm.api.SCMHead;
import jenkins.scm.api.SCMSource;
Expand Down Expand Up @@ -559,6 +561,28 @@ public void configRoundTripSCMTrigger() throws Exception {
}
}

@Issue("JENKINS-34464")
@Test
public void configRoundTripReverseBuildTrigger() throws Exception {
List<JobProperty> properties = Collections.<JobProperty>singletonList(new PipelineTriggersJobProperty(Collections.<Trigger>singletonList(new ReverseBuildTrigger("some-job", Result.UNSTABLE))));
String snippetJson = "{'propertiesMap': {\n" +
" 'stapler-class-bag': 'true',\n" +
" 'org-jenkinsci-plugins-workflow-job-properties-PipelineTriggersJobProperty': {'triggers': {\n" +
" 'stapler-class-bag': 'true',\n" +
" 'jenkins-triggers-ReverseBuildTrigger': { 'threshold': 'UNSTABLE', 'upstreamProjects': 'some-job'}\n" +
" }}},\n" +
" 'stapler-class': 'org.jenkinsci.plugins.workflow.multibranch.JobPropertyStep',\n" +
" '$class': 'org.jenkinsci.plugins.workflow.multibranch.JobPropertyStep'}";

if (TimerTrigger.DescriptorImpl.class.isAnnotationPresent(Symbol.class)) {
new SnippetizerTester(r).assertGenerateSnippet(snippetJson, "properties([pipelineTriggers([upstream(threshold: 'UNSTABLE', upstreamProjects: 'some-job')])])", null);
new SnippetizerTester(r).assertRoundTrip(new JobPropertyStep(properties), "properties([pipelineTriggers([upstream(threshold: 'UNSTABLE', upstreamProjects: 'some-job')])])");
} else {
new SnippetizerTester(r).assertGenerateSnippet(snippetJson, "properties([pipelineTriggers([[$class: 'ReverseBuildTrigger', threshold: 'UNSTABLE', upstreamProjects: 'some-job']])])", null);
new SnippetizerTester(r).assertRoundTrip(new JobPropertyStep(properties), "properties([pipelineTriggers([[$class: 'ReverseBuildTrigger', threshold: 'UNSTABLE', upstreamProjects: 'some-job']])])");
}
}

@Issue("JENKINS-37005")
@Test
public void noPropertiesWarnings() throws Exception {
Expand Down

0 comments on commit ec7abe9

Please sign in to comment.