I am writing junit test case for below for consumer class which has below method.
@Bean
@Transactional
public Consumer<Message<String>> response() {
return message -> {
Acknowledgment ack = message.getHeaders().get(Ack, Acknowledgment.class);
helper(message);
log.info("hello");
ack.acknowlege();
}
I am trying to go inside the lambda function through test method but able to proceed further. I tried to write the test as below:
@Test
public void testHelper() {
Message<String> message = MessageBuilder.withPayload("Hello").build();
consumer.response();
}
Assuming that you are referencing
java.util.function.Consumer, theresponsemethod is at present returning an instance of theConsumertype and is not invoking the implementation as shared.The operations would be performed only once you call the
acceptmethod of the Consumer returned. Thereafter you canverifythe occurrences of the methods invoked within.