The following issues were found

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

    public void test_codec() throws Exception {
        User user = new User();
        user.setValue(new Integer[] { Integer.valueOf(1), Integer.valueOf(2) });

        SerializeConfig mapping = new SerializeConfig();
        mapping.setAsmEnable(false);

            

Reported by PMD.

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

Line: 22

              
        User user1 = JSON.parseObject(text, User.class);

        Assert.assertEquals(user1.getValue()[0], user.getValue()[0]);
        Assert.assertEquals(user1.getValue()[1], user.getValue()[1]);
    }

    public void test_codec_null() throws Exception {
        User user = new User();

            

Reported by PMD.

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

Line: 23

                      User user1 = JSON.parseObject(text, User.class);

        Assert.assertEquals(user1.getValue()[0], user.getValue()[0]);
        Assert.assertEquals(user1.getValue()[1], user.getValue()[1]);
    }

    public void test_codec_null() throws Exception {
        User user = new User();
        user.setValue(null);

            

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(user1.getValue()[1], user.getValue()[1]);
    }

    public void test_codec_null() throws Exception {
        User user = new User();
        user.setValue(null);

        SerializeConfig mapping = new SerializeConfig();
        mapping.setAsmEnable(false);

            

Reported by PMD.

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

Line: 36

              
        User user1 = JSON.parseObject(text, User.class);

        Assert.assertEquals(user1.getValue(), user.getValue());
    }

    public void test_codec_null_1() throws Exception {
        User user = new User();
        user.setValue(null);

            

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

                      Assert.assertEquals(user1.getValue(), user.getValue());
    }

    public void test_codec_null_1() throws Exception {
        User user = new User();
        user.setValue(null);

        SerializeConfig mapping = new SerializeConfig();
        mapping.setAsmEnable(false);

            

Reported by PMD.

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

Line: 49

              
        User user1 = JSON.parseObject(text, User.class);

        Assert.assertEquals(0, user1.getValue().length);
    }

    public static class User {

        private Integer[] value;

            

Reported by PMD.

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

Line: 49

              
        User user1 = JSON.parseObject(text, User.class);

        Assert.assertEquals(0, user1.getValue().length);
    }

    public static class User {

        private Integer[] value;

            

Reported by PMD.

Returning 'value' may expose an internal array.
Design

Line: 57

                      private Integer[] value;

        public Integer[] getValue() {
            return value;
        }

        public void setValue(Integer[] value) {
            this.value = value;
        }

            

Reported by PMD.

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

Line: 60

                          return value;
        }

        public void setValue(Integer[] value) {
            this.value = value;
        }

    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/ref/RefTest7.java
11 issues
System.out.println is used
Design

