The following issues were found

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

Line: 32

                      user.setGmtModified(new java.sql.Timestamp(new Date().getTime()));
        String userJSON = JSON.toJSONString(user, SerializerFeature.WriteClassName, SerializerFeature.WriteMapNullValue);

        System.out.println(userJSON);

        User returnUser = (User) JSON.parse(userJSON);

    }


            

Reported by PMD.

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

Line: 15

              import junit.framework.TestCase;

public class Bug_for_lenolix_7 extends TestCase {
    protected void setUp() throws Exception {
        JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
        JSON.defaultLocale = Locale.CHINA;

        ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Bug_for_lenolix_7");
    }

            

Reported by PMD.

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

Line: 19

                      JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
        JSON.defaultLocale = Locale.CHINA;

        ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Bug_for_lenolix_7");
    }
    
    public void test_for_objectKey() throws Exception {
        User user = new User();
        user.setId(1);

            

Reported by PMD.

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

Line: 22

                      ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Bug_for_lenolix_7");
    }
    
    public void test_for_objectKey() throws Exception {
        User user = new User();
        user.setId(1);
        user.setName("leno.lix");
        user.setIsBoy(true);
        user.setBirthDay(new Date());

            

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

                      ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Bug_for_lenolix_7");
    }
    
    public void test_for_objectKey() throws Exception {
        User user = new User();
        user.setId(1);
        user.setName("leno.lix");
        user.setIsBoy(true);
        user.setBirthDay(new Date());

            

Reported by PMD.

Avoid unused local variables such as 'returnUser'.
Design

Line: 34

              
        System.out.println(userJSON);

        User returnUser = (User) JSON.parse(userJSON);

    }

    private static class User implements Serializable {


            

Reported by PMD.

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

Line: 38

              
    }

    private static class User implements Serializable {

        /**
             *
             */


            

Reported by PMD.

Found 'DU'-anomaly for variable 'returnUser' (lines '34'-'36').
Error

Line: 34

              
        System.out.println(userJSON);

        User returnUser = (User) JSON.parse(userJSON);

    }

    private static class User implements Serializable {


            

Reported by PMD.

src/main/java/com/alibaba/fastjson/parser/deserializer/JSONPDeserializer.java
8 issues
Potential violation of Law of Demeter (object not created locally)
Design

Line: 20

              
        SymbolTable symbolTable = parser.getSymbolTable();

        String funcName = lexer.scanSymbolUnQuoted(symbolTable);
        lexer.nextToken();

        int tok = lexer.token();

        if (tok == JSONToken.DOT) {

            

Reported by PMD.

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

Line: 21

                      SymbolTable symbolTable = parser.getSymbolTable();

        String funcName = lexer.scanSymbolUnQuoted(symbolTable);
        lexer.nextToken();

        int tok = lexer.token();

        if (tok == JSONToken.DOT) {
            String name = lexer.scanSymbolUnQuoted(parser.getSymbolTable());

            

Reported by PMD.

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

Line: 23

                      String funcName = lexer.scanSymbolUnQuoted(symbolTable);
        lexer.nextToken();

        int tok = lexer.token();

        if (tok == JSONToken.DOT) {
            String name = lexer.scanSymbolUnQuoted(parser.getSymbolTable());
            funcName += ".";
            funcName += name;

            

Reported by PMD.

Prefer StringBuilder (non-synchronized) or StringBuffer (synchronized) over += for concatenating strings
Performance

Line: 28

                      if (tok == JSONToken.DOT) {
            String name = lexer.scanSymbolUnQuoted(parser.getSymbolTable());
            funcName += ".";
            funcName += name;
            lexer.nextToken();
            tok = lexer.token();
        }

        JSONPObject jsonp = new JSONPObject(funcName);

            

Reported by PMD.

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

Line: 38

                      if (tok != JSONToken.LPAREN) {
            throw new JSONException("illegal jsonp : " + lexer.info());
        }
        lexer.nextToken();
        for (;;) {
            Object arg = parser.parse();
            jsonp.addParameter(arg);

            tok = lexer.token();

            

Reported by PMD.

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

Line: 53

                              throw new JSONException("illegal jsonp : " + lexer.info());
            }
         }
        tok = lexer.token();
        if (tok == JSONToken.SEMI) {
            lexer.nextToken();
        }

        return (T) jsonp;

            

Reported by PMD.

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

Line: 5

              
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONPObject;
import com.alibaba.fastjson.parser.*;

import java.lang.reflect.Type;

/**
 * Created by wenshao on 21/02/2017.

            

Reported by PMD.

Found 'DU'-anomaly for variable 'jsonp' (lines '33'-'59').
Error

Line: 33

                          tok = lexer.token();
        }

        JSONPObject jsonp = new JSONPObject(funcName);

        if (tok != JSONToken.LPAREN) {
            throw new JSONException("illegal jsonp : " + lexer.info());
        }
        lexer.nextToken();

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Bug_for_xiedun.java
8 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 java.io.FileReader;

public class Bug_for_xiedun extends TestCase {
    public void test_for_issue() throws Exception {
//        File file = new File("/Users/wenshao/Downloads/json.txt");
//
//        BufferedReader reader = new BufferedReader(new FileReader(file));
//        char[] buf = new char[20480];
//        int readed = reader.read(buf);

            

Reported by PMD.

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

Line: 13

              import java.io.FileReader;

public class Bug_for_xiedun extends TestCase {
    public void test_for_issue() throws Exception {
//        File file = new File("/Users/wenshao/Downloads/json.txt");
//
//        BufferedReader reader = new BufferedReader(new FileReader(file));
//        char[] buf = new char[20480];
//        int readed = reader.read(buf);

            

Reported by PMD.

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

Line: 3

              package com.alibaba.json.bvt.bug;

import com.alibaba.fastjson.JSON;
import junit.framework.TestCase;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;

import java.io.BufferedReader;
import java.io.File;

            

Reported by PMD.

Avoid unused imports such as 'org.apache.commons.io.FileUtils'
Design

Line: 5

              
import com.alibaba.fastjson.JSON;
import junit.framework.TestCase;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;

            

Reported by PMD.

Avoid unused imports such as 'org.apache.commons.io.IOUtils'
Design

Line: 6

              import com.alibaba.fastjson.JSON;
import junit.framework.TestCase;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;


            

Reported by PMD.

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

Line: 8

              import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;

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

            

Reported by PMD.

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

Line: 9

              import org.apache.commons.io.IOUtils;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;

public class Bug_for_xiedun extends TestCase {
    public void test_for_issue() throws Exception {
//        File file = new File("/Users/wenshao/Downloads/json.txt");

            

Reported by PMD.

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

Line: 10

              
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;

public class Bug_for_xiedun extends TestCase {
    public void test_for_issue() throws Exception {
//        File file = new File("/Users/wenshao/Downloads/json.txt");
//

            

Reported by PMD.

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

Line: 14

              public class Bug_for_xujin_int extends TestCase {
    public void test_for_xujin() throws Exception {
        String jsonText="{\"module\":{\"auditStatus\":\"PENDING_VERIFICATION\",\"contactId\":\"asdfasdf\",\n\"errorMsg\":\"中国\"},\"success\":1}\n";
        System.out.println(JSON.VERSION);
        ResultDTO resultDTO = (ResultDTO) JSON.parseObject(jsonText, ResultDTO.class);
    }

    public static class ResultDTO<T extends Serializable> implements Serializable {
        private static final long serialVersionUID = 3682481175041925854L;

            

Reported by PMD.

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

Line: 12

               * Created by wenshao on 09/02/2017.
 */
public class Bug_for_xujin_int extends TestCase {
    public void test_for_xujin() throws Exception {
        String jsonText="{\"module\":{\"auditStatus\":\"PENDING_VERIFICATION\",\"contactId\":\"asdfasdf\",\n\"errorMsg\":\"中国\"},\"success\":1}\n";
        System.out.println(JSON.VERSION);
        ResultDTO resultDTO = (ResultDTO) JSON.parseObject(jsonText, ResultDTO.class);
    }


            

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 09/02/2017.
 */
public class Bug_for_xujin_int extends TestCase {
    public void test_for_xujin() throws Exception {
        String jsonText="{\"module\":{\"auditStatus\":\"PENDING_VERIFICATION\",\"contactId\":\"asdfasdf\",\n\"errorMsg\":\"中国\"},\"success\":1}\n";
        System.out.println(JSON.VERSION);
        ResultDTO resultDTO = (ResultDTO) JSON.parseObject(jsonText, ResultDTO.class);
    }


            

Reported by PMD.

Avoid unused local variables such as 'resultDTO'.
Design

Line: 15

                  public void test_for_xujin() throws Exception {
        String jsonText="{\"module\":{\"auditStatus\":\"PENDING_VERIFICATION\",\"contactId\":\"asdfasdf\",\n\"errorMsg\":\"中国\"},\"success\":1}\n";
        System.out.println(JSON.VERSION);
        ResultDTO resultDTO = (ResultDTO) JSON.parseObject(jsonText, ResultDTO.class);
    }

    public static class ResultDTO<T extends Serializable> implements Serializable {
        private static final long serialVersionUID = 3682481175041925854L;
        private static final String DEFAULT_ERR_CODE = "xin.unknown.error";

            

Reported by PMD.

The class 'ResultDTO' is suspected to be a Data Class (WOC=23.077%, NOPA=0, NOAM=8, WMC=13)
Design

Line: 18

                      ResultDTO resultDTO = (ResultDTO) JSON.parseObject(jsonText, ResultDTO.class);
    }

    public static class ResultDTO<T extends Serializable> implements Serializable {
        private static final long serialVersionUID = 3682481175041925854L;
        private static final String DEFAULT_ERR_CODE = "xin.unknown.error";
        private String errorMsg;
        private String errorCode;
        private int success;

            

Reported by PMD.

Avoid unused private fields such as 'DEFAULT_ERR_CODE'.
Design

Line: 20

              
    public static class ResultDTO<T extends Serializable> implements Serializable {
        private static final long serialVersionUID = 3682481175041925854L;
        private static final String DEFAULT_ERR_CODE = "xin.unknown.error";
        private String errorMsg;
        private String errorCode;
        private int success;
        private T module;


            

Reported by PMD.

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

Line: 23

                      private static final String DEFAULT_ERR_CODE = "xin.unknown.error";
        private String errorMsg;
        private String errorCode;
        private int success;
        private T module;



        public ResultDTO() {

            

Reported by PMD.

Found 'DU'-anomaly for variable 'resultDTO' (lines '15'-'16').
Error

Line: 15

                  public void test_for_xujin() throws Exception {
        String jsonText="{\"module\":{\"auditStatus\":\"PENDING_VERIFICATION\",\"contactId\":\"asdfasdf\",\n\"errorMsg\":\"中国\"},\"success\":1}\n";
        System.out.println(JSON.VERSION);
        ResultDTO resultDTO = (ResultDTO) JSON.parseObject(jsonText, ResultDTO.class);
    }

    public static class ResultDTO<T extends Serializable> implements Serializable {
        private static final long serialVersionUID = 3682481175041925854L;
        private static final String DEFAULT_ERR_CODE = "xin.unknown.error";

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Bug_for_yanpei.java
8 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 junit.framework.TestCase;

public class Bug_for_yanpei extends TestCase {
    public void test_for_sepcial_chars() throws Exception {
        String text = "{\"answerAllow\":true,\"atUsers\":[],\"desc\":\"Halios 1000M \\\"Puck\\\"很微众的品牌,几乎全靠玩家口口相传\"} ";
        JSONObject obj = JSON.parseObject(text);
        Assert.assertEquals(true, obj.get("answerAllow"));;
        Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
        Assert.assertEquals("Halios 1000M \"Puck\"很微众的品牌,几乎全靠玩家口口相传", obj.get("desc"));;

            

Reported by PMD.

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

Line: 14

                  public void test_for_sepcial_chars() throws Exception {
        String text = "{\"answerAllow\":true,\"atUsers\":[],\"desc\":\"Halios 1000M \\\"Puck\\\"很微众的品牌,几乎全靠玩家口口相传\"} ";
        JSONObject obj = JSON.parseObject(text);
        Assert.assertEquals(true, obj.get("answerAllow"));;
        Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
        Assert.assertEquals("Halios 1000M \"Puck\"很微众的品牌,几乎全靠玩家口口相传", obj.get("desc"));;
    }
}

            

Reported by PMD.

An empty statement (semicolon) not part of a loop
Error

Line: 14

                  public void test_for_sepcial_chars() throws Exception {
        String text = "{\"answerAllow\":true,\"atUsers\":[],\"desc\":\"Halios 1000M \\\"Puck\\\"很微众的品牌,几乎全靠玩家口口相传\"} ";
        JSONObject obj = JSON.parseObject(text);
        Assert.assertEquals(true, obj.get("answerAllow"));;
        Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
        Assert.assertEquals("Halios 1000M \"Puck\"很微众的品牌,几乎全靠玩家口口相传", obj.get("desc"));;
    }
}

            

Reported by PMD.

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

Line: 15

                      String text = "{\"answerAllow\":true,\"atUsers\":[],\"desc\":\"Halios 1000M \\\"Puck\\\"很微众的品牌,几乎全靠玩家口口相传\"} ";
        JSONObject obj = JSON.parseObject(text);
        Assert.assertEquals(true, obj.get("answerAllow"));;
        Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
        Assert.assertEquals("Halios 1000M \"Puck\"很微众的品牌,几乎全靠玩家口口相传", obj.get("desc"));;
    }
}

            

Reported by PMD.

An empty statement (semicolon) not part of a loop
Error

Line: 15

                      String text = "{\"answerAllow\":true,\"atUsers\":[],\"desc\":\"Halios 1000M \\\"Puck\\\"很微众的品牌,几乎全靠玩家口口相传\"} ";
        JSONObject obj = JSON.parseObject(text);
        Assert.assertEquals(true, obj.get("answerAllow"));;
        Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
        Assert.assertEquals("Halios 1000M \"Puck\"很微众的品牌,几乎全靠玩家口口相传", obj.get("desc"));;
    }
}

            

Reported by PMD.

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

Line: 15

                      String text = "{\"answerAllow\":true,\"atUsers\":[],\"desc\":\"Halios 1000M \\\"Puck\\\"很微众的品牌,几乎全靠玩家口口相传\"} ";
        JSONObject obj = JSON.parseObject(text);
        Assert.assertEquals(true, obj.get("answerAllow"));;
        Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
        Assert.assertEquals("Halios 1000M \"Puck\"很微众的品牌,几乎全靠玩家口口相传", obj.get("desc"));;
    }
}

            

Reported by PMD.

An empty statement (semicolon) not part of a loop
Error

Line: 16

                      JSONObject obj = JSON.parseObject(text);
        Assert.assertEquals(true, obj.get("answerAllow"));;
        Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
        Assert.assertEquals("Halios 1000M \"Puck\"很微众的品牌,几乎全靠玩家口口相传", obj.get("desc"));;
    }
}

            

Reported by PMD.

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

Line: 16

                      JSONObject obj = JSON.parseObject(text);
        Assert.assertEquals(true, obj.get("answerAllow"));;
        Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
        Assert.assertEquals("Halios 1000M \"Puck\"很微众的品牌,几乎全靠玩家口口相传", obj.get("desc"));;
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Bug_for_yanpei2.java
8 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 junit.framework.TestCase;

public class Bug_for_yanpei2 extends TestCase {
    public void test_for_sepcial_chars() throws Exception {
        String text = "{\"answerAllow\":true,\"atUsers\":[],\"desc\":\"测试账号\\n测试账号\"}";
        JSONObject obj = JSON.parseObject(text);
        Assert.assertEquals(true, obj.get("answerAllow"));;
        Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
        Assert.assertEquals("测试账号\n测试账号", obj.get("desc"));;

            

Reported by PMD.

An empty statement (semicolon) not part of a loop
Error

Line: 14

                  public void test_for_sepcial_chars() throws Exception {
        String text = "{\"answerAllow\":true,\"atUsers\":[],\"desc\":\"测试账号\\n测试账号\"}";
        JSONObject obj = JSON.parseObject(text);
        Assert.assertEquals(true, obj.get("answerAllow"));;
        Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
        Assert.assertEquals("测试账号\n测试账号", obj.get("desc"));;
    }
}

            

Reported by PMD.

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

Line: 14

                  public void test_for_sepcial_chars() throws Exception {
        String text = "{\"answerAllow\":true,\"atUsers\":[],\"desc\":\"测试账号\\n测试账号\"}";
        JSONObject obj = JSON.parseObject(text);
        Assert.assertEquals(true, obj.get("answerAllow"));;
        Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
        Assert.assertEquals("测试账号\n测试账号", obj.get("desc"));;
    }
}

            

Reported by PMD.

An empty statement (semicolon) not part of a loop
Error

Line: 15

                      String text = "{\"answerAllow\":true,\"atUsers\":[],\"desc\":\"测试账号\\n测试账号\"}";
        JSONObject obj = JSON.parseObject(text);
        Assert.assertEquals(true, obj.get("answerAllow"));;
        Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
        Assert.assertEquals("测试账号\n测试账号", obj.get("desc"));;
    }
}

            

