You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/12/12 08:03:58 UTC

[GitHub] [shardingsphere] sandynz commented on a diff in pull request #22779: Add partial implementation of CDC subscription FULL mode

sandynz commented on code in PR #22779:
URL: https://github.com/apache/shardingsphere/pull/22779#discussion_r1045503457


##########
kernel/data-pipeline/core/src/test/java/org/apache/shardingsphere/data/pipeline/core/util/JobDataNodeLineConvertUtilTest.java:
##########
@@ -0,0 +1,68 @@
+/*
+ * 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.data.pipeline.core.util;
+
+import org.apache.shardingsphere.data.pipeline.api.datanode.JobDataNodeEntry;
+import org.apache.shardingsphere.data.pipeline.api.datanode.JobDataNodeLine;
+import org.apache.shardingsphere.infra.datanode.DataNode;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public final class JobDataNodeLineConvertUtilTest {
+    
+    @Test
+    public void assertConvertDataNodesToLines() {
+        Map<String, List<DataNode>> mockDataNodes = new LinkedHashMap<>();
+        List<DataNode> dataNodes = Arrays.asList(new DataNode("ds_0", "t_order_0"), new DataNode("ds_0", "t_order_1"));
+        List<DataNode> itemDataNodes = Collections.singletonList(new DataNode("ds_0", "t_order_item_0"));
+        mockDataNodes.put("t_order", dataNodes);
+        mockDataNodes.put("t_order_item", itemDataNodes);
+        List<JobDataNodeLine> jobDataNodeLines = JobDataNodeLineConvertUtil.convertDataNodesToLines(mockDataNodes);
+        assertThat(jobDataNodeLines.size(), is(1));
+        List<JobDataNodeEntry> actualNodeEntry = new ArrayList<>(jobDataNodeLines.get(0).getEntries());
+        assertThat(actualNodeEntry.get(0).getLogicTableName(), is("t_order"));
+        assertThat(actualNodeEntry.get(0).getDataNodes().size(), is(2));
+        assertThat(actualNodeEntry.get(1).getLogicTableName(), is("t_order_item"));
+        assertThat(actualNodeEntry.get(1).getDataNodes().size(), is(1));
+    }
+    
+    @Test
+    public void assertConvertDataNodesToLinesWith() {
+        Map<String, List<DataNode>> mockDataNodes = new LinkedHashMap<>();
+        List<DataNode> dataNodes = Arrays.asList(new DataNode("ds_0", "t_order_0"), new DataNode("ds_0", "t_order_1"));
+        List<DataNode> itemDataNodes = Collections.singletonList(new DataNode("ds_0", "t_order_item_0"));
+        mockDataNodes.put("t_order", dataNodes);
+        mockDataNodes.put("t_order_item", itemDataNodes);
+        List<JobDataNodeLine> jobDataNodeLines = JobDataNodeLineConvertUtil.convertDataNodesToLines(mockDataNodes);
+        assertThat(jobDataNodeLines.size(), is(1));
+        List<JobDataNodeEntry> actualNodeEntry = new ArrayList<>(jobDataNodeLines.get(0).getEntries());
+        assertThat(actualNodeEntry.get(0).getLogicTableName(), is("t_order"));
+        assertThat(actualNodeEntry.get(0).getDataNodes().size(), is(2));
+        assertThat(actualNodeEntry.get(1).getLogicTableName(), is("t_order_item"));
+        assertThat(actualNodeEntry.get(1).getDataNodes().size(), is(1));
+    }

Review Comment:
   Looks the content of `assertConvertDataNodesToLinesWith` is the same as `assertConvertDataNodesToLines`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org