### Question:
ComponentResource { @GET @Path("/{componentId}") @Produces(MediaType.APPLICATION_JSON) public Component getComponent(@PathParam("componentId") String componentId) { return componentService.getComponent(componentId); } @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);  }### Answer:
@Test public void getComponent() { final Component mockedComponent= new Component(); mockedComponent.setId("COMPONENT_TO_GET"); when(componentServiceMock.getComponent(anyString())).then(new Answer<Component>() { @Override public Component answer(InvocationOnMock invocation) throws Throwable { String argComponentId = (String) invocation.getArguments()[0]; assertEquals("Service component ID should match the requested component ID", argComponentId, mockedComponent.getId()); return mockedComponent; } }); Component responseComponent = resource().path("/api/components/" + mockedComponent.getId()) .accept(MediaType.APPLICATION_JSON).get(Component.class); assertEquals("Response component should match the mocked component", mockedComponent, responseComponent); verify(componentServiceMock).getComponent(anyString()); }