Search in sources :

Example 1 with ExternalUpdate

use of com.intellij.openapi.updateSettings.impl.ExternalUpdate in project android by JetBrains.

the class SdkComponentSourceTest method testIgnored.

public void testIgnored() throws Exception {
    final AtomicReference<String> id = new AtomicReference<String>();
    ProgressIndicator progress = new StudioProgressIndicatorAdapter(new FakeProgressIndicator(), null);
    for (UpdatableExternalComponent c : myTestComponentSource.getAvailableVersions(progress, null)) {
        if ("package newerRemote".equals(c.getName())) {
            id.set(SdkComponentSource.getPackageRevisionId((RepoPackage) c.getKey()));
        }
    }
    assertNotNull(id.get());
    ExternalComponentManager.getInstance().registerComponentSource(myTestComponentSource);
    UpdateSettings settings = new UpdateSettings() {

        @Override
        public List<String> getEnabledExternalUpdateSources() {
            return ImmutableList.of(myTestComponentSource.getName());
        }

        @Override
        public List<String> getIgnoredBuildNumbers() {
            return ImmutableList.of(id.get());
        }
    };
    Collection<ExternalUpdate> updates = UpdateChecker.updateExternal(true, settings, progress);
    assertEquals(1, updates.size());
    ExternalUpdate update = updates.iterator().next();
    Iterator<UpdatableExternalComponent> iter = update.getComponents().iterator();
    UpdatableExternalComponent component = iter.next();
    assertEquals("package newerPreview", component.getName());
    assertEquals(new Revision(1, 0, 0, 2), ((RepoPackage) component.getKey()).getVersion());
    assertFalse(iter.hasNext());
}
Also used : StudioProgressIndicatorAdapter(com.android.tools.idea.sdk.progress.StudioProgressIndicatorAdapter) AtomicReference(java.util.concurrent.atomic.AtomicReference) UpdateSettings(com.intellij.openapi.updateSettings.impl.UpdateSettings) ExternalUpdate(com.intellij.openapi.updateSettings.impl.ExternalUpdate) Revision(com.android.repository.Revision) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) UpdatableExternalComponent(com.intellij.ide.externalComponents.UpdatableExternalComponent)

Example 2 with ExternalUpdate

use of com.intellij.openapi.updateSettings.impl.ExternalUpdate in project android by JetBrains.

the class SdkComponentSourceTest method testBetaUpdates.

public void testBetaUpdates() throws Exception {
    myChannelId = 1;
    ExternalComponentManager.getInstance().registerComponentSource(myTestComponentSource);
    ProgressIndicator progress = new StudioProgressIndicatorAdapter(new FakeProgressIndicator(), null);
    UpdateSettings settings = new UpdateSettings() {

        @Override
        public List<String> getEnabledExternalUpdateSources() {
            return ImmutableList.of(myTestComponentSource.getName());
        }
    };
    Collection<ExternalUpdate> updates = UpdateChecker.updateExternal(true, settings, progress);
    assertEquals(1, updates.size());
    ExternalUpdate update = updates.iterator().next();
    Iterator<UpdatableExternalComponent> iter = update.getComponents().iterator();
    UpdatableExternalComponent component = iter.next();
    assertEquals("package newerPreview", component.getName());
    assertEquals(new Revision(1, 0, 0, 2), ((RepoPackage) component.getKey()).getVersion());
    component = iter.next();
    assertEquals("package newerRemote", component.getName());
    assertEquals(new Revision(1, 1, 0), ((RepoPackage) component.getKey()).getVersion());
    component = iter.next();
    assertEquals("package zNewerInBeta", component.getName());
    assertEquals(new Revision(2, 0, 0), ((RepoPackage) component.getKey()).getVersion());
    assertFalse(iter.hasNext());
}
Also used : ExternalUpdate(com.intellij.openapi.updateSettings.impl.ExternalUpdate) Revision(com.android.repository.Revision) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) UpdatableExternalComponent(com.intellij.ide.externalComponents.UpdatableExternalComponent) StudioProgressIndicatorAdapter(com.android.tools.idea.sdk.progress.StudioProgressIndicatorAdapter) UpdateSettings(com.intellij.openapi.updateSettings.impl.UpdateSettings)

Example 3 with ExternalUpdate

use of com.intellij.openapi.updateSettings.impl.ExternalUpdate in project android by JetBrains.

the class SdkComponentSourceTest method testUpdates.

public void testUpdates() throws Exception {
    ExternalComponentManager.getInstance().registerComponentSource(myTestComponentSource);
    ProgressIndicator progress = new StudioProgressIndicatorAdapter(new FakeProgressIndicator(), null);
    UpdateSettings settings = new UpdateSettings() {

        @Override
        public List<String> getEnabledExternalUpdateSources() {
            return ImmutableList.of(myTestComponentSource.getName());
        }
    };
    Collection<ExternalUpdate> updates = UpdateChecker.updateExternal(true, settings, progress);
    assertEquals(1, updates.size());
    ExternalUpdate update = updates.iterator().next();
    Iterator<UpdatableExternalComponent> iter = update.getComponents().iterator();
    UpdatableExternalComponent component = iter.next();
    assertEquals("package newerPreview", component.getName());
    assertEquals(new Revision(1, 0, 0, 2), ((RepoPackage) component.getKey()).getVersion());
    component = iter.next();
    assertEquals("package newerRemote", component.getName());
    assertEquals(new Revision(1, 1, 0), ((RepoPackage) component.getKey()).getVersion());
    assertFalse(iter.hasNext());
}
Also used : ExternalUpdate(com.intellij.openapi.updateSettings.impl.ExternalUpdate) Revision(com.android.repository.Revision) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) UpdatableExternalComponent(com.intellij.ide.externalComponents.UpdatableExternalComponent) StudioProgressIndicatorAdapter(com.android.tools.idea.sdk.progress.StudioProgressIndicatorAdapter) UpdateSettings(com.intellij.openapi.updateSettings.impl.UpdateSettings)

Aggregations

Revision (com.android.repository.Revision)3 StudioProgressIndicatorAdapter (com.android.tools.idea.sdk.progress.StudioProgressIndicatorAdapter)3 UpdatableExternalComponent (com.intellij.ide.externalComponents.UpdatableExternalComponent)3 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)3 ExternalUpdate (com.intellij.openapi.updateSettings.impl.ExternalUpdate)3 UpdateSettings (com.intellij.openapi.updateSettings.impl.UpdateSettings)3 AtomicReference (java.util.concurrent.atomic.AtomicReference)1