@Test void subscribe() { when(queryBus.subscribe(any(), any(), any())).thenReturn(() -> true); Registration registration = testSubject.subscribe(queryBus); verify(queryBus, times(1)).subscribe(eq(String.class.getName()), eq(String.class), any()); verify(queryBus, times(1)).subscribe(eq("Hello"), eq(String.class), any()); assertTrue(registration.cancel()); }
public Registration subscribe(QueryBus queryBus) { Collection<Registration> registrationList = model.getHandlers().stream() .map(m -> subscribe(queryBus, m)) .filter(Objects::nonNull) .collect(Collectors.toList()); return () -> registrationList.stream().map(Registration::cancel) .reduce(Boolean::logicalOr) .orElse(false); }
AnnotationQueryHandlerAdapter implements QueryHandlerAdapter,
        MessageHandler<QueryMessage<?, ?>> { public Registration subscribe(QueryBus queryBus) { Collection<Registration> registrationList = model.getHandlers().stream() .map(m -> subscribe(queryBus, m)) .filter(Objects::nonNull) .collect(Collectors.toList()); return () -> registrationList.stream().map(Registration::cancel) .reduce(Boolean::logicalOr) .orElse(false); } }
AnnotationQueryHandlerAdapter implements QueryHandlerAdapter,
        MessageHandler<QueryMessage<?, ?>> { public Registration subscribe(QueryBus queryBus) { Collection<Registration> registrationList = model.getHandlers().stream() .map(m -> subscribe(queryBus, m)) .filter(Objects::nonNull) .collect(Collectors.toList()); return () -> registrationList.stream().map(Registration::cancel) .reduce(Boolean::logicalOr) .orElse(false); } AnnotationQueryHandlerAdapter(T target);  AnnotationQueryHandlerAdapter(T target, ParameterResolverFactory parameterResolverFactory); @SuppressWarnings("unchecked")  AnnotationQueryHandlerAdapter(T target, ParameterResolverFactory parameterResolverFactory,
                                         HandlerDefinition handlerDefinition); }
AnnotationQueryHandlerAdapter implements QueryHandlerAdapter,
        MessageHandler<QueryMessage<?, ?>> { public Registration subscribe(QueryBus queryBus) { Collection<Registration> registrationList = model.getHandlers().stream() .map(m -> subscribe(queryBus, m)) .filter(Objects::nonNull) .collect(Collectors.toList()); return () -> registrationList.stream().map(Registration::cancel) .reduce(Boolean::logicalOr) .orElse(false); } 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<?, ?>> { public Registration subscribe(QueryBus queryBus) { Collection<Registration> registrationList = model.getHandlers().stream() .map(m -> subscribe(queryBus, m)) .filter(Objects::nonNull) .collect(Collectors.toList()); return () -> registrationList.stream().map(Registration::cancel) .reduce(Boolean::logicalOr) .orElse(false); } 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);  }