### Question:
SearchResource extends ResourceBase { @GET @Path("{type: "+ ALL_TYPES_PATTERN + "}/_search") @Produces(MediaType.APPLICATION_JSON) public final Response search(@PathParam("type") String type, @QueryParam("q") String query) { if (isBlank(query)) { return Response.status(Response.Status.BAD_REQUEST).build(); } switch (type) { case "work": return getSearchService().searchWork(query); case "person": return getSearchService().searchPerson(query); case "place": return getSearchService().searchPlace(query); case "corporation": return getSearchService().searchCorporation(query); case "serial": return getSearchService().searchSerial(query); case "workSeries": return getSearchService().searchWorkSeries(query); case "subject": return getSearchService().searchSubject(query); case "genre": return getSearchService().searchGenre(query); case "publication": return getSearchService().searchPublication(query); case "instrument": return getSearchService().searchInstrument(query); case "compositionType": return getSearchService().searchCompositionType(query); case "event": return getSearchService().searchEvent(query); default: throw new RuntimeException("Unknown type: " + type); } } SearchResource();  SearchResource(SearchService searchService); @GET @Path("{type: "+ ALL_TYPES_PATTERN + "}/sorted_list") final Response sortedList(@PathParam("type") String type,
                                     @QueryParam("prefix") String prefix,
                                     @DefaultValue("100") @QueryParam("minSize") int minSize,
                                     @DefaultValue("name") @QueryParam("field") String field); @GET @Path("{type: "+ ALL_TYPES_PATTERN + "}/_search") @Produces(MediaType.APPLICATION_JSON) final Response search(@PathParam("type") String type, @QueryParam("q") String query); @POST @Path("{type: " + ALL_TYPES_PATTERN + "}/_search") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) final Response searchJson(String body, @PathParam("type") String type, @Context UriInfo uriInfo); @POST @Path("clear_index") final Response clearIndex(); @POST @Path("reindex_all") final Response reIndexAll(); @POST @Path("{type: "+ ALL_TYPES_PATTERN + "}/reindex_all") final Response reIndex(
            @PathParam("type") final String type,
            @QueryParam("ignoreConnectedResources") boolean ignoreConnectedResources);  }### Answer:
@Test public void when_search_for_works_returns_work_search_response() throws Exception { Assert.assertSame(mockWorkSearchResponse, searchResource.search("work", "query")); }
@Test public void when_search_for_person_returns_person_search_response() throws Exception { Assert.assertSame(mockPersonSearchResponse, searchResource.search("person", "query")); }
@Test public void when_search_for_place_returns_place_response() throws Exception { Assert.assertSame(mockPlaceSearchResponse, searchResource.search("place", "query")); }
@Test public void when_search_for_corporation_returns_publisher_response() throws Exception { Assert.assertSame(mockCorporationSearchResponse, searchResource.search("corporation", "query")); }
@Test public void when_search_for_serial_returns_serial_response() throws Exception { Assert.assertSame(mockSerialSearchResponse, searchResource.search("serial", "query")); }
@Test public void when_search_for_workSeries_returns_work_eries_response() throws Exception { Assert.assertSame(mockWorkSeriesSearchResponse, searchResource.search("workSeries", "query")); }
@Test public void when_search_with_empty_query_bad_request_is_returned() { assertEquals(SC_BAD_REQUEST, searchResource.search("person", "").getStatus()); assertEquals(SC_BAD_REQUEST, searchResource.search("work", "").getStatus()); }
@Test(expected = RuntimeException.class) public void when_search_for_unknown_type_throws_exceptiom() { searchResource.search("unknown", "a").getStatus(); }