use of com.nixmash.blog.mvc.dto.JsonPostDTO in project nixmash-blog by mintster.
the class AdminPostsControllerTests method saveAndContinueWithBadData_PostUnchanged.
@Test
public void saveAndContinueWithBadData_PostUnchanged() throws Exception {
Post post = postService.getPostById(8L);
String originalTitle = post.getPostTitle();
JsonPostDTO jsonPostDTO = MvcTestUtil.createJsonPostDTO(post);
jsonPostDTO.setPostTitle("saveAndContinueWithBadData_PostUnchanged");
jsonPostDTO.setPostContent(StringUtils.EMPTY);
logger.info(this.json.write(jsonPostDTO).getJson());
mvc.perform(post("/admin/posts/archive").content(json.write(jsonPostDTO).getJson()).contentType(APPLICATION_JSON_UTF8).with(csrf())).andExpect(content().contentTypeCompatibleWith(APPLICATION_JSON_UTF8)).andExpect(content().string(containsString("ERROR")));
post = postService.getPostById(8L);
assertEquals(post.getPostTitle(), originalTitle);
}
use of com.nixmash.blog.mvc.dto.JsonPostDTO in project nixmash-blog by mintster.
the class AdminPostsControllerTests method saveAndContinueWithValidData_UpdatesPost.
@Test
public void saveAndContinueWithValidData_UpdatesPost() throws Exception {
String newTitle = "saveAndContinueWithValidData_UpdatesPost";
Post post = postService.getPostById(8L);
JsonPostDTO jsonPostDTO = MvcTestUtil.createJsonPostDTO(post);
jsonPostDTO.setPostTitle(newTitle);
mvc.perform(post("/admin/posts/archive").content(json.write(jsonPostDTO).getJson()).contentType(APPLICATION_JSON_UTF8).with(csrf())).andExpect(content().string(containsString("SUCCESS")));
post = postService.getPostById(8L);
assertEquals(post.getPostTitle(), newTitle);
File azFile = new File(azTestFileName);
String contents = FileUtils.readFileToString(azFile);
assertFalse(contents.contains(newTitle));
}
Aggregations