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/17 05:06:14 UTC

[GitHub] [shardingsphere] captainbkarthick opened a new pull request, #21603: [ISSUE #21569] Add Tests for ShardingAutoTableAlgorithmUtil Class

captainbkarthick opened a new pull request, #21603:
URL: https://github.com/apache/shardingsphere/pull/21603

   Fixes #21569
   
   Changes proposed in this pull request:
     - Add Test cases for the class ShardingAutoTableAlgorithmUtil.java
   ---
   
   Before committing this PR, I'm sure that I have checked the following options:
   - [ ] My code follows the [code of conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/) of this project.
   - [ ] I have self-reviewed the commit code.
   - [ ] I have (or in comment I request) added corresponding labels for the pull request.
   - [ ] I have passed maven check locally : `mvn clean install -B -T2C -DskipTests -Dmaven.javadoc.skip=true -e`.
   - [ ] I have made corresponding changes to the documentation.
   - [ ] I have added corresponding unit tests for my changes.
   


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


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

Posted by GitBox <gi...@apache.org>.
captainbkarthick commented on code in PR #21603:
URL: https://github.com/apache/shardingsphere/pull/21603#discussion_r999375420


##########
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:
   @strongduanmu 
   "assertThat" is a deprecated method. Hence I used "assertEquals".
   Please confirm if you still need to make it as "assertThat"



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


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

Posted by GitBox <gi...@apache.org>.
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


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

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on code in PR #21603:
URL: https://github.com/apache/shardingsphere/pull/21603#discussion_r1000035073


##########
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:
   > @strongduanmu "assertThat" is a deprecated method. Hence I used "assertEquals". Please confirm if you still need to make it as "assertThat"
   
   Of course, you can read [code of conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/) first.
   



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


[GitHub] [shardingsphere] captainbkarthick commented on pull request #21603: [ISSUE #21569] Add Tests for ShardingAutoTableAlgorithmUtil Class

Posted by GitBox <gi...@apache.org>.
captainbkarthick commented on PR #21603:
URL: https://github.com/apache/shardingsphere/pull/21603#issuecomment-1282254325

   @strongduanmu ,
   Requesting to check and approve the PR


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


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

Posted by GitBox <gi...@apache.org>.
captainbkarthick commented on code in PR #21603:
URL: https://github.com/apache/shardingsphere/pull/21603#discussion_r1000038051


##########
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:
   @strongduanmu,
   Sure.
   I'll make the change and push. 



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


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

Posted by GitBox <gi...@apache.org>.
captainbkarthick commented on code in PR #21603:
URL: https://github.com/apache/shardingsphere/pull/21603#discussion_r999379976


##########
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:
   Fixed this and pushed the changes



##########
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:
   Fixed this and pushed the changes



##########
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:
   Fixed this and pushed the changes



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


[GitHub] [shardingsphere] strongduanmu merged pull request #21603: [ISSUE #21569] Add Tests for ShardingAutoTableAlgorithmUtil Class

Posted by GitBox <gi...@apache.org>.
strongduanmu merged PR #21603:
URL: https://github.com/apache/shardingsphere/pull/21603


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


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

Posted by GitBox <gi...@apache.org>.
captainbkarthick commented on code in PR #21603:
URL: https://github.com/apache/shardingsphere/pull/21603#discussion_r999380282


##########
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:
   Fixed this and pushed the changes



##########
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:
   Fixed this and pushed the changes



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


