The following issues were found

src/test/java/com/alibaba/json/bvt/parser/deser/deny/InitJavaBeanDeserializerTest.java
12 issues
System.out.println is used
Design

Line: 36

                      Exception error = null;
        try {
            Object obj = JSON.parseObject(text, Object.class, config);
            System.out.println(obj.getClass());
        } catch (JSONException ex) {
            error = ex;
        }
        assertNotNull(error);


            

Reported by PMD.

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

Line: 14

               * Created by wenshao on 28/01/2017.
 */
public class InitJavaBeanDeserializerTest extends TestCase {
    ParserConfig config = new ParserConfig();

    protected void setUp() throws Exception {
        assertFalse(config.isAutoTypeSupport());

        Properties properties = new Properties();

            

Reported by PMD.

JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll
Design

Line: 16

              public class InitJavaBeanDeserializerTest extends TestCase {
    ParserConfig config = new ParserConfig();

    protected void setUp() throws Exception {
        assertFalse(config.isAutoTypeSupport());

        Properties properties = new Properties();
        properties.put(ParserConfig.AUTOTYPE_SUPPORT_PROPERTY, "false");
        // config.addAccept("com.alibaba.json.bvt.parser.deser.deny.DenyTest11.Model");

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

                  ParserConfig config = new ParserConfig();

    protected void setUp() throws Exception {
        assertFalse(config.isAutoTypeSupport());

        Properties properties = new Properties();
        properties.put(ParserConfig.AUTOTYPE_SUPPORT_PROPERTY, "false");
        // config.addAccept("com.alibaba.json.bvt.parser.deser.deny.DenyTest11.Model");
        // -ea -Dfastjson.parser.autoTypeAccept=com.alibaba.json.bvt.parser.deser.deny.DenyTest9

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 25

                      // -ea -Dfastjson.parser.autoTypeAccept=com.alibaba.json.bvt.parser.deser.deny.DenyTest9
        config.configFromPropety(properties);

        assertFalse(config.isAutoTypeSupport());
    }

    public void test_desktop() throws Exception {
        DenyTest11.Model model = new DenyTest11.Model();
        model.a = new DenyTest11.B();

            

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

                      assertFalse(config.isAutoTypeSupport());
    }

    public void test_desktop() throws Exception {
        DenyTest11.Model model = new DenyTest11.Model();
        model.a = new DenyTest11.B();
        String text = "{\"@type\":\"com.alibaba.json.bvt.parser.deser.deny.InitJavaBeanDeserializerTest$Model\"}";

        Exception error = null;

            

Reported by PMD.

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

Line: 28

                      assertFalse(config.isAutoTypeSupport());
    }

    public void test_desktop() throws Exception {
        DenyTest11.Model model = new DenyTest11.Model();
        model.a = new DenyTest11.B();
        String text = "{\"@type\":\"com.alibaba.json.bvt.parser.deser.deny.InitJavaBeanDeserializerTest$Model\"}";

        Exception error = null;

            

Reported by PMD.

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

Line: 36

                      Exception error = null;
        try {
            Object obj = JSON.parseObject(text, Object.class, config);
            System.out.println(obj.getClass());
        } catch (JSONException ex) {
            error = ex;
        }
        assertNotNull(error);


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 40

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

        config.initJavaBeanDeserializers(Model.class);

        Object obj = JSON.parseObject(text, Object.class, config);
        assertEquals(Model.class, obj.getClass());

            

Reported by PMD.

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

Line: 45

                      config.initJavaBeanDeserializers(Model.class);

        Object obj = JSON.parseObject(text, Object.class, config);
        assertEquals(Model.class, obj.getClass());
    }

    public static class Model {

    }

            

Reported by PMD.

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

    public void test_ref() throws Exception {
        Object[] array = new Object[1];
        array[0] = array;
        Assert.assertEquals("[{\"$ref\":\"@\"}]", JSON.toJSONString(array));
    }


            

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

                      Assert.assertEquals("[{\"$ref\":\"@\"}]", JSON.toJSONString(array));
    }

    public void test_ref_1() throws Exception {
        Object[] array = new Object[3];
        array[0] = array;
        array[1] = new Object();
        array[2] = new Object();
        Assert.assertEquals("[{\"$ref\":\"@\"},{},{}]", JSON.toJSONString(array));

            

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

                      Assert.assertEquals("[{\"$ref\":\"@\"},{},{}]", JSON.toJSONString(array));
    }

    public void test_ref_2() throws Exception {
        Object[] array = new Object[3];
        array[0] = new Object();
        array[1] = array;
        array[2] = new Object();
        Assert.assertEquals("[{},{\"$ref\":\"@\"},{}]", JSON.toJSONString(array));

            

Reported by PMD.

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

Line: 33

                      Assert.assertEquals("[{},{\"$ref\":\"@\"},{}]", JSON.toJSONString(array));
    }

    public void test_ref_3() throws Exception {
        Object[] array = new Object[3];
        array[0] = new Object();
        array[1] = new Object();
        array[2] = array;
        Assert.assertEquals("[{},{},{\"$ref\":\"@\"}]", JSON.toJSONString(array));

            

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("[{},{},{\"$ref\":\"@\"}]", JSON.toJSONString(array));
    }

    public void test_parse() throws Exception {
        Object[] array2 = JSON.parseObject("[{\"$ref\":\"$\"}]", Object[].class);
        Assert.assertSame(array2, array2[0]);
    }

    public void test_parse_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: 46

                      Assert.assertSame(array2, array2[0]);
    }

    public void test_parse_1() throws Exception {
        Object[] array2 = JSON.parseObject("[{\"$ref\":\"@\"}]", Object[].class);
        Assert.assertSame(array2, array2[0]);
    }
}

            

Reported by PMD.

Found 'DD'-anomaly for variable 'array' (lines '19'-'20').
Error

Line: 19

              
    public void test_ref_1() throws Exception {
        Object[] array = new Object[3];
        array[0] = array;
        array[1] = new Object();
        array[2] = new Object();
        Assert.assertEquals("[{\"$ref\":\"@\"},{},{}]", JSON.toJSONString(array));
    }


            

Reported by PMD.

Found 'DD'-anomaly for variable 'array' (lines '20'-'21').
Error

Line: 20

