@Test
public void processElementWithOutputTimestamp() throws Exception {
try (DoFnTester<Long, String> tester = DoFnTester.of(new CounterDoFn())) {
tester.processElement(1L);
tester.processElement(2L);
List<TimestampedValue<String>> peek = tester.peekOutputElementsWithTimestamp();
TimestampedValue<String> one = TimestampedValue.of("1", new Instant(1000L));
TimestampedValue<String> two = TimestampedValue.of("2", new Instant(2000L));
assertThat(peek, hasItems(one, two));
tester.processElement(3L);
tester.processElement(4L);
TimestampedValue<String> three = TimestampedValue.of("3", new Instant(3000L));
TimestampedValue<String> four = TimestampedValue.of("4", new Instant(4000L));
peek = tester.peekOutputElementsWithTimestamp();
assertThat(peek, hasItems(one, two, three, four));
List<TimestampedValue<String>> take = tester.takeOutputElementsWithTimestamp();
assertThat(take, hasItems(one, two, three, four));
assertTrue(tester.takeOutputElementsWithTimestamp().isEmpty());
assertTrue(tester.peekOutputElementsWithTimestamp().isEmpty());
assertTrue(tester.peekOutputElements().isEmpty());
assertTrue(tester.takeOutputElements().isEmpty());
}
}