@Test public void listFrameworks() { Framework framework1 = new Framework(); framework1.setId("framework-1"); framework1.setName("framework-first"); framework1.setLabel("First Framework"); framework1.setCount(7); framework1.setEnabled(true); Framework framework2 = new Framework(); framework2.setId("framework-2"); framework2.setName("framework-second"); framework2.setLabel("Second Framework"); framework2.setCount(10); framework2.setEnabled(false); List<Framework> mockedFrameworks = new ArrayList<Framework>(); mockedFrameworks.add(framework1); mockedFrameworks.add(framework2); when(frameworkServiceMock.listFrameworks()).thenReturn(mockedFrameworks); Collection<Framework> responseFrameworks = resource().path("/api/frameworks") .accept(MediaType.APPLICATION_JSON).get(new GenericType<Collection<Framework>>(){}); assertEquals("Response clusters should be equal to the mocked clusters", mockedFrameworks, responseFrameworks); verify(frameworkServiceMock).listFrameworks(); }
@GET @Produces(MediaType.APPLICATION_JSON) public List<Framework> listFrameworks() { return frameworkService.listFrameworks(); }
FrameworkResource { @GET @Produces(MediaType.APPLICATION_JSON) public List<Framework> listFrameworks() { return frameworkService.listFrameworks(); } }
FrameworkResource { @GET @Produces(MediaType.APPLICATION_JSON) public List<Framework> listFrameworks() { return frameworkService.listFrameworks(); } @Inject  FrameworkResource(FrameworkService frameworkService,
            ComponentService componentService, ResourceService resourceService,
            SerializationService serializationService); }
FrameworkResource { @GET @Produces(MediaType.APPLICATION_JSON) public List<Framework> listFrameworks() { return frameworkService.listFrameworks(); } @Inject  FrameworkResource(FrameworkService frameworkService,
            ComponentService componentService, ResourceService resourceService,
            SerializationService serializationService); @GET @Produces(MediaType.APPLICATION_JSON) List<Framework> listFrameworks(); @POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_JSON) Framework saveFramework(@FormDataParam("file") byte[] frameworkJar, 
            @FormDataParam("isPublic") @DefaultValue("false") boolean isPublic); @GET @Path("/{frameworkId}") @Produces(MediaType.APPLICATION_JSON) Framework getFramework(@PathParam("frameworkId") String frameworkId); @DELETE @Path("/{frameworkId}") Response deleteFramework(@PathParam("frameworkId") String frameworkId); @GET @Path("/{frameworkId}/jar") @Produces("application/java-archive") Response getFrameworkJar(@PathParam("frameworkId") String frameworkId); @GET @Path("/{frameworkId}/components") @Produces(MediaType.APPLICATION_JSON) List<Component> getFrameworkComponents(@PathParam("frameworkId") String frameworkId); @GET @Path("/{frameworkId}/resources") @Produces(MediaType.APPLICATION_JSON) List<Resource> getFrameworkResources(@PathParam("frameworkId") String frameworkId); @GET @Path("/{frameworkId}/serializations") @Produces(MediaType.APPLICATION_JSON) List<Serialization> getFrameworkSerializations(@PathParam("frameworkId") String frameworkId); }
FrameworkResource { @GET @Produces(MediaType.APPLICATION_JSON) public List<Framework> listFrameworks() { return frameworkService.listFrameworks(); } @Inject  FrameworkResource(FrameworkService frameworkService,
            ComponentService componentService, ResourceService resourceService,
            SerializationService serializationService); @GET @Produces(MediaType.APPLICATION_JSON) List<Framework> listFrameworks(); @POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_JSON) Framework saveFramework(@FormDataParam("file") byte[] frameworkJar, 
            @FormDataParam("isPublic") @DefaultValue("false") boolean isPublic); @GET @Path("/{frameworkId}") @Produces(MediaType.APPLICATION_JSON) Framework getFramework(@PathParam("frameworkId") String frameworkId); @DELETE @Path("/{frameworkId}") Response deleteFramework(@PathParam("frameworkId") String frameworkId); @GET @Path("/{frameworkId}/jar") @Produces("application/java-archive") Response getFrameworkJar(@PathParam("frameworkId") String frameworkId); @GET @Path("/{frameworkId}/components") @Produces(MediaType.APPLICATION_JSON) List<Component> getFrameworkComponents(@PathParam("frameworkId") String frameworkId); @GET @Path("/{frameworkId}/resources") @Produces(MediaType.APPLICATION_JSON) List<Resource> getFrameworkResources(@PathParam("frameworkId") String frameworkId); @GET @Path("/{frameworkId}/serializations") @Produces(MediaType.APPLICATION_JSON) List<Serialization> getFrameworkSerializations(@PathParam("frameworkId") String frameworkId);  }