Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add UpdateMavenProjectsDialog. MavenProject offers 'updateMavenProjec…
…t' method. (fixes #1876) Signed-off-by: Lukáš Valach <lvalach@redhat.com>
- Loading branch information
Showing
3 changed files
with
156 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
...c/org/eclipse/reddeer/eclipse/m2e/core/ui/internal/dialogs/UpdateMavenProjectsDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2017 Red Hat, Inc and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.reddeer.eclipse.m2e.core.ui.internal.dialogs; | ||
|
||
import org.eclipse.reddeer.common.wait.TimePeriod; | ||
import org.eclipse.reddeer.common.wait.WaitWhile; | ||
import org.eclipse.reddeer.jface.dialogs.TitleAreaDialog; | ||
import org.eclipse.reddeer.swt.condition.ShellIsAvailable; | ||
import org.eclipse.reddeer.swt.impl.button.CancelButton; | ||
import org.eclipse.reddeer.swt.impl.button.CheckBox; | ||
import org.eclipse.reddeer.swt.impl.button.OkButton; | ||
import org.eclipse.reddeer.workbench.core.condition.JobIsRunning; | ||
|
||
/** | ||
* Represends "Update Maven Project" dialog. Can operate OK and Cancel buttons and "Clean projects" checkbox. | ||
* | ||
* @author lvalach | ||
* | ||
*/ | ||
public class UpdateMavenProjectsDialog extends TitleAreaDialog { | ||
|
||
public static final String SHELL_TITLE = "Update Maven Project"; | ||
public static final String CLEAN_PROJECTS = "Clean projects"; | ||
|
||
public UpdateMavenProjectsDialog() { | ||
super(SHELL_TITLE); | ||
} | ||
|
||
/** | ||
* Click "OK" button. | ||
*/ | ||
public void ok() { | ||
ok(TimePeriod.LONG); | ||
} | ||
|
||
/** | ||
* Click "OK" button and wait while jobs are running for defined time period. | ||
*/ | ||
public void ok(TimePeriod waitForJobs) { | ||
new OkButton(this).click(); | ||
new WaitWhile(new ShellIsAvailable(SHELL_TITLE)); | ||
new WaitWhile(new JobIsRunning(), waitForJobs, false); | ||
} | ||
|
||
/** | ||
* Click "Cancel" button. | ||
*/ | ||
public void cancel() { | ||
new CancelButton(this).click(); | ||
new WaitWhile(new ShellIsAvailable(SHELL_TITLE)); | ||
} | ||
|
||
/** | ||
* Sets {@value #CLEAN_PROJECTS} checkbox to state "checked". | ||
* | ||
* @param checked | ||
* whether check or not | ||
*/ | ||
public void clean(Boolean checked) { | ||
new CheckBox(this, CLEAN_PROJECTS).toggle(checked); | ||
} | ||
|
||
/** | ||
* Returns true when Check Box {@value #CLEAN_PROJECTS} is checked. | ||
* | ||
* @return true, if is checked | ||
*/ | ||
public boolean isCleanChecked() { | ||
return new CheckBox(this, CLEAN_PROJECTS).isChecked(); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
...er.eclipse.test/src/org/eclipse/reddeer/eclipse/test/core/resources/MavenProjectTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2017 Red Hat, Inc and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* Red Hat Inc. - initial API and implementation | ||
*******************************************************************************/ | ||
|
||
package org.eclipse.reddeer.eclipse.test.core.resources; | ||
|
||
import org.eclipse.reddeer.common.wait.TimePeriod; | ||
import org.eclipse.reddeer.eclipse.core.resources.MavenProject; | ||
import org.eclipse.reddeer.eclipse.m2e.core.ui.wizard.MavenProjectWizard; | ||
import org.eclipse.reddeer.eclipse.m2e.core.ui.wizard.MavenProjectWizardArchetypeParametersPage; | ||
import org.eclipse.reddeer.eclipse.m2e.core.ui.wizard.MavenProjectWizardPage; | ||
import org.eclipse.reddeer.eclipse.test.debug.core.DebuggerTest; | ||
import org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer; | ||
import org.eclipse.reddeer.junit.runner.RedDeerSuite; | ||
import org.eclipse.reddeer.swt.api.TreeItem; | ||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
@RunWith(RedDeerSuite.class) | ||
public class MavenProjectTest { | ||
|
||
private static final String GROUP_ID = "mavenProjectTest"; | ||
private static final String ARTEFACT_ID = "mavenProjectTest"; | ||
|
||
@BeforeClass | ||
public static void createProject() { | ||
clean(); | ||
MavenProjectWizard mavenProjectWizard = new MavenProjectWizard(); | ||
mavenProjectWizard.open(); | ||
MavenProjectWizardPage newMavenProjectPage = new MavenProjectWizardPage(mavenProjectWizard); | ||
newMavenProjectPage.createSimpleProject(true); | ||
mavenProjectWizard.next(); | ||
MavenProjectWizardArchetypeParametersPage artifactPage = new MavenProjectWizardArchetypeParametersPage(mavenProjectWizard); | ||
artifactPage.setGroupId(GROUP_ID); | ||
artifactPage.setArtifactId(ARTEFACT_ID); | ||
mavenProjectWizard.finish(TimePeriod.VERY_LONG); | ||
} | ||
|
||
@Test | ||
public void updateMavenProject(){ | ||
ProjectExplorer pe = new ProjectExplorer(); | ||
TreeItem projectItem = pe.getProject(ARTEFACT_ID).getTreeItem(); | ||
MavenProject mavenProject = new MavenProject(projectItem); | ||
mavenProject.updateMavenProject(); | ||
} | ||
|
||
@AfterClass | ||
public static void clean() { | ||
ProjectExplorer pe = new ProjectExplorer(); | ||
pe.open(); | ||
pe.deleteAllProjects(true); | ||
} | ||
} |