The following issues were found

src/test/java/com/alibaba/json/bvt/parser/TypeUtilsTest_castToJavaBean_JSONType.java
14 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: 16

              
public class TypeUtilsTest_castToJavaBean_JSONType extends TestCase {

    public void test_castToJavaBean() throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", 123);
        map.put("name", "abc");
        VO vo = TypeUtils.castToJavaBean(map, VO.class, null);
        Assert.assertEquals(123, vo.getId());

            

Reported by PMD.

The String literal 'abc' appears 6 times in this file; the first occurrence is on line 19
Error

Line: 19

                  public void test_castToJavaBean() throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", 123);
        map.put("name", "abc");
        VO vo = TypeUtils.castToJavaBean(map, VO.class, null);
        Assert.assertEquals(123, vo.getId());
        Assert.assertEquals("abc", vo.getName());
        
        Assert.assertEquals("{\"name\":\"abc\",\"id\":123}", JSON.toJSONString(vo));

            

Reported by PMD.

The String literal 'name' appears 6 times in this file; the first occurrence is on line 19
Error

Line: 19

                  public void test_castToJavaBean() throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", 123);
        map.put("name", "abc");
        VO vo = TypeUtils.castToJavaBean(map, VO.class, null);
        Assert.assertEquals(123, vo.getId());
        Assert.assertEquals("abc", vo.getName());
        
        Assert.assertEquals("{\"name\":\"abc\",\"id\":123}", JSON.toJSONString(vo));

            

Reported by PMD.

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

Line: 21

                      map.put("id", 123);
        map.put("name", "abc");
        VO vo = TypeUtils.castToJavaBean(map, VO.class, null);
        Assert.assertEquals(123, vo.getId());
        Assert.assertEquals("abc", vo.getName());
        
        Assert.assertEquals("{\"name\":\"abc\",\"id\":123}", JSON.toJSONString(vo));
    }
    

            

Reported by PMD.

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

Line: 22

                      map.put("name", "abc");
        VO vo = TypeUtils.castToJavaBean(map, VO.class, null);
        Assert.assertEquals(123, vo.getId());
        Assert.assertEquals("abc", vo.getName());
        
        Assert.assertEquals("{\"name\":\"abc\",\"id\":123}", JSON.toJSONString(vo));
    }
    
    public void test_castToJavaBean_v2() 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: 27

                      Assert.assertEquals("{\"name\":\"abc\",\"id\":123}", JSON.toJSONString(vo));
    }
    
    public void test_castToJavaBean_v2() throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", 123);
        map.put("name", "abc");
        V2 vo = TypeUtils.castToJavaBean(map, V2.class, null);
        Assert.assertEquals(123, vo.getId());

            

Reported by PMD.

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

Line: 32

                      map.put("id", 123);
        map.put("name", "abc");
        V2 vo = TypeUtils.castToJavaBean(map, V2.class, null);
        Assert.assertEquals(123, vo.getId());
        Assert.assertEquals("abc", vo.getName());
        
        Assert.assertEquals("{\"name\":\"abc\",\"id\":123}", JSON.toJSONString(vo));
    }
    

            

Reported by PMD.

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

Line: 33

                      map.put("name", "abc");
        V2 vo = TypeUtils.castToJavaBean(map, V2.class, null);
        Assert.assertEquals(123, vo.getId());
        Assert.assertEquals("abc", vo.getName());
        
        Assert.assertEquals("{\"name\":\"abc\",\"id\":123}", JSON.toJSONString(vo));
    }
    
    public void test_castToJavaBean_v3() 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: 38

                      Assert.assertEquals("{\"name\":\"abc\",\"id\":123}", JSON.toJSONString(vo));
    }
    
    public void test_castToJavaBean_v3() throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", 123);
        map.put("name", "abc");
        V3 vo = TypeUtils.castToJavaBean(map, V3.class, null);
        Assert.assertEquals(123, vo.getId());

            

Reported by PMD.

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

Line: 43

                      map.put("id", 123);
        map.put("name", "abc");
        V3 vo = TypeUtils.castToJavaBean(map, V3.class, null);
        Assert.assertEquals(123, vo.getId());
        Assert.assertEquals("abc", vo.getName());
        
        Assert.assertEquals("{\"name\":\"abc\",\"id\":123}", JSON.toJSONString(vo));
    }


            

Reported by PMD.

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

Line: 17

               * Created by wenshao on 08/05/2017.
 */
