Source:
public static void enableObjectLegalHold_test() throws Exception { if (!mintEnv) { System.out.println( "Test: enableObjectLegalHold(String bucketName, String objectName, String versionId)"); } long startTime = System.currentTimeMillis(); String bucketName = getRandomName(); String objectName = getRandomName(); try { client.makeBucket(bucketName, null, true); try (final InputStream is = new ContentInputStream(1 * KB)) { client.putObject(bucketName, objectName, is, new PutObjectOptions(1 * KB, -1)); } client.enableObjectLegalHold(bucketName, objectName, ""); if (!client.isObjectLegalHoldEnabled(bucketName, objectName, "")) { System.out.println( "FAILED. expected Object Legal Hold Enabled to be : " + "True" + ", got: False "); mintFailedLog( "enableObjectLegalHold", "(String bucketName, String objectName, String versionId)", startTime, "FAILED" + " >>> ", " expected Object Legal Hold Enabled to be : " + "True" + ", got: False"); } client.disableObjectLegalHold(bucketName, objectName, ""); mintSuccessLog( "enableObjectLegalHold(String bucketName, String objectName, String versionId)", null, startTime); } catch (Exception e) { ErrorResponse errorResponse = null; if (e instanceof ErrorResponseException) { ErrorResponseException exp = (ErrorResponseException) e; errorResponse = exp.errorResponse(); } if (errorResponse != null && errorResponse.errorCode() == ErrorCode.NOT_IMPLEMENTED) { mintIgnoredLog( "enableObjectLegalHold(String bucketName, String objectName, String versionId)", null, startTime); } else { mintFailedLog( "enableObjectLegalHold(String bucketName, String objectName, String versionId)", null, startTime, null, e.toString() + " >>> " + Arrays.toString(e.getStackTrace())); throw e; } } finally { client.removeObject(bucketName, objectName); client.removeBucket(bucketName); } }

Target:
public static void enableObjectLegalHold_test() throws Exception { if (!mintEnv) { System.out.println( "Test: enableObjectLegalHold(String bucketName, String objectName, String versionId)"); } long startTime = System.currentTimeMillis(); String bucketName = getRandomName(); String objectName = getRandomName(); try { client.makeBucket(bucketName, null, true); try { try (final InputStream is = new ContentInputStream(1 * KB)) { client.putObject(bucketName, objectName, is, new PutObjectOptions(1 * KB, -1)); } client.enableObjectLegalHold(bucketName, objectName, null); if (!client.isObjectLegalHoldEnabled(bucketName, objectName, null)) { throw new Exception("[FAILED] isObjectLegalHoldEnabled(): expected: true, got: false"); } client.disableObjectLegalHold(bucketName, objectName, null); mintSuccessLog( "enableObjectLegalHold(String bucketName, String objectName, String versionId)", null, startTime); } finally { client.removeObject(bucketName, objectName); client.removeBucket(bucketName); } } catch (Exception e) { ErrorResponse errorResponse = null; if (e instanceof ErrorResponseException) { ErrorResponseException exp = (ErrorResponseException) e; errorResponse = exp.errorResponse(); } if (errorResponse != null && errorResponse.errorCode() == ErrorCode.NOT_IMPLEMENTED) { mintIgnoredLog( "enableObjectLegalHold(String bucketName, String objectName, String versionId)", null, startTime); } else { mintFailedLog( "enableObjectLegalHold(String bucketName, String objectName, String versionId)", null, startTime, null, e.toString() + " >>> " + Arrays.toString(e.getStackTrace())); throw e; } } }