1 package org.onap.vid.controller;
3 import org.onap.vid.exceptions.GenericUncheckedException;
4 import org.onap.vid.model.ExceptionResponse;
5 import org.onap.vid.model.JobModel;
6 import org.onap.vid.services.BulkInstantiationService;
7 import org.springframework.beans.factory.annotation.Autowired;
8 import org.springframework.http.ResponseEntity;
9 import org.springframework.web.bind.annotation.*;
11 import javax.ws.rs.WebApplicationException;
12 import java.util.UUID;
14 import static org.springframework.http.HttpStatus.BAD_REQUEST;
17 @RequestMapping("asyncForTests")
18 public class AsyncControllerForTests extends VidRestrictedBaseController {
20 private BulkInstantiationService bulkInstantiationService;
23 public AsyncControllerForTests(BulkInstantiationService bulkInstantiationService) {
24 this.bulkInstantiationService = bulkInstantiationService;
27 @RequestMapping(value = "/job/{uuid}", method = RequestMethod.GET)
28 public JobModel getJob(@PathVariable UUID uuid) {
29 return bulkInstantiationService.getJob(uuid);
32 @RequestMapping(value = "/error", method = RequestMethod.GET)
33 public void throwError() {
34 throw new GenericUncheckedException("dummy error");
37 @ExceptionHandler({IllegalArgumentException.class})
38 @ResponseStatus(value=BAD_REQUEST)
39 private ExceptionResponse exceptionHandlerBadRequest(Exception e) {
40 return ControllersUtils.handleException(e, LOGGER);
43 @ExceptionHandler(WebApplicationException.class)
44 private ResponseEntity webApplicationExceptionHandler(WebApplicationException e) {
45 return ControllersUtils.handleWebApplicationException(e, LOGGER);