Skip to content

Commit

Permalink
JBIDE-13236 - Hibernate/JPA annotation generation test added
Browse files Browse the repository at this point in the history
  • Loading branch information
jpeterka committed Dec 4, 2012
1 parent 541b163 commit f70e7d0
Show file tree
Hide file tree
Showing 8 changed files with 204 additions and 10 deletions.
Expand Up @@ -20,7 +20,9 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.ui.ide;bundle-version="3.5.1",
org.jboss.tools.common.ui;bundle-version="3.1.0",
org.eclipse.datatools.connectivity;bundle-version="1.1.2",
org.hibernate.eclipse.libs;bundle-version="3.4.0"
org.hibernate.eclipse.libs;bundle-version="3.4.0",
org.jboss.reddeer.swt;bundle-version="0.0.1",
org.jboss.reddeer.workbench;bundle-version="0.0.1"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Eclipse-RegisterBuddy: org.apache.log4j
Expand Down

This file was deleted.

@@ -0,0 +1,29 @@
package org.test.generation.annotation;

public class Dog {

private long id;
private String name;
private Owner owner;

public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Owner getOwner() {
return owner;
}
public void setOwner(Owner owner) {
this.owner = owner;
}


}
@@ -0,0 +1,38 @@
package org.test.generation.annotation;

import java.util.List;

public class Owner {

long id;
String name;
String surname;
List<Dog> dogs;

public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
public List<Dog> getDogs() {
return dogs;
}
public void setDogs(List<Dog> dogs) {
this.dogs = dogs;
}


}
@@ -1,14 +1,15 @@
package org.jboss.tools.hb.ui.bot.suite;

import org.jboss.tools.hb.ui.bot.test.generation.CreateCodeGenerationConfiguration35;
import org.jboss.tools.hb.ui.bot.test.generation.CreateCodeGenerationConfiguration36;
import org.jboss.tools.hb.ui.bot.test.generation.CreateCodeGenerationConfiguration40;
import org.jboss.tools.hb.ui.bot.test.generation.GenerateJPAHibernateAnnotationsContextMenu;
import org.jboss.tools.hb.ui.bot.test.generation.GenerateJPAHibernateAnnotationsMenuBar;
import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite.SuiteClasses;

@RunWith(RequirementAwareSuite.class)
@SuiteClasses({CreateCodeGenerationConfiguration35.class,CreateCodeGenerationConfiguration36.class,CreateCodeGenerationConfiguration40.class})
//@SuiteClasses({CreateCodeGenerationConfiguration35.class,CreateCodeGenerationConfiguration36.class,CreateCodeGenerationConfiguration40.class})
@SuiteClasses({GenerateJPAHibernateAnnotationsContextMenu.class, GenerateJPAHibernateAnnotationsMenuBar.class})
//@SuiteClasses({GenerateJPAHibernateAnnotationsMenuBar.class})
//@SuiteClasses({CreateCodeGenerationConfiguration40.class})
//@SuiteClasses({JPADDLGenerationTest.class})
//@SuiteClasses({JPAEntitiesGenerationTest.class})
Expand Down
Expand Up @@ -7,6 +7,8 @@
import org.jboss.tools.hb.ui.bot.test.criteria.CriteriaEditorTest;
import org.jboss.tools.hb.ui.bot.test.diagram.MappingDiagramTest;
import org.jboss.tools.hb.ui.bot.test.generation.CreateCodeGenerationConfiguration;
import org.jboss.tools.hb.ui.bot.test.generation.GenerateJPAHibernateAnnotationsContextMenu;
import org.jboss.tools.hb.ui.bot.test.generation.GenerateJPAHibernateAnnotationsMenuBar;
import org.jboss.tools.hb.ui.bot.test.generation.JPADDLGenerationTest;
import org.jboss.tools.hb.ui.bot.test.generation.JPAEntitiesGenerationTest;
import org.jboss.tools.hb.ui.bot.test.generation.RunSchemaExportTest;
Expand Down Expand Up @@ -40,10 +42,12 @@
/* diagram */
MappingDiagramTest.class,
/* generation */
GenerateJPAHibernateAnnotationsContextMenu.class,
GenerateJPAHibernateAnnotationsMenuBar.class,
CreateCodeGenerationConfiguration.class,
JPADDLGenerationTest.class,
JPAEntitiesGenerationTest.class,
RunSchemaExportTest.class,
RunSchemaExportTest.class,
/* hql */
HQLEditorTest.class,
/* jpa */
Expand Down
@@ -0,0 +1,62 @@
package org.jboss.tools.hb.ui.bot.test.generation;

