Search in sources :

Example 1 with CommandExitException

use of com.google.cloud.tools.managedcloudsdk.command.CommandExitException in project google-cloud-intellij by GoogleCloudPlatform.

the class ManagedCloudSdkServiceTest method failed_update_invalidSdk_makesSdkStatus_notAvailable.

@Test
public void failed_update_invalidSdk_makesSdkStatus_notAvailable() throws Exception {
    makeMockSdkInstalled(MOCK_SDK_PATH);
    emulateMockSdkUpdateProcess();
    SdkUpdater mockUpdater = mockManagedCloudSdk.newUpdater();
    doThrow(new CommandExitException(-1, "")).when(mockUpdater).update(any(), any());
    // update breaks SDK
    when(mockManagedCloudSdk.isInstalled()).thenReturn(false);
    sdkService.addStatusUpdateListener(mockStatusUpdateListener);
    sdkService.update();
    ArgumentCaptor<SdkStatus> statusCaptor = ArgumentCaptor.forClass(SdkStatus.class);
    verify(mockStatusUpdateListener, times(2)).onSdkStatusChange(any(), statusCaptor.capture());
    assertThat(statusCaptor.getAllValues()).isEqualTo(Arrays.asList(SdkStatus.INSTALLING, SdkStatus.NOT_AVAILABLE));
}
Also used : SdkUpdater(com.google.cloud.tools.managedcloudsdk.components.SdkUpdater) CommandExitException(com.google.cloud.tools.managedcloudsdk.command.CommandExitException) SdkStatus(com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService.SdkStatus) Test(org.junit.Test)

Example 2 with CommandExitException

use of com.google.cloud.tools.managedcloudsdk.command.CommandExitException in project google-cloud-intellij by GoogleCloudPlatform.

the class ManagedCloudSdkServiceTest method failed_update_validSdk_sdkStatus_available.

@Test
public void failed_update_validSdk_sdkStatus_available() throws Exception {
    makeMockSdkInstalled(MOCK_SDK_PATH);
    emulateMockSdkUpdateProcess();
    SdkUpdater mockUpdater = mockManagedCloudSdk.newUpdater();
    doThrow(new CommandExitException(-1, "")).when(mockUpdater).update(any(), any());
    sdkService.addStatusUpdateListener(mockStatusUpdateListener);
    sdkService.update();
    ArgumentCaptor<SdkStatus> statusCaptor = ArgumentCaptor.forClass(SdkStatus.class);
    verify(mockStatusUpdateListener, times(2)).onSdkStatusChange(any(), statusCaptor.capture());
    assertThat(statusCaptor.getAllValues()).isEqualTo(Arrays.asList(SdkStatus.INSTALLING, SdkStatus.READY));
}
Also used : SdkUpdater(com.google.cloud.tools.managedcloudsdk.components.SdkUpdater) CommandExitException(com.google.cloud.tools.managedcloudsdk.command.CommandExitException) SdkStatus(com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService.SdkStatus) Test(org.junit.Test)

Example 3 with CommandExitException

use of com.google.cloud.tools.managedcloudsdk.command.CommandExitException in project app-maven-plugin by GoogleCloudPlatform.

the class CloudSdkDownloader method downloadCloudSdk.

/**
 * Downloads/installs/updates the Cloud SDK
 *
 * @return The cloud SDK installation directory
 */
public Path downloadCloudSdk(Log log) {
    try {
        ProgressListener progressListener = new NoOpProgressListener();
        ConsoleListener consoleListener = new CloudSdkDownloaderConsoleListener(log);
        if (!managedCloudSdk.isInstalled()) {
            managedCloudSdk.newInstaller().install(progressListener, consoleListener);
        }
        if (!managedCloudSdk.hasComponent(SdkComponent.APP_ENGINE_JAVA)) {
            managedCloudSdk.newComponentInstaller().installComponent(SdkComponent.APP_ENGINE_JAVA, 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);
    }
}
Also used : SdkInstallerException(com.google.cloud.tools.managedcloudsdk.install.SdkInstallerException) ManagedSdkVersionMismatchException(com.google.cloud.tools.managedcloudsdk.ManagedSdkVersionMismatchException) ConsoleListener(com.google.cloud.tools.managedcloudsdk.ConsoleListener) IOException(java.io.IOException) CommandExitException(com.google.cloud.tools.managedcloudsdk.command.CommandExitException) ProgressListener(com.google.cloud.tools.managedcloudsdk.ProgressListener) CommandExecutionException(com.google.cloud.tools.managedcloudsdk.command.CommandExecutionException) ManagedSdkVerificationException(com.google.cloud.tools.managedcloudsdk.ManagedSdkVerificationException)

Aggregations

CommandExitException (com.google.cloud.tools.managedcloudsdk.command.CommandExitException)3 SdkStatus (com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService.SdkStatus)2 SdkUpdater (com.google.cloud.tools.managedcloudsdk.components.SdkUpdater)2 Test (org.junit.Test)2 ConsoleListener (com.google.cloud.tools.managedcloudsdk.ConsoleListener)1 ManagedSdkVerificationException (com.google.cloud.tools.managedcloudsdk.ManagedSdkVerificationException)1 ManagedSdkVersionMismatchException (com.google.cloud.tools.managedcloudsdk.ManagedSdkVersionMismatchException)1 ProgressListener (com.google.cloud.tools.managedcloudsdk.ProgressListener)1 CommandExecutionException (com.google.cloud.tools.managedcloudsdk.command.CommandExecutionException)1 SdkInstallerException (com.google.cloud.tools.managedcloudsdk.install.SdkInstallerException)1 IOException (java.io.IOException)1