The following issues were found

src/test/java/com/alibaba/json/bvt/fullSer/ToJavaObjectTest2.java
5 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

               * Created by wenshao on 04/02/2017.
 */
public class ToJavaObjectTest2 extends TestCase {
    public void test_for_toJavaObject() throws Exception {
        JSONObject obj = JSON.parseObject("{\"model\":{\"id\":123}}");
        Map<String, Model> models = obj.toJavaObject(new TypeReference<Map<String, Model>>(){}.getType());
        assertEquals(123, models.get("model").id);
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                  public void test_for_toJavaObject() throws Exception {
        JSONObject obj = JSON.parseObject("{\"model\":{\"id\":123}}");
        Map<String, Model> models = obj.toJavaObject(new TypeReference<Map<String, Model>>(){}.getType());
        assertEquals(123, models.get("model").id);
    }

    public static class Model {
        public int id;
    }

            

Reported by PMD.

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

Line: 18

                  public void test_for_toJavaObject() throws Exception {
        JSONObject obj = JSON.parseObject("{\"model\":{\"id\":123}}");
        Map<String, Model> models = obj.toJavaObject(new TypeReference<Map<String, Model>>(){}.getType());
        assertEquals(123, models.get("model").id);
    }

    public static class Model {
        public int id;
    }

            

Reported by PMD.

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

Line: 22

                  }

    public static class Model {
        public int id;
    }
}

            

Reported by PMD.

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

Line: 8

              import com.alibaba.fastjson.TypeReference;
import junit.framework.TestCase;

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

/**
 * Created by wenshao on 04/02/2017.
 */

            

