The following issues were found

src/test/java/com/alibaba/json/bvt/bug/Bug14.java
11 issues
System.out.println is used
Design

Line: 18

                  public void test_0() throws Exception {
        double f = -5.5000009;
        Long i = 4294967295l;
        System.out.println(BigInteger.valueOf(i));
        System.out.println(Math.round(f));
        List<AB> list = new ArrayList<AB>();
        list.add(new AB("2a", "3b"));
        list.add(new AB("4a", "6b"));
        list.add(new AB("6a", "7{sdf<>jgh\n}b"));

            

Reported by PMD.

System.out.println is used
Design

Line: 19

                      double f = -5.5000009;
        Long i = 4294967295l;
        System.out.println(BigInteger.valueOf(i));
        System.out.println(Math.round(f));
        List<AB> list = new ArrayList<AB>();
        list.add(new AB("2a", "3b"));
        list.add(new AB("4a", "6b"));
        list.add(new AB("6a", "7{sdf<>jgh\n}b"));
        list.add(new AB("8a", "9b"));

            

Reported by PMD.

System.out.println is used
Design

Line: 33

                      for (AB a : list) {
            map.put(String.valueOf(k++), a);
        }
        System.out.println(JSON.toJSON(list));
        System.out.println(JSON.toJSON(abc));
        System.out.println(JSON.toJSON(new AB("10a", "11ba")));
        System.out.println(JSON.toJSON(map));

    }

            

Reported by PMD.

System.out.println is used
Design

Line: 34

                          map.put(String.valueOf(k++), a);
        }
        System.out.println(JSON.toJSON(list));
        System.out.println(JSON.toJSON(abc));
        System.out.println(JSON.toJSON(new AB("10a", "11ba")));
        System.out.println(JSON.toJSON(map));

    }


            

Reported by PMD.

System.out.println is used
Design

