[jbosstools-commits] JBoss Tools SVN: r39752 - in trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test: src/org/jboss/tools/hb/ui/bot/test/view and 1 other directory.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Thu Mar 22 06:11:58 EDT 2012


Author: jpeterka
Date: 2012-03-22 06:11:58 -0400 (Thu, 22 Mar 2012)
New Revision: 39752

Modified:
   trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/resources/prj/jpatest40/src/org/jpadetails/Machine.java
   trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/test/view/JPADetailViewTest.java
Log:
check codeToJPAView added to JPADetailView ui bot test

Modified: trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/resources/prj/jpatest40/src/org/jpadetails/Machine.java
===================================================================
--- trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/resources/prj/jpatest40/src/org/jpadetails/Machine.java	2012-03-22 10:10:56 UTC (rev 39751)
+++ trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/resources/prj/jpatest40/src/org/jpadetails/Machine.java	2012-03-22 10:11:58 UTC (rev 39752)
@@ -1,16 +1,15 @@
 package org.jpadetails;
 
 import java.io.Serializable;
-import javax.persistence.*;
 
-import org.hibernate.annotations.NamedNativeQuery;
+import javax.persistence.Entity;
+import javax.persistence.Id;
 
 /**
  * Entity implementation class for Entity: Dog
  *
  */
 @Entity
- at NamedNativeQuery(name = "query ", query = "SELECT * FROM MACHINE")
 public class Machine implements Serializable {
 
 	@Id

Modified: trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/test/view/JPADetailViewTest.java
===================================================================
--- trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/test/view/JPADetailViewTest.java	2012-03-22 10:10:56 UTC (rev 39751)
+++ trunk/hibernatetools/tests/org.jboss.tools.hibernate.ui.bot.test/src/org/jboss/tools/hb/ui/bot/test/view/JPADetailViewTest.java	2012-03-22 10:11:58 UTC (rev 39752)
@@ -1,17 +1,21 @@
 package org.jboss.tools.hb.ui.bot.test.view;
 
 import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withLabel;
+import static org.eclipse.swtbot.swt.finder.waits.Conditions.shellCloses;
 import static org.eclipse.swtbot.swt.finder.waits.Conditions.waitForWidget;
 
 import org.eclipse.swt.graphics.Point;
 import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
 import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
 import org.jboss.tools.hb.ui.bot.common.ProjectExplorer;
 import org.jboss.tools.hb.ui.bot.test.HibernateBaseTest;
 import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
 import org.jboss.tools.ui.bot.ext.gen.ActionItem;
 import org.jboss.tools.ui.bot.ext.helper.StringHelper;
 import org.jboss.tools.ui.bot.ext.parts.SWTBotTwistie;
+import org.jboss.tools.ui.bot.ext.view.ProblemsView;
 import org.junit.Test;
 
 /**
@@ -33,10 +37,12 @@
 		importTestProject("/resources/prj/hibernatelib");
 		importTestProject("/resources/prj/jpatest40");
 		
-		checkGenericGeneratorValidation();
+		addNativeQueryViaJPAView();
+		modifyNativeQueryAndCheckJPAView();
 	}
 
-	private void checkGenericGeneratorValidation() {
+
+	private void addNativeQueryViaJPAView() {
 		
 		SWTBotView jd = open.viewOpen(ActionItem.View.JPAJPADetails.LABEL);		
 		ProjectExplorer.open(prj, "src", pkg, entity);
@@ -53,10 +59,43 @@
 		jd.bot().waitWhile(waitForWidget(withLabel(label)));
 
 		bot.sleep(TIME_5S);
-		SWTBotTwistie twistieBot = bot.twistieByLabel("Entity");
-		while (!twistieBot.isExpanded()) {
-			twistieBot.toggle();
+		SWTBotTwistie twistie = bot.twistieByLabel("Queries");
+		while (!twistie.isExpanded()) {
+			twistie.toggle();
 		}
 		
+		bot.button("Add...").click();
+		String title = "Add Query";
+		bot.waitForShell(title);
+		SWTBotShell shell = bot.shell(title);
+		shell.bot().textWithLabel("Name:").setText("selectmachine");
+		shell.bot().comboBoxWithLabel("Type:").setSelection("Named Native Query (hibernate)");
+		shell.bot().button("OK").click();
+		bot.waitUntil(shellCloses(shell));
+		jd.bot().textWithLabel("Query:").setText("SELECT * FROM MACHINE");
+				
+		editor.save();	
+		
+		String path = "/" + prj + "/src/org/jpadetails";
+		String type = "JPA Problem";		
+		
+		SWTBotTreeItem[] items = null;
+		items = ProblemsView.getFilteredErrorsTreeItems(bot, "", path, entity, type);				
+		assertTrue(items.length == 0);
 	}
+	
+	private void modifyNativeQueryAndCheckJPAView() {
+		SWTBotEditor editor = bot.editorByTitle(entity);
+		StringHelper sh = new StringHelper(editor.toTextEditor().getText());
+		String str = "SELECT * FROM MACHINE";
+		Point pos = sh.getPositionAfter(str);
+		editor.setFocus();
+		editor.toTextEditor().selectRange(pos.y, pos.x + 1, 0);
+		editor.toTextEditor().insertText(" ORDER BY name");
+		editor.save();
+		
+		SWTBotView jd = open.viewOpen(ActionItem.View.JPAJPADetails.LABEL);
+		String jpaText = jd.bot().textWithLabel("Query:").getText();
+		assertTrue(jpaText.equals("SELECT * FROM MACHINE ORDER BY name"));
+	}
 }



More information about the jbosstools-commits mailing list