The following issues were found

src/test/java/com/alibaba/json/bvt/issue_1900/Issue1909.java
11 issues
System.out.println is used
Design

Line: 16

                      params.add("val1");
        params.add(2);
        ParamRequest pr = new ParamRequest("methodName", "stringID", params);
        System.out.println(JSON.toJSONString(pr));
        Request paramRequest = JSON.parseObject(JSON.toJSONString(pr), ParamRequest.class);
    }

    public static class ParamRequest extends Request {
        private String methodName;

            

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

public class Issue1909 extends TestCase {
    public void test_for_issue() throws Exception {
        JSONArray params = new JSONArray();
        params.add("val1");
        params.add(2);
        ParamRequest pr = new ParamRequest("methodName", "stringID", params);
        System.out.println(JSON.toJSONString(pr));

            

Reported by PMD.

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

Line: 11

              import java.util.List;

public class Issue1909 extends TestCase {
    public void test_for_issue() throws Exception {
        JSONArray params = new JSONArray();
        params.add("val1");
        params.add(2);
        ParamRequest pr = new ParamRequest("methodName", "stringID", params);
        System.out.println(JSON.toJSONString(pr));

            

Reported by PMD.

Avoid unused local variables such as 'paramRequest'.
Design

Line: 17

                      params.add(2);
        ParamRequest pr = new ParamRequest("methodName", "stringID", params);
        System.out.println(JSON.toJSONString(pr));
        Request paramRequest = JSON.parseObject(JSON.toJSONString(pr), ParamRequest.class);
    }

    public static class ParamRequest extends Request {
        private String methodName;


            

Reported by PMD.

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

Line: 21

                  }

    public static class ParamRequest extends Request {
        private String methodName;

        @JSONField(name = "id", ordinal = 3, serialize = true, deserialize = true)
        private Object id;

        private List<Object> params;

            

Reported by PMD.

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

Line: 21

                  }

    public static class ParamRequest extends Request {
        private String methodName;

        @JSONField(name = "id", ordinal = 3, serialize = true, deserialize = true)
        private Object id;

        private List<Object> params;

            

Reported by PMD.

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

Line: 24

                      private String methodName;

        @JSONField(name = "id", ordinal = 3, serialize = true, deserialize = true)
        private Object id;

        private List<Object> params;

        public ParamRequest(String methodName, Object id, List<Object> params) {
            this.methodName = methodName;

            

Reported by PMD.

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

Line: 24

                      private String methodName;

        @JSONField(name = "id", ordinal = 3, serialize = true, deserialize = true)
        private Object id;

        private List<Object> params;

        public ParamRequest(String methodName, Object id, List<Object> params) {
            this.methodName = methodName;

            

Reported by PMD.

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

Line: 26

                      @JSONField(name = "id", ordinal = 3, serialize = true, deserialize = true)
        private Object id;

        private List<Object> params;

        public ParamRequest(String methodName, Object id, List<Object> params) {
            this.methodName = methodName;
            this.id = id;
            this.params = params;

            

Reported by PMD.

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

Line: 26

                      @JSONField(name = "id", ordinal = 3, serialize = true, deserialize = true)
        private Object id;

        private List<Object> params;

        public ParamRequest(String methodName, Object id, List<Object> params) {
            this.methodName = methodName;
            this.id = id;
            this.params = params;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1700/Issue1764_bean_biginteger.java
11 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 13

              import static com.alibaba.fastjson.serializer.SerializerFeature.BrowserCompatible;

public class Issue1764_bean_biginteger extends TestCase {
    public void test_for_issue() throws Exception {
        assertEquals("{\"value\":\"9007199254741992\"}"
                , JSON.toJSONString(
                        new Model(9007199254741992L), BrowserCompatible));

        assertEquals("{\"value\":\"-9007199254741992\"}"

            

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 static com.alibaba.fastjson.serializer.SerializerFeature.BrowserCompatible;

public class Issue1764_bean_biginteger extends TestCase {
    public void test_for_issue() throws Exception {
        assertEquals("{\"value\":\"9007199254741992\"}"
                , JSON.toJSONString(
                        new Model(9007199254741992L), BrowserCompatible));

        assertEquals("{\"value\":\"-9007199254741992\"}"

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 14

              
public class Issue1764_bean_biginteger extends TestCase {
    public void test_for_issue() throws Exception {
        assertEquals("{\"value\":\"9007199254741992\"}"
                , JSON.toJSONString(
                        new Model(9007199254741992L), BrowserCompatible));

        assertEquals("{\"value\":\"-9007199254741992\"}"
                , JSON.toJSONString(

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                              , JSON.toJSONString(
                        new Model(9007199254741992L), BrowserCompatible));

        assertEquals("{\"value\":\"-9007199254741992\"}"
                , JSON.toJSONString(
                        new Model(-9007199254741992L), BrowserCompatible));

        assertEquals("{\"value\":9007199254740990}"
                , JSON.toJSONString(

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 22

                              , JSON.toJSONString(
                        new Model(-9007199254741992L), BrowserCompatible));

        assertEquals("{\"value\":9007199254740990}"
                , JSON.toJSONString(
                        new Model(9007199254740990L), BrowserCompatible));

        assertEquals("{\"value\":-9007199254740990}"
                , JSON.toJSONString(

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 26

                              , JSON.toJSONString(
                        new Model(9007199254740990L), BrowserCompatible));

        assertEquals("{\"value\":-9007199254740990}"
                , JSON.toJSONString(
                        new Model(-9007199254740990L), BrowserCompatible));

        assertEquals("{\"value\":100}"
                , JSON.toJSONString(

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 30

                              , JSON.toJSONString(
                        new Model(-9007199254740990L), BrowserCompatible));

        assertEquals("{\"value\":100}"
                , JSON.toJSONString(
                        new Model(100), BrowserCompatible));

        assertEquals("{\"value\":-100}"
                , JSON.toJSONString(

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 34

                              , JSON.toJSONString(
                        new Model(100), BrowserCompatible));

        assertEquals("{\"value\":-100}"
                , JSON.toJSONString(
                        new Model(-100), BrowserCompatible));
    }



            

Reported by PMD.

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

Line: 43

              

    public static class Model {
        public BigInteger value;

        public Model() {

        }


            

Reported by PMD.

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

Line: 4

              package com.alibaba.json.bvt.issue_1700;

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

import java.math.BigInteger;


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/filters/PropertyPathTest3.java
11 issues
System.out.println is used
Design

Line: 68

              		public boolean apply(JSONSerializer serializer, Object source, String name) {
			SerialContext nowContext = new SerialContext(serializer.getContext(), source, name, 0, 0);
			String nowPath = getLinkedPath(nowContext);
			System.out.println("path->" + nowPath);
			//只输出children.id
			return containInclude(onlyProperties, nowPath);
		}

	}

            

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

              public class PropertyPathTest3 extends TestCase {

	/** 测试只输出子集合中的特定属性 */
	public void test_path() throws Exception {
		Person p1 = new Person();
		p1.setId(100);

		Person c1 = new Person();
		c1.setId(1000);

            

Reported by PMD.

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

Line: 28

              		Person c2 = new Person();
		c2.setId(2000);

		p1.getChildren().add(c1);
		p1.getChildren().add(c2);
		//只输出children.id以及根上的id
		String s = JSON.toJSONString(p1, new MyPropertyPreFilter(new String[] {"children.id", "id"}));

		Assert.assertEquals("{\"children\":[{\"id\":1000},{\"id\":2000}],\"id\":100}", s);

            

Reported by PMD.

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

Line: 29

              		c2.setId(2000);

		p1.getChildren().add(c1);
		p1.getChildren().add(c2);
		//只输出children.id以及根上的id
		String s = JSON.toJSONString(p1, new MyPropertyPreFilter(new String[] {"children.id", "id"}));

		Assert.assertEquals("{\"children\":[{\"id\":1000},{\"id\":2000}],\"id\":100}", s);
	}

            

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

              	}

	/** 测试只输出子字段map中的特定属性 */
	public void test_path2() throws Exception {
		Person2 p1 = new Person2();
		p1.setId(1);
		Map<String, String> infoMap = new HashMap<String, String>();
		infoMap.put("name", "李三");
		infoMap.put("height", "168");

            

Reported by PMD.

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

Line: 50

              	}

	public static class MyPropertyPreFilter implements PropertyPreFilter {
		String[] onlyProperties;

		public MyPropertyPreFilter(String[] onlyProperties) {
			this.onlyProperties = onlyProperties;
		}


            

Reported by PMD.

The user-supplied array 'onlyProperties' is stored directly.
Design

Line: 52

              	public static class MyPropertyPreFilter implements PropertyPreFilter {
		String[] onlyProperties;

		public MyPropertyPreFilter(String[] onlyProperties) {
			this.onlyProperties = onlyProperties;
		}

		private static boolean containInclude(String[] ss, String s) {
			if(ss == null || ss.length == 0 || s == null)

            

Reported by PMD.

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

Line: 86

              		if(isCollection || isFieldNameNull)
			return parentLinkedPath;
		return
			parentLinkedPath.length() == 0 ? String.valueOf(serialContext.fieldName) :
				parentLinkedPath + "." + serialContext.fieldName;
	}

	public static class Person {


            

Reported by PMD.

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

Line: 90

              				parentLinkedPath + "." + serialContext.fieldName;
	}

	public static class Person {

		private int id;
		private int id2;

		private List<Person> children = new ArrayList<Person>();

            

Reported by PMD.

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

Line: 123

              
	}

	public static class Person2 {
		private int id;
		private Map<String, String> infoMap;

		public int getId() {
			return id;

            

Reported by PMD.

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

               */
public class JSONScannerTest_colon extends TestCase {

    public void test_0() throws Exception {
        JSONScanner lexer = new JSONScanner(":true");
        lexer.nextTokenWithColon();
        Assert.assertEquals(JSONToken.TRUE, lexer.token());
    }


            

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

                      Assert.assertEquals(JSONToken.TRUE, lexer.token());
    }

    public void test_1() throws Exception {
        JSONScanner lexer = new JSONScanner(" : true");
        lexer.nextTokenWithColon();
        Assert.assertEquals(JSONToken.TRUE, lexer.token());
    }


            

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

                      Assert.assertEquals(JSONToken.TRUE, lexer.token());
    }

    public void test_2() throws Exception {
        JSONScanner lexer = new JSONScanner("\n:\ntrue");
        lexer.nextTokenWithColon();
        Assert.assertEquals(JSONToken.TRUE, lexer.token());
    }


            

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

                      Assert.assertEquals(JSONToken.TRUE, lexer.token());
    }

    public void test_3() throws Exception {
        JSONScanner lexer = new JSONScanner("\r:\rtrue");
        lexer.nextTokenWithColon();
        Assert.assertEquals(JSONToken.TRUE, lexer.token());
    }


            

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

                      Assert.assertEquals(JSONToken.TRUE, lexer.token());
    }

    public void test_4() throws Exception {
        JSONScanner lexer = new JSONScanner("\t:\ttrue");
        lexer.nextTokenWithColon();
        Assert.assertEquals(JSONToken.TRUE, lexer.token());
    }


            

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

                      Assert.assertEquals(JSONToken.TRUE, lexer.token());
    }

    public void test_5() throws Exception {
        JSONScanner lexer = new JSONScanner("\t:\ftrue");
        lexer.nextTokenWithColon();
        Assert.assertEquals(JSONToken.TRUE, lexer.token());
    }


            

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

                      Assert.assertEquals(JSONToken.TRUE, lexer.token());
    }

    public void test_6() throws Exception {
        JSONScanner lexer = new JSONScanner("\b:\btrue");
        lexer.nextTokenWithColon();
        Assert.assertEquals(JSONToken.TRUE, lexer.token());
    }


            

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

                      Assert.assertEquals(JSONToken.TRUE, lexer.token());
    }

    public void test_f() throws Exception {
        JSONScanner lexer = new JSONScanner("\f:\btrue");
        lexer.nextTokenWithColon();
        Assert.assertEquals(JSONToken.TRUE, lexer.token());
    }


            

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

                      Assert.assertEquals(JSONToken.TRUE, lexer.token());
    }

    public void test_7() throws Exception {
        JSONException error = null;
        try {
            JSONScanner lexer = new JSONScanner("true");
            lexer.nextTokenWithColon();
        } catch (JSONException e) {

            

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

                      Assert.assertNotNull(error);
    }

    public void test_8() throws Exception {
        JSONScanner lexer = new JSONScanner("\b:\btrue");
        lexer.nextToken();
        Assert.assertEquals(JSONToken.COLON, lexer.token());
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/path/JSONPath_set.java
11 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: 18

              
public class JSONPath_set extends TestCase {

    public void test_set() throws Exception {
        Entity entity = new Entity();

        JSONPath.set(entity, "$.name", "abc");

        Assert.assertEquals("abc", entity.getName());

            

Reported by PMD.

The String literal 'abc' appears 9 times in this file; the first occurrence is on line 21
Error

Line: 21

                  public void test_set() throws Exception {
        Entity entity = new Entity();

        JSONPath.set(entity, "$.name", "abc");

        Assert.assertEquals("abc", entity.getName());
    }

    public void test_set_array() 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: 26

                      Assert.assertEquals("abc", entity.getName());
    }

    public void test_set_array() throws Exception {
        Object[] array = new Object[1];

        JSONPath.set(array, "[0]", "abc");

        Assert.assertEquals("abc", array[0]);

            

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

                      Assert.assertEquals("abc", array[0]);
    }

    public void test_set_list() throws Exception {
        List array = new ArrayList();
        array.add(null);
        array.add(null);

        JSONPath.set(array, "[0]", "abc");

            

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

                      Assert.assertEquals("abc", array.get(0));
    }

    public void test_root_null() throws Exception {
        Assert.assertFalse(JSONPath.set(null, "[0]", "abc"));
    }
    
    public void test_object_not_exits() throws Exception {
        Map<String, Object> root = new HashMap<String, Object>();

            

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

                      Assert.assertFalse(JSONPath.set(null, "[0]", "abc"));
    }
    
    public void test_object_not_exits() throws Exception {
        Map<String, Object> root = new HashMap<String, Object>();
        root.put("values", null);
        Assert.assertTrue(JSONPath.set(root, "$.values[0]", "abc"));
    }


            

Reported by PMD.

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

Line: 54

                      Assert.assertTrue(JSONPath.set(root, "$.values[0]", "abc"));
    }

    public void test_error() throws Exception {
        Map<String, Object> root = new HashMap<String, Object>();
        root.put("values", null);
        JSONPath.set(root, "$.values[0]", "abc");
    }


            

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

                      Assert.assertTrue(JSONPath.set(root, "$.values[0]", "abc"));
    }

    public void test_error() throws Exception {
        Map<String, Object> root = new HashMap<String, Object>();
        root.put("values", null);
        JSONPath.set(root, "$.values[0]", "abc");
    }


            

Reported by PMD.

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

Line: 60

                      JSONPath.set(root, "$.values[0]", "abc");
    }

    static class Entity {

        private Integer id;
        private String  name;

        public Integer getId() {

            

Reported by PMD.

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

Line: 4

              package com.alibaba.json.bvt.path;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.junit.Assert;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/path/JSONPath_max.java
11 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.math.BigDecimal;

public class JSONPath_max extends TestCase {
    public void test_max() throws Exception {
        Object root = JSON.parse("[1,3,9, 5, 2, 4]");
        assertEquals(9, JSONPath.eval(root, "$.max()"));
    }

    public void test_max_1() throws Exception {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 12

              public class JSONPath_max extends TestCase {
    public void test_max() throws Exception {
        Object root = JSON.parse("[1,3,9, 5, 2, 4]");
        assertEquals(9, JSONPath.eval(root, "$.max()"));
    }

    public void test_max_1() throws Exception {
        Object root = JSON.parse("[1,6,7L,3,8,9.1, 5, 2L, 4]");
        assertEquals(new BigDecimal("9.1"), JSONPath.eval(root, "$.max()"));

            

Reported by PMD.

The String literal '$.max()' appears 5 times in this file; the first occurrence is on line 12
Error

Line: 12

              public class JSONPath_max extends TestCase {
    public void test_max() throws Exception {
        Object root = JSON.parse("[1,3,9, 5, 2, 4]");
        assertEquals(9, JSONPath.eval(root, "$.max()"));
    }

    public void test_max_1() throws Exception {
        Object root = JSON.parse("[1,6,7L,3,8,9.1, 5, 2L, 4]");
        assertEquals(new BigDecimal("9.1"), JSONPath.eval(root, "$.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: 15

                      assertEquals(9, JSONPath.eval(root, "$.max()"));
    }

    public void test_max_1() throws Exception {
        Object root = JSON.parse("[1,6,7L,3,8,9.1, 5, 2L, 4]");
        assertEquals(new BigDecimal("9.1"), JSONPath.eval(root, "$.max()"));
    }

    public void test_max_2() throws Exception {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

              
    public void test_max_1() throws Exception {
        Object root = JSON.parse("[1,6,7L,3,8,9.1, 5, 2L, 4]");
        assertEquals(new BigDecimal("9.1"), JSONPath.eval(root, "$.max()"));
    }

    public void test_max_2() throws Exception {
        Object root = JSON.parse("[1,6,7L,3,3.1D,8,9.1D, 5, 2L, 4]");
        assertEquals(9.1D, JSONPath.eval(root, "$.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: 20

                      assertEquals(new BigDecimal("9.1"), JSONPath.eval(root, "$.max()"));
    }

    public void test_max_2() throws Exception {
        Object root = JSON.parse("[1,6,7L,3,3.1D,8,9.1D, 5, 2L, 4]");
        assertEquals(9.1D, JSONPath.eval(root, "$.max()"));
    }

    public void test_max_3() throws Exception {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 22

              
    public void test_max_2() throws Exception {
        Object root = JSON.parse("[1,6,7L,3,3.1D,8,9.1D, 5, 2L, 4]");
        assertEquals(9.1D, JSONPath.eval(root, "$.max()"));
    }

    public void test_max_3() throws Exception {
        Object root = JSON.parse("[1,6,7L,3,3.1F,8,9.1F, 5, 2L, 4]");
        assertEquals(9.1F, JSONPath.eval(root, "$.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: 25

                      assertEquals(9.1D, JSONPath.eval(root, "$.max()"));
    }

    public void test_max_3() throws Exception {
        Object root = JSON.parse("[1,6,7L,3,3.1F,8,9.1F, 5, 2L, 4]");
        assertEquals(9.1F, JSONPath.eval(root, "$.max()"));
    }

    public void test_max_4() throws Exception {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 27

              
    public void test_max_3() throws Exception {
        Object root = JSON.parse("[1,6,7L,3,3.1F,8,9.1F, 5, 2L, 4]");
        assertEquals(9.1F, JSONPath.eval(root, "$.max()"));
    }

    public void test_max_4() throws Exception {
        Object root = JSON.parse("['1', '111', '2']");
        assertEquals("2", JSONPath.eval(root, "$.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: 30

                      assertEquals(9.1F, JSONPath.eval(root, "$.max()"));
    }

    public void test_max_4() throws Exception {
        Object root = JSON.parse("['1', '111', '2']");
        assertEquals("2", JSONPath.eval(root, "$.max()"));
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/path/JSONPath_paths_test3.java
11 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

              import junit.framework.TestCase;

public class JSONPath_paths_test3 extends TestCase {
    public void test_map() throws Exception {
        Model model = new Model();
        model.id = 1001;
        model.name = "wenshao";
        model.attributes.put("type", "employee");
        

            

Reported by PMD.

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

Line: 17

                      Model model = new Model();
        model.id = 1001;
        model.name = "wenshao";
        model.attributes.put("type", "employee");
        
        Map<String, Object> paths = JSONPath.paths(model);
        
        Assert.assertEquals(5, paths.size());
        Assert.assertSame(model, paths.get("/"));

            

Reported by PMD.

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

Line: 21

                      
        Map<String, Object> paths = JSONPath.paths(model);
        
        Assert.assertEquals(5, paths.size());
        Assert.assertSame(model, paths.get("/"));
        Assert.assertEquals(1001, paths.get("/id"));
        Assert.assertEquals("wenshao", paths.get("/name"));
        Assert.assertSame(model.attributes, paths.get("/attributes"));
        Assert.assertEquals("employee", paths.get("/attributes/type"));

            

Reported by PMD.

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

Line: 22

                      Map<String, Object> paths = JSONPath.paths(model);
        
        Assert.assertEquals(5, paths.size());
        Assert.assertSame(model, paths.get("/"));
        Assert.assertEquals(1001, paths.get("/id"));
        Assert.assertEquals("wenshao", paths.get("/name"));
        Assert.assertSame(model.attributes, paths.get("/attributes"));
        Assert.assertEquals("employee", paths.get("/attributes/type"));
    }

            

Reported by PMD.

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

Line: 23

                      
        Assert.assertEquals(5, paths.size());
        Assert.assertSame(model, paths.get("/"));
        Assert.assertEquals(1001, paths.get("/id"));
        Assert.assertEquals("wenshao", paths.get("/name"));
        Assert.assertSame(model.attributes, paths.get("/attributes"));
        Assert.assertEquals("employee", paths.get("/attributes/type"));
    }
    

            

Reported by PMD.

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

Line: 24

                      Assert.assertEquals(5, paths.size());
        Assert.assertSame(model, paths.get("/"));
        Assert.assertEquals(1001, paths.get("/id"));
        Assert.assertEquals("wenshao", paths.get("/name"));
        Assert.assertSame(model.attributes, paths.get("/attributes"));
        Assert.assertEquals("employee", paths.get("/attributes/type"));
    }
    
    public static class Model {

            

Reported by PMD.

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

Line: 25

                      Assert.assertSame(model, paths.get("/"));
        Assert.assertEquals(1001, paths.get("/id"));
        Assert.assertEquals("wenshao", paths.get("/name"));
        Assert.assertSame(model.attributes, paths.get("/attributes"));
        Assert.assertEquals("employee", paths.get("/attributes/type"));
    }
    
    public static class Model {
        public int id;

            

Reported by PMD.

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

Line: 26

                      Assert.assertEquals(1001, paths.get("/id"));
        Assert.assertEquals("wenshao", paths.get("/name"));
        Assert.assertSame(model.attributes, paths.get("/attributes"));
        Assert.assertEquals("employee", paths.get("/attributes/type"));
    }
    
    public static class Model {
        public int id;
        public String name;

            

Reported by PMD.

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

Line: 30

                  }
    
    public static class Model {
        public int id;
        public String name;
        
        public Map<String, Object> attributes = new HashMap<String, Object>();
    }
}

            

Reported by PMD.

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

Line: 31

                  
    public static class Model {
        public int id;
        public String name;
        
        public Map<String, Object> attributes = new HashMap<String, Object>();
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_3300/Issue3329.java
11 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 14

              import java.lang.reflect.Type;

public class Issue3329 extends TestCase {
    public void test_for_issue() throws Exception {
        ParserConfig config = new ParserConfig();
        IdentityHashMap<Type, ObjectDeserializer> deserializers = config.getDeserializers();
        int initSize = deserializers.size();
        for (int i = 0; i < 1000 * 10; ++i) {
            assertEquals(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: 14

              import java.lang.reflect.Type;

public class Issue3329 extends TestCase {
    public void test_for_issue() throws Exception {
        ParserConfig config = new ParserConfig();
        IdentityHashMap<Type, ObjectDeserializer> deserializers = config.getDeserializers();
        int initSize = deserializers.size();
        for (int i = 0; i < 1000 * 10; ++i) {
            assertEquals(123,

            

Reported by PMD.

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

Line: 17

                  public void test_for_issue() throws Exception {
        ParserConfig config = new ParserConfig();
        IdentityHashMap<Type, ObjectDeserializer> deserializers = config.getDeserializers();
        int initSize = deserializers.size();
        for (int i = 0; i < 1000 * 10; ++i) {
            assertEquals(123,
                ((VO<User>) JSON.parseObject("{\"value\":{\"id\":123}}",
                        new ParameterizedTypeImpl(new Type[] {User.class}, null, VO.class),
                        config

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

                      IdentityHashMap<Type, ObjectDeserializer> deserializers = config.getDeserializers();
        int initSize = deserializers.size();
        for (int i = 0; i < 1000 * 10; ++i) {
            assertEquals(123,
                ((VO<User>) JSON.parseObject("{\"value\":{\"id\":123}}",
                        new ParameterizedTypeImpl(new Type[] {User.class}, null, VO.class),
                        config
                        )).value.id
            );

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 21

                      for (int i = 0; i < 1000 * 10; ++i) {
            assertEquals(123,
                ((VO<User>) JSON.parseObject("{\"value\":{\"id\":123}}",
                        new ParameterizedTypeImpl(new Type[] {User.class}, null, VO.class),
                        config
                        )).value.id
            );
        }


            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 21

                      for (int i = 0; i < 1000 * 10; ++i) {
            assertEquals(123,
                ((VO<User>) JSON.parseObject("{\"value\":{\"id\":123}}",
                        new ParameterizedTypeImpl(new Type[] {User.class}, null, VO.class),
                        config
                        )).value.id
            );
        }


            

Reported by PMD.

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

Line: 28

                      }


        assertEquals(2, deserializers.size() - initSize);
    }

    public static class VO<T> {
        public T value;
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 28

                      }


        assertEquals(2, deserializers.size() - initSize);
    }

    public static class VO<T> {
        public T value;
    }

            

Reported by PMD.

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

Line: 32

                  }

    public static class VO<T> {
        public T value;
    }

    public static class User {
        public int id;
    }

            

Reported by PMD.

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

Line: 36

                  }

    public static class User {
        public int id;
    }
}

            

Reported by PMD.

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

Line: 19

                      paramMap.put("url2", "456");
        bean.setParamMap(paramMap);
        String str = JSON.toJSONString(bean);
        System.out.println(str);
        Bean bean2 = JSON.parseObject(str, Bean.class);
        System.out.println(bean2.getAction());
        System.out.println(bean2.getParamMap());
    }


            

Reported by PMD.

System.out.println is used
Design

Line: 21

                      String str = JSON.toJSONString(bean);
        System.out.println(str);
        Bean bean2 = JSON.parseObject(str, Bean.class);
        System.out.println(bean2.getAction());
        System.out.println(bean2.getParamMap());
    }

    public static class Bean {


            

Reported by PMD.

System.out.println is used
Design

Line: 22

                      System.out.println(str);
        Bean bean2 = JSON.parseObject(str, Bean.class);
        System.out.println(bean2.getAction());
        System.out.println(bean2.getParamMap());
    }

    public static class Bean {

        private String                  action;

            

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

              
public class Bug_for_liuwanzhen_ren extends TestCase {

    public void test_0() throws Exception {
        Bean bean = new Bean();
        bean.setAction("123");
        HashMap paramMap = new HashMap();
        paramMap.put("url1", "123");
        paramMap.put("url2", "456");

            

Reported by PMD.

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

Line: 11

              
public class Bug_for_liuwanzhen_ren extends TestCase {

    public void test_0() throws Exception {
        Bean bean = new Bean();
        bean.setAction("123");
        HashMap paramMap = new HashMap();
        paramMap.put("url1", "123");
        paramMap.put("url2", "456");

            

Reported by PMD.

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

Line: 21

                      String str = JSON.toJSONString(bean);
        System.out.println(str);
        Bean bean2 = JSON.parseObject(str, Bean.class);
        System.out.println(bean2.getAction());
        System.out.println(bean2.getParamMap());
    }

    public static class Bean {


            

Reported by PMD.

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

Line: 22

                      System.out.println(str);
        Bean bean2 = JSON.parseObject(str, Bean.class);
        System.out.println(bean2.getAction());
        System.out.println(bean2.getParamMap());
    }

    public static class Bean {

        private String                  action;

            

Reported by PMD.

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

Line: 25

                      System.out.println(bean2.getParamMap());
    }

    public static class Bean {

        private String                  action;
        private HashMap<String, String> paramMap;

        public String getAction() {

            

Reported by PMD.

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

Line: 28

                  public static class Bean {

        private String                  action;
        private HashMap<String, String> paramMap;

        public String getAction() {
            return action;
        }


            

Reported by PMD.

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

Line: 38

                          this.action = action;
        }

        public HashMap<String, String> getParamMap() {
            return paramMap;
        }

        public void setParamMap(HashMap<String, String> paramMap) {
            this.paramMap = paramMap;

            

Reported by PMD.

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

              
public class JSONLexerTest_2 extends TestCase {

    public void test_0() throws Exception {
        VO vo = (VO) JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.parser.JSONLexerTest_2$VO\"}", VO.class);
        Assert.assertNotNull(vo);
    }

    public void test_1() throws Exception {

            

Reported by PMD.

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

Line: 20

                      Assert.assertNotNull(vo);
    }

    public void test_1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.parser.JSONLexerTest_2$VO1\"}", VO.class);
        } catch (JSONException ex) {
            error = ex;

            

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

                      Assert.assertNotNull(error);
    }

    public void test_2() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.parser.JSONLexerTest_2$A\"}", VO.class);
        } catch (JSONException ex) {
            error = ex;

            

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

                      Assert.assertNotNull(error);
    }

    public void test_a() throws Exception {
        P a = JSON.parseObject("{\"vo\":{\"@type\":\"com.alibaba.json.bvt.parser.JSONLexerTest_2$VO\"}}", P.class);
        Assert.assertNotNull(a);
    }

    public void test_list() 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: 45

                      Assert.assertNotNull(a);
    }

    public void test_list() throws Exception {
        List<VO> list = JSON.parseObject("[{\"@type\":\"com.alibaba.json.bvt.parser.JSONLexerTest_2$VO\"}]",
                                         new TypeReference<List<VO>>() {
                                         });
        Assert.assertNotNull(list);
        Assert.assertNotNull(list.get(0));

            

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

                      Assert.assertNotNull(list.get(0));
    }

    public void test_list_2() throws Exception {
        List<VO> list = JSON.parseObject("[{\"@type\":\"com.alibaba.json.bvt.parser.JSONLexerTest_2$VO\"},{}]",
                                         new TypeReference<List<VO>>() {
                                         });
        Assert.assertNotNull(list);
        Assert.assertEquals(2, list.size());

            

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

                      Assert.assertNotNull(list.get(1));
    }

    public void test_error() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[{\"@type\":\"com.alibaba.json.bvt.parser.JSONLexerTest_2$VO\"}[]",
                             new TypeReference<List<VO>>() {
                             });

            

Reported by PMD.

Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block
Design

Line: 69

                          JSON.parseObject("[{\"@type\":\"com.alibaba.json.bvt.parser.JSONLexerTest_2$VO\"}[]",
                             new TypeReference<List<VO>>() {
                             });
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }


            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '21'-'25').
Error

Line: 21

                  }

    public void test_1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.parser.JSONLexerTest_2$VO1\"}", VO.class);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '31'-'35').
Error

Line: 31

                  }

    public void test_2() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.parser.JSONLexerTest_2$A\"}", VO.class);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.