diff --git a/src/test/java/com/dispose/test/debug/demo.java b/src/test/java/com/dispose/test/debug/demo.java new file mode 100644 index 00000000..f2c74531 --- /dev/null +++ b/src/test/java/com/dispose/test/debug/demo.java @@ -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); + } +}