The following issues were found

src/test/java/com/alibaba/json/bvt/parser/deser/DefaultObjectDeserializerTest_collection.java
14 issues
Avoid throwing raw exception types.
Design

Line: 54

              	public static class MyMap<K, V> extends HashMap {

		public MyMap() {
			throw new RuntimeException();
		}

	}
}

            

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

              
public class DefaultObjectDeserializerTest_collection extends TestCase {

	public void test_0() throws Exception {
		String input = "[{}]";

		List<HashMap> map = JSON.parseObject(input,
				new TypeReference<List<HashMap>>() {
				}.getType());

            

Reported by PMD.

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

Line: 21

              				new TypeReference<List<HashMap>>() {
				}.getType());

		Assert.assertEquals(HashMap.class, map.get(0).getClass());
	}

	public void test_1() throws Exception {
		String input = "{}";


            

Reported by PMD.

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

Line: 21

              				new TypeReference<List<HashMap>>() {
				}.getType());

		Assert.assertEquals(HashMap.class, map.get(0).getClass());
	}

	public void test_1() throws Exception {
		String input = "{}";


            

Reported by PMD.

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

Line: 24

              		Assert.assertEquals(HashMap.class, map.get(0).getClass());
	}

	public void test_1() throws Exception {
		String input = "{}";

		BO<HashMap> map = JSON.parseObject(input,
				new TypeReference<BO<HashMap>>() {
				}.getType());

            

Reported by PMD.

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

Line: 24

              		Assert.assertEquals(HashMap.class, map.get(0).getClass());
	}

	public void test_1() throws Exception {
		String input = "{}";

		BO<HashMap> map = JSON.parseObject(input,
				new TypeReference<BO<HashMap>>() {
				}.getType());

            

Reported by PMD.

Avoid unused local variables such as 'map'.
Design

Line: 27

              	public void test_1() throws Exception {
		String input = "{}";

		BO<HashMap> map = JSON.parseObject(input,
				new TypeReference<BO<HashMap>>() {
				}.getType());
	}

	public void test_2() throws Exception {

            

Reported by PMD.

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

Line: 32

              				}.getType());
	}

	public void test_2() throws Exception {

		Exception error = null;
		try {
			String input = "{'map':{}}";


            

Reported by PMD.

Avoid unused local variables such as 'map'.
Design

Line: 38

              		try {
			String input = "{'map':{}}";

			MyMap<String, HashMap> map = JSON.parseObject(input,
					new TypeReference<MyMap<String, HashMap>>() {
					}.getType());
		} catch (Exception ex) {
			error = ex;
		}

            

Reported by PMD.

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

Line: 41

              			MyMap<String, HashMap> map = JSON.parseObject(input,
					new TypeReference<MyMap<String, HashMap>>() {
					}.getType());
		} catch (Exception ex) {
			error = ex;
		}
		Assert.assertNotNull(error);
	}


            

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/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/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/support/hsf/HSFJSONUtilsTest_4.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

              import java.util.HashSet;

