Author: jjankovi
Date: 2012-06-22 03:37:05 -0400 (Fri, 22 Jun 2012)
New Revision: 42169
Removed:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/ti/
Modified:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/RESTFullExplorer.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/RunOnServerDialog.java
Log:
new uiutils classes needed for ws bot tests
Modified:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/RESTFullExplorer.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/RESTFullExplorer.java 2012-06-22
01:33:18 UTC (rev 42168)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/RESTFullExplorer.java 2012-06-22
07:37:05 UTC (rev 42169)
@@ -1,46 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
package org.jboss.tools.ws.ui.bot.test.uiutils;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
+import org.jboss.tools.ws.ui.bot.test.rest.RESTFulAnnotations;
-public class RESTFullExplorer {
+public class RESTFullExplorer extends SWTTestExt {
- public RESTFullExplorer(String projectName) {
- // TODO Auto-generated constructor stub
+ private SWTBotTreeItem restFulExplorer;
+
+ public RESTFullExplorer(String wsProjectName) {
+ String[] pathToRestExplorer = {wsProjectName};
+ restFulExplorer = projectExplorer.selectTreeItem(
+ RESTFulAnnotations.REST_EXPLORER_LABEL.getLabel(),
+ pathToRestExplorer).expand().expand();
}
-
- public Object getRestServiceName(SWTBotTreeItem restService) {
- // TODO Auto-generated method stub
- return null;
+
+ /**
+ *
+ * @return
+ */
+ public SWTBotTreeItem[] getAllRestServices() {
+ return restFulExplorer.getItems();
}
-
- public String getPathForRestFulService(SWTBotTreeItem restService) {
- // TODO Auto-generated method stub
- return "";
+
+ public SWTBotTreeItem restService(String method) {
+ SWTBotTreeItem getMethod = null;
+ for (SWTBotTreeItem ti : getAllRestServices()) {
+ if (ti.getText().contains("GET")) {
+ getMethod = ti;
+ break;
+ }
+ }
+ return getMethod;
}
-
- public Object getConsumesInfo(SWTBotTreeItem restService) {
- // TODO Auto-generated method stub
- return null;
+
+ public RunOnServerDialog runOnServer(SWTBotTreeItem service) {
+ SWTBotTree tree = projectExplorer.bot().tree();
+ ContextMenuHelper.prepareTreeItemForContextMenu(tree, service);
+ SWTBotMenu menu = new SWTBotMenu(ContextMenuHelper.
+ getContextMenu(tree, "Run As", false));
+ menu.menu("1 Run on Server").click();
+ return new RunOnServerDialog();
}
-
- public Object getProducesInfo(SWTBotTreeItem restService) {
- // TODO Auto-generated method stub
- return null;
+
+ /**
+ *
+ * @param restService
+ * @return
+ */
+ public SWTBotTreeItem[] getAllInfoAboutRestService(SWTBotTreeItem restService) {
+ restService.expand();
+ return restService.getItems();
}
-
- public SWTBotTreeItem[] getAllRestServices() {
- // TODO Auto-generated method stub
+
+ /**
+ *
+ * @param restService
+ * @return
+ */
+ public String getConsumesInfo(SWTBotTreeItem restService) {
+ for (SWTBotTreeItem ti: getAllInfoAboutRestService(restService)) {
+ if (ti.getText().contains("consumes:")) {
+ return ti.getText().split(" ")[1];
+ }
+ }
return null;
}
-
- public Object restService(String webService) {
- // TODO Auto-generated method stub
+
+ /**
+ *
+ * @param restService
+ * @return
+ */
+ public String getProducesInfo(SWTBotTreeItem restService) {
+ for (SWTBotTreeItem ti: getAllInfoAboutRestService(restService)) {
+ if (ti.getText().contains("produces:")) {
+ return ti.getText().split(" ")[1];
+ }
+ }
return null;
}
-
- public RunOnServerDialog runOnServer(Object restService) {
- // TODO Auto-generated method stub
- return null;
+
+ /**
+ *
+ * @param restService
+ * @return
+ */
+ public String getRestServiceName(SWTBotTreeItem restService) {
+ return restService.getText().split(" ")[0];
}
-
-}
+
+ /**
+ *
+ * @param restService
+ * @return
+ */
+ public String getPathForRestFulService(SWTBotTreeItem restService) {
+ return restService.getText().split(" ")[1];
+ }
+
+}
\ No newline at end of file
Modified:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/RunOnServerDialog.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/RunOnServerDialog.java 2012-06-22
01:33:18 UTC (rev 42168)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/RunOnServerDialog.java 2012-06-22
07:37:05 UTC (rev 42169)
@@ -1,22 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2012 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.tools.ws.ui.bot.test.uiutils;
-public class RunOnServerDialog {
+import java.util.ArrayList;
+import java.util.List;
- public class Server1 {
- public class Server2 {
- public void finish() {
- }
- }
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.SWTBotFactory;
+import org.jboss.tools.ui.bot.ext.types.IDELabel;
- public Server2 selectServer(String str) {
- return new Server2();
+/**
+ *
+ * @author jjankovi
+ *
+ */
+public class RunOnServerDialog {
- }
-
+ private SWTBotShell shell = null;
+ private SWTBot bot = null;
+ private final String DIALOG_TITLE = "Run On Server";
+
+ public RunOnServerDialog() {
+ shell = SWTBotFactory.getBot().shell(getDialogTitle());
+ bot = shell.bot();
}
- public Server1 chooseExistingServer() {
- return new Server1();
+ private String getDialogTitle() {
+ return DIALOG_TITLE;
}
-
-}
+
+ public RunOnServerDialog chooseExistingServer() {
+ bot.checkBox(0).select();
+ return this;
+ }
+
+ public List<String> getServers() {
+ List<String> servers = new ArrayList<String>();
+ for (SWTBotTreeItem server : bot.tree().getTreeItem("localhost").getItems())
{
+ servers.add(server.getText());
+ }
+ return servers;
+ }
+
+ public RunOnServerDialog selectServer(String server) {
+ for (String serverInDialog : getServers()) {
+ if (serverInDialog.contains(server)) {
+ bot.tree().getTreeItem("localhost")
+ .getNode(serverInDialog).select();
+ break;
+ }
+ }
+ return this;
+ }
+
+ public void finish() {
+ bot.button(IDELabel.Button.FINISH).click();
+ }
+
+ public void cancel() {
+ bot.button(IDELabel.Button.CANCEL).click();
+ }
+
+}
\ No newline at end of file