                  public void test_ref_1() throws Exception {
        Object[] array = new Object[3];
        array[0] = array;
        array[1] = new Object();
        array[2] = new Object();
        Assert.assertEquals("[{\"$ref\":\"@\"},{},{}]", JSON.toJSONString(array));
    }

    public void test_ref_2() throws Exception {

            

Reported by PMD.

Found 'DD'-anomaly for variable 'array' (lines '26'-'27').
Error

Line: 26

                  }

    public void test_ref_2() throws Exception {
        Object[] array = new Object[3];
        array[0] = new Object();
        array[1] = array;
        array[2] = new Object();
        Assert.assertEquals("[{},{\"$ref\":\"@\"},{}]", JSON.toJSONString(array));
    }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'array' (lines '28'-'29').
Error

Line: 28

                  public void test_ref_2() throws Exception {
        Object[] array = new Object[3];
        array[0] = new Object();
        array[1] = array;
        array[2] = new Object();
        Assert.assertEquals("[{},{\"$ref\":\"@\"},{}]", JSON.toJSONString(array));
    }

    public void test_ref_3() throws Exception {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1200/Issue1246.java
12 issues
System.out.println is used
Design

Line: 19

                      b.setX("xx");

        String test = JSON.toJSONString( b );
        System.out.println(test);
        assertEquals("{}", test);

        C c = new C();
        c.ab = b ;


            

Reported by PMD.

System.out.println is used
Design

Line: 26

                      c.ab = b ;

        String testC = JSON.toJSONString( c );
        System.out.println(testC);
        assertEquals("{\"ab\":{}}",testC);

        D d = new D();
        d.setAb( b );


            

Reported by PMD.

System.out.println is used
Design

Line: 33

                      d.setAb( b );

        String testD = JSON.toJSONString( d );
        System.out.println(testD);
        assertEquals("{\"ab\":{}}",testD);
    }

    public static class C{
        public A ab;

            

Reported by PMD.

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

Line: 14

