PK
- key type of input records written to KafkaPV
- value type of input records written to KafkaCK
- key type of output records read from KafkaCV
- value type of output records read from Kafkapublic final class KafkaIOVerifier<PK,PV,CK,CV>
extends java.lang.Object
Example usage:
KafkaProducer<String, Integer> producer = ...
KafkaConsumer<String, Boolean> consumer = ...
KafkaIOVerifier<String, Integer, String, Boolean> verifier =
new KafkaIOVerifier(producer, consumer);
assertThat(
verifier.sending(
new ProducerRecord<>("topic", "key-1", 1991),
new ProducerRecord<>("topic", "key-2", 1108)
), verifier.resultsInOrder(
true, false, true, true
)
);
Constructor and Description |
---|
KafkaIOVerifier(org.apache.kafka.clients.producer.Producer<PK,PV> producer,
org.apache.kafka.clients.consumer.Consumer<CK,CV> consumer)
Creates a verifier.
|
Modifier and Type | Method and Description |
---|---|
org.hamcrest.Matcher<org.apache.flink.statefun.e2e.common.kafka.KafkaIOVerifier.OutputsHandoff<CV>> |
resultsInAnyOrder(org.hamcrest.Matcher<CV>... expectedResults)
Matcher for verifying the outputs, happening in any order, as a result of calling
sending(ProducerRecord[]) . |
org.hamcrest.Matcher<org.apache.flink.statefun.e2e.common.kafka.KafkaIOVerifier.OutputsHandoff<CV>> |
resultsInOrder(org.hamcrest.Matcher<CV>... expectedResults)
Matcher for verifying the outputs as a result of calling
sending(ProducerRecord[]) . |
org.apache.flink.statefun.e2e.common.kafka.KafkaIOVerifier.OutputsHandoff<CV> |
sending(org.apache.kafka.clients.producer.ProducerRecord<PK,PV>... assertionInputs)
Writes to Kafka multiple assertion input producer records, in the given order.
|
public KafkaIOVerifier(org.apache.kafka.clients.producer.Producer<PK,PV> producer, org.apache.kafka.clients.consumer.Consumer<CK,CV> consumer)
producer
- producer to use to write input records to Kafka.consumer
- consumer to use for reading output records from Kafka.@SafeVarargs public final org.apache.flink.statefun.e2e.common.kafka.KafkaIOVerifier.OutputsHandoff<CV> sending(org.apache.kafka.clients.producer.ProducerRecord<PK,PV>... assertionInputs)
The results of calling this method should be asserted using resultsInOrder(Matcher[])
. In the background, the provided Kafka consumer will be used to
continuously poll output records. For each assertion input provided via this method, you must
consequently use resultsInOrder(Matcher[])
to complete the assertion, which then stops
the consumer from polling Kafka.
assertionInputs
- assertion input producer records to send to Kafka.resultsInOrder(Matcher[])
.@SafeVarargs public final org.hamcrest.Matcher<org.apache.flink.statefun.e2e.common.kafka.KafkaIOVerifier.OutputsHandoff<CV>> resultsInOrder(org.hamcrest.Matcher<CV>... expectedResults)
sending(ProducerRecord[])
.expectedResults
- matchers for the expected results.sending(ProducerRecord[])
.@SafeVarargs public final org.hamcrest.Matcher<org.apache.flink.statefun.e2e.common.kafka.KafkaIOVerifier.OutputsHandoff<CV>> resultsInAnyOrder(org.hamcrest.Matcher<CV>... expectedResults)
sending(ProducerRecord[])
.expectedResults
- matchers for the expected results.sending(ProducerRecord[])
.Copyright © 2014–2023 The Apache Software Foundation. All rights reserved.