Line: 21

                      VO[] root = new VO[] { vo };

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

        VO[] array2 = JSON.parseObject(text, VO[].class);
        Assert.assertEquals(1, array2.length);
        Assert.assertNotNull(array2[0].getA());
        Assert.assertNotNull(array2[0].getB());

            

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 RefTest7 extends TestCase {

    public void test_bug_for_juqkai() throws Exception {

        VO vo = new VO();
        C c = new C();
        vo.setA(new A(c));
        vo.setB(new B(c));

            

Reported by PMD.

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

Line: 27

                      Assert.assertEquals(1, array2.length);
        Assert.assertNotNull(array2[0].getA());
        Assert.assertNotNull(array2[0].getB());
        Assert.assertNotNull(array2[0].getA().getC());
        Assert.assertNotNull(array2[0].getB().getC());
        Assert.assertSame(array2[0].getA().getC(), array2[0].getB().getC());
    }

    public static class VO {

            

Reported by PMD.

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

Line: 27

                      Assert.assertEquals(1, array2.length);
        Assert.assertNotNull(array2[0].getA());
        Assert.assertNotNull(array2[0].getB());
        Assert.assertNotNull(array2[0].getA().getC());
        Assert.assertNotNull(array2[0].getB().getC());
        Assert.assertSame(array2[0].getA().getC(), array2[0].getB().getC());
    }

    public static class VO {

            

Reported by PMD.

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

Line: 28

                      Assert.assertNotNull(array2[0].getA());
        Assert.assertNotNull(array2[0].getB());
        Assert.assertNotNull(array2[0].getA().getC());
        Assert.assertNotNull(array2[0].getB().getC());
        Assert.assertSame(array2[0].getA().getC(), array2[0].getB().getC());
    }

    public static class VO {


            

Reported by PMD.

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

Line: 28

                      Assert.assertNotNull(array2[0].getA());
        Assert.assertNotNull(array2[0].getB());
        Assert.assertNotNull(array2[0].getA().getC());
        Assert.assertNotNull(array2[0].getB().getC());
        Assert.assertSame(array2[0].getA().getC(), array2[0].getB().getC());
    }

    public static class VO {


            

Reported by PMD.

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

Line: 29

                      Assert.assertNotNull(array2[0].getB());
        Assert.assertNotNull(array2[0].getA().getC());
        Assert.assertNotNull(array2[0].getB().getC());
        Assert.assertSame(array2[0].getA().getC(), array2[0].getB().getC());
    }

    public static class VO {

        private A a;

            

Reported by PMD.

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

Line: 29

                      Assert.assertNotNull(array2[0].getB());
        Assert.assertNotNull(array2[0].getA().getC());
        Assert.assertNotNull(array2[0].getB().getC());
        Assert.assertSame(array2[0].getA().getC(), array2[0].getB().getC());
    }

    public static class VO {

        private A a;

            

Reported by PMD.

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

Line: 29

                      Assert.assertNotNull(array2[0].getB());
        Assert.assertNotNull(array2[0].getA().getC());
        Assert.assertNotNull(array2[0].getB().getC());
        Assert.assertSame(array2[0].getA().getC(), array2[0].getB().getC());
    }

    public static class VO {

        private A a;

            

Reported by PMD.

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

Line: 29

                      Assert.assertNotNull(array2[0].getB());
        Assert.assertNotNull(array2[0].getA().getC());
        Assert.assertNotNull(array2[0].getB().getC());
        Assert.assertSame(array2[0].getA().getC(), array2[0].getB().getC());
    }

    public static class VO {

        private A a;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_3300/Issue3329.java
11 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 14

              import java.lang.reflect.Type;

public class Issue3329 extends TestCase {
    public void test_for_issue() throws Exception {
        ParserConfig config = new ParserConfig();
        IdentityHashMap<Type, ObjectDeserializer> deserializers = config.getDeserializers();
        int initSize = deserializers.size();
        for (int i = 0; i < 1000 * 10; ++i) {
            assertEquals(123,

            

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

              import java.lang.reflect.Type;

public class Issue3329 extends TestCase {
    public void test_for_issue() throws Exception {
        ParserConfig config = new ParserConfig();
        IdentityHashMap<Type, ObjectDeserializer> deserializers = config.getDeserializers();
        int initSize = deserializers.size();
        for (int i = 0; i < 1000 * 10; ++i) {
            assertEquals(123,

            

Reported by PMD.

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

Line: 17

                  public void test_for_issue() throws Exception {
        ParserConfig config = new ParserConfig();
        IdentityHashMap<Type, ObjectDeserializer> deserializers = config.getDeserializers();
        int initSize = deserializers.size();
        for (int i = 0; i < 1000 * 10; ++i) {
            assertEquals(123,
                ((VO<User>) JSON.parseObject("{\"value\":{\"id\":123}}",
                        new ParameterizedTypeImpl(new Type[] {User.class}, null, VO.class),
                        config

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

                      IdentityHashMap<Type, ObjectDeserializer> deserializers = config.getDeserializers();
        int initSize = deserializers.size();
        for (int i = 0; i < 1000 * 10; ++i) {
            assertEquals(123,
                ((VO<User>) JSON.parseObject("{\"value\":{\"id\":123}}",
                        new ParameterizedTypeImpl(new Type[] {User.class}, null, VO.class),
                        config
                        )).value.id
            );

            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 21

                      for (int i = 0; i < 1000 * 10; ++i) {
            assertEquals(123,
                ((VO<User>) JSON.parseObject("{\"value\":{\"id\":123}}",
                        new ParameterizedTypeImpl(new Type[] {User.class}, null, VO.class),
                        config
                        )).value.id
            );
        }


            

Reported by PMD.

Avoid instantiating new objects inside loops
Performance

Line: 21

                      for (int i = 0; i < 1000 * 10; ++i) {
            assertEquals(123,
                ((VO<User>) JSON.parseObject("{\"value\":{\"id\":123}}",
                        new ParameterizedTypeImpl(new Type[] {User.class}, null, VO.class),
                        config
                        )).value.id
            );
        }


            

Reported by PMD.

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

Line: 28

                      }


        assertEquals(2, deserializers.size() - initSize);
    }

    public static class VO<T> {
        public T value;
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 28

                      }


        assertEquals(2, deserializers.size() - initSize);
    }

    public static class VO<T> {
        public T value;
    }

            

Reported by PMD.

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

Line: 32

                  }

    public static class VO<T> {
        public T value;
    }

    public static class User {
        public int id;
    }

            

Reported by PMD.

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

Line: 36

                  }

    public static class User {
        public int id;
    }
}

            

Reported by PMD.

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

    public void test_0() throws Exception {
        VO vo = (VO) JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.parser.JSONLexerTest_2$VO\"}", VO.class);
        Assert.assertNotNull(vo);
    }

    public void test_1() 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: 20

                      Assert.assertNotNull(vo);
    }

    public void test_1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.parser.JSONLexerTest_2$VO1\"}", VO.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: 30

                      Assert.assertNotNull(error);
    }

    public void test_2() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.parser.JSONLexerTest_2$A\"}", VO.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: 40

                      Assert.assertNotNull(error);
    }

    public void test_a() throws Exception {
        P a = JSON.parseObject("{\"vo\":{\"@type\":\"com.alibaba.json.bvt.parser.JSONLexerTest_2$VO\"}}", P.class);
        Assert.assertNotNull(a);
    }

    public void test_list() throws Exception {

            

Reported by PMD.

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

Line: 45

                      Assert.assertNotNull(a);
    }

    public void test_list() throws Exception {
        List<VO> list = JSON.parseObject("[{\"@type\":\"com.alibaba.json.bvt.parser.JSONLexerTest_2$VO\"}]",
                                         new TypeReference<List<VO>>() {
                                         });
        Assert.assertNotNull(list);
        Assert.assertNotNull(list.get(0));

            

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

                      Assert.assertNotNull(list.get(0));
    }

    public void test_list_2() throws Exception {
        List<VO> list = JSON.parseObject("[{\"@type\":\"com.alibaba.json.bvt.parser.JSONLexerTest_2$VO\"},{}]",
                                         new TypeReference<List<VO>>() {
                                         });
        Assert.assertNotNull(list);
        Assert.assertEquals(2, list.size());

            

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

                      Assert.assertNotNull(list.get(1));
    }

    public void test_error() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[{\"@type\":\"com.alibaba.json.bvt.parser.JSONLexerTest_2$VO\"}[]",
                             new TypeReference<List<VO>>() {
                             });

            

Reported by PMD.

Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block
Design

Line: 69

                          JSON.parseObject("[{\"@type\":\"com.alibaba.json.bvt.parser.JSONLexerTest_2$VO\"}[]",
                             new TypeReference<List<VO>>() {
                             });
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }


            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '21'-'25').
Error

Line: 21

                  }

    public void test_1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.parser.JSONLexerTest_2$VO1\"}", VO.class);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.

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

Line: 31

                  }

    public void test_2() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"@type\":\"com.alibaba.json.bvt.parser.JSONLexerTest_2$A\"}", VO.class);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.

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

Line: 37

                      
        String json = JSON.toJSONString(original, SerializerFeature.UseISO8601DateFormat);

        System.out.println(json); //V1.2.4 输出{"calendar":"2015-05-23","date":"2015-05-23"} , V1.2.6 输出{"calendar":"2015-05-23+08:00","date":"2015-05-23+08:00"}

        Model actual = JSON.parseObject(json, Model.class);

        Assert.assertNotNull(actual);
        Assert.assertNotNull(actual.getDate());

            

Reported by PMD.

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

Line: 17

              import junit.framework.TestCase;

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

                      JSON.defaultLocale = Locale.CHINA;
    }
    
    public void test_for_issue() throws Exception {
        
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd", JSON.defaultLocale);
        format.setTimeZone(JSON.defaultTimeZone);
        Date date = format.parse("2015-05-23");


            

Reported by PMD.

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

Line: 29

                      Date date = format.parse("2015-05-23");

        Calendar c = Calendar.getInstance(JSON.defaultTimeZone, JSON.defaultLocale);
        c.setTime(date);

        Model original = new Model();
        original.setDate(date);
        original.setCalendar(c);
        

            

Reported by PMD.

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

Line: 42

                      Model actual = JSON.parseObject(json, Model.class);

        Assert.assertNotNull(actual);
        Assert.assertNotNull(actual.getDate());
        Assert.assertNotNull(actual.getCalendar());

        Assert.assertEquals("与序列化前比较不相等", original.getDate(), actual.getDate());

        Assert.assertEquals("序列化后的Date 和 Calendar 不相等", actual.getDate(), actual.getCalendar().getTime());

            

Reported by PMD.

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

Line: 43

              
        Assert.assertNotNull(actual);
        Assert.assertNotNull(actual.getDate());
        Assert.assertNotNull(actual.getCalendar());

        Assert.assertEquals("与序列化前比较不相等", original.getDate(), actual.getDate());

        Assert.assertEquals("序列化后的Date 和 Calendar 不相等", actual.getDate(), actual.getCalendar().getTime());
    }

            

