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