com.google.cloud.tools.managedcloudsdk.components.SdkComponent Java Examples
The following examples show how to use
com.google.cloud.tools.managedcloudsdk.components.SdkComponent.
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: CloudSdkAppEngineFactoryTest.java From app-maven-plugin with Apache License 2.0 | 6 votes |
@Before public void wireUp() { when(mojoMock.getCloudSdkHome()).thenReturn(CLOUD_SDK_HOME); when(mojoMock.getCloudSdkVersion()).thenReturn(null); when(mojoMock.getArtifactId()).thenReturn(ARTIFACT_ID); when(mojoMock.getArtifactVersion()).thenReturn(ARTIFACT_VERSION); when(mojoMock.getLog()).thenReturn(logMock); when(mojoMock.getMavenSession()).thenReturn(mavenSession); when(mavenSession.isOffline()).thenReturn(false); doReturn(INSTALL_SDK_PATH) .when(cloudSdkDownloader) .downloadIfNecessary( Mockito.isNull(), Mockito.eq(logMock), Mockito.<SdkComponent>anyList(), Mockito.anyBoolean()); doReturn(INSTALL_SDK_PATH) .when(cloudSdkDownloader) .downloadIfNecessary( Mockito.anyString(), Mockito.eq(logMock), Mockito.<SdkComponent>anyList(), Mockito.anyBoolean()); }
Example #2
Source File: CloudSdkAppEngineFactoryTest.java From app-maven-plugin with Apache License 2.0 | 6 votes |
@Test public void testBuildCloudSdk_downloadWithVersion() { when(mojoMock.getCloudSdkHome()).thenReturn(null); when(mojoMock.getCloudSdkVersion()).thenReturn(CLOUD_SDK_VERSION); // invoke CloudSdk sdk = CloudSdkAppEngineFactory.buildCloudSdk(mojoMock, cloudSdkChecker, cloudSdkDownloader, true); // verify Assert.assertEquals(INSTALL_SDK_PATH, sdk.getPath()); verify(cloudSdkDownloader) .downloadIfNecessary( CLOUD_SDK_VERSION, logMock, ImmutableList.of(SdkComponent.APP_ENGINE_JAVA), false); verifyNoMoreInteractions(cloudSdkChecker); }
Example #3
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 #4
Source File: AppEngineCorePluginConfigurationTest.java From app-gradle-plugin with Apache License 2.0 | 6 votes |
@Test public void testCreateDownloadSdkTask_configureAppEngineComponent() throws IOException { Project project = new TestProject(testProjectDir.getRoot()) .addAppEngineWebXml() .applyStandardProjectBuilder(); DownloadCloudSdkTask task = (DownloadCloudSdkTask) project .getTasks() .getByPath(AppEngineCorePluginConfiguration.DOWNLOAD_CLOUD_SDK_TASK_NAME); List<SdkComponent> components = task.getComponents(); Assert.assertThat(components, Matchers.hasItem(SdkComponent.APP_ENGINE_JAVA)); Assert.assertEquals(1, components.size()); }
Example #5
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 #6
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 #7
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 #8
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 #9
Source File: CloudSdkAppEngineFactoryTest.java From app-maven-plugin with Apache License 2.0 | 6 votes |
@Test public void testBuildCloudSdk_offlinePassthrough() { when(mojoMock.getCloudSdkHome()).thenReturn(null); when(mojoMock.getCloudSdkVersion()).thenReturn(null); when(mavenSession.isOffline()).thenReturn(true); // invoke CloudSdk sdk = CloudSdkAppEngineFactory.buildCloudSdk(mojoMock, cloudSdkChecker, cloudSdkDownloader, true); Assert.assertEquals(INSTALL_SDK_PATH, sdk.getPath()); verify(cloudSdkDownloader) .downloadIfNecessary(null, logMock, ImmutableList.of(SdkComponent.APP_ENGINE_JAVA), true); verify(mavenSession).isOffline(); verifyNoMoreInteractions(cloudSdkChecker); }
Example #10
Source File: CloudSdkDownloaderTest.java From app-maven-plugin with Apache License 2.0 | 5 votes |
@Test public void testDownloadCloudSdk_installSingeComponent() throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException { when(managedCloudSdk.isInstalled()).thenReturn(true); when(managedCloudSdk.hasComponent(SdkComponent.APP_ENGINE_JAVA)).thenReturn(false); downloader.downloadIfNecessary( version, log, ImmutableList.of(SdkComponent.APP_ENGINE_JAVA), false); verify(managedCloudSdk, never()).newInstaller(); verify(managedCloudSdk).newComponentInstaller(); }
Example #11
Source File: CloudSdkAppEngineFactoryTest.java From app-maven-plugin with Apache License 2.0 | 5 votes |
@Test public void testBuildCloudSdk_downloadWithoutVersion() { when(mojoMock.getCloudSdkHome()).thenReturn(null); when(mojoMock.getCloudSdkVersion()).thenReturn(null); // invoke CloudSdk sdk = CloudSdkAppEngineFactory.buildCloudSdk(mojoMock, cloudSdkChecker, cloudSdkDownloader, true); // verify Assert.assertEquals(INSTALL_SDK_PATH, sdk.getPath()); verify(cloudSdkDownloader) .downloadIfNecessary(null, logMock, ImmutableList.of(SdkComponent.APP_ENGINE_JAVA), false); verifyNoMoreInteractions(cloudSdkChecker); }
Example #12
Source File: CloudSdkDownloaderTest.java From app-maven-plugin with Apache License 2.0 | 5 votes |
@Test public void testDownloadCloudSdk_install() throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException { when(managedCloudSdk.isInstalled()).thenReturn(false); downloader.downloadIfNecessary( version, log, ImmutableList.of(SdkComponent.APP_ENGINE_JAVA), false); verify(managedCloudSdk).newInstaller(); }
Example #13
Source File: CloudSdkDownloaderTest.java From app-maven-plugin with Apache License 2.0 | 5 votes |
@Test public void testDownloadCloudSdk_offlineMode() { downloader.downloadIfNecessary( version, log, ImmutableList.of(SdkComponent.APP_ENGINE_JAVA), true); verify(managedCloudSdk).getSdkHome(); verifyNoMoreInteractions(managedCloudSdk); }
Example #14
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 #15
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 #16
Source File: CloudSdkDownloaderTest.java From app-maven-plugin with Apache License 2.0 | 5 votes |
@Test public void testDownloadCloudSdk_update() throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException { when(managedCloudSdk.isInstalled()).thenReturn(true); when(managedCloudSdk.hasComponent(SdkComponent.APP_ENGINE_JAVA)).thenReturn(true); when(managedCloudSdk.isUpToDate()).thenReturn(false); downloader.downloadIfNecessary( version, log, ImmutableList.of(SdkComponent.APP_ENGINE_JAVA), false); verify(managedCloudSdk, never()).newInstaller(); verify(managedCloudSdk, never()).newComponentInstaller(); verify(managedCloudSdk).newUpdater(); }
Example #17
Source File: AppEngineCorePluginConfiguration.java From app-gradle-plugin with Apache License 2.0 | 5 votes |
private void createDownloadCloudSdkTask() { project .getTasks() .create( DOWNLOAD_CLOUD_SDK_TASK_NAME, DownloadCloudSdkTask.class, downloadCloudSdkTask -> { downloadCloudSdkTask.setGroup(taskGroup); downloadCloudSdkTask.setDescription("Download the Cloud SDK"); // make sure we download our required components if (requiresAppEngineJava) { downloadCloudSdkTask.requiresComponent(SdkComponent.APP_ENGINE_JAVA); } project.afterEvaluate( p -> { if (managedCloudSdk != null) { downloadCloudSdkTask.setManagedCloudSdk(managedCloudSdk); if (p.getGradle().getStartParameter().isOffline()) { p.getLogger().debug("Skipping DownloadCloudSdk in --offline mode."); return; } p.getTasks() .matching(task -> task.getName().startsWith("appengine")) .forEach(task -> task.dependsOn(downloadCloudSdkTask)); } }); }); }
Example #18
Source File: CloudSdkAppEngineFactory.java From app-maven-plugin with Apache License 2.0 | 5 votes |
static CloudSdk buildCloudSdk( CloudSdkMojo mojo, CloudSdkChecker cloudSdkChecker, CloudSdkDownloader cloudSdkDownloader, boolean requiresAppEngineComponents) { try { if (mojo.getCloudSdkHome() != null) { // if user defined CloudSdk cloudSdk = new CloudSdk.Builder().sdkPath(mojo.getCloudSdkHome()).build(); if (mojo.getCloudSdkVersion() != null) { cloudSdkChecker.checkCloudSdk(cloudSdk, mojo.getCloudSdkVersion()); } if (requiresAppEngineComponents) { cloudSdkChecker.checkForAppEngine(cloudSdk); } return cloudSdk; } else { // we need to use a managed cloud sdk List<SdkComponent> requiredComponents = new ArrayList<>(); if (requiresAppEngineComponents) { requiredComponents.add(SdkComponent.APP_ENGINE_JAVA); } return new CloudSdk.Builder() .sdkPath( cloudSdkDownloader.downloadIfNecessary( mojo.getCloudSdkVersion(), mojo.getLog(), requiredComponents, mojo.getMavenSession().isOffline())) .build(); } } catch (CloudSdkNotFoundException | CloudSdkVersionFileException | AppEngineJavaComponentsNotInstalledException | CloudSdkOutOfDateException ex) { throw new RuntimeException(ex); } }
Example #19
Source File: CloudSdkInstallJobTest.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
@Test public void testRun_alreadyInstalled() throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException, InterruptedException { when(managedCloudSdk.isInstalled()).thenReturn(true); when(managedCloudSdk.hasComponent(any(SdkComponent.class))).thenReturn(true); CloudSdkInstallJob job = newCloudSdkInstallJob(); job.schedule(); job.join(); assertTrue(job.getResult().isOK()); verify(managedCloudSdk, never()).newInstaller(); verify(managedCloudSdk, never()).newComponentInstaller(); }
Example #20
Source File: CloudSdkInstallJobTest.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
@Test public void testRun_consoleStreamOutput() throws InterruptedException, ManagedSdkVerificationException, ManagedSdkVersionMismatchException { when(managedCloudSdk.isInstalled()).thenReturn(false); when(managedCloudSdk.hasComponent(any(SdkComponent.class))).thenReturn(false); CloudSdkInstallJob job = newCloudSdkInstallJob(); job.schedule(); job.join(); verify(consoleStream).println("[Installing Google Cloud SDK]"); }
Example #21
Source File: CloudSdkInstallJobTest.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
@Before public void setUp() throws ManagedSdkVerificationException, ManagedSdkVersionMismatchException { when(managedCloudSdk.isInstalled()).thenReturn(true); when(managedCloudSdk.hasComponent(any(SdkComponent.class))).thenReturn(true); when(managedCloudSdk.newInstaller()).thenReturn(sdkInstaller); when(managedCloudSdk.newComponentInstaller()).thenReturn(componentInstaller); }
Example #22
Source File: ManagedCloudSdk.java From appengine-plugins-core with Apache License 2.0 | 5 votes |
/** * Query gcloud to see if component is installed. Uses gcloud's '--local-state-only' to avoid * network accesses. */ public boolean hasComponent(SdkComponent component) throws ManagedSdkVerificationException { if (!Files.isRegularFile(getGcloudPath())) { return false; } List<String> listComponentCommand = Arrays.asList( getGcloudPath().toString(), "components", "list", "--only-local-state", "--format=json", "--filter=id:" + component); try { String result = CommandCaller.newCaller().call(listComponentCommand, null, null); List<CloudSdkComponent> components = CloudSdkComponent.fromJsonList(result); if (components.size() > 1) { // not a unique component id throw new ManagedSdkVerificationException("Invalid component " + component); } return !components.isEmpty(); } catch (CommandExecutionException | InterruptedException | CommandExitException ex) { throw new ManagedSdkVerificationException(ex); } }
Example #23
Source File: DownloadCloudSdkTaskTest.java From app-gradle-plugin with Apache License 2.0 | 5 votes |
@Test public void testDownloadCloudSdkAction_skipInstallComponent() 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(true); downloadCloudSdkTask.downloadCloudSdkAction(); verify(managedCloudSdk, never()).newInstaller(); verify(managedCloudSdk, never()).newComponentInstaller(); }
Example #24
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()); }
Example #25
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 #26
Source File: CloudSdkDownloader.java From app-maven-plugin with Apache License 2.0 | 4 votes |
/** * Downloads/installs/updates the Cloud SDK. * * @return The cloud SDK installation directory */ public Path downloadIfNecessary( String version, Log log, List<SdkComponent> components, boolean offline) { ManagedCloudSdk managedCloudSdk = managedCloudSdkFactory.apply(version); if (offline) { // in offline mode, don't download anything return managedCloudSdk.getSdkHome(); } try { ProgressListener progressListener = new NoOpProgressListener(); ConsoleListener consoleListener = new CloudSdkDownloaderConsoleListener(log); if (!managedCloudSdk.isInstalled()) { managedCloudSdk.newInstaller().install(progressListener, consoleListener); } // install requested components if (components != null) { for (SdkComponent component : components) { if (!managedCloudSdk.hasComponent(component)) { managedCloudSdk .newComponentInstaller() .installComponent(component, progressListener, consoleListener); } } } if (!managedCloudSdk.isUpToDate()) { managedCloudSdk.newUpdater().update(progressListener, consoleListener); } return managedCloudSdk.getSdkHome(); } catch (IOException | SdkInstallerException | ManagedSdkVersionMismatchException | InterruptedException | CommandExecutionException | CommandExitException | ManagedSdkVerificationException ex) { throw new RuntimeException(ex); } }
Example #27
Source File: DownloadCloudSdkTask.java From app-gradle-plugin with Apache License 2.0 | 4 votes |
@VisibleForTesting @Internal List<SdkComponent> getComponents() { return ImmutableList.copyOf(components); }
Example #28
Source File: DownloadCloudSdkTask.java From app-gradle-plugin with Apache License 2.0 | 4 votes |
public void requiresComponent(SdkComponent component) { components.add(component); }