               * Created by kimmking on 06/06/2017.
 */
public class Issue1246 extends TestCase {
    public void test_for_issue() throws Exception {
        B b = new B();
        b.setX("xx");

        String test = JSON.toJSONString( b );
        System.out.println(test);

            

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

               * Created by kimmking on 06/06/2017.
 */
public class Issue1246 extends TestCase {
    public void test_for_issue() throws Exception {
        B b = new B();
        b.setX("xx");

        String test = JSON.toJSONString( b );
        System.out.println(test);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 20

              
        String test = JSON.toJSONString( b );
        System.out.println(test);
        assertEquals("{}", test);

        C c = new C();
        c.ab = b ;

        String testC = JSON.toJSONString( c );

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 27

              
        String testC = JSON.toJSONString( c );
        System.out.println(testC);
        assertEquals("{\"ab\":{}}",testC);

        D d = new D();
        d.setAb( b );

        String testD = JSON.toJSONString( d );

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 34

              
        String testD = JSON.toJSONString( d );
        System.out.println(testD);
        assertEquals("{\"ab\":{}}",testD);
    }

    public static class C{
        public A ab;
    }

            

Reported by PMD.

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

Line: 38

                  }

    public static class C{
        public A ab;
    }

    public static class D{
        private A ab;


            

Reported by PMD.

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

Line: 5

              
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;
import org.springframework.util.LinkedMultiValueMap;

/**

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Issue922.java
12 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

               * Created by wenshao on 20/12/2016.
 */
public class Issue922 extends TestCase {
    public void test_for_issue() throws Exception {
        String text = "[1,2,3]";
        JSONArray array = JSON.parseArray(text);
        List<Long> list = array.toJavaList(Long.class);
        assertEquals(1L, list.get(0).longValue());
        assertEquals(2L, list.get(1).longValue());

            

Reported by PMD.

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

Line: 13

               * Created by wenshao on 20/12/2016.
 */
public class Issue922 extends TestCase {
    public void test_for_issue() throws Exception {
        String text = "[1,2,3]";
        JSONArray array = JSON.parseArray(text);
        List<Long> list = array.toJavaList(Long.class);
        assertEquals(1L, list.get(0).longValue());
        assertEquals(2L, list.get(1).longValue());

            

Reported by PMD.

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

Line: 16

                  public void test_for_issue() throws Exception {
        String text = "[1,2,3]";
        JSONArray array = JSON.parseArray(text);
        List<Long> list = array.toJavaList(Long.class);
        assertEquals(1L, list.get(0).longValue());
        assertEquals(2L, list.get(1).longValue());
        assertEquals(3L, list.get(2).longValue());
    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

                      String text = "[1,2,3]";
        JSONArray array = JSON.parseArray(text);
        List<Long> list = array.toJavaList(Long.class);
        assertEquals(1L, list.get(0).longValue());
        assertEquals(2L, list.get(1).longValue());
        assertEquals(3L, list.get(2).longValue());
    }
}

            

Reported by PMD.

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

Line: 17

                      String text = "[1,2,3]";
        JSONArray array = JSON.parseArray(text);
        List<Long> list = array.toJavaList(Long.class);
        assertEquals(1L, list.get(0).longValue());
        assertEquals(2L, list.get(1).longValue());
        assertEquals(3L, list.get(2).longValue());
    }
}

            

Reported by PMD.

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

Line: 17

                      String text = "[1,2,3]";
        JSONArray array = JSON.parseArray(text);
        List<Long> list = array.toJavaList(Long.class);
        assertEquals(1L, list.get(0).longValue());
        assertEquals(2L, list.get(1).longValue());
        assertEquals(3L, list.get(2).longValue());
    }
}

            

Reported by PMD.

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

Line: 18

                      JSONArray array = JSON.parseArray(text);
        List<Long> list = array.toJavaList(Long.class);
        assertEquals(1L, list.get(0).longValue());
        assertEquals(2L, list.get(1).longValue());
        assertEquals(3L, list.get(2).longValue());
    }
}

            

Reported by PMD.

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

Line: 18

                      JSONArray array = JSON.parseArray(text);
        List<Long> list = array.toJavaList(Long.class);
        assertEquals(1L, list.get(0).longValue());
        assertEquals(2L, list.get(1).longValue());
        assertEquals(3L, list.get(2).longValue());
    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                      JSONArray array = JSON.parseArray(text);
        List<Long> list = array.toJavaList(Long.class);
        assertEquals(1L, list.get(0).longValue());
        assertEquals(2L, list.get(1).longValue());
        assertEquals(3L, list.get(2).longValue());
    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

