The following issues were found

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

Line: 10

              import java.util.Queue;

public class Issue2251 extends TestCase {
    public void test_for_issue() throws Exception {
        Model m = new Model();
        m.queue = new LinkedList();
        m.queue.add(1);
        m.queue.add(2);


            

Reported by PMD.

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

Line: 13

                  public void test_for_issue() throws Exception {
        Model m = new Model();
        m.queue = new LinkedList();
        m.queue.add(1);
        m.queue.add(2);

        String str = JSON.toJSONString(m);
        Model m2 = JSON.parseObject(str, Model.class);
        assertNotNull(m2.queue);

            

Reported by PMD.

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

Line: 14

                      Model m = new Model();
        m.queue = new LinkedList();
        m.queue.add(1);
        m.queue.add(2);

        String str = JSON.toJSONString(m);
        Model m2 = JSON.parseObject(str, Model.class);
        assertNotNull(m2.queue);
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

              
        String str = JSON.toJSONString(m);
        Model m2 = JSON.parseObject(str, Model.class);
        assertNotNull(m2.queue);
    }

    public static class Model {
        public Queue queue;
    }

            

Reported by PMD.

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

Line: 22

                  }

    public static class Model {
        public Queue queue;
    }
}

            

Reported by PMD.

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

Line: 12

               * Created by wenshao on 17/03/2017.
 */