public class Issue969 extends TestCase {
    public void test_for_issue() throws Exception {
        JSONObject jsonObject = new JSONObject();

        JSONArray jsonArray = new JSONArray();
        jsonArray.add(new Model());
        jsonObject.put("models", jsonArray);

            

Reported by PMD.

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

Line: 17

               * Created by wenshao on 08/05/2017.
 */
public class Issue969 extends TestCase {
    public void test_for_issue() throws Exception {
        JSONObject jsonObject = new JSONObject();

        JSONArray jsonArray = new JSONArray();
        jsonArray.add(new Model());
        jsonObject.put("models", jsonArray);

            

Reported by PMD.

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

Line: 22

              
        JSONArray jsonArray = new JSONArray();
        jsonArray.add(new Model());
        jsonObject.put("models", jsonArray);

        List list = jsonObject.getObject("models", new TypeReference<List<Model>>(){});

        assertEquals(1, list.size());
        assertEquals(Model.class, list.get(0).getClass());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 26

              
        List list = jsonObject.getObject("models", new TypeReference<List<Model>>(){});

        assertEquals(1, list.size());
        assertEquals(Model.class, list.get(0).getClass());
    }

    public void test_for_issue_1() throws Exception {
        JSONObject jsonObject = new JSONObject();

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 27

                      List list = jsonObject.getObject("models", new TypeReference<List<Model>>(){});

        assertEquals(1, list.size());
        assertEquals(Model.class, list.get(0).getClass());
    }

    public void test_for_issue_1() throws Exception {
        JSONObject jsonObject = new JSONObject();


            

Reported by PMD.

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

Line: 27

                      List list = jsonObject.getObject("models", new TypeReference<List<Model>>(){});

        assertEquals(1, list.size());
        assertEquals(Model.class, list.get(0).getClass());
    }

    public void test_for_issue_1() throws Exception {
        JSONObject jsonObject = new JSONObject();


            

Reported by PMD.

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

Line: 30

                      assertEquals(Model.class, list.get(0).getClass());
    }

    public void test_for_issue_1() throws Exception {
        JSONObject jsonObject = new JSONObject();

        JSONArray jsonArray = new JSONArray();
        jsonArray.add(new Model());
        jsonObject.put("models", jsonArray);

            

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

                      assertEquals(Model.class, list.get(0).getClass());
    }

    public void test_for_issue_1() throws Exception {
        JSONObject jsonObject = new JSONObject();

        JSONArray jsonArray = new JSONArray();
        jsonArray.add(new Model());
        jsonObject.put("models", jsonArray);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 39

              
        List list = jsonObject.getObject("models", new TypeReference<List<Model>>(){}.getType());

        assertEquals(1, list.size());
        assertEquals(Model.class, list.get(0).getClass());
    }

    public static class Model {


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 40

                      List list = jsonObject.getObject("models", new TypeReference<List<Model>>(){}.getType());

        assertEquals(1, list.size());
        assertEquals(Model.class, list.get(0).getClass());
    }

    public static class Model {

    }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/ConcurrentHashMapTest4.java
14 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: 18

              
public class ConcurrentHashMapTest4 extends TestCase {

    public void test_concurrentHashmap() throws Exception {
        OffsetSerializeWrapper wrapper = new OffsetSerializeWrapper();
        wrapper.getOffsetTable().put(new MessageQueue(), new AtomicReference<A>(new A(true)));
        String text = JSON.toJSONString(wrapper);
        Assert.assertEquals("{\"offsetTable\":{{\"items\":[]}:{\"value\":true}}}", text);


            

Reported by PMD.

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

Line: 25

                      Assert.assertEquals("{\"offsetTable\":{{\"items\":[]}:{\"value\":true}}}", text);

        OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
        Assert.assertEquals(1, wrapper2.getOffsetTable().size());

        Iterator<Map.Entry<MessageQueue, AtomicReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicReference<A>> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get().isValue());

            

Reported by PMD.

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

Line: 25

                      Assert.assertEquals("{\"offsetTable\":{{\"items\":[]}:{\"value\":true}}}", text);

        OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
        Assert.assertEquals(1, wrapper2.getOffsetTable().size());

        Iterator<Map.Entry<MessageQueue, AtomicReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicReference<A>> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get().isValue());

            

Reported by PMD.

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

Line: 27

                      OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
        Assert.assertEquals(1, wrapper2.getOffsetTable().size());

        Iterator<Map.Entry<MessageQueue, AtomicReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicReference<A>> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get().isValue());
    }


            

Reported by PMD.

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

Line: 27

                      OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
        Assert.assertEquals(1, wrapper2.getOffsetTable().size());

