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/10/19 11:28:32 UTC

[GitHub] [shardingsphere] strongduanmu commented on a diff in pull request #21603: [ISSUE #21569] Add Tests for ShardingAutoTableAlgorithmUtil Class

strongduanmu commented on code in PR #21603:
URL: https://github.com/apache/shardingsphere/pull/21603#discussion_r999312970


##########
features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/ShardingAutoTableAlgorithmUtilTest.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.algorithm.sharding;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Optional;
+import org.apache.shardingsphere.infra.datanode.DataNodeInfo;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ShardingAutoTableAlgorithmUtilTest {
+    
+    private Collection<String> collection;
+    
+    private DataNodeInfo dataNodeInfo;
+    
+    @Before
+    public void setup() {
+        collection = new ArrayList<>();
+        collection.add("PREFIX----SUFFIX");
+        collection.add("PREFIXSUFFIXSTRING");
+        collection.add("PREFIX----------");
+        

Review Comment:
   Please remove useless blank line.



##########
features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/ShardingAutoTableAlgorithmUtilTest.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.algorithm.sharding;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Optional;
+import org.apache.shardingsphere.infra.datanode.DataNodeInfo;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ShardingAutoTableAlgorithmUtilTest {
+    
+    private Collection<String> collection;
+    
+    private DataNodeInfo dataNodeInfo;
+    
+    @Before
+    public void setup() {
+        collection = new ArrayList<>();
+        collection.add("PREFIX----SUFFIX");
+        collection.add("PREFIXSUFFIXSTRING");
+        collection.add("PREFIX----------");
+        
+        final String prefix = "PREFIX";
+        final int suffixMinLength = 10;
+        final char paddingChar = '-';
+        dataNodeInfo = new DataNodeInfo(prefix, suffixMinLength, paddingChar);
+    }
+    
+    @Test
+    public void assertFindMatchedTargetNameForValidInputs() {
+        
+        Optional<String> output = ShardingAutoTableAlgorithmUtil.findMatchedTargetName(collection, "SUFFIX", dataNodeInfo);
+        assertTrue(output.isPresent());
+        assertEquals("PREFIX----SUFFIX", output.get());
+        

Review Comment:
   Please remove useless blank line.



##########
features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/ShardingAutoTableAlgorithmUtilTest.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.algorithm.sharding;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Optional;
+import org.apache.shardingsphere.infra.datanode.DataNodeInfo;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ShardingAutoTableAlgorithmUtilTest {
+    
+    private Collection<String> collection;
+    
+    private DataNodeInfo dataNodeInfo;
+    
+    @Before
+    public void setup() {
+        collection = new ArrayList<>();
+        collection.add("PREFIX----SUFFIX");
+        collection.add("PREFIXSUFFIXSTRING");
+        collection.add("PREFIX----------");
+        
+        final String prefix = "PREFIX";
+        final int suffixMinLength = 10;
+        final char paddingChar = '-';
+        dataNodeInfo = new DataNodeInfo(prefix, suffixMinLength, paddingChar);
+    }
+    
+    @Test
+    public void assertFindMatchedTargetNameForValidInputs() {
+        
+        Optional<String> output = ShardingAutoTableAlgorithmUtil.findMatchedTargetName(collection, "SUFFIX", dataNodeInfo);
+        assertTrue(output.isPresent());
+        assertEquals("PREFIX----SUFFIX", output.get());

Review Comment:
   Please use assertThat instead of assertEquals.



##########
features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/ShardingAutoTableAlgorithmUtilTest.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.algorithm.sharding;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Optional;
+import org.apache.shardingsphere.infra.datanode.DataNodeInfo;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ShardingAutoTableAlgorithmUtilTest {
+    
+    private Collection<String> collection;
+    
+    private DataNodeInfo dataNodeInfo;
+    
+    @Before
+    public void setup() {
+        collection = new ArrayList<>();
+        collection.add("PREFIX----SUFFIX");
+        collection.add("PREFIXSUFFIXSTRING");
+        collection.add("PREFIX----------");
+        
+        final String prefix = "PREFIX";
+        final int suffixMinLength = 10;
+        final char paddingChar = '-';
+        dataNodeInfo = new DataNodeInfo(prefix, suffixMinLength, paddingChar);
+    }
+    
+    @Test
+    public void assertFindMatchedTargetNameForValidInputs() {
+        
+        Optional<String> output = ShardingAutoTableAlgorithmUtil.findMatchedTargetName(collection, "SUFFIX", dataNodeInfo);
+        assertTrue(output.isPresent());
+        assertEquals("PREFIX----SUFFIX", output.get());
+        
+        Optional<String> output1 = ShardingAutoTableAlgorithmUtil.findMatchedTargetName(collection, "SUFFIXSTRING", dataNodeInfo);
+        assertTrue(output1.isPresent());
+        assertEquals("PREFIXSUFFIXSTRING", output1.get());
+        

Review Comment:
   Please remove useless blank line.



##########
features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/ShardingAutoTableAlgorithmUtilTest.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.algorithm.sharding;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Optional;
+import org.apache.shardingsphere.infra.datanode.DataNodeInfo;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ShardingAutoTableAlgorithmUtilTest {

Review Comment:
   Please add final for ShardingAutoTableAlgorithmUtilTest.



##########
features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/ShardingAutoTableAlgorithmUtilTest.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.algorithm.sharding;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Optional;
+import org.apache.shardingsphere.infra.datanode.DataNodeInfo;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ShardingAutoTableAlgorithmUtilTest {
+    
+    private Collection<String> collection;
+    
+    private DataNodeInfo dataNodeInfo;
+    
+    @Before
+    public void setup() {
+        collection = new ArrayList<>();
+        collection.add("PREFIX----SUFFIX");
+        collection.add("PREFIXSUFFIXSTRING");
+        collection.add("PREFIX----------");
+        
+        final String prefix = "PREFIX";
+        final int suffixMinLength = 10;
+        final char paddingChar = '-';
+        dataNodeInfo = new DataNodeInfo(prefix, suffixMinLength, paddingChar);
+    }
+    
+    @Test
+    public void assertFindMatchedTargetNameForValidInputs() {
+        

Review Comment:
   Please remove useless blank line.



##########
features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/algorithm/sharding/ShardingAutoTableAlgorithmUtilTest.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * 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.algorithm.sharding;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Optional;
+import org.apache.shardingsphere.infra.datanode.DataNodeInfo;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ShardingAutoTableAlgorithmUtilTest {
+    
+    private Collection<String> collection;
+    
+    private DataNodeInfo dataNodeInfo;
+    
+    @Before
+    public void setup() {
+        collection = new ArrayList<>();
+        collection.add("PREFIX----SUFFIX");
+        collection.add("PREFIXSUFFIXSTRING");
+        collection.add("PREFIX----------");
+        
+        final String prefix = "PREFIX";

Review Comment:
   Please remove final modifier in method domain.



-- 
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