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 0663c35ef82 Add test case for
PersistRepositoryConfigurationYamlSwapperFactory (#19302)
0663c35ef82 is described below
commit 0663c35ef8232d9c14a2c48243e69b70873612fe
Author: lushaorong <[email protected]>
AuthorDate: Mon Jul 18 14:14:16 2022 +0800
Add test case for PersistRepositoryConfigurationYamlSwapperFactory (#19302)
---
.../PersistRepositoryConfigurationFixture.java | 35 +++++++++++++++++
...tRepositoryConfigurationYamlSwapperFixture.java | 43 +++++++++++++++++++++
...ositoryConfigurationYamlSwapperFactoryTest.java | 45 ++++++++++++++++++++++
....mode.PersistRepositoryConfigurationYamlSwapper | 18 +++++++++
4 files changed, 141 insertions(+)
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/fixture/PersistRepositoryConfigurationFixture.java
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/fixture/PersistRepositoryConfigurationFixture.java
new file mode 100644
index 00000000000..56e37016d11
--- /dev/null
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/fixture/PersistRepositoryConfigurationFixture.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.yaml.config.swapper.fixture;
+
+import
org.apache.shardingsphere.infra.config.mode.PersistRepositoryConfiguration;
+
+import java.util.Properties;
+
+public class PersistRepositoryConfigurationFixture implements
PersistRepositoryConfiguration {
+
+ @Override
+ public String getType() {
+ return "FIXTURE";
+ }
+
+ @Override
+ public Properties getProps() {
+ return new Properties();
+ }
+}
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/fixture/PersistRepositoryConfigurationYamlSwapperFixture.java
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/fixture/PersistRepositoryConfigurationYamlSwapperFixture.java
new file mode 100644
index 00000000000..01e180c5364
--- /dev/null
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/fixture/PersistRepositoryConfigurationYamlSwapperFixture.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.yaml.config.swapper.fixture;
+
+import
org.apache.shardingsphere.infra.yaml.config.pojo.mode.YamlPersistRepositoryConfiguration;
+import
org.apache.shardingsphere.infra.yaml.config.swapper.mode.PersistRepositoryConfigurationYamlSwapper;
+
+public class PersistRepositoryConfigurationYamlSwapperFixture implements
PersistRepositoryConfigurationYamlSwapper<PersistRepositoryConfigurationFixture>
{
+
+ @Override
+ public YamlPersistRepositoryConfiguration swapToYamlConfiguration(final
PersistRepositoryConfigurationFixture data) {
+ YamlPersistRepositoryConfiguration result = new
YamlPersistRepositoryConfiguration();
+ result.setType(data.getType());
+ result.setProps(data.getProps());
+ return result;
+ }
+
+ @Override
+ public PersistRepositoryConfigurationFixture swapToObject(final
YamlPersistRepositoryConfiguration yamlConfig) {
+ return new PersistRepositoryConfigurationFixture();
+ }
+
+ @Override
+ public String getType() {
+ return "Fixture";
+ }
+
+}
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/mode/PersistRepositoryConfigurationYamlSwapperFactoryTest.java
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/mode/PersistRepositoryConfigurationYamlSwapperFactoryTest.java
new file mode 100644
index 00000000000..0b79ad1aa76
--- /dev/null
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/mode/PersistRepositoryConfigurationYamlSwapperFactoryTest.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.yaml.config.swapper.mode;
+
+import
org.apache.shardingsphere.infra.yaml.config.swapper.fixture.PersistRepositoryConfigurationYamlSwapperFixture;
+import org.junit.Test;
+
+import java.util.Optional;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
+public class PersistRepositoryConfigurationYamlSwapperFactoryTest {
+
+ @SuppressWarnings("rawtypes")
+ @Test
+ public void assertGetInstance() {
+ PersistRepositoryConfigurationYamlSwapper swapper =
PersistRepositoryConfigurationYamlSwapperFactory.getInstance("Fixture");
+ assertThat(swapper,
instanceOf(PersistRepositoryConfigurationYamlSwapperFixture.class));
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Test
+ public void assertFindInstance() {
+ Optional<PersistRepositoryConfigurationYamlSwapper> optional =
PersistRepositoryConfigurationYamlSwapperFactory.findInstance("Fixture");
+ assertTrue(optional.isPresent());
+
+ }
+}
diff --git
a/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.yaml.config.swapper.mode.PersistRepositoryConfigurationYamlSwapper
b/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.yaml.config.swapper.mode.PersistRepositoryConfigurationYamlSwapper
new file mode 100644
index 00000000000..74b8b3308c6
--- /dev/null
+++
b/shardingsphere-infra/shardingsphere-infra-common/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.yaml.config.swapper.mode.PersistRepositoryConfigurationYamlSwapper
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+org.apache.shardingsphere.infra.yaml.config.swapper.fixture.PersistRepositoryConfigurationYamlSwapperFixture
\ No newline at end of file