mchades commented on code in PR #12686:
URL: https://github.com/apache/gravitino/pull/12686#discussion_r3906373006
##########
core/src/test/java/org/apache/gravitino/policy/TestPolicyManager.java:
##########
@@ -354,6 +354,61 @@ public void testAlterPolicy() {
Assertions.assertTrue(enabledPolicy.enabled());
}
+ @Test
+ public void testAlterBuiltInPolicyContent() {
+ String policyName = "policy_" + UUID.randomUUID().toString().replace("-",
"");
+ policyManager.createPolicy(
+ METALAKE,
+ policyName,
+ Policy.BuiltInType.ICEBERG_COMPACTION,
+ null,
+ true,
+ PolicyContents.icebergDataCompaction());
+
+ // Adding a type not in the original set must be rejected.
+ Set<MetadataObject.Type> withExtra =
+ ImmutableSet.of(
+ MetadataObject.Type.CATALOG,
+ MetadataObject.Type.SCHEMA,
+ MetadataObject.Type.TABLE,
+ MetadataObject.Type.FILESET);
+ PolicyContent addedType = PolicyContents.custom(ImmutableMap.of(),
withExtra, null);
+ IllegalArgumentException addEx =
+ Assertions.assertThrows(
+ IllegalArgumentException.class,
+ () ->
+ policyManager.alterPolicy(
+ METALAKE,
+ policyName,
+ PolicyChange.updateContent("system_iceberg_compaction",
addedType)));
+ Assertions.assertTrue(
+ addEx.getMessage().contains("Policy content type mismatch"),
+ "expected mismatch message, got: " + addEx.getMessage());
+ // Format arguments must be substituted — neither placeholder should
survive literally.
+ Assertions.assertFalse(
Review Comment:
Please verify the actual diagnostic values here, not only that the format
placeholders disappeared. This assertion would still pass if the message
dropped both sets or formatted the wrong pair, so it does not cover the
requirement in #12685 to report the expected and received supported-object
sets. Assert that the original set and withExtra (and likewise withFewer below)
are present, or assert the complete messages.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]