@Test public void testSearchGet() throws UnsupportedEncodingException { String queryNotFound = "not found"; String motivation = null; String date = null; String user = null; String page = null; ServiceResponse notFoundResponse = new ServiceResponse(Status.NOT_FOUND, null); String queryString = "http: Parameters params = new Parameters(queryNotFound, motivation, date, user); when(oaAnnotationSearchService.getAnnotationPage(params, queryString, page, null, null)).thenReturn(notFoundResponse); ResponseEntity<Map<String, Object>> responseEntity = controller.searchOAGet(queryNotFound, motivation, date, user, page, request); assertEquals(responseEntity.getStatusCode().NOT_FOUND, HttpStatus.NOT_FOUND); Map<String, Object> map = new HashMap<>(); ServiceResponse foundResponse = new ServiceResponse(Status.OK, map); String queryFound = "found"; params.setQuery(queryFound); when(oaAnnotationSearchService.getAnnotationPage(params, queryString, page, null, null)).thenReturn(foundResponse); responseEntity = controller.searchOAGet(queryFound, motivation, date, user, page, request); assertEquals(responseEntity.getStatusCode().OK, HttpStatus.OK); String queryEmpty = ""; try{ responseEntity = controller.searchOAGet(queryEmpty, motivation, date, user, page, request); }catch (SearchQueryException sqe){ assertNotNull(sqe); } params.setQuery(queryNotFound); when(oaAnnotationSearchService.getAnnotationPage(params, queryString, page, "within", null)).thenReturn(notFoundResponse); responseEntity = controller.searchOAGet(queryNotFound, motivation, date, user, page, request); assertEquals(responseEntity.getStatusCode().NOT_FOUND, HttpStatus.NOT_FOUND); when(oaAnnotationSearchService.getAnnotationPage(params, queryString, page, "within", "topic")).thenReturn(notFoundResponse); responseEntity = controller.searchOAGet(queryNotFound, motivation, date, user, page, request); assertEquals(responseEntity.getStatusCode().NOT_FOUND, HttpStatus.NOT_FOUND); }
@CrossOrigin @RequestMapping(value = OA_SEARCH_REQUEST_PATH, method = RequestMethod.GET) public ResponseEntity<Map<String, Object>> searchOAGet( @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_QUERY, required = false) String query, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_MOTIVATION, required = false) String motivation, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_DATE, required = false) String date, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_USER, required = false) String user, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_PAGE, required = false) String page, HttpServletRequest request) { String queryString = controllerUtility.createQueryString(request); String type = null; if (!controllerUtility.validateParameters(query, motivation, date, user)) { throw new SearchQueryException(AnnotationSearchConstants.EMPTY_QUERY_MESSAGE); } ServiceResponse<Map<String, Object>> serviceResponse = oaAnnotationSearchService .getAnnotationPage(new Parameters(query, motivation, date, user), queryString, page, null, type); Status serviceResponseStatus = serviceResponse.getStatus(); if (serviceResponseStatus.equals(Status.OK)) { return new ResponseEntity<Map<String, Object>>(serviceResponse.getObj(), controllerUtility.getResponseHeaders(), HttpStatus.OK); } if (serviceResponseStatus.equals(Status.NOT_FOUND)) { Map<String, Object> emptyMap = annotationUtils.returnEmptyResultSet(queryString, false, new PageParameters(), false); return new ResponseEntity<Map<String, Object>>(emptyMap, controllerUtility.getResponseHeaders(), HttpStatus.OK); } throw new SearchException(String.format("Unexpected service response status [%s]", serviceResponseStatus)); }
OAAnnotationSearchController { @CrossOrigin @RequestMapping(value = OA_SEARCH_REQUEST_PATH, method = RequestMethod.GET) public ResponseEntity<Map<String, Object>> searchOAGet( @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_QUERY, required = false) String query, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_MOTIVATION, required = false) String motivation, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_DATE, required = false) String date, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_USER, required = false) String user, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_PAGE, required = false) String page, HttpServletRequest request) { String queryString = controllerUtility.createQueryString(request); String type = null; if (!controllerUtility.validateParameters(query, motivation, date, user)) { throw new SearchQueryException(AnnotationSearchConstants.EMPTY_QUERY_MESSAGE); } ServiceResponse<Map<String, Object>> serviceResponse = oaAnnotationSearchService .getAnnotationPage(new Parameters(query, motivation, date, user), queryString, page, null, type); Status serviceResponseStatus = serviceResponse.getStatus(); if (serviceResponseStatus.equals(Status.OK)) { return new ResponseEntity<Map<String, Object>>(serviceResponse.getObj(), controllerUtility.getResponseHeaders(), HttpStatus.OK); } if (serviceResponseStatus.equals(Status.NOT_FOUND)) { Map<String, Object> emptyMap = annotationUtils.returnEmptyResultSet(queryString, false, new PageParameters(), false); return new ResponseEntity<Map<String, Object>>(emptyMap, controllerUtility.getResponseHeaders(), HttpStatus.OK); } throw new SearchException(String.format("Unexpected service response status [%s]", serviceResponseStatus)); } }
OAAnnotationSearchController { @CrossOrigin @RequestMapping(value = OA_SEARCH_REQUEST_PATH, method = RequestMethod.GET) public ResponseEntity<Map<String, Object>> searchOAGet( @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_QUERY, required = false) String query, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_MOTIVATION, required = false) String motivation, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_DATE, required = false) String date, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_USER, required = false) String user, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_PAGE, required = false) String page, HttpServletRequest request) { String queryString = controllerUtility.createQueryString(request); String type = null; if (!controllerUtility.validateParameters(query, motivation, date, user)) { throw new SearchQueryException(AnnotationSearchConstants.EMPTY_QUERY_MESSAGE); } ServiceResponse<Map<String, Object>> serviceResponse = oaAnnotationSearchService .getAnnotationPage(new Parameters(query, motivation, date, user), queryString, page, null, type); Status serviceResponseStatus = serviceResponse.getStatus(); if (serviceResponseStatus.equals(Status.OK)) { return new ResponseEntity<Map<String, Object>>(serviceResponse.getObj(), controllerUtility.getResponseHeaders(), HttpStatus.OK); } if (serviceResponseStatus.equals(Status.NOT_FOUND)) { Map<String, Object> emptyMap = annotationUtils.returnEmptyResultSet(queryString, false, new PageParameters(), false); return new ResponseEntity<Map<String, Object>>(emptyMap, controllerUtility.getResponseHeaders(), HttpStatus.OK); } throw new SearchException(String.format("Unexpected service response status [%s]", serviceResponseStatus)); } @Autowired  OAAnnotationSearchController(OAAnnotationSearchService oaAnnotationSearchService,
			AnnotationAutocompleteService annotationAutocompleteService); }
