The following issues were found

src/test/java/com/alibaba/json/bvt/parser/deser/SqlDateDeserializerTest.java
6 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 SqlDateDeserializerTest extends TestCase {

    public void test_bigdecimal() throws Exception {
        Assert.assertEquals(1309861159710L, JSON.parseObject("1309861159710", java.sql.Date.class).getTime());
        Assert.assertEquals(1309861159710L, JSON.parseObject("1309861159710.0", java.sql.Date.class).getTime());
        Assert.assertEquals(1309861159710L, JSON.parseObject("'1309861159710'", java.sql.Date.class).getTime());

        Assert.assertEquals(null, JSON.parseObject("null", Integer.class));

            

Reported by PMD.

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

Line: 15

              public class SqlDateDeserializerTest extends TestCase {

    public void test_bigdecimal() throws Exception {
        Assert.assertEquals(1309861159710L, JSON.parseObject("1309861159710", java.sql.Date.class).getTime());
        Assert.assertEquals(1309861159710L, JSON.parseObject("1309861159710.0", java.sql.Date.class).getTime());
        Assert.assertEquals(1309861159710L, JSON.parseObject("'1309861159710'", java.sql.Date.class).getTime());

        Assert.assertEquals(null, JSON.parseObject("null", Integer.class));


            

Reported by PMD.

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

Line: 16

              
    public void test_bigdecimal() throws Exception {
        Assert.assertEquals(1309861159710L, JSON.parseObject("1309861159710", java.sql.Date.class).getTime());
        Assert.assertEquals(1309861159710L, JSON.parseObject("1309861159710.0", java.sql.Date.class).getTime());
        Assert.assertEquals(1309861159710L, JSON.parseObject("'1309861159710'", java.sql.Date.class).getTime());

        Assert.assertEquals(null, JSON.parseObject("null", Integer.class));

        DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);

            

Reported by PMD.

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

Line: 17

                  public void test_bigdecimal() throws Exception {
        Assert.assertEquals(1309861159710L, JSON.parseObject("1309861159710", java.sql.Date.class).getTime());
        Assert.assertEquals(1309861159710L, JSON.parseObject("1309861159710.0", java.sql.Date.class).getTime());
        Assert.assertEquals(1309861159710L, JSON.parseObject("'1309861159710'", java.sql.Date.class).getTime());

        Assert.assertEquals(null, JSON.parseObject("null", Integer.class));

        DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
        Assert.assertEquals(null, SqlDateDeserializer.instance.deserialze(parser, null, null));

            

Reported by PMD.

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

Line: 22

                      Assert.assertEquals(null, JSON.parseObject("null", Integer.class));

        DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
        Assert.assertEquals(null, SqlDateDeserializer.instance.deserialze(parser, null, null));
        Assert.assertEquals(JSONToken.LITERAL_INT, SqlDateDeserializer.instance.getFastMatchToken());
    }
}


            

Reported by PMD.

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

Line: 23

              
        DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
        Assert.assertEquals(null, SqlDateDeserializer.instance.deserialze(parser, null, null));
        Assert.assertEquals(JSONToken.LITERAL_INT, SqlDateDeserializer.instance.getFastMatchToken());
    }
}


            

Reported by PMD.

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

Line: 18

              import com.alibaba.fastjson.parser.ParserConfig;

public class DateTest extends TestCase {
    protected void setUp() throws Exception {
        JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
        JSON.defaultLocale = Locale.CHINA;
    }
    
    public void test() 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: 23

                      JSON.defaultLocale = Locale.CHINA;
    }
    
    public void test() throws Exception {
        DefaultJSONParser parser = new DefaultJSONParser("{\"date\":\"2012/04-01\"}", ParserConfig.getGlobalInstance(),
                                                         0);
        parser.setDateFormat("yyyy/MM-dd");
        VO vo = parser.parseObject(VO.class);
        

            

Reported by PMD.

The String literal 'yyyy/MM-dd' appears 4 times in this file; the first occurrence is on line 26
Error

Line: 26

                  public void test() throws Exception {
        DefaultJSONParser parser = new DefaultJSONParser("{\"date\":\"2012/04-01\"}", ParserConfig.getGlobalInstance(),
                                                         0);
        parser.setDateFormat("yyyy/MM-dd");
        VO vo = parser.parseObject(VO.class);
        
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM-dd", JSON.defaultLocale);
        dateFormat.setTimeZone(JSON.defaultTimeZone);
        Assert.assertEquals(dateFormat.parse("2012/04-01"), vo.getDate());

            

Reported by PMD.

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

Line: 31

                      
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM-dd", JSON.defaultLocale);
        dateFormat.setTimeZone(JSON.defaultTimeZone);
        Assert.assertEquals(dateFormat.parse("2012/04-01"), vo.getDate());
        
        parser.close();
    }

    public void test_reader() 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: 36

                      parser.close();
    }

    public void test_reader() throws Exception {

        DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner("{\"date\":\"2012/04-01\"}", 0));
        parser.setDateFormat("yyyy/MM-dd");
        VO vo = parser.parseObject(VO.class);


            

Reported by PMD.

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

Line: 44

              
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM-dd", JSON.defaultLocale);
        dateFormat.setTimeZone(JSON.defaultTimeZone);
        Assert.assertEquals(dateFormat.parse("2012/04-01"), vo.getDate());

        parser.close();
    }

    public static class VO {

            

Reported by PMD.

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

Line: 10

              

public class FieldDeserializerTest8 extends TestCase {
    public void test_0 () throws Exception {
        Assert.assertEquals("33", JSON.parseObject("{\"id\":\"33\"\t}", VO.class).id);
        Assert.assertEquals("33", JSON.parseObject("{\"id\":\"33\"\t}\n\t", VO.class).id);
        Assert.assertEquals("33", JSON.parseObject("{\"id\":\"33\" }", V1.class).id);
        Assert.assertEquals("33", JSON.parseObject("{\"id\":\"33\" }\n\t", V1.class).id);
        Assert.assertEquals("33", JSON.parseObject("{\"id\":\"33\"\n}", V1.class).id);

            

Reported by PMD.

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

Line: 11

              
public class FieldDeserializerTest8 extends TestCase {
    public void test_0 () throws Exception {
        Assert.assertEquals("33", JSON.parseObject("{\"id\":\"33\"\t}", VO.class).id);
        Assert.assertEquals("33", JSON.parseObject("{\"id\":\"33\"\t}\n\t", VO.class).id);
        Assert.assertEquals("33", JSON.parseObject("{\"id\":\"33\" }", V1.class).id);
        Assert.assertEquals("33", JSON.parseObject("{\"id\":\"33\" }\n\t", V1.class).id);
        Assert.assertEquals("33", JSON.parseObject("{\"id\":\"33\"\n}", V1.class).id);
    }

            

Reported by PMD.

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

Line: 12

              public class FieldDeserializerTest8 extends TestCase {
    public void test_0 () throws Exception {
        Assert.assertEquals("33", JSON.parseObject("{\"id\":\"33\"\t}", VO.class).id);
        Assert.assertEquals("33", JSON.parseObject("{\"id\":\"33\"\t}\n\t", VO.class).id);
        Assert.assertEquals("33", JSON.parseObject("{\"id\":\"33\" }", V1.class).id);
        Assert.assertEquals("33", JSON.parseObject("{\"id\":\"33\" }\n\t", V1.class).id);
        Assert.assertEquals("33", JSON.parseObject("{\"id\":\"33\"\n}", V1.class).id);
    }
    

            

Reported by PMD.

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

Line: 13

                  public void test_0 () throws Exception {
        Assert.assertEquals("33", JSON.parseObject("{\"id\":\"33\"\t}", VO.class).id);
        Assert.assertEquals("33", JSON.parseObject("{\"id\":\"33\"\t}\n\t", VO.class).id);
        Assert.assertEquals("33", JSON.parseObject("{\"id\":\"33\" }", V1.class).id);
        Assert.assertEquals("33", JSON.parseObject("{\"id\":\"33\" }\n\t", V1.class).id);
        Assert.assertEquals("33", JSON.parseObject("{\"id\":\"33\"\n}", V1.class).id);
    }
    
    public static class VO {

            

Reported by PMD.

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

Line: 14

                      Assert.assertEquals("33", JSON.parseObject("{\"id\":\"33\"\t}", VO.class).id);
        Assert.assertEquals("33", JSON.parseObject("{\"id\":\"33\"\t}\n\t", VO.class).id);
        Assert.assertEquals("33", JSON.parseObject("{\"id\":\"33\" }", V1.class).id);
        Assert.assertEquals("33", JSON.parseObject("{\"id\":\"33\" }\n\t", V1.class).id);
        Assert.assertEquals("33", JSON.parseObject("{\"id\":\"33\"\n}", V1.class).id);
    }
    
    public static class VO {
        public String id;

            

Reported by PMD.

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

Line: 15

                      Assert.assertEquals("33", JSON.parseObject("{\"id\":\"33\"\t}\n\t", VO.class).id);
        Assert.assertEquals("33", JSON.parseObject("{\"id\":\"33\" }", V1.class).id);
        Assert.assertEquals("33", JSON.parseObject("{\"id\":\"33\" }\n\t", V1.class).id);
        Assert.assertEquals("33", JSON.parseObject("{\"id\":\"33\"\n}", V1.class).id);
    }
    
    public static class VO {
        public String id;
    }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/util/JSONASMUtilTest.java
6 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

              
public class JSONASMUtilTest extends TestCase {

    public void test_0() throws Exception {
        Assert.assertEquals("()I", ASMUtils.desc(HashMap.class.getMethod("size")));
        Assert.assertEquals("(Ljava/lang/Object;)Ljava/lang/Object;", ASMUtils.desc(HashMap.class.getMethod("get", Object.class)));
        Assert.assertEquals("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", ASMUtils.desc(HashMap.class.getMethod("put", Object.class, Object.class)));
    }


            

Reported by PMD.

Avoid using implementation types like 'HashMap'; use the interface instead
Design

Line: 13

              public class JSONASMUtilTest extends TestCase {

    public void test_0() throws Exception {
        Assert.assertEquals("()I", ASMUtils.desc(HashMap.class.getMethod("size")));
        Assert.assertEquals("(Ljava/lang/Object;)Ljava/lang/Object;", ASMUtils.desc(HashMap.class.getMethod("get", Object.class)));
        Assert.assertEquals("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", ASMUtils.desc(HashMap.class.getMethod("put", Object.class, Object.class)));
    }

    public void test_1() throws Exception {

            

Reported by PMD.

Avoid using implementation types like 'HashMap'; use the interface instead
Design

Line: 14

              
    public void test_0() throws Exception {
        Assert.assertEquals("()I", ASMUtils.desc(HashMap.class.getMethod("size")));
        Assert.assertEquals("(Ljava/lang/Object;)Ljava/lang/Object;", ASMUtils.desc(HashMap.class.getMethod("get", Object.class)));
        Assert.assertEquals("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", ASMUtils.desc(HashMap.class.getMethod("put", Object.class, Object.class)));
    }

    public void test_1() throws Exception {
        Assert.assertEquals("I", ASMUtils.type(int.class));

            

Reported by PMD.

Avoid using implementation types like 'HashMap'; use the interface instead
Design

Line: 15

                  public void test_0() throws Exception {
        Assert.assertEquals("()I", ASMUtils.desc(HashMap.class.getMethod("size")));
        Assert.assertEquals("(Ljava/lang/Object;)Ljava/lang/Object;", ASMUtils.desc(HashMap.class.getMethod("get", Object.class)));
        Assert.assertEquals("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", ASMUtils.desc(HashMap.class.getMethod("put", Object.class, Object.class)));
    }

    public void test_1() throws Exception {
        Assert.assertEquals("I", ASMUtils.type(int.class));
        Assert.assertEquals("java/lang/Integer", ASMUtils.type(Integer.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: 18

                      Assert.assertEquals("(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", ASMUtils.desc(HashMap.class.getMethod("put", Object.class, Object.class)));
    }

    public void test_1() throws Exception {
        Assert.assertEquals("I", ASMUtils.type(int.class));
        Assert.assertEquals("java/lang/Integer", ASMUtils.type(Integer.class));
    }

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

                      Assert.assertEquals("java/lang/Integer", ASMUtils.type(Integer.class));
    }

    public void test_2() throws Exception {
        Assert.assertEquals("[I", ASMUtils.type(int[].class));
        Assert.assertEquals("[Ljava/lang/Integer;", ASMUtils.type(Integer[].class));
    }
}

            

Reported by PMD.

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

Line: 10

              

public class FieldDeserializerTest7 extends TestCase {
    public void test_0 () throws Exception {
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33\t}", VO.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33\t}\n\t", VO.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33 }", V1.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33 }\n\t", V1.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33L}", V1.class).id);

            

Reported by PMD.

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

Line: 11

              
public class FieldDeserializerTest7 extends TestCase {
    public void test_0 () throws Exception {
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33\t}", VO.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33\t}\n\t", VO.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33 }", V1.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33 }\n\t", V1.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33L}", V1.class).id);
    }

            

Reported by PMD.

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

Line: 12

              public class FieldDeserializerTest7 extends TestCase {
    public void test_0 () throws Exception {
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33\t}", VO.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33\t}\n\t", VO.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33 }", V1.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33 }\n\t", V1.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33L}", V1.class).id);
    }
    

            

Reported by PMD.

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

Line: 13

                  public void test_0 () throws Exception {
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33\t}", VO.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33\t}\n\t", VO.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33 }", V1.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33 }\n\t", V1.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33L}", V1.class).id);
    }
    
    public static class VO {

            

Reported by PMD.

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

Line: 14

                      Assert.assertTrue(33F == JSON.parseObject("{\"id\":33\t}", VO.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33\t}\n\t", VO.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33 }", V1.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33 }\n\t", V1.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33L}", V1.class).id);
    }
    
    public static class VO {
        public double id;

            

Reported by PMD.

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

Line: 15

                      Assert.assertTrue(33F == JSON.parseObject("{\"id\":33\t}\n\t", VO.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33 }", V1.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33 }\n\t", V1.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33L}", V1.class).id);
    }
    
    public static class VO {
        public double id;
    }

            

