### Question:
PrimitiveConfigurator implements Configurator { @NonNull @Override public Object configure(CNode config, ConfigurationContext context) throws ConfiguratorException { return Stapler.lookupConverter(target).convert(target, context.getSecretSourceResolver().resolve(config.asScalar().toString())); } PrimitiveConfigurator(Class clazz); @Override Class getTarget(); @NonNull @Override Set<Attribute> describe(); @NonNull @Override Object configure(CNode config, ConfigurationContext context); @Override Object check(CNode config, ConfigurationContext context); @CheckForNull @Override CNode describe(Object instance, ConfigurationContext context); @NonNull @Override List<Configurator> getConfigurators(ConfigurationContext context);  }### Answer:
@Test public void _boolean() throws Exception { Configurator c = registry.lookupOrFail(boolean.class); final Object value = c.configure(new Scalar("true"), context); assertTrue((Boolean) value); }
@Test public void _int() throws Exception { Configurator c = registry.lookupOrFail(int.class); final Object value = c.configure(new Scalar("123"), context); assertEquals(123, (int) value); }
@Test public void _Integer() throws Exception { Configurator c = registry.lookupOrFail(Integer.class); final Object value = c.configure(new Scalar("123"), context); assertEquals(123, (int) value); }
@Test public void _string() throws Exception { Configurator c = registry.lookupOrFail(String.class); final Object value = c.configure(new Scalar("abc"), context); assertEquals("abc", value); }
@Test public void _enum() throws Exception { Configurator<Node.Mode> c = registry.lookupOrFail(Node.Mode.class); final Node.Mode value = c.configure(new Scalar("NORMAL"), context); assertEquals(Node.Mode.NORMAL, value); }
@Test public void _enum2() throws Exception { Configurator<TimeUnit> c = registry.lookupOrFail(TimeUnit.class); final TimeUnit value = c.configure(new Scalar("DAYS"), context); assertEquals(TimeUnit.DAYS, value); }
@Test public void _Integer_env() throws Exception { environment.set("ENV_FOR_TEST", "123"); Configurator c = registry.lookupOrFail(Integer.class); final Object value = c.configure(new Scalar("${ENV_FOR_TEST}"), context); assertEquals(123, (int) value); }
@Test public void _string_env() throws Exception { environment.set("ENV_FOR_TEST", "abc"); Configurator c = registry.lookupOrFail(String.class); final Object value = c.configure(new Scalar("${ENV_FOR_TEST}"), context); assertEquals("abc", value); }
@Test public void _string_env_default() throws Exception { environment.set("NOT_THERE", "abc"); Configurator c = registry.lookupOrFail(String.class); final Object value = c.configure(new Scalar("${ENV_FOR_TEST:-unsecured-token}"), context); assertEquals("unsecured-token", value); }
@Test public void _int_env_default() throws Exception { Configurator c = registry.lookupOrFail(Integer.class); final Object value = c.configure(new Scalar("${ENV_FOR_TEST:-123}"), context); assertEquals(123, value); }