ReflectionInvoker implements HandlerInvoker { @Override public void invoke(final Saga saga, final Object message) { } @Inject  ReflectionInvoker(final SagaAnalyzer analyzer); @Override void invoke(final Saga saga, final Object message); @Override void invoke(final InvocationContext invocationContext);  }
@Test void invoke_startupMessage_invokesSagaStartupMessage() throws InvocationTargetException, IllegalAccessException { String startMessage = "any string"; TestSaga saga = new TestSaga(); saga.createNewState(); sut.invoke(createContext(saga, startMessage)); assertThat("Expected saga start method to be called.", saga.startupCalled(), equalTo(true)); }
@Test void invoke_handlerMessage_invokesHandlerMessage() throws InvocationTargetException, IllegalAccessException { FinishMessage handlerMessage = new FinishMessage(); TestSaga saga = new TestSaga(); saga.createNewState(); sut.invoke(createContext(saga, handlerMessage, InvocationHandlerType.CONTINUE)); assertThat("Expected saga handler method to be called.", saga.handlerCalled(), equalTo(true)); }
@Test void invoke_anyMessage_handleMethodNotFound_doesNotThrow() { TestSaga saga = new TestSaga(); saga.createNewState(); catchException(() -> sut.invoke(createContext(saga, 42))); assertThat("Expected no exception to be thrown.", caughtException(), is(nullValue())); }
@Test void invoke_startingContext_callsStartHandler() throws InvocationTargetException, IllegalAccessException { sut = sutWithSameMessageHandler(); SameMessageHandlers saga = new SameMessageHandlers(); saga.createNewState(); sut.invoke(createContext(saga, "message", InvocationHandlerType.START)); assertThat("Expected the start handler to be executed.", saga.isStartHandlerCalled(), is(true)); }
@Test void invoke_continueContext_callsContinueHandler() throws InvocationTargetException, IllegalAccessException { sut = sutWithSameMessageHandler(); SameMessageHandlers saga = new SameMessageHandlers(); saga.createNewState(); sut.invoke(createContext(saga, "message", InvocationHandlerType.CONTINUE)); assertThat("Expected the continue handler to be executed.", saga.isContinueHandlerCalled(), is(true)); }