com.google.cloud.tools.managedcloudsdk.ManagedSdkVersionMismatchException Java Examples

The following examples show how to use com.google.cloud.tools.managedcloudsdk.ManagedSdkVersionMismatchException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CloudSdkUpdateJobTest.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Test
public void testRun_sdkInstalled_noUpdateIfUpToDate()
    throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException,
        InterruptedException {
  when(managedCloudSdk.isInstalled()).thenReturn(true);
  when(managedCloudSdk.isUpToDate()).thenReturn(true);

  CloudSdkUpdateJob job = newCloudSdkUpdateJob();
  job.schedule();
  job.join();

  assertTrue(job.getResult().isOK());
  verify(managedCloudSdk).isInstalled();
  verify(managedCloudSdk).isUpToDate();
  verify(managedCloudSdk).getSdkHome(); // used to log version
  verify(managedCloudSdk, never()).newUpdater();
  verifyNoMoreInteractions(managedCloudSdk);
}
 
Example #2
Source File: CloudSdkInstallJobTest.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Test
public void testRun_sdkInstalled_componentNotInstalled()
    throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException,
        InterruptedException, CommandExecutionException, CommandExitException {
  when(managedCloudSdk.isInstalled()).thenReturn(true);
  when(managedCloudSdk.hasComponent(any(SdkComponent.class))).thenReturn(false);

  CloudSdkInstallJob job = newCloudSdkInstallJob();
  job.schedule();
  job.join();

  assertTrue(job.getResult().isOK());
  verify(managedCloudSdk, never()).newInstaller();
  verify(managedCloudSdk).newComponentInstaller();
  verify(componentInstaller)
      .installComponent(
          any(SdkComponent.class), any(ProgressListener.class), any(ConsoleListener.class));
}
 
Example #3
Source File: DownloadCloudSdkTaskTest.java    From app-gradle-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void testDownloadCloudSdkAction_installMultipleComponents()
    throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException,
        InterruptedException, CommandExecutionException, SdkInstallerException, IOException,
        CommandExitException {
  downloadCloudSdkTask.setManagedCloudSdk(managedCloudSdk);
  downloadCloudSdkTask.requiresComponent(SdkComponent.APP_ENGINE_JAVA);
  downloadCloudSdkTask.requiresComponent(SdkComponent.BETA);
  when(managedCloudSdk.isInstalled()).thenReturn(true);
  when(managedCloudSdk.hasComponent(SdkComponent.APP_ENGINE_JAVA)).thenReturn(false);
  when(managedCloudSdk.hasComponent(SdkComponent.BETA)).thenReturn(false);
  downloadCloudSdkTask.downloadCloudSdkAction();
  verify(managedCloudSdk, never()).newInstaller();
  verify(managedCloudSdk, times(2)).newComponentInstaller();
  verify(componentInstaller).installComponent(eq(SdkComponent.APP_ENGINE_JAVA), any(), any());
  verify(componentInstaller).installComponent(eq(SdkComponent.BETA), any(), any());
}
 
Example #4
Source File: DownloadCloudSdkTaskTest.java    From app-gradle-plugin with Apache License 2.0 6 votes vote down vote up
@Test
public void testDownloadCloudSdkAction_installSomeOfMultipleComponents()
    throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException,
        InterruptedException, CommandExecutionException, SdkInstallerException, IOException,
        CommandExitException {
  downloadCloudSdkTask.setManagedCloudSdk(managedCloudSdk);
  downloadCloudSdkTask.requiresComponent(SdkComponent.APP_ENGINE_JAVA);
  downloadCloudSdkTask.requiresComponent(SdkComponent.BETA);
  when(managedCloudSdk.isInstalled()).thenReturn(true);
  when(managedCloudSdk.hasComponent(SdkComponent.APP_ENGINE_JAVA)).thenReturn(false);
  when(managedCloudSdk.hasComponent(SdkComponent.BETA)).thenReturn(true);
  downloadCloudSdkTask.downloadCloudSdkAction();
  verify(managedCloudSdk, never()).newInstaller();
  verify(managedCloudSdk).newComponentInstaller();
  verify(componentInstaller).installComponent(eq(SdkComponent.APP_ENGINE_JAVA), any(), any());
}
 
