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/25 12:37:04 UTC

[GitHub] [shardingsphere] pandaapo opened a new pull request, #21752: fix issue: add unit test for ReflectiveUtil.

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

   Fixes #21746.
   
   ---
   
   Before committing this PR, I'm sure that I have checked the following options:
   - [x] My code follows the [code of conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/) of this project.
   - [x] 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] pandaapo commented on pull request #21752: fix issue: add unit test for ReflectiveUtil.

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

   @sandynz Could you review this 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] sandynz commented on a diff in pull request #21752: fix issue: add unit test for ReflectiveUtil.

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


##########
infra/util/src/test/java/org/apache/shardingsphere/infra/util/reflect/ReflectiveUtilTest.java:
##########
@@ -0,0 +1,43 @@
+package org.apache.shardingsphere.infra.util.reflect;
+
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+public class ReflectiveUtilTest {

Review Comment:
   `final` should be added for class



##########
infra/util/src/test/java/org/apache/shardingsphere/infra/util/reflect/ReflectiveUtilTest.java:
##########
@@ -0,0 +1,43 @@
+package org.apache.shardingsphere.infra.util.reflect;

Review Comment:
   License header should be added



##########
infra/util/src/test/java/org/apache/shardingsphere/infra/util/reflect/ReflectiveUtilTest.java:
##########
@@ -0,0 +1,43 @@
+package org.apache.shardingsphere.infra.util.reflect;
+
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+public class ReflectiveUtilTest {
+
+    @Test
+    public void testGetFieldValue() {
+        UserPojo pojo = new UserPojo("test");
+        String fieldValue = (String)ReflectiveUtil.getFieldValue(pojo, "foo");

Review Comment:
   Blank is necessary after `(String)` for check style



##########
infra/util/src/test/java/org/apache/shardingsphere/infra/util/reflect/ReflectiveUtilTest.java:
##########
@@ -0,0 +1,43 @@
+package org.apache.shardingsphere.infra.util.reflect;
+
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+public class ReflectiveUtilTest {
+
+    @Test
+    public void testGetFieldValue() {

Review Comment:
   Unit test method name should start with `assert`, e.g. assertGetFieldValue



##########
infra/util/src/test/java/org/apache/shardingsphere/infra/util/reflect/ReflectiveUtilTest.java:
##########
@@ -0,0 +1,43 @@
+package org.apache.shardingsphere.infra.util.reflect;
+
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+public class ReflectiveUtilTest {
+
+    @Test
+    public void testGetFieldValue() {
+        UserPojo pojo = new UserPojo("test");
+        String fieldValue = (String)ReflectiveUtil.getFieldValue(pojo, "foo");
+        assertTrue("test".equals(fieldValue));
+    }
+
+    @Test
+    public void testSetField() {
+        UserPojo pojo = new UserPojo();
+        ReflectiveUtil.setField(pojo, "foo", "test");
+        assertTrue("test".equals(pojo.getFoo()));
+    }
+
+    @Test
+    public void testSetStaticField() {
+        ReflectiveUtil.setStaticField(UserPojo.class, "bar", "test");
+        assertTrue("test".equals(UserPojo.bar));
+    }
+
+    @AllArgsConstructor
+    @NoArgsConstructor

Review Comment:
   1, If XxxArgsConstructor is not required, then they could be removed.
   
   2, It's better to mark it as `private final` for inner class.
   



-- 
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] sandynz commented on pull request #21752: fix issue: add unit test for ReflectiveUtil.

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

   Hi @pandaapo , you could communicate it on the original issue. If there's new progress, I'll continue review.


-- 
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] pandaapo commented on pull request #21752: fix issue: add unit test for ReflectiveUtil.

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

   > @pandaapo , I'm sorry, I didn't check the related issue yesterday, it's already assigned to another contributor. This PR could not be merged, could you try another issue? There's suggestion in original issue.
   
   I noticed that. But my PR was committed one day before the assigning.


-- 
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] pandaapo commented on pull request #21752: fix issue: add unit test for ReflectiveUtil.

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

   > Thanks for you contribution. Since you just submit PR today, suggest to read through [Set up env](https://shardingsphere.apache.org/community/en/involved/contribute/dev-env/) and [Code of Conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/)
   
   Thanks for your guidance and review. I will check the contribute guide.


-- 
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] sandynz commented on pull request #21752: fix issue: add unit test for ReflectiveUtil.

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

   From the original issue, another issue is taken, so I close this 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] pandaapo commented on a diff in pull request #21752: fix issue: add unit test for ReflectiveUtil.

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


##########
infra/util/src/test/java/org/apache/shardingsphere/infra/util/reflect/ReflectiveUtilTest.java:
##########
@@ -0,0 +1,43 @@
+package org.apache.shardingsphere.infra.util.reflect;
+
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
+
+public class ReflectiveUtilTest {
+
+    @Test
+    public void testGetFieldValue() {
+        UserPojo pojo = new UserPojo("test");
+        String fieldValue = (String)ReflectiveUtil.getFieldValue(pojo, "foo");
+        assertTrue("test".equals(fieldValue));
+    }
+
+    @Test
+    public void testSetField() {
+        UserPojo pojo = new UserPojo();
+        ReflectiveUtil.setField(pojo, "foo", "test");
+        assertTrue("test".equals(pojo.getFoo()));
+    }
+
+    @Test
+    public void testSetStaticField() {
+        ReflectiveUtil.setStaticField(UserPojo.class, "bar", "test");
+        assertTrue("test".equals(UserPojo.bar));
+    }
+
+    @AllArgsConstructor
+    @NoArgsConstructor

Review Comment:
   The constructor with args was used in the test case.



-- 
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] sandynz commented on pull request #21752: fix issue: add unit test for ReflectiveUtil.

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

   @pandaapo , I'm sorry, I didn't check the related issue yesterday, it's already assigned to another contributor. This PR could not be merged, could you try another issue? There's suggestion in original issue.


-- 
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] sandynz closed pull request #21752: fix issue: add unit test for ReflectiveUtil.

Posted by GitBox <gi...@apache.org>.
sandynz closed pull request #21752: fix issue: add unit test for ReflectiveUtil.
URL: https://github.com/apache/shardingsphere/pull/21752


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