### Question:
SagaStartTask implements SagaTask { @Segment(name = "startTaskCommit", category = "application", library = "kamon") @Override public SagaResponse commit(SagaRequest request, SagaResponse parentResponse) { try { sagaLog.offer(new SagaStartedEvent(sagaId, requestJson, request)); } catch (Exception e) { throw new SagaStartFailedException("Failed to persist SagaStartedEvent for " + requestJson, e); } return SagaResponse.EMPTY_RESPONSE; } SagaStartTask(String sagaId, String requestJson, SagaLog sagaLog); @Segment(name = "startTaskCommit", category = "application", library = "kamon") @Override SagaResponse commit(SagaRequest request, SagaResponse parentResponse); @Override void compensate(SagaRequest request); @Override void abort(SagaRequest request, Exception e);  }### Answer:
@Test public void emptyResponseOnSuccessfulEventPersistence() throws Exception { ArgumentCaptor<SagaStartedEvent> argumentCaptor = ArgumentCaptor.forClass(SagaStartedEvent.class); doNothing().when(sagaLog).offer(argumentCaptor.capture()); sagaStartTask.commit(request, SagaResponse.EMPTY_RESPONSE); SagaStartedEvent event = argumentCaptor.getValue(); assertThat(event.sagaId, is(sagaId)); assertThat(event.json(null), is(requestJson)); assertThat(event.payload(), is(request)); }
@Test public void blowsUpWhenEventIsNotPersisted() { doThrow(RuntimeException.class).when(sagaLog).offer(any(SagaStartedEvent.class)); try { sagaStartTask.commit(request, SagaResponse.EMPTY_RESPONSE); expectFailing(SagaStartFailedException.class); } catch (SagaStartFailedException e) { assertThat(e.getMessage(), startsWith("Failed to persist SagaStartedEvent")); } }