import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.jboss.reddeer.swt.api.Menu;
import org.jboss.reddeer.swt.api.Shell;
import org.jboss.reddeer.swt.api.TreeItem;
import org.jboss.reddeer.swt.impl.button.PushButton;
import org.jboss.reddeer.swt.impl.menu.ContextMenu;
import org.jboss.reddeer.swt.impl.shell.DefaultShell;
import org.jboss.reddeer.swt.impl.shell.WorkbenchShell;
import org.jboss.reddeer.swt.impl.tree.ViewTreeItem;
import org.jboss.tools.hb.ui.bot.test.HibernateBaseTest;
import org.jboss.tools.ui.bot.ext.config.Annotations.DB;
import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
import org.jboss.tools.ui.bot.ext.helper.StringHelper;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
import org.jboss.tools.ui.bot.ext.view.PackageExplorer;
import org.junit.Test;

@Require(db = @DB, clearProjects = true, perspective = "JPA")
public class GenerateJPAHibernateAnnotationsContextMenu extends HibernateBaseTest {

final String prj = "configurationtest";
final String out = "src";
final String hbcfg = "hibernate.cfg.xml";
final String pckg = "org.test.generation.annotation";



@Test
public void testGenerateJPAHibernateAnnotationsContextMenu() {
importTestProject("/resources/prj/" + prj);
generateJPAHibernateAnnotationsContextMenu();
}


private void generateJPAHibernateAnnotationsContextMenu() {
PackageExplorer pe = new PackageExplorer();
pe.selectProject(prj);

TreeItem item = new ViewTreeItem(prj,"src",pckg,"Dog.java");
item.select();

Menu menu = new ContextMenu("Source","Generate Hibernate/JPA annotations");
menu.select();

Shell s = new DefaultShell("Hibernate: add JPA annotations");
new PushButton("Next >").click();
new PushButton("Finish").click();

Shell ws = new WorkbenchShell();
TreeItem itemre = new ViewTreeItem(prj,"src",pckg,"Dog.java");
item.doubleClick();

SWTBotEditor editor = bot.editorByTitle("Dog.java");
editor.setFocus();
StringHelper sh = new StringHelper(editor.toTextEditor().getText());
sh.getPositionAfter("@Entity");
}
}
@@ -0,0 +1,62 @@
package org.jboss.tools.hb.ui.bot.test.generation;

import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.jboss.reddeer.swt.api.Menu;
import org.jboss.reddeer.swt.api.Shell;
import org.jboss.reddeer.swt.api.TreeItem;
import org.jboss.reddeer.swt.impl.button.PushButton;
import org.jboss.reddeer.swt.impl.menu.ContextMenu;
import org.jboss.reddeer.swt.impl.menu.ShellMenu;
import org.jboss.reddeer.swt.impl.shell.DefaultShell;
import org.jboss.reddeer.swt.impl.shell.WorkbenchShell;
import org.jboss.reddeer.swt.impl.tree.ViewTreeItem;
import org.jboss.tools.hb.ui.bot.test.HibernateBaseTest;
import org.jboss.tools.ui.bot.ext.config.Annotations.DB;
import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
import org.jboss.tools.ui.bot.ext.helper.StringHelper;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
import org.jboss.tools.ui.bot.ext.view.PackageExplorer;
import org.junit.Test;

@Require(db = @DB, clearProjects = true, perspective = "JPA")
public class GenerateJPAHibernateAnnotationsMenuBar extends HibernateBaseTest {

final String prj = "configurationtest";
final String out = "src";
final String hbcfg = "hibernate.cfg.xml";
final String pckg = "org.test.generation.annotation";


@Test
public void testGenerateJPAHibernateAnnotations() {
importTestProject("/resources/prj/" + prj);
generateJPAHibernateAnnotationsMenuBar();
}

private void generateJPAHibernateAnnotationsMenuBar() {
PackageExplorer pe = new PackageExplorer();
pe.selectProject(prj);

TreeItem item = new ViewTreeItem(prj,"src",pckg,"Dog.java");
item.select();

Menu menu = new ShellMenu("Source","Generate Hibernate/JPA annotations");
menu.select();

Shell s = new DefaultShell("Hibernate: add JPA annotations");
new PushButton("Next >").click();
new PushButton("Finish").click();

Shell ws = new WorkbenchShell();
TreeItem item2 = new ViewTreeItem(prj,"src",pckg,"Dog.java");
item2.doubleClick();

SWTBotEditor editor = bot.editorByTitle("Dog.java");
editor.setFocus();
StringHelper sh = new StringHelper(editor.toTextEditor().getText());
sh.getPositionAfter("@Entity");
}

}

0 comments on commit f70e7d0

Please sign in to comment.