The following issues were found

src/main/java/com/alibaba/fastjson/serializer/CalendarCodec.java
26 issues
The class 'CalendarCodec' has a Modified Cyclomatic Complexity of 4 (Highest = 12).
Design

Line: 23

              import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;

public class CalendarCodec extends ContextObjectDeserializer implements ObjectSerializer, ObjectDeserializer, ContextObjectSerializer {

    public final static CalendarCodec instance = new CalendarCodec();

    private DatatypeFactory dateFactory;


            

Reported by PMD.

The class 'CalendarCodec' has a Standard Cyclomatic Complexity of 4 (Highest = 12).
Design

Line: 23

              import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;

public class CalendarCodec extends ContextObjectDeserializer implements ObjectSerializer, ObjectDeserializer, ContextObjectSerializer {

    public final static CalendarCodec instance = new CalendarCodec();

    private DatatypeFactory dateFactory;


            

Reported by PMD.

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

Line: 27

              
    public final static CalendarCodec instance = new CalendarCodec();

    private DatatypeFactory dateFactory;

    public void write(JSONSerializer serializer, Object object, BeanContext context) throws IOException {
        SerializeWriter out = serializer.out;
        String format = context.getFormat();
        Calendar calendar = (Calendar) object;

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 34

                      String format = context.getFormat();
        Calendar calendar = (Calendar) object;

        if (format.equals("unixtime")) {
            long seconds = calendar.getTimeInMillis() / 1000L;
            out.writeInt((int) seconds);
            return;
        }


            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 34

                      String format = context.getFormat();
        Calendar calendar = (Calendar) object;

        if (format.equals("unixtime")) {
            long seconds = calendar.getTimeInMillis() / 1000L;
            out.writeInt((int) seconds);
            return;
        }


            

Reported by PMD.

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

Line: 34

                      String format = context.getFormat();
        Calendar calendar = (Calendar) object;

        if (format.equals("unixtime")) {
            long seconds = calendar.getTimeInMillis() / 1000L;
            out.writeInt((int) seconds);
            return;
        }


            

Reported by PMD.

A Calendar is used to create a Date or DateTime, this is expensive.
Performance

Line: 35

                      Calendar calendar = (Calendar) object;

        if (format.equals("unixtime")) {
            long seconds = calendar.getTimeInMillis() / 1000L;
            out.writeInt((int) seconds);
            return;
        }

        DateFormat dateFormat = new SimpleDateFormat(format);

            

Reported by PMD.

When instantiating a SimpleDateFormat object, specify a Locale
Error

Line: 40

                          return;
        }

        DateFormat dateFormat = new SimpleDateFormat(format);
        if (dateFormat == null) {
            dateFormat = new SimpleDateFormat(JSON.DEFFAULT_DATE_FORMAT, serializer.locale);
        }
        dateFormat.setTimeZone(serializer.timeZone);
        String text = dateFormat.format(calendar.getTime());

            

Reported by PMD.

A Calendar is used to create a Date or DateTime, this is expensive.
Performance

Line: 45

                          dateFormat = new SimpleDateFormat(JSON.DEFFAULT_DATE_FORMAT, serializer.locale);
        }
        dateFormat.setTimeZone(serializer.timeZone);
        String text = dateFormat.format(calendar.getTime());
        out.writeString(text);
    }


    public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features)

            

Reported by PMD.

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

Line: 45

                          dateFormat = new SimpleDateFormat(JSON.DEFFAULT_DATE_FORMAT, serializer.locale);
        }
        dateFormat.setTimeZone(serializer.timeZone);
        String text = dateFormat.format(calendar.getTime());
        out.writeString(text);
    }


    public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features)

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1500/Issue1584.java
26 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 16

              import java.util.Map;