Reported by PMD.

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

Line: 15

                      String text = "{\"answerAllow\":true,\"atUsers\":[],\"desc\":\"测试账号\\n测试账号\"}";
        JSONObject obj = JSON.parseObject(text);
        Assert.assertEquals(true, obj.get("answerAllow"));;
        Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
        Assert.assertEquals("测试账号\n测试账号", obj.get("desc"));;
    }
}

            

Reported by PMD.

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

Line: 15

                      String text = "{\"answerAllow\":true,\"atUsers\":[],\"desc\":\"测试账号\\n测试账号\"}";
        JSONObject obj = JSON.parseObject(text);
        Assert.assertEquals(true, obj.get("answerAllow"));;
        Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
        Assert.assertEquals("测试账号\n测试账号", obj.get("desc"));;
    }
}

            

Reported by PMD.

An empty statement (semicolon) not part of a loop
Error

Line: 16

                      JSONObject obj = JSON.parseObject(text);
        Assert.assertEquals(true, obj.get("answerAllow"));;
        Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
        Assert.assertEquals("测试账号\n测试账号", obj.get("desc"));;
    }
}

            

Reported by PMD.

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

Line: 16

                      JSONObject obj = JSON.parseObject(text);
        Assert.assertEquals(true, obj.get("answerAllow"));;
        Assert.assertEquals(0, obj.getJSONArray("atUsers").size());;
        Assert.assertEquals("测试账号\n测试账号", obj.get("desc"));;
    }
}

            

