Skip to content
Permalink
Browse files

JENKINS-26535 can be worked around using a collection of raw types.

  • Loading branch information
jglick committed Oct 26, 2015
1 parent f61ed78 commit b5302ebc2e2479f03c538060460e43d0c1c0b47a
@@ -41,15 +41,16 @@
/**
* Resets the properties of the current job.
*/
@SuppressWarnings("rawtypes") // TODO JENKINS-26535: cannot bind List<JobProperty<?>>
public class JobPropertyStep extends AbstractStepImpl {

private final List<JobProperty<?>> properties;
private final List<JobProperty> properties;

@DataBoundConstructor public JobPropertyStep(List<JobProperty<?>> properties) {
@DataBoundConstructor public JobPropertyStep(List<JobProperty> properties) {
this.properties = properties;
}

public List<JobProperty<?>> getProperties() {
public List<JobProperty> getProperties() {
return properties;
}

@@ -58,7 +59,7 @@
@Inject transient JobPropertyStep step;
@StepContextParameter Run<?,?> build;

@SuppressWarnings({"unchecked", "rawtypes"}) // untypable
@SuppressWarnings("unchecked") // untypable
@Override protected Void run() throws Exception {
Job<?,?> job = build.getParent();
for (JobProperty prop : step.properties) {
@@ -54,12 +54,13 @@
@Rule public JenkinsRule r = new JenkinsRule();
@Rule public GitSampleRepoRule sampleRepo = new GitSampleRepoRule();

@SuppressWarnings("rawtypes")
@Issue("JENKINS-30519")
@Test public void configRoundTrip() throws Exception {
StepConfigTester tester = new StepConfigTester(r);
// TODO fails (returns null)
assertEquals(Collections.emptyList(), tester.configRoundTrip(new JobPropertyStep(Collections.<JobProperty<?>>emptyList())).getProperties());
List<JobProperty<?>> properties = tester.configRoundTrip(new JobPropertyStep(Collections.<JobProperty<?>>singletonList(new ParametersDefinitionProperty(new BooleanParameterDefinition("flag", true, null))))).getProperties();
assertEquals(Collections.emptyList(), tester.configRoundTrip(new JobPropertyStep(Collections.<JobProperty>emptyList())).getProperties());
List<JobProperty> properties = tester.configRoundTrip(new JobPropertyStep(Collections.<JobProperty>singletonList(new ParametersDefinitionProperty(new BooleanParameterDefinition("flag", true, null))))).getProperties();
assertEquals(1, properties.size());
assertEquals(ParametersDefinitionProperty.class, properties.get(0));
ParametersDefinitionProperty pdp = (ParametersDefinitionProperty) properties.get(0);
@@ -87,7 +88,6 @@
r.waitUntilNoActivity();
WorkflowRun b1 = p.getLastBuild();
assertEquals(1, b1.getNumber());
// TODO fails due to JENKINS-28510
r.assertLogContains("received default value", b1);
WorkflowRun b2 = r.assertBuildStatusSuccess(p.scheduleBuild2(0, new ParametersAction(new StringParameterValue("myparam", "special value"))));
assertEquals(2, b2.getNumber());
@@ -219,7 +219,7 @@ private static Object coerce(String context, Type type, @Nonnull Object o) throw
Jenkins j = Jenkins.getInstance();
ClassLoader loader = j != null ? j.getPluginManager().uberClassLoader : DescribableHelper.class.getClassLoader();
clazz = loader.loadClass(clazzS);
} else {
} else if (type instanceof Class) {
clazz = null;
for (Class<?> c : findSubtypes((Class<?>) type)) {
if (c.getSimpleName().equals(clazzS)) {
@@ -232,6 +232,8 @@ private static Object coerce(String context, Type type, @Nonnull Object o) throw
if (clazz == null) {
throw new UnsupportedOperationException("no known implementation of " + type + " is named " + clazzS);
}
} else {
throw new UnsupportedOperationException("JENKINS-26535: do not know how to handle " + type);
}
return instantiate(clazz.asSubclass((Class<?>) type), m);
} else if (o instanceof String && type instanceof Class && ((Class) type).isEnum()) {

0 comments on commit b5302eb

Please sign in to comment.
You can’t perform that action at this time.