### Question:
TxConsistentService { public boolean handle(TxEvent event) { return true; } TxConsistentService(TxEventRepository eventRepository, CommandRepository commandRepository, TxTimeoutRepository timeoutRepository); boolean handle(TxEvent event); int handleSupportTxPause(TxEvent event); Set<String> fetchLocalTxIdOfEndedGlobalTx(Set<String> localTxIdSet); boolean saveKafkaMessage(KafkaMessage message); boolean registerGlobalTx(TxEvent event); boolean registerSubTx(TxEvent subTxEvent, TxEventAddition subTxEventAddition); boolean checkIsExistsEventType(String globalTxId, String localTxId, String type);  }### Answer:
@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)); }
@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)); }