Search in sources :

Example 1 with SdkComponentInstaller

use of com.google.cloud.tools.managedcloudsdk.components.SdkComponentInstaller 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 2 with SdkComponentInstaller

use of com.google.cloud.tools.managedcloudsdk.components.SdkComponentInstaller in project google-cloud-intellij by GoogleCloudPlatform.

the class ManagedCloudSdkServiceTest method failed_install_appEngineException_changesSdkStatus_inProgress.

@Test
public void failed_install_appEngineException_changesSdkStatus_inProgress() throws Exception {
    sdkService.addStatusUpdateListener(mockStatusUpdateListener);
    emulateMockSdkInstallationProcess(MOCK_SDK_PATH);
    SdkComponentInstaller mockComponentInstaller = mockManagedCloudSdk.newComponentInstaller();
    doThrow(new CommandExecutionException(new UnsupportedOperationException())).when(mockComponentInstaller).installComponent(any(), any(), any());
    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 : SdkComponentInstaller(com.google.cloud.tools.managedcloudsdk.components.SdkComponentInstaller) CommandExecutionException(com.google.cloud.tools.managedcloudsdk.command.CommandExecutionException) SdkStatus(com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService.SdkStatus) Test(org.junit.Test)

Aggregations

CommandExecutionException (com.google.cloud.tools.managedcloudsdk.command.CommandExecutionException)2 SdkComponentInstaller (com.google.cloud.tools.managedcloudsdk.components.SdkComponentInstaller)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 CommandExitException (com.google.cloud.tools.managedcloudsdk.command.CommandExitException)1 SdkInstaller (com.google.cloud.tools.managedcloudsdk.install.SdkInstaller)1 IOException (java.io.IOException)1 CancellationException (java.util.concurrent.CancellationException)1 Test (org.junit.Test)1