@Test
public void testBasic() throws Exception {
assertThat(filter.getLegalValues(), containsInAnyOrder("42.0", "6.283", "-17.5"));
for (String test : Arrays.asList("42.0", "6.283", "-17.5", "42", "6.2830", "-1.75e1")) {
assertThat(
filter.applies(test),
Matchers.describedAs("Filter should apply to %0", is(true), test));
}
for (String test : Arrays.asList("42.0", "42", "4.2e1")) {
assertThat(filter.apply(test), equalTo("42.0"));
}
for (String test : Arrays.asList("42.5", "6.281", "-17.52", "-42.0", "-6.283", "17.5")) {
assertThat(filter.applies(test), is(false));
try {
filter.apply(test);
fail();
} catch (Exception ex) {
assertThat(ex, instanceOf(ParameterException.class));
}
}
assertThat(filter.apply(null), equalTo("Default"));
assertThat(filter.apply(""), equalTo("Default"));
}