@Test public void scanHandledMessageTypes_sagaWithContinueHandler_returnsHandler() throws ExecutionException { mockSaga(String.class, Integer.class); Map<Class<? extends Saga>, SagaHandlersMap> classSagaHandlersMapMap = sut.scanHandledMessageTypes(); assertThat("Expected saga type to be present.", classSagaHandlersMapMap.containsKey(TestSaga.class), is(true)); Collection<MessageHandler> handlers = classSagaHandlersMapMap.get(TestSaga.class).messageHandlers(); Optional<MessageHandler> continueHandler = handlers.stream().filter(h -> h.getMessageType().equals(Integer.class)).findFirst(); assertThat("Expected handlers map to contain handler type", continueHandler.isPresent(), is(true)); assertThat("Expected handlers map to to be starting type.", continueHandler.get().getStartsSaga(), is(false)); }
@Override public Map<Class<? extends Saga>, SagaHandlersMap> scanHandledMessageTypes() { Collection<Class<? extends Saga>> sagaClasses = typeScanner.scanForSagas(); Stream<DescribesHandlers> directDescriptionSagas = sagaClasses.stream() .filter(DescribesHandlers.class::isAssignableFrom) .filter(c -> !Modifier.isAbstract(c.getModifiers())) .flatMap(this::createDirectDescriptionInstance); return createHandlersMap(directDescriptionSagas); }
HandlerDescriptionAnalyzer implements SagaAnalyzer { @Override public Map<Class<? extends Saga>, SagaHandlersMap> scanHandledMessageTypes() { Collection<Class<? extends Saga>> sagaClasses = typeScanner.scanForSagas(); Stream<DescribesHandlers> directDescriptionSagas = sagaClasses.stream() .filter(DescribesHandlers.class::isAssignableFrom) .filter(c -> !Modifier.isAbstract(c.getModifiers())) .flatMap(this::createDirectDescriptionInstance); return createHandlersMap(directDescriptionSagas); } }
HandlerDescriptionAnalyzer implements SagaAnalyzer { @Override public Map<Class<? extends Saga>, SagaHandlersMap> scanHandledMessageTypes() { Collection<Class<? extends Saga>> sagaClasses = typeScanner.scanForSagas(); Stream<DescribesHandlers> directDescriptionSagas = sagaClasses.stream() .filter(DescribesHandlers.class::isAssignableFrom) .filter(c -> !Modifier.isAbstract(c.getModifiers())) .flatMap(this::createDirectDescriptionInstance); return createHandlersMap(directDescriptionSagas); } @Inject  HandlerDescriptionAnalyzer(final TypeScanner typeScanner, final SagaInstanceCreator instanceCreator); }
HandlerDescriptionAnalyzer implements SagaAnalyzer { @Override public Map<Class<? extends Saga>, SagaHandlersMap> scanHandledMessageTypes() { Collection<Class<? extends Saga>> sagaClasses = typeScanner.scanForSagas(); Stream<DescribesHandlers> directDescriptionSagas = sagaClasses.stream() .filter(DescribesHandlers.class::isAssignableFrom) .filter(c -> !Modifier.isAbstract(c.getModifiers())) .flatMap(this::createDirectDescriptionInstance); return createHandlersMap(directDescriptionSagas); } @Inject  HandlerDescriptionAnalyzer(final TypeScanner typeScanner, final SagaInstanceCreator instanceCreator); @Override Map<Class<? extends Saga>, SagaHandlersMap> scanHandledMessageTypes(); }
HandlerDescriptionAnalyzer implements SagaAnalyzer { @Override public Map<Class<? extends Saga>, SagaHandlersMap> scanHandledMessageTypes() { Collection<Class<? extends Saga>> sagaClasses = typeScanner.scanForSagas(); Stream<DescribesHandlers> directDescriptionSagas = sagaClasses.stream() .filter(DescribesHandlers.class::isAssignableFrom) .filter(c -> !Modifier.isAbstract(c.getModifiers())) .flatMap(this::createDirectDescriptionInstance); return createHandlersMap(directDescriptionSagas); } @Inject  HandlerDescriptionAnalyzer(final TypeScanner typeScanner, final SagaInstanceCreator instanceCreator); @Override Map<Class<? extends Saga>, SagaHandlersMap> scanHandledMessageTypes();  }