The following issues were found

src/main/java/com/alibaba/fastjson/serializer/CharArrayCodec.java
19 issues
The class 'CharArrayCodec' has a Modified Cyclomatic Complexity of 5 (Highest = 11).
Design

Line: 14

              import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;


public class CharArrayCodec implements ObjectDeserializer {

    @SuppressWarnings("unchecked")
    public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
        return (T) deserialze(parser);
    }

            

Reported by PMD.

The class 'CharArrayCodec' has a Standard Cyclomatic Complexity of 5 (Highest = 11).
Design

Line: 14

              import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;


public class CharArrayCodec implements ObjectDeserializer {

    @SuppressWarnings("unchecked")
    public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
        return (T) deserialze(parser);
    }

            

Reported by PMD.

The method 'deserialze(DefaultJSONParser)' has an NPath complexity of 272, current threshold is 200
Design

Line: 22

                  }
    
    @SuppressWarnings("unchecked")
    public static <T> T deserialze(DefaultJSONParser parser) {
        final JSONLexer lexer = parser.lexer;
        if (lexer.token() == JSONToken.LITERAL_STRING) {
            String val = lexer.stringVal();
            lexer.nextToken(JSONToken.COMMA);
            return (T) val.toCharArray();

            

Reported by PMD.

The method 'deserialze' has a Standard Cyclomatic Complexity of 11.
Design

Line: 22

                  }
    
    @SuppressWarnings("unchecked")
    public static <T> T deserialze(DefaultJSONParser parser) {
        final JSONLexer lexer = parser.lexer;
        if (lexer.token() == JSONToken.LITERAL_STRING) {
            String val = lexer.stringVal();
            lexer.nextToken(JSONToken.COMMA);
            return (T) val.toCharArray();

            

Reported by PMD.

The method 'deserialze(DefaultJSONParser)' has a cyclomatic complexity of 12.
Design

Line: 22

                  }
    
    @SuppressWarnings("unchecked")
    public static <T> T deserialze(DefaultJSONParser parser) {
        final JSONLexer lexer = parser.lexer;
        if (lexer.token() == JSONToken.LITERAL_STRING) {
            String val = lexer.stringVal();
            lexer.nextToken(JSONToken.COMMA);
            return (T) val.toCharArray();

            

Reported by PMD.

The method 'deserialze' has a Modified Cyclomatic Complexity of 11.
Design

Line: 22

                  }
    
    @SuppressWarnings("unchecked")
    public static <T> T deserialze(DefaultJSONParser parser) {
        final JSONLexer lexer = parser.lexer;
        if (lexer.token() == JSONToken.LITERAL_STRING) {
            String val = lexer.stringVal();
            lexer.nextToken(JSONToken.COMMA);
            return (T) val.toCharArray();

            

Reported by PMD.

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

Line: 24

                  @SuppressWarnings("unchecked")
    public static <T> T deserialze(DefaultJSONParser parser) {
        final JSONLexer lexer = parser.lexer;
        if (lexer.token() == JSONToken.LITERAL_STRING) {
            String val = lexer.stringVal();
            lexer.nextToken(JSONToken.COMMA);
            return (T) val.toCharArray();
        }
        

            

Reported by PMD.

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

Line: 27

                      if (lexer.token() == JSONToken.LITERAL_STRING) {
            String val = lexer.stringVal();
            lexer.nextToken(JSONToken.COMMA);
            return (T) val.toCharArray();
        }
        
        if (lexer.token() == JSONToken.LITERAL_INT) {
            Number val = lexer.integerValue();
            lexer.nextToken(JSONToken.COMMA);

            

Reported by PMD.

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

Line: 30

                          return (T) val.toCharArray();
        }
        
        if (lexer.token() == JSONToken.LITERAL_INT) {
            Number val = lexer.integerValue();
            lexer.nextToken(JSONToken.COMMA);
            return (T) val.toString().toCharArray();
        }


            

Reported by PMD.

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

Line: 33

                      if (lexer.token() == JSONToken.LITERAL_INT) {
            Number val = lexer.integerValue();
            lexer.nextToken(JSONToken.COMMA);
            return (T) val.toString().toCharArray();
        }

        Object value = parser.parse();

        if (value instanceof  String) {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/DateParserTest.java
19 issues
This class has too many methods, consider refactoring it.
Design

Line: 18

              import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.parser.ParserConfig;

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

            

Reported by PMD.

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

Line: 19

              import com.alibaba.fastjson.parser.ParserConfig;

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

                      JSON.defaultLocale = Locale.CHINA;
    }
    
    public void test_date_new() throws Exception {
        DefaultJSONParser parser = new DefaultJSONParser("new Date(1294552193254)");

        java.util.Date date = parser.parseObject(java.util.Date.class);

        Assert.assertEquals(new java.util.Date(1294552193254L), 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: 33

                      parser.close();
    }
    
    public void test_date_new_1() throws Exception {
        DefaultJSONParser parser = new DefaultJSONParser("new Date(1294552193254)");

        java.util.Date date = (java.util.Date) parser.parse();

        Assert.assertEquals(new java.util.Date(1294552193254L), 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: 42

                      parser.close();
    }
    
    public void test_date_0() throws Exception {
        DefaultJSONParser parser = new DefaultJSONParser("1294552193254");

        java.util.Date date = parser.parseObject(java.util.Date.class);

        Assert.assertEquals(new java.util.Date(1294552193254L), 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: 51

                      parser.close();
    }

    public void test_date_1() throws Exception {
        int features = JSON.DEFAULT_PARSER_FEATURE;
        features = Feature.config(features, Feature.AllowISO8601DateFormat, true);
        DefaultJSONParser parser = new DefaultJSONParser("\"2011-01-09T13:49:53.254\"", ParserConfig.getGlobalInstance(), features);

        java.util.Date date = parser.parseObject(java.util.Date.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: 62

                      parser.close();
    }

    public void test_date_2() throws Exception {
        int features = JSON.DEFAULT_PARSER_FEATURE;
        DefaultJSONParser parser = new DefaultJSONParser("new Date(1294552193254)", ParserConfig.getGlobalInstance(), features);

        java.util.Date date = parser.parseObject(java.util.Date.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: 72

                      parser.close();
    }

    public void test_date_3() throws Exception {
        java.util.Date date = JSON.parseObject("\"2011-01-09T13:49:53\"", java.util.Date.class, Feature.AllowISO8601DateFormat);

        Assert.assertEquals(new java.util.Date(1294552193000L), 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: 78

                      Assert.assertEquals(new java.util.Date(1294552193000L), date);
    }

    public void test_date_4() throws Exception {
        int features = JSON.DEFAULT_PARSER_FEATURE;
        features = Feature.config(features, Feature.AllowISO8601DateFormat, true);
        DefaultJSONParser parser = new DefaultJSONParser("\"2011-01-09\"", ParserConfig.getGlobalInstance(), features);

        java.util.Date date = parser.parseObject(java.util.Date.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: 89

                      parser.close();
    }

    public void test_date_5() throws Exception {
        JSONObject object = JSON.parseObject("{d:'2011-01-09T13:49:53'}", Feature.AllowISO8601DateFormat);
        Assert.assertEquals(new java.util.Date(1294552193000L), object.get("d"));
    }

    public void test_date_6() throws Exception {

            

Reported by PMD.

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

    public void test_charArray() throws Exception {
        Assert.assertEquals(null, JSON.parseObject("{}", VO.class).getValue());
        Assert.assertEquals(null, JSON.parseObject("{value:null}", VO.class).getValue());
        Assert.assertEquals(null, JSON.parseObject("{'value':null}", VO.class).getValue());
        Assert.assertEquals(null, JSON.parseObject("{\"value\":null}", VO.class).getValue());
        Assert.assertEquals(0, JSON.parseObject("{\"value\":\"\"}", VO.class).getValue().length);

            

Reported by PMD.

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

Line: 11

              public class CharArrayDeserializerTest extends TestCase {

    public void test_charArray() throws Exception {
        Assert.assertEquals(null, JSON.parseObject("{}", VO.class).getValue());
        Assert.assertEquals(null, JSON.parseObject("{value:null}", VO.class).getValue());
        Assert.assertEquals(null, JSON.parseObject("{'value':null}", VO.class).getValue());
        Assert.assertEquals(null, JSON.parseObject("{\"value\":null}", VO.class).getValue());
        Assert.assertEquals(0, JSON.parseObject("{\"value\":\"\"}", VO.class).getValue().length);
        Assert.assertEquals(2, JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue().length);

            

Reported by PMD.

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

Line: 12

              
    public void test_charArray() throws Exception {
        Assert.assertEquals(null, JSON.parseObject("{}", VO.class).getValue());
        Assert.assertEquals(null, JSON.parseObject("{value:null}", VO.class).getValue());
        Assert.assertEquals(null, JSON.parseObject("{'value':null}", VO.class).getValue());
        Assert.assertEquals(null, JSON.parseObject("{\"value\":null}", VO.class).getValue());
        Assert.assertEquals(0, JSON.parseObject("{\"value\":\"\"}", VO.class).getValue().length);
        Assert.assertEquals(2, JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue().length);
        Assert.assertEquals("ab", new String(JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue()));

            

Reported by PMD.

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

Line: 13

                  public void test_charArray() throws Exception {
        Assert.assertEquals(null, JSON.parseObject("{}", VO.class).getValue());
        Assert.assertEquals(null, JSON.parseObject("{value:null}", VO.class).getValue());
        Assert.assertEquals(null, JSON.parseObject("{'value':null}", VO.class).getValue());
        Assert.assertEquals(null, JSON.parseObject("{\"value\":null}", VO.class).getValue());
        Assert.assertEquals(0, JSON.parseObject("{\"value\":\"\"}", VO.class).getValue().length);
        Assert.assertEquals(2, JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue().length);
        Assert.assertEquals("ab", new String(JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue()));
        Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12}", VO.class).getValue()));

            

Reported by PMD.

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

Line: 14

                      Assert.assertEquals(null, JSON.parseObject("{}", VO.class).getValue());
        Assert.assertEquals(null, JSON.parseObject("{value:null}", VO.class).getValue());
        Assert.assertEquals(null, JSON.parseObject("{'value':null}", VO.class).getValue());
        Assert.assertEquals(null, JSON.parseObject("{\"value\":null}", VO.class).getValue());
        Assert.assertEquals(0, JSON.parseObject("{\"value\":\"\"}", VO.class).getValue().length);
        Assert.assertEquals(2, JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue().length);
        Assert.assertEquals("ab", new String(JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue()));
        Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12}", VO.class).getValue()));
        Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12L}", VO.class).getValue()));

            

Reported by PMD.

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

Line: 15

                      Assert.assertEquals(null, JSON.parseObject("{value:null}", VO.class).getValue());
        Assert.assertEquals(null, JSON.parseObject("{'value':null}", VO.class).getValue());
        Assert.assertEquals(null, JSON.parseObject("{\"value\":null}", VO.class).getValue());
        Assert.assertEquals(0, JSON.parseObject("{\"value\":\"\"}", VO.class).getValue().length);
        Assert.assertEquals(2, JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue().length);
        Assert.assertEquals("ab", new String(JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue()));
        Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12}", VO.class).getValue()));
        Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12L}", VO.class).getValue()));
        Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12S}", VO.class).getValue()));

            

Reported by PMD.

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

Line: 15

                      Assert.assertEquals(null, JSON.parseObject("{value:null}", VO.class).getValue());
        Assert.assertEquals(null, JSON.parseObject("{'value':null}", VO.class).getValue());
        Assert.assertEquals(null, JSON.parseObject("{\"value\":null}", VO.class).getValue());
        Assert.assertEquals(0, JSON.parseObject("{\"value\":\"\"}", VO.class).getValue().length);
        Assert.assertEquals(2, JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue().length);
        Assert.assertEquals("ab", new String(JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue()));
        Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12}", VO.class).getValue()));
        Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12L}", VO.class).getValue()));
        Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12S}", VO.class).getValue()));

            

Reported by PMD.

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

Line: 16

                      Assert.assertEquals(null, JSON.parseObject("{'value':null}", VO.class).getValue());
        Assert.assertEquals(null, JSON.parseObject("{\"value\":null}", VO.class).getValue());
        Assert.assertEquals(0, JSON.parseObject("{\"value\":\"\"}", VO.class).getValue().length);
        Assert.assertEquals(2, JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue().length);
        Assert.assertEquals("ab", new String(JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue()));
        Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12}", VO.class).getValue()));
        Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12L}", VO.class).getValue()));
        Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12S}", VO.class).getValue()));
        Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12B}", VO.class).getValue()));

            

Reported by PMD.

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

Line: 16

                      Assert.assertEquals(null, JSON.parseObject("{'value':null}", VO.class).getValue());
        Assert.assertEquals(null, JSON.parseObject("{\"value\":null}", VO.class).getValue());
        Assert.assertEquals(0, JSON.parseObject("{\"value\":\"\"}", VO.class).getValue().length);
        Assert.assertEquals(2, JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue().length);
        Assert.assertEquals("ab", new String(JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue()));
        Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12}", VO.class).getValue()));
        Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12L}", VO.class).getValue()));
        Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12S}", VO.class).getValue()));
        Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12B}", VO.class).getValue()));

            

Reported by PMD.

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

Line: 17

                      Assert.assertEquals(null, JSON.parseObject("{\"value\":null}", VO.class).getValue());
        Assert.assertEquals(0, JSON.parseObject("{\"value\":\"\"}", VO.class).getValue().length);
        Assert.assertEquals(2, JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue().length);
        Assert.assertEquals("ab", new String(JSON.parseObject("{\"value\":\"ab\"}", VO.class).getValue()));
        Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12}", VO.class).getValue()));
        Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12L}", VO.class).getValue()));
        Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12S}", VO.class).getValue()));
        Assert.assertEquals("12", new String(JSON.parseObject("{\"value\":12B}", VO.class).getValue()));
        Assert.assertEquals("{}", new String(JSON.parseObject("{\"value\":{}}", VO.class).getValue()));

            

