@Test public void listComponents() { Component mockedComponent = new Component(); List<Component> mockedComponents = new ArrayList<Component>(); mockedComponents.add(mockedComponent); when(componentServiceMock.listComponents(anyString())).thenReturn(mockedComponents); Collection<Component> responseComponents = resource().path("/api/components") .queryParam("visibility", "ALL").accept(MediaType.APPLICATION_JSON) .get(new GenericType<Collection<Component>>(){}); assertEquals("Response components should match the mocked components", mockedComponents, responseComponents); verify(componentServiceMock).listComponents(anyString()); }
@GET @Produces(MediaType.APPLICATION_JSON) public Collection<Component> listComponents(@QueryParam("visibility") @DefaultValue(Framework.VISIBILITY_ALL) String visibility) { return componentService.listComponents(visibility); }
ComponentResource { @GET @Produces(MediaType.APPLICATION_JSON) public Collection<Component> listComponents(@QueryParam("visibility") @DefaultValue(Framework.VISIBILITY_ALL) String visibility) { return componentService.listComponents(visibility); } }
ComponentResource { @GET @Produces(MediaType.APPLICATION_JSON) public Collection<Component> listComponents(@QueryParam("visibility") @DefaultValue(Framework.VISIBILITY_ALL) String visibility) { return componentService.listComponents(visibility); } @Inject  ComponentResource(ComponentService componentService); }
ComponentResource { @GET @Produces(MediaType.APPLICATION_JSON) public Collection<Component> listComponents(@QueryParam("visibility") @DefaultValue(Framework.VISIBILITY_ALL) String visibility) { return componentService.listComponents(visibility); } @Inject  ComponentResource(ComponentService componentService); @GET @Produces(MediaType.APPLICATION_JSON) Collection<Component> listComponents(@QueryParam("visibility") 
            @DefaultValue(Framework.VISIBILITY_ALL) String visibility); @GET @Path("/{componentId}") @Produces(MediaType.APPLICATION_JSON) Component getComponent(@PathParam("componentId") String componentId); @GET @Path("/{componentId}/config") @Produces(MediaType.APPLICATION_JSON) ComponentConfig getComponentConfig(@PathParam("componentId") String componentId); @GET @Path("/{componentId}/icon") @Produces("image/jpeg") Response getComponentIcon(@PathParam("componentId") String componentId); }
ComponentResource { @GET @Produces(MediaType.APPLICATION_JSON) public Collection<Component> listComponents(@QueryParam("visibility") @DefaultValue(Framework.VISIBILITY_ALL) String visibility) { return componentService.listComponents(visibility); } @Inject  ComponentResource(ComponentService componentService); @GET @Produces(MediaType.APPLICATION_JSON) Collection<Component> listComponents(@QueryParam("visibility") 
            @DefaultValue(Framework.VISIBILITY_ALL) String visibility); @GET @Path("/{componentId}") @Produces(MediaType.APPLICATION_JSON) Component getComponent(@PathParam("componentId") String componentId); @GET @Path("/{componentId}/config") @Produces(MediaType.APPLICATION_JSON) ComponentConfig getComponentConfig(@PathParam("componentId") String componentId); @GET @Path("/{componentId}/icon") @Produces("image/jpeg") Response getComponentIcon(@PathParam("componentId") String componentId);  }