The following issues were found
src/test/java/com/alibaba/json/bvt/serializer/enum_/EnumOrdinalTest.java
4 issues
Line: 17
int serializerFeatures = JSON.DEFAULT_GENERATE_FEATURE & ~SerializerFeature.WriteEnumUsingName.mask;
String text = JSON.toJSONString(model, serializerFeatures);
System.out.println(text);
}
public static class Model {
public Type type;
}
Reported by PMD.
Line: 11
* Created by wenshao on 17/03/2017.
*/
public class EnumOrdinalTest extends TestCase {
public void test_enum_ordinal() throws Exception {
Model model = new Model();
model.type = Type.Big;
int serializerFeatures = JSON.DEFAULT_GENERATE_FEATURE & ~SerializerFeature.WriteEnumUsingName.mask;
String text = JSON.toJSONString(model, serializerFeatures);
Reported by PMD.
Line: 11
* Created by wenshao on 17/03/2017.
*/
public class EnumOrdinalTest extends TestCase {
public void test_enum_ordinal() throws Exception {
Model model = new Model();
model.type = Type.Big;
int serializerFeatures = JSON.DEFAULT_GENERATE_FEATURE & ~SerializerFeature.WriteEnumUsingName.mask;
String text = JSON.toJSONString(model, serializerFeatures);
Reported by PMD.
Line: 21
}
public static class Model {
public Type type;
}
public static enum Type {
Big, Medium, Small
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/enum_/EnumTest4.java
4 issues
Line: 8
import junit.framework.TestCase;
public class EnumTest4 extends TestCase {
public void test_for_enum() throws Exception {
assertEquals("101", JSON.toJSONString(Type.Big));
assertEquals("101", JSON.toJSONString(Type1.Big));
}
public enum Type {
Reported by PMD.
Line: 8
import junit.framework.TestCase;
public class EnumTest4 extends TestCase {
public void test_for_enum() throws Exception {
assertEquals("101", JSON.toJSONString(Type.Big));
assertEquals("101", JSON.toJSONString(Type1.Big));
}
public enum Type {
Reported by PMD.
Line: 9
public class EnumTest4 extends TestCase {
public void test_for_enum() throws Exception {
assertEquals("101", JSON.toJSONString(Type.Big));
assertEquals("101", JSON.toJSONString(Type1.Big));
}
public enum Type {
Big(101), Small(102);
Reported by PMD.
Line: 10
public class EnumTest4 extends TestCase {
public void test_for_enum() throws Exception {
assertEquals("101", JSON.toJSONString(Type.Big));
assertEquals("101", JSON.toJSONString(Type1.Big));
}
public enum Type {
Big(101), Small(102);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/enum_/EnumUsingToString_JSONType.java
4 issues
Line: 13
* Created by wenshao on 17/03/2017.
*/
public class EnumUsingToString_JSONType extends TestCase {
public void test_toString() {
Model model = new Model();
model.gender = Gender.M;
String text = JSON.toJSONString(model);
assertEquals("{\"gender\":\"男\"}", text);
Reported by PMD.
Line: 18
model.gender = Gender.M;
String text = JSON.toJSONString(model);
assertEquals("{\"gender\":\"男\"}", text);
}
@JSONType(serialzeFeatures = SerializerFeature.WriteEnumUsingToString)
public static class Model {
public Gender gender;
Reported by PMD.
Line: 23
@JSONType(serialzeFeatures = SerializerFeature.WriteEnumUsingToString)
public static class Model {
public Gender gender;
}
public static enum Gender {
M("男"),
W("女");
Reported by PMD.
Line: 4
package com.alibaba.json.bvt.serializer.enum_;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.annotation.JSONType;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;
/**
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/JSONPath_array_multi.java
4 issues
Line: 14
public class JSONPath_array_multi extends TestCase {
Object[] list = new Object[10];
public JSONPath_array_multi(){
for (int i = 0; i < list.length; ++i) {
list[i] = new Object();
}
Reported by PMD.
Line: 22
}
}
public void test_list_multi() throws Exception {
List<Object> result = (List<Object>) new JSONPath("$[2,4,5,8,100]").eval(list);
Assert.assertEquals(5, result.size());
Assert.assertSame(list[2], result.get(0));
Assert.assertSame(list[4], result.get(1));
Assert.assertSame(list[5], result.get(2));
Reported by PMD.
Line: 32
Assert.assertNull(result.get(4));
}
public void test_list_multi_negative() throws Exception {
List<Object> result = (List<Object>) new JSONPath("$[-1,-2,-100]")
.eval(list);
Assert.assertEquals(3, result.size());
Assert.assertSame(list[9], result.get(0));
Assert.assertSame(list[8], result.get(1));
Reported by PMD.
Line: 3
package com.alibaba.json.bvt.path;
import java.util.ArrayList;
import java.util.List;
import junit.framework.TestCase;
import org.junit.Assert;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/features/WriteNonStringValueAsStringTestByteField.java
4 issues
Line: 11
import junit.framework.TestCase;
public class WriteNonStringValueAsStringTestByteField extends TestCase {
public void test_0() throws Exception {
VO vo = new VO();
vo.id = 100;
String text = JSON.toJSONString(vo, SerializerFeature.WriteNonStringValueAsString);
Assert.assertEquals("{\"id\":\"100\"}", text);
Reported by PMD.
Line: 19
Assert.assertEquals("{\"id\":\"100\"}", text);
}
public void test_1() throws Exception {
V1 vo = new V1();
vo.id = 100;
String text = JSON.toJSONString(vo, SerializerFeature.WriteNonStringValueAsString);
Assert.assertEquals("{\"id\":\"100\"}", text);
Reported by PMD.
Line: 28
}
public static class VO {
public byte id;
}
private static class V1 {
public byte id;
Reported by PMD.
Line: 33
private static class V1 {
public byte id;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/features/WriteNonStringValueAsStringTestByteObjectField.java
4 issues
Line: 11
import junit.framework.TestCase;
public class WriteNonStringValueAsStringTestByteObjectField extends TestCase {
public void test_0() throws Exception {
VO vo = new VO();
vo.id = 100;
String text = JSON.toJSONString(vo, SerializerFeature.WriteNonStringValueAsString);
Assert.assertEquals("{\"id\":\"100\"}", text);
Reported by PMD.
Line: 19
Assert.assertEquals("{\"id\":\"100\"}", text);
}
public void test_1() throws Exception {
V1 vo = new V1();
vo.id = 100;
String text = JSON.toJSONString(vo, SerializerFeature.WriteNonStringValueAsString);
Assert.assertEquals("{\"id\":\"100\"}", text);
Reported by PMD.
Line: 28
}
public static class VO {
public Byte id;
}
private static class V1 {
public Byte id;
Reported by PMD.
Line: 33
private static class V1 {
public Byte id;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/features/WriteNonStringValueAsStringTestIntegerField.java
4 issues
Line: 11
import junit.framework.TestCase;
public class WriteNonStringValueAsStringTestIntegerField extends TestCase {
public void test_0() throws Exception {
VO vo = new VO();
vo.id = 100;
String text = JSON.toJSONString(vo, SerializerFeature.WriteNonStringValueAsString);
Assert.assertEquals("{\"id\":\"100\"}", text);
Reported by PMD.
Line: 19
Assert.assertEquals("{\"id\":\"100\"}", text);
}
public void test_1() throws Exception {
V1 vo = new V1();
vo.id = 100;
String text = JSON.toJSONString(vo, SerializerFeature.WriteNonStringValueAsString);
Assert.assertEquals("{\"id\":\"100\"}", text);
Reported by PMD.
Line: 28
}
public static class VO {
public Integer id;
}
private static class V1 {
public Integer id;
Reported by PMD.
Line: 33
private static class V1 {
public Integer id;
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/path/JSONPath_containsValue_bigdecimal.java
4 issues
Line: 13
import junit.framework.TestCase;
public class JSONPath_containsValue_bigdecimal extends TestCase {
public void test_root() throws Exception {
Model model = new Model();
model.value = new BigDecimal("1001");
Assert.assertTrue(JSONPath.containsValue(model, "/value", 1001));
Assert.assertTrue(JSONPath.containsValue(model, "/value", 1001L));
Reported by PMD.
Line: 17
Model model = new Model();
model.value = new BigDecimal("1001");
Assert.assertTrue(JSONPath.containsValue(model, "/value", 1001));
Assert.assertTrue(JSONPath.containsValue(model, "/value", 1001L));
Assert.assertTrue(JSONPath.containsValue(model, "/value", (short) 1001));
Assert.assertFalse(JSONPath.containsValue(model, "/value", 1002));
Assert.assertFalse(JSONPath.containsValue(model, "/value", 1002L));
Reported by PMD.
Line: 27
}
public static class Model {
public BigDecimal value;
}
}
Reported by PMD.
Line: 4
package com.alibaba.json.bvt.path;
import java.math.BigDecimal;
import java.math.BigInteger;
import org.junit.Assert;
import com.alibaba.fastjson.JSONPath;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/parser/stream/JSONReaderScannerTest_boolean.java
4 issues
Line: 12
import com.alibaba.fastjson.parser.JSONReaderScanner;
public class JSONReaderScannerTest_boolean extends TestCase {
public void test_true() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner("{\"name\":true}"));
JSONObject json = parser.parseObject();
Assert.assertEquals(Boolean.TRUE, json.get("name"));
parser.close();
}
Reported by PMD.
Line: 15
public void test_true() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner("{\"name\":true}"));
JSONObject json = parser.parseObject();
Assert.assertEquals(Boolean.TRUE, json.get("name"));
parser.close();
}
public void test_false() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner("{\"name\":false}"));
Reported by PMD.
Line: 19
parser.close();
}
public void test_false() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner("{\"name\":false}"));
JSONObject json = parser.parseObject();
Assert.assertEquals(Boolean.FALSE, json.get("name"));
parser.close();
}
Reported by PMD.
Line: 22
public void test_false() throws Exception {
DefaultJSONParser parser = new DefaultJSONParser(new JSONReaderScanner("{\"name\":false}"));
JSONObject json = parser.parseObject();
Assert.assertEquals(Boolean.FALSE, json.get("name"));
parser.close();
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/serializer/filters/MTopFilterTest.java
4 issues
Line: 14
public class MTopFilterTest extends TestCase {
public void test_0() throws Exception {
Model model = new Model();
model.id = 1001;
model.name = "yongbo";
model.user = new Person();
model.user.personId = 2002;
Reported by PMD.
Line: 41
Assert.assertEquals(model.user.personId, values.get("personId"));
}
public static class Model {
private int id;
private String name;
private Person user;
Reported by PMD.
Line: 22
model.user.personId = 2002;
final HashMap<String, Object> values = new HashMap<String, Object>();
ValueFilter valueFilter = new ValueFilter() {
@Override
public Object process(Object object, String name, Object value) {
values.put(name, value);
return value;
Reported by PMD.
Line: 22
model.user.personId = 2002;
final HashMap<String, Object> values = new HashMap<String, Object>();
ValueFilter valueFilter = new ValueFilter() {
@Override
public Object process(Object object, String name, Object value) {
values.put(name, value);
return value;
Reported by PMD.