Class KafkaMatchers
java.lang.Object
org.springframework.kafka.test.hamcrest.KafkaMatchers
Hamcrest
Matcher
s utilities.- Author:
- Gary Russell, Biju Kunjummen
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
static class
static class
-
Method Summary
Modifier and TypeMethodDescriptionstatic <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 aConsumerRecord
assuming the topic has been set withCreateTime
.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 aConsumerRecord
static <V> org.hamcrest.Matcher<org.apache.kafka.clients.consumer.ConsumerRecord<?,
V>> hasValue
(V value)
-
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 aConsumerRecord
assuming the topic has been set withCreateTime
.- 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 aConsumerRecord
- Parameters:
type
- timestamp type of the recordts
- timestamp of the consumer record.- Returns:
- a Matcher that matches the timestamp in a consumer record.
- Since:
- 1.3
-