切换到jackson #10
@@ -14,7 +14,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.celess.blog.enmu.ResponseEnum.DATA_IS_DELETED;
|
||||
import static cn.celess.blog.enmu.ResponseEnum.SUCCESS;
|
||||
@@ -36,25 +36,26 @@ public class CommentControllerTest extends BaseTest {
|
||||
Article article = articleMapper.getLastestArticle();
|
||||
CommentReq commentReq = new CommentReq();
|
||||
commentReq.setPagePath("/article/" + article.getId());
|
||||
commentReq.setContent(UUID.randomUUID().toString());
|
||||
commentReq.setPid(-1L);
|
||||
commentReq.setToUserId(-1L);
|
||||
commentReq.setContent(randomStr());
|
||||
List<User> all = userMapper.findAll();
|
||||
commentReq.setPid(1L);
|
||||
commentReq.setToUserId(2l);
|
||||
getMockData(post("/user/comment/create"), userLogin(), commentReq).andDo(result -> {
|
||||
Response<CommentModel> response = getResponse(result, COMMENT_MODEL_TYPE);
|
||||
assertEquals(SUCCESS.getCode(), response.getCode());
|
||||
CommentModel model = response.getResult();
|
||||
assertNotEquals(0, model.getId());
|
||||
assertEquals(commentReq.getPid(), model.getPid().longValue());
|
||||
assertEquals(-1, model.getPid().longValue());
|
||||
assertEquals(1, model.getPid().longValue());
|
||||
assertEquals(commentReq.getContent(), model.getContent());
|
||||
assertNotNull(model.getDate());
|
||||
assertNotNull(model.getFromUser());
|
||||
assertNull(model.getToUser());
|
||||
assertNotNull(model.getToUser());
|
||||
});
|
||||
|
||||
|
||||
commentReq.setPagePath("/article/" + article.getId());
|
||||
commentReq.setContent(UUID.randomUUID().toString());
|
||||
commentReq.setContent(randomStr());
|
||||
commentReq.setPid(-1L);
|
||||
commentReq.setToUserId(2);
|
||||
getMockData(post("/user/comment/create"), userLogin(), commentReq).andDo(result -> {
|
||||
@@ -75,7 +76,7 @@ public class CommentControllerTest extends BaseTest {
|
||||
// 测试二级回复
|
||||
Comment latestComment = commentMapper.getLastestComment();
|
||||
commentReq.setPagePath("/article/" + article.getId());
|
||||
commentReq.setContent(UUID.randomUUID().toString());
|
||||
commentReq.setContent(randomStr());
|
||||
commentReq.setPid(latestComment.getId());
|
||||
getMockData(post("/user/comment/create"), userLogin(), commentReq).andDo(result -> {
|
||||
Response<CommentModel> response = getResponse(result, COMMENT_MODEL_TYPE);
|
||||
@@ -120,7 +121,7 @@ public class CommentControllerTest extends BaseTest {
|
||||
Comment comment = commentMapper.getLastestComment();
|
||||
CommentReq commentReq = new CommentReq();
|
||||
commentReq.setId(comment.getId());
|
||||
commentReq.setContent(UUID.randomUUID().toString());
|
||||
commentReq.setContent(randomStr());
|
||||
// 不合法数据 setResponseId
|
||||
getMockData(put("/user/comment/update"), userLogin(), commentReq).andDo(result -> {
|
||||
Response<CommentModel> response = getResponse(result, COMMENT_MODEL_TYPE);
|
||||
|
||||
@@ -11,7 +11,6 @@ import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static cn.celess.blog.enmu.ResponseEnum.*;
|
||||
import static org.junit.Assert.*;
|
||||
@@ -45,7 +44,7 @@ public class LinksControllerTest extends BaseTest {
|
||||
});
|
||||
|
||||
// https/http
|
||||
linkReq.setName(UUID.randomUUID().toString().substring(0, 4));
|
||||
linkReq.setName(randomStr(4));
|
||||
linkReq.setOpen(false);
|
||||
linkReq.setUrl("example.com");
|
||||
getMockData(post("/admin/links/create"), adminLogin(), linkReq).andDo(result -> {
|
||||
@@ -105,7 +104,7 @@ public class LinksControllerTest extends BaseTest {
|
||||
LinkReq linkReq = new LinkReq();
|
||||
linkReq.setUrl(latest.getUrl());
|
||||
linkReq.setOpen(!latest.getOpen());
|
||||
linkReq.setName(UUID.randomUUID().toString().substring(0, 4));
|
||||
linkReq.setName(randomStr(4));
|
||||
linkReq.setId(latest.getId());
|
||||
|
||||
getMockData(put("/admin/links/update"), adminLogin(), linkReq).andDo(result -> {
|
||||
|
||||
@@ -68,8 +68,8 @@ public class UserControllerTest extends BaseTest {
|
||||
|
||||
@Test
|
||||
public void updateInfo() throws Exception {
|
||||
String desc = UUID.randomUUID().toString().substring(0, 4);
|
||||
String disPlayName = UUID.randomUUID().toString().substring(0, 4);
|
||||
String desc = randomStr(4);
|
||||
String disPlayName = randomStr(4);
|
||||
getMockData(put("/user/userInfo/update?desc=" + desc + "&displayName=" + disPlayName), userLogin()).andDo(result -> {
|
||||
Response<UserModel> response = getResponse(result, USER_MODEL_TYPE);
|
||||
assertEquals(SUCCESS.getCode(), response.getCode());
|
||||
@@ -157,7 +157,7 @@ public class UserControllerTest extends BaseTest {
|
||||
public void multipleDelete() throws Exception {
|
||||
List<User> userList = new ArrayList<>();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
String s = UUID.randomUUID().toString();
|
||||
String s = randomStr();
|
||||
String email = s.substring(s.length() - 4) + "@celess.cn";
|
||||
String pwd = MD5Util.getMD5("123456789");
|
||||
User user = new User(email, pwd);
|
||||
@@ -202,7 +202,7 @@ public class UserControllerTest extends BaseTest {
|
||||
userReq.setEmailStatus(new Random().nextBoolean());
|
||||
userReq.setRole("admin");
|
||||
userReq.setDisplayName(randomStr(4));
|
||||
userReq.setEmail(randomStr().substring(0, 5) + "@celess.cn");
|
||||
userReq.setEmail(randomStr(5) + "@celess.cn");
|
||||
getMockData(put("/admin/user"), adminLogin(), userReq).andDo(result -> {
|
||||
Response<UserModel> response = getResponse(result, USER_MODEL_TYPE);
|
||||
assertEquals(SUCCESS.getCode(), response.getCode());
|
||||
|
||||
Reference in New Issue
Block a user