Author: ljelinko
Date: 2011-11-22 05:14:19 -0500 (Tue, 22 Nov 2011)
New Revision: 36524
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/entity/EntityFactory.java
Modified:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortlet.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortletProject.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/entity/WorkspaceFile.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/WorkspaceMatchersFactory.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/file/ExistingFileMatcher.java
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/file/xml/XMLFileNodeContentMatcher.java
Log:
Created entity factory, changed ExistingFileMatcher to use WorkspaceFile and added
splitting functionality to WorkspaceFile
Modified:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortlet.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortlet.java 2011-11-22
10:07:39 UTC (rev 36523)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortlet.java 2011-11-22
10:14:19 UTC (rev 36524)
@@ -1,11 +1,11 @@
package org.jboss.tools.portlet.ui.bot.test.create;
import static
org.jboss.tools.portlet.ui.bot.test.create.CreateJavaPortletProject.PROJECT_NAME;
+import static org.jboss.tools.portlet.ui.bot.test.entity.EntityFactory.file;
import static
org.jboss.tools.portlet.ui.bot.test.matcher.problems.ProblemViewMatchersFactory.isNumberOfErrors;
import static
org.jboss.tools.portlet.ui.bot.test.matcher.workspace.WorkspaceMatchersFactory.containsNodes;
-import static
org.jboss.tools.portlet.ui.bot.test.matcher.workspace.WorkspaceMatchersFactory.existsInProject;
+import static
org.jboss.tools.portlet.ui.bot.test.matcher.workspace.WorkspaceMatchersFactory.exists;
-import org.jboss.tools.portlet.ui.bot.test.entity.WorkspaceFile;
import org.jboss.tools.portlet.ui.bot.test.entity.XMLNode;
import org.jboss.tools.portlet.ui.bot.test.task.SWTTask;
import org.jboss.tools.portlet.ui.bot.test.task.wizard.web.jboss.PortletCreationTask;
@@ -35,10 +35,10 @@
doPerform(getCreatePortletTask());
doAssertThat(0, isNumberOfErrors());
- doAssertThat(CLASS_FILE, existsInProject(PROJECT_NAME));
- doAssertThat("WebContent/WEB-INF/default-object.xml",
existsInProject(PROJECT_NAME));
- doAssertThat("WebContent/WEB-INF/portlet-instances.xml",
existsInProject(PROJECT_NAME));
- doAssertThat(new WorkspaceFile(PROJECT_NAME,
"WebContent/WEB-INF/portlet.xml"), containsNodes(new
XMLNode("portlet-app/portlet/portlet-class", FULL_CLASS_NAME)));
+ doAssertThat(file(PROJECT_NAME, CLASS_FILE), exists());
+ doAssertThat(file(PROJECT_NAME, "WebContent/WEB-INF/default-object.xml"),
exists());
+ doAssertThat(file(PROJECT_NAME, "WebContent/WEB-INF/portlet-instances.xml"),
exists());
+ doAssertThat(file(PROJECT_NAME, "WebContent/WEB-INF/portlet.xml"),
containsNodes(new XMLNode("portlet-app/portlet/portlet-class",
FULL_CLASS_NAME)));
System.out.println("");
}
Modified:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortletProject.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortletProject.java 2011-11-22
10:07:39 UTC (rev 36523)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/create/CreateJavaPortletProject.java 2011-11-22
10:14:19 UTC (rev 36524)
@@ -1,7 +1,8 @@
package org.jboss.tools.portlet.ui.bot.test.create;
+import static org.jboss.tools.portlet.ui.bot.test.entity.EntityFactory.file;
import static
org.jboss.tools.portlet.ui.bot.test.matcher.problems.ProblemViewMatchersFactory.isNumberOfErrors;
-import static
org.jboss.tools.portlet.ui.bot.test.matcher.workspace.WorkspaceMatchersFactory.existsInProject;
+import static
org.jboss.tools.portlet.ui.bot.test.matcher.workspace.WorkspaceMatchersFactory.exists;
import static
org.jboss.tools.portlet.ui.bot.test.matcher.workspace.WorkspaceMatchersFactory.hasFacets;
import static
org.jboss.tools.portlet.ui.bot.test.matcher.workspace.WorkspaceMatchersFactory.isExistingProject;
@@ -40,8 +41,8 @@
doAssertThat(0, isNumberOfErrors());
doAssertThat(PROJECT_NAME, isExistingProject());
- doAssertThat("WebContent/WEB-INF/portlet.xml",
existsInProject(PROJECT_NAME));
- doAssertThat("JBoss Portlet Libraries", existsInProject(PROJECT_NAME));
+ doAssertThat(file(PROJECT_NAME, "WebContent/WEB-INF/portlet.xml"),
exists());
+ doAssertThat(file(PROJECT_NAME, "JBoss Portlet Libraries"), exists());
doAssertThat(PROJECT_NAME, hasFacets(new FacetDefinition(FACET_NAME,
FACET_CATEGORY)));
}
Added:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/entity/EntityFactory.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/entity/EntityFactory.java
(rev 0)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/entity/EntityFactory.java 2011-11-22
10:14:19 UTC (rev 36524)
@@ -0,0 +1,18 @@
+package org.jboss.tools.portlet.ui.bot.test.entity;
+
+/**
+ * Convenient factory method for creating entity objects.
+ *
+ * @author Lucia Jelinkova
+ *
+ */
+public class EntityFactory {
+
+ private EntityFactory() {
+ // static factory methods
+ }
+
+ public static WorkspaceFile file(String project, String filePath){
+ return new WorkspaceFile(project, filePath);
+ }
+}
Modified:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/entity/WorkspaceFile.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/entity/WorkspaceFile.java 2011-11-22
10:07:39 UTC (rev 36523)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/entity/WorkspaceFile.java 2011-11-22
10:14:19 UTC (rev 36524)
@@ -2,16 +2,26 @@
public class WorkspaceFile {
+ public static final String FILE_SEPARATOR = "/";
+
private String project;
-
- private String file;
- public WorkspaceFile(String project, String file) {
+ private String filePath;
+
+ public WorkspaceFile(String project, String filePath) {
super();
this.project = project;
- this.file = file;
+ this.filePath = filePath;
}
+ public String getFileName(){
+ return getFilePathAsArray()[getFilePathAsArray().length - 1];
+ }
+
+ public String[] getFilePathAsArray(){
+ return getFilePath().split(FILE_SEPARATOR);
+ }
+
public String getProject() {
return project;
}
@@ -20,16 +30,16 @@
this.project = project;
}
- public String getFile() {
- return file;
+ public String getFilePath() {
+ return filePath;
}
- public void setFile(String file) {
- this.file = file;
+ public void setFilePath(String file) {
+ this.filePath = file;
}
-
+
@Override
public String toString() {
- return "Workspace file: " + getProject() + "/" + getFile();
+ return "Workspace file: " + getProject() + FILE_SEPARATOR + getFilePath();
}
}
Modified:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/WorkspaceMatchersFactory.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/WorkspaceMatchersFactory.java 2011-11-22
10:07:39 UTC (rev 36523)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/WorkspaceMatchersFactory.java 2011-11-22
10:14:19 UTC (rev 36524)
@@ -25,8 +25,8 @@
return new ExistingProjectMatcher();
}
- public static SWTMatcher<String> existsInProject(String project){
- return new ExistingFileMatcher(project);
+ public static SWTMatcher<WorkspaceFile> exists(){
+ return new ExistingFileMatcher();
}
public static SWTMatcher<String> hasFacets(FacetDefinition... facets){
Modified:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/file/ExistingFileMatcher.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/file/ExistingFileMatcher.java 2011-11-22
10:07:39 UTC (rev 36523)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/file/ExistingFileMatcher.java 2011-11-22
10:14:19 UTC (rev 36524)
@@ -1,6 +1,7 @@
package org.jboss.tools.portlet.ui.bot.test.matcher.workspace.file;
import org.hamcrest.Description;
+import org.jboss.tools.portlet.ui.bot.test.entity.WorkspaceFile;
import org.jboss.tools.portlet.ui.bot.test.matcher.AbstractSWTMatcher;
import org.jboss.tools.ui.bot.ext.SWTBotFactory;
import org.jboss.tools.ui.bot.ext.gen.ActionItem;
@@ -11,20 +12,12 @@
* @author Lucia Jelinkova
*
*/
-public class ExistingFileMatcher extends AbstractSWTMatcher<String> {
+public class ExistingFileMatcher extends AbstractSWTMatcher<WorkspaceFile> {
- private static final String FILE_SEPARATOR = "/";
-
- private String project;
-
- public ExistingFileMatcher(String project) {
- this.project = project;
- }
-
@Override
- public boolean matchesSafely(String path) {
+ public boolean matchesSafely(WorkspaceFile file) {
SWTBotFactory.getOpen().perspective(ActionItem.Perspective.JAVA.LABEL);
- return SWTBotFactory.getPackageexplorer().isFilePresent(project,
path.split(FILE_SEPARATOR));
+ return SWTBotFactory.getPackageexplorer().isFilePresent(file.getProject(),
file.getFilePathAsArray());
}
@Override
Modified:
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/file/xml/XMLFileNodeContentMatcher.java
===================================================================
---
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/file/xml/XMLFileNodeContentMatcher.java 2011-11-22
10:07:39 UTC (rev 36523)
+++
trunk/portlet/tests/org.jboss.tools.portlet.ui.bot.test/src/org/jboss/tools/portlet/ui/bot/test/matcher/workspace/file/xml/XMLFileNodeContentMatcher.java 2011-11-22
10:14:19 UTC (rev 36524)
@@ -31,9 +31,8 @@
@Override
public boolean matchesSafely(WorkspaceFile file) {
- String[] filePath = file.getFile().split("/");
- SWTBotFactory.getPackageexplorer().openFile(file.getProject(), filePath);
- SWTBotEditorExt editor =
SWTBotFactory.getBot().swtBotEditorExtByTitle(filePath[filePath.length - 1]);
+ SWTBotFactory.getPackageexplorer().openFile(file.getProject(),
file.getFilePathAsArray());
+ SWTBotEditorExt editor =
SWTBotFactory.getBot().swtBotEditorExtByTitle(file.getFileName());
SWTBotTree tree = editor.bot().tree();
for (XMLNode node : nodes){