### Question:
ReserveTruckCommandController { @PostMapping("/reservations") public ResponseEntity<Void> reserveTruck(@RequestBody ReserveTruckCommandDto commandDto, UriComponentsBuilder uriComponentsBuilder) { String confirmationNumber = service.reserveTruck(commandDto); Map<String, String> uriVariables = new HashMap<>(); uriVariables.put("confirmationNumber", confirmationNumber); URI locationUri = uriComponentsBuilder .path("/reservations/{confirmationNumber}") .buildAndExpand(uriVariables) .toUri(); return ResponseEntity.accepted() .location(locationUri) .build(); } ReserveTruckCommandController(ReserveTruckCommandService service); @PostMapping("/reservations") ResponseEntity<Void> reserveTruck(@RequestBody ReserveTruckCommandDto commandDto,
                                                  UriComponentsBuilder uriComponentsBuilder);  }### Answer:
@Test public void reserveTruck() throws Exception { doReturn("some-confirmation-number") .when(mockService) .reserveTruck(any()); ReserveTruckCommandDto commandDto = new ReserveTruckCommandDto( "some-truck-type", "some-metro-area", "some-pickup-store-id", "some-pickup-date", "some-dropoff-store-id", "some-dropoff-date", "some-customer-name", "some-credit-card-number"); byte[] commandDtoBytes = objectMapper.writeValueAsBytes(commandDto); mockMvc .perform( post("/reservations") .contentType(MediaType.APPLICATION_JSON_UTF8) .content(commandDtoBytes) ) .andExpect(status().isAccepted()) .andExpect(redirectedUrlPattern("**/reservations/some-confirmation-number")) .andReturn(); verify(mockService).reserveTruck(commandDto); }