@Test
  public void testNoLockCallsWithNoLock() throws TException {
    Configuration confWithLock = new Configuration(overriddenHiveConf);
    confWithLock.setBoolean(ConfigProperties.LOCK_HIVE_ENABLED, false);

    HiveTableOperations noLockSpyOps =
        spy(
            new HiveTableOperations(
                confWithLock,
                spyCachedClientPool,
                ops.io(),
                catalog.name(),
                TABLE_IDENTIFIER.namespace().level(0),
                TABLE_IDENTIFIER.name()));

    ArgumentCaptor<EnvironmentContext> contextCaptor =
        ArgumentCaptor.forClass(EnvironmentContext.class);

    doNothing()
        .when(spyClient)
        .alter_table_with_environmentContext(any(), any(), any(), contextCaptor.capture());

    noLockSpyOps.doCommit(metadataV2, metadataV1);

    // Make sure that the locking is not used
    verify(spyClient, never()).lock(any(LockRequest.class));
    verify(spyClient, never()).checkLock(any(Long.class));
    verify(spyClient, never()).heartbeat(any(Long.class), any(Long.class));
    verify(spyClient, never()).unlock(any(Long.class));

    // Make sure that the expected parameter context values are set
    Map<String, String> context = contextCaptor.getValue().getProperties();
    assertThat(context).hasSize(3);
    assertThat(HiveTableOperations.METADATA_LOCATION_PROP).isEqualTo(context.get("expected_parameter_key"));
    assertThat(metadataV2.metadataFileLocation()).isEqualTo(context.get("expected_parameter_value"));
  }
Wraps an ArgumentCaptor to provide data based on the request
iceberg/iceberg-catalog/src/test/java/org/apache/iceberg/hive/TestHiveCommitLocks.java