You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/09/04 14:23:40 UTC
[shardingsphere] branch master updated: Refactor PostgreSQLDialectExceptionMapperTest (#20775)
This is an automated email from the ASF dual-hosted git repository.
zhaojinchao 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 1d099c249e7 Refactor PostgreSQLDialectExceptionMapperTest (#20775)
1d099c249e7 is described below
commit 1d099c249e754e396efa70400b7a8888e660b592
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sun Sep 4 22:23:34 2022 +0800
Refactor PostgreSQLDialectExceptionMapperTest (#20775)
---
.../mapper/PostgreSQLDialectExceptionMapperTest.java | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/shardingsphere-dialect-exception/shardingsphere-postgresql-dialect-exception/src/test/java/org/apache/shardingsphere/dialect/postgresql/mapper/PostgreSQLDialectExceptionMapperTest.java b/shardingsphere-dialect-exception/shardingsphere-postgresql-dialect-exception/src/test/java/org/apache/shardingsphere/dialect/postgresql/mapper/PostgreSQLDialectExceptionMapperTest.java
index d0e3cc33b42..785d13832f6 100644
--- a/shardingsphere-dialect-exception/shardingsphere-postgresql-dialect-exception/src/test/java/org/apache/shardingsphere/dialect/postgresql/mapper/PostgreSQLDialectExceptionMapperTest.java
+++ b/shardingsphere-dialect-exception/shardingsphere-postgresql-dialect-exception/src/test/java/org/apache/shardingsphere/dialect/postgresql/mapper/PostgreSQLDialectExceptionMapperTest.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.dialect.postgresql.mapper;
+import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.dialect.exception.SQLDialectException;
import org.apache.shardingsphere.dialect.exception.connection.TooManyConnectionsException;
import org.apache.shardingsphere.dialect.exception.data.InsertColumnsAndValuesMismatchedException;
@@ -26,6 +27,7 @@ import org.apache.shardingsphere.dialect.exception.transaction.InTransactionExce
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
import org.postgresql.util.PSQLState;
import java.util.Arrays;
@@ -36,18 +38,14 @@ import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
@RunWith(Parameterized.class)
+@RequiredArgsConstructor
public final class PostgreSQLDialectExceptionMapperTest {
private final Class<SQLDialectException> sqlDialectExceptionClazz;
-
+
private final String psqlState;
-
- public PostgreSQLDialectExceptionMapperTest(final Class<SQLDialectException> sqlDialectExceptionClazz, final String psqlState) {
- this.sqlDialectExceptionClazz = sqlDialectExceptionClazz;
- this.psqlState = psqlState;
- }
-
- @Parameterized.Parameters
+
+ @Parameters(name = "{1} -> {0}")
public static Collection<Object[]> getConvertParameters() {
return Arrays.asList(new Object[][]{
{DatabaseCreateExistsException.class, "42P04"},
@@ -59,9 +57,7 @@ public final class PostgreSQLDialectExceptionMapperTest {
}
@Test
- @SuppressWarnings("unchecked")
public void convert() {
- PostgreSQLDialectExceptionMapper dialectExceptionMapper = new PostgreSQLDialectExceptionMapper();
- assertThat(dialectExceptionMapper.convert(mock(sqlDialectExceptionClazz)).getSQLState(), is(psqlState));
+ assertThat(new PostgreSQLDialectExceptionMapper().convert(mock(sqlDialectExceptionClazz)).getSQLState(), is(psqlState));
}
}