File tree Expand file tree Collapse file tree 4 files changed +36
-0
lines changed
main/java/net/andreinc/mockneat/unit/objects
test/java/net/andreinc/mockneat/unit/objects Expand file tree Collapse file tree 4 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ .gradlew
2+ .gradlew.bat
13.gradle /*
24! gradle /wrapper /gradle-wrapper.jar
35.idea /*
Original file line number Diff line number Diff line change 2323import net .andreinc .mockneat .abstraction .MockValue ;
2424
2525import java .lang .reflect .Field ;
26+ import java .lang .reflect .Modifier ;
2627import java .util .HashMap ;
2728import java .util .LinkedHashMap ;
2829import java .util .Map ;
@@ -154,6 +155,11 @@ private void setValues(T object) {
154155 return ;
155156 }
156157
158+ if (Modifier .isStatic (field .getModifiers ())) {
159+ // Skip static fields
160+ return ;
161+ }
162+
157163 String name = field .getName ();
158164 Class <?> fieldCls = field .getType ();
159165 Object val = null ;
Original file line number Diff line number Diff line change 1919
2020import net .andreinc .mockneat .unit .objects .model .Customer1 ;
2121import net .andreinc .mockneat .unit .objects .model .FinalValue ;
22+ import net .andreinc .mockneat .unit .objects .model .SerialPojo ;
2223import net .andreinc .mockneat .unit .objects .model .TheAbstractClass ;
2324import net .andreinc .mockneat .Constants ;
2425import net .andreinc .mockneat .utils .NamesCheckUtils ;
@@ -178,4 +179,10 @@ public void testReflectionConstructWithConstantDefaults() throws Exception {
178179 }
179180 );
180181 }
182+
183+ @ Test
184+ public void testSerialUIDPojo () throws Exception {
185+ // Checks issue with static fields
186+ M .reflect (SerialPojo .class ).field ("name" , M .names ()).val ();
187+ }
181188}
Original file line number Diff line number Diff line change 1+ package net .andreinc .mockneat .unit .objects .model ;
2+
3+ import java .io .Serializable ;
4+
5+ public class SerialPojo implements Serializable {
6+
7+ private static final long serialVersionUID = 42L ;
8+
9+ private String name ;
10+
11+ public SerialPojo () {
12+ }
13+
14+ public String getName () {
15+ return name ;
16+ }
17+
18+ public void setName (String name ) {
19+ this .name = name ;
20+ }
21+ }
You can’t perform that action at this time.
0 commit comments