Reported by PMD.

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

    public void test_for_bug(){
        String jsonStr = "{\"items\":[{\"id\":1,\"name\":\"kata\"}]}";
        TestReply testReply = JSON.parseObject(jsonStr, new TypeReference<TestReply>() {
        });

        Assert.assertEquals(testReply.getItems().get(0).getId() , 1);

            

Reported by PMD.

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

Line: 18

                      TestReply testReply = JSON.parseObject(jsonStr, new TypeReference<TestReply>() {
        });

        Assert.assertEquals(testReply.getItems().get(0).getId() , 1);
    }

    public static class SuperBaseReply<T> {
        private List<T> items;


            

Reported by PMD.

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

Line: 18

                      TestReply testReply = JSON.parseObject(jsonStr, new TypeReference<TestReply>() {
        });

        Assert.assertEquals(testReply.getItems().get(0).getId() , 1);
    }

    public static class SuperBaseReply<T> {
        private List<T> items;


            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 37

              
    }

    public static class Msg implements Serializable {
        private int id;
        private String name;

        public int getId() {
            return id;

            

Reported by PMD.

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

Line: 37

              
    }

    public static class Msg implements Serializable {
        private int id;
        private String name;

        public int getId() {
            return id;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_3200/Issue3266.java
5 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 junit.framework.TestCase;

public class Issue3266 extends TestCase {
    public void test_for_issue() throws Exception {
        VO vo = new VO();
        vo.type = Color.Black;

        String str = JSON.toJSONString(vo);
        assertEquals("{\"type\":1003}", str);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 14

                      vo.type = Color.Black;

        String str = JSON.toJSONString(vo);
        assertEquals("{\"type\":1003}", str);

        VO vo2 = JSON.parseObject(str, VO.class);

    }


            

Reported by PMD.

Avoid unused local variables such as 'vo2'.
Design

Line: 16

                      String str = JSON.toJSONString(vo);
        assertEquals("{\"type\":1003}", str);

        VO vo2 = JSON.parseObject(str, VO.class);

    }

    public static class VO {
        public Color type;

            

Reported by PMD.

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

Line: 21

                  }

    public static class VO {
        public Color type;
    }

    public enum Color {
        Red(1001),
        White(1002),

            

Reported by PMD.

Found 'DU'-anomaly for variable 'vo2' (lines '16'-'18').
Error

Line: 16

                      String str = JSON.toJSONString(vo);
        assertEquals("{\"type\":1003}", str);

        VO vo2 = JSON.parseObject(str, VO.class);

    }

    public static class VO {
        public Color type;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_3200/Issue3266_mixedin.java
5 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 junit.framework.TestCase;

public class Issue3266_mixedin extends TestCase {
    public void test_for_issue() throws Exception {
        JSON.addMixInAnnotations(Color.class, ColorMixedIn.class);

        VO vo = new VO();
        vo.type = Color.Black;


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 16

                      vo.type = Color.Black;

        String str = JSON.toJSONString(vo);
        assertEquals("{\"type\":1003}", str);

        VO vo2 = JSON.parseObject(str, VO.class);
    }

    public static class VO {

            

Reported by PMD.

Avoid unused local variables such as 'vo2'.
Design

Line: 18

                      String str = JSON.toJSONString(vo);
        assertEquals("{\"type\":1003}", str);

        VO vo2 = JSON.parseObject(str, VO.class);
    }

    public static class VO {
        public Color type;
    }

            

Reported by PMD.

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

Line: 22

                  }

    public static class VO {
        public Color type;
    }

    public enum Color {
        Red(1001),
        White(1002),

            

Reported by PMD.

Found 'DU'-anomaly for variable 'vo2' (lines '18'-'19').
Error

Line: 18

                      String str = JSON.toJSONString(vo);
        assertEquals("{\"type\":1003}", str);

        VO vo2 = JSON.parseObject(str, VO.class);
    }

    public static class VO {
        public Color type;
    }

            

Reported by PMD.

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

    public void test_0() throws Exception {
        String text = "{a:1,b:2}";
        JSONObject json = JSON.parseObject(text, JSONObject.class);
        Assert.assertEquals(1, json.getIntValue("a"));
        Assert.assertEquals(2, json.getIntValue("b"));
    }

            

Reported by PMD.

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

Line: 16

                  public void test_0() throws Exception {
        String text = "{a:1,b:2}";
        JSONObject json = JSON.parseObject(text, JSONObject.class);
        Assert.assertEquals(1, json.getIntValue("a"));
        Assert.assertEquals(2, json.getIntValue("b"));
    }

    public void test_array_exception() throws Exception {
        String text = "[1, 2]}";

            

Reported by PMD.

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

Line: 17

                      String text = "{a:1,b:2}";
        JSONObject json = JSON.parseObject(text, JSONObject.class);
        Assert.assertEquals(1, json.getIntValue("a"));
        Assert.assertEquals(2, json.getIntValue("b"));
    }

    public void test_array_exception() throws Exception {
        String text = "[1, 2]}";
        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: 20

                      Assert.assertEquals(2, json.getIntValue("b"));
    }

    public void test_array_exception() throws Exception {
        String text = "[1, 2]}";
        Exception error = null;
        try {
            JSON.parseObject(text, JSONArray.class);
        } catch (JSONException ex) {

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '22'-'26').
Error

Line: 22

              
    public void test_array_exception() throws Exception {
        String text = "[1, 2]}";
        Exception error = null;
        try {
            JSON.parseObject(text, JSONArray.class);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_2200/Issue2289.java
5 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 junit.framework.TestCase;

public class Issue2289 extends TestCase {
    public void test_for_issue() throws Exception {
        B b = new B();
        b.id = 123;

        JSONSerializer jsonSerializer = new JSONSerializer();


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                      jsonSerializer.writeAs(b, A.class);

        String str = jsonSerializer.toString();
        assertEquals("{}", str);
    }

    public static class A {

    }

            

Reported by PMD.

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

Line: 26

                  }

    public static class B extends A {
        public int id;
    }
}

            

Reported by PMD.

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

Line: 3

              package com.alibaba.json.bvt.issue_2200;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.ObjectSerializer;
import junit.framework.TestCase;

public class Issue2289 extends TestCase {
    public void test_for_issue() throws Exception {

            

Reported by PMD.

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

Line: 5

              
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.ObjectSerializer;
import junit.framework.TestCase;

public class Issue2289 extends TestCase {
    public void test_for_issue() throws Exception {
        B b = new B();

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_3200/Issue3281.java
5 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: 19

               * @Description:补充测试用例
 */
public class Issue3281 extends TestCase {
    public void test_for_issue() {
        ModelState modelBack = JSON.parseObject("{\"counterMap\":{\"0\":0,\"100\":0,\"200\":0,\"300\":0,\"400\":0," +
                "\"500\":0,\"600\":0,\"700\":0,\"800\":0,\"900\":0,\"1000\":0},\"formatDate\":null," +
                "\"modelName\":\"test\",\"modelScores\":{\"Test1-1000\":{\"max\":1.0997832999999515,\"min\":0.0," +
                "\"recording\":false}},\"modelVersion\":\"1\",\"pit\":1592470429399,\"useCaseName\":\"test\"," +
                "\"variableName\":\"v2\"}", ModelState.class);

            

Reported by PMD.

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

Line: 25

                              "\"modelName\":\"test\",\"modelScores\":{\"Test1-1000\":{\"max\":1.0997832999999515,\"min\":0.0," +
                "\"recording\":false}},\"modelVersion\":\"1\",\"pit\":1592470429399,\"useCaseName\":\"test\"," +
                "\"variableName\":\"v2\"}", ModelState.class);
        Assert.assertNotNull(modelBack.getCounterMap());
        Assert.assertNotNull(modelBack.getModelScores());
    }

    @Builder
    @Data

            

Reported by PMD.

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

Line: 26

                              "\"recording\":false}},\"modelVersion\":\"1\",\"pit\":1592470429399,\"useCaseName\":\"test\"," +
                "\"variableName\":\"v2\"}", ModelState.class);
        Assert.assertNotNull(modelBack.getCounterMap());
        Assert.assertNotNull(modelBack.getModelScores());
    }

    @Builder
    @Data
    @AllArgsConstructor

            

Reported by PMD.

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

Line: 33

                  @Data
    @AllArgsConstructor
    public static class ModelState {
        private HashMap<String, Long> counterMap;

        private Date formatDate;

        private HashMap<String, TGigest> modelScores;


            

Reported by PMD.

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

Line: 37

              
        private Date formatDate;

        private HashMap<String, TGigest> modelScores;

        private String modelName;

        private Long modelVersion;


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1300/Issue_for_zuojian.java
5 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 java.util.Date;

public class Issue_for_zuojian extends TestCase {
    public void test_for_issue() throws Exception {
        JSON.DEFFAULT_DATE_FORMAT = "yyyyMMddHHmmssSSSZ";
        String json = "{\"value\":\"20180131022733000-0800\"}";
        JSON.parseObject(json, Model.class);
        JSON.DEFFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
    }

            

Reported by PMD.

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

Line: 10

              import java.util.Date;

public class Issue_for_zuojian extends TestCase {
    public void test_for_issue() throws Exception {
        JSON.DEFFAULT_DATE_FORMAT = "yyyyMMddHHmmssSSSZ";
        String json = "{\"value\":\"20180131022733000-0800\"}";
        JSON.parseObject(json, Model.class);
        JSON.DEFFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
    }

            

Reported by PMD.

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

Line: 17

                      JSON.DEFFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
    }

    public void test_for_issue_1() throws Exception {
        JSON.DEFFAULT_DATE_FORMAT = "yyyyMMddHHmmssSSSZ";

        String json = "{\"value\":\"20180131022733000-0800\"}";
        JSONObject object = JSON.parseObject(json);
        object.getObject("value", Date.class);

            

Reported by PMD.

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

Line: 17

                      JSON.DEFFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
    }

    public void test_for_issue_1() throws Exception {
        JSON.DEFFAULT_DATE_FORMAT = "yyyyMMddHHmmssSSSZ";

        String json = "{\"value\":\"20180131022733000-0800\"}";
        JSONObject object = JSON.parseObject(json);
        object.getObject("value", Date.class);

            

Reported by PMD.

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

Line: 22

              
        String json = "{\"value\":\"20180131022733000-0800\"}";
        JSONObject object = JSON.parseObject(json);
        object.getObject("value", Date.class);

        JSON.DEFFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
    }

    public static class Model {

            

Reported by PMD.

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

    public void test_codec_null() throws Exception {

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

        {

            

Reported by PMD.

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

Line: 24

              
            V0 v1 = JSON.parseObject(text, V0.class);

            Assert.assertEquals(v1.getValue(), v.getValue());
        }
        {
            V0 v = new V0();
            v.setValue(Integer.valueOf(123));
            String text = JSON.toJSONString(v, mapping, SerializerFeature.WriteMapNullValue);

            

Reported by PMD.

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

Line: 34

              
            V0 v1 = JSON.parseObject(text, V0.class);

            Assert.assertEquals(v1.getValue(), v.getValue());
        }
    }

    public void test_codec_null_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: 38

                      }
    }

    public void test_codec_null_1() throws Exception {

        SerializeConfig mapping = new SerializeConfig();
        mapping.setAsmEnable(false);
        {
            V0 v = new V0();

            

Reported by PMD.

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

Line: 56

              
            V0 v1 = JSON.parseObject(text, V0.class);

            Assert.assertEquals(v1.getValue(), v.getValue());
        }
    }

    public static class V0 {


            

Reported by PMD.

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

Line: 11

              	public void test_exception() throws Exception {
		RuntimeException ex = new RuntimeException("e1");
		String text = JSON.toJSONString(ex);
		System.out.println(text);
		
		RuntimeException ex2 = (RuntimeException) JSON.parse(text);
	}
}

            

Reported by PMD.

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

Line: 8

              import com.alibaba.fastjson.JSON;

public class Bug_for_Exception extends TestCase {
	public void test_exception() throws Exception {
		RuntimeException ex = new RuntimeException("e1");
		String text = JSON.toJSONString(ex);
		System.out.println(text);
		
		RuntimeException ex2 = (RuntimeException) JSON.parse(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: 8

              import com.alibaba.fastjson.JSON;

public class Bug_for_Exception extends TestCase {
	public void test_exception() throws Exception {
		RuntimeException ex = new RuntimeException("e1");
		String text = JSON.toJSONString(ex);
		System.out.println(text);
		
		RuntimeException ex2 = (RuntimeException) JSON.parse(text);

            

Reported by PMD.

Avoid unused local variables such as 'ex2'.
Design

Line: 13

              		String text = JSON.toJSONString(ex);
		System.out.println(text);
		
		RuntimeException ex2 = (RuntimeException) JSON.parse(text);
	}
}

            

Reported by PMD.

Found 'DU'-anomaly for variable 'ex2' (lines '13'-'14').
Error

Line: 13

              		String text = JSON.toJSONString(ex);
		System.out.println(text);
		
		RuntimeException ex2 = (RuntimeException) JSON.parse(text);
	}
}

            

Reported by PMD.