@Test public void testAutocompleteGet() throws UnsupportedEncodingException { String queryNotFound = "not found"; String motivation = null; String date = null; String user = null; String min = null; ServiceResponse notFoundResponse = new ServiceResponse(Status.NOT_FOUND, null); when(annotationAutocompleteService.getTerms(queryNotFound, motivation,date, user, min,"http: ResponseEntity<Map<String, Object>> responseEntity = controller.autocompleteGet(queryNotFound, motivation, date, user, min, 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(annotationAutocompleteService.getTerms(queryFound, motivation,date, user, min,"http: responseEntity = controller.autocompleteGet(queryFound, motivation, date, user, min, request); assertEquals(responseEntity.getStatusCode().OK, HttpStatus.OK); }
@CrossOrigin @RequestMapping(value = W3C_AUTOCOMPLETE_REQUEST_PATH, method = RequestMethod.GET) public 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) { String queryString = controllerUtility.createQueryString(request); ServiceResponse<Map<String, Object>> serviceResponse = annotationAutocompleteService.getTerms(query, motivation, date, user, min, queryString, true, null); 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.returnEmptyAutocompleteResultSet(queryString, motivation, date, user); return new ResponseEntity<Map<String, Object>>(emptyMap, controllerUtility.getResponseHeaders(), HttpStatus.OK); } throw new SearchException(String.format("Unexpected service response status [%s]", serviceResponseStatus)); }
W3CAnnotationSearchController { @CrossOrigin @RequestMapping(value = W3C_AUTOCOMPLETE_REQUEST_PATH, method = RequestMethod.GET) public 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) { String queryString = controllerUtility.createQueryString(request); ServiceResponse<Map<String, Object>> serviceResponse = annotationAutocompleteService.getTerms(query, motivation, date, user, min, queryString, true, null); 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.returnEmptyAutocompleteResultSet(queryString, motivation, date, user); return new ResponseEntity<Map<String, Object>>(emptyMap, controllerUtility.getResponseHeaders(), HttpStatus.OK); } throw new SearchException(String.format("Unexpected service response status [%s]", serviceResponseStatus)); } }
W3CAnnotationSearchController { @CrossOrigin @RequestMapping(value = W3C_AUTOCOMPLETE_REQUEST_PATH, method = RequestMethod.GET) public 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) { String queryString = controllerUtility.createQueryString(request); ServiceResponse<Map<String, Object>> serviceResponse = annotationAutocompleteService.getTerms(query, motivation, date, user, min, queryString, true, null); 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.returnEmptyAutocompleteResultSet(queryString, motivation, date, user); return new ResponseEntity<Map<String, Object>>(emptyMap, controllerUtility.getResponseHeaders(), HttpStatus.OK); } throw new SearchException(String.format("Unexpected service response status [%s]", serviceResponseStatus)); } @Autowired  W3CAnnotationSearchController(W3CAnnotationSearchService w3cAnnotationSearchService,
			AnnotationAutocompleteService annotationAutocompleteService); }
W3CAnnotationSearchController { @CrossOrigin @RequestMapping(value = W3C_AUTOCOMPLETE_REQUEST_PATH, method = RequestMethod.GET) public 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) { String queryString = controllerUtility.createQueryString(request); ServiceResponse<Map<String, Object>> serviceResponse = annotationAutocompleteService.getTerms(query, motivation, date, user, min, queryString, true, null); 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.returnEmptyAutocompleteResultSet(queryString, motivation, date, user); return new ResponseEntity<Map<String, Object>>(emptyMap, controllerUtility.getResponseHeaders(), HttpStatus.OK); } throw new SearchException(String.format("Unexpected service response status [%s]", serviceResponseStatus)); } @Autowired  W3CAnnotationSearchController(W3CAnnotationSearchService w3cAnnotationSearchService,
			AnnotationAutocompleteService annotationAutocompleteService); @CrossOrigin @RequestMapping(value = W3C_SEARCH_REQUEST_PATH, method = RequestMethod.GET) ResponseEntity<Map<String, Object>> searchGet(
			@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_W3C_SEARCH_REQUEST_PATH, method = RequestMethod.GET) ResponseEntity<Map<String, Object>> searchWithinGet(@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 = W3C_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_W3C_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); }
W3CAnnotationSearchController { @CrossOrigin @RequestMapping(value = W3C_AUTOCOMPLETE_REQUEST_PATH, method = RequestMethod.GET) public 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) { String queryString = controllerUtility.createQueryString(request); ServiceResponse<Map<String, Object>> serviceResponse = annotationAutocompleteService.getTerms(query, motivation, date, user, min, queryString, true, null); 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.returnEmptyAutocompleteResultSet(queryString, motivation, date, user); return new ResponseEntity<Map<String, Object>>(emptyMap, controllerUtility.getResponseHeaders(), HttpStatus.OK); } throw new SearchException(String.format("Unexpected service response status [%s]", serviceResponseStatus)); } @Autowired  W3CAnnotationSearchController(W3CAnnotationSearchService w3cAnnotationSearchService,
			AnnotationAutocompleteService annotationAutocompleteService); @CrossOrigin @RequestMapping(value = W3C_SEARCH_REQUEST_PATH, method = RequestMethod.GET) ResponseEntity<Map<String, Object>> searchGet(
			@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_W3C_SEARCH_REQUEST_PATH, method = RequestMethod.GET) ResponseEntity<Map<String, Object>> searchWithinGet(@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 = W3C_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_W3C_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; }