The following issues were found

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

Line: 13

              
public class CreateInstanceErrorTest2 extends TestCase {

    public void test_ordered_field() throws Exception {
        Exception error = null;
        try {
            Model model = JSON.parseObject("{\"value\":{\"@type\":\"com.alibaba.json.bvt.parser.CreateInstanceErrorTest2$MyMap\"}}", Model.class);
        } catch (Exception ex) {
            error = ex;

            

Reported by PMD.

Avoid unused local variables such as 'model'.
Design

Line: 16

                  public void test_ordered_field() throws Exception {
        Exception error = null;
        try {
            Model model = JSON.parseObject("{\"value\":{\"@type\":\"com.alibaba.json.bvt.parser.CreateInstanceErrorTest2$MyMap\"}}", Model.class);
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }

            

Reported by PMD.

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

Line: 17

                      Exception error = null;
        try {
            Model model = JSON.parseObject("{\"value\":{\"@type\":\"com.alibaba.json.bvt.parser.CreateInstanceErrorTest2$MyMap\"}}", Model.class);
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }


            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 28

                      public Object value;
    }
    
    public static class MyMap extends HashMap {
        public MyMap(){
            throw new UnsupportedOperationException();
        }
    }
}

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '14'-'18').
Error

Line: 14

              public class CreateInstanceErrorTest2 extends TestCase {

