@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); when(textSearchService.getTextPositions(queryNotFound, "http: ResponseEntity<Map<String, Object>> responseEntity = controller.searchTextOAGet(queryNotFound, page, null, null,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"; when(textSearchService.getTextPositions(queryFound, "http: responseEntity = controller.searchTextOAGet(queryFound, page, null, null,request); assertEquals(responseEntity.getStatusCode().OK, HttpStatus.OK); String queryEmpty = ""; try{ responseEntity = controller.searchTextOAGet(queryEmpty, page, null, null,request); }catch (SearchQueryException sqe){ assertNotNull(sqe); } }
@CrossOrigin @RequestMapping(value = OA_TEXT_SEARCH_REQUEST_PATH, method = RequestMethod.GET) public ResponseEntity<Map<String, Object>> searchTextOAGet( @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_QUERY, required = true) String query, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_PAGE, required = false) String page, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_WIDTH, required = false) String width, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_HEIGHT, required = false) String height, HttpServletRequest request) { String queryString = controllerUtility.createQueryString(request); String widthHeight = null; if (!StringUtils.isEmpty(width) && !StringUtils.isEmpty(height)) { widthHeight = width + "|" + height; } if (StringUtils.isEmpty(query)) { throw new SearchQueryException("Please enter a query to search"); } ServiceResponse<Map<String, Object>> serviceResponse = textSearchService.getTextPositions(query, queryString, false, page, false, null, widthHeight); 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 = textUtils.returnEmptyResultSet(queryString, false, new PageParameters(), true); return new ResponseEntity<Map<String, Object>>(emptyMap, controllerUtility.getResponseHeaders(), HttpStatus.OK); } throw new SearchException(String.format("Unexpected service response status [%s]", serviceResponseStatus)); }
OATextSearchController { @CrossOrigin @RequestMapping(value = OA_TEXT_SEARCH_REQUEST_PATH, method = RequestMethod.GET) public ResponseEntity<Map<String, Object>> searchTextOAGet( @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_QUERY, required = true) String query, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_PAGE, required = false) String page, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_WIDTH, required = false) String width, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_HEIGHT, required = false) String height, HttpServletRequest request) { String queryString = controllerUtility.createQueryString(request); String widthHeight = null; if (!StringUtils.isEmpty(width) && !StringUtils.isEmpty(height)) { widthHeight = width + "|" + height; } if (StringUtils.isEmpty(query)) { throw new SearchQueryException("Please enter a query to search"); } ServiceResponse<Map<String, Object>> serviceResponse = textSearchService.getTextPositions(query, queryString, false, page, false, null, widthHeight); 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 = textUtils.returnEmptyResultSet(queryString, false, new PageParameters(), true); return new ResponseEntity<Map<String, Object>>(emptyMap, controllerUtility.getResponseHeaders(), HttpStatus.OK); } throw new SearchException(String.format("Unexpected service response status [%s]", serviceResponseStatus)); } }
OATextSearchController { @CrossOrigin @RequestMapping(value = OA_TEXT_SEARCH_REQUEST_PATH, method = RequestMethod.GET) public ResponseEntity<Map<String, Object>> searchTextOAGet( @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_QUERY, required = true) String query, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_PAGE, required = false) String page, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_WIDTH, required = false) String width, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_HEIGHT, required = false) String height, HttpServletRequest request) { String queryString = controllerUtility.createQueryString(request); String widthHeight = null; if (!StringUtils.isEmpty(width) && !StringUtils.isEmpty(height)) { widthHeight = width + "|" + height; } if (StringUtils.isEmpty(query)) { throw new SearchQueryException("Please enter a query to search"); } ServiceResponse<Map<String, Object>> serviceResponse = textSearchService.getTextPositions(query, queryString, false, page, false, null, widthHeight); 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 = textUtils.returnEmptyResultSet(queryString, false, new PageParameters(), true); return new ResponseEntity<Map<String, Object>>(emptyMap, controllerUtility.getResponseHeaders(), HttpStatus.OK); } throw new SearchException(String.format("Unexpected service response status [%s]", serviceResponseStatus)); } @Autowired  OATextSearchController(TextSearchService textSearchService,
			AnnotationAutocompleteService annotationAutocompleteService); }
