### Question:
IMSController { @RequestMapping(value = "/api/bookings", method = RequestMethod.POST) @ResponseBody public ResponseEntity book(@RequestBody IMSBookingRequest payload) { BookResult bookResult; try { bookResult = bookingService.book(payload.getTargetingChannel(), payload.getDays(), payload.getPrice(), payload.getAdvID(), payload.getRequestCount()); } catch (Exception e) { LOGGER.error(e.getMessage()); return ResponseBuilder.buildError(e); } return ResponseBuilder.build(bookResult, HTTP_OK_CODE); }  @RequestMapping(value = "/ping", method = RequestMethod.GET) @ResponseBody ResponseEntity ping(); @RequestMapping(value = "/api/inventory/count", method = RequestMethod.POST) @ResponseBody ResponseEntity getInventory(@RequestBody IMSRequestQuery payload); @RequestMapping(value = "/api/users/count", method = RequestMethod.POST) @ResponseBody ResponseEntity getUserEstimate(@RequestBody IMSRequestQuery payload); @RequestMapping(value = "/api/bookings", method = RequestMethod.POST) @ResponseBody ResponseEntity book(@RequestBody IMSBookingRequest payload); @RequestMapping(value = "/api/bookings/{bookingId}", method = RequestMethod.DELETE) @ResponseBody ResponseEntity removeBooking(@PathVariable("bookingId") String bookingId); @RequestMapping(value = "/api/{advId}/bookings", method = RequestMethod.GET) @ResponseBody ResponseEntity getAdvID(@PathVariable("advId") String advId); @RequestMapping(value = "/api/bookings/{bookingId}", method = RequestMethod.GET) @ResponseBody ResponseEntity getBookingById(@PathVariable("bookingId") String bookingId); @RequestMapping(value = "/api/chart", method = RequestMethod.POST) @ResponseBody ResponseEntity chart(@RequestBody IMSRequestQuery payload);  }### Answer:
@Test public void book() throws Exception { IMSBookingRequest payload = new IMSBookingRequest(); TargetingChannel tc = new TargetingChannel(); tc.setG(Arrays.asList("g_f")); tc.setA(Arrays.asList("3")); payload.setTargetingChannel(tc); List<Range> ranges = new ArrayList<>(); Range r1 = new Range(); r1.setSt("2018-01-05"); r1.setEd("2018-01-05"); r1.setSh("0"); r1.setEh("23"); ranges.add(r1); payload.setDays(ranges); payload.setPrice(10D); payload.setAdvID("advid100"); payload.setRequestCount(10); when(bkSrv.book(payload.getTargetingChannel(), payload.getDays(), payload.getPrice(), payload.getAdvID(), payload.getRequestCount())) .thenReturn(new BookResult("bookId", 10L)); String reqJson = "{\"targetingChannel\": {\"g\": [\"g_f\"],\"a\": [\"3\"]},\"advId\": \"advid100\",\"price\": 10,\"days\": [{\"st\": \"2018-01-05\",\"ed\": \"2018-01-05\",\"sh\": 0,\"eh\": 23}],\"requestCount\": 10}"; MvcResult res = (MvcResult) mockMvc.perform(post("/api/bookings").contentType( MediaType.APPLICATION_JSON).content(reqJson)) .andReturn(); System.out.println("book " + res.toString()); }