                      List<Long> list = array.toJavaList(Long.class);
        assertEquals(1L, list.get(0).longValue());
        assertEquals(2L, list.get(1).longValue());
        assertEquals(3L, list.get(2).longValue());
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/fastjson/jsonpath/issue3607/TestIssue3607.java
12 issues
The String literal ' {\n' appears 7 times in this file; the first occurrence is on line 24
Error

Line: 24

                              "        \"dataRows\": [\n" +
                "            {\n" +
                "                \"dataFields\": [\n" +
                "                    {\n" +
                "                        \"id\": 1332,\n" +
                "                        \"name\": \"gmtRegular\",\n" +
                "                        \"status\": \"success\",\n" +
                "                        \"valueType\": \"DATE\"\n" +
                "                    },\n" +

            

Reported by PMD.

The String literal ' \'status\': \'success\',\n' appears 7 times in this file; the first occurrence is on line 27
Error

Line: 27

                              "                    {\n" +
                "                        \"id\": 1332,\n" +
                "                        \"name\": \"gmtRegular\",\n" +
                "                        \"status\": \"success\",\n" +
                "                        \"valueType\": \"DATE\"\n" +
                "                    },\n" +
                "                    {\n" +
                "                        \"id\": 302,\n" +
                "                        \"name\": \"deptNo\",\n" +

            

Reported by PMD.

The String literal ' },\n' appears 6 times in this file; the first occurrence is on line 29
Error

Line: 29

                              "                        \"name\": \"gmtRegular\",\n" +
                "                        \"status\": \"success\",\n" +
                "                        \"valueType\": \"DATE\"\n" +
                "                    },\n" +
                "                    {\n" +
                "                        \"id\": 302,\n" +
                "                        \"name\": \"deptNo\",\n" +
                "                        \"status\": \"success\",\n" +
                "                        \"value\": \"C3736\",\n" +

            

Reported by PMD.

The String literal ' \'valueType\': \'STRING\'\n' appears 4 times in this file; the first occurrence is on line 35
Error

Line: 35

                              "                        \"name\": \"deptNo\",\n" +
                "                        \"status\": \"success\",\n" +
                "                        \"value\": \"C3736\",\n" +
                "                        \"valueType\": \"STRING\"\n" +
                "                    },\n" +
                "                    {\n" +
                "                        \"id\": 143,\n" +
                "                        \"name\": \"gmtOrigRegular\",\n" +
                "                        \"status\": \"success\",\n" +

            

Reported by PMD.

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

Line: 82

              

        List<String> evalResult = (List<String>) JSONPath.eval(testData, "$.data.dataRows[*].dataFields[*].value", false);
        Assert.assertEquals(testData.getData().getDataRows().get(0).getDataFields().size(), evalResult.size());

    }

    static class TestData {
        private Test1 data;

            

Reported by PMD.

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

Line: 82

              

        List<String> evalResult = (List<String>) JSONPath.eval(testData, "$.data.dataRows[*].dataFields[*].value", false);
        Assert.assertEquals(testData.getData().getDataRows().get(0).getDataFields().size(), evalResult.size());

    }

    static class TestData {
        private Test1 data;

            

Reported by PMD.

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

Line: 82

              

        List<String> evalResult = (List<String>) JSONPath.eval(testData, "$.data.dataRows[*].dataFields[*].value", false);
        Assert.assertEquals(testData.getData().getDataRows().get(0).getDataFields().size(), evalResult.size());

    }

    static class TestData {
        private Test1 data;

            

Reported by PMD.

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

Line: 82

              

        List<String> evalResult = (List<String>) JSONPath.eval(testData, "$.data.dataRows[*].dataFields[*].value", false);
        Assert.assertEquals(testData.getData().getDataRows().get(0).getDataFields().size(), evalResult.size());

    }

    static class TestData {
        private Test1 data;

            

Reported by PMD.

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

Line: 82

              

        List<String> evalResult = (List<String>) JSONPath.eval(testData, "$.data.dataRows[*].dataFields[*].value", false);
        Assert.assertEquals(testData.getData().getDataRows().get(0).getDataFields().size(), evalResult.size());

    }

    static class TestData {
        private Test1 data;

            

Reported by PMD.

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

Line: 82

              

