|
@@ -4043,11 +4043,144 @@ class TestModelverse(unittest.TestCase):
|
|
|
except ModelExists:
|
|
|
assert sig == transformation_signature("users/user/test/c")
|
|
|
|
|
|
+ def test_op_transformation_add_MT(self):
|
|
|
+ # Add models for transformation
|
|
|
+ model_add("users/user/test/A", "formalisms/SimpleClassDiagrams", """
|
|
|
+ SimpleAttribute String {}
|
|
|
+ Class A {
|
|
|
+ name = "A"
|
|
|
+ name : String
|
|
|
+ }
|
|
|
+ """)
|
|
|
+ model_add("users/user/test/B", "formalisms/SimpleClassDiagrams", """
|
|
|
+ SimpleAttribute String {}
|
|
|
+ Class B {
|
|
|
+ name = "B"
|
|
|
+ name : String
|
|
|
+ }
|
|
|
+ """)
|
|
|
+ model_add("users/user/test/a", "users/user/test/A", "A {}")
|
|
|
+ model_add("users/user/test/b", "users/user/test/B", "B {}")
|
|
|
+
|
|
|
+ default_function = "Composite c{}"
|
|
|
+
|
|
|
+ # Add a transformation with normal signature
|
|
|
+ transformation_add_MT({"MODEL_A": "users/user/test/A"}, {"MODEL_B": "users/user/test/B"}, "users/user/test/c", default_function)
|
|
|
+
|
|
|
+ # Add a transformation with normal signature and merged metamodel changes
|
|
|
+ def operation(model):
|
|
|
+ # Check if both are present
|
|
|
+ lst = element_list_nice(model)
|
|
|
+ assert len(lst) == 6
|
|
|
+ assert {"__id": "MODEL_A/String", "__type": "SimpleAttribute", "name": None, "constraint": {"AL": ""}} in lst
|
|
|
+ assert {"__id": "MODEL_A/A", "__type": "Class", "name": "A", "lower_cardinality": None, "upper_cardinality": None, "abstract": None, "constraint": {"AL": ""}} in lst
|
|
|
+ assert {"__id": "MODEL_A/A_name", "__type": "AttributeLink", "__source": "MODEL_A/A", "__target": "MODEL_A/String", "name": "name", "optional": False, "constraint": {"AL": ""}} in lst
|
|
|
+ assert {"__id": "MODEL_B/String", "__type": "SimpleAttribute", "name": None, "constraint": {"AL": ""}} in lst
|
|
|
+ assert {"__id": "MODEL_B/B", "__type": "Class", "name": "B", "lower_cardinality": None, "upper_cardinality": None, "abstract": None, "constraint": {"AL": ""}} in lst
|
|
|
+ assert {"__id": "MODEL_B/B_name", "__type": "AttributeLink", "__source": "MODEL_B/B", "__target": "MODEL_B/String", "name": "name", "optional": False, "constraint": {"AL": ""}} in lst
|
|
|
+
|
|
|
+ # Do minor merge operation
|
|
|
+ instantiate(model, "Association", edge=("MODEL_A/A", "MODEL_B/B"), ID="trace")
|
|
|
+
|
|
|
+ # Check again
|
|
|
+ lst = element_list_nice(model)
|
|
|
+ assert len(lst) == 7
|
|
|
+ assert {"__id": "MODEL_A/String", "__type": "SimpleAttribute", "name": None, "constraint": {"AL": ""}} in lst
|
|
|
+ assert {"__id": "MODEL_A/A", "__type": "Class", "name": "A", "lower_cardinality": None, "upper_cardinality": None, "abstract": None, "constraint": {"AL": ""}} in lst
|
|
|
+ assert {"__id": "MODEL_A/A_name", "__type": "AttributeLink", "__source": "MODEL_A/A", "__target": "MODEL_A/String", "name": "name", "optional": False, "constraint": {"AL": ""}} in lst
|
|
|
+ assert {"__id": "MODEL_B/String", "__type": "SimpleAttribute", "name": None, "constraint": {"AL": ""}} in lst
|
|
|
+ assert {"__id": "MODEL_B/B", "__type": "Class", "name": "B", "lower_cardinality": None, "upper_cardinality": None, "abstract": None, "constraint": {"AL": ""}} in lst
|
|
|
+ assert {"__id": "MODEL_B/B_name", "__type": "AttributeLink", "__source": "MODEL_B/B", "__target": "MODEL_B/String", "name": "name", "optional": False, "constraint": {"AL": ""}} in lst
|
|
|
+ assert {"__id": "trace", "__type": "Association", "__source": "MODEL_A/A", "__target": "MODEL_B/B", "name": None, "source_lower_cardinality": None, "source_upper_cardinality": None, "target_lower_cardinality": None, "target_upper_cardinality": None, "abstract": None, "constraint": {"AL": ""}, "lower_cardinality": None, "upper_cardinality": None} in lst
|
|
|
+
|
|
|
+ transformation_add_MT({"MODEL_A": "users/user/test/A"}, {"MODEL_B": "users/user/test/B"}, "users/user/test/d", default_function, operation)
|
|
|
+
|
|
|
+ def operation(model):
|
|
|
+ # Check if both are present
|
|
|
+ lst = element_list_nice(model)
|
|
|
+ assert len(lst) == 6
|
|
|
+ assert {"__id": "MODEL_A/String", "__type": "SimpleAttribute", "name": None, "constraint": {"AL": ""}} in lst
|
|
|
+ assert {"__id": "MODEL_A/A", "__type": "Class", "name": "A", "lower_cardinality": None, "upper_cardinality": None, "abstract": None, "constraint": {"AL": ""}} in lst
|
|
|
+ assert {"__id": "MODEL_A/A_name", "__type": "AttributeLink", "__source": "MODEL_A/A", "__target": "MODEL_A/String", "name": "name", "optional": False, "constraint": {"AL": ""}} in lst
|
|
|
+ assert {"__id": "MODEL_B/String", "__type": "SimpleAttribute", "name": None, "constraint": {"AL": ""}} in lst
|
|
|
+ assert {"__id": "MODEL_B/B", "__type": "Class", "name": "B", "lower_cardinality": None, "upper_cardinality": None, "abstract": None, "constraint": {"AL": ""}} in lst
|
|
|
+ assert {"__id": "MODEL_B/B_name", "__type": "AttributeLink", "__source": "MODEL_B/B", "__target": "MODEL_B/String", "name": "name", "optional": False, "constraint": {"AL": ""}} in lst
|
|
|
+
|
|
|
+ transformation_add_MT({"MODEL_A": "users/user/test/A", "MODEL_B": "users/user/test/B"}, {"MODEL_B": "users/user/test/B"}, "users/user/test/e", default_function, operation)
|
|
|
+
|
|
|
+ try:
|
|
|
+ transformation_add_MT({"MODEL_A": "users/user/test/A", "MODEL_B": "users/user/test/B"}, {"MODEL_B": "users/user/test/A"}, "users/user/test/f", default_function)
|
|
|
+ self.fail()
|
|
|
+ except SignatureMismatch:
|
|
|
+ pass
|
|
|
+
|
|
|
+ # Add a transformation with empty signature
|
|
|
+ try:
|
|
|
+ transformation_add_MT({}, {}, "users/user/test/g", default_function)
|
|
|
+ self.fail()
|
|
|
+ except EmptySignature:
|
|
|
+ assert "g" not in model_list("users/user/test")
|
|
|
+
|
|
|
+ # Add a transformation with empty signature and a callback
|
|
|
+ try:
|
|
|
+ def operation(model):
|
|
|
+ pass
|
|
|
+ transformation_add_MT({}, {}, "users/user/test/h", default_function, operation)
|
|
|
+ self.fail()
|
|
|
+ except CallbackOnEmptySignature:
|
|
|
+ assert "h" not in model_list("users/user/test")
|
|
|
+
|
|
|
+ # Add transformation with unknown metamodel in signature (input)
|
|
|
+ try:
|
|
|
+ transformation_add_MT({"MODEL_A": "adbdsf"}, {"MODEL_B": "users/user/test/A"}, "users/user/test/i", default_function)
|
|
|
+ self.fail()
|
|
|
+ except UnknownModel:
|
|
|
+ assert "i" not in model_list("users/user/test")
|
|
|
+
|
|
|
+ # Add transformation with unknown metamodel in signature (output)
|
|
|
+ try:
|
|
|
+ transformation_add_MT({"MODEL_A": "users/user/test/A"}, {"MODEL_B": "adfad"}, "users/user/test/j", default_function)
|
|
|
+ self.fail()
|
|
|
+ except UnknownModel:
|
|
|
+ assert "j" not in model_list("users/user/test")
|
|
|
+
|
|
|
+ # Add transformation with unreadable metamodel in signature (input)
|
|
|
+ try:
|
|
|
+ transformation_add_MT({"MODEL_A": "administration/core"}, {"MODEL_B": "users/user/test/B"}, "users/user/test/k", default_function)
|
|
|
+ self.fail()
|
|
|
+ except ReadPermissionDenied:
|
|
|
+ assert "k" not in model_list("users/user/test")
|
|
|
+
|
|
|
+ # Add transformation with unreadable metamodel in signature (output)
|
|
|
+ try:
|
|
|
+ transformation_add_MT({"MODEL_A": "users/user/test/A"}, {"MODEL_B": "administration/core"}, "users/user/test/l", default_function)
|
|
|
+ self.fail()
|
|
|
+ except ReadPermissionDenied:
|
|
|
+ assert "l" not in model_list("users/user/test")
|
|
|
+
|
|
|
+ # Try to use a non-RAMifiable metamodel in input
|
|
|
+ try:
|
|
|
+ transformation_add_MT({"MODEL_A": "users/user/test/a"}, {}, "users/user/test/m", default_function)
|
|
|
+ self.fail()
|
|
|
+ except UnknownM3:
|
|
|
+ assert "m" not in model_list("users/user/test")
|
|
|
+
|
|
|
+ # Try to use a non-RAMifiable metamodel in output
|
|
|
+ try:
|
|
|
+ transformation_add_MT({}, {"MODEL_A": "users/user/test/a"}, "users/user/test/n", default_function)
|
|
|
+ self.fail()
|
|
|
+ except UnknownM3:
|
|
|
+ assert "n" not in model_list("users/user/test")
|
|
|
+
|
|
|
+ # Try to create activity that already exists
|
|
|
+ sig = transformation_signature("users/user/test/c")
|
|
|
+ try:
|
|
|
+ transformation_add_MT({}, {}, "users/user/test/c", default_function)
|
|
|
+ except ModelExists:
|
|
|
+ assert sig == transformation_signature("users/user/test/c")
|
|
|
+
|
|
|
"""
|
|
|
def test_op_model_render(self):
|
|
|
- def test_op_transformation_add_MT(self):
|
|
|
- def test_op_transformation_add_AL(self):
|
|
|
- def test_op_transformation_add_MANUAL(self):
|
|
|
def test_op_transformation_execute_MT(self):
|
|
|
def test_op_transformation_execute_AL(self):
|
|
|
def test_op_transformation_execute_MANUAL(self):
|