The following issues were found

src/test/java/com/alibaba/json/bvt/kotlin/DataClassSimpleTest.java
6 issues
System.out.println is used
Design

Line: 24

                      Class clazz = classLoader.loadClass("DataClassSimple");

        String[] names = ASMUtils.lookupParameterNames(clazz.getConstructors()[0]);
        System.out.println(JSON.toJSONString(names));

        String json = "{\"a\":1001,\"b\":1002}";
        Object obj = JSON.parseObject(json, clazz);
        assertEquals("{\"a\":1001,\"b\":1002}", JSON.toJSONString(obj));


            

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

               */
public class DataClassSimpleTest extends TestCase {

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

        String[] names = ASMUtils.lookupParameterNames(clazz.getConstructors()[0]);
        System.out.println(JSON.toJSONString(names));

            

Reported by PMD.

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

Line: 23

                      ExtClassLoader classLoader = new ExtClassLoader();
        Class clazz = classLoader.loadClass("DataClassSimple");

        String[] names = ASMUtils.lookupParameterNames(clazz.getConstructors()[0]);
        System.out.println(JSON.toJSONString(names));

        String json = "{\"a\":1001,\"b\":1002}";
        Object obj = JSON.parseObject(json, clazz);
        assertEquals("{\"a\":1001,\"b\":1002}", JSON.toJSONString(obj));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 28

              
        String json = "{\"a\":1001,\"b\":1002}";
        Object obj = JSON.parseObject(json, clazz);
        assertEquals("{\"a\":1001,\"b\":1002}", JSON.toJSONString(obj));

    }

    public static class ExtClassLoader extends ClassLoader {
        Map<String, byte[]> resources = new HashMap<String, byte[]>();

            

Reported by PMD.

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

Line: 33

                  }

    public static class ExtClassLoader extends ClassLoader {
        Map<String, byte[]> resources = new HashMap<String, byte[]>();

        public ExtClassLoader() throws IOException {
            super(Thread.currentThread().getContextClassLoader());

            {

            

Reported by PMD.

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

Line: 40

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

                resources.put("DataClassSimple.class", bytes);


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/TypeUtilsToJSONTest.java
6 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

              @SuppressWarnings("rawtypes")
public class TypeUtilsToJSONTest extends TestCase {

    public void test_0() throws Exception {
        HashMap map = new HashMap();

        JSONObject json = (JSONObject) JSON.toJSON(map);

        Assert.assertEquals(map.size(), json.size());

            

Reported by PMD.

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

Line: 22

              
        JSONObject json = (JSONObject) JSON.toJSON(map);

        Assert.assertEquals(map.size(), json.size());
    }

    public void test_1() throws Exception {
        List list = new ArrayList();


            

Reported by PMD.

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

Line: 25

                      Assert.assertEquals(map.size(), json.size());
    }

    public void test_1() throws Exception {
        List list = new ArrayList();

        JSONArray json = (JSONArray) JSON.toJSON(list);

        Assert.assertEquals(list.size(), json.size());

            

Reported by PMD.

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

Line: 30

              
        JSONArray json = (JSONArray) JSON.toJSON(list);

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

    public void test_null() throws Exception {
        Assert.assertEquals(null, JSON.toJSON(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: 33

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

    public void test_null() throws Exception {
        Assert.assertEquals(null, JSON.toJSON(null));
    }

    public static class User {


            

Reported by PMD.

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

Line: 37

                      Assert.assertEquals(null, JSON.toJSON(null));
    }

    public static class User {

        private long   id;
        private String name;

        public long getId() {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/TypeUtilsTest_compatibleWithJavaBean_boolean.java
6 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 12

              
public class TypeUtilsTest_compatibleWithJavaBean_boolean extends TestCase {

    private boolean origin_compatibleWithJavaBean;

    protected void setUp() throws Exception {
        origin_compatibleWithJavaBean = TypeUtils.compatibleWithJavaBean;
        TypeUtils.compatibleWithJavaBean = true;
    }

            

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

              
    private boolean origin_compatibleWithJavaBean;

    protected void setUp() throws Exception {
        origin_compatibleWithJavaBean = TypeUtils.compatibleWithJavaBean;
        TypeUtils.compatibleWithJavaBean = true;
    }

    protected void tearDown() throws Exception {

            

Reported by PMD.

JUnit 4 tests that clean up tests should use the @After annotation, JUnit5 tests should use @AfterEach or @AfterAll
Design

Line: 19

                      TypeUtils.compatibleWithJavaBean = true;
    }

    protected void tearDown() throws Exception {
        TypeUtils.compatibleWithJavaBean = origin_compatibleWithJavaBean;
    }

    public void test_true() throws Exception {
        String text = JSON.toJSONString(new VO(true));

            

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

                      TypeUtils.compatibleWithJavaBean = origin_compatibleWithJavaBean;
    }

    public void test_true() throws Exception {
        String text = JSON.toJSONString(new VO(true));
        Assert.assertEquals("{\"ID\":true}", text);
        Assert.assertEquals(true, JSON.parseObject(text, VO.class).isID());
    }


            

Reported by PMD.

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

Line: 26

                  public void test_true() throws Exception {
        String text = JSON.toJSONString(new VO(true));
        Assert.assertEquals("{\"ID\":true}", text);
        Assert.assertEquals(true, JSON.parseObject(text, VO.class).isID());
    }

    public static class VO {

        private boolean id;

            

Reported by PMD.

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

Line: 31

              
    public static class VO {

        private boolean id;

        public VO(){

        }


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/TypeUtilsTest_compatibleWithJavaBean.java
6 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 12

              
public class TypeUtilsTest_compatibleWithJavaBean extends TestCase {

    private boolean origin_compatibleWithJavaBean;

    protected void setUp() throws Exception {
        origin_compatibleWithJavaBean = TypeUtils.compatibleWithJavaBean;
        TypeUtils.compatibleWithJavaBean = true;
    }

            

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

              
    private boolean origin_compatibleWithJavaBean;

    protected void setUp() throws Exception {
        origin_compatibleWithJavaBean = TypeUtils.compatibleWithJavaBean;
        TypeUtils.compatibleWithJavaBean = true;
    }

    protected void tearDown() throws Exception {

            

Reported by PMD.

JUnit 4 tests that clean up tests should use the @After annotation, JUnit5 tests should use @AfterEach or @AfterAll
Design

Line: 19

                      TypeUtils.compatibleWithJavaBean = true;
    }

    protected void tearDown() throws Exception {
        TypeUtils.compatibleWithJavaBean = origin_compatibleWithJavaBean;
    }

    public void test_true() throws Exception {
        String text = JSON.toJSONString(new VO(123));

            

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

                      TypeUtils.compatibleWithJavaBean = origin_compatibleWithJavaBean;
    }

    public void test_true() throws Exception {
        String text = JSON.toJSONString(new VO(123));
        Assert.assertEquals("{\"ID\":123}", text);
        Assert.assertEquals(123, JSON.parseObject(text, VO.class).getID());
    }


            

Reported by PMD.

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

Line: 26

                  public void test_true() throws Exception {
        String text = JSON.toJSONString(new VO(123));
        Assert.assertEquals("{\"ID\":123}", text);
        Assert.assertEquals(123, JSON.parseObject(text, VO.class).getID());
    }

    public static class VO {

        private int id;

            

Reported by PMD.

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

Line: 31

              
    public static class VO {

        private int id;

        public VO(){

        }


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/feature/WriteNullStringAsEmptyTest.java
6 issues
System.out.println is used
Design

Line: 26

              
        Model model = new Model();
        String json = JSON.toJSONString(model, filter, SerializerFeature.WriteNullStringAsEmpty);
        System.out.println(json);
    }


    private static class Model {
        @JSONField(serialzeFeatures = SerializerFeature.WriteNullStringAsEmpty)

            

Reported by PMD.

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

Line: 13

               * Created by wenshao on 14/03/2017.
 */
public class WriteNullStringAsEmptyTest extends TestCase {
    public void test_features() throws Exception {
        PropertyFilter filter = new PropertyFilter() {

            public boolean apply(Object object, String name, Object value) {
                if (value == null && object instanceof Model && "id".equals(name)) {
                    return false;

            

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

               * Created by wenshao on 14/03/2017.
 */
public class WriteNullStringAsEmptyTest extends TestCase {
    public void test_features() throws Exception {
        PropertyFilter filter = new PropertyFilter() {

            public boolean apply(Object object, String name, Object value) {
                if (value == null && object instanceof Model && "id".equals(name)) {
                    return false;

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 17

                      PropertyFilter filter = new PropertyFilter() {

            public boolean apply(Object object, String name, Object value) {
                if (value == null && object instanceof Model && "id".equals(name)) {
                    return false;
                }
                return true;
            }
        };

            

Reported by PMD.

Found 'DU'-anomaly for variable 'filter' (lines '14'-'27').
Error

Line: 14

               */
public class WriteNullStringAsEmptyTest extends TestCase {
    public void test_features() throws Exception {
        PropertyFilter filter = new PropertyFilter() {

            public boolean apply(Object object, String name, Object value) {
                if (value == null && object instanceof Model && "id".equals(name)) {
                    return false;
                }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'filter' (lines '14'-'27').
Error

Line: 14

               */
public class WriteNullStringAsEmptyTest extends TestCase {
    public void test_features() throws Exception {
        PropertyFilter filter = new PropertyFilter() {

            public boolean apply(Object object, String name, Object value) {
                if (value == null && object instanceof Model && "id".equals(name)) {
                    return false;
                }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_2900/Issue2952.java
6 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 12

              import junit.framework.TestCase;

public class Issue2952 extends TestCase {
    public void test_for_issue() throws Exception {
        String expected = "{\"l\":null,\"s\":null,\"b\":null,\"i\":null,\"o\":null}";
        SerializerFeature[] serializerFeatures = {
                SerializerFeature.WriteNullListAsEmpty,
                SerializerFeature.WriteNullStringAsEmpty,
                SerializerFeature.WriteNullBooleanAsFalse,

            

Reported by PMD.

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

Line: 12

              import junit.framework.TestCase;

public class Issue2952 extends TestCase {
    public void test_for_issue() throws Exception {
        String expected = "{\"l\":null,\"s\":null,\"b\":null,\"i\":null,\"o\":null}";
        SerializerFeature[] serializerFeatures = {
                SerializerFeature.WriteNullListAsEmpty,
                SerializerFeature.WriteNullStringAsEmpty,
                SerializerFeature.WriteNullBooleanAsFalse,

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 22

                      };
        SerializeConfig asmConfig = new SerializeConfig();
        asmConfig.setAsmEnable(true);
        assertEquals(expected, JSON.toJSONString(new Pojo(), asmConfig, serializerFeatures));
        assertEquals(expected, JSON.toJSONString(new Pojo2(), asmConfig, serializerFeatures));
        SerializeConfig noasmConfig = new SerializeConfig();
        noasmConfig.setAsmEnable(false);
        assertEquals(expected, JSON.toJSONString(new Pojo(), noasmConfig, serializerFeatures));
        assertEquals(expected, JSON.toJSONString(new Pojo2(), noasmConfig, serializerFeatures));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 23

                      SerializeConfig asmConfig = new SerializeConfig();
        asmConfig.setAsmEnable(true);
        assertEquals(expected, JSON.toJSONString(new Pojo(), asmConfig, serializerFeatures));
        assertEquals(expected, JSON.toJSONString(new Pojo2(), asmConfig, serializerFeatures));
        SerializeConfig noasmConfig = new SerializeConfig();
        noasmConfig.setAsmEnable(false);
        assertEquals(expected, JSON.toJSONString(new Pojo(), noasmConfig, serializerFeatures));
        assertEquals(expected, JSON.toJSONString(new Pojo2(), noasmConfig, serializerFeatures));
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 26

                      assertEquals(expected, JSON.toJSONString(new Pojo2(), asmConfig, serializerFeatures));
        SerializeConfig noasmConfig = new SerializeConfig();
        noasmConfig.setAsmEnable(false);
        assertEquals(expected, JSON.toJSONString(new Pojo(), noasmConfig, serializerFeatures));
        assertEquals(expected, JSON.toJSONString(new Pojo2(), noasmConfig, serializerFeatures));
    }

    public static class Pojo {
        @JSONField(serialzeFeatures=SerializerFeature.WriteMapNullValue, ordinal=0)

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 27

                      SerializeConfig noasmConfig = new SerializeConfig();
        noasmConfig.setAsmEnable(false);
        assertEquals(expected, JSON.toJSONString(new Pojo(), noasmConfig, serializerFeatures));
        assertEquals(expected, JSON.toJSONString(new Pojo2(), noasmConfig, serializerFeatures));
    }

    public static class Pojo {
        @JSONField(serialzeFeatures=SerializerFeature.WriteMapNullValue, ordinal=0)
        public Object[] l;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1900/Issue1941_JSONField_order.java
6 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 10

              
public class Issue1941_JSONField_order extends TestCase {

    public void test_for_issue() throws Exception {
        String json = "{\"type\":\"floorV2\",\"templateId\":\"x123\",\"name\":\"floorname2\"}";
        FloorV2  a=(FloorV2) JSON.parseObject(json,Area.class);
        assertEquals("floorname2", a.name);
        assertEquals("x123", a.templateId);
    }

            

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

              
public class Issue1941_JSONField_order extends TestCase {

    public void test_for_issue() throws Exception {
        String json = "{\"type\":\"floorV2\",\"templateId\":\"x123\",\"name\":\"floorname2\"}";
        FloorV2  a=(FloorV2) JSON.parseObject(json,Area.class);
        assertEquals("floorname2", a.name);
        assertEquals("x123", a.templateId);
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 13

                  public void test_for_issue() throws Exception {
        String json = "{\"type\":\"floorV2\",\"templateId\":\"x123\",\"name\":\"floorname2\"}";
        FloorV2  a=(FloorV2) JSON.parseObject(json,Area.class);
        assertEquals("floorname2", a.name);
        assertEquals("x123", a.templateId);
    }

    @JSONType(seeAlso = {FloorV2.class}, typeKey = "type")
    public static interface Area {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 14

                      String json = "{\"type\":\"floorV2\",\"templateId\":\"x123\",\"name\":\"floorname2\"}";
        FloorV2  a=(FloorV2) JSON.parseObject(json,Area.class);
        assertEquals("floorname2", a.name);
        assertEquals("x123", a.templateId);
    }

    @JSONType(seeAlso = {FloorV2.class}, typeKey = "type")
    public static interface Area {
    }

            

Reported by PMD.

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

Line: 25

                  public static class FloorV2 implements Area {
        @JSONField(ordinal = -1)
        public String type;
        public String templateId;
        public String name;
    }
}

            

Reported by PMD.

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

Line: 26

                      @JSONField(ordinal = -1)
        public String type;
        public String templateId;
        public String name;
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1900/Issue1941.java
6 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 9

              
public class Issue1941 extends TestCase {

    public void test_for_issue() throws Exception {
        String json = "{\"type\":\"floorV2\",\"templateId\":\"x123\",\"name\":\"floorname2\"}";
        FloorV2  a=(FloorV2) JSON.parseObject(json,Area.class);
        assertEquals("floorname2", a.name);
        assertEquals("x123", a.templateId);
    }

            

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

              
public class Issue1941 extends TestCase {

    public void test_for_issue() throws Exception {
        String json = "{\"type\":\"floorV2\",\"templateId\":\"x123\",\"name\":\"floorname2\"}";
        FloorV2  a=(FloorV2) JSON.parseObject(json,Area.class);
        assertEquals("floorname2", a.name);
        assertEquals("x123", a.templateId);
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 12

                  public void test_for_issue() throws Exception {
        String json = "{\"type\":\"floorV2\",\"templateId\":\"x123\",\"name\":\"floorname2\"}";
        FloorV2  a=(FloorV2) JSON.parseObject(json,Area.class);
        assertEquals("floorname2", a.name);
        assertEquals("x123", a.templateId);
    }

    @JSONType(seeAlso = {FloorV2.class}, typeKey = "type")
    public static interface Area {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 13

                      String json = "{\"type\":\"floorV2\",\"templateId\":\"x123\",\"name\":\"floorname2\"}";
        FloorV2  a=(FloorV2) JSON.parseObject(json,Area.class);
        assertEquals("floorname2", a.name);
        assertEquals("x123", a.templateId);
    }

    @JSONType(seeAlso = {FloorV2.class}, typeKey = "type")
    public static interface Area {
    }

            

Reported by PMD.

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

Line: 23

                  @JSONType(typeName = "floorV2")
    public static class FloorV2 implements Area {
        public String type;
        public String templateId;
        public String name;
    }
}

            

Reported by PMD.

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

Line: 24

                  public static class FloorV2 implements Area {
        public String type;
        public String templateId;
        public String name;
    }
}

            

Reported by PMD.

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

Line: 14

              import java.util.Map;

public class Issue3082 extends TestCase {
    public void test_for_issue_entry() throws Exception {
        String str = "{\"k\":{\"k\":\"v\"}}";
        Map.Entry<String, Map.Entry<String, String>> entry = JSON.parseObject(str, new TypeReference<Map.Entry<String, Map.Entry<String, String>>>() {});
        assertEquals("v", entry.getValue().getValue());
    }


            

Reported by PMD.

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

Line: 17

                  public void test_for_issue_entry() throws Exception {
        String str = "{\"k\":{\"k\":\"v\"}}";
        Map.Entry<String, Map.Entry<String, String>> entry = JSON.parseObject(str, new TypeReference<Map.Entry<String, Map.Entry<String, String>>>() {});
        assertEquals("v", entry.getValue().getValue());
    }

    public void test_for_issue() throws Exception {
        HashSet<Map.Entry<String, Map.Entry<String, String>>> nestedSet = new HashSet<Map.Entry<String, Map.Entry<String, String>>>();
        nestedSet.add(new AbstractMap.SimpleEntry<String, Map.Entry<String, String>>("a", new AbstractMap.SimpleEntry<String, String>("b", "c")));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

                  public void test_for_issue_entry() throws Exception {
        String str = "{\"k\":{\"k\":\"v\"}}";
        Map.Entry<String, Map.Entry<String, String>> entry = JSON.parseObject(str, new TypeReference<Map.Entry<String, Map.Entry<String, String>>>() {});
        assertEquals("v", entry.getValue().getValue());
    }

    public void test_for_issue() throws Exception {
        HashSet<Map.Entry<String, Map.Entry<String, String>>> nestedSet = new HashSet<Map.Entry<String, Map.Entry<String, String>>>();
        nestedSet.add(new AbstractMap.SimpleEntry<String, Map.Entry<String, String>>("a", new AbstractMap.SimpleEntry<String, String>("b", "c")));

            

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

                      assertEquals("v", entry.getValue().getValue());
    }

    public void test_for_issue() throws Exception {
        HashSet<Map.Entry<String, Map.Entry<String, String>>> nestedSet = new HashSet<Map.Entry<String, Map.Entry<String, String>>>();
        nestedSet.add(new AbstractMap.SimpleEntry<String, Map.Entry<String, String>>("a", new AbstractMap.SimpleEntry<String, String>("b", "c")));
        nestedSet.add(new AbstractMap.SimpleEntry<String, Map.Entry<String, String>>("d", new AbstractMap.SimpleEntry<String, String>("e", "f")));

        String content = JSON.toJSONString(nestedSet);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 30

                      HashSet<Map.Entry<String, Map.Entry<String, String>>> deserializedNestedSet;
        Type type = new TypeReference<HashSet<Map.Entry<String, Map.Entry<String, String>>>>() {}.getType();
        deserializedNestedSet = JSON.parseObject(content, type);
        assertEquals(nestedSet, deserializedNestedSet);
    }
}

            

Reported by PMD.

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

Line: 5

              
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;

import java.lang.reflect.Type;
import java.util.AbstractMap;
import java.util.HashSet;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_3000/Issue3093.java
6 issues
System.out.println is used
Design

Line: 13

              public class Issue3093 extends TestCase {
    public void test_for_issue() throws Exception {
        Timestamp ts = new Timestamp(Calendar.getInstance().getTimeInMillis());
        System.out.println(ts.toString());
        String json = JSON.toJSONString(ts, SerializerFeature.UseISO8601DateFormat);
        System.out.println(json);
    }
}

            

Reported by PMD.

System.out.println is used
Design

Line: 15

                      Timestamp ts = new Timestamp(Calendar.getInstance().getTimeInMillis());
        System.out.println(ts.toString());
        String json = JSON.toJSONString(ts, SerializerFeature.UseISO8601DateFormat);
        System.out.println(json);
    }
}

            

Reported by PMD.

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

Line: 11

              import java.util.Calendar;

public class Issue3093 extends TestCase {
    public void test_for_issue() throws Exception {
        Timestamp ts = new Timestamp(Calendar.getInstance().getTimeInMillis());
        System.out.println(ts.toString());
        String json = JSON.toJSONString(ts, SerializerFeature.UseISO8601DateFormat);
        System.out.println(json);
    }

            

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

              import java.util.Calendar;

public class Issue3093 extends TestCase {
    public void test_for_issue() throws Exception {
        Timestamp ts = new Timestamp(Calendar.getInstance().getTimeInMillis());
        System.out.println(ts.toString());
        String json = JSON.toJSONString(ts, SerializerFeature.UseISO8601DateFormat);
        System.out.println(json);
    }

            

Reported by PMD.

A Calendar is used to create a Date or DateTime, this is expensive.
Performance

Line: 12

              
public class Issue3093 extends TestCase {
    public void test_for_issue() throws Exception {
        Timestamp ts = new Timestamp(Calendar.getInstance().getTimeInMillis());
        System.out.println(ts.toString());
        String json = JSON.toJSONString(ts, SerializerFeature.UseISO8601DateFormat);
        System.out.println(json);
    }
}

            

Reported by PMD.

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

Line: 12

              
public class Issue3093 extends TestCase {
    public void test_for_issue() throws Exception {
        Timestamp ts = new Timestamp(Calendar.getInstance().getTimeInMillis());
        System.out.println(ts.toString());
        String json = JSON.toJSONString(ts, SerializerFeature.UseISO8601DateFormat);
        System.out.println(json);
    }
}

            

Reported by PMD.