cecemei commented on code in PR #17774:
URL: https://github.com/apache/druid/pull/17774#discussion_r2032233902


##########
processing/src/test/java/org/apache/druid/query/DataSourceTest.java:
##########
@@ -221,4 +225,53 @@ public void 
testMapWithRestriction_onRestrictedDataSource_alwaysThrows()
     ISE e3 = Assert.assertThrows(ISE.class, () -> 
restrictedDataSource.withPolicies(policyWasNotChecked));
     Assert.assertEquals("Missing policy check result for table [table1]", 
e3.getMessage());
   }
+
+  @Test
+  public void testValidate_onInlineDataSource()
+  {
+    InlineDataSource inlineDataSource = 
InlineDataSource.fromIterable(ImmutableList.of(), RowSignature.empty());
+    
Assert.assertTrue(inlineDataSource.validate(NoopPolicyEnforcer.instance()));
+    Assert.assertTrue(inlineDataSource.validate(new 
RestrictAllTablesPolicyEnforcer(null)));
+  }
+
+  @Test
+  public void testValidate_onRestrictedDataSource()
+  {
+    RestrictedDataSource restrictedDataSource = RestrictedDataSource.create(
+        TableDataSource.create("table1"),
+        RowFilterPolicy.from(new NullFilter("random-column", null))
+    );
+    
Assert.assertTrue(restrictedDataSource.validate(NoopPolicyEnforcer.instance()));
+    Assert.assertTrue(restrictedDataSource.validate(new 
RestrictAllTablesPolicyEnforcer(null)));
+    // Fail, only NoRestrictionPolicy is allowed.
+    Assert.assertFalse(restrictedDataSource.validate(new 
RestrictAllTablesPolicyEnforcer(ImmutableList.of(
+        "NoRestrictionPolicy"))));
+  }
+
+  @Test
+  public void testValidate_onTableDataSource()
+  {
+    TableDataSource tableDataSource = TableDataSource.create("table1");
+    Assert.assertTrue(tableDataSource.validate(NoopPolicyEnforcer.instance()));
+    // Fail, policy must exist on table
+    Assert.assertFalse(tableDataSource.validate(new 
RestrictAllTablesPolicyEnforcer(null)));
+  }
+
+  @Test
+  public void testValidate_onUnionDataSource()

Review Comment:
   Added tests for union with restricted and join.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to