From ac920a1f05066acb097c3dbb47a6ef4e6b7eb726 Mon Sep 17 00:00:00 2001 From: Raigor Date: Fri, 27 Oct 2023 02:42:25 -0500 Subject: [PATCH] Optimize the import of `org.junit.jupiter.api.Assertions` (#28878) * Optimize the import of org.junit.jupiter.api.Assertions * Fix spotless --- .../ConvertYamlConfigurationExecutorTest.java | 11 ++++------- .../executor/MySQLSetVariableAdminExecutorTest.java | 6 +++--- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationExecutorTest.java b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationExecutorTest.java index 0831b2259dde2..a9d11d82cce43 100644 --- a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationExecutorTest.java +++ b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/queryable/ConvertYamlConfigurationExecutorTest.java @@ -25,7 +25,6 @@ import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader; import org.apache.shardingsphere.parser.rule.SQLParserRule; import org.apache.shardingsphere.parser.rule.builder.DefaultSQLParserRuleConfigurationBuilder; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import java.io.BufferedReader; @@ -37,6 +36,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertNotNull; class ConvertYamlConfigurationExecutorTest { @@ -95,12 +95,9 @@ private void assertRowData(final Collection data, final assertParseSQL((String) actual.getCell(1)); } - private void assertParseSQL(final String actual) { - Splitter.on(";").trimResults().omitEmptyStrings().splitToList(actual).forEach(this::assertNotNull); - } - - private void assertNotNull(final String sql) { - Assertions.assertNotNull(sqlParserRule.getSQLParserEngine(TypedSPILoader.getService(DatabaseType.class, "MySQL")).parse(sql, false)); + private void assertParseSQL(final String distSQLs) { + Splitter.on(";").trimResults().omitEmptyStrings().splitToList(distSQLs) + .forEach(each -> assertNotNull(sqlParserRule.getSQLParserEngine(TypedSPILoader.getService(DatabaseType.class, "MySQL")).parse(each, false))); } @SneakyThrows(IOException.class) diff --git a/proxy/backend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLSetVariableAdminExecutorTest.java b/proxy/backend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLSetVariableAdminExecutorTest.java index 3e8ed5709d6b3..e587c7801a4ce 100644 --- a/proxy/backend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLSetVariableAdminExecutorTest.java +++ b/proxy/backend/type/mysql/src/test/java/org/apache/shardingsphere/proxy/backend/mysql/handler/admin/executor/MySQLSetVariableAdminExecutorTest.java @@ -37,7 +37,6 @@ import org.apache.shardingsphere.sql.parser.sql.dialect.statement.mysql.dal.MySQLSetStatement; import org.apache.shardingsphere.test.mock.AutoMockExtension; import org.apache.shardingsphere.test.mock.StaticMockSettings; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.MockedConstruction; @@ -48,6 +47,7 @@ import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.RETURNS_DEEP_STUBS; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mockConstruction; @@ -109,7 +109,7 @@ void assertSetUnknownSystemVariable() { SetStatement setStatement = new MySQLSetStatement(); setStatement.getVariableAssigns().add(unknownVariableAssignSegment); MySQLSetVariableAdminExecutor executor = new MySQLSetVariableAdminExecutor(setStatement); - Assertions.assertThrows(UnknownSystemVariableException.class, () -> executor.execute(mock(ConnectionSession.class))); + assertThrows(UnknownSystemVariableException.class, () -> executor.execute(mock(ConnectionSession.class))); } @Test @@ -120,6 +120,6 @@ void assertSetVariableWithIncorrectScope() { SetStatement setStatement = new MySQLSetStatement(); setStatement.getVariableAssigns().add(variableAssignSegment); MySQLSetVariableAdminExecutor executor = new MySQLSetVariableAdminExecutor(setStatement); - Assertions.assertThrows(ErrorGlobalVariableException.class, () -> executor.execute(mock(ConnectionSession.class))); + assertThrows(ErrorGlobalVariableException.class, () -> executor.execute(mock(ConnectionSession.class))); } }