This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 8174b3fcdef Remove useless DataNodeBuilder (#33537)
8174b3fcdef is described below
commit 8174b3fcdef699fdf035f3b96ff64a4062a560b3
Author: Liang Zhang <[email protected]>
AuthorDate: Mon Nov 4 18:28:48 2024 +0800
Remove useless DataNodeBuilder (#33537)
* Remove useless DataNodeBuilder
* Remove useless DataNodeBuilder
---
.../ReadwriteSplittingDataNodeBuilder.java | 57 --------------------
...e.shardingsphere.infra.datanode.DataNodeBuilder | 18 -------
.../ReadwriteSplittingDataNodeBuilderTest.java | 63 ----------------------
.../shadow/datanode/ShadowDataNodeBuilder.java | 57 --------------------
...e.shardingsphere.infra.datanode.DataNodeBuilder | 18 -------
.../shadow/datanode/ShadowDataNodeBuilderTest.java | 63 ----------------------
.../infra/datanode/DataNodeBuilder.java | 42 ---------------
.../shardingsphere/infra/datanode/DataNodes.java | 30 ++++++-----
.../infra/fixture/DataNodeBuilderFixture.java | 48 -----------------
.../schema/util/SchemaMetaDataUtilsTest.java | 30 ++++++-----
...e.shardingsphere.infra.datanode.DataNodeBuilder | 18 -------
11 files changed, 35 insertions(+), 409 deletions(-)
diff --git
a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/datanode/ReadwriteSplittingDataNodeBuilder.java
b/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/datanode/ReadwriteSplittingDataNodeBuilder.java
deleted file mode 100644
index 135343ecccc..00000000000
---
a/features/readwrite-splitting/core/src/main/java/org/apache/shardingsphere/readwritesplitting/datanode/ReadwriteSplittingDataNodeBuilder.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.readwritesplitting.datanode;
-
-import org.apache.shardingsphere.infra.annotation.HighFrequencyInvocation;
-import org.apache.shardingsphere.infra.datanode.DataNode;
-import org.apache.shardingsphere.infra.datanode.DataNodeBuilder;
-import org.apache.shardingsphere.infra.datanode.DataNodeUtils;
-import
org.apache.shardingsphere.infra.rule.attribute.datasource.DataSourceMapperRuleAttribute;
-import
org.apache.shardingsphere.readwritesplitting.constant.ReadwriteSplittingOrder;
-import
org.apache.shardingsphere.readwritesplitting.rule.ReadwriteSplittingRule;
-
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.Map;
-
-/**
- * Readwrite-splitting data node builder.
- */
-@HighFrequencyInvocation
-public final class ReadwriteSplittingDataNodeBuilder implements
DataNodeBuilder<ReadwriteSplittingRule> {
-
- @Override
- public Collection<DataNode> build(final Collection<DataNode> dataNodes,
final ReadwriteSplittingRule rule) {
- Collection<DataNode> result = new LinkedList<>();
- Map<String, Collection<String>> dataSourceMapper =
rule.getAttributes().getAttribute(DataSourceMapperRuleAttribute.class).getDataSourceMapper();
- for (DataNode each : dataNodes) {
- result.addAll(DataNodeUtils.buildDataNode(each, dataSourceMapper));
- }
- return result;
- }
-
- @Override
- public int getOrder() {
- return ReadwriteSplittingOrder.ORDER;
- }
-
- @Override
- public Class<ReadwriteSplittingRule> getTypeClass() {
- return ReadwriteSplittingRule.class;
- }
-}
diff --git
a/features/readwrite-splitting/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.datanode.DataNodeBuilder
b/features/readwrite-splitting/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.datanode.DataNodeBuilder
deleted file mode 100644
index 7da6f0a0465..00000000000
---
a/features/readwrite-splitting/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.datanode.DataNodeBuilder
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-org.apache.shardingsphere.readwritesplitting.datanode.ReadwriteSplittingDataNodeBuilder
diff --git
a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/datanode/ReadwriteSplittingDataNodeBuilderTest.java
b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/datanode/ReadwriteSplittingDataNodeBuilderTest.java
deleted file mode 100644
index 5542d5cf9a9..00000000000
---
a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/datanode/ReadwriteSplittingDataNodeBuilderTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.readwritesplitting.datanode;
-
-import org.apache.shardingsphere.infra.datanode.DataNode;
-import org.apache.shardingsphere.infra.datanode.DataNodeBuilder;
-import org.apache.shardingsphere.infra.rule.attribute.RuleAttributes;
-import
org.apache.shardingsphere.infra.rule.attribute.datasource.DataSourceMapperRuleAttribute;
-import org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPILoader;
-import
org.apache.shardingsphere.readwritesplitting.rule.ReadwriteSplittingRule;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.Mock;
-import org.mockito.junit.jupiter.MockitoExtension;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.mockito.Mockito.when;
-
-@ExtendWith(MockitoExtension.class)
-class ReadwriteSplittingDataNodeBuilderTest {
-
- @Mock
- private ReadwriteSplittingRule rule;
-
- @Mock
- private DataSourceMapperRuleAttribute dataSourceMapperRuleAttribute;
-
- private ReadwriteSplittingDataNodeBuilder builder;
-
- @BeforeEach
- void setUp() {
-
when(dataSourceMapperRuleAttribute.getDataSourceMapper()).thenReturn(Collections.singletonMap("foo_db",
Arrays.asList("foo_write_db", "foo_read_db")));
- when(rule.getAttributes()).thenReturn(new
RuleAttributes(dataSourceMapperRuleAttribute));
- builder = (ReadwriteSplittingDataNodeBuilder)
OrderedSPILoader.getServices(DataNodeBuilder.class,
Collections.singleton(rule)).get(rule);
- }
-
- @Test
- void assertBuild() {
- Collection<DataNode> actual = builder.build(Collections.singleton(new
DataNode("foo_db.foo_tbl")), rule);
- assertThat(actual, is(Arrays.asList(new
DataNode("foo_write_db.foo_tbl"), new DataNode("foo_read_db.foo_tbl"))));
- }
-}
diff --git
a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/datanode/ShadowDataNodeBuilder.java
b/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/datanode/ShadowDataNodeBuilder.java
deleted file mode 100644
index 1ebaca50f73..00000000000
---
a/features/shadow/core/src/main/java/org/apache/shardingsphere/shadow/datanode/ShadowDataNodeBuilder.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.shadow.datanode;
-
-import org.apache.shardingsphere.infra.annotation.HighFrequencyInvocation;
-import org.apache.shardingsphere.infra.datanode.DataNode;
-import org.apache.shardingsphere.infra.datanode.DataNodeBuilder;
-import org.apache.shardingsphere.infra.datanode.DataNodeUtils;
-import
org.apache.shardingsphere.infra.rule.attribute.datasource.DataSourceMapperRuleAttribute;
-import org.apache.shardingsphere.shadow.constant.ShadowOrder;
-import org.apache.shardingsphere.shadow.rule.ShadowRule;
-
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.Map;
-
-/**
- * Shadow data node builder.
- */
-@HighFrequencyInvocation
-public final class ShadowDataNodeBuilder implements
DataNodeBuilder<ShadowRule> {
-
- @Override
- public Collection<DataNode> build(final Collection<DataNode> dataNodes,
final ShadowRule rule) {
- Collection<DataNode> result = new LinkedList<>();
- Map<String, Collection<String>> dataSourceMapper =
rule.getAttributes().getAttribute(DataSourceMapperRuleAttribute.class).getDataSourceMapper();
- for (DataNode each : dataNodes) {
- result.addAll(DataNodeUtils.buildDataNode(each, dataSourceMapper));
- }
- return result;
- }
-
- @Override
- public int getOrder() {
- return ShadowOrder.ORDER;
- }
-
- @Override
- public Class<ShadowRule> getTypeClass() {
- return ShadowRule.class;
- }
-}
diff --git
a/features/shadow/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.datanode.DataNodeBuilder
b/features/shadow/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.datanode.DataNodeBuilder
deleted file mode 100644
index 5d77151e833..00000000000
---
a/features/shadow/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.datanode.DataNodeBuilder
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-org.apache.shardingsphere.shadow.datanode.ShadowDataNodeBuilder
diff --git
a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/datanode/ShadowDataNodeBuilderTest.java
b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/datanode/ShadowDataNodeBuilderTest.java
deleted file mode 100644
index 31427860bab..00000000000
---
a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/datanode/ShadowDataNodeBuilderTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.shadow.datanode;
-
-import org.apache.shardingsphere.infra.datanode.DataNode;
-import org.apache.shardingsphere.infra.datanode.DataNodeBuilder;
-import org.apache.shardingsphere.infra.rule.attribute.RuleAttributes;
-import
org.apache.shardingsphere.infra.rule.attribute.datasource.DataSourceMapperRuleAttribute;
-import org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPILoader;
-import org.apache.shardingsphere.shadow.rule.ShadowRule;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.Mock;
-import org.mockito.junit.jupiter.MockitoExtension;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.mockito.Mockito.when;
-
-@ExtendWith(MockitoExtension.class)
-class ShadowDataNodeBuilderTest {
-
- @Mock
- private ShadowRule rule;
-
- @Mock
- private DataSourceMapperRuleAttribute dataSourceMapperRuleAttribute;
-
- private ShadowDataNodeBuilder builder;
-
- @BeforeEach
- void setUp() {
-
when(dataSourceMapperRuleAttribute.getDataSourceMapper()).thenReturn(Collections.singletonMap("foo_db",
Arrays.asList("foo_prod_db", "foo_shadow_db")));
- when(rule.getAttributes()).thenReturn(new
RuleAttributes(dataSourceMapperRuleAttribute));
- builder = (ShadowDataNodeBuilder)
OrderedSPILoader.getServices(DataNodeBuilder.class,
Collections.singleton(rule)).get(rule);
- }
-
- @Test
- void assertBuild() {
- Collection<DataNode> actual = builder.build(Collections.singleton(new
DataNode("foo_db.foo_tbl")), rule);
- assertThat(actual, is(Arrays.asList(new
DataNode("foo_prod_db.foo_tbl"), new DataNode("foo_shadow_db.foo_tbl"))));
- }
-}
diff --git
a/infra/common/src/main/java/org/apache/shardingsphere/infra/datanode/DataNodeBuilder.java
b/infra/common/src/main/java/org/apache/shardingsphere/infra/datanode/DataNodeBuilder.java
deleted file mode 100644
index 7e87abd8f65..00000000000
---
a/infra/common/src/main/java/org/apache/shardingsphere/infra/datanode/DataNodeBuilder.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.infra.datanode;
-
-import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
-import org.apache.shardingsphere.infra.spi.annotation.SingletonSPI;
-import org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPI;
-
-import java.util.Collection;
-
-/**
- * Data node builder.
- *
- * @param <T> type of rule
- */
-@SingletonSPI
-public interface DataNodeBuilder<T extends ShardingSphereRule> extends
OrderedSPI<T> {
-
- /**
- * Build data nodes.
- *
- * @param dataNodes data nodes
- * @param rule rule
- * @return data nodes
- */
- Collection<DataNode> build(Collection<DataNode> dataNodes, T rule);
-}
diff --git
a/infra/common/src/main/java/org/apache/shardingsphere/infra/datanode/DataNodes.java
b/infra/common/src/main/java/org/apache/shardingsphere/infra/datanode/DataNodes.java
index 44935845d7c..af70785fd3e 100644
---
a/infra/common/src/main/java/org/apache/shardingsphere/infra/datanode/DataNodes.java
+++
b/infra/common/src/main/java/org/apache/shardingsphere/infra/datanode/DataNodes.java
@@ -21,12 +21,13 @@ import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.annotation.HighFrequencyInvocation;
import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
import
org.apache.shardingsphere.infra.rule.attribute.datanode.DataNodeRuleAttribute;
-import org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPILoader;
+import
org.apache.shardingsphere.infra.rule.attribute.datasource.DataSourceMapperRuleAttribute;
import java.util.Collection;
import java.util.Collections;
+import java.util.LinkedList;
import java.util.Map;
-import java.util.Map.Entry;
+import java.util.Optional;
/**
* Data nodes.
@@ -36,14 +37,6 @@ public final class DataNodes {
private final Collection<ShardingSphereRule> rules;
- @SuppressWarnings("rawtypes")
- private final Map<ShardingSphereRule, DataNodeBuilder> dataNodeBuilders;
-
- public DataNodes(final Collection<ShardingSphereRule> rules) {
- this.rules = rules;
- dataNodeBuilders = OrderedSPILoader.getServices(DataNodeBuilder.class,
rules);
- }
-
/**
* Get data nodes.
*
@@ -51,14 +44,16 @@ public final class DataNodes {
* @return data nodes
*/
@HighFrequencyInvocation
- @SuppressWarnings({"unchecked", "rawtypes"})
public Collection<DataNode> getDataNodes(final String tableName) {
Collection<DataNode> result = getDataNodesByTableName(tableName);
if (result.isEmpty()) {
return result;
}
- for (Entry<ShardingSphereRule, DataNodeBuilder> entry :
dataNodeBuilders.entrySet()) {
- result = entry.getValue().build(result, entry.getKey());
+ for (ShardingSphereRule each : rules) {
+ Optional<DataSourceMapperRuleAttribute>
dataSourceMapperRuleAttribute =
each.getAttributes().findAttribute(DataSourceMapperRuleAttribute.class);
+ if (dataSourceMapperRuleAttribute.isPresent()) {
+ result = buildDataNodes(result,
dataSourceMapperRuleAttribute.get());
+ }
}
return result;
}
@@ -76,4 +71,13 @@ public final class DataNodes {
private Collection<DataNode> getDataNodesByTableName(final
ShardingSphereRule rule, final String tableName) {
return
rule.getAttributes().findAttribute(DataNodeRuleAttribute.class).map(optional ->
optional.getDataNodesByTableName(tableName)).orElse(Collections.emptyList());
}
+
+ private Collection<DataNode> buildDataNodes(final Collection<DataNode>
dataNodes, final DataSourceMapperRuleAttribute dataSourceMapperRuleAttribute) {
+ Collection<DataNode> result = new LinkedList<>();
+ Map<String, Collection<String>> dataSourceMapper =
dataSourceMapperRuleAttribute.getDataSourceMapper();
+ for (DataNode each : dataNodes) {
+ result.addAll(DataNodeUtils.buildDataNode(each, dataSourceMapper));
+ }
+ return result;
+ }
}
diff --git
a/infra/common/src/test/java/org/apache/shardingsphere/infra/fixture/DataNodeBuilderFixture.java
b/infra/common/src/test/java/org/apache/shardingsphere/infra/fixture/DataNodeBuilderFixture.java
deleted file mode 100644
index 116942caf0b..00000000000
---
a/infra/common/src/test/java/org/apache/shardingsphere/infra/fixture/DataNodeBuilderFixture.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.infra.fixture;
-
-import org.apache.shardingsphere.infra.datanode.DataNode;
-import org.apache.shardingsphere.infra.datanode.DataNodeBuilder;
-import org.apache.shardingsphere.infra.datanode.DataNodeUtils;
-import
org.apache.shardingsphere.infra.rule.attribute.datasource.DataSourceMapperRuleAttribute;
-
-import java.util.Collection;
-import java.util.LinkedList;
-
-public final class DataNodeBuilderFixture implements
DataNodeBuilder<FixtureRule> {
-
- @Override
- public Collection<DataNode> build(final Collection<DataNode> dataNodes,
final FixtureRule rule) {
- Collection<DataNode> result = new LinkedList<>();
- for (DataNode each : dataNodes) {
- result.addAll(DataNodeUtils.buildDataNode(each,
rule.getAttributes().getAttribute(DataSourceMapperRuleAttribute.class).getDataSourceMapper()));
- }
- return result;
- }
-
- @Override
- public int getOrder() {
- return 3;
- }
-
- @Override
- public Class<FixtureRule> getTypeClass() {
- return FixtureRule.class;
- }
-}
diff --git
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/util/SchemaMetaDataUtilsTest.java
b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/util/SchemaMetaDataUtilsTest.java
index 55f51be33f1..b10d3fb333b 100644
---
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/util/SchemaMetaDataUtilsTest.java
+++
b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/util/SchemaMetaDataUtilsTest.java
@@ -47,12 +47,14 @@ class SchemaMetaDataUtilsTest {
@Test
void assertGetSchemaMetaDataLoaderMaterialsWhenConfigCheckMetaDataEnable()
{
- ShardingSphereRule rule = mock(ShardingSphereRule.class);
+ ShardingSphereRule rule0 = mock(ShardingSphereRule.class);
DataNodeRuleAttribute ruleAttribute =
mock(DataNodeRuleAttribute.class);
when(ruleAttribute.getDataNodesByTableName("t_order")).thenReturn(mockShardingDataNodes());
- when(rule.getAttributes()).thenReturn(new
RuleAttributes(ruleAttribute));
- GenericSchemaBuilderMaterial material = new
GenericSchemaBuilderMaterial(mock(DatabaseType.class), mockStorageTypes(),
mockDataSourceMap(),
- Arrays.asList(rule, mock(ShardingSphereRule.class)),
mock(ConfigurationProperties.class), "sharding_db");
+ when(rule0.getAttributes()).thenReturn(new
RuleAttributes(ruleAttribute));
+ ShardingSphereRule rule1 = mock(ShardingSphereRule.class);
+ when(rule1.getAttributes()).thenReturn(new RuleAttributes());
+ GenericSchemaBuilderMaterial material = new
GenericSchemaBuilderMaterial(
+ mock(DatabaseType.class), mockStorageTypes(),
mockDataSourceMap(), Arrays.asList(rule0, rule1),
mock(ConfigurationProperties.class), "sharding_db");
Collection<MetaDataLoaderMaterial> actual =
SchemaMetaDataUtils.getMetaDataLoaderMaterials(Collections.singleton("t_order"),
material, true);
assertThat(actual.size(), is(2));
Iterator<MetaDataLoaderMaterial> iterator = actual.iterator();
@@ -66,12 +68,14 @@ class SchemaMetaDataUtilsTest {
@Test
void
assertGetSchemaMetaDataLoaderMaterialsWhenNotConfigCheckMetaDataEnable() {
- ShardingSphereRule rule = mock(ShardingSphereRule.class);
+ ShardingSphereRule rule0 = mock(ShardingSphereRule.class);
DataNodeRuleAttribute ruleAttribute =
mock(DataNodeRuleAttribute.class);
when(ruleAttribute.getDataNodesByTableName("t_order")).thenReturn(mockShardingDataNodes());
- when(rule.getAttributes()).thenReturn(new
RuleAttributes(ruleAttribute));
- GenericSchemaBuilderMaterial material = new
GenericSchemaBuilderMaterial(mock(DatabaseType.class), mockStorageTypes(),
mockDataSourceMap(),
- Arrays.asList(rule, mock(ShardingSphereRule.class)),
mock(ConfigurationProperties.class), "sharding_db");
+ when(rule0.getAttributes()).thenReturn(new
RuleAttributes(ruleAttribute));
+ ShardingSphereRule rule1 = mock(ShardingSphereRule.class);
+ when(rule1.getAttributes()).thenReturn(new RuleAttributes());
+ GenericSchemaBuilderMaterial material = new
GenericSchemaBuilderMaterial(
+ mock(DatabaseType.class), mockStorageTypes(),
mockDataSourceMap(), Arrays.asList(rule0, rule1),
mock(ConfigurationProperties.class), "sharding_db");
Collection<MetaDataLoaderMaterial> actual =
SchemaMetaDataUtils.getMetaDataLoaderMaterials(Collections.singleton("t_order"),
material, false);
assertThat(actual.size(), is(1));
Iterator<MetaDataLoaderMaterial> iterator = actual.iterator();
@@ -82,12 +86,14 @@ class SchemaMetaDataUtilsTest {
@Test
void
assertGetSchemaMetaDataLoaderMaterialsWhenNotConfigCheckMetaDataEnableForSingleTableDataNode()
{
- ShardingSphereRule rule = mock(ShardingSphereRule.class);
+ ShardingSphereRule rule0 = mock(ShardingSphereRule.class);
DataNodeRuleAttribute ruleAttribute =
mock(DataNodeRuleAttribute.class);
when(ruleAttribute.getDataNodesByTableName("t_single")).thenReturn(mockSingleTableDataNodes());
- when(rule.getAttributes()).thenReturn(new
RuleAttributes(ruleAttribute));
- GenericSchemaBuilderMaterial material = new
GenericSchemaBuilderMaterial(mock(DatabaseType.class), mockStorageTypes(),
mockDataSourceMap(),
- Arrays.asList(rule, mock(ShardingSphereRule.class)),
mock(ConfigurationProperties.class), "public");
+ when(rule0.getAttributes()).thenReturn(new
RuleAttributes(ruleAttribute));
+ ShardingSphereRule rule1 = mock(ShardingSphereRule.class);
+ when(rule1.getAttributes()).thenReturn(new RuleAttributes());
+ GenericSchemaBuilderMaterial material = new
GenericSchemaBuilderMaterial(
+ mock(DatabaseType.class), mockStorageTypes(),
mockDataSourceMap(), Arrays.asList(rule0, rule1),
mock(ConfigurationProperties.class), "public");
Collection<MetaDataLoaderMaterial> actual =
SchemaMetaDataUtils.getMetaDataLoaderMaterials(Collections.singleton("t_single"),
material, false);
assertThat(actual.size(), is(1));
Iterator<MetaDataLoaderMaterial> iterator = actual.iterator();
diff --git
a/infra/common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.datanode.DataNodeBuilder
b/infra/common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.datanode.DataNodeBuilder
deleted file mode 100644
index 0db71dc8ee4..00000000000
---
a/infra/common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.datanode.DataNodeBuilder
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-org.apache.shardingsphere.infra.fixture.DataNodeBuilderFixture