Skip to content

Commit

Permalink
Fix test error
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangML committed Jan 22, 2025
1 parent d61cbb7 commit 94d4ad1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
import org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereRowData;
import org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereTableData;
import org.apache.shardingsphere.infra.metadata.statistics.collector.StatisticsCollector;
import org.apache.shardingsphere.infra.metadata.statistics.collector.dialect.shardingsphere.ShardingSphereTableStatisticsCollector;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
import org.apache.shardingsphere.sharding.rule.ShardingTable;
Expand Down Expand Up @@ -57,11 +57,11 @@ class ShardingStatisticsTableCollectorTest {

private final DatabaseType databaseType = TypedSPILoader.getService(DatabaseType.class, "FIXTURE");

private StatisticsCollector statisticsCollector;
private ShardingSphereTableStatisticsCollector shardingSphereTableStatisticsCollector;

@BeforeEach
void setUp() {
statisticsCollector = TypedSPILoader.getService(StatisticsCollector.class, "sharding_table_statistics");
shardingSphereTableStatisticsCollector = TypedSPILoader.getService(ShardingSphereTableStatisticsCollector.class, "shardingsphere.sharding_table_statistics");
}

@Test
Expand All @@ -71,7 +71,7 @@ void assertCollectWithoutShardingRule() throws SQLException {
when(database.getProtocolType()).thenReturn(databaseType);
ShardingSphereMetaData metaData = new ShardingSphereMetaData(
Collections.singleton(database), mock(ResourceMetaData.class), mock(RuleMetaData.class), new ConfigurationProperties(new Properties()));
Optional<ShardingSphereTableData> actual = statisticsCollector.collect("foo_db", mock(ShardingSphereTable.class), metaData);
Optional<ShardingSphereTableData> actual = shardingSphereTableStatisticsCollector.collect("foo_db", "foo_db", mock(ShardingSphereTable.class), metaData);
assertFalse(actual.isPresent());
}

Expand All @@ -85,7 +85,7 @@ void assertCollectWithShardingRule() throws SQLException {
ShardingSphereDatabase database = new ShardingSphereDatabase(
"foo_db", databaseType, new ResourceMetaData(Collections.emptyMap(), storageUnits), new RuleMetaData(Collections.singleton(rule)), Collections.emptyList());
ShardingSphereMetaData metaData = new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), new ConfigurationProperties(new Properties()));
Optional<ShardingSphereTableData> actual = statisticsCollector.collect("foo_db", mock(ShardingSphereTable.class), metaData);
Optional<ShardingSphereTableData> actual = shardingSphereTableStatisticsCollector.collect("foo_db", "foo_db", mock(ShardingSphereTable.class), metaData);
assertTrue(actual.isPresent());
assertThat(actual.get().getName(), is("sharding_table_statistics"));
List<ShardingSphereRowData> actualRows = new ArrayList<>(actual.get().getRows());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
import org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereRowData;
import org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereTableData;
import org.apache.shardingsphere.infra.metadata.statistics.collector.StatisticsCollector;
import org.apache.shardingsphere.infra.metadata.statistics.collector.dialect.shardingsphere.ShardingSphereTableStatisticsCollector;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
import org.apache.shardingsphere.sharding.rule.ShardingTable;
Expand Down Expand Up @@ -59,11 +59,11 @@ class MySQLShardingStatisticsTableCollectorTest {

private final DatabaseType databaseType = TypedSPILoader.getService(DatabaseType.class, "MySQL");

private StatisticsCollector statisticsCollector;
private ShardingSphereTableStatisticsCollector shardingSphereTableStatisticsCollector;

@BeforeEach
void setUp() {
statisticsCollector = TypedSPILoader.getService(StatisticsCollector.class, "sharding_table_statistics");
shardingSphereTableStatisticsCollector = TypedSPILoader.getService(ShardingSphereTableStatisticsCollector.class, "shardingsphere.sharding_table_statistics");
}

@Test
Expand All @@ -76,7 +76,7 @@ void assertCollect() throws SQLException {
ShardingSphereDatabase database = new ShardingSphereDatabase(
"foo_db", databaseType, new ResourceMetaData(Collections.emptyMap(), storageUnits), new RuleMetaData(Collections.singleton(rule)), Collections.emptyList());
ShardingSphereMetaData metaData = new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), new ConfigurationProperties(new Properties()));
Optional<ShardingSphereTableData> actual = statisticsCollector.collect("foo_db", mock(ShardingSphereTable.class), metaData);
Optional<ShardingSphereTableData> actual = shardingSphereTableStatisticsCollector.collect("foo_db", "foo_db", mock(ShardingSphereTable.class), metaData);
assertTrue(actual.isPresent());
assertThat(actual.get().getName(), is("sharding_table_statistics"));
List<ShardingSphereRowData> actualRows = new ArrayList<>(actual.get().getRows());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
import org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereRowData;
import org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereTableData;
import org.apache.shardingsphere.infra.metadata.statistics.collector.StatisticsCollector;
import org.apache.shardingsphere.infra.metadata.statistics.collector.dialect.shardingsphere.ShardingSphereTableStatisticsCollector;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
import org.apache.shardingsphere.sharding.rule.ShardingTable;
Expand Down Expand Up @@ -60,11 +60,11 @@ class OpenGaussShardingStatisticsTableCollectorTest {

private final DatabaseType databaseType = TypedSPILoader.getService(DatabaseType.class, "openGauss");

private StatisticsCollector statisticsCollector;
private ShardingSphereTableStatisticsCollector shardingSphereTableStatisticsCollector;

@BeforeEach
void setUp() {
statisticsCollector = TypedSPILoader.getService(StatisticsCollector.class, "sharding_table_statistics");
shardingSphereTableStatisticsCollector = TypedSPILoader.getService(ShardingSphereTableStatisticsCollector.class, "shardingsphere.sharding_table_statistics");
}

@Test
Expand All @@ -77,7 +77,7 @@ void assertCollectWithoutExistedTables() throws SQLException {
ShardingSphereDatabase database = new ShardingSphereDatabase(
"foo_db", databaseType, new ResourceMetaData(Collections.emptyMap(), storageUnits), new RuleMetaData(Collections.singleton(rule)), Collections.emptyList());
ShardingSphereMetaData metaData = new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), new ConfigurationProperties(new Properties()));
Optional<ShardingSphereTableData> actual = statisticsCollector.collect("foo_db", mock(ShardingSphereTable.class), metaData);
Optional<ShardingSphereTableData> actual = shardingSphereTableStatisticsCollector.collect("foo_db", "foo_db", mock(ShardingSphereTable.class), metaData);
assertTrue(actual.isPresent());
assertThat(actual.get().getName(), is("sharding_table_statistics"));
List<ShardingSphereRowData> actualRows = new ArrayList<>(actual.get().getRows());
Expand All @@ -96,7 +96,7 @@ void assertCollectWithExistedTables() throws SQLException {
ShardingSphereDatabase database = new ShardingSphereDatabase(
"foo_db", databaseType, new ResourceMetaData(Collections.emptyMap(), storageUnits), new RuleMetaData(Collections.singleton(rule)), Collections.emptyList());
ShardingSphereMetaData metaData = new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), new ConfigurationProperties(new Properties()));
Optional<ShardingSphereTableData> actual = statisticsCollector.collect("foo_db", mock(ShardingSphereTable.class), metaData);
Optional<ShardingSphereTableData> actual = shardingSphereTableStatisticsCollector.collect("foo_db", "foo_db", mock(ShardingSphereTable.class), metaData);
assertTrue(actual.isPresent());
assertThat(actual.get().getName(), is("sharding_table_statistics"));
List<ShardingSphereRowData> actualRows = new ArrayList<>(actual.get().getRows());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
import org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereRowData;
import org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereTableData;
import org.apache.shardingsphere.infra.metadata.statistics.collector.StatisticsCollector;
import org.apache.shardingsphere.infra.metadata.statistics.collector.dialect.shardingsphere.ShardingSphereTableStatisticsCollector;
import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
import org.apache.shardingsphere.sharding.rule.ShardingTable;
Expand Down Expand Up @@ -59,11 +59,11 @@ class PostgreSQLShardingStatisticsTableCollectorTest {

private final DatabaseType databaseType = TypedSPILoader.getService(DatabaseType.class, "PostgreSQL");

private StatisticsCollector statisticsCollector;
private ShardingSphereTableStatisticsCollector shardingSphereTableStatisticsCollector;

@BeforeEach
void setUp() {
statisticsCollector = TypedSPILoader.getService(StatisticsCollector.class, "sharding_table_statistics");
shardingSphereTableStatisticsCollector = TypedSPILoader.getService(ShardingSphereTableStatisticsCollector.class, "shardingsphere.sharding_table_statistics");
}

@Test
Expand All @@ -76,7 +76,7 @@ void assertCollect() throws SQLException {
ShardingSphereDatabase database = new ShardingSphereDatabase(
"foo_db", databaseType, new ResourceMetaData(Collections.emptyMap(), storageUnits), new RuleMetaData(Collections.singleton(rule)), Collections.emptyList());
ShardingSphereMetaData metaData = new ShardingSphereMetaData(Collections.singleton(database), mock(), mock(), new ConfigurationProperties(new Properties()));
Optional<ShardingSphereTableData> actual = statisticsCollector.collect("foo_db", mock(ShardingSphereTable.class), metaData);
Optional<ShardingSphereTableData> actual = shardingSphereTableStatisticsCollector.collect("foo_db", "foo_db", mock(ShardingSphereTable.class), metaData);
assertTrue(actual.isPresent());
assertThat(actual.get().getName(), is("sharding_table_statistics"));
List<ShardingSphereRowData> actualRows = new ArrayList<>(actual.get().getRows());
Expand Down

0 comments on commit 94d4ad1

Please sign in to comment.