Java Code Examples for io.jenkins.plugins.casc.Configurator#configure()

The following examples show how to use io.jenkins.plugins.casc.Configurator#configure() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PrimitiveConfiguratorTest.java    From configuration-as-code-plugin with MIT License 5 votes vote down vote up
@Test
public void _enum() throws Exception {
    // Jenkins do register a StaplerConverter for it.
    Configurator<Node.Mode> c = registry.lookupOrFail(Node.Mode.class);
    final Node.Mode value = c.configure(new Scalar("NORMAL"), context);
    assertEquals(Node.Mode.NORMAL, value);

}
 
Example 2
Source File: PrimitiveConfiguratorTest.java    From configuration-as-code-plugin with MIT License 5 votes vote down vote up
@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);

}
 
Example 3
Source File: PrimitiveConfiguratorTest.java    From configuration-as-code-plugin with MIT License 5 votes vote down vote up
@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);
}
 
Example 4
Source File: PrimitiveConfiguratorTest.java    From configuration-as-code-plugin with MIT License 5 votes vote down vote up
@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);
}
 
Example 5
Source File: PrimitiveConfiguratorTest.java    From configuration-as-code-plugin with MIT License 5 votes vote down vote up
@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);
}
 
Example 6
Source File: PrimitiveConfiguratorTest.java    From configuration-as-code-plugin with MIT License 4 votes vote down vote up
@Test
public void _boolean() throws Exception {
    Configurator c = registry.lookupOrFail(boolean.class);
    final Object value = c.configure(new Scalar("true"), context);
    assertTrue((Boolean) value);
}
 
Example 7
Source File: PrimitiveConfiguratorTest.java    From configuration-as-code-plugin with MIT License 4 votes vote down vote up
@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);
}
 
Example 8
Source File: PrimitiveConfiguratorTest.java    From configuration-as-code-plugin with MIT License 4 votes vote down vote up
@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);
}
 
Example 9
Source File: PrimitiveConfiguratorTest.java    From configuration-as-code-plugin with MIT License 4 votes vote down vote up
@Test
public void _string() throws Exception {
    Configurator c = registry.lookupOrFail(String.class);
    final Object value = c.configure(new Scalar("abc"), context);
    assertEquals("abc", value);
}
 
Example 10
Source File: PrimitiveConfiguratorTest.java    From configuration-as-code-plugin with MIT License 4 votes vote down vote up
@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);
}