K
- the type of the record keyV
- the type of the record valuepublic class TestInputTopic<K,V> extends Object
TestInputTopic
is used to pipe records to topic in TopologyTestDriver
.
To use TestInputTopic
create a new instance via
TopologyTestDriver.createInputTopic(String, Serializer, Serializer)
.
In actual test code, you can pipe new record values, keys and values or list of KeyValue
pairs.
If you have multiple source topics, you need to create a TestInputTopic
for each.
private TestInputTopic<Long, String> inputTopic;
...
inputTopic = testDriver.createInputTopic(INPUT_TOPIC, longSerializer, stringSerializer);
...
inputTopic.pipeInput("Hello");
TopologyTestDriver
Modifier and Type | Method and Description |
---|---|
void |
advanceTime(Duration advance)
Advances the internally tracked event time of this input topic.
|
void |
pipeInput(K key,
V value)
Send an input record with the given key and value on the topic and then commit the records.
|
void |
pipeInput(K key,
V value,
Instant timestamp)
Send an input record with the given key, value and timestamp on the topic and then commit the records.
|
void |
pipeInput(K key,
V value,
long timestampMs)
Send an input record with the given key, value and timestamp on the topic and then commit the records.
|
void |
pipeInput(TestRecord<K,V> record)
Send an input record with the given record on the topic and then commit the records.
|
void |
pipeInput(V value)
Send an input record with the given value on the topic and then commit the records.
|
void |
pipeInput(V value,
Instant timestamp)
Send an input record with the given value and timestamp on the topic and then commit the records.
|
void |
pipeKeyValueList(List<KeyValue<K,V>> keyValues)
Send input records with the given KeyValue list on the topic then commit each record individually.
|
void |
pipeKeyValueList(List<KeyValue<K,V>> keyValues,
Instant startTimestamp,
Duration advance)
Send input records with the given
KeyValue list on the topic then commit each record individually. |
void |
pipeRecordList(List<? extends TestRecord<K,V>> records)
Send input records with the given KeyValue list on the topic then commit each record individually.
|
void |
pipeValueList(List<V> values)
Send input records with the given value list on the topic then commit each record individually.
|
void |
pipeValueList(List<V> values,
Instant startTimestamp,
Duration advance)
Send input records with the given value list on the topic then commit each record individually.
|
String |
toString() |
public void advanceTime(Duration advance)
Note: advancing the event time on the input topic, does not advance the tracked stream time in
TopologyTestDriver
as long as no new input records are piped.
Furthermore, it does not advance the wall-clock time of TopologyTestDriver
.
advance
- the duration of time to advancepublic void pipeInput(TestRecord<K,V> record)
record
- the record to sentpublic void pipeInput(V value)
value
- the record valuepublic void pipeInput(K key, V value)
key
- the record keyvalue
- the record valuepublic void pipeInput(V value, Instant timestamp)
value
- the record valuetimestamp
- the record timestamppublic void pipeInput(K key, V value, long timestampMs)
key
- the record keyvalue
- the record valuetimestampMs
- the record timestamppublic void pipeInput(K key, V value, Instant timestamp)
key
- the record keyvalue
- the record valuetimestamp
- the record timestamppublic void pipeRecordList(List<? extends TestRecord<K,V>> records)
records
- the list of TestRecord recordspublic void pipeKeyValueList(List<KeyValue<K,V>> keyValues)
autoAdvance
setting.public void pipeValueList(List<V> values)
autoAdvance
setting.public void pipeKeyValueList(List<KeyValue<K,V>> keyValues, Instant startTimestamp, Duration advance)
KeyValue
list on the topic then commit each record individually.
Does not auto advance internally tracked time.public void pipeValueList(List<V> values, Instant startTimestamp, Duration advance)
autoAdvance
setting.values
- the List
of valuesstartTimestamp
- the timestamp for the first generated recordadvance
- the time difference between two consecutive generated records