Package org.apache.kafka.streams.test
Class TestRecord<K,V>
- java.lang.Object
-
- org.apache.kafka.streams.test.TestRecord<K,V>
-
public class TestRecord<K,V> extends Object
A key/value pair, including timestamp and record headers, to be sent to or received fromTopologyTestDriver
. If [a] record does not contain a timestamp,TestInputTopic
will auto advance it's time when the record is piped.
-
-
Constructor Summary
Constructors Constructor Description TestRecord(K key, V value)
Creates a record.TestRecord(K key, V value, Instant recordTime)
Creates a record.TestRecord(K key, V value, Headers headers)
Creates a record.TestRecord(K key, V value, Headers headers, Long timestampMs)
Creates a record.TestRecord(K key, V value, Headers headers, Instant recordTime)
Creates a record.TestRecord(ConsumerRecord<K,V> record)
Create aTestRecord
from aConsumerRecord
.TestRecord(ProducerRecord<K,V> record)
Create aTestRecord
from aProducerRecord
.TestRecord(V value)
Create a record withnull
key.
-
-
-
Constructor Detail
-
TestRecord
public TestRecord(K key, V value, Headers headers, Instant recordTime)
Creates a record.- Parameters:
key
- The key that will be included in the recordvalue
- The value of the recordheaders
- the record headers that will be included in the recordrecordTime
- The timestamp of the record.
-
TestRecord
public TestRecord(K key, V value, Headers headers, Long timestampMs)
Creates a record.- Parameters:
key
- The key that will be included in the recordvalue
- The value of the recordheaders
- the record headers that will be included in the recordtimestampMs
- The timestamp of the record, in milliseconds since the beginning of the epoch.
-
TestRecord
public TestRecord(K key, V value, Instant recordTime)
Creates a record.- Parameters:
key
- The key of the recordvalue
- The value of the recordrecordTime
- The timestamp of the record as Instant.
-
TestRecord
public TestRecord(K key, V value, Headers headers)
Creates a record.- Parameters:
key
- The key of the recordvalue
- The value of the recordheaders
- The record headers that will be included in the record
-
TestRecord
public TestRecord(K key, V value)
Creates a record.- Parameters:
key
- The key of the recordvalue
- The value of the record
-
TestRecord
public TestRecord(V value)
Create a record withnull
key.- Parameters:
value
- The value of the record
-
TestRecord
public TestRecord(ConsumerRecord<K,V> record)
Create aTestRecord
from aConsumerRecord
.- Parameters:
record
- The v
-
TestRecord
public TestRecord(ProducerRecord<K,V> record)
Create aTestRecord
from aProducerRecord
.- Parameters:
record
- The record contents
-
-
Method Detail
-
headers
public Headers headers()
- Returns:
- The headers.
-
key
public K key()
- Returns:
- The key (or
null
if no key is specified).
-
value
public V value()
- Returns:
- The value.
-
timestamp
public Long timestamp()
- Returns:
- The timestamp, which is in milliseconds since epoch.
-
getHeaders
public Headers getHeaders()
- Returns:
- The headers.
-
getKey
public K getKey()
- Returns:
- The key (or null if no key is specified)
-
getValue
public V getValue()
- Returns:
- The value.
-
getRecordTime
public Instant getRecordTime()
- Returns:
- The timestamp.
-
-