private void handleReply(boolean compensating) { SagaInstance expectedSagaInstanceAfterSecondStep = makeExpectedSagaInstanceAfterSecondStep(); when(sagaInstanceRepository.find(sagaType, sagaId)) .thenReturn(sagaInstance); when(sagaDefinition.handleReply(anyString(), any(TestSagaData.class), any(Message.class))) .thenReturn(makeSecondSagaActions(compensating)); when(sagaCommandProducer.sendCommands(anyString(), anyString(), anyList(), anyString())).thenReturn (requestId2.asString()); sagaMessageHandler.accept(replyFromParticipant1); verify(sagaInstanceRepository).find(sagaType, sagaId); verify(sagaCommandProducer).sendCommands(sagaType, sagaId, Collections.singletonList(commandForParticipant2), sagaReplyChannel); verify(sagaInstanceRepository).update(argThat(sagaInstance -> sagaInstanceEquals(expectedSagaInstanceAfterSecondStep, sagaInstance))); assertSagaInstanceEquals(expectedSagaInstanceAfterSecondStep, sagaInstance); verifyNoMoreInteractions(sagaInstanceRepository, sagaCommandProducer); }