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 320a6fc5ec6 Remove useless UT of Yaml swappers (#33039)
320a6fc5ec6 is described below
commit 320a6fc5ec62280110e340422fd2da05d44586de
Author: Liang Zhang <[email protected]>
AuthorDate: Sat Sep 28 22:26:50 2024 +0800
Remove useless UT of Yaml swappers (#33039)
---
.../YamlBroadcastRuleConfigurationSwapperTest.java | 49 -----
.../YamlEncryptRuleConfigurationSwapperTest.java | 85 ---------
...lEncryptColumnRuleConfigurationSwapperTest.java | 76 --------
...mlEncryptTableRuleConfigurationSwapperTest.java | 101 ----------
.../YamlMaskRuleConfigurationSwapperTest.java | 76 --------
...YamlMaskColumnRuleConfigurationSwapperTest.java | 46 -----
.../YamlMaskTableRuleConfigurationSwapperTest.java | 75 --------
...writeSplittingRuleConfigurationSwapperTest.java | 93 ---------
.../YamlShadowRuleConfigurationSwapperTest.java | 124 ------------
.../YamlShardingRuleConfigurationSwapperTest.java | 207 ---------------------
.../YamlShardingCacheConfigurationSwapperTest.java | 59 ------
...ardingCacheOptionsConfigurationSwapperTest.java | 49 -----
...rdingAutoTableRuleConfigurationSwapperTest.java | 96 ----------
...lShardingTableRuleConfigurationSwapperTest.java | 108 -----------
...eyGenerateStrategyConfigurationSwapperTest.java | 48 -----
...rdingAuditStrategyConfigurationSwapperTest.java | 51 -----
...mlShardingStrategyConfigurationSwapperTest.java | 132 -------------
.../YamlAuthorityRuleConfigurationSwapperTest.java | 93 ---------
.../swapper/YamlEngineUserConfigurationTest.java | 49 -----
.../yaml/swapper/YamlUserSwapperTest.java | 80 --------
.../ShardingSpherePipelineDataSourceCreator.java | 2 +-
.../{pojo => }/YamlSingleRuleConfiguration.java | 2 +-
.../YamlSingleRuleConfigurationSwapper.java | 4 +-
...onfig.swapper.rule.YamlRuleConfigurationSwapper | 2 +-
...onfigurationRepositoryTupleSwapperEngineIT.java | 2 +-
.../YamlSingleRuleConfigurationSwapperTest.java | 57 ------
.../it/SQLParserRuleConfigurationYamlIT.java | 2 +-
...LParserCacheOptionConfigurationSwapperTest.java | 45 -----
.../YamlSQLParserRuleConfigurationSwapperTest.java | 66 -------
.../src/test/resources/yaml/sql-parser-rule.yaml | 4 +-
...amlTransactionRuleConfigurationSwapperTest.java | 50 -----
.../pipeline/cases/PipelineContainerComposer.java | 2 +-
32 files changed, 10 insertions(+), 1925 deletions(-)
diff --git
a/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/yaml/swapper/YamlBroadcastRuleConfigurationSwapperTest.java
b/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/yaml/swapper/YamlBroadcastRuleConfigurationSwapperTest.java
deleted file mode 100644
index 341ce97c1a6..00000000000
---
a/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/yaml/swapper/YamlBroadcastRuleConfigurationSwapperTest.java
+++ /dev/null
@@ -1,49 +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.broadcast.yaml.swapper;
-
-import org.apache.shardingsphere.broadcast.config.BroadcastRuleConfiguration;
-import
org.apache.shardingsphere.broadcast.yaml.config.YamlBroadcastRuleConfiguration;
-import org.junit.jupiter.api.Test;
-
-import java.util.Collections;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class YamlBroadcastRuleConfigurationSwapperTest {
-
- @Test
- void assertSwapToYamlConfiguration() {
- BroadcastRuleConfiguration ruleConfig = new
BroadcastRuleConfiguration(Collections.singleton("t_address"));
- YamlBroadcastRuleConfigurationSwapper swapper = new
YamlBroadcastRuleConfigurationSwapper();
- YamlBroadcastRuleConfiguration yamlRuleConfig =
swapper.swapToYamlConfiguration(ruleConfig);
- assertThat(yamlRuleConfig.getTables().size(), is(1));
- assertThat(yamlRuleConfig.getTables().iterator().next(),
is("t_address"));
- }
-
- @Test
- void assertSwapToObject() {
- YamlBroadcastRuleConfiguration yamlRuleConfig = new
YamlBroadcastRuleConfiguration();
- yamlRuleConfig.getTables().add("t_address");
- YamlBroadcastRuleConfigurationSwapper swapper = new
YamlBroadcastRuleConfigurationSwapper();
- BroadcastRuleConfiguration ruleConfig =
swapper.swapToObject(yamlRuleConfig);
- assertThat(ruleConfig.getTables().size(), is(1));
- assertThat(ruleConfig.getTables().iterator().next(), is("t_address"));
- }
-}
diff --git
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/YamlEncryptRuleConfigurationSwapperTest.java
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/YamlEncryptRuleConfigurationSwapperTest.java
deleted file mode 100644
index 28ee43cddfe..00000000000
---
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/YamlEncryptRuleConfigurationSwapperTest.java
+++ /dev/null
@@ -1,85 +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.encrypt.yaml.swapper;
-
-import org.apache.shardingsphere.encrypt.config.EncryptRuleConfiguration;
-import
org.apache.shardingsphere.encrypt.config.rule.EncryptTableRuleConfiguration;
-import
org.apache.shardingsphere.encrypt.yaml.config.YamlEncryptRuleConfiguration;
-import
org.apache.shardingsphere.encrypt.yaml.config.rule.YamlEncryptTableRuleConfiguration;
-import
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
-import org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPILoader;
-import
org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
-import
org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapper;
-import org.junit.jupiter.api.Test;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Properties;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.mockito.Mockito.mock;
-
-class YamlEncryptRuleConfigurationSwapperTest {
-
- @Test
- void assertSwapToYamlConfiguration() {
- YamlEncryptRuleConfiguration actual =
getSwapper().swapToYamlConfiguration(createEncryptRuleConfiguration());
- assertThat(actual.getTables().size(), is(1));
- assertThat(actual.getTables().get("tbl").getName(), is("tbl"));
- assertTrue(actual.getTables().get("tbl").getColumns().isEmpty());
- assertThat(actual.getEncryptors().size(), is(1));
- assertThat(actual.getEncryptors().get("foo_encryptor").getType(),
is("CORE.FIXTURE"));
- assertThat(actual.getEncryptors().get("foo_encryptor").getProps(),
is(new Properties()));
- }
-
- private EncryptRuleConfiguration createEncryptRuleConfiguration() {
- Collection<EncryptTableRuleConfiguration> tables =
Collections.singleton(new EncryptTableRuleConfiguration("tbl",
Collections.emptyList()));
- Map<String, AlgorithmConfiguration> encryptors =
Collections.singletonMap("foo_encryptor", new
AlgorithmConfiguration("CORE.FIXTURE", new Properties()));
- return new EncryptRuleConfiguration(tables, encryptors);
- }
-
- @Test
- void assertSwapToObject() {
- EncryptRuleConfiguration actual =
getSwapper().swapToObject(createYamlEncryptRuleConfiguration());
- assertThat(actual.getTables().size(), is(1));
- assertThat(actual.getTables().iterator().next().getName(), is("tbl"));
-
assertTrue(actual.getTables().iterator().next().getColumns().isEmpty());
- assertThat(actual.getEncryptors().size(), is(1));
- assertThat(actual.getEncryptors().get("foo_encryptor").getType(),
is("CORE.FIXTURE"));
- assertThat(actual.getEncryptors().get("foo_encryptor").getProps(),
is(new Properties()));
- }
-
- private YamlEncryptRuleConfiguration createYamlEncryptRuleConfiguration() {
- YamlEncryptRuleConfiguration result = new
YamlEncryptRuleConfiguration();
- YamlEncryptTableRuleConfiguration tableRuleConfig = new
YamlEncryptTableRuleConfiguration();
- tableRuleConfig.setName("tbl");
- result.getTables().put("tbl", tableRuleConfig);
- YamlAlgorithmConfiguration algorithmConfig = new
YamlAlgorithmConfiguration();
- algorithmConfig.setType("CORE.FIXTURE");
- result.getEncryptors().put("foo_encryptor", algorithmConfig);
- return result;
- }
-
- private YamlEncryptRuleConfigurationSwapper getSwapper() {
- EncryptRuleConfiguration ruleConfig =
mock(EncryptRuleConfiguration.class);
- return (YamlEncryptRuleConfigurationSwapper)
OrderedSPILoader.getServices(YamlRuleConfigurationSwapper.class,
Collections.singleton(ruleConfig)).get(ruleConfig);
- }
-}
diff --git
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/rule/YamlEncryptColumnRuleConfigurationSwapperTest.java
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/rule/YamlEncryptColumnRuleConfigurationSwapperTest.java
deleted file mode 100644
index 7bafc796957..00000000000
---
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/rule/YamlEncryptColumnRuleConfigurationSwapperTest.java
+++ /dev/null
@@ -1,76 +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.encrypt.yaml.swapper.rule;
-
-import
org.apache.shardingsphere.encrypt.config.rule.EncryptColumnItemRuleConfiguration;
-import
org.apache.shardingsphere.encrypt.config.rule.EncryptColumnRuleConfiguration;
-import
org.apache.shardingsphere.encrypt.yaml.config.rule.YamlEncryptColumnItemRuleConfiguration;
-import
org.apache.shardingsphere.encrypt.yaml.config.rule.YamlEncryptColumnRuleConfiguration;
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-class YamlEncryptColumnRuleConfigurationSwapperTest {
-
- @Test
- void assertSwapToYamlConfiguration() {
- YamlEncryptColumnRuleConfigurationSwapper swapper = new
YamlEncryptColumnRuleConfigurationSwapper();
- EncryptColumnRuleConfiguration encryptColumnRuleConfig = new
EncryptColumnRuleConfiguration("logicColumn", new
EncryptColumnItemRuleConfiguration("cipherColumn", "encryptorName"));
- encryptColumnRuleConfig.setAssistedQuery(new
EncryptColumnItemRuleConfiguration("assistedQueryColumn",
"foo_assist_query_encryptor"));
- encryptColumnRuleConfig.setLikeQuery(new
EncryptColumnItemRuleConfiguration("likeQueryColumn", "foo_like_encryptor"));
- YamlEncryptColumnRuleConfiguration actual =
swapper.swapToYamlConfiguration(encryptColumnRuleConfig);
- assertThat(actual.getName(), is("logicColumn"));
- assertThat(actual.getCipher().getName(), is("cipherColumn"));
- assertThat(actual.getCipher().getEncryptorName(), is("encryptorName"));
- assertThat(actual.getAssistedQuery().getName(),
is("assistedQueryColumn"));
- assertThat(actual.getAssistedQuery().getEncryptorName(),
is("foo_assist_query_encryptor"));
- assertThat(actual.getLikeQuery().getName(), is("likeQueryColumn"));
- assertThat(actual.getLikeQuery().getEncryptorName(),
is("foo_like_encryptor"));
- }
-
- @Test
- void assertSwapToObject() {
- YamlEncryptColumnRuleConfigurationSwapper swapper = new
YamlEncryptColumnRuleConfigurationSwapper();
- EncryptColumnRuleConfiguration actual =
swapper.swapToObject(buildYamlEncryptColumnRuleConfiguration());
- assertThat(actual.getName(), is("logicColumn"));
- assertThat(actual.getCipher().getName(), is("cipherColumn"));
- assertTrue(actual.getAssistedQuery().isPresent());
- assertThat(actual.getAssistedQuery().get().getName(),
is("assistedQueryColumn"));
- assertTrue(actual.getLikeQuery().isPresent());
- assertThat(actual.getLikeQuery().get().getName(),
is("likeQueryColumn"));
- assertThat(actual.getCipher().getEncryptorName(), is("encryptorName"));
- }
-
- private YamlEncryptColumnRuleConfiguration
buildYamlEncryptColumnRuleConfiguration() {
- YamlEncryptColumnRuleConfiguration result = new
YamlEncryptColumnRuleConfiguration();
- result.setName("logicColumn");
- YamlEncryptColumnItemRuleConfiguration cipherColumnConfig = new
YamlEncryptColumnItemRuleConfiguration();
- cipherColumnConfig.setName("cipherColumn");
- cipherColumnConfig.setEncryptorName("encryptorName");
- result.setCipher(cipherColumnConfig);
- YamlEncryptColumnItemRuleConfiguration assistedQueryColumnConfig = new
YamlEncryptColumnItemRuleConfiguration();
- assistedQueryColumnConfig.setName("assistedQueryColumn");
- result.setAssistedQuery(assistedQueryColumnConfig);
- YamlEncryptColumnItemRuleConfiguration likeQueryColumnConfig = new
YamlEncryptColumnItemRuleConfiguration();
- likeQueryColumnConfig.setName("likeQueryColumn");
- result.setLikeQuery(likeQueryColumnConfig);
- return result;
- }
-}
diff --git
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/rule/YamlEncryptTableRuleConfigurationSwapperTest.java
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/rule/YamlEncryptTableRuleConfigurationSwapperTest.java
deleted file mode 100644
index 046d544d334..00000000000
---
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/swapper/rule/YamlEncryptTableRuleConfigurationSwapperTest.java
+++ /dev/null
@@ -1,101 +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.encrypt.yaml.swapper.rule;
-
-import
org.apache.shardingsphere.encrypt.config.rule.EncryptColumnItemRuleConfiguration;
-import
org.apache.shardingsphere.encrypt.config.rule.EncryptColumnRuleConfiguration;
-import
org.apache.shardingsphere.encrypt.config.rule.EncryptTableRuleConfiguration;
-import
org.apache.shardingsphere.encrypt.yaml.config.rule.YamlEncryptColumnItemRuleConfiguration;
-import
org.apache.shardingsphere.encrypt.yaml.config.rule.YamlEncryptColumnRuleConfiguration;
-import
org.apache.shardingsphere.encrypt.yaml.config.rule.YamlEncryptTableRuleConfiguration;
-import org.junit.jupiter.api.Test;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-class YamlEncryptTableRuleConfigurationSwapperTest {
-
- private final YamlEncryptTableRuleConfigurationSwapper swapper = new
YamlEncryptTableRuleConfigurationSwapper();
-
- @Test
- void assertSwapToYamlConfiguration() {
- EncryptColumnRuleConfiguration encryptColumnTwoConfig = new
EncryptColumnRuleConfiguration("encrypt_column_2", new
EncryptColumnItemRuleConfiguration("encrypt_cipher_2", "test_encryptor_2"));
- EncryptColumnRuleConfiguration encryptColumnThreeConfig =
- new EncryptColumnRuleConfiguration("encrypt_column_3", new
EncryptColumnItemRuleConfiguration("encrypt_cipher_3", "test_encryptor_3"));
- Collection<EncryptColumnRuleConfiguration> encryptColumnRuleConfigs =
Arrays.asList(
- new EncryptColumnRuleConfiguration("encrypt_column_1", new
EncryptColumnItemRuleConfiguration("encrypt_cipher_1", "test_encryptor_1")),
- encryptColumnTwoConfig,
- encryptColumnThreeConfig);
- EncryptTableRuleConfiguration encryptTableRuleConfig = new
EncryptTableRuleConfiguration("test_table", encryptColumnRuleConfigs);
- YamlEncryptTableRuleConfiguration actualYamlEncryptTableRuleConfig =
swapper.swapToYamlConfiguration(encryptTableRuleConfig);
- assertThat(actualYamlEncryptTableRuleConfig.getName(),
is("test_table"));
- Map<String, YamlEncryptColumnRuleConfiguration> actualColumns =
actualYamlEncryptTableRuleConfig.getColumns();
- assertThat(actualColumns.size(), is(3));
- YamlEncryptColumnRuleConfiguration
actualYamlEncryptColumnRuleConfigFirst = actualColumns.get("encrypt_column_1");
-
assertThat(actualYamlEncryptColumnRuleConfigFirst.getCipher().getName(),
is("encrypt_cipher_1"));
-
assertThat(actualYamlEncryptColumnRuleConfigFirst.getCipher().getEncryptorName(),
is("test_encryptor_1"));
- YamlEncryptColumnRuleConfiguration
actualYamlEncryptColumnRuleConfigSecond = actualColumns.get("encrypt_column_2");
-
assertThat(actualYamlEncryptColumnRuleConfigSecond.getCipher().getName(),
is("encrypt_cipher_2"));
-
assertThat(actualYamlEncryptColumnRuleConfigSecond.getCipher().getEncryptorName(),
is("test_encryptor_2"));
- YamlEncryptColumnRuleConfiguration
actualYamlEncryptColumnRuleConfigThird = actualColumns.get("encrypt_column_3");
-
assertThat(actualYamlEncryptColumnRuleConfigThird.getCipher().getName(),
is("encrypt_cipher_3"));
-
assertThat(actualYamlEncryptColumnRuleConfigThird.getCipher().getEncryptorName(),
is("test_encryptor_3"));
- }
-
- @Test
- void assertSwapToObject() {
- Map<String, YamlEncryptColumnRuleConfiguration> columns =
Collections.singletonMap("test_column",
buildYamlEncryptColumnRuleConfiguration());
- YamlEncryptTableRuleConfiguration yamlEncryptTableRuleConfig = new
YamlEncryptTableRuleConfiguration();
- yamlEncryptTableRuleConfig.setName("test_table");
- yamlEncryptTableRuleConfig.setColumns(columns);
- EncryptTableRuleConfiguration actualEncryptTableRuleConfig =
swapper.swapToObject(yamlEncryptTableRuleConfig);
- assertThat(actualEncryptTableRuleConfig.getName(), is("test_table"));
- Collection<EncryptColumnRuleConfiguration> actualColumns =
actualEncryptTableRuleConfig.getColumns();
- assertThat(actualColumns.size(), is(1));
- EncryptColumnRuleConfiguration actualEncryptColumnRuleConfig =
actualColumns.iterator().next();
- assertThat(actualEncryptColumnRuleConfig.getName(), is("test_column"));
- assertThat(actualEncryptColumnRuleConfig.getCipher().getName(),
is("encrypt_cipher"));
-
assertThat(actualEncryptColumnRuleConfig.getCipher().getEncryptorName(),
is("test_encryptor"));
-
assertTrue(actualEncryptColumnRuleConfig.getAssistedQuery().isPresent());
-
assertThat(actualEncryptColumnRuleConfig.getAssistedQuery().get().getName(),
is("encrypt_assisted"));
- assertTrue(actualEncryptColumnRuleConfig.getLikeQuery().isPresent());
-
assertThat(actualEncryptColumnRuleConfig.getLikeQuery().get().getName(),
is("encrypt_like"));
- }
-
- private YamlEncryptColumnRuleConfiguration
buildYamlEncryptColumnRuleConfiguration() {
- YamlEncryptColumnRuleConfiguration result = new
YamlEncryptColumnRuleConfiguration();
- result.setName("encrypt_column");
- YamlEncryptColumnItemRuleConfiguration cipherColumnConfig = new
YamlEncryptColumnItemRuleConfiguration();
- cipherColumnConfig.setName("encrypt_cipher");
- cipherColumnConfig.setEncryptorName("test_encryptor");
- result.setCipher(cipherColumnConfig);
- YamlEncryptColumnItemRuleConfiguration assistedQueryColumnConfig = new
YamlEncryptColumnItemRuleConfiguration();
- assistedQueryColumnConfig.setName("encrypt_assisted");
- result.setAssistedQuery(assistedQueryColumnConfig);
- YamlEncryptColumnItemRuleConfiguration likeQueryColumnConfig = new
YamlEncryptColumnItemRuleConfiguration();
- likeQueryColumnConfig.setName("encrypt_like");
- result.setLikeQuery(likeQueryColumnConfig);
- return result;
- }
-}
diff --git
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/yaml/swapper/YamlMaskRuleConfigurationSwapperTest.java
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/yaml/swapper/YamlMaskRuleConfigurationSwapperTest.java
deleted file mode 100644
index 53f476a6a78..00000000000
---
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/yaml/swapper/YamlMaskRuleConfigurationSwapperTest.java
+++ /dev/null
@@ -1,76 +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.mask.yaml.swapper;
-
-import
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
-import org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPILoader;
-import
org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
-import
org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapper;
-import org.apache.shardingsphere.mask.config.MaskRuleConfiguration;
-import org.apache.shardingsphere.mask.config.rule.MaskTableRuleConfiguration;
-import org.apache.shardingsphere.mask.yaml.config.YamlMaskRuleConfiguration;
-import
org.apache.shardingsphere.mask.yaml.config.rule.YamlMaskTableRuleConfiguration;
-import org.junit.jupiter.api.Test;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Properties;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.mockito.Mockito.mock;
-
-class YamlMaskRuleConfigurationSwapperTest {
-
- @Test
- void assertSwapToYamlConfiguration() {
- YamlMaskRuleConfiguration actual =
getSwapper().swapToYamlConfiguration(createMaskRuleConfiguration());
- assertThat(actual.getTables().size(), is(1));
- assertThat(actual.getMaskAlgorithms().size(), is(1));
- }
-
- private MaskRuleConfiguration createMaskRuleConfiguration() {
- Collection<MaskTableRuleConfiguration> tables =
Collections.singleton(new MaskTableRuleConfiguration("tbl",
Collections.emptyList()));
- Map<String, AlgorithmConfiguration> encryptors =
Collections.singletonMap("myMaskAlgorithm", new AlgorithmConfiguration("MD5",
new Properties()));
- return new MaskRuleConfiguration(tables, encryptors);
- }
-
- @Test
- void assertSwapToObject() {
- MaskRuleConfiguration actual =
getSwapper().swapToObject(createYamlMaskRuleConfiguration());
- assertThat(actual.getTables().size(), is(1));
- assertThat(actual.getMaskAlgorithms().size(), is(1));
- }
-
- private YamlMaskRuleConfiguration createYamlMaskRuleConfiguration() {
- YamlMaskRuleConfiguration result = new YamlMaskRuleConfiguration();
- YamlMaskTableRuleConfiguration tableRuleConfig = new
YamlMaskTableRuleConfiguration();
- tableRuleConfig.setName("t_mask");
- result.getTables().put("t_mask", tableRuleConfig);
- YamlAlgorithmConfiguration algorithmConfig = new
YamlAlgorithmConfiguration();
- algorithmConfig.setType("MD5");
- result.getMaskAlgorithms().put("md5_mask", algorithmConfig);
- return result;
- }
-
- private YamlMaskRuleConfigurationSwapper getSwapper() {
- MaskRuleConfiguration ruleConfig = mock(MaskRuleConfiguration.class);
- return (YamlMaskRuleConfigurationSwapper)
OrderedSPILoader.getServices(YamlRuleConfigurationSwapper.class,
Collections.singleton(ruleConfig)).get(ruleConfig);
- }
-}
diff --git
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/yaml/swapper/rule/YamlMaskColumnRuleConfigurationSwapperTest.java
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/yaml/swapper/rule/YamlMaskColumnRuleConfigurationSwapperTest.java
deleted file mode 100644
index 7cca536d10b..00000000000
---
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/yaml/swapper/rule/YamlMaskColumnRuleConfigurationSwapperTest.java
+++ /dev/null
@@ -1,46 +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.mask.yaml.swapper.rule;
-
-import org.apache.shardingsphere.mask.config.rule.MaskColumnRuleConfiguration;
-import
org.apache.shardingsphere.mask.yaml.config.rule.YamlMaskColumnRuleConfiguration;
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class YamlMaskColumnRuleConfigurationSwapperTest {
-
- @Test
- void assertSwapToYamlConfiguration() {
- MaskColumnRuleConfiguration encryptColumnRuleConfig = new
MaskColumnRuleConfiguration("logicColumn", "md5_mask");
- YamlMaskColumnRuleConfiguration actual = new
YamlMaskColumnRuleConfigurationSwapper().swapToYamlConfiguration(encryptColumnRuleConfig);
- assertThat(actual.getLogicColumn(), is("logicColumn"));
- assertThat(actual.getMaskAlgorithm(), is("md5_mask"));
- }
-
- @Test
- void assertSwapToObject() {
- YamlMaskColumnRuleConfiguration yamlMaskColumnRuleConfig = new
YamlMaskColumnRuleConfiguration();
- yamlMaskColumnRuleConfig.setLogicColumn("logicColumn");
- yamlMaskColumnRuleConfig.setMaskAlgorithm("md5_mask");
- MaskColumnRuleConfiguration actual = new
YamlMaskColumnRuleConfigurationSwapper().swapToObject(yamlMaskColumnRuleConfig);
- assertThat(actual.getLogicColumn(), is("logicColumn"));
- assertThat(actual.getMaskAlgorithm(), is("md5_mask"));
- }
-}
diff --git
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/yaml/swapper/rule/YamlMaskTableRuleConfigurationSwapperTest.java
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/yaml/swapper/rule/YamlMaskTableRuleConfigurationSwapperTest.java
deleted file mode 100644
index 813bfe22baf..00000000000
---
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/yaml/swapper/rule/YamlMaskTableRuleConfigurationSwapperTest.java
+++ /dev/null
@@ -1,75 +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.mask.yaml.swapper.rule;
-
-import org.apache.shardingsphere.mask.config.rule.MaskColumnRuleConfiguration;
-import org.apache.shardingsphere.mask.config.rule.MaskTableRuleConfiguration;
-import
org.apache.shardingsphere.mask.yaml.config.rule.YamlMaskColumnRuleConfiguration;
-import
org.apache.shardingsphere.mask.yaml.config.rule.YamlMaskTableRuleConfiguration;
-import org.junit.jupiter.api.Test;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class YamlMaskTableRuleConfigurationSwapperTest {
-
- private final YamlMaskTableRuleConfigurationSwapper swapper = new
YamlMaskTableRuleConfigurationSwapper();
-
- @Test
- void assertSwapToYamlConfiguration() {
- Collection<MaskColumnRuleConfiguration> encryptColumnRuleConfigs =
Arrays.asList(
- new MaskColumnRuleConfiguration("mask_column_1", "md5_mask"),
- new MaskColumnRuleConfiguration("mask_column_2",
"keep_from_x_to_y"),
- new MaskColumnRuleConfiguration("mask_column_3",
"keep_first_m_last_m"));
- MaskTableRuleConfiguration encryptTableRuleConfig = new
MaskTableRuleConfiguration("test_table", encryptColumnRuleConfigs);
- YamlMaskTableRuleConfiguration actualYamlMaskTableRuleConfig =
swapper.swapToYamlConfiguration(encryptTableRuleConfig);
- assertThat(actualYamlMaskTableRuleConfig.getName(), is("test_table"));
- Map<String, YamlMaskColumnRuleConfiguration> actualColumns =
actualYamlMaskTableRuleConfig.getColumns();
- assertThat(actualColumns.size(), is(3));
- YamlMaskColumnRuleConfiguration actualYamlMaskColumnRuleConfigFirst =
actualColumns.get("mask_column_1");
- assertThat(actualYamlMaskColumnRuleConfigFirst.getMaskAlgorithm(),
is("md5_mask"));
- YamlMaskColumnRuleConfiguration actualYamlMaskColumnRuleConfigSecond =
actualColumns.get("mask_column_2");
- assertThat(actualYamlMaskColumnRuleConfigSecond.getMaskAlgorithm(),
is("keep_from_x_to_y"));
- YamlMaskColumnRuleConfiguration actualYamlMaskColumnRuleConfigThird =
actualColumns.get("mask_column_3");
- assertThat(actualYamlMaskColumnRuleConfigThird.getMaskAlgorithm(),
is("keep_first_m_last_m"));
- }
-
- @Test
- void assertSwapToObject() {
- YamlMaskColumnRuleConfiguration encryptColumnRuleConfig = new
YamlMaskColumnRuleConfiguration();
- encryptColumnRuleConfig.setLogicColumn("mask_column");
- encryptColumnRuleConfig.setMaskAlgorithm("md5_mask");
- Map<String, YamlMaskColumnRuleConfiguration> columns = new
LinkedHashMap<>(1);
- columns.put("mask_column", encryptColumnRuleConfig);
- YamlMaskTableRuleConfiguration yamlMaskTableRuleConfig = new
YamlMaskTableRuleConfiguration();
- yamlMaskTableRuleConfig.setName("test_table");
- yamlMaskTableRuleConfig.setColumns(columns);
- MaskTableRuleConfiguration actualMaskTableRuleConfig =
swapper.swapToObject(yamlMaskTableRuleConfig);
- assertThat(actualMaskTableRuleConfig.getName(), is("test_table"));
- Collection<MaskColumnRuleConfiguration> actualColumns =
actualMaskTableRuleConfig.getColumns();
- assertThat(actualColumns.size(), is(1));
- MaskColumnRuleConfiguration actualMaskColumnRuleConfig =
actualColumns.iterator().next();
- assertThat(actualMaskColumnRuleConfig.getLogicColumn(),
is("mask_column"));
- assertThat(actualMaskColumnRuleConfig.getMaskAlgorithm(),
is("md5_mask"));
- }
-}
diff --git
a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/YamlReadwriteSplittingRuleConfigurationSwapperTest.java
b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/YamlReadwriteSplittingRuleConfigurationSwapperTest.java
deleted file mode 100644
index 31e1bb2a101..00000000000
---
a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/yaml/swapper/YamlReadwriteSplittingRuleConfigurationSwapperTest.java
+++ /dev/null
@@ -1,93 +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.yaml.swapper;
-
-import
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
-import
org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
-import
org.apache.shardingsphere.readwritesplitting.config.ReadwriteSplittingRuleConfiguration;
-import
org.apache.shardingsphere.readwritesplitting.config.rule.ReadwriteSplittingDataSourceGroupRuleConfiguration;
-import
org.apache.shardingsphere.readwritesplitting.yaml.config.YamlReadwriteSplittingRuleConfiguration;
-import
org.apache.shardingsphere.readwritesplitting.yaml.config.rule.YamlReadwriteSplittingDataSourceGroupRuleConfiguration;
-import org.junit.jupiter.api.Test;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Properties;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-class YamlReadwriteSplittingRuleConfigurationSwapperTest {
-
- @Test
- void assertSwapToYamlConfiguration() {
- YamlReadwriteSplittingRuleConfiguration actual =
getSwapper().swapToYamlConfiguration(creatReadwriteSplittingRuleConfiguration());
- assertThat(actual.getDataSourceGroups().size(), is(1));
- assertThat(actual.getLoadBalancers().size(), is(1));
- assertReadwriteSplittingRule(actual);
- }
-
- void assertReadwriteSplittingRule(final
YamlReadwriteSplittingRuleConfiguration actual) {
- assertNotNull(actual.getDataSourceGroups().get("readwrite"));
- YamlReadwriteSplittingDataSourceGroupRuleConfiguration config =
actual.getDataSourceGroups().get("readwrite");
- assertThat(config.getWriteDataSourceName(), is("write_ds"));
-
assertThat(actual.getDataSourceGroups().get("readwrite").getLoadBalancerName(),
is("random"));
- }
-
- void assertReadwriteSplittingRule(final
ReadwriteSplittingRuleConfiguration actual) {
- ReadwriteSplittingDataSourceGroupRuleConfiguration config =
actual.getDataSourceGroups().iterator().next();
- assertThat(config.getName(), is("t_readwrite"));
- assertThat(config.getWriteDataSourceName(), is("write_ds"));
- assertThat(config.getLoadBalancerName(), is("random"));
- }
-
- private ReadwriteSplittingRuleConfiguration
creatReadwriteSplittingRuleConfiguration() {
- Collection<ReadwriteSplittingDataSourceGroupRuleConfiguration>
dataSourceGroupConfigs = Collections.singleton(
- new
ReadwriteSplittingDataSourceGroupRuleConfiguration("readwrite", "write_ds",
Arrays.asList("read_ds_0", "read_ds_1"), "random"));
- Map<String, AlgorithmConfiguration> loadBalancers =
Collections.singletonMap("myLoadBalancer", new AlgorithmConfiguration("RANDOM",
new Properties()));
- return new ReadwriteSplittingRuleConfiguration(dataSourceGroupConfigs,
loadBalancers);
- }
-
- @Test
- void assertSwapToObject() {
- ReadwriteSplittingRuleConfiguration actual =
getSwapper().swapToObject(createYamlReadwriteSplittingRuleConfiguration());
- assertThat(actual.getDataSourceGroups().size(), is(1));
- assertThat(actual.getLoadBalancers().size(), is(1));
- assertReadwriteSplittingRule(actual);
- }
-
- private YamlReadwriteSplittingRuleConfiguration
createYamlReadwriteSplittingRuleConfiguration() {
- YamlReadwriteSplittingDataSourceGroupRuleConfiguration
dataSourceGroupRuleConfig = new
YamlReadwriteSplittingDataSourceGroupRuleConfiguration();
-
dataSourceGroupRuleConfig.setReadDataSourceNames(Arrays.asList("read_ds_0",
"read_ds_1"));
- dataSourceGroupRuleConfig.setWriteDataSourceName("write_ds");
- dataSourceGroupRuleConfig.setLoadBalancerName("random");
- YamlReadwriteSplittingRuleConfiguration result = new
YamlReadwriteSplittingRuleConfiguration();
- result.getDataSourceGroups().put("t_readwrite",
dataSourceGroupRuleConfig);
- YamlAlgorithmConfiguration algorithmConfig = new
YamlAlgorithmConfiguration();
- algorithmConfig.setType("RANDOM");
- result.getLoadBalancers().put("random_loadbalancer", algorithmConfig);
- return result;
- }
-
- private YamlReadwriteSplittingRuleConfigurationSwapper getSwapper() {
- return new YamlReadwriteSplittingRuleConfigurationSwapper();
- }
-}
diff --git
a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/yaml/swapper/YamlShadowRuleConfigurationSwapperTest.java
b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/yaml/swapper/YamlShadowRuleConfigurationSwapperTest.java
deleted file mode 100644
index 54876cffd5a..00000000000
---
a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/yaml/swapper/YamlShadowRuleConfigurationSwapperTest.java
+++ /dev/null
@@ -1,124 +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.yaml.swapper;
-
-import
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
-import
org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
-import org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPILoader;
-import
org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapper;
-import org.apache.shardingsphere.shadow.config.ShadowRuleConfiguration;
-import
org.apache.shardingsphere.shadow.config.datasource.ShadowDataSourceConfiguration;
-import org.apache.shardingsphere.shadow.config.table.ShadowTableConfiguration;
-import
org.apache.shardingsphere.shadow.yaml.config.YamlShadowRuleConfiguration;
-import
org.apache.shardingsphere.shadow.yaml.config.datasource.YamlShadowDataSourceConfiguration;
-import
org.apache.shardingsphere.shadow.yaml.config.table.YamlShadowTableConfiguration;
-import org.junit.jupiter.api.Test;
-
-import java.util.Collections;
-import java.util.Properties;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.mockito.Mockito.mock;
-
-class YamlShadowRuleConfigurationSwapperTest {
-
- @Test
- void assertSwapToYamlConfiguration() {
- YamlShadowRuleConfiguration actual =
getSwapper().swapToYamlConfiguration(createShadowRuleConfiguration());
- assertThat(actual.getDataSources().size(), is(1));
-
assertThat(actual.getDataSources().get("foo_ds").getProductionDataSourceName(),
is("prod_ds"));
-
assertThat(actual.getDataSources().get("foo_ds").getShadowDataSourceName(),
is("shadow_ds"));
- assertThat(actual.getTables().size(), is(1));
- assertThat(actual.getTables().get("tbl").getDataSourceNames(),
is(Collections.singletonList("ds")));
- assertThat(actual.getTables().get("tbl").getShadowAlgorithmNames(),
is(Collections.singletonList("shadow_algo")));
- assertThat(actual.getShadowAlgorithms().size(), is(1));
- assertThat(actual.getShadowAlgorithms().get("shadow_algo").getType(),
is("FIXTURE"));
- assertThat(actual.getShadowAlgorithms().get("shadow_algo").getProps(),
is(new Properties()));
- assertThat(actual.getDefaultShadowAlgorithmName(),
is("default_shadow_algorithm_name"));
- }
-
- private ShadowRuleConfiguration createShadowRuleConfiguration() {
- ShadowRuleConfiguration result = new ShadowRuleConfiguration();
- result.getDataSources().add(new
ShadowDataSourceConfiguration("foo_ds", "prod_ds", "shadow_ds"));
- result.getTables().put("tbl", new
ShadowTableConfiguration(Collections.singleton("ds"),
Collections.singleton("shadow_algo")));
- result.getShadowAlgorithms().put("shadow_algo", new
AlgorithmConfiguration("FIXTURE", new Properties()));
- result.setDefaultShadowAlgorithmName("default_shadow_algorithm_name");
- return result;
- }
-
- @Test
- void assertSwapToObject() {
- ShadowRuleConfiguration actual =
getSwapper().swapToObject(createYamlShadowRuleConfiguration());
- assertThat(actual.getDataSources().size(), is(1));
-
assertShadowDataSourceConfiguration(actual.getDataSources().iterator().next());
- assertThat(actual.getTables().size(), is(1));
- assertShadowTableConfiguration(actual.getTables().get("tbl"));
-
assertAlgorithmConfiguration(actual.getShadowAlgorithms().get("shadow_algo"));
- }
-
- private YamlShadowRuleConfiguration createYamlShadowRuleConfiguration() {
- YamlShadowRuleConfiguration result = new YamlShadowRuleConfiguration();
- result.getDataSources().put("foo_ds",
createYamlShadowDataSourceConfiguration());
- result.getTables().put("tbl", createYamlShadowTableConfiguration());
- result.getShadowAlgorithms().put("shadow_algo",
getYamlAlgorithmConfiguration());
- result.setDefaultShadowAlgorithmName("default_shadow_algorithm_name");
- return result;
- }
-
- private YamlShadowDataSourceConfiguration
createYamlShadowDataSourceConfiguration() {
- YamlShadowDataSourceConfiguration result = new
YamlShadowDataSourceConfiguration();
- result.setProductionDataSourceName("prod_ds");
- result.setShadowDataSourceName("shadow_ds");
- return result;
- }
-
- private YamlShadowTableConfiguration createYamlShadowTableConfiguration() {
- YamlShadowTableConfiguration result = new
YamlShadowTableConfiguration();
- result.setDataSourceNames(Collections.singleton("ds"));
- result.setShadowAlgorithmNames(Collections.singleton("shadow_algo"));
- return result;
- }
-
- private YamlAlgorithmConfiguration getYamlAlgorithmConfiguration() {
- YamlAlgorithmConfiguration result = new YamlAlgorithmConfiguration();
- result.setType("FIXTURE");
- return result;
- }
-
- private void assertShadowDataSourceConfiguration(final
ShadowDataSourceConfiguration actual) {
- assertThat(actual.getName(), is("foo_ds"));
- assertThat(actual.getProductionDataSourceName(), is("prod_ds"));
- assertThat(actual.getShadowDataSourceName(), is("shadow_ds"));
- }
-
- private void assertShadowTableConfiguration(final ShadowTableConfiguration
actual) {
- assertThat(actual.getDataSourceNames(),
is(Collections.singleton("ds")));
- assertThat(actual.getShadowAlgorithmNames(),
is(Collections.singletonList("shadow_algo")));
- }
-
- private void assertAlgorithmConfiguration(final AlgorithmConfiguration
actual) {
- assertThat(actual.getType(), is("FIXTURE"));
- assertThat(actual.getProps(), is(new Properties()));
- }
-
- private YamlShadowRuleConfigurationSwapper getSwapper() {
- ShadowRuleConfiguration ruleConfig =
mock(ShadowRuleConfiguration.class);
- return (YamlShadowRuleConfigurationSwapper)
OrderedSPILoader.getServices(YamlRuleConfigurationSwapper.class,
Collections.singleton(ruleConfig)).get(ruleConfig);
- }
-}
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/YamlShardingRuleConfigurationSwapperTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/YamlShardingRuleConfigurationSwapperTest.java
deleted file mode 100644
index 2130a9a29cd..00000000000
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/YamlShardingRuleConfigurationSwapperTest.java
+++ /dev/null
@@ -1,207 +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.sharding.yaml.swapper;
-
-import
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
-import
org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
-import org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPILoader;
-import
org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapper;
-import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
-import
org.apache.shardingsphere.sharding.api.config.cache.ShardingCacheConfiguration;
-import
org.apache.shardingsphere.sharding.api.config.cache.ShardingCacheOptionsConfiguration;
-import
org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
-import
org.apache.shardingsphere.sharding.api.config.rule.ShardingTableReferenceRuleConfiguration;
-import
org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
-import
org.apache.shardingsphere.sharding.api.config.strategy.audit.ShardingAuditStrategyConfiguration;
-import
org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
-import
org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
-import
org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration;
-import
org.apache.shardingsphere.sharding.yaml.config.cache.YamlShardingCacheConfiguration;
-import
org.apache.shardingsphere.sharding.yaml.config.cache.YamlShardingCacheOptionsConfiguration;
-import
org.apache.shardingsphere.sharding.yaml.config.rule.YamlShardingAutoTableRuleConfiguration;
-import
org.apache.shardingsphere.sharding.yaml.config.rule.YamlTableRuleConfiguration;
-import
org.apache.shardingsphere.sharding.yaml.config.strategy.audit.YamlShardingAuditStrategyConfiguration;
-import
org.apache.shardingsphere.sharding.yaml.config.strategy.keygen.YamlKeyGenerateStrategyConfiguration;
-import
org.apache.shardingsphere.sharding.yaml.config.strategy.sharding.YamlShardingStrategyConfiguration;
-import
org.apache.shardingsphere.sharding.yaml.config.strategy.sharding.YamlStandardShardingStrategyConfiguration;
-import org.apache.shardingsphere.test.util.PropertiesBuilder;
-import org.junit.jupiter.api.Test;
-
-import java.util.Collections;
-import java.util.Properties;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.mockito.Mockito.mock;
-
-class YamlShardingRuleConfigurationSwapperTest {
-
- @Test
- void assertSwapToYamlConfiguration() {
- YamlShardingRuleConfiguration actual =
getSwapper().swapToYamlConfiguration(createMaximumShardingRuleConfiguration());
- assertThat(actual.getTables().size(), is(2));
- assertThat(actual.getAutoTables().size(), is(1));
- assertThat(actual.getBindingTables().size(), is(1));
- assertYamlStrategies(actual);
- assertYamlAlgorithms(actual);
- assertThat(actual.getDefaultShardingColumn(), is("table_id"));
- assertThat(actual.getShardingCache().getAllowedMaxSqlLength(),
is(100));
- }
-
- private void assertYamlStrategies(final YamlShardingRuleConfiguration
actual) {
- assertThat(actual.getDefaultDatabaseStrategy().getStandard(),
instanceOf(YamlStandardShardingStrategyConfiguration.class));
- assertThat(actual.getDefaultTableStrategy().getStandard(),
instanceOf(YamlStandardShardingStrategyConfiguration.class));
- assertThat(actual.getDefaultKeyGenerateStrategy().getColumn(),
is("id"));
- assertThat(actual.getDefaultAuditStrategy().getAuditorNames(),
is(Collections.singletonList("audit_algorithm")));
- }
-
- private void assertYamlAlgorithms(final YamlShardingRuleConfiguration
actual) {
- assertThat(actual.getShardingAlgorithms().size(), is(2));
- assertThat(actual.getKeyGenerators().size(), is(3));
- assertThat(actual.getAuditors().size(), is(1));
- }
-
- private ShardingRuleConfiguration createMaximumShardingRuleConfiguration()
{
- ShardingRuleConfiguration result = new ShardingRuleConfiguration();
- ShardingTableRuleConfiguration shardingTableRuleConfig =
createTableRuleConfiguration("logic_table", "ds_${0..1}.table_${0..2}");
- shardingTableRuleConfig.setKeyGenerateStrategy(new
KeyGenerateStrategyConfiguration("id", "uuid"));
- shardingTableRuleConfig.setAuditStrategy(new
ShardingAuditStrategyConfiguration(Collections.singleton("audit_algorithm"),
false));
- result.getTables().add(shardingTableRuleConfig);
- ShardingTableRuleConfiguration subTableRuleConfig =
createTableRuleConfiguration("sub_logic_table", "ds_${0..1}.sub_table_${0..2}");
- subTableRuleConfig.setKeyGenerateStrategy(new
KeyGenerateStrategyConfiguration("id", "auto_increment"));
- result.getTables().add(subTableRuleConfig);
- ShardingAutoTableRuleConfiguration autoTableRuleConfig = new
ShardingAutoTableRuleConfiguration("auto_table", "ds_1,ds_2");
- autoTableRuleConfig.setShardingStrategy(new
StandardShardingStrategyConfiguration("user_id", "hash_mod"));
- autoTableRuleConfig.setKeyGenerateStrategy(new
KeyGenerateStrategyConfiguration("id", "auto_increment"));
- autoTableRuleConfig.setAuditStrategy(new
ShardingAuditStrategyConfiguration(Collections.singleton("audit_algorithm"),
true));
- result.getAutoTables().add(autoTableRuleConfig);
- result.getBindingTableGroups().add(new
ShardingTableReferenceRuleConfiguration("foo",
shardingTableRuleConfig.getLogicTable() + "," +
subTableRuleConfig.getLogicTable()));
- result.setDefaultDatabaseShardingStrategy(new
StandardShardingStrategyConfiguration("ds_id", "standard"));
- result.setDefaultTableShardingStrategy(new
StandardShardingStrategyConfiguration("table_id", "standard"));
- result.setDefaultShardingColumn("table_id");
- result.setDefaultKeyGenerateStrategy(new
KeyGenerateStrategyConfiguration("id", "default"));
- result.setDefaultAuditStrategy(new
ShardingAuditStrategyConfiguration(Collections.singletonList("audit_algorithm"),
false));
- result.getShardingAlgorithms().put("core_standard_fixture", new
AlgorithmConfiguration("CORE.STANDARD.FIXTURE", new Properties()));
- result.getShardingAlgorithms().put("hash_mod", new
AlgorithmConfiguration("hash_mod", PropertiesBuilder.build(new
PropertiesBuilder.Property("sharding-count", "4"))));
- result.getKeyGenerators().put("uuid", new
AlgorithmConfiguration("UUID", new Properties()));
- result.getKeyGenerators().put("default", new
AlgorithmConfiguration("UUID", new Properties()));
- result.getKeyGenerators().put("auto_increment", new
AlgorithmConfiguration("AUTO_INCREMENT.FIXTURE", new Properties()));
- result.getAuditors().put("audit_algorithm", new
AlgorithmConfiguration("DML_SHARDING_CONDITIONS", new Properties()));
- result.setShardingCache(new ShardingCacheConfiguration(100, new
ShardingCacheOptionsConfiguration(true, 0, 0)));
- return result;
- }
-
- private ShardingTableRuleConfiguration createTableRuleConfiguration(final
String logicTableName, final String actualDataNodes) {
- ShardingTableRuleConfiguration result = new
ShardingTableRuleConfiguration(logicTableName, actualDataNodes);
- result.setDatabaseShardingStrategy(new
StandardShardingStrategyConfiguration("user_id", "database_inline"));
- result.setTableShardingStrategy(new
StandardShardingStrategyConfiguration("order_id", "table_inline"));
- return result;
- }
-
- @Test
- void assertSwapToObject() {
- ShardingRuleConfiguration actual =
getSwapper().swapToObject(createYamlShardingRuleConfiguration());
- assertThat(actual.getTables().size(), is(1));
- assertThat(actual.getAutoTables().size(), is(1));
- assertThat(actual.getBindingTableGroups().size(), is(1));
- assertStrategies(actual);
- assertAlgorithms(actual);
- assertThat(actual.getDefaultShardingColumn(), is("table_id"));
- assertThat(actual.getShardingCache().getAllowedMaxSqlLength(),
is(100));
- }
-
- private void assertStrategies(final ShardingRuleConfiguration actual) {
- assertThat(actual.getDefaultDatabaseShardingStrategy(),
instanceOf(StandardShardingStrategyConfiguration.class));
- assertThat(actual.getDefaultTableShardingStrategy(),
instanceOf(StandardShardingStrategyConfiguration.class));
- assertThat(actual.getDefaultKeyGenerateStrategy().getColumn(),
is("id"));
- assertThat(actual.getDefaultAuditStrategy().getAuditorNames(),
is(Collections.singletonList("audit_algorithm")));
- }
-
- private void assertAlgorithms(final ShardingRuleConfiguration actual) {
- assertThat(actual.getShardingAlgorithms().size(), is(1));
- assertThat(actual.getKeyGenerators().size(), is(1));
- assertThat(actual.getAuditors().size(), is(1));
- }
-
- private YamlShardingRuleConfiguration
createYamlShardingRuleConfiguration() {
- YamlShardingRuleConfiguration result = new
YamlShardingRuleConfiguration();
- YamlTableRuleConfiguration tableRuleConfig = new
YamlTableRuleConfiguration();
- tableRuleConfig.setActualDataNodes("ds_${0..1}.table_${0..2}");
- result.getTables().put("logic_table", tableRuleConfig);
- YamlShardingAutoTableRuleConfiguration autoTableRuleConfig = new
YamlShardingAutoTableRuleConfiguration();
- autoTableRuleConfig.setActualDataSources("ds_1,ds_2");
- result.getAutoTables().put("auto_table", autoTableRuleConfig);
- result.getBindingTables().add("foo:logic_table");
-
result.setDefaultDatabaseStrategy(createYamlShardingStrategyConfig("ds_id"));
-
result.setDefaultTableStrategy(createYamlShardingStrategyConfig("table_id"));
-
result.setDefaultKeyGenerateStrategy(createYamlKeyGenerateStrategyConfig());
- result.setDefaultAuditStrategy(createYamlAuditStrategyConfig());
- result.getShardingAlgorithms().put("core_standard_fixture",
createYamlAlgorithmConfig("CORE.STANDARD.FIXTURE"));
- result.getKeyGenerators().put("default",
createYamlAlgorithmConfig("UUID"));
- result.getAuditors().put("audit_algorithm",
createYamlAlgorithmConfig("DML_SHARDING_CONDITIONS"));
- result.setDefaultShardingColumn("table_id");
- result.setShardingCache(createYamlCacheConfig());
- return result;
- }
-
- private YamlShardingStrategyConfiguration
createYamlShardingStrategyConfig(final String column) {
- YamlStandardShardingStrategyConfiguration
yamlStandardShardingStrategyConfiguration = new
YamlStandardShardingStrategyConfiguration();
- yamlStandardShardingStrategyConfiguration.setShardingColumn(column);
-
yamlStandardShardingStrategyConfiguration.setShardingAlgorithmName("standard");
- YamlShardingStrategyConfiguration yamlShardingStrategyConfiguration =
new YamlShardingStrategyConfiguration();
-
yamlShardingStrategyConfiguration.setStandard(yamlStandardShardingStrategyConfiguration);
- return yamlShardingStrategyConfiguration;
- }
-
- private YamlKeyGenerateStrategyConfiguration
createYamlKeyGenerateStrategyConfig() {
- YamlKeyGenerateStrategyConfiguration
yamlKeyGenerateStrategyConfiguration = new
YamlKeyGenerateStrategyConfiguration();
- yamlKeyGenerateStrategyConfiguration.setColumn("id");
- yamlKeyGenerateStrategyConfiguration.setKeyGeneratorName("default");
- return yamlKeyGenerateStrategyConfiguration;
- }
-
- private YamlShardingAuditStrategyConfiguration
createYamlAuditStrategyConfig() {
- YamlShardingAuditStrategyConfiguration
yamlShardingAuditStrategyConfiguration = new
YamlShardingAuditStrategyConfiguration();
-
yamlShardingAuditStrategyConfiguration.setAuditorNames(Collections.singletonList("audit_algorithm"));
- yamlShardingAuditStrategyConfiguration.setAllowHintDisable(false);
- return yamlShardingAuditStrategyConfiguration;
- }
-
- private YamlAlgorithmConfiguration createYamlAlgorithmConfig(final String
type) {
- YamlAlgorithmConfiguration algorithmConfig = new
YamlAlgorithmConfiguration();
- algorithmConfig.setType(type);
- return algorithmConfig;
- }
-
- private YamlShardingCacheConfiguration createYamlCacheConfig() {
- YamlShardingCacheConfiguration yamlShardingCacheConfiguration = new
YamlShardingCacheConfiguration();
- yamlShardingCacheConfiguration.setAllowedMaxSqlLength(100);
- YamlShardingCacheOptionsConfiguration
yamlShardingCacheOptionsConfiguration = new
YamlShardingCacheOptionsConfiguration();
- yamlShardingCacheOptionsConfiguration.setSoftValues(true);
- yamlShardingCacheOptionsConfiguration.setMaximumSize(0);
- yamlShardingCacheOptionsConfiguration.setInitialCapacity(0);
-
yamlShardingCacheConfiguration.setRouteCache(yamlShardingCacheOptionsConfiguration);
- return yamlShardingCacheConfiguration;
- }
-
- private YamlShardingRuleConfigurationSwapper getSwapper() {
- ShardingRuleConfiguration ruleConfig =
mock(ShardingRuleConfiguration.class);
- return (YamlShardingRuleConfigurationSwapper)
OrderedSPILoader.getServices(YamlRuleConfigurationSwapper.class,
Collections.singleton(ruleConfig)).get(ruleConfig);
- }
-}
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/cache/YamlShardingCacheConfigurationSwapperTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/cache/YamlShardingCacheConfigurationSwapperTest.java
deleted file mode 100644
index 239559f46ee..00000000000
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/cache/YamlShardingCacheConfigurationSwapperTest.java
+++ /dev/null
@@ -1,59 +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.sharding.yaml.swapper.cache;
-
-import
org.apache.shardingsphere.sharding.api.config.cache.ShardingCacheOptionsConfiguration;
-import
org.apache.shardingsphere.sharding.api.config.cache.ShardingCacheConfiguration;
-import
org.apache.shardingsphere.sharding.yaml.config.cache.YamlShardingCacheOptionsConfiguration;
-import
org.apache.shardingsphere.sharding.yaml.config.cache.YamlShardingCacheConfiguration;
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-class YamlShardingCacheConfigurationSwapperTest {
-
- @Test
- void assertSwapToYamlConfiguration() {
- YamlShardingCacheConfiguration actual = new
YamlShardingCacheConfigurationSwapper()
- .swapToYamlConfiguration(new ShardingCacheConfiguration(100,
new ShardingCacheOptionsConfiguration(true, 128, 1024)));
- assertThat(actual.getAllowedMaxSqlLength(), is(100));
- YamlShardingCacheOptionsConfiguration actualRouteCache =
actual.getRouteCache();
- assertTrue(actualRouteCache.isSoftValues());
- assertThat(actualRouteCache.getInitialCapacity(), is(128));
- assertThat(actualRouteCache.getMaximumSize(), is(1024));
- }
-
- @Test
- void assertSwapToObject() {
- YamlShardingCacheConfiguration input = new
YamlShardingCacheConfiguration();
- input.setAllowedMaxSqlLength(200);
- YamlShardingCacheOptionsConfiguration yamlConfig = new
YamlShardingCacheOptionsConfiguration();
- yamlConfig.setSoftValues(true);
- yamlConfig.setInitialCapacity(256);
- yamlConfig.setMaximumSize(4096);
- input.setRouteCache(yamlConfig);
- ShardingCacheConfiguration actual = new
YamlShardingCacheConfigurationSwapper().swapToObject(input);
- assertThat(actual.getAllowedMaxSqlLength(), is(200));
- ShardingCacheOptionsConfiguration actualOptions =
actual.getRouteCache();
- assertTrue(actualOptions.isSoftValues());
- assertThat(actualOptions.getInitialCapacity(), is(256));
- assertThat(actualOptions.getMaximumSize(), is(4096));
- }
-}
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/cache/YamlShardingCacheOptionsConfigurationSwapperTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/cache/YamlShardingCacheOptionsConfigurationSwapperTest.java
deleted file mode 100644
index 1402dda5b56..00000000000
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/cache/YamlShardingCacheOptionsConfigurationSwapperTest.java
+++ /dev/null
@@ -1,49 +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.sharding.yaml.swapper.cache;
-
-import
org.apache.shardingsphere.sharding.api.config.cache.ShardingCacheOptionsConfiguration;
-import
org.apache.shardingsphere.sharding.yaml.config.cache.YamlShardingCacheOptionsConfiguration;
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-class YamlShardingCacheOptionsConfigurationSwapperTest {
-
- @Test
- void assertSwapToYamlConfiguration() {
- YamlShardingCacheOptionsConfiguration actual = new
YamlShardingCacheOptionsConfigurationSwapper().swapToYamlConfiguration(new
ShardingCacheOptionsConfiguration(true, 128, 1024));
- assertTrue(actual.isSoftValues());
- assertThat(actual.getInitialCapacity(), is(128));
- assertThat(actual.getMaximumSize(), is(1024));
- }
-
- @Test
- void assertSwapToObject() {
- YamlShardingCacheOptionsConfiguration input = new
YamlShardingCacheOptionsConfiguration();
- input.setSoftValues(true);
- input.setInitialCapacity(256);
- input.setMaximumSize(4096);
- ShardingCacheOptionsConfiguration actual = new
YamlShardingCacheOptionsConfigurationSwapper().swapToObject(input);
- assertTrue(actual.isSoftValues());
- assertThat(actual.getInitialCapacity(), is(256));
- assertThat(actual.getMaximumSize(), is(4096));
- }
-}
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/rule/YamlShardingAutoTableRuleConfigurationSwapperTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/rule/YamlShardingAutoTableRuleConfigurationSwapperTest.java
deleted file mode 100644
index 51e42e15b12..00000000000
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/rule/YamlShardingAutoTableRuleConfigurationSwapperTest.java
+++ /dev/null
@@ -1,96 +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.sharding.yaml.swapper.rule;
-
-import
org.apache.shardingsphere.sharding.api.config.rule.ShardingAutoTableRuleConfiguration;
-import
org.apache.shardingsphere.sharding.api.config.strategy.audit.ShardingAuditStrategyConfiguration;
-import
org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
-import
org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
-import
org.apache.shardingsphere.sharding.yaml.config.rule.YamlShardingAutoTableRuleConfiguration;
-import
org.apache.shardingsphere.sharding.yaml.config.strategy.audit.YamlShardingAuditStrategyConfiguration;
-import
org.apache.shardingsphere.sharding.yaml.config.strategy.keygen.YamlKeyGenerateStrategyConfiguration;
-import
org.apache.shardingsphere.sharding.yaml.config.strategy.sharding.YamlShardingStrategyConfiguration;
-import
org.apache.shardingsphere.sharding.yaml.config.strategy.sharding.YamlStandardShardingStrategyConfiguration;
-import org.junit.jupiter.api.Test;
-
-import java.util.Collections;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class YamlShardingAutoTableRuleConfigurationSwapperTest {
-
- @Test
- void assertSwapToYamlConfiguration() {
- YamlShardingAutoTableRuleConfigurationSwapper swapper = new
YamlShardingAutoTableRuleConfigurationSwapper();
- YamlShardingAutoTableRuleConfiguration actual =
swapper.swapToYamlConfiguration(createShardingAutoTableRuleConfiguration());
-
assertThat(actual.getShardingStrategy().getStandard().getShardingAlgorithmName(),
is("hash_mod"));
- assertThat(actual.getKeyGenerateStrategy().getKeyGeneratorName(),
is("auto_increment"));
- assertThat(actual.getAuditStrategy().getAuditorNames(),
is(Collections.singletonList("audit_algorithm")));
- }
-
- private ShardingAutoTableRuleConfiguration
createShardingAutoTableRuleConfiguration() {
- ShardingAutoTableRuleConfiguration result = new
ShardingAutoTableRuleConfiguration("auto_table", "ds_1,ds_2");
- result.setShardingStrategy(new
StandardShardingStrategyConfiguration("user_id", "hash_mod"));
- result.setKeyGenerateStrategy(new
KeyGenerateStrategyConfiguration("id", "auto_increment"));
- result.setAuditStrategy(new
ShardingAuditStrategyConfiguration(Collections.singletonList("audit_algorithm"),
true));
- return result;
- }
-
- @Test
- void assertSwapToObject() {
- YamlShardingAutoTableRuleConfigurationSwapper swapper = new
YamlShardingAutoTableRuleConfigurationSwapper();
- ShardingAutoTableRuleConfiguration actual =
swapper.swapToObject(createYamlShardingAutoTableRuleConfiguration());
- assertThat(actual.getShardingStrategy().getShardingAlgorithmName(),
is("hash_mod"));
- assertThat(actual.getKeyGenerateStrategy().getKeyGeneratorName(),
is("auto_increment"));
- assertThat(actual.getAuditStrategy().getAuditorNames(),
is(Collections.singletonList("audit_algorithm")));
- }
-
- private YamlShardingAutoTableRuleConfiguration
createYamlShardingAutoTableRuleConfiguration() {
- YamlShardingAutoTableRuleConfiguration result = new
YamlShardingAutoTableRuleConfiguration();
- result.setLogicTable("auto_table");
- result.setActualDataSources("ds_1,ds_2");
- result.setShardingStrategy(createYamlShardingStrategyConfiguration());
-
result.setKeyGenerateStrategy(createYamlKeyGenerateStrategyConfiguration());
-
result.setAuditStrategy(createYamlShardingAuditStrategyConfiguration());
- return result;
- }
-
- private YamlShardingStrategyConfiguration
createYamlShardingStrategyConfiguration() {
- YamlShardingStrategyConfiguration result = new
YamlShardingStrategyConfiguration();
- YamlStandardShardingStrategyConfiguration
yamlStandardShardingStrategyConfig = new
YamlStandardShardingStrategyConfiguration();
- yamlStandardShardingStrategyConfig.setShardingColumn("user_id");
-
yamlStandardShardingStrategyConfig.setShardingAlgorithmName("hash_mod");
- result.setStandard(yamlStandardShardingStrategyConfig);
- return result;
- }
-
- private YamlKeyGenerateStrategyConfiguration
createYamlKeyGenerateStrategyConfiguration() {
- YamlKeyGenerateStrategyConfiguration result = new
YamlKeyGenerateStrategyConfiguration();
- result.setColumn("id");
- result.setKeyGeneratorName("auto_increment");
- return result;
- }
-
- private YamlShardingAuditStrategyConfiguration
createYamlShardingAuditStrategyConfiguration() {
- YamlShardingAuditStrategyConfiguration result = new
YamlShardingAuditStrategyConfiguration();
- result.setAuditorNames(Collections.singletonList("audit_algorithm"));
- result.setAllowHintDisable(true);
- return result;
- }
-}
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/rule/YamlShardingTableRuleConfigurationSwapperTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/rule/YamlShardingTableRuleConfigurationSwapperTest.java
deleted file mode 100644
index 77bd7380443..00000000000
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/rule/YamlShardingTableRuleConfigurationSwapperTest.java
+++ /dev/null
@@ -1,108 +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.sharding.yaml.swapper.rule;
-
-import
org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
-import
org.apache.shardingsphere.sharding.api.config.strategy.audit.ShardingAuditStrategyConfiguration;
-import
org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
-import
org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
-import
org.apache.shardingsphere.sharding.exception.metadata.MissingRequiredShardingConfigurationException;
-import
org.apache.shardingsphere.sharding.yaml.config.rule.YamlTableRuleConfiguration;
-import
org.apache.shardingsphere.sharding.yaml.config.strategy.audit.YamlShardingAuditStrategyConfiguration;
-import
org.apache.shardingsphere.sharding.yaml.config.strategy.keygen.YamlKeyGenerateStrategyConfiguration;
-import
org.apache.shardingsphere.sharding.yaml.config.strategy.sharding.YamlShardingStrategyConfiguration;
-import
org.apache.shardingsphere.sharding.yaml.config.strategy.sharding.YamlStandardShardingStrategyConfiguration;
-import org.junit.jupiter.api.Test;
-
-import java.util.Collections;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
-class YamlShardingTableRuleConfigurationSwapperTest {
-
- @Test
- void assertSwapToYamlConfiguration() {
- YamlShardingTableRuleConfigurationSwapper swapper = new
YamlShardingTableRuleConfigurationSwapper();
- YamlTableRuleConfiguration actual =
swapper.swapToYamlConfiguration(createShardingTableRuleConfiguration());
-
assertThat(actual.getDatabaseStrategy().getStandard().getShardingAlgorithmName(),
is("standard"));
-
assertThat(actual.getTableStrategy().getStandard().getShardingAlgorithmName(),
is("standard"));
- assertThat(actual.getKeyGenerateStrategy().getKeyGeneratorName(),
is("auto_increment"));
- assertThat(actual.getAuditStrategy().getAuditorNames(),
is(Collections.singletonList("audit_algorithm")));
- }
-
- private ShardingTableRuleConfiguration
createShardingTableRuleConfiguration() {
- ShardingTableRuleConfiguration result = new
ShardingTableRuleConfiguration("logic_table", "ds_${0..1}.table_${0..2}");
- result.setDatabaseShardingStrategy(new
StandardShardingStrategyConfiguration("ds_id", "standard"));
- result.setTableShardingStrategy(new
StandardShardingStrategyConfiguration("table_id", "standard"));
- result.setKeyGenerateStrategy(new
KeyGenerateStrategyConfiguration("id", "auto_increment"));
- result.setAuditStrategy(new
ShardingAuditStrategyConfiguration(Collections.singletonList("audit_algorithm"),
false));
- return result;
- }
-
- @Test
- void assertSwapToObject() {
- YamlShardingTableRuleConfigurationSwapper swapper = new
YamlShardingTableRuleConfigurationSwapper();
- ShardingTableRuleConfiguration actual =
swapper.swapToObject(createYamlTableRuleConfiguration());
-
assertThat(actual.getDatabaseShardingStrategy().getShardingAlgorithmName(),
is("standard"));
-
assertThat(actual.getTableShardingStrategy().getShardingAlgorithmName(),
is("standard"));
- assertThat(actual.getKeyGenerateStrategy().getKeyGeneratorName(),
is("auto_increment"));
- assertThat(actual.getAuditStrategy().getAuditorNames(),
is(Collections.singletonList("audit_algorithm")));
- }
-
- private YamlTableRuleConfiguration createYamlTableRuleConfiguration() {
- YamlTableRuleConfiguration result = new YamlTableRuleConfiguration();
- result.setLogicTable("logic_table");
- result.setActualDataNodes("ds_${0..1}.table_${0..2}");
- result.setDatabaseStrategy(createYamlShardingStrategyConfiguration());
- result.setTableStrategy(createYamlShardingStrategyConfiguration());
-
result.setKeyGenerateStrategy(createYamlKeyGenerateStrategyConfiguration());
-
result.setAuditStrategy(createYamlShardingAuditStrategyConfiguration());
- return result;
- }
-
- private YamlShardingStrategyConfiguration
createYamlShardingStrategyConfiguration() {
- YamlShardingStrategyConfiguration result = new
YamlShardingStrategyConfiguration();
- YamlStandardShardingStrategyConfiguration
yamlStandardShardingStrategyConfiguration = new
YamlStandardShardingStrategyConfiguration();
- yamlStandardShardingStrategyConfiguration.setShardingColumn("user_id");
-
yamlStandardShardingStrategyConfiguration.setShardingAlgorithmName("standard");
- result.setStandard(yamlStandardShardingStrategyConfiguration);
- return result;
- }
-
- private YamlKeyGenerateStrategyConfiguration
createYamlKeyGenerateStrategyConfiguration() {
- YamlKeyGenerateStrategyConfiguration result = new
YamlKeyGenerateStrategyConfiguration();
- result.setColumn("id");
- result.setKeyGeneratorName("auto_increment");
- return result;
- }
-
- private YamlShardingAuditStrategyConfiguration
createYamlShardingAuditStrategyConfiguration() {
- YamlShardingAuditStrategyConfiguration result = new
YamlShardingAuditStrategyConfiguration();
- result.setAuditorNames(Collections.singletonList("audit_algorithm"));
- result.setAllowHintDisable(false);
- return result;
- }
-
- @Test
- void assertSwapToObjectWithNullLogicTable() {
- YamlShardingTableRuleConfigurationSwapper swapper = new
YamlShardingTableRuleConfigurationSwapper();
- assertThrows(MissingRequiredShardingConfigurationException.class, ()
-> swapper.swapToObject(new YamlTableRuleConfiguration()));
- }
-}
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/strategy/YamlKeyGenerateStrategyConfigurationSwapperTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/strategy/YamlKeyGenerateStrategyConfigurationSwapperTest.java
deleted file mode 100644
index 6295712bc2f..00000000000
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/strategy/YamlKeyGenerateStrategyConfigurationSwapperTest.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.sharding.yaml.swapper.strategy;
-
-import
org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
-import
org.apache.shardingsphere.sharding.yaml.config.strategy.keygen.YamlKeyGenerateStrategyConfiguration;
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class YamlKeyGenerateStrategyConfigurationSwapperTest {
-
- @Test
- void assertSwapToYamlConfiguration() {
- KeyGenerateStrategyConfiguration data = new
KeyGenerateStrategyConfiguration("id", "default");
- YamlKeyGenerateStrategyConfigurationSwapper swapper = new
YamlKeyGenerateStrategyConfigurationSwapper();
- YamlKeyGenerateStrategyConfiguration actual =
swapper.swapToYamlConfiguration(data);
- assertThat(actual.getColumn(), is("id"));
- assertThat(actual.getKeyGeneratorName(), is("default"));
- }
-
- @Test
- void assertSwapToObject() {
- YamlKeyGenerateStrategyConfiguration yamlConfig = new
YamlKeyGenerateStrategyConfiguration();
- yamlConfig.setColumn("id");
- yamlConfig.setKeyGeneratorName("default");
- YamlKeyGenerateStrategyConfigurationSwapper swapper = new
YamlKeyGenerateStrategyConfigurationSwapper();
- KeyGenerateStrategyConfiguration actual =
swapper.swapToObject(yamlConfig);
- assertThat(actual.getColumn(), is("id"));
- assertThat(actual.getKeyGeneratorName(), is("default"));
- }
-}
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/strategy/YamlShardingAuditStrategyConfigurationSwapperTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/strategy/YamlShardingAuditStrategyConfigurationSwapperTest.java
deleted file mode 100644
index 5f9c11b377f..00000000000
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/strategy/YamlShardingAuditStrategyConfigurationSwapperTest.java
+++ /dev/null
@@ -1,51 +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.sharding.yaml.swapper.strategy;
-
-import
org.apache.shardingsphere.sharding.api.config.strategy.audit.ShardingAuditStrategyConfiguration;
-import
org.apache.shardingsphere.sharding.yaml.config.strategy.audit.YamlShardingAuditStrategyConfiguration;
-import org.junit.jupiter.api.Test;
-
-import java.util.Collections;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-
-class YamlShardingAuditStrategyConfigurationSwapperTest {
-
- @Test
- void assertSwapToYamlConfiguration() {
- ShardingAuditStrategyConfiguration data = new
ShardingAuditStrategyConfiguration(Collections.singletonList("audit_algorithm"),
false);
- YamlShardingAuditStrategyConfigurationSwapper swapper = new
YamlShardingAuditStrategyConfigurationSwapper();
- YamlShardingAuditStrategyConfiguration actual =
swapper.swapToYamlConfiguration(data);
- assertThat(actual.getAuditorNames(),
is(Collections.singletonList("audit_algorithm")));
- assertFalse(actual.isAllowHintDisable());
- }
-
- @Test
- void assertSwapToObject() {
- YamlShardingAuditStrategyConfiguration yamlConfig = new
YamlShardingAuditStrategyConfiguration();
-
yamlConfig.setAuditorNames(Collections.singletonList("audit_algorithm"));
- yamlConfig.setAllowHintDisable(false);
- YamlShardingAuditStrategyConfigurationSwapper swapper = new
YamlShardingAuditStrategyConfigurationSwapper();
- ShardingAuditStrategyConfiguration actual =
swapper.swapToObject(yamlConfig);
- assertThat(actual.getAuditorNames(),
is(Collections.singletonList("audit_algorithm")));
- assertFalse(actual.isAllowHintDisable());
- }
-}
diff --git
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/strategy/YamlShardingStrategyConfigurationSwapperTest.java
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/strategy/YamlShardingStrategyConfigurationSwapperTest.java
deleted file mode 100644
index 98d4db16f4c..00000000000
---
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/yaml/swapper/strategy/YamlShardingStrategyConfigurationSwapperTest.java
+++ /dev/null
@@ -1,132 +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.sharding.yaml.swapper.strategy;
-
-import
org.apache.shardingsphere.sharding.api.config.strategy.sharding.ComplexShardingStrategyConfiguration;
-import
org.apache.shardingsphere.sharding.api.config.strategy.sharding.HintShardingStrategyConfiguration;
-import
org.apache.shardingsphere.sharding.api.config.strategy.sharding.NoneShardingStrategyConfiguration;
-import
org.apache.shardingsphere.sharding.api.config.strategy.sharding.ShardingStrategyConfiguration;
-import
org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
-import
org.apache.shardingsphere.sharding.yaml.config.strategy.sharding.YamlComplexShardingStrategyConfiguration;
-import
org.apache.shardingsphere.sharding.yaml.config.strategy.sharding.YamlHintShardingStrategyConfiguration;
-import
org.apache.shardingsphere.sharding.yaml.config.strategy.sharding.YamlNoneShardingStrategyConfiguration;
-import
org.apache.shardingsphere.sharding.yaml.config.strategy.sharding.YamlShardingStrategyConfiguration;
-import
org.apache.shardingsphere.sharding.yaml.config.strategy.sharding.YamlStandardShardingStrategyConfiguration;
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class YamlShardingStrategyConfigurationSwapperTest {
-
- @Test
- void assertSwapToYamlConfigurationForStandardShardingStrategy() {
- ShardingStrategyConfiguration data = new
StandardShardingStrategyConfiguration("order_id", "core_standard_fixture");
- YamlShardingStrategyConfigurationSwapper swapper = new
YamlShardingStrategyConfigurationSwapper();
- YamlShardingStrategyConfiguration actual =
swapper.swapToYamlConfiguration(data);
- assertThat(actual.getStandard().getShardingColumn(), is("order_id"));
- assertThat(actual.getStandard().getShardingAlgorithmName(),
is("core_standard_fixture"));
- }
-
- @Test
- void assertSwapToYamlConfigurationForComplexShardingStrategy() {
- ShardingStrategyConfiguration data = new
ComplexShardingStrategyConfiguration("region_id, user_id",
"core_complex_fixture");
- YamlShardingStrategyConfigurationSwapper swapper = new
YamlShardingStrategyConfigurationSwapper();
- YamlShardingStrategyConfiguration actual =
swapper.swapToYamlConfiguration(data);
- assertThat(actual.getComplex().getShardingColumns(), is("region_id,
user_id"));
- assertThat(actual.getComplex().getShardingAlgorithmName(),
is("core_complex_fixture"));
- }
-
- @Test
- void assertSwapToYamlConfigurationForHintShardingStrategy() {
- ShardingStrategyConfiguration data = new
HintShardingStrategyConfiguration("core_hint_fixture");
- YamlShardingStrategyConfigurationSwapper swapper = new
YamlShardingStrategyConfigurationSwapper();
- YamlShardingStrategyConfiguration actual =
swapper.swapToYamlConfiguration(data);
- assertThat(actual.getHint().getShardingAlgorithmName(),
is("core_hint_fixture"));
- }
-
- @Test
- void assertSwapToYamlConfigurationForNoneShardingStrategy() {
- ShardingStrategyConfiguration data = new
NoneShardingStrategyConfiguration();
- YamlShardingStrategyConfigurationSwapper swapper = new
YamlShardingStrategyConfigurationSwapper();
- YamlShardingStrategyConfiguration actual =
swapper.swapToYamlConfiguration(data);
- assertThat(actual.getNone().getClass(),
is(YamlNoneShardingStrategyConfiguration.class));
- }
-
- @Test
- void assertSwapToObjectForStandardShardingStrategy() {
- YamlShardingStrategyConfiguration yamlConfig = new
YamlShardingStrategyConfiguration();
-
yamlConfig.setStandard(createYamlStandardShardingStrategyConfiguration());
- YamlShardingStrategyConfigurationSwapper swapper = new
YamlShardingStrategyConfigurationSwapper();
- ShardingStrategyConfiguration actual =
swapper.swapToObject(yamlConfig);
- assertThat(actual,
instanceOf(StandardShardingStrategyConfiguration.class));
- assertThat(((StandardShardingStrategyConfiguration)
actual).getShardingColumn(), is("order_id"));
- assertThat(actual.getShardingAlgorithmName(),
is("core_standard_fixture"));
- }
-
- private YamlStandardShardingStrategyConfiguration
createYamlStandardShardingStrategyConfiguration() {
- YamlStandardShardingStrategyConfiguration result = new
YamlStandardShardingStrategyConfiguration();
- result.setShardingColumn("order_id");
- result.setShardingAlgorithmName("core_standard_fixture");
- return result;
- }
-
- @Test
- void assertSwapToObjectForComplexShardingStrategy() {
- YamlShardingStrategyConfiguration yamlConfig = new
YamlShardingStrategyConfiguration();
-
yamlConfig.setComplex(createYamlComplexShardingStrategyConfiguration());
- YamlShardingStrategyConfigurationSwapper swapper = new
YamlShardingStrategyConfigurationSwapper();
- ShardingStrategyConfiguration actual =
swapper.swapToObject(yamlConfig);
- assertThat(actual,
instanceOf(ComplexShardingStrategyConfiguration.class));
- assertThat(((ComplexShardingStrategyConfiguration)
actual).getShardingColumns(), is("region_id, user_id"));
- assertThat(actual.getShardingAlgorithmName(),
is("core_complex_fixture"));
- }
-
- private YamlComplexShardingStrategyConfiguration
createYamlComplexShardingStrategyConfiguration() {
- YamlComplexShardingStrategyConfiguration result = new
YamlComplexShardingStrategyConfiguration();
- result.setShardingColumns("region_id, user_id");
- result.setShardingAlgorithmName("core_complex_fixture");
- return result;
- }
-
- @Test
- void assertSwapToObjectForHintShardingStrategy() {
- YamlShardingStrategyConfiguration yamlConfig = new
YamlShardingStrategyConfiguration();
- yamlConfig.setHint(createYamlHintShardingStrategyConfiguration());
- YamlShardingStrategyConfigurationSwapper swapper = new
YamlShardingStrategyConfigurationSwapper();
- ShardingStrategyConfiguration actual =
swapper.swapToObject(yamlConfig);
- assertThat(actual,
instanceOf(HintShardingStrategyConfiguration.class));
- assertThat(actual.getShardingAlgorithmName(), is("core_hint_fixture"));
- }
-
- private YamlHintShardingStrategyConfiguration
createYamlHintShardingStrategyConfiguration() {
- YamlHintShardingStrategyConfiguration result = new
YamlHintShardingStrategyConfiguration();
- result.setShardingAlgorithmName("core_hint_fixture");
- return result;
- }
-
- @Test
- void assertSwapToObjectForNoneShardingStrategy() {
- YamlShardingStrategyConfiguration yamlConfig = new
YamlShardingStrategyConfiguration();
- yamlConfig.setNone(new YamlNoneShardingStrategyConfiguration());
- YamlShardingStrategyConfigurationSwapper swapper = new
YamlShardingStrategyConfigurationSwapper();
- ShardingStrategyConfiguration actual =
swapper.swapToObject(yamlConfig);
- assertThat(actual,
instanceOf(NoneShardingStrategyConfiguration.class));
- }
-}
diff --git
a/kernel/authority/core/src/test/java/org/apache/shardingsphere/authority/yaml/swapper/YamlAuthorityRuleConfigurationSwapperTest.java
b/kernel/authority/core/src/test/java/org/apache/shardingsphere/authority/yaml/swapper/YamlAuthorityRuleConfigurationSwapperTest.java
deleted file mode 100644
index 763a039aedd..00000000000
---
a/kernel/authority/core/src/test/java/org/apache/shardingsphere/authority/yaml/swapper/YamlAuthorityRuleConfigurationSwapperTest.java
+++ /dev/null
@@ -1,93 +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.authority.yaml.swapper;
-
-import org.apache.shardingsphere.authority.config.AuthorityRuleConfiguration;
-import
org.apache.shardingsphere.authority.yaml.config.YamlAuthorityRuleConfiguration;
-import org.apache.shardingsphere.authority.yaml.config.YamlUserConfiguration;
-import
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
-import
org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
-import org.junit.jupiter.api.Test;
-
-import java.util.Collections;
-import java.util.Properties;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-class YamlAuthorityRuleConfigurationSwapperTest {
-
- private final YamlAuthorityRuleConfigurationSwapper swapper = new
YamlAuthorityRuleConfigurationSwapper();
-
- @Test
- void assertSwapToYamlConfiguration() {
- AuthorityRuleConfiguration authorityRuleConfig = new
AuthorityRuleConfiguration(Collections.emptyList(), new
AlgorithmConfiguration("ALL_PERMITTED", new Properties()),
- Collections.singletonMap("md5",
createAlgorithmConfiguration()), "scram_sha256");
- YamlAuthorityRuleConfiguration actual =
swapper.swapToYamlConfiguration(authorityRuleConfig);
- assertTrue(actual.getUsers().isEmpty());
- assertNotNull(actual.getPrivilege());
- assertThat(actual.getDefaultAuthenticator(), is("scram_sha256"));
- assertThat(actual.getAuthenticators().size(), is(1));
- }
-
- @Test
- void assertSwapToObject() {
- YamlAuthorityRuleConfiguration authorityRuleConfig = new
YamlAuthorityRuleConfiguration();
- authorityRuleConfig.setUsers(Collections.singletonList(getYamlUser()));
- authorityRuleConfig.setPrivilege(createYamlAlgorithmConfiguration());
- authorityRuleConfig.setDefaultAuthenticator("scram_sha256");
- authorityRuleConfig.setAuthenticators(Collections.singletonMap("md5",
createYamlAlgorithmConfiguration()));
- AuthorityRuleConfiguration actual =
swapper.swapToObject(authorityRuleConfig);
- assertThat(actual.getUsers().size(), is(1));
- assertNotNull(actual.getPrivilegeProvider());
- assertThat(actual.getDefaultAuthenticator(), is("scram_sha256"));
- assertThat(actual.getAuthenticators().size(), is(1));
- }
-
- @Test
- void assertSwapToObjectWithDefaultProvider() {
- YamlAuthorityRuleConfiguration authorityRuleConfig = new
YamlAuthorityRuleConfiguration();
- authorityRuleConfig.setUsers(Collections.singletonList(getYamlUser()));
- AuthorityRuleConfiguration actual =
swapper.swapToObject(authorityRuleConfig);
- assertThat(actual.getUsers().size(), is(1));
- assertThat(actual.getPrivilegeProvider().getType(),
is("ALL_PERMITTED"));
- assertThat(actual.getUsers().size(), is(1));
- assertNull(actual.getDefaultAuthenticator());
- assertTrue(actual.getAuthenticators().isEmpty());
- }
-
- private YamlUserConfiguration getYamlUser() {
- YamlUserConfiguration result = new YamlUserConfiguration();
- result.setUser("root@localhost");
- result.setPassword("password");
- return result;
- }
-
- private AlgorithmConfiguration createAlgorithmConfiguration() {
- return new AlgorithmConfiguration("MD5", new Properties());
- }
-
- private YamlAlgorithmConfiguration createYamlAlgorithmConfiguration() {
- YamlAlgorithmConfiguration result = new YamlAlgorithmConfiguration();
- result.setType("MD5");
- return result;
- }
-}
diff --git
a/kernel/authority/core/src/test/java/org/apache/shardingsphere/authority/yaml/swapper/YamlEngineUserConfigurationTest.java
b/kernel/authority/core/src/test/java/org/apache/shardingsphere/authority/yaml/swapper/YamlEngineUserConfigurationTest.java
deleted file mode 100644
index 79ffbc51a4e..00000000000
---
a/kernel/authority/core/src/test/java/org/apache/shardingsphere/authority/yaml/swapper/YamlEngineUserConfigurationTest.java
+++ /dev/null
@@ -1,49 +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.authority.yaml.swapper;
-
-import org.apache.shardingsphere.authority.yaml.config.YamlUserConfiguration;
-import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
-import org.junit.jupiter.api.Test;
-
-import java.util.Properties;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class YamlEngineUserConfigurationTest {
-
- @Test
- void assertUnmarshal() {
- YamlUserConfiguration actual = YamlEngine.unmarshal("password: pwd",
YamlUserConfiguration.class);
- assertThat(actual.getPassword(), is("pwd"));
- }
-
- @Test
- void assertSecureUnmarshalProperties() {
- Properties actual = YamlEngine.unmarshal("password: pwd",
Properties.class);
- assertThat(actual.getProperty("password"), is("pwd"));
- }
-
- @Test
- void assertMarshal() {
- YamlUserConfiguration actual = new YamlUserConfiguration();
- actual.setPassword("pwd");
- assertThat(YamlEngine.marshal(actual), is("admin: false" +
System.lineSeparator() + "password: pwd" + System.lineSeparator()));
- }
-}
diff --git
a/kernel/authority/core/src/test/java/org/apache/shardingsphere/authority/yaml/swapper/YamlUserSwapperTest.java
b/kernel/authority/core/src/test/java/org/apache/shardingsphere/authority/yaml/swapper/YamlUserSwapperTest.java
deleted file mode 100644
index 1e11b39bbd3..00000000000
---
a/kernel/authority/core/src/test/java/org/apache/shardingsphere/authority/yaml/swapper/YamlUserSwapperTest.java
+++ /dev/null
@@ -1,80 +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.authority.yaml.swapper;
-
-import org.apache.shardingsphere.authority.yaml.config.YamlUserConfiguration;
-import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-
-class YamlUserSwapperTest {
-
- @Test
- void assertSwapToYamlConfiguration() {
- YamlUserConfiguration actual = new
YamlUserSwapper().swapToYamlConfiguration(new ShardingSphereUser("foo_user",
"foo_pwd", "127.0.0.1"));
- assertNotNull(actual);
- assertThat(actual.getUser(), is("[email protected]"));
- assertThat(actual.getPassword(), is("foo_pwd"));
- }
-
- @Test
- void assertSwapToNullYamlConfiguration() {
- assertNull(new YamlUserSwapper().swapToYamlConfiguration(null));
- }
-
- @Test
- void assertSwapToObject() {
- YamlUserConfiguration user = new YamlUserConfiguration();
- user.setUser("[email protected]");
- user.setPassword("foo_pwd");
- ShardingSphereUser actual = new YamlUserSwapper().swapToObject(user);
- assertNotNull(actual);
- assertThat(actual.getGrantee().getUsername(), is("foo_user"));
- assertThat(actual.getGrantee().getHostname(), is("127.0.0.1"));
- assertThat(actual.getPassword(), is("foo_pwd"));
- }
-
- @Test
- void assertSwapToObjectWithUserEndWithAt() {
- YamlUserConfiguration user = new YamlUserConfiguration();
- user.setUser("foo_user@");
- user.setPassword("foo_pwd");
- ShardingSphereUser actual = new YamlUserSwapper().swapToObject(user);
- assertNotNull(actual);
- assertThat(actual.getGrantee().getUsername(), is("foo_user"));
- assertThat(actual.getGrantee().getHostname(), is("%"));
- assertThat(actual.getPassword(), is("foo_pwd"));
- }
-
- @Test
- void assertSwapToObjectWithEmptyUsername() {
- YamlUserConfiguration user = new YamlUserConfiguration();
- user.setUser("@127.0.0.1");
- assertThrows(IllegalArgumentException.class, () -> new
YamlUserSwapper().swapToObject(user));
- }
-
- @Test
- void assertSwapToNullObject() {
- assertNull(new YamlUserSwapper().swapToObject(null));
- }
-}
diff --git
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/datasource/creator/ShardingSpherePipelineDataSourceCreator.java
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/datasource/creator/ShardingSpherePipelineDataSourceCreator.java
index 8be926d1002..8915b134784 100644
---
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/datasource/creator/ShardingSpherePipelineDataSourceCreator.java
+++
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/datasource/creator/ShardingSpherePipelineDataSourceCreator.java
@@ -38,7 +38,7 @@ import
org.apache.shardingsphere.mode.repository.standalone.jdbc.props.JDBCRepos
import
org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration;
import
org.apache.shardingsphere.sharding.yaml.swapper.ShardingRuleConfigurationConverter;
import org.apache.shardingsphere.single.constant.SingleTableConstants;
-import
org.apache.shardingsphere.single.yaml.config.pojo.YamlSingleRuleConfiguration;
+import
org.apache.shardingsphere.single.yaml.config.YamlSingleRuleConfiguration;
import javax.sql.DataSource;
import java.sql.SQLException;
diff --git
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/pojo/YamlSingleRuleConfiguration.java
b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/YamlSingleRuleConfiguration.java
similarity index 96%
rename from
kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/pojo/YamlSingleRuleConfiguration.java
rename to
kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/YamlSingleRuleConfiguration.java
index 4b67071a761..5a90488195e 100644
---
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/pojo/YamlSingleRuleConfiguration.java
+++
b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/YamlSingleRuleConfiguration.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.single.yaml.config.pojo;
+package org.apache.shardingsphere.single.yaml.config;
import lombok.Getter;
import lombok.Setter;
diff --git
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/swapper/YamlSingleRuleConfigurationSwapper.java
b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/swapper/YamlSingleRuleConfigurationSwapper.java
similarity index 93%
rename from
kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/swapper/YamlSingleRuleConfigurationSwapper.java
rename to
kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/swapper/YamlSingleRuleConfigurationSwapper.java
index 02476d528bf..6c32f6f8ca0 100644
---
a/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/config/swapper/YamlSingleRuleConfigurationSwapper.java
+++
b/kernel/single/core/src/main/java/org/apache/shardingsphere/single/yaml/swapper/YamlSingleRuleConfigurationSwapper.java
@@ -15,12 +15,12 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.single.yaml.config.swapper;
+package org.apache.shardingsphere.single.yaml.swapper;
import
org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapper;
import org.apache.shardingsphere.single.config.SingleRuleConfiguration;
import org.apache.shardingsphere.single.constant.SingleOrder;
-import
org.apache.shardingsphere.single.yaml.config.pojo.YamlSingleRuleConfiguration;
+import
org.apache.shardingsphere.single.yaml.config.YamlSingleRuleConfiguration;
/**
* YAML single rule configuration swapper.
diff --git
a/kernel/single/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapper
b/kernel/single/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapper
index c06ededb21a..baf101e425f 100644
---
a/kernel/single/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapper
+++
b/kernel/single/core/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapper
@@ -15,4 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.single.yaml.config.swapper.YamlSingleRuleConfigurationSwapper
+org.apache.shardingsphere.single.yaml.swapper.YamlSingleRuleConfigurationSwapper
diff --git
a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/it/SingleRuleConfigurationRepositoryTupleSwapperEngineIT.java
b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/it/SingleRuleConfigurationRepositoryTupleSwapperEngineIT.java
index 78a299e77c9..ce2224dc8df 100644
---
a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/it/SingleRuleConfigurationRepositoryTupleSwapperEngineIT.java
+++
b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/it/SingleRuleConfigurationRepositoryTupleSwapperEngineIT.java
@@ -19,7 +19,7 @@ package org.apache.shardingsphere.single.it;
import org.apache.shardingsphere.mode.tuple.RepositoryTuple;
import
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
-import
org.apache.shardingsphere.single.yaml.config.pojo.YamlSingleRuleConfiguration;
+import
org.apache.shardingsphere.single.yaml.config.YamlSingleRuleConfiguration;
import org.apache.shardingsphere.test.it.yaml.RepositoryTupleSwapperEngineIT;
import java.util.List;
diff --git
a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/yaml/config/swapper/YamlSingleRuleConfigurationSwapperTest.java
b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/yaml/config/swapper/YamlSingleRuleConfigurationSwapperTest.java
deleted file mode 100644
index 5d4b0497717..00000000000
---
a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/yaml/config/swapper/YamlSingleRuleConfigurationSwapperTest.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.single.yaml.config.swapper;
-
-import org.apache.shardingsphere.single.config.SingleRuleConfiguration;
-import
org.apache.shardingsphere.single.yaml.config.pojo.YamlSingleRuleConfiguration;
-import org.junit.jupiter.api.Test;
-
-import java.util.Collections;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-class YamlSingleRuleConfigurationSwapperTest {
-
- @Test
- void assertSwapToObject() {
- YamlSingleRuleConfiguration yamlConfig = new
YamlSingleRuleConfiguration();
- yamlConfig.setDefaultDataSource("ds_0");
- SingleRuleConfiguration ruleConfig = new
YamlSingleRuleConfigurationSwapper().swapToObject(yamlConfig);
- assertTrue(ruleConfig.getDefaultDataSource().isPresent());
- assertThat(ruleConfig.getDefaultDataSource().get(), is("ds_0"));
- }
-
- @Test
- void assertSwapToObjectWithoutDataSource() {
- assertFalse(new YamlSingleRuleConfigurationSwapper().swapToObject(new
YamlSingleRuleConfiguration()).getDefaultDataSource().isPresent());
- }
-
- @Test
- void assertSwapToYaml() {
- assertThat(new
YamlSingleRuleConfigurationSwapper().swapToYamlConfiguration(new
SingleRuleConfiguration(Collections.emptyList(),
"ds_0")).getDefaultDataSource(), is("ds_0"));
- }
-
- @Test
- void assertSwapToYamlWithoutDataSource() {
- assertNull(new
YamlSingleRuleConfigurationSwapper().swapToYamlConfiguration(new
SingleRuleConfiguration()).getDefaultDataSource());
- }
-}
diff --git
a/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/it/SQLParserRuleConfigurationYamlIT.java
b/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/it/SQLParserRuleConfigurationYamlIT.java
index 2db5d2577bb..d49d7d3eeda 100644
---
a/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/it/SQLParserRuleConfigurationYamlIT.java
+++
b/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/it/SQLParserRuleConfigurationYamlIT.java
@@ -24,6 +24,6 @@ import
org.apache.shardingsphere.test.it.yaml.YamlRuleConfigurationIT;
class SQLParserRuleConfigurationYamlIT extends YamlRuleConfigurationIT {
SQLParserRuleConfigurationYamlIT() {
- super("yaml/sql-parser-rule.yaml", new SQLParserRuleConfiguration(new
CacheOption(128, 1024), new CacheOption(256, 4096)));
+ super("yaml/sql-parser-rule.yaml", new SQLParserRuleConfiguration(new
CacheOption(512, 2048L), new CacheOption(256, 4096L)));
}
}
diff --git
a/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/yaml/swapper/YamlSQLParserCacheOptionConfigurationSwapperTest.java
b/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/yaml/swapper/YamlSQLParserCacheOptionConfigurationSwapperTest.java
deleted file mode 100644
index 2199069f743..00000000000
---
a/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/yaml/swapper/YamlSQLParserCacheOptionConfigurationSwapperTest.java
+++ /dev/null
@@ -1,45 +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.parser.yaml.swapper;
-
-import
org.apache.shardingsphere.parser.yaml.config.YamlSQLParserCacheOptionRuleConfiguration;
-import org.apache.shardingsphere.sql.parser.api.CacheOption;
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-
-class YamlSQLParserCacheOptionConfigurationSwapperTest {
-
- @Test
- void assertSwapToYamlConfiguration() {
- YamlSQLParserCacheOptionRuleConfiguration actual = new
YamlSQLParserCacheOptionConfigurationSwapper().swapToYamlConfiguration(new
CacheOption(2, 5L));
- assertThat(actual.getInitialCapacity(), is(2));
- assertThat(actual.getMaximumSize(), is(5L));
- }
-
- @Test
- void assertSwapToObject() {
- YamlSQLParserCacheOptionRuleConfiguration cacheOptionRuleConfig = new
YamlSQLParserCacheOptionRuleConfiguration();
- cacheOptionRuleConfig.setInitialCapacity(2);
- cacheOptionRuleConfig.setMaximumSize(5L);
- CacheOption actual = new
YamlSQLParserCacheOptionConfigurationSwapper().swapToObject(cacheOptionRuleConfig);
- assertThat(actual.getInitialCapacity(), is(2));
- assertThat(actual.getMaximumSize(), is(5L));
- }
-}
diff --git
a/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/yaml/swapper/YamlSQLParserRuleConfigurationSwapperTest.java
b/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/yaml/swapper/YamlSQLParserRuleConfigurationSwapperTest.java
deleted file mode 100644
index 49de723f06a..00000000000
---
a/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/yaml/swapper/YamlSQLParserRuleConfigurationSwapperTest.java
+++ /dev/null
@@ -1,66 +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.parser.yaml.swapper;
-
-import org.apache.shardingsphere.parser.config.SQLParserRuleConfiguration;
-import
org.apache.shardingsphere.parser.yaml.config.YamlSQLParserCacheOptionRuleConfiguration;
-import
org.apache.shardingsphere.parser.yaml.config.YamlSQLParserRuleConfiguration;
-import org.apache.shardingsphere.sql.parser.api.CacheOption;
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-
-class YamlSQLParserRuleConfigurationSwapperTest {
-
- @Test
- void assertSwapToYamlConfiguration() {
- SQLParserRuleConfiguration ruleConfig = new
SQLParserRuleConfiguration(new CacheOption(2, 5L), new CacheOption(4, 7L));
- YamlSQLParserRuleConfiguration actual = new
YamlSQLParserRuleConfigurationSwapper().swapToYamlConfiguration(ruleConfig);
- assertThat(actual.getParseTreeCache().getInitialCapacity(), is(2));
- assertThat(actual.getParseTreeCache().getMaximumSize(), is(5L));
- assertThat(actual.getSqlStatementCache().getInitialCapacity(), is(4));
- assertThat(actual.getSqlStatementCache().getMaximumSize(), is(7L));
- }
-
- @Test
- void assertSwapToObjectWithDefaultConfig() {
- YamlSQLParserRuleConfiguration yamlConfig = new
YamlSQLParserRuleConfiguration();
- SQLParserRuleConfiguration actual = new
YamlSQLParserRuleConfigurationSwapper().swapToObject(yamlConfig);
- assertThat(actual.getParseTreeCache().getInitialCapacity(), is(128));
- assertThat(actual.getParseTreeCache().getMaximumSize(), is(1024L));
- assertThat(actual.getSqlStatementCache().getInitialCapacity(),
is(2000));
- assertThat(actual.getSqlStatementCache().getMaximumSize(), is(65535L));
- }
-
- @Test
- void assertSwapToObject() {
- YamlSQLParserRuleConfiguration yamlConfig = new
YamlSQLParserRuleConfiguration();
- yamlConfig.setParseTreeCache(new
YamlSQLParserCacheOptionRuleConfiguration());
- yamlConfig.getParseTreeCache().setInitialCapacity(2);
- yamlConfig.getParseTreeCache().setMaximumSize(5L);
- yamlConfig.setSqlStatementCache(new
YamlSQLParserCacheOptionRuleConfiguration());
- yamlConfig.getSqlStatementCache().setInitialCapacity(4);
- yamlConfig.getSqlStatementCache().setMaximumSize(7L);
- SQLParserRuleConfiguration actual = new
YamlSQLParserRuleConfigurationSwapper().swapToObject(yamlConfig);
- assertThat(actual.getParseTreeCache().getInitialCapacity(), is(2));
- assertThat(actual.getParseTreeCache().getMaximumSize(), is(5L));
- assertThat(actual.getSqlStatementCache().getInitialCapacity(), is(4));
- assertThat(actual.getSqlStatementCache().getMaximumSize(), is(7L));
- }
-}
diff --git
a/kernel/sql-parser/core/src/test/resources/yaml/sql-parser-rule.yaml
b/kernel/sql-parser/core/src/test/resources/yaml/sql-parser-rule.yaml
index 9eace8f0797..9ef8f52386c 100644
--- a/kernel/sql-parser/core/src/test/resources/yaml/sql-parser-rule.yaml
+++ b/kernel/sql-parser/core/src/test/resources/yaml/sql-parser-rule.yaml
@@ -18,8 +18,8 @@
rules:
- !SQL_PARSER
parseTreeCache:
- initialCapacity: 128
- maximumSize: 1024
+ initialCapacity: 512
+ maximumSize: 2048
sqlStatementCache:
initialCapacity: 256
maximumSize: 4096
diff --git
a/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/yaml/swapper/YamlTransactionRuleConfigurationSwapperTest.java
b/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/yaml/swapper/YamlTransactionRuleConfigurationSwapperTest.java
deleted file mode 100644
index aadbc4500c4..00000000000
---
a/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/yaml/swapper/YamlTransactionRuleConfigurationSwapperTest.java
+++ /dev/null
@@ -1,50 +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.transaction.yaml.swapper;
-
-import
org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
-import
org.apache.shardingsphere.transaction.yaml.config.YamlTransactionRuleConfiguration;
-import org.junit.jupiter.api.Test;
-
-import java.util.Properties;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class YamlTransactionRuleConfigurationSwapperTest {
-
- @Test
- void assertSwapToYamlConfiguration() {
- YamlTransactionRuleConfiguration actual = new
YamlTransactionRuleConfigurationSwapper().swapToYamlConfiguration(new
TransactionRuleConfiguration("default", "provider", new Properties()));
- assertThat(actual.getDefaultType(), is("default"));
- assertThat(actual.getProviderType(), is("provider"));
- assertThat(actual.getProps(), is(new Properties()));
- }
-
- @Test
- void assertSwapToObject() {
- YamlTransactionRuleConfiguration yamlConfig = new
YamlTransactionRuleConfiguration();
- yamlConfig.setDefaultType("default");
- yamlConfig.setProviderType("provider");
- yamlConfig.setProps(new Properties());
- TransactionRuleConfiguration actual = new
YamlTransactionRuleConfigurationSwapper().swapToObject(yamlConfig);
- assertThat(actual.getDefaultType(), is("default"));
- assertThat(actual.getProviderType(), is("provider"));
- assertThat(actual.getProps(), is(new Properties()));
- }
-}
diff --git
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/cases/PipelineContainerComposer.java
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/cases/PipelineContainerComposer.java
index f6624e35d22..2a9251c52d4 100644
---
a/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/cases/PipelineContainerComposer.java
+++
b/test/e2e/operation/pipeline/src/test/java/org/apache/shardingsphere/test/e2e/data/pipeline/cases/PipelineContainerComposer.java
@@ -37,7 +37,7 @@ import
org.apache.shardingsphere.infra.database.postgresql.type.PostgreSQLDataba
import
org.apache.shardingsphere.infra.exception.core.ShardingSpherePreconditions;
import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
import org.apache.shardingsphere.infra.yaml.config.pojo.YamlRootConfiguration;
-import
org.apache.shardingsphere.single.yaml.config.pojo.YamlSingleRuleConfiguration;
+import
org.apache.shardingsphere.single.yaml.config.YamlSingleRuleConfiguration;
import
org.apache.shardingsphere.test.e2e.data.pipeline.command.ExtraSQLCommand;
import
org.apache.shardingsphere.test.e2e.data.pipeline.env.PipelineE2EEnvironment;
import
org.apache.shardingsphere.test.e2e.data.pipeline.env.enums.PipelineEnvTypeEnum;