The following issues were found

src/test/java/com/alibaba/json/bvt/issue_1600/Issue1635.java
7 issues
The class 'Foo' is suspected to be a Data Class (WOC=0.000%, NOPA=4, NOAM=0, WMC=1)
Design

Line: 12

              import java.util.List;

public class Issue1635 extends TestCase {
    public static class Foo {
        public String name;
        public Integer BarCount;
        public Boolean flag;
        public List list;


            

Reported by PMD.

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

Line: 13

              
public class Issue1635 extends TestCase {
    public static class Foo {
        public String name;
        public Integer BarCount;
        public Boolean flag;
        public List list;

        public Foo(String name, Integer barCount) {

            

Reported by PMD.

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

Line: 14

              public class Issue1635 extends TestCase {
    public static class Foo {
        public String name;
        public Integer BarCount;
        public Boolean flag;
        public List list;

        public Foo(String name, Integer barCount) {
            this.name = name;

            

Reported by PMD.

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

Line: 24

                      }
    }

    public void test_issue() throws Exception {
        SerializeConfig config = new SerializeConfig();
        config.setAsmEnable(false);
        Foo foo = new Foo(null, null);
        String json = JSON.toJSONString(foo
                , config, new PascalNameFilter()

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 35

                              , SerializerFeature.WriteNullStringAsEmpty
                , SerializerFeature.WriteNullListAsEmpty
        );
        assertEquals("{\"BarCount\":0,\"Flag\":false,\"List\":[],\"Name\":\"\"}", json);
    }

    public void test_issue_1() throws Exception {
        SerializeConfig config = new SerializeConfig();
        config.setAsmEnable(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: 38

                      assertEquals("{\"BarCount\":0,\"Flag\":false,\"List\":[],\"Name\":\"\"}", json);
    }

    public void test_issue_1() throws Exception {
        SerializeConfig config = new SerializeConfig();
        config.setAsmEnable(false);
        Foo foo = new Foo(null, null);
        String json = JSON.toJSONString(foo
                , config, new PascalNameFilter()

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 50

                              , SerializerFeature.WriteNullListAsEmpty
                , SerializerFeature.BeanToArray
        );
        assertEquals("[0,false,[],\"\"]", json);
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1800/Issue1871.java
7 issues
System.out.println is used
Design

Line: 21

                      m.map.put("b", "2");

        String json = JSON.toJSONString(m, SerializerFeature.WriteClassName);
        System.out.println(json);
    }

    public static class UnwrapClass {

        private String name;

            

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

              import java.util.Map;

public class Issue1871 extends TestCase  {
    public void test_for_issue() throws Exception {
        UnwrapClass m = new UnwrapClass();
        m.map = new HashMap();
        m.name = "ljw";
        m.map.put("a", "1");
        m.map.put("b", "2");

            

Reported by PMD.

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

Line: 13

              import java.util.Map;

public class Issue1871 extends TestCase  {
    public void test_for_issue() throws Exception {
        UnwrapClass m = new UnwrapClass();
        m.map = new HashMap();
        m.name = "ljw";
        m.map.put("a", "1");
        m.map.put("b", "2");

            

Reported by PMD.

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

Line: 17

                      UnwrapClass m = new UnwrapClass();
        m.map = new HashMap();
        m.name = "ljw";
        m.map.put("a", "1");
        m.map.put("b", "2");

        String json = JSON.toJSONString(m, SerializerFeature.WriteClassName);
        System.out.println(json);
    }

            

Reported by PMD.

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

Line: 18

                      m.map = new HashMap();
        m.name = "ljw";
        m.map.put("a", "1");
        m.map.put("b", "2");

        String json = JSON.toJSONString(m, SerializerFeature.WriteClassName);
        System.out.println(json);
    }


            

Reported by PMD.

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

Line: 24

                      System.out.println(json);
    }

    public static class UnwrapClass {

        private String name;

        @JSONField(unwrapped = true)
        private Map<String, String> map;

            

Reported by PMD.

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

Line: 9

              import junit.framework.TestCase;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

public class Issue1871 extends TestCase  {
    public void test_for_issue() throws Exception {
        UnwrapClass m = new UnwrapClass();

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1900/Issue1939.java
7 issues
Classes implementing Serializable should set a serialVersionUID
Error

Line: 18

                  @XmlType(name = "", propOrder = {
            "any"
    })
    public static class Container implements Serializable {
        @XmlAnyElement(lax = true)
        public List<Object> any;
    }
    private static final String MESSAGE = "<Container>" +
            "<WeightMajor measurementSystem=\"English\" unit=\"lbs\">0</WeightMajor>" +

            

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

                          "<WeightMajor measurementSystem=\"English\" unit=\"lbs\">0</WeightMajor>" +
            "</Container>";

    public void test_for_issue() throws Exception {
        JAXBContext context = JAXBContext.newInstance(Container.class, Issue1939.class);
        Container con = (Container) context.createUnmarshaller().unmarshal(new StringReader(MESSAGE));
        assertEquals("{\"any\":[\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?><WeightMajor measurementSystem=\\\"English\\\" unit=\\\"lbs\\\">0</WeightMajor>\"]}",
                JSON.toJSONString(con));
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 29

                  public void test_for_issue() throws Exception {
        JAXBContext context = JAXBContext.newInstance(Container.class, Issue1939.class);
        Container con = (Container) context.createUnmarshaller().unmarshal(new StringReader(MESSAGE));
        assertEquals("{\"any\":[\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?><WeightMajor measurementSystem=\\\"English\\\" unit=\\\"lbs\\\">0</WeightMajor>\"]}",
                JSON.toJSONString(con));
    }

    public void test_for_issue_1() throws Exception {
        JAXBContext context = JAXBContext.newInstance(Container.class, Issue1939.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: 33

                              JSON.toJSONString(con));
    }

    public void test_for_issue_1() throws Exception {
        JAXBContext context = JAXBContext.newInstance(Container.class, Issue1939.class);
        Container con = (Container) context.createUnmarshaller().unmarshal(new StringReader(MESSAGE));
        assertEquals("{\"any\":[\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?><WeightMajor measurementSystem=\\\"English\\\" unit=\\\"lbs\\\">0</WeightMajor>\"]}",
                JSON.toJSON(con).toString());
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 36

                  public void test_for_issue_1() throws Exception {
        JAXBContext context = JAXBContext.newInstance(Container.class, Issue1939.class);
        Container con = (Container) context.createUnmarshaller().unmarshal(new StringReader(MESSAGE));
        assertEquals("{\"any\":[\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?><WeightMajor measurementSystem=\\\"English\\\" unit=\\\"lbs\\\">0</WeightMajor>\"]}",
                JSON.toJSON(con).toString());
    }
}

            

Reported by PMD.

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

Line: 37

                      JAXBContext context = JAXBContext.newInstance(Container.class, Issue1939.class);
        Container con = (Container) context.createUnmarshaller().unmarshal(new StringReader(MESSAGE));
        assertEquals("{\"any\":[\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?><WeightMajor measurementSystem=\\\"English\\\" unit=\\\"lbs\\\">0</WeightMajor>\"]}",
                JSON.toJSON(con).toString());
    }
}

            

Reported by PMD.

Avoid unused imports such as 'javax.xml.bind.annotation'
Design

Line: 7

              import junit.framework.TestCase;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.annotation.*;
import java.io.Serializable;
import java.io.StringReader;
import java.util.List;

public class Issue1939 extends TestCase {

            

Reported by PMD.

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

Line: 7

              import junit.framework.TestCase;

public class Issue1996 extends TestCase {
    public void test_for_issue() throws Exception {
        StringBuilder sb = new StringBuilder();

        char start = '\uD800';
        char end = '\uDFFF';


            

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 Issue1996 extends TestCase {
    public void test_for_issue() throws Exception {
        StringBuilder sb = new StringBuilder();

        char start = '\uD800';
        char end = '\uDFFF';


            

Reported by PMD.

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

Line: 22

              
        // ok
        String json1 = JSON.toJSONString(s);
        byte[] bytes = json1.getBytes("utf-8");

        byte[] bytes2 = JSON.toJSONBytes(s);
        assertEquals(new String(bytes), new String(bytes2));

        assertEquals(bytes.length, bytes2.length);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 25

                      byte[] bytes = json1.getBytes("utf-8");

        byte[] bytes2 = JSON.toJSONBytes(s);
        assertEquals(new String(bytes), new String(bytes2));

        assertEquals(bytes.length, bytes2.length);
        for (int i = 0; i < bytes.length; i++) {
            assertEquals(bytes[i], bytes[i]);
        }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 27

                      byte[] bytes2 = JSON.toJSONBytes(s);
        assertEquals(new String(bytes), new String(bytes2));

        assertEquals(bytes.length, bytes2.length);
        for (int i = 0; i < bytes.length; i++) {
            assertEquals(bytes[i], bytes[i]);
        }
    }
}

            

Reported by PMD.

This for loop can be replaced by a foreach loop
Design

Line: 28

                      assertEquals(new String(bytes), new String(bytes2));

        assertEquals(bytes.length, bytes2.length);
        for (int i = 0; i < bytes.length; i++) {
            assertEquals(bytes[i], bytes[i]);
        }
    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 29

              
        assertEquals(bytes.length, bytes2.length);
        for (int i = 0; i < bytes.length; i++) {
            assertEquals(bytes[i], bytes[i]);
        }
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_2000/Issue2088.java
7 issues
JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll
Design

Line: 13

              import java.util.TimeZone;

public class Issue2088 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: 18

                      JSON.defaultLocale = Locale.CHINA;
    }

    public void test_for_issue() throws Exception {
        String json = "{\"date\":\"20181011103607186+0800\"}";
        Model m = JSON.parseObject(json, Model.class);

        SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSSZ");
        format.setTimeZone(JSON.defaultTimeZone);

            

Reported by PMD.

When instantiating a SimpleDateFormat object, specify a Locale
Error

Line: 22

                      String json = "{\"date\":\"20181011103607186+0800\"}";
        Model m = JSON.parseObject(json, Model.class);

        SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSSZ");
        format.setTimeZone(JSON.defaultTimeZone);
        Date date = format.parse("20181011103607186+0800");

        assertEquals(date, m.date);
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 26

                      format.setTimeZone(JSON.defaultTimeZone);
        Date date = format.parse("20181011103607186+0800");

        assertEquals(date, m.date);
    }

    public void test_for_issue_1() throws Exception {
        String json = "{\"date\":\"20181011103607186-0800\"}";
        Model m = JSON.parseObject(json, Model.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: 29

                      assertEquals(date, m.date);
    }

    public void test_for_issue_1() throws Exception {
        String json = "{\"date\":\"20181011103607186-0800\"}";
        Model m = JSON.parseObject(json, Model.class);

        SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSSZ", JSON.defaultLocale);
        format.setTimeZone(JSON.defaultTimeZone);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 37

                      format.setTimeZone(JSON.defaultTimeZone);
        Date date = format.parse("20181011103607186-0800");

        assertEquals(date, m.date);
    }

    public static class Model {
        @JSONField(format = "yyyyMMddHHmmssSSSZ")
        public Date date;

            

Reported by PMD.

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

Line: 42

              
    public static class Model {
        @JSONField(format = "yyyyMMddHHmmssSSSZ")
        public Date date;
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_2200/Issue2214.java
7 issues
System.out.println is used
Design

Line: 22

                      Type[] types = method.getGenericParameterTypes();
        List argList = JSON.parseArray(text, types);
        Object res = new User().testGenericArrayArray2((List[][]) argList.get(0));
        System.out.println(res);
    }

    public static class User {
        public List[][] testGenericArrayArray2(List[][] res){
            return res;

            

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 java.util.List;

public class Issue2214 extends TestCase {
    public void test_for_issue() throws Exception {
        List list = new ArrayList();
        list.add("robin");
        Object[] args = new Object[]{new List[][]{new List[]{list}}};
        String text = JSON.toJSONString(args);
        Class clazz = User.class;

            

Reported by PMD.

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

Line: 12

              import java.util.List;

public class Issue2214 extends TestCase {
    public void test_for_issue() throws Exception {
        List list = new ArrayList();
        list.add("robin");
        Object[] args = new Object[]{new List[][]{new List[]{list}}};
        String text = JSON.toJSONString(args);
        Class clazz = User.class;

            

Reported by PMD.

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

Line: 18

                      Object[] args = new Object[]{new List[][]{new List[]{list}}};
        String text = JSON.toJSONString(args);
        Class clazz = User.class;
        Method method = clazz.getMethod("testGenericArrayArray2", List[][].class);
        Type[] types = method.getGenericParameterTypes();
        List argList = JSON.parseArray(text, types);
        Object res = new User().testGenericArrayArray2((List[][]) argList.get(0));
        System.out.println(res);
    }

            

Reported by PMD.

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

Line: 19

                      String text = JSON.toJSONString(args);
        Class clazz = User.class;
        Method method = clazz.getMethod("testGenericArrayArray2", List[][].class);
        Type[] types = method.getGenericParameterTypes();
        List argList = JSON.parseArray(text, types);
        Object res = new User().testGenericArrayArray2((List[][]) argList.get(0));
        System.out.println(res);
    }


            

Reported by PMD.

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

Line: 21

                      Method method = clazz.getMethod("testGenericArrayArray2", List[][].class);
        Type[] types = method.getGenericParameterTypes();
        List argList = JSON.parseArray(text, types);
        Object res = new User().testGenericArrayArray2((List[][]) argList.get(0));
        System.out.println(res);
    }

    public static class User {
        public List[][] testGenericArrayArray2(List[][] res){

            

Reported by PMD.

Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 26

                  }

    public static class User {
        public List[][] testGenericArrayArray2(List[][] res){
            return res;
        }
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_2200/Issue2253.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 java.util.Map;

public class Issue2253 extends TestCase {
    public void test_for_issue() throws Exception {
        List<Map<String, Object>> result = new ArrayList();
        result.add(new LinkedHashMap());
        result.get(0).put("3", 3);
        result.get(0).put("2", 2);
        result.get(0).put("7", 7);

            

Reported by PMD.

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

Line: 15

              import java.util.Map;

public class Issue2253 extends TestCase {
    public void test_for_issue() throws Exception {
        List<Map<String, Object>> result = new ArrayList();
        result.add(new LinkedHashMap());
        result.get(0).put("3", 3);
        result.get(0).put("2", 2);
        result.get(0).put("7", 7);

            

Reported by PMD.

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

Line: 18

                  public void test_for_issue() throws Exception {
        List<Map<String, Object>> result = new ArrayList();
        result.add(new LinkedHashMap());
        result.get(0).put("3", 3);
        result.get(0).put("2", 2);
        result.get(0).put("7", 7);

        assertEquals("[{\"3\":3,\"2\":2,\"7\":7}]", JSON.toJSONString(result, SerializerFeature.WriteMapNullValue));


            

Reported by PMD.

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

Line: 19

                      List<Map<String, Object>> result = new ArrayList();
        result.add(new LinkedHashMap());
        result.get(0).put("3", 3);
        result.get(0).put("2", 2);
        result.get(0).put("7", 7);

        assertEquals("[{\"3\":3,\"2\":2,\"7\":7}]", JSON.toJSONString(result, SerializerFeature.WriteMapNullValue));

        result = JSON.parseObject(JSON.toJSONString(result, SerializerFeature.WriteMapNullValue), new TypeReference<List<Map<String, Object>>>() {}, Feature.OrderedField);

            

Reported by PMD.

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

Line: 20

                      result.add(new LinkedHashMap());
        result.get(0).put("3", 3);
        result.get(0).put("2", 2);
        result.get(0).put("7", 7);

        assertEquals("[{\"3\":3,\"2\":2,\"7\":7}]", JSON.toJSONString(result, SerializerFeature.WriteMapNullValue));

        result = JSON.parseObject(JSON.toJSONString(result, SerializerFeature.WriteMapNullValue), new TypeReference<List<Map<String, Object>>>() {}, Feature.OrderedField);


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 22

                      result.get(0).put("2", 2);
        result.get(0).put("7", 7);

        assertEquals("[{\"3\":3,\"2\":2,\"7\":7}]", JSON.toJSONString(result, SerializerFeature.WriteMapNullValue));

        result = JSON.parseObject(JSON.toJSONString(result, SerializerFeature.WriteMapNullValue), new TypeReference<List<Map<String, Object>>>() {}, Feature.OrderedField);

        assertEquals("[{\"3\":3,\"2\":2,\"7\":7}]", JSON.toJSONString(result, SerializerFeature.WriteMapNullValue));
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 26

              
        result = JSON.parseObject(JSON.toJSONString(result, SerializerFeature.WriteMapNullValue), new TypeReference<List<Map<String, Object>>>() {}, Feature.OrderedField);

        assertEquals("[{\"3\":3,\"2\":2,\"7\":7}]", JSON.toJSONString(result, SerializerFeature.WriteMapNullValue));
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_2700/Issue2779.java
7 issues
This class has a bunch of public methods and attributes
Design

Line: 1

              package com.alibaba.json.bvt.issue_2700;

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

import java.util.List;

public class Issue2779 extends TestCase {


            

Reported by PMD.

Avoid really long classes.
Design

Line: 8

              
import java.util.List;

public class Issue2779 extends TestCase {

    public void test_for_issue() throws Exception {
        String str = JSON.toJSONString(new Model());
        JSON.parseObject(str, Model.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: 10

              
public class Issue2779 extends TestCase {

    public void test_for_issue() throws Exception {
        String str = JSON.toJSONString(new Model());
        JSON.parseObject(str, Model.class);
    }

    public static class Model {

            

Reported by PMD.

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

Line: 10

              
public class Issue2779 extends TestCase {

    public void test_for_issue() throws Exception {
        String str = JSON.toJSONString(new Model());
        JSON.parseObject(str, Model.class);
    }

    public static class Model {

            

Reported by PMD.

Avoid really long classes.
Design

Line: 15

                      JSON.parseObject(str, Model.class);
    }

    public static class Model {
        private List f000;
        private List f001;
        private List f002;
        private List f003;
        private List f004;

            

Reported by PMD.

The class 'Model' has a total cyclomatic complexity of 400 (highest 1).
Design

Line: 15

                      JSON.parseObject(str, Model.class);
    }

    public static class Model {
        private List f000;
        private List f001;
        private List f002;
        private List f003;
        private List f004;

            

Reported by PMD.

Too many fields
Design

Line: 15

                      JSON.parseObject(str, Model.class);
    }

    public static class Model {
        private List f000;
        private List f001;
        private List f002;
        private List f003;
        private List f004;

            

Reported by PMD.

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

public class Issue3206 extends TestCase {
    public void test_for_issue() throws Exception {
        VO vo = new VO();
        vo.date = new java.util.Date(1590819204293L);


        assertEquals(JSON.toJSONString(vo), "{\"date\":\"2020-05-30\"}");

            

Reported by PMD.

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

Line: 9

              import junit.framework.TestCase;

public class Issue3206 extends TestCase {
    public void test_for_issue() throws Exception {
        VO vo = new VO();
        vo.date = new java.util.Date(1590819204293L);


        assertEquals(JSON.toJSONString(vo), "{\"date\":\"2020-05-30\"}");

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 14

                      vo.date = new java.util.Date(1590819204293L);


        assertEquals(JSON.toJSONString(vo), "{\"date\":\"2020-05-30\"}");

        String str = JSON.toJSONString(vo, new NameFilter() {
            public String process(Object object, String name, Object value) {
                return name;
            }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 21

                              return name;
            }
        });
        assertEquals(str, "{\"date\":\"2020-05-30\"}");
    }

    public static class VO {
        @JSONField(format="yyyy-MM-dd")
        public java.util.Date date;

            

Reported by PMD.

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

Line: 26

              
    public static class VO {
        @JSONField(format="yyyy-MM-dd")
        public java.util.Date date;
    }
}

            

Reported by PMD.

Found 'DU'-anomaly for variable 'str' (lines '16'-'22').
Error

Line: 16

              
        assertEquals(JSON.toJSONString(vo), "{\"date\":\"2020-05-30\"}");

        String str = JSON.toJSONString(vo, new NameFilter() {
            public String process(Object object, String name, Object value) {
                return name;
            }
        });
        assertEquals(str, "{\"date\":\"2020-05-30\"}");

            

Reported by PMD.

Found 'DU'-anomaly for variable 'str' (lines '16'-'22').
Error

Line: 16

              
        assertEquals(JSON.toJSONString(vo), "{\"date\":\"2020-05-30\"}");

        String str = JSON.toJSONString(vo, new NameFilter() {
            public String process(Object object, String name, Object value) {
                return name;
            }
        });
        assertEquals(str, "{\"date\":\"2020-05-30\"}");

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_3200/Issue3245.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 Issue3245 extends TestCase {
    public void test_for_issue() throws Exception {
        JSONValidator v = JSONValidator.from("[]");
        v.validate();
        assertEquals(JSONValidator.Type.Array, v.getType());
    }


            

Reported by PMD.

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

Line: 9

              public class Issue3245 extends TestCase {
    public void test_for_issue() throws Exception {
        JSONValidator v = JSONValidator.from("[]");
        v.validate();
        assertEquals(JSONValidator.Type.Array, v.getType());
    }

    public void test_for_issue_1() throws Exception {
        assertEquals(JSONValidator.Type.Array, JSONValidator.from("[]").getType());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 10

                  public void test_for_issue() throws Exception {
        JSONValidator v = JSONValidator.from("[]");
        v.validate();
        assertEquals(JSONValidator.Type.Array, v.getType());
    }

    public void test_for_issue_1() throws Exception {
        assertEquals(JSONValidator.Type.Array, JSONValidator.from("[]").getType());
    }

            

Reported by PMD.

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

Line: 10

                  public void test_for_issue() throws Exception {
        JSONValidator v = JSONValidator.from("[]");
        v.validate();
        assertEquals(JSONValidator.Type.Array, v.getType());
    }

    public void test_for_issue_1() throws Exception {
        assertEquals(JSONValidator.Type.Array, JSONValidator.from("[]").getType());
    }

            

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

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

    public void test_for_issue_1() throws Exception {
        assertEquals(JSONValidator.Type.Array, JSONValidator.from("[]").getType());
    }
}

            

Reported by PMD.

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

Line: 14

                  }

    public void test_for_issue_1() throws Exception {
        assertEquals(JSONValidator.Type.Array, JSONValidator.from("[]").getType());
    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 14

                  }

    public void test_for_issue_1() throws Exception {
        assertEquals(JSONValidator.Type.Array, JSONValidator.from("[]").getType());
    }
}

            

Reported by PMD.