Split { public static <InputT> UsingBuilder<InputT> of(PCollection<InputT> input) { return new UsingBuilder<>(DEFAULT_NAME, input); }  static OfBuilder named(String name); static UsingBuilder<InputT> of(PCollection<InputT> input);  }
@Test public void testBuild_ImplicitName() { final PCollection<String> dataset = TestUtils.createMockDataset(TypeDescriptors.strings()); final Split.Output<String> split = Split.of(dataset).using((UnaryPredicate<String>) what -> true).output(); final Filter positive = (Filter) TestUtils.getProducer(split.positive()); assertTrue(positive.getName().isPresent()); assertEquals(Split.DEFAULT_NAME + Split.POSITIVE_FILTER_SUFFIX, positive.getName().get()); final Filter negative = (Filter) TestUtils.getProducer(split.negative()); assertTrue(negative.getName().isPresent()); assertEquals(Split.DEFAULT_NAME + Split.NEGATIVE_FILTER_SUFFIX, negative.getName().get()); }
@SuppressWarnings("unchecked") @Test public void testBuild_NegatedPredicate() { final PCollection<Integer> dataset = TestUtils.createMockDataset(TypeDescriptors.integers()); final Split.Output<Integer> split = Split.of(dataset).using((UnaryPredicate<Integer>) what -> what % 2 == 0).output(); final Filter<Integer> oddNumbers = (Filter) TestUtils.getProducer(split.negative()); assertFalse(oddNumbers.getPredicate().apply(0)); assertFalse(oddNumbers.getPredicate().apply(2)); assertFalse(oddNumbers.getPredicate().apply(4)); assertTrue(oddNumbers.getPredicate().apply(1)); assertTrue(oddNumbers.getPredicate().apply(3)); assertTrue(oddNumbers.getPredicate().apply(5)); }