Search in sources :

Example 1 with SdkUpdater

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

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

the class ManagedCloudSdkServiceTest method cancelled_update_keepsSdkStatus_available.

@Test
public void cancelled_update_keepsSdkStatus_available() throws Exception {
    makeMockSdkInstalled(MOCK_SDK_PATH);
    emulateMockSdkUpdateProcess();
    SdkUpdater mockUpdater = mockManagedCloudSdk.newUpdater();
    doThrow(new CancellationException()).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 : CancellationException(java.util.concurrent.CancellationException) SdkUpdater(com.google.cloud.tools.managedcloudsdk.components.SdkUpdater) SdkStatus(com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService.SdkStatus) Test(org.junit.Test)

Example 3 with SdkUpdater

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

the class ManagedCloudSdkServiceTest method interrupted_update_keepsSdkStatus_available.

@Test
public void interrupted_update_keepsSdkStatus_available() throws Exception {
    makeMockSdkInstalled(MOCK_SDK_PATH);
    emulateMockSdkUpdateProcess();
    SdkUpdater mockUpdater = mockManagedCloudSdk.newUpdater();
    doThrow(new InterruptedException()).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) SdkStatus(com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService.SdkStatus) Test(org.junit.Test)

Example 4 with SdkUpdater

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

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

the class ManagedCloudSdkServiceTest method cancelled_update_showsNotification.

@Test
public void cancelled_update_showsNotification() throws Exception {
    makeMockSdkInstalled(MOCK_SDK_PATH);
    emulateMockSdkUpdateProcess();
    SdkUpdater mockUpdater = mockManagedCloudSdk.newUpdater();
    doThrow(new CancellationException()).when(mockUpdater).update(any(), any());
    sdkService.update();
    verify(mockUiPresenter).notifyManagedSdkJobCancellation(ManagedSdkJobType.UPDATE);
}
Also used : CancellationException(java.util.concurrent.CancellationException) SdkUpdater(com.google.cloud.tools.managedcloudsdk.components.SdkUpdater) Test(org.junit.Test)

Aggregations

SdkUpdater (com.google.cloud.tools.managedcloudsdk.components.SdkUpdater)6 Test (org.junit.Test)5 SdkStatus (com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService.SdkStatus)4 CommandExitException (com.google.cloud.tools.managedcloudsdk.command.CommandExitException)3 CancellationException (java.util.concurrent.CancellationException)3 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 IOException (java.io.IOException)1