Pārlūkot izejas kodu

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
BentleyJOakes 6 gadi atpakaļ
vecāks
revīzija
7e9d54a194

+ 3 - 3
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);

+ 2 - 1
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++)

+ 68 - 0
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();
+    },
+
+
+};