NihalJain commented on code in PR #17295:
URL: https://github.com/apache/pinot/pull/17295#discussion_r2584871527


##########
pinot-spi/src/test/java/org/apache/pinot/spi/utils/builder/UserConfigBuilderTest.java:
##########
@@ -0,0 +1,261 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.pinot.spi.utils.builder;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.pinot.spi.config.user.AccessType;
+import org.apache.pinot.spi.config.user.ComponentType;
+import org.apache.pinot.spi.config.user.RoleType;
+import org.apache.pinot.spi.config.user.UserConfig;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+
+/**
+ * Tests for {@link UserConfigBuilder}
+ */
+public class UserConfigBuilderTest {
+
+  private static final String TEST_USERNAME = "testUser";
+  private static final String TEST_PASSWORD = "testPassword";
+
+  @Test
+  public void testBasicUserConfigBuild() {
+    UserConfig userConfig = new UserConfigBuilder()
+        .setUsername(TEST_USERNAME)
+        .setPassword(TEST_PASSWORD)
+        .setComponentType(ComponentType.BROKER)
+        .setRoleType(RoleType.USER)
+        .build();
+
+    Assert.assertNotNull(userConfig, "UserConfig should not be null");
+    Assert.assertEquals(userConfig.getUserName(), TEST_USERNAME, "Username 
should match");
+    Assert.assertEquals(userConfig.getPassword(), TEST_PASSWORD, "Password 
should match");
+    Assert.assertEquals(userConfig.getComponentType(), ComponentType.BROKER, 
"Component type should match");
+    Assert.assertEquals(userConfig.getRoleType(), RoleType.USER, "Role type 
should match");
+    Assert.assertNull(userConfig.getTables(), "Tables should be null when not 
set");
+    Assert.assertNull(userConfig.getExcludeTables(), "Exclude tables should be 
null when not set");
+    Assert.assertNull(userConfig.getPermissios(), "Permissions should be null 
when not set");

Review Comment:
   typo in existing method name, raised 
https://github.com/apache/pinot/issues/17307 for fix



##########
pinot-spi/src/test/java/org/apache/pinot/spi/utils/builder/UserConfigBuilderTest.java:
##########
@@ -0,0 +1,261 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.pinot.spi.utils.builder;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.pinot.spi.config.user.AccessType;
+import org.apache.pinot.spi.config.user.ComponentType;
+import org.apache.pinot.spi.config.user.RoleType;
+import org.apache.pinot.spi.config.user.UserConfig;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+
+/**
+ * Tests for {@link UserConfigBuilder}
+ */
+public class UserConfigBuilderTest {
+
+  private static final String TEST_USERNAME = "testUser";
+  private static final String TEST_PASSWORD = "testPassword";
+
+  @Test
+  public void testBasicUserConfigBuild() {
+    UserConfig userConfig = new UserConfigBuilder()
+        .setUsername(TEST_USERNAME)
+        .setPassword(TEST_PASSWORD)
+        .setComponentType(ComponentType.BROKER)
+        .setRoleType(RoleType.USER)
+        .build();
+
+    Assert.assertNotNull(userConfig, "UserConfig should not be null");
+    Assert.assertEquals(userConfig.getUserName(), TEST_USERNAME, "Username 
should match");
+    Assert.assertEquals(userConfig.getPassword(), TEST_PASSWORD, "Password 
should match");
+    Assert.assertEquals(userConfig.getComponentType(), ComponentType.BROKER, 
"Component type should match");
+    Assert.assertEquals(userConfig.getRoleType(), RoleType.USER, "Role type 
should match");
+    Assert.assertNull(userConfig.getTables(), "Tables should be null when not 
set");
+    Assert.assertNull(userConfig.getExcludeTables(), "Exclude tables should be 
null when not set");
+    Assert.assertNull(userConfig.getPermissios(), "Permissions should be null 
when not set");
+    Assert.assertNull(userConfig.getRlsFilters(), "RLS filters should be null 
when not set");
+  }
+
+  @Test
+  public void testUserConfigWithTableList() {
+    List<String> tableList = Arrays.asList("table1", "table2", "table3");
+
+    UserConfig userConfig = new UserConfigBuilder()
+        .setUsername(TEST_USERNAME)
+        .setPassword(TEST_PASSWORD)
+        .setComponentType(ComponentType.CONTROLLER)
+        .setRoleType(RoleType.ADMIN)
+        .setTableList(tableList)
+        .build();
+
+    Assert.assertNotNull(userConfig.getTables(), "Tables should not be null");
+    Assert.assertEquals(userConfig.getTables(), tableList, "Table list should 
match");
+    Assert.assertEquals(userConfig.getTables().size(), 3, "Table list size 
should be 3");
+  }
+
+  @Test
+  public void testUserConfigWithExcludeTableList() {
+    List<String> excludeTableList = Arrays.asList("excludeTable1", 
"excludeTable2");
+
+    UserConfig userConfig = new UserConfigBuilder()
+        .setUsername(TEST_USERNAME)
+        .setPassword(TEST_PASSWORD)
+        .setComponentType(ComponentType.SERVER)
+        .setRoleType(RoleType.USER)
+        .setExcludeTableList(excludeTableList)
+        .build();
+
+    Assert.assertNotNull(userConfig.getExcludeTables(), "Exclude tables should 
not be null");
+    Assert.assertEquals(userConfig.getExcludeTables(), excludeTableList, 
"Exclude table list should match");
+    Assert.assertEquals(userConfig.getExcludeTables().size(), 2, "Exclude 
table list size should be 2");
+  }
+
+  @Test
+  public void testUserConfigWithPermissionList() {
+    List<AccessType> permissionList = Arrays.asList(AccessType.READ, 
AccessType.CREATE, AccessType.UPDATE);
+
+    UserConfig userConfig = new UserConfigBuilder()
+        .setUsername(TEST_USERNAME)
+        .setPassword(TEST_PASSWORD)
+        .setComponentType(ComponentType.MINION)
+        .setRoleType(RoleType.ADMIN)
+        .setPermissionList(permissionList)
+        .build();
+
+    Assert.assertNotNull(userConfig.getPermissios(), "Permissions should not 
be null");
+    Assert.assertEquals(userConfig.getPermissios(), permissionList, 
"Permission list should match");
+    Assert.assertEquals(userConfig.getPermissios().size(), 3, "Permission list 
size should be 3");
+    Assert.assertTrue(userConfig.getPermissios().contains(AccessType.READ), 
"Should contain READ permission");
+    Assert.assertTrue(userConfig.getPermissios().contains(AccessType.CREATE), 
"Should contain CREATE permission");
+    Assert.assertTrue(userConfig.getPermissios().contains(AccessType.UPDATE), 
"Should contain UPDATE permission");

Review Comment:
   typo in existing method name, raised 
https://github.com/apache/pinot/issues/17307 for fix



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