UploadService extends ComponentSupport { public String upload(final String repositoryName, final HttpServletRequest request) throws IOException { checkNotNull(repositoryName); checkNotNull(request); Repository repository = checkNotNull(repositoryManager.get(repositoryName), "Specified repository is missing"); UploadResponse uploadResponse = uploadManager.handle(repository, request); return createSearchTerm(uploadResponse.getAssetPaths()); } @Inject  UploadService(final RepositoryManager repositoryManager,
                       final UploadManager uploadManager); Collection<UploadDefinition> getAvailableDefinitions(); String upload(final String repositoryName, final HttpServletRequest request);  }
@Test public void testUpload_unknownRepository() throws IOException { try { component.upload("foo", request); fail("Expected exception to be thrown"); } catch (NullPointerException e) { assertThat(e.getMessage(), is("Specified repository is missing")); } }
@Test public void testUpload() throws IOException { assertThat(component.upload(REPO_NAME, request), is("foo")); }