Search in sources :

Example 1 with XPathHelper

use of org.jboss.tools.hibernate.ui.bot.test.XPathHelper 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 2 with XPathHelper

use of org.jboss.tools.hibernate.ui.bot.test.XPathHelper 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 3 with XPathHelper

use of org.jboss.tools.hibernate.ui.bot.test.XPathHelper 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)

Aggregations

ProjectExplorer (org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer)3 XPathHelper (org.jboss.tools.hibernate.ui.bot.test.XPathHelper)3 Test (org.junit.Test)3 NewHibernateMappingElementsSelectionPage2 (org.jboss.tools.hibernate.reddeer.jdt.ui.wizards.NewHibernateMappingElementsSelectionPage2)2 NewHibernateMappingFilePage (org.jboss.tools.hibernate.reddeer.jdt.ui.wizards.NewHibernateMappingFilePage)2 NewHibernateMappingFileWizard (org.jboss.tools.hibernate.reddeer.jdt.ui.wizards.NewHibernateMappingFileWizard)2 NewHibernateMappingPreviewPage (org.jboss.tools.hibernate.reddeer.jdt.ui.wizards.NewHibernateMappingPreviewPage)2 Hibernate3CompoundEditor (org.jboss.tools.hibernate.reddeer.ui.xml.editor.Hibernate3CompoundEditor)2 JpaXmlEditor (org.jboss.tools.hibernate.reddeer.editor.JpaXmlEditor)1