Add simple test to FunctionalExtractionTest (#3522)

This commit is contained in:
Charles Allen 2016-09-28 23:45:15 -07:00 committed by Gian Merlino
parent 78b06a7d7e
commit 654e1db309
1 changed files with 21 additions and 7 deletions

View File

@ -105,21 +105,21 @@ public class FunctionalExtractionTest
private static String MISSING = "missing";
@Parameterized.Parameters
@Parameterized.Parameters(name = "{0}")
public static Iterable<Object[]> constructorFeeder()
{
return ImmutableList.of(
new Object[]{NULL_FN},
new Object[]{TURTLE_FN},
new Object[]{EMPTY_STR_FN},
new Object[]{IDENTITY_FN},
new Object[]{ONLY_PRESENT}
new Object[]{"null", NULL_FN},
new Object[]{"turtle", TURTLE_FN},
new Object[]{"empty", EMPTY_STR_FN},
new Object[]{"identity", IDENTITY_FN},
new Object[]{"only_PRESENT", ONLY_PRESENT}
);
}
private final Function<String, String> fn;
public FunctionalExtractionTest(Function<String, String> fn)
public FunctionalExtractionTest(String label, Function<String, String> fn)
{
this.fn = fn;
}
@ -138,6 +138,20 @@ public class FunctionalExtractionTest
Assert.assertEquals(Strings.isNullOrEmpty(out) ? in : out, exFn.apply(in));
}
@Test
public void testRetainMissingButFound()
{
final String in = PRESENT_KEY;
final FunctionalExtraction exFn = new SimpleFunctionExtraction(
fn,
true,
null,
false
);
final String out = fn.apply(in);
Assert.assertEquals(Strings.isNullOrEmpty(out) ? in : out, exFn.apply(in));
}
@Test
public void testReplaceMissing()
{