Improve test coverage UsePreviousTimeOnInvalidTimestamp
Author: Jeyhun Karimov
Reviewers: Matthias J. Sax Guozhang Wang
Closes from jeyhunkarimov/KAFKA-4661
package org.apache.kafka.streams.processor;
import org.apache.kafka.clients.consumer.ConsumerRecord;
+import org.apache.kafka.streams.errors.StreamsException;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.fail;
public class UsePreviousTimeOnInvalidTimestampTest extends TimestampExtractorTest {
@@ -42,4 +44,13 @@ public class UsePreviousTimeOnInvalidTimestampTest extends TimestampExtractorTes
assertThat(timestamp, is(previousTime));
}
+ @Test
+ public void shouldThrowStreamsException() {
+ final TimestampExtractor extractor = new UsePreviousTimeOnInvalidTimestamp();
+ final ConsumerRecord record = new ConsumerRecord<>("anyTopic", 0, 0, null, null);
+ try {
+ extractor.extract(record, -1);
+ fail("should have thrown StreamsException");
+ } catch (final StreamsException expected) { }
+ }
}
