The following issues were found
src/test/java/com/alibaba/json/bvt/writeAsArray/WriteAsArray_Object_2_public.java
9 issues
Line: 13
public class WriteAsArray_Object_2_public extends TestCase {
public void test_0() throws Exception {
A a = new A();
a.setId(123);
a.setName("wenshao");
VO vo = new VO();
Reported by PMD.
Line: 26
Assert.assertEquals("[1001,[123,\"wenshao\"]]", text);
VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
Assert.assertEquals(vo.getValue().getId(), vo2.getValue().getId());
Assert.assertEquals(vo.getValue().getName(), vo2.getValue().getName());
}
public static class VO {
Reported by PMD.
Line: 26
Assert.assertEquals("[1001,[123,\"wenshao\"]]", text);
VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
Assert.assertEquals(vo.getValue().getId(), vo2.getValue().getId());
Assert.assertEquals(vo.getValue().getName(), vo2.getValue().getName());
}
public static class VO {
Reported by PMD.
Line: 26
Assert.assertEquals("[1001,[123,\"wenshao\"]]", text);
VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
Assert.assertEquals(vo.getValue().getId(), vo2.getValue().getId());
Assert.assertEquals(vo.getValue().getName(), vo2.getValue().getName());
}
public static class VO {
Reported by PMD.
Line: 27
VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
Assert.assertEquals(vo.getValue().getId(), vo2.getValue().getId());
Assert.assertEquals(vo.getValue().getName(), vo2.getValue().getName());
}
public static class VO {
private int id;
Reported by PMD.
Line: 27
VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
Assert.assertEquals(vo.getValue().getId(), vo2.getValue().getId());
Assert.assertEquals(vo.getValue().getName(), vo2.getValue().getName());
}
public static class VO {
private int id;
Reported by PMD.
Line: 27
VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
Assert.assertEquals(vo.getValue().getId(), vo2.getValue().getId());
Assert.assertEquals(vo.getValue().getName(), vo2.getValue().getName());
}
public static class VO {
private int id;
Reported by PMD.
Line: 30
Assert.assertEquals(vo.getValue().getName(), vo2.getValue().getName());
}
public static class VO {
private int id;
private A value;
public int getId() {
Reported by PMD.
Line: 53
}
public static class A {
private int id;
private String name;
public int getId() {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/JSONFieldTest_unwrapped_2.java
9 issues
Line: 13
public class JSONFieldTest_unwrapped_2 extends TestCase {
public void test_jsonField() throws Exception {
String text = "{\"id\":123,\"latitude\":37,\"longitude\":127}";
Assert.assertEquals("{\"id\":123,\"latitude\":37,\"longitude\":127}", text);
VO vo2 = JSON.parseObject(text, VO.class);
assertNotNull(vo2.properties);
Reported by PMD.
Line: 13
public class JSONFieldTest_unwrapped_2 extends TestCase {
public void test_jsonField() throws Exception {
String text = "{\"id\":123,\"latitude\":37,\"longitude\":127}";
Assert.assertEquals("{\"id\":123,\"latitude\":37,\"longitude\":127}", text);
VO vo2 = JSON.parseObject(text, VO.class);
assertNotNull(vo2.properties);
Reported by PMD.
Line: 18
Assert.assertEquals("{\"id\":123,\"latitude\":37,\"longitude\":127}", text);
VO vo2 = JSON.parseObject(text, VO.class);
assertNotNull(vo2.properties);
assertEquals(37, vo2.properties.get("latitude"));
assertEquals(127, vo2.properties.get("longitude"));
}
Reported by PMD.
Line: 19
VO vo2 = JSON.parseObject(text, VO.class);
assertNotNull(vo2.properties);
assertEquals(37, vo2.properties.get("latitude"));
assertEquals(127, vo2.properties.get("longitude"));
}
public static class VO {
Reported by PMD.
Line: 19
VO vo2 = JSON.parseObject(text, VO.class);
assertNotNull(vo2.properties);
assertEquals(37, vo2.properties.get("latitude"));
assertEquals(127, vo2.properties.get("longitude"));
}
public static class VO {
Reported by PMD.
Line: 20
VO vo2 = JSON.parseObject(text, VO.class);
assertNotNull(vo2.properties);
assertEquals(37, vo2.properties.get("latitude"));
assertEquals(127, vo2.properties.get("longitude"));
}
public static class VO {
public int id;
Reported by PMD.
Line: 20
VO vo2 = JSON.parseObject(text, VO.class);
assertNotNull(vo2.properties);
assertEquals(37, vo2.properties.get("latitude"));
assertEquals(127, vo2.properties.get("longitude"));
}
public static class VO {
public int id;
Reported by PMD.
Line: 27
public static class VO {
public int id;
private Map<String, Object> properties = new LinkedHashMap<String, Object>();
@JSONField(unwrapped = true)
public void setProperty(String key, Object value) {
properties.put(key, value);
}
Reported by PMD.
Line: 27
public static class VO {
public int id;
private Map<String, Object> properties = new LinkedHashMap<String, Object>();
@JSONField(unwrapped = true)
public void setProperty(String key, Object value) {
properties.put(key, value);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/writeClassName/WriteClassNameTest_Collection2.java
9 issues
Line: 22
A a = new A();
a.setList(Collections.singletonList(new B()));
String text = JSON.toJSONString(a, SerializerFeature.WriteClassName);
System.out.println(text);
Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Collection2$A\",\"list\":[{}]}",
text);
A a1 = (A) JSON.parse(text);
Reported by PMD.
Line: 14
import com.alibaba.fastjson.serializer.SerializerFeature;
public class WriteClassNameTest_Collection2 extends TestCase {
protected void setUp() throws Exception {
ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Collection2");
}
public void test_list() throws Exception {
A a = new A();
Reported by PMD.
Line: 15
public class WriteClassNameTest_Collection2 extends TestCase {
protected void setUp() throws Exception {
ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Collection2");
}
public void test_list() throws Exception {
A a = new A();
a.setList(Collections.singletonList(new B()));
Reported by PMD.
Line: 18
ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Collection2");
}
public void test_list() throws Exception {
A a = new A();
a.setList(Collections.singletonList(new B()));
String text = JSON.toJSONString(a, SerializerFeature.WriteClassName);
System.out.println(text);
Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Collection2$A\",\"list\":[{}]}",
Reported by PMD.
Line: 28
A a1 = (A) JSON.parse(text);
Assert.assertEquals(1, a1.getList().size());
Assert.assertTrue(a1.getList().iterator().next() instanceof B);
}
public static class A {
Reported by PMD.
Line: 28
A a1 = (A) JSON.parse(text);
Assert.assertEquals(1, a1.getList().size());
Assert.assertTrue(a1.getList().iterator().next() instanceof B);
}
public static class A {
Reported by PMD.
Line: 29
A a1 = (A) JSON.parse(text);
Assert.assertEquals(1, a1.getList().size());
Assert.assertTrue(a1.getList().iterator().next() instanceof B);
}
public static class A {
private Collection<B> list;
Reported by PMD.
Line: 29
A a1 = (A) JSON.parse(text);
Assert.assertEquals(1, a1.getList().size());
Assert.assertTrue(a1.getList().iterator().next() instanceof B);
}
public static class A {
private Collection<B> list;
Reported by PMD.
Line: 29
A a1 = (A) JSON.parse(text);
Assert.assertEquals(1, a1.getList().size());
Assert.assertTrue(a1.getList().iterator().next() instanceof B);
}
public static class A {
private Collection<B> list;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1600/Issue1603_getter.java
9 issues
Line: 11
import java.util.Collections;
public class Issue1603_getter extends TestCase {
public void test_emptySet() throws Exception {
Model_1 m = JSON.parseObject("{\"values\":[\"a\"]}", Model_1.class);
assertEquals(0, m.values.size());
}
public void test_emptyList() throws Exception {
Reported by PMD.
Line: 13
public class Issue1603_getter extends TestCase {
public void test_emptySet() throws Exception {
Model_1 m = JSON.parseObject("{\"values\":[\"a\"]}", Model_1.class);
assertEquals(0, m.values.size());
}
public void test_emptyList() throws Exception {
Model_2 m = JSON.parseObject("{\"values\":[\"a\"]}", Model_2.class);
assertEquals(0, m.values.size());
Reported by PMD.
Line: 13
public class Issue1603_getter extends TestCase {
public void test_emptySet() throws Exception {
Model_1 m = JSON.parseObject("{\"values\":[\"a\"]}", Model_1.class);
assertEquals(0, m.values.size());
}
public void test_emptyList() throws Exception {
Model_2 m = JSON.parseObject("{\"values\":[\"a\"]}", Model_2.class);
assertEquals(0, m.values.size());
Reported by PMD.
Line: 16
assertEquals(0, m.values.size());
}
public void test_emptyList() throws Exception {
Model_2 m = JSON.parseObject("{\"values\":[\"a\"]}", Model_2.class);
assertEquals(0, m.values.size());
}
public void test_unmodifier() throws Exception {
Reported by PMD.
Line: 18
public void test_emptyList() throws Exception {
Model_2 m = JSON.parseObject("{\"values\":[\"a\"]}", Model_2.class);
assertEquals(0, m.values.size());
}
public void test_unmodifier() throws Exception {
Model_3 m = JSON.parseObject("{\"values\":[\"a\"]}", Model_3.class);
assertEquals(0, m.values.size());
Reported by PMD.
Line: 18
public void test_emptyList() throws Exception {
Model_2 m = JSON.parseObject("{\"values\":[\"a\"]}", Model_2.class);
assertEquals(0, m.values.size());
}
public void test_unmodifier() throws Exception {
Model_3 m = JSON.parseObject("{\"values\":[\"a\"]}", Model_3.class);
assertEquals(0, m.values.size());
Reported by PMD.
Line: 21
assertEquals(0, m.values.size());
}
public void test_unmodifier() throws Exception {
Model_3 m = JSON.parseObject("{\"values\":[\"a\"]}", Model_3.class);
assertEquals(0, m.values.size());
}
public static class Model_1 {
Reported by PMD.
Line: 23
public void test_unmodifier() throws Exception {
Model_3 m = JSON.parseObject("{\"values\":[\"a\"]}", Model_3.class);
assertEquals(0, m.values.size());
}
public static class Model_1 {
private final Collection<String> values = Collections.emptySet();
Reported by PMD.
Line: 23
public void test_unmodifier() throws Exception {
Model_3 m = JSON.parseObject("{\"values\":[\"a\"]}", Model_3.class);
assertEquals(0, m.values.size());
}
public static class Model_1 {
private final Collection<String> values = Collections.emptySet();
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/array/FieldFloatArray2Test.java
9 issues
Line: 10
* Created by wenshao on 11/01/2017.
*/
public class FieldFloatArray2Test extends TestCase {
public void test_intArray() throws Exception {
Model model = JSON.parseObject("{\"value\":[[1,2.1,-0.3]]}", Model.class);
assertNotNull(model.value);
assertEquals(1, model.value.length);
assertEquals(3, model.value[0].length);
assertEquals(1f, model.value[0][0]);
Reported by PMD.
Line: 10
* Created by wenshao on 11/01/2017.
*/
public class FieldFloatArray2Test extends TestCase {
public void test_intArray() throws Exception {
Model model = JSON.parseObject("{\"value\":[[1,2.1,-0.3]]}", Model.class);
assertNotNull(model.value);
assertEquals(1, model.value.length);
assertEquals(3, model.value[0].length);
assertEquals(1f, model.value[0][0]);
Reported by PMD.
Line: 12
public class FieldFloatArray2Test extends TestCase {
public void test_intArray() throws Exception {
Model model = JSON.parseObject("{\"value\":[[1,2.1,-0.3]]}", Model.class);
assertNotNull(model.value);
assertEquals(1, model.value.length);
assertEquals(3, model.value[0].length);
assertEquals(1f, model.value[0][0]);
assertEquals(2.1f, model.value[0][1]);
assertEquals(-0.3f, model.value[0][2]);
Reported by PMD.
Line: 13
public void test_intArray() throws Exception {
Model model = JSON.parseObject("{\"value\":[[1,2.1,-0.3]]}", Model.class);
assertNotNull(model.value);
assertEquals(1, model.value.length);
assertEquals(3, model.value[0].length);
assertEquals(1f, model.value[0][0]);
assertEquals(2.1f, model.value[0][1]);
assertEquals(-0.3f, model.value[0][2]);
}
Reported by PMD.
Line: 14
Model model = JSON.parseObject("{\"value\":[[1,2.1,-0.3]]}", Model.class);
assertNotNull(model.value);
assertEquals(1, model.value.length);
assertEquals(3, model.value[0].length);
assertEquals(1f, model.value[0][0]);
assertEquals(2.1f, model.value[0][1]);
assertEquals(-0.3f, model.value[0][2]);
}
Reported by PMD.
Line: 15
assertNotNull(model.value);
assertEquals(1, model.value.length);
assertEquals(3, model.value[0].length);
assertEquals(1f, model.value[0][0]);
assertEquals(2.1f, model.value[0][1]);
assertEquals(-0.3f, model.value[0][2]);
}
public static class Model {
Reported by PMD.
Line: 16
assertEquals(1, model.value.length);
assertEquals(3, model.value[0].length);
assertEquals(1f, model.value[0][0]);
assertEquals(2.1f, model.value[0][1]);
assertEquals(-0.3f, model.value[0][2]);
}
public static class Model {
public float[][] value;
Reported by PMD.
Line: 17
assertEquals(3, model.value[0].length);
assertEquals(1f, model.value[0][0]);
assertEquals(2.1f, model.value[0][1]);
assertEquals(-0.3f, model.value[0][2]);
}
public static class Model {
public float[][] value;
}
Reported by PMD.
Line: 21
}
public static class Model {
public float[][] value;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue87_hashset.java
9 issues
Line: 18
to.add("test1");
to.add("test2");
String text = JSON.toJSONString(to);
System.out.println(text);
JSONObject jo = JSON.parseObject(text);
to = JSON.toJavaObject(jo, TestObject.class);
}
public static class TestObject {
Reported by PMD.
Line: 13
public class Issue87_hashset extends TestCase {
public void test_for_issue() throws Exception {
TestObject to = new TestObject();
to.add("test1");
to.add("test2");
String text = JSON.toJSONString(to);
System.out.println(text);
Reported by PMD.
Line: 13
public class Issue87_hashset extends TestCase {
public void test_for_issue() throws Exception {
TestObject to = new TestObject();
to.add("test1");
to.add("test2");
String text = JSON.toJSONString(to);
System.out.println(text);
Reported by PMD.
Line: 20
String text = JSON.toJSONString(to);
System.out.println(text);
JSONObject jo = JSON.parseObject(text);
to = JSON.toJavaObject(jo, TestObject.class);
}
public static class TestObject {
private HashSet<String> set = new HashSet<String>(0);
Reported by PMD.
Line: 25
public static class TestObject {
private HashSet<String> set = new HashSet<String>(0);
public HashSet<String> getSet() {
return set;
}
Reported by PMD.
Line: 27
private HashSet<String> set = new HashSet<String>(0);
public HashSet<String> getSet() {
return set;
}
public void setSet(HashSet<String> set) {
this.set = set;
Reported by PMD.
Line: 31
return set;
}
public void setSet(HashSet<String> set) {
this.set = set;
}
public void add(String str) {
set.add(str);
Reported by PMD.
Line: 4
package com.alibaba.json.bvt.bug;
import java.util.HashSet;
import java.util.Set;
import junit.framework.TestCase;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
Reported by PMD.
Line: 20
String text = JSON.toJSONString(to);
System.out.println(text);
JSONObject jo = JSON.parseObject(text);
to = JSON.toJavaObject(jo, TestObject.class);
}
public static class TestObject {
private HashSet<String> set = new HashSet<String>(0);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/JSONFieldTest6.java
9 issues
Line: 13
public class JSONFieldTest6 extends TestCase {
public void test_for_issue1()
{
NonStringMap nonStringMap = new NonStringMap();
Map<Integer, Integer> map1 = new HashMap();
map1.put( 111,666 );
nonStringMap.setMap1( map1 );
Reported by PMD.
Line: 20
map1.put( 111,666 );
nonStringMap.setMap1( map1 );
String json = JSON.toJSONString( nonStringMap );
assertEquals( "{\"map1\":{\"111\":666}}", json );
}
public void test_for_issue2()
{
NonStringMap nonStringMap = new NonStringMap();
Reported by PMD.
Line: 23
assertEquals( "{\"map1\":{\"111\":666}}", json );
}
public void test_for_issue2()
{
NonStringMap nonStringMap = new NonStringMap();
Map<Integer, Integer> map2 = new HashMap();
map2.put( 222,888 );
nonStringMap.setMap2( map2 );
Reported by PMD.
Line: 30
map2.put( 222,888 );
nonStringMap.setMap2( map2 );
String json = JSON.toJSONString( nonStringMap );
assertEquals( "{\"map2\":{222:\"888\"}}", json );
}
public void test_for_issue3()
{
NonStringMap nonStringMap = new NonStringMap();
Reported by PMD.
Line: 33
assertEquals( "{\"map2\":{222:\"888\"}}", json );
}
public void test_for_issue3()
{
NonStringMap nonStringMap = new NonStringMap();
Map<Integer, Integer> map3 = new HashMap();
map3.put( 333,999 );
nonStringMap.setMap3( map3 );
Reported by PMD.
Line: 40
map3.put( 333,999 );
nonStringMap.setMap3( map3 );
String json = JSON.toJSONString( nonStringMap );
assertEquals( "{\"map3\":{\"333\":\"999\"}}", json );
}
public void test_for_issue4()
{
NonStringMap nonStringMap = new NonStringMap();
Reported by PMD.
Line: 43
assertEquals( "{\"map3\":{\"333\":\"999\"}}", json );
}
public void test_for_issue4()
{
NonStringMap nonStringMap = new NonStringMap();
Bean person = new Bean();
person.setAge( 23 );
nonStringMap.setPerson( person );
Reported by PMD.
Line: 50
person.setAge( 23 );
nonStringMap.setPerson( person );
String json = JSON.toJSONString( nonStringMap );
assertEquals( "{\"person\":{\"age\":\"23\"}}", json );
}
class NonStringMap
{
@JSONField( serialzeFeatures = {SerializerFeature.WriteNonStringKeyAsString} )
Reported by PMD.
Line: 53
assertEquals( "{\"person\":{\"age\":\"23\"}}", json );
}
class NonStringMap
{
@JSONField( serialzeFeatures = {SerializerFeature.WriteNonStringKeyAsString} )
private Map map1;
public Map getMap1()
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/deser/array/FieldFloatArray2Test_private.java
9 issues
Line: 10
* Created by wenshao on 11/01/2017.
*/
public class FieldFloatArray2Test_private extends TestCase {
public void test_intArray() throws Exception {
Model model = JSON.parseObject("{\"value\":[[1,2.1,-0.3]]}", Model.class);
assertNotNull(model.value);
assertEquals(1, model.value.length);
assertEquals(3, model.value[0].length);
assertEquals(1f, model.value[0][0]);
Reported by PMD.
Line: 10
* Created by wenshao on 11/01/2017.
*/
public class FieldFloatArray2Test_private extends TestCase {
public void test_intArray() throws Exception {
Model model = JSON.parseObject("{\"value\":[[1,2.1,-0.3]]}", Model.class);
assertNotNull(model.value);
assertEquals(1, model.value.length);
assertEquals(3, model.value[0].length);
assertEquals(1f, model.value[0][0]);
Reported by PMD.
Line: 12
public class FieldFloatArray2Test_private extends TestCase {
public void test_intArray() throws Exception {
Model model = JSON.parseObject("{\"value\":[[1,2.1,-0.3]]}", Model.class);
assertNotNull(model.value);
assertEquals(1, model.value.length);
assertEquals(3, model.value[0].length);
assertEquals(1f, model.value[0][0]);
assertEquals(2.1f, model.value[0][1]);
assertEquals(-0.3f, model.value[0][2]);
Reported by PMD.
Line: 13
public void test_intArray() throws Exception {
Model model = JSON.parseObject("{\"value\":[[1,2.1,-0.3]]}", Model.class);
assertNotNull(model.value);
assertEquals(1, model.value.length);
assertEquals(3, model.value[0].length);
assertEquals(1f, model.value[0][0]);
assertEquals(2.1f, model.value[0][1]);
assertEquals(-0.3f, model.value[0][2]);
}
Reported by PMD.
Line: 14
Model model = JSON.parseObject("{\"value\":[[1,2.1,-0.3]]}", Model.class);
assertNotNull(model.value);
assertEquals(1, model.value.length);
assertEquals(3, model.value[0].length);
assertEquals(1f, model.value[0][0]);
assertEquals(2.1f, model.value[0][1]);
assertEquals(-0.3f, model.value[0][2]);
}
Reported by PMD.
Line: 15
assertNotNull(model.value);
assertEquals(1, model.value.length);
assertEquals(3, model.value[0].length);
assertEquals(1f, model.value[0][0]);
assertEquals(2.1f, model.value[0][1]);
assertEquals(-0.3f, model.value[0][2]);
}
private static class Model {
Reported by PMD.
Line: 16
assertEquals(1, model.value.length);
assertEquals(3, model.value[0].length);
assertEquals(1f, model.value[0][0]);
assertEquals(2.1f, model.value[0][1]);
assertEquals(-0.3f, model.value[0][2]);
}
private static class Model {
public float[][] value;
Reported by PMD.
Line: 17
assertEquals(3, model.value[0].length);
assertEquals(1f, model.value[0][0]);
assertEquals(2.1f, model.value[0][1]);
assertEquals(-0.3f, model.value[0][2]);
}
private static class Model {
public float[][] value;
}
Reported by PMD.
Line: 21
}
private static class Model {
public float[][] value;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/typeRef/TypeReferenceTest6.java
9 issues
Line: 15
public class TypeReferenceTest6 extends TestCase {
public void test_typeRef() throws Exception {
TypeReference<Map<String, Entity>> typeRef = new TypeReference<Map<String, Entity>>() {
};
Map<String, Entity> map = JSON.parseObject(
"{\"value\":{\"id\":\"abc\",\"list\":[{\"id\":123}]}}", typeRef);
Reported by PMD.
Line: 22
Map<String, Entity> map = JSON.parseObject(
"{\"value\":{\"id\":\"abc\",\"list\":[{\"id\":123}]}}", typeRef);
Entity entity = map.get("value");
Assert.assertNotNull(entity);
Assert.assertEquals("abc", entity.getId());
Assert.assertEquals(1, entity.getList().size());
Assert.assertEquals(123, entity.getList().get(0).getId());
}
Reported by PMD.
Line: 24
Entity entity = map.get("value");
Assert.assertNotNull(entity);
Assert.assertEquals("abc", entity.getId());
Assert.assertEquals(1, entity.getList().size());
Assert.assertEquals(123, entity.getList().get(0).getId());
}
public static class Entity {
Reported by PMD.
Line: 25
Entity entity = map.get("value");
Assert.assertNotNull(entity);
Assert.assertEquals("abc", entity.getId());
Assert.assertEquals(1, entity.getList().size());
Assert.assertEquals(123, entity.getList().get(0).getId());
}
public static class Entity {
private String id;
Reported by PMD.
Line: 25
Entity entity = map.get("value");
Assert.assertNotNull(entity);
Assert.assertEquals("abc", entity.getId());
Assert.assertEquals(1, entity.getList().size());
Assert.assertEquals(123, entity.getList().get(0).getId());
}
public static class Entity {
private String id;
Reported by PMD.
Line: 26
Assert.assertNotNull(entity);
Assert.assertEquals("abc", entity.getId());
Assert.assertEquals(1, entity.getList().size());
Assert.assertEquals(123, entity.getList().get(0).getId());
}
public static class Entity {
private String id;
Reported by PMD.
Line: 26
Assert.assertNotNull(entity);
Assert.assertEquals("abc", entity.getId());
Assert.assertEquals(1, entity.getList().size());
Assert.assertEquals(123, entity.getList().get(0).getId());
}
public static class Entity {
private String id;
Reported by PMD.
Line: 26
Assert.assertNotNull(entity);
Assert.assertEquals("abc", entity.getId());
Assert.assertEquals(1, entity.getList().size());
Assert.assertEquals(123, entity.getList().get(0).getId());
}
public static class Entity {
private String id;
Reported by PMD.
Line: 29
Assert.assertEquals(123, entity.getList().get(0).getId());
}
public static class Entity {
private String id;
private List<A> list = new ArrayList<A>();
public String getId() {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/IntFieldTest2.java
9 issues
Line: 17
public class IntFieldTest2 extends TestCase {
public void test_model() throws Exception {
Model model = new Model();
model.id = -1001;
model.id2 = -1002;
String text = JSON.toJSONString(model);
Reported by PMD.
Line: 26
Assert.assertEquals("{\"id\":-1001,\"id2\":-1002}", text);
}
public void test_model_max() throws Exception {
Model model = new Model();
model.id = Integer.MIN_VALUE;
model.id2 = Integer.MAX_VALUE;
String text = JSON.toJSONString(model);
Reported by PMD.
Line: 42
}
}
public void test_model_map() throws Exception {
String text = "{\"model\":{\"id\":-1001,\"id2\":-1002}}";
JSONReader reader = new JSONReader(new StringReader(text));
Map<String, Model> map = reader.readObject(new TypeReference<Map<String, Model>>() {
});
Reported by PMD.
Line: 54
reader.close();
}
public void test_model_map_error() throws Exception {
String text = "{\"model\":{\"id\":-1001,\"id2\":-1002[";
Exception error = null;
JSONReader reader = new JSONReader(new StringReader(text));
try {
Reported by PMD.
Line: 68
Assert.assertNotNull(error);
}
public void test_model_map_error_2() throws Exception {
String text = "{\"model\":{\"id\":-1001,\"id2\":-1002}[";
Exception error = null;
JSONReader reader = new JSONReader(new StringReader(text));
try {
Reported by PMD.
Line: 84
public static class Model {
public int id;
public int id2;
}
}
Reported by PMD.
Line: 85
public static class Model {
public int id;
public int id2;
}
}
Reported by PMD.
Line: 57
public void test_model_map_error() throws Exception {
String text = "{\"model\":{\"id\":-1001,\"id2\":-1002[";
Exception error = null;
JSONReader reader = new JSONReader(new StringReader(text));
try {
reader.readObject(new TypeReference<Map<String, Model>>() {
});
} catch (JSONException ex) {
Reported by PMD.
Line: 71
public void test_model_map_error_2() throws Exception {
String text = "{\"model\":{\"id\":-1001,\"id2\":-1002}[";
Exception error = null;
JSONReader reader = new JSONReader(new StringReader(text));
try {
reader.readObject(new TypeReference<Map<String, Model>>() {
});
} catch (JSONException ex) {
Reported by PMD.