summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetya Sabeva2013-03-14 08:14:24 (EDT)
committer Petya Sabeva2013-04-10 09:29:21 (EDT)
commit3d776d5fddefa31731027bf638c9ffdf8e223110 (patch)
tree81bd2f6951484dcec75b845e4ce27fef75b33d61
parentd692b2952c6cb5d339aac871455311934789dfc8 (diff)
downloadwebtools.dali-3d776d5fddefa31731027bf638c9ffdf8e223110.zip
webtools.dali-3d776d5fddefa31731027bf638c9ffdf8e223110.tar.gz
webtools.dali-3d776d5fddefa31731027bf638c9ffdf8e223110.tar.bz2
Bug 403482 - Add SWT bot tests for xml defined persistent types
-rw-r--r--jpa_diagram_editor/development/org.eclipse.jpt.jpadiagrameditor.releng/pom.xml48
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/JPADiagramEditor.java8
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/AddAttributeCommand.java51
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/AddPersistentAttributeInOrmXMLCommand.java49
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/AddPersistentTypeToOrmXmlCommand.java2
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/DeleteAttributeCommand.java153
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/RemovePersistentAttributeFromormXmlCommand.java33
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/RenameAttributeCommand.java63
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/RenameEntityCommand.java22
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddJPAEntityFeature.java28
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ClickAddAttributeButtonFeature.java2
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ClickAddElementCollectionButtonFeature.java8
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ClickRemoveAttributeButtonFeature.java10
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateEmbeddableFeature.java10
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateIsARelationFeature.java1
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateJPAEntityFeature.java5
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DeleteRelationFeature.java34
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/EmbedCollectionOfObjectsFeature.java9
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/EmbedSingleObjectFeature.java9
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/GraphicalAddAttributeFeature.java6
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/GraphicalRemoveAttributeFeature.java1
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorAttributeTypeFeature.java4
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorEntityFeature.java2
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorFeatureProvider.java12
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyBiDirRelation.java6
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyUniDirRelation.java2
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneBiDirRelation.java6
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneUniDirRelation.java2
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToManyUniDirRelation.java2
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneBiDirRelation.java6
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneUniDirRelation.java2
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtil.java18
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPASolver.java4
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JpaArtifactFactory.java142
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/META-INF/MANIFEST.MF15
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/conditions/ConnectionIsShown.java (renamed from jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/ConnectionIsShown.java)2
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/conditions/DiagramIsEmpty.java (renamed from jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/DiagramIsEmpty.java)2
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/conditions/ElementAppearsInDiagram.java (renamed from jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/ElementAppearsInDiagram.java)2
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/conditions/ElementDisappears.java (renamed from jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/ElementDisappears.java)2
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/conditions/ElementIsShown.java (renamed from jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/ElementIsShown.java)2
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/embeddable/EmbeddableInDiagramSWTBotTest.java900
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/embeddable/relationships/EmbeddableRelationshipsSWTBotTest.java1070
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/emebeddable10/EmbeddableInJPAProject10SWTBotTest.java109
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/entity/EntitiesInDiagramSWTBotTest.java1018
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/entity/OpenDiagramEditorSWTBotTest.java58
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/entity/derivedIds/EntitiesDerivedIdsSWTBotTest.java221
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/entity/orm/OrmPersistentTypesSWTBotTest.java250
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/entity/orm/derivedIds/OrmEntitiesDerivedIdsSWTBotTest.java226
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/entity/relationships/EntityRelationshipsSWTBotTest.java222
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/internal/AbstractSwtBotEditorTest.java257
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/internal/JPACreateFactory.java258
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/mappedsuperclass/MappedSuperclassesInDiagramSWTBotTest.java (renamed from jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/MappedSuperclassesInDiagramSWTBotTest.java)515
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/mappedsuperclass/relationships/MappedSuperclassRelationshipsSWTBotTest.java374
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/ContextMenuHelper.java131
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EmbeddableInDiagramSWTBotTest.java2065
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EntitiesInDiagramSWTBotTest.java2379
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/utils/ContextMenuHelper.java487
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/utils/EditorProxy.java (renamed from jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EditorProxy.java)1051
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/utils/RelationshipsUtils.java1361
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/utils/Utils.java (renamed from jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/internal/Utils.java)2
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/JPACreateFactory.java10
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/CreateDeleteOnlyAttributeTest.java6
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationAttributesTest.java33
63 files changed, 7941 insertions, 5847 deletions
diff --git a/jpa_diagram_editor/development/org.eclipse.jpt.jpadiagrameditor.releng/pom.xml b/jpa_diagram_editor/development/org.eclipse.jpt.jpadiagrameditor.releng/pom.xml
index 88a28e5..00aa2d3 100644
--- a/jpa_diagram_editor/development/org.eclipse.jpt.jpadiagrameditor.releng/pom.xml
+++ b/jpa_diagram_editor/development/org.eclipse.jpt.jpadiagrameditor.releng/pom.xml
@@ -11,21 +11,19 @@
<tycho-version>0.15.0</tycho-version>
<eclipse-site>http://download.eclipse.org/eclipse/updates/4.3milestones/</eclipse-site>
<emf-site>http://download.eclipse.org/modeling/emf/emf/updates/2.9milestones/</emf-site>
- <modeling-site>http://download.eclipse.org/modeling/emf/updates/releases</modeling-site>
- <dtp-site>http://download.eclipse.org/datatools/downloads/drops/M_updates_1.10.2/</dtp-site>
- <gef-site>http://download.eclipse.org/tools/gef/updates/milestones/</gef-site>
- <wtp-site>http://build.eclipse.org/webtools/committers/wtp4x-R3.5.0-I/20130307051714/I-3.5.0-20130307051714/repository/</wtp-site>
- <graphiti-site>http://download.eclipse.org/graphiti/updates/milestones/</graphiti-site>
- <swtbot-site>http://download.eclipse.org/technology/swtbot/helios/dev-build/update-site</swtbot-site>
- <tycho.testArgLine>-Xmx512m -Xms128m -XX:PermSize=32m -XX:MaxPermSize=256m -DenableDebug -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=1044</tycho.testArgLine>
+ <emf-transaction>http://download.eclipse.org/modeling/emf/transaction/updates/milestones</emf-transaction>
+ <emf-validation>http://download.eclipse.org/modeling/emf/validation/updates/milestones</emf-validation>
+ <dtp-site>http://download.eclipse.org/datatools/downloads/drops/M_updates_1.11.0/</dtp-site>
+ <gef-site>http://download.eclipse.org/tools/gef/updates/interim/</gef-site>
+ <wtp-site>http://build.eclipse.org/webtools/committers/wtp4x-R3.5.0-I/20130404041018/I-3.5.0-20130404041018/repository/</wtp-site>
+ <graphiti-site>http://download.eclipse.org/graphiti/updates/milestones/S-0.10.0M6-201303191346</graphiti-site>
+ <swtbot-site>http://download.eclipse.org/technology/swtbot/releases/latest/</swtbot-site>
</properties>
<modules>
<module>../../plugins/org.eclipse.jpt.jpadiagrameditor.ui</module>
<module>../../plugins/org.eclipse.jpt.jpadiagrameditor.doc.user</module>
<module>../../plugins/org.eclipse.jpt.jpadiagrameditor.branding</module>
- <!-- module>../../tests/org.eclipse.jpt.jpadiagrameditor.ui.tests</module>
- <module>../../tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests</module-->
<module>../../features/org.eclipse.jpt.jpadiagrameditor.feature</module>
<module>../org.eclipse.jpt.jpadiagrameditor.repository</module>
</modules>
@@ -44,15 +42,16 @@
<version>${tycho-version}</version>
<configuration>
<resolver>p2</resolver>
- <!-- dependencies>
- <dependency>
- <type>eclipse-feature</type>
- <artifactId>org.eclipse.jpt.jpa.feature</artifactId>
- <version>0.0.0</version>
- </dependency>
- </dependencies-->
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-surefire-plugin</artifactId>
+ <version>${tycho-version}</version>
+ <configuration>
+ <argLine>-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y</argLine>
+ </configuration>
+ </plugin>
</plugins>
</build>
@@ -67,20 +66,25 @@
<url>${emf-site}</url>
<layout>p2</layout>
</repository>
+ <repository>
+ <id>GEF</id>
+ <url>${gef-site}</url>
+ <layout>p2</layout>
+ </repository>
<repository>
<id>DTP</id>
<url>${dtp-site}</url>
<layout>p2</layout>
</repository>
<repository>
- <id>Modeling</id>
- <url>${modeling-site}</url>
- <layout>p2</layout>
+ <id>EmfTransaction</id>
+ <url>${emf-transaction}</url>
+ <layout>p2</layout>
</repository>
<repository>
- <id>GEF</id>
- <url>${gef-site}</url>
- <layout>p2</layout>
+ <id>EmfValidation</id>
+ <url>${emf-validation}</url>
+ <layout>p2</layout>
</repository>
<repository>
<id>WTP</id>
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/JPADiagramEditor.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/JPADiagramEditor.java
index 1641284..c014df2 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/JPADiagramEditor.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/JPADiagramEditor.java
@@ -337,10 +337,10 @@ public class JPADiagramEditor extends DiagramEditor implements JpaEditorManager{
.getBusinessObjectForPictogramElement(
(PictogramElement) m);
if ((bo == null) || (!(bo instanceof JpaStructureNode))){
- if(jpaSelectionModel == null)
- return;
- jpaSelectionModel.setValue(null);
- setFileModel(null);
+ if(jpaSelectionModel != null) {
+ jpaSelectionModel.setValue(null);
+ setFileModel(null);
+ }
return;
}
JpaStructureNode jpaStructureNode = (JpaStructureNode) bo;
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/AddAttributeCommand.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/AddAttributeCommand.java
index 31d2e3a..9e9d299 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/AddAttributeCommand.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/AddAttributeCommand.java
@@ -24,14 +24,14 @@ import java.util.Properties;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
import org.eclipse.jpt.common.utility.command.Command;
import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.propertypage.JPADiagramPropertyPage;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
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;
@@ -45,7 +45,6 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
*/
public class AddAttributeCommand implements Command {
- private IJPAEditorFeatureProvider fp;
private PersistentType jpt;
private String attributeType;
private String mapKeyType;
@@ -54,27 +53,23 @@ public class AddAttributeCommand implements Command {
private String[] attrTypes;
private List<String> annotations;
private boolean isCollection;
- private ICompilationUnit cu;
/**
* Constructor for the create new attribute command.
*
- * @param fp
* @param jpt
* @param attributeType
* @param mapKeyType
* @param attributeName
* @param actName
* @param isCollection
- * @param cu
*/
- public AddAttributeCommand(IJPAEditorFeatureProvider fp,
+ public AddAttributeCommand(
PersistentType jpt, String attributeType, String mapKeyType,
String attributeName, String actName, String[] attrTypes,
List<String> annotations,
- boolean isCollection, ICompilationUnit cu) {
+ boolean isCollection) {
super();
- this.fp = fp;
this.jpt = jpt;
this.attributeType = attributeType;
this.mapKeyType = mapKeyType;
@@ -83,22 +78,18 @@ public class AddAttributeCommand implements Command {
this.attrTypes = attrTypes;
this.annotations = annotations;
this.isCollection = isCollection;
- this.cu = cu;
}
/**
* Creates a new attribute.
*/
public void execute() {
- IType type = null;
try {
-// if(jpt != null){
-// cu = JPAEditorUtil.getCompilationUnit(jpt);
-// }
+ IJavaProject jp = JavaCore.create(jpt.getJpaProject().getProject());
+ IType type = jp.findType(jpt.getName());
+ ICompilationUnit cu = type.getCompilationUnit();
JPAEditorUtil.createImport(cu, attributeType);
attributeType = JPAEditorUtil.returnSimpleName(attributeType);
- type = cu.findPrimaryType();
-
if ((attrTypes != null) && (attrTypes.length > 0)) {
JPAEditorUtil.createImports(cu, attrTypes);
}
@@ -112,15 +103,12 @@ public class AddAttributeCommand implements Command {
}
}
- createAttribute(fp, jpt, attributeType, mapKeyType, attributeName,
+ createAttribute(jpt, attributeType, mapKeyType, attributeName,
actName, cu, type, isCollection, attrTypes, contents);
- if(jpt != null) {
- jpt.getJpaProject().getContextModelRoot().synchronizeWithResourceModel();
- JavaResourceType jrt = jpt.getJavaResourceType();
- jrt.getJavaResourceCompilationUnit().synchronizeWithJavaSource();
- jpt.update();
- }
+ jpt.getJavaResourceType().getJavaResourceCompilationUnit().synchronizeWithJavaSource();
+ jpt.synchronizeWithResourceModel();
+ jpt.update();
} catch (JavaModelException e) {
JPADiagramEditorPlugin
@@ -132,7 +120,6 @@ public class AddAttributeCommand implements Command {
/**
* Creates an attribute the persistent type.
*
- * @param fp
* @param jpt
* @param attrTypeName
* @param mapKeyType
@@ -143,13 +130,12 @@ public class AddAttributeCommand implements Command {
* @param isCollection
* @throws JavaModelException
*/
- private void createAttribute(IJPAEditorFeatureProvider fp,
- PersistentType jpt, String attrTypeName, String mapKeyType,
+ private void createAttribute(PersistentType jpt, String attrTypeName, String mapKeyType,
String attrName, String actName, ICompilationUnit cu, IType type,
boolean isCollection, String[] attrTypeElementNames, String annotationContents) throws JavaModelException {
if (isCollection) {
- createAttributeOfCollectiontype(fp, jpt, attrTypeName,
+ createAttributeOfCollectiontype(jpt, attrTypeName,
mapKeyType, attrName, actName, cu, type);
} else {
createSimpleAttribute(attrTypeName, attrName, actName,
@@ -182,7 +168,7 @@ public class AddAttributeCommand implements Command {
} else {
contents = attrFieldContent;
}
-
+
type.createField(contents, null, false, new NullProgressMonitor());
type.createMethod(
@@ -197,7 +183,6 @@ public class AddAttributeCommand implements Command {
* Creates a new attribute of a collection type, depending on the specified
* collection type in the Preference/Properties page.
*
- * @param fp
* @param jpt
* @param attributeType
* @param mapKeyType
@@ -207,12 +192,12 @@ public class AddAttributeCommand implements Command {
* @param type
* @throws JavaModelException
*/
- private void createAttributeOfCollectiontype(IJPAEditorFeatureProvider fp,
+ private void createAttributeOfCollectiontype(
PersistentType jpt, String attributeType, String mapKeyType,
String attributeName, String actName, ICompilationUnit cu,
IType type) throws JavaModelException {
IProject project = jpt.getJpaProject().getProject();
- Properties props = fp.loadProperties(project);
+ Properties props = loadProperties(project);
if (JPADiagramPropertyPage.isCollectionType(project, props)) {
createAttributeByCollectionMethodType(attributeType, null,
attributeName, actName, cu, type,
@@ -411,5 +396,9 @@ public class AddAttributeCommand implements Command {
" }\n"; //$NON-NLS-1$
return contents;
}
+
+ private Properties loadProperties(IProject project) {
+ return JPADiagramPropertyPage.loadProperties(project);
+ }
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/AddPersistentAttributeInOrmXMLCommand.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/AddPersistentAttributeInOrmXMLCommand.java
new file mode 100644
index 0000000..dce1b07
--- /dev/null
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/AddPersistentAttributeInOrmXMLCommand.java
@@ -0,0 +1,49 @@
+package org.eclipse.jpt.jpadiagrameditor.ui.internal.command;
+
+import org.eclipse.jpt.common.utility.command.Command;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
+import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
+import org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
+
+public class AddPersistentAttributeInOrmXMLCommand implements Command {
+
+ private PersistentType jpt;
+ private PersistentAttribute jpa;
+ private String mappingKey;
+
+ public AddPersistentAttributeInOrmXMLCommand(PersistentType jpt, PersistentAttribute jpa, String mappingKey){
+ this.jpt = jpt;
+ this.jpa = jpa;
+ this.mappingKey = mappingKey;
+ }
+
+ public void execute() {
+ MappingFileRef ormXml = JpaArtifactFactory.instance().getOrmXmlByForPersistentType(jpt);
+ if(ormXml != null && ormXml.getMappingFile() != null) {
+ OrmPersistentType ormPersistentType = (OrmPersistentType)ormXml.getMappingFile().getManagedType(jpt.getName());
+ if(ormPersistentType == null)
+ return;
+ OrmPersistentAttribute ormAttribute = ormPersistentType.getAttributeNamed(jpa.getName());
+ if(ormAttribute == null) {
+ ormPersistentType.getJavaResourceType().getJavaResourceCompilationUnit().synchronizeWithJavaSource();
+ ormPersistentType.update();
+ ormAttribute = ormPersistentType.getAttributeNamed(jpa.getName());
+ }
+ if(ormAttribute != null && ormAttribute.isVirtual()){
+ if(mappingKey == null){
+ ormPersistentType.addAttributeToXml(ormAttribute);
+ } else {
+ ormPersistentType.addAttributeToXml(ormAttribute, mappingKey);
+ }
+ }
+ }
+
+ jpt.getJavaResourceType().getJavaResourceCompilationUnit().synchronizeWithJavaSource();
+ jpt.synchronizeWithResourceModel();
+ jpt.update();
+ }
+
+}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/AddPersistentTypeToOrmXmlCommand.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/AddPersistentTypeToOrmXmlCommand.java
index ac8051a..a7f6a11 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/AddPersistentTypeToOrmXmlCommand.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/AddPersistentTypeToOrmXmlCommand.java
@@ -53,6 +53,8 @@ public class AddPersistentTypeToOrmXmlCommand implements Command {
MappingFileRef mapFile = iter.next();
if(mapFile.getFileName().equals(ormFileName)){
OrmXml ormXml = (OrmXml) mapFile.getMappingFile();
+ if(ormXml == null || ormXml.getRoot() == null)
+ return;
OrmPersistentType type = ormXml.getRoot().addPersistentType(mapping, persistentTypeName);
for(PersistentAttribute pa : type.getDefaultAttributes()){
type.addAttributeToXml(type.getAttributeNamed(pa.getName()));
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/DeleteAttributeCommand.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/DeleteAttributeCommand.java
index 74c7ba5..2440179 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/DeleteAttributeCommand.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/DeleteAttributeCommand.java
@@ -20,12 +20,12 @@ import java.util.Locale;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.graphiti.ui.editor.IDiagramContainerUI;
-import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IField;
+import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
import org.eclipse.jpt.common.utility.command.Command;
import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
@@ -39,34 +39,61 @@ public class DeleteAttributeCommand implements Command {
private PersistentType jpt;
private String attributeName;
private IJPAEditorFeatureProvider fp;
- private ICompilationUnit unit;
- public DeleteAttributeCommand(ICompilationUnit unit, PersistentType jpt, String attributeName,
+ public DeleteAttributeCommand(PersistentType jpt, String attributeName,
IJPAEditorFeatureProvider fp) {
super();
this.jpt = jpt;
- this.unit = unit;
this.attributeName = attributeName;
this.fp = fp;
}
public void execute() {
- boolean isMethodAnnotated = false;
- if(jpt != null) {
-
- JpaArtifactFactory.instance().removeOrmPersistentAttribute(jpt, attributeName);
-
- unit = fp.getCompilationUnit(jpt);
- isMethodAnnotated = JpaArtifactFactory.instance()
- .isMethodAnnotated(jpt);
- }
-
- IType javaType = unit.findPrimaryType();
+ JpaArtifactFactory.instance().removeOrmPersistentAttribute(jpt, attributeName);
+ try {
+ IJavaProject jp = JavaCore.create(jpt.getJpaProject().getProject());
+ IType javaType = jp.findType(jpt.getName());
+
String attrNameWithCapitalLetter = attributeName.substring(0, 1)
.toUpperCase(Locale.ENGLISH) + attributeName.substring(1);
+ IMethod getAttributeMethod = findGetterMethod(javaType,
+ attrNameWithCapitalLetter);
+
+ String typeSignature = getReturnedType(getAttributeMethod);
+
+ deleteGetterMethod(typeSignature, getAttributeMethod);
+ deleteField(javaType);
+ deleteSetterMethod(javaType, attrNameWithCapitalLetter,
+ typeSignature);
+
+ IWorkbenchSite ws = ((IDiagramContainerUI) fp.getDiagramTypeProvider().getDiagramBehavior().getDiagramContainer()).getSite();
+ JPAEditorUtil.organizeImports(javaType.getCompilationUnit(), ws);
+
+ jpt.getJavaResourceType().getJavaResourceCompilationUnit().synchronizeWithJavaSource();
+ jpt.synchronizeWithResourceModel();
+ jpt.update();
+
+ } catch (JavaModelException e) {
+ JPADiagramEditorPlugin
+ .logError(
+ "Cannnot delete attribute with name " + attributeName, e); //$NON-NLS-1$
+ }
+
+ }
+
+ private String getReturnedType(IMethod getAttributeMethod)
+ throws JavaModelException {
String typeSignature = null;
+ if ((getAttributeMethod != null) && getAttributeMethod.exists()) {
+ typeSignature = getAttributeMethod.getReturnType();
+ }
+ return typeSignature;
+ }
+
+ private IMethod findGetterMethod(IType javaType,
+ String attrNameWithCapitalLetter) {
String getterPrefix = "get"; //$NON-NLS-1$
String methodName = getterPrefix + attrNameWithCapitalLetter;
IMethod getAttributeMethod = javaType.getMethod(methodName,
@@ -76,78 +103,34 @@ public class DeleteAttributeCommand implements Command {
}
methodName = getterPrefix + attrNameWithCapitalLetter; //$NON-NLS-1$
getAttributeMethod = javaType.getMethod(methodName, new String[0]);
- try {
- if ((getAttributeMethod != null) && getAttributeMethod.exists())
- typeSignature = getAttributeMethod.getReturnType();
- } catch (JavaModelException e1) {
- JPADiagramEditorPlugin.logError("Cannot obtain the type of the getter with name " + methodName + "()", e1); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- if (typeSignature == null)
- methodName = null;
-
- if (isMethodAnnotated) {
- try {
- IField attributeField = javaType.getField(attributeName);
-
- if ((attributeField != null) && !attributeField.exists())
- attributeField = javaType.getField(JPAEditorUtil.revertFirstLetterCase(attributeName));
- if ((attributeField != null) && attributeField.exists())
- attributeField.delete(true, new NullProgressMonitor());
- } catch (JavaModelException e) {
- JPADiagramEditorPlugin.logError("Cannot remove the attribute field with name " + attributeName, e); //$NON-NLS-1$
- }
- try {
- methodName = getterPrefix + attrNameWithCapitalLetter; //$NON-NLS-1$
- if (getAttributeMethod != null) {
- typeSignature = getAttributeMethod.getReturnType();
- if (getAttributeMethod.exists())
- getAttributeMethod.delete(true, new NullProgressMonitor());
- }
- } catch (JavaModelException e) {
- JPADiagramEditorPlugin.logError("Cannot remove the attribute getter with name " + methodName + "()", e); //$NON-NLS-1$ //$NON-NLS-2$
- }
- } else {
- try {
- methodName = getterPrefix + attrNameWithCapitalLetter; //$NON-NLS-1$
- if (getAttributeMethod.exists()) {
- typeSignature = getAttributeMethod.getReturnType();
- getAttributeMethod.delete(true, new NullProgressMonitor());
- }
- } catch (JavaModelException e) {
- JPADiagramEditorPlugin.logError("Cannot remove the attribute getter with name " + methodName + "()", e); //$NON-NLS-1$ //$NON-NLS-2$
- }
- try {
- IField attributeField = javaType.getField(this.attributeName);
- if (attributeField != null)
- if (!attributeField.exists())
- attributeField = javaType.getField(JPAEditorUtil.revertFirstLetterCase(attributeName));
- if ((attributeField != null) && attributeField.exists())
- attributeField.delete(true, new NullProgressMonitor());
- } catch (JavaModelException e) {
- JPADiagramEditorPlugin.logError("Cannot remove the attribute field with name " + attributeName, e); //$NON-NLS-1$
- }
+ return getAttributeMethod;
+ }
+
+ private void deleteSetterMethod(IType javaType,
+ String attrNameWithCapitalLetter, String typeSignature)
+ throws JavaModelException {
+ String methodName = "set" + attrNameWithCapitalLetter; //$NON-NLS-1$
+ if(typeSignature != null) {
+ IMethod setAttributeMethod = javaType.getMethod(methodName,
+ new String[] { typeSignature });
+ if ((setAttributeMethod != null) && setAttributeMethod.exists())
+ setAttributeMethod.delete(true, new NullProgressMonitor());
}
- try {
- methodName = "set" + attrNameWithCapitalLetter; //$NON-NLS-1$
- if(typeSignature != null) {
- IMethod setAttributeMethod = javaType.getMethod(methodName,
- new String[] { typeSignature });
- if ((setAttributeMethod != null) && setAttributeMethod.exists())
- setAttributeMethod.delete(true, new NullProgressMonitor());
- }
- } catch (Exception e) {
- JPADiagramEditorPlugin.logError("Cannot remove the attribute setter with name " + methodName + "(...)", e); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ private void deleteGetterMethod(String typeSignature, IMethod getAttributeMethod) throws JavaModelException {
+ if (getAttributeMethod != null && getAttributeMethod.exists()) {
+ getAttributeMethod.delete(true, new NullProgressMonitor());
}
+ }
- IWorkbenchSite ws = ((IDiagramContainerUI)fp.getDiagramTypeProvider().getDiagramBehavior().getDiagramContainer()).getSite();
- JPAEditorUtil.organizeImports(unit, ws);
-
- if(jpt != null) {
- jpt.getJpaProject().getContextModelRoot().synchronizeWithResourceModel();
- JavaResourceType jrt = jpt.getJavaResourceType();
- jrt.getJavaResourceCompilationUnit().synchronizeWithJavaSource();
- jpt.update();
+ private void deleteField(IType javaType) throws JavaModelException {
+ IField attributeField = javaType.getField(attributeName);
+ if (attributeField != null) {
+ if (!attributeField.exists()) {
+ attributeField = javaType.getField(JPAEditorUtil.revertFirstLetterCase(attributeName));
+ }
+ attributeField.delete(true, new NullProgressMonitor());
}
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/RemovePersistentAttributeFromormXmlCommand.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/RemovePersistentAttributeFromormXmlCommand.java
new file mode 100644
index 0000000..bce128b
--- /dev/null
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/RemovePersistentAttributeFromormXmlCommand.java
@@ -0,0 +1,33 @@
+package org.eclipse.jpt.jpadiagrameditor.ui.internal.command;
+
+import org.eclipse.jpt.common.utility.command.Command;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
+import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
+import org.eclipse.jpt.jpa.core.context.orm.OrmSpecifiedPersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
+
+public class RemovePersistentAttributeFromormXmlCommand implements Command {
+
+ private PersistentType jpt;
+ private String attributeName;
+
+ public RemovePersistentAttributeFromormXmlCommand(PersistentType jpt, String attributeName){
+ this.jpt = jpt;
+ this.attributeName = attributeName;
+ }
+
+ public void execute() {
+ MappingFileRef ormXml = JpaArtifactFactory.instance().getOrmXmlByForPersistentType(jpt);
+ if(ormXml != null && ormXml.getMappingFile() != null) {
+ OrmPersistentType ormPersistentType = (OrmPersistentType)ormXml.getMappingFile().getPersistentType(jpt.getName());
+ OrmPersistentAttribute ormReadOnlyAttribute = ormPersistentType.getAttributeNamed(attributeName);
+ if(ormReadOnlyAttribute instanceof OrmSpecifiedPersistentAttribute)
+ ormPersistentType.removeAttributeFromXml((OrmSpecifiedPersistentAttribute) ormReadOnlyAttribute);
+ }
+ jpt.getJavaResourceType().getJavaResourceCompilationUnit().synchronizeWithJavaSource();
+ jpt.synchronizeWithResourceModel();
+ jpt.update();
+ }
+}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/RenameAttributeCommand.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/RenameAttributeCommand.java
index 6fc85cd..cebbd02 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/RenameAttributeCommand.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/RenameAttributeCommand.java
@@ -23,8 +23,10 @@ import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IField;
+import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.ui.refactoring.RenameSupport;
import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
@@ -36,7 +38,6 @@ import org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef;
import org.eclipse.jpt.jpa.core.resource.orm.XmlAttributeMapping;
import org.eclipse.jpt.jpa.core.resource.orm.XmlTypeMapping;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
import org.eclipse.swt.widgets.Shell;
@@ -45,43 +46,34 @@ import org.eclipse.ui.IWorkbenchWindow;
public class RenameAttributeCommand implements Command {
private PersistentType jpt;
- private ICompilationUnit jptCompilationUnit;
private String oldName;
private String newName;
- private IJPAEditorFeatureProvider fp;
- public RenameAttributeCommand(ICompilationUnit jptCompilationUnit, PersistentType jpt, String oldName,
- String newName, IJPAEditorFeatureProvider fp){
+ public RenameAttributeCommand(PersistentType jpt, String oldName,
+ String newName){
super();
this.jpt = jpt;
- this.jptCompilationUnit = jptCompilationUnit;
this.oldName = oldName;
- this.newName = newName;
- this.fp = fp;
-
+ this.newName = newName;
}
public void execute() {
- if(jptCompilationUnit == null) {
- jptCompilationUnit = fp.getCompilationUnit(jpt);
- }
- try {
- boolean isMethodAnnotated = false;
- if(jpt!= null){
- renameAttribute(jpt, oldName, newName);
- isMethodAnnotated = JpaArtifactFactory.instance().isMethodAnnotated(jpt);
- }
- renameAttribute(jptCompilationUnit, oldName, newName, fp, isMethodAnnotated);
+ try {
+ renameAttribute(jpt, oldName, newName);
+ boolean isMethodAnnotated = JpaArtifactFactory.instance().isMethodAnnotated(jpt);
+
+ ICompilationUnit jptCompilationUnit = JPAEditorUtil.getCompilationUnit(jpt);
+ renameAttribute(jptCompilationUnit, oldName, newName, isMethodAnnotated);
- if(jpt != null) {
- jpt.getJpaProject().getContextModelRoot().synchronizeWithResourceModel();
- JavaResourceType jrt = jpt.getJavaResourceType();
- jrt.getJavaResourceCompilationUnit().synchronizeWithJavaSource();
- jpt.update();
- }
- } catch (InterruptedException e) {
+
+ jpt.getJpaProject().getContextModelRoot().synchronizeWithResourceModel();
+ JavaResourceType jrt = jpt.getJavaResourceType();
+ jrt.getJavaResourceCompilationUnit().synchronizeWithJavaSource();
+ jpt.update();
+
+ } catch (Exception e) {
JPADiagramEditorPlugin.logError("Cannot rename attribute", e); //$NON-NLS-1$
}
}
@@ -90,7 +82,6 @@ public class RenameAttributeCommand implements Command {
MappingFileRef mapFileRef = JpaArtifactFactory.instance().getOrmXmlByForPersistentType(jpt);
if(mapFileRef != null) {
EntityMappings root = (EntityMappings) mapFileRef.getMappingFile().getRoot();
-// XmlEntityMappings xmlEntities = root.getXmlEntityMappings();
Iterator<OrmManagedType> managedTypesIter = root.getManagedTypes().iterator();
while(managedTypesIter.hasNext()) {
XmlTypeMapping xmlType = (XmlTypeMapping) managedTypesIter.next().getXmlManagedType();
@@ -103,24 +94,14 @@ public class RenameAttributeCommand implements Command {
}
}
}
-
-// List<XmlTypeMapping> typeMappings = xmlEntities.getTypeMappings();
-// for(XmlTypeMapping xmlType : typeMappings){
-// if(xmlType.getAttributes() == null)
-// return;
-// List<XmlAttributeMapping> attributeMappings = xmlType.getAttributes().getAttributeMappings();
-// for(XmlAttributeMapping attr : attributeMappings){
-// if(attr.getName().equals(oldName)){
-// attr.setName(newName);
-// }
-// }
-// }
}
}
private void renameAttribute(ICompilationUnit cu, String oldName,
- String newName, IJPAEditorFeatureProvider fp, boolean isMethodAnnotated) throws InterruptedException {
- IType javaType = cu.findPrimaryType();
+ String newName, boolean isMethodAnnotated) throws Exception {
+
+ IJavaProject jp = JavaCore.create(jpt.getJpaProject().getProject());
+ IType javaType = jp.findType(jpt.getName());
if (javaType == null)
return;
IField attributeField = null;
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/RenameEntityCommand.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/RenameEntityCommand.java
index ed88276..efb110f 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/RenameEntityCommand.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/RenameEntityCommand.java
@@ -17,13 +17,16 @@
package org.eclipse.jpt.jpadiagrameditor.ui.internal.command;
import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.ui.refactoring.RenameSupport;
import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
import org.eclipse.jpt.common.utility.command.Command;
import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow;
@@ -31,17 +34,15 @@ public class RenameEntityCommand implements Command {
private PersistentType jpt;
private String newEntityName;
- private IJPAEditorFeatureProvider fp;
- public RenameEntityCommand(PersistentType jpt, String newEntityName, IJPAEditorFeatureProvider fp){
+ public RenameEntityCommand(PersistentType jpt, String newEntityName){
super();
this.jpt = jpt;
this.newEntityName = newEntityName;
- this.fp = fp;
}
public void execute() {
- renameEntityClass(fp.getCompilationUnit(jpt), newEntityName);
+ renameEntityClass(JPAEditorUtil.getCompilationUnit(jpt), newEntityName);
jpt.getJpaProject().getContextModelRoot().synchronizeWithResourceModel();
JavaResourceType jrt = jpt.getJavaResourceType();
jrt.getJavaResourceCompilationUnit().synchronizeWithJavaSource();
@@ -49,8 +50,15 @@ public class RenameEntityCommand implements Command {
}
private void renameEntityClass(ICompilationUnit cu, String newName) {
- IType javaType = cu.findPrimaryType();
- renameType(javaType, newName);
+ IJavaProject jp = JavaCore.create(jpt.getJpaProject().getProject());
+ try {
+ IType javaType = jp.findType(jpt.getName());
+ renameType(javaType, newName);
+
+ } catch (JavaModelException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
private void renameType(IType type, String newName) {
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddJPAEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddJPAEntityFeature.java
index 6107022e..af5d481 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddJPAEntityFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddJPAEntityFeature.java
@@ -141,32 +141,6 @@ public class AddJPAEntityFeature extends AbstractAddShapeFeature {
ICompilationUnit cu = ((SourceType)newObj).getCompilationUnit();
jpt = JPAEditorUtil.getJPType(cu);
}
-
-// MappingFileRef fileRef = JpaArtifactFactory.instance().getOrmXmlByForPersistentType(jpt);
-// if(fileRef != null) {
-// if(fileRef.getPersistentType(jpt.getName()) != null){
-// jpt = fileRef.getPersistentType(jpt.getName());
-// }
-// }
-
-
- //TODO this is wrong, should not need to do any of these updates or syncs.
- //should be changing the dali model synchronously so that all the syncs/updates are completed
- //take a look at the JpaProjectManager.execute(Command, ExtendedCommandContext)
-// JavaResourceType jrt = null;
-// if(jpt instanceof JavaPersistentType) {
-// jrt = ((JavaPersistentType)jpt).getJavaResourceType();
-// } else if (jpt instanceof OrmPersistentType){
-// jrt = ((OrmPersistentType)jpt).getJavaPersistentType().getJavaResourceType();
-// }
-//
-// if(jrt != null) {
-// jrt.getJavaResourceCompilationUnit().synchronizeWithJavaSource();
-// }
-//
- jpt.update();
- jpt.synchronizeWithResourceModel();
-
final Diagram targetDiagram = (Diagram) context.getTargetContainer();
final Wrp wrp = new Wrp();
createEntity(context, fp, targetDiagram, wrp, jpt);
@@ -433,7 +407,7 @@ public class AddJPAEntityFeature extends AbstractAddShapeFeature {
headerRect.setX(JPAEditorConstants.HEADER_TEXT_RECT_X);
String headerTextString = JPAEditorUtil.getText(addedWrapper);
- ICompilationUnit cu = getFeatureProvider().getCompilationUnit(addedWrapper);
+ ICompilationUnit cu = JPAEditorUtil.getCompilationUnit(addedWrapper);
JPAEditorUtil.becomeWorkingCopy(cu);
headerTextString = JPAEditorUtil.returnSimpleName(headerTextString);
try {
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ClickAddAttributeButtonFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ClickAddAttributeButtonFeature.java
index 2d92aa3..ed50a94 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ClickAddAttributeButtonFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ClickAddAttributeButtonFeature.java
@@ -58,7 +58,7 @@ public class ClickAddAttributeButtonFeature extends AbstractCreateFeature {
PersistentAttribute newAttr = jpt.resolveAttribute(newAttrName);
getFeatureProvider().addAddIgnore((PersistentType) newAttr.getParent(), newAttr.getName());
- JpaArtifactFactory.instance().addOrmPersistentAttribute(jpt, newAttr, newAttr.getMappingKey());
+ JpaArtifactFactory.instance().addOrmPersistentAttribute(jpt, newAttr, null);
addGraphicalRepresentation(context, newAttr);
getFeatureProvider().getDirectEditingInfo().setActive(true);
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ClickAddElementCollectionButtonFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ClickAddElementCollectionButtonFeature.java
index 9487211..1ed40ae 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ClickAddElementCollectionButtonFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ClickAddElementCollectionButtonFeature.java
@@ -57,9 +57,11 @@ public class ClickAddElementCollectionButtonFeature extends AbstractCreateFeatur
String newAttrName = JpaArtifactFactory.instance().createNewAttribute(jpt, true, getFeatureProvider());
PersistentAttribute newAttr = jpt.resolveAttribute(newAttrName);
- newAttr.getJavaPersistentAttribute().setMappingKey(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY);
- JpaArtifactFactory.instance().addOrmPersistentAttribute(jpt, newAttr, MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY);
-
+// newAttr.getJavaPersistentAttribute().setMappingKey(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY);
+ PersistentAttribute ormAttr = JpaArtifactFactory.instance().addOrmPersistentAttribute(jpt, newAttr, MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY);
+ if(ormAttr == null || ormAttr.isVirtual()){
+ newAttr.getJavaPersistentAttribute().setMappingKey(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY);
+ }
getFeatureProvider().addAddIgnore((PersistentType) newAttr.getParent(), newAttr.getName());
addGraphicalRepresentation(context, newAttr);
getFeatureProvider().getDirectEditingInfo().setActive(true);
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ClickRemoveAttributeButtonFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ClickRemoveAttributeButtonFeature.java
index 2c0a115..d645cc5 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ClickRemoveAttributeButtonFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ClickRemoveAttributeButtonFeature.java
@@ -28,13 +28,13 @@ import org.eclipse.graphiti.internal.features.context.impl.base.PictogramElement
import org.eclipse.graphiti.mm.algorithms.Text;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.ui.features.DefaultDeleteFeature;
-import org.eclipse.jdt.core.IType;
import org.eclipse.jpt.common.ui.internal.utility.SynchronousUiCommandContext;
import org.eclipse.jpt.common.utility.command.Command;
import org.eclipse.jpt.jpa.core.JpaProjectManager;
import org.eclipse.jpt.jpa.core.context.AttributeMapping;
import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
import org.eclipse.jpt.jpa.core.context.PersistentType;
+import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.jpa.core.jpa2.context.DerivedIdentity2_0;
import org.eclipse.jpt.jpa.core.jpa2.context.SingleRelationshipMapping2_0;
@@ -253,10 +253,10 @@ public class ClickRemoveAttributeButtonFeature extends DefaultDeleteFeature {
private void deleteFieldFromIdClassCompositePK(String attrName,
PersistentType jpt) {
JpaArtifactFactory jpaFactory = JpaArtifactFactory.instance();
- String idClassFQN = jpaFactory.getIdType(jpt);
- if(idClassFQN != null && isDeleteAttributeAllowed(jpt, idClassFQN)){
- IType type = jpaFactory.getType(jpt.getJpaProject().getJavaProject(), idClassFQN);
- Command deleteAttributeCommand = new DeleteAttributeCommand(type.getCompilationUnit(), null, attrName, getFeatureProvider());
+ JavaPersistentType idClassJPT = jpaFactory.getIdClassJPT(jpt);
+ if(idClassJPT != null && isDeleteAttributeAllowed(jpt, idClassJPT.getName())){
+
+ Command deleteAttributeCommand = new DeleteAttributeCommand(idClassJPT, attrName, getFeatureProvider());
try {
getJpaProjectManager().execute(deleteAttributeCommand, SynchronousUiCommandContext.instance());
} catch (InterruptedException e) {
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateEmbeddableFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateEmbeddableFeature.java
index 6c47e7d..1fe74e0 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateEmbeddableFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateEmbeddableFeature.java
@@ -97,15 +97,16 @@ public class CreateEmbeddableFeature extends AbstractCreateFeature {
PersistentType jpt = JpaArtifactFactory.instance().getJPT(
embeddableName, pu);
+
if (jpt != null) {
if(JPADiagramPropertyPage.doesSupportOrmXml(targetProject)) {
JpaArtifactFactory.instance().addPersistentTypeToORMXml(jpaProject, embeddableName, MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY);
}
- addGraphicalRepresentation(context, jpt);
+ addGraphicalRepresentation(context, jpt);
IWorkbenchSite ws = ((IDiagramContainerUI)getFeatureProvider().getDiagramTypeProvider().getDiagramBehavior().getDiagramContainer()).getSite();
ICompilationUnit cu = getFeatureProvider().getCompilationUnit(jpt);
getFeatureProvider().getJPAEditorUtil().formatCode(cu, ws);
- return new Object[] { jpt };
+ return new Object[] { jpt };
} else {
JPADiagramEditorPlugin
.logError(
@@ -114,7 +115,10 @@ public class CreateEmbeddableFeature extends AbstractCreateFeature {
+ " could not be created", new Exception()); //$NON-NLS-1$
}
- return new Object[] {};
+ IWorkbenchSite ws = ((IDiagramContainerUI) getDiagramBehavior().getDiagramContainer()).getSite();
+ ICompilationUnit cu = JPAEditorUtil.getCompilationUnit(jpt);
+ getFeatureProvider().getJPAEditorUtil().formatCode(cu, ws);
+ return new Object[] { jpt };
}
@Override
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateIsARelationFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateIsARelationFeature.java
index 08b39f4..4ae1cc4 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateIsARelationFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateIsARelationFeature.java
@@ -77,6 +77,7 @@ public class CreateIsARelationFeature extends AbstractCreateConnectionFeature {
for(PersistentAttribute jpa : subclass.getAttributes()){
if(jpa.getMappingKey().equals(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY)){
jpa.getJavaPersistentAttribute().setMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
+// MappingFileRef mapFileRef = JpaArtifactFactory.instance().getOrmXmlByForPersistentType(jpa.getDeclaringPersistentType());
} else if(jpa.getMappingKey().equals(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY)) {
jpa.getJavaPersistentAttribute().setMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateJPAEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateJPAEntityFeature.java
index 3e615f2..7d91b46 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateJPAEntityFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateJPAEntityFeature.java
@@ -175,6 +175,11 @@ public class CreateJPAEntityFeature extends AbstractCreateFeature {
if (jpt != null) {
if(JPADiagramPropertyPage.doesSupportOrmXml(targetProject)) {
JpaArtifactFactory.instance().addPersistentTypeToORMXml(jpaProject, entityName, MappingKeys.ENTITY_TYPE_MAPPING_KEY);
+ try {
+ jpt.getResource().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ } catch (CoreException e1) {
+ JPADiagramEditorPlugin.logError("Cannot refresh the project", e1); //$NON-NLS-1$
+ }
}
// jpt = pu.getPersistentType(entityName);
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DeleteRelationFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DeleteRelationFeature.java
index 2364e0d..8ed49b0 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DeleteRelationFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DeleteRelationFeature.java
@@ -19,9 +19,7 @@ import org.eclipse.graphiti.features.context.IContext;
import org.eclipse.graphiti.features.context.IDeleteContext;
import org.eclipse.graphiti.features.context.impl.DeleteContext;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
-import org.eclipse.graphiti.ui.editor.IDiagramContainerUI;
import org.eclipse.graphiti.ui.features.DefaultDeleteFeature;
-import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
import org.eclipse.jpt.jpa.core.context.PersistentType;
@@ -30,13 +28,10 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeaturePr
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.AbstractRelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.HasReferanceRelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IBidirectionalRelation;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IRelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IUnidirectionalRelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IsARelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.IJPAEditorUtil;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
-import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.PlatformUI;
@@ -97,7 +92,7 @@ public class DeleteRelationFeature extends DefaultDeleteFeature{
PersistentType subclass = rel.getSubclass();
JpaArtifactFactory.instance().buildHierarchy(superclass, subclass, false);
- JPAEditorUtil.getCompilationUnit(subclass);
+ ut.getCompilationUnit(subclass);
// subclass.getJavaResourceType().getJavaResourceCompilationUnit().synchronizeWithJavaSource();
getFeatureProvider().addJPTForUpdate(subclass.getName());
@@ -146,32 +141,7 @@ public class DeleteRelationFeature extends DefaultDeleteFeature{
feat.delete(deleteInverseAttributeContext, false);
}
}
-
- @Override
- public void postDelete(IDeleteContext context) {
- PictogramElement pe = context.getPictogramElement();
- Object businessObjectForPictogramElement = getBusinessObjectForPictogramElement(pe);
- IWorkbenchSite ws = ((IDiagramContainerUI)getFeatureProvider().getDiagramTypeProvider().getDiagramBehavior().getDiagramContainer()).getSite();
- if (businessObjectForPictogramElement instanceof IRelation) {
- IRelation rel = (IRelation) businessObjectForPictogramElement;
- ICompilationUnit cu = getFeatureProvider().getCompilationUnit(rel.getOwner());
- ut.organizeImports(cu, ws);
- if (rel instanceof IBidirectionalRelation) {
- cu = getFeatureProvider().getCompilationUnit(rel.getInverse());
- ut.organizeImports(cu, ws);
- }
- } else if(businessObjectForPictogramElement instanceof HasReferanceRelation){
- HasReferanceRelation rel = (HasReferanceRelation) businessObjectForPictogramElement;
- ICompilationUnit cu = getFeatureProvider().getCompilationUnit(rel.getEmbeddingEntity());
- ut.organizeImports(cu, ws);
- } else if (businessObjectForPictogramElement instanceof IsARelation){
- IsARelation rel = (IsARelation) businessObjectForPictogramElement;
- ICompilationUnit cu = getFeatureProvider().getCompilationUnit(rel.getSubclass());
- ut.organizeImports(cu, ws);
- }
- }
-
-
+
@Override
public IJPAEditorFeatureProvider getFeatureProvider() {
return (IJPAEditorFeatureProvider)super.getFeatureProvider();
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/EmbedCollectionOfObjectsFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/EmbedCollectionOfObjectsFeature.java
index 32facd6..6ac4da0 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/EmbedCollectionOfObjectsFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/EmbedCollectionOfObjectsFeature.java
@@ -87,10 +87,11 @@ public class EmbedCollectionOfObjectsFeature extends AbstractCreateConnectionFea
mapKeyType = JPAEditorConstants.STRING_TYPE;
}
- PersistentAttribute embeddedAttribute = JPAEditorUtil.addAnnotatedAttribute(getFeatureProvider(), embeddingEntity, embeddable, true, mapKeyType);
- embeddedAttribute.getJavaPersistentAttribute().setMappingKey(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY);
- JpaArtifactFactory.instance().addOrmPersistentAttribute(embeddingEntity, embeddedAttribute, MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY);
-
+ PersistentAttribute embeddedAttribute = JPAEditorUtil.addAnnotatedAttribute(embeddingEntity, embeddable, true, mapKeyType);
+ PersistentAttribute ormAttr = JpaArtifactFactory.instance().addOrmPersistentAttribute(embeddingEntity, embeddedAttribute, MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY);
+ if(ormAttr == null || ormAttr.isVirtual()){
+ embeddedAttribute.getJavaPersistentAttribute().setMappingKey(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY);
+ }
HasReferanceRelation rel = new HasCollectionReferenceRelation(embeddingEntity, embeddable);
rel.setEmbeddedAnnotatedAttribute(embeddedAttribute);
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/EmbedSingleObjectFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/EmbedSingleObjectFeature.java
index 4fb5739..8ba6d8b 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/EmbedSingleObjectFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/EmbedSingleObjectFeature.java
@@ -76,10 +76,11 @@ public class EmbedSingleObjectFeature extends AbstractCreateConnectionFeature {
PersistentType embeddingEntity = getPersistentType(context.getSourceAnchor());
PersistentType embeddable = getPersistentType(context.getTargetAnchor());
- PersistentAttribute embeddedAttribute = JPAEditorUtil.addAnnotatedAttribute(getFeatureProvider(), embeddingEntity, embeddable, false, null);
- embeddedAttribute.getJavaPersistentAttribute().setMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
- JpaArtifactFactory.instance().addOrmPersistentAttribute(embeddingEntity, embeddedAttribute, MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
-
+ PersistentAttribute embeddedAttribute = JPAEditorUtil.addAnnotatedAttribute(embeddingEntity, embeddable, false, null);
+ PersistentAttribute ormAttr = JpaArtifactFactory.instance().addOrmPersistentAttribute(embeddingEntity, embeddedAttribute, MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
+ if(ormAttr == null || ormAttr.isVirtual()){
+ embeddedAttribute.getJavaPersistentAttribute().setMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
+ }
HasReferanceRelation rel = new HasSingleReferenceRelation(embeddingEntity, embeddable);
rel.setEmbeddedAnnotatedAttribute(embeddedAttribute);
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/GraphicalAddAttributeFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/GraphicalAddAttributeFeature.java
index 984d066..d387d02 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/GraphicalAddAttributeFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/GraphicalAddAttributeFeature.java
@@ -63,9 +63,9 @@ public class GraphicalAddAttributeFeature extends AbstractAddShapeFeature {
.getNewObject();
String txt = JPAEditorUtil.getText(newAttr);
AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(newAttr);
- if(!attributeMapping.getKey().equals(newAttr.getJavaPersistentAttribute().getMappingKey())){
-// newAttr.getJavaPersistentAttribute().setMappingKey(attributeMapping.getKey());
- }
+// if(!attributeMapping.getKey().equals(newAttr.getJavaPersistentAttribute().getMappingKey())){
+//// newAttr.getJavaPersistentAttribute().setMappingKey(attributeMapping.getKey());
+// }
ContainerShape textShape = null;
ContainerShape primaryShape = GraphicsUpdater
.getPrimaryShape(entityShape);
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/GraphicalRemoveAttributeFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/GraphicalRemoveAttributeFeature.java
index 2ecdd19..4f98e12 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/GraphicalRemoveAttributeFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/GraphicalRemoveAttributeFeature.java
@@ -50,6 +50,7 @@ public class GraphicalRemoveAttributeFeature extends AbstractCustomFeature {
TransactionalEditingDomain ted = TransactionUtil.getEditingDomain(pe);
if (ted == null)
return;
+
ted.getCommandStack().execute(new RecordingCommand(ted) {
@Override
protected void doExecute() {
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorAttributeTypeFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorAttributeTypeFeature.java
index c50c888..b21102a 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorAttributeTypeFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorAttributeTypeFeature.java
@@ -73,8 +73,8 @@ public class RefactorAttributeTypeFeature extends AbstractCustomFeature {
JpaArtifactFactory.instance().deleteAttribute((PersistentType) jpa.getParent(), jpa.getName(),
getFeatureProvider());
- PersistentAttribute newAt = JpaArtifactFactory.instance().makeNewAttribute(getFeatureProvider(), (PersistentType) jpa.getParent(),
- null, jpa.getName(), newTypeName, jpa.getName(), newTypeName, attributeTypeTypeNames, annotations, false);
+ PersistentAttribute newAt = JpaArtifactFactory.instance().makeNewAttribute((PersistentType) jpa.getParent(),
+ jpa.getName(), newTypeName, jpa.getName(), newTypeName, attributeTypeTypeNames, annotations, false);
getFeatureProvider().replaceAttribute(jpa, newAt);
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 36ceb56..4d8ce5f 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
@@ -152,7 +152,7 @@ public abstract class RefactorEntityFeature extends AbstractCustomFeature {
jpt.getJpaProject().addCollectionChangeListener(JpaProject.JPA_FILES_COLLECTION, lsnr);
ShowBusy showBusy = new ShowBusy(s);
JPASolver.ignoreEvents = true;
- JpaArtifactFactory.instance().renameEntityClass(jpt, newName, getFeatureProvider());
+ JpaArtifactFactory.instance().renameEntityClass(jpt, newName);
BusyIndicator.showWhile(Display.getCurrent(), showBusy);
jpt.getJpaProject().removeCollectionChangeListener(JpaProject.JPA_FILES_COLLECTION, lsnr);
JPASolver.ignoreEvents = false;
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorFeatureProvider.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorFeatureProvider.java
index 3d8eec9..372e81b 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorFeatureProvider.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorFeatureProvider.java
@@ -789,11 +789,10 @@ public class JPAEditorFeatureProvider extends DefaultFeatureProvider implements
for (ClassRef classRef : unit.getClassRefs()) {
if (classRef.getJavaPersistentType() != null) { // null if
final PersistentType jpt = classRef.getJavaPersistentType();
- PictogramElement pe = getPictogramElementForBusinessObject(jpt);
+ final PictogramElement pe = getPictogramElementForBusinessObject(jpt);
if(pe == null)
continue;
- final GraphicsAlgorithm algo = pe.getGraphicsAlgorithm();
- TransactionalEditingDomain ted = TransactionUtil.getEditingDomain(algo);
+ TransactionalEditingDomain ted = TransactionUtil.getEditingDomain(pe);
JPAEditorConstants.DIAGRAM_OBJECT_TYPE dot = JpaArtifactFactory.instance().determineDiagramObjectType(jpt);
String renderingStyle = JpaArtifactFactory.instance().getRenderingStyle(dot);
@@ -806,11 +805,14 @@ public class JPAEditorFeatureProvider extends DefaultFeatureProvider implements
@Override
protected void doExecute() {
- gaService.setRenderingStyle(algo, gradientColoredArea);
+ GraphicsAlgorithm algo = pe.getGraphicsAlgorithm();
+// gaService.setRenderingStyle(algo, gradientColoredArea);
algo.setForeground(gaService.manageColor(d, foreground));
+ gaService.setRenderingStyle(algo, gradientColoredArea);
+
}
});
- }
+ }
}
}
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyBiDirRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyBiDirRelation.java
index 5f77911..391b6b7 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyBiDirRelation.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyBiDirRelation.java
@@ -70,14 +70,14 @@ public class ManyToManyBiDirRelation extends ManyToManyRelation implements IBidi
boolean isMap = JPADiagramPropertyPage.isMapType(owner.getJpaProject().getProject());
String mapKeyType = getMapKeyType(isMap, inverse, embeddingEntity);
- ownerAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(fp, owner, inverse, true, mapKeyType);
+ ownerAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(owner, inverse, true, mapKeyType);
mapKeyType = getMapKeyType(isMap, owner, embeddingEntity);
if(JpaArtifactFactory.instance().isEmbeddable(owner)){
- inverseAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(fp, inverse, embeddingEntity, true, mapKeyType);
+ inverseAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(inverse, embeddingEntity, true, mapKeyType);
} else {
- inverseAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(fp, inverse, owner, true, mapKeyType);
+ inverseAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(inverse, owner, true, mapKeyType);
}
JpaArtifactFactory.instance().addManyToManyBidirectionalRelation(fp, owner, ownerAnnotatedAttribute, inverse, inverseAnnotatedAttribute, isMap);
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyUniDirRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyUniDirRelation.java
index 6a03f34..9d0277d 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyUniDirRelation.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyUniDirRelation.java
@@ -46,7 +46,7 @@ public class ManyToManyUniDirRelation extends ManyToManyRelation implements IUni
private void createRelation(IJPAEditorFeatureProvider fp) {
boolean isMap = JPADiagramPropertyPage.isMapType(owner.getJpaProject().getProject());
String mapKeyType = getMapKeyType(isMap, inverse);
- ownerAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(fp, owner, inverse, true, mapKeyType);
+ ownerAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(owner, inverse, true, mapKeyType);
JpaArtifactFactory.instance().addManyToManyUnidirectionalRelation(fp, owner, ownerAnnotatedAttribute, isMap);
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneBiDirRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneBiDirRelation.java
index 5929017..6cf06f2 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneBiDirRelation.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneBiDirRelation.java
@@ -60,14 +60,14 @@ public class ManyToOneBiDirRelation extends ManyToOneRelation implements IBidir
}
private void createRelation(IJPAEditorFeatureProvider fp, PersistentType embeddingEntity, boolean isDerivedIdFeature) {
- ownerAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(fp, owner, inverse, false, null);
+ ownerAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(owner, inverse, false, null);
boolean isMap = JPADiagramPropertyPage.isMapType(owner.getJpaProject().getProject());
String mapKeyType = getMapKeyType(isMap, owner, embeddingEntity);
if(JpaArtifactFactory.instance().isEmbeddable(owner)){
- inverseAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(fp, inverse, embeddingEntity, true, mapKeyType);
+ inverseAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(inverse, embeddingEntity, true, mapKeyType);
} else {
- inverseAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(fp, inverse, owner, true, mapKeyType);
+ inverseAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(inverse, owner, true, mapKeyType);
}
JpaArtifactFactory.instance().addManyToOneBidirectionalRelation(fp, owner, ownerAnnotatedAttribute, inverse, inverseAnnotatedAttribute, isMap);
if(isDerivedIdFeature){
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneUniDirRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneUniDirRelation.java
index e609da9..53505a4 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneUniDirRelation.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneUniDirRelation.java
@@ -43,7 +43,7 @@ public class ManyToOneUniDirRelation extends ManyToOneRelation implements IUnidi
}
private void createRelation(IJPAEditorFeatureProvider fp, boolean isDerivedIdFeature) {
- ownerAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(fp, owner, inverse, false, null);
+ ownerAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(owner, inverse, false, null);
JpaArtifactFactory.instance().addManyToOneUnidirectionalRelation(fp, owner, ownerAnnotatedAttribute);
if(isDerivedIdFeature){
JpaArtifactFactory.instance().calculateDerivedIdAttribute(owner, inverse, ownerAnnotatedAttribute);
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToManyUniDirRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToManyUniDirRelation.java
index c3cc5a6..0ce917a 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToManyUniDirRelation.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToManyUniDirRelation.java
@@ -46,7 +46,7 @@ public class OneToManyUniDirRelation extends OneToManyRelation implements IUnidi
private void createRelation(IJPAEditorFeatureProvider fp) {
boolean isMap = JPADiagramPropertyPage.isMapType(owner.getJpaProject().getProject());
String mapKeyType = getMapKeyType(isMap, inverse);
- ownerAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(fp, owner, inverse, true, mapKeyType);
+ ownerAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(owner, inverse, true, mapKeyType);
JpaArtifactFactory.instance().addOneToManyUnidirectionalRelation(fp, owner, ownerAnnotatedAttribute, isMap);
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneBiDirRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneBiDirRelation.java
index b9b7983..2423522 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneBiDirRelation.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneBiDirRelation.java
@@ -59,12 +59,12 @@ public class OneToOneBiDirRelation extends OneToOneRelation implements IBidirect
}
private void createRelation(IJPAEditorFeatureProvider fp, PersistentType embeddingEntity, boolean isDerivedIdFeature) {
- ownerAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(fp, owner, inverse, false, null);
+ ownerAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(owner, inverse, false, null);
if(JpaArtifactFactory.instance().isEmbeddable(owner)){
- inverseAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(fp, inverse, embeddingEntity, false, null);
+ inverseAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(inverse, embeddingEntity, false, null);
} else {
- inverseAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(fp, inverse, owner, false, null);
+ inverseAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(inverse, owner, false, null);
}
JpaArtifactFactory.instance().addOneToOneBidirectionalRelation(fp, owner, ownerAnnotatedAttribute, inverse, inverseAnnotatedAttribute);
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneUniDirRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneUniDirRelation.java
index 15e4a94..c895569 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneUniDirRelation.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneUniDirRelation.java
@@ -43,7 +43,7 @@ public class OneToOneUniDirRelation extends OneToOneRelation implements IUnidire
}
private void createRelation(IJPAEditorFeatureProvider fp, boolean isDerivedIdFeature) {
- ownerAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(fp, owner, inverse, false, null);
+ ownerAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(owner, inverse, false, null);
JpaArtifactFactory.instance().addOneToOneUnidirectionalRelation(fp, owner, ownerAnnotatedAttribute);
if(isDerivedIdFeature){
JpaArtifactFactory.instance().calculateDerivedIdAttribute(owner, inverse, ownerAnnotatedAttribute);
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtil.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtil.java
index f7729e6..dbee958 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtil.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtil.java
@@ -90,7 +90,6 @@ import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.TransientMapping;
import org.eclipse.jpt.jpa.core.context.VersionMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.jpa.core.jpa2.context.DerivedIdentity2_0;
@@ -978,7 +977,8 @@ public class JPAEditorUtil {
static public void formatCode(ICompilationUnit cu, IWorkbenchSite ws) {
FormatAllAction action = new FormatAllAction(ws);
- action.run(new StructuredSelection(cu));
+ if(cu != null)
+ action.run(new StructuredSelection(cu));
}
static public String generateUniquePersistentObjectName(JpaProject jpaProject, String pack, String objectTypeName, IJPAEditorFeatureProvider fp){
@@ -1156,10 +1156,8 @@ public class JPAEditorUtil {
}
public static ICompilationUnit getCompilationUnit(PersistentType jpt) {
- if (jpt instanceof OrmPersistentType){
- jpt = ((OrmPersistentType)jpt).getJavaPersistentType();
- }
- return getCompilationUnit((IFile) jpt.getResource());
+ ICompilationUnit unit = jpt.getJavaResourceType().getJavaResourceCompilationUnit().getCompilationUnit();
+ return unit;
}
public static ICompilationUnit getCompilationUnit(IFile file) {
@@ -1414,7 +1412,7 @@ public class JPAEditorUtil {
return h1.equals(h2);
}
- public static PersistentAttribute addAnnotatedAttribute(IJPAEditorFeatureProvider fp, PersistentType referencingJPT,
+ public static PersistentAttribute addAnnotatedAttribute(PersistentType referencingJPT,
PersistentType referencedJPT, boolean isCollection, String mapKeyType){
String name = returnSimpleName(referencedJPT.getName());
@@ -1430,11 +1428,9 @@ public class JPAEditorUtil {
nameWithNonCapitalLetter = produceUniqueAttributeName(referencingJPT, nameWithNonCapitalLetter);
actNameWithNonCapitalLetter = produceUniqueAttributeName(referencingJPT, actNameWithNonCapitalLetter);
- ICompilationUnit referencingCU = JPAEditorUtil.getCompilationUnit(referencingJPT);
- return JpaArtifactFactory.instance().addAttribute(fp, referencingJPT, referencedJPT, mapKeyType,
+ return JpaArtifactFactory.instance().addAttribute(referencingJPT, referencedJPT, mapKeyType,
nameWithNonCapitalLetter,
- actNameWithNonCapitalLetter, isCollection,
- referencingCU);
+ actNameWithNonCapitalLetter, isCollection);
}
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPASolver.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPASolver.java
index 2d42e57..3517902 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPASolver.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPASolver.java
@@ -390,8 +390,8 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
}
}
- ICompilationUnit cu = getCompilationUnit(jpt);
- JPAEditorUtil.discardWorkingCopyOnce(cu);
+// ICompilationUnit cu = getCompilationUnit(jpt);
+// JPAEditorUtil.discardWorkingCopyOnce(cu);
} else if (o instanceof AbstractRelation) {
AbstractRelation rel = (AbstractRelation) o;
attribToRel.remove(produceOwnerKeyForRel(rel));
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 c676abf..a9bc5d8 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
@@ -48,7 +48,6 @@ import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IPackageDeclaration;
import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.common.core.JptResourceModel;
@@ -87,6 +86,7 @@ import org.eclipse.jpt.jpa.core.context.SpecifiedJoinColumn;
import org.eclipse.jpt.jpa.core.context.SpecifiedJoinColumnRelationshipStrategy;
import org.eclipse.jpt.jpa.core.context.SpecifiedMappedByRelationshipStrategy;
import org.eclipse.jpt.jpa.core.context.TypeMapping;
+import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpa.core.context.orm.OrmManagedType;
import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
@@ -104,6 +104,7 @@ import org.eclipse.jpt.jpa.core.resource.java.IdAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.MapKeyAnnotation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.command.AddAttributeCommand;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.command.AddPersistentAttributeInOrmXMLCommand;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.command.AddPersistentTypeToOrmXmlCommand;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.command.CreateEntityTypeHierarchy;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.command.DeleteAttributeCommand;
@@ -312,10 +313,12 @@ public class JpaArtifactFactory {
}
private PersistentAttribute setMappingKeyToAttribute(IFeatureProvider fp, PersistentType jpt, PersistentAttribute jpa, String mappingKey){
- PersistentAttribute resolvedManySideAttribute = jpt.resolveAttribute(jpa.getName());
- resolvedManySideAttribute.getJavaPersistentAttribute().setMappingKey(mappingKey);
- addOrmPersistentAttribute(jpt, jpa, mappingKey);
- return resolvedManySideAttribute;
+ PersistentAttribute resolvedManySideAttribute = jpt.getAttributeNamed(jpa.getName());
+ PersistentAttribute ormAttr = addOrmPersistentAttribute(jpt, resolvedManySideAttribute, mappingKey);
+ if(ormAttr == null || ormAttr.isVirtual()){
+ resolvedManySideAttribute.getJavaPersistentAttribute().setMappingKey(mappingKey);
+ }
+ return jpa;
}
private void addJoinColumnIfNecessary(PersistentAttribute jpa,
@@ -708,7 +711,6 @@ public class JpaArtifactFactory {
/**
* Create a relationship attribute.
- * @param fp
* @param jpt - the referencing {@link PersistentType}
* @param attributeType - the referenced {@link PersistentType}
* @param mapKeyType
@@ -718,9 +720,9 @@ public class JpaArtifactFactory {
* @param cu - the {@link ICompilationUnit} of the referencing {@link PersistentType}
* @return the newly created relationship attribute.
*/
- public PersistentAttribute addAttribute(IJPAEditorFeatureProvider fp, PersistentType jpt,
+ public PersistentAttribute addAttribute(PersistentType jpt,
PersistentType attributeType, String mapKeyType, String attributeName,
- String actName, boolean isCollection, ICompilationUnit cu) {
+ String actName, boolean isCollection) {
try {
if (doesAttributeExist(jpt, actName)) {
@@ -729,7 +731,7 @@ public class JpaArtifactFactory {
} catch (JavaModelException e) {
JPADiagramEditorPlugin.logError("Cannnot create a new attribute with name " + attributeName, e); //$NON-NLS-1$
}
- PersistentAttribute res = makeNewAttribute(fp, jpt, cu, attributeName, attributeType.getName(), actName, mapKeyType, null, null, isCollection);
+ PersistentAttribute res = makeNewAttribute(jpt, attributeName, attributeType.getName(), actName, mapKeyType, null, null, isCollection);
return res;
}
@@ -766,18 +768,13 @@ public class JpaArtifactFactory {
boolean isCollection, IJPAEditorFeatureProvider fp) {
String newAttrName = genUniqueAttrName(jpt, JPAEditorConstants.STRING_TYPE, fp);
- ICompilationUnit cu = fp.getCompilationUnit(jpt);
- makeNewAttribute(fp, jpt, cu, newAttrName, JPAEditorConstants.STRING_TYPE, newAttrName, JPAEditorConstants.STRING_TYPE, null, null, isCollection);
+ makeNewAttribute(jpt, newAttrName, JPAEditorConstants.STRING_TYPE, newAttrName, JPAEditorConstants.STRING_TYPE, null, null, isCollection);
return newAttrName;
}
- public PersistentAttribute makeNewAttribute(IJPAEditorFeatureProvider fp, PersistentType jpt, ICompilationUnit cu, String attrName, String attrTypeName,
+
+ public PersistentAttribute makeNewAttribute(PersistentType jpt, String attrName, String attrTypeName,
String actName, String mapKeyType, String[] attrTypes, List<String> annotations, boolean isCollection) {
-
- if(cu == null){
- cu = fp.getCompilationUnit(jpt);
- }
-
- Command createNewAttributeCommand = new AddAttributeCommand(fp, jpt, attrTypeName, mapKeyType, attrName, actName, attrTypes, annotations, isCollection, cu);
+ Command createNewAttributeCommand = new AddAttributeCommand(jpt, attrTypeName, mapKeyType, attrName, actName, attrTypes, annotations, isCollection);
try {
getJpaProjectManager().execute(createNewAttributeCommand, SynchronousUiCommandContext.instance());
} catch (InterruptedException e) {
@@ -790,20 +787,15 @@ public class JpaArtifactFactory {
return jpa;
}
- public void addOrmPersistentAttribute(PersistentType jpt, PersistentAttribute jpa, String mappingKey){
- MappingFileRef ormXml = getOrmXmlByForPersistentType(jpt);
- if(ormXml != null && ormXml.getMappingFile() != null) {
- OrmPersistentType ormPersistentType = (OrmPersistentType)ormXml.getMappingFile().getPersistentType(jpt.getName());
- if(ormPersistentType == null)
- return;
- if(mappingKey != null) {
- ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed(jpa.getName()), mappingKey);
- } else {
- if(ormPersistentType.getAttributeNamed(jpa.getName()) != null){
- ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed(jpa.getName()), jpa.getMappingKey());
- }
- }
+ public PersistentAttribute addOrmPersistentAttribute(PersistentType jpt, PersistentAttribute jpa, String mappingKey){
+ Command addpersAttrCommand = new AddPersistentAttributeInOrmXMLCommand(jpt, jpa, mappingKey);
+ try {
+ getJpaProjectManager().execute(addpersAttrCommand, SynchronousUiCommandContext.instance());
+ } catch (InterruptedException e) {
+ e.printStackTrace();
}
+
+ return getORMPersistentAttribute(jpa);
}
public void removeOrmPersistentAttribute(PersistentType jpt, String attributeName){
@@ -814,6 +806,10 @@ public class JpaArtifactFactory {
if(ormReadOnlyAttribute instanceof OrmSpecifiedPersistentAttribute)
ormPersistentType.removeAttributeFromXml((OrmSpecifiedPersistentAttribute) ormReadOnlyAttribute);
}
+
+ jpt.getJavaResourceType().getJavaResourceCompilationUnit().synchronizeWithJavaSource();
+ jpt.synchronizeWithResourceModel();
+ jpt.update();
}
/**
@@ -826,7 +822,7 @@ public class JpaArtifactFactory {
IJPAEditorFeatureProvider fp) {
synchronized (jpt) {
- Command deleteAttributeCommand = new DeleteAttributeCommand(null, jpt, attributeName, fp);
+ Command deleteAttributeCommand = new DeleteAttributeCommand(jpt, attributeName, fp);
try {
getJpaProjectManager().execute(deleteAttributeCommand, SynchronousUiCommandContext.instance());
} catch (InterruptedException e) {
@@ -1200,9 +1196,9 @@ public class JpaArtifactFactory {
return res;
}
- public void renameEntityClass(PersistentType jpt, String newEntityName, IJPAEditorFeatureProvider fp) {
+ public void renameEntityClass(PersistentType jpt, String newEntityName) {
- Command renameEntityCommand = new RenameEntityCommand(jpt, newEntityName, fp);
+ Command renameEntityCommand = new RenameEntityCommand(jpt, newEntityName);
try {
getJpaProjectManager().execute(renameEntityCommand, SynchronousUiCommandContext.instance());
} catch (InterruptedException e) {
@@ -1240,7 +1236,7 @@ public class JpaArtifactFactory {
String attributeTypeName = getRelTypeName(oldAt);
- Command renameAttributeCommand = new RenameAttributeCommand(null, jpt, oldName, newName, fp);
+ Command renameAttributeCommand = new RenameAttributeCommand(jpt, oldName, newName);
getJpaProjectManager().execute(renameAttributeCommand, SynchronousUiCommandContext.instance());
PersistentAttribute newAt = jpt.getAttributeNamed(newName);
@@ -1306,11 +1302,9 @@ public class JpaArtifactFactory {
if (rel != null) {
updateRelation(jpt, fp, rel);
if(hasIDClass(jpt)) {
- String idClassFQN = getIdType(jpt);
- IJavaProject javaProject = JavaCore.create(jpt.getJpaProject().getProject());
- IType type = getType(javaProject, idClassFQN);
- if(type != null && type.getField(oldAt.getName()).exists()){
- Command renameAttributeCommand = new RenameAttributeCommand(type.getCompilationUnit(), null, oldAt.getName(), newAt.getName(), fp);
+ JavaPersistentType idClassJPT = getIdClassJPT(jpt);
+ if(idClassJPT != null && (idClassJPT.getAttributeNamed(oldAt.getName()) != null)){
+ Command renameAttributeCommand = new RenameAttributeCommand(idClassJPT, oldAt.getName(), newAt.getName());
getJpaProjectManager().execute(renameAttributeCommand, SynchronousUiCommandContext.instance());
}
}
@@ -1840,16 +1834,30 @@ public class JpaArtifactFactory {
}
return false;
}
-
- public String getIdType(PersistentType jpt) {
- String idClass = null;
+
+ public JavaPersistentType getIdClassJPT(PersistentType jpt){
+ JavaPersistentType idClassType = null;
TypeMapping mapping = getTypeMapping(jpt);
if(mapping instanceof Entity){
- idClass = ((Entity)mapping).getIdClassReference().getFullyQualifiedIdClassName();
+ idClassType = ((Entity)mapping).getIdClass();
+ if(idClassType == null) {
+ String idClassFqn = ((Entity)mapping).getIdClassReference().getFullyQualifiedIdClassName();
+ PersistentType idClassPersistentType = jpt.getPersistenceUnit().getPersistentType(idClassFqn);
+ if(idClassPersistentType instanceof OrmPersistentType){
+ idClassType = ((OrmPersistentType)idClassPersistentType).getJavaPersistentType();
+ } else {
+ idClassType = (JavaPersistentType) idClassPersistentType;
+ }
+ }
}
- if (idClass != null)
- return idClass;
+ return idClassType;
+ }
+
+ public String getIdType(PersistentType jpt) {
+ JavaPersistentType idClassJPT = getIdClassJPT(jpt);
+ if (idClassJPT != null)
+ return idClassJPT.getName();
PersistentAttribute[] ids = getIds(jpt);
if (ids.length == 0)
return null;
@@ -2053,12 +2061,11 @@ public class JpaArtifactFactory {
public void calculateDerivedIdAttribute(PersistentType ownerJPT, PersistentType inverseJPT, PersistentAttribute ownerAttr) {
String attributeType = null;
if(hasSimplePk(inverseJPT)){
-
PersistentAttribute jpa = getSimplePkAttribute(inverseJPT);
attributeType = JPAEditorUtil.getAttributeTypeNameWithGenerics(jpa);
} else {
if(hasIDClass(inverseJPT)){
- attributeType = getIdType(inverseJPT);
+ attributeType = getIdClassJPT(inverseJPT).getName();
} else if (hasEmbeddedPk(inverseJPT)){
attributeType = JPAEditorUtil.getAttributeTypeNameWithGenerics(getEmbeddedIdAttribute(inverseJPT));
}
@@ -2082,13 +2089,15 @@ public class JpaArtifactFactory {
boolean isXmlDefined = getORMPersistentAttribute(ownerAttr) != null;
if(hasIDClass(ownerJPT)){
annotationName = IdAnnotation.ANNOTATION_NAME;
- String ownerIdClassFQN = getIdType(ownerJPT);
- addDerivedIdAnnotation(ownerJPT, inverseJPT, ownerAttr, ownerIdClassFQN,
+ JavaPersistentType composedJPT = getIdClassJPT(ownerJPT);
+ addDerivedIdAnnotation(ownerJPT, inverseJPT, ownerAttr, composedJPT,
inverseIdClassFQN, annotationName, isXmlDefined);
} else if(hasEmbeddedPk(ownerJPT)){
annotationName = MapsIdAnnotation2_0.ANNOTATION_NAME;
- String ownerIdClassFQN = JPAEditorUtil.getAttributeTypeNameWithGenerics(getEmbeddedIdAttribute(ownerJPT));
- mapsIdValue = addDerivedIdAnnotation(ownerJPT, inverseJPT, ownerAttr, ownerIdClassFQN,
+ PersistentAttribute embeddedIdAttribute = getEmbeddedIdAttribute(ownerJPT);
+ String embbeddedIdAttrType = getRelTypeName(embeddedIdAttribute);
+ PersistentType composedJPT = getPersistenceUnit(ownerJPT).getPersistentType(embbeddedIdAttrType);
+ mapsIdValue = addDerivedIdAnnotation(ownerJPT, inverseJPT, ownerAttr, composedJPT,
inverseIdClassFQN, annotationName, isXmlDefined);
} else if(hasSimplePk(ownerJPT)){
annotationName = MapsIdAnnotation2_0.ANNOTATION_NAME;
@@ -2120,24 +2129,23 @@ public class JpaArtifactFactory {
*/
private String addDerivedIdAnnotation(PersistentType ownerJPT,
PersistentType inverseJPT, PersistentAttribute ownerAttr,
- String ownerIdClassFQN, String inverseIdClassFQN, String annotationName, boolean isXmlDefined) {
- if(!inverseIdClassFQN.equals(ownerIdClassFQN)){
+ PersistentType ownerIdClass, String inverseIdClassFQN, String annotationName, boolean isXmlDefined) {
+ if(ownerIdClass != null && !inverseIdClassFQN.equals(ownerIdClass.getName())){
String attributeType = JPAEditorUtil.returnSimpleName(inverseIdClassFQN);
- addFieldInCompositeKeyClass(inverseJPT, ownerAttr, ownerIdClassFQN, attributeType);
+ addFieldInCompositeKeyClass(inverseJPT, ownerAttr, ownerIdClass, attributeType);
if(!isXmlDefined) {
Annotation ann = ownerAttr.getJavaPersistentAttribute().getResourceAttribute().addAnnotation(annotationName);
if(ann != null && ann instanceof MapsIdAnnotation2_0){
((MapsIdAnnotation2_0)ann).setValue(ownerAttr.getName());
}
}
- return ownerAttr.getName();
} else {
if(!isXmlDefined) {
ownerAttr.getJavaPersistentAttribute().getResourceAttribute().addAnnotation(annotationName);
}
}
- return null;
+ return ownerAttr.getName();
}
private void addDerivedIdMapping(PersistentAttribute attr, String idAttributeName, String annotationName){
@@ -2163,21 +2171,11 @@ public class JpaArtifactFactory {
* @param attributeTypeName - the attribute's type
*/
private void addFieldInCompositeKeyClass(PersistentType inverseJPT,
- PersistentAttribute ownerAttr, String fqnClass, String attributeTypeName) {
- IJavaProject javaProject = JavaCore.create(ownerAttr.getJpaProject().getProject());
- IType type = getType(javaProject, fqnClass);
- if(type != null && !type.getField(ownerAttr.getName()).exists()){
- ICompilationUnit unit = type.getCompilationUnit();
- PersistentType jpt = JPAEditorUtil.getJPType(unit);
- Command createNewAttributeCommand = new AddAttributeCommand(null, jpt, attributeTypeName, null, ownerAttr.getName(),
- ownerAttr.getName(), null, null, false, unit);
- try {
- getJpaProjectManager().execute(createNewAttributeCommand, SynchronousUiCommandContext.instance());
- } catch (InterruptedException e) {
- JPADiagramEditorPlugin.logError("Cannot create a new attribute with name " + ownerAttr.getName(), e); //$NON-NLS-1$
- }
- if(jpt != null) {
- PersistentAttribute attr = jpt.getAttributeNamed(ownerAttr.getName());
+ PersistentAttribute ownerAttr, PersistentType fqnClass, String attributeTypeName) {
+ if(fqnClass != null && (fqnClass.getAttributeNamed(ownerAttr.getName()) == null)){
+ PersistentAttribute attr = makeNewAttribute(fqnClass, ownerAttr.getName(), attributeTypeName, ownerAttr.getName(), null, null, null, false);
+ PersistentAttribute ormAttr = JpaArtifactFactory.instance().addOrmPersistentAttribute(fqnClass, attr, MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
+ if(ormAttr == null || ormAttr.isVirtual()){
attr.getJavaPersistentAttribute().setMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
}
}
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/META-INF/MANIFEST.MF b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/META-INF/MANIFEST.MF
index 025d40d..86f83f9 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/META-INF/MANIFEST.MF
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/META-INF/MANIFEST.MF
@@ -27,11 +27,12 @@ Require-Bundle: org.easymock;bundle-version="[2.4.0,3.0.0)",
org.eclipse.wst.common.modulecore;bundle-version="[1.2.1,2.0.0)",
org.eclipse.wst.common.project.facet.core;bundle-version="[1.3.0,2.0.0)",
org.eclipse.core.filesystem;bundle-version="[1.3.1,2.0.0)",
- org.junit4;bundle-version="[4.0.0,5.0.0)",
- org.eclipse.swtbot.eclipse.core;bundle-version="2.0.5",
- org.eclipse.swtbot.eclipse.gef.finder;bundle-version="2.0.5",
- org.eclipse.swtbot.eclipse.finder;bundle-version="2.0.5",
- org.eclipse.swtbot.junit4_x;bundle-version="2.0.5",
- org.hamcrest;bundle-version="1.1.0",
org.apache.log4j,
- org.eclipse.swtbot.forms.finder;bundle-version="2.0.5"
+ org.eclipse.jpt.common.utility,
+ org.eclipse.jpt.common.ui;bundle-version="1.3.0",
+ org.eclipse.swtbot.eclipse.core;bundle-version="2.1.0",
+ org.eclipse.swtbot.eclipse.gef.finder;bundle-version="2.1.0",
+ org.eclipse.swtbot.junit4_x;bundle-version="2.1.0",
+ org.eclipse.swtbot.forms.finder;bundle-version="2.1.0",
+ org.hamcrest.core;bundle-version="1.3.0",
+ org.junit;bundle-version="4.11.0"
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/ConnectionIsShown.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/conditions/ConnectionIsShown.java
index 467f7ab..3829058 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/ConnectionIsShown.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/conditions/ConnectionIsShown.java
@@ -1,4 +1,4 @@
-package org.eclipse.jpt.jpadiagrameditor.swtbot.tests.ui.editor;
+package org.eclipse.jpt.jpadiagrameditor.swtbot.tests.conditions;
import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/DiagramIsEmpty.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/conditions/DiagramIsEmpty.java
index 0a3f5a9..c245dd9 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/DiagramIsEmpty.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/conditions/DiagramIsEmpty.java
@@ -1,4 +1,4 @@
-package org.eclipse.jpt.jpadiagrameditor.swtbot.tests.ui.editor;
+package org.eclipse.jpt.jpadiagrameditor.swtbot.tests.conditions;
import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/ElementAppearsInDiagram.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/conditions/ElementAppearsInDiagram.java
index 572690e..126cab3 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/ElementAppearsInDiagram.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/conditions/ElementAppearsInDiagram.java
@@ -1,4 +1,4 @@
-package org.eclipse.jpt.jpadiagrameditor.swtbot.tests.ui.editor;
+package org.eclipse.jpt.jpadiagrameditor.swtbot.tests.conditions;
import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/ElementDisappears.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/conditions/ElementDisappears.java
index 3e2a900..b389cbf 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/ElementDisappears.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/conditions/ElementDisappears.java
@@ -1,4 +1,4 @@
-package org.eclipse.jpt.jpadiagrameditor.swtbot.tests.ui.editor;
+package org.eclipse.jpt.jpadiagrameditor.swtbot.tests.conditions;
import java.util.ArrayList;
import java.util.List;
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/ElementIsShown.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/conditions/ElementIsShown.java
index fcfbf40..ca37312 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/ElementIsShown.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/conditions/ElementIsShown.java
@@ -1,4 +1,4 @@
-package org.eclipse.jpt.jpadiagrameditor.swtbot.tests.ui.editor;
+package org.eclipse.jpt.jpadiagrameditor.swtbot.tests.conditions;
import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/embeddable/EmbeddableInDiagramSWTBotTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/embeddable/EmbeddableInDiagramSWTBotTest.java
new file mode 100644
index 0000000..51e9ae5
--- /dev/null
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/embeddable/EmbeddableInDiagramSWTBotTest.java
@@ -0,0 +1,900 @@
+package org.eclipse.jpt.jpadiagrameditor.swtbot.tests.embeddable;
+
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.ui.internal.parts.DiagramEditPart;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jpt.jpa.core.MappingKeys;
+import org.eclipse.jpt.jpa.core.jpa2.MappingKeys2_0;
+import org.eclipse.jpt.jpa.ui.details.JptJpaUiDetailsMessages;
+import org.eclipse.jpt.jpa.ui.jpa2.details.JptJpaUiDetailsMessages2_0;
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.conditions.ElementIsShown;
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.internal.AbstractSwtBotEditorTest;
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.utils.Utils;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.HasReferanceRelation.HasReferenceType;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(SWTBotJunit4ClassRunner.class)
+@SuppressWarnings("restriction")
+public class EmbeddableInDiagramSWTBotTest extends AbstractSwtBotEditorTest {
+
+ protected static String TEST_PROJECT = "Test_" + System.currentTimeMillis();
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ createJPa20Project(TEST_PROJECT);
+ }
+
+ /**
+ * Add embeddable to diagram and check that it does not contain a
+ * "Primary Key", "Relation Attributes" and "Other Attributes" sections.
+ */
+ @Test
+ public void testAddEmbeddable() {
+ Utils.sayTestStarted("testAddEmbeddable");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ editorProxy.addEmbeddableToDiagram(50, 50, jpaProject);
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ jpaDiagramEditor.save();
+ assertFalse("Editor must not be dirty!", jpaDiagramEditor.isDirty());
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testAddEmbeddable");
+ }
+
+ /**
+ * Remove an embeddable from the diagram using the embeddable's context
+ * button "Delete"
+ */
+ @Test
+ public void testRemoveEmnbeddableViaButton() {
+ Utils.sayTestStarted("testRemoveEmnbeddableViaButton");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ editorProxy.deleteJPTViaButton(embeddable, true);
+
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testRemoveEmnbeddableViaButton");
+ }
+
+ /**
+ * Remove an embeddable from the diagram using the embeddable's context menu
+ * "Delete"
+ */
+ @Test
+ public void testRemoveEmbeddableViaContextMenu() {
+ Utils.sayTestStarted("testRemoveEmbeddableViaContextMenu");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ editorProxy.deleteJPTViaMenu(embeddable);
+
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testRemoveEmbeddableViaContextMenu");
+ }
+
+// /**
+// * Adds a new attribute to the embeddable using the entity's context button
+// * "Create Attribute"
+// */
+// @Test
+// public void testAddAttributeToEmbeddablle() {
+// Utils.sayTestStarted("testAddAttributeToEmbeddablle");
+//
+// assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+//
+// SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+// 50, jpaProject);
+// assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+//
+// assertFalse(
+// "\"Other Attributes\" section must not be visible!",
+// editorProxy
+// .isSectionVisible(
+// JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
+// embeddable));
+//
+// String attributeName = editorProxy.getUniqueAttrName(embeddable);
+// editorProxy.addAttributeToJPT(embeddable, attributeName, false);
+// assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+//
+// embeddable.click();
+// editorProxy.deleteDiagramElements(false);
+// jpaDiagramEditor.save();
+//
+// Utils.sayTestFinished("testAddAttributeToEmbeddablle");
+// }
+
+
+
+ /**
+ * Removes the attribute using the "Delete Attribute" context button.
+ */
+ @Test
+ public void testAddRemoveAttributeFromEmbeddableViaContextButton() {
+ Utils.sayTestStarted("testRemoveAttributeFromEmbeddableViaContextButton");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ String attributeName = editorProxy.getUniqueAttrName(embeddable);
+ SWTBotGefEditPart attribute = editorProxy.addAttributeToJPT(embeddable, attributeName, false);
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ editorProxy.removeAttributeViaButton(embeddable, attribute, attributeName, false);
+
+ embeddable.click();
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testRemoveAttributeFromEmbeddableViaContextButton");
+ }
+
+ /**
+ * Removes the attribute using the "Delete" context menu.
+ */
+ @Test
+ public void testAddRemoveAttributeFromEmbeddableViaMenu() {
+ Utils.sayTestStarted("testRemoveAttributeFromEmbeddableViaMenu");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ String attributeName = editorProxy.getUniqueAttrName(embeddable);
+ SWTBotGefEditPart attribute = editorProxy.addAttributeToJPT(embeddable, attributeName, false);
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ editorProxy.removeAttributeViaMenu(embeddable, attribute, attributeName);
+
+ embeddable.click();
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testRemoveAttributeFromEmbeddableViaMenu");
+ }
+
+ @Test
+ public void testAddRemoveElementCollectionAttributeToEmbeddable(){
+ Utils.sayTestStarted("testAddElementCollectionAttributeToEmbeddable");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50, 50, jpaProject);
+
+ assertFalse(
+ "\"Other Attributes\" section must not be visible!",
+ editorProxy.isSectionVisible(JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes, embeddable));
+
+ String attributeName = editorProxy.getUniqueAttrName(embeddable);
+ SWTBotGefEditPart attribute = editorProxy.addElementCollectionAttributeToJPT(embeddable, attributeName);
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ editorProxy.removeAttributeViaButton(embeddable, attribute, attributeName, false);
+
+ embeddable.click();
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testAddElementCollectionAttributeToEmbeddable");
+ }
+
+
+ /**
+ * Add two embeddables and one entity in the diagram. Add an attribute of collection type to
+ * the first embeddable. Check that it is not possible to embed a collection of the first
+ * embeddable neither into the second embeddable, nor into the entity, but it is possible to embed
+ * a collection of the second embeddable to the first embeddable.
+ */
+
+ @Test
+ public void testEmbedCollectionOfObjectsWithCollectionAttribute() {
+ Utils.sayTestStarted("testEmbedCollectionOfObjectsWithCollectionAttribute");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart embeddable1 = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+ SWTBotGefEditPart embeddable2 = editorProxy.addEmbeddableToDiagram(50,
+ 200, jpaProject);
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(200, 50, jpaProject);
+
+ assertFalse(
+ "\"Other Attributes\" section must not be visible!",
+ editorProxy.isSectionVisible(JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes, embeddable1));
+
+ String attributeName = editorProxy.getUniqueAttrName(embeddable1);
+ SWTBotGefEditPart attribute = editorProxy.addElementCollectionAttributeToJPT(embeddable1, attributeName);
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ editorProxy.testNoEmbeddedConnectionIsCreated(
+ JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, 0, entity, embeddable1, false);
+
+ editorProxy.testNoEmbeddedConnectionIsCreated(
+ JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, 0, embeddable2, embeddable1, false);
+
+ jpaDiagramEditor.activateDefaultTool();
+ editorProxy.waitASecond();
+ editorProxy.removeAttributeViaButton(embeddable1, attribute, attributeName, false);
+
+ editorProxy._testEmbeddedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddable1,
+ embeddable2, HasReferenceType.COLLECTION,
+ MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
+ JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
+ 3);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testEmbedCollectionOfObjectsWithCollectionAttribute");
+ }
+
+ /**
+ * Adds a new attribute and rename it
+ */
+ @Test
+ public void testDirectEditingAttributeInEmbeddable() {
+ Utils.sayTestStarted("testDirectEditingAttributeInEmbeddable");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ String attributeName = editorProxy.getUniqueAttrName(embeddable);
+ editorProxy.directEditAttribute(embeddable, attributeName);
+
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testDirectEditingAttributeInEmbeddable");
+ }
+
+ /**
+ * Adds a new embeddable and rename it
+ */
+ @Ignore
+ @Test
+ public void testDirectEditingEmbeddable() {
+ Utils.sayTestStarted("testDirectEditingEmbeddable");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+ String oldEmbeddableName = editorProxy.getJPTObjectForGefElement(embeddable).getSimpleName();
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ editorProxy.moveMouse(100, 70);
+ embeddable.click();
+ embeddable.activateDirectEdit();
+ jpaDiagramEditor.directEditType("NewEntityName");
+ editorProxy.moveMouse(0, 0);
+
+ SWTBotGefEditPart oldEmbeddable = jpaDiagramEditor
+ .getEditPart(oldEmbeddableName);
+ SWTBotGefEditPart newEmbeddable = jpaDiagramEditor
+ .getEditPart("NewEntityName");
+ assertNotNull("The entity must be renamed!", newEmbeddable);
+ assertNull("The attribute must be renamed!", oldEmbeddable);
+
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testDirectEditingEmbeddable");
+ }
+
+ /**
+ * Test that the source of the embeddable is opened, when is double clicked
+ * on it
+ */
+ @Ignore
+ @Test
+ public void testDoubleClickOnEmbeddable() {
+ Utils.sayTestStarted("testDoubleClickOnEmbeddable");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ editorProxy.moveMouse(100, 70);
+ jpaDiagramEditor.doubleClick(embeddable);
+ editorProxy.moveMouse(0, 0);
+
+ SWTBotEditor activeEditor = workbenchBot.activeEditor();
+ assertEquals("The Java editor of the enity did not open!",
+ "Embeddable1.java", activeEditor.getTitle());
+ activeEditor.close();
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testDoubleClickOnEmbeddable");
+ }
+
+ /**
+ * Change the attribute type.
+ */
+ @Test
+ public void testChangeAttributeTypeInEmbeddable() {
+ Utils.sayTestStarted("testChangeAttributeTypeInEmbeddable");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ assertFalse(
+ "\"Other Attributes\" section must not be visible!",
+ editorProxy
+ .isSectionVisible(
+ JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
+ embeddable));
+
+ String attributeName = editorProxy.getUniqueAttrName(embeddable);
+ SWTBotGefEditPart attribute = editorProxy.addAttributeToJPT(embeddable,
+ attributeName, false);
+ assertNotNull("The attribute must not be renamed!", attribute);
+
+ final IFeatureProvider fp = ((DiagramEditPart) jpaDiagramEditor
+ .mainEditPart().part()).getFeatureProvider();
+
+ String currentAttributeType = editorProxy.getAttributeType(
+ attributeName, fp);
+ assertEquals("java.lang.String", currentAttributeType);
+
+ SWTBotShell changeTypeDialog = editorProxy
+ .getSelectNewAttributeTypeDialog(attribute);
+ SWTBotText attributeType = editorProxy
+ .getNewTypeInputField(changeTypeDialog);
+
+ // test invalid attribute type
+ attributeType.setText("");
+ assertFalse(editorProxy.getOkButton(changeTypeDialog).isEnabled());
+ assertTrue(editorProxy.getCancelButton(changeTypeDialog).isEnabled());
+ SWTBotText dialogError = editorProxy
+ .getDialogErroMessage(changeTypeDialog);
+ assertEquals(" The new type name must not be empty",
+ dialogError.getText());
+ // cancel the dialog
+ editorProxy.getCancelButton(changeTypeDialog).click();
+
+ // assert that the attribute type is not changed
+ currentAttributeType = editorProxy.getAttributeType(attributeName, fp);
+ assertEquals("The attribute type must not be changed!",
+ "java.lang.String", currentAttributeType);
+
+ changeTypeDialog = editorProxy
+ .getSelectNewAttributeTypeDialog(attribute);
+ attributeType = editorProxy.getNewTypeInputField(changeTypeDialog);
+
+ // change the attribute type to int
+ attributeType.setText("int");
+ assertTrue(editorProxy.getOkButton(changeTypeDialog).isEnabled());
+ assertTrue(editorProxy.getCancelButton(changeTypeDialog).isEnabled());
+ // confirm the dialog
+ editorProxy.getOkButton(changeTypeDialog).click();
+ editorProxy.waitASecond();
+ // assert that the attribute's type is changed
+ String newAttributeType = editorProxy
+ .getAttributeType(attributeName, fp);
+ assertFalse("The attribute type must be changed!",
+ ("java.lang.String").equals(newAttributeType));
+ assertEquals("The attribute type must be changed!", "int",
+ newAttributeType);
+
+ assertTrue("Editor must be dirty!", jpaDiagramEditor.isDirty());
+ embeddable.click();
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testChangeAttributeTypeInEmbeddable");
+ }
+
+ /**
+ * Rename the embeddable using its context menu
+ * "Refactor Entity Class -> Rename..."
+ */
+ @Ignore
+ @Test
+ public void testRenameEmbeddableViaMenu() {
+ Utils.sayTestStarted("testRenameEmbeddableViaMenu");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+ String oldEmbeddableName = editorProxy.getJPTObjectForGefElement(embeddable).getSimpleName();
+
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ embeddable.click();
+ jpaDiagramEditor
+ .clickContextMenu(JPAEditorMessages.JPAEditorToolBehaviorProvider_renameEntityClass);
+
+ SWTBotShell renameEntityDialog = editorProxy.getRenameEntityDialog();
+ SWTBotText embeddableName = renameEntityDialog.bot().textWithLabel(
+ "New name:");
+
+ // test invalid entity name
+ embeddableName.setText("");
+ assertFalse(editorProxy.getFinishButton(renameEntityDialog).isEnabled());
+ assertTrue(editorProxy.getCancelButton(renameEntityDialog).isEnabled());
+
+ embeddableName.setText("NewEntityName");
+ assertTrue(editorProxy.getFinishButton(renameEntityDialog).isEnabled());
+ assertTrue(editorProxy.getCancelButton(renameEntityDialog).isEnabled());
+
+ editorProxy.getFinishButton(renameEntityDialog).click();
+ bot.waitUntil(new ElementIsShown(jpaDiagramEditor, "NewEntityName"),
+ 10000);
+
+ embeddable = jpaDiagramEditor.getEditPart("NewEntityName");
+ assertNotNull("Entity name must be changed!", embeddable);
+
+ assertNull("Entity naem must be changed!",
+ jpaDiagramEditor.getEditPart(oldEmbeddableName));
+
+ embeddable.click();
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testRenameEmbeddableViaMenu");
+ }
+
+ /**
+ * Move the embeddable class using the embeddable's context menu
+ * "Refactor Entity Class -> Move..."
+ */
+ @Ignore
+ @Test
+ public void testMoveEmbeddableViaMenu() throws JavaModelException {
+ Utils.sayTestStarted("testMoveEmbeddableViaMenu");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+ String embeddableName = editorProxy.getJPTObjectForGefElement(embeddable).getSimpleName();
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ JpaArtifactFactory factory = JpaArtifactFactory.instance();
+
+ String packageName = factory
+ .getMappedSuperclassPackageDeclaration(editorProxy
+ .getJPTObjectForGefElement(embeddable));
+
+ embeddable.click();
+ jpaDiagramEditor
+ .clickContextMenu(JPAEditorMessages.JPAEditorToolBehaviorProvider_moveEntityClass);
+
+ SWTBotShell moveEntityDialog = editorProxy.getMoveEntityDialog();
+ moveEntityDialog.bot().tree().getTreeItem(TEST_PROJECT).select()
+ .expandNode("src").expandNode("org").select().click();
+ assertTrue(editorProxy.getOkButton(moveEntityDialog).isEnabled());
+ editorProxy.getOkButton(moveEntityDialog).click();
+ editorProxy.waitASecond();
+
+ embeddable = jpaDiagramEditor.getEditPart(embeddableName);
+ String newEntityPackage = factory
+ .getMappedSuperclassPackageDeclaration(editorProxy
+ .getJPTObjectForGefElement(embeddable));
+ assertFalse("Entity must be moved!",
+ packageName.equals(newEntityPackage));
+ assertTrue("Entity must be changed!", newEntityPackage.equals("org"));
+
+ embeddable.click();
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testMoveEmbeddableViaMenu");
+ }
+
+ /**
+ * Collapse/expand embeddable using its context buttons
+ */
+ @Test
+ public void testCollapseExapandEmbeddableViaContextButton() {
+ Utils.sayTestStarted("testCollapseExapandEmbeddableViaContextButton");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ String attributeName = editorProxy.getUniqueAttrName(embeddable);
+ editorProxy.addAttributeToJPT(embeddable, attributeName, false);
+
+ editorProxy.collapseExpandJPTViaButton(embeddable);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testCollapseExapandEmbeddableViaContextButton");
+ }
+
+ /**
+ * Collapse/expand embeddable using its context menus
+ */
+ @Test
+ public void testCollapseExapandEmbeddableViaMenu() {
+ Utils.sayTestStarted("testCollapseExapandEmbeddableViaMenu");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ String attributeName = editorProxy.getUniqueAttrName(embeddable);
+ editorProxy.addAttributeToJPT(embeddable, attributeName, false);
+
+ editorProxy.collapseExpandJPTViaMenu(embeddable);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testCollapseExapandEmbeddableViaMenu");
+ }
+
+ /**
+ * Add a new attribute without saving the embeddable and call the
+ * "Discard Changes" context menu. Assert that the newly added attribute is
+ * removed and the embeddable does not contain unsaved changes.
+ */
+ @Ignore
+ @Test
+ public void testDiscardChangesFromEmbeddable() {
+ Utils.sayTestStarted("testDiscardChangesFromEmbeddable");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ String attributeName = editorProxy.getUniqueAttrName(embeddable);
+ editorProxy.discardChanges(embeddable, attributeName);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testDiscardChangesFromEmbeddable");
+ }
+
+ /**
+ * Add a new attribute without saving the embeddable and call the
+ * embeddable's context menu "Remove All Entities from Diagram -> ... and
+ * Discard
+ * Changes" context menu. Assert that the diagram is empty. Call "Show All
+ * Entities" context menu and assert that the newly added attribute is
+ * removed and the embeddable does not contain unsaved changes.
+ */
+ @Test
+ public void testRemoveAndDiscardChangesFromEmbeddableViaMenu() {
+ Utils.sayTestStarted("testRemoveAndDiscardChangesFromEmbeddableViaMenu");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ String attributeName = editorProxy.getUniqueAttrName(embeddable);
+ editorProxy.removeAndDiscardChangesViaMenu(embeddable, attributeName);
+
+ embeddable.click();
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testRemoveAndDiscardChangesFromEmbeddableViaMenu");
+ }
+
+ /**
+ * Add a new attribute without saving the embeddable and call the
+ * embeddable's context menu "Remove All Entities from Diagram -> ... and
+ * Save Changes" context menu. Assert that the diagram is empty. Call "Show
+ * All Entities" context menu and assert that the newly added attribute is
+ * added and the embeddable does not contain unsaved changes.
+ */
+ @Ignore
+ @Test
+ public void testRemoveAndSaveChangesToEmbeddableViaMenu() {
+ Utils.sayTestStarted("testRemoveAndSaveChangesToEmbeddableViaMenu");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ String attributeName = editorProxy.getUniqueAttrName(embeddable);
+ editorProxy.removeAndSaveChangesViaMenu(embeddable, attributeName);
+
+ embeddable.click();
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testRemoveAndSaveChangesToEmbeddableViaMenu");
+ }
+
+ /**
+ * Add a new attribute to the embeddable. From the embeddable's context menu
+ * select "Save". Assert that the embeddable does not contain any unsaved
+ * changes, but the diagram editor is still dirty.
+ */
+ @Test
+ public void testSaveOnlyEmbeddable() {
+ Utils.sayTestStarted("testSaveOnlyEmbeddable");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ String attributeName = editorProxy.getUniqueAttrName(embeddable);
+ editorProxy.saveOnlyJPT(embeddable, attributeName);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testSaveOnlyEmbeddable");
+ }
+
+ /**
+ * Add one entity and one embeddable in the diagram. Embed a single instance
+ * of the embeddable into the entity and checks that the connection exists
+ * and a new embedded attribute is added to the entity.
+ */
+ @Test
+ public void testEmbedSingleObjectInEntity() {
+ Utils.sayTestStarted("testEmbedSingleObjectInEntity");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
+ jpaProject);
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 200, jpaProject);
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ editorProxy._testEmbeddedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, entity, embeddable,
+ HasReferenceType.SINGLE,
+ MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
+ JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 2);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testEmbedSingleObjectInEntity");
+ }
+
+ /**
+ * Add one entity and one embeddable in the diagram. Embed a collection of
+ * the embeddable into the entity and checks that the connection exists and
+ * a new embedded attribute is added to the entity.
+ */
+ @Test
+ public void testEmbedCollectionOfObjectsInEntity() {
+ Utils.sayTestStarted("testEmbedCollectionOfObjectsInEntity");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
+ jpaProject);
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 200, jpaProject);
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ editorProxy._testEmbeddedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, entity,
+ embeddable, HasReferenceType.COLLECTION,
+ MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
+ JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
+ 2);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testEmbedCollectionOfObjectsInEntity");
+ }
+
+ /**
+ * Add two embeddables in the diagram. Embed a single instance of the first
+ * embeddable into the second embeddable and checks that the connection
+ * exists and a new embedded attribute is added to the second embeddable.
+ */
+ @Test
+ public void testEmbedSingleObjectInEmbeddable() {
+ Utils.sayTestStarted("testEmbedSingleObjectInEmbeddable");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart embeddable1 = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+ SWTBotGefEditPart embeddable2 = editorProxy.addEmbeddableToDiagram(50,
+ 200, jpaProject);
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ editorProxy._testEmbeddedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddable1,
+ embeddable2, HasReferenceType.SINGLE,
+ MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
+ JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 2);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testEmbedSingleObjectInEmbeddable");
+ }
+
+ /**
+ * Add two embeddables in the diagram. Embed a collection of the first
+ * embeddable into the second embeddable and checks that the connection
+ * exists and a new embedded attribute is added to the second embeddable.
+ */
+
+ @Test
+ public void testEmbedCollectionOfObjectsInEmbeddable() {
+ Utils.sayTestStarted("testEmbedCollectionOfObjectsInEmbeddable");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart embeddable1 = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+ SWTBotGefEditPart embeddable2 = editorProxy.addEmbeddableToDiagram(50,
+ 200, jpaProject);
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ editorProxy._testEmbeddedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddable1,
+ embeddable2, HasReferenceType.COLLECTION,
+ MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
+ JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
+ 2);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testEmbedCollectionOfObjectsInEmbeddable");
+ }
+
+ /**
+ * Add two embeddables and one entity in the diagram. Embed a collection of
+ * the first embeddable to the second one. Check that it is not possible to
+ * embed a collection of the second embeddable into the entity, but it is
+ * possible to embed a collection of the first embeddable to the entity.
+ */
+
+ @Test
+ public void testEmbedCollectionOfObjectsInEmbeddableAndEntity() {
+ Utils.sayTestStarted("testEmbedCollectionOfObjectsInEmbeddableAndEntity");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart embeddable1 = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+ SWTBotGefEditPart embeddable2 = editorProxy.addEmbeddableToDiagram(50,
+ 200, jpaProject);
+
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ editorProxy.embedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddable1,
+ embeddable2, HasReferenceType.COLLECTION,
+ MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
+ JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
+ 2);
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(200, 50,
+ jpaProject);
+
+ editorProxy.testNoEmbeddedConnectionIsCreated(
+ JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, 0, entity, embeddable1, true);
+
+ editorProxy._testEmbeddedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, entity,
+ embeddable2, HasReferenceType.COLLECTION,
+ MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
+ JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
+ 4);
+
+
+ String embeddableName = editorProxy.getJPTObjectForGefElement(embeddable2).getSimpleName();
+ String embeddingAttributeName = JPAEditorUtil.decapitalizeFirstLetter(embeddableName);
+ editorProxy.deleteAttributeInJPT(embeddable1, embeddingAttributeName);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testEmbedCollectionOfObjectsInEmbeddableAndEntity");
+ }
+
+ /**
+ * Add three embeddables in the diagram. Embed a collection of
+ * the first embeddable to the second one. Check that it is not possible to
+ * embed a collection of the second embeddable into the third one, but it is
+ * possible to embed a collection of the first embeddable to the third embeddable.
+ */
+ @Ignore
+ @Test
+ public void testEmbedCollectionOfObjectsInTwoEmbeddables() {
+ Utils.sayTestStarted("testEmbedCollectionOfObjectsInTwoEmbeddables");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart embeddable1 = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+ SWTBotGefEditPart embeddable2 = editorProxy.addEmbeddableToDiagram(50,
+ 200, jpaProject);
+
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ editorProxy.embedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddable1,
+ embeddable2, HasReferenceType.COLLECTION,
+ MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
+ JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
+ 2);
+
+ SWTBotGefEditPart embeddable3 = editorProxy.addEmbeddableToDiagram(200, 50,
+ jpaProject);
+
+ editorProxy.testNoEmbeddedConnectionIsCreated(
+ JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, 0, embeddable3, embeddable1, true);
+
+ editorProxy._testEmbeddedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddable3,
+ embeddable2, HasReferenceType.COLLECTION,
+ MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
+ JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
+ 4);
+
+ String embeddableName = editorProxy.getJPTObjectForGefElement(embeddable2).getSimpleName();
+ String embeddingAttributeName = JPAEditorUtil.decapitalizeFirstLetter(embeddableName);
+ editorProxy.deleteAttributeInJPT(embeddable1, embeddingAttributeName);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testEmbedCollectionOfObjectsInTwoEmbeddables");
+ }
+}
+
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/embeddable/relationships/EmbeddableRelationshipsSWTBotTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/embeddable/relationships/EmbeddableRelationshipsSWTBotTest.java
new file mode 100644
index 0000000..08f738a
--- /dev/null
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/embeddable/relationships/EmbeddableRelationshipsSWTBotTest.java
@@ -0,0 +1,1070 @@
+package org.eclipse.jpt.jpadiagrameditor.swtbot.tests.embeddable.relationships;
+
+import org.eclipse.jpt.jpa.core.MappingKeys;
+import org.eclipse.jpt.jpa.core.jpa2.MappingKeys2_0;
+import org.eclipse.jpt.jpa.ui.details.JptJpaUiDetailsMessages;
+import org.eclipse.jpt.jpa.ui.jpa2.details.JptJpaUiDetailsMessages2_0;
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.internal.AbstractSwtBotEditorTest;
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.utils.Utils;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.HasReferanceRelation.HasReferenceType;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IRelation;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(SWTBotJunit4ClassRunner.class)
+@SuppressWarnings("restriction")
+public class EmbeddableRelationshipsSWTBotTest extends AbstractSwtBotEditorTest {
+
+ protected static String TEST_PROJECT = "Test_" + System.currentTimeMillis();
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ createJPa20Project(TEST_PROJECT);
+ }
+
+ /**
+ * Test no one-to-one unidirectional relationship from entity to embeddable
+ * is created.
+ */
+ @Test
+ public void testOneToOneUniDirRelationFromEntityToEmbeddable() {
+ Utils.sayTestStarted("testOneToOneUniDirRelationFromEntityToEmbeddable");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
+ 2, entity, embeddable);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testOneToOneUniDirRelationFromEntityToEmbeddable");
+ }
+
+ /**
+ * Test no one-to-one bidirectional relationship from entity to embeddable
+ * is created.
+ */
+ @Test
+ public void testOneToOneBiDirRelationFromEntityToEmbeddable() {
+ Utils.sayTestStarted("testOneToOneBiDirRelationFromEntityToEmbeddable");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
+ 3, entity, embeddable);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testOneToOneBiDirRelationFromEntityToEmbeddable");
+ }
+
+ /**
+ * Test no one-to-many unidirectional relationship from entity to embeddable
+ * is created.
+ */
+ @Test
+ public void testOneToManyUniDirRelationFromEntityToEmbeddable() {
+ Utils.sayTestStarted("testOneToManyUniDirRelationFromEntityToEmbeddable");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateOneToManyUniDirRelationFeature_oneToManyUniDirFeatureName,
+ 0, entity, embeddable);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testOneToManyUniDirRelationFromEntityToEmbeddable");
+ }
+
+ /**
+ * Test no many-to-one unidirectional relationship from entity to embeddable
+ * is created.
+ */
+ @Test
+ public void testManyToOneUniDirRelationFromEntityToEmbeddable() {
+ Utils.sayTestStarted("testManyToOneUniDirRelationFromEntityToEmbeddable");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
+ 2, entity, embeddable);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testManyToOneUniDirRelationFromEntityToEmbeddable");
+ }
+
+ /**
+ * Test no many-to-one bidirectional relationship from entity to embeddable
+ * is created.
+ */
+ @Test
+ public void testManyToOneBiDirRelationFromEntityToEmbeddable() {
+ Utils.sayTestStarted("testManyToOneBiDirRelationFromEntityToEmbeddable");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
+ 3, entity, embeddable);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testManyToOneBiDirRelationFromEntityToEmbeddable");
+ }
+
+ /**
+ * Test no many-to-many unidirectional relationship from entity to
+ * embeddable is created.
+ */
+ @Test
+ public void testManyToManyUniDirRelationFromEntityToEmbeddable() {
+ Utils.sayTestStarted("testManyToManyUniDirRelationFromEntityToEmbeddable");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateManyToManyUniDirRelationFeature_manyToManyUniDirFeatureName,
+ 0, entity, embeddable);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testManyToManyUniDirRelationFromEntityToEmbeddable");
+ }
+
+ /**
+ * Test no many-to-many bidirectional relationship from entity to embeddable
+ * is created.
+ */
+ @Test
+ public void testManyToManyBiDirRelationFromEntityToEmbeddable() {
+ Utils.sayTestStarted("testManyToManyBiDirRelationFromEntityToEmbeddable");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName,
+ 1, entity, embeddable);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testManyToManyBiDirRelationFromEntityToEmbeddable");
+ }
+
+ /**
+ * Test that if the embeddable is not embedded, no one-to-one bidirectional
+ * relationship will be created from the embeddable to the entity. Add
+ * second entity and embed a single value of the embeddable. Check that a
+ * one-to-one relationship will be created from embeddable to the entity.
+ * Check that if the inverse attribute will be deleted the connection will
+ * be transformed into one-to-one unidirectional relationship. Test that if
+ * the owner attribute will be deleted, the relationship will disappear.
+ */
+ @Test
+ public void testOneToOneBiDirRelationFromEmbeddableToEntity() {
+ Utils.sayTestStarted("testOneToOneBiDirRelationFromEmbeddableToEntity");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
+ 3, embeddable, entity);
+
+ SWTBotGefEditPart embeddingEntity = editorProxy.addEntityToDiagram(200,
+ 50, jpaProject);
+
+ editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity, embeddable,
+ HasReferenceType.SINGLE,
+ MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
+ JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
+
+ editorProxy
+ .testBiDirRel(
+ JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
+ embeddable,
+ entity,
+ IRelation.RelType.ONE_TO_ONE,
+ MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, true, false);
+
+ editorProxy
+ .testBiDirRelRemoveInverseAttribute(
+ JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
+ embeddable,
+ entity,
+ IRelation.RelType.ONE_TO_ONE,
+ MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, true, false);
+
+ editorProxy
+ .testBiDirRelRemoveOwnerAttr(
+ JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
+ embeddable,
+ entity,
+ IRelation.RelType.ONE_TO_ONE,
+ MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, true, false);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testOneToOneBiDirRelationFromEmbeddableToEntity");
+ }
+
+ /**
+ * Test that if the embeddable is not embedded, no many-to-one bidirectional
+ * relationship will be created from the embeddable to the entity. Add
+ * second entity and embed a single value of the embeddable. Check that a
+ * many-to-one relationship will be created from embeddable to the entity.
+ * Check that if the inverse attribute will be deleted the connection will
+ * be transformed into one-to-one unidirectional relationship. Test that if
+ * the owner attribute will be deleted, the relationship will disappear.
+ */
+ @Test
+ public void testManyToOneBiDirRelationFromEmbeddableToEntity() {
+ Utils.sayTestStarted("testManyToOneBiDirRelationFromEmbeddableToEntity");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
+ 3, embeddable, entity);
+
+ SWTBotGefEditPart embeddingEntity = editorProxy.addEntityToDiagram(200,
+ 50, jpaProject);
+
+ editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity, embeddable,
+ HasReferenceType.SINGLE,
+ MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
+ JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
+
+ editorProxy
+ .testBiDirRelWithTwoMappingTypes(
+ JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
+ embeddable,
+ entity,
+ IRelation.RelType.MANY_TO_ONE,
+ MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY,
+ MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, true, false);
+
+ editorProxy
+ .testBiDirRelWithTwoMappingsWithoutInverseAttr(
+ JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
+ embeddable,
+ entity,
+ IRelation.RelType.MANY_TO_ONE,
+ MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY,
+ MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, true, false);
+
+ editorProxy
+ .testBiDirRelWithTwoMappingsWithoutOwnerAttr(
+ JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
+ embeddable,
+ entity,
+ IRelation.RelType.MANY_TO_ONE,
+ MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY,
+ MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, true, false);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testManyToOneBiDirRelationFromEmbeddableToEntity");
+ }
+
+ /**
+ * Test that if the embeddable is not embedded, no many-to-many
+ * bidirectional relationship will be created from the embeddable to the
+ * entity. Add second entity and embed a single value of the embeddable.
+ * Check that a many-to-many relationship will be created from embeddable to
+ * the entity. Check that if the inverse attribute will be deleted the
+ * connection will be transformed into one-to-one unidirectional
+ * relationship. Test that if the owner attribute will be deleted, the
+ * relationship will disappear.
+ */
+ @Test
+ public void testManyToManyBiDirRelationFromEmbeddableToEntity() {
+ Utils.sayTestStarted("testManyToManyBiDirRelationFromEmbeddableToEntity");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName,
+ 1, embeddable, entity);
+
+ SWTBotGefEditPart embeddingEntity = editorProxy.addEntityToDiagram(200,
+ 50, jpaProject);
+
+ editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity, embeddable,
+ HasReferenceType.SINGLE,
+ MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
+ JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
+
+ editorProxy
+ .testBiDirRel(
+ JPAEditorMessages.CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName,
+ embeddable,
+ entity,
+ IRelation.RelType.MANY_TO_MANY,
+ MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, false, false);
+
+ editorProxy
+ .testBiDirRelRemoveInverseAttribute(
+ JPAEditorMessages.CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName,
+ embeddable,
+ entity,
+ IRelation.RelType.MANY_TO_MANY,
+ MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, false, false);
+
+ editorProxy
+ .testBiDirRelRemoveOwnerAttr(
+ JPAEditorMessages.CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName,
+ embeddable,
+ entity,
+ IRelation.RelType.MANY_TO_MANY,
+ MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, false, false);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testManyToManyBiDirRelationFromEmbeddableToEntity");
+ }
+
+ /**
+ * Test that if the embeddable is not embedded, no one-to-one unidirectional
+ * relationship will be created from the embeddable to the entity. Add
+ * second entity and embed a single value of the embeddable. Check that a
+ * one-to-one relationship will be created from embeddable to the entity.
+ * Check that if the owner attribute will be deleted, the relationship will
+ * disappear.
+ */
+ @Test
+ public void testOneToOneUniDirRelationFromEmbeddableToEntity() {
+ Utils.sayTestStarted("testOneToOneUniDirRelationFromEmbeddableToEntity");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
+ 2, embeddable, entity);
+
+ SWTBotGefEditPart embeddingEntity = editorProxy.addEntityToDiagram(200,
+ 50, jpaProject);
+
+ editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity, embeddable,
+ HasReferenceType.SINGLE,
+ MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
+ JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
+
+ editorProxy
+ .testUniDirRelation(
+ JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
+ embeddable,
+ entity,
+ IRelation.RelType.ONE_TO_ONE,
+ MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, true, false);
+
+ editorProxy
+ .testUniDirRelRemoveOwnerAttribute(
+ JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
+ embeddable,
+ entity,
+ IRelation.RelType.ONE_TO_ONE,
+ MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, true, false);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testOneToOneUniDirRelationFromEmbeddableToEntity");
+ }
+
+ /**
+ * Test that if the embeddable is not embedded, no many-to-one
+ * unidirectional relationship will be created from the embeddable to the
+ * entity. Add second entity and embed a single value of the embeddable.
+ * Check that a many-to-one relationship will be created from embeddable to
+ * the entity. Check that if the owner attribute will be deleted, the
+ * relationship will disappear.
+ */
+ @Test
+ public void testManyToOneUniDirRelationFromEmbeddableToEntity() {
+ Utils.sayTestStarted("testManyToOneUniDirRelationFromEmbeddableToEntity");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
+ 2, embeddable, entity);
+
+ SWTBotGefEditPart embeddingEntity = editorProxy.addEntityToDiagram(200,
+ 50, jpaProject);
+
+ editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity, embeddable,
+ HasReferenceType.SINGLE,
+ MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
+ JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
+
+ editorProxy
+ .testUniDirRelation(
+ JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
+ embeddable,
+ entity,
+ IRelation.RelType.MANY_TO_ONE,
+ MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, true, false);
+
+ editorProxy
+ .testUniDirRelRemoveOwnerAttribute(
+ JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
+ embeddable,
+ entity,
+ IRelation.RelType.MANY_TO_ONE,
+ MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, true, false);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testManyToOneUniDirRelationFromEmbeddableToEntity");
+ }
+
+ /**
+ * Test that if the embeddable is not embedded, no many-to-many
+ * unidirectional relationship will be created from the embeddable to the
+ * entity. Add second entity and embed a single value of the embeddable.
+ * Check that a many-to-many relationship will be created from embeddable to
+ * the entity. Check that if the owner attribute will be deleted, the
+ * relationship will disappear.
+ */
+ @Test
+ public void testManyToManyUniDirRelationFromEmbeddableToEntity() {
+ Utils.sayTestStarted("testManyToManyUniDirRelationFromEmbeddableToEntity");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateManyToManyUniDirRelationFeature_manyToManyUniDirFeatureName,
+ 0, embeddable, entity);
+
+ SWTBotGefEditPart embeddingEntity = editorProxy.addEntityToDiagram(200,
+ 50, jpaProject);
+
+ editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity, embeddable,
+ HasReferenceType.SINGLE,
+ MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
+ JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
+
+ editorProxy
+ .testUniDirRelation(
+ JPAEditorMessages.CreateManyToManyUniDirRelationFeature_manyToManyUniDirFeatureName,
+ embeddable,
+ entity,
+ IRelation.RelType.MANY_TO_MANY,
+ MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, false, false);
+
+ editorProxy
+ .testUniDirRelRemoveOwnerAttribute(
+ JPAEditorMessages.CreateManyToManyUniDirRelationFeature_manyToManyUniDirFeatureName,
+ embeddable,
+ entity,
+ IRelation.RelType.MANY_TO_MANY,
+ MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, false, false);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testManyToManyUniDirRelationFromEmbeddableToEntity");
+ }
+
+ /**
+ * Test that if the embeddable is not embedded, no one-to-one bidirectional
+ * relationship will be created from the embeddable to the entity. Add
+ * second entity and embed a collection of the embeddable. Check that a
+ * one-to-one relationship will be created from embeddable to the entity.
+ * Check that if the owner attribute will be deleted, the relationship will
+ * disappear.
+ */
+ @Test
+ public void testOneToOneBiDirRelationFromEmbeddedCollectionToEntity() {
+ Utils.sayTestStarted("testOneToOneBiDirRelationFromEmbeddableToEntity");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
+ 3, embeddable, entity);
+
+ SWTBotGefEditPart embeddingEntity = editorProxy.addEntityToDiagram(200,
+ 50, jpaProject);
+
+ editorProxy.embedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddingEntity,
+ embeddable, HasReferenceType.COLLECTION,
+ MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
+ JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
+ 3);
+
+ editorProxy
+ .testBiDirRel(
+ JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
+ embeddable,
+ entity,
+ IRelation.RelType.ONE_TO_ONE,
+ MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, true, false);
+
+ editorProxy
+ .testBiDirRelRemoveInverseAttribute(
+ JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
+ embeddable,
+ entity,
+ IRelation.RelType.ONE_TO_ONE,
+ MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, true, false);
+
+ editorProxy
+ .testBiDirRelRemoveOwnerAttr(
+ JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
+ embeddable,
+ entity,
+ IRelation.RelType.ONE_TO_ONE,
+ MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, true, false);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testOneToOneBiDirRelationFromEmbeddableToEntity");
+ }
+
+ /**
+ * Test that if the embeddable is not embedded, no many-to-one bidirectional
+ * relationship will be created from the embeddable to the entity. Add
+ * second entity and embed a collection of the embeddable. Check that a
+ * many-to-one relationship will be created from embeddable to the entity.
+ * Check that if the owner attribute will be deleted, the relationship will
+ * disappear.
+ */
+
+ @Test
+ public void testManyToOneBiDirRelationFromEmbeddedCollectionToEntity() {
+ Utils.sayTestStarted("testManyToOneBiDirRelationFromEmbeddableToEntity");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
+ 3, embeddable, entity);
+
+ SWTBotGefEditPart embeddingEntity = editorProxy.addEntityToDiagram(200,
+ 50, jpaProject);
+
+ editorProxy.embedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddingEntity,
+ embeddable, HasReferenceType.COLLECTION,
+ MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
+ JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
+ 3);
+
+ editorProxy
+ .testBiDirRelWithTwoMappingTypes(
+ JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
+ embeddable,
+ entity,
+ IRelation.RelType.MANY_TO_ONE,
+ MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY,
+ MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, true, false);
+
+ editorProxy
+ .testBiDirRelWithTwoMappingsWithoutInverseAttr(
+ JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
+ embeddable,
+ entity,
+ IRelation.RelType.MANY_TO_ONE,
+ MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY,
+ MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, true, false);
+
+ editorProxy
+ .testBiDirRelWithTwoMappingsWithoutOwnerAttr(
+ JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
+ embeddable,
+ entity,
+ IRelation.RelType.MANY_TO_ONE,
+ MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY,
+ MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, true, false);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testManyToOneBiDirRelationFromEmbeddableToEntity");
+ }
+
+ /**
+ * Test that no one-to-one bidirectional relationship will be created, if
+ * the embeddable is embedded in two entities.
+ */
+ @Test
+ public void testNoOneToOneBiDirConnectionIsCreatedInEmbeddableInTwoEntities() {
+ Utils.sayTestStarted("testNoOneToOneBiDirConnectionIsCreatedInEmbeddableInTwoEntities");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+
+ SWTBotGefEditPart embeddingEntity1 = editorProxy.addEntityToDiagram(
+ 200, 50, jpaProject);
+
+ SWTBotGefEditPart embeddingEntity2 = editorProxy.addEntityToDiagram(
+ 200, 200, jpaProject);
+
+ editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity1, embeddable,
+ HasReferenceType.SINGLE,
+ MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
+ JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
+
+ editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity2, embeddable,
+ HasReferenceType.SINGLE,
+ MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
+ JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
+
+ editorProxy
+ .testNoConnectionIsCreatedWithEmbeddable(
+ JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
+ 1, entity, embeddable);
+
+ editorProxy
+ .testUniDirRelation(
+ JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
+ embeddable,
+ entity,
+ IRelation.RelType.ONE_TO_ONE,
+ MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, true, false);
+
+ editorProxy
+ .testUniDirRelRemoveOwnerAttribute(
+ JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
+ embeddable,
+ entity,
+ IRelation.RelType.ONE_TO_ONE,
+ MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, true, false);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testNoOneToOneBiDirConnectionIsCreatedInEmbeddableInTwoEntities");
+ }
+
+ /**
+ * Test that no many-to-one bidirectional relationship will be created, if
+ * the embeddable is embedded in two entities.
+ */
+ @Test
+ public void testNoManyToOneBiDirConnectionIsCreatedInEmbeddableInTwoEntities() {
+ Utils.sayTestStarted("testNoBiDirConnectionIsCreatedInEmbeddableInTwoEntities");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+
+ SWTBotGefEditPart embeddingEntity1 = editorProxy.addEntityToDiagram(
+ 200, 50, jpaProject);
+
+ SWTBotGefEditPart embeddingEntity2 = editorProxy.addEntityToDiagram(
+ 200, 200, jpaProject);
+
+ editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity1, embeddable,
+ HasReferenceType.SINGLE,
+ MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
+ JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
+
+ editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity2, embeddable,
+ HasReferenceType.SINGLE,
+ MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
+ JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
+
+ editorProxy
+ .testNoConnectionIsCreatedWithEmbeddable(
+ JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
+ 1, entity, embeddable);
+
+ editorProxy
+ .testUniDirRelation(
+ JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
+ embeddable,
+ entity,
+ IRelation.RelType.MANY_TO_ONE,
+ MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, true, false);
+
+ editorProxy
+ .testUniDirRelRemoveOwnerAttribute(
+ JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
+ embeddable,
+ entity,
+ IRelation.RelType.MANY_TO_ONE,
+ MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, true, false);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testNoBiDirConnectionIsCreatedInEmbeddableInTwoEntities");
+ }
+
+ /**
+ * Test that no many-to-many bidirectional relationship will be created, if
+ * the embeddable is embedded in two entities.
+ */
+ @Test
+ public void testNoManyToManyBiDirConnectionIsCreatedInEmbeddableInTwoEntities() {
+ Utils.sayTestStarted("testNoManyToManyBiDirConnectionIsCreatedInEmbeddableInTwoEntities");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+
+ SWTBotGefEditPart embeddingEntity1 = editorProxy.addEntityToDiagram(
+ 200, 50, jpaProject);
+
+ SWTBotGefEditPart embeddingEntity2 = editorProxy.addEntityToDiagram(
+ 200, 200, jpaProject);
+
+ editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity1, embeddable,
+ HasReferenceType.SINGLE,
+ MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
+ JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
+
+ editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity2, embeddable,
+ HasReferenceType.SINGLE,
+ MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
+ JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
+
+ editorProxy
+ .testNoConnectionIsCreatedWithEmbeddable(
+ JPAEditorMessages.CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName,
+ 1, entity, embeddable);
+
+ editorProxy
+ .testUniDirRelation(
+ JPAEditorMessages.CreateManyToManyUniDirRelationFeature_manyToManyUniDirFeatureName,
+ embeddable,
+ entity,
+ IRelation.RelType.MANY_TO_MANY,
+ MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, false, false);
+
+ editorProxy
+ .testUniDirRelRemoveOwnerAttribute(
+ JPAEditorMessages.CreateManyToManyUniDirRelationFeature_manyToManyUniDirFeatureName,
+ embeddable,
+ entity,
+ IRelation.RelType.MANY_TO_MANY,
+ MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, false, false);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testNoManyToManyBiDirConnectionIsCreatedInEmbeddableInTwoEntities");
+ }
+
+ /**
+ * Test that if the embeddable is not embedded, no one-to-one unidirectional
+ * relationship will be created from the embeddable to the entity. Add
+ * second entity and embed a collection of the embeddable. Check that a
+ * one-to-one relationship will be created from embeddable to the entity.
+ * Check that if the owner attribute will be deleted, the relationship will
+ * disappear.
+ */
+ @Test
+ public void testOneToOneUniDirRelationFromEmbeddedCollectionToEntity() {
+ Utils.sayTestStarted("testOneToOneUniDirRelationFromEmbeddedCollectionToEntity");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
+ 2, embeddable, entity);
+
+ SWTBotGefEditPart embeddingEntity = editorProxy.addEntityToDiagram(200,
+ 50, jpaProject);
+
+ editorProxy.embedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddingEntity,
+ embeddable, HasReferenceType.COLLECTION,
+ MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
+ JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
+ 3);
+
+ editorProxy
+ .testUniDirRelation(
+ JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
+ embeddable,
+ entity,
+ IRelation.RelType.ONE_TO_ONE,
+ MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, true, false);
+
+ editorProxy
+ .testUniDirRelRemoveOwnerAttribute(
+ JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
+ embeddable,
+ entity,
+ IRelation.RelType.ONE_TO_ONE,
+ MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, true, false);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testOneToOneUniDirRelationFromEmbeddedCollectionToEntity");
+ }
+
+ /**
+ * Test that if the embeddable is not embedded, no many-to-one
+ * unidirectional relationship will be created from the embeddable to the
+ * entity. Add second entity and embed a collection of the embeddable. Check
+ * that a many-to-one relationship will be created from embeddable to the
+ * entity. Check that if the owner attribute will be deleted, the
+ * relationship will disappear.
+ */
+ @Test
+ public void testManyToOneUniDirRelationFromEmbeddedCollectionToEntity() {
+ Utils.sayTestStarted("testManyToOneUniDirRelationFromEmbeddedCollectionToEntity");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
+ 2, embeddable, entity);
+
+ SWTBotGefEditPart embeddingEntity = editorProxy.addEntityToDiagram(200,
+ 50, jpaProject);
+
+ editorProxy.embedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddingEntity,
+ embeddable, HasReferenceType.COLLECTION,
+ MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
+ JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
+ 3);
+
+ editorProxy
+ .testUniDirRelation(
+ JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
+ embeddable,
+ entity,
+ IRelation.RelType.MANY_TO_ONE,
+ MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, true, false);
+
+ editorProxy
+ .testUniDirRelRemoveOwnerAttribute(
+ JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
+ embeddable,
+ entity,
+ IRelation.RelType.MANY_TO_ONE,
+ MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, true, false);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testManyToOneUniDirRelationFromEmbeddedCollectionToEntity");
+ }
+
+ /**
+ * Test that if a collection of embeddable is embedded into an entity,
+ * neither uni- nor bi-directional many-to-many relationships will be
+ * created.
+ */
+ @Test
+ public void testManyToManyRelationFromEmbeddedCollectionToEntity() {
+ Utils.sayTestStarted("testManyToManyRelationFromEmbeddedCollectionToEntity");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateManyToManyUniDirRelationFeature_manyToManyUniDirFeatureName,
+ 0, embeddable, entity);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName,
+ 1, embeddable, entity);
+
+ SWTBotGefEditPart embeddingEntity = editorProxy.addEntityToDiagram(200,
+ 50, jpaProject);
+
+ editorProxy.embedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddingEntity,
+ embeddable, HasReferenceType.COLLECTION,
+ MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
+ JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
+ 3);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName,
+ 0, embeddable, entity);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName,
+ 1, embeddable, entity);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testManyToManyRelationFromEmbeddedCollectionToEntity");
+ }
+
+ /**
+ * Test that if a collection of embeddable is embedded into an entity, no
+ * one-to-many unidirectional relationships will be created.
+ */
+ @Test
+ public void testOneToManyRelationFromEmbeddedCollectionToEntity() {
+ Utils.sayTestStarted("testOneToManyRelationFromEmbeddedCollectionToEntity");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+ SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateOneToManyUniDirRelationFeature_oneToManyUniDirFeatureName,
+ 0, embeddable, entity);
+
+ SWTBotGefEditPart embeddingEntity = editorProxy.addEntityToDiagram(200,
+ 50, jpaProject);
+
+ editorProxy.embedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddingEntity,
+ embeddable, HasReferenceType.COLLECTION,
+ MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
+ JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
+ 3);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateOneToManyUniDirRelationFeature_oneToManyUniDirFeatureName,
+ 0, embeddable, entity);
+
+ editorProxy.deleteDiagramElements(false);
+// jpaDiagramEditor.saveAndClose();
+
+ Utils.sayTestFinished("testOneToManyRelationFromEmbeddedCollectionToEntity");
+ }
+}
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/emebeddable10/EmbeddableInJPAProject10SWTBotTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/emebeddable10/EmbeddableInJPAProject10SWTBotTest.java
new file mode 100644
index 0000000..88714e7
--- /dev/null
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/emebeddable10/EmbeddableInJPAProject10SWTBotTest.java
@@ -0,0 +1,109 @@
+package org.eclipse.jpt.jpadiagrameditor.swtbot.tests.emebeddable10;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jpt.jpa.core.MappingKeys;
+import org.eclipse.jpt.jpa.ui.details.JptJpaUiDetailsMessages;
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.internal.AbstractSwtBotEditorTest;
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.utils.Utils;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.HasReferanceRelation.HasReferenceType;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(SWTBotJunit4ClassRunner.class)
+@SuppressWarnings("restriction")
+public class EmbeddableInJPAProject10SWTBotTest extends AbstractSwtBotEditorTest{
+ protected static String TEST_PROJECT = "Test10_" + System.currentTimeMillis();
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ createJPa10Project(TEST_PROJECT);
+ }
+
+ @Test
+ public void testJPA10WithEmbeddables() throws CoreException {
+ Utils.sayTestStarted("testJPA10WithEmbeddables");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart embeddable1 = editorProxy.addEmbeddableToDiagram(50,
+ 50, jpaProject);
+ SWTBotGefEditPart embeddable2 = editorProxy.addEmbeddableToDiagram(50,
+ 200, jpaProject);
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(300, 50,
+ jpaProject);
+
+ boolean notAllowed = false;
+
+ try {
+ jpaDiagramEditor.activateTool(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName);
+ } catch (WidgetNotFoundException e) {
+ notAllowed = true;
+ }
+
+ assertTrue(
+ "The action \"Embed Collection of Elements\" must not be available by JPA projects with 1.0 facet.",
+ notAllowed);
+
+ editorProxy.testNoEmbeddedConnectionIsCreated(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, 0, embeddable1, embeddable2, false);
+
+ editorProxy.embedConnection(jpaDiagramEditor, JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, entity, embeddable1,
+ HasReferenceType.SINGLE,
+ MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
+ JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 2);
+
+ SWTBotGefEditPart entity1 = editorProxy.addEntityToDiagram(300, 300,
+ jpaProject);
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateOneToManyUniDirRelationFeature_oneToManyUniDirFeatureName,
+ 0, embeddable1, entity1);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
+ 0, embeddable1, entity1);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
+ 1, embeddable1, entity1);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
+ 0, embeddable1, entity1);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
+ 1, embeddable1, entity1);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateManyToManyUniDirRelationFeature_manyToManyUniDirFeatureName,
+ 0, embeddable1, entity1);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName,
+ 1, embeddable1, entity1);
+
+ String embeddableName = editorProxy.getJPTObjectForGefElement(embeddable1).getSimpleName();
+ String embeddingAttributeName = JPAEditorUtil.decapitalizeFirstLetter(embeddableName);
+ editorProxy.deleteAttributeInJPT(entity, embeddingAttributeName);
+
+ editorProxy.deleteDiagramElements(false);
+
+// jpaDiagramEditor.saveAndClose();
+
+ Utils.sayTestFinished("testJPA10WithEmbeddables");
+
+ }
+}
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/entity/EntitiesInDiagramSWTBotTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/entity/EntitiesInDiagramSWTBotTest.java
new file mode 100644
index 0000000..f8b1257
--- /dev/null
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/entity/EntitiesInDiagramSWTBotTest.java
@@ -0,0 +1,1018 @@
+package org.eclipse.jpt.jpadiagrameditor.swtbot.tests.entity;
+
+import java.util.List;
+
+import org.eclipse.graphiti.features.IFeatureProvider;
+import org.eclipse.graphiti.mm.pictograms.PictogramElement;
+import org.eclipse.graphiti.ui.internal.parts.DiagramEditPart;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.conditions.ElementAppearsInDiagram;
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.conditions.ElementIsShown;
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.internal.AbstractSwtBotEditorTest;
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.utils.Utils;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotStyledText;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(SWTBotJunit4ClassRunner.class)
+@SuppressWarnings("restriction")
+public class EntitiesInDiagramSWTBotTest extends AbstractSwtBotEditorTest {
+
+ protected static String TEST_PROJECT = "Test_" + System.currentTimeMillis();
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ createJPa20Project(TEST_PROJECT);
+ }
+
+ /**
+ * Add entity to diagram and check that it contains a "Primary Key" section
+ * with one attribute "id" and no "Relation Attributes" and
+ * "Other Attributes" sections.
+ */
+ @Test
+ public void testAddEntity() {
+ Utils.sayTestStarted("testAddEntity");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ editorProxy.addEntityToDiagram(50, 50, jpaProject);
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ jpaDiagramEditor.save();
+ assertFalse("Editor must not be dirty!", jpaDiagramEditor.isDirty());
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testAddEntity");
+ }
+
+ /**
+ * Remove an entity from the diagram using the entity's context button
+ * "Delete"
+ */
+ @Test
+ public void testRemoveEntityViaButton() {
+ Utils.sayTestStarted("testRemoveEntityViaButton");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
+ jpaProject);
+
+ editorProxy.deleteJPTViaButton(entity, true);
+
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testRemoveEntityViaButton");
+ }
+
+ /**
+ * Remove an entity from the diagram using the entity's context menu
+ * "Delete"
+ */
+ @Test
+ public void testRemoveEntityViaContextMenu() {
+ Utils.sayTestStarted("testRemoveEntityViaContextMenu");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
+ jpaProject);
+
+ editorProxy.deleteJPTViaMenu(entity);
+
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testRemoveEntityViaContextMenu");
+ }
+
+ @Test
+ public void testAddElementCollectionAttribute() {
+ Utils.sayTestStarted("testAddElementCollectionAttribute");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
+ jpaProject);
+
+ assertFalse(
+ "\"Other Attributes\" section must not be visible!",
+ editorProxy
+ .isSectionVisible(
+ JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
+ entity));
+
+ String attributeName = editorProxy.getUniqueAttrName(entity);
+ SWTBotGefEditPart attribute = editorProxy.addElementCollectionAttributeToJPT(entity, attributeName);
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+ editorProxy.removeAttributeViaButton(entity, attribute, attributeName, false);
+
+ entity.click();
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testAddElementCollectionAttribute");
+ }
+
+ /**
+ * Removes the attribute using the "Delete Attribute" context button.
+ */
+ @Test
+ public void testRemoveAttributeViaContextButton() {
+ Utils.sayTestStarted("testRemoveAttributeViaContextButton");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
+ jpaProject);
+
+ String attributeName = editorProxy.getUniqueAttrName(entity);
+ SWTBotGefEditPart attribute = editorProxy.addAttributeToJPT(entity, attributeName, false);
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ editorProxy.removeAttributeViaButton(entity, attribute, attributeName, false);
+
+ entity.click();
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testRemoveAttributeViaContextButton");
+ }
+
+ /**
+ * Removes the attribute using the "Delete" context menu.
+ */
+ @Test
+ public void testRemoveAttributeViaMenu() {
+ Utils.sayTestStarted("testRemoveAttributeViaMenu");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
+ jpaProject);
+
+ String attributeName = editorProxy.getUniqueAttrName(entity);
+ SWTBotGefEditPart attribute = editorProxy.addAttributeToJPT(entity, attributeName, false);
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ editorProxy.removeAttributeViaMenu(entity, attribute, attributeName);
+
+ entity.click();
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testRemoveAttributeViaMenu");
+ }
+
+ /**
+ * Adds a new attribute and rename it
+ */
+ @Test
+ public void testDirectEditingAttribute() {
+ Utils.sayTestStarted("testDirectEditingAttribute");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
+ jpaProject);
+
+ String attributeName = editorProxy.getUniqueAttrName(entity);
+ editorProxy.directEditAttribute(entity, attributeName);
+
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testDirectEditingAttribute");
+ }
+
+ /**
+ * Adds a new entity and rename it
+ */
+ @Ignore
+ @Test
+ public void testDirectEditingEntity() {
+ Utils.sayTestStarted("testDirectEditingEntity");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
+ jpaProject);
+
+ String oldEntityName = editorProxy.getJPTObjectForGefElement(entity).getSimpleName();
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ editorProxy.moveMouse(100, 70);
+ entity.click();
+ entity.activateDirectEdit();
+ jpaDiagramEditor.directEditType("NewEntityName");
+ editorProxy.moveMouse(0, 0);
+
+ SWTBotGefEditPart oldEntity = jpaDiagramEditor.getEditPart(oldEntityName);
+ SWTBotGefEditPart newEntity = jpaDiagramEditor
+ .getEditPart("NewEntityName");
+ assertNotNull("The entity must be renamed!", newEntity);
+ assertNull("The attribute must be renamed!", oldEntity);
+
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testDirectEditingEntity");
+ }
+
+ /**
+ * Test that the source of the entity is opened, when is double clicked on
+ * it
+ */
+ @Ignore
+ @Test
+ public void testDoubleClickOnEntity() {
+ Utils.sayTestStarted("testDoubleClickOnEntity");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
+ jpaProject);
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+ editorProxy.moveMouse(100, 70);
+ jpaDiagramEditor.doubleClick(entity);
+ editorProxy.moveMouse(0, 0);
+
+ SWTBotEditor activeEditor = workbenchBot.activeEditor();
+ assertEquals("The Java editor of the enity did not open!",
+ "Entity1.java", activeEditor.getTitle());
+ activeEditor.close();
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testDoubleClickOnEntity");
+ }
+
+ /**
+ * Change the attribute type.
+ */
+ @Test
+ public void testChangeAttributeType() {
+ Utils.sayTestStarted("testChangeAttributeType");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
+ jpaProject);
+
+ assertFalse(
+ "\"Other Attributes\" section must not be visible!",
+ editorProxy
+ .isSectionVisible(
+ JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
+ entity));
+
+ String attributeName = editorProxy.getUniqueAttrName(entity);
+ SWTBotGefEditPart attribute = editorProxy.addAttributeToJPT(entity,
+ attributeName, false);
+ assertNotNull("The attribute must not be renamed!", attribute);
+
+ final IFeatureProvider fp = ((DiagramEditPart) jpaDiagramEditor
+ .mainEditPart().part()).getFeatureProvider();
+
+ String currentAttributeType = editorProxy.getAttributeType(
+ attributeName, fp);
+ assertEquals("java.lang.String", currentAttributeType);
+
+ SWTBotShell changeTypeDialog = editorProxy
+ .getSelectNewAttributeTypeDialog(attribute);
+ SWTBotText attributeType = editorProxy
+ .getNewTypeInputField(changeTypeDialog);
+
+ // test invalid attribute type
+ attributeType.setText("");
+ assertFalse(editorProxy.getOkButton(changeTypeDialog).isEnabled());
+ assertTrue(editorProxy.getCancelButton(changeTypeDialog).isEnabled());
+ SWTBotText dialogError = editorProxy
+ .getDialogErroMessage(changeTypeDialog);
+ assertEquals(" The new type name must not be empty",
+ dialogError.getText());
+ // cancel the dialog
+ editorProxy.getCancelButton(changeTypeDialog).click();
+
+ // assert that the attribute type is not changed
+ currentAttributeType = editorProxy.getAttributeType(attributeName, fp);
+ assertEquals("The attribute type must not be changed!",
+ "java.lang.String", currentAttributeType);
+
+ changeTypeDialog = editorProxy
+ .getSelectNewAttributeTypeDialog(attribute);
+ attributeType = editorProxy.getNewTypeInputField(changeTypeDialog);
+
+ // change the attribute type to int
+ attributeType.setText("int");
+ assertTrue(editorProxy.getOkButton(changeTypeDialog).isEnabled());
+ assertTrue(editorProxy.getCancelButton(changeTypeDialog).isEnabled());
+ // confirm the dialog
+ editorProxy.getOkButton(changeTypeDialog).click();
+ editorProxy.waitASecond();
+ // assert that the attribute's type is changed
+ String newAttributeType = editorProxy
+ .getAttributeType(attributeName, fp);
+ assertFalse("The attribute type must be changed!",
+ ("java.lang.String").equals(newAttributeType));
+ assertEquals("The attribute type must be changed!", "int",
+ newAttributeType);
+
+ assertTrue("Editor must be dirty!", jpaDiagramEditor.isDirty());
+ entity.click();
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testChangeAttributeType");
+ }
+
+ /**
+ * Rename the entity using its context menu
+ * "Refactor Entity Class -> Rename..."
+ */
+ @Ignore
+ @Test
+ public void testRenameEntityViaMenu() {
+ Utils.sayTestStarted("testRenameEntityViaMenu");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
+ jpaProject);
+ String oldEntityName = editorProxy.getJPTObjectForGefElement(entity).getSimpleName();
+
+ entity.click();
+ jpaDiagramEditor
+ .clickContextMenu(JPAEditorMessages.JPAEditorToolBehaviorProvider_renameEntityClass);
+
+ SWTBotShell renameEntityDialog = editorProxy.getRenameEntityDialog();
+ SWTBotText entityName = renameEntityDialog.bot().textWithLabel(
+ "New name:");
+
+ // test invalid entity name
+ entityName.setText("");
+ assertFalse(editorProxy.getFinishButton(renameEntityDialog).isEnabled());
+ assertTrue(editorProxy.getCancelButton(renameEntityDialog).isEnabled());
+
+ entityName.setText("NewEntityName");
+ assertTrue(editorProxy.getFinishButton(renameEntityDialog).isEnabled());
+ assertTrue(editorProxy.getCancelButton(renameEntityDialog).isEnabled());
+
+ editorProxy.getFinishButton(renameEntityDialog).click();
+ bot.waitUntil(new ElementIsShown(jpaDiagramEditor, "NewEntityName"),
+ 10000);
+
+ entity = jpaDiagramEditor.getEditPart("NewEntityName");
+ assertNotNull("Entity name must be changed!", entity);
+ assertNull("Entity naem must be changed!",
+ jpaDiagramEditor.getEditPart(oldEntityName));
+
+ entity.click();
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testRenameEntityViaMenu");
+ }
+
+ /**
+ * Move the entity class using the entity's context menu
+ * "Refactor Entity Class -> Move..."
+ */
+ @Ignore
+ @Test
+ public void testMoveEntityViaMenu() throws JavaModelException {
+ Utils.sayTestStarted("testMoveEntityViaMenu");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
+ jpaProject);
+ String entityName = editorProxy.getJPTObjectForGefElement(entity).getSimpleName();
+ JpaArtifactFactory factory = JpaArtifactFactory.instance();
+
+ String packageName = factory
+ .getMappedSuperclassPackageDeclaration(editorProxy
+ .getJPTObjectForGefElement(entity));
+
+ entity.click();
+ jpaDiagramEditor
+ .clickContextMenu(JPAEditorMessages.JPAEditorToolBehaviorProvider_moveEntityClass);
+
+ SWTBotShell moveEntityDialog = editorProxy.getMoveEntityDialog();
+ moveEntityDialog.bot().tree().getTreeItem(TEST_PROJECT).select()
+ .expandNode("src").expandNode("org").select().click();
+ assertTrue(editorProxy.getOkButton(moveEntityDialog).isEnabled());
+ editorProxy.getOkButton(moveEntityDialog).click();
+ editorProxy.waitASecond();
+
+ entity = jpaDiagramEditor.getEditPart(entityName);
+ String newEntityPackage = factory
+ .getMappedSuperclassPackageDeclaration(editorProxy
+ .getJPTObjectForGefElement(entity));
+ assertFalse("Entity must be moved!",
+ packageName.equals(newEntityPackage));
+ assertTrue("Entity must be changed!", newEntityPackage.equals("org"));
+
+ entity.click();
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testMoveEntityViaMenu");
+ }
+
+ /**
+ * Collapse/expand entity using its context buttons
+ */
+ @Test
+ public void testCollapseExapandEntityViaContextButton() {
+ Utils.sayTestStarted("testCollapseExapandEntityViaContextButton");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
+ jpaProject);
+
+ editorProxy.collapseExpandJPTViaButton(entity);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testCollapseExapandEntityViaContextButton");
+ }
+
+ /**
+ * Collapse/expand entity using its context menus
+ */
+ @Test
+ public void testCollapseExapandEntityViaMenu() {
+ Utils.sayTestStarted("testCollapseExapandEntityViaMenu");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
+ jpaProject);
+
+ editorProxy.collapseExpandJPTViaMenu(entity);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testCollapseExapandEntityViaMenu");
+ }
+
+ /**
+ * Collapse/expand all entities using the context menus
+ */
+ @Test
+ public void testCollapseExapandAllEntitiesViaMenu() {
+ Utils.sayTestStarted("testCollapseExapandAllEntitiesViaMenu");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity1 = editorProxy.addEntityToDiagram(50, 50,
+ jpaProject);
+ SWTBotGefEditPart entity2 = editorProxy.addEntityToDiagram(300, 50,
+ jpaProject);
+
+ editorProxy.collapseExpandAllJPTsViaMenu(entity1, entity2);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testCollapseExapandAllEntitiesViaMenu");
+ }
+
+ /**
+ * Add a new attribute without saving the entity and call the
+ * "Discard Changes" context menu. Assert that the newly added attribute is
+ * removed and the entity does not contain unsaved changes.
+ */
+ @Ignore
+ @Test
+ public void testDiscardChanges() {
+ Utils.sayTestStarted("testDiscardChanges");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
+ jpaProject);
+
+ String attributeName = editorProxy.getUniqueAttrName(entity);
+ editorProxy.discardChanges(entity, attributeName);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testDiscardChanges");
+ }
+
+ /**
+ * Add a new attribute without saving the entity and call the entity's
+ * context menu "Remove All Entities from Diagram -> ... and Discard
+ * Changes" context menu. Assert that the diagram is empty. Call "Show All
+ * Entities" context menu and assert that the newly added attribute is
+ * removed and the entity does not contain unsaved changes.
+ */
+ @Ignore
+ @Test
+ public void testRemoveAndDiscardChangesViaMenu() {
+ Utils.sayTestStarted("testRemoveAndDiscardChangesViaMenu");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
+ jpaProject);
+
+ String attributeName = editorProxy.getUniqueAttrName(entity);
+ editorProxy.removeAndDiscardChangesViaMenu(entity, attributeName);
+
+ entity.click();
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testRemoveAndDiscardChangesViaMenu");
+ }
+
+ /**
+ * Add a new attribute without saving the entity and call the entity's
+ * context menu "Remove All Entities from Diagram -> ... and Save
+ * Changes" context menu. Assert that the diagram is empty. Call "Show All
+ * Entities" context menu and assert that the newly added attribute is added
+ * and the entity does not contain unsaved changes.
+ */
+ @Test
+ public void testRemoveAndSaveChangesViaMenu() {
+ Utils.sayTestStarted("testRemoveAndSaveChangesViaMenu");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
+ jpaProject);
+
+ String attributeName = editorProxy.getUniqueAttrName(entity);
+ editorProxy.removeAndSaveChangesViaMenu(entity, attributeName);
+
+ entity.click();
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testRemoveAndSaveChangesViaMenu");
+ }
+
+ /**
+ * Add a new attribute to the entity. From the entity's context menu select
+ * "Save". Assert that the entity does not contain any unsaved changes, but
+ * the diagram editor is still dirty.
+ */
+ @Test
+ public void testSaveOnlyEntity() {
+ Utils.sayTestStarted("testSaveOnlyEntity");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
+ jpaProject);
+ String attributeName = editorProxy.getUniqueAttrName(entity);
+ editorProxy.saveOnlyJPT(entity, attributeName);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testSaveOnlyEntity");
+ }
+
+ /**
+ * Create a JPA project and one entity in it. Open the JPA diagram editor
+ * and call the "Show All Entities" context menu. Assert that the previously
+ * created entity is shown in the diagram.
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testShowAllEntities() throws Exception {
+ Utils.sayTestStarted("testShowAllEntities");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ factory.createEntity(jpaProject, "com.sap.test.Customer");
+ assertTrue(jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ jpaDiagramEditor
+ .clickContextMenu(JPAEditorMessages.JPAEditorToolBehaviorProvider_showAllTheEntities);
+
+ bot.waitUntil(new ElementAppearsInDiagram(jpaDiagramEditor), 20000);
+
+ List<SWTBotGefEditPart> entities = jpaDiagramEditor.mainEditPart()
+ .children();
+ assertFalse("Diagram editor must contain at least one entity!",
+ entities.isEmpty());
+
+ SWTBotGefEditPart entity = jpaDiagramEditor.getEditPart("Customer");
+ assertNotNull(entity);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testShowAllEntities");
+ }
+
+ /**
+ * Collapse/expand "Primary Key" section by double click on it
+ */
+ @Ignore
+ @Test
+ public void testCollapseExpandCompartmentByDoubleClick() {
+ Utils.sayTestStarted("testCollapseExpandCompartmentByDoubleClick");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ editorProxy.addEntityToDiagram(50, 50, jpaProject);
+
+ editorProxy.moveMouse(100, 100);
+ SWTBotGefEditPart primaryKeySection = jpaDiagramEditor
+ .getEditPart(JPAEditorMessages.AddJPAEntityFeature_primaryKeysShape);
+
+ int height = ((PictogramElement) primaryKeySection.part().getModel())
+ .getGraphicsAlgorithm().getHeight();
+
+ primaryKeySection.click();
+
+ jpaDiagramEditor.doubleClick(primaryKeySection);
+ primaryKeySection = jpaDiagramEditor
+ .getEditPart(JPAEditorMessages.AddJPAEntityFeature_primaryKeysShape);
+ int newHeight = ((PictogramElement) primaryKeySection.part().getModel())
+ .getGraphicsAlgorithm().getHeight();
+ assertEquals("Primary Key section must be collapsed!",
+ JPAEditorConstants.COMPARTMENT_MIN_HEIGHT, newHeight);
+ assertTrue(newHeight < height);
+
+ jpaDiagramEditor.doubleClick(primaryKeySection);
+ primaryKeySection = jpaDiagramEditor
+ .getEditPart(JPAEditorMessages.AddJPAEntityFeature_primaryKeysShape);
+ int newHeight1 = ((PictogramElement) primaryKeySection.part()
+ .getModel()).getGraphicsAlgorithm().getHeight();
+ assertEquals("Primary Key section must be collapsed!", height,
+ newHeight1);
+ assertTrue(newHeight1 > JPAEditorConstants.COMPARTMENT_MIN_HEIGHT);
+
+ editorProxy.moveMouse(0, 0);
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testCollapseExpandCompartmentByDoubleClick");
+ }
+
+ /**
+ * Collapse/expand compartment by its context menu
+ */
+ @Ignore
+ @Test
+ public void testCollapseExpandCompartmentByContextMenu() {
+ Utils.sayTestStarted("testCollapseExpandCompartmentByContextMenu");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
+ jpaProject);
+
+ // editorProxy.moveMouse(jpaDiagramEditor, 100, 100);
+ SWTBotGefEditPart primaryKeySection = editorProxy.getSectionInJPT(
+ entity, JPAEditorMessages.AddJPAEntityFeature_primaryKeysShape);
+ // SWTBotGefEditPart primaryKeySection =
+ // jpaDiagramEditor.getEditPart(JPAEditorMessages.AddJPAEntityFeature_primaryKeysShape);
+ primaryKeySection.select();
+ int height = ((PictogramElement) primaryKeySection.part().getModel())
+ .getGraphicsAlgorithm().getHeight();
+
+ primaryKeySection.click();
+
+ jpaDiagramEditor
+ .clickContextMenu(JPAEditorMessages.JPAEditorToolBehaviorProvider_collapseAttrGroupMenuItem);
+ primaryKeySection = jpaDiagramEditor
+ .getEditPart(JPAEditorMessages.AddJPAEntityFeature_primaryKeysShape);
+ int newHeight = ((PictogramElement) primaryKeySection.part().getModel())
+ .getGraphicsAlgorithm().getHeight();
+ assertEquals("Primary Key section must be collapsed!",
+ JPAEditorConstants.COMPARTMENT_MIN_HEIGHT, newHeight);
+ assertTrue(newHeight < height);
+
+ jpaDiagramEditor
+ .clickContextMenu(JPAEditorMessages.JPAEditorToolBehaviorProvider_expandAttrMenuItem);
+ primaryKeySection = jpaDiagramEditor
+ .getEditPart(JPAEditorMessages.AddJPAEntityFeature_primaryKeysShape);
+ int newHeight1 = ((PictogramElement) primaryKeySection.part()
+ .getModel()).getGraphicsAlgorithm().getHeight();
+ assertEquals("Primary Key section must be collapsed!", height,
+ newHeight1);
+ assertTrue(newHeight1 > JPAEditorConstants.COMPARTMENT_MIN_HEIGHT);
+
+ editorProxy.moveMouse(0, 0);
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testCollapseExpandCompartmentByContextMenu");
+ }
+
+ /**
+ * Test the integration between the JPA diagram editor and the JPA Details
+ * view: 1.) Close the JPA Details view 2.) Create an entity and call the
+ * context menu "Open JPA Details View" 3.) Assert that the JPA Details view
+ * is opened and the appropriate information is shown (the type is mapped as
+ * entity and the expandable sections are available). 4.) Change the mapping
+ * type to "Mapped Superclass" 5.) Change the mapping type to "Embeddable"
+ * and assert that the type is removed from the diagram 6.) Revert the
+ * mapping type to be "Entity" and call the "Show All Entities" context menu
+ * to visualize the entity in the diagram editor.
+ */
+ @Ignore
+ @Test
+ public void testChangeEntityMappingTypeViaJPADetailsView() {
+ Utils.sayTestStarted("testChangeEntityMappingTypeViaJPADetailsView");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ workbenchBot.viewByTitle("JPA Details").close();
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
+ jpaProject);
+ String entityName = editorProxy.getJPTObjectForGefElement(entity).getSimpleName();
+
+ jpaDiagramEditor.save();
+ jpaDiagramEditor
+ .clickContextMenu(JPAEditorMessages.JPAEditorToolBehaviorProvider_openJPADetailsView);
+
+ // assert that the JPA Details view is opened
+ SWTBotView jpaDetailsView = workbenchBot.viewByTitle("JPA Details");
+ assertTrue("JPA Details view must be opened!",
+ jpaDetailsView.isActive());
+
+ // assert that the type is mapped as entity in the JPA Deatils view
+ entity.click();
+ SWTBot jpaDetailsBot = jpaDetailsView.bot();
+ SWTBotStyledText styledText = jpaDetailsBot.styledText();
+ assertEquals("Type '" +entityName+ "' is mapped as entity.",
+ styledText.getText());
+ assertNotNull("Entity must be shown in the diagram!",
+ jpaDiagramEditor.getEditPart(entityName));
+ // assert that the entity's sections are enabled
+ assertTrue(jpaDetailsBot.label("Entity").isEnabled());
+ assertTrue(jpaDetailsBot.label("Queries").isEnabled());
+ assertTrue(jpaDetailsBot.label("Inheritance").isEnabled());
+ assertTrue(jpaDetailsBot.label("Attribute Overrides").isEnabled());
+ assertTrue(jpaDetailsBot.label("Primary Key Generation").isEnabled());
+ assertTrue(jpaDetailsBot.label("Secondary Tables").isEnabled());
+
+ // change the mapping type to "Mapped Superclass" and assert that the
+ // type is mapped
+ // as mapped superclass in the JPA Details view
+ editorProxy.clickOnStyledText(styledText, 30);
+ editorProxy.changeMappingtype("Mapped Superclass");
+ styledText = jpaDetailsBot.styledText();
+ assertEquals("Type '" + entityName + "' is mapped as mapped superclass.",
+ styledText.getText());
+ assertNotNull("Entity must be shown in the diagram!",
+ jpaDiagramEditor.getEditPart(entityName));
+ // assert that the mapped superclass'es sections are enabled
+ assertTrue(jpaDetailsBot.label("Mapped Superclass").isEnabled());
+ assertTrue(jpaDetailsBot.label("Queries").isEnabled());
+
+ // change the mapping type to "Embeddable" and assert that the element
+ // is removed from the diagram
+ // and the type is mapped as embeddable in the JPA Details view
+ editorProxy.clickOnStyledText(styledText, 30);
+ editorProxy.changeMappingtype("Embeddable");
+ styledText = jpaDetailsBot.styledText();
+ assertEquals("Type '" + entityName + "' is mapped as embeddable.",
+ styledText.getText());
+ assertNotNull("Entity must disappear from the diagram!",
+ jpaDiagramEditor.getEditPart(entityName));
+ // assert that the embeddable's section is enabled
+ // assertTrue(jpaDetailsBot.label("Embeddable").isEnabled());
+
+ // revert the mapping type to Entity
+ editorProxy.clickOnStyledText(styledText, 30);
+ editorProxy.changeMappingtype("Entity");
+ assertNotNull("Entity must disappear from the diagram!",
+ jpaDiagramEditor.getEditPart(entityName));
+
+ jpaDiagramEditor.click(0, 0);
+
+ jpaDiagramEditor.select(entityName);
+ styledText = jpaDetailsBot.styledText();
+ assertEquals("Type '" + entityName + "' is mapped as entity.",
+ styledText.getText());
+ // assert that the entity's sections are enabled
+ assertTrue(jpaDetailsBot.label("Entity").isEnabled());
+ assertTrue(jpaDetailsBot.label("Queries").isEnabled());
+ assertTrue(jpaDetailsBot.label("Inheritance").isEnabled());
+ assertTrue(jpaDetailsBot.label("Attribute Overrides").isEnabled());
+ assertTrue(jpaDetailsBot.label("Primary Key Generation").isEnabled());
+ assertTrue(jpaDetailsBot.label("Secondary Tables").isEnabled());
+
+ entity.click();
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testChangeEntityMappingTypeViaJPADetailsView");
+ }
+
+ /**
+ * Test the integration between the JPA diagram editor and the JPA Details
+ * view: 1.) Close the JPA Details view 2.) Create an entity and call the
+ * context menu "Open JPA Details View" 3.) Assert that the JPA Details view
+ * is opened and the appropriate information is shown (the id attribute is
+ * mapped as id and the expandable sections are available). 4.) Change the
+ * attribute mapping type to "Basic" and assert that the attribute is moved
+ * to "Other Attributes" compartment 5.) Change the attribute mapping type
+ * to "On-To-Many" and assert that the attribute is moved to
+ * "Relation Attributes" compartment 7.) Revert the attribute mapping to
+ * "ID" and assert that the attributes is moved back to the "Primary Key"
+ * compartment
+ */
+ @Ignore
+ @Test
+ public void testChangeAttributeMappingTypeViaJPADetailsView() {
+ Utils.sayTestStarted("testChangeAttributeMappingTypeViaJPADetailsView");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ workbenchBot.viewByTitle("JPA Details").close();
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
+ jpaProject);
+
+ jpaDiagramEditor.save();
+ jpaDiagramEditor
+ .clickContextMenu(JPAEditorMessages.JPAEditorToolBehaviorProvider_openJPADetailsView);
+
+ // assert that the JPA Details view is opened
+ SWTBotView jpaDetailsView = workbenchBot.viewByTitle("JPA Details");
+ assertTrue("JPA Details view must be opened!",
+ jpaDetailsView.isActive());
+
+ SWTBotGefEditPart primaryKeyAttr = jpaDiagramEditor.getEditPart("id");
+ primaryKeyAttr.click();
+
+ // assert that the default entity's attribute is mapped as primary key
+ SWTBot jpaDetailsBot = jpaDetailsView.bot();
+ SWTBotStyledText styledText = jpaDetailsBot.styledText();
+ assertEquals("Attribute 'id' is mapped as ID.", styledText.getText());
+ // assert that the attribute is under "Primary Key" section
+ assertTrue(
+ "Attribute must be in the \"Primary Key\" section of the entity!",
+ editorProxy.isSectionVisible(
+ JPAEditorMessages.AddJPAEntityFeature_primaryKeysShape,
+ entity));
+ assertFalse(
+ "Attribute must be in the \"Primary Key\" section of the entity!",
+ editorProxy
+ .isSectionVisible(
+ JPAEditorMessages.AddJPAEntityFeature_relationAttributesShapes,
+ entity));
+ assertFalse(
+ "Attribute must be in the \"Primary Key\" section of the entity!",
+ editorProxy
+ .isSectionVisible(
+ JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
+ entity));
+ // assert that the ID's sections are available
+ assertTrue(jpaDetailsBot.label("ID").isEnabled());
+ assertTrue(jpaDetailsBot.label("Type").isEnabled());
+ assertTrue(jpaDetailsBot.label("Primary Key Generation").isEnabled());
+
+ // change the attribute type to basic
+ editorProxy.clickOnStyledText(styledText, 29);
+ editorProxy.changeMappingtype("Basic");
+ styledText = jpaDetailsBot.styledText();
+ assertEquals("Attribute 'id' is mapped as basic.", styledText.getText());
+ // assert that the attribute is moved under "Other Attributes" section
+ assertFalse(
+ "Attribute must be in the \"Primary Key\" section of the entity!",
+ editorProxy.isSectionVisible(
+ JPAEditorMessages.AddJPAEntityFeature_primaryKeysShape,
+ entity));
+ assertFalse(
+ "Attribute must be in the \"Relation Attributes\" section of the entity!",
+ editorProxy
+ .isSectionVisible(
+ JPAEditorMessages.AddJPAEntityFeature_relationAttributesShapes,
+ entity));
+ assertTrue(
+ "Attribute must be in the \"Other Attributes\" section of the entity!",
+ editorProxy
+ .isSectionVisible(
+ JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
+ entity));
+ // assert that the Basic's sections are available
+ assertTrue(jpaDetailsBot.label("Basic").isEnabled());
+ assertTrue(jpaDetailsBot.label("Type").isEnabled());
+
+ // change the attribute type to Many to Many
+ editorProxy.clickOnStyledText(styledText, 29);
+ editorProxy.changeMappingtype("Many to Many");
+ styledText = jpaDetailsBot.styledText();
+ assertEquals("Attribute 'id' is mapped as many to many.",
+ styledText.getText());
+ // assert that the attribute is moved under the "Relation Attributes"
+ // section
+ assertFalse(
+ "Attribute must be in the \"Primary key\" section of the entity!",
+ editorProxy.isSectionVisible(
+ JPAEditorMessages.AddJPAEntityFeature_primaryKeysShape,
+ entity));
+ assertTrue(
+ "Attribute must be in the \"Relation Attributes\" section of the entity!",
+ editorProxy
+ .isSectionVisible(
+ JPAEditorMessages.AddJPAEntityFeature_relationAttributesShapes,
+ entity));
+ assertFalse(
+ "Attribute must be in the \"Other Attributes\" section of the entity!",
+ editorProxy
+ .isSectionVisible(
+ JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
+ entity));
+ // assert that the Many to Many's sections are available
+ assertTrue(jpaDetailsBot.label("Many to Many").isEnabled());
+ assertTrue(jpaDetailsBot.label("Joining Strategy").isEnabled());
+ assertTrue(jpaDetailsBot.label("Ordering").isEnabled());
+
+ // revert the attribute type back to Id
+ editorProxy.clickOnStyledText(styledText, 29);
+ editorProxy.changeMappingtype("ID");
+ styledText = jpaDetailsBot.styledText();
+ assertEquals("Attribute 'id' is mapped as ID.", styledText.getText());
+ // assert that the attribute is under "Primary Key" section
+ assertTrue(
+ "Attribute must be in the \"Primary Key\" section of the entity!",
+ editorProxy.isSectionVisible(
+ JPAEditorMessages.AddJPAEntityFeature_primaryKeysShape,
+ entity));
+ assertFalse(
+ "Attribute must be in the \"Relation Attributes\" section of the entity!",
+ editorProxy
+ .isSectionVisible(
+ JPAEditorMessages.AddJPAEntityFeature_relationAttributesShapes,
+ entity));
+ assertFalse(
+ "Attribute must be in the \"Other Attributes\" section of the entity!",
+ editorProxy
+ .isSectionVisible(
+ JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
+ entity));
+ // assert that the ID's sections are available
+ assertTrue(jpaDetailsBot.label("ID").isEnabled());
+ assertTrue(jpaDetailsBot.label("Type").isEnabled());
+ assertTrue(jpaDetailsBot.label("Primary Key Generation").isEnabled());
+
+ entity.click();
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testChangeAttributeMappingTypeViaJPADetailsView");
+ }
+}
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/entity/OpenDiagramEditorSWTBotTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/entity/OpenDiagramEditorSWTBotTest.java
new file mode 100644
index 0000000..d2aed6e
--- /dev/null
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/entity/OpenDiagramEditorSWTBotTest.java
@@ -0,0 +1,58 @@
+package org.eclipse.jpt.jpadiagrameditor.swtbot.tests.entity;
+
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.internal.AbstractSwtBotEditorTest;
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.utils.Utils;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class OpenDiagramEditorSWTBotTest extends AbstractSwtBotEditorTest{
+
+ protected static String TEST_PROJECT = "Test_" + System.currentTimeMillis();
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ createJPa20Project(TEST_PROJECT);
+ }
+
+ /**
+ * Test that the JPA Diagram editor is opened when the context menu
+ * "JPA Tools -> Open Diagram" of the project is called.
+ */
+ @Test
+ public void testOpenDiagramOnProjectLevel() {
+ Utils.sayTestStarted("testOpenDiagramOnProjectLevel");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ workbenchBot.closeAllEditors();
+ // open JPA diagram editor on project level: JPA Tools -> Open Diagram
+ SWTBotGefEditor diagramEditor = editorProxy
+ .openDiagramOnJPAProjectNode(jpaProject.getName(), true);
+ diagramEditor.close();
+
+ Utils.sayTestFinished("testOpenDiagramOnProjectLevel");
+ }
+
+ /**
+ * Test that the JPA Diagram editor is opened when the context menu
+ * "Open Diagram" of the JPA content node is called.
+ */
+ @Test
+ public void testOpenDiagramOnJPAContentNodeLevel() {
+ Utils.sayTestStarted("testOpenDiagramOnJPAContentNodeLevel");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ workbenchBot.closeAllEditors();
+ // open JPA diagram editor on JPA content level: Open Diagram
+ SWTBotGefEditor diagramEditor = editorProxy
+ .openDiagramOnJPAContentNode(jpaProject.getName());
+ diagramEditor.close();
+
+ Utils.sayTestFinished("testOpenDiagramOnJPAContentNodeLevel");
+ }
+
+}
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/entity/derivedIds/EntitiesDerivedIdsSWTBotTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/entity/derivedIds/EntitiesDerivedIdsSWTBotTest.java
new file mode 100644
index 0000000..a6ce18e
--- /dev/null
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/entity/derivedIds/EntitiesDerivedIdsSWTBotTest.java
@@ -0,0 +1,221 @@
+package org.eclipse.jpt.jpadiagrameditor.swtbot.tests.entity.derivedIds;
+
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.internal.AbstractSwtBotEditorTest;
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.utils.Utils;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class EntitiesDerivedIdsSWTBotTest extends AbstractSwtBotEditorTest {
+
+ protected static String TEST_PROJECT = "Test_" + System.currentTimeMillis();
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ createJPa20Project(TEST_PROJECT);
+ }
+
+
+ /**
+ * Create two entities in the diagram. From the second entity, remove the default
+ * primary key attribute. From the "Derived Identifiers" select "One-to-One" unidirectional
+ * relation feature and click first on the second entity and then on the first one.
+ * Assert that the connection appears. Assert that the owner attribute of the relation is mapped
+ * as primary key attribute in the second entity and there is no "Relation Attributes" section.
+ * Test that the created relation is successfully deleted. Repeats all steps for the other three
+ * types of relation also.
+ */
+ @Test
+ public void testSimpleDerivedIdWithoutDefaultPK(){
+ Utils.sayTestStarted("testSimpleDerivedIdWithoutDefaultPK");
+ relUtils.simpleDerivedIdWithoutDefaultPK(false);
+ Utils.sayTestFinished("testSimpleDerivedIdWithoutDefaultPK");
+ }
+
+ /**
+ * Create two entities in the diagram. From the "Derived Identifiers" select "One-to-One"
+ * unidirectional relation feature and click first on the second entity and then on the first one.
+ * Assert that the connection appears. Assert that the owner attribute of the relation is mapped
+ * with the MapsId annotation in the second entity and there is no "Relation Attributes" section.
+ * Test that the created relation is successfully deleted. Repeats all steps for the other three
+ * types of relation also.
+ */
+ @Test
+ public void testSimpleDerivedIdWithDefaultPK(){
+ Utils.sayTestStarted("testSimpleDerivedIdWithDefaultPK");
+ relUtils.simpleDerivedIdWithDefaultPK(false);
+ Utils.sayTestFinished("testSimpleDerivedIdWithDefaultPK");
+ }
+
+
+ /**
+ * Create two entities and one embeddable in the diagram. From the second entity, remove the default
+ * primary key attribute. From the "Composition" section, select "Embed Single object" and embed the
+ * embeddable into the entity2. From the "JPA Details" view, change the mapping of the embedded attribute
+ * in the entity2 to EmbeddedId. From the "Derived Identifiers" select "One-to-One"
+ * unidirectional relation feature and click first on the second entity and then on the first one.
+ * Assert that the connection appears. Assert that the owner attribute of the relation is mapped
+ * with the MapsId annotation in the second entity and there is no "Relation Attributes" section.
+ * Test that the created relation is successfully deleted. Repeats all steps for the other three
+ * types of relation also.
+ */
+ @Test
+ public void testDerivedIdWithEmbeddedPK(){
+ Utils.sayTestStarted("testDerivedIdWithEmbeddedPK");
+ relUtils.derivedIdWithEmbeddedPK(false);
+ Utils.sayTestFinished("testDerivedIdWithEmbeddedPK");
+ }
+
+ /**
+ * Create two entities in the diagram. Create a simple java class. From the second entity, remove the default
+ * primary key attribute. Use the created java class as IDClass in entity2. From the "Derived Identifiers" select "One-to-One"
+ * unidirectional relation feature and click first on the second entity and then on the first one.
+ * Assert that the connection appears. Assert that the owner attribute of the relation is mapped
+ * as primary key attribute in the second entity and there is no "Relation Attributes" section.
+ * Test that the created relation is successfully deleted. Repeats all steps for the other three
+ * types of relation also.
+ */
+ @Test
+ public void testDerivedIdWithIdClassPK() throws Exception{
+ Utils.sayTestStarted("testDerivedIdWithIdClassPK");
+ relUtils.derivedIdWithIdClassPK(false);
+ Utils.sayTestFinished("testDerivedIdWithIdClassPK");
+ }
+
+ /**
+ * Create two entities in the diagram. Create a simple java class. Remove the default
+ * primary key attribute from both entities. Use the created java class as IDClass in both entities.
+ * From the "Derived Identifiers" select "One-to-One" unidirectional relation feature and click first on the second entity and then on the first one.
+ * Assert that the connection appears. Assert that the owner attribute of the relation is mapped
+ * as primary key attribute in the second entity and there is no "Relation Attributes" section.
+ * Test that the created relation is successfully deleted. Repeats all steps for the other three
+ * types of relation also.
+ */
+ @Test
+ public void testDerivedIdWithSameIdClassPK() throws Exception{
+ Utils.sayTestStarted("testDerivedIdWithSameIdClassPK");
+ relUtils.derivedIdWithSameIdClassPK(false);
+ Utils.sayTestFinished("testDerivedIdWithSameIdClassPK");
+ }
+
+ /**
+ * Create two entities in the diagram. Create two simple java class. Remove the default
+ * primary key attribute from both entities. Use the first java class as IDClass in the first entity and the second
+ * java class as IdClass for the second entity. From the "Derived Identifiers" select "One-to-One"
+ * unidirectional relation feature and click first on the second entity and then on the first one.
+ * Assert that the connection appears. Assert that the owner attribute of the relation is mapped
+ * as primary key attribute in the second entity and there is no "Relation Attributes" section.
+ * Assert that a new helper attribute is automatically added in the second java class and its type is the type
+ * of the first java class, used as IDClass.
+ * Test that the created relation is successfully deleted. Repeats all steps for the other three
+ * types of relation also.
+ */
+ @Test
+ public void testDerivedIdWithDifferentIdClassPK() throws Exception{
+ Utils.sayTestStarted("testDerivedIdWithDifferentIdClassPK");
+ relUtils.derivedIdWithDifferentIdClassPK(false);
+ Utils.sayTestFinished("testDerivedIdWithDifferentIdClassPK");
+ }
+
+ /**
+ * Create two entities and one embeddable in the diagram. Remove the default primary key attribute from both entities.
+ * Embed the embeddable in both entities and change the mappig of the embedded attributes to EmbeddedIds.
+ * From the "Derived Identifiers" select "One-to-One" unidirectional relation feature and click first on the second
+ * entity and then on the first one. Assert that the connection appears. Assert that the owner attribute of the relation is mapped
+ * with MapsId in the second entity and there is no "Relation Attributes" section.
+ * Test that the created relation is successfully deleted. Repeats all steps for the other three
+ * types of relation also.
+ */
+ @Test
+ public void testDerivedIdWithSameEmbeddedPK(){
+ Utils.sayTestStarted("testDerivedIdWithSameEmbeddedPK");
+ relUtils.derivedIdWithSameEmbeddedPK(false);
+ Utils.sayTestFinished("testDerivedIdWithSameEmbeddedPK");
+ }
+
+ /**
+ * Create two entities and two embeddable in the diagram. Remove the default primary key attribute from both entities.
+ * Embed the first embeddable in the first enetity and the second one in the second entity. Change the mapping of the
+ * embedded attributes to EmbeddedIds. From the "Derived Identifiers" select "One-to-One" unidirectional relation feature
+ * and click first on the second entity and then on the first one. Assert that the connection appears. Assert that the owner
+ * attribute of the relation is mapped with MapsId in the second entity and there is no "Relation Attributes" section.
+ * Assert that e new helper attribute is added in the second embeddable and its type is of the first embeddable.
+ * Test that the created relation is successfully deleted. Repeats all steps for the other three
+ * types of relation also.
+ */
+ @Test
+ public void testDerivedIdWithDifferentEmbeddedPK(){
+ Utils.sayTestStarted("testDerivedIdWithDifferentEmbeddedPK");
+ relUtils.derivedIdWithDifferentEmbeddedPK(false);
+ Utils.sayTestFinished("testDerivedIdWithDifferentEmbeddedPK");
+ }
+
+ /**
+ * Create two entities and one embeddable in the diagram. Create a simple java class. Remove the default primary key attribute
+ * from both entities. Set the java class as IDClass to the first entity and embed the embeddable in the second entity.
+ * Change the mapping of the embedded attributes to EmbeddedIds. From the "Derived Identifiers" select "One-to-One" unidirectional relation feature
+ * and click first on the second entity and then on the first one. Assert that the connection appears. Assert that the owner
+ * attribute of the relation is mapped with MapsId in the second entity and there is no "Relation Attributes" section.
+ * Assert that e new helper attribute is added in the embeddable and its type is of the java class used as IdClass.
+ * Test that the created relation is successfully deleted. Repeats all steps for the other three
+ * types of relation also.
+ */
+ @Test
+ public void testDerivedIdWithIdClassAndEmbeddedPK() throws Exception {
+ Utils.sayTestStarted("testDerivedIdWithIdClassAndEmbeddedPK");
+ relUtils.derivedIdWithIdClassAndEmbeddedPK(false);
+ Utils.sayTestFinished("testDerivedIdWithIdClassAndEmbeddedPK");
+ }
+
+
+ /**
+ * Create two entities and one embeddable in the diagram.Remove the default primary key attribute
+ * from both entities. Set the embeddable as IDClass to the first entity and embed the embeddable in the second entity.
+ * Change the mapping of the embedded attributes to EmbeddedIds. From the "Derived Identifiers" select "One-to-One" unidirectional relation feature
+ * and click first on the second entity and then on the first one. Assert that the connection appears. Assert that the owner
+ * attribute of the relation is mapped with MapsId in the second entity and there is no "Relation Attributes" section.
+ * Test that the created relation is successfully deleted. Repeats all steps for the other three
+ * types of relation also.
+ */
+ @Test
+ public void testDerivedIdWithIdClassAndSameEmbeddedPK() throws Exception {
+ Utils.sayTestStarted("testDerivedIdWithIdClassAndSameEmbeddedPK");
+ relUtils.derivedIdWithIdClassAndSameEmbeddedPK(false);
+ Utils.sayTestFinished("testDerivedIdWithIdClassAndSameEmbeddedPK");
+ }
+
+ /**
+ * Create two entities and one embeddable in the diagram. Create a simple java class. Remove the default primary key attribute
+ * from both entities. Embed the embeddable in the first entity and set the java class as IDClass to the second entity.
+ * Change the mapping of the embedded attributes to EmbeddedIds. From the "Derived Identifiers" select "One-to-One" unidirectional relation feature
+ * and click first on the second entity and then on the first one. Assert that the connection appears. Assert that the owner
+ * attribute of the relation is mapped as primary key attribute in the second entity and there is no "Relation Attributes" section.
+ * Assert that e new helper attribute is added in the java class and its type is of the embeddable.
+ * Test that the created relation is successfully deleted. Repeats all steps for the other three
+ * types of relation also.
+ */
+ @Test
+ public void testDerivedIdWithEmbeddedPkAndIdClass() throws Exception {
+ Utils.sayTestStarted("testDerivedIdWithEmbeddedPkAndIdClass");
+ relUtils.derivedIdWithEmbeddedPkAndIdClass(false);
+ Utils.sayTestFinished("testDerivedIdWithEmbeddedPkAndIdClass");
+ }
+
+ /**
+ * Create two entities and one embeddable in the diagram. Remove the default primary key attribute
+ * from both entities. Embed the embeddable in the first entity and set the embeddable as IDClass to the second entity.
+ * Change the mapping of the embedded attributes to EmbeddedIds. From the "Derived Identifiers" select "One-to-One" unidirectional relation feature
+ * and click first on the second entity and then on the first one. Assert that the connection appears. Assert that the owner
+ * attribute of the relation is mapped as primary key attribute in the second entity and there is no "Relation Attributes" section.
+ * Test that the created relation is successfully deleted. Repeats all steps for the other three
+ * types of relation also.
+ */
+ @Test
+ public void testDerivedIdWithEmbeddedPkAndSameIdClass() throws Exception {
+ Utils.sayTestStarted("testDerivedIdWithEmbeddedPkAndSameIdClass");
+ relUtils.derivedIdWithEmbeddedPkAndSameIdClass(false);
+ Utils.sayTestFinished("testDerivedIdWithEmbeddedPkAndSameIdClass");
+ }
+}
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/entity/orm/OrmPersistentTypesSWTBotTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/entity/orm/OrmPersistentTypesSWTBotTest.java
new file mode 100644
index 0000000..5174022
--- /dev/null
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/entity/orm/OrmPersistentTypesSWTBotTest.java
@@ -0,0 +1,250 @@
+package org.eclipse.jpt.jpadiagrameditor.swtbot.tests.entity.orm;
+
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.internal.AbstractSwtBotEditorTest;
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.utils.Utils;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class OrmPersistentTypesSWTBotTest extends AbstractSwtBotEditorTest {
+
+ protected static String TEST_PROJECT = "Test_" + System.currentTimeMillis();
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ createJPa20ProjectWithOrm(TEST_PROJECT);
+ }
+
+ /**
+ * Add an entity in the diagram and assert that it is registered in the orm.xml.
+ * Add an attribute to the entity and assert that it is registered in the orm.xml.
+ * Delete the attribute from the diagram and assert that the attribute is deleted from the orm.xml.
+ * Delete the entity from the diagram and assert that it is also deleted from the orm.xml.
+ * @throws InterruptedException
+ */
+ @Test
+ public void testAddEntityAndAttributeInOrmXml() throws InterruptedException {
+ Utils.sayTestStarted("testAddEntityAndAttributeInOrmXml");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+ //add entity in diagram
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50, jpaProject);
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+ String entitySimpleName = editorProxy.getJPTObjectForGefElement(entity).getSimpleName();
+ String entityName = editorProxy.getJPTObjectForGefElement(entity).getName();
+
+ //assert that entity is added in the orm.xml file
+ assertNotNull(ormXml.getPersistentType(entityName));
+
+ jpaDiagramEditor.save();
+ assertFalse("Editor must not be dirty!", jpaDiagramEditor.isDirty());
+
+ String attributeName = editorProxy.getUniqueAttrName(entity);
+ //add attribute to the entity
+ SWTBotGefEditPart attribute = editorProxy.addAttributeToJPT(entity, attributeName, true);
+ PersistentAttribute pa = editorProxy.getJPAObjectForGefElement(attribute);
+ assertNotNull(pa);
+ assertNotNull("Attribute must be added into the orm.xml", JpaArtifactFactory.instance().getORMPersistentAttribute(pa));
+ //delete the attribute from the entity
+ editorProxy.removeAttributeViaButton(entity, attribute, attributeName, true);
+ assertNull("Attribute must be deleted from the orm.xml", JpaArtifactFactory.instance().getORMPersistentAttribute(pa));
+ pa = editorProxy.getJPAObjectForGefElement(attribute);
+ assertNull(pa);
+
+ jpaDiagramEditor.save();
+ //delete the entity from the diagram
+ entity = jpaDiagramEditor.getEditPart(entitySimpleName);
+ editorProxy.deleteJPTViaButton(entity, true);
+ assertNull(ormXml.getPersistentType(entityName));
+
+ editorProxy.deleteDiagramElements(true);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testAddEntityAndAttributeInOrmXml");
+ }
+
+ @Test
+ public void testOneToOneUniDirRelationship() throws InterruptedException {
+ Utils.sayTestStarted("testOneToOneUniDirRelationship");
+ relUtils.oneToOneUniDirRelationship(true);
+ Utils.sayTestFinished("testOneToOneUniDirRelationship");
+ }
+
+
+ /**
+ * Creates "One to One" unidirectional self relationship (from entity1 to
+ * entity1). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore.
+ */
+ @Test
+ public void testSelfOneToOneUniDirRelationship() {
+ Utils.sayTestStarted("testSelfOneToOneUniDirRelationship");
+ relUtils.selfOneToOneUniDirRelationship(true);
+ Utils.sayTestFinished("testSelfOneToOneUniDirRelationship");
+ }
+
+ /**
+ * Creates "One to One" bidirectional relationship (from entity1 to
+ * entity2). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore. Check
+ * that if the inverse attribute will be deleted the connection will be
+ * transformed into one-to-one unidirectional relationship. Test that if the
+ * owner attribute will be deleted, the relationship will disappear.
+ */
+ @Test
+ public void testOneToOneBiDirRelationship() {
+ Utils.sayTestStarted("testOneToOneBiDirRelationship");
+ relUtils.oneToOneBiDirRelationship(true);
+ Utils.sayTestFinished("testOneToOneBiDirRelationship");
+ }
+
+ /**
+ * Creates "One to One" bidirectional self relationship (from entity1 to
+ * entity1). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore.
+ */
+ @Test
+ public void testSelfOneToOneBiDirRelationship() {
+ Utils.sayTestStarted("testSelfOneToOneBiDirRelationship");
+ relUtils.selfOneToOneBiDirRelationship(true);
+ Utils.sayTestFinished("testSelfOneToOneBiDirRelationship");
+ }
+
+ /**
+ * Creates "One to Many" unidirectional relationship (from entity1 to
+ * entity2). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore. Check
+ * that if the owner attribute will be deleted, the relationship will
+ * disappear.
+ */
+ @Test
+ public void testOneToManyUniDirRelationship() {
+ Utils.sayTestStarted("testOneToManyUniDirRelationship");
+ relUtils.oneToManyUniDirRelationship(true);
+ Utils.sayTestFinished("testOneToManyUniDirRelationship");
+ }
+
+ /**
+ * Creates "One to Many" unidirectional self relationship (from entity1 to
+ * entity1). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore.
+ */
+ @Test
+ public void testSelfOneToManyUniDirRelationship() {
+ Utils.sayTestStarted("testSelfOneToManyUniDirRelationship");
+ relUtils.selfOneToManyUniDirRelationship(true);
+ Utils.sayTestFinished("testSelfOneToManyUniDirRelationship");
+ }
+
+ /**
+ * Creates "Many to One" unidirectional relationship (from entity1 to
+ * entity2). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore. Check
+ * that if the owner attribute will be deleted, the relationship will
+ * disappear.
+ */
+ @Test
+ public void testManyToOneUniDirRelationship() {
+ Utils.sayTestStarted("testManyToOneUniDirRelationship");
+ relUtils.manyToOneUniDirRelationship(true);
+ Utils.sayTestFinished("testManyToOneUniDirRelationship");
+ }
+
+ /**
+ * Creates "Many to One" unidirectional self relationship (from entity1 to
+ * entity1). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore.
+ */
+ @Test
+ public void testSelfManyToOneUniDirRelationship() {
+ Utils.sayTestStarted("testSelfManyToOneUniDirRelationship");
+ relUtils.selfManyToOneUniDirRelationship(true);
+ Utils.sayTestFinished("testSelfManyToOneUniDirRelationship");
+ }
+
+ /**
+ * Creates a "Many to One" bidirectional relationship (from entity1 to
+ * entity2). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore. Check
+ * that if the inverse attribute will be deleted the connection will be
+ * transformed into many-to-one unidirectional relationship. Test that if
+ * the owner attribute will be deleted, the relationship will disappear.
+ */
+ @Test
+ public void testManyToOneBiDirRelationship() {
+ Utils.sayTestStarted("testManyToOneBiDirRelationship");
+ relUtils.manyToOneBiDirRelationship(true);
+ Utils.sayTestFinished("testManyToOneBiDirRelationship");
+ }
+
+ /**
+ * Creates a "Many to One" bidirectional self relationship (from entity1 to
+ * entity1). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore.
+ */
+ @Test
+ public void testSelfManyToOneBiDirRelationship() {
+ Utils.sayTestStarted("testSelfManyToOneBiDirRelationship");
+ relUtils.selfManyToOneBiDirRelationship(true);
+ Utils.sayTestFinished("testSelfManyToOneBiDirRelationship");
+ }
+
+ /**
+ * Creates "Many to Many" unidirectional relationship (from entity1 to
+ * entity2). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore. Check
+ * that if the owner attribute will be deleted, the relationship will
+ * disappear.
+ */
+ @Test
+ public void testManyToManyUniDirRelationship() {
+ Utils.sayTestStarted("testManyToManyUniDirRelationship");
+ relUtils.manyToManyUniDirRelationship(true);
+ Utils.sayTestFinished("testManyToManyUniDirRelationship");
+ }
+
+ /**
+ * Creates "Many to Many" unidirectional self relationship (from entity1 to
+ * entity1). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore.
+ */
+ @Test
+ public void testSelfManyToManyUniDirRelationship() {
+ Utils.sayTestStarted("testSelfManyToManyUniDirRelationship");
+ relUtils.selfManyToManyUniDirRelationship(true);
+ Utils.sayTestFinished("testSelfManyToManyUniDirRelationship");
+ }
+
+ /**
+ * Creates a "Many to Many" bidirectional relationship (from entity1 to
+ * entity2). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore. Check
+ * that if the inverse attribute will be deleted the connection will be
+ * transformed into many-to-many unidirectional relationship. Test that if
+ * the owner attribute will be deleted, the relationship will disappear.
+ */
+ @Test
+ public void testManyToManyBiDirRelationship() {
+ Utils.sayTestStarted("testManyToManyBiDirRelationship");
+ relUtils.manyToManyBiDirRelationship(true);
+ Utils.sayTestFinished("testManyToManyBiDirRelationship");
+ }
+
+ /**
+ * Creates a "Many to Many" bidirectional self relationship (from entity1 to
+ * entity1). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore.
+ */
+ @Test
+ public void testSelfManyToManyBiDirRelationship() {
+ Utils.sayTestStarted("testSelfManyToManyBiDirRelationship");
+ relUtils.selfManyToManyBiDirRelationship(true);
+ Utils.sayTestFinished("testSelfManyToManyBiDirRelationship");
+ }
+}
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/entity/orm/derivedIds/OrmEntitiesDerivedIdsSWTBotTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/entity/orm/derivedIds/OrmEntitiesDerivedIdsSWTBotTest.java
new file mode 100644
index 0000000..f04bced
--- /dev/null
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/entity/orm/derivedIds/OrmEntitiesDerivedIdsSWTBotTest.java
@@ -0,0 +1,226 @@
+package org.eclipse.jpt.jpadiagrameditor.swtbot.tests.entity.orm.derivedIds;
+
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.internal.AbstractSwtBotEditorTest;
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.utils.Utils;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class OrmEntitiesDerivedIdsSWTBotTest extends AbstractSwtBotEditorTest {
+
+ protected static String TEST_PROJECT = "Test_" + System.currentTimeMillis();
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ createJPa20ProjectWithOrm(TEST_PROJECT);
+ }
+
+
+ /**
+ * Create two entities in the diagram. From the second entity, remove the default
+ * primary key attribute. From the "Derived Identifiers" select "One-to-One" unidirectional
+ * relation feature and click first on the second entity and then on the first one.
+ * Assert that the connection appears. Assert that the owner attribute of the relation is mapped
+ * as primary key attribute in the second entity and there is no "Relation Attributes" section.
+ * Test that the created relation is successfully deleted. Repeats all steps for the other three
+ * types of relation also.
+ */
+ @Test
+ public void testSimpleDerivedIdWithoutDefaultPK(){
+ Utils.sayTestStarted("testSimpleDerivedIdWithoutDefaultPK");
+ relUtils.simpleDerivedIdWithoutDefaultPK(true);
+ Utils.sayTestFinished("testSimpleDerivedIdWithoutDefaultPK");
+ }
+
+ /**
+ * Create two entities in the diagram. From the "Derived Identifiers" select "One-to-One"
+ * unidirectional relation feature and click first on the second entity and then on the first one.
+ * Assert that the connection appears. Assert that the owner attribute of the relation is mapped
+ * with the MapsId annotation in the second entity and there is no "Relation Attributes" section.
+ * Test that the created relation is successfully deleted. Repeats all steps for the other three
+ * types of relation also.
+ */
+ @Ignore
+ @Test
+ public void testSimpleDerivedIdWithDefaultPK(){
+ Utils.sayTestStarted("testSimpleDerivedIdWithDefaultPK");
+ relUtils.simpleDerivedIdWithDefaultPK(true);
+ Utils.sayTestFinished("testSimpleDerivedIdWithDefaultPK");
+ }
+
+
+ /**
+ * Create two entities and one embeddable in the diagram. From the second entity, remove the default
+ * primary key attribute. From the "Composition" section, select "Embed Single object" and embed the
+ * embeddable into the entity2. From the "JPA Details" view, change the mapping of the embedded attribute
+ * in the entity2 to EmbeddedId. From the "Derived Identifiers" select "One-to-One"
+ * unidirectional relation feature and click first on the second entity and then on the first one.
+ * Assert that the connection appears. Assert that the owner attribute of the relation is mapped
+ * with the MapsId annotation in the second entity and there is no "Relation Attributes" section.
+ * Test that the created relation is successfully deleted. Repeats all steps for the other three
+ * types of relation also.
+ */
+ @Ignore
+ @Test
+ public void testDerivedIdWithEmbeddedPK(){
+ Utils.sayTestStarted("testDerivedIdWithEmbeddedPK");
+ relUtils.derivedIdWithEmbeddedPK(true);
+ Utils.sayTestFinished("testDerivedIdWithEmbeddedPK");
+ }
+
+ /**
+ * Create two entities in the diagram. Create a simple java class. From the second entity, remove the default
+ * primary key attribute. Use the created java class as IDClass in entity2. From the "Derived Identifiers" select "One-to-One"
+ * unidirectional relation feature and click first on the second entity and then on the first one.
+ * Assert that the connection appears. Assert that the owner attribute of the relation is mapped
+ * as primary key attribute in the second entity and there is no "Relation Attributes" section.
+ * Test that the created relation is successfully deleted. Repeats all steps for the other three
+ * types of relation also.
+ */
+ @Test
+ public void testDerivedIdWithIdClassPK() throws Exception{
+ Utils.sayTestStarted("testDerivedIdWithIdClassPK");
+ relUtils.derivedIdWithIdClassPK(true);
+ Utils.sayTestFinished("testDerivedIdWithIdClassPK");
+ }
+
+ /**
+ * Create two entities in the diagram. Create a simple java class. Remove the default
+ * primary key attribute from both entities. Use the created java class as IDClass in both entities.
+ * From the "Derived Identifiers" select "One-to-One" unidirectional relation feature and click first on the second entity and then on the first one.
+ * Assert that the connection appears. Assert that the owner attribute of the relation is mapped
+ * as primary key attribute in the second entity and there is no "Relation Attributes" section.
+ * Test that the created relation is successfully deleted. Repeats all steps for the other three
+ * types of relation also.
+ */
+ @Test
+ public void testDerivedIdWithSameIdClassPK() throws Exception{
+ Utils.sayTestStarted("testDerivedIdWithSameIdClassPK");
+ relUtils.derivedIdWithSameIdClassPK(true);
+ Utils.sayTestFinished("testDerivedIdWithSameIdClassPK");
+ }
+
+ /**
+ * Create two entities in the diagram. Create two simple java class. Remove the default
+ * primary key attribute from both entities. Use the first java class as IDClass in the first entity and the second
+ * java class as IdClass for the second entity. From the "Derived Identifiers" select "One-to-One"
+ * unidirectional relation feature and click first on the second entity and then on the first one.
+ * Assert that the connection appears. Assert that the owner attribute of the relation is mapped
+ * as primary key attribute in the second entity and there is no "Relation Attributes" section.
+ * Assert that a new helper attribute is automatically added in the second java class and its type is the type
+ * of the first java class, used as IDClass.
+ * Test that the created relation is successfully deleted. Repeats all steps for the other three
+ * types of relation also.
+ */
+ @Test
+ public void testDerivedIdWithDifferentIdClassPK() throws Exception{
+ Utils.sayTestStarted("testDerivedIdWithDifferentIdClassPK");
+ relUtils.derivedIdWithDifferentIdClassPK(true);
+ Utils.sayTestFinished("testDerivedIdWithDifferentIdClassPK");
+ }
+
+ /**
+ * Create two entities and one embeddable in the diagram. Remove the default primary key attribute from both entities.
+ * Embed the embeddable in both entities and change the mappig of the embedded attributes to EmbeddedIds.
+ * From the "Derived Identifiers" select "One-to-One" unidirectional relation feature and click first on the second
+ * entity and then on the first one. Assert that the connection appears. Assert that the owner attribute of the relation is mapped
+ * with MapsId in the second entity and there is no "Relation Attributes" section.
+ * Test that the created relation is successfully deleted. Repeats all steps for the other three
+ * types of relation also.
+ */
+ @Test
+ public void testDerivedIdWithSameEmbeddedPK(){
+ Utils.sayTestStarted("testDerivedIdWithSameEmbeddedPK");
+ relUtils.derivedIdWithSameEmbeddedPK(true);
+ Utils.sayTestFinished("testDerivedIdWithSameEmbeddedPK");
+ }
+
+ /**
+ * Create two entities and two embeddable in the diagram. Remove the default primary key attribute from both entities.
+ * Embed the first embeddable in the first enetity and the second one in the second entity. Change the mapping of the
+ * embedded attributes to EmbeddedIds. From the "Derived Identifiers" select "One-to-One" unidirectional relation feature
+ * and click first on the second entity and then on the first one. Assert that the connection appears. Assert that the owner
+ * attribute of the relation is mapped with MapsId in the second entity and there is no "Relation Attributes" section.
+ * Assert that e new helper attribute is added in the second embeddable and its type is of the first embeddable.
+ * Test that the created relation is successfully deleted. Repeats all steps for the other three
+ * types of relation also.
+ */
+ @Ignore
+ @Test
+ public void testDerivedIdWithDifferentEmbeddedPK(){
+ Utils.sayTestStarted("testDerivedIdWithDifferentEmbeddedPK");
+ relUtils.derivedIdWithDifferentEmbeddedPK(true);
+ Utils.sayTestFinished("testDerivedIdWithDifferentEmbeddedPK");
+ }
+
+ /**
+ * Create two entities and one embeddable in the diagram. Create a simple java class. Remove the default primary key attribute
+ * from both entities. Set the java class as IDClass to the first entity and embed the embeddable in the second entity.
+ * Change the mapping of the embedded attributes to EmbeddedIds. From the "Derived Identifiers" select "One-to-One" unidirectional relation feature
+ * and click first on the second entity and then on the first one. Assert that the connection appears. Assert that the owner
+ * attribute of the relation is mapped with MapsId in the second entity and there is no "Relation Attributes" section.
+ * Assert that e new helper attribute is added in the embeddable and its type is of the java class used as IdClass.
+ * Test that the created relation is successfully deleted. Repeats all steps for the other three
+ * types of relation also.
+ */
+ @Ignore
+ @Test
+ public void testDerivedIdWithIdClassAndEmbeddedPK() throws Exception {
+ Utils.sayTestStarted("testDerivedIdWithIdClassAndEmbeddedPK");
+ relUtils.derivedIdWithIdClassAndEmbeddedPK(true);
+ Utils.sayTestFinished("testDerivedIdWithIdClassAndEmbeddedPK");
+ }
+
+
+ /**
+ * Create two entities and one embeddable in the diagram.Remove the default primary key attribute
+ * from both entities. Set the embeddable as IDClass to the first entity and embed the embeddable in the second entity.
+ * Change the mapping of the embedded attributes to EmbeddedIds. From the "Derived Identifiers" select "One-to-One" unidirectional relation feature
+ * and click first on the second entity and then on the first one. Assert that the connection appears. Assert that the owner
+ * attribute of the relation is mapped with MapsId in the second entity and there is no "Relation Attributes" section.
+ * Test that the created relation is successfully deleted. Repeats all steps for the other three
+ * types of relation also.
+ */
+ @Test
+ public void testDerivedIdWithIdClassAndSameEmbeddedPK() throws Exception {
+ Utils.sayTestStarted("testDerivedIdWithIdClassAndSameEmbeddedPK");
+ relUtils.derivedIdWithIdClassAndSameEmbeddedPK(true);
+ Utils.sayTestFinished("testDerivedIdWithIdClassAndSameEmbeddedPK");
+ }
+
+ /**
+ * Create two entities and one embeddable in the diagram. Create a simple java class. Remove the default primary key attribute
+ * from both entities. Embed the embeddable in the first entity and set the java class as IDClass to the second entity.
+ * Change the mapping of the embedded attributes to EmbeddedIds. From the "Derived Identifiers" select "One-to-One" unidirectional relation feature
+ * and click first on the second entity and then on the first one. Assert that the connection appears. Assert that the owner
+ * attribute of the relation is mapped as primary key attribute in the second entity and there is no "Relation Attributes" section.
+ * Assert that e new helper attribute is added in the java class and its type is of the embeddable.
+ * Test that the created relation is successfully deleted. Repeats all steps for the other three
+ * types of relation also.
+ */
+ @Test
+ public void testDerivedIdWithEmbeddedPkAndIdClass() throws Exception {
+ Utils.sayTestStarted("testDerivedIdWithEmbeddedPkAndIdClass");
+ relUtils.derivedIdWithEmbeddedPkAndIdClass(true);
+ Utils.sayTestFinished("testDerivedIdWithEmbeddedPkAndIdClass");
+ }
+
+ /**
+ * Create two entities and one embeddable in the diagram. Remove the default primary key attribute
+ * from both entities. Embed the embeddable in the first entity and set the embeddable as IDClass to the second entity.
+ * Change the mapping of the embedded attributes to EmbeddedIds. From the "Derived Identifiers" select "One-to-One" unidirectional relation feature
+ * and click first on the second entity and then on the first one. Assert that the connection appears. Assert that the owner
+ * attribute of the relation is mapped as primary key attribute in the second entity and there is no "Relation Attributes" section.
+ * Test that the created relation is successfully deleted. Repeats all steps for the other three
+ * types of relation also.
+ */
+ @Test
+ public void testDerivedIdWithEmbeddedPkAndSameIdClass() throws Exception {
+ Utils.sayTestStarted("testDerivedIdWithEmbeddedPkAndSameIdClass");
+ relUtils.derivedIdWithEmbeddedPkAndSameIdClass(true);
+ Utils.sayTestFinished("testDerivedIdWithEmbeddedPkAndSameIdClass");
+ }
+} \ No newline at end of file
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/entity/relationships/EntityRelationshipsSWTBotTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/entity/relationships/EntityRelationshipsSWTBotTest.java
new file mode 100644
index 0000000..30818dd
--- /dev/null
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/entity/relationships/EntityRelationshipsSWTBotTest.java
@@ -0,0 +1,222 @@
+package org.eclipse.jpt.jpadiagrameditor.swtbot.tests.entity.relationships;
+
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.internal.AbstractSwtBotEditorTest;
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.utils.Utils;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class EntityRelationshipsSWTBotTest extends AbstractSwtBotEditorTest {
+
+ protected static String TEST_PROJECT = "Test_" + System.currentTimeMillis();
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ createJPa20Project(TEST_PROJECT);
+ }
+
+
+ @Test
+ public void testOneToOneUniDirRelationship() throws InterruptedException {
+ Utils.sayTestStarted("testOneToOneUniDirRelationship");
+ relUtils.oneToOneUniDirRelationship(false);
+ Utils.sayTestFinished("testOneToOneUniDirRelationship");
+ }
+
+
+ /**
+ * Creates "One to One" unidirectional self relationship (from entity1 to
+ * entity1). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore.
+ */
+ @Test
+ public void testSelfOneToOneUniDirRelationship() {
+ Utils.sayTestStarted("testSelfOneToOneUniDirRelationship");
+ relUtils.selfOneToOneUniDirRelationship(false);
+ Utils.sayTestFinished("testSelfOneToOneUniDirRelationship");
+ }
+
+ /**
+ * Creates "One to One" bidirectional relationship (from entity1 to
+ * entity2). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore. Check
+ * that if the inverse attribute will be deleted the connection will be
+ * transformed into one-to-one unidirectional relationship. Test that if the
+ * owner attribute will be deleted, the relationship will disappear.
+ */
+ @Test
+ public void testOneToOneBiDirRelationship() {
+ Utils.sayTestStarted("testOneToOneBiDirRelationship");
+ relUtils.oneToOneBiDirRelationship(false);
+ Utils.sayTestFinished("testOneToOneBiDirRelationship");
+ }
+
+ /**
+ * Creates "One to One" bidirectional self relationship (from entity1 to
+ * entity1). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore.
+ */
+ @Test
+ public void testSelfOneToOneBiDirRelationship() {
+ Utils.sayTestStarted("testSelfOneToOneBiDirRelationship");
+ relUtils.selfOneToOneBiDirRelationship(false);
+ Utils.sayTestFinished("testSelfOneToOneBiDirRelationship");
+ }
+
+ /**
+ * Creates "One to Many" unidirectional relationship (from entity1 to
+ * entity2). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore. Check
+ * that if the owner attribute will be deleted, the relationship will
+ * disappear.
+ */
+ @Test
+ public void testOneToManyUniDirRelationship() {
+ Utils.sayTestStarted("testOneToManyUniDirRelationship");
+ relUtils.oneToManyUniDirRelationship(false);
+ Utils.sayTestFinished("testOneToManyUniDirRelationship");
+ }
+
+ /**
+ * Creates "One to Many" unidirectional self relationship (from entity1 to
+ * entity1). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore.
+ */
+ @Test
+ public void testSelfOneToManyUniDirRelationship() {
+ Utils.sayTestStarted("testSelfOneToManyUniDirRelationship");
+ relUtils.selfOneToManyUniDirRelationship(false);
+ Utils.sayTestFinished("testSelfOneToManyUniDirRelationship");
+ }
+
+ /**
+ * Creates "Many to One" unidirectional relationship (from entity1 to
+ * entity2). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore. Check
+ * that if the owner attribute will be deleted, the relationship will
+ * disappear.
+ */
+ @Test
+ public void testManyToOneUniDirRelationship() {
+ Utils.sayTestStarted("testManyToOneUniDirRelationship");
+ relUtils.manyToOneUniDirRelationship(false);
+ Utils.sayTestFinished("testManyToOneUniDirRelationship");
+ }
+
+ /**
+ * Creates "Many to One" unidirectional self relationship (from entity1 to
+ * entity1). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore.
+ */
+ @Test
+ public void testSelfManyToOneUniDirRelationship() {
+ Utils.sayTestStarted("testSelfManyToOneUniDirRelationship");
+ relUtils.selfManyToOneUniDirRelationship(false);
+ Utils.sayTestFinished("testSelfManyToOneUniDirRelationship");
+ }
+
+ /**
+ * Creates a "Many to One" bidirectional relationship (from entity1 to
+ * entity2). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore. Check
+ * that if the inverse attribute will be deleted the connection will be
+ * transformed into many-to-one unidirectional relationship. Test that if
+ * the owner attribute will be deleted, the relationship will disappear.
+ */
+ @Test
+ public void testManyToOneBiDirRelationship() {
+ Utils.sayTestStarted("testManyToOneBiDirRelationship");
+ relUtils.manyToOneBiDirRelationship(false);
+ Utils.sayTestFinished("testManyToOneBiDirRelationship");
+ }
+
+ /**
+ * Creates a "Many to One" bidirectional self relationship (from entity1 to
+ * entity1). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore.
+ */
+ @Test
+ public void testSelfManyToOneBiDirRelationship() {
+ Utils.sayTestStarted("testSelfManyToOneBiDirRelationship");
+ relUtils.selfManyToOneBiDirRelationship(false);
+ Utils.sayTestFinished("testSelfManyToOneBiDirRelationship");
+ }
+
+ /**
+ * Creates "Many to Many" unidirectional relationship (from entity1 to
+ * entity2). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore. Check
+ * that if the owner attribute will be deleted, the relationship will
+ * disappear.
+ */
+ @Test
+ public void testManyToManyUniDirRelationship() {
+ Utils.sayTestStarted("testManyToManyUniDirRelationship");
+ relUtils.manyToManyUniDirRelationship(false);
+ Utils.sayTestFinished("testManyToManyUniDirRelationship");
+ }
+
+ /**
+ * Creates "Many to Many" unidirectional self relationship (from entity1 to
+ * entity1). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore.
+ */
+ @Test
+ public void testSelfManyToManyUniDirRelationship() {
+ Utils.sayTestStarted("testSelfManyToManyUniDirRelationship");
+ relUtils.selfManyToManyUniDirRelationship(false);
+ Utils.sayTestFinished("testSelfManyToManyUniDirRelationship");
+ }
+
+ /**
+ * Creates a "Many to Many" bidirectional relationship (from entity1 to
+ * entity2). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore. Check
+ * that if the inverse attribute will be deleted the connection will be
+ * transformed into many-to-many unidirectional relationship. Test that if
+ * the owner attribute will be deleted, the relationship will disappear.
+ */
+ @Test
+ public void testManyToManyBiDirRelationship() {
+ Utils.sayTestStarted("testManyToManyBiDirRelationship");
+ relUtils.manyToManyBiDirRelationship(false);
+ Utils.sayTestFinished("testManyToManyBiDirRelationship");
+ }
+
+ /**
+ * Creates a "Many to Many" bidirectional self relationship (from entity1 to
+ * entity1). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore.
+ */
+ @Test
+ public void testSelfManyToManyBiDirRelationship() {
+ Utils.sayTestStarted("testSelfManyToManyBiDirRelationship");
+ relUtils.selfManyToManyBiDirRelationship(false);
+ Utils.sayTestFinished("testSelfManyToManyBiDirRelationship");
+ }
+
+ /**
+ * Creates a new Inherited entity by entity. Assert that the inherited
+ * entity does not contain a primary key.
+ */
+ @Test
+ public void testInheritedEntityByEntity() {
+ Utils.sayTestStarted("testInheritedEntityByEntity");
+ relUtils.inheritedEntityByEntity(false);
+ Utils.sayTestFinished("testInheritedEntityByEntity");
+ }
+
+ /**
+ * Create two entities in the diagram. From the "Inheritance" section of the palette
+ * select "Inherit Persistent Type". Clock on the first entity and then click on the
+ * second one. Assert that an is-a relation is created.
+ */
+ @Test
+ public void testIsARelationBetweenExistingEntities() {
+ Utils.sayTestStarted("testIsARelationBetweenExistingEntities");
+ relUtils.isARelationBetweenExistingEntities(false);
+ Utils.sayTestFinished("testIsARelationBetweenExistingEntities");
+ }
+}
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/internal/AbstractSwtBotEditorTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/internal/AbstractSwtBotEditorTest.java
new file mode 100644
index 0000000..3583753
--- /dev/null
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/internal/AbstractSwtBotEditorTest.java
@@ -0,0 +1,257 @@
+package org.eclipse.jpt.jpadiagrameditor.swtbot.tests.internal;
+
+import static org.eclipse.swtbot.swt.finder.waits.Conditions.shellCloses;
+import static org.eclipse.swtbot.swt.finder.waits.Conditions.shellIsActive;
+
+import java.util.Iterator;
+
+import junit.framework.ComparisonFailure;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.core.context.orm.OrmXml;
+import org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.utils.ContextMenuHelper;
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.utils.EditorProxy;
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.utils.RelationshipsUtils;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.propertypage.JPADiagramPropertyPage;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.gef.finder.SWTBotGefTestCase;
+import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.TimeoutException;
+import org.junit.After;
+
+@SuppressWarnings("restriction")
+public class AbstractSwtBotEditorTest extends SWTBotGefTestCase{
+ protected static JPACreateFactory factory = JPACreateFactory.instance();
+ protected static JpaProject jpaProject;
+
+ protected static SWTGefBot bot = new SWTGefBot();
+ protected static SWTWorkbenchBot workbenchBot = new SWTWorkbenchBot();
+ protected static EditorProxy editorProxy;
+
+ protected static SWTBotGefEditor jpaDiagramEditor;
+ protected static RelationshipsUtils relUtils;
+ protected static OrmXml ormXml;
+
+
+ public static void createJPa10Project(String name) throws Exception{
+ createJPa20Project(name, "1.0", false);
+ }
+
+ public static void createJPa20Project(String name) throws Exception{
+ createJPa20Project(name, "2.0", false);
+ }
+
+ public static void createJPa20ProjectWithOrm(String name) throws Exception{
+ createJPa20Project(name, "2.0", true);
+ }
+
+ private static void createJPa20Project(String name, String version, boolean withOrmXml) throws Exception{
+ SWTBotPreferences.TIMEOUT = 1000;
+ try {
+ bot.viewByTitle("Welcome").close();
+ } catch (Exception e) {
+ // ignore
+ } finally {
+ SWTBotPreferences.TIMEOUT = 5000;
+ }
+ workbenchBot.perspectiveByLabel("JPA").activate();
+ bot.closeAllEditors();
+
+ factory = JPACreateFactory.instance();
+ boolean isJPA20 = false;
+ if(version.equals("1.0")){
+ jpaProject = factory.createJPAProject(name);
+ isJPA20 = false;
+ } else {
+ jpaProject = factory.createJPA20Project(name);
+ isJPA20 = true;
+ }
+ assertNotNull(jpaProject);
+ assertEquals(name, jpaProject.getName());
+ editorProxy = new EditorProxy(workbenchBot, bot);
+
+ if(withOrmXml) {
+ JPACreateFactory.waitNonSystemJobs();
+ jpaDiagramEditorPropertiesPage(jpaProject.getName());
+
+ JPACreateFactory.waitNonSystemJobs();
+
+ jpaProject.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ //assert that the orm.xml file exists.
+ ormXml = getOrmXMl(jpaProject);
+ assertNotNull(ormXml);
+ editorProxy.setOrmXml(ormXml);
+ }
+
+ jpaDiagramEditor = editorProxy.openDiagramOnJPAProjectNode(
+ jpaProject.getName(), isJPA20);
+ editorProxy.setJpaDiagramEditor(jpaDiagramEditor);
+
+ relUtils = new RelationshipsUtils(jpaDiagramEditor, editorProxy, jpaProject);
+ if(withOrmXml) {
+ assertNotNull(ormXml);
+ relUtils.setOrmXml(ormXml);
+ }
+
+ Thread.sleep(2000);
+ }
+
+ private static void jpaDiagramEditorPropertiesPage(String name) {
+ SWTBot propertiesPageBot = ContextMenuHelper.openProjectProperties(workbenchBot, name);
+
+ //Test JPA Diagram Editor properties page
+ SWTBotTree peropertiesPageTree = propertiesPageBot.tree();
+ ContextMenuHelper.selectNodeInTree(peropertiesPageTree, "JPA");
+
+ try{
+ assertEquals("Could Not Accept Changes ", propertiesPageBot.activeShell().getText());
+ propertiesPageBot.activeShell().bot().button(IDialogConstants.OK_LABEL).click();
+ } catch (ComparisonFailure e) {
+
+ }
+
+ propertiesPageBot.comboBoxWithLabel("Type:").setSelection("Disable Library Configuration");
+ propertiesPageBot.button("Apply").click();
+
+ try {
+ JPACreateFactory.waitNonSystemJobs();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ ContextMenuHelper.selectNodeInTree(peropertiesPageTree, "JPA", "JPA Diagram Editor");
+ assertFalse(propertiesPageBot.checkBoxInGroup("Add to entity mappings in XML", "XML entity mappings").isChecked());
+ // assert the "XML entity mappings" group is disabled
+ assertFalse(propertiesPageBot.labelInGroup("Mapping file:", "XML entity mappings").isEnabled());
+ assertFalse(propertiesPageBot.textWithLabelInGroup("Mapping file:", "XML entity mappings").isEnabled());
+ assertEquals("META-INF/orm.xml", propertiesPageBot.textWithLabelInGroup("Mapping file:", "XML entity mappings").getText());
+ assertFalse(propertiesPageBot.buttonInGroup("Browse...", "XML entity mappings").isEnabled());
+
+ propertiesPageBot.checkBoxInGroup("Add to entity mappings in XML", "XML entity mappings").select();
+ // assert the "XML entity mappings" group is enabled
+ assertTrue(propertiesPageBot.labelInGroup("Mapping file:", "XML entity mappings").isEnabled());
+ assertTrue(propertiesPageBot.textWithLabelInGroup("Mapping file:", "XML entity mappings").isEnabled());
+ assertEquals("META-INF/orm.xml", propertiesPageBot.textWithLabelInGroup("Mapping file:", "XML entity mappings").getText());
+ assertTrue(propertiesPageBot.buttonInGroup("Browse...", "XML entity mappings").isEnabled());
+
+ //checks that the orm.xml does not exist
+ //assert that there is an error message and the OK button is disabled
+ SWTBotText errorMsg = propertiesPageBot.text(1);
+ assertEquals(JPAEditorMessages.JPADiagramPropertyPage_NotExistsXmlErrorMsg, errorMsg.getText());
+ assertFalse(propertiesPageBot.button(IDialogConstants.OK_LABEL).isEnabled());
+
+ //create new orm.xml with the dialogs which open, when the Browse button is pressed
+ //press the Browse button
+ propertiesPageBot.buttonInGroup("Browse...", "XML entity mappings").click();
+ //assert that the "Mapping File" dialog appears
+ workbenchBot.waitUntil(shellIsActive("Mapping File"), 10000);
+ SWTBotShell createMappingdialog = workbenchBot.shell("Mapping File");
+ //assert that the "Ok" button of the "Mapping File" dialog is disabled, because there is no
+ //orm.xml
+ assertFalse(createMappingdialog.bot().button(IDialogConstants.OK_LABEL).isEnabled());
+ //press the "New..." button of the "mapping File" dialog to create a new orm.xml file
+ createMappingdialog.bot().button("New...").click();
+ //assert that the "New Mapping File" dialog is opened.
+ workbenchBot.waitUntil(shellIsActive("New Mapping File"));
+ //press the "Finish" button of the "New Mapping File" dialog to create new orm.xml
+ workbenchBot.shell("New Mapping File").bot().button(IDialogConstants.FINISH_LABEL).click();
+ //wait the "New Mapping File" dialog to be closed.
+ workbenchBot.waitUntil(shellCloses(workbenchBot.shell("New Mapping File")));
+ //assert that the "Ok" button of the "Mapping File" dialog is now enabled and press it.
+ assertTrue(createMappingdialog.bot().button(IDialogConstants.OK_LABEL).isEnabled());
+ createMappingdialog.bot().button(IDialogConstants.OK_LABEL).click();
+ //wait until the "Mapping File" dialog is closed.
+ workbenchBot.waitUntil(shellCloses(createMappingdialog));
+
+ //assert that there is no error message in the properties page, saying that the orm.xml file does
+ //not exists.
+ errorMsg = propertiesPageBot.text(1);
+ assertNotSame(JPAEditorMessages.JPADiagramPropertyPage_NotExistsXmlErrorMsg, errorMsg.getText());
+ //assert that the "Ok" button of the "JPA Diagram Editor" property page is already enabled
+ //and press it.
+ assertTrue(propertiesPageBot.button(IDialogConstants.OK_LABEL).isEnabled());
+ propertiesPageBot.button(IDialogConstants.OK_LABEL).click();
+ //wait until the property page is closed.
+ try {
+ workbenchBot.waitUntil(shellCloses(propertiesPageBot.activeShell()));
+ } catch (TimeoutException e) {
+
+ }
+ }
+
+ private static void createJpaProjectViaWizard(String name, String version) {
+ ContextMenuHelper.clickMenu("File", "New", "Other...");
+ SWTBot swtBot = workbenchBot.shell("New").bot();
+ ContextMenuHelper.selectTreeItem(swtBot.tree(), "JPA", "JPA Project");
+ swtBot.button(IDialogConstants.NEXT_LABEL).click();
+
+ swtBot.textWithLabel("Project name:").setText(name);
+ swtBot.comboBoxInGroup("Target runtime").setSelection("jre6");
+ swtBot.comboBoxInGroup("JPA version").setSelection(version);
+ swtBot.button(IDialogConstants.NEXT_LABEL).click();
+
+ swtBot.button(IDialogConstants.NEXT_LABEL).click();
+
+ swtBot.comboBoxInGroup("Platform").setSelection("Generic 2.0");
+ swtBot.comboBoxWithLabel("Type:").setSelection("Disable Library Configuration");
+
+// swtBot.checkBox("Create mapping file (orm.xml)").select();
+
+ swtBot.button(IDialogConstants.FINISH_LABEL).click();
+
+ swtBot.waitUntil(shellCloses(swtBot.activeShell()), 30000);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ editorProxy.deleteResources(jpaProject, ormXml!=null);
+ }
+
+ private static OrmXml getOrmXMl(JpaProject jpaProject){
+ jpaProject.getContextModelRoot().synchronizeWithResourceModel();
+
+ try {
+ JPACreateFactory.waitNonSystemJobs();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ PersistenceUnit unit = JpaArtifactFactory.instance().getPersistenceUnit(jpaProject);
+ assertNotNull(unit);
+ unit.synchronizeWithResourceModel();
+ unit.update();
+
+
+ assertTrue(unit.getMappingFileRefsSize() > 0);
+ if(unit.getMappingFileRefsSize() == 0)
+ return null;
+
+ String ormFileName = JPADiagramPropertyPage.getOrmXmlFileName(jpaProject.getProject());
+ assertNotNull(ormFileName);
+ Iterator<MappingFileRef> iter = unit.getMappingFileRefs().iterator();
+ while(iter.hasNext()){
+ MappingFileRef mapFile = iter.next();
+ assertEquals(ormFileName, mapFile.getFileName());
+ if(mapFile.getFileName().equals(ormFileName)){
+ OrmXml ormXml = (OrmXml) mapFile.getMappingFile();
+ return ormXml;
+ }
+ }
+ return null;
+ }
+}
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/internal/JPACreateFactory.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/internal/JPACreateFactory.java
index 494e01c..495c5bb 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/internal/JPACreateFactory.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/internal/JPACreateFactory.java
@@ -19,6 +19,7 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
@@ -28,7 +29,6 @@ import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceDescription;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
@@ -36,8 +36,8 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaCore;
@@ -55,6 +55,7 @@ import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml;
import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetDataModelProperties;
import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetInstallDataModelProperties;
import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetInstallDataModelProvider;
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.utils.Utils;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
@@ -74,7 +75,7 @@ public class JPACreateFactory {
private IProject project;
private IJavaProject javaProject;
//private IPackageFragmentRoot sourceFolder;
- JpaProject jpaProject;
+// JpaProject jpaProject;
public static synchronized JPACreateFactory instance() {
if (factory == null)
@@ -91,14 +92,6 @@ public class JPACreateFactory {
p.open(null);
return p;
}
-
- protected IDataModel buildJpaConfigDataModel() {
- IDataModel dataModel = DataModelFactory.createDataModel(new JpaFacetInstallDataModelProvider());
- dataModel.setProperty(IFacetDataModelProperties.FACET_VERSION_STR, "1.0");
- dataModel.setProperty(JpaFacetDataModelProperties.PLATFORM, null /*GenericPlatform.VERSION_1_0.getId()*/);
- dataModel.setProperty(JpaFacetInstallDataModelProperties.CREATE_ORM_XML, Boolean.TRUE);
- return dataModel;
- }
public JpaProject createJPAProject(String projectName) throws CoreException {
return createJPAProject(projectName, null, "1.0");
@@ -117,13 +110,9 @@ public class JPACreateFactory {
}
installFacet(facetedProject, "jst.utility", "1.0");
installFacet(facetedProject, "jpt.jpa", jpaFacetVersion, jpaConfig);
- addJar(javaProject, jpaJarName());
- if (eclipseLinkJarName() != null) {
- addJar(javaProject, eclipseLinkJarName());
- }
- project.refreshLocal(IResource.DEPTH_INFINITE, null);
- jpaProject = this.getJpaProject(project);
+ addPersistenceJarIntoProject(javaProject);
int cnt = 0;
+ JpaProject jpaProject = null;
while ((jpaProject == null) && (cnt < 1000)){
try {
Thread.sleep(500);
@@ -137,8 +126,18 @@ public class JPACreateFactory {
// jpaProject.setUpdater(new SynchronousJpaProjectUpdater(jpaProject));
return jpaProject;
}
+
+ public void addPersistenceJarIntoProject(IJavaProject javaProject) throws JavaModelException,
+ CoreException {
+ addJar(javaProject, jpaJarName());
+ if (eclipseLinkJarName() != null) {
+ addJar(javaProject, eclipseLinkJarName());
+ }
+// project.refreshLocal(IResource.DEPTH_INFINITE, null);
+// jpaProject = this.getJpaProject(project);
+ }
- private JpaProject getJpaProject(IProject p) {
+ public JpaProject getJpaProject(IProject p) {
return (JpaProject) p.getAdapter(JpaProject.class);
}
@@ -582,8 +581,7 @@ public class JPACreateFactory {
}
if (javaPersistentType == null)
throw new RuntimeException("The entity could not be created");
- ICompilationUnit compilationUnit = JavaCore.createCompilationUnitFrom(entity);
- JpaArtifactFactory.instance().makeNewAttribute(null, javaPersistentType, compilationUnit, attName, attType, attActName, attType, null, null, isCollection);
+ JpaArtifactFactory.instance().makeNewAttribute(javaPersistentType, attName, attType, attActName, attType, null, null, isCollection);
}
private IFile createFieldAnnotatedEntity(IFolder folder, String packageName, String entityName) throws IOException, CoreException {
@@ -630,5 +628,225 @@ public class JPACreateFactory {
return createFieldAnnotatedEntity(folder, packageName , entityName);
}
+ /**
+ * Wait all build and refresh jobs to complete by joining them.
+ */
+ public static void joinBuildAndRerfreshJobs() {
+ ArrayList<Job> jobs = new ArrayList<Job>();
+ Job[] jobsArray;
+ jobsArray = Job.getJobManager().find(ResourcesPlugin.FAMILY_AUTO_BUILD);
+ jobs.addAll(Arrays.asList(jobsArray));
+ jobsArray = Job.getJobManager().find(ResourcesPlugin.FAMILY_AUTO_REFRESH);
+ jobs.addAll(Arrays.asList(jobsArray));
+ jobsArray = Job.getJobManager().find(ResourcesPlugin.FAMILY_MANUAL_BUILD);
+ jobs.addAll(Arrays.asList(jobsArray));
+ jobsArray = Job.getJobManager().find(ResourcesPlugin.FAMILY_MANUAL_REFRESH);
+ jobs.addAll(Arrays.asList(jobsArray));
+ Utils.printlnFormatted("Waiting for " + jobs.size() + " Jobs to finish...");
+ for (int i = 0; i < jobs.size(); i++) {
+ Job job = jobs.get(i);
+ int jobState = job.getState();
+ if ((jobState == Job.RUNNING) || (jobState == Job.WAITING)) {
+ try {
+ job.join();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ /**
+ * Wait all build and refresh jobs to complete or until 30 seconds timeout
+ * pass.
+ */
+ public static void waitBuildAndRerfreshJobs() {
+ Utils.printlnFormatted("Entered into joinBuildAndRerfreshJobs.");
+ ArrayList<Job> jobs = new ArrayList<Job>();
+ Job[] jobsArray;
+ int timeout = SIDE_JOBS_COMPLETE_TIMEOUT;
+
+ while (timeout > 0) {
+ jobs.clear();
+ jobsArray = Job.getJobManager().find(ResourcesPlugin.FAMILY_AUTO_BUILD);
+ jobs.addAll(Arrays.asList(jobsArray));
+ jobsArray = Job.getJobManager().find(ResourcesPlugin.FAMILY_AUTO_REFRESH);
+ jobs.addAll(Arrays.asList(jobsArray));
+ jobsArray = Job.getJobManager().find(ResourcesPlugin.FAMILY_MANUAL_BUILD);
+ jobs.addAll(Arrays.asList(jobsArray));
+ jobsArray = Job.getJobManager().find(ResourcesPlugin.FAMILY_MANUAL_REFRESH);
+ jobs.addAll(Arrays.asList(jobsArray));
+ if (jobs.size() == 0) {
+ return;
+ }
+ Utils.printlnFormatted("Waiting for " + jobs.size() + " Jobs to finish...");
+ for (Job job : jobsArray) {
+ Utils.printlnFormatted("Waiting for job: " + job.getName() + ", which is " + jobStateToString(job));
+ }
+ timeout -= 1000;
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ }
+
+ }
+ }
+
+ private static String jobStateToString(Job job) {
+ int state = job.getState();
+ switch (state) {
+ case Job.NONE:
+ return "NONE";
+ case Job.RUNNING:
+ return "RUNNING";
+ case Job.SLEEPING:
+ return "SLEEPING";
+ case Job.WAITING:
+ return "SLEEPING";
+ }
+ return "UNKNOWN";
+ }
+
+
+
+ /**
+ * Waits a certain time for any non system job to complete and if there is
+ * still jobs after the certain periord,<br/>
+ * removes all of them so the test will have a clean environment
+ *
+ * @return flag
+ * @throws InterruptedException
+ */
+ public static boolean waitNonSystemJobs() throws InterruptedException {
+ Utils.printlnFormatted("Entered into waitNonSystemJobs.");
+ return waitNonSystemJobs(SIDE_JOBS_COMPLETE_TIMEOUT, true);
+ }
+
+ /**
+ * Waits a certain time for any non system job to complete and if there is still jobs after the certain periord,<br/>
+ * removes all of them so the test will have a clean environment
+ *
+ * @param timeout
+ * time after which the jobs will be canceled.
+ * @return
+ * @throws InterruptedException
+ */
+ public static boolean waitNonSystemJobs(int timeout) throws InterruptedException {
+ return waitNonSystemJobs(timeout, true);
+ }
+
+ /**
+ * Waits a certain time for any non system job to complete and if there is
+ * still jobs after the certain periord,<br/>
+ * removes all of them so the test will have a clean environment
+ *
+ * @param timeout
+ * time after which the jobs will be canceled.
+ * @param cancelWaitForBrowser
+ * will cancel rightaway the wait for browser jobs
+ * @return
+ * @throws InterruptedException
+ */
+ public static boolean waitNonSystemJobs(int timeout, boolean cancelWaitForBrowser) throws InterruptedException {
+ Job[] find = null;
+ int count = 0;
+
+ while (timeout > 0) {
+ count = 0;
+ find = Job.getJobManager().find(null);
+ for (Job job : find) {
+ if (!job.isSystem()) {
+ count++;
+ if (!DUMPER_JOB_NAME.equals(job.getName())) {
+ Utils.printlnFormatted("Waiting for job: " + job.getName() + ", which is " + jobStateToString(job));
+ }
+ }
+ }
+ if (DEBUG && (count == 1)) {
+ return true;
+ } else if (!DEBUG && (count == 0)) {
+ return true;
+ }
+ timeout -= 1000;
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ }
+
+ }
+ Utils.println("Cancelling any running job...");
+
+ find = Job.getJobManager().find(null);
+ for (Job job : find) {
+ if (!job.isSystem() && !DUMPER_JOB_NAME.equals(job.getName())) {
+ printTrace(job);
+ cancelJob(job);
+ }
+ }
+
+ find = Job.getJobManager().find(null);
+ count = 0;
+ for (Job job : find) {
+ if (!job.isSystem()) {
+ count++;
+ }
+ }
+ if (count == 0) {
+ Utils.printlnFormatted("All jobs removed");
+ return true;
+ }
+
+ Utils.printlnFormatted("There are still unremoved job. This may cause the test to block.");
+ return false;
+ }
+
+ /**
+ * Cancels all running system jobs.
+ *
+ * @return true if no jobs are running at the end.
+ * @throws InterruptedException
+ */
+ public static boolean cancelAllNonSystemJobs() throws InterruptedException {
+ waitNonSystemJobs(0);
+ return waitNonSystemJobs();
+ }
+
+ private static void printTrace(Job job) {
+ Thread thread = job.getThread();
+ if (thread == null) {
+ Utils.println("Null Thread ....");
+ return;
+ }
+ StackTraceElement[] stackTrace = thread.getStackTrace();
+ if (stackTrace != null) {
+ for (StackTraceElement traceElement : stackTrace) {
+ if (traceElement != null) {
+ Utils.println("\tat " + traceElement.toString());
+ }
+ }
+ }
+ }
+
+ /**
+ * Will call cancel job and produce a log
+ *
+ * @param job
+ */
+ private static void cancelJob(Job job) {
+ Utils.printlnFormatted("* [" + job.getName() + "]...");
+ job.cancel();
+ Utils.printlnFormatted("* [" + job.getName() + "]...cancelled.");
+ }
+
+
+ // used to decide whether to print Job Manager's state
+ private static boolean DEBUG = false;
+
+ // seconds
+ private static final String DUMPER_JOB_NAME = "Dumper 1";
+
+ private static final int SIDE_JOBS_COMPLETE_TIMEOUT = 30 * 1000; // 30
+
+
}
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/mappedsuperclass/MappedSuperclassesInDiagramSWTBotTest.java
index 511b05f..8a803cc 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/mappedsuperclass/MappedSuperclassesInDiagramSWTBotTest.java
@@ -1,26 +1,19 @@
-package org.eclipse.jpt.jpadiagrameditor.swtbot.tests.ui.editor;
+package org.eclipse.jpt.jpadiagrameditor.swtbot.tests.mappedsuperclass;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.ui.internal.parts.DiagramEditPart;
import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.ui.details.JptJpaUiDetailsMessages;
-import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.internal.JPACreateFactory;
-import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.internal.Utils;
+import org.eclipse.jpt.jpa.core.MappingKeys;
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.conditions.ElementIsShown;
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.internal.AbstractSwtBotEditorTest;
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.utils.Utils;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IRelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
-import org.eclipse.swtbot.eclipse.gef.finder.SWTBotGefTestCase;
-import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
-import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
-import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
-import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
@@ -28,45 +21,13 @@ import org.junit.runner.RunWith;
@RunWith(SWTBotJunit4ClassRunner.class)
@SuppressWarnings("restriction")
-public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
+public class MappedSuperclassesInDiagramSWTBotTest extends AbstractSwtBotEditorTest {
- protected static String TEST_PROJECT;
- protected static JPACreateFactory factory = JPACreateFactory.instance();
- protected static JpaProject jpaProject;
-
- protected static SWTGefBot bot = new SWTGefBot();
- protected static SWTWorkbenchBot workbenchBot = new SWTWorkbenchBot();
- protected static EditorProxy editorProxy = new EditorProxy(workbenchBot,
- bot);
-
- protected static SWTBotGefEditor jpaDiagramEditor;
+ protected static String TEST_PROJECT = "Test_" + System.currentTimeMillis();
@BeforeClass
public static void beforeClass() throws Exception {
-
- SWTBotPreferences.TIMEOUT = 1000;
- try {
- bot.viewByTitle("Welcome").close();
- } catch (Exception e) {
- // ignore
- } finally {
- SWTBotPreferences.TIMEOUT = 5000;
- }
- workbenchBot.perspectiveByLabel("JPA").activate();
-
- TEST_PROJECT = "Test_" + System.currentTimeMillis();
-
- factory = JPACreateFactory.instance();
- jpaProject = factory.createJPA20Project(TEST_PROJECT);
- assertNotNull(jpaProject);
-
- workbenchBot.closeAllEditors();
-
- jpaDiagramEditor = editorProxy.openDiagramOnJPAProjectNode(
- TEST_PROJECT, true);
- editorProxy.setJpaDiagramEditor(jpaDiagramEditor);
-
- Thread.sleep(2000);
+ createJPa20Project(TEST_PROJECT);
}
/**
@@ -87,7 +48,7 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
jpaDiagramEditor.save();
assertFalse("Editor must not be dirty!", jpaDiagramEditor.isDirty());
- editorProxy.deleteDiagramElements();
+ editorProxy.deleteDiagramElements(false);
jpaDiagramEditor.save();
Utils.sayTestFinished("testAddMappedSuperclass");
@@ -107,7 +68,7 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
SWTBotGefEditPart mappedSuperclass = editorProxy
.addMappedSuperclassToDiagram(50, 50, jpaProject);
- editorProxy.deleteJPTViaButton(mappedSuperclass);
+ editorProxy.deleteJPTViaButton(mappedSuperclass, true);
assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
jpaDiagramEditor.save();
@@ -137,38 +98,6 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
Utils.sayTestFinished("testRemoveEntityViaContextMenu");
}
- /**
- * Adds a new attribute to the mapped superclass using the entity's context
- * button "Create Attribute"
- */
- @Test
- public void testAddAttribute() {
- Utils.sayTestStarted("testAddAttribute");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart mappedSuperclass = editorProxy
- .addMappedSuperclassToDiagram(50, 50, jpaProject);
-
- assertFalse(
- "\"Other Attributes\" section must not be visible!",
- editorProxy
- .isSectionVisible(
- JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
- mappedSuperclass));
-
- String attributeName = editorProxy.getUniqueAttrName(mappedSuperclass);
- editorProxy.addAttributeToJPT(mappedSuperclass, attributeName);
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- mappedSuperclass.click();
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testAddAttribute");
- }
-
@Test
public void testAddElementCollectionAttributeToMappedSuperclass() {
Utils.sayTestStarted("testAddElementCollectionAttributeToMappedSuperclass");
@@ -187,11 +116,13 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
mappedSuperclass));
String attributeName = editorProxy.getUniqueAttrName(mappedSuperclass);
- editorProxy.addElementCollectionAttributeToJPT(mappedSuperclass, attributeName);
+ SWTBotGefEditPart attribute = editorProxy.addElementCollectionAttributeToJPT(mappedSuperclass, attributeName);
assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ editorProxy.removeAttributeViaButton(mappedSuperclass, attribute, attributeName, false);
mappedSuperclass.click();
- editorProxy.deleteDiagramElements();
+ editorProxy.deleteDiagramElements(false);
jpaDiagramEditor.save();
Utils.sayTestFinished("testAddElementCollectionAttributeToMappedSuperclass");
@@ -201,7 +132,7 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
* Removes the attribute using the "Delete Attribute" context button.
*/
@Test
- public void testRemoveAttributeViaContextButton() {
+ public void testAddRemoveAttributeViaContextButton() {
Utils.sayTestStarted("testRemoveAttributeViaContextButton");
assertTrue("The diagram must be empty.", jpaDiagramEditor
@@ -211,10 +142,13 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
.addMappedSuperclassToDiagram(50, 50, jpaProject);
String attributeName = editorProxy.getUniqueAttrName(mappedSuperclass);
- editorProxy.removeAttributeViaButton(mappedSuperclass, attributeName);
+ SWTBotGefEditPart attribute = editorProxy.addAttributeToJPT(mappedSuperclass, attributeName, false);
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ editorProxy.removeAttributeViaButton(mappedSuperclass, attribute, attributeName, false);
mappedSuperclass.click();
- editorProxy.deleteDiagramElements();
+ editorProxy.deleteDiagramElements(false);
jpaDiagramEditor.save();
Utils.sayTestFinished("testRemoveAttributeViaContextButton");
@@ -224,7 +158,7 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
* Removes the attribute using the "Delete" context menu.
*/
@Test
- public void testRemoveAttributeViaMenu() {
+ public void testAddRemoveAttributeViaMenu() {
Utils.sayTestStarted("testRemoveAttributeViaMenu");
assertTrue("The diagram must be empty.", jpaDiagramEditor
@@ -234,10 +168,13 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
.addMappedSuperclassToDiagram(50, 50, jpaProject);
String attributeName = editorProxy.getUniqueAttrName(mappedSuperclass);
- editorProxy.removeAttributeViaMenu(mappedSuperclass, attributeName);
+ SWTBotGefEditPart attribute = editorProxy.addAttributeToJPT(mappedSuperclass, attributeName, false);
+ assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
+
+ editorProxy.removeAttributeViaMenu(mappedSuperclass, attribute, attributeName);
mappedSuperclass.click();
- editorProxy.deleteDiagramElements();
+ editorProxy.deleteDiagramElements(false);
jpaDiagramEditor.save();
Utils.sayTestFinished("testRemoveAttributeViaMenu");
@@ -261,7 +198,7 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
- editorProxy.deleteDiagramElements();
+ editorProxy.deleteDiagramElements(false);
jpaDiagramEditor.save();
Utils.sayTestFinished("testDirectEditingAttribute");
@@ -298,7 +235,7 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
- editorProxy.deleteDiagramElements();
+ editorProxy.deleteDiagramElements(false);
jpaDiagramEditor.save();
Utils.sayTestFinished("testDirectEditingEntity");
@@ -328,7 +265,7 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
"MpdSuprcls1.java", activeEditor.getTitle());
activeEditor.close();
- editorProxy.deleteDiagramElements();
+ editorProxy.deleteDiagramElements(false);
jpaDiagramEditor.save();
Utils.sayTestFinished("testDoubleClickOnEntity");
@@ -356,7 +293,7 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
String attributeName = editorProxy.getUniqueAttrName(mappedSuperclass);
SWTBotGefEditPart attribute = editorProxy.addAttributeToJPT(
- mappedSuperclass, attributeName);
+ mappedSuperclass, attributeName, false);
assertNotNull("The attribute must not be renamed!", attribute);
final IFeatureProvider fp = ((DiagramEditPart) jpaDiagramEditor
@@ -408,7 +345,7 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
assertTrue("Editor must be dirty!", jpaDiagramEditor.isDirty());
mappedSuperclass.click();
- editorProxy.deleteDiagramElements();
+ editorProxy.deleteDiagramElements(false);
jpaDiagramEditor.save();
Utils.sayTestFinished("testChangeAttributeType");
@@ -458,7 +395,7 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
jpaDiagramEditor.getEditPart(oldMappedSuperclassName));
mappedSuperclass.click();
- editorProxy.deleteDiagramElements();
+ editorProxy.deleteDiagramElements(false);
jpaDiagramEditor.save();
Utils.sayTestFinished("testRenameEntityViaMenu");
@@ -505,7 +442,7 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
assertTrue("Entity must be changed!", newEntityPackage.equals("org"));
mappedSuperclass.click();
- editorProxy.deleteDiagramElements();
+ editorProxy.deleteDiagramElements(false);
jpaDiagramEditor.save();
Utils.sayTestFinished("testMoveEntityViaMenu");
@@ -525,11 +462,11 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
.addMappedSuperclassToDiagram(50, 50, jpaProject);
String attributeName = editorProxy.getUniqueAttrName(mappedSuperclass);
- editorProxy.addAttributeToJPT(mappedSuperclass, attributeName);
+ editorProxy.addAttributeToJPT(mappedSuperclass, attributeName, false);
editorProxy.collapseExpandJPTViaButton(mappedSuperclass);
- editorProxy.deleteDiagramElements();
+ editorProxy.deleteDiagramElements(false);
jpaDiagramEditor.save();
Utils.sayTestFinished("testCollapseExapandEntityViaContextButton");
@@ -549,11 +486,11 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
.addMappedSuperclassToDiagram(50, 50, jpaProject);
String attributeName = editorProxy.getUniqueAttrName(mappedSuperclass);
- editorProxy.addAttributeToJPT(mappedSuperclass, attributeName);
+ editorProxy.addAttributeToJPT(mappedSuperclass, attributeName, false);
editorProxy.collapseExpandJPTViaMenu(mappedSuperclass);
- editorProxy.deleteDiagramElements();
+ editorProxy.deleteDiagramElements(false);
jpaDiagramEditor.save();
Utils.sayTestFinished("testCollapseExapandEntityViaMenu");
@@ -564,6 +501,7 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
* "Discard Changes" context menu. Assert that the newly added attribute is
* removed and the mapped superclass does not contain unsaved changes.
*/
+ @Ignore
@Test
public void testDiscardChanges() {
Utils.sayTestStarted("testDiscardChanges");
@@ -577,7 +515,7 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
String attributeName = editorProxy.getUniqueAttrName(mappedSuperclass);
editorProxy.discardChanges(mappedSuperclass, attributeName);
- editorProxy.deleteDiagramElements();
+ editorProxy.deleteDiagramElements(false);
jpaDiagramEditor.save();
Utils.sayTestFinished("testDiscardChanges");
@@ -591,6 +529,7 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
* Entities" context menu and assert that the newly added attribute is
* removed and the mapped superclass does not contain unsaved changes.
*/
+ @Ignore
@Test
public void testRemoveAndDiscardChangesViaMenu() {
Utils.sayTestStarted("testRemoveAndDiscardChangesViaMenu");
@@ -606,7 +545,7 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
attributeName);
mappedSuperclass.click();
- editorProxy.deleteDiagramElements();
+ editorProxy.deleteDiagramElements(false);
jpaDiagramEditor.save();
Utils.sayTestFinished("testRemoveAndDiscardChangesViaMenu");
@@ -634,7 +573,7 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.removeAndSaveChangesViaMenu(mappedSuperclass, attributeName);
mappedSuperclass.click();
- editorProxy.deleteDiagramElements();
+ editorProxy.deleteDiagramElements(false);
jpaDiagramEditor.save();
Utils.sayTestFinished("testRemoveAndSaveChangesViaMenu");
@@ -658,7 +597,7 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
String attributeName = editorProxy.getUniqueAttrName(mappedSuperclass);
editorProxy.saveOnlyJPT(mappedSuperclass, attributeName);
- editorProxy.deleteDiagramElements();
+ editorProxy.deleteDiagramElements(false);
jpaDiagramEditor.save();
Utils.sayTestFinished("testSaveOnlyEntity");
@@ -679,10 +618,10 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
.addMappedSuperclassToDiagram(50, 50, jpaProject);
editorProxy.createInheritedEntity(mappedSuperclass, jpaProject,
- JptJpaUiDetailsMessages.MappedSuperclassUiProvider_linkLabel,
+ MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY,
true, false);
- editorProxy.deleteDiagramElements();
+ editorProxy.deleteDiagramElements(false);
jpaDiagramEditor.save();
@@ -720,10 +659,10 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.waitASecond();
editorProxy.testCreateAndDeleteIsARelation(superclass, subclassName,
- JptJpaUiDetailsMessages.MappedSuperclassUiProvider_linkLabel,
+ MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY,
true, superclassName, subclass, false);
- editorProxy.deleteDiagramElements();
+ editorProxy.deleteDiagramElements(false);
jpaDiagramEditor.save();
@@ -765,7 +704,7 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.waitASecond();
editorProxy.testIsARelationProperties(superclass, subclassName,
- JptJpaUiDetailsMessages.MappedSuperclassUiProvider_linkLabel,
+ MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY,
true, superclassName, subclass, false);
SWTBotGefEditPart secondSuperclass = editorProxy.addEntityToDiagram(
@@ -783,367 +722,11 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
assertTrue("There is no connection created.", secondSuperclass
.sourceConnections().isEmpty());
- editorProxy.deleteDiagramElements();
+ editorProxy.deleteDiagramElements(false);
jpaDiagramEditor.save();
Utils.sayTestFinished("testNoIsARelationIsCreated");
}
- /**
- * Tests that the creation of a one-to-one unidirectional relationship from
- * mapped superclass to entity is possible.
- */
- @Test
- public void testOneToOneUniDirRelFromMappedSuperclass() {
- Utils.sayTestStarted("testOneToOneUniDirRelFromMappedSuperclass");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart mappedSuperclass = editorProxy
- .addMappedSuperclassToDiagram(50, 50, jpaProject);
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
-
- // create One-to-One unidirectional relation from the mapped superclass
- // to entity
-
- editorProxy
- .testUniDirRelation(
- JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- mappedSuperclass,
- entity,
- IRelation.RelType.ONE_TO_ONE,
- JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
-
- editorProxy.deleteDiagramElements();
-
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testOneToOneUniDirRelFromMappedSuperclass");
- }
-
- /**
- * Tests that the creation of a one-to-many unidirectional relationship from
- * mapped superclass to entity is possible.
- */
- @Test
- public void testOneToManyUniDirRelFromMappedSuperclass() {
- Utils.sayTestStarted("testOneToManyUniDirRelFromMappedSuperclass");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart mappedSuperclass = editorProxy
- .addMappedSuperclassToDiagram(50, 50, jpaProject);
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
-
- // create One-to-many unidirectional relation from the mapped superclass
- // to entity1
-
- editorProxy
- .testUniDirRelation(
- JPAEditorMessages.CreateOneToManyUniDirRelationFeature_oneToManyUniDirFeatureName,
- mappedSuperclass,
- entity,
- IRelation.RelType.ONE_TO_MANY,
- JptJpaUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, false);
-
- editorProxy.deleteDiagramElements();
-
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testOneToManyUniDirRelFromMappedSuperclass");
- }
-
- /**
- * Tests that the creation of a many-to-one unidirectional relationship from
- * mapped superclass to entity is possible.
- */
- @Test
- public void testManyToOneUniDirRelFromMappedSuperclass() {
- Utils.sayTestStarted("testManyToOneUniDirRelFromMappedSuperclass");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart mappedSuperclass = editorProxy
- .addMappedSuperclassToDiagram(50, 50, jpaProject);
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
-
- // create Many-to-One unidirectional relation from the mapped superclass
- // to entity1
-
- editorProxy
- .testUniDirRelation(
- JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- mappedSuperclass,
- entity,
- IRelation.RelType.MANY_TO_ONE,
- JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true);
-
- editorProxy.deleteDiagramElements();
-
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testManyToOneUniDirRelFromMappedSuperclass");
- }
-
- /**
- * Tests that the creation of a many-to-many unidirectional relationship
- * from mapped superclass to entity is possible.
- */
- @Test
- public void testManyToManyUniDirRelFromMappedSuperclass() {
- Utils.sayTestStarted("testManyToManyUniDirRelFromMappedSuperclass");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart mappedSuperclass = editorProxy
- .addMappedSuperclassToDiagram(50, 50, jpaProject);
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
-
- // create Many-to-Many unidirectional relation from the mapped
- // superclass
- // to entity1
-
- editorProxy
- .testUniDirRelation(
- JPAEditorMessages.CreateManyToManyUniDirRelationFeature_manyToManyUniDirFeatureName,
- mappedSuperclass,
- entity,
- IRelation.RelType.MANY_TO_MANY,
- JptJpaUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
-
- editorProxy.deleteDiagramElements();
-
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testManyToManyUniDirRelFromMappedSuperclass");
- }
-
- /**
- * Test no one-to-one unidirectional or bidirectional relationship from
- * entity to mapped superclass is created.
- */
- @Test
- public void testOneToOneRelationFromEntityToMappedSuperclass() {
- Utils.sayTestStarted("testOneToOneRelationFromEntityToMappedSuperclass");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart mappedSuperclass = editorProxy
- .addMappedSuperclassToDiagram(50, 50, jpaProject);
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- 2, entity, mappedSuperclass);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- 3, entity, mappedSuperclass);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testOneToOneRelationFromEntityToMappedSuperclass");
- }
-
- /**
- * Test no one-to-one bidirectional relationship from mapped superclass to
- * entity is created.
- */
- @Test
- public void testOneToOneBiDirRelationFromMappedSuperclassToEntity() {
- Utils.sayTestStarted("testOneToOneBiDirRelationFromMappedSuperclassToEntity");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart mappedSuperclass = editorProxy
- .addMappedSuperclassToDiagram(50, 50, jpaProject);
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- 3, mappedSuperclass, entity);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testOneToOneBiDirRelationFromMappedSuperclassToEntity");
- }
-
- /**
- * Test no one-to-many unidirectional relationship from entity to mapped
- * superclass is created.
- */
- @Test
- public void testOneToManyUniDirRelationFromEntityToMappedSuperclass() {
- Utils.sayTestStarted("testOneToManyUniDirRelationFromEntityToMappedSuperclass");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart mappedSuperclass = editorProxy
- .addMappedSuperclassToDiagram(50, 50, jpaProject);
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateOneToManyUniDirRelationFeature_oneToManyUniDirFeatureName,
- 0, entity, mappedSuperclass);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testOneToManyUniDirRelationFromEntityToMappedSuperclass");
- }
-
- /**
- * Test no many-to-one unidirectional or bidirectional relationship from
- * entity to mapped superclass is created.
- */
- @Test
- public void testManyToOneRelationFromEntityToMappedSuperclass() {
- Utils.sayTestStarted("testManyToOneRelationFromEntityToMappedSuperclass");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart mappedSuperclass = editorProxy
- .addMappedSuperclassToDiagram(50, 50, jpaProject);
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- 2, entity, mappedSuperclass);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- 3, entity, mappedSuperclass);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testManyToOneRelationFromEntityToMappedSuperclass");
- }
-
- /**
- * Test no many-to-one bidirectional relationship from mapped superclass to
- * entity is created.
- */
- @Test
- public void testManyToOneBiDirRelationFromMappedSuperclassToEntity() {
- Utils.sayTestStarted("testManyToOneBiDirRelationFromMappedSuperclassToEntity");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart mappedSuperclass = editorProxy
- .addMappedSuperclassToDiagram(50, 50, jpaProject);
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- 3, mappedSuperclass, entity);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testManyToOneBiDirRelationFromMappedSuperclassToEntity");
- }
-
- /**
- * Test no many-to-many unidirectional or bidirectional relationship from
- * entity to mapped superclass is created.
- */
- @Test
- public void testManyToManyUniDirRelationFromEntityToEmbeddable() {
- Utils.sayTestStarted("testManyToManyUniDirRelationFromEntityToEmbeddable");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart mappedSuperclass = editorProxy
- .addMappedSuperclassToDiagram(50, 50, jpaProject);
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateManyToManyUniDirRelationFeature_manyToManyUniDirFeatureName,
- 0, entity, mappedSuperclass);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName,
- 1, entity, mappedSuperclass);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testManyToManyUniDirRelationFromEntityToEmbeddable");
- }
-
- /**
- * Test no many-to-many bidirectional relationship from mapped superclass to
- * entity is created.
- */
- @Test
- public void testManyToManyBiDirRelationFromMappedSuperclassToEntity() {
- Utils.sayTestStarted("testManyToManyBiDirRelationFromMappedSuperclassToEntity");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart mappedSuperclass = editorProxy
- .addMappedSuperclassToDiagram(50, 50, jpaProject);
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName,
- 1, mappedSuperclass, entity);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.saveAndClose();
-
- Utils.sayTestFinished("testManyToManyBiDirRelationFromMappedSuperclassToEntity");
- }
-
- @After
- public void tearDown() throws Exception {
- editorProxy.deleteResources(jpaProject);
- }
-
}
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/mappedsuperclass/relationships/MappedSuperclassRelationshipsSWTBotTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/mappedsuperclass/relationships/MappedSuperclassRelationshipsSWTBotTest.java
new file mode 100644
index 0000000..1a5c921
--- /dev/null
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/mappedsuperclass/relationships/MappedSuperclassRelationshipsSWTBotTest.java
@@ -0,0 +1,374 @@
+package org.eclipse.jpt.jpadiagrameditor.swtbot.tests.mappedsuperclass.relationships;
+
+import org.eclipse.jpt.jpa.core.MappingKeys;
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.internal.AbstractSwtBotEditorTest;
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.utils.Utils;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IRelation;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class MappedSuperclassRelationshipsSWTBotTest extends AbstractSwtBotEditorTest {
+
+ protected static String TEST_PROJECT = "Test_" + System.currentTimeMillis();
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ createJPa20Project(TEST_PROJECT);
+ }
+
+ /**
+ * Tests that the creation of a one-to-one unidirectional relationship from
+ * mapped superclass to entity is possible.
+ */
+ @Test
+ public void testOneToOneUniDirRelFromMappedSuperclass() {
+ Utils.sayTestStarted("testOneToOneUniDirRelFromMappedSuperclass");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart mappedSuperclass = editorProxy
+ .addMappedSuperclassToDiagram(50, 50, jpaProject);
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+
+ // create One-to-One unidirectional relation from the mapped superclass
+ // to entity
+
+ editorProxy
+ .testUniDirRelation(
+ JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
+ mappedSuperclass,
+ entity,
+ IRelation.RelType.ONE_TO_ONE,
+ MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, true, false);
+
+ editorProxy.deleteDiagramElements(false);
+
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testOneToOneUniDirRelFromMappedSuperclass");
+ }
+
+ /**
+ * Tests that the creation of a one-to-many unidirectional relationship from
+ * mapped superclass to entity is possible.
+ */
+ @Test
+ public void testOneToManyUniDirRelFromMappedSuperclass() {
+ Utils.sayTestStarted("testOneToManyUniDirRelFromMappedSuperclass");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart mappedSuperclass = editorProxy
+ .addMappedSuperclassToDiagram(50, 50, jpaProject);
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+
+ // create One-to-many unidirectional relation from the mapped superclass
+ // to entity1
+
+ editorProxy
+ .testUniDirRelation(
+ JPAEditorMessages.CreateOneToManyUniDirRelationFeature_oneToManyUniDirFeatureName,
+ mappedSuperclass,
+ entity,
+ IRelation.RelType.ONE_TO_MANY,
+ MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, false, false);
+
+ editorProxy.deleteDiagramElements(false);
+
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testOneToManyUniDirRelFromMappedSuperclass");
+ }
+
+ /**
+ * Tests that the creation of a many-to-one unidirectional relationship from
+ * mapped superclass to entity is possible.
+ */
+ @Test
+ public void testManyToOneUniDirRelFromMappedSuperclass() {
+ Utils.sayTestStarted("testManyToOneUniDirRelFromMappedSuperclass");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart mappedSuperclass = editorProxy
+ .addMappedSuperclassToDiagram(50, 50, jpaProject);
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+
+ // create Many-to-One unidirectional relation from the mapped superclass
+ // to entity1
+
+ editorProxy
+ .testUniDirRelation(
+ JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
+ mappedSuperclass,
+ entity,
+ IRelation.RelType.MANY_TO_ONE,
+ MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, true, false);
+
+ editorProxy.deleteDiagramElements(false);
+
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testManyToOneUniDirRelFromMappedSuperclass");
+ }
+
+ /**
+ * Tests that the creation of a many-to-many unidirectional relationship
+ * from mapped superclass to entity is possible.
+ */
+ @Test
+ public void testManyToManyUniDirRelFromMappedSuperclass() {
+ Utils.sayTestStarted("testManyToManyUniDirRelFromMappedSuperclass");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart mappedSuperclass = editorProxy
+ .addMappedSuperclassToDiagram(50, 50, jpaProject);
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+
+ // create Many-to-Many unidirectional relation from the mapped
+ // superclass
+ // to entity1
+
+ editorProxy
+ .testUniDirRelation(
+ JPAEditorMessages.CreateManyToManyUniDirRelationFeature_manyToManyUniDirFeatureName,
+ mappedSuperclass,
+ entity,
+ IRelation.RelType.MANY_TO_MANY,
+ MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, false, false);
+
+ editorProxy.deleteDiagramElements(false);
+
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testManyToManyUniDirRelFromMappedSuperclass");
+ }
+
+ /**
+ * Test no one-to-one unidirectional or bidirectional relationship from
+ * entity to mapped superclass is created.
+ */
+ @Test
+ public void testOneToOneRelationFromEntityToMappedSuperclass() {
+ Utils.sayTestStarted("testOneToOneRelationFromEntityToMappedSuperclass");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart mappedSuperclass = editorProxy
+ .addMappedSuperclassToDiagram(50, 50, jpaProject);
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
+ 2, entity, mappedSuperclass);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
+ 3, entity, mappedSuperclass);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testOneToOneRelationFromEntityToMappedSuperclass");
+ }
+
+ /**
+ * Test no one-to-one bidirectional relationship from mapped superclass to
+ * entity is created.
+ */
+ @Test
+ public void testOneToOneBiDirRelationFromMappedSuperclassToEntity() {
+ Utils.sayTestStarted("testOneToOneBiDirRelationFromMappedSuperclassToEntity");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart mappedSuperclass = editorProxy
+ .addMappedSuperclassToDiagram(50, 50, jpaProject);
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
+ 3, mappedSuperclass, entity);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testOneToOneBiDirRelationFromMappedSuperclassToEntity");
+ }
+
+ /**
+ * Test no one-to-many unidirectional relationship from entity to mapped
+ * superclass is created.
+ */
+ @Test
+ public void testOneToManyUniDirRelationFromEntityToMappedSuperclass() {
+ Utils.sayTestStarted("testOneToManyUniDirRelationFromEntityToMappedSuperclass");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart mappedSuperclass = editorProxy
+ .addMappedSuperclassToDiagram(50, 50, jpaProject);
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateOneToManyUniDirRelationFeature_oneToManyUniDirFeatureName,
+ 0, entity, mappedSuperclass);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testOneToManyUniDirRelationFromEntityToMappedSuperclass");
+ }
+
+ /**
+ * Test no many-to-one unidirectional or bidirectional relationship from
+ * entity to mapped superclass is created.
+ */
+ @Test
+ public void testManyToOneRelationFromEntityToMappedSuperclass() {
+ Utils.sayTestStarted("testManyToOneRelationFromEntityToMappedSuperclass");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart mappedSuperclass = editorProxy
+ .addMappedSuperclassToDiagram(50, 50, jpaProject);
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
+ 2, entity, mappedSuperclass);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
+ 3, entity, mappedSuperclass);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testManyToOneRelationFromEntityToMappedSuperclass");
+ }
+
+ /**
+ * Test no many-to-one bidirectional relationship from mapped superclass to
+ * entity is created.
+ */
+ @Test
+ public void testManyToOneBiDirRelationFromMappedSuperclassToEntity() {
+ Utils.sayTestStarted("testManyToOneBiDirRelationFromMappedSuperclassToEntity");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart mappedSuperclass = editorProxy
+ .addMappedSuperclassToDiagram(50, 50, jpaProject);
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
+ 3, mappedSuperclass, entity);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testManyToOneBiDirRelationFromMappedSuperclassToEntity");
+ }
+
+ /**
+ * Test no many-to-many unidirectional or bidirectional relationship from
+ * entity to mapped superclass is created.
+ */
+ @Test
+ public void testManyToManyUniDirRelationFromEntityToEmbeddable() {
+ Utils.sayTestStarted("testManyToManyUniDirRelationFromEntityToEmbeddable");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart mappedSuperclass = editorProxy
+ .addMappedSuperclassToDiagram(50, 50, jpaProject);
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateManyToManyUniDirRelationFeature_manyToManyUniDirFeatureName,
+ 0, entity, mappedSuperclass);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName,
+ 1, entity, mappedSuperclass);
+
+ editorProxy.deleteDiagramElements(false);
+ jpaDiagramEditor.save();
+
+ Utils.sayTestFinished("testManyToManyUniDirRelationFromEntityToEmbeddable");
+ }
+
+ /**
+ * Test no many-to-many bidirectional relationship from mapped superclass to
+ * entity is created.
+ */
+ @Test
+ public void testManyToManyBiDirRelationFromMappedSuperclassToEntity() {
+ Utils.sayTestStarted("testManyToManyBiDirRelationFromMappedSuperclassToEntity");
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart mappedSuperclass = editorProxy
+ .addMappedSuperclassToDiagram(50, 50, jpaProject);
+
+ SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
+ jpaProject);
+
+ editorProxy
+ .testNoConnectionIsCreated(
+ JPAEditorMessages.CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName,
+ 1, mappedSuperclass, entity);
+
+ editorProxy.deleteDiagramElements(false);
+// jpaDiagramEditor.saveAndClose();
+
+ Utils.sayTestFinished("testManyToManyBiDirRelationFromMappedSuperclassToEntity");
+ }
+}
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/ContextMenuHelper.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/ContextMenuHelper.java
deleted file mode 100644
index 40a3e17..0000000
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/ContextMenuHelper.java
+++ /dev/null
@@ -1,131 +0,0 @@
-package org.eclipse.jpt.jpadiagrameditor.swtbot.tests.ui.editor;
-
-import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withRegex;
-import static org.hamcrest.core.AllOf.allOf;
-import static org.hamcrest.core.IsInstanceOf.instanceOf;
-
-import java.util.Arrays;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
-import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
-import org.eclipse.swtbot.swt.finder.results.VoidResult;
-import org.eclipse.swtbot.swt.finder.results.WidgetResult;
-import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot;
-import org.hamcrest.Matcher;
-
-public class ContextMenuHelper
-{
-
- /**
- * Clicks the context menu matching the text.
- *
- * @param text
- * the text on the context menu.
- * @throws WidgetNotFoundException
- * if the widget is not found.
- */
- @SuppressWarnings("unchecked")
- public static void clickContextMenu( final AbstractSWTBot<?> bot, final String... texts )
- {
- final Matcher<?>[] matchers = new Matcher<?>[texts.length];
- for ( int i = 0; i < texts.length; i++ )
- {
- // matchers[i] = allOf( instanceOf( MenuItem.class ), withMnemonic( texts[i] ) );
- matchers[i] = allOf( instanceOf( MenuItem.class ), withRegex( texts[i] ) );
- }
-
- // show
- final MenuItem menuItem = UIThreadRunnable.syncExec( new WidgetResult<MenuItem>()
- {
- public MenuItem run()
- {
- MenuItem menuItem = null;
- Control control = ( Control ) bot.widget;
- Menu menu = control.getMenu();
- for ( int i = 0; i < matchers.length; i++ )
- {
- menuItem = show( menu, matchers[i] );
- if ( menuItem != null )
- {
- menu = menuItem.getMenu();
- }
- else
- {
- hide( menu );
- break;
- }
- }
-
- return menuItem;
- }
- } );
- if ( menuItem == null )
- {
- throw new WidgetNotFoundException( "Could not find menu: " + Arrays.asList( texts ) );
- }
-
- // click
- click( menuItem );
-
- // hide
- UIThreadRunnable.syncExec( new VoidResult()
- {
- public void run()
- {
- hide( menuItem.getParent() );
- }
- } );
- }
-
-
- private static MenuItem show( final Menu menu, final Matcher<?> matcher )
- {
- if ( menu != null )
- {
- menu.notifyListeners( SWT.Show, new Event() );
- MenuItem[] items = menu.getItems();
- for ( final MenuItem menuItem : items )
- {
- if ( matcher.matches( menuItem ) )
- {
- return menuItem;
- }
- }
- menu.notifyListeners( SWT.Hide, new Event() );
- }
- return null;
- }
-
-
- private static void click( final MenuItem menuItem )
- {
- final Event event = new Event();
- event.time = ( int ) System.currentTimeMillis();
- event.widget = menuItem;
- event.display = menuItem.getDisplay();
- event.type = SWT.Selection;
-
- UIThreadRunnable.asyncExec( menuItem.getDisplay(), new VoidResult()
- {
- public void run()
- {
- menuItem.notifyListeners( SWT.Selection, event );
- }
- } );
- }
-
-
- private static void hide( final Menu menu )
- {
- menu.notifyListeners( SWT.Hide, new Event() );
- if ( menu.getParentMenu() != null )
- {
- hide( menu.getParentMenu() );
- }
- }
-} \ No newline at end of file
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
deleted file mode 100644
index f47e448..0000000
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EmbeddableInDiagramSWTBotTest.java
+++ /dev/null
@@ -1,2065 +0,0 @@
-package org.eclipse.jpt.jpadiagrameditor.swtbot.tests.ui.editor;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.graphiti.features.IFeatureProvider;
-import org.eclipse.graphiti.ui.internal.parts.DiagramEditPart;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.jpa2.MappingKeys2_0;
-import org.eclipse.jpt.jpa.ui.details.JptJpaUiDetailsMessages;
-import org.eclipse.jpt.jpa.ui.jpa2.details.JptJpaUiDetailsMessages2_0;
-import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.internal.JPACreateFactory;
-import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.internal.Utils;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.HasReferanceRelation.HasReferenceType;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IRelation;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
-import org.eclipse.swtbot.eclipse.gef.finder.SWTBotGefTestCase;
-import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
-import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
-import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
-import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
-import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
-import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
-import org.junit.After;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(SWTBotJunit4ClassRunner.class)
-@SuppressWarnings("restriction")
-public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
-
- protected static String TEST_PROJECT;
- protected static JPACreateFactory factory = JPACreateFactory.instance();
- protected static JpaProject jpaProject;
-
- protected static SWTGefBot bot = new SWTGefBot();
- protected static SWTWorkbenchBot workbenchBot = new SWTWorkbenchBot();
- protected static EditorProxy editorProxy = new EditorProxy(workbenchBot,
- bot);
-
- protected static SWTBotGefEditor jpaDiagramEditor;
-
- @BeforeClass
- public static void beforeClass() throws Exception {
-
- SWTBotPreferences.TIMEOUT = 1000;
- try {
- bot.viewByTitle("Welcome").close();
- } catch (Exception e) {
- // ignore
- } finally {
- SWTBotPreferences.TIMEOUT = 5000;
- }
- workbenchBot.perspectiveByLabel("JPA").activate();
- workbenchBot.viewByTitle("JPA Structure").close();
-
- TEST_PROJECT = "Test_" + System.currentTimeMillis();
-
- factory = JPACreateFactory.instance();
- jpaProject = factory.createJPA20Project(TEST_PROJECT);
- assertNotNull(jpaProject);
-
- workbenchBot.closeAllEditors();
-
- jpaDiagramEditor = editorProxy
- .openDiagramOnJPAProjectNode(TEST_PROJECT, true);
- editorProxy.setJpaDiagramEditor(jpaDiagramEditor);
-
- Thread.sleep(2000);
- }
-
- /**
- * Add embeddable to diagram and check that it does not contain a
- * "Primary Key", "Relation Attributes" and "Other Attributes" sections.
- */
- @Test
- public void testAddEmbeddable() {
- Utils.sayTestStarted("testAddEmbeddable");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- editorProxy.addEmbeddableToDiagram(50, 50, jpaProject);
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- jpaDiagramEditor.save();
- assertFalse("Editor must not be dirty!", jpaDiagramEditor.isDirty());
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testAddEmbeddable");
- }
-
- /**
- * Remove an embeddable from the diagram using the embeddable's context
- * button "Delete"
- */
- @Test
- public void testRemoveEmnbeddableViaButton() {
- Utils.sayTestStarted("testRemoveEmnbeddableViaButton");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- editorProxy.deleteJPTViaButton(embeddable);
-
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testRemoveEmnbeddableViaButton");
- }
-
- /**
- * Remove an embeddable from the diagram using the embeddable's context menu
- * "Delete"
- */
- @Test
- public void testRemoveEmbeddableViaContextMenu() {
- Utils.sayTestStarted("testRemoveEmbeddableViaContextMenu");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- editorProxy.deleteJPTViaMenu(embeddable);
-
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testRemoveEmbeddableViaContextMenu");
- }
-
- /**
- * Adds a new attribute to the embeddable using the entity's context button
- * "Create Attribute"
- */
- @Test
- public void testAddAttributeToEmbeddablle() {
- Utils.sayTestStarted("testAddAttributeToEmbeddablle");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- assertFalse(
- "\"Other Attributes\" section must not be visible!",
- editorProxy
- .isSectionVisible(
- JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
- embeddable));
-
- String attributeName = editorProxy.getUniqueAttrName(embeddable);
- editorProxy.addAttributeToJPT(embeddable, attributeName);
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- embeddable.click();
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testAddAttributeToEmbeddablle");
- }
-
- @Test
- public void testAddElementCollectionAttributeToEmbeddable(){
- Utils.sayTestStarted("testAddElementCollectionAttributeToEmbeddable");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50, 50, jpaProject);
-
- assertFalse(
- "\"Other Attributes\" section must not be visible!",
- editorProxy.isSectionVisible(JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes, embeddable));
-
- String attributeName = editorProxy.getUniqueAttrName(embeddable);
- editorProxy.addElementCollectionAttributeToJPT(embeddable, attributeName);
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- embeddable.click();
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testAddElementCollectionAttributeToEmbeddable");
- }
-
-
- /**
- * Add two embeddables and one entity in the diagram. Add an attribute of collection type to
- * the first embeddable. Check that it is not possible to embed a collection of the first
- * embeddable neither into the second embeddable, nor into the entity, but it is possible to embed
- * a collection of the second embeddable to the first embeddable.
- */
-
- @Test
- public void testEmbedCollectionOfObjectsWithCollectionAttribute() {
- Utils.sayTestStarted("testEmbedCollectionOfObjectsWithCollectionAttribute");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart embeddable1 = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
- SWTBotGefEditPart embeddable2 = editorProxy.addEmbeddableToDiagram(50,
- 200, jpaProject);
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(200, 50, jpaProject);
-
- assertFalse(
- "\"Other Attributes\" section must not be visible!",
- editorProxy.isSectionVisible(JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes, embeddable1));
-
- String attributeName = editorProxy.getUniqueAttrName(embeddable1);
- editorProxy.addElementCollectionAttributeToJPT(embeddable1, attributeName);
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- editorProxy.testNoEmbeddedConnectionIsCreated(
- JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, 0, entity, embeddable1, false);
-
- editorProxy.testNoEmbeddedConnectionIsCreated(
- JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, 0, embeddable2, embeddable1, false);
-
- editorProxy._testEmbeddedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddable1,
- embeddable2, HasReferenceType.COLLECTION,
- MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
- JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
- 3);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testEmbedCollectionOfObjectsWithCollectionAttribute");
- }
-
- /**
- * Removes the attribute using the "Delete Attribute" context button.
- */
- @Test
- public void testRemoveAttributeFromEmbeddableViaContextButton() {
- Utils.sayTestStarted("testRemoveAttributeFromEmbeddableViaContextButton");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- String attributeName = editorProxy.getUniqueAttrName(embeddable);
- editorProxy.removeAttributeViaButton(embeddable, attributeName);
-
- embeddable.click();
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testRemoveAttributeFromEmbeddableViaContextButton");
- }
-
- /**
- * Removes the attribute using the "Delete" context menu.
- */
- @Test
- public void testRemoveAttributeFromEmbeddableViaMenu() {
- Utils.sayTestStarted("testRemoveAttributeFromEmbeddableViaMenu");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- String attributeName = editorProxy.getUniqueAttrName(embeddable);
- editorProxy.removeAttributeViaMenu(embeddable, attributeName);
-
- embeddable.click();
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testRemoveAttributeFromEmbeddableViaMenu");
- }
-
- /**
- * Adds a new attribute and rename it
- */
- @Test
- public void testDirectEditingAttributeInEmbeddable() {
- Utils.sayTestStarted("testDirectEditingAttributeInEmbeddable");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- String attributeName = editorProxy.getUniqueAttrName(embeddable);
- editorProxy.directEditAttribute(embeddable, attributeName);
-
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testDirectEditingAttributeInEmbeddable");
- }
-
- /**
- * Adds a new embeddable and rename it
- */
- @Ignore
- @Test
- public void testDirectEditingEmbeddable() {
- Utils.sayTestStarted("testDirectEditingEmbeddable");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
- String oldEmbeddableName = editorProxy.getJPTObjectForGefElement(embeddable).getSimpleName();
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- editorProxy.moveMouse(100, 70);
- embeddable.click();
- embeddable.activateDirectEdit();
- jpaDiagramEditor.directEditType("NewEntityName");
- editorProxy.moveMouse(0, 0);
-
- SWTBotGefEditPart oldEmbeddable = jpaDiagramEditor
- .getEditPart(oldEmbeddableName);
- SWTBotGefEditPart newEmbeddable = jpaDiagramEditor
- .getEditPart("NewEntityName");
- assertNotNull("The entity must be renamed!", newEmbeddable);
- assertNull("The attribute must be renamed!", oldEmbeddable);
-
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testDirectEditingEmbeddable");
- }
-
- /**
- * Test that the source of the embeddable is opened, when is double clicked
- * on it
- */
- @Ignore
- @Test
- public void testDoubleClickOnEmbeddable() {
- Utils.sayTestStarted("testDoubleClickOnEmbeddable");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- editorProxy.moveMouse(100, 70);
- jpaDiagramEditor.doubleClick(embeddable);
- editorProxy.moveMouse(0, 0);
-
- SWTBotEditor activeEditor = workbenchBot.activeEditor();
- assertEquals("The Java editor of the enity did not open!",
- "Embeddable1.java", activeEditor.getTitle());
- activeEditor.close();
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testDoubleClickOnEmbeddable");
- }
-
- /**
- * Change the attribute type.
- */
- @Test
- public void testChangeAttributeTypeInEmbeddable() {
- Utils.sayTestStarted("testChangeAttributeTypeInEmbeddable");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- assertFalse(
- "\"Other Attributes\" section must not be visible!",
- editorProxy
- .isSectionVisible(
- JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
- embeddable));
-
- String attributeName = editorProxy.getUniqueAttrName(embeddable);
- SWTBotGefEditPart attribute = editorProxy.addAttributeToJPT(embeddable,
- attributeName);
- assertNotNull("The attribute must not be renamed!", attribute);
-
- final IFeatureProvider fp = ((DiagramEditPart) jpaDiagramEditor
- .mainEditPart().part()).getFeatureProvider();
-
- String currentAttributeType = editorProxy.getAttributeType(
- attributeName, fp);
- assertEquals("java.lang.String", currentAttributeType);
-
- SWTBotShell changeTypeDialog = editorProxy
- .getSelectNewAttributeTypeDialog(attribute);
- SWTBotText attributeType = editorProxy
- .getNewTypeInputField(changeTypeDialog);
-
- // test invalid attribute type
- attributeType.setText("");
- assertFalse(editorProxy.getOkButton(changeTypeDialog).isEnabled());
- assertTrue(editorProxy.getCancelButton(changeTypeDialog).isEnabled());
- SWTBotText dialogError = editorProxy
- .getDialogErroMessage(changeTypeDialog);
- assertEquals(" The new type name must not be empty",
- dialogError.getText());
- // cancel the dialog
- editorProxy.getCancelButton(changeTypeDialog).click();
-
- // assert that the attribute type is not changed
- currentAttributeType = editorProxy.getAttributeType(attributeName, fp);
- assertEquals("The attribute type must not be changed!",
- "java.lang.String", currentAttributeType);
-
- changeTypeDialog = editorProxy
- .getSelectNewAttributeTypeDialog(attribute);
- attributeType = editorProxy.getNewTypeInputField(changeTypeDialog);
-
- // change the attribute type to int
- attributeType.setText("int");
- assertTrue(editorProxy.getOkButton(changeTypeDialog).isEnabled());
- assertTrue(editorProxy.getCancelButton(changeTypeDialog).isEnabled());
- // confirm the dialog
- editorProxy.getOkButton(changeTypeDialog).click();
- editorProxy.waitASecond();
- // assert that the attribute's type is changed
- String newAttributeType = editorProxy
- .getAttributeType(attributeName, fp);
- assertFalse("The attribute type must be changed!",
- ("java.lang.String").equals(newAttributeType));
- assertEquals("The attribute type must be changed!", "int",
- newAttributeType);
-
- assertTrue("Editor must be dirty!", jpaDiagramEditor.isDirty());
- embeddable.click();
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testChangeAttributeTypeInEmbeddable");
- }
-
- /**
- * Rename the embeddable using its context menu
- * "Refactor Entity Class -> Rename..."
- */
- @Ignore
- @Test
- public void testRenameEmbeddableViaMenu() {
- Utils.sayTestStarted("testRenameEmbeddableViaMenu");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
- String oldEmbeddableName = editorProxy.getJPTObjectForGefElement(embeddable).getSimpleName();
-
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- embeddable.click();
- jpaDiagramEditor
- .clickContextMenu(JPAEditorMessages.JPAEditorToolBehaviorProvider_renameEntityClass);
-
- SWTBotShell renameEntityDialog = editorProxy.getRenameEntityDialog();
- SWTBotText embeddableName = renameEntityDialog.bot().textWithLabel(
- "New name:");
-
- // test invalid entity name
- embeddableName.setText("");
- assertFalse(editorProxy.getFinishButton(renameEntityDialog).isEnabled());
- assertTrue(editorProxy.getCancelButton(renameEntityDialog).isEnabled());
-
- embeddableName.setText("NewEntityName");
- assertTrue(editorProxy.getFinishButton(renameEntityDialog).isEnabled());
- assertTrue(editorProxy.getCancelButton(renameEntityDialog).isEnabled());
-
- editorProxy.getFinishButton(renameEntityDialog).click();
- bot.waitUntil(new ElementIsShown(jpaDiagramEditor, "NewEntityName"),
- 10000);
-
- embeddable = jpaDiagramEditor.getEditPart("NewEntityName");
- assertNotNull("Entity name must be changed!", embeddable);
-
- assertNull("Entity naem must be changed!",
- jpaDiagramEditor.getEditPart(oldEmbeddableName));
-
- embeddable.click();
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testRenameEmbeddableViaMenu");
- }
-
- /**
- * Move the embeddable class using the embeddable's context menu
- * "Refactor Entity Class -> Move..."
- */
- @Ignore
- @Test
- public void testMoveEmbeddableViaMenu() throws JavaModelException {
- Utils.sayTestStarted("testMoveEmbeddableViaMenu");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
- String embeddableName = editorProxy.getJPTObjectForGefElement(embeddable).getSimpleName();
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- JpaArtifactFactory factory = JpaArtifactFactory.instance();
-
- String packageName = factory
- .getMappedSuperclassPackageDeclaration(editorProxy
- .getJPTObjectForGefElement(embeddable));
-
- embeddable.click();
- jpaDiagramEditor
- .clickContextMenu(JPAEditorMessages.JPAEditorToolBehaviorProvider_moveEntityClass);
-
- SWTBotShell moveEntityDialog = editorProxy.getMoveEntityDialog();
- moveEntityDialog.bot().tree().getTreeItem(TEST_PROJECT).select()
- .expandNode("src").expandNode("org").select().click();
- assertTrue(editorProxy.getOkButton(moveEntityDialog).isEnabled());
- editorProxy.getOkButton(moveEntityDialog).click();
- editorProxy.waitASecond();
-
- embeddable = jpaDiagramEditor.getEditPart(embeddableName);
- String newEntityPackage = factory
- .getMappedSuperclassPackageDeclaration(editorProxy
- .getJPTObjectForGefElement(embeddable));
- assertFalse("Entity must be moved!",
- packageName.equals(newEntityPackage));
- assertTrue("Entity must be changed!", newEntityPackage.equals("org"));
-
- embeddable.click();
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testMoveEmbeddableViaMenu");
- }
-
- /**
- * Collapse/expand embeddable using its context buttons
- */
- @Test
- public void testCollapseExapandEmbeddableViaContextButton() {
- Utils.sayTestStarted("testCollapseExapandEmbeddableViaContextButton");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- String attributeName = editorProxy.getUniqueAttrName(embeddable);
- editorProxy.addAttributeToJPT(embeddable, attributeName);
-
- editorProxy.collapseExpandJPTViaButton(embeddable);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testCollapseExapandEmbeddableViaContextButton");
- }
-
- /**
- * Collapse/expand embeddable using its context menus
- */
- @Test
- public void testCollapseExapandEmbeddableViaMenu() {
- Utils.sayTestStarted("testCollapseExapandEmbeddableViaMenu");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- String attributeName = editorProxy.getUniqueAttrName(embeddable);
- editorProxy.addAttributeToJPT(embeddable, attributeName);
-
- editorProxy.collapseExpandJPTViaMenu(embeddable);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testCollapseExapandEmbeddableViaMenu");
- }
-
- /**
- * Add a new attribute without saving the embeddable and call the
- * "Discard Changes" context menu. Assert that the newly added attribute is
- * removed and the embeddable does not contain unsaved changes.
- */
- @Ignore
- @Test
- public void testDiscardChangesFromEmbeddable() {
- Utils.sayTestStarted("testDiscardChangesFromEmbeddable");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- String attributeName = editorProxy.getUniqueAttrName(embeddable);
- editorProxy.discardChanges(embeddable, attributeName);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testDiscardChangesFromEmbeddable");
- }
-
- /**
- * Add a new attribute without saving the embeddable and call the
- * embeddable's context menu "Remove All Entities from Diagram -> ... and
- * Discard
- * Changes" context menu. Assert that the diagram is empty. Call "Show All
- * Entities" context menu and assert that the newly added attribute is
- * removed and the embeddable does not contain unsaved changes.
- */
- @Test
- public void testRemoveAndDiscardChangesFromEmbeddableViaMenu() {
- Utils.sayTestStarted("testRemoveAndDiscardChangesFromEmbeddableViaMenu");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- String attributeName = editorProxy.getUniqueAttrName(embeddable);
- editorProxy.removeAndDiscardChangesViaMenu(embeddable, attributeName);
-
- embeddable.click();
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testRemoveAndDiscardChangesFromEmbeddableViaMenu");
- }
-
- /**
- * Add a new attribute without saving the embeddable and call the
- * embeddable's context menu "Remove All Entities from Diagram -> ... and
- * Save Changes" context menu. Assert that the diagram is empty. Call "Show
- * All Entities" context menu and assert that the newly added attribute is
- * added and the embeddable does not contain unsaved changes.
- */
- @Test
- public void testRemoveAndSaveChangesToEmbeddableViaMenu() {
- Utils.sayTestStarted("testRemoveAndSaveChangesToEmbeddableViaMenu");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- String attributeName = editorProxy.getUniqueAttrName(embeddable);
- editorProxy.removeAndSaveChangesViaMenu(embeddable, attributeName);
-
- embeddable.click();
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testRemoveAndSaveChangesToEmbeddableViaMenu");
- }
-
- /**
- * Add a new attribute to the embeddable. From the embeddable's context menu
- * select "Save". Assert that the embeddable does not contain any unsaved
- * changes, but the diagram editor is still dirty.
- */
- @Test
- public void testSaveOnlyEmbeddable() {
- Utils.sayTestStarted("testSaveOnlyEmbeddable");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- String attributeName = editorProxy.getUniqueAttrName(embeddable);
- editorProxy.saveOnlyJPT(embeddable, attributeName);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testSaveOnlyEmbeddable");
- }
-
- /**
- * Add one entity and one embeddable in the diagram. Embed a single instance
- * of the embeddable into the entity and checks that the connection exists
- * and a new embedded attribute is added to the entity.
- */
- @Test
- public void testEmbedSingleObjectInEntity() {
- Utils.sayTestStarted("testEmbedSingleObjectInEntity");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 200, jpaProject);
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- editorProxy._testEmbeddedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, entity, embeddable,
- HasReferenceType.SINGLE,
- MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
- JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 2);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testEmbedSingleObjectInEntity");
- }
-
- /**
- * Add one entity and one embeddable in the diagram. Embed a collection of
- * the embeddable into the entity and checks that the connection exists and
- * a new embedded attribute is added to the entity.
- */
- @Test
- public void testEmbedCollectionOfObjectsInEntity() {
- Utils.sayTestStarted("testEmbedCollectionOfObjectsInEntity");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 200, jpaProject);
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- editorProxy._testEmbeddedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, entity,
- embeddable, HasReferenceType.COLLECTION,
- MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
- JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
- 2);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testEmbedCollectionOfObjectsInEntity");
- }
-
- /**
- * Add two embeddables in the diagram. Embed a single instance of the first
- * embeddable into the second embeddable and checks that the connection
- * exists and a new embedded attribute is added to the second embeddable.
- */
- @Test
- public void testEmbedSingleObjectInEmbeddable() {
- Utils.sayTestStarted("testEmbedSingleObjectInEmbeddable");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart embeddable1 = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
- SWTBotGefEditPart embeddable2 = editorProxy.addEmbeddableToDiagram(50,
- 200, jpaProject);
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- editorProxy._testEmbeddedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddable1,
- embeddable2, HasReferenceType.SINGLE,
- MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
- JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 2);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testEmbedSingleObjectInEmbeddable");
- }
-
- /**
- * Add two embeddables in the diagram. Embed a collection of the first
- * embeddable into the second embeddable and checks that the connection
- * exists and a new embedded attribute is added to the second embeddable.
- */
-
- @Test
- public void testEmbedCollectionOfObjectsInEmbeddable() {
- Utils.sayTestStarted("testEmbedCollectionOfObjectsInEmbeddable");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart embeddable1 = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
- SWTBotGefEditPart embeddable2 = editorProxy.addEmbeddableToDiagram(50,
- 200, jpaProject);
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- editorProxy._testEmbeddedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddable1,
- embeddable2, HasReferenceType.COLLECTION,
- MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
- JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
- 2);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testEmbedCollectionOfObjectsInEmbeddable");
- }
-
- /**
- * Add two embeddables and one entity in the diagram. Embed a collection of
- * the first embeddable to the second one. Check that it is not possible to
- * embed a collection of the second embeddable into the entity, but it is
- * possible to embed a collection of the first embeddable to the entity.
- */
-
- @Test
- public void testEmbedCollectionOfObjectsInEmbeddableAndEntity() {
- Utils.sayTestStarted("testEmbedCollectionOfObjectsInEmbeddableAndEntity");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart embeddable1 = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
- SWTBotGefEditPart embeddable2 = editorProxy.addEmbeddableToDiagram(50,
- 200, jpaProject);
-
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- editorProxy.embedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddable1,
- embeddable2, HasReferenceType.COLLECTION,
- MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
- JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
- 2);
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(200, 50,
- jpaProject);
-
- editorProxy.testNoEmbeddedConnectionIsCreated(
- JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, 0, entity, embeddable1, true);
-
- editorProxy._testEmbeddedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, entity,
- embeddable2, HasReferenceType.COLLECTION,
- MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
- JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
- 4);
-
-
- String embeddableName = editorProxy.getJPTObjectForGefElement(embeddable2).getSimpleName();
- String embeddingAttributeName = JPAEditorUtil.decapitalizeFirstLetter(embeddableName);
- editorProxy.deleteAttributeInJPT(embeddable1, embeddingAttributeName);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testEmbedCollectionOfObjectsInEmbeddableAndEntity");
- }
-
- /**
- * Add three embeddables in the diagram. Embed a collection of
- * the first embeddable to the second one. Check that it is not possible to
- * embed a collection of the second embeddable into the third one, but it is
- * possible to embed a collection of the first embeddable to the third embeddable.
- */
-
- @Test
- public void testEmbedCollectionOfObjectsInTwoEmbeddables() {
- Utils.sayTestStarted("testEmbedCollectionOfObjectsInTwoEmbeddables");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart embeddable1 = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
- SWTBotGefEditPart embeddable2 = editorProxy.addEmbeddableToDiagram(50,
- 200, jpaProject);
-
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- editorProxy.embedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddable1,
- embeddable2, HasReferenceType.COLLECTION,
- MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
- JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
- 2);
-
- SWTBotGefEditPart embeddable3 = editorProxy.addEmbeddableToDiagram(200, 50,
- jpaProject);
-
- editorProxy.testNoEmbeddedConnectionIsCreated(
- JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, 0, embeddable3, embeddable1, true);
-
- editorProxy._testEmbeddedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddable3,
- embeddable2, HasReferenceType.COLLECTION,
- MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
- JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
- 4);
-
- String embeddableName = editorProxy.getJPTObjectForGefElement(embeddable2).getSimpleName();
- String embeddingAttributeName = JPAEditorUtil.decapitalizeFirstLetter(embeddableName);
- editorProxy.deleteAttributeInJPT(embeddable1, embeddingAttributeName);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testEmbedCollectionOfObjectsInTwoEmbeddables");
- }
-
- /**
- * Test no one-to-one unidirectional relationship from entity to embeddable
- * is created.
- */
- @Test
- public void testOneToOneUniDirRelationFromEntityToEmbeddable() {
- Utils.sayTestStarted("testOneToOneUniDirRelationFromEntityToEmbeddable");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- 2, entity, embeddable);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testOneToOneUniDirRelationFromEntityToEmbeddable");
- }
-
- /**
- * Test no one-to-one bidirectional relationship from entity to embeddable
- * is created.
- */
- @Test
- public void testOneToOneBiDirRelationFromEntityToEmbeddable() {
- Utils.sayTestStarted("testOneToOneBiDirRelationFromEntityToEmbeddable");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- 3, entity, embeddable);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testOneToOneBiDirRelationFromEntityToEmbeddable");
- }
-
- /**
- * Test no one-to-many unidirectional relationship from entity to embeddable
- * is created.
- */
- @Test
- public void testOneToManyUniDirRelationFromEntityToEmbeddable() {
- Utils.sayTestStarted("testOneToManyUniDirRelationFromEntityToEmbeddable");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateOneToManyUniDirRelationFeature_oneToManyUniDirFeatureName,
- 0, entity, embeddable);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testOneToManyUniDirRelationFromEntityToEmbeddable");
- }
-
- /**
- * Test no many-to-one unidirectional relationship from entity to embeddable
- * is created.
- */
- @Test
- public void testManyToOneUniDirRelationFromEntityToEmbeddable() {
- Utils.sayTestStarted("testManyToOneUniDirRelationFromEntityToEmbeddable");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- 2, entity, embeddable);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testManyToOneUniDirRelationFromEntityToEmbeddable");
- }
-
- /**
- * Test no many-to-one bidirectional relationship from entity to embeddable
- * is created.
- */
- @Test
- public void testManyToOneBiDirRelationFromEntityToEmbeddable() {
- Utils.sayTestStarted("testManyToOneBiDirRelationFromEntityToEmbeddable");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- 3, entity, embeddable);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testManyToOneBiDirRelationFromEntityToEmbeddable");
- }
-
- /**
- * Test no many-to-many unidirectional relationship from entity to
- * embeddable is created.
- */
- @Test
- public void testManyToManyUniDirRelationFromEntityToEmbeddable() {
- Utils.sayTestStarted("testManyToManyUniDirRelationFromEntityToEmbeddable");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateManyToManyUniDirRelationFeature_manyToManyUniDirFeatureName,
- 0, entity, embeddable);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testManyToManyUniDirRelationFromEntityToEmbeddable");
- }
-
- /**
- * Test no many-to-many bidirectional relationship from entity to embeddable
- * is created.
- */
- @Test
- public void testManyToManyBiDirRelationFromEntityToEmbeddable() {
- Utils.sayTestStarted("testManyToManyBiDirRelationFromEntityToEmbeddable");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName,
- 1, entity, embeddable);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testManyToManyBiDirRelationFromEntityToEmbeddable");
- }
-
- /**
- * Test that if the embeddable is not embedded, no one-to-one bidirectional
- * relationship will be created from the embeddable to the entity. Add
- * second entity and embed a single value of the embeddable. Check that a
- * one-to-one relationship will be created from embeddable to the entity.
- * Check that if the inverse attribute will be deleted the connection will
- * be transformed into one-to-one unidirectional relationship. Test that if
- * the owner attribute will be deleted, the relationship will disappear.
- */
- @Test
- public void testOneToOneBiDirRelationFromEmbeddableToEntity() {
- Utils.sayTestStarted("testOneToOneBiDirRelationFromEmbeddableToEntity");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- 3, embeddable, entity);
-
- SWTBotGefEditPart embeddingEntity = editorProxy.addEntityToDiagram(200,
- 50, jpaProject);
-
- editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity, embeddable,
- HasReferenceType.SINGLE,
- MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
- JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
-
- editorProxy
- .testBiDirRel(
- JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- embeddable,
- entity,
- IRelation.RelType.ONE_TO_ONE,
- JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
-
- editorProxy
- .testBiDirRelRemoveInverseAttribute(
- JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- embeddable,
- entity,
- IRelation.RelType.ONE_TO_ONE,
- JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
-
- editorProxy
- .testBiDirRelRemoveOwnerAttr(
- JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- embeddable,
- entity,
- IRelation.RelType.ONE_TO_ONE,
- JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testOneToOneBiDirRelationFromEmbeddableToEntity");
- }
-
- /**
- * Test that if the embeddable is not embedded, no many-to-one bidirectional
- * relationship will be created from the embeddable to the entity. Add
- * second entity and embed a single value of the embeddable. Check that a
- * many-to-one relationship will be created from embeddable to the entity.
- * Check that if the inverse attribute will be deleted the connection will
- * be transformed into one-to-one unidirectional relationship. Test that if
- * the owner attribute will be deleted, the relationship will disappear.
- */
- @Test
- public void testManyToOneBiDirRelationFromEmbeddableToEntity() {
- Utils.sayTestStarted("testManyToOneBiDirRelationFromEmbeddableToEntity");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- 3, embeddable, entity);
-
- SWTBotGefEditPart embeddingEntity = editorProxy.addEntityToDiagram(200,
- 50, jpaProject);
-
- editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity, embeddable,
- HasReferenceType.SINGLE,
- MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
- JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
-
- editorProxy
- .testBiDirRelWithTwoMappingTypes(
- JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- embeddable,
- entity,
- IRelation.RelType.MANY_TO_ONE,
- JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel,
- JptJpaUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, true);
-
- editorProxy
- .testBiDirRelWithTwoMappingsWithoutInverseAttr(
- JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- embeddable,
- entity,
- IRelation.RelType.MANY_TO_ONE,
- JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel,
- JptJpaUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, true);
-
- editorProxy
- .testBiDirRelWithTwoMappingsWithoutOwnerAttr(
- JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- embeddable,
- entity,
- IRelation.RelType.MANY_TO_ONE,
- JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel,
- JptJpaUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, true);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testManyToOneBiDirRelationFromEmbeddableToEntity");
- }
-
- /**
- * Test that if the embeddable is not embedded, no many-to-many
- * bidirectional relationship will be created from the embeddable to the
- * entity. Add second entity and embed a single value of the embeddable.
- * Check that a many-to-many relationship will be created from embeddable to
- * the entity. Check that if the inverse attribute will be deleted the
- * connection will be transformed into one-to-one unidirectional
- * relationship. Test that if the owner attribute will be deleted, the
- * relationship will disappear.
- */
- @Test
- public void testManyToManyBiDirRelationFromEmbeddableToEntity() {
- Utils.sayTestStarted("testManyToManyBiDirRelationFromEmbeddableToEntity");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName,
- 1, embeddable, entity);
-
- SWTBotGefEditPart embeddingEntity = editorProxy.addEntityToDiagram(200,
- 50, jpaProject);
-
- editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity, embeddable,
- HasReferenceType.SINGLE,
- MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
- JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
-
- editorProxy
- .testBiDirRel(
- JPAEditorMessages.CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName,
- embeddable,
- entity,
- IRelation.RelType.MANY_TO_MANY,
- JptJpaUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
-
- editorProxy
- .testBiDirRelRemoveInverseAttribute(
- JPAEditorMessages.CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName,
- embeddable,
- entity,
- IRelation.RelType.MANY_TO_MANY,
- JptJpaUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
-
- editorProxy
- .testBiDirRelRemoveOwnerAttr(
- JPAEditorMessages.CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName,
- embeddable,
- entity,
- IRelation.RelType.MANY_TO_MANY,
- JptJpaUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testManyToManyBiDirRelationFromEmbeddableToEntity");
- }
-
- /**
- * Test that if the embeddable is not embedded, no one-to-one unidirectional
- * relationship will be created from the embeddable to the entity. Add
- * second entity and embed a single value of the embeddable. Check that a
- * one-to-one relationship will be created from embeddable to the entity.
- * Check that if the owner attribute will be deleted, the relationship will
- * disappear.
- */
- @Test
- public void testOneToOneUniDirRelationFromEmbeddableToEntity() {
- Utils.sayTestStarted("testOneToOneUniDirRelationFromEmbeddableToEntity");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- 2, embeddable, entity);
-
- SWTBotGefEditPart embeddingEntity = editorProxy.addEntityToDiagram(200,
- 50, jpaProject);
-
- editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity, embeddable,
- HasReferenceType.SINGLE,
- MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
- JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
-
- editorProxy
- .testUniDirRelation(
- JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- embeddable,
- entity,
- IRelation.RelType.ONE_TO_ONE,
- JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
-
- editorProxy
- .testUniDirRelRemoveOwnerAttribute(
- JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- embeddable,
- entity,
- IRelation.RelType.ONE_TO_ONE,
- JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testOneToOneUniDirRelationFromEmbeddableToEntity");
- }
-
- /**
- * Test that if the embeddable is not embedded, no many-to-one
- * unidirectional relationship will be created from the embeddable to the
- * entity. Add second entity and embed a single value of the embeddable.
- * Check that a many-to-one relationship will be created from embeddable to
- * the entity. Check that if the owner attribute will be deleted, the
- * relationship will disappear.
- */
- @Test
- public void testManyToOneUniDirRelationFromEmbeddableToEntity() {
- Utils.sayTestStarted("testManyToOneUniDirRelationFromEmbeddableToEntity");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- 2, embeddable, entity);
-
- SWTBotGefEditPart embeddingEntity = editorProxy.addEntityToDiagram(200,
- 50, jpaProject);
-
- editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity, embeddable,
- HasReferenceType.SINGLE,
- MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
- JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
-
- editorProxy
- .testUniDirRelation(
- JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- embeddable,
- entity,
- IRelation.RelType.MANY_TO_ONE,
- JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true);
-
- editorProxy
- .testUniDirRelRemoveOwnerAttribute(
- JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- embeddable,
- entity,
- IRelation.RelType.MANY_TO_ONE,
- JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testManyToOneUniDirRelationFromEmbeddableToEntity");
- }
-
- /**
- * Test that if the embeddable is not embedded, no many-to-many
- * unidirectional relationship will be created from the embeddable to the
- * entity. Add second entity and embed a single value of the embeddable.
- * Check that a many-to-many relationship will be created from embeddable to
- * the entity. Check that if the owner attribute will be deleted, the
- * relationship will disappear.
- */
- @Test
- public void testManyToManyUniDirRelationFromEmbeddableToEntity() {
- Utils.sayTestStarted("testManyToManyUniDirRelationFromEmbeddableToEntity");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateManyToManyUniDirRelationFeature_manyToManyUniDirFeatureName,
- 0, embeddable, entity);
-
- SWTBotGefEditPart embeddingEntity = editorProxy.addEntityToDiagram(200,
- 50, jpaProject);
-
- editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity, embeddable,
- HasReferenceType.SINGLE,
- MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
- JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
-
- editorProxy
- .testUniDirRelation(
- JPAEditorMessages.CreateManyToManyUniDirRelationFeature_manyToManyUniDirFeatureName,
- embeddable,
- entity,
- IRelation.RelType.MANY_TO_MANY,
- JptJpaUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
-
- editorProxy
- .testUniDirRelRemoveOwnerAttribute(
- JPAEditorMessages.CreateManyToManyUniDirRelationFeature_manyToManyUniDirFeatureName,
- embeddable,
- entity,
- IRelation.RelType.MANY_TO_MANY,
- JptJpaUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testManyToManyUniDirRelationFromEmbeddableToEntity");
- }
-
- /**
- * Test that if the embeddable is not embedded, no one-to-one bidirectional
- * relationship will be created from the embeddable to the entity. Add
- * second entity and embed a collection of the embeddable. Check that a
- * one-to-one relationship will be created from embeddable to the entity.
- * Check that if the owner attribute will be deleted, the relationship will
- * disappear.
- */
- @Test
- public void testOneToOneBiDirRelationFromEmbeddedCollectionToEntity() {
- Utils.sayTestStarted("testOneToOneBiDirRelationFromEmbeddableToEntity");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- 3, embeddable, entity);
-
- SWTBotGefEditPart embeddingEntity = editorProxy.addEntityToDiagram(200,
- 50, jpaProject);
-
- editorProxy.embedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddingEntity,
- embeddable, HasReferenceType.COLLECTION,
- MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
- JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
- 3);
-
- editorProxy
- .testBiDirRel(
- JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- embeddable,
- entity,
- IRelation.RelType.ONE_TO_ONE,
- JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
-
- editorProxy
- .testBiDirRelRemoveInverseAttribute(
- JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- embeddable,
- entity,
- IRelation.RelType.ONE_TO_ONE,
- JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
-
- editorProxy
- .testBiDirRelRemoveOwnerAttr(
- JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- embeddable,
- entity,
- IRelation.RelType.ONE_TO_ONE,
- JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testOneToOneBiDirRelationFromEmbeddableToEntity");
- }
-
- /**
- * Test that if the embeddable is not embedded, no many-to-one bidirectional
- * relationship will be created from the embeddable to the entity. Add
- * second entity and embed a collection of the embeddable. Check that a
- * many-to-one relationship will be created from embeddable to the entity.
- * Check that if the owner attribute will be deleted, the relationship will
- * disappear.
- */
-
- @Test
- public void testManyToOneBiDirRelationFromEmbeddedCollectionToEntity() {
- Utils.sayTestStarted("testManyToOneBiDirRelationFromEmbeddableToEntity");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- 3, embeddable, entity);
-
- SWTBotGefEditPart embeddingEntity = editorProxy.addEntityToDiagram(200,
- 50, jpaProject);
-
- editorProxy.embedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddingEntity,
- embeddable, HasReferenceType.COLLECTION,
- MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
- JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
- 3);
-
- editorProxy
- .testBiDirRelWithTwoMappingTypes(
- JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- embeddable,
- entity,
- IRelation.RelType.MANY_TO_ONE,
- JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel,
- JptJpaUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, true);
-
- editorProxy
- .testBiDirRelWithTwoMappingsWithoutInverseAttr(
- JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- embeddable,
- entity,
- IRelation.RelType.MANY_TO_ONE,
- JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel,
- JptJpaUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, true);
-
- editorProxy
- .testBiDirRelWithTwoMappingsWithoutOwnerAttr(
- JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- embeddable,
- entity,
- IRelation.RelType.MANY_TO_ONE,
- JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel,
- JptJpaUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, true);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testManyToOneBiDirRelationFromEmbeddableToEntity");
- }
-
- /**
- * Test that no one-to-one bidirectional relationship will be created, if
- * the embeddable is embedded in two entities.
- */
- @Test
- public void testNoOneToOneBiDirConnectionIsCreatedInEmbeddableInTwoEntities() {
- Utils.sayTestStarted("testNoOneToOneBiDirConnectionIsCreatedInEmbeddableInTwoEntities");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
-
- SWTBotGefEditPart embeddingEntity1 = editorProxy.addEntityToDiagram(
- 200, 50, jpaProject);
-
- SWTBotGefEditPart embeddingEntity2 = editorProxy.addEntityToDiagram(
- 200, 200, jpaProject);
-
- editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity1, embeddable,
- HasReferenceType.SINGLE,
- MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
- JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
-
- editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity2, embeddable,
- HasReferenceType.SINGLE,
- MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
- JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
-
- editorProxy
- .testNoConnectionIsCreatedWithEmbeddable(
- JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- 1, entity, embeddable);
-
- editorProxy
- .testUniDirRelation(
- JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- embeddable,
- entity,
- IRelation.RelType.ONE_TO_ONE,
- JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
-
- editorProxy
- .testUniDirRelRemoveOwnerAttribute(
- JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- embeddable,
- entity,
- IRelation.RelType.ONE_TO_ONE,
- JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testNoOneToOneBiDirConnectionIsCreatedInEmbeddableInTwoEntities");
- }
-
- /**
- * Test that no many-to-one bidirectional relationship will be created, if
- * the embeddable is embedded in two entities.
- */
- @Test
- public void testNoManyToOneBiDirConnectionIsCreatedInEmbeddableInTwoEntities() {
- Utils.sayTestStarted("testNoBiDirConnectionIsCreatedInEmbeddableInTwoEntities");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
-
- SWTBotGefEditPart embeddingEntity1 = editorProxy.addEntityToDiagram(
- 200, 50, jpaProject);
-
- SWTBotGefEditPart embeddingEntity2 = editorProxy.addEntityToDiagram(
- 200, 200, jpaProject);
-
- editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity1, embeddable,
- HasReferenceType.SINGLE,
- MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
- JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
-
- editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity2, embeddable,
- HasReferenceType.SINGLE,
- MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
- JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
-
- editorProxy
- .testNoConnectionIsCreatedWithEmbeddable(
- JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- 1, entity, embeddable);
-
- editorProxy
- .testUniDirRelation(
- JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- embeddable,
- entity,
- IRelation.RelType.MANY_TO_ONE,
- JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true);
-
- editorProxy
- .testUniDirRelRemoveOwnerAttribute(
- JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- embeddable,
- entity,
- IRelation.RelType.MANY_TO_ONE,
- JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testNoBiDirConnectionIsCreatedInEmbeddableInTwoEntities");
- }
-
- /**
- * Test that no many-to-many bidirectional relationship will be created, if
- * the embeddable is embedded in two entities.
- */
- @Test
- public void testNoManyToManyBiDirConnectionIsCreatedInEmbeddableInTwoEntities() {
- Utils.sayTestStarted("testNoManyToManyBiDirConnectionIsCreatedInEmbeddableInTwoEntities");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
-
- SWTBotGefEditPart embeddingEntity1 = editorProxy.addEntityToDiagram(
- 200, 50, jpaProject);
-
- SWTBotGefEditPart embeddingEntity2 = editorProxy.addEntityToDiagram(
- 200, 200, jpaProject);
-
- editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity1, embeddable,
- HasReferenceType.SINGLE,
- MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
- JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
-
- editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity2, embeddable,
- HasReferenceType.SINGLE,
- MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
- JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
-
- editorProxy
- .testNoConnectionIsCreatedWithEmbeddable(
- JPAEditorMessages.CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName,
- 1, entity, embeddable);
-
- editorProxy
- .testUniDirRelation(
- JPAEditorMessages.CreateManyToManyUniDirRelationFeature_manyToManyUniDirFeatureName,
- embeddable,
- entity,
- IRelation.RelType.MANY_TO_MANY,
- JptJpaUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
-
- editorProxy
- .testUniDirRelRemoveOwnerAttribute(
- JPAEditorMessages.CreateManyToManyUniDirRelationFeature_manyToManyUniDirFeatureName,
- embeddable,
- entity,
- IRelation.RelType.MANY_TO_MANY,
- JptJpaUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testNoManyToManyBiDirConnectionIsCreatedInEmbeddableInTwoEntities");
- }
-
- /**
- * Test that if the embeddable is not embedded, no one-to-one unidirectional
- * relationship will be created from the embeddable to the entity. Add
- * second entity and embed a collection of the embeddable. Check that a
- * one-to-one relationship will be created from embeddable to the entity.
- * Check that if the owner attribute will be deleted, the relationship will
- * disappear.
- */
- @Test
- public void testOneToOneUniDirRelationFromEmbeddedCollectionToEntity() {
- Utils.sayTestStarted("testOneToOneUniDirRelationFromEmbeddedCollectionToEntity");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- 2, embeddable, entity);
-
- SWTBotGefEditPart embeddingEntity = editorProxy.addEntityToDiagram(200,
- 50, jpaProject);
-
- editorProxy.embedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddingEntity,
- embeddable, HasReferenceType.COLLECTION,
- MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
- JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
- 3);
-
- editorProxy
- .testUniDirRelation(
- JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- embeddable,
- entity,
- IRelation.RelType.ONE_TO_ONE,
- JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
-
- editorProxy
- .testUniDirRelRemoveOwnerAttribute(
- JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- embeddable,
- entity,
- IRelation.RelType.ONE_TO_ONE,
- JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testOneToOneUniDirRelationFromEmbeddedCollectionToEntity");
- }
-
- /**
- * Test that if the embeddable is not embedded, no many-to-one
- * unidirectional relationship will be created from the embeddable to the
- * entity. Add second entity and embed a collection of the embeddable. Check
- * that a many-to-one relationship will be created from embeddable to the
- * entity. Check that if the owner attribute will be deleted, the
- * relationship will disappear.
- */
- @Test
- public void testManyToOneUniDirRelationFromEmbeddedCollectionToEntity() {
- Utils.sayTestStarted("testManyToOneUniDirRelationFromEmbeddedCollectionToEntity");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- 2, embeddable, entity);
-
- SWTBotGefEditPart embeddingEntity = editorProxy.addEntityToDiagram(200,
- 50, jpaProject);
-
- editorProxy.embedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddingEntity,
- embeddable, HasReferenceType.COLLECTION,
- MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
- JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
- 3);
-
- editorProxy
- .testUniDirRelation(
- JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- embeddable,
- entity,
- IRelation.RelType.MANY_TO_ONE,
- JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true);
-
- editorProxy
- .testUniDirRelRemoveOwnerAttribute(
- JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- embeddable,
- entity,
- IRelation.RelType.MANY_TO_ONE,
- JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testManyToOneUniDirRelationFromEmbeddedCollectionToEntity");
- }
-
- /**
- * Test that if a collection of embeddable is embedded into an entity,
- * neither uni- nor bi-directional many-to-many relationships will be
- * created.
- */
- @Test
- public void testManyToManyRelationFromEmbeddedCollectionToEntity() {
- Utils.sayTestStarted("testManyToManyRelationFromEmbeddedCollectionToEntity");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateManyToManyUniDirRelationFeature_manyToManyUniDirFeatureName,
- 0, embeddable, entity);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName,
- 1, embeddable, entity);
-
- SWTBotGefEditPart embeddingEntity = editorProxy.addEntityToDiagram(200,
- 50, jpaProject);
-
- editorProxy.embedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddingEntity,
- embeddable, HasReferenceType.COLLECTION,
- MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
- JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
- 3);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName,
- 0, embeddable, entity);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName,
- 1, embeddable, entity);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testManyToManyRelationFromEmbeddedCollectionToEntity");
- }
-
- /**
- * Test that if a collection of embeddable is embedded into an entity, no
- * one-to-many unidirectional relationships will be created.
- */
- @Test
- public void testOneToManyRelationFromEmbeddedCollectionToEntity() {
- Utils.sayTestStarted("testOneToManyRelationFromEmbeddedCollectionToEntity");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 200,
- jpaProject);
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateOneToManyUniDirRelationFeature_oneToManyUniDirFeatureName,
- 0, embeddable, entity);
-
- SWTBotGefEditPart embeddingEntity = editorProxy.addEntityToDiagram(200,
- 50, jpaProject);
-
- editorProxy.embedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddingEntity,
- embeddable, HasReferenceType.COLLECTION,
- MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
- JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
- 3);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateOneToManyUniDirRelationFeature_oneToManyUniDirFeatureName,
- 0, embeddable, entity);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.saveAndClose();
-
- Utils.sayTestFinished("testOneToManyRelationFromEmbeddedCollectionToEntity");
- }
-
- @Test
- public void testJPA10WithEmbeddables() throws CoreException {
- Utils.sayTestStarted("testJPA10WithEmbeddables");
-
- workbenchBot.closeAllEditors();
-
- String name = "Test10_" + System.currentTimeMillis();
-
- JpaProject jpaProject10 = factory.createJPAProject(name);
- assertNotNull(jpaProject10);
-
- SWTBotGefEditor jpaDiagramEditor10 = editorProxy
- .openDiagramOnJPAProjectNode(name, false);
- editorProxy.setJpaDiagramEditor(jpaDiagramEditor10);
-
- SWTBotGefEditPart embeddable1 = editorProxy.addEmbeddableToDiagram(50,
- 50, jpaProject);
- SWTBotGefEditPart embeddable2 = editorProxy.addEmbeddableToDiagram(50,
- 200, jpaProject);
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(300, 50,
- jpaProject);
-
- boolean notAllowed = false;
-
- try {
- jpaDiagramEditor10.activateTool(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName);
- } catch (WidgetNotFoundException e) {
- notAllowed = true;
- }
-
- assertTrue(
- "The action \"Embed Collection of Elements\" must not be available by JPA projects with 1.0 facet.",
- notAllowed);
-
- editorProxy.testNoEmbeddedConnectionIsCreated(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, 0, embeddable1, embeddable2, false);
-
- editorProxy.embedConnection(jpaDiagramEditor10, JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, entity, embeddable1,
- HasReferenceType.SINGLE,
- MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
- JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 2);
-
- SWTBotGefEditPart entity1 = editorProxy.addEntityToDiagram(300, 300,
- jpaProject);
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateOneToManyUniDirRelationFeature_oneToManyUniDirFeatureName,
- 0, embeddable1, entity1);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- 0, embeddable1, entity1);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- 1, embeddable1, entity1);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- 0, embeddable1, entity1);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- 1, embeddable1, entity1);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateManyToManyUniDirRelationFeature_manyToManyUniDirFeatureName,
- 0, embeddable1, entity1);
-
- editorProxy
- .testNoConnectionIsCreated(
- JPAEditorMessages.CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName,
- 1, embeddable1, entity1);
-
- String embeddableName = editorProxy.getJPTObjectForGefElement(embeddable1).getSimpleName();
- String embeddingAttributeName = JPAEditorUtil.decapitalizeFirstLetter(embeddableName);
- editorProxy.deleteAttributeInJPT(entity, embeddingAttributeName);
-
- editorProxy.deleteDiagramElements();
-
- jpaDiagramEditor10.saveAndClose();
-
- Utils.sayTestFinished("testJPA10WithEmbeddables");
-
- }
-
- @After
- public void tearDown() throws Exception {
- editorProxy.deleteResources(jpaProject);
- }
-}
-
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
deleted file mode 100644
index 089c066..0000000
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EntitiesInDiagramSWTBotTest.java
+++ /dev/null
@@ -1,2379 +0,0 @@
-package org.eclipse.jpt.jpadiagrameditor.swtbot.tests.ui.editor;
-
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.graphiti.features.IFeatureProvider;
-import org.eclipse.graphiti.mm.pictograms.PictogramElement;
-import org.eclipse.graphiti.ui.internal.parts.DiagramEditPart;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.Entity;
-import org.eclipse.jpt.jpa.core.context.PersistentType;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.ui.details.JptJpaUiDetailsMessages;
-import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.internal.JPACreateFactory;
-import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.internal.Utils;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IRelation;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
-import org.eclipse.swtbot.eclipse.gef.finder.SWTBotGefTestCase;
-import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
-import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
-import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
-import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
-import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotStyledText;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
-import org.junit.After;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(SWTBotJunit4ClassRunner.class)
-@SuppressWarnings("restriction")
-public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
-
- protected static String TEST_PROJECT;
- protected static JPACreateFactory factory = JPACreateFactory.instance();
- protected static JpaProject jpaProject;
-
- protected static SWTGefBot bot = new SWTGefBot();
- protected static SWTWorkbenchBot workbenchBot = new SWTWorkbenchBot();
- protected static EditorProxy editorProxy = new EditorProxy(workbenchBot,
- bot);
-
- protected static SWTBotGefEditor jpaDiagramEditor;
-
- @BeforeClass
- public static void beforeClass() throws Exception {
-
- SWTBotPreferences.TIMEOUT = 1000;
- try {
- bot.viewByTitle("Welcome").close();
- } catch (Exception e) {
- // ignore
- } finally {
- SWTBotPreferences.TIMEOUT = 5000;
- }
- workbenchBot.perspectiveByLabel("JPA").activate();
-
- TEST_PROJECT = "Test_" + System.currentTimeMillis();
-
- factory = JPACreateFactory.instance();
- jpaProject = factory.createJPA20Project(TEST_PROJECT);
- assertNotNull(jpaProject);
-
- workbenchBot.closeAllEditors();
-
- jpaDiagramEditor = editorProxy.openDiagramOnJPAProjectNode(
- TEST_PROJECT, true);
- editorProxy.setJpaDiagramEditor(jpaDiagramEditor);
-
- Thread.sleep(2000);
- }
-
- /**
- * Add entity to diagram and check that it contains a "Primary Key" section
- * with one attribute "id" and no "Relation Attributes" and
- * "Other Attributes" sections.
- */
- @Test
- public void testAddEntity() {
- Utils.sayTestStarted("testAddEntity");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- editorProxy.addEntityToDiagram(50, 50, jpaProject);
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- jpaDiagramEditor.save();
- assertFalse("Editor must not be dirty!", jpaDiagramEditor.isDirty());
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testAddEntity");
- }
-
- /**
- * Remove an entity from the diagram using the entity's context button
- * "Delete"
- */
- @Test
- public void testRemoveEntityViaButton() {
- Utils.sayTestStarted("testRemoveEntityViaButton");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- editorProxy.deleteJPTViaButton(entity);
-
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testRemoveEntityViaButton");
- }
-
- /**
- * Remove an entity from the diagram using the entity's context menu
- * "Delete"
- */
- @Test
- public void testRemoveEntityViaContextMenu() {
- Utils.sayTestStarted("testRemoveEntityViaContextMenu");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- editorProxy.deleteJPTViaMenu(entity);
-
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testRemoveEntityViaContextMenu");
- }
-
- /**
- * Adds a new attribute to the entity using the entity's context button
- * "Create Attribute"
- */
- @Test
- public void testAddAttribute() {
- Utils.sayTestStarted("testAddAttribute");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- assertFalse(
- "\"Other Attributes\" section must not be visible!",
- editorProxy
- .isSectionVisible(
- JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
- entity));
-
- String attributeName = editorProxy.getUniqueAttrName(entity);
- editorProxy.addAttributeToJPT(entity, attributeName);
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- entity.click();
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testAddAttribute");
- }
-
- @Ignore
- @Test
- public void testAddElementCollectionAttribute() {
- Utils.sayTestStarted("testAddElementCollectionAttribute");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- assertFalse(
- "\"Other Attributes\" section must not be visible!",
- editorProxy
- .isSectionVisible(
- JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
- entity));
-
- String attributeName = editorProxy.getUniqueAttrName(entity);
- editorProxy.addElementCollectionAttributeToJPT(entity, attributeName);
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- entity.click();
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testAddElementCollectionAttribute");
- }
-
- /**
- * Removes the attribute using the "Delete Attribute" context button.
- */
- @Test
- public void testRemoveAttributeViaContextButton() {
- Utils.sayTestStarted("testRemoveAttributeViaContextButton");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- String attributeName = editorProxy.getUniqueAttrName(entity);
- editorProxy.removeAttributeViaButton(entity, attributeName);
-
- entity.click();
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testRemoveAttributeViaContextButton");
- }
-
- /**
- * Removes the attribute using the "Delete" context menu.
- */
- @Test
- public void testRemoveAttributeViaMenu() {
- Utils.sayTestStarted("testRemoveAttributeViaMenu");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- String attributeName = editorProxy.getUniqueAttrName(entity);
- editorProxy.removeAttributeViaMenu(entity, attributeName);
-
- entity.click();
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testRemoveAttributeViaMenu");
- }
-
- /**
- * Adds a new attribute and rename it
- */
- @Test
- public void testDirectEditingAttribute() {
- Utils.sayTestStarted("testDirectEditingAttribute");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- String attributeName = editorProxy.getUniqueAttrName(entity);
- editorProxy.directEditAttribute(entity, attributeName);
-
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testDirectEditingAttribute");
- }
-
- /**
- * Adds a new entity and rename it
- */
- @Ignore
- @Test
- public void testDirectEditingEntity() {
- Utils.sayTestStarted("testDirectEditingEntity");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- String oldEntityName = editorProxy.getJPTObjectForGefElement(entity).getSimpleName();
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- editorProxy.moveMouse(100, 70);
- entity.click();
- entity.activateDirectEdit();
- jpaDiagramEditor.directEditType("NewEntityName");
- editorProxy.moveMouse(0, 0);
-
- SWTBotGefEditPart oldEntity = jpaDiagramEditor.getEditPart(oldEntityName);
- SWTBotGefEditPart newEntity = jpaDiagramEditor
- .getEditPart("NewEntityName");
- assertNotNull("The entity must be renamed!", newEntity);
- assertNull("The attribute must be renamed!", oldEntity);
-
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testDirectEditingEntity");
- }
-
- /**
- * Test that the source of the entity is opened, when is double clicked on
- * it
- */
- @Ignore
- @Test
- public void testDoubleClickOnEntity() {
- Utils.sayTestStarted("testDoubleClickOnEntity");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
- editorProxy.moveMouse(100, 70);
- jpaDiagramEditor.doubleClick(entity);
- editorProxy.moveMouse(0, 0);
-
- SWTBotEditor activeEditor = workbenchBot.activeEditor();
- assertEquals("The Java editor of the enity did not open!",
- "Entity1.java", activeEditor.getTitle());
- activeEditor.close();
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testDoubleClickOnEntity");
- }
-
- /**
- * Change the attribute type.
- */
- @Test
- public void testChangeAttributeType() {
- Utils.sayTestStarted("testChangeAttributeType");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- assertFalse(
- "\"Other Attributes\" section must not be visible!",
- editorProxy
- .isSectionVisible(
- JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
- entity));
-
- String attributeName = editorProxy.getUniqueAttrName(entity);
- SWTBotGefEditPart attribute = editorProxy.addAttributeToJPT(entity,
- attributeName);
- assertNotNull("The attribute must not be renamed!", attribute);
-
- final IFeatureProvider fp = ((DiagramEditPart) jpaDiagramEditor
- .mainEditPart().part()).getFeatureProvider();
-
- String currentAttributeType = editorProxy.getAttributeType(
- attributeName, fp);
- assertEquals("java.lang.String", currentAttributeType);
-
- SWTBotShell changeTypeDialog = editorProxy
- .getSelectNewAttributeTypeDialog(attribute);
- SWTBotText attributeType = editorProxy
- .getNewTypeInputField(changeTypeDialog);
-
- // test invalid attribute type
- attributeType.setText("");
- assertFalse(editorProxy.getOkButton(changeTypeDialog).isEnabled());
- assertTrue(editorProxy.getCancelButton(changeTypeDialog).isEnabled());
- SWTBotText dialogError = editorProxy
- .getDialogErroMessage(changeTypeDialog);
- assertEquals(" The new type name must not be empty",
- dialogError.getText());
- // cancel the dialog
- editorProxy.getCancelButton(changeTypeDialog).click();
-
- // assert that the attribute type is not changed
- currentAttributeType = editorProxy.getAttributeType(attributeName, fp);
- assertEquals("The attribute type must not be changed!",
- "java.lang.String", currentAttributeType);
-
- changeTypeDialog = editorProxy
- .getSelectNewAttributeTypeDialog(attribute);
- attributeType = editorProxy.getNewTypeInputField(changeTypeDialog);
-
- // change the attribute type to int
- attributeType.setText("int");
- assertTrue(editorProxy.getOkButton(changeTypeDialog).isEnabled());
- assertTrue(editorProxy.getCancelButton(changeTypeDialog).isEnabled());
- // confirm the dialog
- editorProxy.getOkButton(changeTypeDialog).click();
- editorProxy.waitASecond();
- // assert that the attribute's type is changed
- String newAttributeType = editorProxy
- .getAttributeType(attributeName, fp);
- assertFalse("The attribute type must be changed!",
- ("java.lang.String").equals(newAttributeType));
- assertEquals("The attribute type must be changed!", "int",
- newAttributeType);
-
- assertTrue("Editor must be dirty!", jpaDiagramEditor.isDirty());
- entity.click();
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testChangeAttributeType");
- }
-
- /**
- * Rename the entity using its context menu
- * "Refactor Entity Class -> Rename..."
- */
- @Ignore
- @Test
- public void testRenameEntityViaMenu() {
- Utils.sayTestStarted("testRenameEntityViaMenu");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
- String oldEntityName = editorProxy.getJPTObjectForGefElement(entity).getSimpleName();
-
- entity.click();
- jpaDiagramEditor
- .clickContextMenu(JPAEditorMessages.JPAEditorToolBehaviorProvider_renameEntityClass);
-
- SWTBotShell renameEntityDialog = editorProxy.getRenameEntityDialog();
- SWTBotText entityName = renameEntityDialog.bot().textWithLabel(
- "New name:");
-
- // test invalid entity name
- entityName.setText("");
- assertFalse(editorProxy.getFinishButton(renameEntityDialog).isEnabled());
- assertTrue(editorProxy.getCancelButton(renameEntityDialog).isEnabled());
-
- entityName.setText("NewEntityName");
- assertTrue(editorProxy.getFinishButton(renameEntityDialog).isEnabled());
- assertTrue(editorProxy.getCancelButton(renameEntityDialog).isEnabled());
-
- editorProxy.getFinishButton(renameEntityDialog).click();
- bot.waitUntil(new ElementIsShown(jpaDiagramEditor, "NewEntityName"),
- 10000);
-
- entity = jpaDiagramEditor.getEditPart("NewEntityName");
- assertNotNull("Entity name must be changed!", entity);
- assertNull("Entity naem must be changed!",
- jpaDiagramEditor.getEditPart(oldEntityName));
-
- entity.click();
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testRenameEntityViaMenu");
- }
-
- /**
- * Move the entity class using the entity's context menu
- * "Refactor Entity Class -> Move..."
- */
- @Ignore
- @Test
- public void testMoveEntityViaMenu() throws JavaModelException {
- Utils.sayTestStarted("testMoveEntityViaMenu");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
- String entityName = editorProxy.getJPTObjectForGefElement(entity).getSimpleName();
- JpaArtifactFactory factory = JpaArtifactFactory.instance();
-
- String packageName = factory
- .getMappedSuperclassPackageDeclaration(editorProxy
- .getJPTObjectForGefElement(entity));
-
- entity.click();
- jpaDiagramEditor
- .clickContextMenu(JPAEditorMessages.JPAEditorToolBehaviorProvider_moveEntityClass);
-
- SWTBotShell moveEntityDialog = editorProxy.getMoveEntityDialog();
- moveEntityDialog.bot().tree().getTreeItem(TEST_PROJECT).select()
- .expandNode("src").expandNode("org").select().click();
- assertTrue(editorProxy.getOkButton(moveEntityDialog).isEnabled());
- editorProxy.getOkButton(moveEntityDialog).click();
- editorProxy.waitASecond();
-
- entity = jpaDiagramEditor.getEditPart(entityName);
- String newEntityPackage = factory
- .getMappedSuperclassPackageDeclaration(editorProxy
- .getJPTObjectForGefElement(entity));
- assertFalse("Entity must be moved!",
- packageName.equals(newEntityPackage));
- assertTrue("Entity must be changed!", newEntityPackage.equals("org"));
-
- entity.click();
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testMoveEntityViaMenu");
- }
-
- /**
- * Collapse/expand entity using its context buttons
- */
- @Test
- public void testCollapseExapandEntityViaContextButton() {
- Utils.sayTestStarted("testCollapseExapandEntityViaContextButton");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- editorProxy.collapseExpandJPTViaButton(entity);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testCollapseExapandEntityViaContextButton");
- }
-
- /**
- * Collapse/expand entity using its context menus
- */
- @Test
- public void testCollapseExapandEntityViaMenu() {
- Utils.sayTestStarted("testCollapseExapandEntityViaMenu");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- editorProxy.collapseExpandJPTViaMenu(entity);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testCollapseExapandEntityViaMenu");
- }
-
- /**
- * Collapse/expand all entities using the context menus
- */
- @Test
- public void testCollapseExapandAllEntitiesViaMenu() {
- Utils.sayTestStarted("testCollapseExapandAllEntitiesViaMenu");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity1 = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
- SWTBotGefEditPart entity2 = editorProxy.addEntityToDiagram(300, 50,
- jpaProject);
-
- editorProxy.collapseExpandAllJPTsViaMenu(entity1, entity2);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testCollapseExapandAllEntitiesViaMenu");
- }
-
- /**
- * Add a new attribute without saving the entity and call the
- * "Discard Changes" context menu. Assert that the newly added attribute is
- * removed and the entity does not contain unsaved changes.
- */
- @Test
- public void testDiscardChanges() {
- Utils.sayTestStarted("testDiscardChanges");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- String attributeName = editorProxy.getUniqueAttrName(entity);
- editorProxy.discardChanges(entity, attributeName);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testDiscardChanges");
- }
-
- /**
- * Add a new attribute without saving the entity and call the entity's
- * context menu "Remove All Entities from Diagram -> ... and Discard
- * Changes" context menu. Assert that the diagram is empty. Call "Show All
- * Entities" context menu and assert that the newly added attribute is
- * removed and the entity does not contain unsaved changes.
- */
- @Test
- public void testRemoveAndDiscardChangesViaMenu() {
- Utils.sayTestStarted("testRemoveAndDiscardChangesViaMenu");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- String attributeName = editorProxy.getUniqueAttrName(entity);
- editorProxy.removeAndDiscardChangesViaMenu(entity, attributeName);
-
- entity.click();
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testRemoveAndDiscardChangesViaMenu");
- }
-
- /**
- * Add a new attribute without saving the entity and call the entity's
- * context menu "Remove All Entities from Diagram -> ... and Save
- * Changes" context menu. Assert that the diagram is empty. Call "Show All
- * Entities" context menu and assert that the newly added attribute is added
- * and the entity does not contain unsaved changes.
- */
- @Test
- public void testRemoveAndSaveChangesViaMenu() {
- Utils.sayTestStarted("testRemoveAndSaveChangesViaMenu");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- String attributeName = editorProxy.getUniqueAttrName(entity);
- editorProxy.removeAndSaveChangesViaMenu(entity, attributeName);
-
- entity.click();
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testRemoveAndSaveChangesViaMenu");
- }
-
- /**
- * Add a new attribute to the entity. From the entity's context menu select
- * "Save". Assert that the entity does not contain any unsaved changes, but
- * the diagram editor is still dirty.
- */
- @Test
- public void testSaveOnlyEntity() {
- Utils.sayTestStarted("testSaveOnlyEntity");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
- String attributeName = editorProxy.getUniqueAttrName(entity);
- editorProxy.saveOnlyJPT(entity, attributeName);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testSaveOnlyEntity");
- }
-
- /**
- * Create a JPA project and one entity in it. Open the JPA diagram editor
- * and call the "Show All Entities" context menu. Assert that the previously
- * created entity is shown in the diagram.
- *
- * @throws Exception
- */
- @Test
- public void testShowAllEntities() throws Exception {
- Utils.sayTestStarted("testShowAllEntities");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- factory.createEntity(jpaProject, "com.sap.test.Customer");
- assertTrue(jpaDiagramEditor.mainEditPart().children().isEmpty());
-
- jpaDiagramEditor
- .clickContextMenu(JPAEditorMessages.JPAEditorToolBehaviorProvider_showAllTheEntities);
-
- bot.waitUntil(new ElementAppearsInDiagram(jpaDiagramEditor), 20000);
-
- List<SWTBotGefEditPart> entities = jpaDiagramEditor.mainEditPart()
- .children();
- assertFalse("Diagram editor must contain at least one entity!",
- entities.isEmpty());
-
- SWTBotGefEditPart entity = jpaDiagramEditor.getEditPart("Customer");
- assertNotNull(entity);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testShowAllEntities");
- }
-
- /**
- * Collapse/expand "Primary Key" section by double click on it
- */
- @Ignore
- @Test
- public void testCollapseExpandCompartmentByDoubleClick() {
- Utils.sayTestStarted("testCollapseExpandCompartmentByDoubleClick");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- editorProxy.addEntityToDiagram(50, 50, jpaProject);
-
- editorProxy.moveMouse(100, 100);
- SWTBotGefEditPart primaryKeySection = jpaDiagramEditor
- .getEditPart(JPAEditorMessages.AddJPAEntityFeature_primaryKeysShape);
-
- int height = ((PictogramElement) primaryKeySection.part().getModel())
- .getGraphicsAlgorithm().getHeight();
-
- primaryKeySection.click();
-
- jpaDiagramEditor.doubleClick(primaryKeySection);
- primaryKeySection = jpaDiagramEditor
- .getEditPart(JPAEditorMessages.AddJPAEntityFeature_primaryKeysShape);
- int newHeight = ((PictogramElement) primaryKeySection.part().getModel())
- .getGraphicsAlgorithm().getHeight();
- assertEquals("Primary Key section must be collapsed!",
- JPAEditorConstants.COMPARTMENT_MIN_HEIGHT, newHeight);
- assertTrue(newHeight < height);
-
- jpaDiagramEditor.doubleClick(primaryKeySection);
- primaryKeySection = jpaDiagramEditor
- .getEditPart(JPAEditorMessages.AddJPAEntityFeature_primaryKeysShape);
- int newHeight1 = ((PictogramElement) primaryKeySection.part()
- .getModel()).getGraphicsAlgorithm().getHeight();
- assertEquals("Primary Key section must be collapsed!", height,
- newHeight1);
- assertTrue(newHeight1 > JPAEditorConstants.COMPARTMENT_MIN_HEIGHT);
-
- editorProxy.moveMouse(0, 0);
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testCollapseExpandCompartmentByDoubleClick");
- }
-
- /**
- * Collapse/expand compartment by its context menu
- */
- @Ignore
- @Test
- public void testCollapseExpandCompartmentByContextMenu() {
- Utils.sayTestStarted("testCollapseExpandCompartmentByContextMenu");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- // editorProxy.moveMouse(jpaDiagramEditor, 100, 100);
- SWTBotGefEditPart primaryKeySection = editorProxy.getSectionInJPT(
- entity, JPAEditorMessages.AddJPAEntityFeature_primaryKeysShape);
- // SWTBotGefEditPart primaryKeySection =
- // jpaDiagramEditor.getEditPart(JPAEditorMessages.AddJPAEntityFeature_primaryKeysShape);
- primaryKeySection.select();
- int height = ((PictogramElement) primaryKeySection.part().getModel())
- .getGraphicsAlgorithm().getHeight();
-
- primaryKeySection.click();
-
- jpaDiagramEditor
- .clickContextMenu(JPAEditorMessages.JPAEditorToolBehaviorProvider_collapseAttrGroupMenuItem);
- primaryKeySection = jpaDiagramEditor
- .getEditPart(JPAEditorMessages.AddJPAEntityFeature_primaryKeysShape);
- int newHeight = ((PictogramElement) primaryKeySection.part().getModel())
- .getGraphicsAlgorithm().getHeight();
- assertEquals("Primary Key section must be collapsed!",
- JPAEditorConstants.COMPARTMENT_MIN_HEIGHT, newHeight);
- assertTrue(newHeight < height);
-
- jpaDiagramEditor
- .clickContextMenu(JPAEditorMessages.JPAEditorToolBehaviorProvider_expandAttrMenuItem);
- primaryKeySection = jpaDiagramEditor
- .getEditPart(JPAEditorMessages.AddJPAEntityFeature_primaryKeysShape);
- int newHeight1 = ((PictogramElement) primaryKeySection.part()
- .getModel()).getGraphicsAlgorithm().getHeight();
- assertEquals("Primary Key section must be collapsed!", height,
- newHeight1);
- assertTrue(newHeight1 > JPAEditorConstants.COMPARTMENT_MIN_HEIGHT);
-
- editorProxy.moveMouse(0, 0);
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testCollapseExpandCompartmentByContextMenu");
- }
-
- /**
- * Test the integration between the JPA diagram editor and the JPA Details
- * view: 1.) Close the JPA Details view 2.) Create an entity and call the
- * context menu "Open JPA Details View" 3.) Assert that the JPA Details view
- * is opened and the appropriate information is shown (the type is mapped as
- * entity and the expandable sections are available). 4.) Change the mapping
- * type to "Mapped Superclass" 5.) Change the mapping type to "Embeddable"
- * and assert that the type is removed from the diagram 6.) Revert the
- * mapping type to be "Entity" and call the "Show All Entities" context menu
- * to visualize the entity in the diagram editor.
- */
- @Ignore
- @Test
- public void testChangeEntityMappingTypeViaJPADetailsView() {
- Utils.sayTestStarted("testChangeEntityMappingTypeViaJPADetailsView");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- workbenchBot.viewByTitle("JPA Details").close();
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
- String entityName = editorProxy.getJPTObjectForGefElement(entity).getSimpleName();
-
- jpaDiagramEditor.save();
- jpaDiagramEditor
- .clickContextMenu(JPAEditorMessages.JPAEditorToolBehaviorProvider_openJPADetailsView);
-
- // assert that the JPA Details view is opened
- SWTBotView jpaDetailsView = workbenchBot.viewByTitle("JPA Details");
- assertTrue("JPA Details view must be opened!",
- jpaDetailsView.isActive());
-
- // assert that the type is mapped as entity in the JPA Deatils view
- entity.click();
- SWTBot jpaDetailsBot = jpaDetailsView.bot();
- SWTBotStyledText styledText = jpaDetailsBot.styledText();
- assertEquals("Type '" +entityName+ "' is mapped as entity.",
- styledText.getText());
- assertNotNull("Entity must be shown in the diagram!",
- jpaDiagramEditor.getEditPart(entityName));
- // assert that the entity's sections are enabled
- assertTrue(jpaDetailsBot.label("Entity").isEnabled());
- assertTrue(jpaDetailsBot.label("Queries").isEnabled());
- assertTrue(jpaDetailsBot.label("Inheritance").isEnabled());
- assertTrue(jpaDetailsBot.label("Attribute Overrides").isEnabled());
- assertTrue(jpaDetailsBot.label("Primary Key Generation").isEnabled());
- assertTrue(jpaDetailsBot.label("Secondary Tables").isEnabled());
-
- // change the mapping type to "Mapped Superclass" and assert that the
- // type is mapped
- // as mapped superclass in the JPA Details view
- editorProxy.clickOnStyledText(styledText, 30);
- editorProxy.changeMappingtype("Mapped Superclass");
- styledText = jpaDetailsBot.styledText();
- assertEquals("Type '" + entityName + "' is mapped as mapped superclass.",
- styledText.getText());
- assertNotNull("Entity must be shown in the diagram!",
- jpaDiagramEditor.getEditPart(entityName));
- // assert that the mapped superclass'es sections are enabled
- assertTrue(jpaDetailsBot.label("Mapped Superclass").isEnabled());
- assertTrue(jpaDetailsBot.label("Queries").isEnabled());
-
- // change the mapping type to "Embeddable" and assert that the element
- // is removed from the diagram
- // and the type is mapped as embeddable in the JPA Details view
- editorProxy.clickOnStyledText(styledText, 30);
- editorProxy.changeMappingtype("Embeddable");
- styledText = jpaDetailsBot.styledText();
- assertEquals("Type '" + entityName + "' is mapped as embeddable.",
- styledText.getText());
- assertNotNull("Entity must disappear from the diagram!",
- jpaDiagramEditor.getEditPart(entityName));
- // assert that the embeddable's section is enabled
- // assertTrue(jpaDetailsBot.label("Embeddable").isEnabled());
-
- // revert the mapping type to Entity
- editorProxy.clickOnStyledText(styledText, 30);
- editorProxy.changeMappingtype("Entity");
- assertNotNull("Entity must disappear from the diagram!",
- jpaDiagramEditor.getEditPart(entityName));
-
- jpaDiagramEditor.click(0, 0);
-
- jpaDiagramEditor.select(entityName);
- styledText = jpaDetailsBot.styledText();
- assertEquals("Type '" + entityName + "' is mapped as entity.",
- styledText.getText());
- // assert that the entity's sections are enabled
- assertTrue(jpaDetailsBot.label("Entity").isEnabled());
- assertTrue(jpaDetailsBot.label("Queries").isEnabled());
- assertTrue(jpaDetailsBot.label("Inheritance").isEnabled());
- assertTrue(jpaDetailsBot.label("Attribute Overrides").isEnabled());
- assertTrue(jpaDetailsBot.label("Primary Key Generation").isEnabled());
- assertTrue(jpaDetailsBot.label("Secondary Tables").isEnabled());
-
- entity.click();
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testChangeEntityMappingTypeViaJPADetailsView");
- }
-
- /**
- * Test the integration between the JPA diagram editor and the JPA Details
- * view: 1.) Close the JPA Details view 2.) Create an entity and call the
- * context menu "Open JPA Details View" 3.) Assert that the JPA Details view
- * is opened and the appropriate information is shown (the id attribute is
- * mapped as id and the expandable sections are available). 4.) Change the
- * attribute mapping type to "Basic" and assert that the attribute is moved
- * to "Other Attributes" compartment 5.) Change the attribute mapping type
- * to "On-To-Many" and assert that the attribute is moved to
- * "Relation Attributes" compartment 7.) Revert the attribute mapping to
- * "ID" and assert that the attributes is moved back to the "Primary Key"
- * compartment
- */
- @Ignore
- @Test
- public void testChangeAttributeMappingTypeViaJPADetailsView() {
- Utils.sayTestStarted("testChangeAttributeMappingTypeViaJPADetailsView");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- workbenchBot.viewByTitle("JPA Details").close();
- SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- jpaDiagramEditor.save();
- jpaDiagramEditor
- .clickContextMenu(JPAEditorMessages.JPAEditorToolBehaviorProvider_openJPADetailsView);
-
- // assert that the JPA Details view is opened
- SWTBotView jpaDetailsView = workbenchBot.viewByTitle("JPA Details");
- assertTrue("JPA Details view must be opened!",
- jpaDetailsView.isActive());
-
- SWTBotGefEditPart primaryKeyAttr = jpaDiagramEditor.getEditPart("id");
- primaryKeyAttr.click();
-
- // assert that the default entity's attribute is mapped as primary key
- SWTBot jpaDetailsBot = jpaDetailsView.bot();
- SWTBotStyledText styledText = jpaDetailsBot.styledText();
- assertEquals("Attribute 'id' is mapped as ID.", styledText.getText());
- // assert that the attribute is under "Primary Key" section
- assertTrue(
- "Attribute must be in the \"Primary Key\" section of the entity!",
- editorProxy.isSectionVisible(
- JPAEditorMessages.AddJPAEntityFeature_primaryKeysShape,
- entity));
- assertFalse(
- "Attribute must be in the \"Primary Key\" section of the entity!",
- editorProxy
- .isSectionVisible(
- JPAEditorMessages.AddJPAEntityFeature_relationAttributesShapes,
- entity));
- assertFalse(
- "Attribute must be in the \"Primary Key\" section of the entity!",
- editorProxy
- .isSectionVisible(
- JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
- entity));
- // assert that the ID's sections are available
- assertTrue(jpaDetailsBot.label("ID").isEnabled());
- assertTrue(jpaDetailsBot.label("Type").isEnabled());
- assertTrue(jpaDetailsBot.label("Primary Key Generation").isEnabled());
-
- // change the attribute type to basic
- editorProxy.clickOnStyledText(styledText, 29);
- editorProxy.changeMappingtype("Basic");
- styledText = jpaDetailsBot.styledText();
- assertEquals("Attribute 'id' is mapped as basic.", styledText.getText());
- // assert that the attribute is moved under "Other Attributes" section
- assertFalse(
- "Attribute must be in the \"Primary Key\" section of the entity!",
- editorProxy.isSectionVisible(
- JPAEditorMessages.AddJPAEntityFeature_primaryKeysShape,
- entity));
- assertFalse(
- "Attribute must be in the \"Relation Attributes\" section of the entity!",
- editorProxy
- .isSectionVisible(
- JPAEditorMessages.AddJPAEntityFeature_relationAttributesShapes,
- entity));
- assertTrue(
- "Attribute must be in the \"Other Attributes\" section of the entity!",
- editorProxy
- .isSectionVisible(
- JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
- entity));
- // assert that the Basic's sections are available
- assertTrue(jpaDetailsBot.label("Basic").isEnabled());
- assertTrue(jpaDetailsBot.label("Type").isEnabled());
-
- // change the attribute type to Many to Many
- editorProxy.clickOnStyledText(styledText, 29);
- editorProxy.changeMappingtype("Many to Many");
- styledText = jpaDetailsBot.styledText();
- assertEquals("Attribute 'id' is mapped as many to many.",
- styledText.getText());
- // assert that the attribute is moved under the "Relation Attributes"
- // section
- assertFalse(
- "Attribute must be in the \"Primary key\" section of the entity!",
- editorProxy.isSectionVisible(
- JPAEditorMessages.AddJPAEntityFeature_primaryKeysShape,
- entity));
- assertTrue(
- "Attribute must be in the \"Relation Attributes\" section of the entity!",
- editorProxy
- .isSectionVisible(
- JPAEditorMessages.AddJPAEntityFeature_relationAttributesShapes,
- entity));
- assertFalse(
- "Attribute must be in the \"Other Attributes\" section of the entity!",
- editorProxy
- .isSectionVisible(
- JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
- entity));
- // assert that the Many to Many's sections are available
- assertTrue(jpaDetailsBot.label("Many to Many").isEnabled());
- assertTrue(jpaDetailsBot.label("Joining Strategy").isEnabled());
- assertTrue(jpaDetailsBot.label("Ordering").isEnabled());
-
- // revert the attribute type back to Id
- editorProxy.clickOnStyledText(styledText, 29);
- editorProxy.changeMappingtype("ID");
- styledText = jpaDetailsBot.styledText();
- assertEquals("Attribute 'id' is mapped as ID.", styledText.getText());
- // assert that the attribute is under "Primary Key" section
- assertTrue(
- "Attribute must be in the \"Primary Key\" section of the entity!",
- editorProxy.isSectionVisible(
- JPAEditorMessages.AddJPAEntityFeature_primaryKeysShape,
- entity));
- assertFalse(
- "Attribute must be in the \"Relation Attributes\" section of the entity!",
- editorProxy
- .isSectionVisible(
- JPAEditorMessages.AddJPAEntityFeature_relationAttributesShapes,
- entity));
- assertFalse(
- "Attribute must be in the \"Other Attributes\" section of the entity!",
- editorProxy
- .isSectionVisible(
- JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
- entity));
- // assert that the ID's sections are available
- assertTrue(jpaDetailsBot.label("ID").isEnabled());
- assertTrue(jpaDetailsBot.label("Type").isEnabled());
- assertTrue(jpaDetailsBot.label("Primary Key Generation").isEnabled());
-
- entity.click();
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testChangeAttributeMappingTypeViaJPADetailsView");
- }
-
- /**
- * Creates "One to One" unidirectional relationship (from entity1 to
- * entity2). Assert that the relation attributes exists. Delete the
- * relationship and assert that the attributes do not exists anymore. Check
- * that if the owner attribute will be deleted, the relationship will
- * disappear.
- *
- */
- @Test
- public void testOneToOneUniDirRelationship() {
- Utils.sayTestStarted("testOneToOneUniDirRelationship");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity1 = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
- SWTBotGefEditPart entity2 = editorProxy.addEntityToDiagram(200, 50,
- jpaProject);
-
- // create One-to-One unidirectional relation from entity1 to entity2
- editorProxy
- .testUniDirRelation(
- JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- entity1,
- entity2,
- IRelation.RelType.ONE_TO_ONE,
- JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
-
- // create One-to-One unidirectional relation from entity1 to entity2
- editorProxy
- .testUniDirRelRemoveOwnerAttribute(
- JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- entity1,
- entity2,
- IRelation.RelType.ONE_TO_ONE,
- JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
-
- editorProxy.deleteDiagramElements();
-
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testOneToOneUniDirRelationship");
- }
-
- /**
- * Creates "One to One" unidirectional self relationship (from entity1 to
- * entity1). Assert that the relation attributes exists. Delete the
- * relationship and assert that the attributes do not exists anymore.
- */
- @Test
- public void testSelfOneToOneUniDirRelationship() {
- Utils.sayTestStarted("testSelfOneToOneUniDirRelationship");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity1 = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- // create One-to-One unidirectional self relation from entity1 to
- // entity1
- editorProxy
- .testSelfUniDirRelation(
- JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- entity1,
- IRelation.RelType.ONE_TO_ONE,
- JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
-
- editorProxy.deleteDiagramElements();
-
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testSelfOneToOneUniDirRelationship");
- }
-
- /**
- * Creates "One to One" bidirectional relationship (from entity1 to
- * entity2). Assert that the relation attributes exists. Delete the
- * relationship and assert that the attributes do not exists anymore. Check
- * that if the inverse attribute will be deleted the connection will be
- * transformed into one-to-one unidirectional relationship. Test that if the
- * owner attribute will be deleted, the relationship will disappear.
- */
- @Test
- public void testOneToOneBiDirRelationship() {
- Utils.sayTestStarted("testOneToOneBiDirRelationship");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity1 = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
- SWTBotGefEditPart entity2 = editorProxy.addEntityToDiagram(200, 50,
- jpaProject);
-
- // create One-to-One bidirectional relation from entity1 to entity2
- editorProxy
- .testBiDirRel(
- JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- entity1,
- entity2,
- IRelation.RelType.ONE_TO_ONE,
- JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
-
- // create One-to-One bidirectional relation from entity1 to entity2
- editorProxy
- .testBiDirRelRemoveInverseAttribute(
- JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- entity1,
- entity2,
- IRelation.RelType.ONE_TO_ONE,
- JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
-
- // create One-to-One bidirectional relation from entity1 to entity2
- editorProxy
- .testBiDirRelRemoveOwnerAttr(
- JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- entity1,
- entity2,
- IRelation.RelType.ONE_TO_ONE,
- JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
-
- editorProxy.deleteDiagramElements();
-
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testOneToOneBiDirRelationship");
- }
-
- /**
- * Creates "One to One" bidirectional self relationship (from entity1 to
- * entity1). Assert that the relation attributes exists. Delete the
- * relationship and assert that the attributes do not exists anymore.
- */
- @Test
- public void testSelfOneToOneBiDirRelationship() {
- Utils.sayTestStarted("testSelfOneToOneBiDirRelationship");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity1 = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- // create One-to-One bidirectional self relation from entity1 to entity1
- editorProxy
- .testSelfBiDirRel(
- JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- entity1,
- IRelation.RelType.ONE_TO_ONE,
- JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
-
- editorProxy.deleteDiagramElements();
-
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testSelfOneToOneBiDirRelationship");
- }
-
- /**
- * Creates "One to Many" unidirectional relationship (from entity1 to
- * entity2). Assert that the relation attributes exists. Delete the
- * relationship and assert that the attributes do not exists anymore. Check
- * that if the owner attribute will be deleted, the relationship will
- * disappear.
- */
- @Test
- public void testOneToManyUniDirRelationship() {
- Utils.sayTestStarted("testOneToManyUniDirRelationship");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity1 = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
- SWTBotGefEditPart entity2 = editorProxy.addEntityToDiagram(200, 50,
- jpaProject);
-
- // create One-to-Many unidirectional relation from entity1 to entity2
- editorProxy
- .testUniDirRelation(
- JPAEditorMessages.CreateOneToManyUniDirRelationFeature_oneToManyUniDirFeatureName,
- entity1,
- entity2,
- IRelation.RelType.ONE_TO_MANY,
- JptJpaUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, false);
-
- // create One-to-One bidirectional relation from entity1 to entity2
- editorProxy
- .testUniDirRelRemoveOwnerAttribute(
- JPAEditorMessages.CreateOneToManyUniDirRelationFeature_oneToManyUniDirFeatureName,
- entity1,
- entity2,
- IRelation.RelType.ONE_TO_MANY,
- JptJpaUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, false);
-
- editorProxy.deleteDiagramElements();
-
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testOneToManyUniDirRelationship");
- }
-
- /**
- * Creates "One to Many" unidirectional self relationship (from entity1 to
- * entity1). Assert that the relation attributes exists. Delete the
- * relationship and assert that the attributes do not exists anymore.
- */
- @Test
- public void testSelfOneToManyUniDirRelationship() {
- Utils.sayTestStarted("testSelfOneToManyUniDirRelationship");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity1 = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- // create One-to-Many unidirectional self relation from entity1 to
- // entity1
-
- editorProxy
- .testSelfUniDirRelation(
- JPAEditorMessages.CreateOneToManyUniDirRelationFeature_oneToManyUniDirFeatureName,
- entity1,
- IRelation.RelType.ONE_TO_MANY,
- JptJpaUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, false);
-
- editorProxy.deleteDiagramElements();
-
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testSelfOneToManyUniDirRelationship");
- }
-
- /**
- * Creates "Many to One" unidirectional relationship (from entity1 to
- * entity2). Assert that the relation attributes exists. Delete the
- * relationship and assert that the attributes do not exists anymore. Check
- * that if the owner attribute will be deleted, the relationship will
- * disappear.
- */
- @Test
- public void testManyToOneUniDirRelationship() {
- Utils.sayTestStarted("testManyToOneUniDirRelationship");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity1 = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
- SWTBotGefEditPart entity2 = editorProxy.addEntityToDiagram(200, 50,
- jpaProject);
-
- // create Many-to-One unidirectional relation from entity1 to entity2
- editorProxy
- .testUniDirRelation(
- JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- entity1,
- entity2,
- IRelation.RelType.MANY_TO_ONE,
- JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true);
-
- // create Many-to-One bidirectional relation from entity1 to entity2
- editorProxy
- .testUniDirRelRemoveOwnerAttribute(
- JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- entity1,
- entity2,
- IRelation.RelType.MANY_TO_ONE,
- JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true);
-
- editorProxy.deleteDiagramElements();
-
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testManyToOneUniDirRelationship");
- }
-
- /**
- * Creates "Many to One" unidirectional self relationship (from entity1 to
- * entity1). Assert that the relation attributes exists. Delete the
- * relationship and assert that the attributes do not exists anymore.
- */
- @Test
- public void testSelfManyToOneUniDirRelationship() {
- Utils.sayTestStarted("testSelfManyToOneUniDirRelationship");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity1 = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- // create Many-to-One unidirectional self relation from entity1 to
- // entity1
- editorProxy
- .testSelfUniDirRelation(
- JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- entity1,
- IRelation.RelType.MANY_TO_ONE,
- JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true);
-
- editorProxy.deleteDiagramElements();
-
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testSelfManyToOneUniDirRelationship");
- }
-
- /**
- * Creates a "Many to One" bidirectional relationship (from entity1 to
- * entity2). Assert that the relation attributes exists. Delete the
- * relationship and assert that the attributes do not exists anymore. Check
- * that if the inverse attribute will be deleted the connection will be
- * transformed into many-to-one unidirectional relationship. Test that if
- * the owner attribute will be deleted, the relationship will disappear.
- */
- @Test
- public void testManyToOneBiDirRelationship() {
- Utils.sayTestStarted("testManyToOneBiDirRelationship");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity1 = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
- SWTBotGefEditPart entity2 = editorProxy.addEntityToDiagram(200, 50,
- jpaProject);
-
- // create Many-to-One bidirectional relation from entity1 to entity2
- editorProxy
- .testBiDirRelWithTwoMappingTypes(
- JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- entity1,
- entity2,
- IRelation.RelType.MANY_TO_ONE,
- JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel,
- JptJpaUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, true);
-
- // create Many-to-One bidirectional relation from entity1 to entity2
- editorProxy
- .testBiDirRelWithTwoMappingsWithoutInverseAttr(
- JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- entity1,
- entity2,
- IRelation.RelType.MANY_TO_ONE,
- JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel,
- JptJpaUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, true);
-
- // create Many-to-One bidirectional relation from entity1 to entity2
- editorProxy
- .testBiDirRelWithTwoMappingsWithoutOwnerAttr(
- JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- entity1,
- entity2,
- IRelation.RelType.MANY_TO_ONE,
- JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel,
- JptJpaUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, true);
-
- editorProxy.deleteDiagramElements();
-
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testManyToOneBiDirRelationship");
- }
-
- /**
- * Creates a "Many to One" bidirectional self relationship (from entity1 to
- * entity1). Assert that the relation attributes exists. Delete the
- * relationship and assert that the attributes do not exists anymore.
- */
- @Test
- public void testSelfManyToOneBiDirRelationship() {
- Utils.sayTestStarted("testSelfManyToOneBiDirRelationship");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity1 = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- // create Many-to-Many bidirectional self relation from entity1 to
- // entity1
- editorProxy
- .testSelfBiDirRelWithTwoMappings(
- JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- entity1,
- IRelation.RelType.MANY_TO_ONE,
- JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel,
- JptJpaUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, true);
-
- editorProxy.deleteDiagramElements();
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testSelfManyToOneBiDirRelationship");
- }
-
- /**
- * Creates "Many to Many" unidirectional relationship (from entity1 to
- * entity2). Assert that the relation attributes exists. Delete the
- * relationship and assert that the attributes do not exists anymore. Check
- * that if the owner attribute will be deleted, the relationship will
- * disappear.
- */
- @Test
- public void testManyToManyUniDirRelationship() {
- Utils.sayTestStarted("testManyToManyUniDirRelationship");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity1 = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
- SWTBotGefEditPart entity2 = editorProxy.addEntityToDiagram(200, 50,
- jpaProject);
-
- // create Many-to-Many unidirectional relation from entity1 to entity2
- editorProxy
- .testUniDirRelation(
- JPAEditorMessages.CreateManyToManyUniDirRelationFeature_manyToManyUniDirFeatureName,
- entity1,
- entity2,
- IRelation.RelType.MANY_TO_MANY,
- JptJpaUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
-
- // create Many-to-Many bidirectional relation from entity1 to entity2
- editorProxy
- .testUniDirRelRemoveOwnerAttribute(
- JPAEditorMessages.CreateManyToManyUniDirRelationFeature_manyToManyUniDirFeatureName,
- entity1,
- entity2,
- IRelation.RelType.MANY_TO_MANY,
- JptJpaUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
-
- editorProxy.deleteDiagramElements();
-
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testManyToManyUniDirRelationship");
- }
-
- /**
- * Creates "Many to Many" unidirectional self relationship (from entity1 to
- * entity1). Assert that the relation attributes exists. Delete the
- * relationship and assert that the attributes do not exists anymore.
- */
- @Test
- public void testSelfManyToManyUniDirRelationship() {
- Utils.sayTestStarted("testSelfManyToManyUniDirRelationship");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity1 = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- // create Many-to-Many unidirectional self relation from entity1 to
- // entity1
- editorProxy
- .testSelfUniDirRelation(
- JPAEditorMessages.CreateManyToManyUniDirRelationFeature_manyToManyUniDirFeatureName,
- entity1,
- IRelation.RelType.MANY_TO_MANY,
- JptJpaUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
-
- editorProxy.deleteDiagramElements();
-
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testSelfManyToManyUniDirRelationship");
- }
-
- /**
- * Creates a "Many to Many" bidirectional relationship (from entity1 to
- * entity2). Assert that the relation attributes exists. Delete the
- * relationship and assert that the attributes do not exists anymore. Check
- * that if the inverse attribute will be deleted the connection will be
- * transformed into many-to-many unidirectional relationship. Test that if
- * the owner attribute will be deleted, the relationship will disappear.
- */
- @Test
- public void testManyToManyBiDirRelationship() {
- Utils.sayTestStarted("testManyToManyBiDirRelationship");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity1 = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
- SWTBotGefEditPart entity2 = editorProxy.addEntityToDiagram(200, 50,
- jpaProject);
-
- // create Many-to-Many bidirectional relation from entity1 to entity2
- editorProxy
- .testBiDirRel(
- JPAEditorMessages.CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName,
- entity1,
- entity2,
- IRelation.RelType.MANY_TO_MANY,
- JptJpaUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
-
- // create Many-to-Many bidirectional relation from entity1 to entity2
- editorProxy
- .testBiDirRelRemoveInverseAttribute(
- JPAEditorMessages.CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName,
- entity1,
- entity2,
- IRelation.RelType.MANY_TO_MANY,
- JptJpaUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
-
- // create Many-to-Many bidirectional relation from entity1 to entity2
- editorProxy
- .testBiDirRelRemoveOwnerAttr(
- JPAEditorMessages.CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName,
- entity1,
- entity2,
- IRelation.RelType.MANY_TO_MANY,
- JptJpaUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
-
- editorProxy.deleteDiagramElements();
-
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testManyToManyBiDirRelationship");
- }
-
- /**
- * Creates a "Many to Many" bidirectional self relationship (from entity1 to
- * entity1). Assert that the relation attributes exists. Delete the
- * relationship and assert that the attributes do not exists anymore.
- */
- @Test
- public void testSelfManyToManyBiDirRelationship() {
- Utils.sayTestStarted("testSelfManyToManyBiDirRelationship");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity1 = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- // create Many-to-Many bidirectional self relation from entity1 to
- // entity1
- editorProxy
- .testSelfBiDirRel(
- JPAEditorMessages.CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName,
- entity1,
- IRelation.RelType.MANY_TO_MANY,
- JptJpaUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
-
- editorProxy.deleteDiagramElements();
-
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testSelfManyToManyBiDirRelationship");
- }
-
- /**
- * Creates a new Inherited entity by entity. Assert that the inherited
- * entity does not contain a primary key.
- */
- @Test
- public void testInheritedEntityByEntity() {
- Utils.sayTestStarted("testInheritedEntityByEntity");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart entity1 = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- editorProxy.createInheritedEntity(entity1, jpaProject,
- JptJpaUiDetailsMessages.EntityUiProvider_linkLabel, false, false);
-
- editorProxy.deleteDiagramElements();
-
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testInheritedEntityByEntity");
- }
-
- /**
- * Create two entities in the diagram. From the "Inheritance" section of the palette
- * select "Inherit Persistent Type". Clock on the first entity and then click on the
- * second one. Assert that an is-a relation is created.
- */
- @Test
- public void testIsARelationBetweenExistingEntities() {
- Utils.sayTestStarted("testIsARelationBetweenExistingEntities");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart superclass = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
- String superclassName = editorProxy.getJPTObjectForGefElement(
- superclass).getSimpleName();
-
- SWTBotGefEditPart subclass = editorProxy.addEntityToDiagram(50, 300,
- jpaProject);
- String subclassName = editorProxy.getJPTObjectForGefElement(subclass)
- .getSimpleName();
-
- jpaDiagramEditor
- .activateTool(JPAEditorMessages.CreateIsARelationFeature_CreateIsARelationFeatureName);
- jpaDiagramEditor.click(superclass);
- jpaDiagramEditor.click(subclass);
-
- editorProxy.waitASecond();
-
- editorProxy.testCreateAndDeleteIsARelation(superclass, subclassName,
- JptJpaUiDetailsMessages.EntityUiProvider_linkLabel, false,
- superclassName, subclass, true);
-
- editorProxy.deleteDiagramElements();
-
- jpaDiagramEditor.save();
-
- Utils.sayTestFinished("testIsARelationBetweenExistingEntities");
- }
-
- /**
- * Create two entities in the diagram. From the second entity, remove the default
- * primary key attribute. From the "Derived Identifiers" select "One-to-One" unidirectional
- * relation feature and click first on the second entity and then on the first one.
- * Assert that the connection appears. Assert that the owner attribute of the relation is mapped
- * as primary key attribute in the second entity and there is no "Relation Attributes" section.
- * Test that the created relation is successfully deleted. Repeats all steps for the other three
- * types of relation also.
- */
- @Test
- public void testSimpleDerivedIdWithoutDefaultPK(){
- Utils.sayTestStarted("testSimpleDerivedIdWithoutDefaultPK");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart parentEntity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- SWTBotGefEditPart dependentEntity = editorProxy.addEntityToDiagram(50, 300,
- jpaProject);
-
- editorProxy.deleteEntityDefaultPK(dependentEntity);
-
- editorProxy.testUniDirDerivedIdWithIdAnnotation(JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- dependentEntity, parentEntity, IRelation.RelType.ONE_TO_ONE, "OneToOne",
- "Id", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel);
-
- editorProxy.testBiDirDerivedIdWithIdAnnotation(JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- dependentEntity, parentEntity, IRelation.RelType.ONE_TO_ONE, "OneToOne",
- "Id", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel);
-
- editorProxy.testUniDirDerivedIdWithIdAnnotation(JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- dependentEntity, parentEntity, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
- "Id", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel);
-
- editorProxy.testBiDirDerivedIdWithIdAnnotation(JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- dependentEntity, parentEntity, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
- "Id", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel);
-
- Utils.sayTestFinished("testSimpleDerivedIdWithoutDefaultPK");
- }
-
- /**
- * Create two entities in the diagram. From the "Derived Identifiers" select "One-to-One"
- * unidirectional relation feature and click first on the second entity and then on the first one.
- * Assert that the connection appears. Assert that the owner attribute of the relation is mapped
- * with the MapsId annotation in the second entity and there is no "Relation Attributes" section.
- * Test that the created relation is successfully deleted. Repeats all steps for the other three
- * types of relation also.
- */
- @Test
- public void testSimpleDerivedIdWithDefaultPK(){
- Utils.sayTestStarted("testSimpleDerivedIdWithDefaultPK");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart parentEntity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- SWTBotGefEditPart dependentEntity = editorProxy.addEntityToDiagram(50, 300,
- jpaProject);
-
- editorProxy.testUniDirDerivedIdWithIdAnnotation(JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- dependentEntity, parentEntity, IRelation.RelType.ONE_TO_ONE, "OneToOne",
- "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel);
-
- editorProxy.testBiDirDerivedIdWithIdAnnotation(JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- dependentEntity, parentEntity, IRelation.RelType.ONE_TO_ONE, "OneToOne",
- "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel);
-
- editorProxy.testUniDirDerivedIdWithIdAnnotation(JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- dependentEntity, parentEntity, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
- "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel);
-
- editorProxy.testBiDirDerivedIdWithIdAnnotation(JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- dependentEntity, parentEntity, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
- "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel);
-
- Utils.sayTestFinished("testSimpleDerivedIdWithDefaultPK");
- }
-
-
- /**
- * Create two entities and one embeddable in the diagram. From the second entity, remove the default
- * primary key attribute. From the "Composition" section, select "Embed Single object" and embed the
- * embeddable into the entity2. From the "JPA Details" view, change the mapping of the embedded attribute
- * in the entity2 to EmbeddedId. From the "Derived Identifiers" select "One-to-One"
- * unidirectional relation feature and click first on the second entity and then on the first one.
- * Assert that the connection appears. Assert that the owner attribute of the relation is mapped
- * with the MapsId annotation in the second entity and there is no "Relation Attributes" section.
- * Test that the created relation is successfully deleted. Repeats all steps for the other three
- * types of relation also.
- */
- @Test
- public void testDerivedIdWithEmbeddedPK(){
- Utils.sayTestStarted("testDerivedIdWithEmbeddedPK");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart parentEntity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- SWTBotGefEditPart dependentEntity = editorProxy.addEntityToDiagram(50, 300,
- jpaProject);
-
- editorProxy.deleteEntityDefaultPK(dependentEntity);
-
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(300, 50, jpaProject);
-
- editorProxy.addEmbeddedIdToEntity(dependentEntity, embeddable);
-
-
- editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.ONE_TO_ONE, "OneToOne",
- "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, false, false, null);
-
- editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.ONE_TO_ONE, "OneToOne",
- "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true, false, null);
-
- editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
- "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, false, false, null);
-
- editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
- "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true, false, null);
-
- Utils.sayTestFinished("testDerivedIdWithEmbeddedPK");
- }
-
- /**
- * Create two entities in the diagram. Create a simple java class. From the second entity, remove the default
- * primary key attribute. Use the created java class as IDClass in entity2. From the "Derived Identifiers" select "One-to-One"
- * unidirectional relation feature and click first on the second entity and then on the first one.
- * Assert that the connection appears. Assert that the owner attribute of the relation is mapped
- * as primary key attribute in the second entity and there is no "Relation Attributes" section.
- * Test that the created relation is successfully deleted. Repeats all steps for the other three
- * types of relation also.
- */
- @Test
- public void testDerivedIdWithIdClassPK() throws Exception{
- Utils.sayTestStarted("testDerivedIdWithIdClassPK");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart parentEntity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- SWTBotGefEditPart dependentEntity = editorProxy.addEntityToDiagram(50, 300,
- jpaProject);
-
- IFile idClass = editorProxy.setIdClass(dependentEntity, "TestIdClass", jpaProject);
-
- editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.ONE_TO_ONE, "OneToOne",
- "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, false, false, null);
-
- editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.ONE_TO_ONE, "OneToOne",
- "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true, false, null);
-
- editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
- "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, false, false, null);
-
- editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
- "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true, false, null);
-
- Utils.sayTestFinished("testDerivedIdWithIdClassPK");
- }
-
- /**
- * Create two entities in the diagram. Create a simple java class. Remove the default
- * primary key attribute from both entities. Use the created java class as IDClass in both entities.
- * From the "Derived Identifiers" select "One-to-One" unidirectional relation feature and click first on the second entity and then on the first one.
- * Assert that the connection appears. Assert that the owner attribute of the relation is mapped
- * as primary key attribute in the second entity and there is no "Relation Attributes" section.
- * Test that the created relation is successfully deleted. Repeats all steps for the other three
- * types of relation also.
- */
- @Test
- public void testDerivedIdWithSameIdClassPK() throws Exception{
- Utils.sayTestStarted("testDerivedIdWithSameIdClassPK");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart parentEntity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- IFile idClass = editorProxy.setIdClass(parentEntity, "TestParentIdClass", jpaProject);
- String idClassFQN = "TestParentIdClass";
-
- SWTBotGefEditPart dependentEntity = editorProxy.addEntityToDiagram(50, 300,
- jpaProject);
-
- PersistentType parentJPTType= editorProxy.getJPTObjectForGefElement(dependentEntity);
-
- TypeMapping typeMapping = JpaArtifactFactory.instance().getTypeMapping(parentJPTType);
- assertTrue(Entity.class.isInstance(typeMapping));
- ((Entity)typeMapping).getIdClassReference().setSpecifiedIdClassName(idClassFQN);
-
- editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.ONE_TO_ONE, "OneToOne",
- "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, false, true, null);
-
- editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.ONE_TO_ONE, "OneToOne",
- "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true, true, null);
-
- editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
- "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, false, true, null);
-
- editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
- "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true, true, null);
-
- Utils.sayTestFinished("testDerivedIdWithSameIdClassPK");
- }
-
- /**
- * Create two entities in the diagram. Create two simple java class. Remove the default
- * primary key attribute from both entities. Use the first java class as IDClass in the first entity and the second
- * java class as IdClass for the second entity. From the "Derived Identifiers" select "One-to-One"
- * unidirectional relation feature and click first on the second entity and then on the first one.
- * Assert that the connection appears. Assert that the owner attribute of the relation is mapped
- * as primary key attribute in the second entity and there is no "Relation Attributes" section.
- * Assert that a new helper attribute is automatically added in the second java class and its type is the type
- * of the first java class, used as IDClass.
- * Test that the created relation is successfully deleted. Repeats all steps for the other three
- * types of relation also.
- */
- @Test
- public void testDerivedIdWithDifferentIdClassPK() throws Exception{
- Utils.sayTestStarted("testDerivedIdWithDifferentIdClassPK");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart parentEntity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- editorProxy.setIdClass(parentEntity, "TestParentIdClass", jpaProject);
- String idClassFQN = "TestParentIdClass";
-
- SWTBotGefEditPart dependentEntity = editorProxy.addEntityToDiagram(50, 300,
- jpaProject);
-
- IFile idClass = editorProxy.setIdClass(dependentEntity, "TestIdClass", jpaProject);
-
-
- editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.ONE_TO_ONE, "OneToOne",
- "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, false, false, idClassFQN);
-
- editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.ONE_TO_ONE, "OneToOne",
- "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true, false, idClassFQN);
-
- editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
- "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, false, false, idClassFQN);
-
- editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
- "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true, false, idClassFQN);
-
- Utils.sayTestFinished("testDerivedIdWithDifferentIdClassPK");
- }
-
- /**
- * Create two entities and one embeddable in the diagram. Remove the default primary key attribute from both entities.
- * Embed the embeddable in both entities and change the mappig of the embedded attributes to EmbeddedIds.
- * From the "Derived Identifiers" select "One-to-One" unidirectional relation feature and click first on the second
- * entity and then on the first one. Assert that the connection appears. Assert that the owner attribute of the relation is mapped
- * with MapsId in the second entity and there is no "Relation Attributes" section.
- * Test that the created relation is successfully deleted. Repeats all steps for the other three
- * types of relation also.
- */
- @Test
- public void testDerivedIdWithSameEmbeddedPK(){
- Utils.sayTestStarted("testDerivedIdWithSameEmbeddedPK");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart parentEntity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- SWTBotGefEditPart dependentEntity = editorProxy.addEntityToDiagram(50, 300,
- jpaProject);
-
- editorProxy.deleteEntityDefaultPK(dependentEntity);
- editorProxy.deleteEntityDefaultPK(parentEntity);
-
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(300, 50, jpaProject);
-
- editorProxy.addEmbeddedIdToEntity(dependentEntity, embeddable);
-
- editorProxy.addEmbeddedIdToEntity(parentEntity, embeddable);
-
-
- editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.ONE_TO_ONE, "OneToOne",
- "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, false, true, null);
-
- editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.ONE_TO_ONE, "OneToOne",
- "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true, true, null);
- editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
- "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, false, true, null);
-
- editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
- "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true, true, null);
-
- Utils.sayTestFinished("testDerivedIdWithSameEmbeddedPK");
- }
-
- /**
- * Create two entities and two embeddable in the diagram. Remove the default primary key attribute from both entities.
- * Embed the first embeddable in the first enetity and the second one in the second entity. Change the mapping of the
- * embedded attributes to EmbeddedIds. From the "Derived Identifiers" select "One-to-One" unidirectional relation feature
- * and click first on the second entity and then on the first one. Assert that the connection appears. Assert that the owner
- * attribute of the relation is mapped with MapsId in the second entity and there is no "Relation Attributes" section.
- * Assert that e new helper attribute is added in the second embeddable and its type is of the first embeddable.
- * Test that the created relation is successfully deleted. Repeats all steps for the other three
- * types of relation also.
- */
- @Ignore
- @Test
- public void testDerivedIdWithDifferentEmbeddedPK(){
- Utils.sayTestStarted("testDerivedIdWithDifferentEmbeddedPK");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart parentEntity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- editorProxy.deleteEntityDefaultPK(parentEntity);
-
- SWTBotGefEditPart parentEmbeddable = editorProxy.addEmbeddableToDiagram(300, 50, jpaProject);
-
- editorProxy.addEmbeddedIdToEntity(parentEntity, parentEmbeddable);
-
- editorProxy.waitASecond();
-
- SWTBotGefEditPart dependentEntity = editorProxy.addEntityToDiagram(50, 300,
- jpaProject);
-
- editorProxy.deleteEntityDefaultPK(dependentEntity);
-
- SWTBotGefEditPart dependentEmbeddable = editorProxy.addEmbeddableToDiagram(300, 300, jpaProject);
- editorProxy.addEmbeddedIdToEntity(dependentEntity, dependentEmbeddable);
-
- String idClassFQN = editorProxy.getJPTObjectForGefElement(parentEmbeddable).getName();
-
- editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- dependentEntity, parentEntity, dependentEmbeddable, IRelation.RelType.ONE_TO_ONE, "OneToOne",
- "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, false, false, idClassFQN);
-
- editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- dependentEntity, parentEntity, dependentEmbeddable, IRelation.RelType.ONE_TO_ONE, "OneToOne",
- "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true, false, idClassFQN);
-
- editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- dependentEntity, parentEntity, dependentEmbeddable, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
- "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, false, false, idClassFQN);
-
- editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- dependentEntity, parentEntity, dependentEmbeddable, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
- "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true, false, idClassFQN);
-
- Utils.sayTestFinished("testDerivedIdWithDifferentEmbeddedPK");
- }
-
- /**
- * Create two entities and one embeddable in the diagram. Create a simple java class. Remove the default primary key attribute
- * from both entities. Set the java class as IDClass to the first entity and embed the embeddable in the second entity.
- * Change the mapping of the embedded attributes to EmbeddedIds. From the "Derived Identifiers" select "One-to-One" unidirectional relation feature
- * and click first on the second entity and then on the first one. Assert that the connection appears. Assert that the owner
- * attribute of the relation is mapped with MapsId in the second entity and there is no "Relation Attributes" section.
- * Assert that e new helper attribute is added in the embeddable and its type is of the java class used as IdClass.
- * Test that the created relation is successfully deleted. Repeats all steps for the other three
- * types of relation also.
- */
- @Test
- public void testDerivedIdWithIdClassAndEmbeddedPK() throws Exception {
- Utils.sayTestStarted("testDerivedIdWithIdClassAndEmbeddedPK");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart parentEntity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- SWTBotGefEditPart dependentEntity = editorProxy.addEntityToDiagram(50, 300,
- jpaProject);
-
- editorProxy.deleteEntityDefaultPK(dependentEntity);
-
- JPACreateFactory.instance().createIdClassInProject(jpaProject.getProject(), new String[] {"org", "persistence"}, "TestIdClass");
- String idClassFQN = "org.persistence.TestIdClass";
-
- PersistentType parentJPTType= editorProxy.getJPTObjectForGefElement(parentEntity);
- TypeMapping typeMapping = JpaArtifactFactory.instance().getTypeMapping(parentJPTType);
- assertTrue(Entity.class.isInstance(typeMapping));
- ((Entity)typeMapping).getIdClassReference().setSpecifiedIdClassName("TestIdClass");
-
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(300, 50, jpaProject);
-
- editorProxy.addEmbeddedIdToEntity(dependentEntity, embeddable);
-
-
- editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.ONE_TO_ONE, "OneToOne",
- "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, false, false, idClassFQN);
-
- editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.ONE_TO_ONE, "OneToOne",
- "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true, false, idClassFQN);
-
- editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
- "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, false, false, idClassFQN);
-
- editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
- "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true, false, idClassFQN);
-
- Utils.sayTestFinished("testDerivedIdWithIdClassAndEmbeddedPK");
- }
-
-
- /**
- * Create two entities and one embeddable in the diagram.Remove the default primary key attribute
- * from both entities. Set the embeddable as IDClass to the first entity and embed the embeddable in the second entity.
- * Change the mapping of the embedded attributes to EmbeddedIds. From the "Derived Identifiers" select "One-to-One" unidirectional relation feature
- * and click first on the second entity and then on the first one. Assert that the connection appears. Assert that the owner
- * attribute of the relation is mapped with MapsId in the second entity and there is no "Relation Attributes" section.
- * Test that the created relation is successfully deleted. Repeats all steps for the other three
- * types of relation also.
- */
- @Test
- public void testDerivedIdWithIdClassAndSameEmbeddedPK() throws Exception {
- Utils.sayTestStarted("testDerivedIdWithIdClassAndSameEmbeddedPK");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart parentEntity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- editorProxy.deleteEntityDefaultPK(parentEntity);
- String attrnamString = editorProxy.getUniqueAttrName(parentEntity);
- editorProxy.addAttributeToJPT(parentEntity, attrnamString);
-
- SWTBotGefEditPart dependentEntity = editorProxy.addEntityToDiagram(50, 300,
- jpaProject);
-
- editorProxy.deleteEntityDefaultPK(dependentEntity);
-
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(300, 50, jpaProject);
-
- editorProxy.addEmbeddedIdToEntity(dependentEntity, embeddable);
-
- String attrname = editorProxy.getUniqueAttrName(embeddable);
- jpaDiagramEditor.activateDefaultTool();
- editorProxy.waitASecond();
- editorProxy.addAttributeToJPT(embeddable, attrname);
-
- PersistentType parentJPTType= editorProxy.getJPTObjectForGefElement(parentEntity);
-
- String className = editorProxy.getJPTObjectForGefElement(embeddable).getSimpleName();
- TypeMapping typeMapping = JpaArtifactFactory.instance().getTypeMapping(parentJPTType);
- assertTrue(Entity.class.isInstance(typeMapping));
- ((Entity)typeMapping).getIdClassReference().setSpecifiedIdClassName(className);
-
- editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.ONE_TO_ONE, "OneToOne",
- "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, false, true, null);
-
- editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.ONE_TO_ONE, "OneToOne",
- "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true, true, null);
-
- editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
- "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, false, true, null);
-
- editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
- "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true, true, null);
-
- Utils.sayTestFinished("testDerivedIdWithIdClassAndSameEmbeddedPK");
- }
-
- /**
- * Create two entities and one embeddable in the diagram. Create a simple java class. Remove the default primary key attribute
- * from both entities. Embed the embeddable in the first entity and set the java class as IDClass to the second entity.
- * Change the mapping of the embedded attributes to EmbeddedIds. From the "Derived Identifiers" select "One-to-One" unidirectional relation feature
- * and click first on the second entity and then on the first one. Assert that the connection appears. Assert that the owner
- * attribute of the relation is mapped as primary key attribute in the second entity and there is no "Relation Attributes" section.
- * Assert that e new helper attribute is added in the java class and its type is of the embeddable.
- * Test that the created relation is successfully deleted. Repeats all steps for the other three
- * types of relation also.
- */
- @Test
- public void testDerivedIdWithEmbeddedPkAndIdClass() throws Exception {
- Utils.sayTestStarted("testDerivedIdWithEmbeddedPkAndIdClass");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart parentEntity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- editorProxy.deleteEntityDefaultPK(parentEntity);
-
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(300, 50, jpaProject);
-
- editorProxy.addEmbeddedIdToEntity(parentEntity, embeddable);
-
-
- SWTBotGefEditPart dependentEntity = editorProxy.addEntityToDiagram(50, 300,
- jpaProject);
-
-
- IFile idClass = JPACreateFactory.instance().createIdClassInProject(jpaProject.getProject(), new String[] {"org", "persistence"}, "TestIdClass");
- String idClassFQN = editorProxy.getJPTObjectForGefElement(embeddable).getSimpleName();
-
- PersistentType parentJPTType= editorProxy.getJPTObjectForGefElement(dependentEntity);
- TypeMapping typeMapping = JpaArtifactFactory.instance().getTypeMapping(parentJPTType);
- assertTrue(Entity.class.isInstance(typeMapping));
- ((Entity)typeMapping).getIdClassReference().setSpecifiedIdClassName("TestIdClass");
-
-
- editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.ONE_TO_ONE, "OneToOne",
- "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, false, false, idClassFQN);
-
- editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.ONE_TO_ONE, "OneToOne",
- "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true, false, idClassFQN);
-
- editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
- "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, false, false, idClassFQN);
-
- editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
- "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true, false, idClassFQN);
-
- Utils.sayTestFinished("testDerivedIdWithEmbeddedPkAndIdClass");
- }
-
- /**
- * Create two entities and one embeddable in the diagram. Remove the default primary key attribute
- * from both entities. Embed the embeddable in the first entity and set the embeddable as IDClass to the second entity.
- * Change the mapping of the embedded attributes to EmbeddedIds. From the "Derived Identifiers" select "One-to-One" unidirectional relation feature
- * and click first on the second entity and then on the first one. Assert that the connection appears. Assert that the owner
- * attribute of the relation is mapped as primary key attribute in the second entity and there is no "Relation Attributes" section.
- * Test that the created relation is successfully deleted. Repeats all steps for the other three
- * types of relation also.
- */
- @Test
- public void testDerivedIdWithEmbeddedPkAndSameIdClass() throws Exception {
- Utils.sayTestStarted("testDerivedIdWithEmbeddedPkAndSameIdClass");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- SWTBotGefEditPart parentEntity = editorProxy.addEntityToDiagram(50, 50,
- jpaProject);
-
- editorProxy.deleteEntityDefaultPK(parentEntity);
-
- SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(300, 50, jpaProject);
-
- editorProxy.addEmbeddedIdToEntity(parentEntity, embeddable);
-
- String attrname = editorProxy.getUniqueAttrName(embeddable);
- jpaDiagramEditor.activateDefaultTool();
- editorProxy.waitASecond();
- editorProxy.addAttributeToJPT(embeddable, attrname);
-
- SWTBotGefEditPart dependentEntity = editorProxy.addEntityToDiagram(50, 300,
- jpaProject);
-
- editorProxy.deleteEntityDefaultPK(dependentEntity);
- String attrnamString = editorProxy.getUniqueAttrName(parentEntity);
- editorProxy.addAttributeToJPT(parentEntity, attrnamString);
-
- PersistentType parentJPTType= editorProxy.getJPTObjectForGefElement(dependentEntity);
- String className = editorProxy.getJPTObjectForGefElement(embeddable).getSimpleName();
- TypeMapping typeMapping = JpaArtifactFactory.instance().getTypeMapping(parentJPTType);
- assertTrue(Entity.class.isInstance(typeMapping));
- ((Entity)typeMapping).getIdClassReference().setSpecifiedIdClassName(className);
-
- editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- dependentEntity, parentEntity, (IFile)parentJPTType.getResource(), IRelation.RelType.ONE_TO_ONE, "OneToOne",
- "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, false, true, null);
-
- editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- dependentEntity, parentEntity, (IFile)parentJPTType.getResource(), IRelation.RelType.ONE_TO_ONE, "OneToOne",
- "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true, true, null);
-
- editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- dependentEntity, parentEntity, (IFile)parentJPTType.getResource(), IRelation.RelType.MANY_TO_ONE, "ManyToOne",
- "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, false, true, null);
-
- editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- dependentEntity, parentEntity, (IFile)parentJPTType.getResource(), IRelation.RelType.MANY_TO_ONE, "ManyToOne",
- "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true, true, null);
-
- Utils.sayTestFinished("testDerivedIdWithEmbeddedPkAndSameIdClass");
- }
-
- /**
- * Test that the JPA Diagram editor is opened when the context menu
- * "JPA Tools -> Open Diagram" of the project is called.
- */
- @Test
- public void testOpenDiagramOnProjectLevel() {
- Utils.sayTestStarted("testOpenDiagramOnProjectLevel");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- workbenchBot.closeAllEditors();
- // open JPA diagram editor on project level: JPA Tools -> Open Diagram
- SWTBotGefEditor diagramEditor = editorProxy
- .openDiagramOnJPAProjectNode(TEST_PROJECT, true);
- diagramEditor.close();
-
- Utils.sayTestFinished("testOpenDiagramOnProjectLevel");
- }
-
- /**
- * Test that the JPA Diagram editor is opened when the context menu
- * "Open Diagram" of the JPA content node is called.
- */
- @Test
- public void testOpenDiagramOnJPAContentNodeLevel() {
- Utils.sayTestStarted("testOpenDiagramOnJPAContentNodeLevel");
-
- assertTrue("The diagram must be empty.", jpaDiagramEditor
- .mainEditPart().children().isEmpty());
-
- workbenchBot.closeAllEditors();
- // open JPA diagram editor on JPA content level: Open Diagram
- SWTBotGefEditor diagramEditor = editorProxy
- .openDiagramOnJPAContentNode(TEST_PROJECT);
- diagramEditor.close();
-
- Utils.sayTestFinished("testOpenDiagramOnJPAContentNodeLevel");
- }
-
- @After
- public void tearDown() throws Exception {
- editorProxy.deleteResources(jpaProject);
- }
-}
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/utils/ContextMenuHelper.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/utils/ContextMenuHelper.java
new file mode 100644
index 0000000..3a0142e
--- /dev/null
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/utils/ContextMenuHelper.java
@@ -0,0 +1,487 @@
+package org.eclipse.jpt.jpadiagrameditor.swtbot.tests.utils;
+
+import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withMnemonic;
+import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withRegex;
+import static org.eclipse.swtbot.swt.finder.waits.Conditions.shellIsActive;
+import static org.eclipse.swtbot.swt.finder.waits.Conditions.widgetIsEnabled;
+import static org.hamcrest.core.AllOf.allOf;
+import static org.hamcrest.core.IsInstanceOf.instanceOf;
+
+import java.text.MessageFormat;
+import java.util.ArrayDeque;
+import java.util.Arrays;
+import java.util.Deque;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Widget;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.VoidResult;
+import org.eclipse.swtbot.swt.finder.results.WidgetResult;
+import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
+import org.eclipse.swtbot.swt.finder.utils.SWTUtils;
+import org.eclipse.swtbot.swt.finder.waits.Conditions;
+import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
+import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.eclipse.ui.internal.WorkbenchMessages;
+import org.hamcrest.Matcher;
+
+public class ContextMenuHelper
+{
+
+ /**
+ * Clicks the context menu matching the text.
+ *
+ * @param text
+ * the text on the context menu.
+ * @throws WidgetNotFoundException
+ * if the widget is not found.
+ */
+ @SuppressWarnings("unchecked")
+ public static void clickContextMenu( final AbstractSWTBot<?> bot, final String... texts )
+ {
+ final Matcher<?>[] matchers = new Matcher<?>[texts.length];
+ for ( int i = 0; i < texts.length; i++ )
+ {
+ // matchers[i] = allOf( instanceOf( MenuItem.class ), withMnemonic( texts[i] ) );
+ matchers[i] = allOf( instanceOf( MenuItem.class ), withRegex( texts[i] ) );
+ }
+
+ // show
+ final MenuItem menuItem = UIThreadRunnable.syncExec( new WidgetResult<MenuItem>()
+ {
+ public MenuItem run()
+ {
+ MenuItem menuItem = null;
+ Control control = ( Control ) bot.widget;
+ Menu menu = control.getMenu();
+ for ( int i = 0; i < matchers.length; i++ )
+ {
+ menuItem = show( menu, matchers[i] );
+ if ( menuItem != null )
+ {
+ menu = menuItem.getMenu();
+ }
+ else
+ {
+ hide( menu );
+ break;
+ }
+ }
+
+ return menuItem;
+ }
+ } );
+ if ( menuItem == null )
+ {
+ throw new WidgetNotFoundException( "Could not find menu: " + Arrays.asList( texts ) );
+ }
+
+ // click
+ click( menuItem );
+
+ // hide
+ UIThreadRunnable.syncExec( new VoidResult()
+ {
+ public void run()
+ {
+ hide( menuItem.getParent() );
+ }
+ } );
+ }
+
+ /**
+ * Clicks the menu from the menu bar matching the given text in the active
+ * shell.
+ *
+ * @param texts
+ * the text on the context menu.
+ * @throws WidgetNotFoundException
+ * if the widget is not found.
+ */
+ public static void clickMenu(final String... texts) {
+ clickMenu(new SWTWorkbenchBot().activeShell(), texts);
+ }
+
+ /**
+ * Clicks the menu from the menu bar matching the given text.
+ *
+ * @param bot
+ * the widget.
+ * @param texts
+ * the text on the context menu.
+ * @throws WidgetNotFoundException
+ * if the widget is not found.
+ */
+ public static MenuItem clickMenu(final AbstractSWTBot<?> bot, final String... texts) {
+ return clickMenu(bot, false, texts);
+ }
+
+ /**
+ * Clicks the menu from the menu bar matching the given text and toggles the
+ * selection of the menu item
+ *
+ * @param bot
+ * the widget.
+ * @param texts
+ * the text on the context menu.
+ * @throws WidgetNotFoundException
+ * if the widget is not found.
+ */
+ public static void clickMenuToggleSeletion(final AbstractSWTBot<?> bot, final String... texts) {
+ clickMenu(bot, true, texts);
+ }
+
+ /**
+ * Clicks the menu from the menu bar matching the given text and toggles the
+ * selection of the menu item
+ *
+ * @param bot
+ * the widget.
+ * @param texts
+ * the text on the context menu.
+ * @param toggleSelection
+ * a flag that shows if the selection of the menu item should be
+ * toggled
+ * @throws WidgetNotFoundException
+ * if the widget is not found.
+ */
+ private static MenuItem clickMenu(final AbstractSWTBot<?> bot, boolean toggleSelection, final String... texts) {
+ // show
+ final MenuItem menuItem = UIThreadRunnable.syncExec(new WidgetResult<MenuItem>() {
+ @Override
+ public MenuItem run() {
+ MenuItem item = null;
+ Shell control = (Shell) bot.widget;
+ Menu menu = control.getMenuBar();
+ for (String text : texts) {
+ @SuppressWarnings("unchecked")
+ Matcher<?> matcher = allOf(instanceOf(MenuItem.class), withMnemonic(text));
+ item = show(menu, matcher);
+ if (item != null) {
+ menu = item.getMenu();
+ } else {
+ hide(menu);
+ break;
+ }
+ }
+
+ return item;
+ }
+ });
+ if (menuItem == null) {
+ throw new WidgetNotFoundException("Could not find menu: " + Arrays.asList(texts));
+ }
+
+ // click
+ new SWTWorkbenchBot().waitUntil(Conditions.widgetIsEnabled(new SWTBotMenu(menuItem)));
+ click(menuItem, toggleSelection);
+
+ // hide
+ UIThreadRunnable.syncExec(new VoidResult() {
+ @Override
+ public void run() {
+ hide(menuItem.getParent());
+ }
+ });
+
+ return menuItem;
+ }
+
+ private static MenuItem show( final Menu menu, final Matcher<?> matcher )
+ {
+ if ( menu != null )
+ {
+ menu.notifyListeners( SWT.Show, new Event() );
+ MenuItem[] items = menu.getItems();
+ for ( final MenuItem menuItem : items )
+ {
+ if ( matcher.matches( menuItem ) )
+ {
+ return menuItem;
+ }
+ }
+ menu.notifyListeners( SWT.Hide, new Event() );
+ }
+ return null;
+ }
+
+
+ private static void click( final MenuItem menuItem )
+ {
+ final Event event = new Event();
+ event.time = ( int ) System.currentTimeMillis();
+ event.widget = menuItem;
+ event.display = menuItem.getDisplay();
+ event.type = SWT.Selection;
+
+ UIThreadRunnable.asyncExec( menuItem.getDisplay(), new VoidResult()
+ {
+ public void run()
+ {
+ menuItem.notifyListeners( SWT.Selection, event );
+ }
+ } );
+ }
+
+ /**
+ * Click on a menu item
+ *
+ * @param menuItem
+ * the menu item that will click
+ * @param toogleSelection
+ * a flag that shows if the selection of the menu item should be
+ * toggled
+ */
+ private static void click(final MenuItem menuItem, final boolean toogleSelection) {
+ final Event event = new Event();
+ event.time = (int) System.currentTimeMillis();
+ event.widget = menuItem;
+ event.display = menuItem.getDisplay();
+ event.type = SWT.Selection;
+
+ UIThreadRunnable.asyncExec(menuItem.getDisplay(), new VoidResult() {
+ @Override
+ public void run() {
+ boolean seleted = true;
+ if (toogleSelection && (SWTUtils.hasStyle(menuItem, SWT.CHECK) | SWTUtils.hasStyle(menuItem, SWT.RADIO))) {
+ seleted = !menuItem.getSelection();
+ }
+ menuItem.setSelection(seleted);
+ menuItem.notifyListeners(SWT.Selection, event);
+ }
+ });
+ }
+
+
+ private static void hide( final Menu menu )
+ {
+ menu.notifyListeners( SWT.Hide, new Event() );
+ if ( menu.getParentMenu() != null )
+ {
+ hide( menu.getParentMenu() );
+ }
+ }
+
+
+ /**
+ * Selects an tree item in the browser tree and expands the selected tree
+ * item. Takes care that all attributes and child entries are initialized so
+ * that there are no pending background actions and event notifications.
+ * This is necessary to avoid race conditions.
+ *
+ * @param tree
+ * the browser tree
+ * @param path
+ * the path to the tree item
+ * @return the selected tree item as SWTBotTreeItem
+ * @throws WidgetNotFoundException
+ * when the tree item is not found in the tree
+ */
+ public static SWTBotTreeItem selectTreeItem(final SWTBotTree tree, final String... path) throws WidgetNotFoundException {
+ return selectTreeItem(tree, true, path);
+ }
+
+ /**
+ * Selects an tree item in the browser tree and optionally expands the
+ * selected tree item. Takes care that all attributes and child entries are
+ * initialized so that there are no pending background actions and event
+ * notifications. This is necessary to avoid race conditions.
+ *
+ * @param tree
+ * the browser tree
+ * @param expandChild
+ * true to expand the child tree item
+ * @param path
+ * the path to the tree item
+ * @return the selected tree item as SWTBotTreeItem
+ * @throws WidgetNotFoundException
+ * when the tree item is not found in the tree
+ */
+ public static SWTBotTreeItem selectTreeItem(final SWTBotTree tree, final boolean expandChild, final String... path)
+ throws WidgetNotFoundException {
+ tree.unselect();
+
+ SWTBotTreeItem treeItem = getTreeItem(tree, expandChild, path);
+ waitForWidgetEnabled(treeItem);
+ treeItem.select();
+ return treeItem;
+ }
+
+ /**
+ * Finds a tree item in a tree and and optionally expands the found tree
+ * item. Takes care that all attributes and child entries are initialized so
+ * that there are no pending background actions and event notifications.
+ * This is necessary to avoid race conditions.
+ *
+ * @param tree
+ * the tree
+ * @param expandChild
+ * true to expand the found tree item
+ * @param path
+ * the path to the tree item
+ * @return the tree item as SWTBotTreeItem
+ * @throws WidgetNotFoundException
+ * when the tree item is not found in the tree
+ */
+ public static SWTBotTreeItem getTreeItem(final SWTBotTree tree, final boolean expandChild, final String... path) throws WidgetNotFoundException {
+ Assert.isTrue(path.length > 0);
+ SWTBotTreeItem treeItem = null;
+// try {
+ // wait for the first item
+ new SWTBot().waitUntil(new DefaultCondition() {
+ @Override
+ public boolean test() throws Exception {
+ try {
+ tree.getTreeItem(path[0]);
+ return true;
+ } catch (WidgetNotFoundException wnfe) {
+ return false;
+ }
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return "Could not find node with text " + path[0]; //$NON-NLS-1$
+ }
+ });
+
+ treeItem = tree.getTreeItem(path[0]);
+ for (int i = 1; i < path.length; i++) {
+ if (treeItem.rowCount() > 0) {
+ waitForWidgetEnabled(tree);
+ treeItem.expand();
+ }
+
+ final String nodeText = path[i];
+ final SWTBotTreeItem currentTreeItem = treeItem;
+
+ // wait until the node appears in the
+ // expanded subtree
+ // as the expansion is executed
+ // asynchronously in the UI thread
+ new SWTBot().waitUntil(new DefaultCondition() {
+ @Override
+ public boolean test() throws Exception {
+ try {
+ currentTreeItem.getNode(nodeText);
+ return true;
+ } catch (WidgetNotFoundException wnfe) {
+ currentTreeItem.collapse();
+ currentTreeItem.expand();
+
+ return false;
+ }
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return "Could not find node with text " + nodeText; //$NON-NLS-1$
+ }
+ });
+
+ treeItem = treeItem.getNode(nodeText);
+ }
+ if (treeItem.widget.isDisposed()) {
+ getTreeItem(tree, expandChild, path);
+ } else {
+ if (expandChild && (treeItem.rowCount() > 0)) {
+ waitForWidgetEnabled(tree);
+ treeItem.expand();
+ }
+ }
+
+// } catch (TimeoutException te) {
+// throw new WidgetNotFoundException(te.getMessage());
+// }
+ return treeItem;
+ }
+
+ /**
+ * Waits until a widget is enabled
+ *
+ * @param widget
+ * the widget
+ */
+ public static void waitForWidgetEnabled(AbstractSWTBot<? extends Widget> widget) {
+ waitForWidgetEnabled(widget, SWTBotPreferences.DEFAULT_POLL_DELAY);
+ }
+
+ /**
+ * Waits until a widget is enabled
+ *
+ * @param widget
+ * @param pollDelay
+ * the interval on which the check is performed
+ */
+ public static void waitForWidgetEnabled(AbstractSWTBot<? extends Widget> widget, long pollDelay) {
+ new SWTWorkbenchBot().waitUntil(widgetIsEnabled(widget), SWTBotPreferences.TIMEOUT, pollDelay);
+ }
+
+ public static SWTBotTreeItem selectNodeInTree(SWTBotTree tree, String... path) {
+ SWTBotTreeItem firstLevelTreeItem = tree.getTreeItem(path[0]);
+ firstLevelTreeItem.select();
+ firstLevelTreeItem.click();
+ firstLevelTreeItem.expand();
+ if (path.length > 1) {
+ String[] newPath = Arrays.copyOfRange(path, 1, path.length);
+ return selectSubnode(firstLevelTreeItem, newPath);
+ }
+ return firstLevelTreeItem;
+ }
+
+ private static SWTBotTreeItem selectSubnode(SWTBotTreeItem parentNode, String... path) {
+ SWTBotTreeItem resultTreeItem = parentNode;
+ for (int i = 0; i < path.length; i++) {
+ resultTreeItem = parentNode.getNode(path[i]);
+ resultTreeItem.select();
+ resultTreeItem.click();
+ resultTreeItem.expand();
+ if (i < (path.length - 1)) {
+ String[] newPath = Arrays.copyOfRange(path, 1, path.length);
+ return selectSubnode(resultTreeItem, newPath);
+ }
+ }
+ return resultTreeItem;
+ }
+
+ /**
+ * Open properties in the given path
+ *
+ * @param contextMenu
+ * the name of the context menu
+ * @param pathToResource
+ * the path to the resource
+ * @return the workbench bot
+ */
+ public static SWTWorkbenchBot openProjectProperties(SWTWorkbenchBot bot, String projectName) {
+
+ bot.viewByTitle("Project Explorer").show();
+ SWTBotTree resourcesTree = bot.tree();
+
+ // Depending on the previous operation the tree can
+ // be disabled.
+ // This will fail expanded operations below. That is
+ // way we need wait condition.
+ bot.waitUntil(widgetIsEnabled(resourcesTree));
+ selectTreeItem(resourcesTree, projectName);
+ clickContextMenu(resourcesTree, WorkbenchMessages.Workbench_properties);
+
+ bot.waitUntil(shellIsActive(MessageFormat.format(WorkbenchMessages.PropertyDialog_propertyMessage, projectName)), 20000);
+ SWTBotShell shell = bot.shell(MessageFormat.format(WorkbenchMessages.PropertyDialog_propertyMessage, projectName));
+ shell.activate();
+ return bot;
+ }
+} \ No newline at end of file
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/utils/EditorProxy.java
index 8ec3bae..2c0fdbc 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/utils/EditorProxy.java
@@ -1,4 +1,4 @@
-package org.eclipse.jpt.jpadiagrameditor.swtbot.tests.ui.editor;
+package org.eclipse.jpt.jpadiagrameditor.swtbot.tests.utils;
import static org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable.asyncExec;
import static org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable.syncExec;
@@ -22,6 +22,7 @@ import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.draw2d.FigureCanvas;
@@ -38,27 +39,39 @@ import org.eclipse.graphiti.ui.internal.contextbuttons.ContextButton;
import org.eclipse.graphiti.ui.internal.contextbuttons.ContextButtonPad;
import org.eclipse.graphiti.ui.internal.parts.DiagramEditPart;
import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jdt.core.IField;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jpt.common.core.resource.java.Annotation;
import org.eclipse.jpt.common.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.common.ui.internal.utility.SynchronousUiCommandContext;
+import org.eclipse.jpt.common.utility.command.Command;
import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.core.JpaProjectManager;
import org.eclipse.jpt.jpa.core.MappingKeys;
import org.eclipse.jpt.jpa.core.context.AttributeMapping;
import org.eclipse.jpt.jpa.core.context.Entity;
import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.TypeMapping;
+import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
+import org.eclipse.jpt.jpa.core.context.orm.OrmSpecifiedPersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.orm.OrmXml;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.jpa.core.jpa2.MappingKeys2_0;
import org.eclipse.jpt.jpa.core.jpa2.context.DerivedIdentity2_0;
+import org.eclipse.jpt.jpa.core.jpa2.context.ManyToOneMapping2_0;
+import org.eclipse.jpt.jpa.core.jpa2.context.OneToOneMapping2_0;
import org.eclipse.jpt.jpa.core.jpa2.context.SingleRelationshipMapping2_0;
import org.eclipse.jpt.jpa.ui.details.JptJpaUiDetailsMessages;
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.conditions.ConnectionIsShown;
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.conditions.DiagramIsEmpty;
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.conditions.ElementAppearsInDiagram;
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.conditions.ElementDisappears;
+import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.conditions.ElementIsShown;
import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.internal.JPACreateFactory;
-import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.internal.Utils;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.propertypage.JPADiagramPropertyPage;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
@@ -101,6 +114,8 @@ public class EditorProxy {
protected SWTGefBot bot;
private SWTBotGefEditor jpaDiagramEditor;
+ private JpaArtifactFactory jpaFactory;
+ private OrmXml ormXml;
/**
* Create proxy object.
@@ -110,6 +125,7 @@ public class EditorProxy {
public EditorProxy(SWTWorkbenchBot workbenchBot, SWTGefBot bot) {
this.workbenchBot = workbenchBot;
this.bot = bot;
+ jpaFactory = JpaArtifactFactory.instance();
}
public SWTBotGefEditor openDiagramOnJPAContentNode(String name) {
@@ -229,7 +245,7 @@ public class EditorProxy {
* @return the newly added attribute
*/
public SWTBotGefEditPart addAttributeToJPT(SWTBotGefEditPart jptType,
- String attributeName) {
+ String attributeName, boolean isOrmXml) {
PersistentType jpt = getJPTObjectForGefElement(jptType);
@@ -259,10 +275,14 @@ public class EditorProxy {
PersistentAttribute jpa = getJPAObjectForGefElement(attribute);
assertNotNull(jpa);
+ if(isOrmXml) {
+ assertNotNull(jpaFactory.getORMPersistentAttribute(jpa));
+ }
+
assertEquals(
"The newly added attribute must be mapped as basic attribute.",
MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY,
- jpa.getMappingKey());
+ jpaFactory.getAttributeMapping(jpa).getKey());
return attribute;
}
@@ -291,7 +311,7 @@ public class EditorProxy {
assertEquals(
"The newly added attribute must be mapped as element-collection.",
MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
- jpa.getMappingKey());
+ jpaFactory.getAttributeMapping(jpa).getKey());
return attribute;
}
@@ -326,32 +346,8 @@ public class EditorProxy {
public SWTBotGefEditPart addEntityToDiagram(int x, int y,
JpaProject jpaProject) {
- String entityName = getUniqueEntityName(jpaProject);
-
- jpaDiagramEditor
- .activateTool(JPAEditorMessages.CreateJPAEntityFeature_jpaEntityFeatureName);
- jpaDiagramEditor.doubleClick(x, y);
+ SWTBotGefEditPart entity = addEnt(x, y, jpaProject);
- try {
- bot.waitUntil(new ElementIsShown(jpaDiagramEditor, entityName),
- 15000);
- } catch (TimeoutException e) {
- jpaDiagramEditor.activateDefaultTool();
-
- jpaDiagramEditor
- .activateTool(JPAEditorMessages.CreateJPAEntityFeature_jpaEntityFeatureName);
- jpaDiagramEditor.doubleClick(x, y);
-
- bot.waitUntil(new ElementIsShown(jpaDiagramEditor, entityName),
- 15000);
- }
-
- List<SWTBotGefEditPart> entities = jpaDiagramEditor.mainEditPart()
- .children();
- assertFalse("Editor must contains at least one entity!",
- entities.isEmpty());
-
- SWTBotGefEditPart entity = jpaDiagramEditor.getEditPart(entityName);
assertNotNull("Entity is not added!", entity);
SWTBotGefEditPart idAttribute = jpaDiagramEditor.getEditPart("id");
@@ -367,15 +363,120 @@ public class EditorProxy {
isSectionVisible(
JPAEditorMessages.AddJPAEntityFeature_relationAttributesShapes,
entity));
-// assertFalse(
-// "\"Other Attributes\" section must not be visible!",
-// isSectionVisible(
-// JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
-// entity));
return entity;
}
+ private SWTBotGefEditPart addEnt(int x, int y, JpaProject jpaProject) {
+
+ String entityName = getUniqueEntityName(jpaProject);
+
+ jpaDiagramEditor
+ .activateTool(JPAEditorMessages.CreateJPAEntityFeature_jpaEntityFeatureName);
+ jpaDiagramEditor.doubleClick(x, y);
+
+ SWTBotGefEditPart entity = null;
+
+ try {
+ bot.waitUntil(new ElementIsShown(jpaDiagramEditor, entityName));
+ entity = jpaDiagramEditor.getEditPart(entityName);
+ } catch (TimeoutException e) {
+
+ if(!jpaDiagramEditor.selectedEditParts().isEmpty()) {
+ assertEquals(1, jpaDiagramEditor.selectedEditParts().size());
+
+ PersistentType pers = getJPTObjectForGefElement(jpaDiagramEditor.selectedEditParts().get(0));
+ assertNotNull(pers);
+ assertEquals(entityName, pers.getSimpleName());
+
+ jpaDiagramEditor.save();
+
+ entity = jpaDiagramEditor.selectedEditParts().get(0);
+
+ deleteJPTViaButton(entity, false);
+ bot.waitUntil(new ElementDisappears(jpaDiagramEditor, entityName));
+
+ entity = addEnt(x, y, jpaProject);
+ } else {
+ addEnt(x, y, jpaProject);
+ }
+ }
+ return entity;
+ }
+
+
+ private SWTBotGefEditPart addEmb(int x, int y, JpaProject jpaProject) {
+
+ String embeddableName = getUniqueEmbeddableName(jpaProject);
+
+ jpaDiagramEditor
+ .activateTool(JPAEditorMessages.CreateEmbeddableFeature_EmbeddableFeatureName);
+ jpaDiagramEditor.doubleClick(x, y);
+
+ SWTBotGefEditPart embeddable = null;
+
+ try {
+ bot.waitUntil(new ElementIsShown(jpaDiagramEditor, embeddableName));
+ embeddable = jpaDiagramEditor.getEditPart(embeddableName);
+ } catch (TimeoutException e) {
+
+ if(!jpaDiagramEditor.selectedEditParts().isEmpty()) {
+ assertEquals(1, jpaDiagramEditor.selectedEditParts().size());
+
+ PersistentType pers = getJPTObjectForGefElement(jpaDiagramEditor.selectedEditParts().get(0));
+ assertNotNull(pers);
+ assertEquals(embeddableName, pers.getSimpleName());
+
+ jpaDiagramEditor.save();
+
+ embeddable = jpaDiagramEditor.selectedEditParts().get(0);
+
+ deleteJPTViaButton(embeddable, false);
+ bot.waitUntil(new ElementDisappears(jpaDiagramEditor, embeddableName));
+
+ embeddable = addEmb(x, y, jpaProject);
+ } else {
+ addEmb(x, y, jpaProject);
+ }
+ }
+ return embeddable;
+ }
+
+ private SWTBotGefEditPart addMpdSprcls(int x, int y, JpaProject jpaProject) {
+ String mappedSuperclassName = getUniqueMappedSuperclassName(jpaProject);
+
+ jpaDiagramEditor
+ .activateTool(JPAEditorMessages.CreateMappedSuperclassFeature_createMappedSuperclassFeatureName);
+ jpaDiagramEditor.doubleClick(x, y);
+
+ SWTBotGefEditPart mappedSuperclass = null;
+
+ try {
+ bot.waitUntil(new ElementIsShown(jpaDiagramEditor, mappedSuperclassName));
+ mappedSuperclass = jpaDiagramEditor.getEditPart(mappedSuperclassName);
+ } catch (TimeoutException e) {
+ if(!jpaDiagramEditor.selectedEditParts().isEmpty()) {
+ assertEquals(1, jpaDiagramEditor.selectedEditParts().size());
+
+ PersistentType pers = getJPTObjectForGefElement(jpaDiagramEditor.selectedEditParts().get(0));
+ assertNotNull(pers);
+ assertEquals(mappedSuperclassName, pers.getSimpleName());
+
+ jpaDiagramEditor.save();
+
+ mappedSuperclass = jpaDiagramEditor.selectedEditParts().get(0);
+
+ deleteJPTViaButton(mappedSuperclass, false);
+ bot.waitUntil(new ElementDisappears(jpaDiagramEditor, mappedSuperclassName));
+
+ mappedSuperclass = addMpdSprcls(x, y, jpaProject);
+ } else {
+ addMpdSprcls(x, y, jpaProject);
+ }
+ }
+ return mappedSuperclass;
+ }
+
/**
* Add mapped superclass to diagram
*
@@ -387,32 +488,8 @@ public class EditorProxy {
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);
- } catch (TimeoutException e) {
- jpaDiagramEditor.activateDefaultTool();
-
- jpaDiagramEditor
- .activateTool(JPAEditorMessages.CreateMappedSuperclassFeature_createMappedSuperclassFeatureName);
- jpaDiagramEditor.doubleClick(x, y);
-
- bot.waitUntil(new ElementIsShown(jpaDiagramEditor,
- mappedSuperclassName), 15000);
- }
- List<SWTBotGefEditPart> entities = jpaDiagramEditor.mainEditPart()
- .children();
- assertFalse("Editor must contains at least one mapped superclass!",
- entities.isEmpty());
-
- SWTBotGefEditPart mappedSuperclass = jpaDiagramEditor
- .getEditPart(mappedSuperclassName);
+ SWTBotGefEditPart mappedSuperclass = addMpdSprcls(x, y, jpaProject);
+
assertNotNull("Mapped superclass is not added!", mappedSuperclass);
List<SWTBotGefEditPart> parts = new ArrayList<SWTBotGefEditPart>();
@@ -433,11 +510,6 @@ public class EditorProxy {
isSectionVisible(
JPAEditorMessages.AddJPAEntityFeature_relationAttributesShapes,
mappedSuperclass));
-// assertFalse(
-// "\"Other Attributes\" section must not be visible!",
-// isSectionVisible(
-// JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
-// mappedSuperclass));
return mappedSuperclass;
}
@@ -453,33 +525,9 @@ public class EditorProxy {
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),
- 20000);
- } catch (TimeoutException e) {
- jpaDiagramEditor.activateDefaultTool();
-
- jpaDiagramEditor
- .activateTool(JPAEditorMessages.CreateEmbeddableFeature_EmbeddableFeatureName);
- jpaDiagramEditor.doubleClick(x, y);
-
- bot.waitUntil(new ElementIsShown(jpaDiagramEditor, embeddableName),
- 20000);
- }
-
- List<SWTBotGefEditPart> entities = jpaDiagramEditor.mainEditPart()
- .children();
- assertFalse("Editor must contains at least one embeddable!",
- entities.isEmpty());
+
+ SWTBotGefEditPart embeddable = addEmb(x, y, jpaProject);
- SWTBotGefEditPart embeddable = jpaDiagramEditor
- .getEditPart(embeddableName);
assertNotNull("Embeddable is not added!", embeddable);
List<SWTBotGefEditPart> editParts = new ArrayList<SWTBotGefEditPart>();
@@ -499,12 +547,6 @@ public class EditorProxy {
isSectionVisible(
JPAEditorMessages.AddJPAEntityFeature_relationAttributesShapes,
embeddable));
-// assertFalse(
-// "\"Other Attributes\" section must not be visible!",
-// isSectionVisible(
-// JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
-// embeddable));
-
return embeddable;
}
@@ -591,7 +633,14 @@ public class EditorProxy {
* @param entityName
* - the name of the entity to be deleted
*/
- public void deleteDiagramElements() {
+ public void deleteDiagramElements(boolean isOrmXml) {
+
+ try {
+ JPACreateFactory.waitNonSystemJobs(60000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
jpaDiagramEditor.save();
List<SWTBotGefEditPart> entitiesInDiagram = jpaDiagramEditor
@@ -603,8 +652,11 @@ public class EditorProxy {
SWTBotGefEditPart editPart = entitiesInDiagram.get(i);
assertNotNull(editPart);
PersistentType type = getJPTObjectForGefElement(editPart);
+ deleteAllAttributesFromJPT(editPart, type);
if (type != null) {
editPart.select();
+// deletePersistentObject(editPart, type
+// .getSimpleName());
jpaDiagramEditor.clickContextMenu("Delete");
confirmDelete();
bot.waitUntil(
@@ -612,25 +664,54 @@ public class EditorProxy {
.getSimpleName()), 10000);
editPart = jpaDiagramEditor.getEditPart(type.getSimpleName());
assertNull("Entity is not deleted!", editPart);
+ if(isOrmXml){
+ assertNull(ormXml.getPersistentType(type.getName()));
+ }
}
}
-
- waitASecond();
- entitiesInDiagram = jpaDiagramEditor.mainEditPart().children();
- assertTrue("Diagram must be empty!", entitiesInDiagram.isEmpty());
-
+
+ bot.waitUntil(new DiagramIsEmpty(jpaDiagramEditor), 20000 );
jpaDiagramEditor.save();
+
+ try {
+ JPACreateFactory.waitNonSystemJobs();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
// assertTrue("Editor must be dirty!", jpaDiagramEditor.isDirty());
}
+ private void deleteAllAttributesFromJPT(SWTBotGefEditPart editPart,
+ PersistentType type) {
+ if(type!= null) {
+ for(PersistentAttribute pa : type.getAttributes()){
+ if(!(pa.getName().equals("id"))) {
+ deleteAttributeInJPT(editPart, pa.getName());
+ }
+ }
+ jpaDiagramEditor.activateDefaultTool();
+ if(isJPTDirty(editPart)) {
+ jpaDiagramEditor.select(editPart);
+ jpaDiagramEditor.click(editPart);
+ jpaDiagramEditor.clickContextMenu("Save");
+ }
+ jpaDiagramEditor.save();
+ }
+ }
+
public void deleteAttributeInJPT(SWTBotGefEditPart jpt, String attributeName) {
+ try {
+ JPACreateFactory.waitNonSystemJobs(60000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
jpaDiagramEditor.activateDefaultTool();
- List<SWTBotGefEditPart> jptParts = new ArrayList<SWTBotGefEditPart>();
- jptParts.add(jpt);
- SWTBotGefEditPart attribute = jpaDiagramEditor.getEditpart(
- attributeName, jptParts);
+ SWTBotGefEditPart attribute = getAttributeInPE(jpt, attributeName);
attribute.select();
attribute.click();
jpaDiagramEditor.clickContextMenu("Delete");
@@ -947,6 +1028,9 @@ public class EditorProxy {
connection.select();
jpaDiagramEditor.clickContextMenu("Delete");
denyDelete();
+
+ jpaDiagramEditor.save();
+
assertFalse(entity1.sourceConnections().isEmpty());
assertFalse(entity2.targetConnections().isEmpty());
connection = getConnection(entity1, entity2);
@@ -990,6 +1074,9 @@ public class EditorProxy {
connection.select();
jpaDiagramEditor.clickContextMenu("Delete");
denyDelete();
+
+ jpaDiagramEditor.save();
+
assertFalse(entity1.sourceConnections().isEmpty());
assertFalse(entity1.targetConnections().isEmpty());
connection = getConnection(entity1, entity1);
@@ -1021,6 +1108,9 @@ public class EditorProxy {
connection.select();
jpaDiagramEditor.clickContextMenu("Delete");
denyDelete();
+
+ jpaDiagramEditor.save();
+
assertFalse(entity1.sourceConnections().isEmpty());
assertFalse(entity2.targetConnections().isEmpty());
connection = getConnection(entity1, entity2);
@@ -1063,6 +1153,9 @@ public class EditorProxy {
connection.select();
jpaDiagramEditor.clickContextMenu("Delete");
denyDelete();
+
+ jpaDiagramEditor.save();
+
assertFalse(entity1.sourceConnections().isEmpty());
assertFalse(entity1.targetConnections().isEmpty());
connection = getConnection(entity1, entity1);
@@ -1089,12 +1182,19 @@ public class EditorProxy {
*/
public void assertBiDirRelationIsDeleted(SWTBotGefEditPart entity1,
SWTBotGefEditPart entity2, SWTBotGefConnectionEditPart connection,
- String ownerAttributeName, String inverseAttributeName) {
+ String ownerAttributeName, String inverseAttributeName, boolean isOrmXml) {
+
+ PersistentAttribute ownerAt = getJPAObjectForGefElement(jpaDiagramEditor.getEditPart(ownerAttributeName));
+ PersistentAttribute inverseAt = getJPAObjectForGefElement(jpaDiagramEditor.getEditPart(inverseAttributeName));
+
connection.select();
jpaDiagramEditor.clickContextMenu("Delete");
confirmDelete();
bot.waitUntil(new ElementDisappears(jpaDiagramEditor,
ownerAttributeName), 10000);
+
+ jpaDiagramEditor.save();
+
// assertTrue(entity1.sourceConnections().isEmpty());
// assertTrue(entity2.targetConnections().isEmpty());
assertNull(jpaDiagramEditor.getEditPart(ownerAttributeName));
@@ -1110,6 +1210,10 @@ public class EditorProxy {
isSectionVisible(
entity2,
JPAEditorMessages.AddJPAEntityFeature_relationAttributesShapes));
+ if(isOrmXml){
+ assertOrmAttrIsDeleted(ownerAt);
+ assertOrmAttrIsDeleted(inverseAt);
+ }
}
/**
@@ -1125,12 +1229,18 @@ public class EditorProxy {
*/
public void assertSelfBiDirRelationIsDeleted(SWTBotGefEditPart entity1,
SWTBotGefConnectionEditPart connection, String ownerAttributeName,
- String inverseAttributeName) {
+ String inverseAttributeName, boolean isOrmXml) {
+ PersistentAttribute ownerAt = getJPAObjectForGefElement(jpaDiagramEditor.getEditPart(ownerAttributeName));
+ PersistentAttribute inverseAt = getJPAObjectForGefElement(jpaDiagramEditor.getEditPart(inverseAttributeName));
+
connection.select();
jpaDiagramEditor.clickContextMenu("Delete");
confirmDelete();
bot.waitUntil(new ElementDisappears(jpaDiagramEditor,
ownerAttributeName), 10000);
+
+ jpaDiagramEditor.save();
+
assertTrue(entity1.sourceConnections().isEmpty());
assertTrue(entity1.targetConnections().isEmpty());
assertNull(jpaDiagramEditor.getEditPart(ownerAttributeName));
@@ -1140,6 +1250,10 @@ public class EditorProxy {
isSectionVisible(
entity1,
JPAEditorMessages.AddJPAEntityFeature_relationAttributesShapes));
+ if(isOrmXml){
+ assertOrmAttrIsDeleted(ownerAt);
+ assertOrmAttrIsDeleted(inverseAt);
+ }
}
/**
@@ -1156,12 +1270,18 @@ public class EditorProxy {
*/
public void assertUniDirRelationIsDeleted(SWTBotGefEditPart entity1,
SWTBotGefEditPart entity2, SWTBotGefConnectionEditPart connection,
- String attributeName) {
+ String attributeName, boolean isOrmXml) {
+
+ PersistentAttribute at = getJPAObjectForGefElement(jpaDiagramEditor.getEditPart(attributeName));
connection.select();
jpaDiagramEditor.clickContextMenu("Delete");
confirmDelete();
+
bot.waitUntil(new ElementDisappears(jpaDiagramEditor, attributeName),
- 10000);
+ 20000);
+
+ jpaDiagramEditor.save();
+
// assertTrue(entity1.sourceConnections().isEmpty());
// assertTrue(entity2.targetConnections().isEmpty());
assertNull(jpaDiagramEditor.getEditPart(attributeName));
@@ -1175,6 +1295,22 @@ public class EditorProxy {
isSectionVisible(
entity2,
JPAEditorMessages.AddJPAEntityFeature_relationAttributesShapes));
+
+ if(isOrmXml){
+ assertOrmAttrIsDeleted(at);
+ }
+ }
+
+ private void assertOrmAttrIsDeleted(PersistentAttribute at) {
+ OrmPersistentType ormJpt = ormXml.getPersistentType(at.getDeclaringPersistentType().getName());
+ assertNotNull(ormJpt);
+ OrmPersistentAttribute ormAttr = ormJpt.getAttributeNamed(at.getName());
+ try {
+ assertNull(ormAttr);
+ } catch (AssertionError e) {
+ assertNotNull(ormAttr);
+ assertTrue(ormAttr.isVirtual());
+ }
}
/**
@@ -1189,7 +1325,8 @@ public class EditorProxy {
* @param inverseAttributeName
*/
public void assertSelfUniDirRelationIsDeleted(SWTBotGefEditPart entity1,
- SWTBotGefConnectionEditPart connection, String attributeName) {
+ SWTBotGefConnectionEditPart connection, String attributeName, boolean isOrmXml) {
+ PersistentAttribute at = getJPAObjectForGefElement(jpaDiagramEditor.getEditPart(attributeName));
connection.select();
jpaDiagramEditor.clickContextMenu("Delete");
confirmDelete();
@@ -1197,12 +1334,18 @@ public class EditorProxy {
10000);
assertTrue(entity1.sourceConnections().isEmpty());
assertTrue(entity1.targetConnections().isEmpty());
+
+ jpaDiagramEditor.save();
+
assertNull(jpaDiagramEditor.getEditPart(attributeName));
assertFalse(
"\"Relation Attributes\" section of the owner entity must not be visible!",
isSectionVisible(
entity1,
JPAEditorMessages.AddJPAEntityFeature_relationAttributesShapes));
+ if(isOrmXml){
+ assertOrmAttrIsDeleted(at);
+ }
}
/**
@@ -1317,12 +1460,21 @@ public class EditorProxy {
* @param rel
* @return the name of the owner relationship attribute
*/
- public String testOwnerRelationAttributeProperties(IRelation rel) {
+ public String testOwnerRelationAttributeProperties(IRelation rel, String mappingKey, boolean isOrmXml) {
PersistentAttribute ownerAttr = rel.getOwnerAnnotatedAttribute();
String attributeName = rel.getOwnerAttributeName();
assertNotNull(ownerAttr);
assertNotNull(jpaDiagramEditor.getEditPart(attributeName));
-
+ if(isOrmXml) {
+ OrmPersistentType ormJpt = ormXml.getPersistentType(ownerAttr.getDeclaringPersistentType().getName());
+ assertNotNull(ormJpt);
+ OrmPersistentAttribute ormAttr = ormJpt.getAttributeNamed(attributeName);
+ assertNotNull(ormAttr);
+ assertFalse(ormAttr.isVirtual());
+ }
+
+ assertIsMappedAttribute(ownerAttr, mappingKey);
+
return attributeName;
}
@@ -1339,8 +1491,9 @@ public class EditorProxy {
String attributeName = embeddedAttr.getName();
assertNotNull(embeddedAttr);
assertNotNull(jpaDiagramEditor.getEditPart(attributeName));
+ AttributeMapping attrMapping = jpaFactory.getAttributeMapping(embeddedAttr);
assertEquals("The attribute must be embedded attribute.",
- embeddedAttr.getMappingKey(), attributeMapping);
+ attributeMapping, attrMapping.getKey());
return attributeName;
}
@@ -1351,12 +1504,21 @@ public class EditorProxy {
* @param rel
* @return the name of the inverse relationship attribute
*/
- public String testInverseRelationAttributeProperties(IRelation rel) {
+ public String testInverseRelationAttributeProperties(IRelation rel, String mappingKey, boolean isOrmXml) {
PersistentAttribute inverseAttr = rel
.getInverseAnnotatedAttribute();
String inverseAttributeName = rel.getInverseAttributeName();
assertNotNull(inverseAttr);
assertNotNull(jpaDiagramEditor.getEditPart(inverseAttributeName));
+ if(isOrmXml) {
+ OrmPersistentType ormJpt = ormXml.getPersistentType(inverseAttr.getDeclaringPersistentType().getName());
+ assertNotNull(ormJpt);
+ OrmPersistentAttribute ormAttr = ormJpt.getAttributeNamed(inverseAttributeName);
+ assertNotNull(ormAttr);
+ assertFalse(ormAttr.isVirtual());
+ }
+
+ assertIsMappedAttribute(inverseAttr, mappingKey);
return inverseAttributeName;
}
@@ -1425,33 +1587,41 @@ public class EditorProxy {
}
}
- /**
- * Assert that the relation attribute is correctly mapped in the JPA Details
- * view
- *
- * @param attributeName
- * @param relationAttributeMapping
- * - the expected attribute mapping
- */
- public void assertAttributeIsCorretlyMapped(String attributeName,
- String relationAttributeMapping) {
-
- // assert that the JPA Details view is opened
- SWTBotView jpaDetailsView = workbenchBot.viewByTitle("JPA Details");
- jpaDetailsView.setFocus();
- assertTrue("JPA Details view must be opened!",
- jpaDetailsView.isActive());
-
- SWTBotGefEditPart attribute = jpaDiagramEditor
- .getEditPart(attributeName);
- attribute.select();
- attribute.click();
-
- // assert that the default entity's attribute is mapped as primary key
- SWTBot jpaDetailsBot = jpaDetailsView.bot();
- SWTBotStyledText styledText = jpaDetailsBot.styledText();
- assertEquals("Attribute '" + attributeName + "' is mapped as "
- + relationAttributeMapping + ".", styledText.getText());
+// /**
+// * Assert that the relation attribute is correctly mapped in the JPA Details
+// * view
+// *
+// * @param attributeName
+// * @param relationAttributeMapping
+// * - the expected attribute mapping
+// */
+// public void assertAttributeIsCorretlyMapped(String attributeName,
+// String relationAttributeMapping) {
+//
+// // assert that the JPA Details view is opened
+// SWTBotView jpaDetailsView = workbenchBot.viewByTitle("JPA Details");
+// jpaDetailsView.setFocus();
+// assertTrue("JPA Details view must be opened!",
+// jpaDetailsView.isActive());
+//
+// SWTBotGefEditPart attribute = jpaDiagramEditor
+// .getEditPart(attributeName);
+// attribute.select();
+// attribute.click();
+//
+// // assert that the default entity's attribute is mapped as primary key
+// jpaDetailsView.show();
+// SWTBot jpaDetailsBot = jpaDetailsView.bot();
+// SWTBotStyledText styledText = jpaDetailsBot.styledText();
+// assertEquals("Attribute '" + attributeName + "' is mapped as "
+// + relationAttributeMapping + ".", styledText.getText());
+// }
+
+ public void assertIsMappedAttribute(PersistentAttribute jpa, String mappingKey){
+ assertEquals(
+ "The newly added attribute must be mapped as basic attribute.",
+ mappingKey,
+ jpaFactory.getAttributeMapping(jpa).getKey());
}
/**
@@ -1489,7 +1659,7 @@ public class EditorProxy {
// assert that the JPA Details view is opened
SWTBotView jpaDetailsView = workbenchBot.viewByTitle("JPA Details");
- jpaDetailsView.setFocus();
+ jpaDetailsView.show();
assertTrue("JPA Details view must be opened!",
jpaDetailsView.isActive());
@@ -1507,7 +1677,14 @@ public class EditorProxy {
+ ".", styledText.getText());
}
- public void deleteJPTViaButton(SWTBotGefEditPart jptType) {
+ public void deleteJPTViaButton(SWTBotGefEditPart jptType, boolean must) {
+
+ try {
+ JPACreateFactory.waitNonSystemJobs(60000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
String jptName = getJPTObjectForGefElement(jptType).getSimpleName();
@@ -1515,10 +1692,16 @@ public class EditorProxy {
jptType,
JPAEditorMessages.JPAEditorToolBehaviorProvider_deleteEntityFromModelButtonLabel);
denyDelete();
+ if(must) {
+ jptType = jpaDiagramEditor.getEditPart(jptName);
+ assertNotNull("Entity is deleted!", jptType);
+ }
- jptType = jpaDiagramEditor.getEditPart(jptName);
- assertNotNull("Entity is deleted!", jptType);
+ deletePersistentObject(jptType, jptName);
+ }
+ private void deletePersistentObject(SWTBotGefEditPart jptType,
+ String jptName) {
pressEntityContextButton(
jptType,
JPAEditorMessages.JPAEditorToolBehaviorProvider_deleteEntityFromModelButtonLabel);
@@ -1529,6 +1712,13 @@ public class EditorProxy {
}
public void deleteJPTViaMenu(SWTBotGefEditPart jptType) {
+
+ try {
+ JPACreateFactory.waitNonSystemJobs(60000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
String jptName = getJPTObjectForGefElement(jptType).getSimpleName();
@@ -1547,20 +1737,11 @@ public class EditorProxy {
assertNull("Entity is not deleted!", jptType);
}
- public void removeAttributeViaButton(SWTBotGefEditPart jptType,
- String attributeName) {
-
- assertFalse(
- "\"Other Attributes\" section must not be visible!",
-
- isSectionVisible(
- JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
- jptType));
-
- SWTBotGefEditPart attribute = addAttributeToJPT(jptType, attributeName);
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
- jpaDiagramEditor.save();
+ public void removeAttributeViaButton(SWTBotGefEditPart jptType, SWTBotGefEditPart attribute,
+ String attributeName, boolean isOrmXml) {
+ attribute.click();
+
pressAttributeDeleteContextButton(attribute);
denyDelete();
attribute = jpaDiagramEditor.getEditPart(attributeName);
@@ -1582,18 +1763,8 @@ public class EditorProxy {
}
- public void removeAttributeViaMenu(SWTBotGefEditPart jptType,
+ public void removeAttributeViaMenu(SWTBotGefEditPart jptType, SWTBotGefEditPart attribute,
String attributeName) {
- assertFalse(
- "\"Other Attributes\" section must not be visible!",
- isSectionVisible(
- JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
- jptType));
-
- SWTBotGefEditPart attribute = addAttributeToJPT(jptType, attributeName);
- assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
- jpaDiagramEditor.save();
-
attribute.click();
jpaDiagramEditor.clickContextMenu("Delete");
denyDelete();
@@ -1624,7 +1795,7 @@ public class EditorProxy {
JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
jptType));
- SWTBotGefEditPart attribute = addAttributeToJPT(jptType, attributeName);
+ SWTBotGefEditPart attribute = addAttributeToJPT(jptType, attributeName, false);
assertNotNull("The attribute must not be renamed!", attribute);
jpaDiagramEditor.directEditType("newAttrName");
@@ -1739,7 +1910,7 @@ public class EditorProxy {
jptType));
assertFalse(isJPTDirty(jptType));
- addAttributeToJPT(jptType, attributeName);
+ addAttributeToJPT(jptType, attributeName, false);
assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
assertTrue(isJPTDirty(jptType));
@@ -1755,8 +1926,6 @@ public class EditorProxy {
public void removeAndDiscardChangesViaMenu(SWTBotGefEditPart jptType,
String attributeName) {
- String jptName = getJPTObjectForGefElement(jptType).getSimpleName();
-
assertFalse("Diagram must contain at least one entity!",
jpaDiagramEditor.mainEditPart().children().isEmpty());
@@ -1767,7 +1936,7 @@ public class EditorProxy {
jptType));
assertFalse(isJPTDirty(jptType));
- addAttributeToJPT(jptType, attributeName);
+ addAttributeToJPT(jptType, attributeName, false);
assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
assertTrue(isJPTDirty(jptType));
@@ -1785,12 +1954,18 @@ public class EditorProxy {
assertFalse("Diagram must contain at least one entity!",
jpaDiagramEditor.mainEditPart().children().isEmpty());
+
+ assertEquals(1, jpaDiagramEditor.mainEditPart().children().size());
- jptType = jpaDiagramEditor.getEditPart(jptName);
+ jptType = jpaDiagramEditor.mainEditPart().children().get(0);
+ assertNotNull(jptType);
SWTBotGefEditPart attribute = jpaDiagramEditor
.getEditPart(attributeName);
assertNull("Changes must be discard!", attribute);
- assertFalse(isJPTDirty(jptType));
+
+// waitASecond();
+
+// assertFalse(isJPTDirty(jptType));
}
public void removeAndSaveChangesViaMenu(SWTBotGefEditPart jptType,
@@ -1801,14 +1976,14 @@ public class EditorProxy {
String jptName = getJPTObjectForGefElement(jptType).getSimpleName();
- assertFalse(
- "\"Other Attributes\" section must not be visible!",
- isSectionVisible(
- JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
- jptType));
+// assertFalse(
+// "\"Other Attributes\" section must not be visible!",
+// isSectionVisible(
+// JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
+// jptType));
assertFalse(isJPTDirty(jptType));
- addAttributeToJPT(jptType, attributeName);
+ addAttributeToJPT(jptType, attributeName, false);
assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
assertTrue(isJPTDirty(jptType));
@@ -1836,14 +2011,14 @@ public class EditorProxy {
public void saveOnlyJPT(SWTBotGefEditPart jptType, String attributeName) {
- assertFalse(
- "\"Other Attributes\" section must not be visible!",
- isSectionVisible(
- JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
- jptType));
+// assertFalse(
+// "\"Other Attributes\" section must not be visible!",
+// isSectionVisible(
+// JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
+// jptType));
assertFalse(isJPTDirty(jptType));
- addAttributeToJPT(jptType, attributeName);
+ addAttributeToJPT(jptType, attributeName, false);
assertTrue("Editor must be dirty", jpaDiagramEditor.isDirty());
assertTrue(isJPTDirty(jptType));
@@ -1856,7 +2031,7 @@ public class EditorProxy {
public void testUniDirRelation(String relationFeatureName,
SWTBotGefEditPart owner, SWTBotGefEditPart inverse,
- RelType reltype, String linkLabel, boolean canBeDerivedIdFeature) {
+ RelType reltype, String mappingKey, boolean canBeDerivedIdFeature, boolean isOrmXml) {
int sourceConSize = owner.sourceConnections().size();
@@ -1870,6 +2045,8 @@ public class EditorProxy {
jpaDiagramEditor.click(inverse);
bot.waitUntil(new ConnectionIsShown(owner, sourceConSize), 10000);
+ jpaDiagramEditor.save();
+
waitASecond();
jpaDiagramEditor.activateDefaultTool();
@@ -1882,27 +2059,26 @@ public class EditorProxy {
assertEquals(IRelation.RelDir.UNI, rel.getRelDir());
assertEquals(reltype, rel.getRelType());
- String attributeName = testOwnerRelationAttributeProperties(rel);
+ String attributeName = testOwnerRelationAttributeProperties(rel, mappingKey, isOrmXml);
assertNull(rel.getInverseAnnotatedAttribute());
- assertAttributeIsCorretlyMapped(attributeName, linkLabel);
-
assertUniDirRelationIsNotDeleted(owner, inverse, connection,
attributeName, false);
- assertUniDirRelationIsDeleted(owner, inverse, connection, attributeName);
- }
-
+ assertUniDirRelationIsDeleted(owner, inverse, connection, attributeName, isOrmXml);
+ }
public void testUniDirDerivedIdWithIdAnnotation(String relationFeatureName,
SWTBotGefEditPart owner, SWTBotGefEditPart inverse,
- RelType reltype, String relationAnnotation, String derivedIdAnnotation, String linkLabel){
+ RelType reltype, String relationAnnotation, String derivedIdAnnotation, String mappingKey, boolean isOrmXml){
jpaDiagramEditor
.activateTool(relationFeatureName, 0);
jpaDiagramEditor.click(owner);
jpaDiagramEditor.click(inverse);
bot.waitUntil(new ConnectionIsShown(owner));
+
+ jpaDiagramEditor.save();
waitASecond();
jpaDiagramEditor.activateDefaultTool();
@@ -1916,36 +2092,50 @@ public class EditorProxy {
assertEquals(IRelation.RelDir.UNI, rel.getRelDir());
assertEquals(reltype, rel.getRelType());
- String ownerAttributeName = testOwnerRelationAttributeProperties(rel);
-
- assertAttributeIsCorretlyMapped(ownerAttributeName, linkLabel);
+ String ownerAttributeName = testOwnerRelationAttributeProperties(rel, mappingKey, isOrmXml);
SWTBotView jpaDetailsView = workbenchBot.viewByTitle("JPA Details");
- jpaDetailsView.setFocus();
+ jpaDetailsView.show();
assertTrue("JPA Details view must be opened!",
jpaDetailsView.isActive());
SWTBotGefEditPart attribute = jpaDiagramEditor
.getEditPart(ownerAttributeName);
- attribute.select();
+// attribute.select();
attribute.click();
PersistentAttribute jpa = getJPAObjectForGefElement(attribute);
- HashSet<String> annotations = getAnnotationNames(jpa);
- assertTrue(annotations.contains(relationAnnotation));
- assertTrue(annotations.contains(derivedIdAnnotation));
+// HashSet<String> annotations = getAnnotationNames(jpa);
+// assertTrue(annotations.contains(relationAnnotation));
+// assertTrue(annotations.contains(derivedIdAnnotation));
+
+ AttributeMapping attributeMapping = jpaFactory.getAttributeMapping(jpa);
+
+ if(relationAnnotation.equals("OneToOne")){
+ assertTrue(attributeMapping instanceof OneToOneMapping2_0);
+ } else {
+ assertTrue(attributeMapping instanceof ManyToOneMapping2_0);
+ }
+
+ assertTrue(attributeMapping instanceof SingleRelationshipMapping2_0);
+ DerivedIdentity2_0 identity = ((SingleRelationshipMapping2_0)attributeMapping).getDerivedIdentity();
+ if(derivedIdAnnotation.equals("Id")) {
+ assertTrue(identity.usesIdDerivedIdentityStrategy());
+ } else {
+ assertTrue(identity.usesMapsIdDerivedIdentityStrategy());
+ }
assertUniDirRelationIsNotDeleted(owner, inverse, connection, ownerAttributeName, true);
- assertUniDirRelationIsDeleted(owner, inverse, connection, ownerAttributeName);
+ assertUniDirRelationIsDeleted(owner, inverse, connection, ownerAttributeName, isOrmXml);
}
public void testUniDirDerivedIdWithEmbeddedPk(String relationFeatureName,
SWTBotGefEditPart owner, SWTBotGefEditPart inverse, SWTBotGefEditPart embeddable,
- RelType reltype, String relationAnnotation, String derivedIdAnnotation, String linkLabel,
- boolean isBiDir, boolean isSamePK, String idClassFQN){
+ RelType reltype, String relationAnnotation, String derivedIdAnnotation, String mappingKey,
+ boolean isBiDir, boolean isSamePK, String idClassFQN, boolean isOrmXml){
int sourceConnSize = owner.sourceConnections().size();
@@ -1956,9 +2146,19 @@ public class EditorProxy {
}
jpaDiagramEditor.click(owner);
+ jpaDiagramEditor.select(inverse);
jpaDiagramEditor.click(inverse);
- bot.waitUntil(new ConnectionIsShown(owner, sourceConnSize), 20000);
+ try {
+ bot.waitUntil(new ConnectionIsShown(owner, sourceConnSize), 20000);
+ } catch (TimeoutException e) {
+ jpaDiagramEditor.click(owner);
+ jpaDiagramEditor.click(50, 50);
+
+ bot.waitUntil(new ConnectionIsShown(owner, sourceConnSize), 20000);
+ }
+
+ jpaDiagramEditor.save();
waitASecond();
jpaDiagramEditor.activateDefaultTool();
@@ -1976,36 +2176,45 @@ public class EditorProxy {
}
assertEquals(reltype, rel.getRelType());
- String ownerAttributeName = testOwnerRelationAttributeProperties(rel);
+ String ownerAttributeName = testOwnerRelationAttributeProperties(rel, mappingKey, isOrmXml);
String inverseAttributeName = null;
if(isBiDir){
- inverseAttributeName = testInverseRelationAttributeProperties(rel);
+ inverseAttributeName = testInverseRelationAttributeProperties(rel, getInverseMappingKey(mappingKey), isOrmXml);
}
- assertAttributeIsCorretlyMapped(ownerAttributeName, linkLabel);
-
SWTBotGefEditPart attribute = jpaDiagramEditor
.getEditPart(ownerAttributeName);
attribute.select();
attribute.click();
PersistentAttribute jpa = getJPAObjectForGefElement(attribute);
+ AttributeMapping attributeMapping = jpaFactory.getAttributeMapping(jpa);
- HashSet<String> annotations = getAnnotationNames(jpa);
- assertTrue(annotations.contains(relationAnnotation));
- assertTrue(annotations.contains("MapsId"));
+ if(relationAnnotation.equals("OneToOne")){
+ assertTrue(attributeMapping instanceof OneToOneMapping2_0);
+ } else {
+ assertTrue(attributeMapping instanceof ManyToOneMapping2_0);
+ }
+
+ assertTrue(attributeMapping instanceof SingleRelationshipMapping2_0);
+ DerivedIdentity2_0 identity = ((SingleRelationshipMapping2_0)attributeMapping).getDerivedIdentity();
+ if(derivedIdAnnotation.equals("Id")) {
+ assertTrue(identity.usesIdDerivedIdentityStrategy());
+ } else {
+ assertTrue(identity.usesMapsIdDerivedIdentityStrategy());
+ }
String helperAttributeName = null;
if(!isSamePK) {
- helperAttributeName = assertContainsHelperAttrInEmbeddable(inverse, embeddable, jpa, idClassFQN);
+ helperAttributeName = assertContainsHelperAttrInEmbeddable(inverse, embeddable, jpa, idClassFQN, isOrmXml);
}
if(isBiDir){
assertBiDirRelationIsNotDeleted(owner, inverse, connection, ownerAttributeName, inverseAttributeName, true);
- assertBiDirRelationIsDeleted(owner, inverse, connection, ownerAttributeName, inverseAttributeName);
+ assertBiDirRelationIsDeleted(owner, inverse, connection, ownerAttributeName, inverseAttributeName, isOrmXml);
} else {
assertUniDirRelationIsNotDeleted(owner, inverse, connection, ownerAttributeName, true);
- assertUniDirRelationIsDeleted(owner, inverse, connection, ownerAttributeName);
+ assertUniDirRelationIsDeleted(owner, inverse, connection, ownerAttributeName, isOrmXml);
}
if(!isSamePK)
@@ -2013,9 +2222,9 @@ public class EditorProxy {
}
public void testUniDirDerivedIdWithIdClassPk(String relationFeatureName,
- SWTBotGefEditPart owner, SWTBotGefEditPart inverse, IFile idClass,
- RelType reltype, String relationAnnotation, String derivedIdAnnotation, String linkLabel,
- boolean isBiDir, boolean isSamePK, String idClassFQN) throws JavaModelException{
+ SWTBotGefEditPart owner, SWTBotGefEditPart inverse, JavaPersistentType idClass,
+ RelType reltype, String relationAnnotation, String derivedIdAnnotation, String mappingKey,
+ boolean isBiDir, boolean isSamePK, String idClassFQN, boolean isOrmXml) throws JavaModelException{
if(isBiDir){
jpaDiagramEditor.activateTool(relationFeatureName, 1);
} else {
@@ -2025,6 +2234,8 @@ public class EditorProxy {
jpaDiagramEditor.click(inverse);
bot.waitUntil(new ConnectionIsShown(owner), 10000);
+
+ jpaDiagramEditor.save();
waitASecond();
jpaDiagramEditor.activateDefaultTool();
@@ -2042,14 +2253,12 @@ public class EditorProxy {
}
assertEquals(reltype, rel.getRelType());
- String ownerAttributeName = testOwnerRelationAttributeProperties(rel);
+ String ownerAttributeName = testOwnerRelationAttributeProperties(rel, mappingKey, isOrmXml);
String inverseAttributeName = null;
if(isBiDir){
- inverseAttributeName = testInverseRelationAttributeProperties(rel);
+ inverseAttributeName = testInverseRelationAttributeProperties(rel, getInverseMappingKey(mappingKey), isOrmXml);
}
- assertAttributeIsCorretlyMapped(ownerAttributeName, linkLabel);
-
SWTBotGefEditPart attribute = jpaDiagramEditor
.getEditPart(ownerAttributeName);
attribute.select();
@@ -2057,9 +2266,17 @@ public class EditorProxy {
PersistentAttribute jpa = getJPAObjectForGefElement(attribute);
- HashSet<String> annotations = getAnnotationNames(jpa);
- assertTrue(annotations.contains(relationAnnotation));
- assertTrue(annotations.contains("Id"));
+ AttributeMapping attributeMapping = jpaFactory.getAttributeMapping(jpa);
+
+ if(relationAnnotation.equals("OneToOne")){
+ assertTrue(attributeMapping instanceof OneToOneMapping2_0);
+ } else {
+ assertTrue(attributeMapping instanceof ManyToOneMapping2_0);
+ }
+
+ assertTrue(attributeMapping instanceof SingleRelationshipMapping2_0);
+ DerivedIdentity2_0 identity = ((SingleRelationshipMapping2_0)attributeMapping).getDerivedIdentity();
+ assertTrue(identity.usesIdDerivedIdentityStrategy());
String helperAttributeName = null;
if(!isSamePK) {
@@ -2068,44 +2285,39 @@ public class EditorProxy {
if(isBiDir){
assertBiDirRelationIsNotDeleted(owner, inverse, connection, ownerAttributeName, inverseAttributeName, true);
- assertBiDirRelationIsDeleted(owner, inverse, connection, ownerAttributeName, inverseAttributeName);
+ assertBiDirRelationIsDeleted(owner, inverse, connection, ownerAttributeName, inverseAttributeName, isOrmXml);
} else {
assertUniDirRelationIsNotDeleted(owner, inverse, connection, ownerAttributeName, true);
- assertUniDirRelationIsDeleted(owner, inverse, connection, ownerAttributeName);
+ assertUniDirRelationIsDeleted(owner, inverse, connection, ownerAttributeName, isOrmXml);
}
if(!isSamePK) {
- IType idClassType = JavaCore.createCompilationUnitFrom(idClass).findPrimaryType();
- assertFalse(idClassType.getField(helperAttributeName).exists());
+// IType idClassType = JavaCore.createCompilationUnitFrom(idClass).findPrimaryType();
+ assertNull(idClass.getAttributeNamed(helperAttributeName));
}
}
private String assertContainsHelperAttrInEmbeddable(
SWTBotGefEditPart inverse, SWTBotGefEditPart embeddable,
- PersistentAttribute jpa, String IdClassFQN) {
+ PersistentAttribute jpa, String IdClassFQN, boolean isOrmXml) {
String helperAttributeName = JPAEditorUtil.decapitalizeFirstLetter(getJPTObjectForGefElement(inverse).getSimpleName());
-// SWTBotGefEditPart helperAttr = getAttributeInPE(embeddable, helperAttributeName);
PersistentType pt = getJPTObjectForGefElement(embeddable);
+ pt.getJavaResourceType().getJavaResourceCompilationUnit().synchronizeWithJavaSource();
+ pt.synchronizeWithResourceModel();
+ pt.update();
PersistentAttribute helperAttr = pt.getAttributeNamed(helperAttributeName);
- assertNotNull(pt.getAttributeNamed(helperAttributeName));
+ assertNotNull(helperAttr);
-// embeddable.part().refresh();
-//
-// helperAttr = getAttributeInPE(embeddable, helperAttributeName);
-// assertNotNull(helperAttr);
+ if(isOrmXml) {
+ assertNotNull(jpaFactory.getORMPersistentAttribute(helperAttr));
+ }
AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(jpa);
assertTrue(SingleRelationshipMapping2_0.class.isInstance(attributeMapping));
DerivedIdentity2_0 identity = ((SingleRelationshipMapping2_0)attributeMapping).getDerivedIdentity();
assertTrue(identity.usesMapsIdDerivedIdentityStrategy());
assertEquals(helperAttributeName, identity.getMapsIdDerivedIdentityStrategy().getSpecifiedIdAttributeName());
-
-// Annotation an = jpa.getResourceAttribute().getAnnotation(MapsId2_0Annotation.ANNOTATION_NAME);
-// assertNotNull(an);
-// assertTrue(an instanceof MapsId2_0Annotation);
-// String mapsIdValue = ((MapsId2_0Annotation)an).getValue();
-// assertEquals(mapsIdValue, helperAttributeName);
String helperAttrType = JPAEditorUtil.getAttributeTypeNameWithGenerics(helperAttr);
@@ -2120,30 +2332,23 @@ public class EditorProxy {
private String assertContainsHelperAttrInIdClass(
- SWTBotGefEditPart inverse, IFile idClass,
+ SWTBotGefEditPart inverse, JavaPersistentType idClass,
PersistentAttribute jpa, String IdClassFQN) throws JavaModelException {
- IType idClassType = JavaCore.createCompilationUnitFrom(idClass).findPrimaryType();
- assertNotNull(idClassType);
-
-// Annotation an = jpa.getResourceAttribute().getAnnotation(IdAnnotation.ANNOTATION_NAME);
-// assertNotNull(an);
-
+// IType idClassType = JavaCore.createCompilationUnitFrom(idClass).findPrimaryType();
+// assertNotNull(idClassType);
+// idClassType.getCompilationUnit().save(new NullProgressMonitor(), true);
AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(jpa);
assertTrue(SingleRelationshipMapping2_0.class.isInstance(attributeMapping));
DerivedIdentity2_0 identity = ((SingleRelationshipMapping2_0)attributeMapping).getDerivedIdentity();
assertTrue(identity.usesIdDerivedIdentityStrategy());
-// assertEquals(helperAttributeName, identity.getIdDerivedIdentityStrategy()..getSpecifiedIdAttributeName());
-
-// AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(jpa);
-// assertTrue(IdMapping.class.isInstance(attributeMapping));
-
- IField helperAttr = idClassType.getField(jpa.getName());
+
+ JavaSpecifiedPersistentAttribute helperAttr = idClass.getAttributeNamed(jpa.getName());
assertNotNull(helperAttr);
-
-
- String helperAttrType = helperAttr.getSource().split(" ")[1];
+
+// helperAttr.getClassFile().isOpen().getTypeSignature();
+ String helperAttrType = helperAttr.getTypeName();
if(IdClassFQN != null){
assertEquals(helperAttrType, IdClassFQN);
@@ -2151,7 +2356,7 @@ public class EditorProxy {
String primaryKeyType = JPAEditorUtil.getAttributeTypeNameWithGenerics(getJPAObjectForGefElement(getAttributeInPE(inverse, "id")));
assertEquals(helperAttrType, primaryKeyType);
}
- return helperAttr.getElementName();
+ return helperAttr.getName();
}
public SWTBotGefEditPart getAttributeInPE(
@@ -2165,13 +2370,15 @@ public class EditorProxy {
public void testBiDirDerivedIdWithIdAnnotation(String relationFeatureName,
SWTBotGefEditPart owner, SWTBotGefEditPart inverse,
- RelType reltype, String relationAnnotation, String derivedIdAnnotation, String linkLabel){
+ RelType reltype, String relationAnnotation, String derivedIdAnnotation, String mappingKey, boolean isOrmXml){
jpaDiagramEditor
.activateTool(relationFeatureName, 1);
jpaDiagramEditor.click(owner);
jpaDiagramEditor.click(inverse);
bot.waitUntil(new ConnectionIsShown(owner));
+
+ jpaDiagramEditor.save();
waitASecond();
jpaDiagramEditor.activateDefaultTool();
@@ -2185,13 +2392,11 @@ public class EditorProxy {
assertEquals(IRelation.RelDir.BI, rel.getRelDir());
assertEquals(reltype, rel.getRelType());
- String ownerAttributeName = testOwnerRelationAttributeProperties(rel);
- String inverseAttributeName = testInverseRelationAttributeProperties(rel);
-
- assertAttributeIsCorretlyMapped(ownerAttributeName, linkLabel);
+ String ownerAttributeName = testOwnerRelationAttributeProperties(rel, mappingKey, isOrmXml);
+ String inverseAttributeName = testInverseRelationAttributeProperties(rel, getInverseMappingKey(mappingKey), isOrmXml);
SWTBotView jpaDetailsView = workbenchBot.viewByTitle("JPA Details");
- jpaDetailsView.setFocus();
+ jpaDetailsView.show();
assertTrue("JPA Details view must be opened!",
jpaDetailsView.isActive());
@@ -2201,25 +2406,52 @@ public class EditorProxy {
attribute.click();
PersistentAttribute jpa = getJPAObjectForGefElement(attribute);
+
+ AttributeMapping attributeMapping = jpaFactory.getAttributeMapping(jpa);
- HashSet<String> annotations = getAnnotationNames(jpa);
- assertTrue(annotations.contains(relationAnnotation));
- assertTrue(annotations.contains(derivedIdAnnotation));
+ if(relationAnnotation.equals("OneToOne")){
+ assertTrue(attributeMapping instanceof OneToOneMapping2_0);
+ } else {
+ assertTrue(attributeMapping instanceof ManyToOneMapping2_0);
+ }
+
+ assertTrue(attributeMapping instanceof SingleRelationshipMapping2_0);
+ DerivedIdentity2_0 identity = ((SingleRelationshipMapping2_0)attributeMapping).getDerivedIdentity();
+ if(derivedIdAnnotation.equals("Id")) {
+ assertTrue(identity.usesIdDerivedIdentityStrategy());
+ } else {
+ assertTrue(identity.usesMapsIdDerivedIdentityStrategy());
+ }
assertBiDirRelationIsNotDeleted(owner, inverse, connection, ownerAttributeName, inverseAttributeName, true);
- assertBiDirRelationIsDeleted(owner, inverse, connection, ownerAttributeName, inverseAttributeName);
+ assertBiDirRelationIsDeleted(owner, inverse, connection, ownerAttributeName, inverseAttributeName, isOrmXml);
+ }
+
+ private String getInverseMappingKey(String mappingKey){
+ String inverseMappingKey = null;
+ if(mappingKey.equals(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY)){
+ inverseMappingKey = MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY;
+ } else if (mappingKey.equals(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY)){
+ inverseMappingKey = MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY;
+ } else {
+ inverseMappingKey = mappingKey;
+ }
+
+ return inverseMappingKey;
}
public void testUniDirDerivedIdWithMapsIdAnnotation(String relationFeatureName,
SWTBotGefEditPart owner, SWTBotGefEditPart inverse,
- RelType reltype, String linkLabel){
+ RelType reltype, String mappingKey, boolean isOrmXml){
jpaDiagramEditor
.activateTool(relationFeatureName, 0);
jpaDiagramEditor.click(owner);
jpaDiagramEditor.click(inverse);
bot.waitUntil(new ConnectionIsShown(owner));
+
+ jpaDiagramEditor.save();
waitASecond();
jpaDiagramEditor.activateDefaultTool();
@@ -2233,12 +2465,10 @@ public class EditorProxy {
assertEquals(IRelation.RelDir.UNI, rel.getRelDir());
assertEquals(reltype, rel.getRelType());
- String ownerAttributeName = testOwnerRelationAttributeProperties(rel);
-
- assertAttributeIsCorretlyMapped(ownerAttributeName, linkLabel);
+ String ownerAttributeName = testOwnerRelationAttributeProperties(rel, mappingKey, isOrmXml);
SWTBotView jpaDetailsView = workbenchBot.viewByTitle("JPA Details");
- jpaDetailsView.setFocus();
+ jpaDetailsView.show();
assertTrue("JPA Details view must be opened!",
jpaDetailsView.isActive());
@@ -2249,13 +2479,19 @@ public class EditorProxy {
PersistentAttribute jpa = getJPAObjectForGefElement(attribute);
- HashSet<String> annotations = getAnnotationNames(jpa);
- assertTrue(annotations.contains("OneToOne"));
- assertTrue(annotations.contains("MapsId"));
+ AttributeMapping attributeMapping = jpaFactory.getAttributeMapping(jpa);
+ assertTrue(attributeMapping instanceof OneToOneMapping2_0);
+
+ DerivedIdentity2_0 identity = ((OneToOneMapping2_0)attributeMapping).getDerivedIdentity();
+ assertTrue(identity.usesMapsIdDerivedIdentityStrategy());
+//
+// HashSet<String> annotations = getAnnotationNames(jpa);
+// assertTrue(annotations.contains("OneToOne"));
+// assertTrue(annotations.contains("MapsId"));
}
public void testSelfUniDirRelation(String relationFeatureName,
- SWTBotGefEditPart entity, RelType reltype, String linkLabel, boolean canBeDerivedIdFeature) {
+ SWTBotGefEditPart entity, RelType reltype, String mappingKey, boolean canBeDerivedIdFeature, boolean isOrmXml) {
if(canBeDerivedIdFeature) {
jpaDiagramEditor.activateTool(relationFeatureName, 2);
@@ -2265,6 +2501,8 @@ public class EditorProxy {
jpaDiagramEditor.click(entity);
jpaDiagramEditor.click(entity);
bot.waitUntil(new ConnectionIsShown(entity));
+
+ jpaDiagramEditor.save();
waitASecond();
jpaDiagramEditor.activateDefaultTool();
@@ -2277,20 +2515,18 @@ public class EditorProxy {
assertNotNull(rel);
assertEquals(IRelation.RelDir.UNI, rel.getRelDir());
assertEquals(reltype, rel.getRelType());
-
- String attributeName = testOwnerRelationAttributeProperties(rel);
+
+ String attributeName = testOwnerRelationAttributeProperties(rel, mappingKey, isOrmXml);
assertNull(rel.getInverseAnnotatedAttribute());
- assertAttributeIsCorretlyMapped(attributeName, linkLabel);
-
assertSelfUniDirRelationIsNotDeleted(entity, connection, attributeName);
- assertSelfUniDirRelationIsDeleted(entity, connection, attributeName);
+ assertSelfUniDirRelationIsDeleted(entity, connection, attributeName, isOrmXml);
}
public void testUniDirRelRemoveOwnerAttribute(String relationFeatureName,
SWTBotGefEditPart owner, SWTBotGefEditPart inverse,
- RelType reltype, String linkLabel, boolean canBeDerivedIdFeature) {
+ RelType reltype, String mappingKey, boolean canBeDerivedIdFeature, boolean isOrmXml) {
if(canBeDerivedIdFeature) {
jpaDiagramEditor.activateTool(relationFeatureName, 2);
@@ -2300,6 +2536,8 @@ public class EditorProxy {
jpaDiagramEditor.click(owner);
jpaDiagramEditor.click(inverse);
bot.waitUntil(new ConnectionIsShown(owner));
+
+ jpaDiagramEditor.save();
waitASecond();
jpaDiagramEditor.activateDefaultTool();
@@ -2313,14 +2551,13 @@ public class EditorProxy {
assertEquals(IRelation.RelDir.UNI, rel.getRelDir());
assertEquals(reltype, rel.getRelType());
- String attributeName = testOwnerRelationAttributeProperties(rel);
+ String attributeName = testOwnerRelationAttributeProperties(rel, mappingKey, isOrmXml);
assertNull(rel.getInverseAnnotatedAttribute());
- assertAttributeIsCorretlyMapped(attributeName, linkLabel);
-
// delete the owner attribute
SWTBotGefEditPart ownerAttrPart = jpaDiagramEditor
.getEditPart(attributeName);
+ PersistentAttribute jpa = getJPAObjectForGefElement(ownerAttrPart);
ownerAttrPart.select();
jpaDiagramEditor.clickContextMenu("Delete");
confirmDelete();
@@ -2330,28 +2567,31 @@ public class EditorProxy {
assertTrue(owner.sourceConnections().isEmpty());
assertTrue(inverse.targetConnections().isEmpty());
assertNull(jpaDiagramEditor.getEditPart(attributeName));
+ if(isOrmXml){
+ assertOrmAttrIsDeleted(jpa);
+ }
assertFalse(isSectionVisible(owner,
JPAEditorMessages.AddJPAEntityFeature_relationAttributesShapes));
}
public void testBiDirRel(String relationFeatureName,
SWTBotGefEditPart owner, SWTBotGefEditPart inverse,
- RelType reltype, String linkLabel, boolean canBeDerivedIdFeature) {
+ RelType reltype, String mappingKey, boolean canBeDerivedIdFeature, boolean isOrmXml) {
testBiDirRelWithTwoMappingTypes(relationFeatureName, owner, inverse,
- reltype, linkLabel, linkLabel, canBeDerivedIdFeature);
+ reltype, mappingKey, mappingKey, canBeDerivedIdFeature, isOrmXml);
}
public void testSelfBiDirRel(String relationFeatureName,
- SWTBotGefEditPart owner, RelType reltype, String linkLabel, boolean canBeDerivedIdFeature) {
+ SWTBotGefEditPart owner, RelType reltype, String mappingKey, boolean canBeDerivedIdFeature, boolean isOrmXml) {
testSelfBiDirRelWithTwoMappings(relationFeatureName, owner, reltype,
- linkLabel, linkLabel, canBeDerivedIdFeature);
+ mappingKey, mappingKey, canBeDerivedIdFeature, isOrmXml);
}
public void testBiDirRelWithTwoMappingTypes(String relationFeatureName,
SWTBotGefEditPart owner, SWTBotGefEditPart inverse,
- RelType reltype, String ownerLinkLabel, String inverseLinkLabel, boolean canBeDerivedIdFeature) {
+ RelType reltype, String ownerMappingKey, String inverseMappingKey, boolean isSimpleRelKind, boolean isOrmXml) {
- if(canBeDerivedIdFeature) {
+ if(isSimpleRelKind) {
jpaDiagramEditor.activateTool(relationFeatureName, 3);
} else {
jpaDiagramEditor.activateTool(relationFeatureName, 1);
@@ -2359,6 +2599,8 @@ public class EditorProxy {
jpaDiagramEditor.click(owner);
jpaDiagramEditor.click(inverse);
bot.waitUntil(new ConnectionIsShown(owner));
+
+ jpaDiagramEditor.save();
waitASecond();
jpaDiagramEditor.activateDefaultTool();
@@ -2372,23 +2614,20 @@ public class EditorProxy {
assertEquals(IRelation.RelDir.BI, rel.getRelDir());
assertEquals(reltype, rel.getRelType());
- String ownerAttributeName = testOwnerRelationAttributeProperties(rel);
-
- String inverseAttributeName = testInverseRelationAttributeProperties(rel);
+ String ownerAttributeName = testOwnerRelationAttributeProperties(rel, ownerMappingKey, isOrmXml);
- assertAttributeIsCorretlyMapped(ownerAttributeName, ownerLinkLabel);
- assertAttributeIsCorretlyMapped(inverseAttributeName, inverseLinkLabel);
+ String inverseAttributeName = testInverseRelationAttributeProperties(rel, inverseMappingKey, isOrmXml);
assertBiDirRelationIsNotDeleted(owner, inverse, connection,
ownerAttributeName, inverseAttributeName, false);
assertBiDirRelationIsDeleted(owner, inverse, connection,
- ownerAttributeName, inverseAttributeName);
+ ownerAttributeName, inverseAttributeName, isOrmXml);
}
public void testSelfBiDirRelWithTwoMappings(String relationFeatureName,
- SWTBotGefEditPart entity, RelType reltype, String ownerLinkLabel,
- String inverseLinkLabel, boolean canBeDerivedIdFeature) {
+ SWTBotGefEditPart entity, RelType reltype, String ownerMappingKey,
+ String inverseMappingKey, boolean canBeDerivedIdFeature, boolean isOrmXml) {
if(canBeDerivedIdFeature) {
jpaDiagramEditor.activateTool(relationFeatureName, 3);
@@ -2398,6 +2637,8 @@ public class EditorProxy {
jpaDiagramEditor.click(entity);
jpaDiagramEditor.click(entity);
bot.waitUntil(new ConnectionIsShown(entity));
+
+ jpaDiagramEditor.save();
waitASecond();
jpaDiagramEditor.activateDefaultTool();
@@ -2411,32 +2652,29 @@ public class EditorProxy {
assertEquals(IRelation.RelDir.BI, rel.getRelDir());
assertEquals(reltype, rel.getRelType());
- String ownerAttributeName = testOwnerRelationAttributeProperties(rel);
+ String ownerAttributeName = testOwnerRelationAttributeProperties(rel, ownerMappingKey, isOrmXml);
- String inverseAttributeName = testInverseRelationAttributeProperties(rel);
-
- assertAttributeIsCorretlyMapped(ownerAttributeName, ownerLinkLabel);
- assertAttributeIsCorretlyMapped(inverseAttributeName, inverseLinkLabel);
+ String inverseAttributeName = testInverseRelationAttributeProperties(rel, inverseMappingKey, isOrmXml);
assertSelfBiDirRelationIsNotDeleted(entity, connection,
ownerAttributeName, inverseAttributeName);
assertSelfBiDirRelationIsDeleted(entity, connection,
- ownerAttributeName, inverseAttributeName);
+ ownerAttributeName, inverseAttributeName, isOrmXml);
}
public void testBiDirRelRemoveInverseAttribute(String relationFeatureName,
SWTBotGefEditPart owner, SWTBotGefEditPart inverse,
- RelType reltype, String linkLabel, boolean canBeDerivedIdFeature) {
+ RelType reltype, String linkLabel, boolean canBeDerivedIdFeature, boolean isOrmXml) {
testBiDirRelWithTwoMappingsWithoutInverseAttr(relationFeatureName,
- owner, inverse, reltype, linkLabel, linkLabel, canBeDerivedIdFeature);
+ owner, inverse, reltype, linkLabel, linkLabel, canBeDerivedIdFeature, isOrmXml);
}
public void testBiDirRelWithTwoMappingsWithoutInverseAttr(
String relationFeatureName, SWTBotGefEditPart owner,
- SWTBotGefEditPart inverse, RelType reltype, String ownerLinkLabel,
- String inverseLinkLabel, boolean canBeDerivedIdFeature) {
+ SWTBotGefEditPart inverse, RelType reltype, String ownerMappingKey,
+ String inverseMappingKey, boolean canBeDerivedIdFeature, boolean isOrmXml) {
if(canBeDerivedIdFeature) {
jpaDiagramEditor.activateTool(relationFeatureName, 3);
@@ -2446,6 +2684,8 @@ public class EditorProxy {
jpaDiagramEditor.click(owner);
jpaDiagramEditor.click(inverse);
bot.waitUntil(new ConnectionIsShown(owner));
+
+ jpaDiagramEditor.save();
waitASecond();
jpaDiagramEditor.activateDefaultTool();
@@ -2459,12 +2699,9 @@ public class EditorProxy {
assertEquals(IRelation.RelDir.BI, rel.getRelDir());
assertEquals(reltype, rel.getRelType());
- String ownerAttributeName = testOwnerRelationAttributeProperties(rel);
-
- String inverseAttributeName = testInverseRelationAttributeProperties(rel);
+ String ownerAttributeName = testOwnerRelationAttributeProperties(rel, ownerMappingKey, isOrmXml);
- assertAttributeIsCorretlyMapped(ownerAttributeName, ownerLinkLabel);
- assertAttributeIsCorretlyMapped(inverseAttributeName, inverseLinkLabel);
+ String inverseAttributeName = testInverseRelationAttributeProperties(rel, inverseMappingKey, isOrmXml);
// delete the inverse attribute
SWTBotGefEditPart inverseAttr = jpaDiagramEditor
@@ -2483,9 +2720,8 @@ public class EditorProxy {
assertEquals(IRelation.RelDir.UNI, rel.getRelDir());
assertEquals(reltype, rel.getRelType());
assertEquals(ownerAttributeName,
- testOwnerRelationAttributeProperties(rel));
+ testOwnerRelationAttributeProperties(rel, ownerMappingKey, isOrmXml));
assertNull(rel.getInverseAnnotatedAttribute());
- assertAttributeIsCorretlyMapped(ownerAttributeName, ownerLinkLabel);
// delete the owner attribute
SWTBotGefEditPart ownerAttr = jpaDiagramEditor
@@ -2508,15 +2744,15 @@ public class EditorProxy {
public void testBiDirRelRemoveOwnerAttr(String relationFeatureName,
SWTBotGefEditPart owner, SWTBotGefEditPart inverse,
- RelType reltype, String linkLabel, boolean canBeDerivedIdFeature) {
+ RelType reltype, String linkLabel, boolean canBeDerivedIdFeature, boolean isOrmXml) {
testBiDirRelWithTwoMappingsWithoutOwnerAttr(relationFeatureName, owner,
- inverse, reltype, linkLabel, linkLabel, canBeDerivedIdFeature);
+ inverse, reltype, linkLabel, linkLabel, canBeDerivedIdFeature, isOrmXml);
}
public void testBiDirRelWithTwoMappingsWithoutOwnerAttr(
String relationFeatureName, SWTBotGefEditPart owner,
- SWTBotGefEditPart inverse, RelType reltype, String ownerLinkLabel,
- String inverseLinkLabel, boolean canBeDerivedIdFeature) {
+ SWTBotGefEditPart inverse, RelType reltype, String ownerMappingKey,
+ String inverseMappingKey, boolean canBeDerivedIdFeature, boolean isOrmXml) {
if(canBeDerivedIdFeature) {
jpaDiagramEditor.activateTool(relationFeatureName, 3);
@@ -2526,6 +2762,8 @@ public class EditorProxy {
jpaDiagramEditor.click(owner);
jpaDiagramEditor.click(inverse);
bot.waitUntil(new ConnectionIsShown(owner));
+
+ jpaDiagramEditor.save();
waitASecond();
jpaDiagramEditor.activateDefaultTool();
@@ -2539,12 +2777,9 @@ public class EditorProxy {
assertEquals(IRelation.RelDir.BI, rel.getRelDir());
assertEquals(reltype, rel.getRelType());
- String ownerAttributeName = testOwnerRelationAttributeProperties(rel);
-
- String inverseAttributeName = testInverseRelationAttributeProperties(rel);
+ String ownerAttributeName = testOwnerRelationAttributeProperties(rel, ownerMappingKey, isOrmXml);
- assertAttributeIsCorretlyMapped(ownerAttributeName, ownerLinkLabel);
- assertAttributeIsCorretlyMapped(inverseAttributeName, inverseLinkLabel);
+ String inverseAttributeName = testInverseRelationAttributeProperties(rel, inverseMappingKey, isOrmXml);
// delete the owner attribute
SWTBotGefEditPart ownerAttrPart = jpaDiagramEditor
@@ -2591,12 +2826,12 @@ public class EditorProxy {
}
public void testCreateAndDeleteIsARelation(SWTBotGefEditPart superclass,
- String subclassName, String superclassMappingLinkLabel,
+ String subclassName, String superclassMappingKey,
boolean byMappedSuperclass, String superclassName,
SWTBotGefEditPart inheritedEntity, boolean existing) {
SWTBotGefConnectionEditPart connection = testIsARelationProperties(
- superclass, subclassName, superclassMappingLinkLabel,
+ superclass, subclassName, superclassMappingKey,
byMappedSuperclass, superclassName, inheritedEntity, existing);
connection.select();
@@ -2613,7 +2848,7 @@ public class EditorProxy {
public SWTBotGefConnectionEditPart testIsARelationProperties(
SWTBotGefEditPart superclass, String subclassName,
- String superclassMappingLinkLabel, boolean byMappedSuperclass,
+ String mappingKey, boolean byMappedSuperclass,
String superclassName, SWTBotGefEditPart inheritedEntity,
boolean existing) {
if (byMappedSuperclass) {
@@ -2637,29 +2872,27 @@ public class EditorProxy {
assertIsARelationExists(superclass, inheritedEntity);
- SWTBotGefConnectionEditPart connection = getConnection(inheritedEntity,
- superclass);
+ SWTBotGefConnectionEditPart connection = getConnection(inheritedEntity, superclass);
assertNotNull("Connection must be shown in the diagram.", connection);
- FreeFormConnection conn = (FreeFormConnection) connection.part()
- .getModel();
+ FreeFormConnection conn = (FreeFormConnection) connection.part().getModel();
assertTrue(IsARelation.isIsAConnection(conn));
IsARelation rel = getIsARelationship();
assertNotNull(rel);
- assertEquals(getJPTObjectForGefElement(inheritedEntity),
- rel.getSubclass());
- assertEquals(getJPTObjectForGefElement(superclass), rel.getSuperclass());
+ PersistentType subclassType = getJPTObjectForGefElement(inheritedEntity);
+ PersistentType superclassType = getJPTObjectForGefElement(superclass);
+ assertEquals(subclassType, rel.getSubclass());
+ assertEquals(superclassType, rel.getSuperclass());
- assertTypeIsCorretlyMapped(superclass, superclassMappingLinkLabel);
- assertTypeIsCorretlyMapped(inheritedEntity,
- JptJpaUiDetailsMessages.EntityUiProvider_linkLabel);
+
+ assertEquals(mappingKey, jpaFactory.getTypeMapping(superclassType).getKey());
+ assertEquals(MappingKeys.ENTITY_TYPE_MAPPING_KEY, jpaFactory.getTypeMapping(subclassType).getKey());
- PersistentType superJPT = getJPTObjectForGefElement(
- inheritedEntity).getSuperPersistentType();
+ PersistentType superJPT = subclassType.getSuperPersistentType();
assertNotNull("The entity must has a super persitent type.", superJPT);
assertEquals(
"The super persistent type must be the source of the connection.",
- superJPT, getJPTObjectForGefElement(superclass));
+ superJPT.getName(), superclassType.getName());
return connection;
}
@@ -2752,6 +2985,12 @@ public class EditorProxy {
embeddable, refType, embeddedMappingKey, linkLabel,
elementsInDiagramCount);
+// try {
+// JPACreateFactory.waitNonSystemJobs();
+// } catch (InterruptedException e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
deleteAttributeInJPT(embeddingEntity, attributeName);
waitASecond();
@@ -2832,6 +3071,8 @@ public class EditorProxy {
String linkLabel) {
bot.waitUntil(new ConnectionIsShown(embeddingEntity), 30000);
+
+ jpaDiagramEditor.save();
assertFalse("The connection must appear", embeddingEntity
.sourceConnections().isEmpty());
@@ -2859,8 +3100,6 @@ public class EditorProxy {
embeddedMappingKey);
assertNotNull(rel.getEmbeddedAnnotatedAttribute());
- assertAttributeIsCorretlyMapped(attributeName, linkLabel);
-
PersistentType parententity = rel.getEmbeddedAnnotatedAttribute().getDeclaringPersistentType();
assertEquals("The entity must contain an embedded attribute.",
parententity, getJPTObjectForGefElement(embeddingEntity));
@@ -2900,7 +3139,14 @@ public class EditorProxy {
public String getUniqueEntityName(JpaProject jpaProject) {
IJPAEditorFeatureProvider fp = (IJPAEditorFeatureProvider) ((DiagramEditPart) jpaDiagramEditor
.mainEditPart().part()).getFeatureProvider();
+
+ if(fp == null){
+ System.out.println("ibi goooo ");
+ jpaDiagramEditor.isActive();
+ }
+ assertNotNull(fp);
+ assertNotNull(fp.getJPAEditorUtil());
String entityName = fp.getJPAEditorUtil().generateUniqueTypeName(
jpaProject,
JPADiagramPropertyPage.getDefaultPackage(jpaProject
@@ -2921,8 +3167,8 @@ public class EditorProxy {
return JPAEditorUtil.returnSimpleName(embeddableName);
}
- public void deleteResources(JpaProject jpaProject) throws CoreException {
- deleteDiagramElements();
+ public void deleteResources(JpaProject jpaProject, boolean isOrmXml) throws CoreException {
+ deleteDiagramElements(isOrmXml);
Utils.printFormatted(">>>>>>>>>>>> elements are deleted from the diagram.");
ListIterator<PersistenceUnit> lit = jpaProject.getContextModelRoot()
@@ -2935,6 +3181,19 @@ public class EditorProxy {
PersistentType type = persistentTypesIterator.next();
type.getResource().delete(true, new NullProgressMonitor());
}
+
+ jpaProject.getResource().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ }
+
+ public void deleteResources(JpaProject jpaProject, String name){
+ Utils.printFormatted(">>>>>>>>>>>> elements are deleted from the diagram.");
+ try {
+ jpaProject.getProject().getFile(name).delete(true, new NullProgressMonitor());
+ jpaProject.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
/**
@@ -2944,7 +3203,7 @@ public class EditorProxy {
* @param embeddable
*/
public void addEmbeddedIdToEntity(SWTBotGefEditPart embeddingEntity,
- SWTBotGefEditPart embeddable) {
+ SWTBotGefEditPart embeddable, boolean isOrmXml) {
jpaDiagramEditor.activateDefaultTool();
embeddingEntity.select();
@@ -2961,7 +3220,18 @@ public class EditorProxy {
assertNotNull(embeddedAttribute);
PersistentAttribute jpa = getJPAObjectForGefElement(embeddedAttribute);
- jpa.getJavaPersistentAttribute().setMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
+// jpa.getJavaPersistentAttribute().setMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
+//
+//
+ PersistentAttribute ormAttribute = jpaFactory.getORMPersistentAttribute(jpa);
+ if(isOrmXml) {
+ assertNotNull(ormAttribute);
+ ((OrmSpecifiedPersistentAttribute)ormAttribute).setMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
+ } else {
+ jpa.getJavaPersistentAttribute().setMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
+
+ }
+
}
/**
@@ -2969,19 +3239,33 @@ public class EditorProxy {
* @param entity - the entity from which the primary key to be deleted
*/
public void deleteEntityDefaultPK(
- SWTBotGefEditPart entity) {
+ SWTBotGefEditPart entity, boolean isOrmXml) {
List<SWTBotGefEditPart> editParts = new ArrayList<SWTBotGefEditPart>();
editParts.add(entity);
SWTBotGefEditPart attribute = jpaDiagramEditor.getEditpart(
"id", editParts);
+ PersistentAttribute pa = getJPAObjectForGefElement(attribute);
+ if(isOrmXml) {
+ OrmPersistentType ormJpt = ormXml.getPersistentType(pa.getDeclaringPersistentType().getName());
+ assertNotNull(ormJpt);
+ OrmPersistentAttribute ormAttr = ormJpt.getAttributeNamed(pa.getName());
+ assertNotNull(ormAttr);
+ }
+
pressAttributeDeleteContextButton(attribute);
confirmDelete();
bot.waitUntil(new ElementDisappears(jpaDiagramEditor, entity, "id"),
20000);
+
+ jpaDiagramEditor.save();
+
attribute = jpaDiagramEditor.getEditpart(
"id", editParts);
assertNull("Attribute must be deleted!", attribute);
+ if(isOrmXml) {
+ assertOrmAttrIsDeleted(pa);
+ }
}
/**
@@ -2994,21 +3278,56 @@ public class EditorProxy {
* @throws CoreException
* @throws JavaModelException
*/
- public IFile setIdClass(SWTBotGefEditPart entity, String idClassName, JpaProject jpaProject)
+ public JavaPersistentType setIdClass(SWTBotGefEditPart entity, String idClassName, JpaProject jpaProject, boolean create)
throws IOException, CoreException, JavaModelException {
- IFile idClass = JPACreateFactory.instance().createIdClassInProject(jpaProject.getProject(), new String[] {"org", "persistence"}, idClassName);
+ if(create) {
+ JPACreateFactory.instance().createIdClassInProject(jpaProject.getProject(), new String[] {"org", "persistence"}, idClassName);
+ }
PersistentType jptType= getJPTObjectForGefElement(entity);
+ Command command = new SetIdClassCommand(jptType, idClassName);
+ try {
+ getJpaProjectManager().execute(command, SynchronousUiCommandContext.instance());
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
TypeMapping typeMapping = JpaArtifactFactory.instance().getTypeMapping(jptType);
assertTrue(Entity.class.isInstance(typeMapping));
- ((Entity)typeMapping).getIdClassReference().setSpecifiedIdClassName(idClassName);
-// Annotation an = jptType.getJavaResourceType().addAnnotation(IdClassAnnotation.ANNOTATION_NAME);
-// ((IdClassAnnotation)an).setValue(idClassName);
+ jptType.getJavaResourceType().getJavaResourceCompilationUnit().synchronizeWithJavaSource();
+ jptType.synchronizeWithResourceModel();
+ jptType.update();
+
+ JavaPersistentType idClass = ((Entity)typeMapping).getIdClass();
return idClass;
}
+ private JpaProjectManager getJpaProjectManager() {
+ return (JpaProjectManager) ResourcesPlugin.getWorkspace().getAdapter(JpaProjectManager.class);
+ }
+
+ private class SetIdClassCommand implements Command {
+
+ private PersistentType jptType;
+ private String idClassName;
+
+ public SetIdClassCommand(PersistentType jptType, String idClassName){
+ this.jptType = jptType;
+ this.idClassName = idClassName;
+ }
+
+ @Override
+ public void execute() {
+ idClassName = "org.persistence." + idClassName;
+ TypeMapping typeMapping = JpaArtifactFactory.instance().getTypeMapping(jptType);
+ assertTrue(Entity.class.isInstance(typeMapping));
+ ((Entity)typeMapping).getIdClassReference().setSpecifiedIdClassName(idClassName);
+ }
+
+ }
+
/**
* Get all annotations as string for the given attribute.
* @param persistentAttribite
@@ -3024,4 +3343,8 @@ public class EditorProxy {
}
return res;
}
+
+ public void setOrmXml(OrmXml ormXml) {
+ this.ormXml = ormXml;
+ }
}
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/utils/RelationshipsUtils.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/utils/RelationshipsUtils.java
new file mode 100644
index 0000000..834cae3
--- /dev/null
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/utils/RelationshipsUtils.java
@@ -0,0 +1,1361 @@
+package org.eclipse.jpt.jpadiagrameditor.swtbot.tests.utils;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.core.MappingKeys;
+import org.eclipse.jpt.jpa.core.context.Entity;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
+import org.eclipse.jpt.jpa.core.context.TypeMapping;
+import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
+import org.eclipse.jpt.jpa.core.context.orm.OrmSpecifiedPersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.orm.OrmXml;
+import org.eclipse.jpt.jpa.ui.details.JptJpaUiDetailsMessages;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IRelation;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
+
+public class RelationshipsUtils {
+
+ private SWTBotGefEditor jpaDiagramEditor;
+ private EditorProxy editorProxy;
+ private JpaProject jpaProject;
+ private OrmXml ormXml;
+
+ public RelationshipsUtils(SWTBotGefEditor jpaDiagramEditor, EditorProxy editorProxy, JpaProject jpaProject) {
+ this.jpaDiagramEditor = jpaDiagramEditor;
+ this.editorProxy = editorProxy;
+ this.jpaProject = jpaProject;
+ }
+
+
+ /**
+ * Creates "One to One" unidirectional relationship (from entity1 to
+ * entity2). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore. Check
+ * that if the owner attribute will be deleted, the relationship will
+ * disappear.
+ *
+ */
+ public void oneToOneUniDirRelationship(boolean isOrmXml) {
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity1 = editorProxy.addEntityToDiagram(50, 50,
+ jpaProject);
+ String entityName1 = editorProxy.getJPTObjectForGefElement(entity1).getName();
+ SWTBotGefEditPart entity2 = editorProxy.addEntityToDiagram(200, 50,
+ jpaProject);
+ String entityName2 = editorProxy.getJPTObjectForGefElement(entity2).getName();
+
+ if(isOrmXml) {
+ assertNotNull(ormXml.getPersistentType(entityName1));
+ assertNotNull(ormXml.getPersistentType(entityName2));
+ }
+
+ // create One-to-One unidirectional relation from entity1 to entity2
+ editorProxy
+ .testUniDirRelation(
+ JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
+ entity1,
+ entity2,
+ IRelation.RelType.ONE_TO_ONE,
+ MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, true, isOrmXml);
+
+ // create One-to-One unidirectional relation from entity1 to entity2
+ editorProxy
+ .testUniDirRelRemoveOwnerAttribute(
+ JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
+ entity1,
+ entity2,
+ IRelation.RelType.ONE_TO_ONE,
+ MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, true, isOrmXml);
+
+ editorProxy.deleteDiagramElements(isOrmXml);
+
+ jpaDiagramEditor.save();
+ }
+
+ /**
+ * Creates "One to One" unidirectional self relationship (from entity1 to
+ * entity1). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore.
+ */
+ public void selfOneToOneUniDirRelationship(boolean isOrmXml) {
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity1 = editorProxy.addEntityToDiagram(50, 50,
+ jpaProject);
+ String entityName = editorProxy.getJPTObjectForGefElement(entity1).getName();
+ if(isOrmXml){
+ assertNotNull(ormXml.getPersistentType(entityName));
+ }
+ // create One-to-One unidirectional self relation from entity1 to
+ // entity1
+ editorProxy
+ .testSelfUniDirRelation(
+ JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
+ entity1,
+ IRelation.RelType.ONE_TO_ONE,
+ MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, true, isOrmXml);
+
+ editorProxy.deleteDiagramElements(isOrmXml);
+
+ jpaDiagramEditor.save();
+ }
+
+ /**
+ * Creates "One to One" bidirectional relationship (from entity1 to
+ * entity2). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore. Check
+ * that if the inverse attribute will be deleted the connection will be
+ * transformed into one-to-one unidirectional relationship. Test that if the
+ * owner attribute will be deleted, the relationship will disappear.
+ */
+ public void oneToOneBiDirRelationship(boolean isOrmXml) {
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity1 = editorProxy.addEntityToDiagram(50, 50,
+ jpaProject);
+ String entityName1 = editorProxy.getJPTObjectForGefElement(entity1).getName();
+ SWTBotGefEditPart entity2 = editorProxy.addEntityToDiagram(200, 50,
+ jpaProject);
+ String entityName2 = editorProxy.getJPTObjectForGefElement(entity2).getName();
+
+ if(isOrmXml){
+ assertNotNull(ormXml.getPersistentType(entityName1));
+ assertNotNull(ormXml.getPersistentType(entityName2));
+ }
+
+ // create One-to-One bidirectional relation from entity1 to entity2
+ editorProxy
+ .testBiDirRel(
+ JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
+ entity1,
+ entity2,
+ IRelation.RelType.ONE_TO_ONE,
+ MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, true, isOrmXml);
+
+ // create One-to-One bidirectional relation from entity1 to entity2
+ editorProxy
+ .testBiDirRelRemoveInverseAttribute(
+ JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
+ entity1,
+ entity2,
+ IRelation.RelType.ONE_TO_ONE,
+ MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, true, isOrmXml);
+
+ // create One-to-One bidirectional relation from entity1 to entity2
+ editorProxy
+ .testBiDirRelRemoveOwnerAttr(
+ JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
+ entity1,
+ entity2,
+ IRelation.RelType.ONE_TO_ONE,
+ MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, true, isOrmXml);
+
+ editorProxy.deleteDiagramElements(isOrmXml);
+
+ jpaDiagramEditor.save();
+ }
+
+ /**
+ * Creates "One to One" bidirectional self relationship (from entity1 to
+ * entity1). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore.
+ */
+ public void selfOneToOneBiDirRelationship(boolean isOrmXml) {
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity1 = editorProxy.addEntityToDiagram(50, 50,
+ jpaProject);
+
+ String entityName = editorProxy.getJPTObjectForGefElement(entity1).getName();
+ if(isOrmXml){
+ assertNotNull(ormXml.getPersistentType(entityName));
+ }
+ // create One-to-One bidirectional self relation from entity1 to entity1
+ editorProxy
+ .testSelfBiDirRel(
+ JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
+ entity1,
+ IRelation.RelType.ONE_TO_ONE,
+ MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, true, isOrmXml);
+
+ editorProxy.deleteDiagramElements(isOrmXml);
+
+ jpaDiagramEditor.save();
+ }
+
+ /**
+ * Creates "One to Many" unidirectional relationship (from entity1 to
+ * entity2). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore. Check
+ * that if the owner attribute will be deleted, the relationship will
+ * disappear.
+ */
+ public void oneToManyUniDirRelationship(boolean isOrmXml) {
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity1 = editorProxy.addEntityToDiagram(50, 50,
+ jpaProject);
+ String entityName1 = editorProxy.getJPTObjectForGefElement(entity1).getName();
+ SWTBotGefEditPart entity2 = editorProxy.addEntityToDiagram(200, 50,
+ jpaProject);
+ String entityname2 = editorProxy.getJPTObjectForGefElement(entity2).getName();
+
+ if(isOrmXml){
+ assertNotNull(ormXml.getPersistentType(entityName1));
+ assertNotNull(ormXml.getPersistentType(entityname2));
+ }
+ // create One-to-Many unidirectional relation from entity1 to entity2
+ editorProxy
+ .testUniDirRelation(
+ JPAEditorMessages.CreateOneToManyUniDirRelationFeature_oneToManyUniDirFeatureName,
+ entity1,
+ entity2,
+ IRelation.RelType.ONE_TO_MANY,
+ MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, false, isOrmXml);
+
+ // create One-to-One bidirectional relation from entity1 to entity2
+ editorProxy
+ .testUniDirRelRemoveOwnerAttribute(
+ JPAEditorMessages.CreateOneToManyUniDirRelationFeature_oneToManyUniDirFeatureName,
+ entity1,
+ entity2,
+ IRelation.RelType.ONE_TO_MANY,
+ MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, false, isOrmXml);
+
+ editorProxy.deleteDiagramElements(isOrmXml);
+
+ jpaDiagramEditor.save();
+ }
+
+ /**
+ * Creates "One to Many" unidirectional self relationship (from entity1 to
+ * entity1). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore.
+ */
+ public void selfOneToManyUniDirRelationship(boolean isOrmXml) {
+
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity1 = editorProxy.addEntityToDiagram(50, 50,
+ jpaProject);
+ String entityName = editorProxy.getJPTObjectForGefElement(entity1).getName();
+ if(isOrmXml){
+ assertNotNull(ormXml.getPersistentType(entityName));
+ }
+
+ // create One-to-Many unidirectional self relation from entity1 to
+ // entity1
+
+ editorProxy
+ .testSelfUniDirRelation(
+ JPAEditorMessages.CreateOneToManyUniDirRelationFeature_oneToManyUniDirFeatureName,
+ entity1,
+ IRelation.RelType.ONE_TO_MANY,
+ MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, false, isOrmXml);
+
+ editorProxy.deleteDiagramElements(isOrmXml);
+
+ jpaDiagramEditor.save();
+ }
+
+ /**
+ * Creates "Many to One" unidirectional relationship (from entity1 to
+ * entity2). Assert that the relation attributes exists. Delete the
+ * relationship and assert that the attributes do not exists anymore. Check
+ * that if the owner attribute will be deleted, the relationship will
+ * disappear.
+ */
+ public void manyToOneUniDirRelationship(boolean isOrmXml) {
+ assertTrue("The diagram must be empty.", jpaDiagramEditor
+ .mainEditPart().children().isEmpty());
+
+ SWTBotGefEditPart entity1 = editorProxy.addEntityToDiagram(50, 50,
+ jpaProject);
+ String entityName1 = editorProxy.getJPTObjectForGefElement(entity1).getName();
+ SWTBotGefEditPart entity2 = edi