Reported by PMD.

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

Line: 10

              

public class FieldDeserializerTest6 extends TestCase {
    public void test_0 () throws Exception {
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33\t}", VO.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33\t}\n\t", VO.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33 }", V1.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33 }\n\t", V1.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33L}", V1.class).id);

            

Reported by PMD.

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

Line: 11

              
public class FieldDeserializerTest6 extends TestCase {
    public void test_0 () throws Exception {
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33\t}", VO.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33\t}\n\t", VO.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33 }", V1.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33 }\n\t", V1.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33L}", V1.class).id);
    }

            

Reported by PMD.

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

Line: 12

              public class FieldDeserializerTest6 extends TestCase {
    public void test_0 () throws Exception {
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33\t}", VO.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33\t}\n\t", VO.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33 }", V1.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33 }\n\t", V1.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33L}", V1.class).id);
    }
    

            

Reported by PMD.

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

Line: 13

                  public void test_0 () throws Exception {
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33\t}", VO.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33\t}\n\t", VO.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33 }", V1.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33 }\n\t", V1.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33L}", V1.class).id);
    }
    
    public static class VO {

            

Reported by PMD.

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

Line: 14

                      Assert.assertTrue(33F == JSON.parseObject("{\"id\":33\t}", VO.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33\t}\n\t", VO.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33 }", V1.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33 }\n\t", V1.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33L}", V1.class).id);
    }
    
    public static class VO {
        public float id;

            

Reported by PMD.

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

Line: 15

                      Assert.assertTrue(33F == JSON.parseObject("{\"id\":33\t}\n\t", VO.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33 }", V1.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33 }\n\t", V1.class).id);
        Assert.assertTrue(33F == JSON.parseObject("{\"id\":33L}", V1.class).id);
    }
    
    public static class VO {
        public float id;
    }

            

