ComponentsResource extends ComponentSupport implements Resource, ComponentsResourceDoc { @Override @GET @Path("/{id}") public ComponentXO getComponentById(@PathParam("id") final String id) { RepositoryItemIDXO repositoryItemXOID = fromString(id); Repository repository = repositoryManagerRESTAdapter.getRepository(repositoryItemXOID.getRepositoryId()); Component component = getComponent(repositoryItemXOID, repository); return fromComponent(component, repository); } @Inject  ComponentsResource(final RepositoryManagerRESTAdapter repositoryManagerRESTAdapter,
                            final BrowseService browseService,
                            final ComponentEntityAdapter componentEntityAdapter,
                            final MaintenanceService maintenanceService,
                            @Named("component") final ContinuationTokenHelper continuationTokenHelper,
                            final UploadManager uploadManager,
                            final UploadConfiguration uploadConfiguration,
                            final ComponentXOFactory componentXOFactory,
                            final Set<ComponentsResourceExtension> componentsResourceExtensions); @Override @GET Page<ComponentXO> getComponents(@QueryParam("continuationToken") final String continuationToken,
                                         @QueryParam("repository") final String repositoryId); @Override @GET @Path("/{id}") ComponentXO getComponentById(@PathParam("id") final String id); @Override @DELETE @Path("/{id}") void deleteComponent(@PathParam("id") final String id); @Override @POST @Consumes(MediaType.MULTIPART_FORM_DATA) void uploadComponent(@QueryParam("repository") final String repositoryId,
                              @Context final HttpServletRequest request); static final String RESOURCE_URI; }
@Test(expected = NotFoundException.class) public void getComponentById_notFound() throws Exception { RepositoryItemIDXO repositoryItemXOID = getRepositoryItemIdXO(null); underTest.getComponentById(repositoryItemXOID.getValue()); }
@Test public void getComponentById_illegalArgumentException() throws Exception { RepositoryItemIDXO repositoryItemXOID = new RepositoryItemIDXO("maven-releases", "f10bd0593de3b5e4b377049bcaa80d3e"); doThrow(new IllegalArgumentException()).when(componentEntityAdapter) .recordIdentity(new DetachedEntityId(repositoryItemXOID.getId())); thrown.expect(hasProperty("response", hasProperty("status", is(UNPROCESSABLE_ENTITY)))); underTest.getComponentById(repositoryItemXOID.getValue()); }
@Test public void getComponentById() throws Exception { RepositoryItemIDXO repositoryItemXOID = getRepositoryItemIdXO(componentOne); ComponentXO componentXO = underTest.getComponentById(repositoryItemXOID.getValue()); assertThat(componentXO, notNullValue()); assertThat(componentXO.getGroup(), is("component-one-group")); assertThat(componentXO.getName(), is("component-one-name")); assertThat(componentXO.getVersion(), is("1.0.0")); assertThat(componentXO.getAssets(), hasSize(1)); verify(componentsResourceExtension).updateComponentXO(any(ComponentXO.class), any(Component.class)); }