@Test @Category(NeedsRunner.class) public void testFilterFieldsByName() { // Pass only elements where field1 == "pass && field2 > 50. PCollection<POJO> filtered = pipeline .apply( Create.of( new POJO("pass", 52, 2), new POJO("pass", 2, 2), new POJO("fail", 100, 100))) .apply( Filter.<POJO>create() .whereFieldName("field1", s -> "pass".equals(s)) .whereFieldName("field2", i -> (Integer) i > 50)); PAssert.that(filtered).containsInAnyOrder(new POJO("pass", 52, 2)); pipeline.run(); }
@Test @Category(NeedsRunner.class) public void testMissingFieldName() { thrown.expect(IllegalArgumentException.class); pipeline .apply(Create.of(new POJO("pass", 52, 2))) .apply(Filter.<POJO>create().whereFieldName("missing", f -> true)); pipeline.run(); }