Code example for MockMvc

Methods: perform

0
        assertEquals(mv.getViewName(), "jsonView"); 
    } 
     
    @Test(expected = NestedServletException.class)
    public void testUpdateNonExistingService() throws Exception {
        this.mvc.perform(get("/updateRegisteredServiceEvaluationOrder.html")
                .param("id", "100").param("evaluationOrder", "200"))
                .andExpect(status().isBadRequest());
    } 
     
    @Test
    public void testDeleteServiceSuccessfully() throws Exception {
        final ModelAndView mv = this.mvc.perform(get("/deleteRegisteredService.html").param("id", "0"))
                .andExpect(status().isFound())
                .andReturn().getModelAndView();
        assertNotNull(mv);
        assertNotNull(mv.getModel().get("serviceName"));    
        assertEquals(mv.getModel().get("serviceName"), "HTTP and IMAP");        
    } 
     
Contextual code suggestions in your IDE  Get Codota for Java