Skip to content

Commit

Permalink
Add MinimalTest checking Element superclasses
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas-Boltz committed Jul 18, 2023
1 parent c4bc67d commit 6d5774c
Show file tree
Hide file tree
Showing 24 changed files with 666 additions and 167 deletions.
2 changes: 1 addition & 1 deletion bundles/mdpa.dfd.datadictionary.edit/plugin.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#

pluginName = BehaviourModel Model Edit Support
pluginName = Data Dictionary Model Edit Support
providerName = www.example.org

_UI_CreateChild_text = {0}
Expand Down
2 changes: 1 addition & 1 deletion bundles/mdpa.dfd.datadictionary.editor/plugin.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#

pluginName = BehaviourModel Model Editor
pluginName = Data Dictionary Model Editor
providerName = www.example.org

_UI_datadictionaryEditor_menu = &datadictionary Editor
Expand Down
6 changes: 3 additions & 3 deletions bundles/mdpa.dfd.datadictionary/model/datadictionary.ecore
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Term" abstract="true" eSuperTypes="../../tools.mdsd.modelingfoundations.identifier/model/identifier.ecore#//Entity"/>
<eClassifiers xsi:type="ecore:EClass" name="TRUE" eSuperTypes="#//Term"/>
<eClassifiers xsi:type="ecore:EClass" name="BinaryOperator" eSuperTypes="#//Term">
<eClassifiers xsi:type="ecore:EClass" name="BinaryOperator" abstract="true" eSuperTypes="#//Term">
<eStructuralFeatures xsi:type="ecore:EReference" name="terms" lowerBound="2" upperBound="2"
eType="#//Term"/>
eType="#//Term" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="AND" eSuperTypes="#//BinaryOperator"/>
<eClassifiers xsi:type="ecore:EClass" name="OR" eSuperTypes="#//BinaryOperator"/>
<eClassifiers xsi:type="ecore:EClass" name="NOT" eSuperTypes="#//Term">
<eStructuralFeatures xsi:type="ecore:EReference" name="negatedTerm" lowerBound="1"
eType="#//Term"/>
eType="#//Term" containment="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="LabelReference" eSuperTypes="#//Term">
<eStructuralFeatures xsi:type="ecore:EReference" name="label" lowerBound="1" eType="#//Label"/>
Expand Down
4 changes: 2 additions & 2 deletions bundles/mdpa.dfd.datadictionary/model/datadictionary.genmodel
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
<genClasses image="false" ecoreClass="datadictionary.ecore#//Term"/>
<genClasses ecoreClass="datadictionary.ecore#//TRUE"/>
<genClasses ecoreClass="datadictionary.ecore#//BinaryOperator">
<genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference datadictionary.ecore#//BinaryOperator/terms"/>
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference datadictionary.ecore#//BinaryOperator/terms"/>
</genClasses>
<genClasses ecoreClass="datadictionary.ecore#//AND"/>
<genClasses ecoreClass="datadictionary.ecore#//OR"/>
<genClasses ecoreClass="datadictionary.ecore#//NOT">
<genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference datadictionary.ecore#//NOT/negatedTerm"/>
<genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference datadictionary.ecore#//NOT/negatedTerm"/>
</genClasses>
<genClasses ecoreClass="datadictionary.ecore#//LabelReference">
<genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference datadictionary.ecore#//LabelReference/label"/>
Expand Down
414 changes: 414 additions & 0 deletions bundles/mdpa.dfd.dataflowdiagram/model/dataflowdiagram.aird

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,6 @@
<module>releng</module>
<module>bundles</module>
<module>features</module>
<module>tests</module>
</modules>
</project>
16 changes: 16 additions & 0 deletions releng/mdpa.dfd.targetplatform/mdpa.dfd.targetplatform.target
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,22 @@
<unit id="org.eclipse.xsd.sdk.feature.group" version="0.0.0"/>
<unit id="org.eclipse.tips.feature.feature.group" version="0.0.0"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="false" type="InstallableUnit">
<repository location="https://download.eclipse.org/tools/orbit/downloads/2022-12/"/>
<unit id="org.junit.jupiter.api" version="0.0.0"/>
<unit id="org.junit.jupiter.params" version="0.0.0"/>
<unit id="org.junit.jupiter.engine" version="0.0.0"/>
<unit id="org.junit.jupiter.migrationsupport" version="0.0.0"/>
<unit id="org.junit.platform.commons" version="0.0.0"/>
<unit id="org.junit.platform.engine" version="0.0.0"/>
<unit id="org.junit.platform.launcher" version="0.0.0"/>
<unit id="org.junit.platform.runner" version="0.0.0"/>
<unit id="org.junit.platform.suite.api" version="0.0.0"/>
<unit id="org.junit.platform.suite.commons" version="0.0.0"/>
<unit id="org.junit.platform.suite.engine" version="0.0.0"/>
<unit id="org.junit.vintage.engine" version="0.0.0"/>
<unit id="org.apiguardian" version="0.0.0"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="false" type="InstallableUnit">
<repository location="https://download.eclipse.org/releases/2022-12/202212071000/"/>
<unit id="org.eclipse.emf.mwe2.launcher.feature.group" version="0.0.0"/>
Expand Down
10 changes: 0 additions & 10 deletions tests/META-INF/MANIFEST.MF

