DefaultStrategyFinder implements StrategyFinder { @Override public Collection<ResolveStrategy> find(final LookupContext context) { Collection<ResolveStrategy> strategies = new ArrayList<>(); if (context.message() instanceof Timeout) { strategies.add(new TimeoutResolveStrategy(typesForMessageMapper, instanceFactory, stateStorage)); } else { strategies.addAll(checkAnnotatedMethodTypes(context)); } return strategies; } @Inject  DefaultStrategyFinder(
            final TypesForMessageMapper typesForMessageMapper,
            final SagaInstanceFactory instanceFactory,
            final KeyExtractor keyExtractor,
            final StateStorage stateStorage); @Override Collection<ResolveStrategy> find(final LookupContext context);  }
@Test public void find_timeout_returnsTimeoutStrategy() { Timeout timeout = Timeout.create(null, null, null, null); LookupContext context = mockMessageContext(timeout); Collection<ResolveStrategy> strategies = sut.find(context); assertThat("Expected a timeout strategy.", strategies, hasItem(isA(TimeoutResolveStrategy.class))); }
@Test public void find_newInstanceMessage_returnsStartNewSagaStrategy() { Object message = mockNewSagaMessage(); LookupContext context = mockMessageContext(message); Collection<ResolveStrategy> strategies = sut.find(context); assertThat("Expected a new saga strategy.", strategies, hasItem(isA(StartNewSagaStrategy.class))); }
@Test public void find_continueSagaMessage_returnsContinueSagaStrategy() { Object message = mockContinueMessage(); LookupContext context = mockMessageContext(message); Collection<ResolveStrategy> strategies = sut.find(context); assertThat("Expected a continue all saga strategy.", strategies, hasItem(isA(ContinueAllStrategy.class))); }