The following issues were found
src/test/java/com/alibaba/json/bvt/issue_1200/Issue1233.java
12 issues
Line: 17
* Created by wenshao on 30/05/2017.
*/
public class Issue1233 extends TestCase {
public void test_for_issue() throws Exception {
ParserConfig.getGlobalInstance().putDeserializer(Area.class, new ObjectDeserializer() {
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
JSONObject jsonObject = (JSONObject) parser.parse();
String areaType;
Reported by PMD.
Line: 17
* Created by wenshao on 30/05/2017.
*/
public class Issue1233 extends TestCase {
public void test_for_issue() throws Exception {
ParserConfig.getGlobalInstance().putDeserializer(Area.class, new ObjectDeserializer() {
public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
JSONObject jsonObject = (JSONObject) parser.parse();
String areaType;
Reported by PMD.
Line: 23
JSONObject jsonObject = (JSONObject) parser.parse();
String areaType;
if (jsonObject.get("type") instanceof String) {
areaType = (String) jsonObject.get("type");
} else {
return null;
}
if (Area.TYPE_SECTION.equals(areaType)) {
Reported by PMD.
Line: 28
} else {
return null;
}
if (Area.TYPE_SECTION.equals(areaType)) {
return (T) JSON.toJavaObject(jsonObject, Section.class);
} else if (Area.TYPE_FLOORV1.equals(areaType)) {
return (T) JSON.toJavaObject(jsonObject, FloorV1.class);
} else if (Area.TYPE_FLOORV2.equals(areaType)) {
return (T) JSON.toJavaObject(jsonObject, FloorV2.class);
Reported by PMD.
Line: 30
}
if (Area.TYPE_SECTION.equals(areaType)) {
return (T) JSON.toJavaObject(jsonObject, Section.class);
} else if (Area.TYPE_FLOORV1.equals(areaType)) {
return (T) JSON.toJavaObject(jsonObject, FloorV1.class);
} else if (Area.TYPE_FLOORV2.equals(areaType)) {
return (T) JSON.toJavaObject(jsonObject, FloorV2.class);
}
return null;
Reported by PMD.
Line: 32
return (T) JSON.toJavaObject(jsonObject, Section.class);
} else if (Area.TYPE_FLOORV1.equals(areaType)) {
return (T) JSON.toJavaObject(jsonObject, FloorV1.class);
} else if (Area.TYPE_FLOORV2.equals(areaType)) {
return (T) JSON.toJavaObject(jsonObject, FloorV2.class);
}
return null;
}
Reported by PMD.
Line: 45
JSONObject jsonObject = JSON.parseObject("{\"type\":\"floorV2\",\"templateId\":\"x123\"}");
FloorV2 floorV2 = (FloorV2) jsonObject.toJavaObject(Area.class);
assertNotNull(floorV2);
assertEquals("x123", floorV2.templateId);
}
public interface Area {
Reported by PMD.
Line: 46
JSONObject jsonObject = JSON.parseObject("{\"type\":\"floorV2\",\"templateId\":\"x123\"}");
FloorV2 floorV2 = (FloorV2) jsonObject.toJavaObject(Area.class);
assertNotNull(floorV2);
assertEquals("x123", floorV2.templateId);
}
public interface Area {
public static final String TYPE_SECTION = "section";
Reported by PMD.
Line: 47
FloorV2 floorV2 = (FloorV2) jsonObject.toJavaObject(Area.class);
assertNotNull(floorV2);
assertEquals("x123", floorV2.templateId);
}
public interface Area {
public static final String TYPE_SECTION = "section";
public static final String TYPE_FLOORV1 = "floorV1";
Reported by PMD.
Line: 63
public String type;
public String templateId;
public String getName() {
return templateId;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/filters/NameFilterTest_long_field.java
12 issues
Line: 15
public class NameFilterTest_long_field extends TestCase {
public void test_namefilter() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
Assert.assertTrue(value instanceof Long);
Reported by PMD.
Line: 19
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
Assert.assertTrue(value instanceof Long);
return "ID";
}
return name;
Reported by PMD.
Line: 19
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
Assert.assertTrue(value instanceof Long);
return "ID";
}
return name;
Reported by PMD.
Line: 31
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getNameFilters().add(filter);
Bean a = new Bean();
serializer.write(a);
String text = out.toString();
Reported by PMD.
Line: 40
Assert.assertEquals("{\"ID\":0}", text);
}
public void test_namefilter_1() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
Reported by PMD.
Line: 44
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 44
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 55
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getNameFilters().add(filter);
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", 0);
serializer.write(map);
Reported by PMD.
Line: 16
public class NameFilterTest_long_field extends TestCase {
public void test_namefilter() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
Assert.assertTrue(value instanceof Long);
return "ID";
Reported by PMD.
Line: 16
public class NameFilterTest_long_field extends TestCase {
public void test_namefilter() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
Assert.assertTrue(value instanceof Long);
return "ID";
Reported by PMD.
src/test/java/com/alibaba/json/demo/FilterDemo.java
12 issues
Line: 46
serializer.write(object);
String outText = out.toString();
System.out.println(outText);
}
}
Reported by PMD.
Line: 13
public class FilterDemo extends TestCase {
public void test_secure() throws Exception {
ValueFilter filter = new ValueFilter() {
public Object process(Object source, String name, Object value) {
if (name.equals("name")) {
Reported by PMD.
Line: 13
public class FilterDemo extends TestCase {
public void test_secure() throws Exception {
ValueFilter filter = new ValueFilter() {
public Object process(Object source, String name, Object value) {
if (name.equals("name")) {
Reported by PMD.
Line: 18
ValueFilter filter = new ValueFilter() {
public Object process(Object source, String name, Object value) {
if (name.equals("name")) {
return "WSJ";
}
return value;
}
};
Reported by PMD.
Line: 18
ValueFilter filter = new ValueFilter() {
public Object process(Object source, String name, Object value) {
if (name.equals("name")) {
return "WSJ";
}
return value;
}
};
Reported by PMD.
Line: 27
NameFilter nameFilter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
};
Reported by PMD.
Line: 27
NameFilter nameFilter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
};
Reported by PMD.
Line: 40
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getValueFilters().add(filter);
serializer.getNameFilters().add(nameFilter);
serializer.write(object);
String outText = out.toString();
Reported by PMD.
Line: 41
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getValueFilters().add(filter);
serializer.getNameFilters().add(nameFilter);
serializer.write(object);
String outText = out.toString();
System.out.println(outText);
Reported by PMD.
Line: 15
public void test_secure() throws Exception {
ValueFilter filter = new ValueFilter() {
public Object process(Object source, String name, Object value) {
if (name.equals("name")) {
return "WSJ";
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/JSONPath_min.java
12 issues
Line: 10
import java.math.BigDecimal;
public class JSONPath_min extends TestCase {
public void test_max() throws Exception {
Object root = JSON.parse("[1,3,9, 5, 2, 4]");
assertEquals(1, JSONPath.eval(root, "$.min()"));
}
public void test_max_1() throws Exception {
Reported by PMD.
Line: 12
public class JSONPath_min extends TestCase {
public void test_max() throws Exception {
Object root = JSON.parse("[1,3,9, 5, 2, 4]");
assertEquals(1, JSONPath.eval(root, "$.min()"));
}
public void test_max_1() throws Exception {
Object root = JSON.parse("[1,6,7L,3,8,9.1, 5, 2L, 4]");
assertEquals(1, JSONPath.eval(root, "$.min()"));
Reported by PMD.
Line: 12
public class JSONPath_min extends TestCase {
public void test_max() throws Exception {
Object root = JSON.parse("[1,3,9, 5, 2, 4]");
assertEquals(1, JSONPath.eval(root, "$.min()"));
}
public void test_max_1() throws Exception {
Object root = JSON.parse("[1,6,7L,3,8,9.1, 5, 2L, 4]");
assertEquals(1, JSONPath.eval(root, "$.min()"));
Reported by PMD.
Line: 15
assertEquals(1, JSONPath.eval(root, "$.min()"));
}
public void test_max_1() throws Exception {
Object root = JSON.parse("[1,6,7L,3,8,9.1, 5, 2L, 4]");
assertEquals(1, JSONPath.eval(root, "$.min()"));
}
public void test_max_2() throws Exception {
Reported by PMD.
Line: 17
public void test_max_1() throws Exception {
Object root = JSON.parse("[1,6,7L,3,8,9.1, 5, 2L, 4]");
assertEquals(1, JSONPath.eval(root, "$.min()"));
}
public void test_max_2() throws Exception {
Object root = JSON.parse("[1,6,7L,3,3.1D,8,9.1F, 5, 2L, 4]");
assertEquals(1, JSONPath.eval(root, "$.min()"));
Reported by PMD.
Line: 20
assertEquals(1, JSONPath.eval(root, "$.min()"));
}
public void test_max_2() throws Exception {
Object root = JSON.parse("[1,6,7L,3,3.1D,8,9.1F, 5, 2L, 4]");
assertEquals(1, JSONPath.eval(root, "$.min()"));
}
public void test_max_3() throws Exception {
Reported by PMD.
Line: 22
public void test_max_2() throws Exception {
Object root = JSON.parse("[1,6,7L,3,3.1D,8,9.1F, 5, 2L, 4]");
assertEquals(1, JSONPath.eval(root, "$.min()"));
}
public void test_max_3() throws Exception {
Object root = JSON.parse("[1,6,7L,3,3.1F,8,9.1F, 5, 2L, 4]");
assertEquals(1, JSONPath.eval(root, "$.min()"));
Reported by PMD.
Line: 25
assertEquals(1, JSONPath.eval(root, "$.min()"));
}
public void test_max_3() throws Exception {
Object root = JSON.parse("[1,6,7L,3,3.1F,8,9.1F, 5, 2L, 4]");
assertEquals(1, JSONPath.eval(root, "$.min()"));
}
public void test_max_4() throws Exception {
Reported by PMD.
Line: 27
public void test_max_3() throws Exception {
Object root = JSON.parse("[1,6,7L,3,3.1F,8,9.1F, 5, 2L, 4]");
assertEquals(1, JSONPath.eval(root, "$.min()"));
}
public void test_max_4() throws Exception {
Object root = JSON.parse("['1', '111', '2']");
assertEquals("1", JSONPath.eval(root, "$.min()"));
Reported by PMD.
Line: 30
assertEquals(1, JSONPath.eval(root, "$.min()"));
}
public void test_max_4() throws Exception {
Object root = JSON.parse("['1', '111', '2']");
assertEquals("1", JSONPath.eval(root, "$.min()"));
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/filters/NameFilterTest_float_field.java
12 issues
Line: 15
public class NameFilterTest_float_field extends TestCase {
public void test_namefilter() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
Reported by PMD.
Line: 19
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 19
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 30
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getNameFilters().add(filter);
Bean a = new Bean();
serializer.write(a);
String text = out.toString();
Reported by PMD.
Line: 39
Assert.assertEquals("{\"ID\":0.0}", text);
}
public void test_namefilter_1() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
Reported by PMD.
Line: 43
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 43
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 54
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getNameFilters().add(filter);
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", 0);
serializer.write(map);
Reported by PMD.
Line: 16
public class NameFilterTest_float_field extends TestCase {
public void test_namefilter() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
Reported by PMD.
Line: 16
public class NameFilterTest_float_field extends TestCase {
public void test_namefilter() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/issue_1200/Issue1235.java
12 issues
Line: 12
* Created by wenshao on 30/05/2017.
*/
public class Issue1235 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"type\":\"floorV2\",\"templateId\":\"x123\"}";
FloorV2 floorV2 = (FloorV2) JSON.parseObject(json, Area.class);
assertNotNull(floorV2);
assertNotNull(floorV2.templateId);
Reported by PMD.
Line: 12
* Created by wenshao on 30/05/2017.
*/
public class Issue1235 extends TestCase {
public void test_for_issue() throws Exception {
String json = "{\"type\":\"floorV2\",\"templateId\":\"x123\"}";
FloorV2 floorV2 = (FloorV2) JSON.parseObject(json, Area.class);
assertNotNull(floorV2);
assertNotNull(floorV2.templateId);
Reported by PMD.
Line: 16
String json = "{\"type\":\"floorV2\",\"templateId\":\"x123\"}";
FloorV2 floorV2 = (FloorV2) JSON.parseObject(json, Area.class);
assertNotNull(floorV2);
assertNotNull(floorV2.templateId);
assertEquals("x123", floorV2.templateId);
assertEquals("floorV2", floorV2.type);
String json2 = JSON.toJSONString(floorV2, SerializerFeature.WriteClassName);
Reported by PMD.
Line: 17
FloorV2 floorV2 = (FloorV2) JSON.parseObject(json, Area.class);
assertNotNull(floorV2);
assertNotNull(floorV2.templateId);
assertEquals("x123", floorV2.templateId);
assertEquals("floorV2", floorV2.type);
String json2 = JSON.toJSONString(floorV2, SerializerFeature.WriteClassName);
assertEquals("{\"type\":\"floorV2\",\"templateId\":\"x123\"}", json2);
Reported by PMD.
Line: 18
FloorV2 floorV2 = (FloorV2) JSON.parseObject(json, Area.class);
assertNotNull(floorV2);
assertNotNull(floorV2.templateId);
assertEquals("x123", floorV2.templateId);
assertEquals("floorV2", floorV2.type);
String json2 = JSON.toJSONString(floorV2, SerializerFeature.WriteClassName);
assertEquals("{\"type\":\"floorV2\",\"templateId\":\"x123\"}", json2);
}
Reported by PMD.
Line: 19
assertNotNull(floorV2);
assertNotNull(floorV2.templateId);
assertEquals("x123", floorV2.templateId);
assertEquals("floorV2", floorV2.type);
String json2 = JSON.toJSONString(floorV2, SerializerFeature.WriteClassName);
assertEquals("{\"type\":\"floorV2\",\"templateId\":\"x123\"}", json2);
}
Reported by PMD.
Line: 22
assertEquals("floorV2", floorV2.type);
String json2 = JSON.toJSONString(floorV2, SerializerFeature.WriteClassName);
assertEquals("{\"type\":\"floorV2\",\"templateId\":\"x123\"}", json2);
}
@JSONType(seeAlso = {FloorV2.class}, typeKey = "type")
public interface Area {
public static final String TYPE_SECTION = "section";
Reported by PMD.
Line: 27
@JSONType(seeAlso = {FloorV2.class}, typeKey = "type")
public interface Area {
public static final String TYPE_SECTION = "section";
public static final String TYPE_FLOORV1 = "floorV1";
public static final String TYPE_FLOORV2 = "floorV2";
}
@JSONType(typeName = "floorV2")
Reported by PMD.
Line: 28
@JSONType(seeAlso = {FloorV2.class}, typeKey = "type")
public interface Area {
public static final String TYPE_SECTION = "section";
public static final String TYPE_FLOORV1 = "floorV1";
public static final String TYPE_FLOORV2 = "floorV2";
}
@JSONType(typeName = "floorV2")
public static class FloorV2 implements Area {
Reported by PMD.
Line: 29
public interface Area {
public static final String TYPE_SECTION = "section";
public static final String TYPE_FLOORV1 = "floorV1";
public static final String TYPE_FLOORV2 = "floorV2";
}
@JSONType(typeName = "floorV2")
public static class FloorV2 implements Area {
public String type;
Reported by PMD.
src/test/java/com/alibaba/fastjson/jsonpath/issue3607/TestIssue3607.java
12 issues
Line: 24
" \"dataRows\": [\n" +
" {\n" +
" \"dataFields\": [\n" +
" {\n" +
" \"id\": 1332,\n" +
" \"name\": \"gmtRegular\",\n" +
" \"status\": \"success\",\n" +
" \"valueType\": \"DATE\"\n" +
" },\n" +
Reported by PMD.
Line: 27
" {\n" +
" \"id\": 1332,\n" +
" \"name\": \"gmtRegular\",\n" +
" \"status\": \"success\",\n" +
" \"valueType\": \"DATE\"\n" +
" },\n" +
" {\n" +
" \"id\": 302,\n" +
" \"name\": \"deptNo\",\n" +
Reported by PMD.
Line: 29
" \"name\": \"gmtRegular\",\n" +
" \"status\": \"success\",\n" +
" \"valueType\": \"DATE\"\n" +
" },\n" +
" {\n" +
" \"id\": 302,\n" +
" \"name\": \"deptNo\",\n" +
" \"status\": \"success\",\n" +
" \"value\": \"C3736\",\n" +
Reported by PMD.
Line: 35
" \"name\": \"deptNo\",\n" +
" \"status\": \"success\",\n" +
" \"value\": \"C3736\",\n" +
" \"valueType\": \"STRING\"\n" +
" },\n" +
" {\n" +
" \"id\": 143,\n" +
" \"name\": \"gmtOrigRegular\",\n" +
" \"status\": \"success\",\n" +
Reported by PMD.
Line: 82
List<String> evalResult = (List<String>) JSONPath.eval(testData, "$.data.dataRows[*].dataFields[*].value", false);
Assert.assertEquals(testData.getData().getDataRows().get(0).getDataFields().size(), evalResult.size());
}
static class TestData {
private Test1 data;
Reported by PMD.
Line: 82
List<String> evalResult = (List<String>) JSONPath.eval(testData, "$.data.dataRows[*].dataFields[*].value", false);
Assert.assertEquals(testData.getData().getDataRows().get(0).getDataFields().size(), evalResult.size());
}
static class TestData {
private Test1 data;
Reported by PMD.
Line: 82
List<String> evalResult = (List<String>) JSONPath.eval(testData, "$.data.dataRows[*].dataFields[*].value", false);
Assert.assertEquals(testData.getData().getDataRows().get(0).getDataFields().size(), evalResult.size());
}
static class TestData {
private Test1 data;
Reported by PMD.
Line: 82
List<String> evalResult = (List<String>) JSONPath.eval(testData, "$.data.dataRows[*].dataFields[*].value", false);
Assert.assertEquals(testData.getData().getDataRows().get(0).getDataFields().size(), evalResult.size());
}
static class TestData {
private Test1 data;
Reported by PMD.
Line: 82
List<String> evalResult = (List<String>) JSONPath.eval(testData, "$.data.dataRows[*].dataFields[*].value", false);
Assert.assertEquals(testData.getData().getDataRows().get(0).getDataFields().size(), evalResult.size());
}
static class TestData {
private Test1 data;
Reported by PMD.
Line: 82
List<String> evalResult = (List<String>) JSONPath.eval(testData, "$.data.dataRows[*].dataFields[*].value", false);
Assert.assertEquals(testData.getData().getDataRows().get(0).getDataFields().size(), evalResult.size());
}
static class TestData {
private Test1 data;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/filters/NameFilterTest_byte_field.java
12 issues
Line: 15
public class NameFilterTest_byte_field extends TestCase {
public void test_namefilter() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (value != null) {
Assert.assertTrue(value instanceof Byte);
Reported by PMD.
Line: 23
Assert.assertTrue(value instanceof Byte);
}
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 23
Assert.assertTrue(value instanceof Byte);
}
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 34
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getNameFilters().add(filter);
Bean a = new Bean();
serializer.write(a);
String text = out.toString();
Reported by PMD.
Line: 43
Assert.assertEquals("{\"ID\":0}", text);
}
public void test_namefilter_1() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
Reported by PMD.
Line: 47
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 47
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 58
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getNameFilters().add(filter);
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", (byte) 0);
serializer.write(map);
Reported by PMD.
Line: 16
public class NameFilterTest_byte_field extends TestCase {
public void test_namefilter() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (value != null) {
Assert.assertTrue(value instanceof Byte);
}
Reported by PMD.
Line: 16
public class NameFilterTest_byte_field extends TestCase {
public void test_namefilter() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (value != null) {
Assert.assertTrue(value instanceof Byte);
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/writeClassName/WriteClassNameTest_Set3.java
12 issues
Line: 26
set.add(new B1());
a.setList(set);
String text = JSON.toJSONString(a, SerializerFeature.WriteClassName);
System.out.println(text);
// Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set3$A\",\"list\":[{},{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set3$B1\"}]}",
// text);
A a1 = (A) JSON.parse(text);
Reported by PMD.
Line: 15
import com.alibaba.fastjson.serializer.SerializerFeature;
public class WriteClassNameTest_Set3 extends TestCase {
protected void setUp() throws Exception {
ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set3");
}
public void test_list() throws Exception {
A a = new A();
Reported by PMD.
Line: 16
public class WriteClassNameTest_Set3 extends TestCase {
protected void setUp() throws Exception {
ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set3");
}
public void test_list() throws Exception {
A a = new A();
LinkedHashSet<B> set = new LinkedHashSet<B>();
Reported by PMD.
Line: 19
ParserConfig.global.addAccept("com.alibaba.json.bvt.writeClassName.WriteClassNameTest_Set3");
}
public void test_list() throws Exception {
A a = new A();
LinkedHashSet<B> set = new LinkedHashSet<B>();
set.add(new B());
set.add(new B1());
a.setList(set);
Reported by PMD.
Line: 32
A a1 = (A) JSON.parse(text);
Assert.assertEquals(2, a1.getList().size());
Assert.assertTrue(new ArrayList<B>(a1.getList()).get(0) instanceof B);
Assert.assertTrue(new ArrayList<B>(a1.getList()).get(1) instanceof B1);
}
private static class A {
Reported by PMD.
Line: 32
A a1 = (A) JSON.parse(text);
Assert.assertEquals(2, a1.getList().size());
Assert.assertTrue(new ArrayList<B>(a1.getList()).get(0) instanceof B);
Assert.assertTrue(new ArrayList<B>(a1.getList()).get(1) instanceof B1);
}
private static class A {
Reported by PMD.
Line: 33
A a1 = (A) JSON.parse(text);
Assert.assertEquals(2, a1.getList().size());
Assert.assertTrue(new ArrayList<B>(a1.getList()).get(0) instanceof B);
Assert.assertTrue(new ArrayList<B>(a1.getList()).get(1) instanceof B1);
}
private static class A {
Reported by PMD.
Line: 34
Assert.assertEquals(2, a1.getList().size());
Assert.assertTrue(new ArrayList<B>(a1.getList()).get(0) instanceof B);
Assert.assertTrue(new ArrayList<B>(a1.getList()).get(1) instanceof B1);
}
private static class A {
private LinkedHashSet<B> list;
Reported by PMD.
Line: 39
private static class A {
private LinkedHashSet<B> list;
public LinkedHashSet<B> getList() {
return list;
}
Reported by PMD.
Line: 41
private LinkedHashSet<B> list;
public LinkedHashSet<B> getList() {
return list;
}
public void setList(LinkedHashSet<B> list) {
this.list = list;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/filters/NameFilterTest_double_field.java
12 issues
Line: 15
public class NameFilterTest_double_field extends TestCase {
public void test_namefilter() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
Reported by PMD.
Line: 19
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 19
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 30
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getNameFilters().add(filter);
Bean a = new Bean();
serializer.write(a);
String text = out.toString();
Reported by PMD.
Line: 39
Assert.assertEquals("{\"ID\":0.0}", text);
}
public void test_namefilter_1() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
Reported by PMD.
Line: 43
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 43
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
return name;
}
Reported by PMD.
Line: 54
SerializeWriter out = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(out);
serializer.getNameFilters().add(filter);
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", 0);
serializer.write(map);
Reported by PMD.
Line: 16
public class NameFilterTest_double_field extends TestCase {
public void test_namefilter() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
Reported by PMD.
Line: 16
public class NameFilterTest_double_field extends TestCase {
public void test_namefilter() throws Exception {
NameFilter filter = new NameFilter() {
public String process(Object source, String name, Object value) {
if (name.equals("id")) {
return "ID";
}
Reported by PMD.