use of io.mantisrx.runtime.parameter.type.EnumCSVParameter in project mantis by Netflix.
the class ParameterDefinitionTest method testEnumCSVParameter.
@Test
public void testEnumCSVParameter() {
Map<String, ParameterDefinition<?>> parameterDefinitions = new HashMap<>();
parameterDefinitions.put("foo", new EnumCSVParameter<>(TestEnum.class).name("foo").required().validator(Validators.alwaysPass()).build());
Map<String, Parameter> parameters = new HashMap<>();
parameters.put("foo", new Parameter("foo", " A , C "));
Map<String, Object> parameterState = ParameterUtils.checkThenCreateState(parameterDefinitions, parameters);
EnumSet<TestEnum> foo = (EnumSet<TestEnum>) parameterState.get("foo");
Assert.assertTrue(foo.contains(TestEnum.A));
Assert.assertTrue(foo.contains(TestEnum.C));
Assert.assertFalse(foo.contains(TestEnum.B));
}
use of io.mantisrx.runtime.parameter.type.EnumCSVParameter in project mantis by Netflix.
the class ParameterDefinitionTest method emptyEnumCSVListValidation.
@Test(expected = IllegalArgumentException.class)
public void emptyEnumCSVListValidation() {
Map<String, ParameterDefinition<?>> parameterDefinitions = new HashMap<>();
parameterDefinitions.put("foo", new EnumCSVParameter<>(TestEnum.class).name("foo").required().validator(Validators.notNullOrEmptyEnumCSV()).build());
Map<String, Parameter> parameters = new HashMap<>();
parameters.put("foo", new Parameter("foo", " "));
ParameterUtils.checkThenCreateState(parameterDefinitions, parameters);
}
Aggregations