The following issues were found

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

Line: 28

                          text = JSON.toJSONString(list);
        }

        System.out.println(text);

        {
            List<Bean> list = JSON.parseObject(text, new TypeReference<List<Bean>>() {}); // 注意这里
            Assert.assertEquals(3, list.size());
            Assert.assertEquals(123, ((Bean) list.get(0)).getId());

            

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

              
public class TypeReferenceTest2 extends TestCase {

    public void test_0() throws Exception {
        String text;

        {
            List<Bean> list = new ArrayList<Bean>();
            list.add(new Bean(123, "马加爵"));

            

Reported by PMD.

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

Line: 55

                      }
    }

    public static class Bean {

        private int    id;
        private String name;

        public Bean(){

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/IgoreGetterTest.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

              import java.io.Reader;

public class IgoreGetterTest extends TestCase {
    public void test_for_issue() throws Exception {
        VO vo = new VO();
        assertEquals("{}", JSON.toJSONString(vo));
    }

    public static class VO {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 13

              public class IgoreGetterTest extends TestCase {
    public void test_for_issue() throws Exception {
        VO vo = new VO();
        assertEquals("{}", JSON.toJSONString(vo));
    }

    public static class VO {
        public InputStream getInputStream() {
            throw  new UnsupportedOperationException();

            

Reported by PMD.

Avoid unused imports such as 'java.io.OutputStream'
Design

Line: 7

              import junit.framework.TestCase;

import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;

public class IgoreGetterTest extends TestCase {
    public void test_for_issue() throws Exception {
        VO vo = new VO();

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/typeRef/TypeReferenceTest5.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: 13

              
public class TypeReferenceTest5 extends TestCase {

    public void test_typeRef() throws Exception {
        TypeReference<A<B>> typeRef = new TypeReference<A<B>>() {
        };

        A<B> a = JSON.parseObject("{\"body\":{\"id\":123}}", typeRef);
        

            

Reported by PMD.

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

Line: 19

              
        A<B> a = JSON.parseObject("{\"body\":{\"id\":123}}", typeRef);
        
        B b = a.getBody();
        Assert.assertEquals(123, b.get("id"));
    }

    public static class A<T> {


            

Reported by PMD.

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

Line: 20

                      A<B> a = JSON.parseObject("{\"body\":{\"id\":123}}", typeRef);
        
        B b = a.getBody();
        Assert.assertEquals(123, b.get("id"));
    }

    public static class A<T> {

        private T body;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/GenericTypeTest.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 GenericTypeTest extends TestCase {
    
    public void test_gerneric() throws Exception {
        MyResultResult result = new MyResultResult();
        JSON.toJSONString(result);
    }
    
    public static class MyResultResult extends BaseResult<String> {

            

Reported by PMD.

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

Line: 11

              
public class GenericTypeTest extends TestCase {
    
    public void test_gerneric() throws Exception {
        MyResultResult result = new MyResultResult();
        JSON.toJSONString(result);
    }
    
    public static class MyResultResult extends BaseResult<String> {

            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 19

                  public static class MyResultResult extends BaseResult<String> {
    }
    
    public static class BaseResult<T> implements Serializable {
        public T data;
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/GenericTypeNotMatchTest.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: 12

               * Created by wenshao on 10/02/2017.
 */
public class GenericTypeNotMatchTest extends TestCase {
    public void test_for_notMatch() throws Exception {
        Model model = new Model();
        Base base = model;
        base.id = BigInteger.valueOf(3);
        JSON.toJSONString(base);
    }

            

Reported by PMD.

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

Line: 12

               * Created by wenshao on 10/02/2017.
 */
public class GenericTypeNotMatchTest extends TestCase {
    public void test_for_notMatch() throws Exception {
        Model model = new Model();
        Base base = model;
        base.id = BigInteger.valueOf(3);
        JSON.toJSONString(base);
    }

            

Reported by PMD.

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

Line: 24

                  }

    public static class Base<T> {
        public T id;
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/path/JSONPath_containsValue.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: 13

              import junit.framework.TestCase;

public class JSONPath_containsValue extends TestCase {
    public void test_root() throws Exception {
        List list = new ArrayList();
        list.add("kiki");
        list.add("ljw2083");
        list.add("wenshao");
        

            

Reported by PMD.

The String literal 'kiki' appears 4 times in this file; the first occurrence is on line 15
Error

Line: 15

              public class JSONPath_containsValue extends TestCase {
    public void test_root() throws Exception {
        List list = new ArrayList();
        list.add("kiki");
        list.add("ljw2083");
        list.add("wenshao");
        
        Assert.assertTrue(JSONPath.containsValue(list, "/0", "kiki"));
        Assert.assertFalse(JSONPath.containsValue(list, "/0", "kiki_"));

            

Reported by PMD.

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

Line: 32

                      Assert.assertTrue(JSONPath.contains(list, "/2"));
        Assert.assertFalse(JSONPath.contains(list, "/3"));
        Assert.assertFalse(JSONPath.contains(null, "$"));
        Assert.assertFalse(JSONPath.compile("$").contains(null));
        Assert.assertFalse(JSONPath.containsValue(null, "$", "kiki"));
    }
    
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/filters/AfterFilterTest2.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: 12

              import com.alibaba.fastjson.serializer.BeforeFilter;

public class AfterFilterTest2 extends TestCase {
    public void test_afterFilter() throws Exception {
        AfterFilter filter = new AfterFilter() {
            
            @Override
            public void writeAfter(Object object) {
                this.writeKeyValue("id", 123);

            

Reported by PMD.

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

Line: 23

                      Assert.assertEquals("{\"id\":123}",JSON.toJSONString( new VO(), filter));
    }
    
    public void test_afterFilter2() throws Exception {
        AfterFilter filter = new AfterFilter() {
            
            @Override
            public void writeAfter(Object object) {
                this.writeKeyValue("id", 123);

            

Reported by PMD.

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

Line: 9

              
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.AfterFilter;
import com.alibaba.fastjson.serializer.BeforeFilter;

public class AfterFilterTest2 extends TestCase {
    public void test_afterFilter() throws Exception {
        AfterFilter filter = new AfterFilter() {
            

            

Reported by PMD.

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

    public void test_0() throws Exception {
        Assert.assertEquals("null", JSON.toJSONString(Float.NaN));
        Assert.assertEquals("null", JSON.toJSONString(Double.NaN));
        Assert.assertEquals("null", JSON.toJSONString(Float.POSITIVE_INFINITY));
        Assert.assertEquals("null", JSON.toJSONString(Float.NEGATIVE_INFINITY));
        Assert.assertEquals("null", JSON.toJSONString(Double.NaN));

            

Reported by PMD.

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

Line: 11

              public class FloatTest extends TestCase {

    public void test_0() throws Exception {
        Assert.assertEquals("null", JSON.toJSONString(Float.NaN));
        Assert.assertEquals("null", JSON.toJSONString(Double.NaN));
        Assert.assertEquals("null", JSON.toJSONString(Float.POSITIVE_INFINITY));
        Assert.assertEquals("null", JSON.toJSONString(Float.NEGATIVE_INFINITY));
        Assert.assertEquals("null", JSON.toJSONString(Double.NaN));
        Assert.assertEquals("null", JSON.toJSONString(Double.POSITIVE_INFINITY));

            

Reported by PMD.

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

Line: 34

                      Assert.assertEquals(null, JSON.parseObject(JSON.toJSONString(new Bean(Float.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY))).get("f2"));
    }

    public static class Bean {

        private float  f1 = Float.NaN;
        private double f2 = Double.NaN;
        
        public Bean() {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/FloatFormatTest2.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 09/01/2017.
 */
public class FloatFormatTest2 extends TestCase {
    public void test_format() throws Exception {
        Model model = new Model();
        model.value = 123.45678F;

        String str = JSON.toJSONString(model);
        assertEquals("{\"value\":123.46}", str);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 16

                      model.value = 123.45678F;

        String str = JSON.toJSONString(model);
        assertEquals("{\"value\":123.46}", str);
    }

    public static class Model {
        @JSONField(format = "0.00")
        public Float value;

            

Reported by PMD.

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

Line: 21

              
    public static class Model {
        @JSONField(format = "0.00")
        public Float value;
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/FloatFormatTest.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 09/01/2017.
 */
public class FloatFormatTest extends TestCase {
    public void test_format() throws Exception {
        Model model = new Model();
        model.value = 123.45678F;

        String str = JSON.toJSONString(model);
        assertEquals("{\"value\":123.46}", str);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 16

                      model.value = 123.45678F;

        String str = JSON.toJSONString(model);
        assertEquals("{\"value\":123.46}", str);
    }

    public static class Model {
        @JSONField(format = "0.00")
        public float value;

            

Reported by PMD.

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

Line: 21

              
    public static class Model {
        @JSONField(format = "0.00")
        public float value;
    }
}

            

Reported by PMD.