com.google.cloud.tools.managedcloudsdk.command.CommandExitException Java Examples
The following examples show how to use
com.google.cloud.tools.managedcloudsdk.command.CommandExitException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CloudSdkInstallJobTest.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
@Test public void testRun_notInstalled() throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException, InterruptedException, IOException, SdkInstallerException, CommandExecutionException, CommandExitException { when(managedCloudSdk.isInstalled()).thenReturn(false); when(managedCloudSdk.hasComponent(any(SdkComponent.class))).thenReturn(false); CloudSdkInstallJob job = newCloudSdkInstallJob(); job.schedule(); job.join(); assertTrue(job.getResult().isOK()); verify(managedCloudSdk).newInstaller(); verify(managedCloudSdk).newComponentInstaller(); verify(sdkInstaller).install(any(ProgressListener.class), any(ConsoleListener.class)); verify(componentInstaller) .installComponent( any(SdkComponent.class), any(ProgressListener.class), any(ConsoleListener.class)); }
Example #2
Source File: ManagedCloudSdkTest.java From appengine-plugins-core with Apache License 2.0 | 6 votes |
private void downgradeCloudSdk(ManagedCloudSdk testSdk) throws InterruptedException, CommandExitException, CommandExecutionException, UnsupportedOsException { Map<String, String> env = null; if (OsInfo.getSystemOsInfo().name().equals(OsInfo.Name.WINDOWS)) { env = WindowsBundledPythonCopierTestHelper.newInstance(testSdk.getGcloudPath()).copyPython(); } CommandRunner.newRunner() .run( Arrays.asList( testSdk.getGcloudPath().toString(), "components", "update", "--quiet", "--version=" + FIXED_VERSION), null, env, testListener); }
Example #3
Source File: WindowsBundledPythonCopier.java From appengine-plugins-core with Apache License 2.0 | 6 votes |
@Override public Map<String, String> copyPython() throws InterruptedException, CommandExitException, CommandExecutionException { List<String> copyPythonCommand = Arrays.asList(gcloud.toString(), "components", "copy-bundled-python"); // The path returned from gcloud points to the "python.exe" binary, e.g., // c:/users/ieuser/appdata/local/temp/tmpjmkt_z/python/python.exe // However, it may not copy but return an existing Python executable. // // A trim() required to remove newlines from call result. Using new lines in windows // environment passed through via ProcessBuilder will result in cryptic : "The syntax of // the command is incorrect." String pythonExePath = commandCaller.call(copyPythonCommand, null, null).trim(); if (isUnderTempDirectory(pythonExePath, System.getenv())) { Runtime.getRuntime().addShutdownHook(new Thread(() -> deleteCopiedPython(pythonExePath))); } return ImmutableMap.of("CLOUDSDK_PYTHON", pythonExePath); }
Example #4
Source File: SdkComponentInstaller.java From appengine-plugins-core with Apache License 2.0 | 6 votes |
/** * Install a component. * * @param component component to install * @param progressListener listener to action progress feedback * @param consoleListener listener to process console feedback */ public void installComponent( SdkComponent component, ProgressListener progressListener, ConsoleListener consoleListener) throws InterruptedException, CommandExitException, CommandExecutionException { progressListener.start("Installing " + component.toString(), ProgressListener.UNKNOWN); Map<String, String> environment = null; if (pythonCopier != null) { environment = pythonCopier.copyPython(); } Path workingDirectory = gcloudPath.getRoot(); List<String> command = Arrays.asList( gcloudPath.toString(), "components", "install", component.toString(), "--quiet"); commandRunner.run(command, workingDirectory, environment, consoleListener); progressListener.done(); }
Example #5
Source File: SdkInstallerTest.java From appengine-plugins-core with Apache License 2.0 | 6 votes |
@Test public void testDownloadSdk_failedDownload() throws InterruptedException, CommandExecutionException, CommandExitException, IOException { SdkInstaller testInstaller = new SdkInstaller( fileResourceProviderFactory, failureDownloaderFactory, successfulLatestExtractorFactory, successfulInstallerFactory); try { testInstaller.install(progressListener, consoleListener); Assert.fail("SdKInstallerException expected but not thrown"); } catch (SdkInstallerException ex) { Assert.assertEquals( "Download succeeded but valid archive not found at " + fakeArchiveDestination.toString(), ex.getMessage()); } }
Example #6
Source File: Installer.java From appengine-plugins-core with Apache License 2.0 | 6 votes |
/** Install a cloud sdk (only run this on LATEST). */ public void install() throws CommandExitException, CommandExecutionException, InterruptedException { List<String> command = new ArrayList<>(installScriptProvider.getScriptCommandLine(installedSdkRoot)); command.add("--path-update=false"); // don't update user's path command.add("--command-completion=false"); // don't add command completion command.add("--quiet"); // don't accept user input during install command.add("--usage-reporting=" + usageReporting); // usage reporting passthrough Path workingDirectory = installedSdkRoot.getParent(); Map<String, String> installerEnvironment = installScriptProvider.getScriptEnvironment(); progressListener.start("Installing Cloud SDK", ProgressListener.UNKNOWN); commandRunner.run(command, workingDirectory, installerEnvironment, consoleListener); progressListener.done(); }
Example #7
Source File: SdkInstallerTest.java From appengine-plugins-core with Apache License 2.0 | 6 votes |
@Test public void testDownloadSdk_failedExtraction() throws InterruptedException, IOException, CommandExitException, CommandExecutionException { SdkInstaller testInstaller = new SdkInstaller( fileResourceProviderFactory, successfulDownloaderFactory, failureExtractorFactory, successfulInstallerFactory); try { testInstaller.install(progressListener, consoleListener); Assert.fail("SdKInstallerException expected but not thrown"); } catch (SdkInstallerException ex) { Assert.assertEquals( "Extraction succeeded but valid sdk home not found at " + fakeSdkHome.toString(), ex.getMessage()); } }
Example #8
Source File: CloudSdkInstallJobTest.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
@Test public void testFailureSeverity() throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException, InterruptedException, IOException, SdkInstallerException, CommandExecutionException, CommandExitException { when(managedCloudSdk.isInstalled()).thenReturn(false); when(managedCloudSdk.hasComponent(any(SdkComponent.class))).thenReturn(false); SdkInstallerException installerException = new SdkInstallerException("unsupported"); when(managedCloudSdk.newInstaller()).thenReturn(sdkInstaller); when(sdkInstaller.install(any(ProgressWrapper.class), any(ConsoleListener.class))) .thenThrow(installerException); CloudSdkInstallJob job = newCloudSdkInstallJob(); job.schedule(); job.join(); IStatus result = job.getResult(); assertEquals(IStatus.WARNING, result.getSeverity()); assertEquals("Failed to install the Google Cloud SDK.", result.getMessage()); assertEquals(installerException, result.getException()); }
Example #9
Source File: CloudSdkInstallJobTest.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
@Test public void testRun_sdkInstalled_componentNotInstalled() throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException, InterruptedException, CommandExecutionException, CommandExitException { when(managedCloudSdk.isInstalled()).thenReturn(true); when(managedCloudSdk.hasComponent(any(SdkComponent.class))).thenReturn(false); CloudSdkInstallJob job = newCloudSdkInstallJob(); job.schedule(); job.join(); assertTrue(job.getResult().isOK()); verify(managedCloudSdk, never()).newInstaller(); verify(managedCloudSdk).newComponentInstaller(); verify(componentInstaller) .installComponent( any(SdkComponent.class), any(ProgressListener.class), any(ConsoleListener.class)); }
Example #10
Source File: CloudSdkUpdateJobTest.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
@Test public void testRun_sdkInstalled_updateSuccess() throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException, InterruptedException, CommandExecutionException, CommandExitException { when(managedCloudSdk.isInstalled()).thenReturn(true); when(managedCloudSdk.isUpToDate()).thenReturn(false); when(managedCloudSdk.newUpdater()).thenReturn(sdkUpdater); CloudSdkUpdateJob job = newCloudSdkUpdateJob(); job.schedule(); job.join(); assertTrue(job.getResult().isOK()); verify(managedCloudSdk).isInstalled(); verify(managedCloudSdk).isUpToDate(); verify(managedCloudSdk).newUpdater(); verify(sdkUpdater).update(any(ProgressListener.class), any(ConsoleListener.class)); verify(managedCloudSdk, times(2)).getSdkHome(); // used to log old and new versions verifyNoMoreInteractions(managedCloudSdk); }
Example #11
Source File: DownloadCloudSdkTaskTest.java From app-gradle-plugin with Apache License 2.0 | 6 votes |
@Test public void testDownloadCloudSdkAction_installSomeOfMultipleComponents() throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException, InterruptedException, CommandExecutionException, SdkInstallerException, IOException, CommandExitException { downloadCloudSdkTask.setManagedCloudSdk(managedCloudSdk); downloadCloudSdkTask.requiresComponent(SdkComponent.APP_ENGINE_JAVA); downloadCloudSdkTask.requiresComponent(SdkComponent.BETA); when(managedCloudSdk.isInstalled()).thenReturn(true); when(managedCloudSdk.hasComponent(SdkComponent.APP_ENGINE_JAVA)).thenReturn(false); when(managedCloudSdk.hasComponent(SdkComponent.BETA)).thenReturn(true); downloadCloudSdkTask.downloadCloudSdkAction(); verify(managedCloudSdk, never()).newInstaller(); verify(managedCloudSdk).newComponentInstaller(); verify(componentInstaller).installComponent(eq(SdkComponent.APP_ENGINE_JAVA), any(), any()); }
Example #12
Source File: DownloadCloudSdkTaskTest.java From app-gradle-plugin with Apache License 2.0 | 6 votes |
@Test public void testDownloadCloudSdkAction_installMultipleComponents() throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException, InterruptedException, CommandExecutionException, SdkInstallerException, IOException, CommandExitException { downloadCloudSdkTask.setManagedCloudSdk(managedCloudSdk); downloadCloudSdkTask.requiresComponent(SdkComponent.APP_ENGINE_JAVA); downloadCloudSdkTask.requiresComponent(SdkComponent.BETA); when(managedCloudSdk.isInstalled()).thenReturn(true); when(managedCloudSdk.hasComponent(SdkComponent.APP_ENGINE_JAVA)).thenReturn(false); when(managedCloudSdk.hasComponent(SdkComponent.BETA)).thenReturn(false); downloadCloudSdkTask.downloadCloudSdkAction(); verify(managedCloudSdk, never()).newInstaller(); verify(managedCloudSdk, times(2)).newComponentInstaller(); verify(componentInstaller).installComponent(eq(SdkComponent.APP_ENGINE_JAVA), any(), any()); verify(componentInstaller).installComponent(eq(SdkComponent.BETA), any(), any()); }
Example #13
Source File: CloudSdkUpdateJobTest.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
@Test public void testRun_sdkInstalled_updateFailed() throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException, InterruptedException, CommandExitException, CommandExecutionException { when(managedCloudSdk.isInstalled()).thenReturn(true); when(managedCloudSdk.isUpToDate()).thenReturn(false); when(managedCloudSdk.newUpdater()).thenReturn(sdkUpdater); CommandExecutionException exception = new CommandExecutionException(new RuntimeException()); doThrow(exception).when(sdkUpdater) .update(any(ProgressListener.class), any(ConsoleListener.class)); CloudSdkUpdateJob job = newCloudSdkUpdateJob(); job.schedule(); job.join(); assertEquals(IStatus.ERROR, job.getResult().getSeverity()); assertEquals(exception, job.getResult().getException()); verify(managedCloudSdk).isInstalled(); verify(managedCloudSdk).isUpToDate(); verify(managedCloudSdk).newUpdater(); verify(sdkUpdater).update(any(ProgressListener.class), any(ConsoleListener.class)); verify(managedCloudSdk).getSdkHome(); // used to obtain old version verifyNoMoreInteractions(managedCloudSdk); }
Example #14
Source File: SdkInstallerTest.java From appengine-plugins-core with Apache License 2.0 | 6 votes |
@Test public void testDownloadSdk_failedInstallation() throws InterruptedException, IOException, CommandExitException, CommandExecutionException { SdkInstaller testInstaller = new SdkInstaller( fileResourceProviderFactory, successfulDownloaderFactory, successfulLatestExtractorFactory, failureInstallerFactory); try { testInstaller.install(progressListener, consoleListener); Assert.fail("SdKInstallerException expected but not thrown"); } catch (SdkInstallerException ex) { Assert.assertEquals( "Installation succeeded but gcloud executable not found at " + fakeGcloud.toString(), ex.getMessage()); } }
Example #15
Source File: WindowsBundledPythonCopierTest.java From appengine-plugins-core with Apache License 2.0 | 5 votes |
@Test public void testCopyPython() throws InterruptedException, CommandExitException, CommandExecutionException { WindowsBundledPythonCopier testCopier = new WindowsBundledPythonCopier(fakeGcloud, mockCommandCaller); Map<String, String> testEnv = testCopier.copyPython(); Assert.assertEquals(ImmutableMap.of("CLOUDSDK_PYTHON", "copied-python"), testEnv); }
Example #16
Source File: SdkComponentInstallerTest.java From appengine-plugins-core with Apache License 2.0 | 5 votes |
@Before public void setUpMocks() throws InterruptedException, CommandExitException, CommandExecutionException { Path root = FileSystems.getDefault().getRootDirectories().iterator().next(); fakeGcloudPath = root.resolve("my/path/to/fake-gcloud"); Mockito.when(mockBundledPythonCopier.copyPython()).thenReturn(mockPythonEnv); }
Example #17
Source File: SdkComponentInstallerTest.java From appengine-plugins-core with Apache License 2.0 | 5 votes |
@Test public void testInstallComponent_successRun() throws InterruptedException, CommandExitException, CommandExecutionException { SdkComponentInstaller testInstaller = new SdkComponentInstaller(fakeGcloudPath, mockCommandRunner, null); testInstaller.installComponent(testComponent, mockProgressListener, mockConsoleListener); Mockito.verify(mockProgressListener).start(Mockito.anyString(), Mockito.eq(-1L)); Mockito.verify(mockProgressListener).done(); Mockito.verify(mockCommandRunner) .run( Mockito.eq(expectedCommand()), Mockito.nullable(Path.class), Mockito.<Map<String, String>>any(), Mockito.eq(mockConsoleListener)); }
Example #18
Source File: SdkComponentInstallerTest.java From appengine-plugins-core with Apache License 2.0 | 5 votes |
@Test public void testInstallComponent_withBundledPythonCopier() throws InterruptedException, CommandExitException, CommandExecutionException { SdkComponentInstaller testInstaller = new SdkComponentInstaller(fakeGcloudPath, mockCommandRunner, mockBundledPythonCopier); testInstaller.installComponent(testComponent, mockProgressListener, mockConsoleListener); Mockito.verify(mockProgressListener).start(Mockito.anyString(), Mockito.eq(-1L)); Mockito.verify(mockProgressListener).done(); Mockito.verify(mockCommandRunner) .run( Mockito.eq(expectedCommand()), Mockito.nullable(Path.class), Mockito.eq(mockPythonEnv), Mockito.eq(mockConsoleListener)); }
Example #19
Source File: SdkInstallerTest.java From appengine-plugins-core with Apache License 2.0 | 5 votes |
@Test public void testDownloadSdk_successRunWithoutExplicitInstall() throws CommandExecutionException, InterruptedException, IOException, CommandExitException, SdkInstallerException { SdkInstaller testInstaller = new SdkInstaller( fileResourceProviderFactory, successfulDownloaderFactory, successfulVersionedExtractorFactory, null); Path result = testInstaller.install(progressListener, consoleListener); Assert.assertEquals(fakeSdkHome, result); }
Example #20
Source File: SdkComponentInstallerTest.java From appengine-plugins-core with Apache License 2.0 | 5 votes |
@Test public void testInstallComponent_workingDirectorySet() throws InterruptedException, CommandExitException, CommandExecutionException { SdkComponentInstaller testInstaller = new SdkComponentInstaller(fakeGcloudPath, mockCommandRunner, null); testInstaller.installComponent(testComponent, mockProgressListener, mockConsoleListener); Mockito.verify(mockCommandRunner) .run( Mockito.anyList(), Mockito.eq(fakeGcloudPath.getRoot()), Mockito.<Map<String, String>>any(), Mockito.any(ConsoleListener.class)); }
Example #21
Source File: SdkUpdaterTest.java From appengine-plugins-core with Apache License 2.0 | 5 votes |
@Before public void setUpFakesAndMocks() throws InterruptedException, CommandExitException, CommandExecutionException { Path root = FileSystems.getDefault().getRootDirectories().iterator().next(); fakeGcloudPath = root.resolve("my/path/to/fake-gcloud"); Mockito.when(mockBundledPythonCopier.copyPython()).thenReturn(mockPythonEnv); }
Example #22
Source File: SdkUpdaterTest.java From appengine-plugins-core with Apache License 2.0 | 5 votes |
@Test public void testUpdate_successRun() throws InterruptedException, CommandExitException, CommandExecutionException { SdkUpdater testUpdater = new SdkUpdater(fakeGcloudPath, mockCommandRunner, null); testUpdater.update(mockProgressListener, mockConsoleListener); Mockito.verify(mockProgressListener).start(Mockito.anyString(), Mockito.eq(-1L)); Mockito.verify(mockProgressListener).done(); Mockito.verify(mockCommandRunner) .run( Mockito.eq(expectedCommand()), Mockito.nullable(Path.class), Mockito.<Map<String, String>>any(), Mockito.eq(mockConsoleListener)); }
Example #23
Source File: SdkUpdaterTest.java From appengine-plugins-core with Apache License 2.0 | 5 votes |
@Test public void testUpdate_withBundledPythonCopier() throws InterruptedException, CommandExitException, CommandExecutionException { SdkUpdater testUpdater = new SdkUpdater(fakeGcloudPath, mockCommandRunner, mockBundledPythonCopier); testUpdater.update(mockProgressListener, mockConsoleListener); Mockito.verify(mockProgressListener).start(Mockito.anyString(), Mockito.eq(-1L)); Mockito.verify(mockProgressListener).done(); Mockito.verify(mockCommandRunner) .run( Mockito.eq(expectedCommand()), Mockito.nullable(Path.class), Mockito.eq(mockPythonEnv), Mockito.eq(mockConsoleListener)); }
Example #24
Source File: SdkUpdaterTest.java From appengine-plugins-core with Apache License 2.0 | 5 votes |
@Test public void testInstallComponent_workingDirectorySet() throws InterruptedException, CommandExitException, CommandExecutionException { SdkUpdater testUpdater = new SdkUpdater(fakeGcloudPath, mockCommandRunner, null); testUpdater.update(mockProgressListener, mockConsoleListener); Mockito.verify(mockCommandRunner) .run( Mockito.anyList(), Mockito.eq(fakeGcloudPath.getRoot()), Mockito.<Map<String, String>>any(), Mockito.any(ConsoleListener.class)); }
Example #25
Source File: CloudSdkDownloaderTest.java From app-maven-plugin with Apache License 2.0 | 5 votes |
@Test public void testDownloadCloudSdk_installMultipleComponents() throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException, InterruptedException, CommandExitException, CommandExecutionException { when(managedCloudSdk.isInstalled()).thenReturn(true); when(managedCloudSdk.hasComponent(SdkComponent.APP_ENGINE_JAVA)).thenReturn(false); when(managedCloudSdk.hasComponent(SdkComponent.BETA)).thenReturn(false); downloader.downloadIfNecessary( version, log, ImmutableList.of(SdkComponent.APP_ENGINE_JAVA, SdkComponent.BETA), false); verify(managedCloudSdk, never()).newInstaller(); verify(managedCloudSdk, times(2)).newComponentInstaller(); verify(componentInstaller).installComponent(eq(SdkComponent.APP_ENGINE_JAVA), any(), any()); verify(componentInstaller).installComponent(eq(SdkComponent.BETA), any(), any()); }
Example #26
Source File: CloudSdkDownloaderTest.java From app-maven-plugin with Apache License 2.0 | 5 votes |
@Test public void testDownloadCloudSdk_installSomeOfMultipleComponents() throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException, InterruptedException, CommandExitException, CommandExecutionException { when(managedCloudSdk.isInstalled()).thenReturn(true); when(managedCloudSdk.hasComponent(SdkComponent.APP_ENGINE_JAVA)).thenReturn(false); when(managedCloudSdk.hasComponent(SdkComponent.BETA)).thenReturn(true); downloader.downloadIfNecessary( version, log, ImmutableList.of(SdkComponent.APP_ENGINE_JAVA, SdkComponent.BETA), false); verify(managedCloudSdk, never()).newInstaller(); verify(managedCloudSdk).newComponentInstaller(); verify(componentInstaller).installComponent(eq(SdkComponent.APP_ENGINE_JAVA), any(), any()); }
Example #27
Source File: DownloadCloudSdkTask.java From app-gradle-plugin with Apache License 2.0 | 5 votes |
/** Task entrypoint : Download/update Cloud SDK. */ @TaskAction public void downloadCloudSdkAction() throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException, InterruptedException, CommandExecutionException, SdkInstallerException, CommandExitException, IOException { // managedCloudSdk is set by AppEngineCorePluginConfiguration if the cloud SDK home is empty if (managedCloudSdk == null) { throw new GradleException("Cloud SDK home path must not be configured to run this task."); } ProgressListener progressListener = new NoOpProgressListener(); ConsoleListener consoleListener = new DownloadCloudSdkTaskConsoleListener(getProject()); // Install sdk if not installed if (!managedCloudSdk.isInstalled()) { SdkInstaller installer = managedCloudSdk.newInstaller(); installer.install(progressListener, consoleListener); } // install components if (components != null) { for (SdkComponent component : components) { if (!managedCloudSdk.hasComponent(component)) { managedCloudSdk .newComponentInstaller() .installComponent(component, progressListener, consoleListener); } } } // If version is set to LATEST, update Cloud SDK if (!managedCloudSdk.isUpToDate()) { SdkUpdater updater = managedCloudSdk.newUpdater(); updater.update(progressListener, consoleListener); } }
Example #28
Source File: DownloadCloudSdkTaskTest.java From app-gradle-plugin with Apache License 2.0 | 5 votes |
@Test public void testDownloadCloudSdkAction_badConfigure() throws CommandExecutionException, InterruptedException, SdkInstallerException, ManagedSdkVersionMismatchException, CommandExitException, ManagedSdkVerificationException, IOException { downloadCloudSdkTask.setManagedCloudSdk(null); try { downloadCloudSdkTask.downloadCloudSdkAction(); Assert.fail(); } catch (GradleException ex) { Assert.assertEquals( "Cloud SDK home path must not be configured to run this task.", ex.getMessage()); } }
Example #29
Source File: DownloadCloudSdkTaskTest.java From app-gradle-plugin with Apache License 2.0 | 5 votes |
@Test public void testDownloadCloudSdkAction_install() throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException, InterruptedException, CommandExecutionException, SdkInstallerException, IOException, CommandExitException { downloadCloudSdkTask.setManagedCloudSdk(managedCloudSdk); when(managedCloudSdk.isInstalled()).thenReturn(false); downloadCloudSdkTask.downloadCloudSdkAction(); verify(managedCloudSdk).newInstaller(); verify(managedCloudSdk, never()).newComponentInstaller(); }
Example #30
Source File: DownloadCloudSdkTaskTest.java From app-gradle-plugin with Apache License 2.0 | 5 votes |
@Test public void testDownloadCloudSdkAction_installComponent() throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException, InterruptedException, CommandExecutionException, SdkInstallerException, IOException, CommandExitException { downloadCloudSdkTask.setManagedCloudSdk(managedCloudSdk); downloadCloudSdkTask.requiresComponent(SdkComponent.APP_ENGINE_JAVA); when(managedCloudSdk.isInstalled()).thenReturn(true); when(managedCloudSdk.hasComponent(SdkComponent.APP_ENGINE_JAVA)).thenReturn(false); downloadCloudSdkTask.downloadCloudSdkAction(); verify(managedCloudSdk, never()).newInstaller(); verify(managedCloudSdk).newComponentInstaller(); verify(componentInstaller).installComponent(eq(SdkComponent.APP_ENGINE_JAVA), any(), any()); }