The following issues were found

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

public class WriteAsArray_float2_private extends TestCase {
    public void test_0 () throws Exception {
        VO vo = new VO();
        vo.setId(123F);
        vo.setName("wenshao");
        
        String text = JSON.toJSONString(vo, SerializerFeature.BeanToArray);

            

Reported by PMD.

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

Line: 26

                      Assert.assertEquals(vo.name, vo2.name);
    }
    
    public void test_error() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[123.A,\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;

            

Reported by PMD.

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

Line: 36

                      Assert.assertNotNull(error);
    }
    
    public void test_error1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[\"A\",\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;

            

Reported by PMD.

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

Line: 46

                      Assert.assertNotNull(error);
    }
    
    public void test_error2() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[123:\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;

            

Reported by PMD.

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

Line: 56

                      Assert.assertNotNull(error);
    }
    
    private static class VO {
        private float id;
        private String name;

        public float getId() {
            return id;

            

Reported by PMD.

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

Line: 27

                  }
    
    public void test_error() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[123.A,\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '37'-'41').
Error

Line: 37

                  }
    
    public void test_error1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[\"A\",\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '47'-'51').
Error

Line: 47

                  }
    
    public void test_error2() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[123:\"wenshao\"]", VO.class, Feature.SupportArrayToBean);
        } catch (JSONException ex) {
            error = ex;
        }

            

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/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_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_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/writeAsArray/WriteAsArray_Object.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 WriteAsArray_Object extends TestCase {

    public void test_0() throws Exception {
        A a = new A();
        a.setId(123);
        a.setName("wenshao");
        
        VO vo = new VO();

            

Reported by PMD.

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

Line: 26

                      Assert.assertEquals("[[123,\"wenshao\"]]", text);
        
        VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
        Assert.assertEquals(vo.getA().getId(), vo2.getA().getId());
        Assert.assertEquals(vo.getA().getName(), vo2.getA().getName());
    }

    private static class VO {


            

Reported by PMD.

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

Line: 26

                      Assert.assertEquals("[[123,\"wenshao\"]]", text);
        
        VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
        Assert.assertEquals(vo.getA().getId(), vo2.getA().getId());
        Assert.assertEquals(vo.getA().getName(), vo2.getA().getName());
    }

    private static class VO {


            

Reported by PMD.

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

Line: 26

                      Assert.assertEquals("[[123,\"wenshao\"]]", text);
        
        VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
        Assert.assertEquals(vo.getA().getId(), vo2.getA().getId());
        Assert.assertEquals(vo.getA().getName(), vo2.getA().getName());
    }

    private static class VO {


            

Reported by PMD.

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

Line: 27

                      
        VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
        Assert.assertEquals(vo.getA().getId(), vo2.getA().getId());
        Assert.assertEquals(vo.getA().getName(), vo2.getA().getName());
    }

    private static class VO {

        private A a;

            

Reported by PMD.

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

Line: 27

                      
        VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
        Assert.assertEquals(vo.getA().getId(), vo2.getA().getId());
        Assert.assertEquals(vo.getA().getName(), vo2.getA().getName());
    }

    private static class VO {

        private A a;

            

Reported by PMD.

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

Line: 27

                      
        VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
        Assert.assertEquals(vo.getA().getId(), vo2.getA().getId());
        Assert.assertEquals(vo.getA().getName(), vo2.getA().getName());
    }

    private static class VO {

        private A a;

            

Reported by PMD.

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

Line: 44

              
    }

    private static class A {

        private int    id;
        private String name;

        public int getId() {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/util/Base64Test.java
8 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 7

              import junit.framework.TestCase;

public class Base64Test extends TestCase {
    public void test_base64() throws Exception {
        String str = "阿里巴巴網絡有限公司主要通過旗下三個交易市場協助世界各地數以百萬計的買家和供應商從事網上生意,包括:集中服務全球進出口商的國際交易市場(www.alibaba.com);集中國內貿易的中國交易市場(www.1688.com);以及在國際交易市場上的全球批發交易平台(www.aliexpress.com),為規模較小、需要小批量貨物快速付運的買家提供服務。更多>>";

        byte[] bytes = str.getBytes("UTF8");
        String base64Str = com.alibaba.json.test.Base64.encodeToString(bytes, false);


            

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 Base64Test extends TestCase {
    public void test_base64() throws Exception {
        String str = "阿里巴巴網絡有限公司主要通過旗下三個交易市場協助世界各地數以百萬計的買家和供應商從事網上生意,包括:集中服務全球進出口商的國際交易市場(www.alibaba.com);集中國內貿易的中國交易市場(www.1688.com);以及在國際交易市場上的全球批發交易平台(www.aliexpress.com),為規模較小、需要小批量貨物快速付運的買家提供服務。更多>>";

        byte[] bytes = str.getBytes("UTF8");
        String base64Str = com.alibaba.json.test.Base64.encodeToString(bytes, false);


            

Reported by PMD.

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

Line: 10

                  public void test_base64() throws Exception {
        String str = "阿里巴巴網絡有限公司主要通過旗下三個交易市場協助世界各地數以百萬計的買家和供應商從事網上生意,包括:集中服務全球進出口商的國際交易市場(www.alibaba.com);集中國內貿易的中國交易市場(www.1688.com);以及在國際交易市場上的全球批發交易平台(www.aliexpress.com),為規模較小、需要小批量貨物快速付運的買家提供服務。更多>>";

        byte[] bytes = str.getBytes("UTF8");
        String base64Str = com.alibaba.json.test.Base64.encodeToString(bytes, false);

        {
            byte[] bytes2 = Base64.decodeFast(base64Str);
            assertEquals(str, new String(bytes2, "UTF8"));

            

Reported by PMD.

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

Line: 10

                  public void test_base64() throws Exception {
        String str = "阿里巴巴網絡有限公司主要通過旗下三個交易市場協助世界各地數以百萬計的買家和供應商從事網上生意,包括:集中服務全球進出口商的國際交易市場(www.alibaba.com);集中國內貿易的中國交易市場(www.1688.com);以及在國際交易市場上的全球批發交易平台(www.aliexpress.com),為規模較小、需要小批量貨物快速付運的買家提供服務。更多>>";

        byte[] bytes = str.getBytes("UTF8");
        String base64Str = com.alibaba.json.test.Base64.encodeToString(bytes, false);

        {
            byte[] bytes2 = Base64.decodeFast(base64Str);
            assertEquals(str, new String(bytes2, "UTF8"));

            

Reported by PMD.

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

Line: 11

                      String str = "阿里巴巴網絡有限公司主要通過旗下三個交易市場協助世界各地數以百萬計的買家和供應商從事網上生意,包括:集中服務全球進出口商的國際交易市場(www.alibaba.com);集中國內貿易的中國交易市場(www.1688.com);以及在國際交易市場上的全球批發交易平台(www.aliexpress.com),為規模較小、需要小批量貨物快速付運的買家提供服務。更多>>";

        byte[] bytes = str.getBytes("UTF8");
        String base64Str = com.alibaba.json.test.Base64.encodeToString(bytes, false);

        {
            byte[] bytes2 = Base64.decodeFast(base64Str);
            assertEquals(str, new String(bytes2, "UTF8"));
        }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 15

              
        {
            byte[] bytes2 = Base64.decodeFast(base64Str);
            assertEquals(str, new String(bytes2, "UTF8"));
        }

        {
            byte[] bytes2 = Base64.decodeFast(base64Str, 0, base64Str.length());
            assertEquals(str, new String(bytes2, "UTF8"));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 20

              
        {
            byte[] bytes2 = Base64.decodeFast(base64Str, 0, base64Str.length());
            assertEquals(str, new String(bytes2, "UTF8"));
        }

        {
            byte[] bytes2 = Base64.decodeFast(base64Str.toCharArray(), 0, base64Str.length());
            assertEquals(str, new String(bytes2, "UTF8"));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 25

              
        {
            byte[] bytes2 = Base64.decodeFast(base64Str.toCharArray(), 0, base64Str.length());
            assertEquals(str, new String(bytes2, "UTF8"));
        }
    }
}

            

Reported by PMD.

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

Line: 14

              import java.util.TimeZone;

public class Issue2894 extends TestCase {
    protected void setUp() throws Exception {
        JSON.defaultTimeZone = TimeZone.getDefault();
        JSON.defaultLocale = Locale.CHINA;
    }

    public void test_for_issue() throws Exception {

            

Reported by PMD.

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

Line: 19

                      JSON.defaultLocale = Locale.CHINA;
    }

    public void test_for_issue() throws Exception {
        String json = "{\"timestamp\":\"2019-09-19 08:49:52.350000000\"}";
        Pojo pojo = JSONObject.parseObject(json, Pojo.class);
        int nanos = pojo.timestamp.getNanos();
        assertEquals(nanos, 350000000);
        assertEquals("{\"timestamp\":\"2019-09-19 08:49:52.000000350\"}", JSON.toJSONString(pojo));

            

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

                      JSON.defaultLocale = Locale.CHINA;
    }

    public void test_for_issue() throws Exception {
        String json = "{\"timestamp\":\"2019-09-19 08:49:52.350000000\"}";
        Pojo pojo = JSONObject.parseObject(json, Pojo.class);
        int nanos = pojo.timestamp.getNanos();
        assertEquals(nanos, 350000000);
        assertEquals("{\"timestamp\":\"2019-09-19 08:49:52.000000350\"}", JSON.toJSONString(pojo));

            

Reported by PMD.

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

Line: 22

                  public void test_for_issue() throws Exception {
        String json = "{\"timestamp\":\"2019-09-19 08:49:52.350000000\"}";
        Pojo pojo = JSONObject.parseObject(json, Pojo.class);
        int nanos = pojo.timestamp.getNanos();
        assertEquals(nanos, 350000000);
        assertEquals("{\"timestamp\":\"2019-09-19 08:49:52.000000350\"}", JSON.toJSONString(pojo));
    }

    public static class Pojo {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 23

                      String json = "{\"timestamp\":\"2019-09-19 08:49:52.350000000\"}";
        Pojo pojo = JSONObject.parseObject(json, Pojo.class);
        int nanos = pojo.timestamp.getNanos();
        assertEquals(nanos, 350000000);
        assertEquals("{\"timestamp\":\"2019-09-19 08:49:52.000000350\"}", JSON.toJSONString(pojo));
    }

    public static class Pojo {
        @JSONField(name = "timestamp", format = "yyyy-MM-dd HH:mm:ss.SSSSSSSSS")

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 24

                      Pojo pojo = JSONObject.parseObject(json, Pojo.class);
        int nanos = pojo.timestamp.getNanos();
        assertEquals(nanos, 350000000);
        assertEquals("{\"timestamp\":\"2019-09-19 08:49:52.000000350\"}", JSON.toJSONString(pojo));
    }

    public static class Pojo {
        @JSONField(name = "timestamp", format = "yyyy-MM-dd HH:mm:ss.SSSSSSSSS")
        public Timestamp timestamp;

            

Reported by PMD.

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

Line: 29

              
    public static class Pojo {
        @JSONField(name = "timestamp", format = "yyyy-MM-dd HH:mm:ss.SSSSSSSSS")
        public Timestamp timestamp;
    }
}

            

Reported by PMD.

Avoid unused imports such as 'lombok.Data'
Design

Line: 7

              import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import junit.framework.TestCase;
import lombok.Data;

import java.sql.Timestamp;
import java.util.Locale;
import java.util.TimeZone;


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1500/Issue1558.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 java.io.Serializable;

public class Issue1558 extends TestCase {
    public void test_for_issue() throws Exception {
        ParserConfig config = new ParserConfig();
        config.setAutoTypeSupport(true);
        String text = "{\"id\": \"439a3213-e734-4bf3-9870-2c471f43d651\", \"instance\": \"v1\", \"interface\": \"com.xxx.aplan.UICommands\", \"method\": \"start\", \"params\": [\"tony\"], \"@type\": \"com.alibaba.json.bvt.issue_1500.Issue1558$Request\"}";

        JSON.parseObject(text, Request.class, config);

            

Reported by PMD.

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

Line: 11

              import java.io.Serializable;

public class Issue1558 extends TestCase {
    public void test_for_issue() throws Exception {
        ParserConfig config = new ParserConfig();
        config.setAutoTypeSupport(true);
        String text = "{\"id\": \"439a3213-e734-4bf3-9870-2c471f43d651\", \"instance\": \"v1\", \"interface\": \"com.xxx.aplan.UICommands\", \"method\": \"start\", \"params\": [\"tony\"], \"@type\": \"com.alibaba.json.bvt.issue_1500.Issue1558$Request\"}";

        JSON.parseObject(text, Request.class, config);

            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 20

                  }

    @JSONType
    public static class Request implements Serializable {
        private String id;
        private String instance;
        private String _interface;
        private String method;
        private Object[] params;

            

Reported by PMD.

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

Line: 20

                  }

    @JSONType
    public static class Request implements Serializable {
        private String id;
        private String instance;
        private String _interface;
        private String method;
        private Object[] params;

            

Reported by PMD.

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

Line: 23

                  public static class Request implements Serializable {
        private String id;
        private String instance;
        private String _interface;
        private String method;
        private Object[] params;
        public String getId() {
            return id;
        }

            

Reported by PMD.

Returning 'params' may expose an internal array.
Design

Line: 51

                          this.method = method;
        }
        public Object[] getParams() {
            return params;
        }
        public void setParams(Object[] params) {
            this.params = params;
        }
    }

            

Reported by PMD.

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

Line: 53

                      public Object[] getParams() {
            return params;
        }
        public void setParams(Object[] params) {
            this.params = params;
        }
    }
}

            

Reported by PMD.

Consider using varargs for methods or constructors which take an array the last parameter.
Design

Line: 53

                      public Object[] getParams() {
            return params;
        }
        public void setParams(Object[] params) {
            this.params = params;
        }
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_2800/Issue2830.java
8 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 8

              import junit.framework.TestCase;

public class Issue2830 extends TestCase {
    public void test_for_issue() throws Exception {
        JSONObject jsonObject = JSONObject.parseObject("{\"qty\":\"10\",\"qty1\":\"10.0\",\"qty2\":\"10.000\"}");

        assertEquals(10, jsonObject.getIntValue("qty"));
        assertEquals(10, jsonObject.getIntValue("qty1"));
        assertEquals(10, jsonObject.getIntValue("qty2"));

            

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 Issue2830 extends TestCase {
    public void test_for_issue() throws Exception {
        JSONObject jsonObject = JSONObject.parseObject("{\"qty\":\"10\",\"qty1\":\"10.0\",\"qty2\":\"10.000\"}");

        assertEquals(10, jsonObject.getIntValue("qty"));
        assertEquals(10, jsonObject.getIntValue("qty1"));
        assertEquals(10, jsonObject.getIntValue("qty2"));

            

Reported by PMD.

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

Line: 11

                  public void test_for_issue() throws Exception {
        JSONObject jsonObject = JSONObject.parseObject("{\"qty\":\"10\",\"qty1\":\"10.0\",\"qty2\":\"10.000\"}");

        assertEquals(10, jsonObject.getIntValue("qty"));
        assertEquals(10, jsonObject.getIntValue("qty1"));
        assertEquals(10, jsonObject.getIntValue("qty2"));

    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 11

                  public void test_for_issue() throws Exception {
        JSONObject jsonObject = JSONObject.parseObject("{\"qty\":\"10\",\"qty1\":\"10.0\",\"qty2\":\"10.000\"}");

        assertEquals(10, jsonObject.getIntValue("qty"));
        assertEquals(10, jsonObject.getIntValue("qty1"));
        assertEquals(10, jsonObject.getIntValue("qty2"));

    }
}

            

Reported by PMD.

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

Line: 12

                      JSONObject jsonObject = JSONObject.parseObject("{\"qty\":\"10\",\"qty1\":\"10.0\",\"qty2\":\"10.000\"}");

        assertEquals(10, jsonObject.getIntValue("qty"));
        assertEquals(10, jsonObject.getIntValue("qty1"));
        assertEquals(10, jsonObject.getIntValue("qty2"));

    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 12

                      JSONObject jsonObject = JSONObject.parseObject("{\"qty\":\"10\",\"qty1\":\"10.0\",\"qty2\":\"10.000\"}");

        assertEquals(10, jsonObject.getIntValue("qty"));
        assertEquals(10, jsonObject.getIntValue("qty1"));
        assertEquals(10, jsonObject.getIntValue("qty2"));

    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 13

              
        assertEquals(10, jsonObject.getIntValue("qty"));
        assertEquals(10, jsonObject.getIntValue("qty1"));
        assertEquals(10, jsonObject.getIntValue("qty2"));

    }
}

            

Reported by PMD.

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

Line: 13

              
        assertEquals(10, jsonObject.getIntValue("qty"));
        assertEquals(10, jsonObject.getIntValue("qty1"));
        assertEquals(10, jsonObject.getIntValue("qty2"));

    }
}

            

Reported by PMD.