Class KafkaMatchers

java.lang.Object
org.springframework.kafka.test.hamcrest.KafkaMatchers

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

    • 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