/** Mocks managed SDK as if installed and having App Engine Component. */ private void makeMockSdkInstalled(Path mockSdkPath) { try { when(mockManagedCloudSdk.isInstalled()).thenReturn(true); when(mockManagedCloudSdk.hasComponent(SdkComponent.APP_ENGINE_JAVA)).thenReturn(true); when(mockManagedCloudSdk.getSdkHome()).thenReturn(mockSdkPath); } catch (Exception ex) { // shouldn't happen in the tests. throw new AssertionError(ex); } }
/** 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); } }
@Test public void testDownloadCloudSdkAction_installComponent() throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException, InterruptedException, CommandExecutionException, SdkInstallerException, IOException, CommandExitException { downloadCloudSdkTask.setManagedCloudSdk(managedCloudSdk); downloadCloudSdkTask.requiresAppEngineJava(true); when(managedCloudSdk.isInstalled()).thenReturn(true); when(managedCloudSdk.hasComponent(SdkComponent.APP_ENGINE_JAVA)).thenReturn(false); downloadCloudSdkTask.downloadCloudSdkAction(); verify(managedCloudSdk, never()).newInstaller(); verify(managedCloudSdk).newComponentInstaller(); }
private ManagedSdkJobResult installAppEngineJavaComponent() throws Exception { if (!safeCheckSdkStatus(() -> managedCloudSdk.hasComponent(SdkComponent.APP_ENGINE_JAVA))) { ConsoleListener appEngineConsoleListener = logger::debug; progressListener = ManagedCloudSdkServiceUiPresenter.getInstance().createProgressListener(this); notifySdkProcessingStarted(); executeWithSdkWriteLock( () -> managedCloudSdk .newComponentInstaller() .installComponent( SdkComponent.APP_ENGINE_JAVA, progressListener, appEngineConsoleListener)); return ManagedSdkJobResult.PROCESSED; } else { return ManagedSdkJobResult.UP_TO_DATE; } }
if (!managedCloudSdk.hasComponent(SdkComponent.APP_ENGINE_JAVA)) { SdkComponentInstaller componentInstaller = managedCloudSdk.newComponentInstaller(); componentInstaller.installComponent(
&& !managedCloudSdk.hasComponent(SdkComponent.APP_ENGINE_JAVA)) { managedCloudSdk .newComponentInstaller()