Example #5
Source File: CloudSdkInstallJobTest.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Test
public void testFailureSeverity()
    throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException,
        InterruptedException, IOException, SdkInstallerException, CommandExecutionException,
        CommandExitException {
  when(managedCloudSdk.isInstalled()).thenReturn(false);
  when(managedCloudSdk.hasComponent(any(SdkComponent.class))).thenReturn(false);
  SdkInstallerException installerException = new SdkInstallerException("unsupported");
  when(managedCloudSdk.newInstaller()).thenReturn(sdkInstaller);
  when(sdkInstaller.install(any(ProgressWrapper.class), any(ConsoleListener.class)))
      .thenThrow(installerException);

  CloudSdkInstallJob job = newCloudSdkInstallJob();
  job.schedule();
  job.join();

  IStatus result = job.getResult();
  assertEquals(IStatus.WARNING, result.getSeverity());
  assertEquals("Failed to install the Google Cloud SDK.", result.getMessage());
  assertEquals(installerException, result.getException());
}
 
Example #6
Source File: CloudSdkInstallJobTest.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Test
public void testRun_notInstalled()
    throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException,
        InterruptedException, IOException, SdkInstallerException, CommandExecutionException,
        CommandExitException {
  when(managedCloudSdk.isInstalled()).thenReturn(false);
  when(managedCloudSdk.hasComponent(any(SdkComponent.class))).thenReturn(false);

  CloudSdkInstallJob job = newCloudSdkInstallJob();
  job.schedule();
  job.join();

  assertTrue(job.getResult().isOK());
  verify(managedCloudSdk).newInstaller();
  verify(managedCloudSdk).newComponentInstaller();
  verify(sdkInstaller).install(any(ProgressListener.class), any(ConsoleListener.class));
  verify(componentInstaller)
      .installComponent(
          any(SdkComponent.class), any(ProgressListener.class), any(ConsoleListener.class));
}
 
Example #7
Source File: CloudSdkUpdateJobTest.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Test
public void testRun_sdkInstalled_updateSuccess()
    throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException,
        InterruptedException, CommandExecutionException, CommandExitException {
  when(managedCloudSdk.isInstalled()).thenReturn(true);
  when(managedCloudSdk.isUpToDate()).thenReturn(false);
  when(managedCloudSdk.newUpdater()).thenReturn(sdkUpdater);

  CloudSdkUpdateJob job = newCloudSdkUpdateJob();
  job.schedule();
  job.join();

  assertTrue(job.getResult().isOK());
  verify(managedCloudSdk).isInstalled();
  verify(managedCloudSdk).isUpToDate();
  verify(managedCloudSdk).newUpdater();
  verify(sdkUpdater).update(any(ProgressListener.class), any(ConsoleListener.class));
  verify(managedCloudSdk, times(2)).getSdkHome(); // used to log old and new versions
  verifyNoMoreInteractions(managedCloudSdk);
}
 
Example #8
Source File: ManagedCloudSdkStartupTest.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Test
public void testNotifiedIfInstalledAndOutOfDate()
    throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException {
  doReturn(true).when(installation).isInstalled();
  doReturn(false).when(installation).isUpToDate();

  ManagedCloudSdkStartup startup = new ManagedCloudSdkStartup(workbench);
  startup.checkInstallation(sdkManager, installation, null);
  verify(installation).isInstalled();
  verify(installation).isUpToDate();
  verify(installation).getSdkHome(); // used to get version
  // indirectly check that the user was notified of the update
  verify(workbench).getDisplay();
  verify(display).asyncExec(any(Runnable.class));
  verifyNoMoreInteractions(sdkManager, installation, workbench, display);
}
 
