Source:
<code>private void testOperator(int numThreads, boolean maintainOrder, long waitInterval) throws InterruptedException { CollectorTestSink<Object> sinkOut = new CollectorTestSink<>(); CollectorTestSink<Object> sinkErr = new CollectorTestSink<>(); TestAsyncProcessor async = new TestAsyncProcessor(); async.setNumProcessors(numThreads); async.setMaintainTupleOrder(maintainOrder); async.output.setSink(sinkOut); async.error.setSink(sinkErr); async.setup(null); for (int windowId = 0; windowId < 10; windowId++) { async.beginWindow(windowId); for (int i = 0; i < 100; i++) { async.input.put(Integer.toString(windowId * 100 + i)); } async.endWindow(); } for (int i = 0; i < 10; i++) { Thread.sleep(waitInterval / 10); async.endWindow(); <START> } <END> async.teardown(); List<Object> outTuples = sinkOut.collectedTuples; List<Object> errTuples = sinkErr.collectedTuples; Assert.assertEquals(666, outTuples.size()); Assert.assertEquals(334, errTuples.size()); int previous = -1; for (Object outTuple : outTuples) { Assert.assertTrue(outTuple instanceof String); String outTuple1 = (String)outTuple; String[] split = outTuple1.split(";"); Assert.assertEquals(2, split.length); int current = Integer.parseInt(split[0]); if (current % 3 == 1) { Assert.assertEquals("FIRSTPASS", split[1]); } else if (current % 3 == 2) { Assert.assertEquals("SECONDPASS", split[1]); } else if (current % 3 == 0) { Assert.assertTrue(false); } if (maintainOrder) { Assert.assertTrue(previous < current); previous = current; } } previous = -1; for (Object errTuple : errTuples) { Assert.assertTrue(errTuple instanceof String); String errTuple1 = (String)errTuple; String[] split = errTuple1.split(";"); Assert.assertEquals(1, split.length); int current = Integer.parseInt(split[0]); Assert.assertTrue(current % 3 == 0); if (maintainOrder) { Assert.assertTrue(previous < current); previous = current; } } }</code><technical_language>is this loop doing? endWindow() is called for beginWindow done in previous loop (line 91-97)</technical_language>

Target:
private void testOperator(int numThreads, boolean maintainOrder, long waitInterval) throws InterruptedException { CollectorTestSink<Object> sinkOut = new CollectorTestSink<>(); CollectorTestSink<Object> sinkErr = new CollectorTestSink<>(); TestAsyncProcessor async = new TestAsyncProcessor(); async.setNumProcessors(numThreads); async.setMaintainTupleOrder(maintainOrder); async.output.setSink(sinkOut); async.error.setSink(sinkErr); async.setup(null); int windowId = 0; for (windowId = 0; windowId < 10; windowId++) { async.beginWindow(windowId); for (int i = 0; i < 100; i++) { async.input.put(Integer.toString(windowId * 100 + i)); } async.endWindow(); } for (int i = 0; i < 10; i++) { async.beginWindow(windowId++); Thread.sleep(waitInterval / 10); async.endWindow(); } async.teardown(); List<Object> outTuples = sinkOut.collectedTuples; List<Object> errTuples = sinkErr.collectedTuples; Assert.assertEquals(666, outTuples.size()); Assert.assertEquals(334, errTuples.size()); int previous = -1; for (Object outTuple : outTuples) { Assert.assertTrue(outTuple instanceof String); String outTuple1 = (String)outTuple; String[] split = outTuple1.split(";"); Assert.assertEquals(2, split.length); int current = Integer.parseInt(split[0]); switch (current % 3) { case 0: Assert.assertTrue(false); break; case 1: Assert.assertEquals("FIRSTPASS", split[1]); break; case 2: Assert.assertEquals("SECONDPASS", split[1]); break; default: throw new RuntimeException("Something wrong happened. Should never end up here."); } if (maintainOrder) { Assert.assertTrue(previous < current); previous = current; } } previous = -1; for (Object errTuple : errTuples) { Assert.assertTrue(errTuple instanceof String); String errTuple1 = (String)errTuple; String[] split = errTuple1.split(";"); Assert.assertEquals(1, split.length); int current = Integer.parseInt(split[0]); Assert.assertTrue(current % 3 == 0); if (maintainOrder) { Assert.assertTrue(previous < current); previous = current; } } }