|
@@ -23,14 +23,12 @@ expected_model_full_list = set([("SimpleClassDiagrams", "SimpleClassDiagrams", "
|
|
|
("core", "CoreFormalism", "admin", "admin", "200")])
|
|
|
|
|
|
class TestModelverseCore(unittest.TestCase):
|
|
|
- @classmethod
|
|
|
- def setup_class(self):
|
|
|
+ def setUp(self):
|
|
|
self.proc, self.address = start_mvc()
|
|
|
init(self.address)
|
|
|
login("admin", "admin")
|
|
|
|
|
|
- @classmethod
|
|
|
- def teardown_class(self):
|
|
|
+ def tearDown(self):
|
|
|
kill(self.proc)
|
|
|
|
|
|
def test_list(self):
|
|
@@ -269,255 +267,36 @@ class TestModelverseCore(unittest.TestCase):
|
|
|
'"p3" --> 5'])
|
|
|
|
|
|
def test_process_model_trivial_pn(self):
|
|
|
- self.assertTrue(run_file(all_files,
|
|
|
- [ "admin", "admin", "admin",
|
|
|
- "model_add",
|
|
|
- "SimpleClassDiagrams",
|
|
|
- "PetriNet",
|
|
|
- ] + get_model_constructor(open("integration/code/pn_design.mvc", "r").read()) + [
|
|
|
- "model_add",
|
|
|
- "SimpleClassDiagrams",
|
|
|
- "ReachabilityGraph",
|
|
|
- ] + get_model_constructor(open("integration/code/reachability_graph.mvc", "r").read()) + [
|
|
|
- "model_list",
|
|
|
- "transformation_add_MT_language",
|
|
|
- "PetriNet",
|
|
|
- "",
|
|
|
- "PetriNet_RAM",
|
|
|
- "transformation_add_MT_language",
|
|
|
- "ReachabilityGraph",
|
|
|
- "",
|
|
|
- "ReachabilityGraph_RAM",
|
|
|
- "transformation_add_MT",
|
|
|
- "PetriNet_RAM",
|
|
|
- "",
|
|
|
- "PetriNet",
|
|
|
- "",
|
|
|
- "initialize_PN",
|
|
|
- ] + get_model_constructor(open("integration/code/initialize_PN.mvc", "r").read()) + [
|
|
|
- "transformation_add_MANUAL",
|
|
|
- "PetriNet",
|
|
|
- "",
|
|
|
- "PetriNet",
|
|
|
- "",
|
|
|
- "refine_PN",
|
|
|
- "transformation_add_AL",
|
|
|
- "PetriNet",
|
|
|
- "",
|
|
|
- "ReachabilityGraph",
|
|
|
- "",
|
|
|
- "reachability",
|
|
|
- ] + get_constructor(open("integration/code/reachability.alc", "r").read()) + [
|
|
|
- "transformation_add_MT",
|
|
|
- "ReachabilityGraph_RAM",
|
|
|
- "ReachabilityGraph",
|
|
|
- "",
|
|
|
- "",
|
|
|
- "reachability_print",
|
|
|
- ] + get_model_constructor(open("integration/code/reachabilitygraph_print.mvc", "r").read()) + [
|
|
|
- "model_add",
|
|
|
- "ProcessModel",
|
|
|
- "pn_reachability",
|
|
|
- ] + get_model_constructor(open("integration/code/pm_pn_reachability.mvc", "r").read()) + [
|
|
|
- "model_list",
|
|
|
- "process_execute",
|
|
|
- "pn_reachability",
|
|
|
- "my_",
|
|
|
- "instantiate",
|
|
|
- "PetriNet/Place",
|
|
|
- "p1",
|
|
|
- "attr_add",
|
|
|
- "p1",
|
|
|
- "name",
|
|
|
- "p1",
|
|
|
- "attr_add",
|
|
|
- "p1",
|
|
|
- "tokens",
|
|
|
- 1,
|
|
|
- "instantiate",
|
|
|
- "PetriNet/Transition",
|
|
|
- "t1",
|
|
|
- "attr_add",
|
|
|
- "t1",
|
|
|
- "name",
|
|
|
- "t1",
|
|
|
- "instantiate",
|
|
|
- "PetriNet/P2T",
|
|
|
- "p2t",
|
|
|
- "p1",
|
|
|
- "t1",
|
|
|
- "attr_add",
|
|
|
- "p2t",
|
|
|
- "weight",
|
|
|
- 1,
|
|
|
- "exit",
|
|
|
- "model_list",
|
|
|
- ],
|
|
|
- [ # bootup phase
|
|
|
- "Desired username for admin user?",
|
|
|
- "Desired password for admin user?",
|
|
|
- "Please repeat the password",
|
|
|
- "Passwords match!",
|
|
|
- "Welcome to the Model Management Interface v2.0!",
|
|
|
- "Use the 'help' command for a list of possible commands",
|
|
|
- "Ready for command...",
|
|
|
- # model_add
|
|
|
- "Creating new model!",
|
|
|
- "Model type?",
|
|
|
- "Model name?",
|
|
|
- "Waiting for model constructors...",
|
|
|
- "Model upload success!",
|
|
|
- "Ready for command...",
|
|
|
- # model_add
|
|
|
- "Creating new model!",
|
|
|
- "Model type?",
|
|
|
- "Model name?",
|
|
|
- "Waiting for model constructors...",
|
|
|
- "Model upload success!",
|
|
|
- "Ready for command...",
|
|
|
- # model_list
|
|
|
- set(model_list) |
|
|
|
- set([
|
|
|
- " PetriNet : SimpleClassDiagrams",
|
|
|
- " ReachabilityGraph : SimpleClassDiagrams",]),
|
|
|
- "Ready for command...",
|
|
|
- # transformation_add_MT_language
|
|
|
- "Formalisms to include (terminate with empty string)?",
|
|
|
- "Name of the RAMified transformation metamodel?",
|
|
|
- "Ready for command...",
|
|
|
- # transformation_add_MT_language
|
|
|
- "Formalisms to include (terminate with empty string)?",
|
|
|
- "Name of the RAMified transformation metamodel?",
|
|
|
- "Ready for command...",
|
|
|
- # transformation_add_MT
|
|
|
- "RAMified metamodel to use?",
|
|
|
- "Supported metamodels:",
|
|
|
- set([" PetriNet",]),
|
|
|
- "Which metamodels do you want to use as source for the operation (empty string to finish)?",
|
|
|
- "Which metamodels do you want to use as target for the operation (empty string to finish)?",
|
|
|
- "Name of new operation?",
|
|
|
- "Waiting for model constructors...",
|
|
|
- "Ready for command...",
|
|
|
- # transformation_add_MANUAL
|
|
|
- "Which metamodels do you want to use as source for the operation (empty string to finish)?",
|
|
|
- "Which metamodels do you want to use as target for the operation (empty string to finish)?",
|
|
|
- "Name of operation model?",
|
|
|
- "Ready for command...",
|
|
|
- # transformation_add_AL
|
|
|
- "Which metamodels do you want to use as source for the operation (empty string to finish)?",
|
|
|
- "Which metamodels do you want to use as target for the operation (empty string to finish)?",
|
|
|
- "Name of operation model?",
|
|
|
- "Waiting for model constructors...",
|
|
|
- "Ready for command...",
|
|
|
- # transformation_add_MT
|
|
|
- "RAMified metamodel to use?",
|
|
|
- "Supported metamodels:",
|
|
|
- set([" ReachabilityGraph",]),
|
|
|
- "Which metamodels do you want to use as source for the operation (empty string to finish)?",
|
|
|
- "Which metamodels do you want to use as target for the operation (empty string to finish)?",
|
|
|
- "Name of new operation?",
|
|
|
- "Waiting for model constructors...",
|
|
|
- "Ready for command...",
|
|
|
- # model_add
|
|
|
- "Creating new model!",
|
|
|
- "Model type?",
|
|
|
- "Model name?",
|
|
|
- "Waiting for model constructors...",
|
|
|
- "Model upload success!",
|
|
|
- "Ready for command...",
|
|
|
- # model_list
|
|
|
- set(model_list) |
|
|
|
- set([
|
|
|
- " PetriNet : SimpleClassDiagrams",
|
|
|
- " ReachabilityGraph : SimpleClassDiagrams",
|
|
|
- " initialize_PN : PetriNet_RAM",
|
|
|
- " refine_PN : ManualOperation",
|
|
|
- " reachability : ActionLanguage",
|
|
|
- " reachability_print : ReachabilityGraph_RAM",
|
|
|
- " pn_reachability : ProcessModel",
|
|
|
- " PetriNet_RAM : SimpleClassDiagrams",
|
|
|
- " ReachabilityGraph_RAM : SimpleClassDiagrams",
|
|
|
- " __merged_PetriNet_RAM : SimpleClassDiagrams",
|
|
|
- " __merged_ReachabilityGraph_RAM : SimpleClassDiagrams",
|
|
|
- " __merged_refine_PN : SimpleClassDiagrams",
|
|
|
- " __merged_reachability : SimpleClassDiagrams",
|
|
|
- ]),
|
|
|
- "Ready for command...",
|
|
|
- # process_execute
|
|
|
- "Which process model do you want to execute?",
|
|
|
- "Model prefix to use?",
|
|
|
- "Please perform manual operation \"refine_PN\"",
|
|
|
- "Model loaded, ready for commands!",
|
|
|
- "Mode: r/w",
|
|
|
- "Use 'help' command for a list of possible commands",
|
|
|
- "Please give your command.",
|
|
|
- # instantiate p1
|
|
|
- "Type to instantiate?",
|
|
|
- "Name of new element?",
|
|
|
- "Instantiation successful!",
|
|
|
- None,
|
|
|
- "Please give your command.",
|
|
|
- "Which element do you want to assign an attribute to?",
|
|
|
- "Which attribute do you wish to assign?",
|
|
|
- "Value of attribute?",
|
|
|
- "Added attribute!",
|
|
|
- "Please give your command.",
|
|
|
- "Which element do you want to assign an attribute to?",
|
|
|
- "Which attribute do you wish to assign?",
|
|
|
- "Value of attribute?",
|
|
|
- "Added attribute!",
|
|
|
- "Please give your command.",
|
|
|
- # instantiate t1
|
|
|
- "Type to instantiate?",
|
|
|
- "Name of new element?",
|
|
|
- "Instantiation successful!",
|
|
|
- None,
|
|
|
- "Please give your command.",
|
|
|
- "Which element do you want to assign an attribute to?",
|
|
|
- "Which attribute do you wish to assign?",
|
|
|
- "Value of attribute?",
|
|
|
- "Added attribute!",
|
|
|
- "Please give your command.",
|
|
|
- # instantiate p2t
|
|
|
- "Type to instantiate?",
|
|
|
- "Name of new element?",
|
|
|
- "Source name?",
|
|
|
- "Destination name?",
|
|
|
- "Instantiation successful!",
|
|
|
- None,
|
|
|
- "Please give your command.",
|
|
|
- "Which element do you want to assign an attribute to?",
|
|
|
- "Which attribute do you wish to assign?",
|
|
|
- "Value of attribute?",
|
|
|
- "Added attribute!",
|
|
|
- "Please give your command.",
|
|
|
- set(['"0": {"p1": 1, }',
|
|
|
- '"1": {"p1": 0, }',
|
|
|
- ]),
|
|
|
- set(['"0" --["t1"]--> "1"',
|
|
|
- ]),
|
|
|
- "Ready for command...",
|
|
|
- # model_list
|
|
|
- set(model_list) |
|
|
|
- set([
|
|
|
- " PetriNet : SimpleClassDiagrams",
|
|
|
- " ReachabilityGraph : SimpleClassDiagrams",
|
|
|
- " initialize_PN : PetriNet_RAM",
|
|
|
- " refine_PN : ManualOperation",
|
|
|
- " reachability : ActionLanguage",
|
|
|
- " reachability_print : ReachabilityGraph_RAM",
|
|
|
- " pn_reachability : ProcessModel",
|
|
|
- " PetriNet_RAM : SimpleClassDiagrams",
|
|
|
- " ReachabilityGraph_RAM : SimpleClassDiagrams",
|
|
|
- " my_pn : PetriNet",
|
|
|
- " my_reachability : ReachabilityGraph",
|
|
|
- " __merged_PetriNet_RAM : SimpleClassDiagrams",
|
|
|
- " __merged_ReachabilityGraph_RAM : SimpleClassDiagrams",
|
|
|
- " __merged_refine_PN : SimpleClassDiagrams",
|
|
|
- " __merged_reachability : SimpleClassDiagrams",
|
|
|
- ]),
|
|
|
- "Ready for command...",
|
|
|
- ]))
|
|
|
+ model_add("PetriNet", "SimpleClassDiagrams", open("integration/code/pn_design.mvc", "r").read())
|
|
|
+ model_add("ReachabilityGraph", "SimpleClassDiagrams", open("integration/code/reachability_graph.mvc", "r").read())
|
|
|
+ model_add("pn_reachability", "ProcessModel", open("integration/code/pm_pn_reachability.mvc", "r").read())
|
|
|
+ transformation_add_MT_language(["PetriNet"], "PetriNet_RAM")
|
|
|
+ transformation_add_MT_language(["ReachabilityGraph"], "ReachabilityGraph_RAM")
|
|
|
+ transformation_add_MT("PetriNet_RAM", [], ["PetriNet"], "initialize_PN", open("integration/code/initialize_PN.mvc", "r").read())
|
|
|
+ transformation_add_MANUAL(["PetriNet"], ["PetriNet"], "refine_PN")
|
|
|
+ transformation_add_AL(["PetriNet"], ["ReachabilityGraph"], "reachability", open("integration/code/reachability.alc", "r").read())
|
|
|
+ transformation_add_MT("ReachabilityGraph_RAM", ["ReachabilityGraph"], [], "reachability_print", open("integration/code/reachabilitygraph_print.mvc", 'r').read())
|
|
|
+
|
|
|
+ def callback_refine_PN():
|
|
|
+ p1 = instantiate(None, "PetriNet/Place")
|
|
|
+ attr_assign(None, p1, "name", "p1")
|
|
|
+ attr_assign(None, p1, "tokens", 1)
|
|
|
+
|
|
|
+ t1 = instantiate(None, "PetriNet/Transition")
|
|
|
+ attr_assign(None, t1, "name", "t1")
|
|
|
+
|
|
|
+ p2t = instantiate(None, "PetriNet/P2T", (p1, t1))
|
|
|
+ attr_assign(None, p2t, "weight", 1)
|
|
|
+
|
|
|
+ log = set([])
|
|
|
+ def callback_print(value):
|
|
|
+ log.add(value)
|
|
|
+
|
|
|
+ process_execute("pn_reachability", "my_", {"refine_PN": callback_refine_PN, "reachability_print": callback_print})
|
|
|
+
|
|
|
+ assert log == set(['"0": {"p1": 1, }',
|
|
|
+ '"1": {"p1": 0, }',
|
|
|
+ '"0" --["t1"]--> "1"'])
|
|
|
|
|
|
def test_render(self):
|
|
|
model_add("CausalBlockDiagrams", "SimpleClassDiagrams", open("integration/code/cbd_design.mvc", 'r').read())
|