Example #9
Source File: CloudSdkUpdateJobTest.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@Test
public void testRun_sdkInstalled_updateFailed()
    throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException,
        InterruptedException, CommandExitException, CommandExecutionException {
  when(managedCloudSdk.isInstalled()).thenReturn(true);
  when(managedCloudSdk.isUpToDate()).thenReturn(false);
  when(managedCloudSdk.newUpdater()).thenReturn(sdkUpdater);
  CommandExecutionException exception = new CommandExecutionException(new RuntimeException());
  doThrow(exception).when(sdkUpdater)
      .update(any(ProgressListener.class), any(ConsoleListener.class));

  CloudSdkUpdateJob job = newCloudSdkUpdateJob();
  job.schedule();
  job.join();

  assertEquals(IStatus.ERROR, job.getResult().getSeverity());
  assertEquals(exception, job.getResult().getException());
  verify(managedCloudSdk).isInstalled();
  verify(managedCloudSdk).isUpToDate();
  verify(managedCloudSdk).newUpdater();
  verify(sdkUpdater).update(any(ProgressListener.class), any(ConsoleListener.class));
  verify(managedCloudSdk).getSdkHome(); // used to obtain old version
  verifyNoMoreInteractions(managedCloudSdk);
}
 
Example #10
Source File: CloudSdkUpdateJobTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void testRun_errorWhenNotInstalled()
    throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException,
        InterruptedException {
  when(managedCloudSdk.isInstalled()).thenReturn(false);

  CloudSdkUpdateJob job = newCloudSdkUpdateJob();
  job.schedule();
  job.join();

  IStatus result = job.getResult();
  assertEquals(IStatus.ERROR, job.getResult().getSeverity());
  assertEquals("Google Cloud SDK is not installed", result.getMessage());
}
 
Example #11
Source File: CloudSdkDownloaderTest.java    From app-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testDownloadCloudSdk_update()
    throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException {
  when(managedCloudSdk.isInstalled()).thenReturn(true);
  when(managedCloudSdk.hasComponent(SdkComponent.APP_ENGINE_JAVA)).thenReturn(true);
  when(managedCloudSdk.isUpToDate()).thenReturn(false);
  downloader.downloadIfNecessary(
      version, log, ImmutableList.of(SdkComponent.APP_ENGINE_JAVA), false);
  verify(managedCloudSdk, never()).newInstaller();
  verify(managedCloudSdk, never()).newComponentInstaller();
  verify(managedCloudSdk).newUpdater();
}
 
Example #12
Source File: ManagedCloudSdkStartup.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
void checkInstallation(
    CloudSdkManager manager, ManagedCloudSdk installation, IProgressMonitor monitor)
    throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException {
  if (!installation.isInstalled()) {
    CloudSdkInstallNotification.showNotification(workbench, manager::installManagedSdkAsync);
  } else if (!installation.isUpToDate()) {
    CloudSdkVersion currentVersion = getVersion(installation.getSdkHome());
    CloudSdkUpdateNotification.showNotification(
        workbench, currentVersion, manager::updateManagedSdkAsync);
  }
}
 
Example #13
Source File: CloudSdkDownloaderTest.java    From app-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testDownloadCloudSdk_install()
    throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException {
  when(managedCloudSdk.isInstalled()).thenReturn(false);
  downloader.downloadIfNecessary(
      version, log, ImmutableList.of(SdkComponent.APP_ENGINE_JAVA), false);
  verify(managedCloudSdk).newInstaller();
}
 
Example #14
Source File: CloudSdkDownloaderTest.java    From app-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testDownloadCloudSdk_installSingeComponent()
    throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException {
  when(managedCloudSdk.isInstalled()).thenReturn(true);
  when(managedCloudSdk.hasComponent(SdkComponent.APP_ENGINE_JAVA)).thenReturn(false);
  downloader.downloadIfNecessary(
      version, log, ImmutableList.of(SdkComponent.APP_ENGINE_JAVA), false);
  verify(managedCloudSdk, never()).newInstaller();
  verify(managedCloudSdk).newComponentInstaller();
}
 