Reported by PMD.

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

Line: 45

                      Assert.assertNotNull(actual.getDate());
        Assert.assertNotNull(actual.getCalendar());

        Assert.assertEquals("与序列化前比较不相等", original.getDate(), actual.getDate());

        Assert.assertEquals("序列化后的Date 和 Calendar 不相等", actual.getDate(), actual.getCalendar().getTime());
    }
    
    public static class Model {

            

Reported by PMD.

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

Line: 47

              
        Assert.assertEquals("与序列化前比较不相等", original.getDate(), actual.getDate());

        Assert.assertEquals("序列化后的Date 和 Calendar 不相等", actual.getDate(), actual.getCalendar().getTime());
    }
    
    public static class Model {
        private Date date;
        private Calendar calendar;

            

Reported by PMD.

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

Line: 47

              
        Assert.assertEquals("与序列化前比较不相等", original.getDate(), actual.getDate());

        Assert.assertEquals("序列化后的Date 和 Calendar 不相等", actual.getDate(), actual.getCalendar().getTime());
    }
    
    public static class Model {
        private Date date;
        private Calendar calendar;

            

Reported by PMD.

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

Line: 47

              
        Assert.assertEquals("与序列化前比较不相等", original.getDate(), actual.getDate());

        Assert.assertEquals("序列化后的Date 和 Calendar 不相等", actual.getDate(), actual.getCalendar().getTime());
    }
    
    public static class Model {
        private Date date;
        private Calendar calendar;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_2900/Issue2939.java
11 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 13

              import java.util.concurrent.ArrayBlockingQueue;

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

        LinkedMultiValueMap multiValueMap = new LinkedMultiValueMap();
        multiValueMap.add("k1","k11");
        multiValueMap.add("k1","k12");
        multiValueMap.add("k1","k13");

            

Reported by PMD.

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

Line: 13

              import java.util.concurrent.ArrayBlockingQueue;

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

        LinkedMultiValueMap multiValueMap = new LinkedMultiValueMap();
        multiValueMap.add("k1","k11");
        multiValueMap.add("k1","k12");
        multiValueMap.add("k1","k13");

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 23

              

        String json = JSON.toJSONString(multiValueMap);
        assertEquals("{\"k1\":[\"k11\",\"k12\",\"k13\"],\"k2\":[\"k21\"]}", json);


        Object obj = JSON.parseObject(json, LinkedMultiValueMap.class);
        assertTrue(obj != null);


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 27

              

        Object obj = JSON.parseObject(json, LinkedMultiValueMap.class);
        assertTrue(obj != null);

        LinkedMultiValueMap map = (LinkedMultiValueMap) obj;
        assertSame(3, map.get("k1").size());

    }

            