        List<String> evalResult = (List<String>) JSONPath.eval(testData, "$.data.dataRows[*].dataFields[*].value", false);
        Assert.assertEquals(testData.getData().getDataRows().get(0).getDataFields().size(), evalResult.size());

    }

    static class TestData {
        private Test1 data;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1200/Issue1233.java
12 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

               * Created by wenshao on 30/05/2017.
 */
public class Issue1233 extends TestCase {
    public void test_for_issue() throws Exception {
        ParserConfig.getGlobalInstance().putDeserializer(Area.class, new ObjectDeserializer() {
            public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
                JSONObject jsonObject = (JSONObject) parser.parse();
                String areaType;


            

Reported by PMD.

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

Line: 17

               * Created by wenshao on 30/05/2017.
 */
public class Issue1233 extends TestCase {
    public void test_for_issue() throws Exception {
        ParserConfig.getGlobalInstance().putDeserializer(Area.class, new ObjectDeserializer() {
            public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
                JSONObject jsonObject = (JSONObject) parser.parse();
                String areaType;


            

Reported by PMD.

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

Line: 23

                              JSONObject jsonObject = (JSONObject) parser.parse();
                String areaType;

                if (jsonObject.get("type") instanceof String) {
                    areaType = (String) jsonObject.get("type");
                } else {
                    return null;
                }
                if (Area.TYPE_SECTION.equals(areaType)) {

            

Reported by PMD.

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

Line: 28

                              } else {
                    return null;
                }
                if (Area.TYPE_SECTION.equals(areaType)) {
                    return (T) JSON.toJavaObject(jsonObject, Section.class);
                } else if (Area.TYPE_FLOORV1.equals(areaType)) {
                    return (T) JSON.toJavaObject(jsonObject, FloorV1.class);
                } else if (Area.TYPE_FLOORV2.equals(areaType)) {
                    return (T) JSON.toJavaObject(jsonObject, FloorV2.class);

            

Reported by PMD.

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

Line: 30

                              }
                if (Area.TYPE_SECTION.equals(areaType)) {
                    return (T) JSON.toJavaObject(jsonObject, Section.class);
                } else if (Area.TYPE_FLOORV1.equals(areaType)) {
                    return (T) JSON.toJavaObject(jsonObject, FloorV1.class);
                } else if (Area.TYPE_FLOORV2.equals(areaType)) {
                    return (T) JSON.toJavaObject(jsonObject, FloorV2.class);
                }
                return null;

            

Reported by PMD.

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

Line: 32

                                  return (T) JSON.toJavaObject(jsonObject, Section.class);
                } else if (Area.TYPE_FLOORV1.equals(areaType)) {
                    return (T) JSON.toJavaObject(jsonObject, FloorV1.class);
                } else if (Area.TYPE_FLOORV2.equals(areaType)) {
                    return (T) JSON.toJavaObject(jsonObject, FloorV2.class);
                }
                return null;
            }


            

Reported by PMD.

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

Line: 45

              
        JSONObject jsonObject = JSON.parseObject("{\"type\":\"floorV2\",\"templateId\":\"x123\"}");

        FloorV2 floorV2 = (FloorV2) jsonObject.toJavaObject(Area.class);
        assertNotNull(floorV2);
        assertEquals("x123", floorV2.templateId);
    }

    public interface Area {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 46

                      JSONObject jsonObject = JSON.parseObject("{\"type\":\"floorV2\",\"templateId\":\"x123\"}");

        FloorV2 floorV2 = (FloorV2) jsonObject.toJavaObject(Area.class);
        assertNotNull(floorV2);
        assertEquals("x123", floorV2.templateId);
    }

    public interface Area {
        public static final String TYPE_SECTION = "section";

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 47

              
        FloorV2 floorV2 = (FloorV2) jsonObject.toJavaObject(Area.class);
        assertNotNull(floorV2);
        assertEquals("x123", floorV2.templateId);
    }

    public interface Area {
        public static final String TYPE_SECTION = "section";
        public static final String TYPE_FLOORV1 = "floorV1";

            

Reported by PMD.

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

Line: 63

              
        public String type;

        public String templateId;

        public String getName() {
            return templateId;
        }
    }

            

Reported by PMD.

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

    public void test_namefilter() throws Exception {
        NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    Assert.assertTrue(value instanceof Integer);

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 19

                      NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    Assert.assertTrue(value instanceof Integer);
                    return "ID";
                }

                return name;

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 19

                      NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    Assert.assertTrue(value instanceof Integer);
                    return "ID";
                }

                return name;

            

Reported by PMD.

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

Line: 31

              
        SerializeWriter out = new SerializeWriter();
        JSONSerializer serializer = new JSONSerializer(out);
        serializer.getNameFilters().add(filter);

        Bean a = new Bean();
        serializer.write(a);

        String text = out.toString();

            

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.assertEquals("{\"ID\":0}", text);
    }

    public void test_namefilter_1() throws Exception {
        NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    return "ID";

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 44

                      NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    return "ID";
                }

                return name;
            }

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 44

                      NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    return "ID";
                }