Reported by PMD.

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

    public void test_0() throws Exception {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("currency", "CNY");

        String text = JSON.toJSONString(jsonObject);


            

Reported by PMD.

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

Line: 16

              
    public void test_0() throws Exception {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("currency", "CNY");

        String text = JSON.toJSONString(jsonObject);

        Currency currency = JSON.parseObject(text, Currency.class);


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 22

              
        Currency currency = JSON.parseObject(text, Currency.class);

        assertSame(Currency.getInstance("CNY"), currency);
    }

    public void test_1() throws Exception {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("currencyCode", "CNY");

            

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

                      assertSame(Currency.getInstance("CNY"), currency);
    }

    public void test_1() throws Exception {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("currencyCode", "CNY");

        String text = JSON.toJSONString(jsonObject);


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 33

              
        Currency currency = JSON.parseObject(text, Currency.class);

        assertSame(Currency.getInstance("CNY"), currency);
    }

    public static class VO {
        public Currency value;


            

Reported by PMD.

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

Line: 5

              
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import junit.framework.TestCase;

import java.util.Currency;
import java.util.Locale;

            

Reported by PMD.

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

Line: 6

              import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import junit.framework.TestCase;

import java.util.Currency;
import java.util.Locale;


            

Reported by PMD.

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

Line: 10

              import junit.framework.TestCase;

import java.util.Currency;
import java.util.Locale;

public class CurrencyTest4 extends TestCase {

    public void test_0() throws Exception {
        JSONObject jsonObject = new JSONObject();

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/SerializeEnumAsJavaBeanTest_manual.java
8 issues
JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll
Design

Line: 12

               * Created by wenshao on 08/01/2017.
 */
public class SerializeEnumAsJavaBeanTest_manual extends TestCase {
    protected void setUp() throws Exception {
        SerializeConfig serializeConfig = SerializeConfig.globalInstance;
        serializeConfig.configEnumAsJavaBean(OrderType.class);
    }

    public void test_serializeEnumAsJavaBean() throws Exception {

            

Reported by PMD.

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

Line: 14

              public class SerializeEnumAsJavaBeanTest_manual extends TestCase {
    protected void setUp() throws Exception {
        SerializeConfig serializeConfig = SerializeConfig.globalInstance;
        serializeConfig.configEnumAsJavaBean(OrderType.class);
    }

    public void test_serializeEnumAsJavaBean() throws Exception {
        String text = JSON.toJSONString(OrderType.PayOrder);
        assertEquals("{\"remark\":\"支付订单\",\"value\":1}", text);

            

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

                      serializeConfig.configEnumAsJavaBean(OrderType.class);
    }

    public void test_serializeEnumAsJavaBean() throws Exception {
        String text = JSON.toJSONString(OrderType.PayOrder);
        assertEquals("{\"remark\":\"支付订单\",\"value\":1}", text);
    }

    public void test_field() throws Exception {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

              
    public void test_serializeEnumAsJavaBean() throws Exception {
        String text = JSON.toJSONString(OrderType.PayOrder);
        assertEquals("{\"remark\":\"支付订单\",\"value\":1}", text);
    }

    public void test_field() throws Exception {

        Model model = new Model();

            

Reported by PMD.

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

Line: 22

                      assertEquals("{\"remark\":\"支付订单\",\"value\":1}", text);
    }

    public void test_field() throws Exception {

        Model model = new Model();
        model.orderType = OrderType.SettleBill;
        String text = JSON.toJSONString(model);
        assertEquals("{\"orderType\":{\"remark\":\"结算单\",\"value\":2}}", text);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 27

                      Model model = new Model();
        model.orderType = OrderType.SettleBill;
        String text = JSON.toJSONString(model);
        assertEquals("{\"orderType\":{\"remark\":\"结算单\",\"value\":2}}", text);
    }

    public static enum OrderType {
        PayOrder(1, "支付订单"), //
        SettleBill(2, "结算单");

            

Reported by PMD.

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

Line: 44

                  }

    public static class Model {
        public OrderType orderType;
    }
}

            

Reported by PMD.

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

Line: 4

              package com.alibaba.json.bvt;

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

/**
 * Created by wenshao on 08/01/2017.

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/SerializeEnumAsJavaBeanTest.java
8 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 08/01/2017.
 */
public class SerializeEnumAsJavaBeanTest extends TestCase {
    public void test_serializeEnumAsJavaBean() throws Exception {
        String text = JSON.toJSONString(OrderType.PayOrder);
        assertEquals("{\"remark\":\"支付订单\",\"value\":1}", text);
    }

    public void test_field() throws Exception {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 13

              public class SerializeEnumAsJavaBeanTest extends TestCase {
    public void test_serializeEnumAsJavaBean() throws Exception {
        String text = JSON.toJSONString(OrderType.PayOrder);
        assertEquals("{\"remark\":\"支付订单\",\"value\":1}", text);
    }

    public void test_field() throws Exception {
        Model model = new Model();
        model.orderType = OrderType.SettleBill;

            

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

                      assertEquals("{\"remark\":\"支付订单\",\"value\":1}", text);
    }

    public void test_field() throws Exception {
        Model model = new Model();
        model.orderType = OrderType.SettleBill;
        String text = JSON.toJSONString(model);
        assertEquals("{\"orderType\":{\"remark\":\"结算单\",\"value\":2}}", text);
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 20

                      Model model = new Model();
        model.orderType = OrderType.SettleBill;
        String text = JSON.toJSONString(model);
        assertEquals("{\"orderType\":{\"remark\":\"结算单\",\"value\":2}}", text);
    }

    public void test_field_2() throws Exception {
        Model model = new Model();
        model.orderType = OrderType.SettleBill;

            

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

                      assertEquals("{\"orderType\":{\"remark\":\"结算单\",\"value\":2}}", text);
    }

    public void test_field_2() throws Exception {
        Model model = new Model();
        model.orderType = OrderType.SettleBill;
        model.orderType1 = OrderType.SettleBill;
        String text = JSON.toJSONString(model);
        assertEquals("{\"orderType\":{\"remark\":\"结算单\",\"value\":2},\"orderType1\":{\"remark\":\"结算单\",\"value\":2}}", text);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 28

                      model.orderType = OrderType.SettleBill;
        model.orderType1 = OrderType.SettleBill;
        String text = JSON.toJSONString(model);
        assertEquals("{\"orderType\":{\"remark\":\"结算单\",\"value\":2},\"orderType1\":{\"remark\":\"结算单\",\"value\":2}}", text);
    }

    @JSONType(serializeEnumAsJavaBean = true)
    public static enum OrderType {
        PayOrder(1, "支付订单"), //

            

Reported by PMD.

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

Line: 46

                  }

    public static class Model {
        public OrderType orderType;
        public OrderType orderType1;
    }
}

            

Reported by PMD.

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

Line: 47

              
    public static class Model {
        public OrderType orderType;
        public OrderType orderType1;
    }
}

            

Reported by PMD.

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

Line: 17

                              "    \"is_stop\":false/*comment*/" +
                "}";
        Model testUser = JSON.parseObject(jsonString, Model.class);
        System.out.println(testUser);
    }

    public void test_for_issue_true() throws Exception {
        String jsonString = "" +
                "{" +

            

Reported by PMD.

System.out.println is used
Design

Line: 27

                              "    \"is_stop\":true/*comment*/" +
                "}";
        Model testUser = JSON.parseObject(jsonString, Model.class);
        System.out.println(testUser);
    }

    public static class Model {
        public int age;
        public boolean is_top;

            

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

               * Created by wenshao on 20/12/2016.
 */
public class Issue939 extends TestCase {
    public void test_for_issue_false() throws Exception {
        String jsonString = "" +
                "{" +
                "    \"age\": 25," +
                "    \"is_stop\":false/*comment*/" +
                "}";

            

Reported by PMD.

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

Line: 10

               * Created by wenshao on 20/12/2016.
 */
public class Issue939 extends TestCase {
    public void test_for_issue_false() throws Exception {
        String jsonString = "" +
                "{" +
                "    \"age\": 25," +
                "    \"is_stop\":false/*comment*/" +
                "}";

            

Reported by PMD.

Do not add empty strings
Performance

Line: 11

               */
public class Issue939 extends TestCase {
    public void test_for_issue_false() throws Exception {
        String jsonString = "" +
                "{" +
                "    \"age\": 25," +
                "    \"is_stop\":false/*comment*/" +
                "}";
        Model testUser = JSON.parseObject(jsonString, Model.class);

            

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

                      System.out.println(testUser);
    }

    public void test_for_issue_true() throws Exception {
        String jsonString = "" +
                "{" +
                "    \"age\": 25," +
                "    \"is_stop\":true/*comment*/" +
                "}";

            

Reported by PMD.

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

Line: 20

                      System.out.println(testUser);
    }

    public void test_for_issue_true() throws Exception {
        String jsonString = "" +
                "{" +
                "    \"age\": 25," +
                "    \"is_stop\":true/*comment*/" +
                "}";

            

Reported by PMD.

Do not add empty strings
Performance

Line: 21

                  }

    public void test_for_issue_true() throws Exception {
        String jsonString = "" +
                "{" +
                "    \"age\": 25," +
                "    \"is_stop\":true/*comment*/" +
                "}";
        Model testUser = JSON.parseObject(jsonString, Model.class);

            

Reported by PMD.