|
1 | 1 | package org.jenkinsci.plugins.parameterizedscheduler;
|
2 | 2 |
|
| 3 | +import com.cwctravel.hudson.plugins.extended_choice_parameter.ExtendedChoiceParameterDefinition; |
3 | 4 | import hudson.model.FreeStyleProject;
|
4 | 5 | import hudson.model.Job;
|
5 | 6 | import hudson.model.ParameterDefinition;
|
@@ -106,6 +107,30 @@ public void declarative() throws Exception {
|
106 | 107 | assertThat((String) p.getLastCompletedBuild().getAction(ParametersAction.class).getParameter("foo").getValue(), is("bar"));
|
107 | 108 | }
|
108 | 109 |
|
| 110 | + @Test |
| 111 | + @Issue("JENKINS-49372") |
| 112 | + public void extendedChoiceJson() throws Exception { |
| 113 | + FreeStyleProject p = r.createFreeStyleProject(); |
| 114 | + p.addProperty(new ParametersDefinitionProperty(new ExtendedChoiceParameterDefinition("foo", ExtendedChoiceParameterDefinition.PARAMETER_TYPE_JSON, "", |
| 115 | + "", "", "def jsonSlurper = new groovy.json.JsonSlurper()\n" + |
| 116 | + "def object = jsonSlurper.parseText('{\"schema\":{\"type\":\"object\",\"title\":\"Car\",\"properties\":{\"make\":{\"type\":\"string\",\"enum\":[\"Toyota\",\"BMW\",\"Honda\",\"Ford\",\"Chevy\",\"VW\"]},\"model\":{\"type\":\"string\"},\"year\":{\"type\":\"integer\",\"enum\":[1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014],\"default\":2008}}}}')\n" + |
| 117 | + "return object", "", "", "", "", |
| 118 | + "", "", "" , "", "", "", |
| 119 | + "", "", "", "", "", "", |
| 120 | + "", "", "", "", false, false, |
| 121 | + 0, "", ""))); |
| 122 | + assertThat(p.getLastCompletedBuild(), is(nullValue())); |
| 123 | + Trigger<Job> t = new ParameterizedTimerTrigger("* * * * *%foo={\"make\":\"Toyota\",\"model\":\"test\",\"year\":2008}"); |
| 124 | + t.start(p, true); |
| 125 | + p.addTrigger(t); |
| 126 | + new Cron().doRun(); |
| 127 | + assertThat(p.isInQueue(), is(true)); |
| 128 | + r.waitUntilNoActivity(); |
| 129 | + // Build should complete successfully but will not have any value |
| 130 | + assertThat(p.getLastCompletedBuild(), is(notNullValue())); |
| 131 | + assertThat(p.getLastCompletedBuild().getAction(ParametersAction.class).getParameter("foo").getValue(), is("{\"make\":\"Toyota\",\"model\":\"test\",\"year\":2008}")); |
| 132 | + } |
| 133 | + |
109 | 134 | @Test
|
110 | 135 | @Issue("JENKINS-49372")
|
111 | 136 | public void nullValueCreated() throws Exception {
|
|
0 commit comments