Skip to content

Commit

Permalink
Revise #29308, remove duplicated FooDistSQLShardingAlgorithmFixture (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
RaigorJiang authored Dec 7, 2023
1 parent fe1acdd commit d9a29d4
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ public Collection<LocalDataQueryResultRow> getRows(final ShowShardingAlgorithmIm
Collection<LocalDataQueryResultRow> result = new LinkedList<>();
Collection<ShardingAlgorithm> shardingAlgorithms = ShardingSphereServiceLoader.getServiceInstances(ShardingAlgorithm.class);
for (ShardingAlgorithm each : shardingAlgorithms) {
LocalDataQueryResultRow row = new LocalDataQueryResultRow(each.getClass().getSimpleName(), each.getType(), each.getClass().getName());
result.add(row);
result.add(new LocalDataQueryResultRow(each.getClass().getSimpleName(), each.getType(), each.getClass().getName()));
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
# limitations under the License.
#

org.apache.shardingsphere.proxy.backend.handler.distsql.fixture.FooDistSQLShardingAlgorithmFixture
org.apache.shardingsphere.sharding.distsql.handler.query.ShowShardingAlgorithmImplementationsExecutor
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.mockito.Mockito.mock;

class ShowShardingAlgorithmImplementationsExecutorTest {
Expand All @@ -37,7 +37,7 @@ class ShowShardingAlgorithmImplementationsExecutorTest {
void assertGetRowData() {
QueryableRALExecutor<ShowShardingAlgorithmImplementationsStatement> executor = new ShowShardingAlgorithmImplementationsExecutor();
Collection<LocalDataQueryResultRow> actual = executor.getRows(mock(ShowShardingAlgorithmImplementationsStatement.class));
assertTrue(actual.size() > 0);
assertFalse(actual.isEmpty());
Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
LocalDataQueryResultRow row = iterator.next();
assertThat(row.getCell(1), is("FooDistSQLShardingAlgorithmFixture"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ public Collection<LocalDataQueryResultRow> getRows(final ShowServiceProviderImpl
}
Collection<?> shardingAlgorithms = ShardingSphereServiceLoader.getServiceInstances(clazz);
for (Object each : shardingAlgorithms) {
TypedSPI type = (TypedSPI) each;
LocalDataQueryResultRow row = new LocalDataQueryResultRow(type.getClass().getSimpleName(), type.getType(), type.getClass().getName());
result.add(row);
TypedSPI implementation = (TypedSPI) each;
result.add(new LocalDataQueryResultRow(implementation.getClass().getSimpleName(), implementation.getType(), implementation.getClass().getName()));
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,3 @@ org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.ShowStatus
org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.ShowTableMetaDataExecutor
org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.ShowMigrationRuleExecutor
org.apache.shardingsphere.proxy.backend.handler.distsql.ral.queryable.ShowServiceProviderImplementationsExecutor
org.apache.shardingsphere.sharding.distsql.handler.query.ShowShardingAlgorithmImplementationsExecutor

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand All @@ -37,14 +37,14 @@ class ShowServiceProviderImplementationsExecutorTest {
void assertGetRowData() {
QueryableRALExecutor<ShowServiceProviderImplementationsStatement> executor = new ShowServiceProviderImplementationsExecutor();
ShowServiceProviderImplementationsStatement statement = mock(ShowServiceProviderImplementationsStatement.class);
when(statement.getServiceProviderInterface()).thenReturn("org.apache.shardingsphere.sharding.spi.ShardingAlgorithm");
when(statement.getServiceProviderInterface()).thenReturn("org.apache.shardingsphere.infra.datasource.pool.destroyer.DataSourcePoolActiveDetector");
Collection<LocalDataQueryResultRow> actual = executor.getRows(statement);
assertTrue(actual.size() > 0);
assertFalse(actual.isEmpty());
Iterator<LocalDataQueryResultRow> iterator = actual.iterator();
LocalDataQueryResultRow row = iterator.next();
assertThat(row.getCell(1), is("FooDistSQLShardingAlgorithmFixture"));
assertThat(row.getCell(2), is("FOO.DISTSQL.FIXTURE"));
assertThat(row.getCell(3), is("org.apache.shardingsphere.proxy.backend.handler.distsql.fixture.FooDistSQLShardingAlgorithmFixture"));
assertThat(row.getCell(1), is("HikariDataSourcePoolActiveDetector"));
assertThat(row.getCell(2), is("com.zaxxer.hikari.HikariDataSource"));
assertThat(row.getCell(3), is("org.apache.shardingsphere.infra.datasource.pool.hikari.detector.HikariDataSourcePoolActiveDetector"));
}

@Test
Expand Down

0 comments on commit d9a29d4

Please sign in to comment.