Skip to content

Commit

Permalink
for code style (#3689)
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu authored and tristaZero committed Dec 9, 2019
1 parent 8e985bd commit 3b3053c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
Expand Up @@ -54,7 +54,7 @@ public Collection<InsertColumnsToken> generateSQLTokens(final SQLStatementContex
Collection<InsertColumnsToken> result = new LinkedList<>();
Optional<EncryptTable> encryptTable = getEncryptRule().findEncryptTable(sqlStatementContext.getTablesContext().getSingleTableName());
Preconditions.checkState(encryptTable.isPresent());
Set<String> insertColumns = new HashSet(((InsertStatement) sqlStatementContext.getSqlStatement()).getColumnNames());
Set<String> insertColumns = new HashSet<>(((InsertStatement) sqlStatementContext.getSqlStatement()).getColumnNames());
for (ColumnSegment each : ((InsertStatement) sqlStatementContext.getSqlStatement()).getColumns()) {
List<String> columns = getColumns(encryptTable.get(), each, insertColumns);
if (!columns.isEmpty()) {
Expand Down
Expand Up @@ -120,7 +120,7 @@ private int getStopIndex(final Collection<InsertValuesSegment> segments) {

private void encryptToken(final InsertValueToken insertValueToken, final String tableName, final InsertSQLStatementContext sqlStatementContext, final InsertValueContext insertValueContext) {
Optional<SQLToken> useDefaultInsertColumnsToken = findPreviousSQLToken(UseDefaultInsertColumnsToken.class);
Set<String> columnNames = new HashSet(sqlStatementContext.getColumnNames());
Set<String> columnNames = new HashSet<>(sqlStatementContext.getColumnNames());
Iterator<String> descendingColumnNames = sqlStatementContext.getDescendingColumnNames();
while (descendingColumnNames.hasNext()) {
String columnName = descendingColumnNames.next();
Expand Down
Expand Up @@ -33,11 +33,9 @@
import static org.junit.Assert.assertThat;

@RunWith(MockitoJUnitRunner.class)
public class SPIRoutingHookTest {
public final class SPIRoutingHookTest {

private SPIRoutingHook spiRoutingHook = new SPIRoutingHook();

private String sql = "select * from table";
private final SPIRoutingHook spiRoutingHook = new SPIRoutingHook();

@Mock
private SQLRouteResult sqlRouteResult;
Expand All @@ -50,6 +48,7 @@ public class SPIRoutingHookTest {

@Test
public void assertStart() {
String sql = "SELECT * FROM table";
spiRoutingHook.start(sql);
RoutingHook routingHook = getFixtureHook();
assertThat(routingHook, instanceOf(RoutingHookFixture.class));
Expand All @@ -73,6 +72,7 @@ public void assertFinishFailure() {
assertThat(((RoutingHookFixture) routingHook).getCause(), is(exception));
}

@SuppressWarnings("unchecked")
@SneakyThrows
private RoutingHook getFixtureHook() {
Field routingHooksField = SPIRoutingHook.class.getDeclaredField("routingHooks");
Expand Down
Expand Up @@ -31,10 +31,10 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertThat;

public class SPITimeServiceTest {

public final class SPITimeServiceTest {
private SPITimeService timeService = new SPITimeService();

@Test
public void assertGetTime() {
Optional<TimeServiceFixture> optional = getFixtureHook();
Expand All @@ -44,7 +44,7 @@ public void assertGetTime() {
Date time = timeService.getTime();
assertThat(date, is(time));
}

@Test
public void assertGetTimeWithDefault() {
Optional<TimeServiceFixture> optional = getFixtureHook();
Expand All @@ -55,7 +55,8 @@ public void assertGetTimeWithDefault() {
Date time = timeService.getTime();
assertTrue(time.after(date));
}


@SuppressWarnings("unchecked")
@SneakyThrows
private Optional<TimeServiceFixture> getFixtureHook() {
Field routingHooksField = SPITimeService.class.getDeclaredField("timeServices");
Expand Down

0 comments on commit 3b3053c

Please sign in to comment.