Example #15
Source File: CloudSdkDownloaderTest.java    From app-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testDownloadCloudSdk_installMultipleComponents()
    throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException,
        InterruptedException, CommandExitException, CommandExecutionException {
  when(managedCloudSdk.isInstalled()).thenReturn(true);
  when(managedCloudSdk.hasComponent(SdkComponent.APP_ENGINE_JAVA)).thenReturn(false);
  when(managedCloudSdk.hasComponent(SdkComponent.BETA)).thenReturn(false);
  downloader.downloadIfNecessary(
      version, log, ImmutableList.of(SdkComponent.APP_ENGINE_JAVA, SdkComponent.BETA), false);
  verify(managedCloudSdk, never()).newInstaller();
  verify(managedCloudSdk, times(2)).newComponentInstaller();
  verify(componentInstaller).installComponent(eq(SdkComponent.APP_ENGINE_JAVA), any(), any());
  verify(componentInstaller).installComponent(eq(SdkComponent.BETA), any(), any());
}
 
Example #16
Source File: CloudSdkDownloaderTest.java    From app-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testDownloadCloudSdk_installSomeOfMultipleComponents()
    throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException,
        InterruptedException, CommandExitException, CommandExecutionException {
  when(managedCloudSdk.isInstalled()).thenReturn(true);
  when(managedCloudSdk.hasComponent(SdkComponent.APP_ENGINE_JAVA)).thenReturn(false);
  when(managedCloudSdk.hasComponent(SdkComponent.BETA)).thenReturn(true);
  downloader.downloadIfNecessary(
      version, log, ImmutableList.of(SdkComponent.APP_ENGINE_JAVA, SdkComponent.BETA), false);
  verify(managedCloudSdk, never()).newInstaller();
  verify(managedCloudSdk).newComponentInstaller();
  verify(componentInstaller).installComponent(eq(SdkComponent.APP_ENGINE_JAVA), any(), any());
}
 
Example #17
Source File: CloudSdkDownloaderTest.java    From app-maven-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testDownloadCloudSdk_ignoreComponents()
    throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException {
  when(managedCloudSdk.isInstalled()).thenReturn(true);
  downloader.downloadIfNecessary(version, log, Collections.emptyList(), false);
  verify(managedCloudSdk, never()).newInstaller();
  verify(managedCloudSdk, never()).newComponentInstaller();
}
 
Example #18
Source File: DownloadCloudSdkTask.java    From app-gradle-plugin with Apache License 2.0 5 votes vote down vote up
/** Task entrypoint : Download/update Cloud SDK. */
@TaskAction
public void downloadCloudSdkAction()
    throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException,
        InterruptedException, CommandExecutionException, SdkInstallerException,
        CommandExitException, IOException {
  // managedCloudSdk is set by AppEngineCorePluginConfiguration if the cloud SDK home is empty
  if (managedCloudSdk == null) {
    throw new GradleException("Cloud SDK home path must not be configured to run this task.");
  }

  ProgressListener progressListener = new NoOpProgressListener();
  ConsoleListener consoleListener = new DownloadCloudSdkTaskConsoleListener(getProject());

  // Install sdk if not installed
  if (!managedCloudSdk.isInstalled()) {
    SdkInstaller installer = managedCloudSdk.newInstaller();
    installer.install(progressListener, consoleListener);
  }

  // install components
  if (components != null) {
    for (SdkComponent component : components) {
      if (!managedCloudSdk.hasComponent(component)) {
        managedCloudSdk
            .newComponentInstaller()
            .installComponent(component, progressListener, consoleListener);
      }
    }
  }

  // If version is set to LATEST, update Cloud SDK
  if (!managedCloudSdk.isUpToDate()) {
    SdkUpdater updater = managedCloudSdk.newUpdater();
    updater.update(progressListener, consoleListener);
  }
}
 
Example #19
Source File: CloudSdkInstallJobTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void testRun_alreadyInstalled()
    throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException,
        InterruptedException {
  when(managedCloudSdk.isInstalled()).thenReturn(true);
  when(managedCloudSdk.hasComponent(any(SdkComponent.class))).thenReturn(true);

  CloudSdkInstallJob job = newCloudSdkInstallJob();
  job.schedule();
  job.join();

  assertTrue(job.getResult().isOK());
  verify(managedCloudSdk, never()).newInstaller();
  verify(managedCloudSdk, never()).newComponentInstaller();
}
 
