@Test void testInterceptMessages() throws Exception { List<QueryMessage<?, ?>> withInterceptor = new ArrayList<>(); List<QueryMessage<?, ?>> withoutInterceptor = new ArrayList<>(); testSubject = new AnnotationQueryHandlerAdapter<>(new MyInterceptingQueryHandler(withoutInterceptor, withInterceptor)); QueryMessage<String, String> testQueryMessage = new GenericQueryMessage<>("Hi", "Hello", ResponseTypes.instanceOf(String.class)); String result = (String) testSubject.handle(testQueryMessage); assertEquals("Hi", result); assertEquals(Collections.singletonList(testQueryMessage), withInterceptor); assertEquals(Collections.singletonList(testQueryMessage), withoutInterceptor); }
@Override public Object handle(QueryMessage<?, ?> message) throws Exception { MessageHandlingMember<? super T> handler = model.getHandlers(target.getClass()).filter(m -> m.canHandle(message)) .findFirst() .orElseThrow(() -> new NoHandlerForQueryException("No suitable handler was found for the query of type " + message.getPayloadType().getName())); return model.chainedInterceptor(target.getClass()).handle(message, target, handler); }
AnnotationQueryHandlerAdapter implements QueryHandlerAdapter,
        MessageHandler<QueryMessage<?, ?>> { @Override public Object handle(QueryMessage<?, ?> message) throws Exception { MessageHandlingMember<? super T> handler = model.getHandlers(target.getClass()).filter(m -> m.canHandle(message)) .findFirst() .orElseThrow(() -> new NoHandlerForQueryException("No suitable handler was found for the query of type " + message.getPayloadType().getName())); return model.chainedInterceptor(target.getClass()).handle(message, target, handler); } }
AnnotationQueryHandlerAdapter implements QueryHandlerAdapter,
        MessageHandler<QueryMessage<?, ?>> { @Override public Object handle(QueryMessage<?, ?> message) throws Exception { MessageHandlingMember<? super T> handler = model.getHandlers(target.getClass()).filter(m -> m.canHandle(message)) .findFirst() .orElseThrow(() -> new NoHandlerForQueryException("No suitable handler was found for the query of type " + message.getPayloadType().getName())); return model.chainedInterceptor(target.getClass()).handle(message, target, handler); } AnnotationQueryHandlerAdapter(T target);  AnnotationQueryHandlerAdapter(T target, ParameterResolverFactory parameterResolverFactory); @SuppressWarnings("unchecked")  AnnotationQueryHandlerAdapter(T target, ParameterResolverFactory parameterResolverFactory,
                                         HandlerDefinition handlerDefinition); }
AnnotationQueryHandlerAdapter implements QueryHandlerAdapter,
        MessageHandler<QueryMessage<?, ?>> { @Override public Object handle(QueryMessage<?, ?> message) throws Exception { MessageHandlingMember<? super T> handler = model.getHandlers(target.getClass()).filter(m -> m.canHandle(message)) .findFirst() .orElseThrow(() -> new NoHandlerForQueryException("No suitable handler was found for the query of type " + message.getPayloadType().getName())); return model.chainedInterceptor(target.getClass()).handle(message, target, handler); } AnnotationQueryHandlerAdapter(T target);  AnnotationQueryHandlerAdapter(T target, ParameterResolverFactory parameterResolverFactory); @SuppressWarnings("unchecked")  AnnotationQueryHandlerAdapter(T target, ParameterResolverFactory parameterResolverFactory,
                                         HandlerDefinition handlerDefinition); Registration subscribe(QueryBus queryBus); @Override Object handle(QueryMessage<?, ?> message); @Override boolean canHandle(QueryMessage<?, ?> message); }
AnnotationQueryHandlerAdapter implements QueryHandlerAdapter,
        MessageHandler<QueryMessage<?, ?>> { @Override public Object handle(QueryMessage<?, ?> message) throws Exception { MessageHandlingMember<? super T> handler = model.getHandlers(target.getClass()).filter(m -> m.canHandle(message)) .findFirst() .orElseThrow(() -> new NoHandlerForQueryException("No suitable handler was found for the query of type " + message.getPayloadType().getName())); return model.chainedInterceptor(target.getClass()).handle(message, target, handler); } AnnotationQueryHandlerAdapter(T target);  AnnotationQueryHandlerAdapter(T target, ParameterResolverFactory parameterResolverFactory); @SuppressWarnings("unchecked")  AnnotationQueryHandlerAdapter(T target, ParameterResolverFactory parameterResolverFactory,
                                         HandlerDefinition handlerDefinition); Registration subscribe(QueryBus queryBus); @Override Object handle(QueryMessage<?, ?> message); @Override boolean canHandle(QueryMessage<?, ?> message);  }