@Test public void get_UnknownDestination() throws Exception { doThrow(new UnknownDestinationException("Hive", NAME)).when(service).getHiveDestination(NAME); mockMvc .perform(get(HIVE_DESTINATION_ENDPOINT)) .andExpect(status().isNotFound()) .andExpect(jsonPath("$.timestamp", isA(Long.TYPE))) .andExpect(jsonPath("$.success", is(false))) .andExpect(jsonPath("$.message", is("Hive destination for Road \"road1\" does not exist."))); }
@ApiOperation(value = "Returns details of a Hive destination") @ApiResponses({ @ApiResponse(code = 200, message = "Details of a Hive destination.", response = StandardResponse.class), @ApiResponse(code = 404, message = "Road or Hive destination not found.", response = StandardResponse.class) }) @GetMapping public HiveDestinationModel get(@PathVariable String name) throws UnknownRoadException, UnknownDestinationException { return hiveDestinationService.getHiveDestination(name); }
HiveDestinationController { @ApiOperation(value = "Returns details of a Hive destination") @ApiResponses({ @ApiResponse(code = 200, message = "Details of a Hive destination.", response = StandardResponse.class), @ApiResponse(code = 404, message = "Road or Hive destination not found.", response = StandardResponse.class) }) @GetMapping public HiveDestinationModel get(@PathVariable String name) throws UnknownRoadException, UnknownDestinationException { return hiveDestinationService.getHiveDestination(name); } }
HiveDestinationController { @ApiOperation(value = "Returns details of a Hive destination") @ApiResponses({ @ApiResponse(code = 200, message = "Details of a Hive destination.", response = StandardResponse.class), @ApiResponse(code = 404, message = "Road or Hive destination not found.", response = StandardResponse.class) }) @GetMapping public HiveDestinationModel get(@PathVariable String name) throws UnknownRoadException, UnknownDestinationException { return hiveDestinationService.getHiveDestination(name); }  }
HiveDestinationController { @ApiOperation(value = "Returns details of a Hive destination") @ApiResponses({ @ApiResponse(code = 200, message = "Details of a Hive destination.", response = StandardResponse.class), @ApiResponse(code = 404, message = "Road or Hive destination not found.", response = StandardResponse.class) }) @GetMapping public HiveDestinationModel get(@PathVariable String name) throws UnknownRoadException, UnknownDestinationException { return hiveDestinationService.getHiveDestination(name); }  @ApiOperation(value = "Returns details of a Hive destination") @ApiResponses({ @ApiResponse(code = 200, message = "Details of a Hive destination.", response = StandardResponse.class), @ApiResponse(code = 404, message = "Road or Hive destination not found.", response = StandardResponse.class) }) @GetMapping HiveDestinationModel get(@PathVariable String name); @ApiOperation(value = "Creates a new Hive destination") @ApiResponses({ @ApiResponse(code = 200, message = "Creation of a new Hive destination requested.", response = StandardResponse.class), @ApiResponse(code = 404, message = "Road not found.", response = StandardResponse.class), @ApiResponse(code = 409, message = "Hive destination already exists.", response = StandardResponse.class) }) @PreAuthorize("@paverAuthorisation.isAuthorised(authentication)") @PostMapping StandardResponse post(@PathVariable String name, @RequestBody HiveDestinationModel hiveDestinationModel); @ApiOperation(value = "Updates an existing Hive destination") @ApiResponses({ @ApiResponse(code = 200, message = "Update of existing Hive destination requested.", response = StandardResponse.class), @ApiResponse(code = 404, message = "Road or Hive destination not found.", response = StandardResponse.class) }) @PreAuthorize("@paverAuthorisation.isAuthorised(authentication)") @PutMapping StandardResponse put(@PathVariable String name, @RequestBody HiveDestinationModel hiveDestinationModel); @ApiOperation(value = "Deletes an existing Hive destination") @ApiResponses({ @ApiResponse(code = 200, message = "Deletion of existing Hive destination requested.", response = StandardResponse.class), @ApiResponse(code = 404, message = "Road or Hive destination not found.", response = StandardResponse.class) }) @PreAuthorize("@paverAuthorisation.isAuthorised(authentication)") @DeleteMapping StandardResponse delete(@PathVariable String name); @ExceptionHandler(UnknownRoadException.class) ResponseEntity<StandardResponse> unknownRoadExceptionHandler(HttpServletRequest request, Exception e); @ExceptionHandler(UnknownDestinationException.class) ResponseEntity<StandardResponse> unknownDestinationExceptionHandler(HttpServletRequest request, Exception e); @ExceptionHandler(AlreadyExistsException.class) ResponseEntity<StandardResponse> alreadyExistsExceptionHandler(HttpServletRequest request, Exception e); @ExceptionHandler(IllegalArgumentException.class) ResponseEntity<StandardResponse> illegalArgumentExceptionHandler(HttpServletRequest request, Exception e); @ExceptionHandler(InvalidLandingIntervalException.class) ResponseEntity<StandardResponse> invalidLandingIntervalExceptionHandler(
      HttpServletRequest request,
      Exception e); }
