@Test @DisplayName( "invocation of auth method should return empty response " + "if there're no auth.context but authenticator exists") void testAuthMethodWhenNoContextButThereIsAuthenticator() throws Exception { final String methodName = "helloAuthContext"; 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_RESPONSE, method.getParameterCount(), Void.TYPE, IS_REQUEST_TYPE_SERVICE_MESSAGE, AUTH); Authenticator<Map> mockedAuthenticator = Mockito.mock(Authenticator.class); Mockito.when(mockedAuthenticator.apply(ArgumentMatchers.anyMap())) .thenReturn(Mono.just(AUTH_DATA)); serviceMethodInvoker = new ServiceMethodInvoker( method, stubService, methodInfo, DefaultErrorMapper.INSTANCE, dataDecoder, authenticator, principalMapper); ServiceMessage message = ServiceMessage.builder().qualifier(qualifierPrefix + methodName).build(); StepVerifier.create(serviceMethodInvoker.invokeOne(message)).verifyComplete(); }
public Mono<ServiceMessage> invokeOne(ServiceMessage message) { return Mono.deferWithContext(context -> authenticate(message, context)) .flatMap(authData -> deferWithContextOne(message, authData)) .map(response -> toResponse(response, message.qualifier(), message.dataFormat())) .onErrorResume( throwable -> Mono.just(errorMapper.toMessage(message.qualifier(), throwable))); }
ServiceMethodInvoker { public Mono<ServiceMessage> invokeOne(ServiceMessage message) { return Mono.deferWithContext(context -> authenticate(message, context)) .flatMap(authData -> deferWithContextOne(message, authData)) .map(response -> toResponse(response, message.qualifier(), message.dataFormat())) .onErrorResume( throwable -> Mono.just(errorMapper.toMessage(message.qualifier(), throwable))); } }
ServiceMethodInvoker { public Mono<ServiceMessage> invokeOne(ServiceMessage message) { return Mono.deferWithContext(context -> authenticate(message, context)) .flatMap(authData -> deferWithContextOne(message, authData)) .map(response -> toResponse(response, message.qualifier(), message.dataFormat())) .onErrorResume( throwable -> Mono.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 Mono<ServiceMessage> invokeOne(ServiceMessage message) { return Mono.deferWithContext(context -> authenticate(message, context)) .flatMap(authData -> deferWithContextOne(message, authData)) .map(response -> toResponse(response, message.qualifier(), message.dataFormat())) .onErrorResume( throwable -> Mono.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 Mono<ServiceMessage> invokeOne(ServiceMessage message) { return Mono.deferWithContext(context -> authenticate(message, context)) .flatMap(authData -> deferWithContextOne(message, authData)) .map(response -> toResponse(response, message.qualifier(), message.dataFormat())) .onErrorResume( throwable -> Mono.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();  }