[GitHub] [shardingsphere] codecov-commenter commented on pull request #21603: [ISSUE #21569] Add Tests for ShardingAutoTableAlgorithmUtil Class

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #21603:
URL: https://github.com/apache/shardingsphere/pull/21603#issuecomment-1282392810

   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/21603?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#21603](https://codecov.io/gh/apache/shardingsphere/pull/21603?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (83c5b1a) into [master](https://codecov.io/gh/apache/shardingsphere/commit/d29e64f018e9510d5e8f9aaae7f68fd72718ea02?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (d29e64f) will **increase** coverage by `0.06%`.
   > The diff coverage is `100.00%`.
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #21603      +/-   ##
   ============================================
   + Coverage     61.03%   61.10%   +0.06%     
   - Complexity     2509     2511       +2     
   ============================================
     Files          4111     4111              
     Lines         57302    57288      -14     
     Branches       7589     7589              
   ============================================
   + Hits          34976    35006      +30     
   + Misses        19392    19348      -44     
     Partials       2934     2934              
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/21603?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...rithm/sharding/ShardingAutoTableAlgorithmUtil.java](https://codecov.io/gh/apache/shardingsphere/pull/21603/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmVhdHVyZXMvc2hhcmRpbmcvY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvYWxnb3JpdGhtL3NoYXJkaW5nL1NoYXJkaW5nQXV0b1RhYmxlQWxnb3JpdGhtVXRpbC5qYXZh) | `100.00% <100.00%> (ø)` | |
   | [...arding/datetime/AutoIntervalShardingAlgorithm.java](https://codecov.io/gh/apache/shardingsphere/pull/21603/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmVhdHVyZXMvc2hhcmRpbmcvY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvYWxnb3JpdGhtL3NoYXJkaW5nL2RhdGV0aW1lL0F1dG9JbnRlcnZhbFNoYXJkaW5nQWxnb3JpdGhtLmphdmE=) | `93.33% <100.00%> (ø)` | |
   | [...gorithm/sharding/mod/HashModShardingAlgorithm.java](https://codecov.io/gh/apache/shardingsphere/pull/21603/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmVhdHVyZXMvc2hhcmRpbmcvY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvYWxnb3JpdGhtL3NoYXJkaW5nL21vZC9IYXNoTW9kU2hhcmRpbmdBbGdvcml0aG0uamF2YQ==) | `100.00% <100.00%> (ø)` | |
   | [...g/algorithm/sharding/mod/ModShardingAlgorithm.java](https://codecov.io/gh/apache/shardingsphere/pull/21603/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmVhdHVyZXMvc2hhcmRpbmcvY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvYWxnb3JpdGhtL3NoYXJkaW5nL21vZC9Nb2RTaGFyZGluZ0FsZ29yaXRobS5qYXZh) | `93.02% <100.00%> (ø)` | |
   | [...sharding/range/AbstractRangeShardingAlgorithm.java](https://codecov.io/gh/apache/shardingsphere/pull/21603/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmVhdHVyZXMvc2hhcmRpbmcvY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvYWxnb3JpdGhtL3NoYXJkaW5nL3JhbmdlL0Fic3RyYWN0UmFuZ2VTaGFyZGluZ0FsZ29yaXRobS5qYXZh) | `90.90% <100.00%> (ø)` | |
   | [...kend/config/yaml/YamlProxyServerConfiguration.java](https://codecov.io/gh/apache/shardingsphere/pull/21603/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHJveHkvYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC9jb25maWcveWFtbC9ZYW1sUHJveHlTZXJ2ZXJDb25maWd1cmF0aW9uLmphdmE=) | `55.55% <0.00%> (-22.23%)` | :arrow_down: |
   | [...ndler/impl/BarrierMetaDataChangedEventHandler.java](https://codecov.io/gh/apache/shardingsphere/pull/21603/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a2VybmVsL2RhdGEtcGlwZWxpbmUvY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvZGF0YS9waXBlbGluZS9jb3JlL21ldGFkYXRhL25vZGUvZXZlbnQvaGFuZGxlci9pbXBsL0JhcnJpZXJNZXRhRGF0YUNoYW5nZWRFdmVudEhhbmRsZXIuamF2YQ==) | `20.00% <0.00%> (-13.34%)` | :arrow_down: |
   | [...ReplicationDatabaseDiscoveryProviderAlgorithm.java](https://codecov.io/gh/apache/shardingsphere/pull/21603/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmVhdHVyZXMvZGItZGlzY292ZXJ5L3Byb3ZpZGVyL29wZW5nYXVzcy9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvZGJkaXNjb3Zlcnkvb3BlbmdhdXNzL09wZW5HYXVzc05vcm1hbFJlcGxpY2F0aW9uRGF0YWJhc2VEaXNjb3ZlcnlQcm92aWRlckFsZ29yaXRobS5qYXZh) | `26.31% <0.00%> (-3.69%)` | :arrow_down: |
   | [.../packet/binlog/AbstractMySQLBinlogEventPacket.java](https://codecov.io/gh/apache/shardingsphere/pull/21603/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZGItcHJvdG9jb2wvbXlzcWwvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2RiL3Byb3RvY29sL215c3FsL3BhY2tldC9iaW5sb2cvQWJzdHJhY3RNeVNRTEJpbmxvZ0V2ZW50UGFja2V0LmphdmE=) | `66.66% <0.00%> (-3.34%)` | :arrow_down: |
   | [...distsql/rdl/rule/RuleDefinitionBackendHandler.java](https://codecov.io/gh/apache/shardingsphere/pull/21603/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHJveHkvYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC9oYW5kbGVyL2Rpc3RzcWwvcmRsL3J1bGUvUnVsZURlZmluaXRpb25CYWNrZW5kSGFuZGxlci5qYXZh) | `74.46% <0.00%> (-3.09%)` | :arrow_down: |
   | ... and [84 more](https://codecov.io/gh/apache/shardingsphere/pull/21603/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


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


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

Posted by GitBox <gi...@apache.org>.
captainbkarthick commented on code in PR #21603:
URL: https://github.com/apache/shardingsphere/pull/21603#discussion_r1000172986


##########
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:
   @strongduanmu ,
   The changes are pushed.
   Requesting to check.
   
   Thanks.



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