The following issues were found

src/test/java/com/alibaba/json/bvt/issue_2300/Issue2334.java
5 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 9

              import junit.framework.TestCase;

public class Issue2334 extends TestCase {
    public void test_for_issue() throws Exception {
        String json = "{\n" +
                "\"EXTINFO\":{\n" +
                "\"bct_loan_account_status[15]\":\"aaa\",\n" +
                "\"wc_bank_num_of_trans_last_3_mon[6]\":-9999,\n" +
                "\"fahai_shixin_post_time[46]\":\"bbb\",\n" +

            

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

              import junit.framework.TestCase;

public class Issue2334 extends TestCase {
    public void test_for_issue() throws Exception {
        String json = "{\n" +
                "\"EXTINFO\":{\n" +
                "\"bct_loan_account_status[15]\":\"aaa\",\n" +
                "\"wc_bank_num_of_trans_last_3_mon[6]\":-9999,\n" +
                "\"fahai_shixin_post_time[46]\":\"bbb\",\n" +

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 21

              
        JSONObject object = JSON.parseObject(json);

        assertEquals("aaa"
                , JSONPath.eval(object, "$.EXTINFO.bct_loan_account_status\\[15\\]"));

        Object result = JSONPath.extract(json, "$.EXTINFO.bct_loan_account_status\\[15\\]");
        assertEquals("aaa", result.toString());
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 25

                              , JSONPath.eval(object, "$.EXTINFO.bct_loan_account_status\\[15\\]"));

        Object result = JSONPath.extract(json, "$.EXTINFO.bct_loan_account_status\\[15\\]");
        assertEquals("aaa", result.toString());
    }
}

            

Reported by PMD.

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

Line: 25

                              , JSONPath.eval(object, "$.EXTINFO.bct_loan_account_status\\[15\\]"));

        Object result = JSONPath.extract(json, "$.EXTINFO.bct_loan_account_status\\[15\\]");
        assertEquals("aaa", result.toString());
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1300/Issue1310.java
5 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 11

               * Created by wenshao on 29/07/2017.
 */
