|
@@ -19,11 +19,161 @@ def null_operation(model):
|
|
|
|
|
|
def model_is_empty_operation(model):
|
|
|
assert model is None
|
|
|
+
|
|
|
+def ops_manual_callback(model):
|
|
|
+ p1 = instantiate(model, "PetriNet_Runtime/Place")
|
|
|
+ p2 = instantiate(model, "PetriNet_Runtime/Place")
|
|
|
+ p3 = instantiate(model, "PetriNet_Runtime/Place")
|
|
|
+ t1 = instantiate(model, "PetriNet_Runtime/Transition")
|
|
|
+ p2t1 = instantiate(model, "PetriNet_Runtime/P2T", (p1, t1))
|
|
|
+ p2t2 = instantiate(model, "PetriNet_Runtime/P2T", (p2, t1))
|
|
|
+ t2p1 = instantiate(model, "PetriNet_Runtime/T2P", (t1, p3))
|
|
|
+ attr_assign(model, p1, "tokens", 1)
|
|
|
+ attr_assign(model, p1, "name", "p1")
|
|
|
+ attr_assign(model, p2, "tokens", 2)
|
|
|
+ attr_assign(model, p2, "name", "p2")
|
|
|
+ attr_assign(model, p3, "tokens", 3)
|
|
|
+ attr_assign(model, p3, "name", "p3")
|
|
|
+ attr_assign(model, t1, "name", "t1")
|
|
|
+ attr_assign(model, t1, "executing", False)
|
|
|
+ attr_assign(model, p2t1, "weight", 1)
|
|
|
+ attr_assign(model, p2t2, "weight", 1)
|
|
|
+ attr_assign(model, t2p1, "weight", 2)
|
|
|
+
|
|
|
+def pn_subfunc_callback_refine_PN(model):
|
|
|
+ p1 = instantiate(model, "PetriNet/Place")
|
|
|
+ attr_assign(model, p1, "name", "p1")
|
|
|
+ attr_assign(model, p1, "tokens", 1)
|
|
|
+
|
|
|
+ t1 = instantiate(model, "PetriNet/Transition")
|
|
|
+ attr_assign(model, t1, "name", "t1")
|
|
|
+
|
|
|
+ p2t = instantiate(model, "PetriNet/P2T", (p1, t1))
|
|
|
+ attr_assign(model, p2t, "weight", 1)
|
|
|
+
|
|
|
+def render_add_tracability(model):
|
|
|
+ instantiate(model, "Association", ("abstract/Block", "rendered/Group"), ID="TracabilityLink")
|
|
|
+
|
|
|
+def ops_add_tracability_D2R(model):
|
|
|
+ instantiate(model, "Association", ("PetriNet/Place", "PetriNet_Runtime/Place"), ID="D2R_PlaceLink")
|
|
|
+ instantiate(model, "Association", ("PetriNet/Transition", "PetriNet_Runtime/Transition"), ID="D2R_TransitionLink")
|
|
|
|
|
|
+def ops_add_tracability_R2D(model):
|
|
|
+ instantiate(model, "Association", ("PetriNet_Runtime/Place", "PetriNet/Place"), ID="R2D_PlaceLink")
|
|
|
+ instantiate(model, "Association", ("PetriNet_Runtime/Transition", "PetriNet/Transition"), ID="R2D_TransitionLink")
|
|
|
+
|
|
|
def operation_exec_1(model):
|
|
|
assert model is not None
|
|
|
assert [{"__id": "MODEL_A/__0", "__type": "MODEL_A/A", "name": None}] == element_list_nice(model)
|
|
|
instantiate(model, "MODEL_B/B")
|
|
|
+
|
|
|
+def operation_MAN_0(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
|
|
|
+
|
|
|
+def operation_MAN_1(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
|
|
|
+
|
|
|
+def operation_MT_0(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
|
|
|
+
|
|
|
+def operation_MT_1(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
|
|
|
+
|
|
|
+def operation_AL_0(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
|
|
|
+
|
|
|
+def operation_AL_1(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
|
|
|
|
|
|
model_hierarchy = \
|
|
|
{"formalisms/": {"SimpleClassDiagrams": {},
|
|
@@ -4065,45 +4215,8 @@ class TestModelverse(unittest.TestCase):
|
|
|
transformation_add_MANUAL({"MODEL_A": "users/user/test/A"}, {"MODEL_B": "users/user/test/B"}, "users/user/test/c")
|
|
|
|
|
|
# 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_MANUAL({"MODEL_A": "users/user/test/A"}, {"MODEL_B": "users/user/test/B"}, "users/user/test/d", 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_MANUAL({"MODEL_A": "users/user/test/A", "MODEL_B": "users/user/test/B"}, {"MODEL_B": "users/user/test/B"}, "users/user/test/e", operation)
|
|
|
+ transformation_add_MANUAL({"MODEL_A": "users/user/test/A"}, {"MODEL_B": "users/user/test/B"}, "users/user/test/d", operation_MAN_0)
|
|
|
+ transformation_add_MANUAL({"MODEL_A": "users/user/test/A", "MODEL_B": "users/user/test/B"}, {"MODEL_B": "users/user/test/B"}, "users/user/test/e", operation_MAN_1)
|
|
|
|
|
|
try:
|
|
|
transformation_add_MANUAL({"MODEL_A": "users/user/test/A", "MODEL_B": "users/user/test/B"}, {"MODEL_B": "users/user/test/A"}, "users/user/test/f")
|
|
@@ -4116,9 +4229,7 @@ class TestModelverse(unittest.TestCase):
|
|
|
|
|
|
# Add a transformation with empty signature and a callback
|
|
|
try:
|
|
|
- def operation(model):
|
|
|
- pass
|
|
|
- transformation_add_MANUAL({}, {}, "users/user/test/h", operation)
|
|
|
+ transformation_add_MANUAL({}, {}, "users/user/test/h", null_operation)
|
|
|
self.fail()
|
|
|
except CallbackOnEmptySignature:
|
|
|
assert "h" not in model_list("users/user/test")
|
|
@@ -4204,45 +4315,10 @@ class TestModelverse(unittest.TestCase):
|
|
|
transformation_add_AL({"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_AL({"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_AL({"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)
|
|
|
+
|
|
|
+ transformation_add_AL({"MODEL_A": "users/user/test/A"}, {"MODEL_B": "users/user/test/B"}, "users/user/test/d", default_function, operation_AL_0)
|
|
|
+ transformation_add_AL({"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_AL_1)
|
|
|
|
|
|
try:
|
|
|
transformation_add_AL({"MODEL_A": "users/user/test/A", "MODEL_B": "users/user/test/B"}, {"MODEL_B": "users/user/test/A"}, "users/user/test/f", default_function)
|
|
@@ -4255,9 +4331,7 @@ class TestModelverse(unittest.TestCase):
|
|
|
|
|
|
# Add a transformation with empty signature and a callback
|
|
|
try:
|
|
|
- def operation(model):
|
|
|
- pass
|
|
|
- transformation_add_AL({}, {}, "users/user/test/h", default_function, operation)
|
|
|
+ transformation_add_AL({}, {}, "users/user/test/h", default_function, null_operation)
|
|
|
self.fail()
|
|
|
except CallbackOnEmptySignature:
|
|
|
assert "h" not in model_list("users/user/test")
|
|
@@ -4350,45 +4424,10 @@ class TestModelverse(unittest.TestCase):
|
|
|
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"}, "users/user/test/d", default_function, operation_MT_0)
|
|
|
+
|
|
|
|
|
|
- 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)
|
|
|
+ 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_MT_1)
|
|
|
|
|
|
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)
|
|
@@ -4405,9 +4444,7 @@ class TestModelverse(unittest.TestCase):
|
|
|
|
|
|
# Add a transformation with empty signature and a callback
|
|
|
try:
|
|
|
- def operation(model):
|
|
|
- pass
|
|
|
- transformation_add_MT({}, {}, "users/user/test/h", default_function, operation)
|
|
|
+ transformation_add_MT({}, {}, "users/user/test/h", default_function, null_operation)
|
|
|
self.fail()
|
|
|
except CallbackOnEmptySignature:
|
|
|
assert "h" not in model_list("users/user/test")
|
|
@@ -5407,43 +5444,14 @@ class TestModelverse(unittest.TestCase):
|
|
|
def test_operations(self):
|
|
|
log = []
|
|
|
|
|
|
- def manual_callback(model):
|
|
|
- p1 = instantiate(model, "PetriNet_Runtime/Place")
|
|
|
- p2 = instantiate(model, "PetriNet_Runtime/Place")
|
|
|
- p3 = instantiate(model, "PetriNet_Runtime/Place")
|
|
|
- t1 = instantiate(model, "PetriNet_Runtime/Transition")
|
|
|
- p2t1 = instantiate(model, "PetriNet_Runtime/P2T", (p1, t1))
|
|
|
- p2t2 = instantiate(model, "PetriNet_Runtime/P2T", (p2, t1))
|
|
|
- t2p1 = instantiate(model, "PetriNet_Runtime/T2P", (t1, p3))
|
|
|
- attr_assign(model, p1, "tokens", 1)
|
|
|
- attr_assign(model, p1, "name", "p1")
|
|
|
- attr_assign(model, p2, "tokens", 2)
|
|
|
- attr_assign(model, p2, "name", "p2")
|
|
|
- attr_assign(model, p3, "tokens", 3)
|
|
|
- attr_assign(model, p3, "name", "p3")
|
|
|
- attr_assign(model, t1, "name", "t1")
|
|
|
- attr_assign(model, t1, "executing", False)
|
|
|
- attr_assign(model, p2t1, "weight", 1)
|
|
|
- attr_assign(model, p2t2, "weight", 1)
|
|
|
- attr_assign(model, t2p1, "weight", 2)
|
|
|
-
|
|
|
model_add("users/user/test/PetriNet", "formalisms/SimpleClassDiagrams", open("integration/code/pn_design.mvc", "r").read())
|
|
|
model_add("users/user/test/PetriNet_Runtime", "formalisms/SimpleClassDiagrams", open("integration/code/pn_runtime.mvc", "r").read())
|
|
|
-
|
|
|
model_add("users/user/test/my_pn", "users/user/test/PetriNet", open("integration/code/pn_design_model.mvc", "r").read())
|
|
|
|
|
|
- def add_tracability_D2R(model):
|
|
|
- instantiate(model, "Association", ("PetriNet/Place", "PetriNet_Runtime/Place"), ID="D2R_PlaceLink")
|
|
|
- instantiate(model, "Association", ("PetriNet/Transition", "PetriNet_Runtime/Transition"), ID="D2R_TransitionLink")
|
|
|
-
|
|
|
- def add_tracability_R2D(model):
|
|
|
- instantiate(model, "Association", ("PetriNet_Runtime/Place", "PetriNet/Place"), ID="R2D_PlaceLink")
|
|
|
- instantiate(model, "Association", ("PetriNet_Runtime/Transition", "PetriNet/Transition"), ID="R2D_TransitionLink")
|
|
|
-
|
|
|
transformation_add_MT({"PetriNet": "users/user/test/PetriNet"}, {}, "users/user/test/print_pn", open("integration/code/pn_print.mvc").read())
|
|
|
- transformation_add_MANUAL({"PetriNet": "users/user/test/PetriNet"}, {"PetriNet_Runtime": "users/user/test/PetriNet_Runtime"}, "users/user/test/pn_design_to_runtime", add_tracability_D2R)
|
|
|
+ transformation_add_MANUAL({"PetriNet": "users/user/test/PetriNet"}, {"PetriNet_Runtime": "users/user/test/PetriNet_Runtime"}, "users/user/test/pn_design_to_runtime", ops_add_tracability_D2R)
|
|
|
transformation_add_AL({"PetriNet_Runtime": "users/user/test/PetriNet_Runtime"}, {"PetriNet_Runtime": "users/user/test/PetriNet_Runtime"}, "users/user/test/pn_simulate", open("integration/code/pn_simulate.alc").read())
|
|
|
- transformation_add_MT({"PetriNet_Runtime": "users/user/test/PetriNet_Runtime"}, {"PetriNet": "users/user/test/PetriNet"}, "users/user/test/pn_runtime_to_design", open("integration/code/pn_runtime_to_design.mvc").read(), add_tracability_R2D)
|
|
|
+ transformation_add_MT({"PetriNet_Runtime": "users/user/test/PetriNet_Runtime"}, {"PetriNet": "users/user/test/PetriNet"}, "users/user/test/pn_runtime_to_design", open("integration/code/pn_runtime_to_design.mvc").read(), ops_add_tracability_R2D)
|
|
|
|
|
|
log = []
|
|
|
ctrl = log_output.Controller(log, keep_running=False)
|
|
@@ -5457,7 +5465,7 @@ class TestModelverse(unittest.TestCase):
|
|
|
'"p2" --> 2',
|
|
|
'"p3" --> 3'])
|
|
|
|
|
|
- assert transformation_execute_MANUAL("users/user/test/pn_design_to_runtime", {"PetriNet": "users/user/test/my_pn"}, {"PetriNet_Runtime": "users/user/test/my_pn_RT"}, manual_callback) == True
|
|
|
+ assert transformation_execute_MANUAL("users/user/test/pn_design_to_runtime", {"PetriNet": "users/user/test/my_pn"}, {"PetriNet_Runtime": "users/user/test/my_pn_RT"}, ops_manual_callback) == True
|
|
|
assert transformation_execute_AL("users/user/test/pn_simulate", {"PetriNet_Runtime": "users/user/test/my_pn_RT"}, {"PetriNet_Runtime": "users/user/test/my_pn_RT"}) == True
|
|
|
assert transformation_execute_MT("users/user/test/pn_runtime_to_design", {"PetriNet_Runtime": "users/user/test/my_pn_RT"}, {"PetriNet": "users/user/test/my_pn"}) == True
|
|
|
|
|
@@ -5482,16 +5490,6 @@ class TestModelverse(unittest.TestCase):
|
|
|
transformation_add_AL({"PetriNet": "users/user/test/PetriNet"}, {"ReachabilityGraph": "users/user/test/ReachabilityGraph"}, "users/user/test/reachability", open("integration/code/reachability_subfunction.alc", "r").read())
|
|
|
transformation_add_MT({"ReachabilityGraph": "users/user/test/ReachabilityGraph"}, {}, "users/user/test/reachability_print", open("integration/code/reachabilitygraph_print.mvc", 'r').read())
|
|
|
|
|
|
- def callback_refine_PN(model):
|
|
|
- p1 = instantiate(model, "PetriNet/Place")
|
|
|
- attr_assign(model, p1, "name", "p1")
|
|
|
- attr_assign(model, p1, "tokens", 1)
|
|
|
-
|
|
|
- t1 = instantiate(model, "PetriNet/Transition")
|
|
|
- attr_assign(model, t1, "name", "t1")
|
|
|
-
|
|
|
- p2t = instantiate(model, "PetriNet/P2T", (p1, t1))
|
|
|
- attr_assign(model, p2t, "weight", 1)
|
|
|
|
|
|
log = []
|
|
|
ctrl = log_output.Controller(log, keep_running=False)
|
|
@@ -5499,7 +5497,7 @@ class TestModelverse(unittest.TestCase):
|
|
|
thrd.daemon = True
|
|
|
thrd.start()
|
|
|
|
|
|
- process_execute("users/user/test/pn_reachability", {}, {"users/user/test/refine_PN": callback_refine_PN, "users/user/test/reachability_print": (ctrl, "inp", "outp")})
|
|
|
+ process_execute("users/user/test/pn_reachability", {}, {"users/user/test/refine_PN": pn_subfunc_callback_refine_PN, "users/user/test/reachability_print": (ctrl, "inp", "outp")})
|
|
|
thrd.join()
|
|
|
|
|
|
assert set(log) == set(['"0": {"p1": 1}',
|
|
@@ -5511,10 +5509,7 @@ class TestModelverse(unittest.TestCase):
|
|
|
model_add("users/user/test/MM_rendered_graphical", "formalisms/SimpleClassDiagrams", open("integration/code/MM_rendered_graphical.mvc", 'r').read())
|
|
|
model_add("users/user/test/my_CBD", "users/user/test/CausalBlockDiagrams", open("integration/code/my_cbd.mvc", 'r').read())
|
|
|
|
|
|
- def add_tracability(model):
|
|
|
- instantiate(model, "Association", ("abstract/Block", "rendered/Group"), ID="TracabilityLink")
|
|
|
-
|
|
|
- transformation_add_MT({"abstract": "users/user/test/CausalBlockDiagrams", "rendered": "users/user/test/MM_rendered_graphical"}, {"abstract": "users/user/test/CausalBlockDiagrams", "rendered": "users/user/test/MM_rendered_graphical"}, "users/user/test/render_graphical_CBD", open("integration/code/CBD_mapper.mvc", 'r').read(), add_tracability)
|
|
|
+ transformation_add_MT({"abstract": "users/user/test/CausalBlockDiagrams", "rendered": "users/user/test/MM_rendered_graphical"}, {"abstract": "users/user/test/CausalBlockDiagrams", "rendered": "users/user/test/MM_rendered_graphical"}, "users/user/test/render_graphical_CBD", open("integration/code/CBD_mapper.mvc", 'r').read(), render_add_tracability)
|
|
|
result = model_render("users/user/test/my_CBD", "users/user/test/render_graphical_CBD", "users/user/test/my_perceptualized_CBD")
|
|
|
|
|
|
assert len(result) == 23
|