@Test public void person() throws Exception { String name = "test name"; String contactMethod = "contact method"; String solrResponse = "{ \"solrResponse\": \"this is a test response.\" }"; final String encodedContactMethodJoin = URLEncoder.encode("{!join from=id to=contact_method_ss}"); String query = "object_type_s:PERSON AND name:" + URLEncoder.encode(name) + " AND " + encodedContactMethodJoin + "value_parseable:" + URLEncoder.encode(contactMethod + "*"); String sort = "last_name_lcs ASC, first_name_lcs ASC"; query = query.replaceAll(" ", "+"); sort = sort.replaceAll(" ", "+"); expect(mockAuthentication.getName()).andReturn("user").atLeastOnce(); expect(mockExecuteSolrQuery.getResultsByPredefinedQuery(mockAuthentication, SolrCore.ADVANCED_SEARCH, query, 0, 10, sort, false)) .andReturn(solrResponse); replayAll(); MvcResult result = mockMvc .perform(get("/api/v1/plugin/search/personSearch?name=" + name + "&cm=" + contactMethod).principal(mockAuthentication)) .andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn(); verifyAll(); String jsonString = result.getResponse().getContentAsString(); log.debug("Got JSON: " + jsonString); assertEquals(solrResponse, jsonString); }
@RequestMapping(value = "/personSearch", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public String person(@RequestParam(value = "name", required = true) String personName, @RequestParam(value = "cm", required = true) String contactMethod, @RequestParam(value = "start", required = false, defaultValue = "0") int startRow, @RequestParam(value = "n", required = false, defaultValue = "10") int maxRows, Authentication authentication, HttpServletResponse httpResponse) throws MuleException, UnsupportedEncodingException { log.debug("User '{}' is searching for name '{}', contact method value: '{}'", authentication.getName(), personName, contactMethod); final String encodedContactMethodJoin = URLEncoder.encode("{!join from=id to=contact_method_ss}", "UTF-8"); String query = "object_type_s:PERSON AND name:" + URLEncoder.encode(personName, "UTF-8") + " AND " + encodedContactMethodJoin + "value_parseable:" + URLEncoder.encode(processSearchArgument(contactMethod), "UTF-8"); String sort = "last_name_lcs ASC, first_name_lcs ASC"; query = query.replaceAll(" ", "+"); sort = sort.replaceAll(" ", "+"); String results = getExecuteSolrQuery().getResultsByPredefinedQuery(authentication, SolrCore.ADVANCED_SEARCH, query, startRow, maxRows, sort, false); httpResponse.addHeader("X-JSON", results); return results; }
PersonSearchByNameAndContactMethodAPIController { @RequestMapping(value = "/personSearch", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public String person(@RequestParam(value = "name", required = true) String personName, @RequestParam(value = "cm", required = true) String contactMethod, @RequestParam(value = "start", required = false, defaultValue = "0") int startRow, @RequestParam(value = "n", required = false, defaultValue = "10") int maxRows, Authentication authentication, HttpServletResponse httpResponse) throws MuleException, UnsupportedEncodingException { log.debug("User '{}' is searching for name '{}', contact method value: '{}'", authentication.getName(), personName, contactMethod); final String encodedContactMethodJoin = URLEncoder.encode("{!join from=id to=contact_method_ss}", "UTF-8"); String query = "object_type_s:PERSON AND name:" + URLEncoder.encode(personName, "UTF-8") + " AND " + encodedContactMethodJoin + "value_parseable:" + URLEncoder.encode(processSearchArgument(contactMethod), "UTF-8"); String sort = "last_name_lcs ASC, first_name_lcs ASC"; query = query.replaceAll(" ", "+"); sort = sort.replaceAll(" ", "+"); String results = getExecuteSolrQuery().getResultsByPredefinedQuery(authentication, SolrCore.ADVANCED_SEARCH, query, startRow, maxRows, sort, false); httpResponse.addHeader("X-JSON", results); return results; } }
PersonSearchByNameAndContactMethodAPIController { @RequestMapping(value = "/personSearch", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public String person(@RequestParam(value = "name", required = true) String personName, @RequestParam(value = "cm", required = true) String contactMethod, @RequestParam(value = "start", required = false, defaultValue = "0") int startRow, @RequestParam(value = "n", required = false, defaultValue = "10") int maxRows, Authentication authentication, HttpServletResponse httpResponse) throws MuleException, UnsupportedEncodingException { log.debug("User '{}' is searching for name '{}', contact method value: '{}'", authentication.getName(), personName, contactMethod); final String encodedContactMethodJoin = URLEncoder.encode("{!join from=id to=contact_method_ss}", "UTF-8"); String query = "object_type_s:PERSON AND name:" + URLEncoder.encode(personName, "UTF-8") + " AND " + encodedContactMethodJoin + "value_parseable:" + URLEncoder.encode(processSearchArgument(contactMethod), "UTF-8"); String sort = "last_name_lcs ASC, first_name_lcs ASC"; query = query.replaceAll(" ", "+"); sort = sort.replaceAll(" ", "+"); String results = getExecuteSolrQuery().getResultsByPredefinedQuery(authentication, SolrCore.ADVANCED_SEARCH, query, startRow, maxRows, sort, false); httpResponse.addHeader("X-JSON", results); return results; }  }
PersonSearchByNameAndContactMethodAPIController { @RequestMapping(value = "/personSearch", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public String person(@RequestParam(value = "name", required = true) String personName, @RequestParam(value = "cm", required = true) String contactMethod, @RequestParam(value = "start", required = false, defaultValue = "0") int startRow, @RequestParam(value = "n", required = false, defaultValue = "10") int maxRows, Authentication authentication, HttpServletResponse httpResponse) throws MuleException, UnsupportedEncodingException { log.debug("User '{}' is searching for name '{}', contact method value: '{}'", authentication.getName(), personName, contactMethod); final String encodedContactMethodJoin = URLEncoder.encode("{!join from=id to=contact_method_ss}", "UTF-8"); String query = "object_type_s:PERSON AND name:" + URLEncoder.encode(personName, "UTF-8") + " AND " + encodedContactMethodJoin + "value_parseable:" + URLEncoder.encode(processSearchArgument(contactMethod), "UTF-8"); String sort = "last_name_lcs ASC, first_name_lcs ASC"; query = query.replaceAll(" ", "+"); sort = sort.replaceAll(" ", "+"); String results = getExecuteSolrQuery().getResultsByPredefinedQuery(authentication, SolrCore.ADVANCED_SEARCH, query, startRow, maxRows, sort, false); httpResponse.addHeader("X-JSON", results); return results; }  @RequestMapping(value = "/personSearch", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody String person(@RequestParam(value = "name", required = true) String personName,
            @RequestParam(value = "cm", required = true) String contactMethod,
            @RequestParam(value = "start", required = false, defaultValue = "0") int startRow,
            @RequestParam(value = "n", required = false, defaultValue = "10") int maxRows, Authentication authentication,
            HttpServletResponse httpResponse); ExecuteSolrQuery getExecuteSolrQuery(); void setExecuteSolrQuery(ExecuteSolrQuery executeSolrQuery); }
PersonSearchByNameAndContactMethodAPIController { @RequestMapping(value = "/personSearch", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public String person(@RequestParam(value = "name", required = true) String personName, @RequestParam(value = "cm", required = true) String contactMethod, @RequestParam(value = "start", required = false, defaultValue = "0") int startRow, @RequestParam(value = "n", required = false, defaultValue = "10") int maxRows, Authentication authentication, HttpServletResponse httpResponse) throws MuleException, UnsupportedEncodingException { log.debug("User '{}' is searching for name '{}', contact method value: '{}'", authentication.getName(), personName, contactMethod); final String encodedContactMethodJoin = URLEncoder.encode("{!join from=id to=contact_method_ss}", "UTF-8"); String query = "object_type_s:PERSON AND name:" + URLEncoder.encode(personName, "UTF-8") + " AND " + encodedContactMethodJoin + "value_parseable:" + URLEncoder.encode(processSearchArgument(contactMethod), "UTF-8"); String sort = "last_name_lcs ASC, first_name_lcs ASC"; query = query.replaceAll(" ", "+"); sort = sort.replaceAll(" ", "+"); String results = getExecuteSolrQuery().getResultsByPredefinedQuery(authentication, SolrCore.ADVANCED_SEARCH, query, startRow, maxRows, sort, false); httpResponse.addHeader("X-JSON", results); return results; }  @RequestMapping(value = "/personSearch", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody String person(@RequestParam(value = "name", required = true) String personName,
            @RequestParam(value = "cm", required = true) String contactMethod,
            @RequestParam(value = "start", required = false, defaultValue = "0") int startRow,
            @RequestParam(value = "n", required = false, defaultValue = "10") int maxRows, Authentication authentication,
            HttpServletResponse httpResponse); ExecuteSolrQuery getExecuteSolrQuery(); void setExecuteSolrQuery(ExecuteSolrQuery executeSolrQuery);  }