@Before @Transactional public void setUp() throws Exception { comment = repo.save(new Comment(ObjectId.get().toHexString(), 1L, "#foos")); this.parser = new JsonParser(mapper); mvc = MockMvcBuilders.webAppContextSetup(wac).alwaysDo(print()).build(); }
@Test public void testDeleteOne() throws Exception { MvcResult deleteComment = mvc.perform( delete("/inns/{innId}/comments/{comment}", comment.getInn(), comment.getId()) .principal(MockUser.mock())) .andExpect(request().asyncStarted()) .andReturn(); mvc.perform(asyncDispatch(deleteComment)).andExpect(status().isNoContent()); assertThat( "Object must not exist after deletion", repo.findOne(comment.getId()), is(nullValue(Comment.class))); }
@After public void tearDown() throws Exception { repo.delete(comment); }