@Test public void testPost() { VehiculoController vController = new VehiculoController(); Vehiculo v = new Vehiculo(); ResponseEntity response = vController.crear(v); assertEquals( 400 , response.getStatusCode() ); }
@RequestMapping(value = "/", method = RequestMethod.POST) public ResponseEntity crear(@RequestBody Vehiculo vehiculo ) { ResponseEntity response = new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); try { if (vehiculoService.crear(vehiculo)) { response = new ResponseEntity(vehiculo, HttpStatus.CREATED); } else { response = new ResponseEntity(HttpStatus.CONFLICT); } } catch (VehiculoException e) { response = new ResponseEntity(e.getMessage(), HttpStatus.CONFLICT ); } catch (Exception e) { e.printStackTrace(); response = new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); } return response; }
VehiculoController { @RequestMapping(value = "/", method = RequestMethod.POST) public ResponseEntity crear(@RequestBody Vehiculo vehiculo ) { ResponseEntity response = new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); try { if (vehiculoService.crear(vehiculo)) { response = new ResponseEntity(vehiculo, HttpStatus.CREATED); } else { response = new ResponseEntity(HttpStatus.CONFLICT); } } catch (VehiculoException e) { response = new ResponseEntity(e.getMessage(), HttpStatus.CONFLICT ); } catch (Exception e) { e.printStackTrace(); response = new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); } return response; } }
VehiculoController { @RequestMapping(value = "/", method = RequestMethod.POST) public ResponseEntity crear(@RequestBody Vehiculo vehiculo ) { ResponseEntity response = new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); try { if (vehiculoService.crear(vehiculo)) { response = new ResponseEntity(vehiculo, HttpStatus.CREATED); } else { response = new ResponseEntity(HttpStatus.CONFLICT); } } catch (VehiculoException e) { response = new ResponseEntity(e.getMessage(), HttpStatus.CONFLICT ); } catch (Exception e) { e.printStackTrace(); response = new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); } return response; }  }
VehiculoController { @RequestMapping(value = "/", method = RequestMethod.POST) public ResponseEntity crear(@RequestBody Vehiculo vehiculo ) { ResponseEntity response = new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); try { if (vehiculoService.crear(vehiculo)) { response = new ResponseEntity(vehiculo, HttpStatus.CREATED); } else { response = new ResponseEntity(HttpStatus.CONFLICT); } } catch (VehiculoException e) { response = new ResponseEntity(e.getMessage(), HttpStatus.CONFLICT ); } catch (Exception e) { e.printStackTrace(); response = new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); } return response; }  @RequestMapping(value = "", method = RequestMethod.GET) ResponseEntity<ArrayList<Vehiculo>> listar(); @RequestMapping(value = "/{id}", method = RequestMethod.GET) ResponseEntity<Vehiculo> detalle(@PathVariable int id); @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) ResponseEntity eliminar(@PathVariable int id); @RequestMapping(value = "/", method = RequestMethod.POST) ResponseEntity crear(@RequestBody Vehiculo vehiculo ); @RequestMapping(value = "{id}", method = RequestMethod.PUT) ResponseEntity modificar(@PathVariable int id, @RequestBody Vehiculo vehiculo); }
VehiculoController { @RequestMapping(value = "/", method = RequestMethod.POST) public ResponseEntity crear(@RequestBody Vehiculo vehiculo ) { ResponseEntity response = new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); try { if (vehiculoService.crear(vehiculo)) { response = new ResponseEntity(vehiculo, HttpStatus.CREATED); } else { response = new ResponseEntity(HttpStatus.CONFLICT); } } catch (VehiculoException e) { response = new ResponseEntity(e.getMessage(), HttpStatus.CONFLICT ); } catch (Exception e) { e.printStackTrace(); response = new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR); } return response; }  @RequestMapping(value = "", method = RequestMethod.GET) ResponseEntity<ArrayList<Vehiculo>> listar(); @RequestMapping(value = "/{id}", method = RequestMethod.GET) ResponseEntity<Vehiculo> detalle(@PathVariable int id); @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) ResponseEntity eliminar(@PathVariable int id); @RequestMapping(value = "/", method = RequestMethod.POST) ResponseEntity crear(@RequestBody Vehiculo vehiculo ); @RequestMapping(value = "{id}", method = RequestMethod.PUT) ResponseEntity modificar(@PathVariable int id, @RequestBody Vehiculo vehiculo);  }