public class HSFJSONUtilsTest_4 extends TestCase {
    public void test_for_hsf() throws Exception {
        final Method method = HSFJSONUtilsTest_4.class.getMethod("f", HashSet.class, BigDecimalDO.class);

        String json = "{\"argsTypes\":[\"java.util.HashSet\",\"com.alibaba.json.bvt.support.hsf.HSFJSONUtilsTest_4$BigDecimalDO\"],\"argsObjs\":[[{\"bd\":10.12379}],{\"$ref\":\"$.argsObjs[0][0]\"}]}";

        Object[] values = HSFJSONUtils.parseInvocationArguments(json, new MethodLocator() {

            

Reported by PMD.

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

Line: 13

              import java.util.HashSet;

public class HSFJSONUtilsTest_4 extends TestCase {
    public void test_for_hsf() throws Exception {
        final Method method = HSFJSONUtilsTest_4.class.getMethod("f", HashSet.class, BigDecimalDO.class);

        String json = "{\"argsTypes\":[\"java.util.HashSet\",\"com.alibaba.json.bvt.support.hsf.HSFJSONUtilsTest_4$BigDecimalDO\"],\"argsObjs\":[[{\"bd\":10.12379}],{\"$ref\":\"$.argsObjs[0][0]\"}]}";

        Object[] values = HSFJSONUtils.parseInvocationArguments(json, new MethodLocator() {

            

Reported by PMD.

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

Line: 14

              
public class HSFJSONUtilsTest_4 extends TestCase {
    public void test_for_hsf() throws Exception {
        final Method method = HSFJSONUtilsTest_4.class.getMethod("f", HashSet.class, BigDecimalDO.class);

        String json = "{\"argsTypes\":[\"java.util.HashSet\",\"com.alibaba.json.bvt.support.hsf.HSFJSONUtilsTest_4$BigDecimalDO\"],\"argsObjs\":[[{\"bd\":10.12379}],{\"$ref\":\"$.argsObjs[0][0]\"}]}";

        Object[] values = HSFJSONUtils.parseInvocationArguments(json, new MethodLocator() {


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 25

                          }
        });

        assertEquals(2, values.length);

        HashSet<BigDecimalDO> set = (HashSet<BigDecimalDO>) values[0];
        assertEquals(1, set.size());
        assertSame(set.iterator().next(), values[1]);
    }

            

Reported by PMD.

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

Line: 28

                      assertEquals(2, values.length);

        HashSet<BigDecimalDO> set = (HashSet<BigDecimalDO>) values[0];
        assertEquals(1, set.size());
        assertSame(set.iterator().next(), values[1]);
    }

    public static void f(HashSet<BigDecimalDO> a, BigDecimalDO b) {


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 28

                      assertEquals(2, values.length);

        HashSet<BigDecimalDO> set = (HashSet<BigDecimalDO>) values[0];
        assertEquals(1, set.size());
        assertSame(set.iterator().next(), values[1]);
    }

    public static void f(HashSet<BigDecimalDO> a, BigDecimalDO b) {


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 29

              
        HashSet<BigDecimalDO> set = (HashSet<BigDecimalDO>) values[0];
        assertEquals(1, set.size());
        assertSame(set.iterator().next(), values[1]);
    }

    public static void f(HashSet<BigDecimalDO> a, BigDecimalDO b) {

    }

            

Reported by PMD.

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

Line: 29

              
        HashSet<BigDecimalDO> set = (HashSet<BigDecimalDO>) values[0];
        assertEquals(1, set.size());
        assertSame(set.iterator().next(), values[1]);
    }

    public static void f(HashSet<BigDecimalDO> a, BigDecimalDO b) {

    }

            

Reported by PMD.

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

Line: 29

              
        HashSet<BigDecimalDO> set = (HashSet<BigDecimalDO>) values[0];
        assertEquals(1, set.size());
        assertSame(set.iterator().next(), values[1]);
    }

    public static void f(HashSet<BigDecimalDO> a, BigDecimalDO b) {

    }

            

Reported by PMD.

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

Line: 32

                      assertSame(set.iterator().next(), values[1]);
    }

    public static void f(HashSet<BigDecimalDO> a, BigDecimalDO b) {

    }

    public static class BigDecimalDO implements Serializable {


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/BooleanFieldSerializerTest_primitive.java
14 issues
Avoid reassigning parameters such as 'featureValues'
Design

Line: 69

                  }

    @SuppressWarnings("unchecked")
    public static final <T> T parseObjectNoAsm(String input, Type clazz, int featureValues, Feature... features) {
        if (input == null) {
            return null;
        }

        for (Feature feature : features) {

            

Reported by PMD.

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

Line: 20

              
public class BooleanFieldSerializerTest_primitive extends TestCase {

    public void test_0() {
        Assert.assertEquals("{\"value\":false}", JSON.toJSONString(new Entity(), SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullBooleanAsFalse));
    }

    public void test_codec_no_asm() throws Exception {
        Entity v = new Entity();

            

Reported by PMD.

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

Line: 24

                      Assert.assertEquals("{\"value\":false}", JSON.toJSONString(new Entity(), SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullBooleanAsFalse));
    }

    public void test_codec_no_asm() throws Exception {
        Entity v = new Entity();

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


            

Reported by PMD.

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

Line: 35

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

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

    public void test_codec() throws Exception {
        Entity v1 = parseObjectNoAsm("{value:1}", Entity.class, JSON.DEFAULT_PARSER_FEATURE);


            

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(v.getValue(), v1.getValue());
    }

    public void test_codec() throws Exception {
        Entity v1 = parseObjectNoAsm("{value:1}", Entity.class, JSON.DEFAULT_PARSER_FEATURE);

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


            

Reported by PMD.

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

Line: 41

                  public void test_codec() throws Exception {
        Entity v1 = parseObjectNoAsm("{value:1}", Entity.class, JSON.DEFAULT_PARSER_FEATURE);

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

    public void test_codec_0() throws Exception {
        Entity v1 = parseObjectNoAsm("{value:0}", Entity.class, JSON.DEFAULT_PARSER_FEATURE);


            

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

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

    public void test_codec_0() throws Exception {
        Entity v1 = parseObjectNoAsm("{value:0}", Entity.class, JSON.DEFAULT_PARSER_FEATURE);

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


            

Reported by PMD.

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

Line: 47

                  public void test_codec_0() throws Exception {
        Entity v1 = parseObjectNoAsm("{value:0}", Entity.class, JSON.DEFAULT_PARSER_FEATURE);

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

    public void test_codec_1() throws Exception {
        Entity v1 = parseObjectNoAsm("{value:'true'}", Entity.class, JSON.DEFAULT_PARSER_FEATURE);


            

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(false, v1.getValue());
    }

    public void test_codec_1() throws Exception {
        Entity v1 = parseObjectNoAsm("{value:'true'}", Entity.class, JSON.DEFAULT_PARSER_FEATURE);

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


            

Reported by PMD.

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

Line: 53

                  public void test_codec_1() throws Exception {
        Entity v1 = parseObjectNoAsm("{value:'true'}", Entity.class, JSON.DEFAULT_PARSER_FEATURE);

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

    public void test_codec_2() throws Exception {
        Entity v1 = parseObjectNoAsm("{value:null}", Entity.class, JSON.DEFAULT_PARSER_FEATURE);


            

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/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.

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

Line: 13

              
public class AbstractSerializeTest2 extends TestCase {

    protected void setUp() throws Exception {
        ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.AbstractSerializeTest2");
        ParserConfig.global.addAccept("com.alibaba.json.bvt.parser.deser.AbstractSerializeTest2");
    }

    protected void tearDown() throws Exception {

            

Reported by PMD.

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

Line: 14

              public class AbstractSerializeTest2 extends TestCase {

    protected void setUp() throws Exception {
        ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.AbstractSerializeTest2");
        ParserConfig.global.addAccept("com.alibaba.json.bvt.parser.deser.AbstractSerializeTest2");
    }

    protected void tearDown() throws Exception {
        ParserConfig.getGlobalInstance().putDeserializer(A.class, null);

            

Reported by PMD.

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

Line: 15

              
    protected void setUp() throws Exception {
        ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.AbstractSerializeTest2");
        ParserConfig.global.addAccept("com.alibaba.json.bvt.parser.deser.AbstractSerializeTest2");
    }

    protected void tearDown() throws Exception {
        ParserConfig.getGlobalInstance().putDeserializer(A.class, null);
    }

            

Reported by PMD.

JUnit 4 tests that clean up tests should use the @After annotation, JUnit5 tests should use @AfterEach or @AfterAll
Design

Line: 18

                      ParserConfig.global.addAccept("com.alibaba.json.bvt.parser.deser.AbstractSerializeTest2");
    }

    protected void tearDown() throws Exception {
        ParserConfig.getGlobalInstance().putDeserializer(A.class, null);
    }

    public void test_mapping_0() throws Exception {
        String text = "{\"@type\":\"com.alibaba.json.bvt.parser.deser.AbstractSerializeTest2$A\"}";

            

Reported by PMD.

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

Line: 19

                  }

    protected void tearDown() throws Exception {
        ParserConfig.getGlobalInstance().putDeserializer(A.class, null);
    }

    public void test_mapping_0() throws Exception {
        String text = "{\"@type\":\"com.alibaba.json.bvt.parser.deser.AbstractSerializeTest2$A\"}";


            

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

                      ParserConfig.getGlobalInstance().putDeserializer(A.class, null);
    }

    public void test_mapping_0() throws Exception {
        String text = "{\"@type\":\"com.alibaba.json.bvt.parser.deser.AbstractSerializeTest2$A\"}";

        B b = (B) JSON.parse(text);
        Assert.assertNotNull(b);
    }

            

Reported by PMD.

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

Line: 29

                      Assert.assertNotNull(b);
    }

    public void test_mapping_1() throws Exception {
        String text = "{\"@type\":\"com.alibaba.json.bvt.parser.deser.AbstractSerializeTest2$A\",\"id\":123}";

        B b = (B) JSON.parse(text);
        Assert.assertNotNull(b);
        Assert.assertEquals(123, b.getId());

            

Reported by PMD.

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

Line: 34

              
        B b = (B) JSON.parse(text);
        Assert.assertNotNull(b);
        Assert.assertEquals(123, b.getId());
    }

    public void test_mapping_2() throws Exception {
        String text = "{\"@type\":\"com.alibaba.json.bvt.parser.deser.AbstractSerializeTest2$A\",\"id\":234,\"name\":\"abc\"}";


            

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

                      Assert.assertEquals(123, b.getId());
    }

    public void test_mapping_2() throws Exception {
        String text = "{\"@type\":\"com.alibaba.json.bvt.parser.deser.AbstractSerializeTest2$A\",\"id\":234,\"name\":\"abc\"}";

        B b = (B) JSON.parse(text);
        Assert.assertNotNull(b);
        Assert.assertEquals(234, b.getId());

            

Reported by PMD.

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

Line: 42

              
        B b = (B) JSON.parse(text);
        Assert.assertNotNull(b);
        Assert.assertEquals(234, b.getId());
        Assert.assertEquals("abc", b.getName());
    }

    public void test_mapping_group() throws Exception {
        String text = "{\"a\":{\"id\":234,\"name\":\"abc\"}}";

            

Reported by PMD.

src/test/java/com/alibaba/json/test/InnerInnerTest.java
14 issues
The class 'Outter' is suspected to be a Data Class (WOC=0.000%, NOPA=0, NOAM=4, WMC=4)
Design

Line: 10

              
import junit.framework.TestCase;

class Outter{
	private String name;
	private InnerInner ii;
	
	public String getName() {
		return name;

            

Reported by PMD.

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

Line: 50

              
public class InnerInnerTest extends TestCase{//深层内部类的序列化反序列化测试

	public void testDeserialize(){//
		String json = "{\"ii\":{\"name\":\"iicls\"},\"name\":\"ocls\"}";
		Outter o = JSON.parseObject(json, Outter.class);
		assertEquals("ocls", o.getName());
		assertEquals("iicls", o.getIi().getName());
	}

            

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

              
public class InnerInnerTest extends TestCase{//深层内部类的序列化反序列化测试

	public void testDeserialize(){//
		String json = "{\"ii\":{\"name\":\"iicls\"},\"name\":\"ocls\"}";
		Outter o = JSON.parseObject(json, Outter.class);
		assertEquals("ocls", o.getName());
		assertEquals("iicls", o.getIi().getName());
	}

            

Reported by PMD.

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

Line: 53

              	public void testDeserialize(){//
		String json = "{\"ii\":{\"name\":\"iicls\"},\"name\":\"ocls\"}";
		Outter o = JSON.parseObject(json, Outter.class);
		assertEquals("ocls", o.getName());
		assertEquals("iicls", o.getIi().getName());
	}
	
	public void testSerialize(){
		Outter o = new Outter();

            

Reported by PMD.

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

Line: 53

              	public void testDeserialize(){//
		String json = "{\"ii\":{\"name\":\"iicls\"},\"name\":\"ocls\"}";
		Outter o = JSON.parseObject(json, Outter.class);
		assertEquals("ocls", o.getName());
		assertEquals("iicls", o.getIi().getName());
	}
	
	public void testSerialize(){
		Outter o = new Outter();

            

Reported by PMD.

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

Line: 54

              		String json = "{\"ii\":{\"name\":\"iicls\"},\"name\":\"ocls\"}";
		Outter o = JSON.parseObject(json, Outter.class);
		assertEquals("ocls", o.getName());
		assertEquals("iicls", o.getIi().getName());
	}
	
	public void testSerialize(){
		Outter o = new Outter();
		Inner i = o.new Inner();

            

Reported by PMD.

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

Line: 54

              		String json = "{\"ii\":{\"name\":\"iicls\"},\"name\":\"ocls\"}";
		Outter o = JSON.parseObject(json, Outter.class);
		assertEquals("ocls", o.getName());
		assertEquals("iicls", o.getIi().getName());
	}
	
	public void testSerialize(){
		Outter o = new Outter();
		Inner i = o.new Inner();

            

Reported by PMD.

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

Line: 54

              		String json = "{\"ii\":{\"name\":\"iicls\"},\"name\":\"ocls\"}";
		Outter o = JSON.parseObject(json, Outter.class);
		assertEquals("ocls", o.getName());
		assertEquals("iicls", o.getIi().getName());
	}
	
	public void testSerialize(){
		Outter o = new Outter();
		Inner i = o.new Inner();

            

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

              		assertEquals("iicls", o.getIi().getName());
	}
	
	public void testSerialize(){
		Outter o = new Outter();
		Inner i = o.new Inner();
		InnerInner ii = i.new InnerInner();
		ii.setName("iicls");
		o.setIi(ii);

            

Reported by PMD.

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

Line: 68

              		assertEquals("{\"ii\":{\"name\":\"iicls\"},\"name\":\"ocls\"}", json);
	}
	
	public void testGson(){
		Outter o = new Outter();
		Inner i = o.new Inner();
		InnerInner ii = i.new InnerInner();
		ii.setName("iicls");
		o.setIi(ii);

            

Reported by PMD.