Search in sources :

Example 1 with NewHibernateMappingFilePage

use of org.jboss.tools.hibernate.reddeer.jdt.ui.wizards.NewHibernateMappingFilePage 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 NewHibernateMappingFilePage

use of org.jboss.tools.hibernate.reddeer.jdt.ui.wizards.NewHibernateMappingFilePage 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)

Aggregations

ProjectExplorer (org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer)2 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 XPathHelper (org.jboss.tools.hibernate.ui.bot.test.XPathHelper)2 Test (org.junit.Test)2