HiveDestinationController { @ApiOperation(value = "Returns details of a Hive destination") @ApiResponses({ @ApiResponse(code = 200, message = "Details of a Hive destination.", response = StandardResponse.class), @ApiResponse(code = 404, message = "Road or Hive destination not found.", response = StandardResponse.class) }) @GetMapping public HiveDestinationModel get(@PathVariable String name) throws UnknownRoadException, UnknownDestinationException { return hiveDestinationService.getHiveDestination(name); }  @ApiOperation(value = "Returns details of a Hive destination") @ApiResponses({ @ApiResponse(code = 200, message = "Details of a Hive destination.", response = StandardResponse.class), @ApiResponse(code = 404, message = "Road or Hive destination not found.", response = StandardResponse.class) }) @GetMapping HiveDestinationModel get(@PathVariable String name); @ApiOperation(value = "Creates a new Hive destination") @ApiResponses({ @ApiResponse(code = 200, message = "Creation of a new Hive destination requested.", response = StandardResponse.class), @ApiResponse(code = 404, message = "Road not found.", response = StandardResponse.class), @ApiResponse(code = 409, message = "Hive destination already exists.", response = StandardResponse.class) }) @PreAuthorize("@paverAuthorisation.isAuthorised(authentication)") @PostMapping StandardResponse post(@PathVariable String name, @RequestBody HiveDestinationModel hiveDestinationModel); @ApiOperation(value = "Updates an existing Hive destination") @ApiResponses({ @ApiResponse(code = 200, message = "Update of existing Hive destination requested.", response = StandardResponse.class), @ApiResponse(code = 404, message = "Road or Hive destination not found.", response = StandardResponse.class) }) @PreAuthorize("@paverAuthorisation.isAuthorised(authentication)") @PutMapping StandardResponse put(@PathVariable String name, @RequestBody HiveDestinationModel hiveDestinationModel); @ApiOperation(value = "Deletes an existing Hive destination") @ApiResponses({ @ApiResponse(code = 200, message = "Deletion of existing Hive destination requested.", response = StandardResponse.class), @ApiResponse(code = 404, message = "Road or Hive destination not found.", response = StandardResponse.class) }) @PreAuthorize("@paverAuthorisation.isAuthorised(authentication)") @DeleteMapping StandardResponse delete(@PathVariable String name); @ExceptionHandler(UnknownRoadException.class) ResponseEntity<StandardResponse> unknownRoadExceptionHandler(HttpServletRequest request, Exception e); @ExceptionHandler(UnknownDestinationException.class) ResponseEntity<StandardResponse> unknownDestinationExceptionHandler(HttpServletRequest request, Exception e); @ExceptionHandler(AlreadyExistsException.class) ResponseEntity<StandardResponse> alreadyExistsExceptionHandler(HttpServletRequest request, Exception e); @ExceptionHandler(IllegalArgumentException.class) ResponseEntity<StandardResponse> illegalArgumentExceptionHandler(HttpServletRequest request, Exception e); @ExceptionHandler(InvalidLandingIntervalException.class) ResponseEntity<StandardResponse> invalidLandingIntervalExceptionHandler(
      HttpServletRequest request,
      Exception e);  }