The following issues were found

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

Line: 26

                      set.add(new B1());
        a.setList(set);
        String text = JSON.toJSONString(a, SerializerFeature.WriteClassName);
        System.out.println(text);
//        Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set3$A\",\"list\":[{},{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set3$B1\"}]}",
//                            text);

        A a1 = (A) JSON.parse(text);


            

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 WriteClassNameTest_Set3 extends TestCase {
    protected void setUp() throws Exception {
        ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set3");
    }

    public void test_list() throws Exception {
        A a = new A();

            

Reported by PMD.

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

Line: 16

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

    public void test_list() throws Exception {
        A a = new A();
        LinkedHashSet<B> set = new LinkedHashSet<B>();

            

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.WriteClassNameTest_Set3");
    }

    public void test_list() throws Exception {
        A a = new A();
        LinkedHashSet<B> set = new LinkedHashSet<B>();
        set.add(new B());
        set.add(new B1());
        a.setList(set);

            

Reported by PMD.

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

Line: 32

              
        A a1 = (A) JSON.parse(text);

        Assert.assertEquals(2, a1.getList().size());
        Assert.assertTrue(new ArrayList<B>(a1.getList()).get(0) instanceof B);
        Assert.assertTrue(new ArrayList<B>(a1.getList()).get(1) instanceof B1);
    }

    private static class A {

            

Reported by PMD.

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

Line: 32

              
        A a1 = (A) JSON.parse(text);

        Assert.assertEquals(2, a1.getList().size());
        Assert.assertTrue(new ArrayList<B>(a1.getList()).get(0) instanceof B);
        Assert.assertTrue(new ArrayList<B>(a1.getList()).get(1) instanceof B1);
    }

    private static class A {

            

Reported by PMD.

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

Line: 33

                      A a1 = (A) JSON.parse(text);

        Assert.assertEquals(2, a1.getList().size());
        Assert.assertTrue(new ArrayList<B>(a1.getList()).get(0) instanceof B);
        Assert.assertTrue(new ArrayList<B>(a1.getList()).get(1) instanceof B1);
    }

    private static class A {


            

Reported by PMD.

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

Line: 34

              
        Assert.assertEquals(2, a1.getList().size());
        Assert.assertTrue(new ArrayList<B>(a1.getList()).get(0) instanceof B);
        Assert.assertTrue(new ArrayList<B>(a1.getList()).get(1) instanceof B1);
    }

    private static class A {

        private LinkedHashSet<B> list;

            

Reported by PMD.

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

Line: 39

              
    private static class A {

        private LinkedHashSet<B> list;

        public LinkedHashSet<B> getList() {
            return list;
        }


            

Reported by PMD.

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

Line: 41

              
        private LinkedHashSet<B> list;

        public LinkedHashSet<B> getList() {
            return list;
        }

        public void setList(LinkedHashSet<B> list) {
            this.list = list;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/list/ArrayLisMapDeserializerTest.java
12 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: 15

              
public class ArrayLisMapDeserializerTest extends TestCase {

    public void test_list() throws Exception {
        Entity a = JSON.parseObject("{items:[{}, {a:1}, null]}", Entity.class);
        Assert.assertEquals(0, a.getItems().get(0).size());
        Assert.assertEquals(1, a.getItems().get(1).size());
        Assert.assertEquals(null, a.getItems().get(2));
    }

            

Reported by PMD.

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

Line: 17

              
    public void test_list() throws Exception {
        Entity a = JSON.parseObject("{items:[{}, {a:1}, null]}", Entity.class);
        Assert.assertEquals(0, a.getItems().get(0).size());
        Assert.assertEquals(1, a.getItems().get(1).size());
        Assert.assertEquals(null, a.getItems().get(2));
    }
    
    public void test_list_2() throws Exception {

            

Reported by PMD.

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

Line: 17

              
    public void test_list() throws Exception {
        Entity a = JSON.parseObject("{items:[{}, {a:1}, null]}", Entity.class);
        Assert.assertEquals(0, a.getItems().get(0).size());
        Assert.assertEquals(1, a.getItems().get(1).size());
        Assert.assertEquals(null, a.getItems().get(2));
    }
    
    public void test_list_2() throws Exception {

            

Reported by PMD.

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

Line: 17

              
    public void test_list() throws Exception {
        Entity a = JSON.parseObject("{items:[{}, {a:1}, null]}", Entity.class);
        Assert.assertEquals(0, a.getItems().get(0).size());
        Assert.assertEquals(1, a.getItems().get(1).size());
        Assert.assertEquals(null, a.getItems().get(2));
    }
    
    public void test_list_2() throws Exception {

            

Reported by PMD.

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

Line: 18

                  public void test_list() throws Exception {
        Entity a = JSON.parseObject("{items:[{}, {a:1}, null]}", Entity.class);
        Assert.assertEquals(0, a.getItems().get(0).size());
        Assert.assertEquals(1, a.getItems().get(1).size());
        Assert.assertEquals(null, a.getItems().get(2));
    }
    
    public void test_list_2() throws Exception {
        List<Map> list = JSON.parseObject("[{}, {a:1}, null]", new TypeReference<List<Map>>() {});

            

Reported by PMD.

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

Line: 18

                  public void test_list() throws Exception {
        Entity a = JSON.parseObject("{items:[{}, {a:1}, null]}", Entity.class);
        Assert.assertEquals(0, a.getItems().get(0).size());
        Assert.assertEquals(1, a.getItems().get(1).size());
        Assert.assertEquals(null, a.getItems().get(2));
    }
    
    public void test_list_2() throws Exception {
        List<Map> list = JSON.parseObject("[{}, {a:1}, null]", new TypeReference<List<Map>>() {});

            

Reported by PMD.

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

Line: 18

                  public void test_list() throws Exception {
        Entity a = JSON.parseObject("{items:[{}, {a:1}, null]}", Entity.class);
        Assert.assertEquals(0, a.getItems().get(0).size());
        Assert.assertEquals(1, a.getItems().get(1).size());
        Assert.assertEquals(null, a.getItems().get(2));
    }
    
    public void test_list_2() throws Exception {
        List<Map> list = JSON.parseObject("[{}, {a:1}, null]", new TypeReference<List<Map>>() {});

            

Reported by PMD.

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

Line: 19

                      Entity a = JSON.parseObject("{items:[{}, {a:1}, null]}", Entity.class);
        Assert.assertEquals(0, a.getItems().get(0).size());
        Assert.assertEquals(1, a.getItems().get(1).size());
        Assert.assertEquals(null, a.getItems().get(2));
    }
    
    public void test_list_2() throws Exception {
        List<Map> list = JSON.parseObject("[{}, {a:1}, null]", new TypeReference<List<Map>>() {});
        Assert.assertEquals(0, list.get(0).size());

            

Reported by PMD.

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

Line: 19

                      Entity a = JSON.parseObject("{items:[{}, {a:1}, null]}", Entity.class);
        Assert.assertEquals(0, a.getItems().get(0).size());
        Assert.assertEquals(1, a.getItems().get(1).size());
        Assert.assertEquals(null, a.getItems().get(2));
    }
    
    public void test_list_2() throws Exception {
        List<Map> list = JSON.parseObject("[{}, {a:1}, null]", new TypeReference<List<Map>>() {});
        Assert.assertEquals(0, list.get(0).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: 22

                      Assert.assertEquals(null, a.getItems().get(2));
    }
    
    public void test_list_2() throws Exception {
        List<Map> list = JSON.parseObject("[{}, {a:1}, null]", new TypeReference<List<Map>>() {});
        Assert.assertEquals(0, list.get(0).size());
        Assert.assertEquals(1, list.get(1).size());
        Assert.assertEquals(null, list.get(2));
    }

            

Reported by PMD.

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

Line: 11

              
public class RefTest2 extends TestCase {

    public void test_ref() throws Exception {
        Object[] array = new Object[1];
        array[0] = array;
        Assert.assertEquals("[{\"$ref\":\"@\"}]", JSON.toJSONString(array));
    }


            

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

                      Assert.assertEquals("[{\"$ref\":\"@\"}]", JSON.toJSONString(array));
    }

    public void test_ref_1() throws Exception {
        Object[] array = new Object[3];
        array[0] = array;
        array[1] = new Object();
        array[2] = new Object();
        Assert.assertEquals("[{\"$ref\":\"@\"},{},{}]", JSON.toJSONString(array));

            

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

                      Assert.assertEquals("[{\"$ref\":\"@\"},{},{}]", JSON.toJSONString(array));
    }

    public void test_ref_2() throws Exception {
        Object[] array = new Object[3];
        array[0] = new Object();
        array[1] = array;
        array[2] = new Object();
        Assert.assertEquals("[{},{\"$ref\":\"@\"},{}]", JSON.toJSONString(array));

            

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

                      Assert.assertEquals("[{},{\"$ref\":\"@\"},{}]", JSON.toJSONString(array));
    }

    public void test_ref_3() throws Exception {
        Object[] array = new Object[3];
        array[0] = new Object();
        array[1] = new Object();
        array[2] = array;
        Assert.assertEquals("[{},{},{\"$ref\":\"@\"}]", JSON.toJSONString(array));

            

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

                      Assert.assertEquals("[{},{},{\"$ref\":\"@\"}]", JSON.toJSONString(array));
    }

    public void test_parse() throws Exception {
        Object[] array2 = JSON.parseObject("[{\"$ref\":\"$\"}]", Object[].class);
        Assert.assertSame(array2, array2[0]);
    }

    public void test_parse_1() throws Exception {

            

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

                      Assert.assertSame(array2, array2[0]);
    }

    public void test_parse_1() throws Exception {
        Object[] array2 = JSON.parseObject("[{\"$ref\":\"@\"}]", Object[].class);
        Assert.assertSame(array2, array2[0]);
    }
}

            

Reported by PMD.

Found 'DD'-anomaly for variable 'array' (lines '19'-'20').
Error

Line: 19

              
    public void test_ref_1() throws Exception {
        Object[] array = new Object[3];
        array[0] = array;
        array[1] = new Object();
        array[2] = new Object();
        Assert.assertEquals("[{\"$ref\":\"@\"},{},{}]", JSON.toJSONString(array));
    }


            

Reported by PMD.

Found 'DD'-anomaly for variable 'array' (lines '20'-'21').
Error

Line: 20

                  public void test_ref_1() throws Exception {
        Object[] array = new Object[3];
        array[0] = array;
        array[1] = new Object();
        array[2] = new Object();
        Assert.assertEquals("[{\"$ref\":\"@\"},{},{}]", JSON.toJSONString(array));
    }

    public void test_ref_2() throws Exception {

            

Reported by PMD.

Found 'DD'-anomaly for variable 'array' (lines '26'-'27').
Error

Line: 26

                  }

    public void test_ref_2() throws Exception {
        Object[] array = new Object[3];
        array[0] = new Object();
        array[1] = array;
        array[2] = new Object();
        Assert.assertEquals("[{},{\"$ref\":\"@\"},{}]", JSON.toJSONString(array));
    }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'array' (lines '28'-'29').
Error

Line: 28

                  public void test_ref_2() throws Exception {
        Object[] array = new Object[3];
        array[0] = new Object();
        array[1] = array;
        array[2] = new Object();
        Assert.assertEquals("[{},{\"$ref\":\"@\"},{}]", JSON.toJSONString(array));
    }

    public void test_ref_3() throws Exception {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/deny/InitJavaBeanDeserializerTest.java
12 issues
System.out.println is used
Design

Line: 36

                      Exception error = null;
        try {
            Object obj = JSON.parseObject(text, Object.class, config);
            System.out.println(obj.getClass());
        } catch (JSONException ex) {
            error = ex;
        }
        assertNotNull(error);


            

Reported by PMD.

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

Line: 14

               * Created by wenshao on 28/01/2017.
 */
public class InitJavaBeanDeserializerTest extends TestCase {
    ParserConfig config = new ParserConfig();

    protected void setUp() throws Exception {
        assertFalse(config.isAutoTypeSupport());

        Properties properties = new Properties();

            

Reported by PMD.

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

Line: 16

              public class InitJavaBeanDeserializerTest extends TestCase {
    ParserConfig config = new ParserConfig();

    protected void setUp() throws Exception {
        assertFalse(config.isAutoTypeSupport());

        Properties properties = new Properties();
        properties.put(ParserConfig.AUTOTYPE_SUPPORT_PROPERTY, "false");
        // config.addAccept("com.alibaba.json.bvt.parser.deser.deny.DenyTest11.Model");

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

                  ParserConfig config = new ParserConfig();

    protected void setUp() throws Exception {
        assertFalse(config.isAutoTypeSupport());

        Properties properties = new Properties();
        properties.put(ParserConfig.AUTOTYPE_SUPPORT_PROPERTY, "false");
        // config.addAccept("com.alibaba.json.bvt.parser.deser.deny.DenyTest11.Model");
        // -ea -Dfastjson.parser.autoTypeAccept=com.alibaba.json.bvt.parser.deser.deny.DenyTest9

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 25

                      // -ea -Dfastjson.parser.autoTypeAccept=com.alibaba.json.bvt.parser.deser.deny.DenyTest9
        config.configFromPropety(properties);

        assertFalse(config.isAutoTypeSupport());
    }

    public void test_desktop() throws Exception {
        DenyTest11.Model model = new DenyTest11.Model();
        model.a = new DenyTest11.B();

            

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

                      assertFalse(config.isAutoTypeSupport());
    }

    public void test_desktop() throws Exception {
        DenyTest11.Model model = new DenyTest11.Model();
        model.a = new DenyTest11.B();
        String text = "{\"@type\":\"com.alibaba.json.bvt.parser.deser.deny.InitJavaBeanDeserializerTest$Model\"}";

        Exception error = null;

            

Reported by PMD.

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

Line: 28

                      assertFalse(config.isAutoTypeSupport());
    }

    public void test_desktop() throws Exception {
        DenyTest11.Model model = new DenyTest11.Model();
        model.a = new DenyTest11.B();
        String text = "{\"@type\":\"com.alibaba.json.bvt.parser.deser.deny.InitJavaBeanDeserializerTest$Model\"}";

        Exception error = null;

            

Reported by PMD.

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

Line: 36

                      Exception error = null;
        try {
            Object obj = JSON.parseObject(text, Object.class, config);
            System.out.println(obj.getClass());
        } catch (JSONException ex) {
            error = ex;
        }
        assertNotNull(error);


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 40

                      } catch (JSONException ex) {
            error = ex;
        }
        assertNotNull(error);

        config.initJavaBeanDeserializers(Model.class);

        Object obj = JSON.parseObject(text, Object.class, config);
        assertEquals(Model.class, obj.getClass());

            

Reported by PMD.

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

Line: 45

                      config.initJavaBeanDeserializers(Model.class);

        Object obj = JSON.parseObject(text, Object.class, config);
        assertEquals(Model.class, obj.getClass());
    }

    public static class Model {

    }

            

Reported by PMD.

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

Line: 26

                      
        String text = JSON.toJSONString(entity);
        
        System.out.println(text);
        
        Entity entity2 = JSON.parseObject(text, Entity.class);
        
        Assert.assertNotNull(entity2.getQueue());
        Assert.assertEquals(1, entity2.getQueue().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

              
public class Bug_for_wangran1 extends TestCase {

    public void test_0() throws Exception {
        Entity entity = new Entity();
        
        entity.setId(11);
        entity.setName("xx");
        

            

Reported by PMD.

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

Line: 22

                      Queue q = new Queue();
        q.setId(55);
        
        entity.getQueue().put(q.getId(), q);
        
        String text = JSON.toJSONString(entity);
        
        System.out.println(text);
        

            

Reported by PMD.

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

Line: 30

                      
        Entity entity2 = JSON.parseObject(text, Entity.class);
        
        Assert.assertNotNull(entity2.getQueue());
        Assert.assertEquals(1, entity2.getQueue().size());
        Assert.assertEquals(true, entity2.getQueue().values().iterator().next() instanceof Queue);
    }

    public static class Entity {

            

Reported by PMD.

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

Line: 31

                      Entity entity2 = JSON.parseObject(text, Entity.class);
        
        Assert.assertNotNull(entity2.getQueue());
        Assert.assertEquals(1, entity2.getQueue().size());
        Assert.assertEquals(true, entity2.getQueue().values().iterator().next() instanceof Queue);
    }

    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);
        
        Assert.assertNotNull(entity2.getQueue());
        Assert.assertEquals(1, entity2.getQueue().size());
        Assert.assertEquals(true, entity2.getQueue().values().iterator().next() instanceof Queue);
    }

    public static class Entity {


            

Reported by PMD.

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

Line: 32

                      
        Assert.assertNotNull(entity2.getQueue());
        Assert.assertEquals(1, entity2.getQueue().size());
        Assert.assertEquals(true, entity2.getQueue().values().iterator().next() instanceof Queue);
    }

    public static class Entity {

        private int                 id;

            

Reported by PMD.

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

Line: 32

                      
        Assert.assertNotNull(entity2.getQueue());
        Assert.assertEquals(1, entity2.getQueue().size());
        Assert.assertEquals(true, entity2.getQueue().values().iterator().next() instanceof Queue);
    }

    public static class Entity {

        private int                 id;

            

Reported by PMD.

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

Line: 32

                      
        Assert.assertNotNull(entity2.getQueue());
        Assert.assertEquals(1, entity2.getQueue().size());
        Assert.assertEquals(true, entity2.getQueue().values().iterator().next() instanceof Queue);
    }

    public static class Entity {

        private int                 id;

            

Reported by PMD.

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

Line: 32

                      
        Assert.assertNotNull(entity2.getQueue());
        Assert.assertEquals(1, entity2.getQueue().size());
        Assert.assertEquals(true, entity2.getQueue().values().iterator().next() instanceof Queue);
    }

    public static class Entity {

        private int                 id;

            

Reported by PMD.

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

Line: 12

              
public class Bug_for_issue_537 extends TestCase {

    public void test_for_issue() throws Exception {
        String text = "{\"value\":2147483649}";
        Exception error = null;
        try {
            JSON.parseObject(text, VO.class);
        } catch (JSONException ex) {

            

Reported by PMD.

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

Line: 21

                          error = ex;
        }
        Assert.assertNotNull(error);
        Assert.assertTrue(error.getMessage().contains("field : value"));
    }

    public void test_for_issue_private() throws Exception {
        String text = "{\"value\":2147483649}";
        Exception error = null;

            

Reported by PMD.

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

Line: 21

                          error = ex;
        }
        Assert.assertNotNull(error);
        Assert.assertTrue(error.getMessage().contains("field : value"));
    }

    public void test_for_issue_private() throws Exception {
        String text = "{\"value\":2147483649}";
        Exception error = 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: 24

                      Assert.assertTrue(error.getMessage().contains("field : value"));
    }

    public void test_for_issue_private() throws Exception {
        String text = "{\"value\":2147483649}";
        Exception error = null;
        try {
            JSON.parseObject(text, V1.class);
        } catch (JSONException ex) {

            

Reported by PMD.

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

Line: 33

                          error = ex;
        }
        Assert.assertNotNull(error);
        Assert.assertTrue(error.getMessage().contains("field : value"));
    }
    

    public void test_for_issue_method() throws Exception {
        String text = "{\"value\":2147483649}";

            

Reported by PMD.

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

Line: 33

                          error = ex;
        }
        Assert.assertNotNull(error);
        Assert.assertTrue(error.getMessage().contains("field : value"));
    }
    

    public void test_for_issue_method() throws Exception {
        String text = "{\"value\":2147483649}";

            

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

                  }
    

    public void test_for_issue_method() throws Exception {
        String text = "{\"value\":2147483649}";
        Exception error = null;
        try {
            JSON.parseObject(text, V2.class);
        } catch (JSONException ex) {

            

Reported by PMD.

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

Line: 46

                          error = ex;
        }
        Assert.assertNotNull(error);
        Assert.assertTrue(error.getMessage().contains("field : value"));
    }

    public static class VO {

        public int value;

            

Reported by PMD.

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

Line: 46

                          error = ex;
        }
        Assert.assertNotNull(error);
        Assert.assertTrue(error.getMessage().contains("field : value"));
    }

    public static class VO {

        public int value;

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '14'-'18').
Error

Line: 14

              
    public void test_for_issue() throws Exception {
        String text = "{\"value\":2147483649}";
        Exception error = null;
        try {
            JSON.parseObject(text, VO.class);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.

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

Line: 16

              import junit.framework.TestCase;

public class Bug_for_issue_448 extends TestCase {
    public void test_0() {
        
    }

    // skip
    public void test_for_issue() throws Exception {

            

Reported by PMD.

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

Line: 16

              import junit.framework.TestCase;

public class Bug_for_issue_448 extends TestCase {
    public void test_0() {
        
    }

    // skip
    public void test_for_issue() throws Exception {

            

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

                  }

    // skip
    public void test_for_issue() throws Exception {
        final int value_size = 1024 * 16;
        List<Model> list = new ArrayList<Model>();
        for (int i = 0; i < 10; ++i) {
            Model model = new Model();
            char[] buf = new char[value_size];

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 25

                      final int value_size = 1024 * 16;
        List<Model> list = new ArrayList<Model>();
        for (int i = 0; i < 10; ++i) {
            Model model = new Model();
            char[] buf = new char[value_size];
            for (int j = 0; j < buf.length; ++j) {
                buf[j] = (char) ('a' + j);
            }
            model.value = new String(buf);

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 26

                      List<Model> list = new ArrayList<Model>();
        for (int i = 0; i < 10; ++i) {
            Model model = new Model();
            char[] buf = new char[value_size];
            for (int j = 0; j < buf.length; ++j) {
                buf[j] = (char) ('a' + j);
            }
            model.value = new String(buf);
            list.add(model);

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 30

                          for (int j = 0; j < buf.length; ++j) {
                buf[j] = (char) ('a' + j);
            }
            model.value = new String(buf);
            list.add(model);
        }
        
        String text = JSON.toJSONString(list);
        JSONReader reader = new JSONReader(new StringReader(text));

            

Reported by PMD.

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

Line: 40

                      while (reader.hasNext()) {
            Model model = reader.readObject(Model.class);
            String value = model.value;
            Assert.assertEquals(value_size, value.length());
            for (int i = 0; i < value.length(); ++i) {
                char ch = value.charAt(i);
                Assert.assertEquals("error : index_" + i, (char) ('a' + i), ch);
            }
        }

            

Reported by PMD.

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

Line: 41

                          Model model = reader.readObject(Model.class);
            String value = model.value;
            Assert.assertEquals(value_size, value.length());
            for (int i = 0; i < value.length(); ++i) {
                char ch = value.charAt(i);
                Assert.assertEquals("error : index_" + i, (char) ('a' + i), ch);
            }
        }
        reader.endArray();

            

Reported by PMD.

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

Line: 42

                          String value = model.value;
            Assert.assertEquals(value_size, value.length());
            for (int i = 0; i < value.length(); ++i) {
                char ch = value.charAt(i);
                Assert.assertEquals("error : index_" + i, (char) ('a' + i), ch);
            }
        }
        reader.endArray();
        reader.close();

            

Reported by PMD.

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

Line: 52

              

    public static class Model {
        public String value;
    }
}

            

Reported by PMD.

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

    public void test_castToJavaBean() throws Exception {
        VO vo = new VO();
        vo.setId(123);
        vo.setName("abc");

        Assert.assertEquals("{\"ID\":123,\"name\":\"abc\"}", JSON.toJSONString(vo));

            

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

                      Assert.assertEquals("{\"ID\":123,\"name\":\"abc\"}", JSON.toJSONString(vo));
    }

    public void test_parse() throws Exception {
        VO vo = JSON.parseObject("{\"xid\":123,\"name\":\"abc\"}", VO.class);

        Assert.assertEquals(123, vo.getId());
        Assert.assertEquals("abc", vo.getName());
    }

            

Reported by PMD.

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

Line: 27

                  public void test_parse() throws Exception {
        VO vo = JSON.parseObject("{\"xid\":123,\"name\":\"abc\"}", VO.class);

        Assert.assertEquals(123, vo.getId());
        Assert.assertEquals("abc", vo.getName());
    }

    public void test_parse_var() throws Exception {
        List<?> list = JSON.parseObject("[]", new TypeReference<List<?>>() {

            

Reported by PMD.

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

Line: 28

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

        Assert.assertEquals(123, vo.getId());
        Assert.assertEquals("abc", vo.getName());
    }

    public void test_parse_var() throws Exception {
        List<?> list = JSON.parseObject("[]", new TypeReference<List<?>>() {
        });

            

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

                      Assert.assertEquals("abc", vo.getName());
    }

    public void test_parse_var() throws Exception {
        List<?> list = JSON.parseObject("[]", new TypeReference<List<?>>() {
        });
        Assert.assertNotNull(list);
        Assert.assertEquals(0, list.size());
    }

            

Reported by PMD.

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

Line: 38

                      Assert.assertEquals(0, list.size());
    }

    public void test_deser() throws Exception {
        JSON.parseObject("{\"id\":123}", new TypeReference<X_I>(){});
    }
    
    public void test_deser2() throws Exception {
        JSON.parseObject("{\"id\":123}", new TypeReference<X_X<Integer>>(){});

            

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

                      Assert.assertEquals(0, list.size());
    }

    public void test_deser() throws Exception {
        JSON.parseObject("{\"id\":123}", new TypeReference<X_I>(){});
    }
    
    public void test_deser2() throws Exception {
        JSON.parseObject("{\"id\":123}", new TypeReference<X_X<Integer>>(){});

            

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

                      JSON.parseObject("{\"id\":123}", new TypeReference<X_I>(){});
    }
    
    public void test_deser2() throws Exception {
        JSON.parseObject("{\"id\":123}", new TypeReference<X_X<Integer>>(){});
    }
    
    public void test_deser2_x() throws Exception {
        JSON.parseObject("{\"id\":123}", new TypeReference<X_X<?>>(){});

            

Reported by PMD.

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

Line: 42

                      JSON.parseObject("{\"id\":123}", new TypeReference<X_I>(){});
    }
    
    public void test_deser2() throws Exception {
        JSON.parseObject("{\"id\":123}", new TypeReference<X_X<Integer>>(){});
    }
    
    public void test_deser2_x() throws Exception {
        JSON.parseObject("{\"id\":123}", new TypeReference<X_X<?>>(){});

            

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

                      JSON.parseObject("{\"id\":123}", new TypeReference<X_X<Integer>>(){});
    }
    
    public void test_deser2_x() throws Exception {
        JSON.parseObject("{\"id\":123}", new TypeReference<X_X<?>>(){});
    }
    
    public static class X_I extends X<Integer> {
        

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/generic/GenericTest.java
12 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

              
public class GenericTest extends TestCase {
    
    public void test_0 () throws Exception {
       B b = JSON.parseObject("{\"data\":[1,2,3]}", B.class);
       b.get(0);
    }

    public static abstract class A<T> {

            

Reported by PMD.

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

Line: 10

              
public class GenericTest extends TestCase {
    
    public void test_0 () throws Exception {
       B b = JSON.parseObject("{\"data\":[1,2,3]}", B.class);
       b.get(0);
    }

    public static abstract class A<T> {

            

Reported by PMD.

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

Line: 12

                  
    public void test_0 () throws Exception {
       B b = JSON.parseObject("{\"data\":[1,2,3]}", B.class);
       b.get(0);
    }

    public static abstract class A<T> {
        T[] data;
        

            

Reported by PMD.

This abstract class does not have any abstract methods
Design

Line: 15

                     b.get(0);
    }

    public static abstract class A<T> {
        T[] data;
        
        public A() {
            
        }

            

Reported by PMD.

Returning 'data' may expose an internal array.
Design

Line: 25

              
        
        public T[] getData() {
            return data;
        }


        
        public void setData(T[] data) {

            

Reported by PMD.

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

Line: 30

              

        
        public void setData(T[] data) {
            this.data = data;
        }
    }
    
    public static class B extends A<Long> {

            

Reported by PMD.

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

Line: 46

                  }
    
    public static class C<T> {
        private T[] data;
        
        public C(T[] data) {
            this.data = data;
        }


            

Reported by PMD.

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

Line: 46

                  }
    
    public static class C<T> {
        private T[] data;
        
        public C(T[] data) {
            this.data = data;
        }


            

Reported by PMD.

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

Line: 48

                  public static class C<T> {
        private T[] data;
        
        public C(T[] data) {
            this.data = data;
        }

        
        public T[] getData() {

            

Reported by PMD.

Returning 'data' may expose an internal array.
Design

Line: 54

              
        
        public T[] getData() {
            return data;
        }
        
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/filters/NameFilterTest_int_field.java
12 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: 15

              
public class NameFilterTest_int_field extends TestCase {

    public void test_namefilter() throws Exception {
        NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    Assert.assertTrue(value instanceof Integer);

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 19

                      NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    Assert.assertTrue(value instanceof Integer);
                    return "ID";
                }

                return name;

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 19

                      NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    Assert.assertTrue(value instanceof Integer);
                    return "ID";
                }

                return name;

            

Reported by PMD.

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

Line: 31

              
        SerializeWriter out = new SerializeWriter();
        JSONSerializer serializer = new JSONSerializer(out);
        serializer.getNameFilters().add(filter);

        Bean a = new Bean();
        serializer.write(a);

        String text = out.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: 40

                      Assert.assertEquals("{\"ID\":0}", text);
    }

    public void test_namefilter_1() throws Exception {
        NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    return "ID";

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 44

                      NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    return "ID";
                }

                return name;
            }

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 44

                      NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    return "ID";
                }

                return name;
            }

            

Reported by PMD.

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

Line: 55

              
        SerializeWriter out = new SerializeWriter();
        JSONSerializer serializer = new JSONSerializer(out);
        serializer.getNameFilters().add(filter);

        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", 0);
        serializer.write(map);


            

Reported by PMD.

Found 'DU'-anomaly for variable 'filter' (lines '16'-'38').
Error

Line: 16

              public class NameFilterTest_int_field extends TestCase {

    public void test_namefilter() throws Exception {
        NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    Assert.assertTrue(value instanceof Integer);
                    return "ID";

            

Reported by PMD.

Found 'DU'-anomaly for variable 'filter' (lines '16'-'38').
Error

Line: 16

              public class NameFilterTest_int_field extends TestCase {

    public void test_namefilter() throws Exception {
        NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    Assert.assertTrue(value instanceof Integer);
                    return "ID";

            

Reported by PMD.