Reported by PMD.

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

Line: 15

              
public class BooleanFieldTest_array extends TestCase {

    public void test_model_error_t() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[t", Model.class);
        } 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: 25

                      Assert.assertNotNull(error);
    }
    
    public void test_model_error_tr() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[tr", Model.class);
        } 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: 35

                      Assert.assertNotNull(error);
    }
    
    public void test_model_error_tru() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[tru", Model.class);
        } 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

                  }
    
    
    public void test_model_error_true_notclose() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[true", Model.class);
        } 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: 56

                      Assert.assertNotNull(error);
    }
    
    public void test_model_error_false_notclose() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[false", Model.class);
        } 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: 66

                      Assert.assertNotNull(error);
    }
    
    public void test_model_error_f() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[f", Model.class);
        } 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: 76

                      Assert.assertNotNull(error);
    }
    
    public void test_model_error_fa() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[fa", Model.class);
        } 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: 86

                      Assert.assertNotNull(error);
    }
    
    public void test_model_error_fal() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[fal", Model.class);
        } 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: 97

                  }
    
    
    public void test_model_error_fals() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[fals", Model.class);
        } catch (JSONException ex) {
            error = ex;

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '16'-'20').
Error

Line: 16

              public class BooleanFieldTest_array extends TestCase {

    public void test_model_error_t() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[t", Model.class);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.

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

    public void test_0() throws Exception {
        Timestamp t = new Timestamp(System.currentTimeMillis());

        String text = JSON.toJSONString(t);

        Timestamp t1 = JSON.parseObject(text, Timestamp.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: 23

                      Assert.assertEquals(t, t1);
    }

    public void test_1() throws Exception {
        long t1 = System.currentTimeMillis();
        String text = JSON.toJSONString(t1);

        Timestamp t2 = JSON.parseObject(text, Timestamp.class);
        Assert.assertEquals(t1, t2.getTime());

            

Reported by PMD.

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

Line: 28

                      String text = JSON.toJSONString(t1);

        Timestamp t2 = JSON.parseObject(text, Timestamp.class);
        Assert.assertEquals(t1, t2.getTime());
    }

    public void test_2() throws Exception {
        Date t = new Date(System.currentTimeMillis());


            

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

                      Assert.assertEquals(t1, t2.getTime());
    }

    public void test_2() throws Exception {
        Date t = new Date(System.currentTimeMillis());

        String text = JSON.toJSONString(t);

        Date t1 = JSON.parseObject(text, Date.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: 40

                      Assert.assertEquals(t, t1);
    }

    public void test_3() throws Exception {
        long t1 = System.currentTimeMillis();
        String text = JSON.toJSONString(t1);

        Date t2 = JSON.parseObject(text, Date.class);
        Assert.assertEquals(t1, t2.getTime());

            

Reported by PMD.

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

Line: 45

                      String text = JSON.toJSONString(t1);

        Date t2 = JSON.parseObject(text, Date.class);
        Assert.assertEquals(t1, t2.getTime());
    }

    public void test_4() throws Exception {
        A a = new A();
        a.setDate(new java.sql.Date(System.currentTimeMillis()));

            

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

                      Assert.assertEquals(t1, t2.getTime());
    }

    public void test_4() throws Exception {
        A a = new A();
        a.setDate(new java.sql.Date(System.currentTimeMillis()));
        a.setTime(new java.sql.Timestamp(System.currentTimeMillis()));
        String text = JSON.toJSONString(a);


            

Reported by PMD.

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

Line: 56

              
        A a1 = JSON.parseObject(text, A.class);

        Assert.assertEquals(a.getDate(), a1.getDate());
        Assert.assertEquals(a.getTime(), a1.getTime());
    }

    public void test_error_0() throws Exception {
        Exception error = null;

            

Reported by PMD.

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

Line: 57

                      A a1 = JSON.parseObject(text, A.class);

        Assert.assertEquals(a.getDate(), a1.getDate());
        Assert.assertEquals(a.getTime(), a1.getTime());
    }

    public void test_error_0() throws Exception {
        Exception error = null;
        try {

            

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

                      Assert.assertEquals(a.getTime(), a1.getTime());
    }

    public void test_error_0() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("\"222A\"", Timestamp.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/TestExternal6.java
18 issues
System.out.println is used
Design

Line: 37

              
        {
            String text = JSON.toJSONString(obj);
            System.out.println(text);
        }

        String text = JSON.toJSONString(obj, SerializerFeature.WriteClassName, SerializerFeature.WriteMapNullValue);
        System.out.println(text);
        JSON.parseObject(text, clazz, confg);

            

Reported by PMD.

System.out.println is used
Design

Line: 41

                      }

        String text = JSON.toJSONString(obj, SerializerFeature.WriteClassName, SerializerFeature.WriteMapNullValue);
        System.out.println(text);
        JSON.parseObject(text, clazz, confg);
        String clazzName = JSON.parse(text, confg).getClass().getName();
        Assert.assertEquals(clazz.getName(), clazzName);
    }


            

Reported by PMD.

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

Line: 20

              import com.alibaba.fastjson.serializer.SerializerFeature;

public class TestExternal6 extends TestCase {
    ParserConfig confg = ParserConfig.global;

    protected void setUp() throws Exception {
        confg.addAccept("org.mule.esb.model");
    }


            

Reported by PMD.

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

Line: 22

              public class TestExternal6 extends TestCase {
    ParserConfig confg = ParserConfig.global;

    protected void setUp() throws Exception {
        confg.addAccept("org.mule.esb.model");
    }

    public void test_0() throws Exception {
        ExtClassLoader classLoader = new ExtClassLoader();

            

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

                      confg.addAccept("org.mule.esb.model");
    }

    public void test_0() throws Exception {
        ExtClassLoader classLoader = new ExtClassLoader();
        Class<?> clazz = classLoader.loadClass("org.mule.esb.model.tcc.result.EsbResultModel");
        Method[] methods = clazz.getMethods();
        Method method = clazz.getMethod("setReturnValue", new Class[] { Serializable.class });


            

Reported by PMD.

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

Line: 29

                  public void test_0() throws Exception {
        ExtClassLoader classLoader = new ExtClassLoader();
        Class<?> clazz = classLoader.loadClass("org.mule.esb.model.tcc.result.EsbResultModel");
        Method[] methods = clazz.getMethods();
        Method method = clazz.getMethod("setReturnValue", new Class[] { Serializable.class });

        Object obj = clazz.newInstance();
//        method.invoke(obj, "AAAA");


            

Reported by PMD.

Avoid unused local variables such as 'method'.
Design

Line: 30

                      ExtClassLoader classLoader = new ExtClassLoader();
        Class<?> clazz = classLoader.loadClass("org.mule.esb.model.tcc.result.EsbResultModel");
        Method[] methods = clazz.getMethods();
        Method method = clazz.getMethod("setReturnValue", new Class[] { Serializable.class });

        Object obj = clazz.newInstance();
//        method.invoke(obj, "AAAA");

        {

            

Reported by PMD.

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

Line: 32

                      Method[] methods = clazz.getMethods();
        Method method = clazz.getMethod("setReturnValue", new Class[] { Serializable.class });

        Object obj = clazz.newInstance();
//        method.invoke(obj, "AAAA");

        {
            String text = JSON.toJSONString(obj);
            System.out.println(text);

            

Reported by PMD.

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

Line: 43

                      String text = JSON.toJSONString(obj, SerializerFeature.WriteClassName, SerializerFeature.WriteMapNullValue);
        System.out.println(text);
        JSON.parseObject(text, clazz, confg);
        String clazzName = JSON.parse(text, confg).getClass().getName();
        Assert.assertEquals(clazz.getName(), clazzName);
    }

    public static class ExtClassLoader extends ClassLoader {


            

Reported by PMD.

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

Line: 43

                      String text = JSON.toJSONString(obj, SerializerFeature.WriteClassName, SerializerFeature.WriteMapNullValue);
        System.out.println(text);
        JSON.parseObject(text, clazz, confg);
        String clazzName = JSON.parse(text, confg).getClass().getName();
        Assert.assertEquals(clazz.getName(), clazzName);
    }

    public static class ExtClassLoader extends ClassLoader {


            

Reported by PMD.

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

    public void test_0() throws Exception {
        Entity entity = JSON.parseObject("{,,,list:[,,,{value:3}]}", Entity.class);
        Assert.assertEquals(3, entity.getList().get(0).getValue());
    }

    public void test_1() throws Exception {

            

Reported by PMD.

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

Line: 16

              
    public void test_0() throws Exception {
        Entity entity = JSON.parseObject("{,,,list:[,,,{value:3}]}", Entity.class);
        Assert.assertEquals(3, entity.getList().get(0).getValue());
    }

    public void test_1() throws Exception {
        Entity entity = JSON.parseObject("{list:[{value:3}]}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
        Assert.assertEquals(3, entity.getList().get(0).getValue());

            

Reported by PMD.

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

Line: 16

              
    public void test_0() throws Exception {
        Entity entity = JSON.parseObject("{,,,list:[,,,{value:3}]}", Entity.class);
        Assert.assertEquals(3, entity.getList().get(0).getValue());
    }

    public void test_1() throws Exception {
        Entity entity = JSON.parseObject("{list:[{value:3}]}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
        Assert.assertEquals(3, entity.getList().get(0).getValue());

            

Reported by PMD.

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

Line: 16

              
    public void test_0() throws Exception {
        Entity entity = JSON.parseObject("{,,,list:[,,,{value:3}]}", Entity.class);
        Assert.assertEquals(3, entity.getList().get(0).getValue());
    }

    public void test_1() throws Exception {
        Entity entity = JSON.parseObject("{list:[{value:3}]}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
        Assert.assertEquals(3, entity.getList().get(0).getValue());

            

Reported by PMD.

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

Line: 19

                      Assert.assertEquals(3, entity.getList().get(0).getValue());
    }

    public void test_1() throws Exception {
        Entity entity = JSON.parseObject("{list:[{value:3}]}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
        Assert.assertEquals(3, entity.getList().get(0).getValue());
    }
    
    public void test_null() throws Exception {

            

Reported by PMD.

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

Line: 21

              
    public void test_1() throws Exception {
        Entity entity = JSON.parseObject("{list:[{value:3}]}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
        Assert.assertEquals(3, entity.getList().get(0).getValue());
    }
    
    public void test_null() throws Exception {
        Entity entity = JSON.parseObject("{list:null}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
        Assert.assertEquals(null, entity.getList());

            

Reported by PMD.

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

Line: 21

              
    public void test_1() throws Exception {
        Entity entity = JSON.parseObject("{list:[{value:3}]}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
        Assert.assertEquals(3, entity.getList().get(0).getValue());
    }
    
    public void test_null() throws Exception {
        Entity entity = JSON.parseObject("{list:null}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
        Assert.assertEquals(null, entity.getList());

            

Reported by PMD.

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

Line: 21

              
    public void test_1() throws Exception {
        Entity entity = JSON.parseObject("{list:[{value:3}]}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
        Assert.assertEquals(3, entity.getList().get(0).getValue());
    }
    
    public void test_null() throws Exception {
        Entity entity = JSON.parseObject("{list:null}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
        Assert.assertEquals(null, entity.getList());

            

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

                      Assert.assertEquals(3, entity.getList().get(0).getValue());
    }
    
    public void test_null() throws Exception {
        Entity entity = JSON.parseObject("{list:null}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
        Assert.assertEquals(null, entity.getList());
    }
    public void test_null2() throws Exception {
        Entity entity = JSON.parseObject("{list:[null]}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);

            

Reported by PMD.

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

Line: 26

                  
    public void test_null() throws Exception {
        Entity entity = JSON.parseObject("{list:null}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
        Assert.assertEquals(null, entity.getList());
    }
    public void test_null2() throws Exception {
        Entity entity = JSON.parseObject("{list:[null]}", Entity.class, 0, Feature.AllowUnQuotedFieldNames);
        Assert.assertEquals(null, entity.getList().get(0));
    }

            

Reported by PMD.

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

Line: 18

                      entity.setValue(3L);

        String text = JSON.toJSONString(entity, SerializerFeature.WriteClassName);
        System.out.println(text);
        Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.bug.Bug_for_smoothrat4$Entity\",\"value\":3L}",
                            text);

        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertEquals(Long.valueOf(3), entity2.getValue());

            

Reported by PMD.

System.out.println is used
Design

Line: 33

                      entity.setValue(3);

        String text = JSON.toJSONString(entity, SerializerFeature.WriteClassName);
        System.out.println(text);
        Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.bug.Bug_for_smoothrat4$Entity\",\"value\":3}", text);

        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertEquals(Integer.valueOf(3), entity2.getValue());
    }

            

Reported by PMD.

System.out.println is used
Design

Line: 47

                      entity.setValue((short) 3);

        String text = JSON.toJSONString(entity, SerializerFeature.WriteClassName);
        System.out.println(text);
        Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.bug.Bug_for_smoothrat4$Entity\",\"value\":3S}",
                            text);

        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertEquals(Short.valueOf((short) 3), entity2.getValue());

            

Reported by PMD.

System.out.println is used
Design

Line: 62

                      entity.setValue((byte) 3);

        String text = JSON.toJSONString(entity, SerializerFeature.WriteClassName);
        System.out.println(text);
        Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.bug.Bug_for_smoothrat4$Entity\",\"value\":3B}",
                            text);

        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertEquals(Byte.valueOf((byte) 3), entity2.getValue());

            

Reported by PMD.

System.out.println is used
Design

Line: 77

                      entity.setValue(3F);

        String text = JSON.toJSONString(entity, SerializerFeature.WriteClassName);
        System.out.println(text);
        Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.bug.Bug_for_smoothrat4$Entity\",\"value\":3.0F}",
                            text);

        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertEquals(3F, entity2.getValue());

            

Reported by PMD.

System.out.println is used
Design

Line: 92

                      entity.setValue(3D);

        String text = JSON.toJSONString(entity, SerializerFeature.WriteClassName);
        System.out.println(text);
        Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.bug.Bug_for_smoothrat4$Entity\",\"value\":3.0D}",
                            text);

        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertEquals(3D, entity2.getValue());

            

Reported by PMD.

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

Line: 11

              
public class Bug_for_smoothrat4 extends TestCase {

    public void test_long() throws Exception {

        Entity entity = new Entity();

        entity.setValue(3L);


            

Reported by PMD.

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

Line: 23

                                          text);

        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertEquals(Long.valueOf(3), entity2.getValue());
    }

    public void test_int() throws Exception {

        Entity entity = new Entity();

            

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(Long.valueOf(3), entity2.getValue());
    }

    public void test_int() throws Exception {

        Entity entity = new Entity();

        entity.setValue(3);


            

Reported by PMD.

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

Line: 37

                      Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.bug.Bug_for_smoothrat4$Entity\",\"value\":3}", text);

        Entity entity2 = JSON.parseObject(text, Entity.class);
        Assert.assertEquals(Integer.valueOf(3), entity2.getValue());
    }

    public void test_short() throws Exception {

        Entity entity = new Entity();

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/jsonpatch/JSONPatchTest_0.java
18 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: 8

              import junit.framework.TestCase;

public class JSONPatchTest_0 extends TestCase {
    public void test_for_multi_0() throws Exception {
        String original = "{\n" +
                "  \"baz\": \"qux\",\n" +
                "  \"foo\": \"bar\"\n" +
                "}";


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 21

                              "]";

        String result = JSONPatch.apply(original, patch);
        assertEquals("{\"baz\":\"boo\",\"hello\":[\"world\"]}", result);
    }

    public void test_for_add_1() throws Exception {
        String original = "{}";


            

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

                      assertEquals("{\"baz\":\"boo\",\"hello\":[\"world\"]}", result);
    }

    public void test_for_add_1() throws Exception {
        String original = "{}";

        String patch = "{ \"op\": \"add\", \"path\": \"/a/b/c\", \"value\": [ \"foo\", \"bar\" ] }";

        String result = JSONPatch.apply(original, patch);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 30

                      String patch = "{ \"op\": \"add\", \"path\": \"/a/b/c\", \"value\": [ \"foo\", \"bar\" ] }";

        String result = JSONPatch.apply(original, patch);
        assertEquals("{\"a\":{\"b\":{\"c\":[\"foo\",\"bar\"]}}}", result);
    }

    public void test_for_remove_0() throws Exception {
        String original = "{}";


            

Reported by PMD.

The String literal '{\'a\':{\'b\':{\'c\':[\'foo\',\'bar\']}}}' appears 6 times in this file; the first occurrence is on line 30
Error

Line: 30

                      String patch = "{ \"op\": \"add\", \"path\": \"/a/b/c\", \"value\": [ \"foo\", \"bar\" ] }";

        String result = JSONPatch.apply(original, patch);
        assertEquals("{\"a\":{\"b\":{\"c\":[\"foo\",\"bar\"]}}}", result);
    }

    public void test_for_remove_0() throws Exception {
        String original = "{}";


            

Reported by PMD.

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

Line: 33

                      assertEquals("{\"a\":{\"b\":{\"c\":[\"foo\",\"bar\"]}}}", result);
    }

    public void test_for_remove_0() throws Exception {
        String original = "{}";

        String patch = "{ \"op\": \"remove\", \"path\": \"/a/b/c\" }\n";

        String result = JSONPatch.apply(original, patch);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 39

                      String patch = "{ \"op\": \"remove\", \"path\": \"/a/b/c\" }\n";

        String result = JSONPatch.apply(original, patch);
        assertEquals("{}", result);
    }

    public void test_for_remove_1() throws Exception {
        String original = "{\"a\":{\"b\":{\"c\":[\"foo\",\"bar\"]}}}";


            

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

                      assertEquals("{}", result);
    }

    public void test_for_remove_1() throws Exception {
        String original = "{\"a\":{\"b\":{\"c\":[\"foo\",\"bar\"]}}}";

        String patch = "{ \"op\": \"remove\", \"path\": \"/a/b/c\" }\n";

        String result = JSONPatch.apply(original, patch);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 48

                      String patch = "{ \"op\": \"remove\", \"path\": \"/a/b/c\" }\n";

        String result = JSONPatch.apply(original, patch);
        assertEquals("{\"a\":{\"b\":{}}}", result);
    }

    public void test_for_replace_1() throws Exception {
        String original = "{\"a\":{\"b\":{\"c\":[\"foo\",\"bar\"]}}}";


            

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

                      assertEquals("{\"a\":{\"b\":{}}}", result);
    }

    public void test_for_replace_1() throws Exception {
        String original = "{\"a\":{\"b\":{\"c\":[\"foo\",\"bar\"]}}}";

        String patch = "{ \"op\": \"replace\", \"path\": \"/a/b/c\", \"value\": 42 }";

        String result = JSONPatch.apply(original, patch);

            

Reported by PMD.

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

Line: 14

              import junit.framework.TestCase;

public class Bug_for_issue_430 extends TestCase {
    protected void setUp() throws Exception {
        ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Bug_for_issue_430");
    }

    public void test_for_issue() throws Exception {
        String text = "[{\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}, {\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}]";

            

Reported by PMD.

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

Line: 15

              
public class Bug_for_issue_430 extends TestCase {
    protected void setUp() throws Exception {
        ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Bug_for_issue_430");
    }

    public void test_for_issue() throws Exception {
        String text = "[{\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}, {\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}]";
        JSONArray array = JSON.parseArray(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: 18

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

    public void test_for_issue() throws Exception {
        String text = "[{\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}, {\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}]";
        JSONArray array = JSON.parseArray(text);
        Assert.assertEquals(FooModel.class, array.get(0).getClass());
        Assert.assertEquals(FooModel.class, array.get(1).getClass());
        

            

Reported by PMD.

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

Line: 21

                  public void test_for_issue() throws Exception {
        String text = "[{\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}, {\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}]";
        JSONArray array = JSON.parseArray(text);
        Assert.assertEquals(FooModel.class, array.get(0).getClass());
        Assert.assertEquals(FooModel.class, array.get(1).getClass());
        
        Assert.assertNull(((FooModel)array.get(0)).fooCollection);
        Assert.assertNull(((FooModel)array.get(1)).fooCollection);
    }

            

Reported by PMD.

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

Line: 21

                  public void test_for_issue() throws Exception {
        String text = "[{\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}, {\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}]";
        JSONArray array = JSON.parseArray(text);
        Assert.assertEquals(FooModel.class, array.get(0).getClass());
        Assert.assertEquals(FooModel.class, array.get(1).getClass());
        
        Assert.assertNull(((FooModel)array.get(0)).fooCollection);
        Assert.assertNull(((FooModel)array.get(1)).fooCollection);
    }

            

Reported by PMD.

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

Line: 22

                      String text = "[{\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}, {\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}]";
        JSONArray array = JSON.parseArray(text);
        Assert.assertEquals(FooModel.class, array.get(0).getClass());
        Assert.assertEquals(FooModel.class, array.get(1).getClass());
        
        Assert.assertNull(((FooModel)array.get(0)).fooCollection);
        Assert.assertNull(((FooModel)array.get(1)).fooCollection);
    }
    

            

Reported by PMD.

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

Line: 22

                      String text = "[{\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}, {\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}]";
        JSONArray array = JSON.parseArray(text);
        Assert.assertEquals(FooModel.class, array.get(0).getClass());
        Assert.assertEquals(FooModel.class, array.get(1).getClass());
        
        Assert.assertNull(((FooModel)array.get(0)).fooCollection);
        Assert.assertNull(((FooModel)array.get(1)).fooCollection);
    }
    

            

Reported by PMD.

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

Line: 24

                      Assert.assertEquals(FooModel.class, array.get(0).getClass());
        Assert.assertEquals(FooModel.class, array.get(1).getClass());
        
        Assert.assertNull(((FooModel)array.get(0)).fooCollection);
        Assert.assertNull(((FooModel)array.get(1)).fooCollection);
    }
    
    public void test_for_issue_1() throws Exception {
        String text = "[{\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}, {\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}]";

            

Reported by PMD.

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

Line: 25

                      Assert.assertEquals(FooModel.class, array.get(1).getClass());
        
        Assert.assertNull(((FooModel)array.get(0)).fooCollection);
        Assert.assertNull(((FooModel)array.get(1)).fooCollection);
    }
    
    public void test_for_issue_1() throws Exception {
        String text = "[{\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}, {\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}]";
        JSONArray array = (JSONArray) JSON.parse(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: 28

                      Assert.assertNull(((FooModel)array.get(1)).fooCollection);
    }
    
    public void test_for_issue_1() throws Exception {
        String text = "[{\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}, {\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}]";
        JSONArray array = (JSONArray) JSON.parse(text);
        Assert.assertEquals(FooModel.class, array.get(0).getClass());
        Assert.assertEquals(FooModel.class, array.get(1).getClass());
        

            

Reported by PMD.