Reported by PMD.

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

Line: 10

              

public class FieldDeserializerTest4 extends TestCase {
    public void test_0 () throws Exception {
        Assert.assertEquals(33, JSON.parseObject("{\"id\":33\t}", VO.class).id);
        Assert.assertEquals(33, JSON.parseObject("{\"id\":33\t}\n\t", VO.class).id);
        Assert.assertEquals(33, JSON.parseObject("{\"id\":33 }", V1.class).id);
        Assert.assertEquals(33, JSON.parseObject("{\"id\":33 }\n\t", V1.class).id);
        Assert.assertEquals(33, JSON.parseObject("{\"id\":33L}", V1.class).id);

            

Reported by PMD.

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

Line: 11

              
public class FieldDeserializerTest4 extends TestCase {
    public void test_0 () throws Exception {
        Assert.assertEquals(33, JSON.parseObject("{\"id\":33\t}", VO.class).id);
        Assert.assertEquals(33, JSON.parseObject("{\"id\":33\t}\n\t", VO.class).id);
        Assert.assertEquals(33, JSON.parseObject("{\"id\":33 }", V1.class).id);
        Assert.assertEquals(33, JSON.parseObject("{\"id\":33 }\n\t", V1.class).id);
        Assert.assertEquals(33, JSON.parseObject("{\"id\":33L}", V1.class).id);
    }

            

Reported by PMD.

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

Line: 12

              public class FieldDeserializerTest4 extends TestCase {
    public void test_0 () throws Exception {
        Assert.assertEquals(33, JSON.parseObject("{\"id\":33\t}", VO.class).id);
        Assert.assertEquals(33, JSON.parseObject("{\"id\":33\t}\n\t", VO.class).id);
        Assert.assertEquals(33, JSON.parseObject("{\"id\":33 }", V1.class).id);
        Assert.assertEquals(33, JSON.parseObject("{\"id\":33 }\n\t", V1.class).id);
        Assert.assertEquals(33, JSON.parseObject("{\"id\":33L}", V1.class).id);
    }
    

            

Reported by PMD.

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

Line: 13

                  public void test_0 () throws Exception {
        Assert.assertEquals(33, JSON.parseObject("{\"id\":33\t}", VO.class).id);
        Assert.assertEquals(33, JSON.parseObject("{\"id\":33\t}\n\t", VO.class).id);
        Assert.assertEquals(33, JSON.parseObject("{\"id\":33 }", V1.class).id);
        Assert.assertEquals(33, JSON.parseObject("{\"id\":33 }\n\t", V1.class).id);
        Assert.assertEquals(33, JSON.parseObject("{\"id\":33L}", V1.class).id);
    }
    
    public static class VO {

            

Reported by PMD.

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

Line: 14

                      Assert.assertEquals(33, JSON.parseObject("{\"id\":33\t}", VO.class).id);
        Assert.assertEquals(33, JSON.parseObject("{\"id\":33\t}\n\t", VO.class).id);
        Assert.assertEquals(33, JSON.parseObject("{\"id\":33 }", V1.class).id);
        Assert.assertEquals(33, JSON.parseObject("{\"id\":33 }\n\t", V1.class).id);
        Assert.assertEquals(33, JSON.parseObject("{\"id\":33L}", V1.class).id);
    }
    
    public static class VO {
        public long id;

            

Reported by PMD.

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

Line: 15

                      Assert.assertEquals(33, JSON.parseObject("{\"id\":33\t}\n\t", VO.class).id);
        Assert.assertEquals(33, JSON.parseObject("{\"id\":33 }", V1.class).id);
        Assert.assertEquals(33, JSON.parseObject("{\"id\":33 }\n\t", V1.class).id);
        Assert.assertEquals(33, JSON.parseObject("{\"id\":33L}", V1.class).id);
    }
    
    public static class VO {
        public long id;
    }

            

Reported by PMD.

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

              import com.alibaba.fastjson.parser.JSONScanner;

public class SpecicalStringTest extends TestCase {
    public void test_0 () throws Exception {
        String text;
        {
            JSONObject json = new JSONObject();
            
            Map<String, Object> map = new HashMap<String, Object>();

            

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

                      Assert.assertEquals("{\"text\":\"{\\\"name\\\":\\\"张三\\\"}\"}", text);
    }
    
    public void test_string2() throws Exception {
        StringBuilder buf = new StringBuilder();

        buf.append('"');
        for (int i = 0; i < 200; ++i) {
            buf.append("\\\\\\/\\b\\f\\n\\r\\t\\u" + Integer.toHexString('中'));

            

Reported by PMD.

StringBuffer constructor is initialized with size 16, but has at least 28 characters appended.
Performance

Line: 31

                  }
    
    public void test_string2() throws Exception {
        StringBuilder buf = new StringBuilder();

        buf.append('"');
        for (int i = 0; i < 200; ++i) {
            buf.append("\\\\\\/\\b\\f\\n\\r\\t\\u" + Integer.toHexString('中'));
        }

            

Reported by PMD.

Avoid concatenating nonliterals in a StringBuffer/StringBuilder constructor or append().
Performance

Line: 35

              
        buf.append('"');
        for (int i = 0; i < 200; ++i) {
            buf.append("\\\\\\/\\b\\f\\n\\r\\t\\u" + Integer.toHexString('中'));
        }
        buf.append('"');

        String text = buf.toString();


            

Reported by PMD.

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

Line: 41

              
        String text = buf.toString();

        JSONScanner lexer = new JSONScanner(text.toCharArray(), text.length());
        lexer.nextToken();

        Assert.assertEquals(0, lexer.pos());

        lexer.stringVal();

            

Reported by PMD.

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

Line: 41

              
        String text = buf.toString();

        JSONScanner lexer = new JSONScanner(text.toCharArray(), text.length());
        lexer.nextToken();

        Assert.assertEquals(0, lexer.pos());

        lexer.stringVal();

            

Reported by PMD.

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

Line: 17

              
public class JSONPath_field_wildcard extends TestCase {

    public void test_list_map() throws Exception {
        JSONPath path = new JSONPath("$.*");
        Map<String, Object> map = new LinkedHashMap<String, Object>();
        map.put("id", 123);
        map.put("name", "wenshao");


            

Reported by PMD.

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

Line: 24

                      map.put("name", "wenshao");

        Collection<Object> fieldValues = (Collection<Object>) path.eval(map);
        Iterator<Object> it = fieldValues.iterator();
        Assert.assertSame(map.get("id"), it.next());
        Assert.assertSame(map.get("name"), it.next());
    }
    
    public void test_list_map_none_root() 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: 29

                      Assert.assertSame(map.get("name"), it.next());
    }
    
    public void test_list_map_none_root() throws Exception {
        JSONPath path = new JSONPath("*");
        Entity entity = new Entity(123, "wenshao");
        
        List<Object> fieldValues = (List<Object>) path.eval(entity);
        Assert.assertSame(entity.getId(), fieldValues.get(0));

            

Reported by PMD.

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

Line: 34

                      Entity entity = new Entity(123, "wenshao");
        
        List<Object> fieldValues = (List<Object>) path.eval(entity);
        Assert.assertSame(entity.getId(), fieldValues.get(0));
        Assert.assertSame(entity.getName(), fieldValues.get(1));
    }

    public static class Entity {


            

Reported by PMD.

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

Line: 35

                      
        List<Object> fieldValues = (List<Object>) path.eval(entity);
        Assert.assertSame(entity.getId(), fieldValues.get(0));
        Assert.assertSame(entity.getName(), fieldValues.get(1));
    }

    public static class Entity {

        private Integer id;

            

Reported by PMD.

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

Line: 38

                      Assert.assertSame(entity.getName(), fieldValues.get(1));
    }

    public static class Entity {

        private Integer id;
        private String  name;

        public Entity(Integer id, String name){

            

Reported by PMD.

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

Line: 14

              import com.alibaba.fastjson.JSON;

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

            

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

                  }
    
    
    public void test_sqlDate() throws Exception {
        java.util.Date date = new java.util.Date();
        long millis = date.getTime();
        long millis2 = (millis / 1000)  * 1000;
        
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", JSON.defaultLocale);

            

Reported by PMD.

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

Line: 28

                      SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", JSON.defaultLocale);
        dateFormat.setTimeZone(JSON.defaultTimeZone);
        String text = dateFormat.format(millis);
        text = text.replace(' ', 'T');
        
        SimpleDateFormat dateFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", JSON.defaultLocale);
        dateFormat2.setTimeZone(JSON.defaultTimeZone);
        String text2 = dateFormat2.format(millis2);
        

            

Reported by PMD.

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

Line: 37

                      Assert.assertNull(JSON.parseObject("null", Date.class));
        Assert.assertNull(JSON.parseObject("\"\"", Date.class));
        Assert.assertNull(JSON.parseArray("null", Date.class));
        Assert.assertNull(JSON.parseArray("[null]", Date.class).get(0));
        Assert.assertNull(JSON.parseObject("{\"value\":null}", VO.class).getValue());
        
        Assert.assertEquals(new Date(millis), JSON.parseObject("" + millis, Date.class));
        Assert.assertEquals(new Date(millis), JSON.parseObject("{\"@type\":\"java.sql.Date\",\"val\":" + millis + "}", Date.class));
        Assert.assertEquals(new Date(millis), JSON.parseObject("\"" + millis + "\"", Date.class));

            

Reported by PMD.

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

Line: 38

                      Assert.assertNull(JSON.parseObject("\"\"", Date.class));
        Assert.assertNull(JSON.parseArray("null", Date.class));
        Assert.assertNull(JSON.parseArray("[null]", Date.class).get(0));
        Assert.assertNull(JSON.parseObject("{\"value\":null}", VO.class).getValue());
        
        Assert.assertEquals(new Date(millis), JSON.parseObject("" + millis, Date.class));
        Assert.assertEquals(new Date(millis), JSON.parseObject("{\"@type\":\"java.sql.Date\",\"val\":" + millis + "}", Date.class));
        Assert.assertEquals(new Date(millis), JSON.parseObject("\"" + millis + "\"", Date.class));
        Assert.assertEquals(new Date(millis2), JSON.parseObject("\"" + text2 + "\"", Date.class));

            

Reported by PMD.

Do not add empty strings
Performance

Line: 40

                      Assert.assertNull(JSON.parseArray("[null]", Date.class).get(0));
        Assert.assertNull(JSON.parseObject("{\"value\":null}", VO.class).getValue());
        
        Assert.assertEquals(new Date(millis), JSON.parseObject("" + millis, Date.class));
        Assert.assertEquals(new Date(millis), JSON.parseObject("{\"@type\":\"java.sql.Date\",\"val\":" + millis + "}", Date.class));
        Assert.assertEquals(new Date(millis), JSON.parseObject("\"" + millis + "\"", Date.class));
        Assert.assertEquals(new Date(millis2), JSON.parseObject("\"" + text2 + "\"", Date.class));
        Assert.assertEquals(new Date(millis), JSON.parseObject("\"" + text + "\"", Date.class));
        

            

Reported by PMD.