@Test public void testSearchForFilesWhenSearchedTextIsNull() throws IOException { underTest.searchForFiles(null, session); verify(luceneEngine).search(null); verify(fileChecker).checkFilesExistsWithPairs(lucineResult); verify(session).setAttribute("searchResult", listOfLists); }
@ResponseBody @RequestMapping(value = "/search", method = RequestMethod.POST) public ResponseEntity<String> searchForFiles(@RequestParam("searchedText") final String searchedText, final HttpSession session) { List<List<String>> searchResult = new ArrayList<List<String>>(); ResponseEntity<String> result; HttpHeaders responseHeaders = setHeadersForJSON(); try { searchResult = searchForText(searchedText); addResultToSession(searchResult, session); if (!indexStatus.isReady()) { result = new ResponseEntity<String>(getJson(searchResult), responseHeaders, HttpStatus.PARTIAL_CONTENT); } else { result = new ResponseEntity<String>(getJson(searchResult), responseHeaders, HttpStatus.CREATED); } } catch (QueryCannotBeParsedException e) { logger.warn("Invalid query"); result = new ResponseEntity<String>(QUERY_ERROR_MESSAGE, HttpStatus.BAD_REQUEST); } return result; }
SearchController { @ResponseBody @RequestMapping(value = "/search", method = RequestMethod.POST) public ResponseEntity<String> searchForFiles(@RequestParam("searchedText") final String searchedText, final HttpSession session) { List<List<String>> searchResult = new ArrayList<List<String>>(); ResponseEntity<String> result; HttpHeaders responseHeaders = setHeadersForJSON(); try { searchResult = searchForText(searchedText); addResultToSession(searchResult, session); if (!indexStatus.isReady()) { result = new ResponseEntity<String>(getJson(searchResult), responseHeaders, HttpStatus.PARTIAL_CONTENT); } else { result = new ResponseEntity<String>(getJson(searchResult), responseHeaders, HttpStatus.CREATED); } } catch (QueryCannotBeParsedException e) { logger.warn("Invalid query"); result = new ResponseEntity<String>(QUERY_ERROR_MESSAGE, HttpStatus.BAD_REQUEST); } return result; } }
SearchController { @ResponseBody @RequestMapping(value = "/search", method = RequestMethod.POST) public ResponseEntity<String> searchForFiles(@RequestParam("searchedText") final String searchedText, final HttpSession session) { List<List<String>> searchResult = new ArrayList<List<String>>(); ResponseEntity<String> result; HttpHeaders responseHeaders = setHeadersForJSON(); try { searchResult = searchForText(searchedText); addResultToSession(searchResult, session); if (!indexStatus.isReady()) { result = new ResponseEntity<String>(getJson(searchResult), responseHeaders, HttpStatus.PARTIAL_CONTENT); } else { result = new ResponseEntity<String>(getJson(searchResult), responseHeaders, HttpStatus.CREATED); } } catch (QueryCannotBeParsedException e) { logger.warn("Invalid query"); result = new ResponseEntity<String>(QUERY_ERROR_MESSAGE, HttpStatus.BAD_REQUEST); } return result; }  }
SearchController { @ResponseBody @RequestMapping(value = "/search", method = RequestMethod.POST) public ResponseEntity<String> searchForFiles(@RequestParam("searchedText") final String searchedText, final HttpSession session) { List<List<String>> searchResult = new ArrayList<List<String>>(); ResponseEntity<String> result; HttpHeaders responseHeaders = setHeadersForJSON(); try { searchResult = searchForText(searchedText); addResultToSession(searchResult, session); if (!indexStatus.isReady()) { result = new ResponseEntity<String>(getJson(searchResult), responseHeaders, HttpStatus.PARTIAL_CONTENT); } else { result = new ResponseEntity<String>(getJson(searchResult), responseHeaders, HttpStatus.CREATED); } } catch (QueryCannotBeParsedException e) { logger.warn("Invalid query"); result = new ResponseEntity<String>(QUERY_ERROR_MESSAGE, HttpStatus.BAD_REQUEST); } return result; }  @RequestMapping(value = "/search", method = RequestMethod.GET) void searchAndZip(@RequestParam("text") final String searchedText, final HttpServletResponse resp); @ResponseBody @RequestMapping(value = "/search", method = RequestMethod.POST) ResponseEntity<String> searchForFiles(@RequestParam("searchedText") final String searchedText, final HttpSession session); }
SearchController { @ResponseBody @RequestMapping(value = "/search", method = RequestMethod.POST) public ResponseEntity<String> searchForFiles(@RequestParam("searchedText") final String searchedText, final HttpSession session) { List<List<String>> searchResult = new ArrayList<List<String>>(); ResponseEntity<String> result; HttpHeaders responseHeaders = setHeadersForJSON(); try { searchResult = searchForText(searchedText); addResultToSession(searchResult, session); if (!indexStatus.isReady()) { result = new ResponseEntity<String>(getJson(searchResult), responseHeaders, HttpStatus.PARTIAL_CONTENT); } else { result = new ResponseEntity<String>(getJson(searchResult), responseHeaders, HttpStatus.CREATED); } } catch (QueryCannotBeParsedException e) { logger.warn("Invalid query"); result = new ResponseEntity<String>(QUERY_ERROR_MESSAGE, HttpStatus.BAD_REQUEST); } return result; }  @RequestMapping(value = "/search", method = RequestMethod.GET) void searchAndZip(@RequestParam("text") final String searchedText, final HttpServletResponse resp); @ResponseBody @RequestMapping(value = "/search", method = RequestMethod.POST) ResponseEntity<String> searchForFiles(@RequestParam("searchedText") final String searchedText, final HttpSession session);  }