hivemq / hivemq-mqtt-client

HiveMQ MQTT Client is an MQTT 5.0 and MQTT 3.1.1 compatible and feature-rich high-performance Java client library with different API flavours and backpressure support
https://hivemq.github.io/hivemq-mqtt-client/
Apache License 2.0
824 stars 153 forks source link

How to simulate an exception for compatable future ofpublish.send.whenComplete() in the below code in junit5 #599

Open PoorviIjantkar opened 8 months ago

PoorviIjantkar commented 8 months ago

How to simulate an exception for compatable future ofpublish.send.whenComplete() in the below code in junit5 for the below code

I am writing an integration test.How to mock an exception for whenComplete in the below code:

mqtt5Client.publishWith().topic(topicName) .payload(messagePayLoad) .qos(mqttQos) .retain(isRetainedMessage) .send().whenComplete((connAck, exception) -> { if (exception != null) { log.error("Failed publishing the event ") } else log.info("Successfully published the event ") });`