Is there anyway to mock Emitter in Quarkus?

295 views Asked by At

Hi I tried to test my producer logic and I just wanted to @InjectMock an Emitter but it throw an error something like :

Caused by: jakarta.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type org.eclipse.microprofile.reactive.messaging.Emitter

Any suggestion would be helpful

1

There are 1 answers

3
Ozan Günalp On BEST ANSWER

Reactive Messaging channels are based on CDI extensions, so you cannot inject a mock directly. But you can use the InMemoryConnector to replace the connector implementation and test your producer logic.

Using the in-memory connector, you can get the sink with the channel name of your emitter and assert on received objects.

You can also check https://quarkus.io/guides/kafka#testing-without-a-broker for more information.