parent
acda65d8a5
commit
3866d32179
|
@ -0,0 +1,28 @@
|
||||||
|
package com.dispose.test.debug;
|
||||||
|
|
||||||
|
import com.dispose.pojo.vo.common.IDArrayReq;
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public class demo {
|
||||||
|
@Test
|
||||||
|
public void a1_IDIDArrayReqTest() throws JsonProcessingException {
|
||||||
|
String json = "{\"id\":[\"1\", \"123\", \"1234\", \"1234\"]}";
|
||||||
|
String json2 = "{\"id\":[\"1\", \"123\", \"1234\"]}";
|
||||||
|
String json3 = "{\"id\":[\"\", \"1\", \"123\", \"1234\"]}";
|
||||||
|
|
||||||
|
|
||||||
|
IDArrayReq id = new ObjectMapper().readValue(json3, IDArrayReq.class);
|
||||||
|
Assert.assertEquals(id.getId().length, 1);
|
||||||
|
id = new ObjectMapper().readValue(json2, IDArrayReq.class);
|
||||||
|
Assert.assertEquals(id.getId().length, 3);
|
||||||
|
id = new ObjectMapper().readValue(json, IDArrayReq.class);
|
||||||
|
Assert.assertEquals(id.getId().length, 3);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue