lukecwik commented on a change in pull request #12016:
URL: https://github.com/apache/beam/pull/12016#discussion_r456065552



##########
File path: 
sdks/java/harness/src/test/java/org/apache/beam/fn/harness/FnApiDoFnRunnerTest.java
##########
@@ -2892,4 +2899,492 @@ public void 
testProcessElementForWindowedSplitAndSizeRestriction() throws Except
     Iterables.getOnlyElement(teardownFunctions).run();
     assertThat(mainOutputValues, empty());
   }
+
+  private static SplitResult createSplitResult(double fractionOfRemainder) {
+    ByteString.Output primaryBytes = ByteString.newOutput();
+    ByteString.Output residualBytes = ByteString.newOutput();
+    try {
+      DoubleCoder.of().encode(fractionOfRemainder, primaryBytes);
+      DoubleCoder.of().encode(1 - fractionOfRemainder, residualBytes);
+    } catch (Exception e) {
+      // No-op.
+    }
+    return SplitResult.of(
+        ImmutableList.of(
+            
BundleApplication.newBuilder().setElement(primaryBytes.toByteString()).build()),
+        ImmutableList.of(
+            DelayedBundleApplication.newBuilder()
+                .setApplication(
+                    
BundleApplication.newBuilder().setElement(residualBytes.toByteString()).build())
+                .build()));
+  }
+
+  private static class SplittableFnDataReceiver
+      implements HandlesSplits, FnDataReceiver<WindowedValue> {
+    SplittableFnDataReceiver(
+        List<WindowedValue<KV<KV<String, OffsetRange>, Double>>> 
mainOutputValues) {
+      this.mainOutputValues = mainOutputValues;
+    }
+
+    private final List<WindowedValue<KV<KV<String, OffsetRange>, Double>>> 
mainOutputValues;
+
+    @Override
+    public SplitResult trySplit(double fractionOfRemainder) {
+      return createSplitResult(fractionOfRemainder);
+    }
+
+    @Override
+    public double getProgress() {
+      return 0.7;
+    }
+
+    @Override
+    public void accept(WindowedValue input) throws Exception {
+      mainOutputValues.add(input);
+    }
+  }
+
+  @Test
+  public void 
testProcessElementForTruncateAndSizeRestrictionForwardSplitAndProgress()

Review comment:
       Please make this test the non window observing variant and add a window 
observing one which expects null instead of progress/split.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to