Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize the import of org.junit.jupiter.api.Assertions #28878

Merged
merged 2 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)));
}
}