Fadelis/grpcmock

Enhancement: Add 'willProxyTo' to all communication types

RomanKhachko opened this issue · 2 comments

Currently, the interface StreamRequestProxyResponseBuilderStep is implemented by classes supporting streaming from the client-side (client and bidi streams). However, it would be extremely beneficial to add this functionality for other communication types (server stream and unary).

We use this library not for testing purposes, but as an embedded mock server for our local development experience. Method 'willProxyTo' allows providing a custom dynamic behavior. Therefore, besides predefined responses, we could provide implementations handling request values in runtime.

Hi @RomanKhachko , this is already available for both unary and server streaming requests. There's a method .willProxyTo((request, responseObserver) -> ...), where you control the whole flow, and also .willReturn(request -> ...) where you can respond based on the request and will complete the call that call for you after this function completes. You can see more examples here and here

Amazing! Thanks a lot for the clarification! It's exactly what is needed. We can remove the request then.