@Test public void testCreateSearchTerm() { String result = component .createSearchTerm(Arrays.asList("foo-x.z/bar/bar", "foo-x.z/bar/foo", "foo-x.z/bar/foo/bar")); assertThat(result, is("foo-x.z/bar")); }
@VisibleForTesting String createSearchTerm(final Collection<String> createdPaths) { if (createdPaths.isEmpty()) { return null; } String prefix = Iterables.getFirst(createdPaths, null); for (String path : createdPaths) { prefix = longestPrefix(prefix, path); } return prefix; }
UploadService extends ComponentSupport { @VisibleForTesting String createSearchTerm(final Collection<String> createdPaths) { if (createdPaths.isEmpty()) { return null; } String prefix = Iterables.getFirst(createdPaths, null); for (String path : createdPaths) { prefix = longestPrefix(prefix, path); } return prefix; } }
UploadService extends ComponentSupport { @VisibleForTesting String createSearchTerm(final Collection<String> createdPaths) { if (createdPaths.isEmpty()) { return null; } String prefix = Iterables.getFirst(createdPaths, null); for (String path : createdPaths) { prefix = longestPrefix(prefix, path); } return prefix; } @Inject  UploadService(final RepositoryManager repositoryManager,
                       final UploadManager uploadManager); }
UploadService extends ComponentSupport { @VisibleForTesting String createSearchTerm(final Collection<String> createdPaths) { if (createdPaths.isEmpty()) { return null; } String prefix = Iterables.getFirst(createdPaths, null); for (String path : createdPaths) { prefix = longestPrefix(prefix, path); } return prefix; } @Inject  UploadService(final RepositoryManager repositoryManager,
                       final UploadManager uploadManager); Collection<UploadDefinition> getAvailableDefinitions(); String upload(final String repositoryName, final HttpServletRequest request); }
UploadService extends ComponentSupport { @VisibleForTesting String createSearchTerm(final Collection<String> createdPaths) { if (createdPaths.isEmpty()) { return null; } String prefix = Iterables.getFirst(createdPaths, null); for (String path : createdPaths) { prefix = longestPrefix(prefix, path); } return prefix; } @Inject  UploadService(final RepositoryManager repositoryManager,
                       final UploadManager uploadManager); Collection<UploadDefinition> getAvailableDefinitions(); String upload(final String repositoryName, final HttpServletRequest request);  }