public synchronized void addRecord(ConsumerRecord<K, V> record) {
        ensureNotClosed();
        TopicPartition tp = new TopicPartition(record.topic(), record.partition());
        if (!subscriptions.subscription().contains(record.topic()))
            throw new IllegalStateException("Cannot add records for a topics that is not subscribed by the consumer");
        List<ConsumerRecord<K, V>> recs = records.computeIfAbsent(tp, k -> new ArrayList<>());
        recs.add(record);
    }
A mock of the {@link ShareConsumer} interface you can use for testing code that uses Kafka. This class is <i> not
thread-safe </i>.
clients/src/main/java/org/apache/kafka/clients/consumer/MockShareConsumer.java