Skip to content

Instantly share code, notes, and snippets.

@davideanastasia
Created June 5, 2018 22:41
Show Gist options
  • Save davideanastasia/c6a6e8349a997772b6d7b3b310420eb7 to your computer and use it in GitHub Desktop.
Save davideanastasia/c6a6e8349a997772b6d7b3b310420eb7 to your computer and use it in GitHub Desktop.
public class StopWordRemoveFnTest {
static private class Empty {}
static private final Empty EMPTY = new Empty();
@Test
public void testDoFn() throws Exception {
StopWordRemoveFn<Empty> doFn = new StopWordRemoveFn<>();
DoFnTester<KV<Empty, String>, KV<Empty, String>> fnTester = DoFnTester.of(doFn);
List<KV<Empty, String>> output1 = fnTester.processBundle(KV.of(EMPTY, "dream"));
assertEquals(1, output1.size());
assertEquals(KV.of(EMPTY, "dream"), output1.get(0));
List<KV<Empty, String>> output2 = fnTester.processBundle(
KV.of(EMPTY, "be"), KV.of(EMPTY, "is"), KV.of(EMPTY, "night"));
assertEquals(1, output2.size());
assertEquals(KV.of(EMPTY, "night"), output2.get(0));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment