-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JBIDE-13236 - Hibernate/JPA annotation generation test added
- Loading branch information
Showing
8 changed files
with
204 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 0 additions & 4 deletions
4
tests/org.jboss.tools.hibernate.ui.bot.test/resources/prj/configurationtest/src/.gitignore
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
...e.ui.bot.test/resources/prj/configurationtest/src/org/test/generation/annotation/Dog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
|
||
} |
38 changes: 38 additions & 0 deletions
38
...ui.bot.test/resources/prj/configurationtest/src/org/test/generation/annotation/Owner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
|
||
} |
9 changes: 5 additions & 4 deletions
9
....tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/suite/CodeGenerationSuite.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...org/jboss/tools/hb/ui/bot/test/generation/GenerateJPAHibernateAnnotationsContextMenu.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
...src/org/jboss/tools/hb/ui/bot/test/generation/GenerateJPAHibernateAnnotationsMenuBar.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"); | ||
} | ||
|
||
} |