mkuthan commented on a change in pull request #16668:
URL: https://github.com/apache/beam/pull/16668#discussion_r797010825



##########
File path: sdks/java/core/src/main/java/org/apache/beam/sdk/testing/PAssert.java
##########
@@ -233,6 +233,19 @@ public int hashCode() {
      */
     IterableAssert<T> inWindow(BoundedWindow window);
 
+    /**
+     * Creates a new {@link IterableAssert} like this one, but with the 
assertion restricted to only
+     * run on the provided window.
+     *
+     * <p>The assertion will expect outputs to be produced to the provided 
window exactly once. If
+     * the upstream {@link Trigger} may produce output multiple times, 
consider instead using {@link
+     * #inFinalPane(BoundedWindow)} or {@link #inOnTimePane(BoundedWindow)}.
+     *
+     * @return a new {@link IterableAssert} like this one but with the 
assertion only applied to the
+     *     specified window.
+     */
+    IterableAssert<T> inOnlyPane(BoundedWindow window);

Review comment:
       What kind of validation do you mean? If I understood the code, the 
assertions like `inOnTimePane`, `inLatePane`, or `inWindow` apply a simple 
filter using `PaneInfo` to ensure that only data from given pane is passed for 
further assertions.
   
   The `PaneExtractors.onlyPane` is somehow special because it might throw an 
`AssertionError`, it seems to be correct, the filtering is not enough to ensure 
that it is the only pane.
   
   The condition for "only pane" is defined as `not(!pane.isFirst() || 
!pane.isLast())`. Wouldn't it be more straightforward to throw an error if 
`pane.index > 0`? 
   
   

##########
File path: sdks/java/core/src/main/java/org/apache/beam/sdk/testing/PAssert.java
##########
@@ -340,6 +353,20 @@ public int hashCode() {
 
   /** Builder interface for assertions applicable to a single value. */
   public interface SingletonAssert<T> {
+    /**
+     * Creates a new {@link SingletonAssert} like this one, but with the 
assertion restricted to
+     * only run on the provided window.
+     *
+     * <p>The assertion will concatenate all panes present in the provided 
window if the {@link

Review comment:
       Hmm, 'inWindow' assertion means that only window boundaries should be 
checked but I don't care if the element is early, on-time or late. If there is 
a single element in the result the SingletonAssert is needed.
   
   For example (Scio like DSL for testing):
   ```
   results should inWindow("00:00:00", "00:10:00") {
         containSingleValue("00:09:59.999", "foo") // singleton assert
   }
   ```




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to