lasdf1234 commented on code in PR #11140:
URL: https://github.com/apache/gravitino/pull/11140#discussion_r3271107802


##########
plugins/idp-basic/src/test/java/org/apache/gravitino/idp/storage/mapper/provider/base/TestIdpUserGroupRelBaseSQLProvider.java:
##########
@@ -0,0 +1,153 @@
+/*
+ * 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.gravitino.idp.storage.mapper.provider.base;
+
+import java.util.Arrays;
+import java.util.List;
+import org.apache.gravitino.idp.storage.po.IdpUserGroupRelPO;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class TestIdpUserGroupRelBaseSQLProvider {
+
+  @Test
+  void testSelectGroupNamesByUsername() {
+    String normalizedSql =
+        
createProvider().selectGroupNamesByUsername("alice").replaceAll("\\s+", " 
").trim();
+
+    Assertions.assertEquals(
+        "SELECT g.group_name FROM idp_user_meta u JOIN idp_user_group_rel r ON 
r.user_id ="
+            + " u.user_id AND r.deleted_at = 0 JOIN idp_group_meta g ON 
g.group_id = r.group_id"
+            + " AND g.deleted_at = 0 WHERE u.user_name = #{username} AND 
u.deleted_at = 0 ORDER BY"
+            + " g.group_name",
+        normalizedSql);
+  }
+
+  @Test
+  void testSelectUsernamesByGroupName() {
+    String normalizedSql =
+        createProvider().selectUsernamesByGroupName("dev").replaceAll("\\s+", 
" ").trim();
+
+    Assertions.assertEquals(
+        "SELECT u.user_name FROM idp_group_meta g JOIN idp_user_group_rel r ON 
r.group_id ="
+            + " g.group_id AND r.deleted_at = 0 JOIN idp_user_meta u ON 
u.user_id = r.user_id AND"
+            + " u.deleted_at = 0 WHERE g.group_name = #{groupName} AND 
g.deleted_at = 0 ORDER BY"
+            + " u.user_name",
+        normalizedSql);
+  }
+
+  @Test
+  void testBatchInsertIdpUserGroups() {
+    List<IdpUserGroupRelPO> relations =
+        Arrays.asList(newRelation(1L, 20L, 10L), newRelation(2L, 21L, 10L));
+
+    String normalizedSql =
+        createProvider().batchInsertRelations(relations).replaceAll("\\s+", " 
").trim();
+
+    Assertions.assertEquals(

Review Comment:
   Yes, this doesn't make much sense. I have revised the code and have 
submitted it.



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