Search in sources :

Example 6 with ProjectExplorer

use of org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer in project jbosstools-hibernate by jbosstools.

the class MappingFileTest method prepare.

@Before
public void prepare() {
    importMavenProject(PRJ);
    try {
        Path dogLocation = new File("resources/classes/Dog.java").toPath();
        Path ownerLocation = new File("resources/classes/Owner.java").toPath();
        new File("target/" + PRJ + "/src/main/java/org/test").mkdirs();
        Files.copy(dogLocation, new FileOutputStream("target/" + PRJ + "/src/main/java/org/test/Dog.java"));
        Files.copy(ownerLocation, new FileOutputStream("target/" + PRJ + "/src/main/java/org/test/Owner.java"));
        new File("target/" + PRJ + "/src/main/java/org/test/clazz").mkdirs();
        Path ownerClazzLocation = new File("resources/classes/Owner.javaclazz").toPath();
        Files.copy(ownerClazzLocation, new FileOutputStream("target/" + PRJ + "/src/main/java/org/test/clazz/Owner.java"));
    } catch (IOException e) {
        e.printStackTrace();
        fail("Unable to find pom " + PRJ);
    }
    ProjectExplorer pe = new ProjectExplorer();
    pe.open();
    pe.getProject(PRJ).refresh();
}
Also used : Path(java.nio.file.Path) ProjectExplorer(org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) File(java.io.File) Before(org.junit.Before)

Example 7 with ProjectExplorer

use of org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer in project jbosstools-hibernate by jbosstools.

the class MappingFileTest method createMappingFileFromPackage.

@Test
public void createMappingFileFromPackage() {
    ProjectUtils.getPackage(PRJ, PCKG).select();
    NewHibernateMappingFileWizard wizard = new NewHibernateMappingFileWizard();
    wizard.open();
    NewHibernateMappingElementsSelectionPage2 selPage = new NewHibernateMappingElementsSelectionPage2(wizard);
    selPage.selectItem(PCKG);
    wizard.next();
    NewHibernateMappingFilePage files = new NewHibernateMappingFilePage(wizard);
    assertEquals(2, files.getClasses().size());
    wizard.next();
    NewHibernateMappingPreviewPage preview = new NewHibernateMappingPreviewPage(wizard);
    assertTrue("Preview text cannot be empty", !preview.getPreviewText().equals(""));
    wizard.finish();
    ProjectExplorer pe = new ProjectExplorer();
    pe.open();
    assertTrue("Hbm.xml not generated: Known issue(s): JBIDE-18769, JBIDE-20042", containsItem(PCKG, "Dog.hbm.xml"));
    ProjectUtils.getItem(PRJ, PCKG, "Dog.hbm.xml").open();
    Hibernate3CompoundEditor hme = new Hibernate3CompoundEditor("Dog.hbm.xml");
    hme.activateSourceTab();
    String sourceText = hme.getSourceText();
    XPathHelper xph = XPathHelper.getInstance();
    String table = xph.getMappingFileTable(PCKG + ".Dog", sourceText);
    assertTrue(table.equals("DOG"));
    ProjectUtils.getItem(PRJ, PCKG, "Owner.hbm.xml").open();
    hme = new Hibernate3CompoundEditor("Owner.hbm.xml");
    hme.activateSourceTab();
    sourceText = hme.getSourceText();
    table = xph.getMappingFileTable(PCKG + ".Owner", sourceText);
    assertEquals("OWNER", table);
}
Also used : ProjectExplorer(org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer) Hibernate3CompoundEditor(org.jboss.tools.hibernate.reddeer.ui.xml.editor.Hibernate3CompoundEditor) NewHibernateMappingFilePage(org.jboss.tools.hibernate.reddeer.jdt.ui.wizards.NewHibernateMappingFilePage) XPathHelper(org.jboss.tools.hibernate.ui.bot.test.XPathHelper) NewHibernateMappingPreviewPage(org.jboss.tools.hibernate.reddeer.jdt.ui.wizards.NewHibernateMappingPreviewPage) NewHibernateMappingElementsSelectionPage2(org.jboss.tools.hibernate.reddeer.jdt.ui.wizards.NewHibernateMappingElementsSelectionPage2) NewHibernateMappingFileWizard(org.jboss.tools.hibernate.reddeer.jdt.ui.wizards.NewHibernateMappingFileWizard) Test(org.junit.Test)

Example 8 with ProjectExplorer

use of org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer in project jbosstools-hibernate by jbosstools.

the class MappingFileTest method createMappingFileWithNoConfig.

// JBIDE-21766
@Test
public void createMappingFileWithNoConfig() {
    ProjectExplorer pe = new ProjectExplorer();
    pe.open();
    PropertyDialog pd = pe.getProject(PRJ).openProperties();
    pd.select("Hibernate Settings");
    new DefaultCombo(pd).setSelection("<None>");
    pd.ok();
    createMappingFileFromFile();
}
Also used : ProjectExplorer(org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer) DefaultCombo(org.eclipse.reddeer.swt.impl.combo.DefaultCombo) PropertyDialog(org.eclipse.reddeer.eclipse.ui.dialogs.PropertyDialog) Test(org.junit.Test)