Example #20
Source File: CloudSdkInstallJobTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void testRun_consoleStreamOutput()
    throws InterruptedException, ManagedSdkVerificationException,
        ManagedSdkVersionMismatchException {
  when(managedCloudSdk.isInstalled()).thenReturn(false);
  when(managedCloudSdk.hasComponent(any(SdkComponent.class))).thenReturn(false);

  CloudSdkInstallJob job = newCloudSdkInstallJob();
  job.schedule();
  job.join();

  verify(consoleStream).println("[Installing Google Cloud SDK]");
}
 
Example #21
Source File: CloudSdkInstallJobTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException {
  when(managedCloudSdk.isInstalled()).thenReturn(true);
  when(managedCloudSdk.hasComponent(any(SdkComponent.class))).thenReturn(true);
  when(managedCloudSdk.newInstaller()).thenReturn(sdkInstaller);
  when(managedCloudSdk.newComponentInstaller()).thenReturn(componentInstaller);
}
 
Example #22
Source File: ManagedCloudSdkStartupTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void testInstalledAndUpToDate()
    throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException {
  doReturn(true).when(installation).isInstalled();
  doReturn(true).when(installation).isUpToDate();

  ManagedCloudSdkStartup startup = new ManagedCloudSdkStartup(workbench);
  startup.checkInstallation(sdkManager, installation, null);
  verify(installation).isInstalled();
  verify(installation).isUpToDate();
  verifyNoMoreInteractions(sdkManager, installation, workbench, display);
}
 
Example #23
Source File: ManagedCloudSdkStartupTest.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Test
public void testNotifiedIfNotInstalled()
    throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException {
  doReturn(false).when(installation).isInstalled();
  doReturn(false).when(installation).isUpToDate();

  ManagedCloudSdkStartup startup = new ManagedCloudSdkStartup(workbench);
  startup.checkInstallation(sdkManager, installation, null);
  verify(installation).isInstalled();
  // indirectly check that the user was notified of the update
  verify(workbench).getDisplay();
  verify(display).asyncExec(any(Runnable.class));
  verifyNoMoreInteractions(sdkManager, installation, workbench, display);
}
 
Example #24
Source File: DownloadCloudSdkTaskTest.java    From app-gradle-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testDownloadCloudSdkAction_update()
    throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException,
        InterruptedException, CommandExecutionException, SdkInstallerException, IOException,
        CommandExitException {
  downloadCloudSdkTask.setManagedCloudSdk(managedCloudSdk);
  when(managedCloudSdk.isInstalled()).thenReturn(true);
  when(managedCloudSdk.isUpToDate()).thenReturn(false);
  downloadCloudSdkTask.downloadCloudSdkAction();
  verify(managedCloudSdk, never()).newInstaller();
  verify(managedCloudSdk, never()).newComponentInstaller();
  verify(managedCloudSdk).newUpdater();
}
 
Example #25
Source File: DownloadCloudSdkTaskTest.java    From app-gradle-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testDownloadCloudSdkAction_skipInstallComponent()
    throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException,
        InterruptedException, CommandExecutionException, SdkInstallerException, IOException,
        CommandExitException {
  downloadCloudSdkTask.setManagedCloudSdk(managedCloudSdk);
  downloadCloudSdkTask.requiresComponent(SdkComponent.APP_ENGINE_JAVA);
  when(managedCloudSdk.isInstalled()).thenReturn(true);
  when(managedCloudSdk.hasComponent(SdkComponent.APP_ENGINE_JAVA)).thenReturn(true);
  downloadCloudSdkTask.downloadCloudSdkAction();
  verify(managedCloudSdk, never()).newInstaller();
  verify(managedCloudSdk, never()).newComponentInstaller();
}
 
