This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new ace6d94f93a Remove useless default constructor of ShardingSphereTable
(#33806)
ace6d94f93a is described below
commit ace6d94f93a55351327f6f03b1373f9b9c0be90c
Author: Liang Zhang <[email protected]>
AuthorDate: Mon Nov 25 23:37:29 2024 +0800
Remove useless default constructor of ShardingSphereTable (#33806)
* Refactor ShardingSphereTable
* Remove useless default constructor of ShardingSphereTable
---
.../sharding/merge/dql/orderby/OrderByValueTest.java | 3 ++-
.../infra/metadata/database/schema/model/ShardingSphereTable.java | 5 -----
.../metadata/database/schema/manager/GenericSchemaManagerTest.java | 7 +++++--
.../infra/yaml/schema/swapper/YamlTableSwapperTest.java | 3 ++-
.../route/validator/ddl/SingleDropSchemaMetaDataValidatorTest.java | 3 ++-
.../persist/StandaloneMetaDataManagerPersistServiceTest.java | 5 +++--
6 files changed, 14 insertions(+), 12 deletions(-)
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/orderby/OrderByValueTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/orderby/OrderByValueTest.java
index 1e7067a61a4..c2dd776ba01 100644
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/orderby/OrderByValueTest.java
+++
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/orderby/OrderByValueTest.java
@@ -22,6 +22,7 @@ import
org.apache.shardingsphere.infra.binder.context.statement.dml.SelectStatem
import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.database.core.DefaultDatabase;
import
org.apache.shardingsphere.infra.database.core.metadata.database.enums.NullsOrderType;
+import
org.apache.shardingsphere.infra.database.core.metadata.database.enums.TableType;
import
org.apache.shardingsphere.infra.executor.sql.execute.result.query.QueryResult;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
@@ -148,7 +149,7 @@ class OrderByValueTest {
SelectStatementContext selectStatementContext = new
SelectStatementContext(createShardingSphereMetaData(),
Collections.emptyList(), selectStatement,
DefaultDatabase.LOGIC_NAME, Collections.emptyList());
ShardingSphereSchema schema = mock(ShardingSphereSchema.class);
- when(schema.getTable("table")).thenReturn(new ShardingSphereTable());
+ when(schema.getTable("foo_tbl")).thenReturn(new
ShardingSphereTable("foo_tbl", Collections.emptyList(),
Collections.emptyList(), Collections.emptyList(), TableType.TABLE));
QueryResult queryResult1 = createQueryResult("1", "2");
OrderByValue orderByValue1 = new OrderByValue(queryResult1,
Arrays.asList(
createOrderByItem(new IndexOrderByItemSegment(0, 0, 1,
OrderDirection.DESC, NullsOrderType.FIRST)),
diff --git
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereTable.java
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereTable.java
index 1ecc8332a64..bfd15c84d36 100644
---
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereTable.java
+++
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/model/ShardingSphereTable.java
@@ -27,7 +27,6 @@ import
org.apache.shardingsphere.infra.metadata.identifier.ShardingSphereMetaDat
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -62,10 +61,6 @@ public final class ShardingSphereTable {
private final TableType type;
- public ShardingSphereTable() {
- this("", Collections.emptyList(), Collections.emptyList(),
Collections.emptyList(), TableType.TABLE);
- }
-
public ShardingSphereTable(final String name, final
Collection<ShardingSphereColumn> columns,
final Collection<ShardingSphereIndex> indexes,
final Collection<ShardingSphereConstraint> constraints) {
this(name, columns, indexes, constraints, TableType.TABLE);
diff --git
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/manager/GenericSchemaManagerTest.java
b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/manager/GenericSchemaManagerTest.java
index c2c89105c3b..23330df3cdc 100644
---
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/manager/GenericSchemaManagerTest.java
+++
b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/manager/GenericSchemaManagerTest.java
@@ -18,6 +18,7 @@
package org.apache.shardingsphere.infra.metadata.database.schema.manager;
import org.apache.shardingsphere.infra.database.core.DefaultDatabase;
+import
org.apache.shardingsphere.infra.database.core.metadata.database.enums.TableType;
import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereTable;
import org.junit.jupiter.api.Test;
@@ -57,14 +58,16 @@ class GenericSchemaManagerTest {
@Test
void assertGetToBeAddedTables() {
- Map<String, ShardingSphereTable> actual =
GenericSchemaManager.getToBeAddedTables(Collections.singletonMap("foo_table",
new ShardingSphereTable()), Collections.emptyMap());
+ Map<String, ShardingSphereTable> actual =
GenericSchemaManager.getToBeAddedTables(Collections.singletonMap("foo_table",
+ new ShardingSphereTable("", Collections.emptyList(),
Collections.emptyList(), Collections.emptyList(), TableType.TABLE)),
Collections.emptyMap());
assertThat(actual.size(), is(1));
assertTrue(actual.containsKey("foo_table"));
}
@Test
void assertGetToBeDroppedTables() {
- Map<String, ShardingSphereTable> actual =
GenericSchemaManager.getToBeDroppedTables(Collections.emptyMap(),
Collections.singletonMap("foo_table", new ShardingSphereTable()));
+ Map<String, ShardingSphereTable> actual =
GenericSchemaManager.getToBeDroppedTables(Collections.emptyMap(),
Collections.singletonMap("foo_table",
+ new ShardingSphereTable("", Collections.emptyList(),
Collections.emptyList(), Collections.emptyList(), TableType.TABLE)));
assertThat(actual.size(), is(1));
assertTrue(actual.containsKey("foo_table"));
}
diff --git
a/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/schema/swapper/YamlTableSwapperTest.java
b/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/schema/swapper/YamlTableSwapperTest.java
index 19fe8d2664d..959e31b0920 100644
---
a/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/schema/swapper/YamlTableSwapperTest.java
+++
b/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/schema/swapper/YamlTableSwapperTest.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.infra.yaml.schema.swapper;
+import
org.apache.shardingsphere.infra.database.core.metadata.database.enums.TableType;
import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereColumn;
import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereConstraint;
import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereIndex;
@@ -57,7 +58,7 @@ class YamlTableSwapperTest {
@Test
void assertSwapToObjectWithEmptySchema() {
ShardingSphereTable actual =
swapper.swapToObject(YamlEngine.unmarshal(ConfigurationFileUtils.readFile(EMPTY_YAML_FILE),
YamlShardingSphereTable.class));
- ShardingSphereTable expected = new ShardingSphereTable();
+ ShardingSphereTable expected = new ShardingSphereTable("",
Collections.emptyList(), Collections.emptyList(), Collections.emptyList(),
TableType.TABLE);
assertThat(actual, deepEqual(expected));
}
diff --git
a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/route/validator/ddl/SingleDropSchemaMetaDataValidatorTest.java
b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/route/validator/ddl/SingleDropSchemaMetaDataValidatorTest.java
index b014c9f9a10..66b36335fdc 100644
---
a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/route/validator/ddl/SingleDropSchemaMetaDataValidatorTest.java
+++
b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/route/validator/ddl/SingleDropSchemaMetaDataValidatorTest.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.single.route.validator.ddl;
import
org.apache.shardingsphere.infra.binder.context.statement.SQLStatementContext;
import
org.apache.shardingsphere.infra.binder.context.statement.UnknownSQLStatementContext;
import org.apache.shardingsphere.infra.database.core.DefaultDatabase;
+import
org.apache.shardingsphere.infra.database.core.metadata.database.enums.TableType;
import
org.apache.shardingsphere.infra.exception.kernel.metadata.SchemaNotFoundException;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereSchema;
@@ -61,7 +62,7 @@ class SingleDropSchemaMetaDataValidatorTest {
private ShardingSphereDatabase mockDatabase() {
ShardingSphereDatabase result = mock(ShardingSphereDatabase.class,
RETURNS_DEEP_STUBS);
ShardingSphereSchema schema = new
ShardingSphereSchema(DefaultDatabase.LOGIC_NAME);
- schema.putTable("foo_table", new ShardingSphereTable());
+ schema.putTable("foo_tbl", new ShardingSphereTable("foo_tbl",
Collections.emptyList(), Collections.emptyList(), Collections.emptyList(),
TableType.TABLE));
when(result.getSchemas()).thenReturn(Collections.singletonMap("foo_schema",
schema));
return result;
}
diff --git
a/mode/type/standalone/core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/persist/StandaloneMetaDataManagerPersistServiceTest.java
b/mode/type/standalone/core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/persist/StandaloneMetaDataManagerPersistServiceTest.java
index 0ff1a6d6513..059bafaf5f8 100644
---
a/mode/type/standalone/core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/persist/StandaloneMetaDataManagerPersistServiceTest.java
+++
b/mode/type/standalone/core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/persist/StandaloneMetaDataManagerPersistServiceTest.java
@@ -21,6 +21,7 @@ import lombok.SneakyThrows;
import org.apache.groovy.util.Maps;
import org.apache.shardingsphere.infra.config.props.ConfigurationProperties;
import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
+import
org.apache.shardingsphere.infra.database.core.metadata.database.enums.TableType;
import org.apache.shardingsphere.infra.metadata.ShardingSphereMetaData;
import
org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
import
org.apache.shardingsphere.infra.metadata.database.resource.ResourceMetaData;
@@ -229,9 +230,9 @@ class StandaloneMetaDataManagerPersistServiceTest {
@Test
void assertCreateTable() {
- ShardingSphereTable table = new ShardingSphereTable();
+ ShardingSphereTable table = new ShardingSphereTable("foo_tbl",
Collections.emptyList(), Collections.emptyList(), Collections.emptyList(),
TableType.TABLE);
metaDataManagerPersistService.createTable("foo_db", "foo_schema",
table, "foo_ds");
-
verify(metaDataPersistService.getDatabaseMetaDataFacade().getTable()).persist("foo_db",
"foo_schema", Maps.of("", table));
+
verify(metaDataPersistService.getDatabaseMetaDataFacade().getTable()).persist("foo_db",
"foo_schema", Maps.of("foo_tbl", table));
}
@Test