OATextSearchController { @CrossOrigin @RequestMapping(value = OA_TEXT_SEARCH_REQUEST_PATH, method = RequestMethod.GET) public ResponseEntity<Map<String, Object>> searchTextOAGet( @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_QUERY, required = true) String query, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_PAGE, required = false) String page, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_WIDTH, required = false) String width, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_HEIGHT, required = false) String height, HttpServletRequest request) { String queryString = controllerUtility.createQueryString(request); String widthHeight = null; if (!StringUtils.isEmpty(width) && !StringUtils.isEmpty(height)) { widthHeight = width + "|" + height; } if (StringUtils.isEmpty(query)) { throw new SearchQueryException("Please enter a query to search"); } ServiceResponse<Map<String, Object>> serviceResponse = textSearchService.getTextPositions(query, queryString, false, page, false, null, widthHeight); 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 = textUtils.returnEmptyResultSet(queryString, false, new PageParameters(), true); return new ResponseEntity<Map<String, Object>>(emptyMap, controllerUtility.getResponseHeaders(), HttpStatus.OK); } throw new SearchException(String.format("Unexpected service response status [%s]", serviceResponseStatus)); } @Autowired  OATextSearchController(TextSearchService textSearchService,
			AnnotationAutocompleteService annotationAutocompleteService); @CrossOrigin @RequestMapping(value = OA_TEXT_SEARCH_REQUEST_PATH, method = RequestMethod.GET) ResponseEntity<Map<String, Object>> searchTextOAGet(
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_QUERY, required = true) String query,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_PAGE, required = false) String page,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_WIDTH, required = false) String width,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_HEIGHT, required = false) String height,
			HttpServletRequest request); @CrossOrigin @RequestMapping(value = WITHIN_OA_TEXT_SEARCH_REQUEST_PATH, method = RequestMethod.GET) ResponseEntity<Map<String, Object>> searchTextWithinOAGet(@PathVariable String withinId,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_QUERY, required = true) String query,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_PAGE, required = false) String page,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_WIDTH, required = false) String width,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_HEIGHT, required = false) String height,
			HttpServletRequest request); @CrossOrigin @RequestMapping(value = OA_TEXT_AUTOCOMPLETE_REQUEST_PATH, method = RequestMethod.GET) ResponseEntity<Map<String, Object>> autocompleteTextOAGet(
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_QUERY, required = true) String query,
			@RequestParam(value = PARAM_MIN, required = false) String min, HttpServletRequest request); @CrossOrigin @RequestMapping(value = WITHIN_OA_TEXT_AUTOCOMPLETE_REQUEST_PATH, method = RequestMethod.GET) ResponseEntity<Map<String, Object>> autocompleteTextWithinOAGet(@PathVariable String withinId,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_QUERY, required = true) String query,
			@RequestParam(value = PARAM_MIN, required = false) String min, HttpServletRequest request); }
OATextSearchController { @CrossOrigin @RequestMapping(value = OA_TEXT_SEARCH_REQUEST_PATH, method = RequestMethod.GET) public ResponseEntity<Map<String, Object>> searchTextOAGet( @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_QUERY, required = true) String query, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_PAGE, required = false) String page, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_WIDTH, required = false) String width, @RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_HEIGHT, required = false) String height, HttpServletRequest request) { String queryString = controllerUtility.createQueryString(request); String widthHeight = null; if (!StringUtils.isEmpty(width) && !StringUtils.isEmpty(height)) { widthHeight = width + "|" + height; } if (StringUtils.isEmpty(query)) { throw new SearchQueryException("Please enter a query to search"); } ServiceResponse<Map<String, Object>> serviceResponse = textSearchService.getTextPositions(query, queryString, false, page, false, null, widthHeight); 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 = textUtils.returnEmptyResultSet(queryString, false, new PageParameters(), true); return new ResponseEntity<Map<String, Object>>(emptyMap, controllerUtility.getResponseHeaders(), HttpStatus.OK); } throw new SearchException(String.format("Unexpected service response status [%s]", serviceResponseStatus)); } @Autowired  OATextSearchController(TextSearchService textSearchService,
			AnnotationAutocompleteService annotationAutocompleteService); @CrossOrigin @RequestMapping(value = OA_TEXT_SEARCH_REQUEST_PATH, method = RequestMethod.GET) ResponseEntity<Map<String, Object>> searchTextOAGet(
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_QUERY, required = true) String query,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_PAGE, required = false) String page,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_WIDTH, required = false) String width,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_HEIGHT, required = false) String height,
			HttpServletRequest request); @CrossOrigin @RequestMapping(value = WITHIN_OA_TEXT_SEARCH_REQUEST_PATH, method = RequestMethod.GET) ResponseEntity<Map<String, Object>> searchTextWithinOAGet(@PathVariable String withinId,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_QUERY, required = true) String query,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_PAGE, required = false) String page,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_WIDTH, required = false) String width,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_HEIGHT, required = false) String height,
			HttpServletRequest request); @CrossOrigin @RequestMapping(value = OA_TEXT_AUTOCOMPLETE_REQUEST_PATH, method = RequestMethod.GET) ResponseEntity<Map<String, Object>> autocompleteTextOAGet(
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_QUERY, required = true) String query,
			@RequestParam(value = PARAM_MIN, required = false) String min, HttpServletRequest request); @CrossOrigin @RequestMapping(value = WITHIN_OA_TEXT_AUTOCOMPLETE_REQUEST_PATH, method = RequestMethod.GET) ResponseEntity<Map<String, Object>> autocompleteTextWithinOAGet(@PathVariable String withinId,
			@RequestParam(value = AnnotationSearchConstants.PARAM_FIELD_QUERY, required = true) String query,
			@RequestParam(value = PARAM_MIN, required = false) String min, HttpServletRequest request); static final String CONTROLLER_NAME; static final String PARAM_MIN; }