Skip to content

Can't test tombstone event NullPointerException #564

@HugoSerge

Description

@HugoSerge

Hello,

I'm trying to assert that my topic contains a tombstone event.

Message produced by producer :

key: "randomKey"
value: null

With this code

kafkaTemplate.send(topicName, keyGenerator(itemId.toString(), warehouseGln), null);

In the_topic_contains method

    public void the_topic_contains(Guard guard, boolean fromBeginning, String topicValue, Comparison comparison, String name, String content) {
      ...
            Map<String, String> headers = (Map)Stream.of(record.headers().toArray()).collect(Collectors.toMap(Header::key, (header) -> new String(header.value())));
            Map<String, Object> value = (Map)Mapper.read(record.value().toString()); <----- NPE here
            String messageKey = record.key() != null ? String.valueOf(record.key()) : "";
      ...
        });
    }

Stacktrace

java.lang.NullPointerException: Cannot invoke "Object.toString()" because the return value of "org.apache.kafka.clients.consumer.ConsumerRecord.value()" is null 
	at com.decathlon.tzatziki.steps.KafkaSteps.lambda$the_topic_contains$20(KafkaSteps.java:304)  

If I'm using library correctly I think it's an issue.
Don't hesitate to give me the correct way to achieve this assertion if not.
Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions