Skip to content
Permalink
Browse files

Merge pull request #28 from Vlatombe/JENKINS-46122

[FIX JENKINS-46122] Report base class name when symbol couldn't be resolved
  • Loading branch information...
Vlatombe committed Aug 21, 2017
2 parents 0194fee + 25aa7a8 commit eb9c1d5d5b1a9794925b62e17b9b4b1ee2113b13
@@ -445,7 +445,7 @@ private Object coerce(String context, Type type, Object o) throws Exception {
}
}
}
throw new UnsupportedOperationException("Undefined symbol ‘" + symbol + "");
throw new UnsupportedOperationException("no known implementation of " + base + " is using symbol ‘" + symbol + "");
}

if (Modifier.isAbstract(base.getModifiers())) {
@@ -0,0 +1,27 @@
package org.jenkinsci.plugins.structs;

import hudson.Extension;
import hudson.model.AbstractDescribableImpl;
import hudson.model.Descriptor;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;

/**
* "rod" symbol
*
* @author Kohsuke Kawaguchi
*/
public class FishingRod extends AbstractDescribableImpl<FishingRod> implements Fishing {
@DataBoundConstructor
public FishingRod() {
}


@Extension @Symbol("rod")
public static class DescriptorImpl extends Descriptor<FishingRod> {
@Override
public String getDisplayName() {
return "fishing rod";
}
}
}
@@ -676,6 +676,17 @@ public void resolveClass() throws Exception {
assertEquals(Internet.class, DescribableModel.resolveClass(Tech.class, "Internet", null));
}

@Issue("JENKINS-46122")
@Test
public void resolveSymbolOnWrongBaseClass() throws Exception {
try {
DescribableModel.resolveClass(Tech.class, null, "rod");
fail("No symbol for Tech should exist.");
} catch (UnsupportedOperationException e) {
assertEquals("no known implementation of " + Tech.class + " is using symbol ‘rod’", e.getMessage());
}
}

@Test
public void singleRequiredParameter() throws Exception {
// positive case

0 comments on commit eb9c1d5

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