Code example for MockMvc

Methods: perform

0
        postRepository.save(post); 
    } 
 
    @Test 
    public void getEditBlogPage() throws Exception { 
        mockMvc.perform(get("/admin/blog/" + post.getAdminSlug() + "/edit")) 
                .andExpect(status().isOk()) 
                .andExpect(content().contentTypeCompatibleWith("text/html")) 
                .andExpect(content().string(containsString("Edit · Original Title"))); 
    } 
 
    @Test 
    public void redirectToPublishedPostAfterUpdate() throws Exception { 
        MockHttpServletRequestBuilder editPostRequest = createEditPostRequest(); 
 
        mockMvc.perform(editPostRequest) 
                .andExpect(status().isFound()) 
                .andExpect(result -> { 
                    String redirectedUrl = result.getResponse().getRedirectedUrl(); 
                    assertThat(redirectedUrl, startsWith("/blog/" + post.getPublicSlug()));