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 from TopologyTestDriver. If [a] record does not contain a timestamp, TestInputTopic will auto advance it's time when the record is piped.
  • Constructor Details

    • TestRecord

      public TestRecord​(K key, V value, Headers headers, Instant recordTime)
      Creates a record.
      Parameters:
      key - The key that will be included in the record
      value - The value of the record
      headers - the record headers that will be included in the record
      recordTime - 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 record
      value - The value of the record
      headers - the record headers that will be included in the record
      timestampMs - 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 record
      value - The value of the record
      recordTime - 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 record
      value - The value of the record
      headers - 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 record
      value - The value of the record
    • TestRecord

      public TestRecord​(V value)
      Create a record with null key.
      Parameters:
      value - The value of the record
    • TestRecord

      public TestRecord​(ConsumerRecord<K,​V> record)
      Create a TestRecord from a ConsumerRecord.
      Parameters:
      record - The v
    • TestRecord

      public TestRecord​(ProducerRecord<K,​V> record)
      Create a TestRecord from a ProducerRecord.
      Parameters:
      record - The record contents
  • Method Details

    • 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.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals​(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object