test_mvc.py 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166
  1. import unittest
  2. from utils import run_file, get_constructor, get_model_constructor
  3. all_files = [ "core/mini_modify.alc",
  4. "core/core_formalism.mvc",
  5. "core/core_algorithm.alc",
  6. "primitives.alc",
  7. "object_operations.alc",
  8. "conformance_scd.alc",
  9. "library.alc",
  10. "transform.alc",
  11. "model_management.alc",
  12. "ramify.alc",
  13. "metamodels.alc",
  14. "random.alc",
  15. "constructors.alc",
  16. "modelling.alc",
  17. "compilation_manager.alc",
  18. ]
  19. class TestModelverseCore(unittest.TestCase):
  20. def test_po_list(self):
  21. self.list("PO")
  22. def test_co_list(self):
  23. self.list("CO")
  24. def list(self, mode):
  25. self.assertTrue(run_file(all_files,
  26. [ "root", "root", "root",
  27. "model_list",
  28. ],
  29. [ "Desired username for admin user?",
  30. "Desired password for admin user?",
  31. "Please repeat the password",
  32. "Passwords match!",
  33. "Welcome to the Model Management Interface v2.0!",
  34. "Use the 'help' command for a list of possible commands",
  35. "Ready for command...",
  36. set([" SimpleClassDiagrams : SimpleClassDiagrams",
  37. " CoreFormalism : SimpleClassDiagrams",
  38. " core : CoreFormalism"]),
  39. ],
  40. mode))
  41. def test_po_list_full(self):
  42. self.list_full("PO")
  43. def list_full(self, mode):
  44. self.assertTrue(run_file(all_files,
  45. [ "root", "root", "root",
  46. "model_list_full",
  47. ],
  48. [ "Desired username for admin user?",
  49. "Desired password for admin user?",
  50. "Please repeat the password",
  51. "Passwords match!",
  52. "Welcome to the Model Management Interface v2.0!",
  53. "Use the 'help' command for a list of possible commands",
  54. "Ready for command...",
  55. set([" 221 root admin 673 SimpleClassDiagrams : SimpleClassDiagrams",
  56. " 221 root admin 90 CoreFormalism : SimpleClassDiagrams",
  57. " 200 root admin 45 core : CoreFormalism"]),
  58. ],
  59. mode))
  60. def test_po_model_add_empty(self):
  61. self.model_add_empty("PO")
  62. def model_add_empty(self, mode):
  63. self.assertTrue(run_file(all_files,
  64. [ "root", "root", "root",
  65. "model_add",
  66. "SimpleClassDiagrams",
  67. "Empty",
  68. "exit",
  69. "model_list",
  70. "model_list_full",
  71. ],
  72. [ "Desired username for admin user?",
  73. "Desired password for admin user?",
  74. "Please repeat the password",
  75. "Passwords match!",
  76. "Welcome to the Model Management Interface v2.0!",
  77. "Use the 'help' command for a list of possible commands",
  78. "Ready for command...",
  79. "Creating new model!",
  80. "Model type?",
  81. "Model name?",
  82. "Waiting for model constructors...",
  83. "Model upload success!",
  84. "Ready for command...",
  85. set([" SimpleClassDiagrams : SimpleClassDiagrams",
  86. " CoreFormalism : SimpleClassDiagrams",
  87. " Empty : SimpleClassDiagrams",
  88. " core : CoreFormalism"]),
  89. "Ready for command...",
  90. set([" 221 root admin 673 SimpleClassDiagrams : SimpleClassDiagrams",
  91. " 221 root admin 90 CoreFormalism : SimpleClassDiagrams",
  92. " 200 root nobody 0 Empty : SimpleClassDiagrams",
  93. " 200 root admin 55 core : CoreFormalism"]),
  94. ],
  95. mode))
  96. def test_po_model_empty_modify(self):
  97. self.model_empty_modify("PO")
  98. def model_empty_modify(self, mode):
  99. self.assertTrue(run_file(all_files,
  100. [ "root", "root", "root",
  101. "model_add",
  102. "SimpleClassDiagrams",
  103. "Empty",
  104. "exit",
  105. "model_list",
  106. "model_list_full",
  107. "model_modify",
  108. "Empty",
  109. "instantiate",
  110. "Class",
  111. "A",
  112. "exit",
  113. "model_list_full",
  114. ],
  115. [ "Desired username for admin user?",
  116. "Desired password for admin user?",
  117. "Please repeat the password",
  118. "Passwords match!",
  119. "Welcome to the Model Management Interface v2.0!",
  120. "Use the 'help' command for a list of possible commands",
  121. "Ready for command...",
  122. "Creating new model!",
  123. "Model type?",
  124. "Model name?",
  125. "Waiting for model constructors...",
  126. "Model upload success!",
  127. "Ready for command...",
  128. set([" SimpleClassDiagrams : SimpleClassDiagrams",
  129. " CoreFormalism : SimpleClassDiagrams",
  130. " Empty : SimpleClassDiagrams",
  131. " core : CoreFormalism"]),
  132. "Ready for command...",
  133. set([" 221 root admin 673 SimpleClassDiagrams : SimpleClassDiagrams",
  134. " 221 root admin 90 CoreFormalism : SimpleClassDiagrams",
  135. " 200 root nobody 0 Empty : SimpleClassDiagrams",
  136. " 200 root admin 55 core : CoreFormalism"]),
  137. "Ready for command...",
  138. "Which model do you want to modify?",
  139. "Model loaded, ready for commands!",
  140. "Use 'help' command for a list of possible commands",
  141. "Please give your command.",
  142. "Type to instantiate?",
  143. "Name of new element?",
  144. "Instantiation successful!",
  145. "Please give your command.",
  146. "Ready for command...",
  147. set([" 221 root admin 673 SimpleClassDiagrams : SimpleClassDiagrams",
  148. " 221 root admin 90 CoreFormalism : SimpleClassDiagrams",
  149. " 200 root nobody 1 Empty : SimpleClassDiagrams",
  150. " 200 root admin 55 core : CoreFormalism"]),
  151. "Ready for command...",
  152. ],
  153. mode))
  154. def test_po_model_overwrite(self):
  155. self.model_overwrite("PO")
  156. def model_overwrite(self, mode):
  157. self.assertTrue(run_file(all_files,
  158. [ "root", "root", "root",
  159. "model_add",
  160. "SimpleClassDiagrams",
  161. "Empty",
  162. "exit",
  163. "model_list_full",
  164. "model_modify",
  165. "Empty",
  166. "instantiate",
  167. "Class",
  168. "A",
  169. "exit",
  170. "model_list_full",
  171. "model_overwrite",
  172. "Empty",
  173. "instantiate_node",
  174. "",
  175. "Class",
  176. "B",
  177. "instantiate_node",
  178. "",
  179. "Class",
  180. "C",
  181. "exit",
  182. "model_list_full",
  183. "model_modify",
  184. "Empty",
  185. "list",
  186. "exit",
  187. ],
  188. [ "Desired username for admin user?",
  189. "Desired password for admin user?",
  190. "Please repeat the password",
  191. "Passwords match!",
  192. "Welcome to the Model Management Interface v2.0!",
  193. "Use the 'help' command for a list of possible commands",
  194. "Ready for command...",
  195. "Creating new model!",
  196. "Model type?",
  197. "Model name?",
  198. "Waiting for model constructors...",
  199. "Model upload success!",
  200. "Ready for command...",
  201. set([" 221 root admin 673 SimpleClassDiagrams : SimpleClassDiagrams",
  202. " 221 root admin 90 CoreFormalism : SimpleClassDiagrams",
  203. " 200 root nobody 0 Empty : SimpleClassDiagrams",
  204. " 200 root admin 55 core : CoreFormalism"]),
  205. "Ready for command...",
  206. "Which model do you want to modify?",
  207. "Model loaded, ready for commands!",
  208. "Use 'help' command for a list of possible commands",
  209. "Please give your command.",
  210. "Type to instantiate?",
  211. "Name of new element?",
  212. "Instantiation successful!",
  213. "Please give your command.",
  214. "Ready for command...",
  215. set([" 221 root admin 673 SimpleClassDiagrams : SimpleClassDiagrams",
  216. " 221 root admin 90 CoreFormalism : SimpleClassDiagrams",
  217. " 200 root nobody 1 Empty : SimpleClassDiagrams",
  218. " 200 root admin 55 core : CoreFormalism"]),
  219. "Ready for command...",
  220. "Which model to overwrite?",
  221. "Waiting for model constructors...",
  222. "Model overwrite success!",
  223. "Ready for command...",
  224. set([" 221 root admin 673 SimpleClassDiagrams : SimpleClassDiagrams",
  225. " 221 root admin 90 CoreFormalism : SimpleClassDiagrams",
  226. " 200 root nobody 2 Empty : SimpleClassDiagrams",
  227. " 200 root admin 55 core : CoreFormalism"]),
  228. "Ready for command...",
  229. "Which model do you want to modify?",
  230. "Model loaded, ready for commands!",
  231. "Use 'help' command for a list of possible commands",
  232. "Please give your command.",
  233. "List of all elements:",
  234. set([" B : Class",
  235. " C : Class"]),
  236. "Please give your command.",
  237. "Ready for command...",
  238. ],
  239. mode))
  240. def test_po_transform_add_MT_language(self):
  241. self.transform_add_MT_language("PO")
  242. def transform_add_MT_language(self, mode):
  243. self.assertTrue(run_file(all_files,
  244. [ "root", "root", "root",
  245. "model_add",
  246. "SimpleClassDiagrams",
  247. "PetriNets",
  248. ] + get_model_constructor(open("integration/code/petrinets.mvc", "r").read()) + [
  249. "model_list_full",
  250. "transformation_add_MT_language",
  251. "PetriNets",
  252. "",
  253. "PetriNets_RAM",
  254. "model_list_full",
  255. ],
  256. [ "Desired username for admin user?",
  257. "Desired password for admin user?",
  258. "Please repeat the password",
  259. "Passwords match!",
  260. "Welcome to the Model Management Interface v2.0!",
  261. "Use the 'help' command for a list of possible commands",
  262. "Ready for command...",
  263. "Creating new model!",
  264. "Model type?",
  265. "Model name?",
  266. "Waiting for model constructors...",
  267. "Model upload success!",
  268. "Ready for command...",
  269. set([" 221 root admin 673 SimpleClassDiagrams : SimpleClassDiagrams",
  270. " 221 root admin 90 CoreFormalism : SimpleClassDiagrams",
  271. " 200 root nobody 14 PetriNets : SimpleClassDiagrams",
  272. " 200 root admin 55 core : CoreFormalism"]),
  273. "Ready for command...",
  274. "Formalisms to include (terminate with empty string)?",
  275. "Name of the RAMified transformation metamodel?",
  276. "Ready for command...",
  277. set([" 221 root admin 673 SimpleClassDiagrams : SimpleClassDiagrams",
  278. " 221 root admin 90 CoreFormalism : SimpleClassDiagrams",
  279. " 200 root nobody 14 PetriNets : SimpleClassDiagrams",
  280. " 200 root nobody 14 __merged_PetriNets_RAM : SimpleClassDiagrams",
  281. " 200 root nobody 328 PetriNets_RAM : SimpleClassDiagrams",
  282. " 200 root admin 81 core : CoreFormalism"]),
  283. "Ready for command...",
  284. ],
  285. mode))
  286. def test_po_transform_add_MT_instance(self):
  287. self.transform_add_MT_instance("PO")
  288. def transform_add_MT_instance(self, mode):
  289. self.assertTrue(run_file(all_files,
  290. [ "root", "root", "root",
  291. "model_add",
  292. "SimpleClassDiagrams",
  293. "PetriNets",
  294. ] + get_model_constructor(open("integration/code/petrinets.mvc", "r").read()) + [
  295. "model_list_full",
  296. "transformation_add_MT_language",
  297. "PetriNets",
  298. "",
  299. "PetriNets_RAM",
  300. "model_list_full",
  301. "transformation_add_MT",
  302. "PetriNets_RAM",
  303. "PetriNets",
  304. "",
  305. "",
  306. "PetriNets_Print",
  307. "exit",
  308. "model_list_full",
  309. "transformation_list",
  310. "transformation_list_full",
  311. ],
  312. [ "Desired username for admin user?",
  313. "Desired password for admin user?",
  314. "Please repeat the password",
  315. "Passwords match!",
  316. "Welcome to the Model Management Interface v2.0!",
  317. "Use the 'help' command for a list of possible commands",
  318. "Ready for command...",
  319. "Creating new model!",
  320. "Model type?",
  321. "Model name?",
  322. "Waiting for model constructors...",
  323. "Model upload success!",
  324. "Ready for command...",
  325. set([" 221 root admin 673 SimpleClassDiagrams : SimpleClassDiagrams",
  326. " 221 root admin 90 CoreFormalism : SimpleClassDiagrams",
  327. " 200 root nobody 14 PetriNets : SimpleClassDiagrams",
  328. " 200 root admin 55 core : CoreFormalism"]),
  329. "Ready for command...",
  330. "Formalisms to include (terminate with empty string)?",
  331. "Name of the RAMified transformation metamodel?",
  332. "Ready for command...",
  333. set([" 221 root admin 673 SimpleClassDiagrams : SimpleClassDiagrams",
  334. " 221 root admin 90 CoreFormalism : SimpleClassDiagrams",
  335. " 200 root nobody 14 PetriNets : SimpleClassDiagrams",
  336. " 200 root nobody 14 __merged_PetriNets_RAM : SimpleClassDiagrams",
  337. " 200 root nobody 328 PetriNets_RAM : SimpleClassDiagrams",
  338. " 200 root admin 81 core : CoreFormalism"]),
  339. "Ready for command...",
  340. "RAMified metamodel to use?",
  341. "Supported metamodels:",
  342. set([" PetriNets",
  343. ]),
  344. "",
  345. "Which ones do you want to use as source (empty string to finish)?",
  346. "Model added as source",
  347. "Which ones do you want to use as target (empty string to finish)?",
  348. "Name of new transformation?",
  349. "Waiting for model constructors...",
  350. "Ready for command...",
  351. set([" 221 root admin 673 SimpleClassDiagrams : SimpleClassDiagrams",
  352. " 221 root admin 90 CoreFormalism : SimpleClassDiagrams",
  353. " 200 root nobody 14 PetriNets : SimpleClassDiagrams",
  354. " 200 root nobody 14 __merged_PetriNets_RAM : SimpleClassDiagrams",
  355. " 200 root nobody 328 PetriNets_RAM : SimpleClassDiagrams",
  356. " 200 root nobody 0 PetriNets_Print : PetriNets_RAM",
  357. " 200 root admin 94 core : CoreFormalism"]),
  358. "Ready for command...",
  359. set(["[ModelTransformation] PetriNets_Print : PetriNets_RAM",
  360. ]),
  361. "Ready for command...",
  362. set([" 200 root nobody 0 [ModelTransformation] PetriNets_Print : PetriNets_RAM"
  363. ]),
  364. "Ready for command...",
  365. ],
  366. mode))
  367. def test_po_transform_add_MT_pn_print_upload(self):
  368. self.transform_add_MT_pn_print_upload("PO")
  369. def transform_add_MT_pn_print_upload(self, mode):
  370. self.assertTrue(run_file(all_files,
  371. [ "root", "root", "root",
  372. "model_add",
  373. "SimpleClassDiagrams",
  374. "PetriNets",
  375. ] + get_model_constructor(open("integration/code/pn_runtime.mvc", "r").read()) + [
  376. "model_list_full",
  377. "transformation_add_MT_language",
  378. "PetriNets",
  379. "",
  380. "PetriNets_RAM",
  381. "model_list_full",
  382. "transformation_add_MT",
  383. "PetriNets_RAM",
  384. "PetriNets",
  385. "",
  386. "",
  387. "PetriNets_Print",
  388. ] + get_model_constructor(open("integration/code/pn_print.mvc", "r").read()) + [
  389. "transformation_list_full",
  390. ],
  391. [ "Desired username for admin user?",
  392. "Desired password for admin user?",
  393. "Please repeat the password",
  394. "Passwords match!",
  395. "Welcome to the Model Management Interface v2.0!",
  396. "Use the 'help' command for a list of possible commands",
  397. "Ready for command...",
  398. "Creating new model!",
  399. "Model type?",
  400. "Model name?",
  401. "Waiting for model constructors...",
  402. "Model upload success!",
  403. "Ready for command...",
  404. set([" 221 root admin 673 SimpleClassDiagrams : SimpleClassDiagrams",
  405. " 221 root admin 90 CoreFormalism : SimpleClassDiagrams",
  406. " 200 root nobody 22 PetriNets : SimpleClassDiagrams",
  407. " 200 root admin 55 core : CoreFormalism"]),
  408. "Ready for command...",
  409. "Formalisms to include (terminate with empty string)?",
  410. "Name of the RAMified transformation metamodel?",
  411. "Ready for command...",
  412. set([" 221 root admin 673 SimpleClassDiagrams : SimpleClassDiagrams",
  413. " 221 root admin 90 CoreFormalism : SimpleClassDiagrams",
  414. " 200 root nobody 22 PetriNets : SimpleClassDiagrams",
  415. " 200 root nobody 22 __merged_PetriNets_RAM : SimpleClassDiagrams",
  416. " 200 root nobody 352 PetriNets_RAM : SimpleClassDiagrams",
  417. " 200 root admin 81 core : CoreFormalism"]),
  418. "Ready for command...",
  419. "RAMified metamodel to use?",
  420. "Supported metamodels:",
  421. set([" PetriNets",
  422. ]),
  423. "",
  424. "Which ones do you want to use as source (empty string to finish)?",
  425. "Model added as source",
  426. "Which ones do you want to use as target (empty string to finish)?",
  427. "Name of new transformation?",
  428. "Waiting for model constructors...",
  429. "Ready for command...",
  430. set([" 200 root nobody 26 [ModelTransformation] PetriNets_Print : PetriNets_RAM"
  431. ]),
  432. "Ready for command...",
  433. ],
  434. mode))
  435. def test_po_transform_add_MT_pn_print_exec(self):
  436. self.transform_add_MT_pn_print_exec("PO")
  437. def transform_add_MT_pn_print_exec(self, mode):
  438. self.assertTrue(run_file(all_files,
  439. [ "root", "root", "root",
  440. "model_add",
  441. "SimpleClassDiagrams",
  442. "PetriNets",
  443. ] + get_model_constructor(open("integration/code/pn_runtime.mvc", "r").read()) + [
  444. "model_add",
  445. "PetriNets",
  446. "my_pn",
  447. ] + get_model_constructor(open("integration/code/pn_runtime_model.mvc", "r").read()) + [
  448. "model_list_full",
  449. "transformation_add_MT_language",
  450. "PetriNets",
  451. "",
  452. "PetriNets_RAM",
  453. "model_list_full",
  454. "transformation_add_MT",
  455. "PetriNets_RAM",
  456. "PetriNets",
  457. "",
  458. "",
  459. "PetriNets_Print",
  460. ] + get_model_constructor(open("integration/code/pn_print.mvc", "r").read()) + [
  461. "transformation_list_full",
  462. "transformation_execute",
  463. "PetriNets_Print",
  464. "my_pn",
  465. "transformation_list_full",
  466. ],
  467. [ "Desired username for admin user?",
  468. "Desired password for admin user?",
  469. "Please repeat the password",
  470. "Passwords match!",
  471. "Welcome to the Model Management Interface v2.0!",
  472. "Use the 'help' command for a list of possible commands",
  473. "Ready for command...",
  474. "Creating new model!",
  475. "Model type?",
  476. "Model name?",
  477. "Waiting for model constructors...",
  478. "Model upload success!",
  479. "Ready for command...",
  480. "Creating new model!",
  481. "Model type?",
  482. "Model name?",
  483. "Waiting for model constructors...",
  484. "Model upload success!",
  485. "Ready for command...",
  486. set([" 221 root admin 673 SimpleClassDiagrams : SimpleClassDiagrams",
  487. " 221 root admin 90 CoreFormalism : SimpleClassDiagrams",
  488. " 200 root nobody 22 PetriNets : SimpleClassDiagrams",
  489. " 200 root nobody 27 my_pn : PetriNets",
  490. " 200 root admin 65 core : CoreFormalism"]),
  491. "Ready for command...",
  492. "Formalisms to include (terminate with empty string)?",
  493. "Name of the RAMified transformation metamodel?",
  494. "Ready for command...",
  495. set([" 221 root admin 673 SimpleClassDiagrams : SimpleClassDiagrams",
  496. " 221 root admin 90 CoreFormalism : SimpleClassDiagrams",
  497. " 200 root nobody 22 PetriNets : SimpleClassDiagrams",
  498. " 200 root nobody 22 __merged_PetriNets_RAM : SimpleClassDiagrams",
  499. " 200 root nobody 352 PetriNets_RAM : SimpleClassDiagrams",
  500. " 200 root nobody 27 my_pn : PetriNets",
  501. " 200 root admin 91 core : CoreFormalism"]),
  502. "Ready for command...",
  503. "RAMified metamodel to use?",
  504. "Supported metamodels:",
  505. set([" PetriNets",
  506. ]),
  507. "",
  508. "Which ones do you want to use as source (empty string to finish)?",
  509. "Model added as source",
  510. "Which ones do you want to use as target (empty string to finish)?",
  511. "Name of new transformation?",
  512. "Waiting for model constructors...",
  513. "Ready for command...",
  514. set([" 200 root nobody 26 [ModelTransformation] PetriNets_Print : PetriNets_RAM"
  515. ]),
  516. "Ready for command...",
  517. "Which transformation do you want to execute?",
  518. "Which model to bind for source element PetriNets",
  519. set(['"p1" --> 1',
  520. '"p2" --> 2',
  521. '"p3" --> 3',
  522. ]),
  523. "Transformation executed with result: True",
  524. "Ready for command...",
  525. ],
  526. mode))
  527. def test_po_transform_add_MT_pn_simulate(self):
  528. self.transform_add_MT_pn_simulate("PO")
  529. def transform_add_MT_pn_simulate(self, mode):
  530. self.assertTrue(run_file(all_files,
  531. [ "root", "root", "root",
  532. "model_add",
  533. "SimpleClassDiagrams",
  534. "PetriNets",
  535. ] + get_model_constructor(open("integration/code/pn_design.mvc", "r").read()) + [
  536. "model_add",
  537. "SimpleClassDiagrams",
  538. "PetriNets_Runtime",
  539. ] + get_model_constructor(open("integration/code/pn_runtime.mvc", "r").read()) + [
  540. "model_add",
  541. "PetriNets",
  542. "my_pn",
  543. ] + get_model_constructor(open("integration/code/pn_design_model.mvc", "r").read()) + [
  544. "model_list",
  545. "transformation_add_MT_language",
  546. "PetriNets_Runtime",
  547. "PetriNets",
  548. "",
  549. "PetriNets_RAM",
  550. "model_list",
  551. "model_modify",
  552. "__merged_PetriNets_RAM",
  553. "instantiate",
  554. "Association",
  555. "D2R_PlaceLink",
  556. "PetriNets/Place",
  557. "PetriNets_Runtime/Place",
  558. "instantiate",
  559. "Association",
  560. "D2R_TransitionLink",
  561. "PetriNets/Transition",
  562. "PetriNets_Runtime/Transition",
  563. "instantiate",
  564. "Association",
  565. "R2D_PlaceLink",
  566. "PetriNets_Runtime/Place",
  567. "PetriNets/Place",
  568. "instantiate",
  569. "Association",
  570. "R2D_TransitionLink",
  571. "PetriNets_Runtime/Transition",
  572. "PetriNets/Transition",
  573. "exit",
  574. "transformation_RAMify",
  575. "__merged_PetriNets_RAM",
  576. "PetriNets_RAM",
  577. "transformation_add_MT",
  578. "PetriNets_RAM",
  579. "PetriNets",
  580. "",
  581. "PetriNets_Runtime",
  582. "",
  583. "pn_design_to_runtime",
  584. ] + get_model_constructor(open("integration/code/pn_design_to_runtime.mvc", "r").read()) + [
  585. "transformation_add_MT",
  586. "PetriNets_RAM",
  587. "PetriNets_Runtime",
  588. "",
  589. "PetriNets",
  590. "",
  591. "pn_runtime_to_design",
  592. ] + get_model_constructor(open("integration/code/pn_runtime_to_design.mvc", "r").read()) + [
  593. "transformation_add_MT",
  594. "PetriNets_RAM",
  595. "PetriNets_Runtime",
  596. "",
  597. "PetriNets_Runtime",
  598. "",
  599. "pn_step",
  600. ] + get_model_constructor(open("integration/code/pn_simulate.mvc", "r").read()) + [
  601. "transformation_add_MT",
  602. "PetriNets_RAM",
  603. "PetriNets",
  604. "",
  605. "",
  606. "pn_print",
  607. ] + get_model_constructor(open("integration/code/pn_print.mvc", "r").read()) + [
  608. "model_list",
  609. "transformation_list",
  610. "transformation_execute",
  611. "pn_print",
  612. "my_pn",
  613. "transformation_execute",
  614. "pn_design_to_runtime",
  615. "my_pn",
  616. "my_pn_runtime",
  617. "transformation_execute",
  618. "pn_step",
  619. "my_pn_runtime",
  620. "my_pn_runtime",
  621. "transformation_execute",
  622. "pn_runtime_to_design",
  623. "my_pn_runtime",
  624. "my_pn",
  625. "transformation_execute",
  626. "pn_print",
  627. "my_pn",
  628. ],
  629. [ # bootup phase
  630. "Desired username for admin user?",
  631. "Desired password for admin user?",
  632. "Please repeat the password",
  633. "Passwords match!",
  634. "Welcome to the Model Management Interface v2.0!",
  635. "Use the 'help' command for a list of possible commands",
  636. "Ready for command...",
  637. # model_add
  638. "Creating new model!",
  639. "Model type?",
  640. "Model name?",
  641. "Waiting for model constructors...",
  642. "Model upload success!",
  643. "Ready for command...",
  644. # model_add
  645. "Creating new model!",
  646. "Model type?",
  647. "Model name?",
  648. "Waiting for model constructors...",
  649. "Model upload success!",
  650. "Ready for command...",
  651. # model_add
  652. "Creating new model!",
  653. "Model type?",
  654. "Model name?",
  655. "Waiting for model constructors...",
  656. "Model upload success!",
  657. "Ready for command...",
  658. # model_list
  659. set([" SimpleClassDiagrams : SimpleClassDiagrams",
  660. " CoreFormalism : SimpleClassDiagrams",
  661. " PetriNets : SimpleClassDiagrams",
  662. " my_pn : PetriNets",
  663. " PetriNets_Runtime : SimpleClassDiagrams",
  664. " core : CoreFormalism"]),
  665. "Ready for command...",
  666. # transformation_add_MT_language
  667. "Formalisms to include (terminate with empty string)?",
  668. "Name of the RAMified transformation metamodel?",
  669. "Ready for command...",
  670. # model_list
  671. set([" SimpleClassDiagrams : SimpleClassDiagrams",
  672. " CoreFormalism : SimpleClassDiagrams",
  673. " PetriNets_Runtime : SimpleClassDiagrams",
  674. " PetriNets : SimpleClassDiagrams",
  675. " __merged_PetriNets_RAM : SimpleClassDiagrams",
  676. " PetriNets_RAM : SimpleClassDiagrams",
  677. " my_pn : PetriNets",
  678. " core : CoreFormalism"]),
  679. "Ready for command...",
  680. # model_modify
  681. "Which model do you want to modify?",
  682. "Model loaded, ready for commands!",
  683. "Use 'help' command for a list of possible commands",
  684. "Please give your command.",
  685. # instantiate 1
  686. "Type to instantiate?",
  687. "Name of new element?",
  688. "Source name?",
  689. "Destination name?",
  690. "Instantiation successful!",
  691. "Please give your command.",
  692. # instantiate 2
  693. "Type to instantiate?",
  694. "Name of new element?",
  695. "Source name?",
  696. "Destination name?",
  697. "Instantiation successful!",
  698. "Please give your command.",
  699. # instantiate 3
  700. "Type to instantiate?",
  701. "Name of new element?",
  702. "Source name?",
  703. "Destination name?",
  704. "Instantiation successful!",
  705. "Please give your command.",
  706. # instantiate 4
  707. "Type to instantiate?",
  708. "Name of new element?",
  709. "Source name?",
  710. "Destination name?",
  711. "Instantiation successful!",
  712. "Please give your command.",
  713. "Ready for command...",
  714. # transformation_RAMify
  715. "Which metamodel do you want to RAMify?",
  716. "Where do you want to store the RAMified metamodel?",
  717. "Ready for command...",
  718. # transformation_add_MT
  719. "RAMified metamodel to use?",
  720. "Supported metamodels:",
  721. set([" PetriNets",
  722. " PetriNets_Runtime",
  723. ]),
  724. "",
  725. "Which ones do you want to use as source (empty string to finish)?",
  726. "Model added as source",
  727. "Which ones do you want to use as target (empty string to finish)?",
  728. "Model added as target",
  729. "Name of new transformation?",
  730. "Waiting for model constructors...",
  731. "Ready for command...",
  732. # transformation_add_MT
  733. "RAMified metamodel to use?",
  734. "Supported metamodels:",
  735. set([" PetriNets",
  736. " PetriNets_Runtime",
  737. ]),
  738. "",
  739. "Which ones do you want to use as source (empty string to finish)?",
  740. "Model added as source",
  741. "Which ones do you want to use as target (empty string to finish)?",
  742. "Model added as target",
  743. "Name of new transformation?",
  744. "Waiting for model constructors...",
  745. "Ready for command...",
  746. # transformation_add_MT
  747. "RAMified metamodel to use?",
  748. "Supported metamodels:",
  749. set([" PetriNets",
  750. " PetriNets_Runtime",
  751. ]),
  752. "",
  753. "Which ones do you want to use as source (empty string to finish)?",
  754. "Model added as source",
  755. "Which ones do you want to use as target (empty string to finish)?",
  756. "Model added as target",
  757. "Name of new transformation?",
  758. "Waiting for model constructors...",
  759. "Ready for command...",
  760. # transformation_add_MT
  761. "RAMified metamodel to use?",
  762. "Supported metamodels:",
  763. set([" PetriNets",
  764. " PetriNets_Runtime",
  765. ]),
  766. "",
  767. "Which ones do you want to use as source (empty string to finish)?",
  768. "Model added as source",
  769. "Which ones do you want to use as target (empty string to finish)?",
  770. "Name of new transformation?",
  771. "Waiting for model constructors...",
  772. "Ready for command...",
  773. # model_list
  774. set([" SimpleClassDiagrams : SimpleClassDiagrams",
  775. " CoreFormalism : SimpleClassDiagrams",
  776. " PetriNets_Runtime : SimpleClassDiagrams",
  777. " PetriNets : SimpleClassDiagrams",
  778. " pn_print : PetriNets_RAM",
  779. " pn_design_to_runtime : PetriNets_RAM",
  780. " pn_runtime_to_design : PetriNets_RAM",
  781. " pn_step : PetriNets_RAM",
  782. " __merged_PetriNets_RAM : SimpleClassDiagrams",
  783. " PetriNets_RAM : SimpleClassDiagrams",
  784. " my_pn : PetriNets",
  785. " core : CoreFormalism"]),
  786. "Ready for command...",
  787. # transformation_list
  788. set(["[ModelTransformation] pn_print : PetriNets_RAM",
  789. "[ModelTransformation] pn_design_to_runtime : PetriNets_RAM",
  790. "[ModelTransformation] pn_runtime_to_design : PetriNets_RAM",
  791. "[ModelTransformation] pn_step : PetriNets_RAM"]),
  792. "Ready for command...",
  793. # transformation_execute (pn_print)
  794. "Which transformation do you want to execute?",
  795. "Which model to bind for source element PetriNets",
  796. set(['"p1" --> 1',
  797. '"p2" --> 2',
  798. '"p3" --> 3',
  799. ]),
  800. "Transformation executed with result: True",
  801. "Ready for command...",
  802. # transformation_execute (pn_design_to_runtime)
  803. "Which transformation do you want to execute?",
  804. "Which model to bind for source element PetriNets",
  805. "Which model to create for target element PetriNets_Runtime",
  806. "Transformation executed with result: True",
  807. "Ready for command...",
  808. # transformation_execute (pn_step)
  809. "Which transformation do you want to execute?",
  810. "Which model to bind for source element PetriNets_Runtime",
  811. "Which model to create for target element PetriNets_Runtime",
  812. "Transformation executed with result: True",
  813. "Ready for command...",
  814. # transformation_execute (pn_runtime_to_design)
  815. "Which transformation do you want to execute?",
  816. "Which model to bind for source element PetriNets_Runtime",
  817. "Which model to create for target element PetriNets",
  818. "Transformation executed with result: True",
  819. "Ready for command...",
  820. # transformation_execute (pn_print)
  821. "Which transformation do you want to execute?",
  822. "Which model to bind for source element PetriNets",
  823. set(['"p1" --> 0',
  824. '"p2" --> 1',
  825. '"p3" --> 5',
  826. ]),
  827. "Transformation executed with result: True",
  828. "Ready for command...",
  829. ],
  830. mode))
  831. def test_po_transform_add_MT_pn_simulate_larger(self):
  832. self.transform_add_MT_pn_simulate_larger("PO")
  833. def transform_add_MT_pn_simulate_larger(self, mode):
  834. def step_and_print():
  835. return [ \
  836. # transformation_execute (pn_step)
  837. "Which transformation do you want to execute?",
  838. "Which model to bind for source element PetriNets_Runtime",
  839. "Which model to create for target element PetriNets_Runtime",
  840. "Transformation executed with result: True",
  841. "Ready for command...",
  842. # transformation_execute (pn_runtime_to_design)
  843. "Which transformation do you want to execute?",
  844. "Which model to bind for source element PetriNets_Runtime",
  845. "Which model to create for target element PetriNets",
  846. "Transformation executed with result: True",
  847. "Ready for command...",
  848. # transformation_execute (pn_print)
  849. "Which transformation do you want to execute?",
  850. "Which model to bind for source element PetriNets",
  851. None,
  852. None,
  853. None,
  854. "Transformation executed with result: True",
  855. "Ready for command...",
  856. ]
  857. self.assertTrue(run_file(all_files,
  858. [ "root", "root", "root",
  859. "model_add",
  860. "SimpleClassDiagrams",
  861. "PetriNets",
  862. ] + get_model_constructor(open("integration/code/pn_design.mvc", "r").read()) + [
  863. "model_add",
  864. "SimpleClassDiagrams",
  865. "PetriNets_Runtime",
  866. ] + get_model_constructor(open("integration/code/pn_runtime.mvc", "r").read()) + [
  867. "model_add",
  868. "PetriNets",
  869. "my_pn",
  870. ] + get_model_constructor(open("integration/code/pn_design_model_larger.mvc", "r").read()) + [
  871. "model_list",
  872. "transformation_add_MT_language",
  873. "PetriNets_Runtime",
  874. "PetriNets",
  875. "",
  876. "PetriNets_RAM",
  877. "model_list",
  878. "model_modify",
  879. "__merged_PetriNets_RAM",
  880. "instantiate",
  881. "Association",
  882. "D2R_PlaceLink",
  883. "PetriNets/Place",
  884. "PetriNets_Runtime/Place",
  885. "instantiate",
  886. "Association",
  887. "D2R_TransitionLink",
  888. "PetriNets/Transition",
  889. "PetriNets_Runtime/Transition",
  890. "instantiate",
  891. "Association",
  892. "R2D_PlaceLink",
  893. "PetriNets_Runtime/Place",
  894. "PetriNets/Place",
  895. "instantiate",
  896. "Association",
  897. "R2D_TransitionLink",
  898. "PetriNets_Runtime/Transition",
  899. "PetriNets/Transition",
  900. "exit",
  901. "transformation_RAMify",
  902. "__merged_PetriNets_RAM",
  903. "PetriNets_RAM",
  904. "transformation_add_MT",
  905. "PetriNets_RAM",
  906. "PetriNets",
  907. "",
  908. "PetriNets_Runtime",
  909. "",
  910. "pn_design_to_runtime",
  911. ] + get_model_constructor(open("integration/code/pn_design_to_runtime.mvc", "r").read()) + [
  912. "transformation_add_MT",
  913. "PetriNets_RAM",
  914. "PetriNets_Runtime",
  915. "",
  916. "PetriNets",
  917. "",
  918. "pn_runtime_to_design",
  919. ] + get_model_constructor(open("integration/code/pn_runtime_to_design.mvc", "r").read()) + [
  920. "transformation_add_MT",
  921. "PetriNets_RAM",
  922. "PetriNets_Runtime",
  923. "",
  924. "PetriNets_Runtime",
  925. "",
  926. "pn_step",
  927. ] + get_model_constructor(open("integration/code/pn_simulate.mvc", "r").read()) + [
  928. "transformation_add_MT",
  929. "PetriNets_RAM",
  930. "PetriNets",
  931. "",
  932. "",
  933. "pn_print",
  934. ] + get_model_constructor(open("integration/code/pn_print.mvc", "r").read()) + [
  935. "model_list",
  936. "transformation_list",
  937. "transformation_execute",
  938. "pn_print",
  939. "my_pn",
  940. "transformation_execute",
  941. "pn_design_to_runtime",
  942. "my_pn",
  943. "my_pn_runtime", ] + [
  944. "transformation_execute",
  945. "pn_step",
  946. "my_pn_runtime",
  947. "my_pn_runtime",
  948. "transformation_execute",
  949. "pn_runtime_to_design",
  950. "my_pn_runtime",
  951. "my_pn",
  952. "transformation_execute",
  953. "pn_print",
  954. "my_pn",
  955. ] * 10 + [
  956. ],
  957. [ # bootup phase
  958. "Desired username for admin user?",
  959. "Desired password for admin user?",
  960. "Please repeat the password",
  961. "Passwords match!",
  962. "Welcome to the Model Management Interface v2.0!",
  963. "Use the 'help' command for a list of possible commands",
  964. "Ready for command...",
  965. # model_add
  966. "Creating new model!",
  967. "Model type?",
  968. "Model name?",
  969. "Waiting for model constructors...",
  970. "Model upload success!",
  971. "Ready for command...",
  972. # model_add
  973. "Creating new model!",
  974. "Model type?",
  975. "Model name?",
  976. "Waiting for model constructors...",
  977. "Model upload success!",
  978. "Ready for command...",
  979. # model_add
  980. "Creating new model!",
  981. "Model type?",
  982. "Model name?",
  983. "Waiting for model constructors...",
  984. "Model upload success!",
  985. "Ready for command...",
  986. # model_list
  987. set([" SimpleClassDiagrams : SimpleClassDiagrams",
  988. " CoreFormalism : SimpleClassDiagrams",
  989. " PetriNets : SimpleClassDiagrams",
  990. " my_pn : PetriNets",
  991. " PetriNets_Runtime : SimpleClassDiagrams",
  992. " core : CoreFormalism"]),
  993. "Ready for command...",
  994. # transformation_add_MT_language
  995. "Formalisms to include (terminate with empty string)?",
  996. "Name of the RAMified transformation metamodel?",
  997. "Ready for command...",
  998. # model_list
  999. set([" SimpleClassDiagrams : SimpleClassDiagrams",
  1000. " CoreFormalism : SimpleClassDiagrams",
  1001. " PetriNets_Runtime : SimpleClassDiagrams",
  1002. " PetriNets : SimpleClassDiagrams",
  1003. " __merged_PetriNets_RAM : SimpleClassDiagrams",
  1004. " PetriNets_RAM : SimpleClassDiagrams",
  1005. " my_pn : PetriNets",
  1006. " core : CoreFormalism"]),
  1007. "Ready for command...",
  1008. # model_modify
  1009. "Which model do you want to modify?",
  1010. "Model loaded, ready for commands!",
  1011. "Use 'help' command for a list of possible commands",
  1012. "Please give your command.",
  1013. # instantiate 1
  1014. "Type to instantiate?",
  1015. "Name of new element?",
  1016. "Source name?",
  1017. "Destination name?",
  1018. "Instantiation successful!",
  1019. "Please give your command.",
  1020. # instantiate 2
  1021. "Type to instantiate?",
  1022. "Name of new element?",
  1023. "Source name?",
  1024. "Destination name?",
  1025. "Instantiation successful!",
  1026. "Please give your command.",
  1027. # instantiate 3
  1028. "Type to instantiate?",
  1029. "Name of new element?",
  1030. "Source name?",
  1031. "Destination name?",
  1032. "Instantiation successful!",
  1033. "Please give your command.",
  1034. # instantiate 4
  1035. "Type to instantiate?",
  1036. "Name of new element?",
  1037. "Source name?",
  1038. "Destination name?",
  1039. "Instantiation successful!",
  1040. "Please give your command.",
  1041. "Ready for command...",
  1042. # transformation_RAMify
  1043. "Which metamodel do you want to RAMify?",
  1044. "Where do you want to store the RAMified metamodel?",
  1045. "Ready for command...",
  1046. # transformation_add_MT
  1047. "RAMified metamodel to use?",
  1048. "Supported metamodels:",
  1049. set([" PetriNets",
  1050. " PetriNets_Runtime",
  1051. ]),
  1052. "",
  1053. "Which ones do you want to use as source (empty string to finish)?",
  1054. "Model added as source",
  1055. "Which ones do you want to use as target (empty string to finish)?",
  1056. "Model added as target",
  1057. "Name of new transformation?",
  1058. "Waiting for model constructors...",
  1059. "Ready for command...",
  1060. # transformation_add_MT
  1061. "RAMified metamodel to use?",
  1062. "Supported metamodels:",
  1063. set([" PetriNets",
  1064. " PetriNets_Runtime",
  1065. ]),
  1066. "",
  1067. "Which ones do you want to use as source (empty string to finish)?",
  1068. "Model added as source",
  1069. "Which ones do you want to use as target (empty string to finish)?",
  1070. "Model added as target",
  1071. "Name of new transformation?",
  1072. "Waiting for model constructors...",
  1073. "Ready for command...",
  1074. # transformation_add_MT
  1075. "RAMified metamodel to use?",
  1076. "Supported metamodels:",
  1077. set([" PetriNets",
  1078. " PetriNets_Runtime",
  1079. ]),
  1080. "",
  1081. "Which ones do you want to use as source (empty string to finish)?",
  1082. "Model added as source",
  1083. "Which ones do you want to use as target (empty string to finish)?",
  1084. "Model added as target",
  1085. "Name of new transformation?",
  1086. "Waiting for model constructors...",
  1087. "Ready for command...",
  1088. # transformation_add_MT
  1089. "RAMified metamodel to use?",
  1090. "Supported metamodels:",
  1091. set([" PetriNets",
  1092. " PetriNets_Runtime",
  1093. ]),
  1094. "",
  1095. "Which ones do you want to use as source (empty string to finish)?",
  1096. "Model added as source",
  1097. "Which ones do you want to use as target (empty string to finish)?",
  1098. "Name of new transformation?",
  1099. "Waiting for model constructors...",
  1100. "Ready for command...",
  1101. # model_list
  1102. set([" SimpleClassDiagrams : SimpleClassDiagrams",
  1103. " CoreFormalism : SimpleClassDiagrams",
  1104. " PetriNets_Runtime : SimpleClassDiagrams",
  1105. " PetriNets : SimpleClassDiagrams",
  1106. " pn_print : PetriNets_RAM",
  1107. " pn_design_to_runtime : PetriNets_RAM",
  1108. " pn_runtime_to_design : PetriNets_RAM",
  1109. " pn_step : PetriNets_RAM",
  1110. " __merged_PetriNets_RAM : SimpleClassDiagrams",
  1111. " PetriNets_RAM : SimpleClassDiagrams",
  1112. " my_pn : PetriNets",
  1113. " core : CoreFormalism"]),
  1114. "Ready for command...",
  1115. # transformation_list
  1116. set(["[ModelTransformation] pn_print : PetriNets_RAM",
  1117. "[ModelTransformation] pn_design_to_runtime : PetriNets_RAM",
  1118. "[ModelTransformation] pn_runtime_to_design : PetriNets_RAM",
  1119. "[ModelTransformation] pn_step : PetriNets_RAM"]),
  1120. "Ready for command...",
  1121. # transformation_execute (pn_print)
  1122. "Which transformation do you want to execute?",
  1123. "Which model to bind for source element PetriNets",
  1124. set(['"lock_available" --> 1',
  1125. '"critical_section_1" --> 0',
  1126. '"critical_section_2" --> 0',
  1127. ]),
  1128. "Transformation executed with result: True",
  1129. "Ready for command...",
  1130. # transformation_execute (pn_design_to_runtime)
  1131. "Which transformation do you want to execute?",
  1132. "Which model to bind for source element PetriNets",
  1133. "Which model to create for target element PetriNets_Runtime",
  1134. "Transformation executed with result: True",
  1135. "Ready for command...",
  1136. ] + \
  1137. step_and_print() * 10 +
  1138. [],
  1139. mode))