@Test
  public void testLockHeartbeatFailureDuringCommit() throws TException, InterruptedException {
    doReturn(acquiredLockResponse).when(spyClient).lock(any());
    doAnswer(AdditionalAnswers.answersWithDelay(2000, InvocationOnMock::callRealMethod))
        .when(spyOps)
        .loadHmsTable();
    doThrow(new TException("Failed to heart beat."))
        .when(spyClient)
        .heartbeat(eq(0L), eq(dummyLockId));

    assertThatThrownBy(() -> spyOps.doCommit(metadataV2, metadataV1))
        .isInstanceOf(CommitFailedException.class)
        .hasMessage(
            "org.apache.iceberg.hive.LockException: " +
                "Failed to heartbeat for hive lock. Failed to heart beat.");
  }
Wraps an ArgumentCaptor to provide data based on the request
iceberg/iceberg-catalog/src/test/java/org/apache/iceberg/hive/TestHiveCommitLocks.java