@Test public void createCar() throws Exception { Car car = getCar(); mvc.perform( post(new URI("/cars")) .content(json.write(car).getJson()) .contentType(MediaType.APPLICATION_JSON_UTF8) .accept(MediaType.APPLICATION_JSON_UTF8)) .andExpect(status().isCreated()); }
@PostMapping ResponseEntity<?> post(@Valid @RequestBody Car car) throws URISyntaxException { Resource<Car> resource = assembler.toResource(new Car()); return ResponseEntity.created(new URI(resource.getId().expand().getHref())).body(resource); }
CarController { @PostMapping ResponseEntity<?> post(@Valid @RequestBody Car car) throws URISyntaxException { Resource<Car> resource = assembler.toResource(new Car()); return ResponseEntity.created(new URI(resource.getId().expand().getHref())).body(resource); } }
CarController { @PostMapping ResponseEntity<?> post(@Valid @RequestBody Car car) throws URISyntaxException { Resource<Car> resource = assembler.toResource(new Car()); return ResponseEntity.created(new URI(resource.getId().expand().getHref())).body(resource); } CarController(CarService carService, CarResourceAssembler assembler); }
CarController { @PostMapping ResponseEntity<?> post(@Valid @RequestBody Car car) throws URISyntaxException { Resource<Car> resource = assembler.toResource(new Car()); return ResponseEntity.created(new URI(resource.getId().expand().getHref())).body(resource); } CarController(CarService carService, CarResourceAssembler assembler);  }
CarController { @PostMapping ResponseEntity<?> post(@Valid @RequestBody Car car) throws URISyntaxException { Resource<Car> resource = assembler.toResource(new Car()); return ResponseEntity.created(new URI(resource.getId().expand().getHref())).body(resource); } CarController(CarService carService, CarResourceAssembler assembler);   }