The following issues were found

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

Line: 12

              
public class Issue213Test extends TestCase {

    public void test_0() throws Exception {
        String text = "\t\t\t\t\t\t \u00A020:00-21:30</span><br />\r\n\r\n</p>\r\n<p>\r\n\t\r\n</p>\r\n<p>\r\n\t<br />\r\n</p>\r\n\t\t\t";
        Product e = new Product();
        e.setIntro(text);
        byte[] r = JSON.toJSONBytes(e);
        JSON.parseObject(r, Product.class);

            

Reported by PMD.

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

Line: 12

              
public class Issue213Test extends TestCase {

    public void test_0() throws Exception {
        String text = "\t\t\t\t\t\t \u00A020:00-21:30</span><br />\r\n\r\n</p>\r\n<p>\r\n\t\r\n</p>\r\n<p>\r\n\t<br />\r\n</p>\r\n\t\t\t";
        Product e = new Product();
        e.setIntro(text);
        byte[] r = JSON.toJSONBytes(e);
        JSON.parseObject(r, Product.class);

            

Reported by PMD.

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

Line: 20

                      JSON.parseObject(r, Product.class);
    }

    public static class Product implements Serializable {

        private static final long serialVersionUID = 5515785177596600948L;

        private String            studyTargets;


            

Reported by PMD.

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

Line: 15

              
public class EnumerationTest extends TestCase {

    public void test_enumeration() throws Exception {
        Assert.assertEquals("[]", JSON.toJSONString(new Vector().elements()));
        Assert.assertEquals("[null]", JSON.toJSONString(new Vector(Collections.singleton(null)).elements()));
        
        Assert.assertEquals("{\"value\":[]}", JSON.toJSONString(new VO(), SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullListAsEmpty));
    }

            

Reported by PMD.

Use ArrayList instead of Vector
Performance

Line: 16

              public class EnumerationTest extends TestCase {

    public void test_enumeration() throws Exception {
        Assert.assertEquals("[]", JSON.toJSONString(new Vector().elements()));
        Assert.assertEquals("[null]", JSON.toJSONString(new Vector(Collections.singleton(null)).elements()));
        
        Assert.assertEquals("{\"value\":[]}", JSON.toJSONString(new VO(), SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullListAsEmpty));
    }


            

Reported by PMD.

Use ArrayList instead of Vector
Performance

Line: 17

              
    public void test_enumeration() throws Exception {
        Assert.assertEquals("[]", JSON.toJSONString(new Vector().elements()));
        Assert.assertEquals("[null]", JSON.toJSONString(new Vector(Collections.singleton(null)).elements()));
        
        Assert.assertEquals("{\"value\":[]}", JSON.toJSONString(new VO(), SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullListAsEmpty));
    }

    private static class VO {

            

Reported by PMD.

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

Line: 11

              
public class JSONBytesTest2 extends TestCase {

    public void test_codec() throws Exception {
        String text="𠜎𠜱𠝹𠱓𠱸𠲖𠳏𠳕𠴕𠵼𠵿𠸎𠸏𠹷𠺝𠺢𠻗𠻹𠻺𠼭𠼮𠽌𠾴𠾼𠿪𡁜𡁯𡁵𡁶𡁻𡃁𡃉𡇙𢃇𢞵𢫕𢭃𢯊𢱑𢱕𢳂𢴈𢵌𢵧𢺳𣲷𤓓𤶸𤷪𥄫𦉘𦟌𦧲𦧺𧨾𨅝𨈇𨋢𨳊𨳍𨳒𩶘";

        byte[] bytes = JSON.toJSONBytes(text);
        String text2 = (String) JSON.parse(bytes);


            

Reported by PMD.

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

Line: 17

                      byte[] bytes = JSON.toJSONBytes(text);
        String text2 = (String) JSON.parse(bytes);

        Assert.assertEquals(text.length(), text2.length());
        for (int i = 0; i < text.length(); ++i) {
            char c1 = text.charAt(i);
            char c2 = text2.charAt(i);

            Assert.assertEquals(c1, c2);

            

Reported by PMD.

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

Line: 17

                      byte[] bytes = JSON.toJSONBytes(text);
        String text2 = (String) JSON.parse(bytes);

        Assert.assertEquals(text.length(), text2.length());
        for (int i = 0; i < text.length(); ++i) {
            char c1 = text.charAt(i);
            char c2 = text2.charAt(i);

            Assert.assertEquals(c1, c2);

            

Reported by PMD.

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

Line: 11

               */
public class EmptyArrayAsNullTest extends TestCase {

    public void test_emtpyAsNull() throws Exception {
        String text = "{\"value\":[]}";

        Model model = JSON.parseObject(text, Model.class);
        assertNull(model.value);
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 15

                      String text = "{\"value\":[]}";

        Model model = JSON.parseObject(text, Model.class);
        assertNull(model.value);
    }

    public static class Model {
        public Value value;
    }

            

Reported by PMD.

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

Line: 19

                  }

    public static class Model {
        public Value value;
    }

    public static class Value {

    }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/DefaultJSONParserTest_ref.java
3 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: 28

              
public class DefaultJSONParserTest_ref extends TestCase {

	public void test_ref() {
		Map obj = JSON.parseObject("{\"id\":{},\"value\":{\"$ref\":\"$\"}}", Map.class);
		Assert.assertTrue(obj == obj.get("value"));
	}

	

            

Reported by PMD.

Use equals() to compare object references.
Error

Line: 30

              
	public void test_ref() {
		Map obj = JSON.parseObject("{\"id\":{},\"value\":{\"$ref\":\"$\"}}", Map.class);
		Assert.assertTrue(obj == obj.get("value"));
	}

	
}

            

Reported by PMD.

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

Line: 30

              
	public void test_ref() {
		Map obj = JSON.parseObject("{\"id\":{},\"value\":{\"$ref\":\"$\"}}", Map.class);
		Assert.assertTrue(obj == obj.get("value"));
	}

	
}

            

Reported by PMD.

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

Line: 9

              
public class JSONObjectTest6 extends TestCase {

    public void test() throws Exception {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("value", 123);
        
        Model model = jsonObject.toJavaObject(Model.class);
        assertEquals(123, model.value);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 14

                      jsonObject.put("value", 123);
        
        Model model = jsonObject.toJavaObject(Model.class);
        assertEquals(123, model.value);
    }
    
    public static class Model {
        public int value;
    }

            

Reported by PMD.

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

Line: 18

                  }
    
    public static class Model {
        public int value;
    }
}

            

Reported by PMD.

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

Line: 16

                      VO vo = new VO();
        vo.setValue(Currency.getInstance(Locale.CHINA));
        String text = JSON.toJSONString(vo);
        System.out.println(text);
        JSON.parseObject(text, VO.class);
    }

    public static class VO {


            

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

              
public class CurrencyTest extends TestCase {

    public void test_0() throws Exception {
        VO vo = new VO();
        vo.setValue(Currency.getInstance(Locale.CHINA));
        String text = JSON.toJSONString(vo);
        System.out.println(text);
        JSON.parseObject(text, VO.class);

            

Reported by PMD.

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

Line: 12

              
public class CurrencyTest extends TestCase {

    public void test_0() throws Exception {
        VO vo = new VO();
        vo.setValue(Currency.getInstance(Locale.CHINA));
        String text = JSON.toJSONString(vo);
        System.out.println(text);
        JSON.parseObject(text, VO.class);

            

Reported by PMD.

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

    public void test_get_empty() throws Exception {
        JSONObject obj = new JSONObject();
        obj.put("value", "");
        Assert.assertEquals("", obj.get("value"));
        Assert.assertNull(obj.getObject("value", Model.class));
    }

            

Reported by PMD.

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

Line: 23

                      Assert.assertNull(obj.getObject("value", Model.class));
    }
    
    public void test_get_null() throws Exception {
        TypeUtils.cast("null", getType(), ParserConfig.getGlobalInstance());
        TypeUtils.cast("", getType(), ParserConfig.getGlobalInstance());
    }
    
    public static class Model {

            

Reported by PMD.

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

Line: 23

                      Assert.assertNull(obj.getObject("value", Model.class));
    }
    
    public void test_get_null() throws Exception {
        TypeUtils.cast("null", getType(), ParserConfig.getGlobalInstance());
        TypeUtils.cast("", getType(), ParserConfig.getGlobalInstance());
    }
    
    public static class Model {

            

Reported by PMD.

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

Line: 12

              
public class CircularReferenceTest extends TestCase {

    public void test_0() throws Exception {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ObjectOutputStream objectOut = new ObjectOutputStream(out);

        Category p = new Category();
        p.setId(1);

            

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

              
public class CircularReferenceTest extends TestCase {

    public void test_0() throws Exception {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ObjectOutputStream objectOut = new ObjectOutputStream(out);

        Category p = new Category();
        p.setId(1);

            

Reported by PMD.

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

Line: 23

                          Category child = new Category();
            child.setId(2);
            child.setName("child");
            p.getChildren().add(child);
            child.setParent(p);
        }
        objectOut.writeObject(p);
    }


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Issue944.java
3 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 19/12/2016.
 */
public class Issue944 extends TestCase {
    public void test_for_issue() throws Exception {
        Model model = new Model();
        model.id = 1001;

        String text = JSON.toJSONString(model, SerializerFeature.SkipTransientField);


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

              
        String text = JSON.toJSONString(model, SerializerFeature.SkipTransientField);

        assertEquals("{}", text);
    }

    public static class Model {
        private int id;


            

Reported by PMD.

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

Line: 23

                  }

    public static class Model {
        private int id;

        @Transient
        public int getId() {
            return id;
        }

            

Reported by PMD.