@Test public void listResources() { Resource resource1 = new Resource(); resource1.setId("resource-1"); resource1.setName("resource-one"); resource1.setLabel("Resource One"); resource1.setVersion("1.0.0"); resource1.setFramework("test-framework"); resource1.setFrameworkLabel("Test Framework"); Resource resource2 = new Resource(); resource2.setId("resource-2"); resource2.setName("resource-two"); resource2.setLabel("Resource Two"); resource2.setVersion("1.0.0"); resource2.setFramework("test-framework"); resource2.setFrameworkLabel("Test Framework"); List<Resource> mockedResources = new ArrayList<Resource>(); mockedResources.add(resource1); mockedResources.add(resource2); when(resourceServiceMock.listResources()).thenReturn(mockedResources); Collection<Resource> responseResources = resource().path("/api/resources") .queryParam("visibility", "ALL").accept(MediaType.APPLICATION_JSON) .get(new GenericType<Collection<Resource>>(){}); assertEquals("Response resources should match the mocked resources", mockedResources, responseResources); verify(resourceServiceMock).listResources(); }
@GET @Produces(MediaType.APPLICATION_JSON) public List<Resource> listResources() { return resourceService.listResources(); }
ResourceResource { @GET @Produces(MediaType.APPLICATION_JSON) public List<Resource> listResources() { return resourceService.listResources(); } }
ResourceResource { @GET @Produces(MediaType.APPLICATION_JSON) public List<Resource> listResources() { return resourceService.listResources(); } @Inject  ResourceResource(ResourceService resourceService); }
ResourceResource { @GET @Produces(MediaType.APPLICATION_JSON) public List<Resource> listResources() { return resourceService.listResources(); } @Inject  ResourceResource(ResourceService resourceService); @GET @Produces(MediaType.APPLICATION_JSON) List<Resource> listResources(); @GET @Path("/{resourceId}") @Produces(MediaType.APPLICATION_JSON) Resource getResource(@PathParam("resourceId") String resourceId); @GET @Path("/{resourceId}/config") @Produces(MediaType.APPLICATION_JSON) ResourceConfig getResourceConfig(@PathParam("resourceId") String resourceId); }
ResourceResource { @GET @Produces(MediaType.APPLICATION_JSON) public List<Resource> listResources() { return resourceService.listResources(); } @Inject  ResourceResource(ResourceService resourceService); @GET @Produces(MediaType.APPLICATION_JSON) List<Resource> listResources(); @GET @Path("/{resourceId}") @Produces(MediaType.APPLICATION_JSON) Resource getResource(@PathParam("resourceId") String resourceId); @GET @Path("/{resourceId}/config") @Produces(MediaType.APPLICATION_JSON) ResourceConfig getResourceConfig(@PathParam("resourceId") String resourceId);  }