@Test @DisplayName("invokeMany should return empty response when service returns null") void testInvokeManyWhenReturnNull() throws Exception { final String methodName = "returnNull2"; final Class<? extends StubService> serviceClass = stubService.getClass(); final Method method = serviceClass.getMethod(methodName); final MethodInfo methodInfo = new MethodInfo( serviceClass.getName(), methodName, method.getReturnType(), IS_RETURN_TYPE_SERVICE_MESSAGE, CommunicationMode.REQUEST_STREAM, method.getParameterCount(), Void.TYPE, IS_REQUEST_TYPE_SERVICE_MESSAGE, AUTH); serviceMethodInvoker = new ServiceMethodInvoker( method, stubService, methodInfo, DefaultErrorMapper.INSTANCE, dataDecoder, nullAuthenticator, nullPrincipalMapper); ServiceMessage message = ServiceMessage.builder().qualifier(qualifierPrefix + methodName).build(); StepVerifier.create( Flux.deferWithContext(context -> serviceMethodInvoker.invokeMany(message)) .subscriberContext(context -> context.put(AUTH_CONTEXT_KEY, AUTH_DATA))) .verifyComplete(); }
public Flux<ServiceMessage> invokeMany(ServiceMessage message) { return Mono.deferWithContext(context -> authenticate(message, context)) .flatMapMany(authData -> deferWithContextMany(message, authData)) .map(response -> toResponse(response, message.qualifier(), message.dataFormat())) .onErrorResume( throwable -> Flux.just(errorMapper.toMessage(message.qualifier(), throwable))); }
ServiceMethodInvoker { public Flux<ServiceMessage> invokeMany(ServiceMessage message) { return Mono.deferWithContext(context -> authenticate(message, context)) .flatMapMany(authData -> deferWithContextMany(message, authData)) .map(response -> toResponse(response, message.qualifier(), message.dataFormat())) .onErrorResume( throwable -> Flux.just(errorMapper.toMessage(message.qualifier(), throwable))); } }
ServiceMethodInvoker { public Flux<ServiceMessage> invokeMany(ServiceMessage message) { return Mono.deferWithContext(context -> authenticate(message, context)) .flatMapMany(authData -> deferWithContextMany(message, authData)) .map(response -> toResponse(response, message.qualifier(), message.dataFormat())) .onErrorResume( throwable -> Flux.just(errorMapper.toMessage(message.qualifier(), throwable))); } ServiceMethodInvoker(
      Method method,
      Object service,
      MethodInfo methodInfo,
      ServiceProviderErrorMapper errorMapper,
      ServiceMessageDataDecoder dataDecoder,
      Authenticator<Object> authenticator,
      PrincipalMapper<Object, Object> principalMapper); }
ServiceMethodInvoker { public Flux<ServiceMessage> invokeMany(ServiceMessage message) { return Mono.deferWithContext(context -> authenticate(message, context)) .flatMapMany(authData -> deferWithContextMany(message, authData)) .map(response -> toResponse(response, message.qualifier(), message.dataFormat())) .onErrorResume( throwable -> Flux.just(errorMapper.toMessage(message.qualifier(), throwable))); } ServiceMethodInvoker(
      Method method,
      Object service,
      MethodInfo methodInfo,
      ServiceProviderErrorMapper errorMapper,
      ServiceMessageDataDecoder dataDecoder,
      Authenticator<Object> authenticator,
      PrincipalMapper<Object, Object> principalMapper); Mono<ServiceMessage> invokeOne(ServiceMessage message); Flux<ServiceMessage> invokeMany(ServiceMessage message); Flux<ServiceMessage> invokeBidirectional(Publisher<ServiceMessage> publisher); Object service(); MethodInfo methodInfo(); @Override String toString(); }
ServiceMethodInvoker { public Flux<ServiceMessage> invokeMany(ServiceMessage message) { return Mono.deferWithContext(context -> authenticate(message, context)) .flatMapMany(authData -> deferWithContextMany(message, authData)) .map(response -> toResponse(response, message.qualifier(), message.dataFormat())) .onErrorResume( throwable -> Flux.just(errorMapper.toMessage(message.qualifier(), throwable))); } ServiceMethodInvoker(
      Method method,
      Object service,
      MethodInfo methodInfo,
      ServiceProviderErrorMapper errorMapper,
      ServiceMessageDataDecoder dataDecoder,
      Authenticator<Object> authenticator,
      PrincipalMapper<Object, Object> principalMapper); Mono<ServiceMessage> invokeOne(ServiceMessage message); Flux<ServiceMessage> invokeMany(ServiceMessage message); Flux<ServiceMessage> invokeBidirectional(Publisher<ServiceMessage> publisher); Object service(); MethodInfo methodInfo(); @Override String toString();  }