AscendingTimestampExtractor implements AssignerWithPeriodicWatermarks<T> { public AscendingTimestampExtractor<T> withViolationHandler(MonotonyViolationHandler handler) { this.violationHandler = requireNonNull(handler); return this; }  abstract long extractAscendingTimestamp(T element); AscendingTimestampExtractor<T> withViolationHandler(MonotonyViolationHandler handler); @Override final long extractTimestamp(T element, long elementPrevTimestamp); @Override final Watermark getCurrentWatermark();  }
@Test public void testWithFailingHandler() { AscendingTimestampExtractor<Long> extractor = new LongExtractor() .withViolationHandler(new AscendingTimestampExtractor.FailingHandler()); runValidTests(extractor); try { runInvalidTest(extractor); fail("should fail with an exception"); } catch (Exception ignored) {} }
@Test public void testWithIgnoringHandler() { AscendingTimestampExtractor<Long> extractor = new LongExtractor() .withViolationHandler(new AscendingTimestampExtractor.IgnoringHandler()); runValidTests(extractor); runInvalidTest(extractor); }
@Test public void testWithLoggingHandler() { AscendingTimestampExtractor<Long> extractor = new LongExtractor() .withViolationHandler(new AscendingTimestampExtractor.LoggingHandler()); runValidTests(extractor); runInvalidTest(extractor); }