The following issues were found

src/test/java/com/alibaba/json/bvt/kotlin/ResponseKotlinTest.java
5 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 14

               * Created by wenshao on 10/08/2017.
 */
public class ResponseKotlinTest extends TestCase {
    public void test_kotlin() throws Exception {
        ExtClassLoader classLoader = new ExtClassLoader();
        Class clazz = classLoader.loadClass("ResponseKotlin");

        String json = "{\"text\":\"robohorse\",\"value\":99}";
        Object obj = JSON.parseObject(json, clazz);

            

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

               * Created by wenshao on 10/08/2017.
 */
public class ResponseKotlinTest extends TestCase {
    public void test_kotlin() throws Exception {
        ExtClassLoader classLoader = new ExtClassLoader();
        Class clazz = classLoader.loadClass("ResponseKotlin");

        String json = "{\"text\":\"robohorse\",\"value\":99}";
        Object obj = JSON.parseObject(json, clazz);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 20

              
        String json = "{\"text\":\"robohorse\",\"value\":99}";
        Object obj = JSON.parseObject(json, clazz);
        assertEquals("{\"text\":\"robohorse\",\"value\":99}", JSON.toJSONString(obj));

        String json2 = "{\"text\":\"robohorse\"}";
        Object obj2 = JSON.parseObject(json2, clazz);
        assertEquals("{\"text\":\"robohorse\"}", JSON.toJSONString(obj2));
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 24

              
        String json2 = "{\"text\":\"robohorse\"}";
        Object obj2 = JSON.parseObject(json2, clazz);
        assertEquals("{\"text\":\"robohorse\"}", JSON.toJSONString(obj2));
    }

    public static class ExtClassLoader extends ClassLoader {

        public ExtClassLoader() throws IOException {

            

Reported by PMD.

Ensure that resources like this InputStream object are closed after use
Error

Line: 34

              
            {
                byte[] bytes;
                InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("kotlin/ResponseKotlin.clazz");
                bytes = IOUtils.toByteArray(is);
                is.close();

                super.defineClass("ResponseKotlin", bytes, 0, bytes.length);
            }

            

Reported by PMD.

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

Line: 8

              import junit.framework.TestCase;

public class Issue2129 extends TestCase {
    public void test_for_issue() throws Exception {
        LinkedHashMultimap<String, String> map = LinkedHashMultimap.create();
        map.put("a", "1");
        map.put("a", "b");
        map.put("b", "1");
        String json = JSON.toJSONString(map);

            

Reported by PMD.

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

Line: 10

              public class Issue2129 extends TestCase {
    public void test_for_issue() throws Exception {
        LinkedHashMultimap<String, String> map = LinkedHashMultimap.create();
        map.put("a", "1");
        map.put("a", "b");
        map.put("b", "1");
        String json = JSON.toJSONString(map);
        assertEquals("{\"a\":[\"1\",\"b\"],\"b\":[\"1\"]}", json);
    }

            

Reported by PMD.

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

Line: 11

                  public void test_for_issue() throws Exception {
        LinkedHashMultimap<String, String> map = LinkedHashMultimap.create();
        map.put("a", "1");
        map.put("a", "b");
        map.put("b", "1");
        String json = JSON.toJSONString(map);
        assertEquals("{\"a\":[\"1\",\"b\"],\"b\":[\"1\"]}", json);
    }
}

            

Reported by PMD.

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

Line: 12

                      LinkedHashMultimap<String, String> map = LinkedHashMultimap.create();
        map.put("a", "1");
        map.put("a", "b");
        map.put("b", "1");
        String json = JSON.toJSONString(map);
        assertEquals("{\"a\":[\"1\",\"b\"],\"b\":[\"1\"]}", json);
    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 14

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

            

Reported by PMD.

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

Line: 8

              import junit.framework.TestCase;

public class Issue3671 extends TestCase {
    public void test_for_issue() throws Exception {
        String json = "[{\n" +
                "    \"filters\": [],\n" +
                "    \"id\": \"baidu_route2\",\n" +
                "    \"order\": 0,\n" +
                "    \"predicates\": [{\n" +

            

Reported by PMD.

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

Line: 8

              import junit.framework.TestCase;

public class Issue3671 extends TestCase {
    public void test_for_issue() throws Exception {
        String json = "[{\n" +
                "    \"filters\": [],\n" +
                "    \"id\": \"baidu_route2\",\n" +
                "    \"order\": 0,\n" +
                "    \"predicates\": [{\n" +

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 21

                              "    }],\n" +
                "    \"uri\": \"https://www.baidu.com\"\n" +
                "}]\n";
        assertTrue(JSONValidator.from(json).validate());
        assertTrue(JSON.isValid(json));
    }
}

            

Reported by PMD.

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

Line: 21

                              "    }],\n" +
                "    \"uri\": \"https://www.baidu.com\"\n" +
                "}]\n";
        assertTrue(JSONValidator.from(json).validate());
        assertTrue(JSON.isValid(json));
    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 22

                              "    \"uri\": \"https://www.baidu.com\"\n" +
                "}]\n";
        assertTrue(JSONValidator.from(json).validate());
        assertTrue(JSON.isValid(json));
    }
}

            

Reported by PMD.

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

Line: 14

               * Created by wenshao on 10/08/2017.
 */
public class ResponseKotlin2Test extends TestCase {
    public void test_kotlin() throws Exception {
        ExtClassLoader classLoader = new ExtClassLoader();
        Class clazz = classLoader.loadClass("ResponseKotlin2");

        String json = "{\"text\":\"robohorse\",\"value\":99}";
        Object obj = JSON.parseObject(json, clazz);

            

Reported by PMD.

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

Line: 14

               * Created by wenshao on 10/08/2017.
 */
public class ResponseKotlin2Test extends TestCase {
    public void test_kotlin() throws Exception {
        ExtClassLoader classLoader = new ExtClassLoader();
        Class clazz = classLoader.loadClass("ResponseKotlin2");

        String json = "{\"text\":\"robohorse\",\"value\":99}";
        Object obj = JSON.parseObject(json, clazz);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 20

              
        String json = "{\"text\":\"robohorse\",\"value\":99}";
        Object obj = JSON.parseObject(json, clazz);
        assertEquals("{\"text\":\"robohorse\",\"value\":99}", JSON.toJSONString(obj));

        String json2 = "{\"text\":\"robohorse\"}";
        Object obj2 = JSON.parseObject(json2, clazz);
        assertEquals("{\"text\":\"robohorse\"}", JSON.toJSONString(obj2));
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 24

              
        String json2 = "{\"text\":\"robohorse\"}";
        Object obj2 = JSON.parseObject(json2, clazz);
        assertEquals("{\"text\":\"robohorse\"}", JSON.toJSONString(obj2));
    }

    public static class ExtClassLoader extends ClassLoader {

        public ExtClassLoader() throws IOException {

            

Reported by PMD.

Ensure that resources like this InputStream object are closed after use
Error

Line: 34

              
            {
                byte[] bytes;
                InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("kotlin/ResponseKotlin2.clazz");
                bytes = IOUtils.toByteArray(is);
                is.close();

                super.defineClass("ResponseKotlin2", bytes, 0, bytes.length);
            }

            

Reported by PMD.

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

Line: 9

              import java.util.Date;

public class Issue_for_wuye extends TestCase {
    public void test_for_issue() throws Exception {
        String poistr = "{\"gmtModified\":\"2017-09-07 16:39:19\",\"gmtCreate\":\"2017-09-07 16:39:19\"}";
        TimeBean poiInfo = JSON.parseObject(poistr, TimeBean.class);
    }

    public static class TimeBean {

            

Reported by PMD.

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

Line: 9

              import java.util.Date;

public class Issue_for_wuye extends TestCase {
    public void test_for_issue() throws Exception {
        String poistr = "{\"gmtModified\":\"2017-09-07 16:39:19\",\"gmtCreate\":\"2017-09-07 16:39:19\"}";
        TimeBean poiInfo = JSON.parseObject(poistr, TimeBean.class);
    }

    public static class TimeBean {

            

Reported by PMD.

Avoid unused local variables such as 'poiInfo'.
Design

Line: 11

              public class Issue_for_wuye extends TestCase {
    public void test_for_issue() throws Exception {
        String poistr = "{\"gmtModified\":\"2017-09-07 16:39:19\",\"gmtCreate\":\"2017-09-07 16:39:19\"}";
        TimeBean poiInfo = JSON.parseObject(poistr, TimeBean.class);
    }

    public static class TimeBean {
        private Date time1;
        private Date time2;

            

Reported by PMD.

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

Line: 14

                      TimeBean poiInfo = JSON.parseObject(poistr, TimeBean.class);
    }

    public static class TimeBean {
        private Date time1;
        private Date time2;

        public Date getTime1() {
            return time1;

            

Reported by PMD.

Found 'DU'-anomaly for variable 'poiInfo' (lines '11'-'12').
Error

Line: 11

              public class Issue_for_wuye extends TestCase {
    public void test_for_issue() throws Exception {
        String poistr = "{\"gmtModified\":\"2017-09-07 16:39:19\",\"gmtCreate\":\"2017-09-07 16:39:19\"}";
        TimeBean poiInfo = JSON.parseObject(poistr, TimeBean.class);
    }

    public static class TimeBean {
        private Date time1;
        private Date time2;

            

Reported by PMD.

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

Line: 9

              import junit.framework.TestCase;

public class Issue2201 extends TestCase  {
    public void test_for_issue() throws Exception {
        ParserConfig.getGlobalInstance().register("M2001", Model.class);

        String json = "{\"@type\":\"M2001\",\"id\":3}";
        Model m = (Model) JSON.parseObject(json, Object.class);
        assertEquals(3, m.id);

            

Reported by PMD.

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

Line: 10

              
public class Issue2201 extends TestCase  {
    public void test_for_issue() throws Exception {
        ParserConfig.getGlobalInstance().register("M2001", Model.class);

        String json = "{\"@type\":\"M2001\",\"id\":3}";
        Model m = (Model) JSON.parseObject(json, Object.class);
        assertEquals(3, m.id);
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 14

              
        String json = "{\"@type\":\"M2001\",\"id\":3}";
        Model m = (Model) JSON.parseObject(json, Object.class);
        assertEquals(3, m.id);
    }

    public static class Model {
        public int id;
    }

            

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 id;
    }
}

            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.fastjson.serializer.SerializerFeature'
Design

Line: 5

              
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;

public class Issue2201 extends TestCase  {
    public void test_for_issue() throws Exception {
        ParserConfig.getGlobalInstance().register("M2001", Model.class);

            

Reported by PMD.

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

Line: 13

               * Created by wenshao on 21/02/2017.
 */
public class JSONPParseTest4 extends TestCase {
    public void test_f() throws Exception {
        JSONPObject p = new JSONPObject();
        p.setFunction("f");
        assertEquals("f()", p.toJSONString());
    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 16

                  public void test_f() throws Exception {
        JSONPObject p = new JSONPObject();
        p.setFunction("f");
        assertEquals("f()", p.toJSONString());
    }
}

            

Reported by PMD.

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

Line: 3

              package com.alibaba.json.bvt.jsonp;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONPObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;

/**

            

Reported by PMD.

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

Line: 4

              package com.alibaba.json.bvt.jsonp;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONPObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;

/**

            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.fastjson.serializer.SerializerFeature'
Design

Line: 6

              import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONPObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;

/**
 * Created by wenshao on 21/02/2017.
 */

            

Reported by PMD.

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

Line: 22

                      JSON.writeJSONString(out, model);

        String text = new String(out.toByteArray(), "UTF-8");
        System.out.println(text);
    }

    public static class Model {
        public String value;
    }

            

Reported by PMD.

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

Line: 13

               * Created by wenshao on 13/04/2017.
 */
public class EmojiTest0 extends TestCase {
    public void test_for_emoji() throws Exception {
        Model model = new Model();
        model.value = "An 😀awesome 😃string with a few 😉emojis!";

        ByteArrayOutputStream out = new ByteArrayOutputStream();


            

Reported by PMD.

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

Line: 13

               * Created by wenshao on 13/04/2017.
 */
public class EmojiTest0 extends TestCase {
    public void test_for_emoji() throws Exception {
        Model model = new Model();
        model.value = "An 😀awesome 😃string with a few 😉emojis!";

        ByteArrayOutputStream out = new ByteArrayOutputStream();


            

Reported by PMD.

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

Line: 26

                  }

    public static class Model {
        public String value;
    }
}

            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.fastjson.serializer.SerializerFeature'
Design

Line: 4

              package com.alibaba.json.bvt.emoji;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;

import java.io.ByteArrayOutputStream;

/**

            

Reported by PMD.

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

Line: 32

                              + "        \"task_type\": \"57205\"\n"
                + "    }]";

        System.out.println(JSON.VERSION);

        Object obj = JSONArray.parseArray(str, clazz);
        String result = JSON.toJSONString(obj);
        System.out.println(result);
        assertEquals("[{\"job_item_type\":\"高中\",\"product_id_1\":\"021\",\"product_id_2\":\"02102\",\"product_id_3\":\"0210202\",\"product_name_1\":\"犀利\",\"product_name_2\":\"基础路网\",\"product_name_3\":\"到底\",\"project_item\":\"1105067\",\"project_name\":\"明明想\",\"task_type\":\"57205\",\"task_type_name\":\"黎明X\",\"unit\":\"条\",\"unitremark\":\"任务条数\"}]", result);

            

Reported by PMD.

System.out.println is used
Design

Line: 36

              
        Object obj = JSONArray.parseArray(str, clazz);
        String result = JSON.toJSONString(obj);
        System.out.println(result);
        assertEquals("[{\"job_item_type\":\"高中\",\"product_id_1\":\"021\",\"product_id_2\":\"02102\",\"product_id_3\":\"0210202\",\"product_name_1\":\"犀利\",\"product_name_2\":\"基础路网\",\"product_name_3\":\"到底\",\"project_item\":\"1105067\",\"project_name\":\"明明想\",\"task_type\":\"57205\",\"task_type_name\":\"黎明X\",\"unit\":\"条\",\"unitremark\":\"任务条数\"}]", result);
    }

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

              import java.io.InputStream;

public class Issue_for_kotlin_20181203 extends TestCase {
    public void test_user() throws Exception {
        ExtClassLoader classLoader = new ExtClassLoader();
        Class clazz = classLoader.loadClass("com.autonavi.falcon.data.service.vulpeData.ProjectItemCheckItemRelation1");

        String str = "    [{\n"
                + "        \"project_item\": \"1105067\",\n"

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 37

                      Object obj = JSONArray.parseArray(str, clazz);
        String result = JSON.toJSONString(obj);
        System.out.println(result);
        assertEquals("[{\"job_item_type\":\"高中\",\"product_id_1\":\"021\",\"product_id_2\":\"02102\",\"product_id_3\":\"0210202\",\"product_name_1\":\"犀利\",\"product_name_2\":\"基础路网\",\"product_name_3\":\"到底\",\"project_item\":\"1105067\",\"project_name\":\"明明想\",\"task_type\":\"57205\",\"task_type_name\":\"黎明X\",\"unit\":\"条\",\"unitremark\":\"任务条数\"}]", result);
    }

    private static class ExtClassLoader extends ClassLoader {

        public ExtClassLoader() throws IOException {

            

Reported by PMD.

Ensure that resources like this InputStream object are closed after use
Error

Line: 47

              
            {
                byte[] bytes;
                InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("kotlin/ProjectItemCheckItemRelation1.clazz");
                bytes = IOUtils.toByteArray(is);
                is.close();

                super.defineClass("com.autonavi.falcon.data.service.vulpeData.ProjectItemCheckItemRelation1", bytes, 0, bytes.length);
            }

            

Reported by PMD.

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

Line: 13

              
public class FeatureTest extends TestCase {

    public void test_default() throws Exception {
        DefaultJSONParser parser = new DefaultJSONParser("");

        Assert.assertEquals(false, parser.isEnabled(Feature.AllowComment));
        Assert.assertEquals(true, parser.isEnabled(Feature.AllowSingleQuotes));
        Assert.assertEquals(true, parser.isEnabled(Feature.AllowUnQuotedFieldNames));

            

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.assertEquals(true, parser.isEnabled(Feature.InternFieldNames));
    }

    public void test_config() throws Exception {
        new IOUtils();

        DefaultJSONParser parser = new DefaultJSONParser("");

        Assert.assertEquals(false, parser.isEnabled(Feature.AllowComment));

            

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

                      Assert.assertEquals(false, parser.isEnabled(Feature.InternFieldNames));
    }

    public void test_count() throws Exception {
        assertTrue(Feature.values().length < 32);
    }
}

            

Reported by PMD.

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

Line: 42

                  }

    public void test_count() throws Exception {
        assertTrue(Feature.values().length < 32);
    }
}

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 42

                  }

    public void test_count() throws Exception {
        assertTrue(Feature.values().length < 32);
    }
}

            

Reported by PMD.