@Test public void getFramework() { final Framework mockedFramework= new Framework(); mockedFramework.setId("FRAMEWORK_TO_GET"); when(frameworkServiceMock.getFramework(anyString())).then(new Answer<Framework>() { @Override public Framework answer(InvocationOnMock invocation) throws Throwable { String argFrameworkId = (String) invocation.getArguments()[0]; assertEquals("Service framework ID should match the requested framework ID", argFrameworkId, mockedFramework.getId()); return mockedFramework; } }); Framework responseFramework = resource().path("/api/frameworks/" + mockedFramework.getId()) .accept(MediaType.APPLICATION_JSON).get(Framework.class); assertEquals("Response framework should match the mocked framework", mockedFramework, responseFramework); verify(frameworkServiceMock).getFramework(anyString()); }
@GET @Path("/{frameworkId}") @Produces(MediaType.APPLICATION_JSON) public Framework getFramework(@PathParam("frameworkId") String frameworkId) { return frameworkService.getFramework(frameworkId); }
FrameworkResource { @GET @Path("/{frameworkId}") @Produces(MediaType.APPLICATION_JSON) public Framework getFramework(@PathParam("frameworkId") String frameworkId) { return frameworkService.getFramework(frameworkId); } }
FrameworkResource { @GET @Path("/{frameworkId}") @Produces(MediaType.APPLICATION_JSON) public Framework getFramework(@PathParam("frameworkId") String frameworkId) { return frameworkService.getFramework(frameworkId); } @Inject  FrameworkResource(FrameworkService frameworkService,
            ComponentService componentService, ResourceService resourceService,
            SerializationService serializationService); }
FrameworkResource { @GET @Path("/{frameworkId}") @Produces(MediaType.APPLICATION_JSON) public Framework getFramework(@PathParam("frameworkId") String frameworkId) { return frameworkService.getFramework(frameworkId); } @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 @Path("/{frameworkId}") @Produces(MediaType.APPLICATION_JSON) public Framework getFramework(@PathParam("frameworkId") String frameworkId) { return frameworkService.getFramework(frameworkId); } @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);  }