-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add MinimalTest checking Element superclasses
- Loading branch information
1 parent
c4bc67d
commit 6d5774c
Showing
24 changed files
with
666 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
414 changes: 414 additions & 0 deletions
414
bundles/mdpa.dfd.dataflowdiagram/model/dataflowdiagram.aird
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
File renamed without changes.
1 change: 1 addition & 0 deletions
1
tests/.settings/org.eclipse.jdt.core.prefs → ...ests/.settings/org.eclipse.jdt.core.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
135
tests/mdpa.dfd.tests/src/mdpa/dfd/tests/MinimalTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.