OAAnnotationSearchController { @CrossOrigin @RequestMapping(value = OA_SEARCH_REQUEST_PATH, method = RequestMethod.GET) public ResponseEntity<Map<String, Object>> searchOAGet( @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_QUERY, required = false) String query, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_MOTIVATION, required = false) String motivation, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_DATE, required = false) String date, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_USER, required = false) String user, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_PAGE, required = false) String page, HttpServletRequest request) { String queryString = controllerUtility.createQueryString(request); String type = null; if (!controllerUtility.validateParameters(query, motivation, date, user)) { throw new SearchQueryException(AnnotationSearchConstants.EMPTY_QUERY_MESSAGE); } ServiceResponse<Map<String, Object>> serviceResponse = oaAnnotationSearchService .getAnnotationPage(new Parameters(query, motivation, date, user), queryString, page, null, type); Status serviceResponseStatus = serviceResponse.getStatus(); if (serviceResponseStatus.equals(Status.OK)) { return new ResponseEntity<Map<String, Object>>(serviceResponse.getObj(), controllerUtility.getResponseHeaders(), HttpStatus.OK); } if (serviceResponseStatus.equals(Status.NOT_FOUND)) { Map<String, Object> emptyMap = annotationUtils.returnEmptyResultSet(queryString, false, new PageParameters(), false); return new ResponseEntity<Map<String, Object>>(emptyMap, controllerUtility.getResponseHeaders(), HttpStatus.OK); } throw new SearchException(String.format("Unexpected service response status [%s]", serviceResponseStatus)); } @Autowired  OAAnnotationSearchController(OAAnnotationSearchService oaAnnotationSearchService,
			AnnotationAutocompleteService annotationAutocompleteService); @CrossOrigin @RequestMapping(value = OA_SEARCH_REQUEST_PATH, method = RequestMethod.GET) ResponseEntity<Map<String, Object>> searchOAGet(
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_QUERY, required = false) String query,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_MOTIVATION, required = false) String motivation,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_DATE, required = false) String date,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_USER, required = false) String user,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_PAGE, required = false) String page,
			HttpServletRequest request); @CrossOrigin @RequestMapping(value = WITHIN_OA_SEARCH_REQUEST_PATH, method = RequestMethod.GET) ResponseEntity<Map<String, Object>> searchWithinOAGet(@PathVariable String withinId,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_QUERY, required = false) String query,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_MOTIVATION, required = false) String motivation,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_DATE, required = false) String date,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_USER, required = false) String user,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_PAGE, required = false) String page,
			HttpServletRequest request); @CrossOrigin @RequestMapping(value = OA_AUTOCOMPLETE_REQUEST_PATH, method = RequestMethod.GET) ResponseEntity<Map<String, Object>> autocompleteGet(
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_QUERY, required = true) String query,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_MOTIVATION, required = false) String motivation,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_DATE, required = false) String date,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_USER, required = false) String user,
			@RequestParam(value = PARAM_MIN, required = false) String min, HttpServletRequest request); @CrossOrigin @RequestMapping(value = WITHIN_OA_AUTOCOMPLETE_REQUEST_PATH, method = RequestMethod.GET) ResponseEntity<Map<String, Object>> autocompleteWithinGet(@PathVariable String withinId,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_QUERY, required = true) String query,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_MOTIVATION, required = false) String motivation,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_DATE, required = false) String date,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_USER, required = false) String user,
			@RequestParam(value = PARAM_MIN, required = false) String min, HttpServletRequest request); }