Example 9 with ProjectExplorer

use of org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer in project jbosstools-hibernate by jbosstools.

the class PersistenceXMLFileTest method prepare.

private void prepare() {
    importProject(prj, null);
    ProjectExplorer pe = new ProjectExplorer();
    pe.open();
    PropertyDialog pd = pe.getProject(prj).openProperties();
    FacetsPropertyPage fp = new FacetsPropertyPage(pd);
    pd.select(fp);
    List<TreeItem> facets = fp.getSelectedFacets();
    boolean javaFacet = false;
    boolean jpaFacet = false;
    for (TreeItem facet : facets) {
        if (facet.getText().equals("Java")) {
            javaFacet = true;
        } else if (facet.getText().equals("JPA")) {
            jpaFacet = true;
        }
    }
    if (!javaFacet) {
        fp.selectFacet("Java");
        new DefaultHyperlink(pd).activate();
        Shell s = new DefaultShell("Modify Faceted Project");
        new OkButton(s).click();
        new WaitWhile(new ShellIsAvailable(s));
    }
    if (!jpaFacet) {
        fp.selectFacet("JPA");
        new DefaultHyperlink(pd).activate();
        Shell s = new DefaultShell("Modify Faceted Project");
        new NextButton(s).click();
        JpaFacetInstallPage installPage = new JpaFacetInstallPage(s);
        installPage.setPlatform("Hibernate (JPA 2.1)");
        installPage.setJpaImplementation("Disable Library Configuration");
        new OkButton(s).click();
        new WaitWhile(new ShellIsAvailable(s));
    }
    pd.ok();
}
Also used : ProjectExplorer(org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer) ShellIsAvailable(org.eclipse.reddeer.swt.condition.ShellIsAvailable) NextButton(org.eclipse.reddeer.swt.impl.button.NextButton) TreeItem(org.eclipse.reddeer.swt.api.TreeItem) DefaultHyperlink(org.eclipse.reddeer.uiforms.impl.hyperlink.DefaultHyperlink) OkButton(org.eclipse.reddeer.swt.impl.button.OkButton) DefaultShell(org.eclipse.reddeer.swt.impl.shell.DefaultShell) Shell(org.eclipse.reddeer.swt.api.Shell) WaitWhile(org.eclipse.reddeer.common.wait.WaitWhile) PropertyDialog(org.eclipse.reddeer.eclipse.ui.dialogs.PropertyDialog) DefaultShell(org.eclipse.reddeer.swt.impl.shell.DefaultShell) FacetsPropertyPage(org.eclipse.reddeer.eclipse.wst.common.project.facet.ui.FacetsPropertyPage) JpaFacetInstallPage(org.jboss.tools.hibernate.reddeer.wizard.JpaFacetInstallPage)

Example 10 with ProjectExplorer

use of org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer in project jbosstools-hibernate by jbosstools.

the class ProjectUtils method getItem.

public static ProjectItem getItem(String project, String pckg, String clazz) {
    ProjectExplorer pe = new ProjectExplorer();
    pe.open();
    if (pe.getProject(project).containsResource("Java Resources")) {
        return pe.getProject(project).getProjectItem("Java Resources", "src/main/java", pckg, clazz);
    }
    return pe.getProject(project).getProjectItem("src/main/java", pckg, clazz);
}
Also used : ProjectExplorer(org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer)

Aggregations

ProjectExplorer (org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer)41 Test (org.junit.Test)12 WaitWhile (org.eclipse.reddeer.common.wait.WaitWhile)10 WaitUntil (org.eclipse.reddeer.common.wait.WaitUntil)8 JobIsRunning (org.eclipse.reddeer.workbench.core.condition.JobIsRunning)8 File (java.io.File)6 DefaultShell (org.eclipse.reddeer.swt.impl.shell.DefaultShell)6 PropertyDialog (org.eclipse.reddeer.eclipse.ui.dialogs.PropertyDialog)5 ShellIsAvailable (org.eclipse.reddeer.swt.condition.ShellIsAvailable)5 IOException (java.io.IOException)4 WaitTimeoutExpiredException (org.eclipse.reddeer.common.exception.WaitTimeoutExpiredException)4 OpenShiftExplorerView (org.jboss.tools.openshift.reddeer.view.OpenShiftExplorerView)4 AbstractTest (org.jboss.tools.openshift.ui.bot.test.application.v3.basic.AbstractTest)4 TreeItem (org.eclipse.reddeer.swt.api.TreeItem)3 FinishButton (org.eclipse.reddeer.swt.impl.button.FinishButton)3 NextButton (org.eclipse.reddeer.swt.impl.button.NextButton)3 OkButton (org.eclipse.reddeer.swt.impl.button.OkButton)3 TextEditor (org.eclipse.reddeer.workbench.impl.editor.TextEditor)3 AfterClass (org.junit.AfterClass)3 Before (org.junit.Before)3