The following issues were found

src/test/java/com/alibaba/json/bvt/util/TypeUtilsCastLinkedHashMap.java
4 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 11

              import java.util.LinkedHashMap;

public class TypeUtilsCastLinkedHashMap extends TestCase {
    public void test_for_cast() throws Exception {
        JSONObject obj = JSON.parseObject("{\"id\":1001,\"name\":\"xxx\"}", Feature.OrderedField);
        obj.toJavaObject(LinkedHashMap.class);
    }
}

            

Reported by PMD.

JUnit tests should include assert() or fail()
Design

Line: 11

              import java.util.LinkedHashMap;

public class TypeUtilsCastLinkedHashMap extends TestCase {
    public void test_for_cast() throws Exception {
        JSONObject obj = JSON.parseObject("{\"id\":1001,\"name\":\"xxx\"}", Feature.OrderedField);
        obj.toJavaObject(LinkedHashMap.class);
    }
}

            

Reported by PMD.

Avoid using implementation types like 'LinkedHashMap'; use the interface instead
Design

Line: 13

              public class TypeUtilsCastLinkedHashMap extends TestCase {
    public void test_for_cast() throws Exception {
        JSONObject obj = JSON.parseObject("{\"id\":1001,\"name\":\"xxx\"}", Feature.OrderedField);
        obj.toJavaObject(LinkedHashMap.class);
    }
}

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 13

              public class TypeUtilsCastLinkedHashMap extends TestCase {
    public void test_for_cast() throws Exception {
        JSONObject obj = JSON.parseObject("{\"id\":1001,\"name\":\"xxx\"}", Feature.OrderedField);
        obj.toJavaObject(LinkedHashMap.class);
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/DefaultObjectDeserializerTest3.java
4 issues
JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll
Design

Line: 14

              
@SuppressWarnings("rawtypes")
public class DefaultObjectDeserializerTest3 extends TestCase {
    protected void setUp() throws Exception {
        ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.AbstractSerializeTest2");
    }

    public void test_0() throws Exception {
        HashMap o = (HashMap) JSON.parse("{\"@type\":\"java.lang.Cloneable\"}");

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 15

              @SuppressWarnings("rawtypes")
public class DefaultObjectDeserializerTest3 extends TestCase {
    protected void setUp() throws Exception {
        ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.AbstractSerializeTest2");
    }

    public void test_0() throws Exception {
        HashMap o = (HashMap) JSON.parse("{\"@type\":\"java.lang.Cloneable\"}");
        Assert.assertEquals(0, o.size());

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 18

                      ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.AbstractSerializeTest2");
    }

    public void test_0() throws Exception {
        HashMap o = (HashMap) JSON.parse("{\"@type\":\"java.lang.Cloneable\"}");
        Assert.assertEquals(0, o.size());
    }
}

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 20

              
    public void test_0() throws Exception {
        HashMap o = (HashMap) JSON.parse("{\"@type\":\"java.lang.Cloneable\"}");
        Assert.assertEquals(0, o.size());
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/DefaultObjectDeserializerTest4.java
4 issues
JUnit tests should include assert() or fail()
Design

Line: 12

              
public class DefaultObjectDeserializerTest4 extends TestCase {

    public void test_0() throws Exception {
        DefaultJSONParser parser = new DefaultJSONParser("{\"id\":3, \"name\":\"xx\"}", ParserConfig.getGlobalInstance());

        Entity entity = new Entity();
        parser.parseObject(entity);
    }

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 12

              
public class DefaultObjectDeserializerTest4 extends TestCase {

    public void test_0() throws Exception {
        DefaultJSONParser parser = new DefaultJSONParser("{\"id\":3, \"name\":\"xx\"}", ParserConfig.getGlobalInstance());

        Entity entity = new Entity();
        parser.parseObject(entity);
    }

            

Reported by PMD.

JUnit tests should include assert() or fail()
Design

Line: 19

                      parser.parseObject(entity);
    }

    public void test_1() throws Exception {
        JSON.parseObject("{\"id\":3, \"name\":\"xx\"}", Entity.class, 0, Feature.IgnoreNotMatch);
    }

    public static class Entity {


            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 19

                      parser.parseObject(entity);
    }

    public void test_1() throws Exception {
        JSON.parseObject("{\"id\":3, \"name\":\"xx\"}", Entity.class, 0, Feature.IgnoreNotMatch);
    }

    public static class Entity {


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/DefaultObjectDeserializerTest8.java
4 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 14

              
public class DefaultObjectDeserializerTest8 extends TestCase {

    public <T> void test_1() throws Exception {
        VO<T> vo = JSON.parseObject("{\"value\":[{\"id\":123}]}", new TypeReference<VO<T>>() {
        });
        Assert.assertNotNull(vo.getValue()[0]);
        Assert.assertTrue(vo.getValue()[0] instanceof Map);
    }

            

Reported by PMD.

Returning 'value' may expose an internal array.
Design

Line: 26

                      private T[] value;

        public T[] getValue() {
            return value;
        }

        public void setValue(T[] value) {
            this.value = value;
        }

            

Reported by PMD.

The user-supplied array 'value' is stored directly.
Design

Line: 29

                          return value;
        }

        public void setValue(T[] value) {
            this.value = value;
        }

    }


            

Reported by PMD.

Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 29

                          return value;
        }

        public void setValue(T[] value) {
            this.value = value;
        }

    }


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/support/spring/data/PageToJSONTest.java
4 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 16

              import junit.framework.TestCase;

public class PageToJSONTest extends TestCase {
    public void test_page() throws Exception {
        List<Post> postList = new ArrayList<Post>();
        {
            postList.add(new Post(1001));
        }
        

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 26

                      
        JSONObject obj = (JSONObject) JSON.toJSON(page);
        Assert.assertNotNull(obj);
        Assert.assertEquals(1, obj.getJSONArray("content").size());
    }
    
    public static class Post{
        public int id;
        

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 26

                      
        JSONObject obj = (JSONObject) JSON.toJSON(page);
        Assert.assertNotNull(obj);
        Assert.assertEquals(1, obj.getJSONArray("content").size());
    }
    
    public static class Post{
        public int id;
        

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 30

                  }
    
    public static class Post{
        public int id;
        
        public Post() {
            
        }
        

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/TimeZoneTest.java
4 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 12

              
public class TimeZoneTest extends TestCase {

    public void test_timezone() throws Exception {
        TimeZone tz1 = TimeZone.getDefault();
        String text = JSON.toJSONString(tz1);

        Assert.assertEquals(JSON.toJSONString(tz1.getID()), text);
        

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 16

                      TimeZone tz1 = TimeZone.getDefault();
        String text = JSON.toJSONString(tz1);

        Assert.assertEquals(JSON.toJSONString(tz1.getID()), text);
        
        TimeZone tz2 = JSON.parseObject(text, TimeZone.class);
        Assert.assertEquals(tz1.getID(), tz2.getID());
    }
}

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 19

                      Assert.assertEquals(JSON.toJSONString(tz1.getID()), text);
        
        TimeZone tz2 = JSON.parseObject(text, TimeZone.class);
        Assert.assertEquals(tz1.getID(), tz2.getID());
    }
}

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 19

                      Assert.assertEquals(JSON.toJSONString(tz1.getID()), text);
        
        TimeZone tz2 = JSON.parseObject(text, TimeZone.class);
        Assert.assertEquals(tz1.getID(), tz2.getID());
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/support/spring/FastJsonRedisSerializerTest.java
4 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 18

              

public class FastJsonRedisSerializerTest {
    private FastJsonRedisSerializer<User> serializer;

    @Before
    public void setUp() {
        this.serializer = new FastJsonRedisSerializer<User>(User.class);
    }

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 70

                      fastJsonConfig.setSerializerFeatures(serializerFeatures);

        ParserConfig parserConfig = ParserConfig.getGlobalInstance();
        parserConfig.setAutoTypeSupport(true);
        fastJsonConfig.setParserConfig(parserConfig);

        FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer(Object.class);
        Assert.assertNotNull(fastJsonRedisSerializer.getFastJsonConfig());
        fastJsonRedisSerializer.setFastJsonConfig(fastJsonConfig);

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 82

                      byte[] serializedValue = fastJsonRedisSerializer.serialize(userSer);
        User userDes = (User) fastJsonRedisSerializer.deserialize(serializedValue);

        Assert.assertEquals(userDes.getName(), "土豆");
    }

    static class User {
        private Integer id;
        private String name;

            

Reported by PMD.

The class 'User' is suspected to be a Data Class (WOC=0.000%, NOPA=0, NOAM=6, WMC=8)
Design

Line: 85

                      Assert.assertEquals(userDes.getName(), "土豆");
    }

    static class User {
        private Integer id;
        private String name;
        private Integer age;

        public User() {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/URITest.java
4 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 12

              
public class URITest extends TestCase {

    public void test_file() throws Exception {
        URI uri = URI.create("http://www.alibaba.com/");

        String text = JSON.toJSONString(uri);

        Assert.assertEquals(JSON.toJSONString(uri.toString()), text);

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 17

              
        String text = JSON.toJSONString(uri);

        Assert.assertEquals(JSON.toJSONString(uri.toString()), text);

        URI uri2 = JSON.parseObject(text, URI.class);
        Assert.assertEquals(uri.toString(), uri2.toString());
    }
}

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 20

                      Assert.assertEquals(JSON.toJSONString(uri.toString()), text);

        URI uri2 = JSON.parseObject(text, URI.class);
        Assert.assertEquals(uri.toString(), uri2.toString());
    }
}

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 20

                      Assert.assertEquals(JSON.toJSONString(uri.toString()), text);

        URI uri2 = JSON.parseObject(text, URI.class);
        Assert.assertEquals(uri.toString(), uri2.toString());
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/WriteClassNameTest.java
4 issues
System.out.println is used
Design

Line: 20

                      SerializeConfig config = new SerializeConfig();
        config.setAsmEnable(false);
        String text = JSON.toJSONString(object, config, SerializerFeature.WriteClassName);
        System.out.println(text);
    }

    public static class Entity {

        private int    id;

            

Reported by PMD.

JUnit tests should include assert() or fail()
Design

Line: 11

              
public class WriteClassNameTest extends TestCase {

    public void test_writeClassName() throws Exception {
        Entity object = new Entity();
        object.setId(123);
        object.setName("jobs");
        object.setAverage(3.21F);
        

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 11

              
public class WriteClassNameTest extends TestCase {

    public void test_writeClassName() throws Exception {
        Entity object = new Entity();
        object.setId(123);
        object.setName("jobs");
        object.setAverage(3.21F);
        

            

Reported by PMD.

The class 'Entity' is suspected to be a Data Class (WOC=0.000%, NOPA=0, NOAM=6, WMC=6)
Design

Line: 23

                      System.out.println(text);
    }

    public static class Entity {

        private int    id;
        private String name;
        private float  average;


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/SmartMatchTest2.java
4 issues
A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 12

              
public class SmartMatchTest2 extends TestCase {
    
    public void f_test_0 () throws Exception {
        String text = "{\"_id\":1001}";
        
        VO vo = JSON.parseObject(text, VO.class);
        Assert.assertEquals(1001, vo.getId());
    }

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 16

                      String text = "{\"_id\":1001}";
        
        VO vo = JSON.parseObject(text, VO.class);
        Assert.assertEquals(1001, vo.getId());
    }
    
    public void test_vo2 () throws Exception {
        String text = "{\"_id\":1001}";
        

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 19

                      Assert.assertEquals(1001, vo.getId());
    }
    
    public void test_vo2 () throws Exception {
        String text = "{\"_id\":1001}";
        
        VO2 vo = JSON.parseObject(text, VO2.class);
        Assert.assertEquals(1001, vo.getId());
    }

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 23

                      String text = "{\"_id\":1001}";
        
        VO2 vo = JSON.parseObject(text, VO2.class);
        Assert.assertEquals(1001, vo.getId());
    }

    private static class VO {

        private int id;

            

Reported by PMD.