Search in sources :

Example 1 with UpdatableExternalComponent

use of com.intellij.ide.externalComponents.UpdatableExternalComponent 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 UpdatableExternalComponent

use of com.intellij.ide.externalComponents.UpdatableExternalComponent in project android by JetBrains.

the class SdkComponentSourceTest method testAvailableStableVersions.

public void testAvailableStableVersions() throws Exception {
    ProgressIndicator progress = new StudioProgressIndicatorAdapter(new FakeProgressIndicator(), null);
    Set<UpdatableExternalComponent> components = Sets.newTreeSet(COMPONENT_COMPARATOR);
    components.addAll(myTestComponentSource.getAvailableVersions(progress, null));
    Iterator<UpdatableExternalComponent> componentIter = components.iterator();
    validateStablePackages(componentIter);
    assertFalse(componentIter.hasNext());
}
Also used : ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) UpdatableExternalComponent(com.intellij.ide.externalComponents.UpdatableExternalComponent) StudioProgressIndicatorAdapter(com.android.tools.idea.sdk.progress.StudioProgressIndicatorAdapter)

Example 3 with UpdatableExternalComponent

use of com.intellij.ide.externalComponents.UpdatableExternalComponent 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 4 with UpdatableExternalComponent

use of com.intellij.ide.externalComponents.UpdatableExternalComponent 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)

Example 5 with UpdatableExternalComponent

use of com.intellij.ide.externalComponents.UpdatableExternalComponent in project android by JetBrains.

the class SdkComponentSourceTest method testCurrentVersions.

public void testCurrentVersions() throws Exception {
    Set<UpdatableExternalComponent> components = Sets.newTreeSet(COMPONENT_COMPARATOR);
    components.addAll(myTestComponentSource.getCurrentVersions());
    Iterator<UpdatableExternalComponent> componentIter = components.iterator();
    UpdatableExternalComponent c = componentIter.next();
    assertEquals("package hasPreview", c.getName());
    assertEquals(new Revision(1, 0, 0), ((RepoPackage) c.getKey()).getVersion());
    c = componentIter.next();
    assertEquals("package newerPreview", c.getName());
    assertEquals(new Revision(1, 0, 0, 1), ((RepoPackage) c.getKey()).getVersion());
    c = componentIter.next();
    assertEquals("package newerRemote", c.getName());
    assertEquals(new Revision(1, 0, 0), ((RepoPackage) c.getKey()).getVersion());
    c = componentIter.next();
    assertEquals("package noRemote", c.getName());
    assertEquals(new Revision(1, 0, 0), ((RepoPackage) c.getKey()).getVersion());
    c = componentIter.next();
    assertEquals("package olderPreview", c.getName());
    assertEquals(new Revision(2, 0, 0), ((RepoPackage) c.getKey()).getVersion());
    c = componentIter.next();
    assertEquals("package olderRemote", c.getName());
    assertEquals(new Revision(1, 2, 0), ((RepoPackage) c.getKey()).getVersion());
    c = componentIter.next();
    assertEquals("package samePreview", c.getName());
    assertEquals(new Revision(1, 0, 0, 1), ((RepoPackage) c.getKey()).getVersion());
    c = componentIter.next();
    assertEquals("package sameRemote", c.getName());
    assertEquals(new Revision(1, 0, 0), ((RepoPackage) c.getKey()).getVersion());
    c = componentIter.next();
    assertEquals("package zNewerInBeta", c.getName());
    assertEquals(new Revision(1, 0, 0), ((RepoPackage) c.getKey()).getVersion());
    assertFalse(componentIter.hasNext());
}
Also used : Revision(com.android.repository.Revision) UpdatableExternalComponent(com.intellij.ide.externalComponents.UpdatableExternalComponent)

Aggregations

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