Search in sources :

Example 1 with MavenImportWizard

use of org.eclipse.reddeer.eclipse.m2e.core.ui.wizard.MavenImportWizard in project jbosstools-hibernate by jbosstools.

the class HibernateRedDeerTest method importMavenProject.

public static void importMavenProject(String prjName) {
    try {
        Path sourceFolder = new File("resources/prj/" + prjName).toPath();
        File dir = new File("target/" + prjName);
        if (dir.exists()) {
            deleteDir(dir);
        }
        Path destFolder = dir.toPath();
        Files.walkFileTree(sourceFolder, new SimpleFileVisitor<Path>() {

            @Override
            public FileVisitResult preVisitDirectory(final Path dir, final BasicFileAttributes attrs) throws IOException {
                Files.createDirectories(destFolder.resolve(sourceFolder.relativize(dir)));
                return FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException {
                Files.copy(file, destFolder.resolve(sourceFolder.relativize(file)));
                return FileVisitResult.CONTINUE;
            }
        });
        MavenImportWizard wizard = new MavenImportWizard();
        wizard.open();
        wizard.getWizardPage().setRootDirectory("target/" + prjName);
        wizard.getWizardPage().refresh();
        wizard.getWizardPage().waitUntilProjectIsLoaded(TimePeriod.LONG);
        Shell shell = new DefaultShell("Import Maven Projects");
        new PushButton("Finish").click();
        new WaitWhile(new ShellIsAvailable(shell), TimePeriod.DEFAULT);
        new WaitUntil(new JobIsRunning(), TimePeriod.DEFAULT, false);
        new WaitWhile(new JobIsRunning(), TimePeriod.VERY_LONG);
    } catch (IOException e) {
        fail("Unable to find pom " + prjName);
    }
// TODO check error log for errors
}
Also used : Path(java.nio.file.Path) ShellIsAvailable(org.eclipse.reddeer.swt.condition.ShellIsAvailable) MavenImportWizard(org.eclipse.reddeer.eclipse.m2e.core.ui.wizard.MavenImportWizard) FileVisitResult(java.nio.file.FileVisitResult) IOException(java.io.IOException) JobIsRunning(org.eclipse.reddeer.workbench.core.condition.JobIsRunning) DefaultShell(org.eclipse.reddeer.swt.impl.shell.DefaultShell) WorkbenchShell(org.eclipse.reddeer.workbench.impl.shell.WorkbenchShell) Shell(org.eclipse.reddeer.swt.api.Shell) WaitWhile(org.eclipse.reddeer.common.wait.WaitWhile) DefaultShell(org.eclipse.reddeer.swt.impl.shell.DefaultShell) PushButton(org.eclipse.reddeer.swt.impl.button.PushButton) WaitUntil(org.eclipse.reddeer.common.wait.WaitUntil) File(java.io.File) BasicFileAttributes(java.nio.file.attribute.BasicFileAttributes)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 FileVisitResult (java.nio.file.FileVisitResult)1 Path (java.nio.file.Path)1 BasicFileAttributes (java.nio.file.attribute.BasicFileAttributes)1 WaitUntil (org.eclipse.reddeer.common.wait.WaitUntil)1 WaitWhile (org.eclipse.reddeer.common.wait.WaitWhile)1 MavenImportWizard (org.eclipse.reddeer.eclipse.m2e.core.ui.wizard.MavenImportWizard)1 Shell (org.eclipse.reddeer.swt.api.Shell)1 ShellIsAvailable (org.eclipse.reddeer.swt.condition.ShellIsAvailable)1 PushButton (org.eclipse.reddeer.swt.impl.button.PushButton)1 DefaultShell (org.eclipse.reddeer.swt.impl.shell.DefaultShell)1 JobIsRunning (org.eclipse.reddeer.workbench.core.condition.JobIsRunning)1 WorkbenchShell (org.eclipse.reddeer.workbench.impl.shell.WorkbenchShell)1