Example #26
Source File: DownloadCloudSdkTaskTest.java    From app-gradle-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testDownloadCloudSdkAction_installComponent()
    throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException,
        InterruptedException, CommandExecutionException, SdkInstallerException, IOException,
        CommandExitException {
  downloadCloudSdkTask.setManagedCloudSdk(managedCloudSdk);
  downloadCloudSdkTask.requiresComponent(SdkComponent.APP_ENGINE_JAVA);
  when(managedCloudSdk.isInstalled()).thenReturn(true);
  when(managedCloudSdk.hasComponent(SdkComponent.APP_ENGINE_JAVA)).thenReturn(false);
  downloadCloudSdkTask.downloadCloudSdkAction();
  verify(managedCloudSdk, never()).newInstaller();
  verify(managedCloudSdk).newComponentInstaller();
  verify(componentInstaller).installComponent(eq(SdkComponent.APP_ENGINE_JAVA), any(), any());
}
 
Example #27
Source File: DownloadCloudSdkTaskTest.java    From app-gradle-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testDownloadCloudSdkAction_install()
    throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException,
        InterruptedException, CommandExecutionException, SdkInstallerException, IOException,
        CommandExitException {
  downloadCloudSdkTask.setManagedCloudSdk(managedCloudSdk);
  when(managedCloudSdk.isInstalled()).thenReturn(false);
  downloadCloudSdkTask.downloadCloudSdkAction();
  verify(managedCloudSdk).newInstaller();
  verify(managedCloudSdk, never()).newComponentInstaller();
}
 
Example #28
Source File: DownloadCloudSdkTaskTest.java    From app-gradle-plugin with Apache License 2.0 5 votes vote down vote up
@Test
public void testDownloadCloudSdkAction_badConfigure()
    throws CommandExecutionException, InterruptedException, SdkInstallerException,
        ManagedSdkVersionMismatchException, CommandExitException, ManagedSdkVerificationException,
        IOException {
  downloadCloudSdkTask.setManagedCloudSdk(null);
  try {
    downloadCloudSdkTask.downloadCloudSdkAction();
    Assert.fail();
  } catch (GradleException ex) {
    Assert.assertEquals(
        "Cloud SDK home path must not be configured to run this task.", ex.getMessage());
  }
}
 
Example #29
Source File: CloudSdkUpdateJobTest.java    From google-cloud-eclipse with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException {
  when(managedCloudSdk.isInstalled()).thenReturn(true);
  when(managedCloudSdk.newUpdater()).thenReturn(sdkUpdater);
}
 
Example #30
Source File: CloudSdkDownloader.java    From app-maven-plugin with Apache License 2.0 4 votes vote down vote up
/**
 * Downloads/installs/updates the Cloud SDK.
 *
 * @return The cloud SDK installation directory
 */
public Path downloadIfNecessary(
    String version, Log log, List<SdkComponent> components, boolean offline) {
  ManagedCloudSdk managedCloudSdk = managedCloudSdkFactory.apply(version);
  if (offline) { // in offline mode, don't download anything
    return managedCloudSdk.getSdkHome();
  }
  try {
    ProgressListener progressListener = new NoOpProgressListener();
    ConsoleListener consoleListener = new CloudSdkDownloaderConsoleListener(log);

    if (!managedCloudSdk.isInstalled()) {
      managedCloudSdk.newInstaller().install(progressListener, consoleListener);
    }

    // install requested components
    if (components != null) {
      for (SdkComponent component : components) {
        if (!managedCloudSdk.hasComponent(component)) {
          managedCloudSdk
              .newComponentInstaller()
              .installComponent(component, progressListener, consoleListener);
        }
      }
    }

    if (!managedCloudSdk.isUpToDate()) {
      managedCloudSdk.newUpdater().update(progressListener, consoleListener);
    }

    return managedCloudSdk.getSdkHome();
  } catch (IOException
      | SdkInstallerException
      | ManagedSdkVersionMismatchException
      | InterruptedException
      | CommandExecutionException
      | CommandExitException
      | ManagedSdkVerificationException ex) {
    throw new RuntimeException(ex);
  }
}