use of io.jenkins.plugins.casc.model.Scalar in project configuration-as-code-plugin by jenkinsci.
the class PrimitiveConfiguratorTest method _string.
@Test
public void _string() throws Exception {
Configurator c = registry.lookupOrFail(String.class);
final Object value = c.configure(new Scalar("abc"), context);
assertEquals("abc", value);
}
use of io.jenkins.plugins.casc.model.Scalar in project configuration-as-code-plugin by jenkinsci.
the class PrimitiveConfiguratorTest method _boolean.
@Test
public void _boolean() throws Exception {
Configurator c = registry.lookupOrFail(boolean.class);
final Object value = c.configure(new Scalar("true"), context);
assertTrue((Boolean) value);
}
use of io.jenkins.plugins.casc.model.Scalar in project configuration-as-code-plugin by jenkinsci.
the class PrimitiveConfiguratorTest method _enum2.
@Test
public void _enum2() throws Exception {
// No explicit converter set by jenkins
Configurator<TimeUnit> c = registry.lookupOrFail(TimeUnit.class);
final TimeUnit value = c.configure(new Scalar("DAYS"), context);
assertEquals(TimeUnit.DAYS, value);
}
use of io.jenkins.plugins.casc.model.Scalar in project configuration-as-code-plugin by jenkinsci.
the class PrimitiveConfiguratorTest method _int_env_default.
@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);
}
use of io.jenkins.plugins.casc.model.Scalar in project configuration-as-code-plugin by jenkinsci.
the class DataBoundConfiguratorTest method configureWithSets.
@Test
public void configureWithSets() throws Exception {
Mapping config = new Mapping();
Sequence sequence = new Sequence();
sequence.add(new Scalar("bar"));
sequence.add(new Scalar("foo"));
config.put("strings", sequence);
ConfiguratorRegistry registry = ConfiguratorRegistry.get();
final Bar configured = (Bar) registry.lookupOrFail(Bar.class).configure(config, new ConfigurationContext(registry));
Set<String> strings = configured.getStrings();
assertTrue(strings.contains("foo"));
assertTrue(strings.contains("bar"));
assertFalse(strings.contains("baz"));
}
Aggregations