public class Issue1310 extends TestCase {
    public void test_trim() throws Exception {
        Model model = new Model();
        model.value = " a ";

        assertEquals("{\"value\":\"a\"}", JSON.toJSONString(model));


            

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 29/07/2017.
 */
public class Issue1310 extends TestCase {
    public void test_trim() throws Exception {
        Model model = new Model();
        model.value = " a ";

        assertEquals("{\"value\":\"a\"}", JSON.toJSONString(model));


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 15

                      Model model = new Model();
        model.value = " a ";

        assertEquals("{\"value\":\"a\"}", JSON.toJSONString(model));

        Model model2 = JSON.parseObject("{\"value\":\" a \"}", Model.class);
        assertEquals("a", model2.value);
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                      assertEquals("{\"value\":\"a\"}", JSON.toJSONString(model));

        Model model2 = JSON.parseObject("{\"value\":\" a \"}", Model.class);
        assertEquals("a", model2.value);
    }

    public static class Model {
        @JSONField(format = "trim")
        public String value;

            

Reported by PMD.

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

Line: 23

              
    public static class Model {
        @JSONField(format = "trim")
        public String value;
    }
}

            

Reported by PMD.

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

    public void test_readOnly() throws Exception {
        Model model = new Model();
        model.value.set(1001);

        String text = JSON.toJSONString(model);
        Assert.assertEquals("{\"value\":1001}", text);

            

Reported by PMD.

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

Line: 15

              
    public void test_readOnly() throws Exception {
        Model model = new Model();
        model.value.set(1001);

        String text = JSON.toJSONString(model);
        Assert.assertEquals("{\"value\":1001}", text);
        Model model2 = JSON.parseObject(text, Model.class);
        Assert.assertEquals(model.value.get(), model2.value.get());

            

Reported by PMD.

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

Line: 20

                      String text = JSON.toJSONString(model);
        Assert.assertEquals("{\"value\":1001}", text);
        Model model2 = JSON.parseObject(text, Model.class);
        Assert.assertEquals(model.value.get(), model2.value.get());
    }

    public static class Model {
        public final AtomicLong value = new AtomicLong();


            

Reported by PMD.

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

Line: 20

                      String text = JSON.toJSONString(model);
        Assert.assertEquals("{\"value\":1001}", text);
        Model model2 = JSON.parseObject(text, Model.class);
        Assert.assertEquals(model.value.get(), model2.value.get());
    }

    public static class Model {
        public final AtomicLong value = new AtomicLong();


            

Reported by PMD.

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

Line: 24

                  }

    public static class Model {
        public final AtomicLong value = new AtomicLong();

    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_2200/Issue2239.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.List;

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

        String json = "{\"page\":{}}";

        BaseResponse<Bean> bean = JSON.parseObject(json,
                new TypeReference<BaseResponse<Bean>>() {

            

Reported by PMD.

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

Line: 10

              import java.util.List;

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

        String json = "{\"page\":{}}";

        BaseResponse<Bean> bean = JSON.parseObject(json,
                new TypeReference<BaseResponse<Bean>>() {

            

Reported by PMD.

Avoid unused local variables such as 'bean'.
Design

Line: 14

              
        String json = "{\"page\":{}}";

        BaseResponse<Bean> bean = JSON.parseObject(json,
                new TypeReference<BaseResponse<Bean>>() {
                });
//        bean.getPage().getList(); // 得到的是空
    }


            

Reported by PMD.

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

Line: 26

              
    public static class BaseResponse<T> {

        private PageBean<T> page;



        public PageBean<T> getPage() {
            return page;

            

Reported by PMD.

Found 'DU'-anomaly for variable 'bean' (lines '14'-'18').
Error

Line: 14

              
        String json = "{\"page\":{}}";

        BaseResponse<Bean> bean = JSON.parseObject(json,
                new TypeReference<BaseResponse<Bean>>() {
                });
//        bean.getPage().getList(); // 得到的是空
    }


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_3000/Issue3060.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: 8

              import junit.framework.TestCase;

public class Issue3060 extends TestCase {
    public void test_for_issue() throws Exception {
        String str = "{\"type\":1}";
        Bean bean = JSON.parseObject(str).toJavaObject(Bean.class);
        Bean bean1 = JSON.parseObject(str, Bean.class);
        assertEquals(bean.type, bean1.type);
    }

            

Reported by PMD.

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

Line: 10

              public class Issue3060 extends TestCase {
    public void test_for_issue() throws Exception {
        String str = "{\"type\":1}";
        Bean bean = JSON.parseObject(str).toJavaObject(Bean.class);
        Bean bean1 = JSON.parseObject(str, Bean.class);
        assertEquals(bean.type, bean1.type);
    }

    public static class Bean {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 12

                      String str = "{\"type\":1}";
        Bean bean = JSON.parseObject(str).toJavaObject(Bean.class);
        Bean bean1 = JSON.parseObject(str, Bean.class);
        assertEquals(bean.type, bean1.type);
    }

    public static class Bean {
        public int type;
    }

            

Reported by PMD.

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

Line: 16

                  }

    public static class Bean {
        public int type;
    }

    public enum Type {
        Small, Big
    }

            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.fastjson.annotation.JSONField'
Design

Line: 4

              package com.alibaba.json.bvt.issue_3000;

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

public class Issue3060 extends TestCase {
    public void test_for_issue() throws Exception {
        String str = "{\"type\":1}";

            

Reported by PMD.

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

Line: 12

                      String s = "{ \"componentKey\" : \"CMDB_UPDATE_SERVER\"}";
        Step step = JSON.parseObject(s, Step.class);
        assertEquals("CMDB_UPDATE_SERVER",step.getComponentKey());
        System.out.println(step.getComponentKey());
    }

    private static class Step {
        @JSONField(name = "component_key", alternateNames = {"componentKey"})
        private String componentKey;

            

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 junit.framework.TestCase;

public class Issue3452 extends TestCase {
    public void test_for_issue() throws Exception {
        String s = "{ \"componentKey\" : \"CMDB_UPDATE_SERVER\"}";
        Step step = JSON.parseObject(s, Step.class);
        assertEquals("CMDB_UPDATE_SERVER",step.getComponentKey());
        System.out.println(step.getComponentKey());
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 11

                  public void test_for_issue() throws Exception {
        String s = "{ \"componentKey\" : \"CMDB_UPDATE_SERVER\"}";
        Step step = JSON.parseObject(s, Step.class);
        assertEquals("CMDB_UPDATE_SERVER",step.getComponentKey());
        System.out.println(step.getComponentKey());
    }

    private static class Step {
        @JSONField(name = "component_key", alternateNames = {"componentKey"})

            

Reported by PMD.

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

Line: 11

                  public void test_for_issue() throws Exception {
        String s = "{ \"componentKey\" : \"CMDB_UPDATE_SERVER\"}";
        Step step = JSON.parseObject(s, Step.class);
        assertEquals("CMDB_UPDATE_SERVER",step.getComponentKey());
        System.out.println(step.getComponentKey());
    }

    private static class Step {
        @JSONField(name = "component_key", alternateNames = {"componentKey"})

            

Reported by PMD.

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

Line: 12

                      String s = "{ \"componentKey\" : \"CMDB_UPDATE_SERVER\"}";
        Step step = JSON.parseObject(s, Step.class);
        assertEquals("CMDB_UPDATE_SERVER",step.getComponentKey());
        System.out.println(step.getComponentKey());
    }

    private static class Step {
        @JSONField(name = "component_key", alternateNames = {"componentKey"})
        private String componentKey;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_3000/Issue3066.java
5 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 9

              import junit.framework.TestCase;

public class Issue3066 extends TestCase {
    public void test_for_jsonpath() throws Exception {
        String str = "{ 'id' : 0, 'items' : [ {'name': 'apple', 'price' : 30 }, {'name': 'pear', 'price' : 40 } ] }";
        JSONObject root = JSON.parseObject(str);
        Object max = JSONPath.eval(root, "$.items[*].price.max()");
        assertEquals(40, max);


            

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

              import junit.framework.TestCase;

public class Issue3066 extends TestCase {
    public void test_for_jsonpath() throws Exception {
        String str = "{ 'id' : 0, 'items' : [ {'name': 'apple', 'price' : 30 }, {'name': 'pear', 'price' : 40 } ] }";
        JSONObject root = JSON.parseObject(str);
        Object max = JSONPath.eval(root, "$.items[*].price.max()");
        assertEquals(40, max);


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 13

                      String str = "{ 'id' : 0, 'items' : [ {'name': 'apple', 'price' : 30 }, {'name': 'pear', 'price' : 40 } ] }";
        JSONObject root = JSON.parseObject(str);
        Object max = JSONPath.eval(root, "$.items[*].price.max()");
        assertEquals(40, max);

        Object min = JSONPath.eval(root, "$.items[*].price.min()");
        assertEquals(30, min);

        Object count = JSONPath.eval(root, "$.items[*].price.size()");

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 16

                      assertEquals(40, max);

        Object min = JSONPath.eval(root, "$.items[*].price.min()");
        assertEquals(30, min);

        Object count = JSONPath.eval(root, "$.items[*].price.size()");
        assertEquals(2, count);
    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

                      assertEquals(30, min);

        Object count = JSONPath.eval(root, "$.items[*].price.size()");
        assertEquals(2, count);
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_3000/Issue3075.java
5 issues
This class has a bunch of public methods and attributes
Design

Line: 1

              package com.alibaba.json.bvt.issue_3000;

import com.alibaba.fastjson.JSON;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

import com.alibaba.fastjson.serializer.SerializerFeature;

            

Reported by PMD.

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

Line: 13

              import junit.framework.TestCase;

public class Issue3075 extends TestCase {
    public void test_for_issue() throws Exception {
        SerializerFeature[] features = {
            SerializerFeature.BrowserSecure,
                    // 消除对同一对象重复引用的优化
                    SerializerFeature.DisableCircularReferenceDetect,
                    // 将中文都会序列化为\Uxxxx 格式

            

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 junit.framework.TestCase;

public class Issue3075 extends TestCase {
    public void test_for_issue() throws Exception {
        SerializerFeature[] features = {
            SerializerFeature.BrowserSecure,
                    // 消除对同一对象重复引用的优化
                    SerializerFeature.DisableCircularReferenceDetect,
                    // 将中文都会序列化为\Uxxxx 格式

            

Reported by PMD.

Too many fields
Design

Line: 42

              
    @NoArgsConstructor
    @Data
    public static class TestBasicBO {
        String udgxhkk;
        String dvbvgtm;
        String cegnjlhiz;
        String tmztsttazf;
        List<Integer> dszukwrs;

            

Reported by PMD.

Too many fields
Design

Line: 279

                  @NoArgsConstructor
    @Data

    public static class TestBO extends TestBasicBO{

        public String mlbkyxy;
        public List<Integer> sqhgpd;
        public List<Integer> nikawljmoafb;
        public String rphau;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/JSONReaderScannerTest__entity_int.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: 16

              
public class JSONReaderScannerTest__entity_int extends TestCase {

    public void test_scanInt() throws Exception {
        StringBuffer buf = new StringBuffer();
        buf.append('[');
        for (int i = 0; i < 1024; ++i) {
            if (i != 0) {
                buf.append(',');

            

Reported by PMD.

Avoid concatenating nonliterals in a StringBuffer/StringBuilder constructor or append().
Performance

Line: 23

                          if (i != 0) {
                buf.append(',');
            }
            buf.append("{\"id\":" + i + "}");
        }
        buf.append(']');

        Reader reader = new StringReader(buf.toString());


            

Reported by PMD.

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

Line: 27

                      }
        buf.append(']');

        Reader reader = new StringReader(buf.toString());

        JSONReaderScanner scanner = new JSONReaderScanner(reader);

        DefaultJSONParser parser = new DefaultJSONParser(scanner);
        List<VO> array = parser.parseArray(VO.class);

            

Reported by PMD.

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

Line: 34

                      DefaultJSONParser parser = new DefaultJSONParser(scanner);
        List<VO> array = parser.parseArray(VO.class);
        for (int i = 0; i < array.size(); ++i) {
            Assert.assertEquals(i, array.get(i).getId());
        }
    }

    public static class VO {


            

Reported by PMD.

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

Line: 10

              import org.junit.Assert;
import junit.framework.TestCase;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.parser.DefaultJSONParser;
import com.alibaba.fastjson.parser.JSONReaderScanner;

public class JSONReaderScannerTest__entity_int extends TestCase {


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1300/Issue1371.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: 23

                      A, B, C, D ,E ;
    }

    public void testFastjsonEnum(){

        Map<Rooms, Rooms> enumMap = new TreeMap<Rooms, Rooms>();

        enumMap.put(Rooms.C, Rooms.D);
        enumMap.put(Rooms.E, Rooms.A);

            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.fastjson.parser.Feature'
Design

Line: 4

              package com.alibaba.json.bvt.issue_1300;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import junit.framework.TestCase;
import org.junit.Assert;

            

Reported by PMD.

Avoid unused imports such as 'com.fasterxml.jackson.databind.ObjectMapper'
Design

Line: 6

              import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;


            

Reported by PMD.

Avoid unused imports such as 'com.google.gson.Gson'
Design

Line: 7

              import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;

import java.util.Map;

            

Reported by PMD.

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

Line: 10

              import com.google.gson.Gson;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;

import java.util.Map;
import java.util.TreeMap;

/**

            

Reported by PMD.