The following issues were found

src/test/java/com/alibaba/json/bvt/writeClassName/WriteClassNameTest_List3.java
11 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 15

              
public class WriteClassNameTest_List3 extends TestCase {

    public void test_list() throws Exception {
        Model model = new Model();
        List tables = new ArrayList();
        tables.add(new ExtTable(1001));
        tables.add(new Table());
        model.setTables(tables);

            

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

              
public class WriteClassNameTest_List3 extends TestCase {

    public void test_list() throws Exception {
        Model model = new Model();
        List tables = new ArrayList();
        tables.add(new ExtTable(1001));
        tables.add(new Table());
        model.setTables(tables);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 23

                      model.setTables(tables);

        String json = JSON.toJSONString(model);
        assertEquals("{\"tables\":[{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_List3$ExtTable\",\"id\":1001},{}]}", json);

        Model model2 = JSON.parseObject(json, Model.class);
        assertEquals(ExtTable.class, model2.getTables().iterator().next().getClass());
    }


            

Reported by PMD.

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

Line: 26

                      assertEquals("{\"tables\":[{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_List3$ExtTable\",\"id\":1001},{}]}", json);

        Model model2 = JSON.parseObject(json, Model.class);
        assertEquals(ExtTable.class, model2.getTables().iterator().next().getClass());
    }

    public static class Model {
        @JSONField(serialzeFeatures = SerializerFeature.WriteClassName)
        private List<? extends Table> tables;

            

Reported by PMD.

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

Line: 26

                      assertEquals("{\"tables\":[{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_List3$ExtTable\",\"id\":1001},{}]}", json);

        Model model2 = JSON.parseObject(json, Model.class);
        assertEquals(ExtTable.class, model2.getTables().iterator().next().getClass());
    }

    public static class Model {
        @JSONField(serialzeFeatures = SerializerFeature.WriteClassName)
        private List<? extends Table> tables;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 26

                      assertEquals("{\"tables\":[{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_List3$ExtTable\",\"id\":1001},{}]}", json);

        Model model2 = JSON.parseObject(json, Model.class);
        assertEquals(ExtTable.class, model2.getTables().iterator().next().getClass());
    }

    public static class Model {
        @JSONField(serialzeFeatures = SerializerFeature.WriteClassName)
        private List<? extends Table> tables;

            

Reported by PMD.

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

Line: 26

                      assertEquals("{\"tables\":[{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_List3$ExtTable\",\"id\":1001},{}]}", json);

        Model model2 = JSON.parseObject(json, Model.class);
        assertEquals(ExtTable.class, model2.getTables().iterator().next().getClass());
    }

    public static class Model {
        @JSONField(serialzeFeatures = SerializerFeature.WriteClassName)
        private List<? extends Table> tables;

            

Reported by PMD.

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

Line: 26

                      assertEquals("{\"tables\":[{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_List3$ExtTable\",\"id\":1001},{}]}", json);

        Model model2 = JSON.parseObject(json, Model.class);
        assertEquals(ExtTable.class, model2.getTables().iterator().next().getClass());
    }

    public static class Model {
        @JSONField(serialzeFeatures = SerializerFeature.WriteClassName)
        private List<? extends Table> tables;

            

Reported by PMD.

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

Line: 47

                  }

    public static class ExtTable extends Table {
        public int id;

        public ExtTable() {

        }


            

Reported by PMD.

Avoid unused imports such as 'java.util.HashSet'
Design

Line: 9

              import junit.framework.TestCase;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class WriteClassNameTest_List3 extends TestCase {


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/UUIDFieldTest.java
11 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 UUIDFieldTest extends TestCase {

    public void test_codec() throws Exception {
        User user = new User();
        user.setValue(UUID.randomUUID());

        SerializeConfig mapping = new SerializeConfig();
        mapping.setAsmEnable(false);

            

Reported by PMD.

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

Line: 24

              
        User user1 = JSON.parseObject(text, User.class);

        Assert.assertEquals(user1.getValue(), user.getValue());
    }
    public void test_codec_upper_case() throws Exception {
       User  user = new User();

       String text ="{\"value\":\"79104776-6CA7-4E41-948F-4D2ECD06502A\"}";

            

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

              
        Assert.assertEquals(user1.getValue(), user.getValue());
    }
    public void test_codec_upper_case() throws Exception {
       User  user = new User();

       String text ="{\"value\":\"79104776-6CA7-4E41-948F-4D2ECD06502A\"}";
       user = JSON.parseObject(text,  User.class);


            

Reported by PMD.

The initializer for variable 'user' is never used (overwritten on line 30)
Design

Line: 27

                      Assert.assertEquals(user1.getValue(), user.getValue());
    }
    public void test_codec_upper_case() throws Exception {
       User  user = new User();

       String text ="{\"value\":\"79104776-6CA7-4E41-948F-4D2ECD06502A\"}";
       user = JSON.parseObject(text,  User.class);

       Assert.assertEquals("79104776-6CA7-4E41-948F-4D2ECD06502A", user.getValue().toString().toUpperCase());	   

            

Reported by PMD.

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

Line: 32

                     String text ="{\"value\":\"79104776-6CA7-4E41-948F-4D2ECD06502A\"}";
       user = JSON.parseObject(text,  User.class);

       Assert.assertEquals("79104776-6CA7-4E41-948F-4D2ECD06502A", user.getValue().toString().toUpperCase());	   
    }  

    public void test_codec_null() throws Exception {
        User user = new User();
        user.setValue(null);

            

Reported by PMD.

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

Line: 32

                     String text ="{\"value\":\"79104776-6CA7-4E41-948F-4D2ECD06502A\"}";
       user = JSON.parseObject(text,  User.class);

       Assert.assertEquals("79104776-6CA7-4E41-948F-4D2ECD06502A", user.getValue().toString().toUpperCase());	   
    }  

    public void test_codec_null() throws Exception {
        User user = new User();
        user.setValue(null);

            

Reported by PMD.

When doing a String.toLowerCase()/toUpperCase() call, use a Locale
Error

Line: 32

                     String text ="{\"value\":\"79104776-6CA7-4E41-948F-4D2ECD06502A\"}";
       user = JSON.parseObject(text,  User.class);

       Assert.assertEquals("79104776-6CA7-4E41-948F-4D2ECD06502A", user.getValue().toString().toUpperCase());	   
    }  

    public void test_codec_null() throws Exception {
        User user = new User();
        user.setValue(null);

            

Reported by PMD.

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

Line: 32

                     String text ="{\"value\":\"79104776-6CA7-4E41-948F-4D2ECD06502A\"}";
       user = JSON.parseObject(text,  User.class);

       Assert.assertEquals("79104776-6CA7-4E41-948F-4D2ECD06502A", user.getValue().toString().toUpperCase());	   
    }  

    public void test_codec_null() throws Exception {
        User user = new User();
        user.setValue(null);

            

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

                     Assert.assertEquals("79104776-6CA7-4E41-948F-4D2ECD06502A", user.getValue().toString().toUpperCase());	   
    }  

    public void test_codec_null() throws Exception {
        User user = new User();
        user.setValue(null);

        SerializeConfig mapping = new SerializeConfig();
        mapping.setAsmEnable(false);

            

Reported by PMD.

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

Line: 45

              
        User user1 = JSON.parseObject(text, User.class);

        Assert.assertEquals(user1.getValue(), user.getValue());
    }

    public static class User {

        private UUID value;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/DefaultObjectDeserializerTest6.java
11 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: 17

              
public class DefaultObjectDeserializerTest6 extends TestCase {

    public void test_0() throws Exception {
        Entity vo = JSON.parseObject("{\"value\":{\"1\":{},\"2\":{\"$ref\":\"$.value.1\"}}}", Entity.class);
        Assert.assertSame(vo.getValue().get("1"), vo.getValue().get("2"));
    }
    
    public void test_1() throws Exception {

            

Reported by PMD.

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

Line: 19

              
    public void test_0() throws Exception {
        Entity vo = JSON.parseObject("{\"value\":{\"1\":{},\"2\":{\"$ref\":\"$.value.1\"}}}", Entity.class);
        Assert.assertSame(vo.getValue().get("1"), vo.getValue().get("2"));
    }
    
    public void test_1() throws Exception {
        Entity vo = JSON.parseObject("{\"value\":{\"1\":{},\"2\":{\"$ref\":\"..\"}}}", Entity.class);
        Assert.assertSame(vo.getValue(), vo.getValue().get("2"));

            

Reported by PMD.

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

Line: 19

              
    public void test_0() throws Exception {
        Entity vo = JSON.parseObject("{\"value\":{\"1\":{},\"2\":{\"$ref\":\"$.value.1\"}}}", Entity.class);
        Assert.assertSame(vo.getValue().get("1"), vo.getValue().get("2"));
    }
    
    public void test_1() throws Exception {
        Entity vo = JSON.parseObject("{\"value\":{\"1\":{},\"2\":{\"$ref\":\"..\"}}}", Entity.class);
        Assert.assertSame(vo.getValue(), vo.getValue().get("2"));

            

Reported by PMD.

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

Line: 19

              
    public void test_0() throws Exception {
        Entity vo = JSON.parseObject("{\"value\":{\"1\":{},\"2\":{\"$ref\":\"$.value.1\"}}}", Entity.class);
        Assert.assertSame(vo.getValue().get("1"), vo.getValue().get("2"));
    }
    
    public void test_1() throws Exception {
        Entity vo = JSON.parseObject("{\"value\":{\"1\":{},\"2\":{\"$ref\":\"..\"}}}", Entity.class);
        Assert.assertSame(vo.getValue(), vo.getValue().get("2"));

            

Reported by PMD.

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

Line: 19

              
    public void test_0() throws Exception {
        Entity vo = JSON.parseObject("{\"value\":{\"1\":{},\"2\":{\"$ref\":\"$.value.1\"}}}", Entity.class);
        Assert.assertSame(vo.getValue().get("1"), vo.getValue().get("2"));
    }
    
    public void test_1() throws Exception {
        Entity vo = JSON.parseObject("{\"value\":{\"1\":{},\"2\":{\"$ref\":\"..\"}}}", Entity.class);
        Assert.assertSame(vo.getValue(), vo.getValue().get("2"));

            

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

                      Assert.assertSame(vo.getValue().get("1"), vo.getValue().get("2"));
    }
    
    public void test_1() throws Exception {
        Entity vo = JSON.parseObject("{\"value\":{\"1\":{},\"2\":{\"$ref\":\"..\"}}}", Entity.class);
        Assert.assertSame(vo.getValue(), vo.getValue().get("2"));
    }
    
    public static class Entity {

            

Reported by PMD.

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

Line: 24

                  
    public void test_1() throws Exception {
        Entity vo = JSON.parseObject("{\"value\":{\"1\":{},\"2\":{\"$ref\":\"..\"}}}", Entity.class);
        Assert.assertSame(vo.getValue(), vo.getValue().get("2"));
    }
    
    public static class Entity {

        private final Map<Object, Map<Object, Object>> value;

            

Reported by PMD.

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

Line: 24

                  
    public void test_1() throws Exception {
        Entity vo = JSON.parseObject("{\"value\":{\"1\":{},\"2\":{\"$ref\":\"..\"}}}", Entity.class);
        Assert.assertSame(vo.getValue(), vo.getValue().get("2"));
    }
    
    public static class Entity {

        private final Map<Object, Map<Object, Object>> value;

            

Reported by PMD.

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

Line: 24

                  
    public void test_1() throws Exception {
        Entity vo = JSON.parseObject("{\"value\":{\"1\":{},\"2\":{\"$ref\":\"..\"}}}", Entity.class);
        Assert.assertSame(vo.getValue(), vo.getValue().get("2"));
    }
    
    public static class Entity {

        private final Map<Object, Map<Object, Object>> value;

            

Reported by PMD.

Avoid unused imports such as 'java.util.List'
Design

Line: 3

              package com.alibaba.json.bvt.parser.deser;

import java.util.List;
import java.util.Map;

import junit.framework.TestCase;

import org.junit.Assert;


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/BigIntegerDeserializerTest.java
11 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 BigIntegerDeserializerTest extends TestCase {

    public void test_1() throws Exception {

        BigInteger value = JSON.parseObject("'123'", BigInteger.class);

        Assert.assertEquals(new BigInteger("123"), value);
    }

            

Reported by PMD.

The String literal '123' appears 4 times in this file; the first occurrence is on line 18
Error

Line: 18

              
        BigInteger value = JSON.parseObject("'123'", BigInteger.class);

        Assert.assertEquals(new BigInteger("123"), value);
    }

    public void test_vo() throws Exception {

        VO vo = JSON.parseObject("{\"value\":123}", VO.class);

            

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

                      Assert.assertEquals(new BigInteger("123"), value);
    }

    public void test_vo() throws Exception {

        VO vo = JSON.parseObject("{\"value\":123}", VO.class);

        Assert.assertEquals(new BigInteger("123"), vo.getValue());
    }

            

Reported by PMD.

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

Line: 25

              
        VO vo = JSON.parseObject("{\"value\":123}", VO.class);

        Assert.assertEquals(new BigInteger("123"), vo.getValue());
    }

    public void test_vo_null() throws Exception {

        VO vo = JSON.parseObject("{\"value\":null}", VO.class);

            

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

                      Assert.assertEquals(new BigInteger("123"), vo.getValue());
    }

    public void test_vo_null() throws Exception {

        VO vo = JSON.parseObject("{\"value\":null}", VO.class);

        Assert.assertEquals(null, vo.getValue());
    }

            

Reported by PMD.

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

Line: 32

              
        VO vo = JSON.parseObject("{\"value\":null}", VO.class);

        Assert.assertEquals(null, vo.getValue());
    }

    public void test_vo2() throws Exception {

        VO2 vo = JSON.parseObject("{\"value\":123}", VO2.class);

            

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

                      Assert.assertEquals(null, vo.getValue());
    }

    public void test_vo2() throws Exception {

        VO2 vo = JSON.parseObject("{\"value\":123}", VO2.class);

        Assert.assertEquals(new BigInteger("123"), vo.getValue());
    }

            

Reported by PMD.

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

Line: 39

              
        VO2 vo = JSON.parseObject("{\"value\":123}", VO2.class);

        Assert.assertEquals(new BigInteger("123"), vo.getValue());
    }

    public void test_array() throws Exception {
        List<BigInteger> list = JSON.parseArray("[123,345]", BigInteger.class);
        Assert.assertEquals(new BigInteger("123"), list.get(0));

            

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

                      Assert.assertEquals(new BigInteger("123"), vo.getValue());
    }

    public void test_array() throws Exception {
        List<BigInteger> list = JSON.parseArray("[123,345]", BigInteger.class);
        Assert.assertEquals(new BigInteger("123"), list.get(0));
        Assert.assertEquals(new BigInteger("345"), list.get(1));
    }


            

Reported by PMD.

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

Line: 44

              
    public void test_array() throws Exception {
        List<BigInteger> list = JSON.parseArray("[123,345]", BigInteger.class);
        Assert.assertEquals(new BigInteger("123"), list.get(0));
        Assert.assertEquals(new BigInteger("345"), list.get(1));
    }

    public static class VO {


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/TestExternal3.java
10 issues
System.out.println is used
Design

Line: 32

                      method.invoke(obj, "jobs");
        
        String text = JSON.toJSONString(obj, SerializerFeature.WriteClassName);
        System.out.println(text);
        JSON.parseObject(text, clazz, confg);
        String clazzName = JSON.parse(text, confg).getClass().getName();
        Assert.assertEquals(clazz.getName(), clazzName);
    }
    

            

Reported by PMD.

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

Line: 19

              

public class TestExternal3 extends TestCase {
    ParserConfig confg = ParserConfig.global;
    protected void setUp() throws Exception {
        confg.addAccept("external.VO");
    }

    public void test_0 () throws Exception {

            

Reported by PMD.

JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll
Design

Line: 20

              
public class TestExternal3 extends TestCase {
    ParserConfig confg = ParserConfig.global;
    protected void setUp() throws Exception {
        confg.addAccept("external.VO");
    }

    public void test_0 () throws Exception {
        ExtClassLoader classLoader = new ExtClassLoader();

            

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

                      confg.addAccept("external.VO");
    }

    public void test_0 () throws Exception {
        ExtClassLoader classLoader = new ExtClassLoader();
        Class<?> clazz = classLoader.loadClass("external.VO");
        Method method = clazz.getMethod("setName", new Class[] {String.class});
        Object obj = clazz.newInstance();
        method.invoke(obj, "jobs");

            

Reported by PMD.

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

Line: 28

                      ExtClassLoader classLoader = new ExtClassLoader();
        Class<?> clazz = classLoader.loadClass("external.VO");
        Method method = clazz.getMethod("setName", new Class[] {String.class});
        Object obj = clazz.newInstance();
        method.invoke(obj, "jobs");
        
        String text = JSON.toJSONString(obj, SerializerFeature.WriteClassName);
        System.out.println(text);
        JSON.parseObject(text, clazz, confg);

            

Reported by PMD.

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

Line: 34

                      String text = JSON.toJSONString(obj, SerializerFeature.WriteClassName);
        System.out.println(text);
        JSON.parseObject(text, clazz, confg);
        String clazzName = JSON.parse(text, confg).getClass().getName();
        Assert.assertEquals(clazz.getName(), clazzName);
    }
    
    public static class ExtClassLoader extends ClassLoader {
        public ExtClassLoader() throws IOException{

            

Reported by PMD.

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

Line: 34

                      String text = JSON.toJSONString(obj, SerializerFeature.WriteClassName);
        System.out.println(text);
        JSON.parseObject(text, clazz, confg);
        String clazzName = JSON.parse(text, confg).getClass().getName();
        Assert.assertEquals(clazz.getName(), clazzName);
    }
    
    public static class ExtClassLoader extends ClassLoader {
        public ExtClassLoader() throws IOException{

            

Reported by PMD.

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

Line: 35

                      System.out.println(text);
        JSON.parseObject(text, clazz, confg);
        String clazzName = JSON.parse(text, confg).getClass().getName();
        Assert.assertEquals(clazz.getName(), clazzName);
    }
    
    public static class ExtClassLoader extends ClassLoader {
        public ExtClassLoader() throws IOException{
            super(Thread.currentThread().getContextClassLoader());

            

Reported by PMD.

Ensure that resources like this InputStream object are closed after use
Error

Line: 43

                          super(Thread.currentThread().getContextClassLoader());
            
            byte[] bytes;
            InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("external/VO.clazz");
            bytes = IOUtils.toByteArray(is);
            is.close();
            
            super.defineClass("external.VO", bytes, 0, bytes.length);
        }

            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.fastjson.JSONObject'
Design

Line: 14

              import org.apache.commons.io.IOUtils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;


public class TestExternal3 extends TestCase {
    ParserConfig confg = ParserConfig.global;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/mixins/MixinSerForFieldsTest.java
10 issues
No abstract method which means that the keyword is most likely used to prevent instantiation. Use a private or protected constructor instead.
Design

Line: 20

                      }
    }

    abstract class MixIn {
        @JSONField(serialize = false)
        public String a;
        @JSONField(name = "banana")
        public String b;
    }

            

Reported by PMD.

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

Line: 11

              
public class MixinSerForFieldsTest extends TestCase {
    static class BeanClass {
        public String a;
        public String b;

        public BeanClass(String a, String b) {
            this.a = a;
            this.b = b;

            

Reported by PMD.

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

Line: 12

              public class MixinSerForFieldsTest extends TestCase {
    static class BeanClass {
        public String a;
        public String b;

        public BeanClass(String a, String b) {
            this.a = a;
            this.b = b;
        }

            

Reported by PMD.

This abstract class does not have any abstract methods
Design

Line: 20

                      }
    }

    abstract class MixIn {
        @JSONField(serialize = false)
        public String a;
        @JSONField(name = "banana")
        public String b;
    }

            

Reported by PMD.

Unit tests should not contain more than 1 assert(s).
Design

Line: 27

                      public String b;
    }

    public void test() throws Exception{
        BeanClass bean = new BeanClass("1", "2");

        JSON.addMixInAnnotations(BeanClass.class, MixIn.class);
        String jsonString = JSON.toJSONString(bean);
        JSONObject result = JSON.parseObject(jsonString);

            

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

                      public String b;
    }

    public void test() throws Exception{
        BeanClass bean = new BeanClass("1", "2");

        JSON.addMixInAnnotations(BeanClass.class, MixIn.class);
        String jsonString = JSON.toJSONString(bean);
        JSONObject result = JSON.parseObject(jsonString);

            

Reported by PMD.

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

Line: 33

                      JSON.addMixInAnnotations(BeanClass.class, MixIn.class);
        String jsonString = JSON.toJSONString(bean);
        JSONObject result = JSON.parseObject(jsonString);
        assertEquals(1, result.size());
        assertEquals("2", result.get("banana"));
        JSON.removeMixInAnnotations(BeanClass.class);
    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 33

                      JSON.addMixInAnnotations(BeanClass.class, MixIn.class);
        String jsonString = JSON.toJSONString(bean);
        JSONObject result = JSON.parseObject(jsonString);
        assertEquals(1, result.size());
        assertEquals("2", result.get("banana"));
        JSON.removeMixInAnnotations(BeanClass.class);
    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 34

                      String jsonString = JSON.toJSONString(bean);
        JSONObject result = JSON.parseObject(jsonString);
        assertEquals(1, result.size());
        assertEquals("2", result.get("banana"));
        JSON.removeMixInAnnotations(BeanClass.class);
    }
}

            

Reported by PMD.

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

Line: 34

                      String jsonString = JSON.toJSONString(bean);
        JSONObject result = JSON.parseObject(jsonString);
        assertEquals(1, result.size());
        assertEquals("2", result.get("banana"));
        JSON.removeMixInAnnotations(BeanClass.class);
    }
}

            

Reported by PMD.

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

Line: 16

                              count++;
            }
        }
        System.out.println(count);
    }
    
    final static long flags;
    static {
        long val = 0L;

            

Reported by PMD.

All methods are static. Consider using a utility class instead. Alternatively, you could add a private constructor or make the class abstract to silence this warning.
Design

Line: 5

              
import com.alibaba.fastjson.serializer.SerializerFeature;

public class SpecialTest {
    
    public static void main(String[] args) throws Exception {
        
        int count = 0;
        for (int i = 0; i < 1000; ++i) {

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 7

              
public class SpecialTest {
    
    public static void main(String[] args) throws Exception {
        
        int count = 0;
        for (int i = 0; i < 1000; ++i) {
            char ch = (char) i;
            if(isSpecial(ch)) {

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 28

                  }
    
    static boolean isSpecial(char ch) {
        if (ch <= 31) {
            return true;
        }
        
        if (ch > '\\') { // 92
            return false;

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 32

                          return true;
        }
        
        if (ch > '\\') { // 92
            return false;
        }
        
        return ((1L << (ch - 31)) & flags) != 0;
    }

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 44

                      // return false;
        // }
        
        if (ch == ' ') { // 32
            return false;
        }

        if (ch == '/') { // 47
            return SerializerFeature.isEnabled(features, SerializerFeature.WriteSlashAsSpecial);

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 48

                          return false;
        }

        if (ch == '/') { // 47
            return SerializerFeature.isEnabled(features, SerializerFeature.WriteSlashAsSpecial);
        }

        if (ch > '#' // 35
            && ch != '\\' // 92

            

Reported by PMD.

Avoid unnecessary if..then..else statements when returning booleans
Design

Line: 58

                          return false;
        }

        if (ch <= 0x1F // 31
                || ch == '\\' // 92
                || ch == '"' // 34
                ) {
            return true;
        }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'count' (lines '9'-'13').
Error

Line: 9

                  
    public static void main(String[] args) throws Exception {
        
        int count = 0;
        for (int i = 0; i < 1000; ++i) {
            char ch = (char) i;
            if(isSpecial(ch)) {
                count++;
            }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'count' (lines '13'-'13').
Error

Line: 13

                      for (int i = 0; i < 1000; ++i) {
            char ch = (char) i;
            if(isSpecial(ch)) {
                count++;
            }
        }
        System.out.println(count);
    }
    

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/writeClassName/MapTest.java
10 issues
System.out.println is used
Design

Line: 25

                      
        String text = JSON.toJSONString(vo, SerializerFeature.WriteClassName);
        
        System.out.println(text);
        
        VO vo2 = (VO) JSON.parse(text);
        
        Assert.assertEquals(vo.getValue(), vo2.getValue());
    }

            

Reported by PMD.

System.out.println is used
Design

Line: 39

                      
        String text = JSON.toJSONString(vo, SerializerFeature.WriteClassName);
        
        System.out.println(text);
        
        VO vo2 = (VO) JSON.parse(text);
        
        Assert.assertEquals(vo.getValue(), vo2.getValue());
    }

            

Reported by PMD.

JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll
Design

Line: 15

              import com.alibaba.fastjson.serializer.SerializerFeature;

public class MapTest extends TestCase {
    protected void setUp() throws Exception {
        ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.MapTest");
    }

    public void test_map() throws Exception {
        VO vo = new VO();

            

Reported by PMD.

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

Line: 16

              
public class MapTest extends TestCase {
    protected void setUp() throws Exception {
        ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.MapTest");
    }

    public void test_map() throws Exception {
        VO vo = new VO();
        vo.getValue().put("1", "AA");

            

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

                      ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.MapTest");
    }

    public void test_map() throws Exception {
        VO vo = new VO();
        vo.getValue().put("1", "AA");
        
        String text = JSON.toJSONString(vo, SerializerFeature.WriteClassName);
        

            

Reported by PMD.

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

Line: 21

              
    public void test_map() throws Exception {
        VO vo = new VO();
        vo.getValue().put("1", "AA");
        
        String text = JSON.toJSONString(vo, SerializerFeature.WriteClassName);
        
        System.out.println(text);
        

            

Reported by PMD.

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

Line: 29

                      
        VO vo2 = (VO) JSON.parse(text);
        
        Assert.assertEquals(vo.getValue(), vo2.getValue());
    }
    
    public void test_map_2() throws Exception {
        VO vo = new VO();
        vo.setValue(new TreeMap<String, Object>());

            

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

                      Assert.assertEquals(vo.getValue(), vo2.getValue());
    }
    
    public void test_map_2() throws Exception {
        VO vo = new VO();
        vo.setValue(new TreeMap<String, Object>());
        vo.getValue().put("1", "AA");
        
        String text = JSON.toJSONString(vo, SerializerFeature.WriteClassName);

            

Reported by PMD.

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

Line: 35

                  public void test_map_2() throws Exception {
        VO vo = new VO();
        vo.setValue(new TreeMap<String, Object>());
        vo.getValue().put("1", "AA");
        
        String text = JSON.toJSONString(vo, SerializerFeature.WriteClassName);
        
        System.out.println(text);
        

            

Reported by PMD.

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

Line: 43

                      
        VO vo2 = (VO) JSON.parse(text);
        
        Assert.assertEquals(vo.getValue(), vo2.getValue());
    }

    private static class VO {

        private Map<String, Object> value = new HashMap<String, Object>();

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Issue1017.java
10 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 13

               * Created by wenshao on 11/02/2017.
 */
public class Issue1017 extends TestCase {
    public void test_for_issue() throws Exception {
        String json = "{\"pictureList\":[\"http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000\",\"http://common.cnblogs.com/images/icon_weibo_24.png\"]}";

        User user = JSON.parseObject(json, User.class);
        assertNotNull(user.pictureList);
        assertEquals(2, user.pictureList.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: 13

               * Created by wenshao on 11/02/2017.
 */
public class Issue1017 extends TestCase {
    public void test_for_issue() throws Exception {
        String json = "{\"pictureList\":[\"http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000\",\"http://common.cnblogs.com/images/icon_weibo_24.png\"]}";

        User user = JSON.parseObject(json, User.class);
        assertNotNull(user.pictureList);
        assertEquals(2, user.pictureList.size());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

                      String json = "{\"pictureList\":[\"http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000\",\"http://common.cnblogs.com/images/icon_weibo_24.png\"]}";

        User user = JSON.parseObject(json, User.class);
        assertNotNull(user.pictureList);
        assertEquals(2, user.pictureList.size());
        assertEquals("http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000", user.pictureList.get(0));
        assertEquals("http://common.cnblogs.com/images/icon_weibo_24.png", user.pictureList.get(1));
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

              
        User user = JSON.parseObject(json, User.class);
        assertNotNull(user.pictureList);
        assertEquals(2, user.pictureList.size());
        assertEquals("http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000", user.pictureList.get(0));
        assertEquals("http://common.cnblogs.com/images/icon_weibo_24.png", user.pictureList.get(1));
    }

    public static class User implements Serializable {

            

Reported by PMD.

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

Line: 18

              
        User user = JSON.parseObject(json, User.class);
        assertNotNull(user.pictureList);
        assertEquals(2, user.pictureList.size());
        assertEquals("http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000", user.pictureList.get(0));
        assertEquals("http://common.cnblogs.com/images/icon_weibo_24.png", user.pictureList.get(1));
    }

    public static class User implements Serializable {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

                      User user = JSON.parseObject(json, User.class);
        assertNotNull(user.pictureList);
        assertEquals(2, user.pictureList.size());
        assertEquals("http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000", user.pictureList.get(0));
        assertEquals("http://common.cnblogs.com/images/icon_weibo_24.png", user.pictureList.get(1));
    }

    public static class User implements Serializable {
        private List<String> pictureList;

            

Reported by PMD.

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

Line: 19

                      User user = JSON.parseObject(json, User.class);
        assertNotNull(user.pictureList);
        assertEquals(2, user.pictureList.size());
        assertEquals("http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000", user.pictureList.get(0));
        assertEquals("http://common.cnblogs.com/images/icon_weibo_24.png", user.pictureList.get(1));
    }

    public static class User implements Serializable {
        private List<String> pictureList;

            

Reported by PMD.

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

Line: 20

                      assertNotNull(user.pictureList);
        assertEquals(2, user.pictureList.size());
        assertEquals("http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000", user.pictureList.get(0));
        assertEquals("http://common.cnblogs.com/images/icon_weibo_24.png", user.pictureList.get(1));
    }

    public static class User implements Serializable {
        private List<String> pictureList;
        public List<String> getPictureList() {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 20

                      assertNotNull(user.pictureList);
        assertEquals(2, user.pictureList.size());
        assertEquals("http://static.oschina.net/uploads/user/1218/2437072_100.jpg?t=1461076033000", user.pictureList.get(0));
        assertEquals("http://common.cnblogs.com/images/icon_weibo_24.png", user.pictureList.get(1));
    }

    public static class User implements Serializable {
        private List<String> pictureList;
        public List<String> getPictureList() {

            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 23

                      assertEquals("http://common.cnblogs.com/images/icon_weibo_24.png", user.pictureList.get(1));
    }

    public static class User implements Serializable {
        private List<String> pictureList;
        public List<String> getPictureList() {
            return pictureList;
        }
        public User setPictureList(List<String> pictureList) {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/creator/JSONCreatorTest_double_obj.java
10 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 JSONCreatorTest_double_obj extends TestCase {

    public void test_create() throws Exception {
        Entity entity = new Entity(123.45D, "菜姐");
        String text = JSON.toJSONString(entity);

        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertTrue(entity.getId().doubleValue() == entity2.getId().doubleValue());

            

Reported by PMD.

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

Line: 19

                      String text = JSON.toJSONString(entity);

        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertTrue(entity.getId().doubleValue() == entity2.getId().doubleValue());
        Assert.assertEquals(entity.getName(), entity2.getName());
    }

    public void test_create_2() throws Exception {
        Entity entity = new Entity(123.45D, "菜姐");

            

Reported by PMD.

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

Line: 19

                      String text = JSON.toJSONString(entity);

        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertTrue(entity.getId().doubleValue() == entity2.getId().doubleValue());
        Assert.assertEquals(entity.getName(), entity2.getName());
    }

    public void test_create_2() throws Exception {
        Entity entity = new Entity(123.45D, "菜姐");

            

Reported by PMD.

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

Line: 19

                      String text = JSON.toJSONString(entity);

        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertTrue(entity.getId().doubleValue() == entity2.getId().doubleValue());
        Assert.assertEquals(entity.getName(), entity2.getName());
    }

    public void test_create_2() throws Exception {
        Entity entity = new Entity(123.45D, "菜姐");

            

Reported by PMD.

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

Line: 20

              
        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertTrue(entity.getId().doubleValue() == entity2.getId().doubleValue());
        Assert.assertEquals(entity.getName(), entity2.getName());
    }

    public void test_create_2() throws Exception {
        Entity entity = new Entity(123.45D, "菜姐");
        String text = JSON.toJSONString(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: 23

                      Assert.assertEquals(entity.getName(), entity2.getName());
    }

    public void test_create_2() throws Exception {
        Entity entity = new Entity(123.45D, "菜姐");
        String text = JSON.toJSONString(entity);

        ParserConfig config = new ParserConfig();


            

Reported by PMD.

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

Line: 30

                      ParserConfig config = new ParserConfig();

        Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);
        Assert.assertTrue(entity.getId().doubleValue() == entity2.getId().doubleValue());
        Assert.assertEquals(entity.getName(), entity2.getName());
    }

    public static class Entity {


            

Reported by PMD.

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

Line: 30

                      ParserConfig config = new ParserConfig();

        Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);
        Assert.assertTrue(entity.getId().doubleValue() == entity2.getId().doubleValue());
        Assert.assertEquals(entity.getName(), entity2.getName());
    }

    public static class Entity {


            

Reported by PMD.

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

Line: 30

                      ParserConfig config = new ParserConfig();

        Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);
        Assert.assertTrue(entity.getId().doubleValue() == entity2.getId().doubleValue());
        Assert.assertEquals(entity.getName(), entity2.getName());
    }

    public static class Entity {


            

Reported by PMD.

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

Line: 31

              
        Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);
        Assert.assertTrue(entity.getId().doubleValue() == entity2.getId().doubleValue());
        Assert.assertEquals(entity.getName(), entity2.getName());
    }

    public static class Entity {

        private final Double  id;

            

Reported by PMD.