Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2015-07-23 03:18:27 -0400
committerChristian W. Damus2015-08-12 10:57:45 -0400
commit5b46f47b24f3afd8218cabf1834c850abbc51773 (patch)
treedffa5e4c3911596324489c7487ee6e094f6ab7b9 /tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/gmfgenuml2utp/CreateFromPaletteChildLabelNodesTest.xtend
parent2a3e6fb0e0cedaae9111a95e38591623cc990fc5 (diff)
downloadorg.eclipse.papyrus-5b46f47b24f3afd8218cabf1834c850abbc51773.tar.gz
org.eclipse.papyrus-5b46f47b24f3afd8218cabf1834c850abbc51773.tar.xz
org.eclipse.papyrus-5b46f47b24f3afd8218cabf1834c850abbc51773.zip
Bug 464647: [Tests] Generate JUnit tests for diagram view synch
https://bugs.eclipse.org/bugs/show_bug.cgi?id=464647 Adaptation of initial prototype of a Papyrus Tests Generation framework to add diagram synchronization tests. Changes by Christian W. Damus <give.a.damus@gmail.com>: Rebase onto latest Mars maintenance branch. Fix .ignores: ensure that only contents of xtend-gen/ folders are ignored, not the folders themselves Convert Xtend codegen templates to UTF-8 encoding Update the QVTo transformation to support the statically generated UTP profile. This requires: - invoking the UMLResourcesUtil API for stand-alone set-up - updating the profile-registration workflow component to support the registration of a statically generated profile - updating the QVTo transformation to ensure that applicable stereotypes are resolved in the proper ResourceSet context to avoid losing all applied stereotypes in the generated test model. This, in turn, requires a Java black box to handle the EMF-specific concerns of resource-set context that QVTo is not aware of Fix build.properties files to include all sources and POMs to generate sources in xtend-gen/ folder. Fix compilation problems in the integration of the generated tests into the master suite bundle. Update the Tycho build to include the test generation framework bundle. Update the build and Oomph setup to include the UPR profile bundle dependency and the Papyrus Developer tools dependency. Fix numerous codegen problems: - base model does not reflect correct package name for palette tests - inject replaceable templates instead of making them all static - add generation of import statements in suites - fix references to test constants interface - fix references to diagram creation command Fix remaining compilation errors in Use Case tests: - look up the DiagramUpdater class to compute correct import - factor out creation of generated files into an utility extension - factor out generation of the copyright header comment - add some imports to templates that were missing them Refactor Xtend codegen templates to: - improve management of imports - improve names of AllXyzTestsGen suite classes - don't generate test classes that have no test cases - share common code to simplify the specific test case templates Fix more code generation problems: * missing package imports for required edit-part classes * invalid package imports (non-existent edit-part classes) * non-conformant names of diagram creation command and test constants interface. This introduces new attributes to test classes in the model, of String type, specifying the relevant type names. The defaults are computed by the QVTo transformation but may be overridden (hard-coded) by a diagram test's bundle's specific QVTo to provide custom names Add generated tests for Communication Diagram. Fixed workflow infrastructure to support all-tests generation. Use URI mappings to eliminate the need to copy and delete the framework's QVTo files. Add an infrastructure for generation of diagram synchronization tests. This includes * new abstract test classes in the oep.uml.diagram.tests bundle * updates to the framework UML model to capture the new base test classes * new QVTo transformation to generate synchronization tests in the UTP model * new Xtend template to generate synchronization tests from the UTP Fixed various small problems: * unwanted newlines in some test method bodies * fully-qualified references to UMLTypes class in synchronization tests * missing commas in QVTo scripts that cause edit-part names to be concatenated * (a biggie, actually) fix the all-tests generation to avoid repeating all previous transformations at each step Translate QVTo transformation steps to Xtend: Xtend exposes list values in UML models in their native EList terms, which affords stable and predictable ordering of transformation operations and, hence, test model structure and generated code. It also provides for more concise, debuggable, searchable, and performant transformations with better Java integration. Assign predictable, stable XMI identifiers to elements of generated UML models to avoid unnecessary diffs in source control when re-generating. Regenerate code from the Xtend version of the framework. Git-ignore the generated UTP source models because they reference and depend on UML instance models of the GMFGens that are already git-ignored, so there's no point in having these in git. Besides that they are now much larger because of the generated unique XMI IDs. Develop a DSL for compact and readable declarations of transformation rules for test contexts and assembly into packages. This uses new active annotations which, owing to a logistical limitation of Xtend, must be defined in a new separate plug-in project. Finally! Fixed the generation of the wrong diagram-updater instance field reference for Sequence Diagram, which as a legacy diagram still uses TYPED_INSTANCE. This employs a class-file scanning hack that is potentially expensive in I/O, so it uses a new @Cached active annotation that caches method computation results. Complete the specification of generation of view synchronization tests, adding the following scenarios: * synchronize child label nodes in label compartments of top shapes * synchronize child shape nodes in shape compartments of top shapes * synchronize connections between shapes * synchronize connections between shapes where the source owns the semantic link Define a new ClassificationSuite JUnit test runner that supports filtering entire suites by classification annotations. Apply this runner with the @GeneratedTest annotation to all generated test-suite classes. Refine the generation of link creation and synchronization tests to test links only between edit-parts that the GMFGen model reports as valid sources and targets for the links. This vastly reduces the number of invalid test cases generated for elements that cannot be linked (such as Include between an Actor and a Package). Integrate code generation into the build (both maven build and Eclipse workspace) and suppress generated sources from source control. This is implemented as a build profile in a new parent POM for the UML Diagram Tests bundles. Further elaboration and fixes: * rename 'edition' tests as DirectEdit in generated tests (not yet in the framework) * use a generic name for the test class for top node creation from palette * fix test cases for creation of links in containers to actually create the source and target elements in such container * fix the ClassificationConfig to drill into test suites to look for further filtering annotations instead of assuming that the entire suite is a 'standard' test when the 'standard' tests are excluded by the requested configuration * split test cases that execute multiple test scenarios into separate test case methods per test scenario. This ensures that a single test failure doesn't hide several other test results * move @GeneratedTest annotation from test case method to the test context class to reduce overhead of annotations in the VM * use the GMFGen model's information about child node containment to avoid generating all permutations of top-node/child-node, eliminating most of the the invalid child-node creation tests * fix broken references to the UML model for the Ecore metamodel in UML models for the gmfgen and genmodel metamodels by redirecting them to the UML2-provided Ecore metamodel. Delete the obsolete local ecore.uml * define a model of test exceptions for the purpose of constraining the generation of the UML-UTP model to exclude unwanted permutations of edit parts, optionally for specific kinds of tests * enhance the UML-UTP test model generation to filter the tests that it would generate through the optionally provided test exceptions models * add a test exclusions model to the Use Case test bundle to exclude tests for package-import relationships on classifiers (which UML supports but the diagram does not) * generate a CSS stylesheet (attached via an annotation on the test context class) to enable synchronization of the diagrams for tests * fix generation of invalid child-node permutations in the synchronization tests by using the compartment container information in the GMFGen model * fix various bugs in the abstract test framework operations found by running the generated tests Further refinement and fixes: * add some more flexibility to test exceptions model and utilize it for exclusion of some more Class Diagram tests that don't make sense or cannot be generated like the rest * simplify the generation of synchronization tests, removing the specialized M2T templates * fix the deletion tests that failed because the edit-part to be deleted was not selected * fix the tests dealing with child label nodes in nodes that are themselves child nodes by ensuring proper creation of a top-level node to contain the nested node that has the label children * fix abstract appearance test cases, resolving a large proportion of test failures * further simplification of the M2T templates based on structure of the UTP model * don't just not generate excluded tests, but apply the @FailingTest, @NotImplemented, and @Ignore annotations as appropriate to the reason for the test exclusion * now that the UTP model is not managed in source control, it can use generated XMI IDs to save some space (the computed unique IDs were long, based on qualified names) * add another kind of test exception that blanket excludes an edit-part from all tests * add support for completely omitting test cases from the generated code (instead of just annotating them), e.g. for cases where the generated code would not even compile * create a DSL embedded in the transformation workflow for definition of test exceptions, as a convenient and integrated alternative to the test-exceptions model * add default calculation of edit-parts-to-test lists for all kinds of tests, to stream-line the workflow model. Employ this with the new test-exceptions DSL in the Use Case Diagram tests generation workflow as an example of how it all works * further streamlining of the test exceptions DSL with an active annotation generating constants for the reason kinds and multiplicative nesting of edit-part blocks in forbidden permutation rules * adopt the test exceptions DSL in the Class Diagram tests * support injection of custom GMFGen-to-UTP transformation rules * customize the link creation tests in the Class Diagram to fix association link failures caused by odd default name that associations get in the test environment * automatically compute imports for all edit-part classes actually required by the tests, based on the references to edit-parts in the generated activities, to avoid unused import warnings for edit-part classes that would only have been used by tests that were excluded * fix some problems in behavior diagram tests that failed on attempting to create the top container frame (behavior) that was already implicitly created by creation of the diagram * update abstract synchronization tests to take advantage of diagram editor sharing (cherry-picked from streams/1.1-maintenance Id627299a0b28614877cba0e372d980c6bf3ec675) Signed-off-by: jcadavid <juan.cadavid@cea.fr> Signed-off-by: Christian W. Damus <give.a.damus@gmail.com> Change-Id: I59cc3d621889f0caeff78acd6c0eb07c7479268f
Diffstat (limited to 'tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/gmfgenuml2utp/CreateFromPaletteChildLabelNodesTest.xtend')
-rw-r--r--tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/gmfgenuml2utp/CreateFromPaletteChildLabelNodesTest.xtend80
1 files changed, 80 insertions, 0 deletions
diff --git a/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/gmfgenuml2utp/CreateFromPaletteChildLabelNodesTest.xtend b/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/gmfgenuml2utp/CreateFromPaletteChildLabelNodesTest.xtend
new file mode 100644
index 00000000000..f25621cdcf3
--- /dev/null
+++ b/tests/framework/org.eclipse.papyrus.tests.framework/src/org/eclipse/papyrus/tests/framework/gmfgenuml2utp/CreateFromPaletteChildLabelNodesTest.xtend
@@ -0,0 +1,80 @@
+/*****************************************************************************
+ * Copyright (c) 2014, 2015 CEA LIST, Christian W. Damus, and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ * Christian W. Damus - adapted from QVTo
+ * Christian W. Damus - bug 464647
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.tests.framework.gmfgenuml2utp
+
+import com.google.inject.Inject
+import org.eclipse.papyrus.tests.framework.m2m.Metamodels
+import org.eclipse.uml2.uml.InstanceSpecification
+import org.eclipse.uml2.uml.UMLFactory
+
+/**
+ * Mapping of UML instance specifications for GMFGen model elements to child label palette tests in the UTP test model.
+ */
+class CreateFromPaletteChildLabelNodesTest {
+ static extension UMLFactory = UMLFactory.eINSTANCE
+
+ @Inject extension Metamodels
+ @Inject extension TransformationUtilities
+
+ protected def getContainerCompartmentNames(InstanceSpecification node) {
+ node.containerCompartments.map[editPart]
+ }
+
+ protected def getParentNodeNames(InstanceSpecification node) {
+ node.parentNodes.map[editPart]
+ }
+
+ protected def toCallTestChildLabelNodeOperationActivity(InstanceSpecification labelEditPart,
+ InstanceSpecification compartmentEditPart, InstanceSpecification parentNodeEditPart) {
+
+ createActivity => [
+ name = labelEditPart.editPart.replace('EditPart', '').toFirstLower
+
+ ownedNodes += createCallOperationAction => [
+ name = 'ChildLabelTestNodeActivity_' + parentNodeEditPart.name + '_' + labelEditPart.name + '_' + compartmentEditPart.name
+ operation = frameworkClass('AbstractCreateChildLabelNodeFromPaletteTest').allOperations.head
+ arguments += #[
+ parentNodeEditPart.toValuePin('parentNode'),
+ labelEditPart.toValuePin('childNode'),
+ compartmentEditPart.toIntegerValuePin('compartment'),
+ true.toValuePin('mustPass')
+ ]
+ ]
+ ]
+ }
+
+ protected def toCallTestChildLabelNodeOperationActivity(InstanceSpecification labelEditPart,
+ InstanceSpecification compartmentEditPart, InstanceSpecification nestedNodeEditPart,
+ InstanceSpecification topNodeCompartmentEditPart, InstanceSpecification topNodeEditPart) {
+
+ createActivity => [
+ name = labelEditPart.editPart.replace('EditPart', '').toFirstLower
+
+ ownedNodes += createCallOperationAction => [
+ name = 'ChildLabelTestNodeActivity_' + nestedNodeEditPart.name + '_' + labelEditPart.name + '_' + compartmentEditPart.name
+ operation = frameworkClass('AbstractCreateChildLabelNodeFromPaletteTest').allOperations.head
+ arguments += #[
+ topNodeEditPart.toValuePin('topNode'),
+ topNodeCompartmentEditPart.toIntegerValuePin('topNodeCompartment'),
+ nestedNodeEditPart.toValuePin('parentNode'),
+ labelEditPart.toValuePin('childNode'),
+ compartmentEditPart.toIntegerValuePin('compartment'),
+ true.toValuePin('mustPass')
+ ]
+ ]
+ ]
+ }
+}

Back to the top