The following issues were found

src/test/java/com/alibaba/json/bvt/issue_3200/Issue3246.java
7 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: 9

              import lombok.Data;

public class Issue3246 extends TestCase {
    public void test_for_issue() throws Exception {
        String jsonStr = "{\"d_id\":\"bphyean01\",\"isOpenMergeCode\":0,\"offlineOrder\":false,\"offlineOrderType\":-1,\"og\":0,\"pushIdFromRemote\":false,\"qrisAmountPrice\":22000,\"s_req\":0,\"s_t\":1,\"skr_id\":0,\"type\":1,\"c_id\":471,\"o_$\":5500.0,\"am\":4,\"$_tp\":\"bp\",\"o_t\":1,\"a_m\":3}";
        Order parseOrder = JSON.parseObject(jsonStr,Order.class);
        assertEquals(Integer.valueOf(4), parseOrder.getAmount());
        assertEquals("3", parseOrder.getAddMoney());


            

Reported by PMD.

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

Line: 9

              import lombok.Data;

public class Issue3246 extends TestCase {
    public void test_for_issue() throws Exception {
        String jsonStr = "{\"d_id\":\"bphyean01\",\"isOpenMergeCode\":0,\"offlineOrder\":false,\"offlineOrderType\":-1,\"og\":0,\"pushIdFromRemote\":false,\"qrisAmountPrice\":22000,\"s_req\":0,\"s_t\":1,\"skr_id\":0,\"type\":1,\"c_id\":471,\"o_$\":5500.0,\"am\":4,\"$_tp\":\"bp\",\"o_t\":1,\"a_m\":3}";
        Order parseOrder = JSON.parseObject(jsonStr,Order.class);
        assertEquals(Integer.valueOf(4), parseOrder.getAmount());
        assertEquals("3", parseOrder.getAddMoney());


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 12

                  public void test_for_issue() throws Exception {
        String jsonStr = "{\"d_id\":\"bphyean01\",\"isOpenMergeCode\":0,\"offlineOrder\":false,\"offlineOrderType\":-1,\"og\":0,\"pushIdFromRemote\":false,\"qrisAmountPrice\":22000,\"s_req\":0,\"s_t\":1,\"skr_id\":0,\"type\":1,\"c_id\":471,\"o_$\":5500.0,\"am\":4,\"$_tp\":\"bp\",\"o_t\":1,\"a_m\":3}";
        Order parseOrder = JSON.parseObject(jsonStr,Order.class);
        assertEquals(Integer.valueOf(4), parseOrder.getAmount());
        assertEquals("3", parseOrder.getAddMoney());

    }

    @Data

            

Reported by PMD.

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

Line: 12

                  public void test_for_issue() throws Exception {
        String jsonStr = "{\"d_id\":\"bphyean01\",\"isOpenMergeCode\":0,\"offlineOrder\":false,\"offlineOrderType\":-1,\"og\":0,\"pushIdFromRemote\":false,\"qrisAmountPrice\":22000,\"s_req\":0,\"s_t\":1,\"skr_id\":0,\"type\":1,\"c_id\":471,\"o_$\":5500.0,\"am\":4,\"$_tp\":\"bp\",\"o_t\":1,\"a_m\":3}";
        Order parseOrder = JSON.parseObject(jsonStr,Order.class);
        assertEquals(Integer.valueOf(4), parseOrder.getAmount());
        assertEquals("3", parseOrder.getAddMoney());

    }

    @Data

            

Reported by PMD.

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

Line: 13

                      String jsonStr = "{\"d_id\":\"bphyean01\",\"isOpenMergeCode\":0,\"offlineOrder\":false,\"offlineOrderType\":-1,\"og\":0,\"pushIdFromRemote\":false,\"qrisAmountPrice\":22000,\"s_req\":0,\"s_t\":1,\"skr_id\":0,\"type\":1,\"c_id\":471,\"o_$\":5500.0,\"am\":4,\"$_tp\":\"bp\",\"o_t\":1,\"a_m\":3}";
        Order parseOrder = JSON.parseObject(jsonStr,Order.class);
        assertEquals(Integer.valueOf(4), parseOrder.getAmount());
        assertEquals("3", parseOrder.getAddMoney());

    }

    @Data
    public static class Order {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 13

                      String jsonStr = "{\"d_id\":\"bphyean01\",\"isOpenMergeCode\":0,\"offlineOrder\":false,\"offlineOrderType\":-1,\"og\":0,\"pushIdFromRemote\":false,\"qrisAmountPrice\":22000,\"s_req\":0,\"s_t\":1,\"skr_id\":0,\"type\":1,\"c_id\":471,\"o_$\":5500.0,\"am\":4,\"$_tp\":\"bp\",\"o_t\":1,\"a_m\":3}";
        Order parseOrder = JSON.parseObject(jsonStr,Order.class);
        assertEquals(Integer.valueOf(4), parseOrder.getAmount());
        assertEquals("3", parseOrder.getAddMoney());

    }

    @Data
    public static class Order {

            

Reported by PMD.

Too many fields
Design

Line: 18

                  }

    @Data
    public static class Order {
        @JSONField(name = "d_id", ordinal = 0)
        private String deviceId;
        @JSONField(name = "c_id", ordinal = 1)
        private Integer commodityId;
        @JSONField(name = "o_$", ordinal = 2)

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_3200/Issue3267.java
7 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 7

              import junit.framework.TestCase;

public class Issue3267 extends TestCase {
    public void test_for_issue() throws Exception {
        JSONValidator v = JSONValidator.from("113{}[]");
        v.setSupportMultiValue(false);
        assertFalse(
                v.validate());


            

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

              import junit.framework.TestCase;

public class Issue3267 extends TestCase {
    public void test_for_issue() throws Exception {
        JSONValidator v = JSONValidator.from("113{}[]");
        v.setSupportMultiValue(false);
        assertFalse(
                v.validate());


            

Reported by PMD.

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

Line: 9

              public class Issue3267 extends TestCase {
    public void test_for_issue() throws Exception {
        JSONValidator v = JSONValidator.from("113{}[]");
        v.setSupportMultiValue(false);
        assertFalse(
                v.validate());

        assertEquals(JSONValidator.Type.Value, v.getType());
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 10

                  public void test_for_issue() throws Exception {
        JSONValidator v = JSONValidator.from("113{}[]");
        v.setSupportMultiValue(false);
        assertFalse(
                v.validate());

        assertEquals(JSONValidator.Type.Value, v.getType());
    }
}

            

Reported by PMD.

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

Line: 11

                      JSONValidator v = JSONValidator.from("113{}[]");
        v.setSupportMultiValue(false);
        assertFalse(
                v.validate());

        assertEquals(JSONValidator.Type.Value, v.getType());
    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 13

                      assertFalse(
                v.validate());

        assertEquals(JSONValidator.Type.Value, v.getType());
    }
}

            

Reported by PMD.

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

Line: 13

                      assertFalse(
                v.validate());

        assertEquals(JSONValidator.Type.Value, v.getType());
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_3200/Issue3293.java
7 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

               * @Date :Created in 09:59 2020/6/24
 */
public class Issue3293 extends TestCase {
    public void test_for_issue() throws Exception {
        JSONValidator jv = JSONValidator.from("{\"a\"}");
        Assert.assertFalse(jv.validate());

        jv = JSONValidator.from("113{}[]");
        jv.setSupportMultiValue(false);

            

Reported by PMD.

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

Line: 14

              public class Issue3293 extends TestCase {
    public void test_for_issue() throws Exception {
        JSONValidator jv = JSONValidator.from("{\"a\"}");
        Assert.assertFalse(jv.validate());

        jv = JSONValidator.from("113{}[]");
        jv.setSupportMultiValue(false);
        Assert.assertFalse(jv.validate());
        Assert.assertEquals(JSONValidator.Type.Value, jv.getType());

            

Reported by PMD.

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

Line: 17

                      Assert.assertFalse(jv.validate());

        jv = JSONValidator.from("113{}[]");
        jv.setSupportMultiValue(false);
        Assert.assertFalse(jv.validate());
        Assert.assertEquals(JSONValidator.Type.Value, jv.getType());

        jv = JSONValidator.from("{\"a\":\"12333\"}");
        Assert.assertTrue(jv.validate());

            

Reported by PMD.

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

Line: 18

              
        jv = JSONValidator.from("113{}[]");
        jv.setSupportMultiValue(false);
        Assert.assertFalse(jv.validate());
        Assert.assertEquals(JSONValidator.Type.Value, jv.getType());

        jv = JSONValidator.from("{\"a\":\"12333\"}");
        Assert.assertTrue(jv.validate());


            

Reported by PMD.

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

Line: 19

                      jv = JSONValidator.from("113{}[]");
        jv.setSupportMultiValue(false);
        Assert.assertFalse(jv.validate());
        Assert.assertEquals(JSONValidator.Type.Value, jv.getType());

        jv = JSONValidator.from("{\"a\":\"12333\"}");
        Assert.assertTrue(jv.validate());

        jv = JSONValidator.from("{}");

            

Reported by PMD.

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

Line: 22

                      Assert.assertEquals(JSONValidator.Type.Value, jv.getType());

        jv = JSONValidator.from("{\"a\":\"12333\"}");
        Assert.assertTrue(jv.validate());

        jv = JSONValidator.from("{}");
        Assert.assertTrue(jv.validate());
    }
}

            

Reported by PMD.

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

Line: 25

                      Assert.assertTrue(jv.validate());

        jv = JSONValidator.from("{}");
        Assert.assertTrue(jv.validate());
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_3300/Issue3338.java
7 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 14

               * @Date :Created in 17:11 2020/7/11
 */
public class Issue3338 extends TestCase {
    public void test_for_issue() throws Exception {
        Model model = new Model();
        Map map = new HashMap();
        map.put("nanqi", "因为相信,所以看见。");
        model.setMap(map);


            

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

               * @Date :Created in 17:11 2020/7/11
 */
public class Issue3338 extends TestCase {
    public void test_for_issue() throws Exception {
        Model model = new Model();
        Map map = new HashMap();
        map.put("nanqi", "因为相信,所以看见。");
        model.setMap(map);


            

Reported by PMD.

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

Line: 21

                      model.setMap(map);

        String jsonString = JSONObject.toJSONString(model);
        assertTrue(jsonString.contains("因为相信,所以看见。"));

        Model modelBack = JSONObject.parseObject(jsonString, Model.class);
        assertEquals("因为相信,所以看见。", modelBack.getMap().get("nanqi"));
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 21

                      model.setMap(map);

        String jsonString = JSONObject.toJSONString(model);
        assertTrue(jsonString.contains("因为相信,所以看见。"));

        Model modelBack = JSONObject.parseObject(jsonString, Model.class);
        assertEquals("因为相信,所以看见。", modelBack.getMap().get("nanqi"));
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 24

                      assertTrue(jsonString.contains("因为相信,所以看见。"));

        Model modelBack = JSONObject.parseObject(jsonString, Model.class);
        assertEquals("因为相信,所以看见。", modelBack.getMap().get("nanqi"));
    }

    static class Model {
        private Map map;


            

Reported by PMD.

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

Line: 24

                      assertTrue(jsonString.contains("因为相信,所以看见。"));

        Model modelBack = JSONObject.parseObject(jsonString, Model.class);
        assertEquals("因为相信,所以看见。", modelBack.getMap().get("nanqi"));
    }

    static class Model {
        private Map map;


            

Reported by PMD.

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

Line: 24

                      assertTrue(jsonString.contains("因为相信,所以看见。"));

        Model modelBack = JSONObject.parseObject(jsonString, Model.class);
        assertEquals("因为相信,所以看见。", modelBack.getMap().get("nanqi"));
    }

    static class Model {
        private Map map;


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_3300/Issue3356.java
7 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: 9

              import java.util.UUID;

public class Issue3356 extends TestCase {
    public void test_for_issue() throws Exception {
        UUID uuid = UUID.randomUUID();

        JSONObject object = new JSONObject();
        object.put("1", "1");
        object.put(uuid.toString(), uuid.toString());

            

Reported by PMD.

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

Line: 9

              import java.util.UUID;

public class Issue3356 extends TestCase {
    public void test_for_issue() throws Exception {
        UUID uuid = UUID.randomUUID();

        JSONObject object = new JSONObject();
        object.put("1", "1");
        object.put(uuid.toString(), uuid.toString());

            

Reported by PMD.

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

Line: 14

              
        JSONObject object = new JSONObject();
        object.put("1", "1");
        object.put(uuid.toString(), uuid.toString());
        object.put("A", "A");
        object.put("true", "true");
        assertEquals("1", object.get(1));
        assertEquals("true", object.get(true));
        assertEquals("A", object.get('A'));

            

Reported by PMD.

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

Line: 14

              
        JSONObject object = new JSONObject();
        object.put("1", "1");
        object.put(uuid.toString(), uuid.toString());
        object.put("A", "A");
        object.put("true", "true");
        assertEquals("1", object.get(1));
        assertEquals("true", object.get(true));
        assertEquals("A", object.get('A'));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

                      object.put(uuid.toString(), uuid.toString());
        object.put("A", "A");
        object.put("true", "true");
        assertEquals("1", object.get(1));
        assertEquals("true", object.get(true));
        assertEquals("A", object.get('A'));
    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                      object.put("A", "A");
        object.put("true", "true");
        assertEquals("1", object.get(1));
        assertEquals("true", object.get(true));
        assertEquals("A", object.get('A'));
    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

                      object.put("true", "true");
        assertEquals("1", object.get(1));
        assertEquals("true", object.get(true));
        assertEquals("A", object.get('A'));
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_3300/Issue3443.java
7 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: 7

              import junit.framework.TestCase;

public class Issue3443 extends TestCase {
    public void testCustomJsonSerializerAndAfterFilter() throws Exception {
        SerializeWriter serializeWriter = new SerializeWriter();
        try {
            JSONSerializer jsonSerializer = new JSONSerializer(serializeWriter, new SerializeConfig());

            Parameter parameter = new Parameter();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                          jsonSerializer.config(SerializerFeature.DisableCircularReferenceDetect, true);
            jsonSerializer.getAfterFilters().add(new CustomFilter());
            jsonSerializer.write(parameter);
            assertEquals("{\"parameterDesc\":{\"ParameterDesc\":\"VIP expire date.\"}}", serializeWriter.toString());
        } finally {
            serializeWriter.close();
        }
    }


            

Reported by PMD.

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

Line: 37

                  }

    static class ParameterDesc {
        private String parameterName;
        private String parameterUsage;
        // do some work...

        public ParameterDesc(String parameterName, String parameterUsage) {
            this.parameterName = parameterName;

            

Reported by PMD.

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

Line: 37

                  }

    static class ParameterDesc {
        private String parameterName;
        private String parameterUsage;
        // do some work...

        public ParameterDesc(String parameterName, String parameterUsage) {
            this.parameterName = parameterName;

            

Reported by PMD.

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

Line: 38

              
    static class ParameterDesc {
        private String parameterName;
        private String parameterUsage;
        // do some work...

        public ParameterDesc(String parameterName, String parameterUsage) {
            this.parameterName = parameterName;
            this.parameterUsage = parameterUsage;

            

Reported by PMD.

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

Line: 38

              
    static class ParameterDesc {
        private String parameterName;
        private String parameterUsage;
        // do some work...

        public ParameterDesc(String parameterName, String parameterUsage) {
            this.parameterName = parameterName;
            this.parameterUsage = parameterUsage;

            

Reported by PMD.

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

Line: 3

              package com.alibaba.json.bvt.issue_3300;

import com.alibaba.fastjson.serializer.*;
import junit.framework.TestCase;

public class Issue3443 extends TestCase {
    public void testCustomJsonSerializerAndAfterFilter() throws Exception {
        SerializeWriter serializeWriter = new SerializeWriter();
        try {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_3600/Issue3672.java
7 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

              import junit.framework.TestCase;

public class Issue3672 extends TestCase {
    public void test_for_issue() throws Exception {
        Issue3672Root root = new Issue3672Root();
        Issue3672A a = new Issue3672A();
        Issue3672B b = new Issue3672B();
        Issue3672C c = new Issue3672C();
        Issue3672D d = new Issue3672D();

            

Reported by PMD.

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

Line: 22

                      Issue3672C c = new Issue3672C();
        Issue3672D d = new Issue3672D();
        root.setA(a);
        a.setB(Lists.newArrayList(b).toArray());
        b.setC(c);
        c.setD(d);
        d.setE(Lists.newArrayList(c));
        String str1 = JSON.toJSONString(root, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue);
        String str2 = JSON.toJSONString(root);

            

Reported by PMD.

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

Line: 31

              
        JSONObject obj1 = JSON.parseObject(str1);
        JSONObject obj2 = JSON.parseObject(str2);
        assertEquals(obj1.toString(), obj2.toString());
    }

    @Data
    private class Issue3672Root {
        private Issue3672A a;

            

Reported by PMD.

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

Line: 31

              
        JSONObject obj1 = JSON.parseObject(str1);
        JSONObject obj2 = JSON.parseObject(str2);
        assertEquals(obj1.toString(), obj2.toString());
    }

    @Data
    private class Issue3672Root {
        private Issue3672A a;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 31

              
        JSONObject obj1 = JSON.parseObject(str1);
        JSONObject obj2 = JSON.parseObject(str2);
        assertEquals(obj1.toString(), obj2.toString());
    }

    @Data
    private class Issue3672Root {
        private Issue3672A a;

            

Reported by PMD.

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

Line: 56

              
    @Data
    private class Issue3672D {
        private ArrayList<Issue3672C> e;
    }

}

            

Reported by PMD.

Avoid unused imports such as 'org.junit.Test'
Design

Line: 8

              import com.alibaba.fastjson.serializer.SerializerFeature;
import com.google.common.collect.Lists;
import lombok.Data;
import org.junit.Test;

import java.util.ArrayList;

import junit.framework.TestCase;


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/jdk8/LocalDateTest.java
7 issues
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.JSON;

public class LocalDateTest extends TestCase {
    protected void setUp() throws Exception {
        JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
        JSON.defaultLocale = Locale.CHINA;
    }

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

                      JSON.defaultLocale = Locale.CHINA;
    }

    public void test_for_issue() throws Exception {
        VO vo = new VO();
        vo.setDate(LocalDate.now());
        
        String text = JSON.toJSONString(vo);
        

            

Reported by PMD.

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

Line: 27

                      
        VO vo1 = JSON.parseObject(text, VO.class);
        
        Assert.assertEquals(vo.getDate(), vo1.getDate());
    }

    /**
     * 方法描述: 测试时间戳转换为 日期
     * @author wuqiong  2017/11/21 16:48

            

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

                   * 方法描述: 测试时间戳转换为 日期
     * @author wuqiong  2017/11/21 16:48
     */
    public void test_for_long() throws Exception {
        String text= "{\"date\":1511248447740}";
        VO vo =JSON.parseObject(text,VO.class);
        Assert.assertEquals(2017, vo.date.getYear());
        Assert.assertEquals(11, vo.date.getMonthValue());
        Assert.assertEquals(21, vo.date.getDayOfMonth());

            

Reported by PMD.

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

Line: 37

                  public void test_for_long() throws Exception {
        String text= "{\"date\":1511248447740}";
        VO vo =JSON.parseObject(text,VO.class);
        Assert.assertEquals(2017, vo.date.getYear());
        Assert.assertEquals(11, vo.date.getMonthValue());
        Assert.assertEquals(21, vo.date.getDayOfMonth());
    }

    public static class VO {

            

Reported by PMD.

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

Line: 38

                      String text= "{\"date\":1511248447740}";
        VO vo =JSON.parseObject(text,VO.class);
        Assert.assertEquals(2017, vo.date.getYear());
        Assert.assertEquals(11, vo.date.getMonthValue());
        Assert.assertEquals(21, vo.date.getDayOfMonth());
    }

    public static class VO {


            

Reported by PMD.

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

Line: 39

                      VO vo =JSON.parseObject(text,VO.class);
        Assert.assertEquals(2017, vo.date.getYear());
        Assert.assertEquals(11, vo.date.getMonthValue());
        Assert.assertEquals(21, vo.date.getDayOfMonth());
    }

    public static class VO {

        private LocalDate date;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/joda/JodaTest_6_Period.java
7 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

              import org.joda.time.format.DateTimeFormatter;

public class JodaTest_6_Period extends TestCase {
    public void test_for_joda_0() throws Exception {

       Model m = new Model();
       m.period = Period.days(3);

       String json = JSON.toJSONString(m);

            

Reported by PMD.

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

Line: 10

              import org.joda.time.format.DateTimeFormatter;

public class JodaTest_6_Period extends TestCase {
    public void test_for_joda_0() throws Exception {

       Model m = new Model();
       m.period = Period.days(3);

       String json = JSON.toJSONString(m);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

              
       String json = JSON.toJSONString(m);

       assertEquals("{\"period\":\"P3D\"}", json);

       Model m1 = JSON.parseObject(json, Model.class);
       assertEquals(m.period, m1.period);
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 20

                     assertEquals("{\"period\":\"P3D\"}", json);

       Model m1 = JSON.parseObject(json, Model.class);
       assertEquals(m.period, m1.period);
    }

    public static class Model {
        public Period period;
    }

            

Reported by PMD.

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

Line: 24

                  }

    public static class Model {
        public Period period;
    }
}

            

Reported by PMD.

Avoid unused imports such as 'org.joda.time.format.DateTimeFormat'
Design

Line: 6

              import com.alibaba.fastjson.JSON;
import junit.framework.TestCase;
import org.joda.time.Period;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

public class JodaTest_6_Period extends TestCase {
    public void test_for_joda_0() throws Exception {


            

Reported by PMD.

Avoid unused imports such as 'org.joda.time.format.DateTimeFormatter'
Design

Line: 7

              import junit.framework.TestCase;
import org.joda.time.Period;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

public class JodaTest_6_Period extends TestCase {
    public void test_for_joda_0() throws Exception {

       Model m = new Model();

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/kotlin/Issue1483.java
7 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 16

               */
public class Issue1483 extends TestCase {

    public void test_user() throws Exception {
        ExtClassLoader classLoader = new ExtClassLoader();
        Class clazz = classLoader.loadClass("Person");

        String json = "{\"age\":99,\"name\":\"robohorse\",\"desc\":\"xx\"}";
        Object obj = JSON.parseObject(json, clazz);

            

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

               */
public class Issue1483 extends TestCase {

    public void test_user() throws Exception {
        ExtClassLoader classLoader = new ExtClassLoader();
        Class clazz = classLoader.loadClass("Person");

        String json = "{\"age\":99,\"name\":\"robohorse\",\"desc\":\"xx\"}";
        Object obj = JSON.parseObject(json, clazz);

            

Reported by PMD.

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

Line: 22

              
        String json = "{\"age\":99,\"name\":\"robohorse\",\"desc\":\"xx\"}";
        Object obj = JSON.parseObject(json, clazz);
        assertSame(clazz, obj.getClass());
//
        for (int i = 0; i < 10; ++i) {
            String text = JSON.parseObject(JSON.toJSONString(obj), Feature.OrderedField).toJSONString();
            assertEquals("{\"age\":99,\"desc\":\"xx\",\"name\":\"robohorse\"}", text);
        }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 22

              
        String json = "{\"age\":99,\"name\":\"robohorse\",\"desc\":\"xx\"}";
        Object obj = JSON.parseObject(json, clazz);
        assertSame(clazz, obj.getClass());
//
        for (int i = 0; i < 10; ++i) {
            String text = JSON.parseObject(JSON.toJSONString(obj), Feature.OrderedField).toJSONString();
            assertEquals("{\"age\":99,\"desc\":\"xx\",\"name\":\"robohorse\"}", text);
        }

            

Reported by PMD.

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

Line: 25

                      assertSame(clazz, obj.getClass());
//
        for (int i = 0; i < 10; ++i) {
            String text = JSON.parseObject(JSON.toJSONString(obj), Feature.OrderedField).toJSONString();
            assertEquals("{\"age\":99,\"desc\":\"xx\",\"name\":\"robohorse\"}", text);
        }
    }

    public static class ExtClassLoader extends ClassLoader {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 26

              //
        for (int i = 0; i < 10; ++i) {
            String text = JSON.parseObject(JSON.toJSONString(obj), Feature.OrderedField).toJSONString();
            assertEquals("{\"age\":99,\"desc\":\"xx\",\"name\":\"robohorse\"}", text);
        }
    }

    public static class ExtClassLoader extends ClassLoader {


            

Reported by PMD.

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

Line: 37

              
            {
                byte[] bytes;
                InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("kotlin/Person.clazz");
                bytes = IOUtils.toByteArray(is);
                is.close();

                super.defineClass("Person", bytes, 0, bytes.length);
            }

            

Reported by PMD.