This file was deleted.

6 changes: 5 additions & 1 deletion tests/.classpath → tests/mdpa.dfd.tests/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="src">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
Expand Down
28 changes: 28 additions & 0 deletions tests/mdpa.dfd.tests/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>mdpa.dfd.tests</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -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
Expand Down
15 changes: 15 additions & 0 deletions tests/mdpa.dfd.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
21 changes: 21 additions & 0 deletions tests/mdpa.dfd.tests/models/minimal.datadictionary
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<datadictionary:DataDictionary xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:datadictionary="http://www.example.org/datadictionary">
<labelTypes id="_3--1ICIvEe6PiqL6n35dVA">
<label id="_B5G78CIwEe6PiqL6n35dVA"/>
</labelTypes>
<behaviour id="_IkNiASIwEe6PiqL6n35dVA">
<in id="_I0gn0CIwEe6PiqL6n35dVA" entityName="in"/>
<out id="_K1uRoSIwEe6PiqL6n35dVA" entityName="out"/>
<assignment id="_NI-GoiIwEe6PiqL6n35dVA" outputLabels="_B5G78CIwEe6PiqL6n35dVA" inputPins="_I0gn0CIwEe6PiqL6n35dVA" outputPin="_K1uRoSIwEe6PiqL6n35dVA">
<term xsi:type="datadictionary:AND" id="_No15gCIwEe6PiqL6n35dVA">
<terms xsi:type="datadictionary:TRUE" id="_mhivECJJEe6P-M7CfFBAtg"/>
<terms xsi:type="datadictionary:OR" id="_nfPtciJJEe6P-M7CfFBAtg">
<terms xsi:type="datadictionary:NOT" id="_pJtrMyJJEe6P-M7CfFBAtg">
<negatedTerm xsi:type="datadictionary:TRUE" id="_fT61UCJKEe6WZv922ZB9nw"/>
</terms>
<terms xsi:type="datadictionary:LabelReference" id="_pu3mtCJJEe6P-M7CfFBAtg" label="_B5G78CIwEe6PiqL6n35dVA"/>
</terms>
</term>
</assignment>
</behaviour>
</datadictionary:DataDictionary>
23 changes: 23 additions & 0 deletions tests/mdpa.dfd.tests/models/minimal.dataflowdiagram
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<dataflowdiagram:DataFlowDiagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dataflowdiagram="http://www.example.org/dataflowdiagram" id="_5M_FECJKEe6WZv922ZB9nw">
<flows id="_KSGy8CJLEe6WZv922ZB9nw" sourceNode="_50P5YCJKEe6WZv922ZB9nw" destinationNode="_IfipIyJLEe6WZv922ZB9nw">
<destinationPin href="minimal.datadictionary#_K1uRoSIwEe6PiqL6n35dVA"/>
<sourcePin href="minimal.datadictionary#_I0gn0CIwEe6PiqL6n35dVA"/>
</flows>
<flows id="_P7KtMCJLEe6WZv922ZB9nw" sourceNode="_JQwqsiJLEe6WZv922ZB9nw" destinationNode="_IfipIyJLEe6WZv922ZB9nw">
<destinationPin href="minimal.datadictionary#_K1uRoSIwEe6PiqL6n35dVA"/>
<sourcePin href="minimal.datadictionary#_I0gn0CIwEe6PiqL6n35dVA"/>
</flows>
<nodes xsi:type="dataflowdiagram:External" id="_50P5YCJKEe6WZv922ZB9nw">
<behaviour href="minimal.datadictionary#_IkNiASIwEe6PiqL6n35dVA"/>
<property href="minimal.datadictionary#_B5G78CIwEe6PiqL6n35dVA"/>
</nodes>
<nodes xsi:type="dataflowdiagram:Process" id="_IfipIyJLEe6WZv922ZB9nw">
<behaviour href="minimal.datadictionary#_IkNiASIwEe6PiqL6n35dVA"/>
<property href="minimal.datadictionary#_B5G78CIwEe6PiqL6n35dVA"/>
</nodes>
<nodes xsi:type="dataflowdiagram:Store" id="_JQwqsiJLEe6WZv922ZB9nw">
<behaviour href="minimal.datadictionary#_IkNiASIwEe6PiqL6n35dVA"/>
<property href="minimal.datadictionary#_B5G78CIwEe6PiqL6n35dVA"/>
</nodes>
</dataflowdiagram:DataFlowDiagram>
135 changes: 135 additions & 0 deletions tests/mdpa.dfd.tests/src/mdpa/dfd/tests/MinimalTest.java
Original file line number Diff line number Diff line change
@@ -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();
}
}

}
19 changes: 0 additions & 19 deletions tests/output/changedModel.dataflowdiagrammodel

This file was deleted.

9 changes: 0 additions & 9 deletions tests/resources/MinimalBehaviourModel.behaviourmodel

This file was deleted.

19 changes: 0 additions & 19 deletions tests/resources/MinimalModel.dataflowdiagrammodel

This file was deleted.

Loading

0 comments on commit 6d5774c

Please sign in to comment.