How can I mock zeebe for unit test?

Hi guys,

I have a question, during my implementation I’ve been struggling with this error:

Caused by:
org.springframework.context.ApplicationContextException: Failed to start bean 'zeebeClientLifecycle'; nested exception is io.zeebe.client.api.command.ClientStatusException: io exception

    Caused by:
    io.zeebe.client.api.command.ClientStatusException: io exception

        Caused by:
        java.util.concurrent.ExecutionException: io.grpc.StatusRuntimeException: UNAVAILABLE: io exception

            Caused by:
            io.grpc.StatusRuntimeException: UNAVAILABLE: io exception

                Caused by:
                io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: /0.0.0.0:26500

                    Caused by:
                    java.net.ConnectException: Connection refused

So, How is the best way to mock ZeebeClient ?

1 Like

@Getulio have you tried any of the Java Mocking libraries like Mockito?

1 Like

You can put your job handler logic in a separate method, and unit test it without the Zeebe connection.

Yes, it works (compile) but still trying to connect in a broker!

But I have a service (already has tests) and zeebeClient is injected there.
So I tryed:
mock(ZeebeClass)

Do you have your code in GitHub where we can take a look at it?

Let me try do it separately in a POC
Because thee real code is from my company :frowning_face: , unfortunately I can share it
thanks for helping

1 Like

@Getulio if you can create a reproducer in a separate repo that will be great… I will be happy to look at it.

1 Like