@Test public void resolveVersions() throws Exception { ExtensionVersionSummary v1 = mock(ExtensionVersionSummary.class); when(v1.getVersion()).thenReturn("1.3"); ExtensionVersionSummary v2 = mock(ExtensionVersionSummary.class); when(v2.getVersion()).thenReturn("2.4.1"); List<ExtensionVersionSummary> versionSummaries = Arrays.asList(v1, v2); ExtensionVersions restVersions = mock(ExtensionVersions.class); when(this.unmarshaller.unmarshal(any(InputStream.class))).thenReturn(restVersions); when(restVersions.getExtensionVersionSummaries()).thenReturn(versionSummaries); when(restVersions.getOffset()).thenReturn(5); when(restVersions.getTotalHits()).thenReturn(7); IterableResult<Version> result = this.repository.resolveVersions("foo", 0, -1); assertEquals(5, result.getOffset()); assertEquals(7, result.getTotalHits()); List<Version> versions = new ArrayList<>(); Iterators.addAll(versions, result.iterator()); assertEquals(Arrays.asList(new DefaultVersion("1.3"), new DefaultVersion("2.4.1")), versions); }
@Override public IterableResult<Version> resolveVersions(String id, int offset, int nb) throws ResolveException { ExtensionVersions restExtensions = resolveExtensionVersions(id, null, offset, nb, true); List<Version> versions = new ArrayList<>(restExtensions.getExtensionVersionSummaries().size()); for (ExtensionVersionSummary restExtension : restExtensions.getExtensionVersionSummaries()) { versions.add(new DefaultVersion(restExtension.getVersion())); } return new CollectionIterableResult<>(restExtensions.getTotalHits(), restExtensions.getOffset(), versions); }
XWikiExtensionRepository extends AbstractExtensionRepository implements AdvancedSearchable, RatableExtensionRepository { @Override public IterableResult<Version> resolveVersions(String id, int offset, int nb) throws ResolveException { ExtensionVersions restExtensions = resolveExtensionVersions(id, null, offset, nb, true); List<Version> versions = new ArrayList<>(restExtensions.getExtensionVersionSummaries().size()); for (ExtensionVersionSummary restExtension : restExtensions.getExtensionVersionSummaries()) { versions.add(new DefaultVersion(restExtension.getVersion())); } return new CollectionIterableResult<>(restExtensions.getTotalHits(), restExtensions.getOffset(), versions); } }
XWikiExtensionRepository extends AbstractExtensionRepository implements AdvancedSearchable, RatableExtensionRepository { @Override public IterableResult<Version> resolveVersions(String id, int offset, int nb) throws ResolveException { ExtensionVersions restExtensions = resolveExtensionVersions(id, null, offset, nb, true); List<Version> versions = new ArrayList<>(restExtensions.getExtensionVersionSummaries().size()); for (ExtensionVersionSummary restExtension : restExtensions.getExtensionVersionSummaries()) { versions.add(new DefaultVersion(restExtension.getVersion())); } return new CollectionIterableResult<>(restExtensions.getTotalHits(), restExtensions.getOffset(), versions); } XWikiExtensionRepository(ExtensionRepositoryDescriptor repositoryDescriptor,
        XWikiExtensionRepositoryFactory repositoryFactory, ExtensionLicenseManager licenseManager,
        HttpClientFactory httpClientFactory, ExtensionFactory factory); }
XWikiExtensionRepository extends AbstractExtensionRepository implements AdvancedSearchable, RatableExtensionRepository { @Override public IterableResult<Version> resolveVersions(String id, int offset, int nb) throws ResolveException { ExtensionVersions restExtensions = resolveExtensionVersions(id, null, offset, nb, true); List<Version> versions = new ArrayList<>(restExtensions.getExtensionVersionSummaries().size()); for (ExtensionVersionSummary restExtension : restExtensions.getExtensionVersionSummaries()) { versions.add(new DefaultVersion(restExtension.getVersion())); } return new CollectionIterableResult<>(restExtensions.getTotalHits(), restExtensions.getOffset(), versions); } XWikiExtensionRepository(ExtensionRepositoryDescriptor repositoryDescriptor,
        XWikiExtensionRepositoryFactory repositoryFactory, ExtensionLicenseManager licenseManager,
        HttpClientFactory httpClientFactory, ExtensionFactory factory); Version getRepositoryVersion(); @Override boolean isFilterable(); @Override boolean isSortable(); @Override Extension resolve(ExtensionId extensionId); @Override Extension resolve(ExtensionDependency extensionDependency); @Override IterableResult<Version> resolveVersions(String id, int offset, int nb); @Override IterableResult<Extension> search(String pattern, int offset, int nb); @Override IterableResult<Extension> search(org.xwiki.extension.repository.search.ExtensionQuery query); @Override ExtensionRating getRating(ExtensionId extensionId); @Override ExtensionRating getRating(String extensionId, Version extensionVersion); @Override ExtensionRating getRating(String extensionId, String extensionVersion); }
XWikiExtensionRepository extends AbstractExtensionRepository implements AdvancedSearchable, RatableExtensionRepository { @Override public IterableResult<Version> resolveVersions(String id, int offset, int nb) throws ResolveException { ExtensionVersions restExtensions = resolveExtensionVersions(id, null, offset, nb, true); List<Version> versions = new ArrayList<>(restExtensions.getExtensionVersionSummaries().size()); for (ExtensionVersionSummary restExtension : restExtensions.getExtensionVersionSummaries()) { versions.add(new DefaultVersion(restExtension.getVersion())); } return new CollectionIterableResult<>(restExtensions.getTotalHits(), restExtensions.getOffset(), versions); } XWikiExtensionRepository(ExtensionRepositoryDescriptor repositoryDescriptor,
        XWikiExtensionRepositoryFactory repositoryFactory, ExtensionLicenseManager licenseManager,
        HttpClientFactory httpClientFactory, ExtensionFactory factory); Version getRepositoryVersion(); @Override boolean isFilterable(); @Override boolean isSortable(); @Override Extension resolve(ExtensionId extensionId); @Override Extension resolve(ExtensionDependency extensionDependency); @Override IterableResult<Version> resolveVersions(String id, int offset, int nb); @Override IterableResult<Extension> search(String pattern, int offset, int nb); @Override IterableResult<Extension> search(org.xwiki.extension.repository.search.ExtensionQuery query); @Override ExtensionRating getRating(ExtensionId extensionId); @Override ExtensionRating getRating(String extensionId, Version extensionVersion); @Override ExtensionRating getRating(String extensionId, String extensionVersion); static final Version VERSION10; static final Version VERSION11; }