AppStoreController { @GET @Path("search") @Produces(MediaType.APPLICATION_JSON) public List<AppStoreEntry> search(@QueryParam("q") String keyword) { AppCatalogSolrClient sc = new AppCatalogSolrClient(); return sc.search(keyword); } AppStoreController(); @GET @Path("recommended") @Produces(MediaType.APPLICATION_JSON) List<AppStoreEntry> get(); @GET @Path("search") @Produces(MediaType.APPLICATION_JSON) List<AppStoreEntry> search(@QueryParam("q") String keyword); @GET @Path("get/{id}") @Produces(MediaType.APPLICATION_JSON) AppStoreEntry get(@PathParam("id") String id); @POST @Path("register") @Produces(MediaType.APPLICATION_JSON) Response register(Application app);  }
@Test public void testSearch() throws Exception { String keyword = "jenkins"; AppStoreController ac = Mockito.mock(AppStoreController.class); List<AppStoreEntry> expected = new ArrayList<AppStoreEntry>(); when(ac.search(keyword)).thenReturn(expected); final List<AppStoreEntry> actual = ac.search(keyword); assertEquals(expected, actual); }