Class TestRecord<K,​V>


  • public class TestRecord<K,​V>
    extends java.lang.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 Summary

      Constructors 
      Constructor Description
      TestRecord​(K key, V value)
      Creates a record.
      TestRecord​(K key, V value, java.time.Instant recordTime)
      Creates a record.
      TestRecord​(K key, V value, org.apache.kafka.common.header.Headers headers)
      Creates a record.
      TestRecord​(K key, V value, org.apache.kafka.common.header.Headers headers, java.lang.Long timestampMs)
      Creates a record.
      TestRecord​(K key, V value, org.apache.kafka.common.header.Headers headers, java.time.Instant recordTime)
      Creates a record.
      TestRecord​(org.apache.kafka.clients.consumer.ConsumerRecord<K,​V> record)
      Create a TestRecord from a ConsumerRecord.
      TestRecord​(org.apache.kafka.clients.producer.ProducerRecord<K,​V> record)
      Create a TestRecord from a ProducerRecord.
      TestRecord​(V value)
      Create a record with null key.
    • Constructor Detail

      • TestRecord

        public TestRecord​(K key,
                          V value,
                          org.apache.kafka.common.header.Headers headers,
                          java.time.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,
                          org.apache.kafka.common.header.Headers headers,
                          java.lang.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,
                          java.time.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,
                          org.apache.kafka.common.header.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​(org.apache.kafka.clients.consumer.ConsumerRecord<K,​V> record)
        Create a TestRecord from a ConsumerRecord.
        Parameters:
        record - The v
      • TestRecord

        public TestRecord​(org.apache.kafka.clients.producer.ProducerRecord<K,​V> record)
        Create a TestRecord from a ProducerRecord.
        Parameters:
        record - The record contents
    • Method Detail

      • headers

        public org.apache.kafka.common.header.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 java.lang.Long timestamp()
        Returns:
        The timestamp, which is in milliseconds since epoch.
      • getHeaders

        public org.apache.kafka.common.header.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 java.time.Instant getRecordTime()
        Returns:
        The timestamp.
      • toString

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

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

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object