probleme pour se rendre a controleur
bonjour a tous , j'ai un petit probleme avec mon test
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
@Test
public void deleteDevTest() throws Exception {
doTheInsert();
// Setup Spring test in standalone mode
this.mockMvc = MockMvcBuilders.standaloneSetup(deviceRestController).alwaysDo(MockMvcResultHandlers.print()).build();
mockMvc.perform(delete("/rest/dev/{deleteId}","test")).andExpect(status().isNoContent());
// RETRIEVE
Device found = dao.find("test");
assertNull(found);
} |
ou
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
@Test
public void deleteDeviceTest() throws Exception {
doTheInsert();
// Setup Spring test in standalone mode
this.mockMvc = MockMvcBuilders.standaloneSetup(deviceRestController).alwaysDo(MockMvcResultHandlers.print()).build();
mockMvc.perform(delete("/rest/dev/{deleteId}","deleteId").contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)).andExpect(status().isNoContent());
// RETRIEVE
Device found = dao.find("test");
assertNull(found);
}<div class="bbcode_container">
<div class="bbcode_description">Code:</div>
<hr /><code class="bbcode_code"> et mon controlleur que je veux tester.</code><hr />
</div> @RequestMapping(value = "/rest/dev/{deleteId}", method = RequestMethod.DELETE , headers = { "content-type=application/json" })
@ResponseBody
public ResponseEntity<String> delete(@PathVariable String deviceId) {
if(deviceId == null ) {
return new ResponseEntity<String>(HttpStatus.BAD_REQUEST);
}
LOGGER.debug("Start the methode deleteDevice");
Device device = this.getBusinessServices().getDeviceService().findDevice(deviceId, true);
if (device != null){
this.getBusinessServices().getDeviceService().deleteDevice(device);
} else {
return new ResponseEntity<String>(HttpStatus.NOT_FOUND);
}
return new ResponseEntity<String>(HttpStatus.NO_CONTENT);
} |
Citation:
MockHttpServletRequest:
HTTP Method = DELETE
Request URI = /rest/devices/deleteId
Parameters = {}
Headers = {Content-Type=[application/json], Accept=[application/json]}
Handler:
Type = com.trilliantnetworks.uhes.ui.rest.controller.DeviceRestController
Method = public org.springframework.http.ResponseEntity<java.lang.String> com.trilliantnetworks.uhes.ui.rest.controller.DeviceRestController.delete(java.lang.String)
Async:
Async started = false
Async result = null
Resolved Exception:
Type = org.springframework.web.bind.ServletRequestBindingException
ModelAndView:
View name = null
View = null
Model = null
FlashMap:
MockHttpServletResponse:
Status = 400
Error message = null
Headers = {}
Content type = null
Body =
Forwarded URL = null
Redirected URL = null
Cookies = []
J'arrrive pas a me rendre sur le controlleur avec le pas a pas pour debugger. Ca plante avant de rentre sur le contrôleur. ca me dit que ma requete n'est pas bien construite et pourtant...