DescribableModel implements Serializable { @Deprecated public T instantiate(Map<String,?> arguments) throws IllegalArgumentException { return instantiate(arguments, new LogTaskListener(LOGGER, Level.FINE)); } DescribableModel(Class<T> clazz); static DescribableModel<T> of(Class<T> clazz); Class<T> getType(); Collection<DescribableParameter> getParameters(); DescribableParameter getParameter(String name); boolean hasSingleRequiredParameter(); @CheckForNull DescribableParameter getSoleRequiredParameter(); @CheckForNull DescribableParameter getFirstRequiredParameter(); String getDisplayName(); @Deprecated T instantiate(Map<String,?> arguments); T instantiate(Map<String,?> arguments, @CheckForNull TaskListener listener); Map<String,Object> uninstantiate(T o); UninstantiatedDescribable uninstantiate2(T o); static Map<String,Object> uninstantiate_(Object o); @SuppressWarnings("unchecked") static UninstantiatedDescribable uninstantiate2_(Object o); boolean isDeprecated(); @CheckForNull String getHelp(); @Override String toString(); @SuppressFBWarnings("MS_SHOULD_BE_FINAL") // Used to control warnings that instantiate parameters will be ignored
    @Restricted(NoExternalUse.class)
    static boolean STRICT_PARAMETER_CHECKING; static final String CLAZZ; }
@Test public void instantiate() throws Exception { Map<String,Object> args = map("text", "hello", "flag", true); assertEquals("C:hello/true", instantiate(C.class, args).toString()); args.put("value", "main"); assertEquals("I:main/hello/true", instantiate(I.class, args).toString()); assertEquals("C:goodbye/false", instantiate(C.class, map("text", "goodbye")).toString()); }
@Test public void erroneousParameters() { try { Map<String,Object> args = map("text", "hello", "flag", true, "garbage", "!", "junk", "splat"); instantiate(C.class, args); Assert.fail("Instantiation should have failed due to unnecessary arguments"); } catch (Exception e) { assertThat(e, Matchers.instanceOf(IllegalArgumentException.class)); assertThat(e.getMessage(), is("WARNING: Unknown parameter(s) found for class type '" + C.class.getName() + "': garbage,junk")); } }
@Test public void mismatchedTypes() throws Exception { try { instantiate(I.class, map("value", 99)); fail(); } catch (Exception x) { String message = x.getMessage(); assertTrue(message, message.contains(I.class.getName())); assertTrue(message, message.contains("value")); assertTrue(message, message.contains("java.lang.String")); assertTrue(message, message.contains("java.lang.Integer")); } }