1

I have a @Client annotated interface which is used to access a particular URL and fetch some data when my Application starts in a OnApplicationEvent(ServerStartupEvent event) method. The problem is when I use @Micronaut Test, it instantiates the whole server and my Client connects to the actual Web Server. My code is very similar to the one given in this link except that I have a injected Client Interface I use for accessing data from a URL.

Ideally, What I wanted was that I can have some control on what the Client would return by Mocking it or something. The issue is when I do @Mock for my client it scope is limited to the @Test method and The Client which has been injected in the Main Application class still contact the Web Server.

So, My question is how can I Mock Client Interface for the Application startup such that it returns something.

Alternatively, it would be great if something could be suggested to override the OnApplicationEvent method.

Puneet
  • 45
  • 8

0 Answers0