### Question:
TxConsistentService { public boolean handle(TxEvent event) { if (types.contains(event.type()) && isGlobalTxAborted(event)) { LOG.info("Transaction event {} rejected, because its parent with globalTxId {} was already aborted", event.type(), event.globalTxId()); return false; } eventRepository.save(event); return true; } TxConsistentService(TxEventRepository eventRepository); boolean handle(TxEvent event);  }### Answer:
@Test public void persistEventOnArrival() throws Exception { TxEvent[] events = { newEvent(SagaStartedEvent), newEvent(TxStartedEvent), newEvent(TxEndedEvent), newEvent(TxCompensatedEvent), newEvent(SagaEndedEvent)}; for (TxEvent event : events) { consistentService.handle(event); } assertThat(this.events, contains(events)); }
@Test public void skipTxStartedEvent_IfGlobalTxAlreadyFailed() { String localTxId1 = UUID.randomUUID().toString(); events.add(newEvent(TxStartedEvent)); events.add(newEvent(TxAbortedEvent)); TxEvent event = eventOf(TxStartedEvent, localTxId1); consistentService.handle(event); assertThat(events.size(), is(2)); }
@Test public void skipSagaEndedEvent_IfGlobalTxAlreadyFailed() { String localTxId1 = UUID.randomUUID().toString(); events.add(eventOf(SagaStartedEvent, localTxId1)); events.add(eventOf(TxAbortedEvent, localTxId1)); TxEvent event = eventOf(SagaEndedEvent, localTxId1); consistentService.handle(event); assertThat(events.size(), is(2)); }