This is an automated email from the ASF dual-hosted git repository.
terrymanu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 68b7bab93f9 Refactor ProxyStatementExecutorCallbackTest (#38994)
68b7bab93f9 is described below
commit 68b7bab93f92a5c942af31f272cbde62c45bfbc8
Author: Liang Zhang <[email protected]>
AuthorDate: Sat Jul 4 19:30:35 2026 +0800
Refactor ProxyStatementExecutorCallbackTest (#38994)
* Add guardrails against testing through layers
Define testing-through-layers in AGENTS.md and update the gen-ut skill
to classify SUT-owned versus collaborator-owned behavior before branch
mapping, mocking, parameterization, and test trimming.
* Refactor ProxyStatementExecutorCallbackTest
---
.../callback/impl/ProxyStatementExecutorCallbackTest.java | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/executor/callback/impl/ProxyStatementExecutorCallbackTest.java
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/executor/callback/impl/ProxyStatementExecutorCallbackTest.java
index d87e0a2106e..89085535612 100644
---
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/executor/callback/impl/ProxyStatementExecutorCallbackTest.java
+++
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/executor/callback/impl/ProxyStatementExecutorCallbackTest.java
@@ -17,6 +17,8 @@
package
org.apache.shardingsphere.proxy.backend.connector.jdbc.executor.callback.impl;
+import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
@@ -35,6 +37,8 @@ import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
class ProxyStatementExecutorCallbackTest {
+ private static final DatabaseType DATABASE_TYPE =
TypedSPILoader.getService(DatabaseType.class, "SQL92");
+
@Mock
private Statement statement;
@@ -42,7 +46,7 @@ class ProxyStatementExecutorCallbackTest {
void assertExecuteWithGeneratedKeys() throws SQLException {
String sql = "SELECT 1";
when(statement.execute(sql,
Statement.RETURN_GENERATED_KEYS)).thenReturn(true);
- ProxyStatementExecutorCallback callback = new
ProxyStatementExecutorCallback(mock(), mock(), mock(), mock(), true, true,
false);
+ ProxyStatementExecutorCallback callback = new
ProxyStatementExecutorCallback(DATABASE_TYPE, mock(), mock(), mock(), true,
true, false);
assertTrue(callback.execute(sql, statement, true));
verify(statement).execute(sql, Statement.RETURN_GENERATED_KEYS);
}
@@ -50,7 +54,7 @@ class ProxyStatementExecutorCallbackTest {
@Test
void assertExecuteWithoutGeneratedKeys() throws SQLException {
String sql = "SELECT 1";
- ProxyStatementExecutorCallback callback = new
ProxyStatementExecutorCallback(mock(), mock(), mock(), mock(), false, false,
false);
+ ProxyStatementExecutorCallback callback = new
ProxyStatementExecutorCallback(DATABASE_TYPE, mock(), mock(), mock(), false,
false, false);
assertFalse(callback.execute(sql, statement, false));
verify(statement).execute(sql, Statement.NO_GENERATED_KEYS);
}
@@ -60,7 +64,7 @@ class ProxyStatementExecutorCallbackTest {
String sql = "SELECT 1";
when(statement.execute(sql,
Statement.RETURN_GENERATED_KEYS)).thenThrow(new
SQLFeatureNotSupportedException());
when(statement.execute(sql)).thenReturn(true);
- ProxyStatementExecutorCallback callback = new
ProxyStatementExecutorCallback(mock(), mock(), mock(), mock(), true, false,
false);
+ ProxyStatementExecutorCallback callback = new
ProxyStatementExecutorCallback(DATABASE_TYPE, mock(), mock(), mock(), true,
false, false);
assertTrue(callback.execute(sql, statement, true));
verify(statement).execute(sql, Statement.RETURN_GENERATED_KEYS);
verify(statement).execute(sql);