Open
Description
What I found during writing/testing Proteus-Spring application is the lack of proper test-kit that allows to easily mock broker (possibly avoid it at all) and mock Proteus instance so the testing of the generated client/server can be setup in a few steps.
For now, to test the app, I have to do something like the following:
@RunWith(SpringRunner.class)
@SpringBootTest
public class UserAccessServiceApplicationTest {
@Destination(group = "test", destination = "test")
AccessKeyInfoServiceClient accessKeyInfoServiceClient;
...
@TestConfiguration
public static class TestConfig {
@Bean
public Proteus proteus() {
Proteus proteus = Mockito.mock(Proteus.class);
RequestHandlingRSocket requestHandlingRSocket = new RequestHandlingRSocket();
Mockito.when(proteus.getAccesskey()).thenReturn(1L);
Mockito.when(proteus.getGroupName()).thenReturn("test");
Mockito.when(proteus.getDestination()).thenReturn("test");
Mockito.when(proteus.addService(Mockito.any()))
.thenAnswer(a -> {
requestHandlingRSocket.addService(a.getArgument(0));
return proteus;
});
Mockito.when(proteus.destination(Mockito.anyString(), Mockito.anyString()))
.thenReturn(new DefaultProteusSocket(Payload::retain, () -> requestHandlingRSocket));
Mockito.when(proteus.group(Mockito.anyString()))
.thenReturn(new DefaultProteusSocket(Payload::retain, () -> requestHandlingRSocket));
Mockito.when(proteus.onClose()).thenReturn(Mono.never());
return proteus;
}
}
}
What I would like to see is something similar to annotation based test env setup like one in spring web -> @WebFluxTest
/@WebMvcTest