2016-03-31 12 views
1

Ich erstelle einen @RestController, also muss ich meine Validierung testen, so dass ich ein Modell mit erstellen und keinen Wert festlegen, so dass meine App eine Menge Fehler werfen wird, so muss ich jetzt Testen Sie diese Validierung.Spring Boot Integrationstest RestController Validierung

Ich schaffe diese Methode zu validieren:

@Test 
    public void selarAberturaMatriculaFail() throws Exception { 
     AberturaMatricula aberturaMatricula = new AberturaMatricula(); 
     MockHttpServletRequestBuilder requ = post("/ri/selo/abertura/").contentType(contentType).content(this.jsonWithClass(aberturaMatricula)); 
     mockMvc.perform(requ) 
       .andExpect(model().attributeHasErrors("cns")); 
    } 

aber ich habe diesen Fehler:

No ModelAndView found java.lang.AssertionError: No ModelAndView found

das ist meine Ruhe Methode:

@RestController 
@RequestMapping("/ri") 
public class RIController { 
@RequestMapping(value = "/selo/abertura/", method = RequestMethod.POST) 
    public AberturaMatricula selarAbertura(@RequestBody @Valid AberturaMatricula aberturaMatricula){ 

... 
    } 
} 

In meinem Modell Ich habe cns Eigentum und mehr ..

Antwort

Verwandte Themen