Search in sources :

Example 36 with ProjectExplorer

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

the class MappingFileTest method createMappingFileFromFile.

@Test
public void createMappingFileFromFile() {
    ProjectUtils.getItem(PRJ, PCKG_CLZ, "Owner.java").select();
    NewHibernateMappingFileWizard wizard = new NewHibernateMappingFileWizard();
    wizard.open();
    NewHibernateMappingElementsSelectionPage2 selPage = new NewHibernateMappingElementsSelectionPage2(wizard);
    selPage.selectItem("Owner");
    wizard.next();
    NewHibernateMappingFilePage files = new NewHibernateMappingFilePage(wizard);
    files.selectClasses("Owner");
    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_CLZ, "Owner.hbm.xml"));
    ProjectUtils.getItem(PRJ, PCKG_CLZ, "Owner.hbm.xml").open();
    String fileName = "Owner.hbm.xml";
    Hibernate3CompoundEditor hme = new Hibernate3CompoundEditor(fileName);
    hme.activateSourceTab();
    String sourceText = hme.getSourceText();
    XPathHelper xph = XPathHelper.getInstance();
    String table = xph.getMappingFileTable(PCKG_CLZ + ".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 37 with ProjectExplorer

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

the class PersistenceXMLFileTest method editPersistenceXMLFile.

@Test
public void editPersistenceXMLFile() {
    prepare();
    ProjectExplorer pe = new ProjectExplorer();
    pe.open();
    pe.getProject(prj).getProjectItem("src", "META-INF", "persistence.xml").open();
    JpaXmlEditor pexml = new JpaXmlEditor();
    pexml.setHibernateUsername("sa");
    pexml.setHibernateDialect("H2");
    pexml.save();
    String usernameProp = "hibernate.connection.username";
    String dialectProp = "hibernate.dialect";
    String usernameExpected = "sa";
    String dialectExpected = "org.hibernate.dialect.H2Dialect";
    XPathHelper xh = XPathHelper.getInstance();
    String text = pexml.getSourceText();
    String usrnameVal = xh.getPersistencePropertyValue(usernameProp, text);
    assertTrue("sa value is expected", usrnameVal.equals(usernameExpected));
    String dialectVal = xh.getPersistencePropertyValue(dialectProp, text);
    assertTrue("H2 value is expected", dialectVal.equals(dialectExpected));
}
Also used : ProjectExplorer(org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer) XPathHelper(org.jboss.tools.hibernate.ui.bot.test.XPathHelper) JpaXmlEditor(org.jboss.tools.hibernate.reddeer.editor.JpaXmlEditor) Test(org.junit.Test)

Example 38 with ProjectExplorer

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

the class RevengFileTest method testCreateRevengFile.

@Test
public void testCreateRevengFile() {
    ProjectExplorer pe = new ProjectExplorer();
    pe.open();
    pe.selectProjects(PROJECT_NAME);
    NewReverseEngineeringFileWizard wizard = new NewReverseEngineeringFileWizard();
    wizard.open();
    wizard.next();
    TableFilterWizardPage page = new TableFilterWizardPage(wizard);
    page.setConsoleConfiguration(PROJECT_NAME);
    page.refreshDatabaseSchema();
    page.pressInclude();
    wizard.finish();
    ReverseEngineeringEditor re = new ReverseEngineeringEditor();
    re.activateDesignTab();
    re.activateOverviewTab();
    re.activateSourceTab();
    re.activateTableFiltersTab();
    re.activateTypeMappingsTab();
}
Also used : ProjectExplorer(org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer) ReverseEngineeringEditor(org.jboss.tools.hibernate.reddeer.mapper.editors.ReverseEngineeringEditor) NewReverseEngineeringFileWizard(org.jboss.tools.hibernate.reddeer.console.wizards.NewReverseEngineeringFileWizard) TableFilterWizardPage(org.jboss.tools.hibernate.reddeer.console.wizards.TableFilterWizardPage) Test(org.junit.Test)

Example 39 with ProjectExplorer

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

the class TablesFromJPAEntitiesGeneration method testDDLGeneration.

private void testDDLGeneration(boolean useConsole, String hbVersion, String pkg) {
    ProjectExplorer pe = new ProjectExplorer();
    pe.open();
    pe.selectProjects(prj);
    GenerateDdlWizard w = new GenerateDdlWizard();
    w.open();
    GenerateDdlWizardPage p = new GenerateDdlWizardPage(w);
    p.setFileName(DDL_FILE);
    p.setUseConsoleConfiguration(useConsole);
    if (useConsole) {
        assertTrue(p.isConsoleConfigurationEnabled());
        assertFalse(p.isHibernateVersionEnabled());
        p.setConsoleConfiguration(prj);
    }
    if (!useConsole) {
        assertFalse(p.isConsoleConfigurationEnabled());
        assertTrue(p.isHibernateVersionEnabled());
        p.setHibernateVersion(hbVersion);
    }
    w.finish();
    pe.open();
    try {
        ProjectUtils.getPackage(prj, DDL_FILE).open();
    } catch (RedDeerException e) {
        Assert.fail("DDL is not generated - known issues(s): JBIDE-19431,JBIDE-19535");
    }
    String ddlText = new TextEditor(DDL_FILE).getText();
    assertTrue("DDL file cannot be empty", ddlText.length() > 0);
    checkDDLContent(ddlText);
}
Also used : ProjectExplorer(org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer) GenerateDdlWizardPage(org.jboss.tools.hibernate.reddeer.jpt.ui.wizard.GenerateDdlWizardPage) RedDeerException(org.eclipse.reddeer.common.exception.RedDeerException) TextEditor(org.eclipse.reddeer.workbench.impl.editor.TextEditor) GenerateDdlWizard(org.jboss.tools.hibernate.reddeer.jpt.ui.wizard.GenerateDdlWizard)

Example 40 with ProjectExplorer

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

the class ProjectConfigurationFactory method checkPersistenceXML.

/**
 * Check persistence.xml
 * @param prj project name
 */
public static void checkPersistenceXML(String prj) {
    log.info("Open persistence xml file");
    ProjectExplorer pe = new ProjectExplorer();
    pe.open();
    pe.getProject(prj).getProjectItem("JPA Content", "persistence.xml").open();
    log.info("In editor set some hibernate properties on hibernate tab");
    JpaXmlEditor pexml = new JpaXmlEditor();
    String sourceText = pexml.getSourceText();
    pexml.close();
    assertTrue("persistence.xml cannot be empty", sourceText.length() > 0);
}
Also used : ProjectExplorer(org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer) JpaXmlEditor(org.jboss.tools.hibernate.reddeer.editor.JpaXmlEditor)

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