/** * Test the cases that the matcher should successfully match against. In this case, it should * match against {@link Combine.GroupedValues} on their own and as part of an expanded {@link * Combine.PerKey} transform. */ @Test public void combineValuesWithoutSideInputsSuccessfulMatches() { PTransformMatcher matcher = new DataflowPTransformMatchers.CombineValuesWithoutSideInputsPTransformMatcher(); AppliedPTransform<?, ?, ?> groupedValues; groupedValues = getCombineGroupedValuesFrom(createCombineGroupedValuesPipeline()); assertThat(matcher.matches(groupedValues), is(true)); groupedValues = getCombineGroupedValuesFrom(createCombinePerKeyPipeline()); assertThat(matcher.matches(groupedValues), is(true)); }
/** * Test significant cases that the matcher should not match against. In this case, this explicitly * tests that any {@link Combine.GroupedValues} with side inputs should not match. */ @Test public void combineValuesWithoutSideInputsSkipsNonmatching() { PTransformMatcher matcher = new DataflowPTransformMatchers.CombineValuesWithoutSideInputsPTransformMatcher(); AppliedPTransform<?, ?, ?> groupedValues; groupedValues = getCombineGroupedValuesFrom(createCombineGroupedValuesWithSideInputsPipeline()); assertThat(matcher.matches(groupedValues), is(false)); groupedValues = getCombineGroupedValuesFrom(createCombinePerKeyWithSideInputsPipeline()); assertThat(matcher.matches(groupedValues), is(false)); }
/** * Returns a {@link PTransformMatcher} that matches {@link PTransform}s of class {@link * Combine.GroupedValues} that will be translated into CombineValues transforms in Dataflow's Job * API and skips those that should be expanded into ParDos. * * @param fnApiEnabled Flag indicating whether this matcher is being retrieved for a fnapi or * non-fnapi pipeline. */ private static PTransformMatcher combineValuesTranslation(boolean fnApiEnabled) { if (fnApiEnabled) { return new DataflowPTransformMatchers.CombineValuesWithParentCheckPTransformMatcher(); } else { return new DataflowPTransformMatchers.CombineValuesWithoutSideInputsPTransformMatcher(); } }