        Iterator<Map.Entry<MessageQueue, AtomicReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicReference<A>> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get().isValue());
    }


            

Reported by PMD.

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

Line: 27

                      OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
        Assert.assertEquals(1, wrapper2.getOffsetTable().size());

        Iterator<Map.Entry<MessageQueue, AtomicReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicReference<A>> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get().isValue());
    }


            

Reported by PMD.

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

Line: 29

              
        Iterator<Map.Entry<MessageQueue, AtomicReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicReference<A>> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get().isValue());
    }

    public static class OffsetSerializeWrapper {


            

Reported by PMD.

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

Line: 29

              
        Iterator<Map.Entry<MessageQueue, AtomicReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicReference<A>> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get().isValue());
    }

    public static class OffsetSerializeWrapper {


            

Reported by PMD.

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

Line: 29

              
        Iterator<Map.Entry<MessageQueue, AtomicReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicReference<A>> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get().isValue());
    }

    public static class OffsetSerializeWrapper {


            

Reported by PMD.

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

Line: 30

                      Iterator<Map.Entry<MessageQueue, AtomicReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, AtomicReference<A>> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get().isValue());
    }

    public static class OffsetSerializeWrapper {

        private ConcurrentHashMap<MessageQueue, AtomicReference<A>> offsetTable = new ConcurrentHashMap<MessageQueue, AtomicReference<A>>();

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/jsonp/JSONPParseTest3.java
14 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 21/02/2017.
 */
public class JSONPParseTest3 extends TestCase {
    public void test_f() throws Exception {
        String text = "parent.callback ({'id':1, 'name':'ido)nans'},1,2 );   /**/ ";

        JSONPObject jsonpObject = (JSONPObject) JSON.parseObject(text, JSONPObject.class);
        assertEquals("parent.callback", jsonpObject.getFunction());


            

Reported by PMD.

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

Line: 13

               * Created by wenshao on 21/02/2017.
 */
public class JSONPParseTest3 extends TestCase {
    public void test_f() throws Exception {
        String text = "parent.callback ({'id':1, 'name':'ido)nans'},1,2 );   /**/ ";

        JSONPObject jsonpObject = (JSONPObject) JSON.parseObject(text, JSONPObject.class);
        assertEquals("parent.callback", jsonpObject.getFunction());


            

Reported by PMD.

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

Line: 17

                      String text = "parent.callback ({'id':1, 'name':'ido)nans'},1,2 );   /**/ ";

        JSONPObject jsonpObject = (JSONPObject) JSON.parseObject(text, JSONPObject.class);
        assertEquals("parent.callback", jsonpObject.getFunction());

        assertEquals(3, jsonpObject.getParameters().size());
        JSONObject param = (JSONObject) jsonpObject.getParameters().get(0);
        assertEquals(1, param.get("id"));
        assertEquals("ido)nans", param.get("name"));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

                      String text = "parent.callback ({'id':1, 'name':'ido)nans'},1,2 );   /**/ ";

        JSONPObject jsonpObject = (JSONPObject) JSON.parseObject(text, JSONPObject.class);
        assertEquals("parent.callback", jsonpObject.getFunction());

        assertEquals(3, jsonpObject.getParameters().size());
        JSONObject param = (JSONObject) jsonpObject.getParameters().get(0);
        assertEquals(1, param.get("id"));
        assertEquals("ido)nans", param.get("name"));

            

Reported by PMD.

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

Line: 19

                      JSONPObject jsonpObject = (JSONPObject) JSON.parseObject(text, JSONPObject.class);
        assertEquals("parent.callback", jsonpObject.getFunction());

        assertEquals(3, jsonpObject.getParameters().size());
        JSONObject param = (JSONObject) jsonpObject.getParameters().get(0);
        assertEquals(1, param.get("id"));
        assertEquals("ido)nans", param.get("name"));

        String json = JSON.toJSONString(jsonpObject, SerializerFeature.BrowserSecure, SerializerFeature.MapSortField);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

                      JSONPObject jsonpObject = (JSONPObject) JSON.parseObject(text, JSONPObject.class);
        assertEquals("parent.callback", jsonpObject.getFunction());

        assertEquals(3, jsonpObject.getParameters().size());
        JSONObject param = (JSONObject) jsonpObject.getParameters().get(0);
        assertEquals(1, param.get("id"));
        assertEquals("ido)nans", param.get("name"));

        String json = JSON.toJSONString(jsonpObject, SerializerFeature.BrowserSecure, SerializerFeature.MapSortField);

            

Reported by PMD.

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

Line: 19

                      JSONPObject jsonpObject = (JSONPObject) JSON.parseObject(text, JSONPObject.class);
        assertEquals("parent.callback", jsonpObject.getFunction());

        assertEquals(3, jsonpObject.getParameters().size());
        JSONObject param = (JSONObject) jsonpObject.getParameters().get(0);
        assertEquals(1, param.get("id"));
        assertEquals("ido)nans", param.get("name"));

        String json = JSON.toJSONString(jsonpObject, SerializerFeature.BrowserSecure, SerializerFeature.MapSortField);

            

Reported by PMD.

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

Line: 20

                      assertEquals("parent.callback", jsonpObject.getFunction());

        assertEquals(3, jsonpObject.getParameters().size());
        JSONObject param = (JSONObject) jsonpObject.getParameters().get(0);
        assertEquals(1, param.get("id"));
        assertEquals("ido)nans", param.get("name"));

        String json = JSON.toJSONString(jsonpObject, SerializerFeature.BrowserSecure, SerializerFeature.MapSortField);
        assertEquals("/**/parent.callback({\"id\":1,\"name\":\"ido\\u0029nans\"},1,2)", json);

            

Reported by PMD.

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

Line: 20

                      assertEquals("parent.callback", jsonpObject.getFunction());

        assertEquals(3, jsonpObject.getParameters().size());
        JSONObject param = (JSONObject) jsonpObject.getParameters().get(0);
        assertEquals(1, param.get("id"));
        assertEquals("ido)nans", param.get("name"));

        String json = JSON.toJSONString(jsonpObject, SerializerFeature.BrowserSecure, SerializerFeature.MapSortField);
        assertEquals("/**/parent.callback({\"id\":1,\"name\":\"ido\\u0029nans\"},1,2)", json);

            

Reported by PMD.

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

Line: 21

              
        assertEquals(3, jsonpObject.getParameters().size());
        JSONObject param = (JSONObject) jsonpObject.getParameters().get(0);
        assertEquals(1, param.get("id"));
        assertEquals("ido)nans", param.get("name"));

        String json = JSON.toJSONString(jsonpObject, SerializerFeature.BrowserSecure, SerializerFeature.MapSortField);
        assertEquals("/**/parent.callback({\"id\":1,\"name\":\"ido\\u0029nans\"},1,2)", json);
    }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/JSONLexerTest_set.java
14 issues
JUnit tests should include assert() or fail()
Design

Line: 11

              
public class JSONLexerTest_set extends TestCase {

    public void test_treeSet() throws Exception {
        JSON.parse("Set[]");
    }

    public void test_error() throws Exception {
        Exception error = 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: 11

              
public class JSONLexerTest_set extends TestCase {

    public void test_treeSet() throws Exception {
        JSON.parse("Set[]");
    }

    public void test_error() throws Exception {
        Exception error = 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: 15

                      JSON.parse("Set[]");
    }

    public void test_error() throws Exception {
        Exception error = null;
        try {
            JSON.parse("S_t[]");
        } catch (Exception ex) {
            error = ex;

            

Reported by PMD.

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

Line: 19

                      Exception error = null;
        try {
            JSON.parse("S_t[]");
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
   

            

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_error_1() throws Exception {
        Exception error = null;
        try {
            JSON.parse("Se_[]");
        } catch (Exception ex) {
            error = ex;

            

Reported by PMD.

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

Line: 29

                      Exception error = null;
        try {
            JSON.parse("Se_[]");
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    

            

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

                  }
    
    
    public void test_error_2() throws Exception {
        Exception error = null;
        try {
            JSON.parse("Set_[]");
        } catch (Exception ex) {
            error = ex;

            

Reported by PMD.

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

Line: 40

                      Exception error = null;
        try {
            JSON.parse("Set_[]");
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
    

            

Reported by PMD.

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

Line: 46

                      Assert.assertNotNull(error);
    }
    
    public void test_error_3() throws Exception {
        Exception error = null;
        try {
            JSON.parse("Xet[]");
        } catch (Exception ex) {
            error = ex;

            

Reported by PMD.

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

Line: 50

                      Exception error = null;
        try {
            JSON.parse("Xet[]");
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/ConcurrentHashMapTest5.java
14 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: 19

              
public class ConcurrentHashMapTest5 extends TestCase {

    public void test_concurrentHashmap() throws Exception {
        OffsetSerializeWrapper wrapper = new OffsetSerializeWrapper();
        wrapper.offsetTable.put(new MessageQueue(), new WeakReference<A>(new A(true)));
        String text = JSON.toJSONString(wrapper, new SerializeConfig());
        Assert.assertEquals("{\"offsetTable\":{{\"items\":[]}:{\"value\":true}}}", text);


            

Reported by PMD.

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

Line: 26

                      Assert.assertEquals("{\"offsetTable\":{{\"items\":[]}:{\"value\":true}}}", text);

        OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
        Assert.assertEquals(1, wrapper2.getOffsetTable().size());

        Iterator<Map.Entry<MessageQueue, WeakReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, WeakReference<A>> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get().isValue());

            

Reported by PMD.

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

Line: 26

                      Assert.assertEquals("{\"offsetTable\":{{\"items\":[]}:{\"value\":true}}}", text);

        OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
        Assert.assertEquals(1, wrapper2.getOffsetTable().size());

        Iterator<Map.Entry<MessageQueue, WeakReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, WeakReference<A>> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get().isValue());

            

Reported by PMD.

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

Line: 28

                      OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
        Assert.assertEquals(1, wrapper2.getOffsetTable().size());

        Iterator<Map.Entry<MessageQueue, WeakReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, WeakReference<A>> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get().isValue());
    }


            

Reported by PMD.

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

Line: 28

                      OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
        Assert.assertEquals(1, wrapper2.getOffsetTable().size());

        Iterator<Map.Entry<MessageQueue, WeakReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, WeakReference<A>> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get().isValue());
    }


            

Reported by PMD.

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

Line: 28

                      OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
        Assert.assertEquals(1, wrapper2.getOffsetTable().size());

        Iterator<Map.Entry<MessageQueue, WeakReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, WeakReference<A>> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get().isValue());
    }


            

Reported by PMD.

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

Line: 30

              
        Iterator<Map.Entry<MessageQueue, WeakReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, WeakReference<A>> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get().isValue());
    }

    public static class OffsetSerializeWrapper {


            

Reported by PMD.

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

Line: 30

              
        Iterator<Map.Entry<MessageQueue, WeakReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, WeakReference<A>> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get().isValue());
    }

    public static class OffsetSerializeWrapper {


            

Reported by PMD.

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

Line: 30

              
        Iterator<Map.Entry<MessageQueue, WeakReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, WeakReference<A>> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get().isValue());
    }

    public static class OffsetSerializeWrapper {


            

Reported by PMD.

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

Line: 31

                      Iterator<Map.Entry<MessageQueue, WeakReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, WeakReference<A>> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get().isValue());
    }

    public static class OffsetSerializeWrapper {

        private ConcurrentHashMap<MessageQueue, WeakReference<A>> offsetTable = new ConcurrentHashMap<MessageQueue, WeakReference<A>>();

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Issue869.java
14 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

               * Created by wenshao on 2016/10/19.
 */
public class Issue869 extends TestCase {
    public void test_for_issue() throws Exception {
        List<DoublePoint> doublePointList = new ArrayList<DoublePoint>();
        {
            DoublePoint doublePoint = new DoublePoint();
            doublePoint.startPoint = new Point(22, 35);
            doublePoint.endPoint = doublePoint.startPoint;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 31

                      }

        String json = JSON.toJSONString(doublePointList);
        assertEquals("[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"x\":22,\"y\":35}},{\"endPoint\":{\"x\":16,\"y\":18},\"startPoint\":{\"x\":16,\"y\":18}}]", json);
    }

    public void test_for_issue_parse() throws Exception {

        String text = "[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"$ref\":\"$[0].endPoint\"}},{\"endPoint\":{\"$ref\":\"$[1].startPoint\"},\"startPoint\":{\"x\":16,\"y\":18}}]";

            

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

                      assertEquals("[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"x\":22,\"y\":35}},{\"endPoint\":{\"x\":16,\"y\":18},\"startPoint\":{\"x\":16,\"y\":18}}]", json);
    }

    public void test_for_issue_parse() throws Exception {

        String text = "[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"$ref\":\"$[0].endPoint\"}},{\"endPoint\":{\"$ref\":\"$[1].startPoint\"},\"startPoint\":{\"x\":16,\"y\":18}}]";
        List<DoublePoint> doublePointList = JSON.parseObject(text, new TypeReference<List<DoublePoint>>(){});
        assertNotNull(doublePointList.get(0));
        assertNotNull(doublePointList.get(1));

            

Reported by PMD.

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

Line: 34

                      assertEquals("[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"x\":22,\"y\":35}},{\"endPoint\":{\"x\":16,\"y\":18},\"startPoint\":{\"x\":16,\"y\":18}}]", json);
    }

    public void test_for_issue_parse() throws Exception {

        String text = "[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"$ref\":\"$[0].endPoint\"}},{\"endPoint\":{\"$ref\":\"$[1].startPoint\"},\"startPoint\":{\"x\":16,\"y\":18}}]";
        List<DoublePoint> doublePointList = JSON.parseObject(text, new TypeReference<List<DoublePoint>>(){});
        assertNotNull(doublePointList.get(0));
        assertNotNull(doublePointList.get(1));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 38

              
        String text = "[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"$ref\":\"$[0].endPoint\"}},{\"endPoint\":{\"$ref\":\"$[1].startPoint\"},\"startPoint\":{\"x\":16,\"y\":18}}]";
        List<DoublePoint> doublePointList = JSON.parseObject(text, new TypeReference<List<DoublePoint>>(){});
        assertNotNull(doublePointList.get(0));
        assertNotNull(doublePointList.get(1));
        assertSame(doublePointList.get(0).startPoint, doublePointList.get(0).endPoint);
        assertSame(doublePointList.get(1).startPoint, doublePointList.get(1).endPoint);
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 39

                      String text = "[{\"endPoint\":{\"x\":22,\"y\":35},\"startPoint\":{\"$ref\":\"$[0].endPoint\"}},{\"endPoint\":{\"$ref\":\"$[1].startPoint\"},\"startPoint\":{\"x\":16,\"y\":18}}]";
        List<DoublePoint> doublePointList = JSON.parseObject(text, new TypeReference<List<DoublePoint>>(){});
        assertNotNull(doublePointList.get(0));
        assertNotNull(doublePointList.get(1));
        assertSame(doublePointList.get(0).startPoint, doublePointList.get(0).endPoint);
        assertSame(doublePointList.get(1).startPoint, doublePointList.get(1).endPoint);
    }

    public static  class DoublePoint{

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 40

                      List<DoublePoint> doublePointList = JSON.parseObject(text, new TypeReference<List<DoublePoint>>(){});
        assertNotNull(doublePointList.get(0));
        assertNotNull(doublePointList.get(1));
        assertSame(doublePointList.get(0).startPoint, doublePointList.get(0).endPoint);
        assertSame(doublePointList.get(1).startPoint, doublePointList.get(1).endPoint);
    }

    public static  class DoublePoint{
        public Point startPoint;

            

Reported by PMD.

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

Line: 40

                      List<DoublePoint> doublePointList = JSON.parseObject(text, new TypeReference<List<DoublePoint>>(){});
        assertNotNull(doublePointList.get(0));
        assertNotNull(doublePointList.get(1));
        assertSame(doublePointList.get(0).startPoint, doublePointList.get(0).endPoint);
        assertSame(doublePointList.get(1).startPoint, doublePointList.get(1).endPoint);
    }

    public static  class DoublePoint{
        public Point startPoint;

            

Reported by PMD.

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

Line: 40

                      List<DoublePoint> doublePointList = JSON.parseObject(text, new TypeReference<List<DoublePoint>>(){});
        assertNotNull(doublePointList.get(0));
        assertNotNull(doublePointList.get(1));
        assertSame(doublePointList.get(0).startPoint, doublePointList.get(0).endPoint);
        assertSame(doublePointList.get(1).startPoint, doublePointList.get(1).endPoint);
    }

    public static  class DoublePoint{
        public Point startPoint;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 41

                      assertNotNull(doublePointList.get(0));
        assertNotNull(doublePointList.get(1));
        assertSame(doublePointList.get(0).startPoint, doublePointList.get(0).endPoint);
        assertSame(doublePointList.get(1).startPoint, doublePointList.get(1).endPoint);
    }

    public static  class DoublePoint{
        public Point startPoint;
        public Point endPoint;

            

Reported by PMD.

src/main/java/com/alibaba/fastjson/JSONWriter.java
14 issues
This class has too many methods, consider refactoring it.
Design

Line: 13

              import com.alibaba.fastjson.serializer.SerializeWriter;
import com.alibaba.fastjson.serializer.SerializerFeature;

public class JSONWriter implements Closeable, Flushable {

    private SerializeWriter   writer;

    private JSONSerializer    serializer;


            

Reported by PMD.

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

Line: 15

              
public class JSONWriter implements Closeable, Flushable {

    private SerializeWriter   writer;

    private JSONSerializer    serializer;

    private JSONStreamContext context;


            

Reported by PMD.

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

Line: 15

              
public class JSONWriter implements Closeable, Flushable {

    private SerializeWriter   writer;

    private JSONSerializer    serializer;

    private JSONStreamContext context;


            

Reported by PMD.

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

Line: 17

              
    private SerializeWriter   writer;

    private JSONSerializer    serializer;

    private JSONStreamContext context;

    public JSONWriter(Writer out){
        writer = new SerializeWriter(out);

            

Reported by PMD.

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

Line: 17

              
    private SerializeWriter   writer;

    private JSONSerializer    serializer;

    private JSONStreamContext context;

    public JSONWriter(Writer out){
        writer = new SerializeWriter(out);

            

Reported by PMD.

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

Line: 19

              
    private JSONSerializer    serializer;

    private JSONStreamContext context;

    public JSONWriter(Writer out){
        writer = new SerializeWriter(out);
        serializer = new JSONSerializer(writer);
    }

            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.fastjson.JSONStreamContext'
Design

Line: 8

              import java.io.IOException;
import java.io.Writer;

import static com.alibaba.fastjson.JSONStreamContext.*;
import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.SerializeWriter;
import com.alibaba.fastjson.serializer.SerializerFeature;

public class JSONWriter implements Closeable, Flushable {

            

Reported by PMD.

Found 'DU'-anomaly for variable 'state' (lines '75'-'90').
Error

Line: 75

                  }

    private void beginStructure() {
        final int state = context.state;
        switch (context.state) {
            case PropertyKey:
                writer.write(':');
                break;
            case ArrayValue:

            

Reported by PMD.

Found 'DD'-anomaly for variable 'newState' (lines '104'-'110').
Error

Line: 104

                          return;
        }
        
        int newState = -1;
        switch (context.state) {
            case PropertyKey:
                newState = PropertyValue;
                break;
            case StartArray:

            

Reported by PMD.

Found 'DD'-anomaly for variable 'newState' (lines '104'-'115').
Error

Line: 104

                          return;
        }
        
        int newState = -1;
        switch (context.state) {
            case PropertyKey:
                newState = PropertyValue;
                break;
            case StartArray:

            

Reported by PMD.

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

Line: 24

              
        //基本类型
        if (void.class.isPrimitive()) {
            System.out.println("void");
        }
        if (boolean.class.isPrimitive()) {
            System.out.println("boolean");
        }


            

Reported by PMD.

System.out.println is used
Design

Line: 27

                          System.out.println("void");
        }
        if (boolean.class.isPrimitive()) {
            System.out.println("boolean");
        }

        for (Method method : methods) {
            System.out.println("name: " + method.getName());


            

Reported by PMD.

System.out.println is used
Design

Line: 31

                      }

        for (Method method : methods) {
            System.out.println("name: " + method.getName());

            Class[] paraClassArray = method.getParameterTypes();
            for (Class paraClass : paraClassArray) {
                System.out.println("parameters: " + paraClass);
                

            

Reported by PMD.

System.out.println is used
Design

Line: 35

              
            Class[] paraClassArray = method.getParameterTypes();
            for (Class paraClass : paraClassArray) {
                System.out.println("parameters: " + paraClass);
                
                Package pkg = paraClass.getPackage();
                if (pkg == null || !pkg.getName().equals("java.lang")) {
                    Object obj = paraClass.newInstance();
                  //  System.out.println(obj);

            

Reported by PMD.

System.out.println is used
Design

Line: 43

                                //  System.out.println(obj);

                    String kaka = JSON.toJSONString(obj, SerializerFeature.WriteMapNullValue);
                    System.out.println(kaka);
                    System.out.println(kaka);

//                    ObjectMapper objectMapper = new ObjectMapper();
//                    String tt = objectMapper.writeValueAsString(obj);
//                    System.out.println(tt);

            

Reported by PMD.

System.out.println is used
Design

Line: 44

              
                    String kaka = JSON.toJSONString(obj, SerializerFeature.WriteMapNullValue);
                    System.out.println(kaka);
                    System.out.println(kaka);

//                    ObjectMapper objectMapper = new ObjectMapper();
//                    String tt = objectMapper.writeValueAsString(obj);
//                    System.out.println(tt);
                }

            

Reported by PMD.

System.out.println is used
Design

Line: 53

                          }
            //System.out.println("return: " + method.getReturnType());
            //System.out.println("description: " + method.toGenericString());
            System.out.println();
        }
    }

    public static class ExtClassLoader extends ClassLoader {


            

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

              
public class TestExternal2 extends TestCase {

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

        Class theClass = classLoader.loadClass("com.alibaba.mock.demo.service.MockDemoService");
        Method[] methods = theClass.getMethods();


            

Reported by PMD.

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

Line: 16

              
public class TestExternal2 extends TestCase {

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

        Class theClass = classLoader.loadClass("com.alibaba.mock.demo.service.MockDemoService");
        Method[] methods = theClass.getMethods();


            

Reported by PMD.

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

Line: 20

                      ExtClassLoader classLoader = new ExtClassLoader();

        Class theClass = classLoader.loadClass("com.alibaba.mock.demo.service.MockDemoService");
        Method[] methods = theClass.getMethods();

        //基本类型
        if (void.class.isPrimitive()) {
            System.out.println("void");
        }

            

Reported by PMD.

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

Line: 31

                              "\t},\n" +
                "\t\"aaaa\\\"\":{\"$ref\":\"$.bbbb\\\\\\\"\"}\n" +
                "}";
        System.out.println(json);
        JSONObject root = JSON.parseObject(json);
        assertSame(root.get("bbbb\\"), root.get("aaaa\\"));
    }
}

            

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

               * Created by wenshao on 16/8/23.
 */
public class RefTest23 extends TestCase {
    public void test_ref() throws Exception {
        String json = "{\"$ref\":\"tmall/item\",\"id\":123}";
        JSONObject root = JSON.parseObject(json);
        assertEquals("tmall/item", root.get("$ref"));
        assertEquals(123, root.get("id"));
    }

            

Reported by PMD.

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

Line: 11

               * Created by wenshao on 16/8/23.
 */
public class RefTest23 extends TestCase {
    public void test_ref() throws Exception {
        String json = "{\"$ref\":\"tmall/item\",\"id\":123}";
        JSONObject root = JSON.parseObject(json);
        assertEquals("tmall/item", root.get("$ref"));
        assertEquals(123, root.get("id"));
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 14

                  public void test_ref() throws Exception {
        String json = "{\"$ref\":\"tmall/item\",\"id\":123}";
        JSONObject root = JSON.parseObject(json);
        assertEquals("tmall/item", root.get("$ref"));
        assertEquals(123, root.get("id"));
    }

    public void test_ref_1() throws Exception {
        String json = "{\"$ref\":123}";

            

Reported by PMD.

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

Line: 14

                  public void test_ref() throws Exception {
        String json = "{\"$ref\":\"tmall/item\",\"id\":123}";
        JSONObject root = JSON.parseObject(json);
        assertEquals("tmall/item", root.get("$ref"));
        assertEquals(123, root.get("id"));
    }

    public void test_ref_1() throws Exception {
        String json = "{\"$ref\":123}";

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 15

                      String json = "{\"$ref\":\"tmall/item\",\"id\":123}";
        JSONObject root = JSON.parseObject(json);
        assertEquals("tmall/item", root.get("$ref"));
        assertEquals(123, root.get("id"));
    }

    public void test_ref_1() throws Exception {
        String json = "{\"$ref\":123}";
        JSONObject root = JSON.parseObject(json);

            

Reported by PMD.

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

Line: 15

                      String json = "{\"$ref\":\"tmall/item\",\"id\":123}";
        JSONObject root = JSON.parseObject(json);
        assertEquals("tmall/item", root.get("$ref"));
        assertEquals(123, root.get("id"));
    }

    public void test_ref_1() throws Exception {
        String json = "{\"$ref\":123}";
        JSONObject root = JSON.parseObject(json);

            

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

                      assertEquals(123, root.get("id"));
    }

    public void test_ref_1() throws Exception {
        String json = "{\"$ref\":123}";
        JSONObject root = JSON.parseObject(json);
        assertEquals(123, root.get("$ref"));
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 21

                  public void test_ref_1() throws Exception {
        String json = "{\"$ref\":123}";
        JSONObject root = JSON.parseObject(json);
        assertEquals(123, root.get("$ref"));
    }

    public void test_ref_2() throws Exception {
        String json = "{\n" +
                "\t\"bbbb\\\"\":{\n" +

            

Reported by PMD.

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

Line: 21

                  public void test_ref_1() throws Exception {
        String json = "{\"$ref\":123}";
        JSONObject root = JSON.parseObject(json);
        assertEquals(123, root.get("$ref"));
    }

    public void test_ref_2() throws Exception {
        String json = "{\n" +
                "\t\"bbbb\\\"\":{\n" +

            

Reported by PMD.