@Test public void getFrameworkComponents() { Component mockedComponent1 = new Component(); mockedComponent1.setId("component-1"); mockedComponent1.setName("component-1"); mockedComponent1.setLabel("Component 1"); mockedComponent1.setFramework("test-framework"); mockedComponent1.setFrameworkLabel("Test Framework"); Component mockedComponent2 = new Component(); mockedComponent2.setId("component-2"); mockedComponent2.setName("component-2"); mockedComponent2.setLabel("Component 2"); mockedComponent2.setFramework("test-framework"); mockedComponent2.setFrameworkLabel("Test Framework"); List<Component> mockedComponents = new ArrayList<Component>(); mockedComponents.add(mockedComponent1); mockedComponents.add(mockedComponent2); when(componentServiceMock.listComponentsWithFramework(anyString())) .thenReturn(mockedComponents); List<Component> responseComponents = resource().path("/api/frameworks/" + mockedComponent1.getFramework() + "/components").accept(MediaType.APPLICATION_JSON) .get(new GenericType<List<Component>>(){}); assertEquals("Response components should match the mocked components", mockedComponents, responseComponents); verify(componentServiceMock).listComponentsWithFramework(anyString()); }
@GET @Path("/{frameworkId}/components") @Produces(MediaType.APPLICATION_JSON) public List<Component> getFrameworkComponents(@PathParam("frameworkId") String frameworkId) { return componentService.listComponentsWithFramework(frameworkId); }
FrameworkResource { @GET @Path("/{frameworkId}/components") @Produces(MediaType.APPLICATION_JSON) public List<Component> getFrameworkComponents(@PathParam("frameworkId") String frameworkId) { return componentService.listComponentsWithFramework(frameworkId); } }
FrameworkResource { @GET @Path("/{frameworkId}/components") @Produces(MediaType.APPLICATION_JSON) public List<Component> getFrameworkComponents(@PathParam("frameworkId") String frameworkId) { return componentService.listComponentsWithFramework(frameworkId); } @Inject  FrameworkResource(FrameworkService frameworkService,
            ComponentService componentService, ResourceService resourceService,
            SerializationService serializationService); }
FrameworkResource { @GET @Path("/{frameworkId}/components") @Produces(MediaType.APPLICATION_JSON) public List<Component> getFrameworkComponents(@PathParam("frameworkId") String frameworkId) { return componentService.listComponentsWithFramework(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}/components") @Produces(MediaType.APPLICATION_JSON) public List<Component> getFrameworkComponents(@PathParam("frameworkId") String frameworkId) { return componentService.listComponentsWithFramework(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);  }