This is an automated email from the ASF dual-hosted git repository.
yuqi1129 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/main by this push:
new 2c18230c18 [#10270] test(core): Guard @Param("roleId") binding on
RoleMetaMapper.softDeleteRoleMetaByRoleId (#13666)
2c18230c18 is described below
commit 2c18230c185f937b0a3710e26c413ea27d03ee45
Author: dennismdejong <[email protected]>
AuthorDate: Thu Oct 8 14:26:57 2026 +0200
[#10270] test(core): Guard @Param("roleId") binding on
RoleMetaMapper.softDeleteRoleMetaByRoleId (#13666)
### What changes were proposed in this pull request?
Adds a reflection-based regression test
(`TestRoleMetaMapper#testSoftDeleteRoleMetaByRoleIdHasNamedParam`)
asserting that `RoleMetaMapper.softDeleteRoleMetaByRoleId` carries
`@Param("roleId")` on its first argument. The `@Param` fix itself is
already present in the current codebase.
### Why are the changes needed?
Issue #10270 reports that a missing `@Param("roleId")` on
`RoleMetaMapper.softDeleteRoleMetaByRoleId` could cause MyBatis
named-parameter binding failures at runtime during role deletion via the
REST delete-role path. The annotation is already in place on `main` (the
method now also takes `@Param("currentVersion")` for OCC), but nothing
guarded it from regressing. This test locks in the named binding.
Fix: #10270
### Does this PR introduce any user-facing change?
No.
### How was this patch tested?
- `./gradlew :core:spotlessApply`
- `./gradlew :core:test --tests
org.apache.gravitino.storage.relational.mapper.TestRoleMetaMapper
-PskipITs -PskipDockerTests=true` (1 test, 0 failures)
---
.../relational/mapper/TestRoleMetaMapper.java | 50 ++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git
a/core/src/test/java/org/apache/gravitino/storage/relational/mapper/TestRoleMetaMapper.java
b/core/src/test/java/org/apache/gravitino/storage/relational/mapper/TestRoleMetaMapper.java
new file mode 100644
index 0000000000..e6239f9e1e
--- /dev/null
+++
b/core/src/test/java/org/apache/gravitino/storage/relational/mapper/TestRoleMetaMapper.java
@@ -0,0 +1,50 @@
+/*
+ * 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.storage.relational.mapper;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import org.apache.ibatis.annotations.Param;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+class TestRoleMetaMapper {
+
+ @Test
+ void testSoftDeleteRoleMetaByRoleIdHasNamedParam() throws
NoSuchMethodException {
+ Method method =
+ RoleMetaMapper.class.getMethod("softDeleteRoleMetaByRoleId",
Long.class, Long.class);
+ Annotation[][] parameterAnnotations = method.getParameterAnnotations();
+
+ Assertions.assertEquals(2, parameterAnnotations.length);
+
+ Param roleIdParam = null;
+ for (Annotation annotation : parameterAnnotations[0]) {
+ if (annotation instanceof Param) {
+ roleIdParam = (Param) annotation;
+ break;
+ }
+ }
+
+ Assertions.assertNotNull(
+ roleIdParam,
+ "Missing @Param on softDeleteRoleMetaByRoleId may break MyBatis named
binding.");
+ Assertions.assertEquals("roleId", roleIdParam.value());
+ }
+}