Reported by PMD.

Use assertNull(x) instead of assertTrue(x==null), or assertNotNull(x) vs assertFalse(x==null)
Design

Line: 27

              

        Object obj = JSON.parseObject(json, LinkedMultiValueMap.class);
        assertTrue(obj != null);

        LinkedMultiValueMap map = (LinkedMultiValueMap) obj;
        assertSame(3, map.get("k1").size());

    }

            

Reported by PMD.

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

Line: 30

                      assertTrue(obj != null);

        LinkedMultiValueMap map = (LinkedMultiValueMap) obj;
        assertSame(3, map.get("k1").size());

    }

}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 30

                      assertTrue(obj != null);

        LinkedMultiValueMap map = (LinkedMultiValueMap) obj;
        assertSame(3, map.get("k1").size());

    }

}

            

Reported by PMD.

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

Line: 30

                      assertTrue(obj != null);

        LinkedMultiValueMap map = (LinkedMultiValueMap) obj;
        assertSame(3, map.get("k1").size());

    }

}

            

Reported by PMD.

Avoid unused imports such as 'org.springframework.util.MultiValueMap'
Design

Line: 7

              
import junit.framework.TestCase;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;

import java.util.Queue;
import java.util.concurrent.ArrayBlockingQueue;

public class Issue2939 extends TestCase {

            

Reported by PMD.

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

Line: 9

