'Unit test for Spring KafkaListener with "Acknowledge" interface as an argument

I'm not expert at unit test but trying to write unit test for :

    @KafkaListener(id = "group_id", topics = "topic" )
    public AvroObject listen(AvroObject test, Acknowledgment ack)

But no idea how I can make it when there is and interface as an argument. I try this but not sure is it something useful or not make sense as an test :

    @InjectMocks
    KafkaConsumer kafkaConsumerTest;

    @Test
    @DisplayName("Assert Valid Consume")
    void consumeValidEvent() throws URISyntaxException, IOException, InterruptedException {
        // given
        AvroObject event = createEvent(); //Create sample object as AvroObject

        // when
        AvroObject response = kafkaConsumerTest.listen(event, new Acknowledgment() {
             @Override
            public void acknowledge() {

            }
            @Override
            public void nack(long sleep) {
                //do nothing
            }

        // then
        assertNotNull(response);
        assertEquals(response.getCode1() ,98765);
        assertEquals(response.getCode2() ,123456);
    }

I was wondering if you can give me the best approach for this situation! cheers



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source