public class Issue1080 extends TestCase {
    public void test_for_issue() throws Exception {
        java.util.Date date = JSON.parseObject("\"2017-3-17 00:00:01\"", java.util.Date.class);
        String json = JSON.toJSONStringWithDateFormat(date, "yyyy-MM-dd");
        assertEquals("\"2017-03-17\"", json);
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 15

                  public void test_for_issue() throws Exception {
        java.util.Date date = JSON.parseObject("\"2017-3-17 00:00:01\"", java.util.Date.class);
        String json = JSON.toJSONStringWithDateFormat(date, "yyyy-MM-dd");
        assertEquals("\"2017-03-17\"", json);
    }

    public void test_for_issue_2() throws Exception {
        java.util.Date date = JSON.parseObject("\"2017-3-7 00:00:01\"", java.util.Date.class);
        String json = JSON.toJSONStringWithDateFormat(date, "yyyy-MM-dd");

            

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

                      assertEquals("\"2017-03-17\"", json);
    }

    public void test_for_issue_2() throws Exception {
        java.util.Date date = JSON.parseObject("\"2017-3-7 00:00:01\"", java.util.Date.class);
        String json = JSON.toJSONStringWithDateFormat(date, "yyyy-MM-dd");
        assertEquals("\"2017-03-07\"", json);
    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 21

                  public void test_for_issue_2() throws Exception {
        java.util.Date date = JSON.parseObject("\"2017-3-7 00:00:01\"", java.util.Date.class);
        String json = JSON.toJSONStringWithDateFormat(date, "yyyy-MM-dd");
        assertEquals("\"2017-03-07\"", json);
    }
}

            

Reported by PMD.

Avoid unused imports such as 'java.sql.Date'
Design

Line: 6

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

import java.sql.Date;

/**
 * Created by wenshao on 17/03/2017.
 */
public class Issue1080 extends TestCase {

            

Reported by PMD.

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

Line: 12

               * Created by wenshao on 20/03/2017.
 */
public class Issue1085 extends TestCase {
    public void test_for_issue() throws Exception {
        Model model = (Model) JSON.parseObject("{\"id\":123}", AbstractModel.class);
        assertEquals(123, model.id);
    }

    public static abstract class AbstractModel {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 14

              public class Issue1085 extends TestCase {
    public void test_for_issue() throws Exception {
        Model model = (Model) JSON.parseObject("{\"id\":123}", AbstractModel.class);
        assertEquals(123, model.id);
    }

    public static abstract class AbstractModel {
        public int id;


            

Reported by PMD.

This abstract class does not have any abstract methods
Design

Line: 17

                      assertEquals(123, model.id);
    }

    public static abstract class AbstractModel {
        public int id;

        @JSONCreator
        public static AbstractModel createInstance() {
            return new Model();

            

Reported by PMD.

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

Line: 18

                  }

    public static abstract class AbstractModel {
        public int id;

        @JSONCreator
        public static AbstractModel createInstance() {
            return new Model();
        }

            

Reported by PMD.

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

Line: 5

              
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONCreator;
import com.alibaba.fastjson.annotation.JSONType;
import junit.framework.TestCase;

/**
 * Created by wenshao on 20/03/2017.
 */

            

Reported by PMD.

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

Line: 13

              
public class JSONScannerTest_isEOF extends TestCase {

    public void test_0() throws Exception {
        String text = "{}  ";
        JSONObject obj = JSON.parseObject(text);
        Assert.assertEquals(0, obj.size());
    }


            

Reported by PMD.

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

Line: 16

                  public void test_0() throws Exception {
        String text = "{}  ";
        JSONObject obj = JSON.parseObject(text);
        Assert.assertEquals(0, obj.size());
    }

    public void test_1() throws Exception {
        JSONScanner lexer = new JSONScanner("  ");
        lexer.nextToken();

            

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

                      Assert.assertEquals(0, obj.size());
    }

    public void test_1() throws Exception {
        JSONScanner lexer = new JSONScanner("  ");
        lexer.nextToken();
        Assert.assertTrue(lexer.token() == JSONToken.EOF);
    }


            

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.assertTrue(lexer.token() == JSONToken.EOF);
    }

    public void test_2() throws Exception {
        JSONScanner lexer = new JSONScanner("1  ");
        lexer.nextToken();
        lexer.nextToken();
        Assert.assertTrue(lexer.token() == JSONToken.EOF);
    }

            

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

                      Assert.assertTrue(lexer.token() == JSONToken.EOF);
    }

    public void test_3() throws Exception {
        JSONScanner lexer = new JSONScanner(" {}");
        lexer.nextToken();
        Assert.assertTrue(lexer.token() != JSONToken.EOF);
    }


            

Reported by PMD.

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

Line: 18

                      result.b = Optional.empty();

        String json = JSON.toJSONString(result);
        System.out.println(json);
    }

    public static class JsonResult {
        public Object a;
        public Optional<Object> b;

            

Reported by PMD.

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

Line: 12

               * Created by wenshao on 02/04/2017.
 */
public class OptionalTest4 extends TestCase {
    public void test_for_issue() throws Exception {
        JsonResult result = new JsonResult();
        result.a = Optional.empty();
        result.b = Optional.empty();

        String json = JSON.toJSONString(result);

            

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

               * Created by wenshao on 02/04/2017.
 */
public class OptionalTest4 extends TestCase {
    public void test_for_issue() throws Exception {
        JsonResult result = new JsonResult();
        result.a = Optional.empty();
        result.b = Optional.empty();

        String json = JSON.toJSONString(result);

            

Reported by PMD.

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

Line: 22

                  }

    public static class JsonResult {
        public Object a;
        public Optional<Object> b;
    }
}

            

Reported by PMD.

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

Line: 23

              
    public static class JsonResult {
        public Object a;
        public Optional<Object> b;
    }
}

            

Reported by PMD.

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

Line: 8

              import junit.framework.TestCase;

public class Issue1465 extends TestCase {
    public void test_for_issue() throws Exception {
        String json = "{\"id\":3,\"hasSth\":true}";
        Model model = JSON.parseObject(json, Model.class);
        assertEquals(0, model.hasSth);
        assertEquals(3, model.id);
    }

            

Reported by PMD.

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

Line: 8

              import junit.framework.TestCase;

public class Issue1465 extends TestCase {
    public void test_for_issue() throws Exception {
        String json = "{\"id\":3,\"hasSth\":true}";
        Model model = JSON.parseObject(json, Model.class);
        assertEquals(0, model.hasSth);
        assertEquals(3, model.id);
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 11

                  public void test_for_issue() throws Exception {
        String json = "{\"id\":3,\"hasSth\":true}";
        Model model = JSON.parseObject(json, Model.class);
        assertEquals(0, model.hasSth);
        assertEquals(3, model.id);
    }

    public static class Model {
        private int id;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 12

                      String json = "{\"id\":3,\"hasSth\":true}";
        Model model = JSON.parseObject(json, Model.class);
        assertEquals(0, model.hasSth);
        assertEquals(3, model.id);
    }

    public static class Model {
        private int id;
        @JSONField(deserialize = false)

            

Reported by PMD.

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

Line: 15

                      assertEquals(3, model.id);
    }

    public static class Model {
        private int id;
        @JSONField(deserialize = false)
        private int hasSth;

        public int getHasSth() {

            

Reported by PMD.

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

Line: 14

              
public class NamingSerTest extends TestCase {

    public void test_snake() throws Exception {
        SerializeConfig config = new SerializeConfig();
        config.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase;

        Model model = new Model();
        model.personId = 1001;

            

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

                      Assert.assertEquals(model.personId, model3.personId);
    }

    public void test_kebab() throws Exception {
        SerializeConfig config = new SerializeConfig();
        config.propertyNamingStrategy = PropertyNamingStrategy.KebabCase;

        Model model = new Model();
        model.personId = 1001;

            

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

                      Assert.assertEquals(model.personId, model3.personId);
    }

    public void test_pascal() throws Exception {
        SerializeConfig config = new SerializeConfig();
        config.propertyNamingStrategy = PropertyNamingStrategy.PascalCase;

        Model model = new Model();
        model.personId = 1001;

            

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

                      Assert.assertEquals(model.personId, model3.personId);
    }

    public void test_camel() throws Exception {
        SerializeConfig config = new SerializeConfig();
        config.propertyNamingStrategy = PropertyNamingStrategy.CamelCase;

        Model model = new Model();
        model.personId = 1001;

            

Reported by PMD.

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

Line: 88

              
    public static class Model {

        public int personId;
    }
}

            

Reported by PMD.

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

Line: 17

                      List<Value> parseObject = JSON.parseObject(json, new TypeReference<List<Value>>() {
        });
        for (Value value : parseObject) {
            System.out.println(value.songList + "  " );
        }
    }

    public static class Value {
        @JSONField(alternateNames = {"song_list", "songList"})

            

Reported by PMD.

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

Line: 11

              import java.util.List;

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

        String json = "[{\"song_list\":[{\"val\":1,\"v_al\":2},{\"val\":2,\"v_al\":2},{\"val\":3,\"v_al\":2}],\"songlist\":\"v_al\"}]";
        List<Value> parseObject = JSON.parseObject(json, new TypeReference<List<Value>>() {
        });
        for (Value value : parseObject) {

            

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 Issue1486 extends TestCase {
    public void test_for_issue() throws Exception {

        String json = "[{\"song_list\":[{\"val\":1,\"v_al\":2},{\"val\":2,\"v_al\":2},{\"val\":3,\"v_al\":2}],\"songlist\":\"v_al\"}]";
        List<Value> parseObject = JSON.parseObject(json, new TypeReference<List<Value>>() {
        });
        for (Value value : parseObject) {

            

Reported by PMD.

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

Line: 21

                      }
    }

    public static class Value {
        @JSONField(alternateNames = {"song_list", "songList"})
        List<Value2> songList;

        @JSONField(alternateNames = {"songlist"})
        String songlist;

            

Reported by PMD.

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

Line: 45

                      }
    }

    public static class Value2 {
        int val;

        int v_al;

        public int getVal() {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/mixins/MixinDeserForClassTest.java
5 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 13

              public class MixinDeserForClassTest extends TestCase {
    static class BaseClass {
        @JSONField( deserialize = true )
        public String a;

        @JSONField( deserialize = false, name = "a" )
        public void setA( String v ) {
            a = "XXX" + v;
        }

            

Reported by PMD.

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

Line: 23

              
    static class BaseClass1 {
        @JSONField( deserialize = false )
        public String a;

        @JSONField( deserialize = true, name = "a" )
        public void setA( String v ) {
            a = "XXX" + v;
        }

            

Reported by PMD.

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

Line: 33

              
    static class Mixin {
        @JSONField( deserialize = false )
        public String a;

        @JSONField( deserialize = true, name = "a" )
        public void setA( String v ) {
        }
    }

            

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

                      }
    }

    public void test_1() throws Exception {
        BaseClass1 base = JSON.parseObject( "{\"a\":\"132\"}", BaseClass1.class );
        Assert.assertEquals( "XXX132", base.a );
    }

    public void test_2() 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.assertEquals( "XXX132", base.a );
    }

    public void test_2() throws Exception {
        JSON.addMixInAnnotations(BaseClass.class, Mixin.class);
        BaseClass base = JSON.parseObject( "{\"a\":\"132\"}", BaseClass.class );
        Assert.assertEquals( "XXX132", base.a );
        JSON.removeMixInAnnotations(BaseClass.class);
    }

            

Reported by PMD.

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

Line: 15

              {
    public void test2721() {
        String chineseKeyString = "[{\"名称\": \"脆皮青豆\", \"配料\": [\"豌豆\", \"棕榈油\", \"白砂糖\", \"食用盐\", \"玉米淀粉\"]}]";
        System.out.println(JSONPath.read(chineseKeyString, "$[名称 = '脆皮青豆']"));
        // [{"名称":"脆皮青豆","配料":["豌豆","棕榈油","白砂糖","食用盐","玉米淀粉"]}]

        String normalKeyString = "[{ \"name\": \"脆皮青豆\", \"配料\": [\"豌豆\", \"棕榈油\", \"白砂糖\", \"食用盐\", \"玉米淀粉\"] }]";
        System.out.println(JSONPath.read(normalKeyString, "$[name = '脆皮青豆']"));
        // [{"name":"脆皮青豆","配料":["豌豆","棕榈油","白砂糖","食用盐","玉米淀粉"]}]

            

Reported by PMD.

System.out.println is used
Design

Line: 19

                      // [{"名称":"脆皮青豆","配料":["豌豆","棕榈油","白砂糖","食用盐","玉米淀粉"]}]

        String normalKeyString = "[{ \"name\": \"脆皮青豆\", \"配料\": [\"豌豆\", \"棕榈油\", \"白砂糖\", \"食用盐\", \"玉米淀粉\"] }]";
        System.out.println(JSONPath.read(normalKeyString, "$[name = '脆皮青豆']"));
        // [{"name":"脆皮青豆","配料":["豌豆","棕榈油","白砂糖","食用盐","玉米淀粉"]}]
//
        Assert.assertFalse("Chinese Key is NOT OK, Array length is 0!", ((List) JSONPath.read(chineseKeyString, "$[名称 = '脆皮青豆']")).isEmpty());
        Assert.assertFalse("Chinese Key is NOT OK, Array length is 0!", ((List) JSONPath.read(normalKeyString, "$[name = '脆皮青豆']")).isEmpty());
    }

            

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 Issue2721Test extends TestCase
{
    public void test2721() {
        String chineseKeyString = "[{\"名称\": \"脆皮青豆\", \"配料\": [\"豌豆\", \"棕榈油\", \"白砂糖\", \"食用盐\", \"玉米淀粉\"]}]";
        System.out.println(JSONPath.read(chineseKeyString, "$[名称 = '脆皮青豆']"));
        // [{"名称":"脆皮青豆","配料":["豌豆","棕榈油","白砂糖","食用盐","玉米淀粉"]}]

        String normalKeyString = "[{ \"name\": \"脆皮青豆\", \"配料\": [\"豌豆\", \"棕榈油\", \"白砂糖\", \"食用盐\", \"玉米淀粉\"] }]";

            

Reported by PMD.

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

Line: 3

              package com.alibaba.json.bvt.issue_2700;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONPath;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;

import java.util.List;

            

Reported by PMD.

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

Line: 7

              import com.alibaba.fastjson.JSONPath;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;

import java.util.List;

public class Issue2721Test extends TestCase
{

            

Reported by PMD.