REM:
1. 增加demo测试用例
This commit is contained in:
HuangXin 2020-05-28 16:41:24 +08:00
parent acda65d8a5
commit 3866d32179
1 changed files with 28 additions and 0 deletions

View File

@ -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);
}
}