Line: 35

                      }
        System.out.println(JSON.toJSON(list));
        System.out.println(JSON.toJSON(abc));
        System.out.println(JSON.toJSON(new AB("10a", "11ba")));
        System.out.println(JSON.toJSON(map));

    }

    private static class AB {

            

Reported by PMD.

System.out.println is used
Design

Line: 36

                      System.out.println(JSON.toJSON(list));
        System.out.println(JSON.toJSON(abc));
        System.out.println(JSON.toJSON(new AB("10a", "11ba")));
        System.out.println(JSON.toJSON(map));

    }

    private static class AB {


            

Reported by PMD.

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

Line: 15

              
public class Bug14 extends TestCase {

    public void test_0() throws Exception {
        double f = -5.5000009;
        Long i = 4294967295l;
        System.out.println(BigInteger.valueOf(i));
        System.out.println(Math.round(f));
        List<AB> list = new ArrayList<AB>();

            

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 Bug14 extends TestCase {

    public void test_0() throws Exception {
        double f = -5.5000009;
        Long i = 4294967295l;
        System.out.println(BigInteger.valueOf(i));
        System.out.println(Math.round(f));
        List<AB> list = new ArrayList<AB>();

            

Reported by PMD.

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

Line: 42

              
    private static class AB {

        private String a;
        private String b;

        public AB(){
            super();
        }

            

Reported by PMD.

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

Line: 43

                  private static class AB {

        private String a;
        private String b;

        public AB(){
            super();
        }


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1500/Issue1500.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: 16

              public class Issue1500 extends TestCase {


    public void test_for_issue() throws Exception {

        // test aa
        Aa aa = new Aa();
        aa.setName("aa");
        String jsonAa = JSON.toJSONString(aa);

            

Reported by PMD.

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

Line: 23

                      aa.setName("aa");
        String jsonAa = JSON.toJSONString(aa);
        Aa aa1 = JSON.parseObject(jsonAa, Aa.class);
        Assert.assertEquals("aa",aa1.getName());

        // test C
        C c = new C();
        c.setE(aa);
        String jsonC = JSON.toJSONString(c, SerializerFeature.WriteClassName);

            

Reported by PMD.

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

Line: 30

                      c.setE(aa);
        String jsonC = JSON.toJSONString(c, SerializerFeature.WriteClassName);
        C c2 = JSON.parseObject(jsonC, C.class);
        Assert.assertEquals("Aa",c2.getE().getClass().getSimpleName());
        Assert.assertEquals("aa",((Aa)c2.getE()).getName());
    }

    public static class Aa extends Exception {


            

Reported by PMD.

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

Line: 30

                      c.setE(aa);
        String jsonC = JSON.toJSONString(c, SerializerFeature.WriteClassName);
        C c2 = JSON.parseObject(jsonC, C.class);
        Assert.assertEquals("Aa",c2.getE().getClass().getSimpleName());
        Assert.assertEquals("aa",((Aa)c2.getE()).getName());
    }

    public static class Aa extends Exception {


            

Reported by PMD.

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

Line: 30

                      c.setE(aa);
        String jsonC = JSON.toJSONString(c, SerializerFeature.WriteClassName);
        C c2 = JSON.parseObject(jsonC, C.class);
        Assert.assertEquals("Aa",c2.getE().getClass().getSimpleName());
        Assert.assertEquals("aa",((Aa)c2.getE()).getName());
    }

    public static class Aa extends Exception {


            

Reported by PMD.

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

Line: 31

                      String jsonC = JSON.toJSONString(c, SerializerFeature.WriteClassName);
        C c2 = JSON.parseObject(jsonC, C.class);
        Assert.assertEquals("Aa",c2.getE().getClass().getSimpleName());
        Assert.assertEquals("aa",((Aa)c2.getE()).getName());
    }

    public static class Aa extends Exception {

        public Aa(){

            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 34

                      Assert.assertEquals("aa",((Aa)c2.getE()).getName());
    }

    public static class Aa extends Exception {

        public Aa(){
        }

        private String name;

            

Reported by PMD.

Avoid unused imports such as 'clojure.lang.Obj'
Design

Line: 3

              package com.alibaba.json.bvt.issue_1500;

import clojure.lang.Obj;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;
import org.junit.Assert;


            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.fastjson.parser.ParserConfig'
Design

Line: 5

              
import clojure.lang.Obj;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;
import org.junit.Assert;

import java.util.HashMap;

            

Reported by PMD.

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

Line: 10

              import junit.framework.TestCase;
import org.junit.Assert;

import java.util.HashMap;
import java.util.Map;

public class Issue1500 extends TestCase {



            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1400/Issue1449.java
11 issues
System.out.println is used
Design

Line: 22

                      student.name = "name";
        student.id = 1L;
        student.sex = Sex.MAN;
        System.out.println(JSON.toJSON(student).toString());
        System.out.println(JSON.toJSONString(student));
        String str1 = "{\"id\":1,\"name\":\"name\",\"sex\":\"MAN\"}";
        Student stu1 = JSON.parseObject(str1, Student.class);
        System.out.println(JSON.toJSONString(stu1));
        String str2 = "{\"id\":1,\"name\":\"name\",\"sex\":{\"code\":\"1\",\"des\":\"男\"}}";

            

Reported by PMD.

System.out.println is used
Design

Line: 23

                      student.id = 1L;
        student.sex = Sex.MAN;
        System.out.println(JSON.toJSON(student).toString());
        System.out.println(JSON.toJSONString(student));
        String str1 = "{\"id\":1,\"name\":\"name\",\"sex\":\"MAN\"}";
        Student stu1 = JSON.parseObject(str1, Student.class);
        System.out.println(JSON.toJSONString(stu1));
        String str2 = "{\"id\":1,\"name\":\"name\",\"sex\":{\"code\":\"1\",\"des\":\"男\"}}";
        JSON.parseObject(str2, Student.class);

            

Reported by PMD.

System.out.println is used
Design

Line: 26

                      System.out.println(JSON.toJSONString(student));
        String str1 = "{\"id\":1,\"name\":\"name\",\"sex\":\"MAN\"}";
        Student stu1 = JSON.parseObject(str1, Student.class);
        System.out.println(JSON.toJSONString(stu1));
        String str2 = "{\"id\":1,\"name\":\"name\",\"sex\":{\"code\":\"1\",\"des\":\"男\"}}";
        JSON.parseObject(str2, Student.class);

    }


            

Reported by PMD.

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

Line: 17

              import java.lang.reflect.Type;

public class Issue1449 extends TestCase {
    public void test_for_issue() throws Exception {
        Student student = new Student();
        student.name = "name";
        student.id = 1L;
        student.sex = Sex.MAN;
        System.out.println(JSON.toJSON(student).toString());

            

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

              import java.lang.reflect.Type;

public class Issue1449 extends TestCase {
    public void test_for_issue() throws Exception {
        Student student = new Student();
        student.name = "name";
        student.id = 1L;
        student.sex = Sex.MAN;
        System.out.println(JSON.toJSON(student).toString());

            

Reported by PMD.

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

Line: 22

                      student.name = "name";
        student.id = 1L;
        student.sex = Sex.MAN;
        System.out.println(JSON.toJSON(student).toString());
        System.out.println(JSON.toJSONString(student));
        String str1 = "{\"id\":1,\"name\":\"name\",\"sex\":\"MAN\"}";
        Student stu1 = JSON.parseObject(str1, Student.class);
        System.out.println(JSON.toJSONString(stu1));
        String str2 = "{\"id\":1,\"name\":\"name\",\"sex\":{\"code\":\"1\",\"des\":\"男\"}}";

            

Reported by PMD.

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

Line: 68

                          Object object = parser.parse();
            if (object instanceof JSONObject) {
                JSONObject jsonObject = (JSONObject) object;
                code = jsonObject.getString("code");
            } else {
                code = (String) object;
            }
            if ("0".equals(code)) {
                return (T) Sex.NONE;

            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 86

                          return 0;
        }
    }
    public static class Student implements Serializable {

        public Long id;

        public String name;


            

Reported by PMD.

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

Line: 88

                  }
    public static class Student implements Serializable {

        public Long id;

        public String name;

        public Sex sex;
    }

            

Reported by PMD.

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

Line: 90

              
        public Long id;

        public String name;

        public Sex sex;
    }
}

            

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/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/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/mixins/MixinJSONTypeTest.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: 13

              import junit.framework.TestCase;

public class MixinJSONTypeTest extends TestCase {
	public void test_1() {
		User user1 = new User("zhangsan", "male", 19);
		Assert.assertEquals("{\"age\":19,\"sex\":\"male\",\"userName\":\"zhangsan\"}", JSON.toJSONString(user1));

		JSON.addMixInAnnotations(user1.getClass(), Mixin.class);
		Assert.assertEquals("{\"age\":19,\"userName\":\"zhangsan\",\"sex\":\"male\"}", JSON.toJSONString(user1));

            

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

              		JSON.removeMixInAnnotations(user1.getClass());
	}

	public void test_2() {
		User user1 = new User("lisi", "male", 20);
		Assert.assertEquals("{\"age\":20,\"sex\":\"male\",\"userName\":\"lisi\"}", JSON.toJSONString(user1));

		JSON.addMixInAnnotations(user1.getClass(), Mixin2.class);
		Assert.assertEquals("{\"userName\":\"lisi\"}", JSON.toJSONString(user1));

            

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

              		JSON.removeMixInAnnotations(user1.getClass());
	}

	public void test_3() {
		User user1 = new User("wangwu", "male", 31);
		Assert.assertEquals("{\"age\":31,\"sex\":\"male\",\"userName\":\"wangwu\"}", JSON.toJSONString(user1));

		JSON.addMixInAnnotations(user1.getClass(), Mixin3.class);
		Assert.assertEquals("{\"age\":31,\"sex\":\"male\"}", JSON.toJSONString(user1));

            

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

              		JSON.removeMixInAnnotations(user1.getClass());
	}

	public void test_4() throws Exception {
		JSON.addMixInAnnotations(VO.class, Mixin5.class);
		JSON.addMixInAnnotations(VOBuilder.class, Mixin6.class);

		VO vo = JSON.parseObject("{\"id\":12304,\"name\":\"ljw\"}", VO.class);


            

Reported by PMD.

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

Line: 49

              
		VO vo = JSON.parseObject("{\"id\":12304,\"name\":\"ljw\"}", VO.class);

		Assert.assertEquals(12304, vo.getId());
		Assert.assertEquals("ljw", vo.getName());

		JSON.removeMixInAnnotations(VO.class);
		JSON.removeMixInAnnotations(VOBuilder.class);
	}

            

Reported by PMD.

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

Line: 50

              		VO vo = JSON.parseObject("{\"id\":12304,\"name\":\"ljw\"}", VO.class);

		Assert.assertEquals(12304, vo.getId());
		Assert.assertEquals("ljw", vo.getName());

		JSON.removeMixInAnnotations(VO.class);
		JSON.removeMixInAnnotations(VOBuilder.class);
	}


            

Reported by PMD.

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

Line: 57

              	}

	@JSONType(serialzeFeatures = { SerializerFeature.QuoteFieldNames })
	public class User {
		private String userName;
		private String sex;
		private int age;

		public User(String userName, String sex, int age) {

            

Reported by PMD.

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

Line: 111

              	}

	public static class VO {
		private int id;
		private String name;

		public int getId() {
			return id;
		}

            

Reported by PMD.

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

Line: 112

              
	public static class VO {
		private int id;
		private String name;

		public int getId() {
			return id;
		}


            

Reported by PMD.

Private field 'vo' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 125

              
	private static class VOBuilder {

		private VO vo = new VO();

		public VO xxx() {
			return vo;
		}


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1300/Issue1362.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: 10

               * Created by wenshao on 03/08/2017.
 */
public class Issue1362 extends TestCase {
    public void test_for_issue() throws Exception {
        JSONObject object = new JSONObject();
        object.put("val", "null");
        assertEquals(0D, object.getDoubleValue("val"));
        assertEquals(0F, object.getFloatValue("val"));
        assertEquals(0, object.getIntValue("val"));

            

Reported by PMD.

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

Line: 10

               * Created by wenshao on 03/08/2017.
 */
public class Issue1362 extends TestCase {
    public void test_for_issue() throws Exception {
        JSONObject object = new JSONObject();
        object.put("val", "null");
        assertEquals(0D, object.getDoubleValue("val"));
        assertEquals(0F, object.getFloatValue("val"));
        assertEquals(0, object.getIntValue("val"));

            

Reported by PMD.

The String literal 'val' appears 8 times in this file; the first occurrence is on line 12
Error

Line: 12

              public class Issue1362 extends TestCase {
    public void test_for_issue() throws Exception {
        JSONObject object = new JSONObject();
        object.put("val", "null");
        assertEquals(0D, object.getDoubleValue("val"));
        assertEquals(0F, object.getFloatValue("val"));
        assertEquals(0, object.getIntValue("val"));
        assertEquals(0L, object.getLongValue("val"));
        assertEquals((short) 0, object.getShortValue("val"));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 13

                  public void test_for_issue() throws Exception {
        JSONObject object = new JSONObject();
        object.put("val", "null");
        assertEquals(0D, object.getDoubleValue("val"));
        assertEquals(0F, object.getFloatValue("val"));
        assertEquals(0, object.getIntValue("val"));
        assertEquals(0L, object.getLongValue("val"));
        assertEquals((short) 0, object.getShortValue("val"));
        assertEquals((byte) 0, object.getByteValue("val"));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 14

                      JSONObject object = new JSONObject();
        object.put("val", "null");
        assertEquals(0D, object.getDoubleValue("val"));
        assertEquals(0F, object.getFloatValue("val"));
        assertEquals(0, object.getIntValue("val"));
        assertEquals(0L, object.getLongValue("val"));
        assertEquals((short) 0, object.getShortValue("val"));
        assertEquals((byte) 0, object.getByteValue("val"));
        assertEquals(false, object.getBooleanValue("val"));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 15

                      object.put("val", "null");
        assertEquals(0D, object.getDoubleValue("val"));
        assertEquals(0F, object.getFloatValue("val"));
        assertEquals(0, object.getIntValue("val"));
        assertEquals(0L, object.getLongValue("val"));
        assertEquals((short) 0, object.getShortValue("val"));
        assertEquals((byte) 0, object.getByteValue("val"));
        assertEquals(false, object.getBooleanValue("val"));
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 16

                      assertEquals(0D, object.getDoubleValue("val"));
        assertEquals(0F, object.getFloatValue("val"));
        assertEquals(0, object.getIntValue("val"));
        assertEquals(0L, object.getLongValue("val"));
        assertEquals((short) 0, object.getShortValue("val"));
        assertEquals((byte) 0, object.getByteValue("val"));
        assertEquals(false, object.getBooleanValue("val"));
    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

                      assertEquals(0F, object.getFloatValue("val"));
        assertEquals(0, object.getIntValue("val"));
        assertEquals(0L, object.getLongValue("val"));
        assertEquals((short) 0, object.getShortValue("val"));
        assertEquals((byte) 0, object.getByteValue("val"));
        assertEquals(false, object.getBooleanValue("val"));
    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                      assertEquals(0, object.getIntValue("val"));
        assertEquals(0L, object.getLongValue("val"));
        assertEquals((short) 0, object.getShortValue("val"));
        assertEquals((byte) 0, object.getByteValue("val"));
        assertEquals(false, object.getBooleanValue("val"));
    }
}

            

Reported by PMD.

Use assertTrue(x)/assertFalse(x) instead of assertEquals(true, x)/assertEquals(false, x) or assertEquals(Boolean.TRUE, x)/assertEquals(Boolean.FALSE, x).
Design

Line: 19

                      assertEquals(0L, object.getLongValue("val"));
        assertEquals((short) 0, object.getShortValue("val"));
        assertEquals((byte) 0, object.getByteValue("val"));
        assertEquals(false, object.getBooleanValue("val"));
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/bug2020/Bug_for_money.java
11 issues
Overridable method 'getCentFactor' called during object construction
Error

Line: 48

              
        public Money(double amount, Currency currency) {
            this.currency = currency;
            this.cent = Math.round(amount * getCentFactor());
        }

        public BigDecimal getAmount() {
            return BigDecimal.valueOf(cent, currency.getDefaultFractionDigits());
        }

            

Reported by PMD.

The method name and parameter number are suspiciously close to equals(Object)
Error

Line: 75

                          return (other instanceof Money) && equals((Money) other);
        }

        public boolean equals(Money other) {
            return currency.equals(other.currency) && (cent == other.cent);
        }

        public int hashCode() {
            return (int) (cent ^ (cent >>> 32));

            

Reported by PMD.

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

Line: 12

              import junit.framework.TestCase;

public class Bug_for_money extends TestCase {
    public void test_for_issue() throws Exception {
        JSONObject obj = JSON.parseObject(
                "{\"productMaxPriceAmt\":{\"amount\":4.99,\"centFactor\":100,\"cent\":499,\"currency\":\"USD\","
                        + "\"currencyCode\":\"USD\"}}");
        Money money = obj.getObject("productMaxPriceAmt", Money.class);
        assertEquals("USD", money.getCurrencyCode());

            

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

              import junit.framework.TestCase;

public class Bug_for_money extends TestCase {
    public void test_for_issue() throws Exception {
        JSONObject obj = JSON.parseObject(
                "{\"productMaxPriceAmt\":{\"amount\":4.99,\"centFactor\":100,\"cent\":499,\"currency\":\"USD\","
                        + "\"currencyCode\":\"USD\"}}");
        Money money = obj.getObject("productMaxPriceAmt", Money.class);
        assertEquals("USD", money.getCurrencyCode());

            

Reported by PMD.

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

Line: 16

                      JSONObject obj = JSON.parseObject(
                "{\"productMaxPriceAmt\":{\"amount\":4.99,\"centFactor\":100,\"cent\":499,\"currency\":\"USD\","
                        + "\"currencyCode\":\"USD\"}}");
        Money money = obj.getObject("productMaxPriceAmt", Money.class);
        assertEquals("USD", money.getCurrencyCode());
        assertEquals(new BigDecimal("4.99"), money.getAmount());
    }

    public static class Money implements Serializable, Comparable {

            

Reported by PMD.

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

Line: 17

                              "{\"productMaxPriceAmt\":{\"amount\":4.99,\"centFactor\":100,\"cent\":499,\"currency\":\"USD\","
                        + "\"currencyCode\":\"USD\"}}");
        Money money = obj.getObject("productMaxPriceAmt", Money.class);
        assertEquals("USD", money.getCurrencyCode());
        assertEquals(new BigDecimal("4.99"), money.getAmount());
    }

    public static class Money implements Serializable, Comparable {


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

                              "{\"productMaxPriceAmt\":{\"amount\":4.99,\"centFactor\":100,\"cent\":499,\"currency\":\"USD\","
                        + "\"currencyCode\":\"USD\"}}");
        Money money = obj.getObject("productMaxPriceAmt", Money.class);
        assertEquals("USD", money.getCurrencyCode());
        assertEquals(new BigDecimal("4.99"), money.getAmount());
    }

    public static class Money implements Serializable, Comparable {


            

Reported by PMD.

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

Line: 18

                                      + "\"currencyCode\":\"USD\"}}");
        Money money = obj.getObject("productMaxPriceAmt", Money.class);
        assertEquals("USD", money.getCurrencyCode());
        assertEquals(new BigDecimal("4.99"), money.getAmount());
    }

    public static class Money implements Serializable, Comparable {

        private static final long serialVersionUID = 6009335074727417445L;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                                      + "\"currencyCode\":\"USD\"}}");
        Money money = obj.getObject("productMaxPriceAmt", Money.class);
        assertEquals("USD", money.getCurrencyCode());
        assertEquals(new BigDecimal("4.99"), money.getAmount());
    }

    public static class Money implements Serializable, Comparable {

        private static final long serialVersionUID = 6009335074727417445L;

            

Reported by PMD.

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

Line: 33

              
        private long cent;

        private Currency currency;

        private String currencyCode;

        public Money() {
            this(0);

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/writeAsArray/WriteAsArray_list_public.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: 16

              
public class WriteAsArray_list_public extends TestCase {

    public void test_0() throws Exception {
        VO vo = new VO();
        vo.setId(123);
        vo.setName("wenshao");
        vo.getValues().add("x");


            

Reported by PMD.

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

Line: 20

                      VO vo = new VO();
        vo.setId(123);
        vo.setName("wenshao");
        vo.getValues().add("x");

        String text = JSON.toJSONString(vo, SerializerFeature.BeanToArray);
        Assert.assertEquals("[123,\"wenshao\",[\"x\"]]", text);
        
        VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);

            

Reported by PMD.

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

Line: 26

                      Assert.assertEquals("[123,\"wenshao\",[\"x\"]]", text);
        
        VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
        Assert.assertEquals(vo.getId(), vo2.getId());
        Assert.assertEquals(vo.getName(), vo2.getName());
        Assert.assertEquals(vo.getValues().size(), vo2.getValues().size());
        Assert.assertEquals(vo.getValues().get(0), vo2.getValues().get(0));
    }


            

Reported by PMD.

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

Line: 27

                      
        VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
        Assert.assertEquals(vo.getId(), vo2.getId());
        Assert.assertEquals(vo.getName(), vo2.getName());
        Assert.assertEquals(vo.getValues().size(), vo2.getValues().size());
        Assert.assertEquals(vo.getValues().get(0), vo2.getValues().get(0));
    }

    public static class VO {

            

Reported by PMD.

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

Line: 28

                      VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
        Assert.assertEquals(vo.getId(), vo2.getId());
        Assert.assertEquals(vo.getName(), vo2.getName());
        Assert.assertEquals(vo.getValues().size(), vo2.getValues().size());
        Assert.assertEquals(vo.getValues().get(0), vo2.getValues().get(0));
    }

    public static class VO {


            

Reported by PMD.

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

Line: 28

                      VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
        Assert.assertEquals(vo.getId(), vo2.getId());
        Assert.assertEquals(vo.getName(), vo2.getName());
        Assert.assertEquals(vo.getValues().size(), vo2.getValues().size());
        Assert.assertEquals(vo.getValues().get(0), vo2.getValues().get(0));
    }

    public static class VO {


            

Reported by PMD.

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

Line: 28

                      VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
        Assert.assertEquals(vo.getId(), vo2.getId());
        Assert.assertEquals(vo.getName(), vo2.getName());
        Assert.assertEquals(vo.getValues().size(), vo2.getValues().size());
        Assert.assertEquals(vo.getValues().get(0), vo2.getValues().get(0));
    }

    public static class VO {


            

Reported by PMD.

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

Line: 29

                      Assert.assertEquals(vo.getId(), vo2.getId());
        Assert.assertEquals(vo.getName(), vo2.getName());
        Assert.assertEquals(vo.getValues().size(), vo2.getValues().size());
        Assert.assertEquals(vo.getValues().get(0), vo2.getValues().get(0));
    }

    public static class VO {

        private long         id;

            

Reported by PMD.

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

Line: 29

                      Assert.assertEquals(vo.getId(), vo2.getId());
        Assert.assertEquals(vo.getName(), vo2.getName());
        Assert.assertEquals(vo.getValues().size(), vo2.getValues().size());
        Assert.assertEquals(vo.getValues().get(0), vo2.getValues().get(0));
    }

    public static class VO {

        private long         id;

            

Reported by PMD.

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

Line: 29

                      Assert.assertEquals(vo.getId(), vo2.getId());
        Assert.assertEquals(vo.getName(), vo2.getName());
        Assert.assertEquals(vo.getValues().size(), vo2.getValues().size());
        Assert.assertEquals(vo.getValues().get(0), vo2.getValues().get(0));
    }

    public static class VO {

        private long         id;

            

Reported by PMD.