Class KafkaMatchers


  • public final class KafkaMatchers
    extends java.lang.Object
    Hamcrest Matchers utilities.
    Author:
    Gary Russell, Biju Kunjummen
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <K> org.hamcrest.Matcher<org.apache.kafka.clients.consumer.ConsumerRecord<K,​?>> hasKey​(K key)  
      static org.hamcrest.Matcher<org.apache.kafka.clients.consumer.ConsumerRecord<?,​?>> hasPartition​(int partition)  
      static org.hamcrest.Matcher<org.apache.kafka.clients.consumer.ConsumerRecord<?,​?>> hasTimestamp​(long ts)
      Matcher testing the timestamp of a ConsumerRecord assuming the topic has been set with CreateTime.
      static org.hamcrest.Matcher<org.apache.kafka.clients.consumer.ConsumerRecord<?,​?>> hasTimestamp​(org.apache.kafka.common.record.TimestampType type, long ts)
      Matcher testing the timestamp of a ConsumerRecord
      static <V> org.hamcrest.Matcher<org.apache.kafka.clients.consumer.ConsumerRecord<?,​V>> hasValue​(V value)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • hasKey

        public static <K> org.hamcrest.Matcher<org.apache.kafka.clients.consumer.ConsumerRecord<K,​?>> hasKey​(K key)
        Type Parameters:
        K - the type.
        Parameters:
        key - the key
        Returns:
        a Matcher that matches the key in a consumer record.
      • hasValue

        public static <V> org.hamcrest.Matcher<org.apache.kafka.clients.consumer.ConsumerRecord<?,​V>> hasValue​(V value)
        Type Parameters:
        V - the type.
        Parameters:
        value - the value.
        Returns:
        a Matcher that matches the value in a consumer record.
      • hasPartition

        public static org.hamcrest.Matcher<org.apache.kafka.clients.consumer.ConsumerRecord<?,​?>> hasPartition​(int partition)
        Parameters:
        partition - the partition.
        Returns:
        a Matcher that matches the partition in a consumer record.
      • hasTimestamp

        public static org.hamcrest.Matcher<org.apache.kafka.clients.consumer.ConsumerRecord<?,​?>> hasTimestamp​(long ts)
        Matcher testing the timestamp of a ConsumerRecord assuming the topic has been set with CreateTime.
        Parameters:
        ts - timestamp of the consumer record.
        Returns:
        a Matcher that matches the timestamp in a consumer record.
        Since:
        1.3
      • hasTimestamp

        public static org.hamcrest.Matcher<org.apache.kafka.clients.consumer.ConsumerRecord<?,​?>> hasTimestamp​(org.apache.kafka.common.record.TimestampType type,
                                                                                                                     long ts)
        Matcher testing the timestamp of a ConsumerRecord
        Parameters:
        type - timestamp type of the record
        ts - timestamp of the consumer record.
        Returns:
        a Matcher that matches the timestamp in a consumer record.
        Since:
        1.3