              import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;

import java.util.Queue;
import java.util.concurrent.ArrayBlockingQueue;

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


            

Reported by PMD.

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

Line: 11

              
public class Bug_for_issue_304 extends TestCase {

    public void test_doubleQuote() throws Exception {
        String ss = "{\"value\":\"Intki_E96?\u001A Build\"}";
        Assert.assertEquals("Intki_E96?\u001A Build", JSON.parseObject(ss).get("value"));
    }
    
    public void test_doubleQuote_vo() throws Exception {

            

Reported by PMD.

The String literal 'Intki_E96?\u001a Build' appears 5 times in this file; the first occurrence is on line 13
Error

Line: 13

              
    public void test_doubleQuote() throws Exception {
        String ss = "{\"value\":\"Intki_E96?\u001A Build\"}";
        Assert.assertEquals("Intki_E96?\u001A Build", JSON.parseObject(ss).get("value"));
    }
    
    public void test_doubleQuote_vo() throws Exception {
        String ss = "{\"value\":\"Intki_E96?\u001A Build\"}";
        Assert.assertEquals("Intki_E96?\u001A Build", JSON.parseObject(ss, VO.class).value);

            

Reported by PMD.

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

Line: 13

              
    public void test_doubleQuote() throws Exception {
        String ss = "{\"value\":\"Intki_E96?\u001A Build\"}";
        Assert.assertEquals("Intki_E96?\u001A Build", JSON.parseObject(ss).get("value"));
    }
    
    public void test_doubleQuote_vo() throws Exception {
        String ss = "{\"value\":\"Intki_E96?\u001A Build\"}";
        Assert.assertEquals("Intki_E96?\u001A Build", JSON.parseObject(ss, VO.class).value);

            

Reported by PMD.

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

Line: 16

                      Assert.assertEquals("Intki_E96?\u001A Build", JSON.parseObject(ss).get("value"));
    }
    
    public void test_doubleQuote_vo() throws Exception {
        String ss = "{\"value\":\"Intki_E96?\u001A Build\"}";
        Assert.assertEquals("Intki_E96?\u001A Build", JSON.parseObject(ss, VO.class).value);
    }
    
    public void test_doubleQuote_vo_private() throws Exception {

            

Reported by PMD.

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

Line: 18

                  
    public void test_doubleQuote_vo() throws Exception {
        String ss = "{\"value\":\"Intki_E96?\u001A Build\"}";
        Assert.assertEquals("Intki_E96?\u001A Build", JSON.parseObject(ss, VO.class).value);
    }
    
    public void test_doubleQuote_vo_private() throws Exception {
        String ss = "{\"value\":\"Intki_E96?\u001A Build\"}";
        Assert.assertEquals("Intki_E96?\u001A Build", JSON.parseObject(ss, V1.class).value);

            

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

                      Assert.assertEquals("Intki_E96?\u001A Build", JSON.parseObject(ss, VO.class).value);
    }
    
    public void test_doubleQuote_vo_private() throws Exception {
        String ss = "{\"value\":\"Intki_E96?\u001A Build\"}";
        Assert.assertEquals("Intki_E96?\u001A Build", JSON.parseObject(ss, V1.class).value);
    }
    
    public void test_singleQuote() throws Exception {

            

Reported by PMD.

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

Line: 23

                  
    public void test_doubleQuote_vo_private() throws Exception {
        String ss = "{\"value\":\"Intki_E96?\u001A Build\"}";
        Assert.assertEquals("Intki_E96?\u001A Build", JSON.parseObject(ss, V1.class).value);
    }
    
    public void test_singleQuote() throws Exception {
        String ss = "{'value':'Intki_E96?\u001A Build'}";
        Assert.assertEquals("Intki_E96?\u001A Build", JSON.parseObject(ss).get("value"));

            

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("Intki_E96?\u001A Build", JSON.parseObject(ss, V1.class).value);
    }
    
    public void test_singleQuote() throws Exception {
        String ss = "{'value':'Intki_E96?\u001A Build'}";
        Assert.assertEquals("Intki_E96?\u001A Build", JSON.parseObject(ss).get("value"));
    }
    
    public void test_singleQuote_vo() throws Exception {

            

Reported by PMD.

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

Line: 28

                  
    public void test_singleQuote() throws Exception {
        String ss = "{'value':'Intki_E96?\u001A Build'}";
        Assert.assertEquals("Intki_E96?\u001A Build", JSON.parseObject(ss).get("value"));
    }
    
    public void test_singleQuote_vo() throws Exception {
        String ss = "{'value':'Intki_E96?\u001A Build'}";
        Assert.assertEquals("Intki_E96?\u001A Build", JSON.parseObject(ss, VO.class).value);

            

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("Intki_E96?\u001A Build", JSON.parseObject(ss).get("value"));
    }
    
    public void test_singleQuote_vo() throws Exception {
        String ss = "{'value':'Intki_E96?\u001A Build'}";
        Assert.assertEquals("Intki_E96?\u001A Build", JSON.parseObject(ss, VO.class).value);
    }
    
    public static class VO {

            

Reported by PMD.

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

Line: 17

              import com.alibaba.fastjson.serializer.SimpleDateFormatSerializer;

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

                      JSON.defaultLocale = Locale.CHINA;
    }
    
    public void test_codec() throws Exception {
        SerializeConfig mapping = new SerializeConfig();
        mapping.put(Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd"));

        V0 v = new V0();
        v.setValue(new Date());

            

Reported by PMD.

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

Line: 24

                  
    public void test_codec() throws Exception {
        SerializeConfig mapping = new SerializeConfig();
        mapping.put(Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd"));

        V0 v = new V0();
        v.setValue(new Date());

        String text = JSON.toJSONString(v, mapping);

            

Reported by PMD.

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

Line: 36

                      Assert.assertEquals("{\"value\":" + JSON.toJSONString(format.format(v.getValue())) + "}", text);
    }

    public void test_codec_no_asm() throws Exception {
        V0 v = new V0();
        v.setValue(new Date());

        SerializeConfig mapping = new SerializeConfig();
        mapping.put(Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd"));

            

Reported by PMD.

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

Line: 50

                      Assert.assertEquals("{\"value\":" + JSON.toJSONString(format.format(v.getValue())) + "}", text);
    }
    
    public void test_codec_asm() throws Exception {
        V0 v = new V0();
        v.setValue(new Date());
        
        SerializeConfig mapping = new SerializeConfig();
        mapping.put(Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd"));

            

Reported by PMD.

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

Line: 64

                      Assert.assertEquals("{\"value\":" + JSON.toJSONString(format.format(v.getValue())) + "}", text);
    }

    public void test_codec_null_asm() throws Exception {
        V0 v = new V0();

        SerializeConfig mapping = new SerializeConfig();
        mapping.setAsmEnable(true);


            

Reported by PMD.

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

Line: 76

              
        V0 v1 = JSON.parseObject(text, V0.class);

        Assert.assertEquals(v1.getValue(), v.getValue());
    }
    
    public void test_codec_null_no_asm() throws Exception {
        V0 v = new V0();


            

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

                      Assert.assertEquals(v1.getValue(), v.getValue());
    }
    
    public void test_codec_null_no_asm() throws Exception {
        V0 v = new V0();

        SerializeConfig mapping = new SerializeConfig();
        mapping.put(Date.class, new SimpleDateFormatSerializer("yyyy-MM-dd"));
        mapping.setAsmEnable(false);

            

Reported by PMD.

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

Line: 91

              
        V0 v1 = JSON.parseObject(text, V0.class);

        Assert.assertEquals(v1.getValue(), v.getValue());
    }

    public void test_codec_null_1() throws Exception {
        V0 v = new V0();


            

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

                      Assert.assertEquals(v1.getValue(), v.getValue());
    }

    public void test_codec_null_1() throws Exception {
        V0 v = new V0();

        SerializeConfig mapping = new SerializeConfig();
        mapping.setAsmEnable(false);


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_2900/Issue2914.java
11 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

              import java.util.concurrent.ArrayBlockingQueue;

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

        ComplexInt complexInt = new ComplexInt();

        Queue<Integer> blockQueueInt = new ArrayBlockingQueue<Integer>(5);
        blockQueueInt.offer(1);

            

Reported by PMD.

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

Line: 12

              import java.util.concurrent.ArrayBlockingQueue;

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

        ComplexInt complexInt = new ComplexInt();

        Queue<Integer> blockQueueInt = new ArrayBlockingQueue<Integer>(5);
        blockQueueInt.offer(1);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 24

              
        String jsonInt = JSON.toJSONString(complexInt);

        assertEquals("{\"blockQueue\":[1,2,3]}",jsonInt);

        ComplexInt complexInt1 = JSON.parseObject(jsonInt,Issue2914.ComplexInt.class);

        assertEquals(3, complexInt1.getBlockQueue().size());


            

Reported by PMD.

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

Line: 28

              
        ComplexInt complexInt1 = JSON.parseObject(jsonInt,Issue2914.ComplexInt.class);

        assertEquals(3, complexInt1.getBlockQueue().size());


        Complex complex = new Complex();

        Queue<String> blockQueue = new ArrayBlockingQueue<String>(5);

            

Reported by PMD.

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

Line: 28

              
        ComplexInt complexInt1 = JSON.parseObject(jsonInt,Issue2914.ComplexInt.class);

        assertEquals(3, complexInt1.getBlockQueue().size());


        Complex complex = new Complex();

        Queue<String> blockQueue = new ArrayBlockingQueue<String>(5);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 28

              
        ComplexInt complexInt1 = JSON.parseObject(jsonInt,Issue2914.ComplexInt.class);

        assertEquals(3, complexInt1.getBlockQueue().size());


        Complex complex = new Complex();

        Queue<String> blockQueue = new ArrayBlockingQueue<String>(5);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 41

              
        String json = JSON.toJSONString(complex);

        assertEquals("{\"blockQueue\":[\"BlockQueue 1\",\"BlockQueue 2\",\"BlockQueue 3\"]}",json);

        Complex complex1 = JSON.parseObject(json,Issue2914.Complex.class);

        assertEquals(3, complex1.getBlockQueue().size());


            

Reported by PMD.

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

Line: 45

              
        Complex complex1 = JSON.parseObject(json,Issue2914.Complex.class);

        assertEquals(3, complex1.getBlockQueue().size());

    }




            

Reported by PMD.

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

Line: 45

              
        Complex complex1 = JSON.parseObject(json,Issue2914.Complex.class);

        assertEquals(3, complex1.getBlockQueue().size());

    }




            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 45

              
        Complex complex1 = JSON.parseObject(json,Issue2914.Complex.class);

        assertEquals(3, complex1.getBlockQueue().size());

    }




            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1500/Issue1582.java
11 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: 9

              import junit.framework.TestCase;

public class Issue1582 extends TestCase {
    public void test_for_issue() throws Exception {
        assertSame(Size.Big, JSON.parseObject("\"Big\"", Size.class));
        assertSame(Size.Big, JSON.parseObject("\"big\"", Size.class));
        assertNull(JSON.parseObject("\"Large\"", Size.class));
        assertSame(Size.LL, JSON.parseObject("\"L3\"", Size.class));


            

Reported by PMD.

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

Line: 9

              import junit.framework.TestCase;

public class Issue1582 extends TestCase {
    public void test_for_issue() throws Exception {
        assertSame(Size.Big, JSON.parseObject("\"Big\"", Size.class));
        assertSame(Size.Big, JSON.parseObject("\"big\"", Size.class));
        assertNull(JSON.parseObject("\"Large\"", Size.class));
        assertSame(Size.LL, JSON.parseObject("\"L3\"", Size.class));


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 10

              
public class Issue1582 extends TestCase {
    public void test_for_issue() throws Exception {
        assertSame(Size.Big, JSON.parseObject("\"Big\"", Size.class));
        assertSame(Size.Big, JSON.parseObject("\"big\"", Size.class));
        assertNull(JSON.parseObject("\"Large\"", Size.class));
        assertSame(Size.LL, JSON.parseObject("\"L3\"", Size.class));

        assertSame(Size.Small, JSON.parseObject("\"Little\"", Size.class));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 11

              public class Issue1582 extends TestCase {
    public void test_for_issue() throws Exception {
        assertSame(Size.Big, JSON.parseObject("\"Big\"", Size.class));
        assertSame(Size.Big, JSON.parseObject("\"big\"", Size.class));
        assertNull(JSON.parseObject("\"Large\"", Size.class));
        assertSame(Size.LL, JSON.parseObject("\"L3\"", Size.class));

        assertSame(Size.Small, JSON.parseObject("\"Little\"", Size.class));
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 12

                  public void test_for_issue() throws Exception {
        assertSame(Size.Big, JSON.parseObject("\"Big\"", Size.class));
        assertSame(Size.Big, JSON.parseObject("\"big\"", Size.class));
        assertNull(JSON.parseObject("\"Large\"", Size.class));
        assertSame(Size.LL, JSON.parseObject("\"L3\"", Size.class));

        assertSame(Size.Small, JSON.parseObject("\"Little\"", Size.class));
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 13

                      assertSame(Size.Big, JSON.parseObject("\"Big\"", Size.class));
        assertSame(Size.Big, JSON.parseObject("\"big\"", Size.class));
        assertNull(JSON.parseObject("\"Large\"", Size.class));
        assertSame(Size.LL, JSON.parseObject("\"L3\"", Size.class));

        assertSame(Size.Small, JSON.parseObject("\"Little\"", Size.class));
    }

    public void test_for_issue_1() throws Exception {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 15

                      assertNull(JSON.parseObject("\"Large\"", Size.class));
        assertSame(Size.LL, JSON.parseObject("\"L3\"", Size.class));

        assertSame(Size.Small, JSON.parseObject("\"Little\"", Size.class));
    }

    public void test_for_issue_1() throws Exception {
        JSONObject object = JSON.parseObject("{\"size\":\"Little\"}");
        Model model = object.toJavaObject(Model.class);

            

Reported by PMD.

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

Line: 18

                      assertSame(Size.Small, JSON.parseObject("\"Little\"", Size.class));
    }

    public void test_for_issue_1() throws Exception {
        JSONObject object = JSON.parseObject("{\"size\":\"Little\"}");
        Model model = object.toJavaObject(Model.class);
        assertSame(Size.Small, model.size);
    }


            

Reported by PMD.

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

Line: 20

              
    public void test_for_issue_1() throws Exception {
        JSONObject object = JSON.parseObject("{\"size\":\"Little\"}");
        Model model = object.toJavaObject(Model.class);
        assertSame(Size.Small, model.size);
    }

    public static class Model {
        public Size size;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 21

                  public void test_for_issue_1() throws Exception {
        JSONObject object = JSON.parseObject("{\"size\":\"Little\"}");
        Model model = object.toJavaObject(Model.class);
        assertSame(Size.Small, model.size);
    }

    public static class Model {
        public Size size;
    }

            

Reported by PMD.