use of io.jenkins.plugins.casc.model.Mapping in project configuration-as-code-plugin by jenkinsci.
the class DataBoundConfiguratorTest method shouldExportArray.
@Test
public void shouldExportArray() throws Exception {
ArrayConstructor obj = new ArrayConstructor(new Foo[] { new Foo("", false, 0) });
ConfiguratorRegistry registry = ConfiguratorRegistry.get();
final Configurator c = registry.lookupOrFail(ArrayConstructor.class);
final ConfigurationContext context = new ConfigurationContext(registry);
CNode node = c.describe(obj, context);
assertNotNull(node);
assertTrue(node instanceof Mapping);
Mapping map = (Mapping) node;
assertEquals(map.get("anArray").toString(), "[{qix=0, bar=false, foo=}]");
}
use of io.jenkins.plugins.casc.model.Mapping in project configuration-as-code-plugin by jenkinsci.
the class DataBoundConfiguratorTest method configureWithEmptySet.
@Test
public void configureWithEmptySet() throws Exception {
Mapping config = new Mapping();
ConfiguratorRegistry registry = ConfiguratorRegistry.get();
final Bar configured = (Bar) registry.lookupOrFail(Bar.class).configure(config, new ConfigurationContext(registry));
Set<String> strings = configured.getStrings();
assertEquals(0, strings.size());
}
use of io.jenkins.plugins.casc.model.Mapping in project configuration-as-code-plugin by jenkinsci.
the class DataBoundConfiguratorTest method classParametersAreNonnullByDefault.
@Test
public void classParametersAreNonnullByDefault() throws Exception {
Mapping config = new Mapping();
ConfiguratorRegistry registry = ConfiguratorRegistry.get();
final ClassParametersAreNonnullByDefault configured = (ClassParametersAreNonnullByDefault) registry.lookupOrFail(ClassParametersAreNonnullByDefault.class).configure(config, new ConfigurationContext(registry));
assertTrue(configured.getStrings().isEmpty());
}
use of io.jenkins.plugins.casc.model.Mapping in project configuration-as-code-plugin by jenkinsci.
the class DataBoundConfiguratorTest method configure_databound.
@Test
public void configure_databound() throws Exception {
Mapping config = new Mapping();
config.put("foo", "foo");
config.put("bar", "true");
config.put("qix", "123");
config.put("zot", "DataBoundSetter");
ConfiguratorRegistry registry = ConfiguratorRegistry.get();
final Foo configured = (Foo) registry.lookupOrFail(Foo.class).configure(config, new ConfigurationContext(registry));
assertEquals("foo", configured.foo);
assertTrue(configured.bar);
assertEquals(123, configured.qix);
assertEquals("DataBoundSetter", configured.zot);
assertThat(configured.initialized, is(true));
}
Aggregations