@Test public void getArtifactsSearchResult() { DbSearch search = new DbSearch(); List<String> artifactIds = new ArrayList<>(); artifactIds.add("testSearch_artifact_id_1"); artifactIds.add("testSearch_artifact_id_2"); search.setArtifacts(artifactIds); when(repositoryHandler.getSearchResult(eq("testSearch"), (FiltersHolder) anyObject())).thenReturn(search); final WebResource resource = client().resource("/" + ServerAPI.SEARCH_RESOURCE + "/testSearch"); final ClientResponse response = resource.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); assertNotNull(response); assertEquals(HttpStatus.OK_200, response.getStatus()); final String results = response.getEntity(new GenericType<String>() { }); assertEquals("{\"modules\":null,\"artifacts\":[\"testSearch_artifact_id_1\",\"testSearch_artifact_id_2\"]}", results); }
@GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{searchWord}") public Response getSearchResult(@PathParam("searchWord") final String searchWord, @Context final UriInfo uriInfo) { if(searchWord.length() < 3 || searchWord.indexOf(" ") != -1) { return Response.status(Response.Status.NOT_ACCEPTABLE).build(); } SearchView view = new SearchView(); final FiltersHolder filters = new FiltersHolder(); filters.init(uriInfo.getQueryParameters()); DbSearch result = getSearchHandler().getSearchResult(searchWord, filters); view.setSearchOj(result); return Response.ok(view).build(); }
WebSearchResource extends AbstractResource { @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{searchWord}") public Response getSearchResult(@PathParam("searchWord") final String searchWord, @Context final UriInfo uriInfo) { if(searchWord.length() < 3 || searchWord.indexOf(" ") != -1) { return Response.status(Response.Status.NOT_ACCEPTABLE).build(); } SearchView view = new SearchView(); final FiltersHolder filters = new FiltersHolder(); filters.init(uriInfo.getQueryParameters()); DbSearch result = getSearchHandler().getSearchResult(searchWord, filters); view.setSearchOj(result); return Response.ok(view).build(); } }
WebSearchResource extends AbstractResource { @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{searchWord}") public Response getSearchResult(@PathParam("searchWord") final String searchWord, @Context final UriInfo uriInfo) { if(searchWord.length() < 3 || searchWord.indexOf(" ") != -1) { return Response.status(Response.Status.NOT_ACCEPTABLE).build(); } SearchView view = new SearchView(); final FiltersHolder filters = new FiltersHolder(); filters.init(uriInfo.getQueryParameters()); DbSearch result = getSearchHandler().getSearchResult(searchWord, filters); view.setSearchOj(result); return Response.ok(view).build(); } WebSearchResource(RepositoryHandler repoHandler, GrapesServerConfig dmConfig); }
WebSearchResource extends AbstractResource { @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{searchWord}") public Response getSearchResult(@PathParam("searchWord") final String searchWord, @Context final UriInfo uriInfo) { if(searchWord.length() < 3 || searchWord.indexOf(" ") != -1) { return Response.status(Response.Status.NOT_ACCEPTABLE).build(); } SearchView view = new SearchView(); final FiltersHolder filters = new FiltersHolder(); filters.init(uriInfo.getQueryParameters()); DbSearch result = getSearchHandler().getSearchResult(searchWord, filters); view.setSearchOj(result); return Response.ok(view).build(); } WebSearchResource(RepositoryHandler repoHandler, GrapesServerConfig dmConfig); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{searchWord}") Response getSearchResult(@PathParam("searchWord") final String searchWord, @Context final UriInfo uriInfo); }
WebSearchResource extends AbstractResource { @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{searchWord}") public Response getSearchResult(@PathParam("searchWord") final String searchWord, @Context final UriInfo uriInfo) { if(searchWord.length() < 3 || searchWord.indexOf(" ") != -1) { return Response.status(Response.Status.NOT_ACCEPTABLE).build(); } SearchView view = new SearchView(); final FiltersHolder filters = new FiltersHolder(); filters.init(uriInfo.getQueryParameters()); DbSearch result = getSearchHandler().getSearchResult(searchWord, filters); view.setSearchOj(result); return Response.ok(view).build(); } WebSearchResource(RepositoryHandler repoHandler, GrapesServerConfig dmConfig); @GET @Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_JSON}) @Path("/{searchWord}") Response getSearchResult(@PathParam("searchWord") final String searchWord, @Context final UriInfo uriInfo);  }