Skip to content

Commit

Permalink
Optimize the import of org.junit.jupiter.api.Assertions (#28878)
Browse files Browse the repository at this point in the history
* Optimize the import of org.junit.jupiter.api.Assertions

* Fix spotless
  • Loading branch information
RaigorJiang authored Oct 27, 2023
1 parent 1f28db4 commit ac920a1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {

Expand Down Expand Up @@ -95,12 +95,9 @@ private void assertRowData(final Collection<LocalDataQueryResultRow> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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)));
}
}

0 comments on commit ac920a1

Please sign in to comment.