List of usage examples for org.springframework.ide.eclipse.boot.dash.cloudfoundry CloudAppDashElement getProject
@Override
public IProject getProject()
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void acceptDeployOfExistingApp() throws Exception { CFClientParams targetParams = CfTestTargetParams.fromEnv(); MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); IProject project = projects.createBootProject("to-deploy", withStarters("actuator", "web")); final String appName = "foo"; MockCFApplication deployedApp = space.defApp(appName); CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); waitForApps(model, appName);/*w w w. j a v a 2 s.c o m*/ CloudAppDashElement app = model.getApplication(appName); app.setProject(null); assertNull(app.getProject()); assertEquals(RunState.INACTIVE, app.getRunState()); harness.answerDeploymentPrompt(ui, appName, appName); Mockito.doReturn(true).when(ui).confirmOperation(same("Replace Existing Application"), any()); model.performDeployment(ImmutableSet.of(project), ui, RunState.RUNNING); System.out.println(app.getRunState()); waitForJobsToComplete(); System.out.println(app.getRunState()); assertEquals(project, app.getProject()); assertEquals(1, deployedApp.getPushCount()); verify(ui).confirmOperation(any(), any()); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void cancelDeployOfExistingApp() throws Exception { CFClientParams targetParams = CfTestTargetParams.fromEnv(); MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); IProject project = projects.createBootProject("to-deploy", withStarters("web", "actuator")); final String appName = "foo"; MockCFApplication deployedApp = space.defApp(appName); CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); waitForApps(model, appName);/*w w w. j a va 2 s .c o m*/ CloudAppDashElement app = model.getApplication(appName); app.setProject(null); assertNull(app.getProject()); harness.answerDeploymentPrompt(ui, appName, appName); doReturn(false).when(ui).confirmOperation(same("Replace Existing Application"), any()); model.performDeployment(ImmutableSet.of(project), ui, RunState.RUNNING); waitForJobsToComplete(); assertNull(app.getProject()); // since op was canceled it should not have set the project on the app. assertEquals(0, deployedApp.getPushCount()); // since op was canceled it should not have deployed the app. verify(ui).confirmOperation(any(), any()); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void testDeployManifestWithAbsolutePathAttribute() throws Exception { final String appName = "foo"; CFClientParams targetParams = CfTestTargetParams.fromEnv(); MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); IProject project = projects.createProject("to-deploy"); File zipFile = getTestZip("testapp"); IFile manifestFile = createFile(project, "manifest.yml", "applications:\n" + "- name: foo\n" + " path: " + zipFile.getAbsolutePath() + "\n" + " buildpack: staticfile_buildpack"); CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); harness.answerDeploymentPrompt(ui, manifestFile); model.performDeployment(ImmutableSet.of(project), ui, RunState.RUNNING); waitForApps(model, "foo"); CloudAppDashElement app = model.getApplication("foo"); waitForState(app, RunState.RUNNING, APP_DELETE_TIMEOUT); assertEquals(project, app.getProject()); assertEquals("some content here\n", space.getApplication(appName).getFileContents("test.txt")); verify(ui).promptApplicationDeploymentProperties(any()); verifyNoMoreInteractions(ui);//from w w w . j a va 2 s .co m }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void testDeployManifestWithRelativePathAttribute() throws Exception { final String appName = "foo"; CFClientParams targetParams = CfTestTargetParams.fromEnv(); MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); IProject project = projects.createProject("to-deploy"); File zipFile = getTestZip("testapp"); project.getFolder("zips").create(true, true, new NullProgressMonitor()); project.getFolder("manifests").create(true, true, new NullProgressMonitor()); createFile(project, "zips/testapp.zip", zipFile); IFile manifestFile = createFile(project, "manifests/manifest.yml", "applications:\n" + "- name: foo\n" + " path: ../zips/testapp.zip\n" + " buildpack: staticfile_buildpack"); CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); harness.answerDeploymentPrompt(ui, manifestFile); model.performDeployment(ImmutableSet.of(project), ui, RunState.RUNNING); waitForApps(model, "foo"); CloudAppDashElement app = model.getApplication("foo"); waitForState(app, RunState.RUNNING, APP_DEPLOY_TIMEOUT); assertEquals(project, app.getProject()); assertEquals("some content here\n", space.getApplication(appName).getFileContents("test.txt")); verify(ui).promptApplicationDeploymentProperties(any()); verifyNoMoreInteractions(ui);/*from ww w. j a v a2 s . co m*/ }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void testSelectManifestActionEnablement() throws Exception { CFClientParams targetParams = CfTestTargetParams.fromEnv(); MockCFSpace space = clientFactory.defSpace(targetParams.getOrgName(), targetParams.getSpaceName()); IProject project1 = projects.createProject("pr1"); IProject project2 = projects.createProject("pr2"); final String appName1 = "app1"; final String appName2 = "app2"; MockCFApplication cfApp1 = space.defApp(appName1); MockCFApplication cfApp2 = space.defApp(appName2); CloudFoundryBootDashModel model = harness.createCfTarget(targetParams); waitForApps(model, appName1, appName2); CloudAppDashElement app1 = model.getApplication(appName1); CloudAppDashElement app2 = model.getApplication(appName2); app1.setProject(project1);//from w w w.j av a2 s . c om app2.setProject(project2); IAction action = actions.getSelectManifestAction(); assertTrue(harness.selection.getElements().isEmpty()); assertFalse(action.isEnabled()); harness.selection.setElements(ImmutableSet.of(app1)); assertNotNull(app1.getProject()); assertTrue(action.isEnabled()); harness.selection.setElements(ImmutableSet.of(app1, app2)); assertFalse(action.isEnabled()); app1.setProject(null); harness.selection.setElements(ImmutableSet.of(app1)); assertFalse(action.isEnabled()); harness.selection.setElements(ImmutableSet.of(app2)); assertTrue(action.isEnabled()); action.run(); }
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
private CloudAppDashElement getApplication(CloudFoundryBootDashModel model, IProject project) { for (CloudAppDashElement app : model.getApplicationValues()) { IProject p = app.getProject(); if (project.equals(p)) { return app; }//from www . j a va 2 s . c o m } return null; }