@Test public void updateNow_notEnabled_whenSdkUpToDate() { ManagedCloudSdkService managedCloudSdkService = mock(ManagedCloudSdkService.class); when(mockCloudSdkServiceManager.getCloudSdkService()).thenReturn(managedCloudSdkService); when(managedCloudSdkService.getStatus()).thenReturn(SdkStatus.READY); when(managedCloudSdkService.isUpToDate()).thenReturn(true); ApplicationManager.getApplication() .invokeAndWait( () -> { // use non-spy panel as spy messes up with UI event thread field updates. CloudSdkPanel sdkPanel = new CloudSdkPanel(); CloudSdkServiceUserSettings.getInstance() .setUserSelectedSdkServiceType(CloudSdkServiceType.MANAGED_SDK); sdkPanel.reset(); assertThat(sdkPanel.getUpdateNowButton().isEnabled()).isFalse(); }); }
@Test public void updateNow_enabled_whenSdkReadyToUpdate() { ManagedCloudSdkService managedCloudSdkService = mock(ManagedCloudSdkService.class); when(mockCloudSdkServiceManager.getCloudSdkService()).thenReturn(managedCloudSdkService); when(managedCloudSdkService.getStatus()).thenReturn(SdkStatus.READY); when(managedCloudSdkService.isUpToDate()).thenReturn(false); ApplicationManager.getApplication() .invokeAndWait( () -> { // use non-spy panel as spy messes up with UI event thread field updates. CloudSdkPanel sdkPanel = new CloudSdkPanel(); CloudSdkServiceUserSettings.getInstance() .setUserSelectedSdkServiceType(CloudSdkServiceType.MANAGED_SDK); sdkPanel.reset(); assertThat(sdkPanel.getUpdateNowButton().isEnabled()).isTrue(); }); }
@Test public void updateNow_notEnabled_whenSdkNotReady() { when(mockCloudSdkService.getStatus()).thenReturn(SdkStatus.INSTALLING); ApplicationManager.getApplication() .invokeAndWait( () -> { // use non-spy panel as spy messes up with UI event thread field updates. CloudSdkPanel sdkPanel = new CloudSdkPanel(); CloudSdkServiceUserSettings.getInstance() .setUserSelectedSdkServiceType(CloudSdkServiceType.MANAGED_SDK); sdkPanel.reset(); assertThat(sdkPanel.getUpdateNowButton().isEnabled()).isFalse(); }); }