                return name;
            }

            

Reported by PMD.

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

Line: 55

              
        SerializeWriter out = new SerializeWriter();
        JSONSerializer serializer = new JSONSerializer(out);
        serializer.getNameFilters().add(filter);

        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", 0);
        serializer.write(map);


            

Reported by PMD.

Found 'DU'-anomaly for variable 'filter' (lines '16'-'38').
Error

Line: 16

              public class NameFilterTest_int_field extends TestCase {

    public void test_namefilter() throws Exception {
        NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    Assert.assertTrue(value instanceof Integer);
                    return "ID";

            

Reported by PMD.

Found 'DU'-anomaly for variable 'filter' (lines '16'-'38').
Error

Line: 16

              public class NameFilterTest_int_field extends TestCase {

    public void test_namefilter() throws Exception {
        NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    Assert.assertTrue(value instanceof Integer);
                    return "ID";

            

Reported by PMD.

src/test/java/com/alibaba/json/demo/FilterDemo.java
12 issues
System.out.println is used
Design

Line: 46

                      serializer.write(object);

        String outText = out.toString();
        System.out.println(outText);
    }
}

            

Reported by PMD.

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

Line: 13

              
public class FilterDemo extends TestCase {

    public void test_secure() throws Exception {

        ValueFilter filter = new ValueFilter() {

            public Object process(Object source, String name, Object value) {
                if (name.equals("name")) {

            

Reported by PMD.

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

Line: 13

              
public class FilterDemo extends TestCase {

    public void test_secure() throws Exception {

        ValueFilter filter = new ValueFilter() {

            public Object process(Object source, String name, Object value) {
                if (name.equals("name")) {

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 18

                      ValueFilter filter = new ValueFilter() {

            public Object process(Object source, String name, Object value) {
                if (name.equals("name")) {
                    return "WSJ";
                }
                return value;
            }
        };

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 18

                      ValueFilter filter = new ValueFilter() {

            public Object process(Object source, String name, Object value) {
                if (name.equals("name")) {
                    return "WSJ";
                }
                return value;
            }
        };

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 27

              
        NameFilter nameFilter = new NameFilter() {
            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    return "ID";
                }
                return name;
            }
        };

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 27

              
        NameFilter nameFilter = new NameFilter() {
            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    return "ID";
                }
                return name;
            }
        };

            

Reported by PMD.

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

Line: 40

              
        SerializeWriter out = new SerializeWriter();
        JSONSerializer serializer = new JSONSerializer(out);
        serializer.getValueFilters().add(filter);
        serializer.getNameFilters().add(nameFilter);

        serializer.write(object);

        String outText = out.toString();

            

Reported by PMD.

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

Line: 41

                      SerializeWriter out = new SerializeWriter();
        JSONSerializer serializer = new JSONSerializer(out);
        serializer.getValueFilters().add(filter);
        serializer.getNameFilters().add(nameFilter);

        serializer.write(object);

        String outText = out.toString();
        System.out.println(outText);

            

Reported by PMD.

Found 'DU'-anomaly for variable 'filter' (lines '15'-'47').
Error

Line: 15

              
    public void test_secure() throws Exception {

        ValueFilter filter = new ValueFilter() {

            public Object process(Object source, String name, Object value) {
                if (name.equals("name")) {
                    return "WSJ";
                }

            

Reported by PMD.

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

    public void test_namefilter() throws Exception {
        NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    Assert.assertTrue(value instanceof Long);

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 19

                      NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    Assert.assertTrue(value instanceof Long);
                    return "ID";
                }

                return name;

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 19

                      NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    Assert.assertTrue(value instanceof Long);
                    return "ID";
                }

                return name;

            

Reported by PMD.

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

Line: 31

              
        SerializeWriter out = new SerializeWriter();
        JSONSerializer serializer = new JSONSerializer(out);
        serializer.getNameFilters().add(filter);

        Bean a = new Bean();
        serializer.write(a);

        String text = out.toString();

            

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.assertEquals("{\"ID\":0}", text);
    }

    public void test_namefilter_1() throws Exception {
        NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    return "ID";

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 44

                      NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    return "ID";
                }

                return name;
            }

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 44

                      NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    return "ID";
                }

                return name;
            }

            

Reported by PMD.

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

Line: 55

              
        SerializeWriter out = new SerializeWriter();
        JSONSerializer serializer = new JSONSerializer(out);
        serializer.getNameFilters().add(filter);

        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", 0);
        serializer.write(map);


            

Reported by PMD.

Found 'DU'-anomaly for variable 'filter' (lines '16'-'38').
Error

Line: 16

              public class NameFilterTest_long_field extends TestCase {

    public void test_namefilter() throws Exception {
        NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    Assert.assertTrue(value instanceof Long);
                    return "ID";

            

Reported by PMD.

Found 'DU'-anomaly for variable 'filter' (lines '16'-'38').
Error

Line: 16

              public class NameFilterTest_long_field extends TestCase {

    public void test_namefilter() throws Exception {
        NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("id")) {
                    Assert.assertTrue(value instanceof Long);
                    return "ID";

            

Reported by PMD.

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

Line: 7

              import junit.framework.TestCase;

public class Issue3343 extends TestCase {
    public void test_for_issue() throws Exception {
        assertFalse(
                JSONValidator.from("{\"name\":\"999}")
                        .validate());

        assertTrue(

            

Reported by PMD.

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

Line: 7

              import junit.framework.TestCase;

public class Issue3343 extends TestCase {
    public void test_for_issue() throws Exception {
        assertFalse(
                JSONValidator.from("{\"name\":\"999}")
                        .validate());

        assertTrue(

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 8

              
public class Issue3343 extends TestCase {
    public void test_for_issue() throws Exception {
        assertFalse(
                JSONValidator.from("{\"name\":\"999}")
                        .validate());

        assertTrue(
                JSONValidator.from("false")

            

Reported by PMD.

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

Line: 9

              public class Issue3343 extends TestCase {
    public void test_for_issue() throws Exception {
        assertFalse(
                JSONValidator.from("{\"name\":\"999}")
                        .validate());

        assertTrue(
                JSONValidator.from("false")
                        .validate());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 12

                              JSONValidator.from("{\"name\":\"999}")
                        .validate());

        assertTrue(
                JSONValidator.from("false")
                        .validate());
        assertEquals(JSONValidator.Type.Value,
                JSONValidator.from("false")
                        .getType());

            

Reported by PMD.

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

Line: 13

                                      .validate());

        assertTrue(
                JSONValidator.from("false")
                        .validate());
        assertEquals(JSONValidator.Type.Value,
                JSONValidator.from("false")
                        .getType());


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 15

                      assertTrue(
                JSONValidator.from("false")
                        .validate());
        assertEquals(JSONValidator.Type.Value,
                JSONValidator.from("false")
                        .getType());

        assertTrue(
                JSONValidator.from("999").validate());

            

Reported by PMD.

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

Line: 16

                              JSONValidator.from("false")
                        .validate());
        assertEquals(JSONValidator.Type.Value,
                JSONValidator.from("false")
                        .getType());

        assertTrue(
                JSONValidator.from("999").validate());
        assertEquals(JSONValidator.Type.Value,

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

                              JSONValidator.from("false")
                        .getType());

        assertTrue(
                JSONValidator.from("999").validate());
        assertEquals(JSONValidator.Type.Value,
                JSONValidator.from("999")
                        .getType());
    }

            

Reported by PMD.

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

Line: 20

                                      .getType());

        assertTrue(
                JSONValidator.from("999").validate());
        assertEquals(JSONValidator.Type.Value,
                JSONValidator.from("999")
                        .getType());
    }
}

            

Reported by PMD.