Search in sources :

Example 1 with SdkInstaller

use of com.google.cloud.tools.managedcloudsdk.install.SdkInstaller in project google-cloud-intellij by GoogleCloudPlatform.

the class ManagedCloudSdkServiceTest method interruptedInstall_showsCancelNotification.

@Test
public void interruptedInstall_showsCancelNotification() throws Exception {
    emulateMockSdkInstallationProcess(MOCK_SDK_PATH);
    SdkInstaller sdkInstaller = mockManagedCloudSdk.newInstaller();
    when(sdkInstaller.install(any(), any())).thenThrow(new InterruptedException());
    when(mockManagedCloudSdk.newInstaller()).thenReturn(sdkInstaller);
    sdkService.install();
    verify(mockUiPresenter).notifyManagedSdkJobCancellation(ManagedSdkJobType.INSTALL);
}
Also used : SdkInstaller(com.google.cloud.tools.managedcloudsdk.install.SdkInstaller) Test(org.junit.Test)

Example 2 with SdkInstaller

use of com.google.cloud.tools.managedcloudsdk.install.SdkInstaller in project google-cloud-intellij by GoogleCloudPlatform.

the class ManagedCloudSdkServiceTest method cancelledInstall_showsCancelNotification.

@Test
public void cancelledInstall_showsCancelNotification() throws Exception {
    emulateMockSdkInstallationProcess(MOCK_SDK_PATH);
    SdkInstaller sdkInstaller = mockManagedCloudSdk.newInstaller();
    when(sdkInstaller.install(any(), any())).thenThrow(new CancellationException());
    when(mockManagedCloudSdk.newInstaller()).thenReturn(sdkInstaller);
    sdkService.install();
    verify(mockUiPresenter).notifyManagedSdkJobCancellation(ManagedSdkJobType.INSTALL);
}
Also used : SdkInstaller(com.google.cloud.tools.managedcloudsdk.install.SdkInstaller) CancellationException(java.util.concurrent.CancellationException) Test(org.junit.Test)

Example 3 with SdkInstaller

use of com.google.cloud.tools.managedcloudsdk.install.SdkInstaller in project google-cloud-intellij by GoogleCloudPlatform.

the class ManagedCloudSdkServiceTest method failed_install_changesSdkStatus_inProgress.

@Test
public void failed_install_changesSdkStatus_inProgress() throws Exception {
    sdkService.addStatusUpdateListener(mockStatusUpdateListener);
    emulateMockSdkInstallationProcess(MOCK_SDK_PATH);
    SdkInstaller mockInstaller = mockManagedCloudSdk.newInstaller();
    when(mockInstaller.install(any(), any())).thenThrow(new IOException("IO Error"));
    sdkService.install();
    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 : SdkInstaller(com.google.cloud.tools.managedcloudsdk.install.SdkInstaller) IOException(java.io.IOException) SdkStatus(com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService.SdkStatus) Test(org.junit.Test)

Example 4 with SdkInstaller

use of com.google.cloud.tools.managedcloudsdk.install.SdkInstaller in project google-cloud-intellij by GoogleCloudPlatform.

the class ManagedCloudSdkServiceTest method emulateMockSdkInstallationProcess.

/**
 * Mocks successful installation process with all steps included (SDK, App Engine Java).
 */
private void emulateMockSdkInstallationProcess(Path mockSdkPath) {
    try {
        when(mockManagedCloudSdk.isInstalled()).thenReturn(false);
        SdkInstaller mockInstaller = mock(SdkInstaller.class);
        when(mockManagedCloudSdk.newInstaller()).thenReturn(mockInstaller);
        when(mockInstaller.install(any(), any())).thenReturn(mockSdkPath);
        when(mockManagedCloudSdk.hasComponent(SdkComponent.APP_ENGINE_JAVA)).thenReturn(false);
        SdkComponentInstaller mockComponentInstaller = mock(SdkComponentInstaller.class);
        when(mockManagedCloudSdk.newComponentInstaller()).thenReturn(mockComponentInstaller);
        when(mockManagedCloudSdk.getSdkHome()).thenReturn(mockSdkPath);
    } catch (Exception ex) {
        // shouldn't happen in the tests.
        throw new AssertionError(ex);
    }
}
Also used : SdkInstaller(com.google.cloud.tools.managedcloudsdk.install.SdkInstaller) SdkComponentInstaller(com.google.cloud.tools.managedcloudsdk.components.SdkComponentInstaller) ManagedSdkVerificationException(com.google.cloud.tools.managedcloudsdk.ManagedSdkVerificationException) UnsupportedOsException(com.google.cloud.tools.managedcloudsdk.UnsupportedOsException) CommandExitException(com.google.cloud.tools.managedcloudsdk.command.CommandExitException) CommandExecutionException(com.google.cloud.tools.managedcloudsdk.command.CommandExecutionException) CancellationException(java.util.concurrent.CancellationException) IOException(java.io.IOException)

Example 5 with SdkInstaller

use of com.google.cloud.tools.managedcloudsdk.install.SdkInstaller in project google-cloud-intellij by GoogleCloudPlatform.

the class ManagedCloudSdkServiceTest method interruptedInstall_status_notAvailable.

@Test
public void interruptedInstall_status_notAvailable() throws Exception {
    emulateMockSdkInstallationProcess(MOCK_SDK_PATH);
    SdkInstaller sdkInstaller = mockManagedCloudSdk.newInstaller();
    when(sdkInstaller.install(any(), any())).thenThrow(new InterruptedException());
    when(mockManagedCloudSdk.newInstaller()).thenReturn(sdkInstaller);
    sdkService.install();
    assertThat(sdkService.getStatus()).isEqualTo(SdkStatus.NOT_AVAILABLE);
}
Also used : SdkInstaller(com.google.cloud.tools.managedcloudsdk.install.SdkInstaller) Test(org.junit.Test)

Aggregations

SdkInstaller (com.google.cloud.tools.managedcloudsdk.install.SdkInstaller)7 Test (org.junit.Test)6 IOException (java.io.IOException)4 CancellationException (java.util.concurrent.CancellationException)2 SdkStatus (com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService.SdkStatus)1 ManagedSdkVerificationException (com.google.cloud.tools.managedcloudsdk.ManagedSdkVerificationException)1 UnsupportedOsException (com.google.cloud.tools.managedcloudsdk.UnsupportedOsException)1 CommandExecutionException (com.google.cloud.tools.managedcloudsdk.command.CommandExecutionException)1 CommandExitException (com.google.cloud.tools.managedcloudsdk.command.CommandExitException)1 SdkComponentInstaller (com.google.cloud.tools.managedcloudsdk.components.SdkComponentInstaller)1