    public void test_ordered_field() throws Exception {
        Exception error = null;
        try {
            Model model = JSON.parseObject("{\"value\":{\"@type\":\"com.alibaba.json.bvt.parser.CreateInstanceErrorTest2$MyMap\"}}", Model.class);
        } catch (Exception ex) {
            error = ex;
        }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'model' (lines '16'-'21').
Error

Line: 16

                  public void test_ordered_field() throws Exception {
        Exception error = null;
        try {
            Model model = JSON.parseObject("{\"value\":{\"@type\":\"com.alibaba.json.bvt.parser.CreateInstanceErrorTest2$MyMap\"}}", Model.class);
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }

            

Reported by PMD.

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

Line: 13

              
public class LocalTimeTest3 extends TestCase {

    public void test_for_issue() throws Exception {
        VO vo1 = JSON.parseObject("{\"date\":\"2016-05-05T20:24:28.484\"}", VO.class);
        
        Assert.assertEquals(20, vo1.date.getHour());
        Assert.assertEquals(24, vo1.date.getMinute());
        Assert.assertEquals(28, vo1.date.getSecond());

            

Reported by PMD.

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

Line: 16

                  public void test_for_issue() throws Exception {
        VO vo1 = JSON.parseObject("{\"date\":\"2016-05-05T20:24:28.484\"}", VO.class);
        
        Assert.assertEquals(20, vo1.date.getHour());
        Assert.assertEquals(24, vo1.date.getMinute());
        Assert.assertEquals(28, vo1.date.getSecond());
        Assert.assertEquals(484000000, vo1.date.getNano());
    }


            

Reported by PMD.

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

Line: 17

                      VO vo1 = JSON.parseObject("{\"date\":\"2016-05-05T20:24:28.484\"}", VO.class);
        
        Assert.assertEquals(20, vo1.date.getHour());
        Assert.assertEquals(24, vo1.date.getMinute());
        Assert.assertEquals(28, vo1.date.getSecond());
        Assert.assertEquals(484000000, vo1.date.getNano());
    }

    public static class VO {

            

Reported by PMD.

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

Line: 18

                      
        Assert.assertEquals(20, vo1.date.getHour());
        Assert.assertEquals(24, vo1.date.getMinute());
        Assert.assertEquals(28, vo1.date.getSecond());
        Assert.assertEquals(484000000, vo1.date.getNano());
    }

    public static class VO {


            

Reported by PMD.

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

Line: 19

                      Assert.assertEquals(20, vo1.date.getHour());
        Assert.assertEquals(24, vo1.date.getMinute());
        Assert.assertEquals(28, vo1.date.getSecond());
        Assert.assertEquals(484000000, vo1.date.getNano());
    }

    public static class VO {

        public LocalTime date;

            

Reported by PMD.

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

Line: 24

              
    public static class VO {

        public LocalTime date;


    }
}

            

Reported by PMD.

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

Line: 13

              
public class BuilderTest_error extends TestCase {

    public void test_0() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"id\":12304,\"name\":\"ljw\"}", VO.class);
        } catch (JSONException ex) {
            error = ex;

            

Reported by PMD.

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

Line: 26

                  @JSONType(builder = VOBuilder.class)
    public static class VO {

        private int    id;
        private String name;

        public int getId() {
            return id;
        }

            

Reported by PMD.

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

Line: 27

                  public static class VO {

        private int    id;
        private String name;

        public int getId() {
            return id;
        }


            

Reported by PMD.

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

Line: 40

              
    public static class VOBuilder {

        private VO vo = new VO();

        public VO build() {
            throw new IllegalStateException();
        }


            

Reported by PMD.

Private field 'vo' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 40

              
    public static class VOBuilder {

        private VO vo = new VO();

        public VO build() {
            throw new IllegalStateException();
        }


            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '14'-'18').
Error

Line: 14

              public class BuilderTest_error extends TestCase {

    public void test_0() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"id\":12304,\"name\":\"ljw\"}", VO.class);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.

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

Line: 9

              import junit.framework.TestCase;

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

        JSONObject obj = new JSONObject();
        obj.put("data", new JSONObject());
        obj.getJSONObject("data").put("data", new JSONObject());
        obj.getJSONObject("data").getJSONObject("data").put("map", new JSONObject());

            

Reported by PMD.

The String literal 'data' appears 7 times in this file; the first occurrence is on line 12
Error

Line: 12

                  public void test_for_issue() throws Exception {

        JSONObject obj = new JSONObject();
        obj.put("data", new JSONObject());
        obj.getJSONObject("data").put("data", new JSONObject());
        obj.getJSONObject("data").getJSONObject("data").put("map", new JSONObject());
        obj.getJSONObject("data").getJSONObject("data").getJSONObject("map").put("21160001", "abc");

        String json = JSON.toJSONString(obj);

            

Reported by PMD.

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

Line: 15

                      obj.put("data", new JSONObject());
        obj.getJSONObject("data").put("data", new JSONObject());
        obj.getJSONObject("data").getJSONObject("data").put("map", new JSONObject());
        obj.getJSONObject("data").getJSONObject("data").getJSONObject("map").put("21160001", "abc");

        String json = JSON.toJSONString(obj);
        assertEquals("abc", JSONPath.read(json,"data.data.map.21160001"));
    }
}

            

Reported by PMD.

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

Line: 15

                      obj.put("data", new JSONObject());
        obj.getJSONObject("data").put("data", new JSONObject());
        obj.getJSONObject("data").getJSONObject("data").put("map", new JSONObject());
        obj.getJSONObject("data").getJSONObject("data").getJSONObject("map").put("21160001", "abc");

        String json = JSON.toJSONString(obj);
        assertEquals("abc", JSONPath.read(json,"data.data.map.21160001"));
    }
}

            

Reported by PMD.

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

Line: 15

                      obj.put("data", new JSONObject());
        obj.getJSONObject("data").put("data", new JSONObject());
        obj.getJSONObject("data").getJSONObject("data").put("map", new JSONObject());
        obj.getJSONObject("data").getJSONObject("data").getJSONObject("map").put("21160001", "abc");

        String json = JSON.toJSONString(obj);
        assertEquals("abc", JSONPath.read(json,"data.data.map.21160001"));
    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                      obj.getJSONObject("data").getJSONObject("data").getJSONObject("map").put("21160001", "abc");

        String json = JSON.toJSONString(obj);
        assertEquals("abc", JSONPath.read(json,"data.data.map.21160001"));
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/MapResetTest.java
5 issues
System.out.println is used
Design

Line: 15

              //         book.setMetadata(new MetaData());
        String text = JSON.toJSONString(book);

        System.out.println(text);

        Book book2 = JSON.parseObject(text, Book.class);
        System.out.println(JSON.toJSONString(book2));
    }


            

Reported by PMD.

System.out.println is used
Design

Line: 18

                      System.out.println(text);

        Book book2 = JSON.parseObject(text, Book.class);
        System.out.println(JSON.toJSONString(book2));
    }

    public static class Book {

        private int      id;

            

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

              
public class MapResetTest extends TestCase {

    public void test_0() throws Exception {
        Book book = new Book();

//         book.setMetadata(new MetaData());
        String text = JSON.toJSONString(book);


            

Reported by PMD.

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

Line: 9

              
public class MapResetTest extends TestCase {

    public void test_0() throws Exception {
        Book book = new Book();

//         book.setMetadata(new MetaData());
        String text = JSON.toJSONString(book);


            

Reported by PMD.

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

Line: 21

                      System.out.println(JSON.toJSONString(book2));
    }

    public static class Book {

        private int      id;
        private int      pageCountNum;

        private MetaData metadata;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_2700/Issue2703.java
5 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 Issue2703 extends TestCase {
    public void test_for_issue() {
        Object a = JSON.toJavaObject(new JSONObject(), JSON.class);
        assertTrue(a instanceof JSONObject);

        Object b = new JSONObject().toJavaObject(JSON.class);
        assertTrue(b instanceof JSONObject);

            

Reported by PMD.

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

Line: 9

              import junit.framework.TestCase;

public class Issue2703 extends TestCase {
    public void test_for_issue() {
        Object a = JSON.toJavaObject(new JSONObject(), JSON.class);
        assertTrue(a instanceof JSONObject);

        Object b = new JSONObject().toJavaObject(JSON.class);
        assertTrue(b instanceof JSONObject);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 11

              public class Issue2703 extends TestCase {
    public void test_for_issue() {
        Object a = JSON.toJavaObject(new JSONObject(), JSON.class);
        assertTrue(a instanceof JSONObject);

        Object b = new JSONObject().toJavaObject(JSON.class);
        assertTrue(b instanceof JSONObject);

        Object c = JSON.toJavaObject(new JSONArray(), JSON.class);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 14

                      assertTrue(a instanceof JSONObject);

        Object b = new JSONObject().toJavaObject(JSON.class);
        assertTrue(b instanceof JSONObject);

        Object c = JSON.toJavaObject(new JSONArray(), JSON.class);
        assertTrue(c instanceof JSONArray);
    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

                      assertTrue(b instanceof JSONObject);

        Object c = JSON.toJavaObject(new JSONArray(), JSON.class);
        assertTrue(c instanceof JSONArray);
    }
}

            

Reported by PMD.

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

Line: 13

              
public class LocalDateTest3 extends TestCase {

    public void test_for_issue() throws Exception {
        VO vo = JSON.parseObject("{\"date\":\"2016-05-06\"}", VO.class);
        
        Assert.assertEquals(2016, vo.date.getYear());
        Assert.assertEquals(5, vo.date.getMonthValue());
        Assert.assertEquals(6, vo.date.getDayOfMonth());

            

Reported by PMD.

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

Line: 16

                  public void test_for_issue() throws Exception {
        VO vo = JSON.parseObject("{\"date\":\"2016-05-06\"}", VO.class);
        
        Assert.assertEquals(2016, vo.date.getYear());
        Assert.assertEquals(5, vo.date.getMonthValue());
        Assert.assertEquals(6, vo.date.getDayOfMonth());
    }

    public static class VO {

            

Reported by PMD.

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

Line: 17

                      VO vo = JSON.parseObject("{\"date\":\"2016-05-06\"}", VO.class);
        
        Assert.assertEquals(2016, vo.date.getYear());
        Assert.assertEquals(5, vo.date.getMonthValue());
        Assert.assertEquals(6, vo.date.getDayOfMonth());
    }

    public static class VO {
        public LocalDate date;

            

Reported by PMD.

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

Line: 18

                      
        Assert.assertEquals(2016, vo.date.getYear());
        Assert.assertEquals(5, vo.date.getMonthValue());
        Assert.assertEquals(6, vo.date.getDayOfMonth());
    }

    public static class VO {
        public LocalDate date;


            

Reported by PMD.

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

Line: 22

                  }

    public static class VO {
        public LocalDate date;

    }
}

            

Reported by PMD.

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

Line: 13

               * Created by wenshao on 02/05/2017.
 */
public class Issue1178 extends TestCase {
    public void test_for_issue() throws Exception {
        String json = "{\n" +
                " \"info\": {\n" +
                "        \"test\": \"\", \n" +
                "    }\n" +
                "}";

            

Reported by PMD.

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

Line: 13

               * Created by wenshao on 02/05/2017.
 */
public class Issue1178 extends TestCase {
    public void test_for_issue() throws Exception {
        String json = "{\n" +
                " \"info\": {\n" +
                "        \"test\": \"\", \n" +
                "    }\n" +
                "}";

            

Reported by PMD.

Avoid unused local variables such as 'loginResponse'.
Design

Line: 21

                              "}";

        JSONObject jsonObject = JSON.parseObject(json);
        TestModel loginResponse = JSON.toJavaObject(jsonObject, TestModel.class);

    }

    public static class TestModel implements Serializable {
        public String info;

            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 25

              
    }

    public static class TestModel implements Serializable {
        public String info;
    }
}

            

Reported by PMD.

Found 'DU'-anomaly for variable 'loginResponse' (lines '21'-'23').
Error

Line: 21

                              "}";

        JSONObject jsonObject = JSON.parseObject(json);
        TestModel loginResponse = JSON.toJavaObject(jsonObject, TestModel.class);

    }

    public static class TestModel implements Serializable {
        public String info;

            

Reported by PMD.

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

Line: 13

              
public class LocalDateTest4 extends TestCase {

    public void test_for_issue() throws Exception {
        VO vo = JSON.parseObject("{\"date\":\"20160506\"}", VO.class);
        
        Assert.assertEquals(2016, vo.date.getYear());
        Assert.assertEquals(5, vo.date.getMonthValue());
        Assert.assertEquals(6, vo.date.getDayOfMonth());

            

Reported by PMD.

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

Line: 16

                  public void test_for_issue() throws Exception {
        VO vo = JSON.parseObject("{\"date\":\"20160506\"}", VO.class);
        
        Assert.assertEquals(2016, vo.date.getYear());
        Assert.assertEquals(5, vo.date.getMonthValue());
        Assert.assertEquals(6, vo.date.getDayOfMonth());
    }

    public static class VO {

            

Reported by PMD.

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

Line: 17

                      VO vo = JSON.parseObject("{\"date\":\"20160506\"}", VO.class);
        
        Assert.assertEquals(2016, vo.date.getYear());
        Assert.assertEquals(5, vo.date.getMonthValue());
        Assert.assertEquals(6, vo.date.getDayOfMonth());
    }

    public static class VO {
        public LocalDate date;

            

Reported by PMD.

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

Line: 18

                      
        Assert.assertEquals(2016, vo.date.getYear());
        Assert.assertEquals(5, vo.date.getMonthValue());
        Assert.assertEquals(6, vo.date.getDayOfMonth());
    }

    public static class VO {
        public LocalDate date;


            

Reported by PMD.

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

Line: 22

                  }

    public static class VO {
        public LocalDate date;

    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/guava/LinkedListMultimapTest.java
5 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

               * Created by wenshao on 15/01/2017.
 */
public class LinkedListMultimapTest extends TestCase {
    public void test_for_multimap() throws Exception {
        LinkedListMultimap map = LinkedListMultimap.create();
        map.put("name", "a");
        map.put("name", "b");

        String json = JSON.toJSONString(map);

            

Reported by PMD.

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

Line: 14

              public class LinkedListMultimapTest extends TestCase {
    public void test_for_multimap() throws Exception {
        LinkedListMultimap map = LinkedListMultimap.create();
        map.put("name", "a");
        map.put("name", "b");

        String json = JSON.toJSONString(map);
        assertEquals("{\"name\":[\"a\",\"b\"]}", json);
    }

            

Reported by PMD.

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

Line: 15

                  public void test_for_multimap() throws Exception {
        LinkedListMultimap map = LinkedListMultimap.create();
        map.put("name", "a");
        map.put("name", "b");

        String json = JSON.toJSONString(map);
        assertEquals("{\"name\":[\"a\",\"b\"]}", json);
    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

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

        String json = JSON.toJSONString(map);
        assertEquals("{\"name\":[\"a\",\"b\"]}", json);
    }
}

            

Reported by PMD.

Avoid unused imports such as 'com.google.common.collect.HashMultimap'
Design

Line: 4

              package com.alibaba.json.bvt.guava;

import com.alibaba.fastjson.JSON;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.LinkedListMultimap;
import junit.framework.TestCase;

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

            

Reported by PMD.