2016-03-31 28 views
1

Bir @RestController oluşturuyorum, bu yüzden onaylamamı test etmem gerekiyor, bu yüzden bir model oluşturup herhangi bir değeri ayarlamam, bu yüzden uygulamam çok fazla hata fırlatacak, şimdi ihtiyacım var Bu doğrulamayı test edin.Yay önyükleme Entegrasyon testi RestController doğrulama

Ben doğrulamak için bu yöntemi oluşturun:

@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")); 
    } 

ama bu hata var:

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

bu benim istirahat yöntemidir:

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

... 
    } 
} 

Ben cns özellik ve daha fazlası ..

cevap

İlgili konular