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);
}
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);
}
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));
}
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);
}
}
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);
}
Aggregations