jerryshao commented on code in PR #13478:
URL: https://github.com/apache/gravitino/pull/13478#discussion_r4247824286


##########
core/src/test/java/org/apache/gravitino/policy/TestPolicyManager.java:
##########
@@ -483,6 +483,73 @@ public void testCreateUpdateAndGetRowFilterPolicy() {
     Assertions.assertEquals(updatedContent, updated.content());
     Assertions.assertEquals(
         updatedContent, policyManager.getPolicy(METALAKE, 
policyName).content());
+
+    Assertions.assertThrows(
+        IllegalArgumentException.class,
+        () ->
+            policyManager.createPolicy(
+                METALAKE,
+                "invalid_" + policyName,
+                Policy.BuiltInType.ROW_FILTER,
+                null,
+                true,
+                PolicyContents.rowFilter("filter := col(\"region\")")));
+    Assertions.assertThrows(
+        IllegalArgumentException.class,
+        () ->
+            policyManager.alterPolicy(
+                METALAKE,
+                policyName,
+                PolicyChange.updateContent(
+                    "system_row_filter",
+                    PolicyContents.rowFilter("mask := 
action(\"replace-with-null\")"))));
+    Assertions.assertEquals(
+        updatedContent, policyManager.getPolicy(METALAKE, 
policyName).content());
+  }
+
+  @Test
+  public void testCreateUpdateAndGetColumnMaskPolicy() {
+    String policyName = "column_mask_" + 
UUID.randomUUID().toString().replace("-", "");
+    PolicyContent originalContent = PolicyContents.columnMask("mask := 
action(\"show-last-4\")");
+
+    PolicyEntity created =
+        policyManager.createPolicy(
+            METALAKE, policyName, Policy.BuiltInType.COLUMN_MASK, null, true, 
originalContent);
+
+    Assertions.assertEquals(originalContent, created.content());
+    Assertions.assertEquals(
+        originalContent, policyManager.getPolicy(METALAKE, 
policyName).content());
+
+    PolicyContent updatedContent =
+        PolicyContents.columnMask("mask := action(\"replace-with-null\")");
+    PolicyEntity updated =
+        policyManager.alterPolicy(
+            METALAKE, policyName, 
PolicyChange.updateContent("system_column_mask", updatedContent));
+
+    Assertions.assertEquals(updatedContent, updated.content());
+    Assertions.assertEquals(
+        updatedContent, policyManager.getPolicy(METALAKE, 
policyName).content());
+
+    Assertions.assertThrows(
+        IllegalArgumentException.class,
+        () ->
+            policyManager.createPolicy(
+                METALAKE,
+                "invalid_" + policyName,
+                Policy.BuiltInType.COLUMN_MASK,
+                null,
+                true,
+                PolicyContents.columnMask("mask := action(\"unknown\")")));
+    Assertions.assertThrows(
+        IllegalArgumentException.class,
+        () ->
+            policyManager.alterPolicy(
+                METALAKE,
+                policyName,
+                PolicyChange.updateContent(
+                    "system_column_mask", PolicyContents.columnMask("filter := 
true"))));
+    Assertions.assertEquals(
+        updatedContent, policyManager.getPolicy(METALAKE, 
policyName).content());
   }
 
   @Test

Review Comment:
   I think you'd better add test cases for each class you split. If you already 
have, you'd better split into different classes; if not, please add them.



-- 
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]

Reply via email to