public class Issue1584 extends TestCase {
    public void test_for_issue() throws Exception {
        ParserConfig config = new ParserConfig();

        String json = "{\"k\":1,\"v\":\"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: 16

              import java.util.Map;

public class Issue1584 extends TestCase {
    public void test_for_issue() throws Exception {
        ParserConfig config = new ParserConfig();

        String json = "{\"k\":1,\"v\":\"A\"}";

        {

            

Reported by PMD.

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

Line: 23

              
        {
            Map.Entry entry = JSON.parseObject(json, Map.Entry.class, config);
            Object key = entry.getKey();
            Object value = entry.getValue();
            assertTrue(key.equals("v") || key.equals("k"));
            if (key.equals("v")) {
                assertEquals("A", value);
            } else {

            

Reported by PMD.

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

Line: 24

                      {
            Map.Entry entry = JSON.parseObject(json, Map.Entry.class, config);
            Object key = entry.getKey();
            Object value = entry.getValue();
            assertTrue(key.equals("v") || key.equals("k"));
            if (key.equals("v")) {
                assertEquals("A", value);
            } else {
                assertEquals(1, value);

            

Reported by PMD.

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

Line: 25

                          Map.Entry entry = JSON.parseObject(json, Map.Entry.class, config);
            Object key = entry.getKey();
            Object value = entry.getValue();
            assertTrue(key.equals("v") || key.equals("k"));
            if (key.equals("v")) {
                assertEquals("A", value);
            } else {
                assertEquals(1, value);
            }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 25

                          Map.Entry entry = JSON.parseObject(json, Map.Entry.class, config);
            Object key = entry.getKey();
            Object value = entry.getValue();
            assertTrue(key.equals("v") || key.equals("k"));
            if (key.equals("v")) {
                assertEquals("A", value);
            } else {
                assertEquals(1, value);
            }

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 25

                          Map.Entry entry = JSON.parseObject(json, Map.Entry.class, config);
            Object key = entry.getKey();
            Object value = entry.getValue();
            assertTrue(key.equals("v") || key.equals("k"));
            if (key.equals("v")) {
                assertEquals("A", value);
            } else {
                assertEquals(1, value);
            }

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 25

                          Map.Entry entry = JSON.parseObject(json, Map.Entry.class, config);
            Object key = entry.getKey();
            Object value = entry.getValue();
            assertTrue(key.equals("v") || key.equals("k"));
            if (key.equals("v")) {
                assertEquals("A", value);
            } else {
                assertEquals(1, value);
            }

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 25

                          Map.Entry entry = JSON.parseObject(json, Map.Entry.class, config);
            Object key = entry.getKey();
            Object value = entry.getValue();
            assertTrue(key.equals("v") || key.equals("k"));
            if (key.equals("v")) {
                assertEquals("A", value);
            } else {
                assertEquals(1, value);
            }

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 25

                          Map.Entry entry = JSON.parseObject(json, Map.Entry.class, config);
            Object key = entry.getKey();
            Object value = entry.getValue();
            assertTrue(key.equals("v") || key.equals("k"));
            if (key.equals("v")) {
                assertEquals("A", value);
            } else {
                assertEquals(1, value);
            }

            

Reported by PMD.

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

    public void test_deserializeUsing() throws Exception {
        String jsonStr = "{'subjectList':['CHINESE','MATH']}";
        Teacher teacher = JSON.parseObject(jsonStr, Teacher.class);
        assertEquals(SubjectEnum.CHINESE.ordinal(), teacher.getSubjectList().get(0).intValue());
        assertEquals(SubjectEnum.MATH.ordinal(), teacher.getSubjectList().get(1).intValue());
    }

            

Reported by PMD.

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

Line: 18

               */
public class DeserializeUsingTest extends TestCase {

    public void test_deserializeUsing() throws Exception {
        String jsonStr = "{'subjectList':['CHINESE','MATH']}";
        Teacher teacher = JSON.parseObject(jsonStr, Teacher.class);
        assertEquals(SubjectEnum.CHINESE.ordinal(), teacher.getSubjectList().get(0).intValue());
        assertEquals(SubjectEnum.MATH.ordinal(), teacher.getSubjectList().get(1).intValue());
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 21

                  public void test_deserializeUsing() throws Exception {
        String jsonStr = "{'subjectList':['CHINESE','MATH']}";
        Teacher teacher = JSON.parseObject(jsonStr, Teacher.class);
        assertEquals(SubjectEnum.CHINESE.ordinal(), teacher.getSubjectList().get(0).intValue());
        assertEquals(SubjectEnum.MATH.ordinal(), teacher.getSubjectList().get(1).intValue());
    }

    public void test_deserializeUsing2() throws Exception {
        String jsonStr = "{'subjectList':['CHINESE','MATH']}";

            

Reported by PMD.

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

Line: 21

                  public void test_deserializeUsing() throws Exception {
        String jsonStr = "{'subjectList':['CHINESE','MATH']}";
        Teacher teacher = JSON.parseObject(jsonStr, Teacher.class);
        assertEquals(SubjectEnum.CHINESE.ordinal(), teacher.getSubjectList().get(0).intValue());
        assertEquals(SubjectEnum.MATH.ordinal(), teacher.getSubjectList().get(1).intValue());
    }

    public void test_deserializeUsing2() throws Exception {
        String jsonStr = "{'subjectList':['CHINESE','MATH']}";

            

Reported by PMD.

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

Line: 21

                  public void test_deserializeUsing() throws Exception {
        String jsonStr = "{'subjectList':['CHINESE','MATH']}";
        Teacher teacher = JSON.parseObject(jsonStr, Teacher.class);
        assertEquals(SubjectEnum.CHINESE.ordinal(), teacher.getSubjectList().get(0).intValue());
        assertEquals(SubjectEnum.MATH.ordinal(), teacher.getSubjectList().get(1).intValue());
    }

    public void test_deserializeUsing2() throws Exception {
        String jsonStr = "{'subjectList':['CHINESE','MATH']}";

            

Reported by PMD.

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

Line: 21

                  public void test_deserializeUsing() throws Exception {
        String jsonStr = "{'subjectList':['CHINESE','MATH']}";
        Teacher teacher = JSON.parseObject(jsonStr, Teacher.class);
        assertEquals(SubjectEnum.CHINESE.ordinal(), teacher.getSubjectList().get(0).intValue());
        assertEquals(SubjectEnum.MATH.ordinal(), teacher.getSubjectList().get(1).intValue());
    }

    public void test_deserializeUsing2() throws Exception {
        String jsonStr = "{'subjectList':['CHINESE','MATH']}";

            

Reported by PMD.

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

Line: 21

                  public void test_deserializeUsing() throws Exception {
        String jsonStr = "{'subjectList':['CHINESE','MATH']}";
        Teacher teacher = JSON.parseObject(jsonStr, Teacher.class);
        assertEquals(SubjectEnum.CHINESE.ordinal(), teacher.getSubjectList().get(0).intValue());
        assertEquals(SubjectEnum.MATH.ordinal(), teacher.getSubjectList().get(1).intValue());
    }

    public void test_deserializeUsing2() throws Exception {
        String jsonStr = "{'subjectList':['CHINESE','MATH']}";

            

Reported by PMD.

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

Line: 22

                      String jsonStr = "{'subjectList':['CHINESE','MATH']}";
        Teacher teacher = JSON.parseObject(jsonStr, Teacher.class);
        assertEquals(SubjectEnum.CHINESE.ordinal(), teacher.getSubjectList().get(0).intValue());
        assertEquals(SubjectEnum.MATH.ordinal(), teacher.getSubjectList().get(1).intValue());
    }

    public void test_deserializeUsing2() throws Exception {
        String jsonStr = "{'subjectList':['CHINESE','MATH']}";


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 22

                      String jsonStr = "{'subjectList':['CHINESE','MATH']}";
        Teacher teacher = JSON.parseObject(jsonStr, Teacher.class);
        assertEquals(SubjectEnum.CHINESE.ordinal(), teacher.getSubjectList().get(0).intValue());
        assertEquals(SubjectEnum.MATH.ordinal(), teacher.getSubjectList().get(1).intValue());
    }

    public void test_deserializeUsing2() throws Exception {
        String jsonStr = "{'subjectList':['CHINESE','MATH']}";


            

Reported by PMD.

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

Line: 22

                      String jsonStr = "{'subjectList':['CHINESE','MATH']}";
        Teacher teacher = JSON.parseObject(jsonStr, Teacher.class);
        assertEquals(SubjectEnum.CHINESE.ordinal(), teacher.getSubjectList().get(0).intValue());
        assertEquals(SubjectEnum.MATH.ordinal(), teacher.getSubjectList().get(1).intValue());
    }

    public void test_deserializeUsing2() throws Exception {
        String jsonStr = "{'subjectList':['CHINESE','MATH']}";


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1300/Issue1330_short.java
25 issues
Do not use the short type
Performance

Line: 45

                  }

    public static class Model {
        public short value;
    }
}

            

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 30/07/2017.
 */
public class Issue1330_short extends TestCase {
    public void test_for_issue() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":\"ABC\"}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

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

Line: 11

               * Created by wenshao on 30/07/2017.
 */
public class Issue1330_short extends TestCase {
    public void test_for_issue() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":\"ABC\"}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                      } catch (JSONException e) {
            error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseShort error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;

            

Reported by PMD.

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

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseShort error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseShort error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {

            

Reported by PMD.

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

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseShort error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {

            

Reported by PMD.

Use assertSame(x, y) instead of assertTrue(x==y), or assertNotSame(x,y) vs assertFalse(x==y)
Design

Line: 19

                          error = e;
        }
        assertNotNull(error);
        assertTrue(error.getMessage().indexOf("parseShort error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {

            

Reported by PMD.

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

Line: 22

                      assertTrue(error.getMessage().indexOf("parseShort error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":[]}", Model.class);
        } catch (JSONException e) {
            error = e;

            

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

                      assertTrue(error.getMessage().indexOf("parseShort error, field : value") != -1);
    }

    public void test_for_issue_1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"value\":[]}", Model.class);
        } catch (JSONException e) {
            error = e;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/support/spring/mock/testcase/FastJsonHttpMessageConverter4Test.java
25 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 43

              public class FastJsonHttpMessageConverter4Test {

    @Autowired
    private WebApplicationContext wac;

    private MockMvc mockMvc;

    @Before
    public void setup() {

            

Reported by PMD.

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

Line: 45

                  @Autowired
    private WebApplicationContext wac;

    private MockMvc mockMvc;

    @Before
    public void setup() {
        this.mockMvc = webAppContextSetup(this.wac).build();
    }

            

Reported by PMD.

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

Line: 49

              
    @Before
    public void setup() {
        this.mockMvc = webAppContextSetup(this.wac).build();
    }

    @Test
    public void test1() throws Exception {


            

Reported by PMD.

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

Line: 53

                  }

    @Test
    public void test1() throws Exception {

        JSONObject json = new JSONObject();

        json.put("id", 123);


            

Reported by PMD.

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

Line: 61

              
        json.put("name", "哈哈哈");

        mockMvc.perform(
                (post("/fastjson/test1").characterEncoding("UTF-8").content(json.toJSONString()).contentType(MediaType.APPLICATION_JSON)
                ))
//		.andExpect(status().isOk())
                .andDo(print());
    }

            

Reported by PMD.

The String literal 'UTF-8' appears 4 times in this file; the first occurrence is on line 62
Error

Line: 62

                      json.put("name", "哈哈哈");

        mockMvc.perform(
                (post("/fastjson/test1").characterEncoding("UTF-8").content(json.toJSONString()).contentType(MediaType.APPLICATION_JSON)
                ))
//		.andExpect(status().isOk())
                .andDo(print());
    }


            

Reported by PMD.

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

Line: 62

                      json.put("name", "哈哈哈");

        mockMvc.perform(
                (post("/fastjson/test1").characterEncoding("UTF-8").content(json.toJSONString()).contentType(MediaType.APPLICATION_JSON)
                ))
//		.andExpect(status().isOk())
                .andDo(print());
    }


            

Reported by PMD.

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

Line: 62

                      json.put("name", "哈哈哈");

        mockMvc.perform(
                (post("/fastjson/test1").characterEncoding("UTF-8").content(json.toJSONString()).contentType(MediaType.APPLICATION_JSON)
                ))
//		.andExpect(status().isOk())
                .andDo(print());
    }


            

Reported by PMD.

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

Line: 62

                      json.put("name", "哈哈哈");

        mockMvc.perform(
                (post("/fastjson/test1").characterEncoding("UTF-8").content(json.toJSONString()).contentType(MediaType.APPLICATION_JSON)
                ))
//		.andExpect(status().isOk())
                .andDo(print());
    }


            

Reported by PMD.

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

Line: 69

                  }

    @Test
    public void test2() throws Exception {

        String jsonStr = "[{\"name\":\"p1\",\"sonList\":[{\"name\":\"s1\"}]},{\"name\":\"p2\",\"sonList\":[{\"name\":\"s2\"},{\"name\":\"s3\"}]}]";

        mockMvc.perform(
                (post("/fastjson/test2").characterEncoding("UTF-8").content(jsonStr).contentType(MediaType.APPLICATION_JSON)

            

Reported by PMD.

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

    public void test_0() throws Exception {
        String text = "{ // aa" //
                      + "\n}";
        JSONObject obj = (JSONObject) JSON.parse(text);
        Assert.assertEquals(0, obj.size());
    }

            

Reported by PMD.

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

Line: 17

                      String text = "{ // aa" //
                      + "\n}";
        JSONObject obj = (JSONObject) JSON.parse(text);
        Assert.assertEquals(0, obj.size());
    }

    public void test_1() throws Exception {
        String text = "{ // aa" //
                      + "\n\"value\":1001}";

            

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

                      Assert.assertEquals(0, obj.size());
    }

    public void test_1() throws Exception {
        String text = "{ // aa" //
                      + "\n\"value\":1001}";
        JSONObject obj = (JSONObject) JSON.parse(text);
        Assert.assertEquals(1, obj.size());
        Assert.assertEquals(1001, obj.get("value"));

            

Reported by PMD.

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

Line: 24

                      String text = "{ // aa" //
                      + "\n\"value\":1001}";
        JSONObject obj = (JSONObject) JSON.parse(text);
        Assert.assertEquals(1, obj.size());
        Assert.assertEquals(1001, obj.get("value"));
    }

    public void test_2() throws Exception {
        String text = "{ /* aa */ \"value\":1001}";

            

Reported by PMD.

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

Line: 25

                                    + "\n\"value\":1001}";
        JSONObject obj = (JSONObject) JSON.parse(text);
        Assert.assertEquals(1, obj.size());
        Assert.assertEquals(1001, obj.get("value"));
    }

    public void test_2() throws Exception {
        String text = "{ /* aa */ \"value\":1001}";
        JSONObject obj = (JSONObject) JSON.parse(text);

            

Reported by PMD.

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

Line: 25

                                    + "\n\"value\":1001}";
        JSONObject obj = (JSONObject) JSON.parse(text);
        Assert.assertEquals(1, obj.size());
        Assert.assertEquals(1001, obj.get("value"));
    }

    public void test_2() throws Exception {
        String text = "{ /* aa */ \"value\":1001}";
        JSONObject obj = (JSONObject) JSON.parse(text);

            

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

                      Assert.assertEquals(1001, obj.get("value"));
    }

    public void test_2() throws Exception {
        String text = "{ /* aa */ \"value\":1001}";
        JSONObject obj = (JSONObject) JSON.parse(text);
        Assert.assertEquals(1, obj.size());
        Assert.assertEquals(1001, obj.get("value"));
    }

            

Reported by PMD.

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

Line: 31

                  public void test_2() throws Exception {
        String text = "{ /* aa */ \"value\":1001}";
        JSONObject obj = (JSONObject) JSON.parse(text);
        Assert.assertEquals(1, obj.size());
        Assert.assertEquals(1001, obj.get("value"));
    }

    public void test_3() throws Exception {
        String text = "{ \"value\":/* aa */1001}";

            

Reported by PMD.

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

Line: 32

                      String text = "{ /* aa */ \"value\":1001}";
        JSONObject obj = (JSONObject) JSON.parse(text);
        Assert.assertEquals(1, obj.size());
        Assert.assertEquals(1001, obj.get("value"));
    }

    public void test_3() throws Exception {
        String text = "{ \"value\":/* aa */1001}";
        JSONObject obj = (JSONObject) JSON.parse(text);

            

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

                      Assert.assertEquals(1001, obj.get("value"));
    }

    public void test_3() throws Exception {
        String text = "{ \"value\":/* aa */1001}";
        JSONObject obj = (JSONObject) JSON.parse(text);
        Assert.assertEquals(1, obj.size());
        Assert.assertEquals(1001, obj.get("value"));
    }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/support/moneta/MoneyNumberTest.java
25 issues
Avoid instantiating Short objects. Call Short.valueOf() instead
Performance

Line: 47

                      assertEquals(2.01f, moneyBack.getNumber().floatValue());

        // short
        money = Money.of(new Short("2"), Monetary.getCurrency("EUR"));
        moneyJSON = JSON.toJSONString(money);
        moneyBack = JSON.parseObject(moneyJSON, Money.class);
        assertEquals(2, moneyBack.getNumber().shortValue());

        // BigInteger

            

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

               * @Date :Created in 01:31 2020/7/4
 */
public class MoneyNumberTest extends TestCase {
    public void test_for_issue() throws Exception {
        // Integer
        Money money = Money.of(5000, Monetary.getCurrency("EUR"));
        String moneyJSON = JSON.toJSONString(money);
        Money moneyBack = JSON.parseObject(moneyJSON, Money.class);
        assertEquals(5000, moneyBack.getNumber().intValue());

            

Reported by PMD.

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

Line: 15

               * @Date :Created in 01:31 2020/7/4
 */
public class MoneyNumberTest extends TestCase {
    public void test_for_issue() throws Exception {
        // Integer
        Money money = Money.of(5000, Monetary.getCurrency("EUR"));
        String moneyJSON = JSON.toJSONString(money);
        Money moneyBack = JSON.parseObject(moneyJSON, Money.class);
        assertEquals(5000, moneyBack.getNumber().intValue());

            

Reported by PMD.

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

Line: 17

              public class MoneyNumberTest extends TestCase {
    public void test_for_issue() throws Exception {
        // Integer
        Money money = Money.of(5000, Monetary.getCurrency("EUR"));
        String moneyJSON = JSON.toJSONString(money);
        Money moneyBack = JSON.parseObject(moneyJSON, Money.class);
        assertEquals(5000, moneyBack.getNumber().intValue());

        // Long

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 20

                      Money money = Money.of(5000, Monetary.getCurrency("EUR"));
        String moneyJSON = JSON.toJSONString(money);
        Money moneyBack = JSON.parseObject(moneyJSON, Money.class);
        assertEquals(5000, moneyBack.getNumber().intValue());

        // Long
        money = Money.of(1000L, Monetary.getCurrency("EUR"));
        moneyJSON = JSON.toJSONString(money);
        moneyBack = JSON.parseObject(moneyJSON, Money.class);

            

Reported by PMD.

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

Line: 20

                      Money money = Money.of(5000, Monetary.getCurrency("EUR"));
        String moneyJSON = JSON.toJSONString(money);
        Money moneyBack = JSON.parseObject(moneyJSON, Money.class);
        assertEquals(5000, moneyBack.getNumber().intValue());

        // Long
        money = Money.of(1000L, Monetary.getCurrency("EUR"));
        moneyJSON = JSON.toJSONString(money);
        moneyBack = JSON.parseObject(moneyJSON, Money.class);

            

Reported by PMD.

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

Line: 20

                      Money money = Money.of(5000, Monetary.getCurrency("EUR"));
        String moneyJSON = JSON.toJSONString(money);
        Money moneyBack = JSON.parseObject(moneyJSON, Money.class);
        assertEquals(5000, moneyBack.getNumber().intValue());

        // Long
        money = Money.of(1000L, Monetary.getCurrency("EUR"));
        moneyJSON = JSON.toJSONString(money);
        moneyBack = JSON.parseObject(moneyJSON, Money.class);

            

Reported by PMD.

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

Line: 26

                      money = Money.of(1000L, Monetary.getCurrency("EUR"));
        moneyJSON = JSON.toJSONString(money);
        moneyBack = JSON.parseObject(moneyJSON, Money.class);
        assertEquals(1000, moneyBack.getNumber().longValue());

        // Byte
        money = Money.of(0x4a, Monetary.getCurrency("EUR"));
        moneyJSON = JSON.toJSONString(money);
        moneyBack = JSON.parseObject(moneyJSON, Money.class);

            

Reported by PMD.

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

Line: 26

                      money = Money.of(1000L, Monetary.getCurrency("EUR"));
        moneyJSON = JSON.toJSONString(money);
        moneyBack = JSON.parseObject(moneyJSON, Money.class);
        assertEquals(1000, moneyBack.getNumber().longValue());

        // Byte
        money = Money.of(0x4a, Monetary.getCurrency("EUR"));
        moneyJSON = JSON.toJSONString(money);
        moneyBack = JSON.parseObject(moneyJSON, Money.class);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 26

                      money = Money.of(1000L, Monetary.getCurrency("EUR"));
        moneyJSON = JSON.toJSONString(money);
        moneyBack = JSON.parseObject(moneyJSON, Money.class);
        assertEquals(1000, moneyBack.getNumber().longValue());

        // Byte
        money = Money.of(0x4a, Monetary.getCurrency("EUR"));
        moneyJSON = JSON.toJSONString(money);
        moneyBack = JSON.parseObject(moneyJSON, Money.class);

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/FieldDeserializerTest9.java
25 issues
Unit tests should not contain more than 1 assert(s).
Design

Line: 9

              

public class FieldDeserializerTest9 extends TestCase {
    public void test_0 () throws Exception {
        assertTrue(JSON.parseObject("{\"id\":true\t}", VO.class).id);
        assertTrue(JSON.parseObject("{\"id\":true\t}\n\t", VO.class).id);
        assertTrue(JSON.parseObject("{\"id\":true }", V1.class).id);
        assertTrue(JSON.parseObject("{\"id\":true }\n\t", V1.class).id);
        assertTrue(JSON.parseObject("{\"id\":true\n}", V1.class).id);

            

Reported by PMD.

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

Line: 9

              

public class FieldDeserializerTest9 extends TestCase {
    public void test_0 () throws Exception {
        assertTrue(JSON.parseObject("{\"id\":true\t}", VO.class).id);
        assertTrue(JSON.parseObject("{\"id\":true\t}\n\t", VO.class).id);
        assertTrue(JSON.parseObject("{\"id\":true }", V1.class).id);
        assertTrue(JSON.parseObject("{\"id\":true }\n\t", V1.class).id);
        assertTrue(JSON.parseObject("{\"id\":true\n}", V1.class).id);

            

Reported by PMD.

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

Line: 10

              
public class FieldDeserializerTest9 extends TestCase {
    public void test_0 () throws Exception {
        assertTrue(JSON.parseObject("{\"id\":true\t}", VO.class).id);
        assertTrue(JSON.parseObject("{\"id\":true\t}\n\t", VO.class).id);
        assertTrue(JSON.parseObject("{\"id\":true }", V1.class).id);
        assertTrue(JSON.parseObject("{\"id\":true }\n\t", V1.class).id);
        assertTrue(JSON.parseObject("{\"id\":true\n}", V1.class).id);
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 10

              
public class FieldDeserializerTest9 extends TestCase {
    public void test_0 () throws Exception {
        assertTrue(JSON.parseObject("{\"id\":true\t}", VO.class).id);
        assertTrue(JSON.parseObject("{\"id\":true\t}\n\t", VO.class).id);
        assertTrue(JSON.parseObject("{\"id\":true }", V1.class).id);
        assertTrue(JSON.parseObject("{\"id\":true }\n\t", V1.class).id);
        assertTrue(JSON.parseObject("{\"id\":true\n}", V1.class).id);
    }

            

Reported by PMD.

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

Line: 11

              public class FieldDeserializerTest9 extends TestCase {
    public void test_0 () throws Exception {
        assertTrue(JSON.parseObject("{\"id\":true\t}", VO.class).id);
        assertTrue(JSON.parseObject("{\"id\":true\t}\n\t", VO.class).id);
        assertTrue(JSON.parseObject("{\"id\":true }", V1.class).id);
        assertTrue(JSON.parseObject("{\"id\":true }\n\t", V1.class).id);
        assertTrue(JSON.parseObject("{\"id\":true\n}", V1.class).id);
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 11

              public class FieldDeserializerTest9 extends TestCase {
    public void test_0 () throws Exception {
        assertTrue(JSON.parseObject("{\"id\":true\t}", VO.class).id);
        assertTrue(JSON.parseObject("{\"id\":true\t}\n\t", VO.class).id);
        assertTrue(JSON.parseObject("{\"id\":true }", V1.class).id);
        assertTrue(JSON.parseObject("{\"id\":true }\n\t", V1.class).id);
        assertTrue(JSON.parseObject("{\"id\":true\n}", V1.class).id);
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 12

                  public void test_0 () throws Exception {
        assertTrue(JSON.parseObject("{\"id\":true\t}", VO.class).id);
        assertTrue(JSON.parseObject("{\"id\":true\t}\n\t", VO.class).id);
        assertTrue(JSON.parseObject("{\"id\":true }", V1.class).id);
        assertTrue(JSON.parseObject("{\"id\":true }\n\t", V1.class).id);
        assertTrue(JSON.parseObject("{\"id\":true\n}", V1.class).id);
    }

    public void test_1 () throws Exception {

            

Reported by PMD.

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

Line: 12

                  public void test_0 () throws Exception {
        assertTrue(JSON.parseObject("{\"id\":true\t}", VO.class).id);
        assertTrue(JSON.parseObject("{\"id\":true\t}\n\t", VO.class).id);
        assertTrue(JSON.parseObject("{\"id\":true }", V1.class).id);
        assertTrue(JSON.parseObject("{\"id\":true }\n\t", V1.class).id);
        assertTrue(JSON.parseObject("{\"id\":true\n}", V1.class).id);
    }

    public void test_1 () throws Exception {

            

Reported by PMD.

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

Line: 13

                      assertTrue(JSON.parseObject("{\"id\":true\t}", VO.class).id);
        assertTrue(JSON.parseObject("{\"id\":true\t}\n\t", VO.class).id);
        assertTrue(JSON.parseObject("{\"id\":true }", V1.class).id);
        assertTrue(JSON.parseObject("{\"id\":true }\n\t", V1.class).id);
        assertTrue(JSON.parseObject("{\"id\":true\n}", V1.class).id);
    }

    public void test_1 () throws Exception {
        assertFalse(JSON.parseObject("{\"id\":false\t}", VO.class).id);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 13

                      assertTrue(JSON.parseObject("{\"id\":true\t}", VO.class).id);
        assertTrue(JSON.parseObject("{\"id\":true\t}\n\t", VO.class).id);
        assertTrue(JSON.parseObject("{\"id\":true }", V1.class).id);
        assertTrue(JSON.parseObject("{\"id\":true }\n\t", V1.class).id);
        assertTrue(JSON.parseObject("{\"id\":true\n}", V1.class).id);
    }

    public void test_1 () throws Exception {
        assertFalse(JSON.parseObject("{\"id\":false\t}", VO.class).id);

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/filters/PropertyFilterTest.java
25 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

              
public class PropertyFilterTest extends TestCase {

    public void test_0() throws Exception {
        PropertyFilter filter = new PropertyFilter() {

            public boolean apply(Object source, String name, Object value) {
                return false;
            }

            

Reported by PMD.

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

Line: 27

              
        SerializeWriter out = new SerializeWriter();
        JSONSerializer serializer = new JSONSerializer(out);
        serializer.getPropertyFilters().add(filter);

        A a = new A();
        serializer.write(a);

        String text = out.toString();

            

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

                      Assert.assertEquals("{}", text);
    }
    
    public void test_toJSONString() throws Exception {
        PropertyFilter filter = new PropertyFilter() {

            public boolean apply(Object source, String name, Object value) {
                return false;
            }

            

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

                      Assert.assertEquals("{}", JSON.toJSONString(new A(), filter));
    }

    public void test_1() throws Exception {
        PropertyFilter filter = new PropertyFilter() {

            public boolean apply(Object source, String name, Object value) {
                if ("id".equals(name)) {
                    return true;

            

Reported by PMD.

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

Line: 60

              
        SerializeWriter out = new SerializeWriter();
        JSONSerializer serializer = new JSONSerializer(out);
        serializer.getPropertyFilters().add(filter);

        A a = new A();
        serializer.write(a);

        String text = out.toString();

            

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

                      Assert.assertEquals("{\"id\":0}", text);
    }

    public void test_2() throws Exception {
        PropertyFilter filter = new PropertyFilter() {

            public boolean apply(Object source, String name, Object value) {
                if ("name".equals(name)) {
                    return true;

            

Reported by PMD.

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

Line: 73

                      PropertyFilter filter = new PropertyFilter() {

            public boolean apply(Object source, String name, Object value) {
                if ("name".equals(name)) {
                    return true;
                }
                return false;
            }
        };

            

Reported by PMD.

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

Line: 82

              
        SerializeWriter out = new SerializeWriter();
        JSONSerializer serializer = new JSONSerializer(out);
        serializer.getPropertyFilters().add(filter);

        A a = new A();
        a.setName("chennp2008");
        serializer.write(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: 92

                      Assert.assertEquals("{\"name\":\"chennp2008\"}", text);
    }

    public void test_3() throws Exception {
        PropertyFilter filter = new PropertyFilter() {

            public boolean apply(Object source, String name, Object value) {
                if ("name".equals(name)) {
                    return true;

            

Reported by PMD.

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

Line: 105

              
        SerializeWriter out = new SerializeWriter();
        JSONSerializer serializer = new JSONSerializer(out);
        serializer.getPropertyFilters().add(filter);

        Map<String, Object> map = new HashMap<String, Object>();
        map.put("name", "chennp2008");
        serializer.write(map);


            

Reported by PMD.

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

    public void test_utf() throws Exception {
        JSONObject obj = (JSONObject) JSON.parse("{'name':'刘大'}".getBytes("UTF-8"));
        Assert.assertEquals(1, obj.size());
        Assert.assertEquals("刘大", obj.get("name"));
    }


            

Reported by PMD.

The String literal 'UTF-8' appears 6 times in this file; the first occurrence is on line 12
Error

Line: 12

              public class TestUTF8 extends TestCase {

    public void test_utf() throws Exception {
        JSONObject obj = (JSONObject) JSON.parse("{'name':'刘大'}".getBytes("UTF-8"));
        Assert.assertEquals(1, obj.size());
        Assert.assertEquals("刘大", obj.get("name"));
    }

    public void test_utf_cn() throws Exception {

            

Reported by PMD.

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

Line: 13

              
    public void test_utf() throws Exception {
        JSONObject obj = (JSONObject) JSON.parse("{'name':'刘大'}".getBytes("UTF-8"));
        Assert.assertEquals(1, obj.size());
        Assert.assertEquals("刘大", obj.get("name"));
    }

    public void test_utf_cn() throws Exception {
        String content = "首先来到村委会,走进农家书屋,认真翻看各种图书和报刊。他拿起一份藏文版《人民日报》,询问村民读书读报的情况,并和正在读书的几位藏族青年亲切交谈,勉励他们好好学习,学以致用,培养致富本领。在党支部活动室,村支部书记桑杰介绍了支部建设情况。当听到全村36名党员发挥先锋模范作用";

            

Reported by PMD.

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

Line: 14

                  public void test_utf() throws Exception {
        JSONObject obj = (JSONObject) JSON.parse("{'name':'刘大'}".getBytes("UTF-8"));
        Assert.assertEquals(1, obj.size());
        Assert.assertEquals("刘大", obj.get("name"));
    }

    public void test_utf_cn() throws Exception {
        String content = "首先来到村委会,走进农家书屋,认真翻看各种图书和报刊。他拿起一份藏文版《人民日报》,询问村民读书读报的情况,并和正在读书的几位藏族青年亲切交谈,勉励他们好好学习,学以致用,培养致富本领。在党支部活动室,村支部书记桑杰介绍了支部建设情况。当听到全村36名党员发挥先锋模范作用";
        JSONObject json = new JSONObject();

            

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

                      Assert.assertEquals("刘大", obj.get("name"));
    }

    public void test_utf_cn() throws Exception {
        String content = "首先来到村委会,走进农家书屋,认真翻看各种图书和报刊。他拿起一份藏文版《人民日报》,询问村民读书读报的情况,并和正在读书的几位藏族青年亲切交谈,勉励他们好好学习,学以致用,培养致富本领。在党支部活动室,村支部书记桑杰介绍了支部建设情况。当听到全村36名党员发挥先锋模范作用";
        JSONObject json = new JSONObject();
        json.put("content", content);
        JSONObject obj = (JSONObject) JSON.parse(json.toJSONString().getBytes("UTF-8"));
        Assert.assertEquals(1, obj.size());

            

Reported by PMD.

The String literal 'content' appears 10 times in this file; the first occurrence is on line 20
Error

Line: 20

                  public void test_utf_cn() throws Exception {
        String content = "首先来到村委会,走进农家书屋,认真翻看各种图书和报刊。他拿起一份藏文版《人民日报》,询问村民读书读报的情况,并和正在读书的几位藏族青年亲切交谈,勉励他们好好学习,学以致用,培养致富本领。在党支部活动室,村支部书记桑杰介绍了支部建设情况。当听到全村36名党员发挥先锋模范作用";
        JSONObject json = new JSONObject();
        json.put("content", content);
        JSONObject obj = (JSONObject) JSON.parse(json.toJSONString().getBytes("UTF-8"));
        Assert.assertEquals(1, obj.size());
        Assert.assertEquals(content, obj.get("content"));
    }


            

Reported by PMD.

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

Line: 21

                      String content = "首先来到村委会,走进农家书屋,认真翻看各种图书和报刊。他拿起一份藏文版《人民日报》,询问村民读书读报的情况,并和正在读书的几位藏族青年亲切交谈,勉励他们好好学习,学以致用,培养致富本领。在党支部活动室,村支部书记桑杰介绍了支部建设情况。当听到全村36名党员发挥先锋模范作用";
        JSONObject json = new JSONObject();
        json.put("content", content);
        JSONObject obj = (JSONObject) JSON.parse(json.toJSONString().getBytes("UTF-8"));
        Assert.assertEquals(1, obj.size());
        Assert.assertEquals(content, obj.get("content"));
    }

    public void test_utf_de() throws Exception {

            

Reported by PMD.

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

Line: 22

                      JSONObject json = new JSONObject();
        json.put("content", content);
        JSONObject obj = (JSONObject) JSON.parse(json.toJSONString().getBytes("UTF-8"));
        Assert.assertEquals(1, obj.size());
        Assert.assertEquals(content, obj.get("content"));
    }

    public void test_utf_de() throws Exception {
        String content = "Beim Griechenland-Gipfel gibt es viele Gewinner. Kanzlerin Merkel bekommt die Bankenbeteiligung, Frankreichs Präsident Sarkozy den Aufkauf von Staatsanleihen. \\nEinzig EZB-Präsident Jean-Claude Trichet gilt als Verlierer. Er zog im Machtkampf den Kürzeren";

            

Reported by PMD.

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

Line: 23

                      json.put("content", content);
        JSONObject obj = (JSONObject) JSON.parse(json.toJSONString().getBytes("UTF-8"));
        Assert.assertEquals(1, obj.size());
        Assert.assertEquals(content, obj.get("content"));
    }

    public void test_utf_de() throws Exception {
        String content = "Beim Griechenland-Gipfel gibt es viele Gewinner. Kanzlerin Merkel bekommt die Bankenbeteiligung, Frankreichs Präsident Sarkozy den Aufkauf von Staatsanleihen. \\nEinzig EZB-Präsident Jean-Claude Trichet gilt als Verlierer. Er zog im Machtkampf den Kürzeren";
        JSONObject json = new JSONObject();

            

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

                      Assert.assertEquals(content, obj.get("content"));
    }

    public void test_utf_de() throws Exception {
        String content = "Beim Griechenland-Gipfel gibt es viele Gewinner. Kanzlerin Merkel bekommt die Bankenbeteiligung, Frankreichs Präsident Sarkozy den Aufkauf von Staatsanleihen. \\nEinzig EZB-Präsident Jean-Claude Trichet gilt als Verlierer. Er zog im Machtkampf den Kürzeren";
        JSONObject json = new JSONObject();
        json.put("content", content);
        JSONObject obj = (JSONObject) JSON.parse(json.toJSONString().getBytes("UTF-8"));
        Assert.assertEquals(1, obj.size());

            

Reported by PMD.