Program: 170688
Project: 170688
Buggy source:
@Test(timeout=5000) public void compensatesFailedGlobalTransaction() throws Exception {
  ResponseEntity<String> entity=restTemplate.getForEntity("String_Node_Str",String.class,TRESPASSER);
  assertThat(entity.getStatusCode(),is(INTERNAL_SERVER_ERROR));
  await().atMost(2,SECONDS).until(() -> eventRepo.count() == 7);
  List<String> distinctGlobalTxIds=eventRepo.findDistinctGlobalTxId();
  assertThat(distinctGlobalTxIds.size(),is(1));
  String globalTxId=distinctGlobalTxIds.get(0);
  List<TxEvent> events=eventRepo.findByGlobalTxIdOrderByCreationTime(globalTxId);
  assertThat(events.size(),is(7));
  TxEvent sagaStartedEvent=events.get(0);
  assertThat(sagaStartedEvent.type(),is("String_Node_Str"));
  TxEvent txStartedEvent1=events.get(1);
  assertThat(txStartedEvent1.type(),is("String_Node_Str"));
  assertThat(events.get(2).type(),is("String_Node_Str"));
  TxEvent txStartedEvent2=events.get(3);
  assertThat(txStartedEvent2.type(),is("String_Node_Str"));
  TxEvent txAbortedEvent=events.get(4);
  assertThat(txAbortedEvent.type(),is("String_Node_Str"));
  assertThat(txAbortedEvent.localTxId(),is(txStartedEvent2.localTxId()));
  assertThat(txAbortedEvent.parentTxId(),is(globalTxId));
  assertThat(txAbortedEvent.serviceName(),is(serviceName));
  assertThat(txAbortedEvent.instanceId(),is(txStartedEvent2.instanceId()));
  assertThat(events.get(5).type(),is("String_Node_Str"));
  txAbortedEvent=events.get(5);
  System.out.println(txAbortedEvent);
  assertThat(txAbortedEvent.localTxId(),is(globalTxId));
  assertThat(txAbortedEvent.globalTxId(),is(globalTxId));
  assertThat(txAbortedEvent.parentTxId(),is(nullValue()));
  TxEvent txCompensatedEvent1=events.get(6);
  assertThat(txCompensatedEvent1.type(),is("String_Node_Str"));
  assertThat(txCompensatedEvent1.localTxId(),is(txStartedEvent1.localTxId()));
  assertThat(txCompensatedEvent1.parentTxId(),is(globalTxId));
  assertThat(txCompensatedEvent1.serviceName(),is(serviceName));
  assertThat(txCompensatedEvent1.instanceId(),is(txStartedEvent1.instanceId()));
  assertThat(compensatedMessages,contains("String_Node_Str" + TRESPASSER));
}

Fixed version (ground truth):
@Test(timeout=5000) public void compensatesFailedGlobalTransaction() throws Exception {
  ResponseEntity<String> entity=restTemplate.getForEntity("String_Node_Str",String.class,TRESPASSER);
  assertThat(entity.getStatusCode(),is(INTERNAL_SERVER_ERROR));
  await().atMost(2,SECONDS).until(() -> eventRepo.count() == 7);
  List<String> distinctGlobalTxIds=eventRepo.findDistinctGlobalTxId();
  assertThat(distinctGlobalTxIds.size(),is(1));
  String globalTxId=distinctGlobalTxIds.get(0);
  List<TxEvent> events=eventRepo.findByGlobalTxIdOrderByCreationTime(globalTxId);
  assertThat(events.size(),is(7));
  TxEvent sagaStartedEvent=events.get(0);
  assertThat(sagaStartedEvent.type(),is("String_Node_Str"));
  TxEvent txStartedEvent1=events.get(1);
  assertThat(txStartedEvent1.type(),is("String_Node_Str"));
  assertThat(events.get(2).type(),is("String_Node_Str"));
  TxEvent txStartedEvent2=events.get(3);
  assertThat(txStartedEvent2.type(),is("String_Node_Str"));
  TxEvent txAbortedEvent=events.get(4);
  assertThat(txAbortedEvent.type(),is("String_Node_Str"));
  assertThat(txAbortedEvent.localTxId(),is(txStartedEvent2.localTxId()));
  assertThat(txAbortedEvent.parentTxId(),is(globalTxId));
  assertThat(txAbortedEvent.serviceName(),is(serviceName));
  assertThat(txAbortedEvent.instanceId(),is(txStartedEvent2.instanceId()));
  TxEvent event=events.get(5);
  checkedLastTwoEvents(globalTxId,txStartedEvent1,event);
  event=events.get(6);
  checkedLastTwoEvents(globalTxId,txStartedEvent1,event);
  assertThat(compensatedMessages,contains("String_Node_Str" + TRESPASSER));
}