From 7e9d54a1943f0834cf2a751aeb9047f996e03514 Mon Sep 17 00:00:00 2001 From: BentleyJOakes Date: Mon, 10 Sep 2018 19:03:58 -0400 Subject: [PATCH] Add test for ecore toolbar, and fixes to exporting code. (#69) * Add test for ecore toolbar, and fixes to exporting code. * Note: Does not check for successful creation of the file --- plugins/exportM2Ecore.js | 6 +-- plugins/exportMM2Ecore.js | 3 +- tests/99_ecore_toolbar_test.js | 68 ++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 tests/99_ecore_toolbar_test.js diff --git a/plugins/exportM2Ecore.js b/plugins/exportM2Ecore.js index e7ce8eac..5a1d104c 100644 --- a/plugins/exportM2Ecore.js +++ b/plugins/exportM2Ecore.js @@ -175,7 +175,7 @@ module.exports = { attr.name = key; attr.value = as.nodes[keyDest][key].value; var attrType = as.nodes[keyDest][key].type; - if (attr.value.length > 0) { + if (attr.value != undefined && attr.value.length > 0) { if (attrType.startsWith("list")) attr.list = true; else @@ -206,11 +206,11 @@ module.exports = { remove(keys, "$type"); for (var i = 0; i < keys.length; i++) { var attr = findAttribute(keys[i], keyDest); - if (attr.value.length > 0) + if (attr.value != undefined && attr.value.length > 0) elem.attributes.push(attr); } var contain = []; - if (!isInRoot(keyDest)) + if (!isInRoot(keyDest) && nodeKey != keyDest) contain = findContained(keyDest); elem.contain = contain; listContained.push(elem); diff --git a/plugins/exportMM2Ecore.js b/plugins/exportMM2Ecore.js index c0e8ea7b..a7cea204 100644 --- a/plugins/exportMM2Ecore.js +++ b/plugins/exportMM2Ecore.js @@ -350,7 +350,8 @@ module.exports = { function setMapType(eAttribute, datatype, defaultValue) { //var keys = datatype.split('[')[1].split(']')[0]; //keys = keys.split(','); - var values = datatype.split(']')[1].split('[')[1].split(']')[0]; + //var values = datatype.split(']')[1].split('[')[1].split(']')[0]; + var values = datatype.split('<')[1].split('>')[0]; values = values.split(','); //for(var i = 0; i < keys.length; i++) diff --git a/tests/99_ecore_toolbar_test.js b/tests/99_ecore_toolbar_test.js new file mode 100644 index 00000000..f00c92b1 --- /dev/null +++ b/tests/99_ecore_toolbar_test.js @@ -0,0 +1,68 @@ +let test_utils = require('./test_utils'); +let model_building_utils = require('./model_building_utils'); +let user = "./users/testuser/"; + +let fs = require('fs'); + +let ecore_dir = "./exported_to_ecore/"; + +// tests the ecore toolbar +module.exports = { + + beforeEach : function (client) { + client.url('http://localhost:8124/atompm').pause(1000); + }, + + 'Login' : function (client) { + test_utils.login(client); + }, + + + 'Export MM test': function (client) { + model_building_utils.load_model(client, "autotest", "autotest.model"); + + test_utils.load_toolbar(client, ["Toolbars/Ecore/Export2Ecore.buttons.model"]); + + let MMbutton = "#Toolbars\\2f Ecore\\2f Export2Ecore\\2e buttons\\2e model\\2f ExportMM2Ecore"; + client.waitForElementPresent(MMbutton, 2000, "Load MM Button"); + client.click(MMbutton); + + let dialog_btn = "#dialog_btn"; + client.waitForElementPresent(dialog_btn, 2000, "Load MM Menu"); + client.click(dialog_btn); + + // client.pause(3000); + + // let ecore_path = ecore_dir + "autotestMetamodel.ecore"; + // client.verify.ok(fs.existsSync(ecore_dir), "Check folder existance: '" + ecore_dir + "'"); + // client.verify.ok(fs.existsSync(ecore_path), "Check file existance: '" + ecore_path + "'"); + + }, + + 'Export M test': function (client) { + model_building_utils.load_model(client, "autotest", "autotest_instance.model"); + + test_utils.load_toolbar(client, ["Toolbars/Ecore/Export2Ecore.buttons.model"]); + + let Mbutton = "#Toolbars\\2f Ecore\\2f Export2Ecore\\2e buttons\\2e model\\2f ExportM2Ecore"; + client.waitForElementPresent(Mbutton, 2000, "Load M Button"); + client.click(Mbutton); + + let dialog_btn = "#dialog_btn"; + client.waitForElementPresent(dialog_btn, 2000, "Load M Menu"); + client.click(dialog_btn); + + // client.pause(3000); + // + // let ecore_path = ecore_dir + "autotest_instanceModel.xmi"; + // client.verify.ok(fs.existsSync(ecore_dir), "Check folder existance: '" + ecore_dir + "'"); + // client.verify.ok(fs.existsSync(ecore_path), "Check file existance: '" + ecore_path + "'"); + + }, + + after : function (client) { + client.end(); + }, + + +}; \ No newline at end of file