summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetya Sabeva2012-12-04 06:37:07 (EST)
committerPetya Sabeva2012-12-04 06:37:07 (EST)
commit1211d885029bbc9540f125a0f2806001b3cf0790 (patch)
treeb05a78c73074c687d890ccc4b8231a987868c0c2
parent458e06606716ddf865a96dbed1298615c0f443d9 (diff)
downloadwebtools.dali-1211d885029bbc9540f125a0f2806001b3cf0790.zip
webtools.dali-1211d885029bbc9540f125a0f2806001b3cf0790.tar.gz
webtools.dali-1211d885029bbc9540f125a0f2806001b3cf0790.tar.bz2
Stabilize swtbot UI tests.
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DeleteJPAEntityFeature.java2
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/MoveEntityFeature.java4
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorEntityFeature.java17
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RenameEntityFeature.java6
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/ui/OpenJpaDiagramActionDelegate.java3
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JpaArtifactFactory.java2
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EditorProxy.java343
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EmbeddableInDiagramSWTBotTest.java54
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EntitiesInDiagramSWTBotTest.java36
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/MappedSuperclassesInDiagramSWTBotTest.java42
10 files changed, 301 insertions, 208 deletions
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DeleteJPAEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DeleteJPAEntityFeature.java
index c3b3c19..0191f39 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DeleteJPAEntityFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DeleteJPAEntityFeature.java
@@ -72,7 +72,7 @@ public class DeleteJPAEntityFeature extends DefaultDeleteFeature {
String name = jpt.getName();
- JpaArtifactFactory.instance().forceSaveEntityClass(jpt, getFeatureProvider());
+// JpaArtifactFactory.instance().forceSaveEntityClass(jpt, getFeatureProvider());
JpaArtifactFactory.instance().deleteEntityClass(jpt, getFeatureProvider());
if (! JpaPreferences.getDiscoverAnnotatedClasses(jpt.getJpaProject().getProject())) {
JPAEditorUtil.createUnregisterEntityFromXMLJob(jpaProject, name);
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/MoveEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/MoveEntityFeature.java
index 9fbf3ca..05bdda4 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/MoveEntityFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/MoveEntityFeature.java
@@ -17,7 +17,6 @@ package org.eclipse.jpt.jpadiagrameditor.ui.internal.feature;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.ICustomContext;
-import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.internal.ui.refactoring.reorg.ReorgMoveAction;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.ui.IEditorPart;
@@ -31,10 +30,9 @@ public class MoveEntityFeature extends RefactorEntityFeature {
}
public void execute(ICustomContext context) {
- ICompilationUnit cu = getFeatureProvider().getCompilationUnit(jpt);
IWorkbenchSite ws = ((IEditorPart)getDiagramEditor()).getSite();
ReorgMoveAction action = new ReorgMoveAction(ws);
- execute(context, action, cu);
+ execute(context, action);
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorEntityFeature.java
index efdf9ab..cda63d2 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorEntityFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorEntityFeature.java
@@ -70,7 +70,6 @@ import org.eclipse.swt.widgets.Display;
public abstract class RefactorEntityFeature extends AbstractCustomFeature {
- protected JavaPersistentType jpt = null;
protected Set<JavaPersistentAttribute> ats = null;
protected boolean hasNameAnnotation = false;
@@ -86,7 +85,8 @@ public abstract class RefactorEntityFeature extends AbstractCustomFeature {
PictogramElement pe = ctx.getInnerPictogramElement();
Object bo = getFeatureProvider().getBusinessObjectForPictogramElement(pe);
if (bo instanceof JavaPersistentType) {
- jpt = (JavaPersistentType)bo;
+ JavaPersistentType jpt = (JavaPersistentType)bo;
+ ats = JpaArtifactFactory.instance().getRelatedAttributes(jpt);
hasNameAnnotation = JpaArtifactFactory.instance().hasNameAnnotation(jpt);
return true;
}
@@ -96,7 +96,8 @@ public abstract class RefactorEntityFeature extends AbstractCustomFeature {
return false;
bo = getFeatureProvider().getBusinessObjectForPictogramElement(cs);
if (bo instanceof JavaPersistentType) {
- jpt = (JavaPersistentType)bo;
+ JavaPersistentType jpt = (JavaPersistentType)bo;
+ ats = JpaArtifactFactory.instance().getRelatedAttributes(jpt);
hasNameAnnotation = JpaArtifactFactory.instance().hasNameAnnotation(jpt);
return true;
}
@@ -109,11 +110,15 @@ public abstract class RefactorEntityFeature extends AbstractCustomFeature {
return true;
}
- public void execute(ICustomContext context, SelectionDispatchAction action, ICompilationUnit cu) {
- StructuredSelection sel = new StructuredSelection(cu);
- final Shape pict = (Shape)getFeatureProvider().getPictogramElementForBusinessObject(jpt);
+ public void execute(ICustomContext context, SelectionDispatchAction action) {
+ final Shape pict = (Shape)context.getInnerPictogramElement();
+
JavaPersistentType jpt = (JavaPersistentType)getFeatureProvider().
getBusinessObjectForPictogramElement(pict);
+ ICompilationUnit cu = getFeatureProvider().getCompilationUnit(jpt);
+
+ StructuredSelection sel = new StructuredSelection(cu);
+
final JPAEditorConstants.DIAGRAM_OBJECT_TYPE dot = JpaArtifactFactory.instance().determineDiagramObjectType(jpt);
final PersistenceUnit pu = JpaArtifactFactory.instance().getPersistenceUnit(jpt);
final Semaphore s = new Semaphore(0);
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RenameEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RenameEntityFeature.java
index 1258cfa..d870830 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RenameEntityFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RenameEntityFeature.java
@@ -17,10 +17,8 @@ package org.eclipse.jpt.jpadiagrameditor.ui.internal.feature;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.ICustomContext;
-import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.ui.actions.RenameAction;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchSite;
@@ -33,11 +31,9 @@ public class RenameEntityFeature extends RefactorEntityFeature {
}
public void execute(ICustomContext context) {
- ICompilationUnit cu = getFeatureProvider().getCompilationUnit(jpt);
IWorkbenchSite ws = ((IEditorPart)getDiagramEditor()).getSite();
RenameAction action = new RenameAction(ws);
- ats = JpaArtifactFactory.instance().getRelatedAttributes(jpt);
- execute(context, action, cu);
+ execute(context, action);
}
@Override
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/ui/OpenJpaDiagramActionDelegate.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/ui/OpenJpaDiagramActionDelegate.java
index 3305b5b..1835a0f 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/ui/OpenJpaDiagramActionDelegate.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/ui/OpenJpaDiagramActionDelegate.java
@@ -137,7 +137,7 @@ public class OpenJpaDiagramActionDelegate implements IObjectActionDelegate {
private static final String ERROR_OPENING_DIAGRAM = JPAEditorMessages.OpenJpaDiagramActionDelegate_openJPADiagramErrorMsg;
- private JpaProject jpaProject;
+// private JpaProject jpaProject;
private Shell shell;
private WeakReference<ISelection> selectionRef = new WeakReference<ISelection>(null);
@@ -175,6 +175,7 @@ public class OpenJpaDiagramActionDelegate implements IObjectActionDelegate {
}
protected PersistenceUnit obtainJpaProjectAndPersistenceUnit(ISelection selection) throws CoreException {
+ JpaProject jpaProject = null;
Object firstElement = ((IStructuredSelection) selection).getFirstElement();
if(firstElement instanceof JpaRootContextNodeModel){
jpaProject = JpaArtifactFactory.instance().getJpaProject(((JpaRootContextNodeModel)firstElement).getProject());
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JpaArtifactFactory.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JpaArtifactFactory.java
index 1c3d6bc..999a80e 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JpaArtifactFactory.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JpaArtifactFactory.java
@@ -775,7 +775,7 @@ public class JpaArtifactFactory {
* @param fp
* @return an unique attribute name.
*/
- private String genUniqueAttrName(JavaPersistentType jpt,
+ public String genUniqueAttrName(JavaPersistentType jpt,
String attrTypeName, IJPAEditorFeatureProvider fp) {
ICompilationUnit ijl = fp.getCompilationUnit(jpt);
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EditorProxy.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EditorProxy.java
index cbea87a..5542fea 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EditorProxy.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EditorProxy.java
@@ -13,7 +13,6 @@ import static org.junit.Assert.fail;
import java.awt.AWTException;
import java.awt.Robot;
import java.util.ArrayList;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
@@ -30,6 +29,7 @@ import org.eclipse.gef.GraphicalViewer;
import org.eclipse.gef.LayerConstants;
import org.eclipse.gef.editparts.ScalableFreeformRootEditPart;
import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.mm.pictograms.Anchor;
import org.eclipse.graphiti.mm.pictograms.FreeFormConnection;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.ui.internal.contextbuttons.ContextButton;
@@ -39,6 +39,7 @@ import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.core.MappingKeys;
import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
@@ -56,6 +57,7 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IRelation.RelType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IsARelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Canvas;
@@ -80,7 +82,7 @@ import org.eclipse.swtbot.swt.finder.widgets.TimeoutException;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorReference;
-@SuppressWarnings({"restriction", "deprecation", "unchecked"})
+@SuppressWarnings({ "restriction", "deprecation", "unchecked" })
public class EditorProxy {
private final SWTWorkbenchBot workbenchBot;
@@ -128,7 +130,7 @@ public class EditorProxy {
boolean isJPA20) {
SWTBotTree projectTree = workbenchBot.viewByTitle("Project Explorer")
.bot().tree();
- projectTree.expandNode(name).select();
+ projectTree.getTreeItem(name).select();
ContextMenuHelper.clickContextMenu(projectTree, "JPA Tools",
"Open Diagram");
@@ -208,8 +210,7 @@ public class EditorProxy {
}
/**
- * Adds a new attribute to the entity and checks that: 1. The newly created
- * attribute is selected 2. The "Other Attributes" section is visible
+ * Adds a new attribute to the entity and checks that the "Other Attributes" section is visible
*
* @param attributeName
* - the name of the attribute
@@ -238,16 +239,17 @@ public class EditorProxy {
System.out.println(">>>>>> Attribute is successfully added in "
+ jpt.getName());
- assertTrue("The newly added attribute must be selected.",
- jpaDiagramEditor.selectedEditParts().size() == 1);
- // assertTrue("The newly added attribute must be selected.",
- // jpaDiagramEditor.selectedEditParts().contains(attribute));
-
assertTrue(
"\"Other Attributes\" section must be visible!",
isSectionVisible(
JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
jptType));
+
+ JavaPersistentAttribute jpa = getJPAObjectForGefElement(attribute);
+ assertEquals(
+ "The newly added attribute must be mapped as basic attribute.",
+ MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY,
+ jpa.getMappingKey());
return attribute;
}
@@ -266,11 +268,6 @@ public class EditorProxy {
attributeName, editParts);
assertNotNull("Atrribute is not added.", attribute);
- assertTrue("The newly added attribute must be selected.",
- jpaDiagramEditor.selectedEditParts().size() == 1);
- assertTrue("The newly added attribute must be selected.",
- jpaDiagramEditor.selectedEditParts().contains(attribute));
-
assertTrue(
"\"Other Attributes\" section must be visible!",
isSectionVisible(
@@ -305,21 +302,23 @@ public class EditorProxy {
return figure.isVisible();
}
- /**
- * Add entity to diagram
- * @param x
- * @param y
- * @param jpaProject
- * @return the newly added entity
- */
- public SWTBotGefEditPart addEntityToDiagram(int x, int y, JpaProject jpaProject) {
+ /**
+ * Add entity to diagram
+ *
+ * @param x
+ * @param y
+ * @param jpaProject
+ * @return the newly added entity
+ */
+ public SWTBotGefEditPart addEntityToDiagram(int x, int y,
+ JpaProject jpaProject) {
String entityName = getUniqueEntityName(jpaProject);
-
+
jpaDiagramEditor
.activateTool(JPAEditorMessages.CreateJPAEntityFeature_jpaEntityFeatureName);
jpaDiagramEditor.doubleClick(x, y);
-
+
try {
bot.waitUntil(new ElementIsShown(jpaDiagramEditor, entityName),
15000);
@@ -333,7 +332,6 @@ public class EditorProxy {
bot.waitUntil(new ElementIsShown(jpaDiagramEditor, entityName),
15000);
}
-
List<SWTBotGefEditPart> entities = jpaDiagramEditor.mainEditPart()
.children();
@@ -356,34 +354,35 @@ public class EditorProxy {
isSectionVisible(
JPAEditorMessages.AddJPAEntityFeature_relationAttributesShapes,
entity));
- assertFalse(
- "\"Other Attributes\" section must not be visible!",
- isSectionVisible(
- JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
- entity));
+// assertFalse(
+// "\"Other Attributes\" section must not be visible!",
+// isSectionVisible(
+// JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
+// entity));
return entity;
}
- /**
- * Add mapped superclass to diagram
- * @param x
- * @param y
- * @param jpaProject
- * @return the newly added mapped superclass
- */
+ /**
+ * Add mapped superclass to diagram
+ *
+ * @param x
+ * @param y
+ * @param jpaProject
+ * @return the newly added mapped superclass
+ */
public SWTBotGefEditPart addMappedSuperclassToDiagram(int x, int y,
JpaProject jpaProject) {
-
+
String mappedSuperclassName = getUniqueMappedSuperclassName(jpaProject);
-
+
jpaDiagramEditor
.activateTool(JPAEditorMessages.CreateMappedSuperclassFeature_createMappedSuperclassFeatureName);
jpaDiagramEditor.doubleClick(x, y);
try {
- bot.waitUntil(new ElementIsShown(jpaDiagramEditor, mappedSuperclassName),
- 15000);
+ bot.waitUntil(new ElementIsShown(jpaDiagramEditor,
+ mappedSuperclassName), 15000);
} catch (TimeoutException e) {
jpaDiagramEditor.activateDefaultTool();
@@ -391,8 +390,8 @@ public class EditorProxy {
.activateTool(JPAEditorMessages.CreateMappedSuperclassFeature_createMappedSuperclassFeatureName);
jpaDiagramEditor.doubleClick(x, y);
- bot.waitUntil(new ElementIsShown(jpaDiagramEditor, mappedSuperclassName),
- 15000);
+ bot.waitUntil(new ElementIsShown(jpaDiagramEditor,
+ mappedSuperclassName), 15000);
}
List<SWTBotGefEditPart> entities = jpaDiagramEditor.mainEditPart()
.children();
@@ -421,34 +420,35 @@ public class EditorProxy {
isSectionVisible(
JPAEditorMessages.AddJPAEntityFeature_relationAttributesShapes,
mappedSuperclass));
- assertFalse(
- "\"Other Attributes\" section must not be visible!",
- isSectionVisible(
- JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
- mappedSuperclass));
+// assertFalse(
+// "\"Other Attributes\" section must not be visible!",
+// isSectionVisible(
+// JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
+// mappedSuperclass));
return mappedSuperclass;
}
- /**
- * Add embeddable to diagram
- * @param x
- * @param y
- * @param jpaProject
- * @return the newly added embeddable
- */
+ /**
+ * Add embeddable to diagram
+ *
+ * @param x
+ * @param y
+ * @param jpaProject
+ * @return the newly added embeddable
+ */
public SWTBotGefEditPart addEmbeddableToDiagram(int x, int y,
JpaProject jpaProject) {
-
+
String embeddableName = getUniqueEmbeddableName(jpaProject);
-
+
jpaDiagramEditor
.activateTool(JPAEditorMessages.CreateEmbeddableFeature_EmbeddableFeatureName);
jpaDiagramEditor.doubleClick(x, y);
try {
bot.waitUntil(new ElementIsShown(jpaDiagramEditor, embeddableName),
- 15000);
+ 20000);
} catch (TimeoutException e) {
jpaDiagramEditor.activateDefaultTool();
@@ -457,7 +457,7 @@ public class EditorProxy {
jpaDiagramEditor.doubleClick(x, y);
bot.waitUntil(new ElementIsShown(jpaDiagramEditor, embeddableName),
- 15000);
+ 20000);
}
List<SWTBotGefEditPart> entities = jpaDiagramEditor.mainEditPart()
@@ -465,7 +465,8 @@ public class EditorProxy {
assertFalse("Editor must contains at least one embeddable!",
entities.isEmpty());
- SWTBotGefEditPart embeddable = jpaDiagramEditor.getEditPart(embeddableName);
+ SWTBotGefEditPart embeddable = jpaDiagramEditor
+ .getEditPart(embeddableName);
assertNotNull("Embeddable is not added!", embeddable);
List<SWTBotGefEditPart> editParts = new ArrayList<SWTBotGefEditPart>();
@@ -485,11 +486,11 @@ public class EditorProxy {
isSectionVisible(
JPAEditorMessages.AddJPAEntityFeature_relationAttributesShapes,
embeddable));
- assertFalse(
- "\"Other Attributes\" section must not be visible!",
- isSectionVisible(
- JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
- embeddable));
+// assertFalse(
+// "\"Other Attributes\" section must not be visible!",
+// isSectionVisible(
+// JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
+// embeddable));
return embeddable;
}
@@ -593,20 +594,24 @@ public class EditorProxy {
editPart.select();
jpaDiagramEditor.clickContextMenu("Delete");
confirmDelete();
+ bot.waitUntil(
+ new ElementDisappears(jpaDiagramEditor, type
+ .getSimpleName()), 10000);
+ editPart = jpaDiagramEditor.getEditPart(type.getSimpleName());
+ assertNull("Entity is not deleted!", editPart);
}
}
waitASecond();
entitiesInDiagram = jpaDiagramEditor.mainEditPart().children();
assertTrue("Diagram must be empty!", entitiesInDiagram.isEmpty());
-
+
jpaDiagramEditor.save();
// assertTrue("Editor must be dirty!", jpaDiagramEditor.isDirty());
}
public void deleteAttributeInJPT(SWTBotGefEditPart jpt, String attributeName) {
-
- waitASecond();
+
jpaDiagramEditor.activateDefaultTool();
List<SWTBotGefEditPart> jptParts = new ArrayList<SWTBotGefEditPart>();
@@ -793,7 +798,8 @@ public class EditorProxy {
* @return the IRelation object for the given GEF Connection
*/
public HasReferanceRelation getHasReferenceConnection(
- SWTBotGefConnectionEditPart gefConn) {
+ SWTBotGefConnectionEditPart gefConn, SWTBotGefEditPart attribute) {
+
IJPAEditorFeatureProvider fp = (IJPAEditorFeatureProvider) ((DiagramEditPart) jpaDiagramEditor
.mainEditPart().part()).getFeatureProvider();
FreeFormConnection conn = (FreeFormConnection) gefConn.part()
@@ -801,14 +807,15 @@ public class EditorProxy {
assertNotNull("Relation is not created.", conn);
Object ob = fp.getBusinessObjectForPictogramElement(conn);
- if(ob == null){
- HashSet<HasReferanceRelation> refs = fp.getAllExistingHasReferenceRelations();
- for(HasReferanceRelation ref : refs){
- FreeFormConnection connection = (FreeFormConnection) fp.getPictogramElementForBusinessObject(ref);
- if(connection.equals(conn)){
- return ref;
- }
- }
+ if (ob == null) {
+ JavaPersistentAttribute jpa = getJPAObjectForGefElement(attribute);
+ HasReferanceRelation rel = fp
+ .getEmbeddedRelationRelatedToAttribute(jpa);
+ assertNotNull(rel);
+ FreeFormConnection connection = (FreeFormConnection) fp
+ .getPictogramElementForBusinessObject(rel);
+ assertNotNull(connection);
+ return rel;
} else {
if (ob instanceof HasReferanceRelation) {
return (HasReferanceRelation) ob;
@@ -817,6 +824,18 @@ public class EditorProxy {
return null;
}
+ protected PersistentType getPersistentType(IFeatureProvider fp,
+ Anchor anchor) {
+ if (anchor != null) {
+ Object refObject = fp.getBusinessObjectForPictogramElement(anchor
+ .getParent());
+ if (refObject instanceof PersistentType) {
+ return (PersistentType) refObject;
+ }
+ }
+ return null;
+ }
+
/**
* Gets the business object (JavaPersistentType) for the given GEF element
*
@@ -829,7 +848,7 @@ public class EditorProxy {
final IFeatureProvider fp = ((DiagramEditPart) jpaDiagramEditor
.mainEditPart().part()).getFeatureProvider();
PictogramElement el = (PictogramElement) element.part().getModel();
- if(el == null)
+ if (el == null)
return null;
Object bo = fp.getBusinessObjectForPictogramElement(el);
if (bo instanceof JavaPersistentType) {
@@ -874,6 +893,7 @@ public class EditorProxy {
public boolean isJPTDirty(SWTBotGefEditPart element) {
final IFeatureProvider fp = ((DiagramEditPart) jpaDiagramEditor
.mainEditPart().part()).getFeatureProvider();
+ assertNotNull(element);
PictogramElement el = (PictogramElement) element.part().getModel();
Object bo = fp.getBusinessObjectForPictogramElement(el);
IResource res = null;
@@ -916,7 +936,7 @@ public class EditorProxy {
denyDelete();
assertFalse(entity1.sourceConnections().isEmpty());
assertFalse(entity2.targetConnections().isEmpty());
- connection = entity1.sourceConnections().get(0);
+ connection = getConnection(entity1, entity2);
assertNotNull("Attribute must not be deleted!", connection);
assertNotNull(jpaDiagramEditor.getEditPart(ownerAttributeName));
assertNotNull(jpaDiagramEditor.getEditPart(inverseAttributeName));
@@ -951,7 +971,7 @@ public class EditorProxy {
denyDelete();
assertFalse(entity1.sourceConnections().isEmpty());
assertFalse(entity1.targetConnections().isEmpty());
- connection = entity1.sourceConnections().get(0);
+ connection = getConnection(entity1, entity1);
assertNotNull("Attribute must not be deleted!", connection);
assertNotNull(jpaDiagramEditor.getEditPart(ownerAttributeName));
assertNotNull(jpaDiagramEditor.getEditPart(inverseAttributeName));
@@ -982,7 +1002,7 @@ public class EditorProxy {
denyDelete();
assertFalse(entity1.sourceConnections().isEmpty());
assertFalse(entity2.targetConnections().isEmpty());
- connection = entity1.sourceConnections().get(0);
+ connection = getConnection(entity1, entity2);
assertNotNull("Attribute must not be deleted!", connection);
assertNotNull(jpaDiagramEditor.getEditPart(attributeName));
assertTrue(
@@ -1015,7 +1035,7 @@ public class EditorProxy {
denyDelete();
assertFalse(entity1.sourceConnections().isEmpty());
assertFalse(entity1.targetConnections().isEmpty());
- connection = entity1.sourceConnections().get(0);
+ connection = getConnection(entity1, entity1);
assertNotNull("Attribute must not be deleted!", connection);
assertNotNull(jpaDiagramEditor.getEditPart(attributeName));
assertTrue(
@@ -1743,7 +1763,7 @@ public class EditorProxy {
jpaDiagramEditor
.clickContextMenu(JPAEditorMessages.JPAEditorToolBehaviorProvider_showAllTheEntities);
- bot.waitUntil(new ElementAppearsInDiagram(jpaDiagramEditor), 20000);
+ bot.waitUntil(new ElementAppearsInDiagram(jpaDiagramEditor), 30000);
assertFalse("Diagram must contain at least one entity!",
jpaDiagramEditor.mainEditPart().children().isEmpty());
@@ -1783,15 +1803,15 @@ public class EditorProxy {
jpaDiagramEditor.click(owner);
jpaDiagramEditor.click(inverse);
- bot.waitUntil(new ConnectionIsShown(owner));
+ bot.waitUntil(new ConnectionIsShown(owner), 10000);
waitASecond();
jpaDiagramEditor.activateDefaultTool();
assertConnectionIsCreated(owner, inverse, false);
- SWTBotGefConnectionEditPart connection = owner.sourceConnections().get(
- 0);
+ SWTBotGefConnectionEditPart connection = getConnection(owner, inverse);
+ assertNotNull("Connection must be shown in the diagram.", connection);
IRelation rel = getConnection(connection);
assertNotNull(rel);
assertEquals(IRelation.RelDir.UNI, rel.getRelDir());
@@ -1821,8 +1841,8 @@ public class EditorProxy {
assertSelfConnectionIsCreated(entity);
- SWTBotGefConnectionEditPart connection = entity.sourceConnections()
- .get(0);
+ SWTBotGefConnectionEditPart connection = getConnection(entity, entity);
+ assertNotNull("Connection must be shown in the diagram.", connection);
IRelation rel = getConnection(connection);
assertNotNull(rel);
assertEquals(IRelation.RelDir.UNI, rel.getRelDir());
@@ -1852,8 +1872,8 @@ public class EditorProxy {
assertConnectionIsCreated(owner, inverse, false);
- SWTBotGefConnectionEditPart connection = owner.sourceConnections().get(
- 0);
+ SWTBotGefConnectionEditPart connection = getConnection(owner, inverse);
+ assertNotNull("Connection must be shown in the diagram.", connection);
IRelation rel = getConnection(connection);
assertNotNull(rel);
assertEquals(IRelation.RelDir.UNI, rel.getRelDir());
@@ -1907,8 +1927,8 @@ public class EditorProxy {
assertConnectionIsCreated(owner, inverse, true);
- SWTBotGefConnectionEditPart connection = owner.sourceConnections().get(
- 0);
+ SWTBotGefConnectionEditPart connection = getConnection(owner, inverse);
+ assertNotNull("Connection must be shown in the diagram.", connection);
IRelation rel = getConnection(connection);
assertNotNull(rel);
assertEquals(IRelation.RelDir.BI, rel.getRelDir());
@@ -1942,8 +1962,8 @@ public class EditorProxy {
assertSelfConnectionIsCreated(entity);
- SWTBotGefConnectionEditPart connection = entity.sourceConnections()
- .get(0);
+ SWTBotGefConnectionEditPart connection = getConnection(entity, entity);
+ assertNotNull("Connection must be shown in the diagram.", connection);
IRelation rel = getConnection(connection);
assertNotNull(rel);
assertEquals(IRelation.RelDir.BI, rel.getRelDir());
@@ -1986,8 +2006,8 @@ public class EditorProxy {
assertConnectionIsCreated(owner, inverse, true);
- SWTBotGefConnectionEditPart connection = owner.sourceConnections().get(
- 0);
+ SWTBotGefConnectionEditPart connection = getConnection(owner, inverse);
+ assertNotNull("Connection must be shown in the diagram.", connection);
IRelation rel = getConnection(connection);
assertNotNull(rel);
assertEquals(IRelation.RelDir.BI, rel.getRelDir());
@@ -2010,7 +2030,8 @@ public class EditorProxy {
waitASecond();
// assert that the connection still exists, but it is unidirectional now
assertConnectionIsCreated(owner, inverse, false);
- connection = owner.sourceConnections().get(0);
+ connection = getConnection(owner, inverse);
+ assertNotNull("Connection must be shown in the diagram.", connection);
rel = getConnection(connection);
assertNotNull(rel);
assertEquals(IRelation.RelDir.UNI, rel.getRelDir());
@@ -2061,8 +2082,8 @@ public class EditorProxy {
assertConnectionIsCreated(owner, inverse, true);
- SWTBotGefConnectionEditPart connection = owner.sourceConnections().get(
- 0);
+ SWTBotGefConnectionEditPart connection = getConnection(owner, inverse);
+ assertNotNull("Connection must be shown in the diagram.", connection);
IRelation rel = getConnection(connection);
assertNotNull(rel);
assertEquals(IRelation.RelDir.BI, rel.getRelDir());
@@ -2166,8 +2187,9 @@ public class EditorProxy {
assertIsARelationExists(superclass, inheritedEntity);
- SWTBotGefConnectionEditPart connection = superclass.targetConnections()
- .get(0);
+ SWTBotGefConnectionEditPart connection = getConnection(inheritedEntity,
+ superclass);
+ assertNotNull("Connection must be shown in the diagram.", connection);
FreeFormConnection conn = (FreeFormConnection) connection.part()
.getModel();
assertTrue(IsARelation.isIsAConnection(conn));
@@ -2251,8 +2273,7 @@ public class EditorProxy {
assertTrue("There is no connection.", inverse.targetConnections()
.isEmpty());
}
-
-
+
/**
* Test all specific for the embedded connections properties and delete the
* embedded attribute and check that the connection is deleted as well.
@@ -2308,7 +2329,7 @@ public class EditorProxy {
String linkLabel, int elementsInDiagramCount) {
jpaDiagramEditor.activateTool(toolEntry);
-
+
jpaDiagramEditor.click(embeddingEntity);
jpaDiagramEditor.click(embeddable);
@@ -2317,14 +2338,14 @@ public class EditorProxy {
linkLabel);
return attributeName;
}
-
+
public String embedConnection(SWTBotGefEditor gefEditor, String toolEntry,
SWTBotGefEditPart embeddingEntity, SWTBotGefEditPart embeddable,
HasReferenceType refType, String embeddedMappingKey,
String linkLabel, int elementsInDiagramCount) {
gefEditor.activateTool(toolEntry);
-
+
gefEditor.click(embeddingEntity);
gefEditor.click(embeddable);
@@ -2334,29 +2355,50 @@ public class EditorProxy {
return attributeName;
}
+ private SWTBotGefConnectionEditPart getConnection(SWTBotGefEditPart start,
+ SWTBotGefEditPart end) {
+ List<SWTBotGefConnectionEditPart> connections = start
+ .sourceConnections();
+ assertFalse(connections.isEmpty());
+ for (SWTBotGefConnectionEditPart connection : connections) {
+ FreeFormConnection freeFormConnection = (FreeFormConnection) connection.part().getModel();
+ if (freeFormConnection.getStart() != null && freeFormConnection.getEnd() != null) {
+ PictogramElement startPe = freeFormConnection.getStart().getParent();
+ PictogramElement endPe = freeFormConnection.getEnd().getParent();
+ if (startPe.equals(start.part().getModel()) && endPe.equals(end.part().getModel()))
+ return connection;
+ }
+ }
+
+ return null;
+ }
+
public String checkEmbeddedConnectionProperties(
SWTBotGefEditPart embeddingEntity, SWTBotGefEditPart embeddable,
HasReferenceType refType, String embeddedMappingKey,
String linkLabel) {
-
+
bot.waitUntil(new ConnectionIsShown(embeddingEntity), 30000);
assertFalse("The connection must appear", embeddingEntity
.sourceConnections().isEmpty());
- SWTBotGefConnectionEditPart connection = embeddingEntity
- .sourceConnections().get(0);
-
+ SWTBotGefConnectionEditPart connection = getConnection(embeddingEntity,
+ embeddable);
+ assertNotNull("Connection must be shown in the diagram.", connection);
+
JavaPersistentType emb = getJPTObjectForGefElement(embeddable);
- String embAttr = JPAEditorUtil.decapitalizeFirstLetter(emb.getSimpleName());
-
+ String embAttr = JPAEditorUtil.decapitalizeFirstLetter(emb
+ .getSimpleName());
+
List<SWTBotGefEditPart> editParts = new ArrayList<SWTBotGefEditPart>();
editParts.add(embeddingEntity);
- SWTBotGefEditPart attribute = jpaDiagramEditor.getEditpart(
- embAttr, editParts);
-
+ SWTBotGefEditPart attribute = jpaDiagramEditor.getEditpart(embAttr,
+ editParts);
+
assertNotNull("Embedded attribute must be added.", attribute);
- HasReferanceRelation rel = getHasReferenceConnection(connection);
+ HasReferanceRelation rel = getHasReferenceConnection(connection,
+ attribute);
assertNotNull("Such a connection must exist.", rel);
assertEquals(refType, rel.getReferenceType());
@@ -2370,7 +2412,8 @@ public class EditorProxy {
.getEmbeddedAnnotatedAttribute().getOwningPersistentType();
assertEquals("The entity must contain an embedded attribute.",
parententity, getJPTObjectForGefElement(embeddingEntity));
- assertEquals(rel.getEmbeddingEntity(), getJPTObjectForGefElement(embeddingEntity));
+ assertEquals(rel.getEmbeddingEntity(),
+ getJPTObjectForGefElement(embeddingEntity));
assertEquals(rel.getEmbeddable(), getJPTObjectForGefElement(embeddable));
return attributeName;
}
@@ -2378,48 +2421,64 @@ public class EditorProxy {
public void setJpaDiagramEditor(SWTBotGefEditor jpaDiagramEditor) {
this.jpaDiagramEditor = jpaDiagramEditor;
}
-
+
+ public String getUniqueAttrName(SWTBotGefEditPart jptType) {
+ IJPAEditorFeatureProvider fp = (IJPAEditorFeatureProvider) ((DiagramEditPart) jpaDiagramEditor
+ .mainEditPart().part()).getFeatureProvider();
+ JavaPersistentType jpt = getJPTObjectForGefElement(jptType);
+ String attrName = JpaArtifactFactory.instance().genUniqueAttrName(jpt,
+ "java.lang.String", fp);
+
+ return attrName;
+ }
+
public String getUniqueMappedSuperclassName(JpaProject jpaProject) {
IJPAEditorFeatureProvider fp = (IJPAEditorFeatureProvider) ((DiagramEditPart) jpaDiagramEditor
.mainEditPart().part()).getFeatureProvider();
-
- String mappedSuperclassName = fp.getJPAEditorUtil().generateUniqueTypeName(jpaProject,
- JPADiagramPropertyPage.getDefaultPackage(jpaProject.getProject()),
- ".MpdSuprcls", fp); //$NON-NLS-1$
-
+
+ String mappedSuperclassName = fp.getJPAEditorUtil()
+ .generateUniqueTypeName(
+ jpaProject,
+ JPADiagramPropertyPage.getDefaultPackage(jpaProject
+ .getProject()), ".MpdSuprcls", fp); //$NON-NLS-1$
+
return JPAEditorUtil.returnSimpleName(mappedSuperclassName);
}
-
+
public String getUniqueEntityName(JpaProject jpaProject) {
IJPAEditorFeatureProvider fp = (IJPAEditorFeatureProvider) ((DiagramEditPart) jpaDiagramEditor
.mainEditPart().part()).getFeatureProvider();
-
- String entityName = fp.getJPAEditorUtil().generateUniqueTypeName(jpaProject,
- JPADiagramPropertyPage.getDefaultPackage(jpaProject.getProject()),
- ".Entity", fp); //$NON-NLS-1$
-
+
+ String entityName = fp.getJPAEditorUtil().generateUniqueTypeName(
+ jpaProject,
+ JPADiagramPropertyPage.getDefaultPackage(jpaProject
+ .getProject()), ".Entity", fp); //$NON-NLS-1$
+
return JPAEditorUtil.returnSimpleName(entityName);
}
-
+
public String getUniqueEmbeddableName(JpaProject jpaProject) {
IJPAEditorFeatureProvider fp = (IJPAEditorFeatureProvider) ((DiagramEditPart) jpaDiagramEditor
.mainEditPart().part()).getFeatureProvider();
-
- String embeddableName = fp.getJPAEditorUtil().generateUniqueTypeName(jpaProject,
- JPADiagramPropertyPage.getDefaultPackage(jpaProject.getProject()),
- ".Embeddable", fp); //$NON-NLS-1$
-
+
+ String embeddableName = fp.getJPAEditorUtil().generateUniqueTypeName(
+ jpaProject,
+ JPADiagramPropertyPage.getDefaultPackage(jpaProject
+ .getProject()), ".Embeddable", fp); //$NON-NLS-1$
+
return JPAEditorUtil.returnSimpleName(embeddableName);
}
-
- public void deleteResources(JpaProject jpaProject) throws CoreException{
+
+ public void deleteResources(JpaProject jpaProject) throws CoreException {
deleteDiagramElements();
Utils.printFormatted(">>>>>>>>>>>> elements are deleted from the diagram.");
-
- ListIterator<PersistenceUnit> lit = jpaProject.getRootContextNode().getPersistenceXml().getRoot().getPersistenceUnits().iterator();
+
+ ListIterator<PersistenceUnit> lit = jpaProject.getRootContextNode()
+ .getPersistenceXml().getRoot().getPersistenceUnits().iterator();
PersistenceUnit pu = lit.next();
- Iterator<PersistentType> persistentTypesIterator = (Iterator<PersistentType>) pu.getPersistentTypes().iterator();
- while(persistentTypesIterator.hasNext()){
+ Iterator<PersistentType> persistentTypesIterator = (Iterator<PersistentType>) pu
+ .getPersistentTypes().iterator();
+ while (persistentTypesIterator.hasNext()) {
Utils.printFormatted(">>>>>>>>>>>>>> persistent type resource must be deleted.");
PersistentType type = persistentTypesIterator.next();
type.getResource().delete(true, new NullProgressMonitor());
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EmbeddableInDiagramSWTBotTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EmbeddableInDiagramSWTBotTest.java
index c6d25e6..7514885 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EmbeddableInDiagramSWTBotTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EmbeddableInDiagramSWTBotTest.java
@@ -162,8 +162,9 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
.isSectionVisible(
JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
embeddable));
-
- editorProxy.addAttributeToJPT(embeddable, "attribute1");
+
+ String attributeName = editorProxy.getUniqueAttrName(embeddable);
+ editorProxy.addAttributeToJPT(embeddable, attributeName);
assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
embeddable.click();
@@ -179,16 +180,17 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
- SWTBotGefEditPart entity = editorProxy.addEmbeddableToDiagram(50, 50, jpaProject);
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50, 50, jpaProject);
assertFalse(
"\"Other Attributes\" section must not be visible!",
- editorProxy.isSectionVisible(JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes, entity));
+ editorProxy.isSectionVisible(JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes, embeddable));
- editorProxy.addElementCollectionAttributeToJPT(entity, "attribute1");
+ String attributeName = editorProxy.getUniqueAttrName(embeddable);
+ editorProxy.addElementCollectionAttributeToJPT(embeddable, attributeName);
assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
- entity.click();
+ embeddable.click();
editorProxy.deleteDiagramElements();
jpaDiagramEditor.save();
@@ -220,7 +222,8 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
"\"Other Attributes\" section must not be visible!",
editorProxy.isSectionVisible(JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes, embeddable1));
- editorProxy.addElementCollectionAttributeToJPT(embeddable1, "attribute1");
+ String attributeName = editorProxy.getUniqueAttrName(embeddable1);
+ editorProxy.addElementCollectionAttributeToJPT(embeddable1, attributeName);
assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
editorProxy.testNoEmbeddedConnectionIsCreated(
@@ -254,7 +257,8 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
50, jpaProject);
assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
- editorProxy.removeAttributeViaButton(embeddable, "attribute1");
+ String attributeName = editorProxy.getUniqueAttrName(embeddable);
+ editorProxy.removeAttributeViaButton(embeddable, attributeName);
embeddable.click();
editorProxy.deleteDiagramElements();
@@ -276,7 +280,8 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
50, jpaProject);
assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
- editorProxy.removeAttributeViaMenu(embeddable, "attribute1");
+ String attributeName = editorProxy.getUniqueAttrName(embeddable);
+ editorProxy.removeAttributeViaMenu(embeddable, attributeName);
embeddable.click();
editorProxy.deleteDiagramElements();
@@ -298,7 +303,8 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
50, jpaProject);
assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
- editorProxy.directEditAttribute(embeddable, "attribute1");
+ String attributeName = editorProxy.getUniqueAttrName(embeddable);
+ editorProxy.directEditAttribute(embeddable, attributeName);
assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
@@ -394,15 +400,16 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
embeddable));
+ String attributeName = editorProxy.getUniqueAttrName(embeddable);
SWTBotGefEditPart attribute = editorProxy.addAttributeToJPT(embeddable,
- "attribute1");
+ attributeName);
assertNotNull("The attribute must not be renamed!", attribute);
final IFeatureProvider fp = ((DiagramEditPart) jpaDiagramEditor
.mainEditPart().part()).getFeatureProvider();
String currentAttributeType = editorProxy.getAttributeType(
- "attribute1", fp);
+ attributeName, fp);
assertEquals("java.lang.String", currentAttributeType);
SWTBotShell changeTypeDialog = editorProxy
@@ -422,7 +429,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.getCancelButton(changeTypeDialog).click();
// assert that the attribute type is not changed
- currentAttributeType = editorProxy.getAttributeType("attribute1", fp);
+ currentAttributeType = editorProxy.getAttributeType(attributeName, fp);
assertEquals("The attribute type must not be changed!",
"java.lang.String", currentAttributeType);
@@ -439,7 +446,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.waitASecond();
// assert that the attribute's type is changed
String newAttributeType = editorProxy
- .getAttributeType("attribute1", fp);
+ .getAttributeType(attributeName, fp);
assertFalse("The attribute type must be changed!",
("java.lang.String").equals(newAttributeType));
assertEquals("The attribute type must be changed!", "int",
@@ -565,7 +572,8 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
50, jpaProject);
assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
- editorProxy.addAttributeToJPT(embeddable, "attribute1");
+ String attributeName = editorProxy.getUniqueAttrName(embeddable);
+ editorProxy.addAttributeToJPT(embeddable, attributeName);
editorProxy.collapseExpandJPTViaButton(embeddable);
@@ -588,7 +596,8 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
50, jpaProject);
assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
- editorProxy.addAttributeToJPT(embeddable, "attribute1");
+ String attributeName = editorProxy.getUniqueAttrName(embeddable);
+ editorProxy.addAttributeToJPT(embeddable, attributeName);
editorProxy.collapseExpandJPTViaMenu(embeddable);
@@ -614,7 +623,8 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
50, jpaProject);
assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
- editorProxy.discardChanges(embeddable, "attribute1");
+ String attributeName = editorProxy.getUniqueAttrName(embeddable);
+ editorProxy.discardChanges(embeddable, attributeName);
editorProxy.deleteDiagramElements();
jpaDiagramEditor.save();
@@ -640,7 +650,8 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
50, jpaProject);
assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
- editorProxy.removeAndDiscardChangesViaMenu(embeddable, "attribute1");
+ String attributeName = editorProxy.getUniqueAttrName(embeddable);
+ editorProxy.removeAndDiscardChangesViaMenu(embeddable, attributeName);
embeddable.click();
editorProxy.deleteDiagramElements();
@@ -666,7 +677,8 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
50, jpaProject);
assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
- editorProxy.removeAndSaveChangesViaMenu(embeddable, "attribute1");
+ String attributeName = editorProxy.getUniqueAttrName(embeddable);
+ editorProxy.removeAndSaveChangesViaMenu(embeddable, attributeName);
embeddable.click();
editorProxy.deleteDiagramElements();
@@ -690,7 +702,8 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
50, jpaProject);
assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
- editorProxy.saveOnlyJPT(embeddable, "attribute1");
+ String attributeName = editorProxy.getUniqueAttrName(embeddable);
+ editorProxy.saveOnlyJPT(embeddable, attributeName);
editorProxy.deleteDiagramElements();
jpaDiagramEditor.save();
@@ -731,7 +744,6 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
* the embeddable into the entity and checks that the connection exists and
* a new embedded attribute is added to the entity.
*/
- @Ignore
@Test
public void testEmbedCollectionOfObjectsInEntity() {
Utils.sayTestStarted("testEmbedCollectionOfObjectsInEntity");
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EntitiesInDiagramSWTBotTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EntitiesInDiagramSWTBotTest.java
index 5ecabea..4bbd4d4 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EntitiesInDiagramSWTBotTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EntitiesInDiagramSWTBotTest.java
@@ -165,7 +165,8 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
entity));
- editorProxy.addAttributeToJPT(entity, "attribute1");
+ String attributeName = editorProxy.getUniqueAttrName(entity);
+ editorProxy.addAttributeToJPT(entity, attributeName);
assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
entity.click();
@@ -192,7 +193,8 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
entity));
- editorProxy.addElementCollectionAttributeToJPT(entity, "attribute1");
+ String attributeName = editorProxy.getUniqueAttrName(entity);
+ editorProxy.addElementCollectionAttributeToJPT(entity, attributeName);
assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
entity.click();
@@ -215,7 +217,8 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
jpaProject);
- editorProxy.removeAttributeViaButton(entity, "attribute1");
+ String attributeName = editorProxy.getUniqueAttrName(entity);
+ editorProxy.removeAttributeViaButton(entity, attributeName);
entity.click();
editorProxy.deleteDiagramElements();
@@ -237,7 +240,8 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
jpaProject);
- editorProxy.removeAttributeViaMenu(entity, "attribute1");
+ String attributeName = editorProxy.getUniqueAttrName(entity);
+ editorProxy.removeAttributeViaMenu(entity, attributeName);
entity.click();
editorProxy.deleteDiagramElements();
@@ -259,7 +263,8 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
jpaProject);
- editorProxy.directEditAttribute(entity, "attribute1");
+ String attributeName = editorProxy.getUniqueAttrName(entity);
+ editorProxy.directEditAttribute(entity, attributeName);
assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
@@ -356,15 +361,16 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
entity));
+ String attributeName = editorProxy.getUniqueAttrName(entity);
SWTBotGefEditPart attribute = editorProxy.addAttributeToJPT(entity,
- "attribute1");
+ attributeName);
assertNotNull("The attribute must not be renamed!", attribute);
final IFeatureProvider fp = ((DiagramEditPart) jpaDiagramEditor
.mainEditPart().part()).getFeatureProvider();
String currentAttributeType = editorProxy.getAttributeType(
- "attribute1", fp);
+ attributeName, fp);
assertEquals("java.lang.String", currentAttributeType);
SWTBotShell changeTypeDialog = editorProxy
@@ -384,7 +390,7 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.getCancelButton(changeTypeDialog).click();
// assert that the attribute type is not changed
- currentAttributeType = editorProxy.getAttributeType("attribute1", fp);
+ currentAttributeType = editorProxy.getAttributeType(attributeName, fp);
assertEquals("The attribute type must not be changed!",
"java.lang.String", currentAttributeType);
@@ -401,7 +407,7 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.waitASecond();
// assert that the attribute's type is changed
String newAttributeType = editorProxy
- .getAttributeType("attribute1", fp);
+ .getAttributeType(attributeName, fp);
assertFalse("The attribute type must be changed!",
("java.lang.String").equals(newAttributeType));
assertEquals("The attribute type must be changed!", "int",
@@ -591,7 +597,8 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
jpaProject);
- editorProxy.discardChanges(entity, "attribute1");
+ String attributeName = editorProxy.getUniqueAttrName(entity);
+ editorProxy.discardChanges(entity, attributeName);
editorProxy.deleteDiagramElements();
jpaDiagramEditor.save();
@@ -616,7 +623,8 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
jpaProject);
- editorProxy.removeAndDiscardChangesViaMenu(entity, "attribute1");
+ String attributeName = editorProxy.getUniqueAttrName(entity);
+ editorProxy.removeAndDiscardChangesViaMenu(entity, attributeName);
entity.click();
editorProxy.deleteDiagramElements();
@@ -642,7 +650,8 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
jpaProject);
- editorProxy.removeAndSaveChangesViaMenu(entity, "attribute1");
+ String attributeName = editorProxy.getUniqueAttrName(entity);
+ editorProxy.removeAndSaveChangesViaMenu(entity, attributeName);
entity.click();
editorProxy.deleteDiagramElements();
@@ -665,7 +674,8 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
jpaProject);
- editorProxy.saveOnlyJPT(entity, "attribute1");
+ String attributeName = editorProxy.getUniqueAttrName(entity);
+ editorProxy.saveOnlyJPT(entity, attributeName);
editorProxy.deleteDiagramElements();
jpaDiagramEditor.save();
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/MappedSuperclassesInDiagramSWTBotTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/MappedSuperclassesInDiagramSWTBotTest.java
index 739f0a4..dec2422 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/MappedSuperclassesInDiagramSWTBotTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/MappedSuperclassesInDiagramSWTBotTest.java
@@ -158,7 +158,8 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
mappedSuperclass));
- editorProxy.addAttributeToJPT(mappedSuperclass, "attribute1");
+ String attributeName = editorProxy.getUniqueAttrName(mappedSuperclass);
+ editorProxy.addAttributeToJPT(mappedSuperclass, attributeName);
assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
mappedSuperclass.click();
@@ -185,7 +186,8 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
mappedSuperclass));
- editorProxy.addElementCollectionAttributeToJPT(mappedSuperclass, "attribute1");
+ String attributeName = editorProxy.getUniqueAttrName(mappedSuperclass);
+ editorProxy.addElementCollectionAttributeToJPT(mappedSuperclass, attributeName);
assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
mappedSuperclass.click();
@@ -208,7 +210,8 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
SWTBotGefEditPart mappedSuperclass = editorProxy
.addMappedSuperclassToDiagram(50, 50, jpaProject);
- editorProxy.removeAttributeViaButton(mappedSuperclass, "attribute1");
+ String attributeName = editorProxy.getUniqueAttrName(mappedSuperclass);
+ editorProxy.removeAttributeViaButton(mappedSuperclass, attributeName);
mappedSuperclass.click();
editorProxy.deleteDiagramElements();
@@ -230,7 +233,8 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
SWTBotGefEditPart mappedSuperclass = editorProxy
.addMappedSuperclassToDiagram(50, 50, jpaProject);
- editorProxy.removeAttributeViaMenu(mappedSuperclass, "attribute1");
+ String attributeName = editorProxy.getUniqueAttrName(mappedSuperclass);
+ editorProxy.removeAttributeViaMenu(mappedSuperclass, attributeName);
mappedSuperclass.click();
editorProxy.deleteDiagramElements();
@@ -252,7 +256,8 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
SWTBotGefEditPart mappedSuperclass = editorProxy
.addMappedSuperclassToDiagram(50, 50, jpaProject);
- editorProxy.directEditAttribute(mappedSuperclass, "attribute1");
+ String attributeName = editorProxy.getUniqueAttrName(mappedSuperclass);
+ editorProxy.directEditAttribute(mappedSuperclass, attributeName);
assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
@@ -349,15 +354,16 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
mappedSuperclass));
+ String attributeName = editorProxy.getUniqueAttrName(mappedSuperclass);
SWTBotGefEditPart attribute = editorProxy.addAttributeToJPT(
- mappedSuperclass, "attribute1");
+ mappedSuperclass, attributeName);
assertNotNull("The attribute must not be renamed!", attribute);
final IFeatureProvider fp = ((DiagramEditPart) jpaDiagramEditor
.mainEditPart().part()).getFeatureProvider();
String currentAttributeType = editorProxy.getAttributeType(
- "attribute1", fp);
+ attributeName, fp);
assertEquals("java.lang.String", currentAttributeType);
SWTBotShell changeTypeDialog = editorProxy
@@ -377,7 +383,7 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.getCancelButton(changeTypeDialog).click();
// assert that the attribute type is not changed
- currentAttributeType = editorProxy.getAttributeType("attribute1", fp);
+ currentAttributeType = editorProxy.getAttributeType(attributeName, fp);
assertEquals("The attribute type must not be changed!",
"java.lang.String", currentAttributeType);
@@ -394,7 +400,7 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.waitASecond();
// assert that the attribute's type is changed
String newAttributeType = editorProxy
- .getAttributeType("attribute1", fp);
+ .getAttributeType(attributeName, fp);
assertFalse("The attribute type must be changed!",
("java.lang.String").equals(newAttributeType));
assertEquals("The attribute type must be changed!", "int",
@@ -518,7 +524,8 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
SWTBotGefEditPart mappedSuperclass = editorProxy
.addMappedSuperclassToDiagram(50, 50, jpaProject);
- editorProxy.addAttributeToJPT(mappedSuperclass, "attribute1");
+ String attributeName = editorProxy.getUniqueAttrName(mappedSuperclass);
+ editorProxy.addAttributeToJPT(mappedSuperclass, attributeName);
editorProxy.collapseExpandJPTViaButton(mappedSuperclass);
@@ -541,7 +548,8 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
SWTBotGefEditPart mappedSuperclass = editorProxy
.addMappedSuperclassToDiagram(50, 50, jpaProject);
- editorProxy.addAttributeToJPT(mappedSuperclass, "attribute1");
+ String attributeName = editorProxy.getUniqueAttrName(mappedSuperclass);
+ editorProxy.addAttributeToJPT(mappedSuperclass, attributeName);
editorProxy.collapseExpandJPTViaMenu(mappedSuperclass);
@@ -566,7 +574,8 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
SWTBotGefEditPart mappedSuperclass = editorProxy
.addMappedSuperclassToDiagram(50, 50, jpaProject);
- editorProxy.discardChanges(mappedSuperclass, "attribute1");
+ String attributeName = editorProxy.getUniqueAttrName(mappedSuperclass);
+ editorProxy.discardChanges(mappedSuperclass, attributeName);
editorProxy.deleteDiagramElements();
jpaDiagramEditor.save();
@@ -592,8 +601,9 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
SWTBotGefEditPart mappedSuperclass = editorProxy
.addMappedSuperclassToDiagram(50, 50, jpaProject);
+ String attributeName = editorProxy.getUniqueAttrName(mappedSuperclass);
editorProxy.removeAndDiscardChangesViaMenu(mappedSuperclass,
- "attribute1");
+ attributeName);
mappedSuperclass.click();
editorProxy.deleteDiagramElements();
@@ -620,7 +630,8 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
SWTBotGefEditPart mappedSuperclass = editorProxy
.addMappedSuperclassToDiagram(50, 50, jpaProject);
- editorProxy.removeAndSaveChangesViaMenu(mappedSuperclass, "attribute1");
+ String attributeName = editorProxy.getUniqueAttrName(mappedSuperclass);
+ editorProxy.removeAndSaveChangesViaMenu(mappedSuperclass, attributeName);
mappedSuperclass.click();
editorProxy.deleteDiagramElements();
@@ -644,7 +655,8 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
SWTBotGefEditPart mappedSuperclass = editorProxy
.addMappedSuperclassToDiagram(50, 50, jpaProject);
- editorProxy.saveOnlyJPT(mappedSuperclass, "attribute1");
+ String attributeName = editorProxy.getUniqueAttrName(mappedSuperclass);
+ editorProxy.saveOnlyJPT(mappedSuperclass, attributeName);
editorProxy.deleteDiagramElements();
jpaDiagramEditor.save();