diff --git a/bundles/mdpa.dfd.datadictionary.edit/plugin.properties b/bundles/mdpa.dfd.datadictionary.edit/plugin.properties index 0694b2d..cec505b 100644 --- a/bundles/mdpa.dfd.datadictionary.edit/plugin.properties +++ b/bundles/mdpa.dfd.datadictionary.edit/plugin.properties @@ -1,6 +1,6 @@ # -pluginName = BehaviourModel Model Edit Support +pluginName = Data Dictionary Model Edit Support providerName = www.example.org _UI_CreateChild_text = {0} diff --git a/bundles/mdpa.dfd.datadictionary.editor/plugin.properties b/bundles/mdpa.dfd.datadictionary.editor/plugin.properties index d787ee4..7759445 100644 --- a/bundles/mdpa.dfd.datadictionary.editor/plugin.properties +++ b/bundles/mdpa.dfd.datadictionary.editor/plugin.properties @@ -1,6 +1,6 @@ # -pluginName = BehaviourModel Model Editor +pluginName = Data Dictionary Model Editor providerName = www.example.org _UI_datadictionaryEditor_menu = &datadictionary Editor diff --git a/bundles/mdpa.dfd.datadictionary/model/datadictionary.ecore b/bundles/mdpa.dfd.datadictionary/model/datadictionary.ecore index 7b88d2f..bc74449 100644 --- a/bundles/mdpa.dfd.datadictionary/model/datadictionary.ecore +++ b/bundles/mdpa.dfd.datadictionary/model/datadictionary.ecore @@ -34,15 +34,15 @@ - + + eType="#//Term" containment="true"/> + eType="#//Term" containment="true"/> diff --git a/bundles/mdpa.dfd.datadictionary/model/datadictionary.genmodel b/bundles/mdpa.dfd.datadictionary/model/datadictionary.genmodel index a063a37..f73a7bf 100644 --- a/bundles/mdpa.dfd.datadictionary/model/datadictionary.genmodel +++ b/bundles/mdpa.dfd.datadictionary/model/datadictionary.genmodel @@ -39,12 +39,12 @@ - + - + diff --git a/bundles/mdpa.dfd.dataflowdiagram/model/dataflowdiagram.aird b/bundles/mdpa.dfd.dataflowdiagram/model/dataflowdiagram.aird index f502e03..c2f2b7d 100644 --- a/bundles/mdpa.dfd.dataflowdiagram/model/dataflowdiagram.aird +++ b/bundles/mdpa.dfd.dataflowdiagram/model/dataflowdiagram.aird @@ -6,6 +6,10 @@ platform:/resource/datadictionary/model/datadictionary.ecore platform:/resource/tools.mdsd.modelingfoundations.identifier/model/identifier.genmodel platform:/resource/tools.mdsd.modelingfoundations.identifier/model/identifier.ecore + platform:/resource/mdpa.dfd.datadictionary/model/datadictionary.ecore + dataflowdiagram.ecore + dataflowdiagram.genmodel + platform:/resource/mdpa.dfd.datadictionary/model/datadictionary.genmodel @@ -36,6 +40,10 @@ + + + + @@ -1629,4 +1637,410 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bold + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + italic + + + + + + + + + + + + + + + + + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + + italic + + + + + + + + + + + + italic + + + + + + + + + + + + italic + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml index a807237..eb6bb78 100644 --- a/pom.xml +++ b/pom.xml @@ -171,5 +171,6 @@ releng bundles features + tests \ No newline at end of file diff --git a/releng/mdpa.dfd.targetplatform/mdpa.dfd.targetplatform.target b/releng/mdpa.dfd.targetplatform/mdpa.dfd.targetplatform.target index 62b3aba..1db6545 100644 --- a/releng/mdpa.dfd.targetplatform/mdpa.dfd.targetplatform.target +++ b/releng/mdpa.dfd.targetplatform/mdpa.dfd.targetplatform.target @@ -32,6 +32,22 @@ + + + + + + + + + + + + + + + + diff --git a/tests/META-INF/MANIFEST.MF b/tests/META-INF/MANIFEST.MF deleted file mode 100644 index 716f778..0000000 --- a/tests/META-INF/MANIFEST.MF +++ /dev/null @@ -1,10 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Tests -Bundle-SymbolicName: mdpa.dfd.tests -Bundle-Version: 1.0.0.qualifier -Bundle-RequiredExecutionEnvironment: JavaSE-17 -Automatic-Module-Name: mdpa.dfd.tests -Export-Package: mdpa.dfd.tests -Require-Bundle: mdpa.dfd.dataflowdiagram -Import-Package: org.eclipse.emf.ecore.xmi.impl diff --git a/tests/.classpath b/tests/mdpa.dfd.tests/.classpath similarity index 79% rename from tests/.classpath rename to tests/mdpa.dfd.tests/.classpath index ebeb0b1..5902ee7 100644 --- a/tests/.classpath +++ b/tests/mdpa.dfd.tests/.classpath @@ -5,7 +5,11 @@ - + + + + + diff --git a/tests/mdpa.dfd.tests/.project b/tests/mdpa.dfd.tests/.project new file mode 100644 index 0000000..92a79ab --- /dev/null +++ b/tests/mdpa.dfd.tests/.project @@ -0,0 +1,28 @@ + + + mdpa.dfd.tests + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.pde.PluginNature + + diff --git a/tests/.settings/org.eclipse.core.resources.prefs b/tests/mdpa.dfd.tests/.settings/org.eclipse.core.resources.prefs similarity index 100% rename from tests/.settings/org.eclipse.core.resources.prefs rename to tests/mdpa.dfd.tests/.settings/org.eclipse.core.resources.prefs diff --git a/tests/.settings/org.eclipse.jdt.core.prefs b/tests/mdpa.dfd.tests/.settings/org.eclipse.jdt.core.prefs similarity index 91% rename from tests/.settings/org.eclipse.jdt.core.prefs rename to tests/mdpa.dfd.tests/.settings/org.eclipse.jdt.core.prefs index 8c9943d..9478cb1 100644 --- a/tests/.settings/org.eclipse.jdt.core.prefs +++ b/tests/mdpa.dfd.tests/.settings/org.eclipse.jdt.core.prefs @@ -1,5 +1,6 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=17 diff --git a/tests/mdpa.dfd.tests/META-INF/MANIFEST.MF b/tests/mdpa.dfd.tests/META-INF/MANIFEST.MF new file mode 100644 index 0000000..87606b6 --- /dev/null +++ b/tests/mdpa.dfd.tests/META-INF/MANIFEST.MF @@ -0,0 +1,15 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Data Flow Diagram Tests +Bundle-SymbolicName: mdpa.dfd.tests +Bundle-Version: 1.0.0.qualifier +Bundle-RequiredExecutionEnvironment: JavaSE-17 +Automatic-Module-Name: mdpa.dfd.tests +Export-Package: mdpa.dfd.tests +Require-Bundle: org.junit, + junit-jupiter-api, + tools.mdsd.library.standalone.initialization, + mdpa.dfd.datadictionary, + mdpa.dfd.dataflowdiagram, + org.eclipse.emf.ecore.xmi, + org.eclipse.emf.ecore diff --git a/tests/build.properties b/tests/mdpa.dfd.tests/build.properties similarity index 100% rename from tests/build.properties rename to tests/mdpa.dfd.tests/build.properties diff --git a/tests/mdpa.dfd.tests/models/minimal.datadictionary b/tests/mdpa.dfd.tests/models/minimal.datadictionary new file mode 100644 index 0000000..d5c287c --- /dev/null +++ b/tests/mdpa.dfd.tests/models/minimal.datadictionary @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/tests/mdpa.dfd.tests/models/minimal.dataflowdiagram b/tests/mdpa.dfd.tests/models/minimal.dataflowdiagram new file mode 100644 index 0000000..1bb1a94 --- /dev/null +++ b/tests/mdpa.dfd.tests/models/minimal.dataflowdiagram @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/mdpa.dfd.tests/src/mdpa/dfd/tests/MinimalTest.java b/tests/mdpa.dfd.tests/src/mdpa/dfd/tests/MinimalTest.java new file mode 100644 index 0000000..c9543d7 --- /dev/null +++ b/tests/mdpa.dfd.tests/src/mdpa/dfd/tests/MinimalTest.java @@ -0,0 +1,135 @@ +package mdpa.dfd.tests; + +import static org.junit.jupiter.api.Assertions.*; + +import java.nio.file.Paths; + +import mdpa.dfd.datadictionary.DataDictionary; +import mdpa.dfd.dataflowdiagram.DataFlowDiagram; + +import tools.mdsd.library.standalone.initialization.StandaloneInitializationException; +import tools.mdsd.library.standalone.initialization.StandaloneInitializerBuilder; +import tools.mdsd.modelingfoundations.identifier.Entity; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class MinimalTest { + private static final String PLUGIN_PATH = "mdpa.dfd.tests"; + private static final String DFD_MODEL_PATH = "minimal.dataflowdiagram"; + private static final String DD_MODEL_PATH = "minimal.datadictionary"; + + private ResourceSet resources = new ResourceSetImpl(); + + @BeforeAll + static void setUpBeforeAll() throws Exception { + initStandalone(); + } + + @BeforeEach + void setUpBeforeEach() throws Exception { + } + + @Test + void loadAndCheckSupertype() { + System.out.println("Start loading dfd"); + DataFlowDiagram dfd = (DataFlowDiagram) loadResource(createPluginURI(DFD_MODEL_PATH)); + System.out.println("Start loading dd"); + DataDictionary dd = (DataDictionary) loadResource(createPluginURI(DD_MODEL_PATH)); + + System.out.println("Checking models"); + checkEntitySupertype(dfd, dd); + } + + private void checkEntitySupertype(DataFlowDiagram dfd, DataDictionary dd) { + assertTrue(dfd instanceof Entity); + dfd.getNodes().forEach(n -> { + assertTrue(n instanceof Entity); + }); + System.out.println("Nodes of type Entity"); + dfd.getFlows().forEach(f -> { + assertTrue(f instanceof Entity); + }); + System.out.println("Flows of type Entity"); + + dd.getBehaviour().forEach(b -> { + assertTrue(b instanceof Entity); + b.getAssignment().forEach(a -> { + assertTrue(a instanceof Entity); + }); + b.getIn().forEach(p -> { + assertTrue(p instanceof Entity); + }); + b.getOut().forEach(p -> { + assertTrue(p instanceof Entity); + }); + }); + System.out.println("Behaviour and contained classes of type Entity"); + + dd.getLabelTypes() .forEach(t -> { + assertTrue(t instanceof Entity); + t.getLabel().forEach(l -> { + assertTrue(l instanceof Entity); + }); + }); + System.out.println("LabelTypes and Labels of type Entity"); + } + +// private DataFlowDiagram changeInstance(DataFlowDiagram dfd) { +// dfd.getFlows().get(0).setEntityName("ExcitingFlow"); +// return dfd; +// } + +// private void saveChangedInstance(DataFlowDiagram dfd) { +// ResourceSet resourceSet = new ResourceSetImpl(); +// resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap() +// .put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl()); +// resourceSet.getPackageRegistry().put(dataflowdiagramPackage.eNS_URI, +// dataflowdiagramPackage.eINSTANCE); +// +// Resource resource = resourceSet.createResource(URI.createFileURI("output/changedModel.dataflowdiagrammodel")); +// +// resource.getContents().add(dfd); +// assertDoesNotThrow(() -> resource.save(Collections.EMPTY_MAP)); +// } + + private EObject loadResource(URI modelURI) { + Resource resource = this.resources.getResource(modelURI, true); + if (resource == null) { + throw new IllegalArgumentException(String.format("Model with URI %s could not be loaded", modelURI)); + } else if (resource.getContents().isEmpty()) { + throw new IllegalArgumentException(String.format("Model with URI %s is empty", modelURI)); + } + return resource.getContents().get(0); + } + + private URI createPluginURI(String relativePath) { + String path = Paths.get(PLUGIN_PATH, "models", relativePath) + .toString(); + return URI.createPlatformPluginURI(path, false); + } + + private static void initStandalone() { + Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("dataflowdiagram", new XMIResourceFactoryImpl()); + Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("datadictionary", new XMIResourceFactoryImpl()); + + try { + StandaloneInitializerBuilder.builder() + .registerProjectURI(MinimalTest.class, PLUGIN_PATH) + .build() + .init(); + + } catch (StandaloneInitializationException e) { + e.printStackTrace(); + } + } + +} diff --git a/tests/output/changedModel.dataflowdiagrammodel b/tests/output/changedModel.dataflowdiagrammodel deleted file mode 100644 index f7d7e41..0000000 --- a/tests/output/changedModel.dataflowdiagrammodel +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/tests/resources/MinimalBehaviourModel.behaviourmodel b/tests/resources/MinimalBehaviourModel.behaviourmodel deleted file mode 100644 index 2a73789..0000000 --- a/tests/resources/MinimalBehaviourModel.behaviourmodel +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/tests/resources/MinimalModel.dataflowdiagrammodel b/tests/resources/MinimalModel.dataflowdiagrammodel deleted file mode 100644 index d4eca8d..0000000 --- a/tests/resources/MinimalModel.dataflowdiagrammodel +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/tests/src/mdpa/dfd/tests/MinimalTest.java b/tests/src/mdpa/dfd/tests/MinimalTest.java deleted file mode 100644 index 1bce635..0000000 --- a/tests/src/mdpa/dfd/tests/MinimalTest.java +++ /dev/null @@ -1,65 +0,0 @@ -package mdpa.dfd.tests; - -import static org.junit.jupiter.api.Assertions.*; - -import java.io.File; -import java.util.Collections; - -import mdpa.dfd.diagram.dataflowdiagrammodel.DataFlowDiagram; -import mdpa.dfd.diagram.dataflowdiagrammodel.DataFlowDiagramModelPackage; -import mdpa.dfd.diagram.dataflowdiagrammodel.impl.DataFlowDiagramModelFactoryImpl; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; -import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; -import org.junit.jupiter.api.Test; - -class MinimalTest { - - private static final String RELATIVE_PATH_TO_MINIMAL_EXAMPLE = "resources/MinimalModel.dataflowdiagrammodel"; - private DataFlowDiagram dfd; - - @Test - void loadAndSave() { - dfd = loadInstance(); - dfd = changeInstance(dfd); - saveChangedInstance(dfd); - } - - private DataFlowDiagram loadInstance() { - ResourceSet resourceSet = new ResourceSetImpl(); - resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap() - .put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl()); - resourceSet.getPackageRegistry().put(DataFlowDiagramModelPackage.eNS_URI, - DataFlowDiagramModelPackage.eINSTANCE); - - File file = new File(RELATIVE_PATH_TO_MINIMAL_EXAMPLE); - URI uri = file.isFile() ? URI.createFileURI(file.getAbsolutePath()) - : URI.createURI(RELATIVE_PATH_TO_MINIMAL_EXAMPLE); - - Resource resource = resourceSet.getResource(uri, true); - return (DataFlowDiagram) resource.getContents().get(0); - - } - - private DataFlowDiagram changeInstance(DataFlowDiagram dfd) { - dfd.getFlows().get(0).setEntityName("ExcitingFlow"); - return dfd; - } - - private void saveChangedInstance(DataFlowDiagram dfd) { - ResourceSet resourceSet = new ResourceSetImpl(); - resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap() - .put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl()); - resourceSet.getPackageRegistry().put(DataFlowDiagramModelPackage.eNS_URI, - DataFlowDiagramModelPackage.eINSTANCE); - - Resource resource = resourceSet.createResource(URI.createFileURI("output/changedModel.dataflowdiagrammodel")); - - resource.getContents().add(dfd); - assertDoesNotThrow(() -> resource.save(Collections.EMPTY_MAP)); - } - -} diff --git a/tests/src/mdpa/dfd/tests/resources/MinimalBehaviour.behaviourmodel b/tests/src/mdpa/dfd/tests/resources/MinimalBehaviour.behaviourmodel deleted file mode 100644 index c4baa9a..0000000 --- a/tests/src/mdpa/dfd/tests/resources/MinimalBehaviour.behaviourmodel +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/tests/src/mdpa/dfd/tests/resources/MinimalBehaviourModel.behaviourmodel b/tests/src/mdpa/dfd/tests/resources/MinimalBehaviourModel.behaviourmodel deleted file mode 100644 index 2a73789..0000000 --- a/tests/src/mdpa/dfd/tests/resources/MinimalBehaviourModel.behaviourmodel +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/tests/src/mdpa/dfd/tests/resources/MinimalModel.dataflowdiagrammodel b/tests/src/mdpa/dfd/tests/resources/MinimalModel.dataflowdiagrammodel deleted file mode 100644 index d4eca8d..0000000 --- a/tests/src/mdpa/dfd/tests/resources/MinimalModel.dataflowdiagrammodel +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - -