The following issues were found

src/test/java/com/alibaba/json/bvt/writeAsArray/WriteAsArray_Object_2_public.java
9 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

              
public class WriteAsArray_Object_2_public extends TestCase {

    public void test_0() throws Exception {
        A a = new A();
        a.setId(123);
        a.setName("wenshao");

        VO vo = new VO();

            

Reported by PMD.

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

Line: 26

                      Assert.assertEquals("[1001,[123,\"wenshao\"]]", text);

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

    public static class VO {


            

Reported by PMD.

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

Line: 26

                      Assert.assertEquals("[1001,[123,\"wenshao\"]]", text);

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

    public static class VO {


            

Reported by PMD.

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

Line: 26

                      Assert.assertEquals("[1001,[123,\"wenshao\"]]", text);

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

    public static class VO {


            

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.getValue().getId(), vo2.getValue().getId());
        Assert.assertEquals(vo.getValue().getName(), vo2.getValue().getName());
    }

    public static class VO {

        private int id;

            

Reported by PMD.

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

Line: 27

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

    public static class VO {

        private int id;

            

Reported by PMD.

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

Line: 27

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

    public static class VO {

        private int id;

            

Reported by PMD.

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

Line: 30

                      Assert.assertEquals(vo.getValue().getName(), vo2.getValue().getName());
    }

    public static class VO {

        private int id;
        private A   value;

        public int getId() {

            

Reported by PMD.

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

Line: 53

              
    }

    public static class A {

        private int    id;
        private String name;

        public int getId() {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/JSONFieldTest_unwrapped_2.java
9 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 13

              
public class JSONFieldTest_unwrapped_2 extends TestCase {

    public void test_jsonField() throws Exception {
        String text = "{\"id\":123,\"latitude\":37,\"longitude\":127}";
        Assert.assertEquals("{\"id\":123,\"latitude\":37,\"longitude\":127}", text);

        VO vo2 = JSON.parseObject(text, VO.class);
        assertNotNull(vo2.properties);

            

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

    public void test_jsonField() throws Exception {
        String text = "{\"id\":123,\"latitude\":37,\"longitude\":127}";
        Assert.assertEquals("{\"id\":123,\"latitude\":37,\"longitude\":127}", text);

        VO vo2 = JSON.parseObject(text, VO.class);
        assertNotNull(vo2.properties);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                      Assert.assertEquals("{\"id\":123,\"latitude\":37,\"longitude\":127}", text);

        VO vo2 = JSON.parseObject(text, VO.class);
        assertNotNull(vo2.properties);
        assertEquals(37, vo2.properties.get("latitude"));
        assertEquals(127, vo2.properties.get("longitude"));

    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

              
        VO vo2 = JSON.parseObject(text, VO.class);
        assertNotNull(vo2.properties);
        assertEquals(37, vo2.properties.get("latitude"));
        assertEquals(127, vo2.properties.get("longitude"));

    }

    public static class VO {

            

Reported by PMD.

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

Line: 19

              
        VO vo2 = JSON.parseObject(text, VO.class);
        assertNotNull(vo2.properties);
        assertEquals(37, vo2.properties.get("latitude"));
        assertEquals(127, vo2.properties.get("longitude"));

    }

    public static class VO {

            

Reported by PMD.

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

Line: 20

                      VO vo2 = JSON.parseObject(text, VO.class);
        assertNotNull(vo2.properties);
        assertEquals(37, vo2.properties.get("latitude"));
        assertEquals(127, vo2.properties.get("longitude"));

    }

    public static class VO {
        public int id;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 20

                      VO vo2 = JSON.parseObject(text, VO.class);
        assertNotNull(vo2.properties);
        assertEquals(37, vo2.properties.get("latitude"));
        assertEquals(127, vo2.properties.get("longitude"));

    }

    public static class VO {
        public int id;

            

Reported by PMD.

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

Line: 27

                  public static class VO {
        public int id;

        private Map<String, Object> properties = new LinkedHashMap<String, Object>();

        @JSONField(unwrapped = true)
        public void setProperty(String key, Object value) {
            properties.put(key, value);
        }

            

Reported by PMD.

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

Line: 27

                  public static class VO {
        public int id;

        private Map<String, Object> properties = new LinkedHashMap<String, Object>();

        @JSONField(unwrapped = true)
        public void setProperty(String key, Object value) {
            properties.put(key, value);
        }

            

Reported by PMD.

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

Line: 22

                      A a = new A();
        a.setList(Collections.singletonList(new B()));
        String text = JSON.toJSONString(a, SerializerFeature.WriteClassName);
        System.out.println(text);
        Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Collection2$A\",\"list\":[{}]}",
                            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: 14

              import com.alibaba.fastjson.serializer.SerializerFeature;

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

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

            

Reported by PMD.

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

Line: 15

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

    public void test_list() throws Exception {
        A a = new A();
        a.setList(Collections.singletonList(new 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: 18

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

    public void test_list() throws Exception {
        A a = new A();
        a.setList(Collections.singletonList(new B()));
        String text = JSON.toJSONString(a, SerializerFeature.WriteClassName);
        System.out.println(text);
        Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Collection2$A\",\"list\":[{}]}",

            

Reported by PMD.

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

Line: 28

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

        Assert.assertEquals(1, a1.getList().size());
        Assert.assertTrue(a1.getList().iterator().next() instanceof B);
    }

    public static class A {


            

Reported by PMD.

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

Line: 28

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

        Assert.assertEquals(1, a1.getList().size());
        Assert.assertTrue(a1.getList().iterator().next() instanceof B);
    }

    public static class A {


            

Reported by PMD.

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

Line: 29

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

        Assert.assertEquals(1, a1.getList().size());
        Assert.assertTrue(a1.getList().iterator().next() instanceof B);
    }

    public static class A {

        private Collection<B> list;

            

Reported by PMD.

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

Line: 29

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

        Assert.assertEquals(1, a1.getList().size());
        Assert.assertTrue(a1.getList().iterator().next() instanceof B);
    }

    public static class A {

        private Collection<B> list;

            

Reported by PMD.

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

Line: 29

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

        Assert.assertEquals(1, a1.getList().size());
        Assert.assertTrue(a1.getList().iterator().next() instanceof B);
    }

    public static class A {

        private Collection<B> list;

            

Reported by PMD.

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

Line: 11

              import java.util.Collections;

public class Issue1603_getter extends TestCase {
    public void test_emptySet() throws Exception {
        Model_1 m = JSON.parseObject("{\"values\":[\"a\"]}", Model_1.class);
        assertEquals(0, m.values.size());
    }

    public void test_emptyList() throws Exception {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 13

              public class Issue1603_getter extends TestCase {
    public void test_emptySet() throws Exception {
        Model_1 m = JSON.parseObject("{\"values\":[\"a\"]}", Model_1.class);
        assertEquals(0, m.values.size());
    }

    public void test_emptyList() throws Exception {
        Model_2 m = JSON.parseObject("{\"values\":[\"a\"]}", Model_2.class);
        assertEquals(0, m.values.size());

            

Reported by PMD.

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

Line: 13

              public class Issue1603_getter extends TestCase {
    public void test_emptySet() throws Exception {
        Model_1 m = JSON.parseObject("{\"values\":[\"a\"]}", Model_1.class);
        assertEquals(0, m.values.size());
    }

    public void test_emptyList() throws Exception {
        Model_2 m = JSON.parseObject("{\"values\":[\"a\"]}", Model_2.class);
        assertEquals(0, m.values.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: 16

                      assertEquals(0, m.values.size());
    }

    public void test_emptyList() throws Exception {
        Model_2 m = JSON.parseObject("{\"values\":[\"a\"]}", Model_2.class);
        assertEquals(0, m.values.size());
    }

    public void test_unmodifier() throws Exception {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

              
    public void test_emptyList() throws Exception {
        Model_2 m = JSON.parseObject("{\"values\":[\"a\"]}", Model_2.class);
        assertEquals(0, m.values.size());
    }

    public void test_unmodifier() throws Exception {
        Model_3 m = JSON.parseObject("{\"values\":[\"a\"]}", Model_3.class);
        assertEquals(0, m.values.size());

            

Reported by PMD.

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

Line: 18

              
    public void test_emptyList() throws Exception {
        Model_2 m = JSON.parseObject("{\"values\":[\"a\"]}", Model_2.class);
        assertEquals(0, m.values.size());
    }

    public void test_unmodifier() throws Exception {
        Model_3 m = JSON.parseObject("{\"values\":[\"a\"]}", Model_3.class);
        assertEquals(0, m.values.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: 21

                      assertEquals(0, m.values.size());
    }

    public void test_unmodifier() throws Exception {
        Model_3 m = JSON.parseObject("{\"values\":[\"a\"]}", Model_3.class);
        assertEquals(0, m.values.size());
    }

    public static class Model_1 {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 23

              
    public void test_unmodifier() throws Exception {
        Model_3 m = JSON.parseObject("{\"values\":[\"a\"]}", Model_3.class);
        assertEquals(0, m.values.size());
    }

    public static class Model_1 {
        private final Collection<String> values = Collections.emptySet();


            

Reported by PMD.

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

Line: 23

              
    public void test_unmodifier() throws Exception {
        Model_3 m = JSON.parseObject("{\"values\":[\"a\"]}", Model_3.class);
        assertEquals(0, m.values.size());
    }

    public static class Model_1 {
        private final Collection<String> values = Collections.emptySet();


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/array/FieldFloatArray2Test.java
9 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 11/01/2017.
 */
public class FieldFloatArray2Test extends TestCase {
    public void test_intArray() throws Exception {
        Model model = JSON.parseObject("{\"value\":[[1,2.1,-0.3]]}", Model.class);
        assertNotNull(model.value);
        assertEquals(1, model.value.length);
        assertEquals(3, model.value[0].length);
        assertEquals(1f, model.value[0][0]);

            

Reported by PMD.

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

Line: 10

               * Created by wenshao on 11/01/2017.
 */
public class FieldFloatArray2Test extends TestCase {
    public void test_intArray() throws Exception {
        Model model = JSON.parseObject("{\"value\":[[1,2.1,-0.3]]}", Model.class);
        assertNotNull(model.value);
        assertEquals(1, model.value.length);
        assertEquals(3, model.value[0].length);
        assertEquals(1f, model.value[0][0]);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 12

              public class FieldFloatArray2Test extends TestCase {
    public void test_intArray() throws Exception {
        Model model = JSON.parseObject("{\"value\":[[1,2.1,-0.3]]}", Model.class);
        assertNotNull(model.value);
        assertEquals(1, model.value.length);
        assertEquals(3, model.value[0].length);
        assertEquals(1f, model.value[0][0]);
        assertEquals(2.1f, model.value[0][1]);
        assertEquals(-0.3f, model.value[0][2]);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 13

                  public void test_intArray() throws Exception {
        Model model = JSON.parseObject("{\"value\":[[1,2.1,-0.3]]}", Model.class);
        assertNotNull(model.value);
        assertEquals(1, model.value.length);
        assertEquals(3, model.value[0].length);
        assertEquals(1f, model.value[0][0]);
        assertEquals(2.1f, model.value[0][1]);
        assertEquals(-0.3f, model.value[0][2]);
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 14

                      Model model = JSON.parseObject("{\"value\":[[1,2.1,-0.3]]}", Model.class);
        assertNotNull(model.value);
        assertEquals(1, model.value.length);
        assertEquals(3, model.value[0].length);
        assertEquals(1f, model.value[0][0]);
        assertEquals(2.1f, model.value[0][1]);
        assertEquals(-0.3f, model.value[0][2]);
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 15

                      assertNotNull(model.value);
        assertEquals(1, model.value.length);
        assertEquals(3, model.value[0].length);
        assertEquals(1f, model.value[0][0]);
        assertEquals(2.1f, model.value[0][1]);
        assertEquals(-0.3f, model.value[0][2]);
    }

    public static class Model {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 16

                      assertEquals(1, model.value.length);
        assertEquals(3, model.value[0].length);
        assertEquals(1f, model.value[0][0]);
        assertEquals(2.1f, model.value[0][1]);
        assertEquals(-0.3f, model.value[0][2]);
    }

    public static class Model {
        public float[][] value;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

                      assertEquals(3, model.value[0].length);
        assertEquals(1f, model.value[0][0]);
        assertEquals(2.1f, model.value[0][1]);
        assertEquals(-0.3f, model.value[0][2]);
    }

    public static class Model {
        public float[][] value;
    }

            

Reported by PMD.

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

Line: 21

                  }

    public static class Model {
        public float[][] value;
    }
}

            

Reported by PMD.

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

Line: 18

                      to.add("test1");
        to.add("test2");
        String text = JSON.toJSONString(to);
        System.out.println(text);
        JSONObject jo = JSON.parseObject(text);
        to = JSON.toJavaObject(jo, TestObject.class);
    }
    
    public static class TestObject {

            

Reported by PMD.

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

Line: 13

              

public class Issue87_hashset extends TestCase {
    public void test_for_issue() throws Exception {
        TestObject to = new TestObject();
        to.add("test1");
        to.add("test2");
        String text = JSON.toJSONString(to);
        System.out.println(text);

            

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 Issue87_hashset extends TestCase {
    public void test_for_issue() throws Exception {
        TestObject to = new TestObject();
        to.add("test1");
        to.add("test2");
        String text = JSON.toJSONString(to);
        System.out.println(text);

            

Reported by PMD.

The value assigned to variable 'to' is never used
Design

Line: 20

                      String text = JSON.toJSONString(to);
        System.out.println(text);
        JSONObject jo = JSON.parseObject(text);
        to = JSON.toJavaObject(jo, TestObject.class);
    }
    
    public static class TestObject {

        private HashSet<String> set = new HashSet<String>(0);

            

Reported by PMD.

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

Line: 25

                  
    public static class TestObject {

        private HashSet<String> set = new HashSet<String>(0);

        public HashSet<String> getSet() {
            return set;
        }


            

Reported by PMD.

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

Line: 27

              
        private HashSet<String> set = new HashSet<String>(0);

        public HashSet<String> getSet() {
            return set;
        }

        public void setSet(HashSet<String> set) {
            this.set = set;

            

Reported by PMD.

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

Line: 31

                          return set;
        }

        public void setSet(HashSet<String> set) {
            this.set = set;
        }

        public void add(String str) {
            set.add(str);

            

Reported by PMD.

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

Line: 4

              package com.alibaba.json.bvt.bug;

import java.util.HashSet;
import java.util.Set;

import junit.framework.TestCase;

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

            

Reported by PMD.

Found 'DU'-anomaly for variable 'to' (lines '20'-'21').
Error

Line: 20

                      String text = JSON.toJSONString(to);
        System.out.println(text);
        JSONObject jo = JSON.parseObject(text);
        to = JSON.toJavaObject(jo, TestObject.class);
    }
    
    public static class TestObject {

        private HashSet<String> set = new HashSet<String>(0);

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/JSONFieldTest6.java
9 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

              
public class JSONFieldTest6 extends TestCase {

    public void test_for_issue1()
    {
        NonStringMap nonStringMap = new NonStringMap();
        Map<Integer, Integer> map1 = new HashMap();
        map1.put( 111,666 );
        nonStringMap.setMap1( map1 );

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 20

                      map1.put( 111,666 );
        nonStringMap.setMap1( map1 );
        String json = JSON.toJSONString( nonStringMap );
        assertEquals( "{\"map1\":{\"111\":666}}", json );
    }

    public void test_for_issue2()
    {
        NonStringMap nonStringMap = new NonStringMap();

            

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

                      assertEquals( "{\"map1\":{\"111\":666}}", json );
    }

    public void test_for_issue2()
    {
        NonStringMap nonStringMap = new NonStringMap();
        Map<Integer, Integer> map2 = new HashMap();
        map2.put( 222,888 );
        nonStringMap.setMap2( map2 );

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 30

                      map2.put( 222,888 );
        nonStringMap.setMap2( map2 );
        String json = JSON.toJSONString( nonStringMap );
        assertEquals( "{\"map2\":{222:\"888\"}}", json );
    }

    public void test_for_issue3()
    {
        NonStringMap nonStringMap = new NonStringMap();

            

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

                      assertEquals( "{\"map2\":{222:\"888\"}}", json );
    }

    public void test_for_issue3()
    {
        NonStringMap nonStringMap = new NonStringMap();
        Map<Integer, Integer> map3 = new HashMap();
        map3.put( 333,999 );
        nonStringMap.setMap3( map3 );

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 40

                      map3.put( 333,999 );
        nonStringMap.setMap3( map3 );
        String json = JSON.toJSONString( nonStringMap );
        assertEquals( "{\"map3\":{\"333\":\"999\"}}", json );
    }

    public void test_for_issue4()
    {
        NonStringMap nonStringMap = new NonStringMap();

            

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

                      assertEquals( "{\"map3\":{\"333\":\"999\"}}", json );
    }

    public void test_for_issue4()
    {
        NonStringMap nonStringMap = new NonStringMap();
        Bean person = new Bean();
        person.setAge( 23 );
        nonStringMap.setPerson( person );

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 50

                      person.setAge( 23 );
        nonStringMap.setPerson( person );
        String json = JSON.toJSONString( nonStringMap );
        assertEquals( "{\"person\":{\"age\":\"23\"}}", json );
    }

    class NonStringMap
    {
        @JSONField( serialzeFeatures = {SerializerFeature.WriteNonStringKeyAsString} )

            

Reported by PMD.

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

Line: 53

                      assertEquals( "{\"person\":{\"age\":\"23\"}}", json );
    }

    class NonStringMap
    {
        @JSONField( serialzeFeatures = {SerializerFeature.WriteNonStringKeyAsString} )
        private Map map1;

        public Map getMap1()

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/array/FieldFloatArray2Test_private.java
9 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 11/01/2017.
 */
public class FieldFloatArray2Test_private extends TestCase {
    public void test_intArray() throws Exception {
        Model model = JSON.parseObject("{\"value\":[[1,2.1,-0.3]]}", Model.class);
        assertNotNull(model.value);
        assertEquals(1, model.value.length);
        assertEquals(3, model.value[0].length);
        assertEquals(1f, model.value[0][0]);

            

Reported by PMD.

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

Line: 10

               * Created by wenshao on 11/01/2017.
 */
public class FieldFloatArray2Test_private extends TestCase {
    public void test_intArray() throws Exception {
        Model model = JSON.parseObject("{\"value\":[[1,2.1,-0.3]]}", Model.class);
        assertNotNull(model.value);
        assertEquals(1, model.value.length);
        assertEquals(3, model.value[0].length);
        assertEquals(1f, model.value[0][0]);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 12

              public class FieldFloatArray2Test_private extends TestCase {
    public void test_intArray() throws Exception {
        Model model = JSON.parseObject("{\"value\":[[1,2.1,-0.3]]}", Model.class);
        assertNotNull(model.value);
        assertEquals(1, model.value.length);
        assertEquals(3, model.value[0].length);
        assertEquals(1f, model.value[0][0]);
        assertEquals(2.1f, model.value[0][1]);
        assertEquals(-0.3f, model.value[0][2]);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 13

                  public void test_intArray() throws Exception {
        Model model = JSON.parseObject("{\"value\":[[1,2.1,-0.3]]}", Model.class);
        assertNotNull(model.value);
        assertEquals(1, model.value.length);
        assertEquals(3, model.value[0].length);
        assertEquals(1f, model.value[0][0]);
        assertEquals(2.1f, model.value[0][1]);
        assertEquals(-0.3f, model.value[0][2]);
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 14

                      Model model = JSON.parseObject("{\"value\":[[1,2.1,-0.3]]}", Model.class);
        assertNotNull(model.value);
        assertEquals(1, model.value.length);
        assertEquals(3, model.value[0].length);
        assertEquals(1f, model.value[0][0]);
        assertEquals(2.1f, model.value[0][1]);
        assertEquals(-0.3f, model.value[0][2]);
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 15

                      assertNotNull(model.value);
        assertEquals(1, model.value.length);
        assertEquals(3, model.value[0].length);
        assertEquals(1f, model.value[0][0]);
        assertEquals(2.1f, model.value[0][1]);
        assertEquals(-0.3f, model.value[0][2]);
    }

    private static class Model {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 16

                      assertEquals(1, model.value.length);
        assertEquals(3, model.value[0].length);
        assertEquals(1f, model.value[0][0]);
        assertEquals(2.1f, model.value[0][1]);
        assertEquals(-0.3f, model.value[0][2]);
    }

    private static class Model {
        public float[][] value;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

                      assertEquals(3, model.value[0].length);
        assertEquals(1f, model.value[0][0]);
        assertEquals(2.1f, model.value[0][1]);
        assertEquals(-0.3f, model.value[0][2]);
    }

    private static class Model {
        public float[][] value;
    }

            

Reported by PMD.

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

Line: 21

                  }

    private static class Model {
        public float[][] value;
    }
}

            

Reported by PMD.

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

	public void test_typeRef() throws Exception {
		TypeReference<Map<String, Entity>> typeRef = new TypeReference<Map<String, Entity>>() {
		};

		Map<String, Entity> map = JSON.parseObject(
				"{\"value\":{\"id\":\"abc\",\"list\":[{\"id\":123}]}}", typeRef);

            

Reported by PMD.

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

Line: 22

              		Map<String, Entity> map = JSON.parseObject(
				"{\"value\":{\"id\":\"abc\",\"list\":[{\"id\":123}]}}", typeRef);

		Entity entity = map.get("value");
		Assert.assertNotNull(entity);
		Assert.assertEquals("abc", entity.getId());
		Assert.assertEquals(1, entity.getList().size());
		Assert.assertEquals(123, entity.getList().get(0).getId());
	}

            

Reported by PMD.

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

Line: 24

              
		Entity entity = map.get("value");
		Assert.assertNotNull(entity);
		Assert.assertEquals("abc", entity.getId());
		Assert.assertEquals(1, entity.getList().size());
		Assert.assertEquals(123, entity.getList().get(0).getId());
	}

	public static class Entity {

            

Reported by PMD.

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

Line: 25

              		Entity entity = map.get("value");
		Assert.assertNotNull(entity);
		Assert.assertEquals("abc", entity.getId());
		Assert.assertEquals(1, entity.getList().size());
		Assert.assertEquals(123, entity.getList().get(0).getId());
	}

	public static class Entity {
		private String id;

            

Reported by PMD.

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

Line: 25

              		Entity entity = map.get("value");
		Assert.assertNotNull(entity);
		Assert.assertEquals("abc", entity.getId());
		Assert.assertEquals(1, entity.getList().size());
		Assert.assertEquals(123, entity.getList().get(0).getId());
	}

	public static class Entity {
		private String id;

            

Reported by PMD.

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

Line: 26

              		Assert.assertNotNull(entity);
		Assert.assertEquals("abc", entity.getId());
		Assert.assertEquals(1, entity.getList().size());
		Assert.assertEquals(123, entity.getList().get(0).getId());
	}

	public static class Entity {
		private String id;


            

Reported by PMD.

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

Line: 26

              		Assert.assertNotNull(entity);
		Assert.assertEquals("abc", entity.getId());
		Assert.assertEquals(1, entity.getList().size());
		Assert.assertEquals(123, entity.getList().get(0).getId());
	}

	public static class Entity {
		private String id;


            

Reported by PMD.

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

Line: 26

              		Assert.assertNotNull(entity);
		Assert.assertEquals("abc", entity.getId());
		Assert.assertEquals(1, entity.getList().size());
		Assert.assertEquals(123, entity.getList().get(0).getId());
	}

	public static class Entity {
		private String id;


            

Reported by PMD.

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

Line: 29

              		Assert.assertEquals(123, entity.getList().get(0).getId());
	}

	public static class Entity {
		private String id;

		private List<A> list = new ArrayList<A>();

		public String getId() {

            

Reported by PMD.

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

    public void test_model() throws Exception {
        Model model = new Model();
        model.id = -1001;
        model.id2 = -1002;

        String text = JSON.toJSONString(model);

            

Reported by PMD.

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

Line: 26

                      Assert.assertEquals("{\"id\":-1001,\"id2\":-1002}", text);
    }

    public void test_model_max() throws Exception {
        Model model = new Model();
        model.id = Integer.MIN_VALUE;
        model.id2 = Integer.MAX_VALUE;

        String text = JSON.toJSONString(model);

            

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

                      }
    }

    public void test_model_map() throws Exception {
        String text = "{\"model\":{\"id\":-1001,\"id2\":-1002}}";

        JSONReader reader = new JSONReader(new StringReader(text));
        Map<String, Model> map = reader.readObject(new TypeReference<Map<String, Model>>() {
        });

            

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

                      reader.close();
    }

    public void test_model_map_error() throws Exception {
        String text = "{\"model\":{\"id\":-1001,\"id2\":-1002[";

        Exception error = null;
        JSONReader reader = new JSONReader(new StringReader(text));
        try {

            

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

                      Assert.assertNotNull(error);
    }
    
    public void test_model_map_error_2() throws Exception {
        String text = "{\"model\":{\"id\":-1001,\"id2\":-1002}[";

        Exception error = null;
        JSONReader reader = new JSONReader(new StringReader(text));
        try {

            

Reported by PMD.

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

Line: 84

              
    public static class Model {

        public int id;
        public int id2;
    }
}

            

Reported by PMD.

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

Line: 85

                  public static class Model {

        public int id;
        public int id2;
    }
}

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '57'-'63').
Error

Line: 57

                  public void test_model_map_error() throws Exception {
        String text = "{\"model\":{\"id\":-1001,\"id2\":-1002[";

        Exception error = null;
        JSONReader reader = new JSONReader(new StringReader(text));
        try {
            reader.readObject(new TypeReference<Map<String, Model>>() {
            });
        } catch (JSONException ex) {

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '71'-'77').
Error

Line: 71

                  public void test_model_map_error_2() throws Exception {
        String text = "{\"model\":{\"id\":-1001,\"id2\":-1002}[";

        Exception error = null;
        JSONReader reader = new JSONReader(new StringReader(text));
        try {
            reader.readObject(new TypeReference<Map<String, Model>>() {
            });
        } catch (JSONException ex) {

            

Reported by PMD.