OAAnnotationSearchController { @CrossOrigin @RequestMapping(value = OA_SEARCH_REQUEST_PATH, method = RequestMethod.GET) public ResponseEntity<Map<String, Object>> searchOAGet( @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_QUERY, required = false) String query, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_MOTIVATION, required = false) String motivation, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_DATE, required = false) String date, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_USER, required = false) String user, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_PAGE, required = false) String page, HttpServletRequest request) { String queryString = controllerUtility.createQueryString(request); String type = null; if (!controllerUtility.validateParameters(query, motivation, date, user)) { throw new SearchQueryException(AnnotationSearchConstants.EMPTY_QUERY_MESSAGE); } ServiceResponse<Map<String, Object>> serviceResponse = oaAnnotationSearchService .getAnnotationPage(new Parameters(query, motivation, date, user), queryString, page, null, type); Status serviceResponseStatus = serviceResponse.getStatus(); if (serviceResponseStatus.equals(Status.OK)) { return new ResponseEntity<Map<String, Object>>(serviceResponse.getObj(), controllerUtility.getResponseHeaders(), HttpStatus.OK); } if (serviceResponseStatus.equals(Status.NOT_FOUND)) { Map<String, Object> emptyMap = annotationUtils.returnEmptyResultSet(queryString, false, new PageParameters(), false); return new ResponseEntity<Map<String, Object>>(emptyMap, controllerUtility.getResponseHeaders(), HttpStatus.OK); } throw new SearchException(String.format("Unexpected service response status [%s]", serviceResponseStatus)); } @Autowired  OAAnnotationSearchController(OAAnnotationSearchService oaAnnotationSearchService,
			AnnotationAutocompleteService annotationAutocompleteService); @CrossOrigin @RequestMapping(value = OA_SEARCH_REQUEST_PATH, method = RequestMethod.GET) ResponseEntity<Map<String, Object>> searchOAGet(
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_QUERY, required = false) String query,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_MOTIVATION, required = false) String motivation,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_DATE, required = false) String date,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_USER, required = false) String user,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_PAGE, required = false) String page,
			HttpServletRequest request); @CrossOrigin @RequestMapping(value = WITHIN_OA_SEARCH_REQUEST_PATH, method = RequestMethod.GET) ResponseEntity<Map<String, Object>> searchWithinOAGet(@PathVariable String withinId,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_QUERY, required = false) String query,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_MOTIVATION, required = false) String motivation,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_DATE, required = false) String date,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_USER, required = false) String user,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_PAGE, required = false) String page,
			HttpServletRequest request); @CrossOrigin @RequestMapping(value = OA_AUTOCOMPLETE_REQUEST_PATH, method = RequestMethod.GET) ResponseEntity<Map<String, Object>> autocompleteGet(
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_QUERY, required = true) String query,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_MOTIVATION, required = false) String motivation,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_DATE, required = false) String date,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_USER, required = false) String user,
			@RequestParam(value = PARAM_MIN, required = false) String min, HttpServletRequest request); @CrossOrigin @RequestMapping(value = WITHIN_OA_AUTOCOMPLETE_REQUEST_PATH, method = RequestMethod.GET) ResponseEntity<Map<String, Object>> autocompleteWithinGet(@PathVariable String withinId,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_QUERY, required = true) String query,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_MOTIVATION, required = false) String motivation,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_DATE, required = false) String date,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_USER, required = false) String user,
			@RequestParam(value = PARAM_MIN, required = false) String min, HttpServletRequest request); static final String CONTROLLER_NAME; static final String PARAM_MIN; }