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/26 12:44:05 UTC

[GitHub] [shardingsphere] ishu-thakur opened a new pull request, #21778: Unit test cases for the ReflectiveUtil

ishu-thakur opened a new pull request, #21778:
URL: https://github.com/apache/shardingsphere/pull/21778

   Fixes #21746.
   
   Changes proposed in this pull request:
    Adding the Unit tests for the ReflectiveUtil by adding new test class file as ReflectiveUtilTest under reflect package.


-- 
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 #21778: Unit test cases for the ReflectiveUtil

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


##########
infra/util/src/test/java/org/apache/shardingsphere/infra/util/reflect/ReflectiveUtilTest.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * 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.util.reflect;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.AllArgsConstructor;
+import lombok.NoArgsConstructor;
+import lombok.AccessLevel;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public final class ReflectiveUtilTest {
+    
+    @Test
+    public void assertGetFieldValue() throws IllegalAccessError {
+        ReflectiveFixture reflectiveFixture = new ReflectiveFixture("bar");
+        assertThat(ReflectiveUtil.getFieldValue(reflectiveFixture, "value"), is("bar"));
+    }
+    
+    @Test
+    public void assertSetField() throws IllegalAccessError {
+        ReflectiveFixture reflectiveFixture = new ReflectiveFixture();
+        ReflectiveUtil.setField(reflectiveFixture, "value", "foo");
+        assertThat(ReflectiveUtil.getFieldValue(reflectiveFixture, "value"), is("foo"));
+    }
+    
+    @Test
+    public void assertSetStaticField() throws IllegalAccessError {
+        ReflectiveFixture reflectiveFixture = new ReflectiveFixture();
+        ReflectiveUtil.setStaticField(reflectiveFixture.getClass(), "staticValue", "foo");
+        assertThat(ReflectiveUtil.getFieldValue(reflectiveFixture, "staticValue"), is("foo"));
+    }
+    
+    @AllArgsConstructor
+    @NoArgsConstructor
+    @Getter
+    @Setter(AccessLevel.PRIVATE)
+    public static final class ReflectiveFixture {

Review Comment:
   It's better to use `private` 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 merged pull request #21778: Unit test cases for the ReflectiveUtil

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


-- 
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] ishu-thakur commented on pull request #21778: Unit test cases for the ReflectiveUtil

Posted by GitBox <gi...@apache.org>.
ishu-thakur commented on PR #21778:
URL: https://github.com/apache/shardingsphere/pull/21778#issuecomment-1291983741

   @sandynz @strongduanmu Please 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] codecov-commenter commented on pull request #21778: Unit test cases for the ReflectiveUtil

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

   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/21778?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 [#21778](https://codecov.io/gh/apache/shardingsphere/pull/21778?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (25aa182) into [master](https://codecov.io/gh/apache/shardingsphere/commit/e3f6fbb0b57d6b788b93b1196cdab355d13da085?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (e3f6fbb) will **increase** coverage by `0.02%`.
   > The diff coverage is `n/a`.
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #21778      +/-   ##
   ============================================
   + Coverage     60.79%   60.82%   +0.02%     
     Complexity     2446     2446              
   ============================================
     Files          4118     4118              
     Lines         57478    57478              
     Branches       9693     9693              
   ============================================
   + Hits          34945    34960      +15     
   + Misses        19627    19610      -17     
   - Partials       2906     2908       +2     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/21778?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...rdingsphere/infra/util/reflect/ReflectiveUtil.java](https://codecov.io/gh/apache/shardingsphere/pull/21778/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-aW5mcmEvdXRpbC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvaW5mcmEvdXRpbC9yZWZsZWN0L1JlZmxlY3RpdmVVdGlsLmphdmE=) | `71.42% <0.00%> (+71.42%)` | :arrow_up: |
   
   :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