Skip to content

Commit

Permalink
Add test for ecore toolbar, and fixes to exporting code. (#69)
Browse files Browse the repository at this point in the history
* Add test for ecore toolbar, and fixes to exporting code.
* Note: Does not check for successful creation of the file
  • Loading branch information
BentleyJOakes authored Sep 10, 2018
1 parent 51ddc9b commit 7e9d54a
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 4 deletions.
6 changes: 3 additions & 3 deletions plugins/exportM2Ecore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion plugins/exportMM2Ecore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down
68 changes: 68 additions & 0 deletions tests/99_ecore_toolbar_test.js
Original file line number Diff line number Diff line change
@@ -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();
},


};

0 comments on commit 7e9d54a

Please sign in to comment.