roryqi commented on code in PR #11140: URL: https://github.com/apache/gravitino/pull/11140#discussion_r3267779272
########## plugins/idp-basic/src/test/java/org/apache/gravitino/idp/storage/mapper/provider/base/TestIdpUserGroupRelBaseSQLProvider.java: ########## @@ -0,0 +1,165 @@ +/* + * 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 { + + protected IdpUserGroupRelBaseSQLProvider createProvider() { + return new IdpUserGroupRelBaseSQLProvider() { + @Override + protected String currentTimeMillisExpression() { + return "CURRENT_TIME_MILLIS()"; + } + }; + } + + protected String expectedDeleteAtClause() { + return "deleted_at = CURRENT_TIME_MILLIS()"; + } + + protected String expectedDeleteIdpUserGroupRelMetasByLegacyTimelineSql() { + return "DELETE FROM idp_user_group_rel WHERE deleted_at > 0 AND deleted_at < #{legacyTimeline}" + + " LIMIT #{limit}"; + } + + @Test + void testSelectGroupNamesByUsername() { + String normalizedSql = + createProvider().selectGroupNamesByUsername("alice").replaceAll("\\s+", " ").trim(); + + Assertions.assertTrue(normalizedSql.contains("SELECT g.group_name")); + Assertions.assertTrue(normalizedSql.contains("FROM idp_user_meta u JOIN idp_user_group_rel r")); + Assertions.assertTrue(normalizedSql.contains("JOIN idp_group_meta g")); + Assertions.assertTrue(normalizedSql.contains("r.user_id = u.user_id AND r.deleted_at = 0")); + Assertions.assertTrue(normalizedSql.contains("WHERE u.user_name = #{username}")); + Assertions.assertTrue(normalizedSql.contains("ORDER BY g.group_name")); Review Comment: This is weird. Why do use sql equity assertion here? Assertion.assertEquals(normalizedSql, "xxx"). -- 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]
