@Test public void getResourceConfig() { final Resource mockedResource = new Resource(); mockedResource.setId("resource-1"); mockedResource.setName("resource-one"); mockedResource.setLabel("Resource One"); mockedResource.setVersion("1.0.0"); mockedResource.setFramework("test-framework"); mockedResource.setFrameworkLabel("Test Framework"); ResourceConfig mockedResourceConfig = new ResourceConfig(); mockedResourceConfig.setName("resource-one"); mockedResource.setConfig(mockedResourceConfig); when(resourceServiceMock.getResource(anyString())).then(new Answer<Resource>() { @Override public Resource answer(InvocationOnMock invocation) throws Throwable { String argResourceId = (String) invocation.getArguments()[0]; assertEquals("Service resource ID should match the requested resource ID", argResourceId, mockedResource.getId()); return mockedResource; } }); ResourceConfig responseResourceConfig = resource() .path("/api/resources/" + mockedResource.getId() + "/config") .accept(MediaType.APPLICATION_JSON).get(ResourceConfig.class); assertEquals("Response resource should match the mocked resource", mockedResourceConfig, responseResourceConfig); verify(resourceServiceMock).getResource(anyString()); }
@GET @Path("/{resourceId}/config") @Produces(MediaType.APPLICATION_JSON) public ResourceConfig getResourceConfig(@PathParam("resourceId") String resourceId) { return resourceService.getResource(resourceId).getConfig(); }
ResourceResource { @GET @Path("/{resourceId}/config") @Produces(MediaType.APPLICATION_JSON) public ResourceConfig getResourceConfig(@PathParam("resourceId") String resourceId) { return resourceService.getResource(resourceId).getConfig(); } }
ResourceResource { @GET @Path("/{resourceId}/config") @Produces(MediaType.APPLICATION_JSON) public ResourceConfig getResourceConfig(@PathParam("resourceId") String resourceId) { return resourceService.getResource(resourceId).getConfig(); } @Inject  ResourceResource(ResourceService resourceService); }
ResourceResource { @GET @Path("/{resourceId}/config") @Produces(MediaType.APPLICATION_JSON) public ResourceConfig getResourceConfig(@PathParam("resourceId") String resourceId) { return resourceService.getResource(resourceId).getConfig(); } @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 @Path("/{resourceId}/config") @Produces(MediaType.APPLICATION_JSON) public ResourceConfig getResourceConfig(@PathParam("resourceId") String resourceId) { return resourceService.getResource(resourceId).getConfig(); } @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);  }