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 cb86bb1bc19 Add test case for ResultProcessEngineFactory (#19015)
cb86bb1bc19 is described below
commit cb86bb1bc19ea6967b29fdebd1f77e3938154713
Author: lushaorong <[email protected]>
AuthorDate: Mon Jul 11 00:02:47 2022 -0500
Add test case for ResultProcessEngineFactory (#19015)
---
.../engine/ResultProcessEngineFactoryTest.java | 43 ++++++++++++++++++++++
.../merge/fixture/ResultProcessEngineFixture.java | 34 +++++++++++++++++
.../fixture/rule/ResultProcessRuleFixture.java | 36 ++++++++++++++++++
...ngsphere.infra.merge.engine.ResultProcessEngine | 1 +
4 files changed, 114 insertions(+)
diff --git
a/shardingsphere-infra/shardingsphere-infra-merge/src/test/java/org/apache/shardingsphere/infra/merge/engine/ResultProcessEngineFactoryTest.java
b/shardingsphere-infra/shardingsphere-infra-merge/src/test/java/org/apache/shardingsphere/infra/merge/engine/ResultProcessEngineFactoryTest.java
new file mode 100644
index 00000000000..94ff9f89bf8
--- /dev/null
+++
b/shardingsphere-infra/shardingsphere-infra-merge/src/test/java/org/apache/shardingsphere/infra/merge/engine/ResultProcessEngineFactoryTest.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.merge.engine;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
+
+import java.util.Map;
+
+import
org.apache.shardingsphere.infra.merge.fixture.ResultProcessEngineFixture;
+import
org.apache.shardingsphere.infra.merge.fixture.rule.ResultProcessRuleFixture;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+import org.hamcrest.collection.IsMapContaining;
+import org.junit.Test;
+
+import com.google.common.collect.Lists;
+
+public class ResultProcessEngineFactoryTest {
+
+ @Test
+ public void assertGetInstances() {
+ ResultProcessRuleFixture ruleFixture =
mock(ResultProcessRuleFixture.class);
+ Map<ShardingSphereRule, ResultProcessEngine> instances =
ResultProcessEngineFactory.getInstances(Lists.newArrayList(ruleFixture));
+ assertThat(instances, IsMapContaining.hasKey(ruleFixture));
+ assertThat(instances,
IsMapContaining.hasValue(instanceOf(ResultProcessEngineFixture.class)));
+ }
+}
diff --git
a/shardingsphere-infra/shardingsphere-infra-merge/src/test/java/org/apache/shardingsphere/infra/merge/fixture/ResultProcessEngineFixture.java
b/shardingsphere-infra/shardingsphere-infra-merge/src/test/java/org/apache/shardingsphere/infra/merge/fixture/ResultProcessEngineFixture.java
new file mode 100644
index 00000000000..2f396d04422
--- /dev/null
+++
b/shardingsphere-infra/shardingsphere-infra-merge/src/test/java/org/apache/shardingsphere/infra/merge/fixture/ResultProcessEngineFixture.java
@@ -0,0 +1,34 @@
+/*
+ * 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.merge.fixture;
+
+import org.apache.shardingsphere.infra.merge.engine.ResultProcessEngine;
+import
org.apache.shardingsphere.infra.merge.fixture.rule.ResultProcessRuleFixture;
+
+public class ResultProcessEngineFixture implements
ResultProcessEngine<ResultProcessRuleFixture> {
+
+ @Override
+ public int getOrder() {
+ return 0;
+ }
+
+ @Override
+ public Class<ResultProcessRuleFixture> getTypeClass() {
+ return ResultProcessRuleFixture.class;
+ }
+}
diff --git
a/shardingsphere-infra/shardingsphere-infra-merge/src/test/java/org/apache/shardingsphere/infra/merge/fixture/rule/ResultProcessRuleFixture.java
b/shardingsphere-infra/shardingsphere-infra-merge/src/test/java/org/apache/shardingsphere/infra/merge/fixture/rule/ResultProcessRuleFixture.java
new file mode 100644
index 00000000000..3a49b922279
--- /dev/null
+++
b/shardingsphere-infra/shardingsphere-infra-merge/src/test/java/org/apache/shardingsphere/infra/merge/fixture/rule/ResultProcessRuleFixture.java
@@ -0,0 +1,36 @@
+/*
+ * 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.merge.fixture.rule;
+
+import org.apache.shardingsphere.infra.config.RuleConfiguration;
+import org.apache.shardingsphere.infra.rule.ShardingSphereRule;
+
+import static org.mockito.Mockito.mock;
+
+public class ResultProcessRuleFixture implements ShardingSphereRule {
+
+ @Override
+ public RuleConfiguration getConfiguration() {
+ return mock(RuleConfiguration.class);
+ }
+
+ @Override
+ public String getType() {
+ return ResultProcessRuleFixture.class.getSimpleName();
+ }
+}
diff --git
a/shardingsphere-infra/shardingsphere-infra-merge/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.merge.engine.ResultProcessEngine
b/shardingsphere-infra/shardingsphere-infra-merge/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.merge.engine.ResultProcessEngine
index ca6e74d539f..4e447c5bec6 100644
---
a/shardingsphere-infra/shardingsphere-infra-merge/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.merge.engine.ResultProcessEngine
+++
b/shardingsphere-infra/shardingsphere-infra-merge/src/test/resources/META-INF/services/org.apache.shardingsphere.infra.merge.engine.ResultProcessEngine
@@ -17,3 +17,4 @@
org.apache.shardingsphere.infra.merge.fixture.merger.ResultMergerEngineFixture
org.apache.shardingsphere.infra.merge.fixture.decorator.ResultDecoratorEngineFixture
+org.apache.shardingsphere.infra.merge.fixture.ResultProcessEngineFixture