The following issues were found

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

Line: 11

              
public class JSONCreatorTest_default_double extends TestCase {

    public void test_create() throws Exception {
        Model model = JSON.parseObject("{\"name\":\"wenshao\"}", Model.class);
        Assert.assertTrue(model.id == 0);
        Assert.assertEquals("wenshao", model.name);
    }


            

Reported by PMD.

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

Line: 20

              
    public static class Model {

        private final double id;
        private final String name;

        @JSONCreator
        public Model(@JSONField(name="id") double id, @JSONField(name="name") String name) {
            this.id = id;

            

Reported by PMD.

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

Line: 21

                  public static class Model {

        private final double id;
        private final String name;

        @JSONCreator
        public Model(@JSONField(name="id") double id, @JSONField(name="name") String name) {
            this.id = id;
            this.name = name;

            

Reported by PMD.

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

Line: 11

              
public class JSONCreatorTest_default_float extends TestCase {

    public void test_create() throws Exception {
        Model model = JSON.parseObject("{\"name\":\"wenshao\"}", Model.class);
        Assert.assertTrue(model.id == 0);
        Assert.assertEquals("wenshao", model.name);
    }


            

Reported by PMD.

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

Line: 20

              
    public static class Model {

        private final float id;
        private final String name;

        @JSONCreator
        public Model(@JSONField(name="id") float id, @JSONField(name="name") String name) {
            this.id = id;

            

Reported by PMD.

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

Line: 21

                  public static class Model {

        private final float id;
        private final String name;

        @JSONCreator
        public Model(@JSONField(name="id") float id, @JSONField(name="name") String name) {
            this.id = id;
            this.name = name;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1100/Issue1144.java
3 issues
System.out.println is used
Design

Line: 14

                  public void test_issue_1144() throws Exception {
        Model model = new Model();
        String json = JSON.toJSONString(model);
        System.out.println(json);
    }

    @JSONType(alphabetic = false)
    public static class Model {
        public int f2;

            

Reported by PMD.

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

Line: 11

               * Created by wenshao on 13/04/2017.
 */
public class Issue1144 extends TestCase {
    public void test_issue_1144() throws Exception {
        Model model = new Model();
        String json = JSON.toJSONString(model);
        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

               * Created by wenshao on 13/04/2017.
 */
public class Issue1144 extends TestCase {
    public void test_issue_1144() throws Exception {
        Model model = new Model();
        String json = JSON.toJSONString(model);
        System.out.println(json);
    }


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1700/Issue1769.java
3 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 Issue1769 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 {
        byte[] newby = "{\"beginTime\":\"420180319160440\"}".getBytes();
        QueryTaskResultReq rsp3 = JSON.parseObject(newby, QueryTaskResultReq.class);
        assertEquals("{\"beginTime\":\"152841225111920\"}", new String(JSON.toJSONBytes(rsp3)));
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 21

                  public void test_for_issue() throws Exception {
        byte[] newby = "{\"beginTime\":\"420180319160440\"}".getBytes();
        QueryTaskResultReq rsp3 = JSON.parseObject(newby, QueryTaskResultReq.class);
        assertEquals("{\"beginTime\":\"152841225111920\"}", new String(JSON.toJSONBytes(rsp3)));
    }

    @JSONType(orders = {"beginTime"})
    public static class QueryTaskResultReq
    {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1700/Issue1780_JSONObject.java
3 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

              
public class Issue1780_JSONObject extends TestCase {

	public void test_for_issue() {
		org.json.JSONObject req = new org.json.JSONObject();
		req.put("id", 1111);
		req.put("name", "name11");
		String text = JSON.toJSONString(req, SerializerFeature.SortField);
		assertTrue("{\"id\":1111,\"name\":\"name11\"}".equals(text)

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 15

              		req.put("id", 1111);
		req.put("name", "name11");
		String text = JSON.toJSONString(req, SerializerFeature.SortField);
		assertTrue("{\"id\":1111,\"name\":\"name11\"}".equals(text)
				|| "{\"name\":\"name11\",\"id\":1111}".equals(text)
		);
	}
}

            

Reported by PMD.

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

Line: 4

              package com.alibaba.json.bvt.issue_1700;

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

public class Issue1780_JSONObject extends TestCase {


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_2200/issue2224/KeyedCollection.java
3 issues
This class has too many methods, consider refactoring it.
Design

Line: 8

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

public abstract class KeyedCollection<TKey, TItem> implements CollectionEx<TItem>, Cloneable {
    private transient Map<TKey, TItem> items = new LinkedHashMap<TKey, TItem>();

    protected abstract TKey getKeyForItem(TItem item);

    public TItem get(TKey key) {

            

Reported by PMD.

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

Line: 9

              import java.util.Map;

public abstract class KeyedCollection<TKey, TItem> implements CollectionEx<TItem>, Cloneable {
    private transient Map<TKey, TItem> items = new LinkedHashMap<TKey, TItem>();

    protected abstract TKey getKeyForItem(TItem item);

    public TItem get(TKey key) {
        return this.items.get(key);

            

Reported by PMD.

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

Line: 39

                      return this.items.values().toArray();
    }

    public <T> T[] toArray(T[] a) {
        return this.items.values().toArray(a);
    }

    public boolean add(TItem item) {
        if (item == null)

            

Reported by PMD.

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

Line: 10

               * Created by wenshao on 20/03/2017.
 */
public class Issue1089_private extends TestCase {
    public void test_for_issue() throws Exception {
        String json = "{\"ab\":123,\"a_b\":456}";
        TestBean tb = JSON.parseObject(json, TestBean.class);
        assertEquals(123, tb.getAb());
    }


            

Reported by PMD.

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

Line: 13

                  public void test_for_issue() throws Exception {
        String json = "{\"ab\":123,\"a_b\":456}";
        TestBean tb = JSON.parseObject(json, TestBean.class);
        assertEquals(123, tb.getAb());
    }

    private static class TestBean {
        private int ab;


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 13

                  public void test_for_issue() throws Exception {
        String json = "{\"ab\":123,\"a_b\":456}";
        TestBean tb = JSON.parseObject(json, TestBean.class);
        assertEquals(123, tb.getAb());
    }

    private static class TestBean {
        private int ab;


            

Reported by PMD.

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

Line: 10

               * Created by wenshao on 20/03/2017.
 */
public class Issue1089 extends TestCase {
    public void test_for_issue() throws Exception {
        String json = "{\"ab\":123,\"a_b\":456}";
        TestBean tb = JSON.parseObject(json, TestBean.class);
        assertEquals(123, tb.getAb());
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 13

                  public void test_for_issue() throws Exception {
        String json = "{\"ab\":123,\"a_b\":456}";
        TestBean tb = JSON.parseObject(json, TestBean.class);
        assertEquals(123, tb.getAb());
    }

    public static class TestBean {
        private int ab;


            

Reported by PMD.

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

Line: 13

                  public void test_for_issue() throws Exception {
        String json = "{\"ab\":123,\"a_b\":456}";
        TestBean tb = JSON.parseObject(json, TestBean.class);
        assertEquals(123, tb.getAb());
    }

    public static class TestBean {
        private int ab;


            

Reported by PMD.

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

Line: 10

               * Created by wenshao on 20/03/2017.
 */
public class Issue1086 extends TestCase {
    public void test_for_issue() throws Exception {
        Model model = JSON.parseObject("{\"flag\":1}", Model.class);
        assertTrue(model.flag);
    }

    public static class Model {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 12

              public class Issue1086 extends TestCase {
    public void test_for_issue() throws Exception {
        Model model = JSON.parseObject("{\"flag\":1}", Model.class);
        assertTrue(model.flag);
    }

    public static class Model {
        public boolean flag;
    }

            

Reported by PMD.

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

Line: 16

                  }

    public static class Model {
        public boolean flag;
    }
}

            

Reported by PMD.

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

Line: 11

               * Created by wenshao on 17/03/2017.
 */
public class Issue1082 extends TestCase {
    public void test_for_issue() throws Exception {
        Throwable error = null;
        try {
            JSON.parseObject("{}", Model_1082.class);
        } catch (JSONException ex) {
            error = ex;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                      } catch (JSONException ex) {
            error = ex;
        }
        assertNotNull(error);
    }

    public class Model_1082 {

    }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '12'-'16').
Error

Line: 12

               */
public class Issue1082 extends TestCase {
    public void test_for_issue() throws Exception {
        Throwable error = null;
        try {
            JSON.parseObject("{}", Model_1082.class);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.