AMBARI-18177. [UI] Atlas Zookeeper properties should be updated on zookeeper 
add/remove operations (onechiporenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/71875920
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/71875920
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/71875920

Branch: refs/heads/branch-dev-logsearch
Commit: 7187592036110295285a09b93c7c4da35f53f677
Parents: 1b5e1c0
Author: Oleg Nechiporenko <onechipore...@apache.org>
Authored: Wed Aug 17 11:11:06 2016 +0300
Committer: Oleg Nechiporenko <onechipore...@apache.org>
Committed: Wed Aug 17 11:11:06 2016 +0300

----------------------------------------------------------------------
 ambari-web/app/controllers/main/host/details.js |  20 ++-
 .../configs/add_component_config_initializer.js |  28 +++-
 .../app/utils/configs/config_initializer.js     |   4 +-
 .../configs/hosts_based_initializer_mixin.js    |   3 +-
 .../admin/kerberos/step1_controller_test.js     |  10 +-
 .../test/controllers/main/host/details_test.js  |  50 +++++++
 ambari-web/test/utils/config_test.js            | 130 ++++++++++--------
 .../test/utils/configs_collection_test.js       | 136 +++++++++++--------
 ambari-web/test/utils/http_client_test.js       |   4 +-
 .../common/widget/graph_widget_view_test.js     |   2 +-
 10 files changed, 250 insertions(+), 137 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/71875920/ambari-web/app/controllers/main/host/details.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host/details.js 
b/ambari-web/app/controllers/main/host/details.js
index 1364adf..2076333 100644
--- a/ambari-web/app/controllers/main/host/details.js
+++ b/ambari-web/app/controllers/main/host/details.js
@@ -774,6 +774,7 @@ App.MainHostDetailsController = 
Em.Controller.extend(App.SupportClientConfigsDow
   updateZkConfigs: function (configs) {
     var portValue = configs['zoo.cfg'] && Em.get(configs['zoo.cfg'], 
'clientPort');
     var zkPort = typeof portValue === 'undefined' ? '2181' : portValue;
+    var infraSolrZnode = configs['infra-solr-env'] ? 
Em.get(configs['infra-solr-env'], 'infra_solr_znode') : '/ambari-solr';
     var initializer = App.AddZooKeeperComponentsInitializer;
     var hostComponentsTopology = {
       masterComponentHosts: []
@@ -788,7 +789,8 @@ App.MainHostDetailsController = 
Em.Controller.extend(App.SupportClientConfigsDow
       }
     }
     var dependencies = {
-      zkClientPort: zkPort
+      zkClientPort: zkPort,
+      infraSolrZnode: infraSolrZnode
     };
     hostComponentsTopology.masterComponentHosts = masterComponents;
     Em.keys(configs).forEach(function(fileName) {
@@ -1337,6 +1339,10 @@ App.MainHostDetailsController = 
Em.Controller.extend(App.SupportClientConfigsDow
     if (services.someProperty('serviceName', 'KAFKA')) {
       urlParams.push('(type=kafka-broker&tag=' + 
data.Clusters.desired_configs['kafka-broker'].tag + ')');
     }
+    if (services.someProperty('serviceName', 'ATLAS')) {
+      urlParams.push('(type=application-properties&tag=' + 
data.Clusters.desired_configs['application-properties'].tag + ')');
+      urlParams.push('(type=infra-solr-env&tag=' + 
data.Clusters.desired_configs['infra-solr-env'].tag + ')');
+    }
     return urlParams;
   },
 
@@ -1415,6 +1421,18 @@ App.MainHostDetailsController = 
Em.Controller.extend(App.SupportClientConfigsDow
         }
       );
     }
+    if (installedServiceNames.contains('ATLAS')) {
+      groups.push(
+        {
+          properties: {
+            'application-properties': configs['application-properties']
+          },
+          properties_attributes: {
+            'application-properties': attributes['application-properties']
+          }
+        }
+      );
+    }
     this.saveConfigsBatch(groups, 'ZOOKEEPER_SERVER');
   },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/71875920/ambari-web/app/utils/configs/add_component_config_initializer.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/configs/add_component_config_initializer.js 
b/ambari-web/app/utils/configs/add_component_config_initializer.js
index 6a8ab4c..7e3fedf 100644
--- a/ambari-web/app/utils/configs/add_component_config_initializer.js
+++ b/ambari-web/app/utils/configs/add_component_config_initializer.js
@@ -59,7 +59,10 @@ App.AddComponentConfigInitializer = 
App.HaConfigInitializerClass.extend(App.Host
       'nimbus.seeds': 
this.getHostsListComponentJSONStringifiedConfig('NIMBUS', true),
       'hadoop.proxyuser.{{webhcatUser}}.hosts': 
this.getComponentsHostsConfig(['HIVE_SERVER', 'WEBHCAT_SERVER', 
'HIVE_METASTORE'], false, true),
       'hadoop.proxyuser.{{hiveUser}}.hosts': 
this.getComponentsHostsConfig(['HIVE_SERVER', 'WEBHCAT_SERVER', 
'HIVE_METASTORE'], false, true),
-      'hive.metastore.uris': this.getHostsWithPortConfig(['HIVE_METASTORE'], 
'thrift://', '', ',thrift://', 'hiveMetastorePort', true)
+      'hive.metastore.uris': this.getHostsWithPortConfig(['HIVE_METASTORE'], 
'thrift://', '', ',thrift://', 'hiveMetastorePort', true),
+      'atlas.audit.hbase.zookeeper.quorum': 
this.getHostsListComponentConfig('ZOOKEEPER_SERVER', true),
+      'atlas.graph.storage.hostname': 
this.getHostsListComponentConfig('ZOOKEEPER_SERVER', true),
+      'atlas.kafka.zookeeper.connect': 
this.getHostsWithPortConfig('ZOOKEEPER_SERVER', '', '', ',', 'zkClientPort', 
true)
     };
   },
 
@@ -72,7 +75,8 @@ App.AddComponentConfigInitializer = 
App.HaConfigInitializerClass.extend(App.Host
    */
   __defaultUniqueInitializers: {
     'yarn.resourcemanager.zk-address': '_initYarnRMZkAdress',
-    'templeton.hive.properties': '_initTempletonHiveProperties'
+    'templeton.hive.properties': '_initTempletonHiveProperties',
+    'atlas.graph.index.search.solr.zookeeper-url': 
'_initAtlasGraphIndexSearchSolrZkUrl'
   },
 
   /**
@@ -238,6 +242,20 @@ App.AddComponentConfigInitializer = 
App.HaConfigInitializerClass.extend(App.Host
     return configProperty;
   },
 
+  _initAtlasGraphIndexSearchSolrZkUrl: function (configProperty, localDB, 
dependencies, initializer) {
+    var solr = dependencies.infraSolrZnode;
+    return this._initAsHostsWithPort(configProperty, localDB, dependencies, {
+      component: 'ZOOKEEPER_SERVER',
+      componentExists: true,
+      modifier: {
+        prefix: '',
+        suffix: solr,
+        delimiter: solr + ','
+      },
+      portKey: 'zkClientPort'
+    });
+  },
+
   /**
    * Set up `this.initializers` and `this.uniqueInitializers` properties 
according
    * to property list names.
@@ -282,7 +300,11 @@ App.AddZooKeeperComponentsInitializer = 
App.AddComponentConfigInitializer.create
     'yarn.resourcemanager.zk-address',
     'hive.zookeeper.quorum',
     'storm.zookeeper.servers',
-    'hadoop.registry.zk.quorum'
+    'hadoop.registry.zk.quorum',
+    'atlas.audit.hbase.zookeeper.quorum',
+    'atlas.graph.index.search.solr.zookeeper-url',
+    'atlas.graph.storage.hostname',
+    'atlas.kafka.zookeeper.connect'
   ]
 });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/71875920/ambari-web/app/utils/configs/config_initializer.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/configs/config_initializer.js 
b/ambari-web/app/utils/configs/config_initializer.js
index b4c47f2..3446c86 100644
--- a/ambari-web/app/utils/configs/config_initializer.js
+++ b/ambari-web/app/utils/configs/config_initializer.js
@@ -173,9 +173,9 @@ App.ConfigInitializer = 
App.ConfigInitializerClass.create(App.MountPointsBasedIn
   _initHiveDatabaseValue: function (configProperty) {
     var newMySQLDBOption = Em.get(configProperty, 
'options').findProperty('displayName', 'New MySQL Database');
     if (newMySQLDBOption) {
-      var isNewMySQLDBOptionHidden = 
!App.get('supports.alwaysEnableManagedMySQLForHive') && 
App.get('router.currentState.name') != 'configs' &&
+      var isNewMySQLDBOptionHidden = 
!App.get('supports.alwaysEnableManagedMySQLForHive') && 
App.get('router.currentState.name') !== 'configs' &&
         !App.get('isManagedMySQLForHiveEnabled');
-      if (isNewMySQLDBOptionHidden && Em.get(configProperty, 'value') == 'New 
MySQL Database') {
+      if (isNewMySQLDBOptionHidden && Em.get(configProperty, 'value') === 'New 
MySQL Database') {
         Em.set(configProperty, 'value', 'Existing MySQL Database');
       }
       Em.set(newMySQLDBOption, 'hidden', isNewMySQLDBOptionHidden);

http://git-wip-us.apache.org/repos/asf/ambari/blob/71875920/ambari-web/app/utils/configs/hosts_based_initializer_mixin.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/configs/hosts_based_initializer_mixin.js 
b/ambari-web/app/utils/configs/hosts_based_initializer_mixin.js
index 5c51c12..d0d2503 100644
--- a/ambari-web/app/utils/configs/hosts_based_initializer_mixin.js
+++ b/ambari-web/app/utils/configs/hosts_based_initializer_mixin.js
@@ -118,9 +118,8 @@ App.HostsBasedInitializerMixin = Em.Mixin.create({
       var hasFound = 
initializer.components.contains(masterComponent.component);
       if (Em.isNone(initializer.isInstalled)) {
         return hasFound;
-      } else {
-        return hasFound && masterComponent.isInstalled === 
initializer.isInstalled;
       }
+      return hasFound && masterComponent.isInstalled === 
initializer.isInstalled;
     }).sortProperty('hostName').mapProperty('hostName');
     if (!initializer.asArray) {
       hostNames = hostNames.uniq().join(',');

http://git-wip-us.apache.org/repos/asf/ambari/blob/71875920/ambari-web/test/controllers/main/admin/kerberos/step1_controller_test.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/test/controllers/main/admin/kerberos/step1_controller_test.js 
b/ambari-web/test/controllers/main/admin/kerberos/step1_controller_test.js
index a90fa72..9280367f 100644
--- a/ambari-web/test/controllers/main/admin/kerberos/step1_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/kerberos/step1_controller_test.js
@@ -34,14 +34,8 @@ describe('App.KerberosWizardStep1Controller', function() {
     it("test", function() {
       var options=controller.get('options');
       controller.propertyDidChange('selectedOption');
-      options.forEach(function(option) {
-        if (option.value === controller.get('selectedItem')) {
-          var preConditions=option.preConditions;
-          preConditions.forEach(function(condition) {
-            expect(condition.get('checked')).to.be.false;
-          });
-        }          
-      }, this);
+      var option = options.findProperty('value', 
controller.get('selectedItem'));
+      expect(option.preConditions.everyProperty('checked', false)).to.be.true;
     });
     
   });

http://git-wip-us.apache.org/repos/asf/ambari/blob/71875920/ambari-web/test/controllers/main/host/details_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/host/details_test.js 
b/ambari-web/test/controllers/main/host/details_test.js
index 71efbae..154d0b2 100644
--- a/ambari-web/test/controllers/main/host/details_test.js
+++ b/ambari-web/test/controllers/main/host/details_test.js
@@ -1369,6 +1369,56 @@ describe('App.MainHostDetailsController', function () {
             }
           }
         }
+      },
+      {
+        m: 'ATLAS configs',
+        hostComponentModel: makeHostComponentModel('ZOOKEEPER_SERVER', 
['host1', 'host2']),
+        configs: {
+          'application-properties': {
+            'atlas.audit.hbase.zookeeper.quorum': '',
+            'atlas.graph.index.search.solr.zookeeper-url': '',
+            'atlas.graph.storage.hostname': '',
+            'atlas.kafka.zookeeper.connect': ''
+          }
+        },
+        e: {
+          configs: {
+            'application-properties': {
+              'atlas.audit.hbase.zookeeper.quorum': 'host1,host2',
+              'atlas.graph.index.search.solr.zookeeper-url': 
'host1:2181/ambari-solr,host2:2181/ambari-solr',
+              'atlas.graph.storage.hostname': 'host1,host2',
+              'atlas.kafka.zookeeper.connect': 'host1:2181,host2:2181'
+            }
+          }
+        }
+      },
+      {
+        m: 'ATLAS configs with custom solr',
+        hostComponentModel: makeHostComponentModel('ZOOKEEPER_SERVER', 
['host1', 'host2']),
+        configs: {
+          'infra-solr-env': {
+            'infra_solr_znode': '/custom-solr'
+          },
+          'application-properties': {
+            'atlas.audit.hbase.zookeeper.quorum': '',
+            'atlas.graph.index.search.solr.zookeeper-url': '',
+            'atlas.graph.storage.hostname': '',
+            'atlas.kafka.zookeeper.connect': ''
+          }
+        },
+        e: {
+          configs: {
+            'infra-solr-env': {
+              'infra_solr_znode': '/custom-solr'
+            },
+            'application-properties': {
+              'atlas.audit.hbase.zookeeper.quorum': 'host1,host2',
+              'atlas.graph.index.search.solr.zookeeper-url': 
'host1:2181/custom-solr,host2:2181/custom-solr',
+              'atlas.graph.storage.hostname': 'host1,host2',
+              'atlas.kafka.zookeeper.connect': 'host1:2181,host2:2181'
+            }
+          }
+        }
       }
     ];
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/71875920/ambari-web/test/utils/config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/config_test.js 
b/ambari-web/test/utils/config_test.js
index 99b3630..bb54239 100644
--- a/ambari-web/test/utils/config_test.js
+++ b/ambari-web/test/utils/config_test.js
@@ -34,11 +34,9 @@ describe('App.config', function() {
     ];
 
     tests.forEach(function(t) {
-      describe(t.m, function() {
-        it('' , function() {
+        it(t.m, function() {
           expect(App.config.getOriginalFileName(t.input)).to.equal(t.output);
-        })
-      })
+        });
     });
   });
 
@@ -49,11 +47,9 @@ describe('App.config', function() {
     ];
 
     tests.forEach(function(t) {
-      describe(t.m, function() {
-        it('' , function() {
-          
expect(App.config.getConfigTagFromFileName(t.input)).to.equal(t.output);
-        })
-      })
+      it(t.m, function() {
+        
expect(App.config.getConfigTagFromFileName(t.input)).to.equal(t.output);
+      });
     });
   });
 
@@ -537,6 +533,19 @@ describe('App.config', function() {
 
   describe('#addYarnCapacityScheduler', function () {
     var input, res, configs, csConfig;
+    res = {
+      'value': 'n1=v1\nn2=v2\n',
+      'serviceName': 'YARN',
+      'savedValue': 'n1=sv1\nn2=sv2\n',
+      'recommendedValue': 'n1=rv1\nn2=rv2\n',
+      'isFinal': true,
+      'savedIsFinal': true,
+      'recommendedIsFinal': true,
+      'category': 'CapacityScheduler',
+      'displayName': 'Capacity Scheduler',
+      'description': 'Capacity Scheduler properties',
+      'displayType': 'capacityScheduler'
+    };
     beforeEach(function () {
       sinon.stub(App.config, 'getPropertiesFromTheme').returns([]);
       input = [
@@ -566,19 +575,6 @@ describe('App.config', function() {
         })
       ];
 
-      res = {
-        'value': 'n1=v1\nn2=v2\n',
-        'serviceName': 'YARN',
-        'savedValue': 'n1=sv1\nn2=sv2\n',
-        'recommendedValue': 'n1=rv1\nn2=rv2\n',
-        'isFinal': true,
-        'savedIsFinal': true,
-        'recommendedIsFinal': true,
-        'category': 'CapacityScheduler',
-        'displayName': 'Capacity Scheduler',
-        'description': 'Capacity Scheduler properties',
-        'displayType': 'capacityScheduler'
-      };
       configs = App.config.addYarnCapacityScheduler(input);
       csConfig = configs.findProperty('category', 'CapacityScheduler');
     });
@@ -586,12 +582,12 @@ describe('App.config', function() {
       App.config.getPropertiesFromTheme.restore();
     });
 
-    it('check result config', function () {
-      for (var k in res) {
-        if (res.hasOwnProperty(k)) {
+    describe('check result config', function () {
+      Object.keys(res).forEach(function (k) {
+        it(k, function () {
           expect(csConfig.get(k)).to.eql(res[k]);
-        }
-      }
+        });
+      });
     });
   });
 
@@ -777,7 +773,7 @@ describe('App.config', function() {
   });
 
   describe('#createCustomGroupConfig', function() {
-    var override, configGroup, result, expected;
+    var override, configGroup, result;
     beforeEach(function () {
       sinon.stub(App.config, 'createDefaultConfig', function (name, filename) {
         return { propertyName: name, filename: filename };
@@ -787,23 +783,27 @@ describe('App.config', function() {
         propertyName: 'p1',
         filename: 'f1'
       };
-      expected = {
-        propertyName: 'p1',
-        filename: 'f1',
-        isOriginalSCP: false,
-        overrides: null,
-        group: configGroup,
-        parentSCP: null
-      }
       result = App.config.createCustomGroupConfig(override, configGroup);
     });
     afterEach(function () {
       App.config.createDefaultConfig.restore();
     });
-    it('createsCustomOverride', function () {
-      for (var k in expected) {
-        expect(result.get(k)).to.eql(expected[k]);
-      }
+    describe('createsCustomOverride', function () {
+      var expected = {
+        propertyName: 'p1',
+        filename: 'f1',
+        isOriginalSCP: false,
+        overrides: null,
+        parentSCP: null
+      };
+      Object.keys(expected).forEach(function (k) {
+        it(k, function () {
+          expect(result.get(k)).to.be.eql(expected[k]);
+        });
+      });
+      it('config group is valid', function () {
+        expect(result.get('group')).to.be.eql(configGroup);
+      });
     });
 
     it('updates configGroup properties', function () {
@@ -1242,22 +1242,30 @@ describe('App.config', function() {
 
     beforeEach(function() {
       sinon.stub(App.config, 'parseIdentities');
+      App.config.parseDescriptor(input);
     });
 
     afterEach(function() {
       App.config.parseIdentities.restore();
     });
-    it('runs parseIdentities for each service and component', function() {
-      App.config.parseDescriptor(input);
+
+    it('`parseIdentities` called 3 times', function () {
+      expect(App.config.parseIdentities.calledThrice).to.be.true;
+    });
+
+    it('1st call', function () {
       expect(App.config.parseIdentities.calledWith({
-        serviceName: 'serviceName',
-        components: [
-          { componentName: 'componentName1' },
-          { componentName: 'componentName2' }
-        ]
-      }));
-      expect(App.config.parseIdentities.calledWith({ componentName: 
'componentName2' }));
-      expect(App.config.parseIdentities.calledWith({ componentName: 
'componentName2' }));
+        "serviceName": "serviceName",
+        "components": [{"componentName": "componentName2"}, {"componentName": 
"componentName2"}]
+      }, {})).to.be.true;
+    });
+
+    it('2nd call', function () {
+      expect(App.config.parseIdentities.calledWith({ componentName: 
'componentName2' })).to.be.true;
+    });
+
+    it('3rd call', function () {
+      expect(App.config.parseIdentities.calledWith({ componentName: 
'componentName2' })).to.be.true;
     });
   });
 
@@ -1385,7 +1393,7 @@ describe('App.config', function() {
       App.config.get.restore();
     });
 
-    it('create service config object based on input', function () {
+    describe('create service config object based on input', function () {
       var res = {
         serviceName: 'serviceName1',
         displayName: 'displayName1',
@@ -1395,12 +1403,14 @@ describe('App.config', function() {
         initConfigsLength: 1,
         dependentServiceNames: []
       };
-      for (var k in res) {
-        expect(App.config.createServiceConfig('serviceName1', configGroups, 
configs, 1).get(k)).to.eql(res[k]);
-      }
+      Object.keys(res).forEach(function (k) {
+        it(k, function () {
+          expect(App.config.createServiceConfig('serviceName1', configGroups, 
configs, 1).get(k)).to.eql(res[k]);
+        });
+      });
     });
 
-    it('create default service config object', function () {
+    describe('create default service config object', function () {
       var res = {
         serviceName: 'serviceName1',
         displayName: 'displayName1',
@@ -1409,9 +1419,11 @@ describe('App.config', function() {
         initConfigsLength: 0,
         dependentServiceNames: []
       };
-      for (var k in res) {
-        
expect(App.config.createServiceConfig('serviceName1').get(k)).to.eql(res[k]);
-      }
+      Object.keys(res).forEach(function (k) {
+        it(k, function() {
+          
expect(App.config.createServiceConfig('serviceName1').get(k)).to.eql(res[k]);
+        });
+      });
     });
   });
 
@@ -1475,7 +1487,7 @@ describe('App.config', function() {
     });
     it('runs mapper', function () {
       App.config.saveConfigsToModel({configs: 'configs'});
-      expect(App.stackConfigPropertiesMapper.map.calledWith({configs: 
'configs'}));
+      expect(App.stackConfigPropertiesMapper.map.calledWith({configs: 
'configs'})).to.be.true;
     });
   });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/71875920/ambari-web/test/utils/configs_collection_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/configs_collection_test.js 
b/ambari-web/test/utils/configs_collection_test.js
index bd97950..4a76ae9 100644
--- a/ambari-web/test/utils/configs_collection_test.js
+++ b/ambari-web/test/utils/configs_collection_test.js
@@ -34,29 +34,32 @@ describe('App.configsCollection', function () {
 
   describe('#add', function () {
 
-    var cases = [
+    var throwCases = [
       {
+        obj: undefined,
         collection: [],
-        isError: false,
-        title: 'initial state'
+        isError: true,
+        title: 'null passed'
       },
       {
-        obj: undefined,
+        obj: {},
         collection: [],
         isError: true,
-        title: 'no item passed'
+        title: 'no id passed'
       },
       {
         obj: undefined,
         collection: [],
         isError: true,
-        title: 'null passed'
-      },
+        title: 'no item passed'
+      }
+    ];
+
+    var cases = [
       {
-        obj: {},
         collection: [],
-        isError: true,
-        title: 'no id passed'
+        isError: false,
+        title: 'initial state'
       },
       {
         obj: {
@@ -114,20 +117,22 @@ describe('App.configsCollection', function () {
       }
     ];
 
+    throwCases.forEach(function (item) {
+
+      it(item.title, function () {
+        expect(function () {configsCollection.add(item.obj);}).to.throw(Error);
+      });
+
+    });
+
     cases.forEach(function (item) {
 
       describe(item.title, function () {
 
         beforeEach(function () {
-          try {
-            if (item.hasOwnProperty('obj')) {
-              configsCollection.add(item.obj);
-            }
-          } catch (e) {}
-        });
-
-        it('thrown error', function () {
-          expect(Em.assert.threw()).to.equal(item.isError);
+          if (item.hasOwnProperty('obj')) {
+            configsCollection.add(item.obj);
+          }
         });
 
         it('configs array', function () {
@@ -148,7 +153,7 @@ describe('App.configsCollection', function () {
 
   describe('#getConfig', function () {
 
-    var cases = [
+    var throwCases = [
       {
         result: undefined,
         isError: true,
@@ -159,7 +164,10 @@ describe('App.configsCollection', function () {
         result: undefined,
         isError: true,
         title: 'invalid id passed'
-      },
+      }
+    ];
+
+    var cases = [
       {
         id: 1,
         result: {
@@ -184,6 +192,17 @@ describe('App.configsCollection', function () {
       }
     ];
 
+    throwCases.forEach(function (item) {
+
+      it(item.title, function () {
+        configsCollection.add({
+          id: 1
+        });
+        expect(function () 
{configsCollection.getConfig(item.id);}).to.throw(Error);
+      });
+
+    });
+
     cases.forEach(function (item) {
 
       describe(item.title, function () {
@@ -194,13 +213,7 @@ describe('App.configsCollection', function () {
           configsCollection.add({
             id: 1
           });
-          try {
-            result = configsCollection.getConfig(item.id);
-          } catch (e) {}
-        });
-
-        it('thrown error', function () {
-          expect(Em.assert.threw()).to.equal(item.isError);
+          result = configsCollection.getConfig(item.id);
         });
 
         it('returned value', function () {
@@ -215,20 +228,22 @@ describe('App.configsCollection', function () {
 
   describe('#getConfigByName', function () {
 
-    var configIds = ['n0_f0', 'n1_f1'],
-      cases = [
-        {
-          fileName: 'f0',
-          result: undefined,
-          isError: true,
-          title: 'no name passed'
-        },
-        {
-          name: 'n0',
-          result: undefined,
-          isError: true,
-          title: 'no filename passed'
-        },
+    var configIds = ['n0_f0', 'n1_f1'];
+    var throwCases = [
+      {
+        fileName: 'f0',
+        result: undefined,
+        isError: true,
+        title: 'no name passed'
+      },
+      {
+        name: 'n0',
+        result: undefined,
+        isError: true,
+        title: 'no filename passed'
+      }
+    ];
+    var cases = [
         {
           name: 'n0',
           fileName: 'f0',
@@ -247,6 +262,25 @@ describe('App.configsCollection', function () {
         }
       ];
 
+    beforeEach(function () {
+      sinon.stub(App.config, 'configId', function (name, fileName) {
+        return name + '_' + fileName;
+      });
+    });
+
+    afterEach(function () {
+      configsCollection.clearAll();
+      App.config.configId.restore();
+    });
+
+    throwCases.forEach(function (item) {
+
+      it(item.title, function () {
+        expect(function () {configsCollection.getConfigByName(item.name, 
item.fileName);}).to.throw(Error);
+      });
+
+    });
+
     cases.forEach(function (item) {
 
       describe(item.title, function () {
@@ -254,27 +288,13 @@ describe('App.configsCollection', function () {
         var result;
 
         beforeEach(function () {
-          sinon.stub(App.config, 'configId', function (name, fileName) {
-            return name + '_' + fileName;
-          });
+
           configIds.forEach(function (id) {
             configsCollection.add({
               id: id
             });
           });
-          try {
-            result = configsCollection.getConfigByName(item.name, 
item.fileName);
-          } catch (e) {}
-        });
-
-        afterEach(function () {
-          App.config.configId.restore();
-          configsCollection.clearAll();
-        });
-
-
-        it('thrown error', function () {
-          expect(Em.assert.threw()).to.equal(item.isError);
+          result = configsCollection.getConfigByName(item.name, item.fileName);
         });
 
         it('returned value', function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/71875920/ambari-web/test/utils/http_client_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/http_client_test.js 
b/ambari-web/test/utils/http_client_test.js
index 9e158a4..589c44e 100644
--- a/ambari-web/test/utils/http_client_test.js
+++ b/ambari-web/test/utils/http_client_test.js
@@ -69,9 +69,7 @@ describe('App.HttpClient', function () {
         beforeEach(function () {
           sinon.stub(App.ajax, 'defaultErrorHandler', Em.K);
           sinon.spy(Em, 'assert');
-          try {
-            App.HttpClient.defaultErrorHandler(jqXHR, '', '', 
'http://localhost');
-          } catch (e) {}
+          App.HttpClient.defaultErrorHandler(jqXHR, '', '', 
'http://localhost');
         });
 
         afterEach(function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/71875920/ambari-web/test/views/common/widget/graph_widget_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/widget/graph_widget_view_test.js 
b/ambari-web/test/views/common/widget/graph_widget_view_test.js
index 9c8458c..70fcafb 100644
--- a/ambari-web/test/views/common/widget/graph_widget_view_test.js
+++ b/ambari-web/test/views/common/widget/graph_widget_view_test.js
@@ -424,7 +424,7 @@ describe('App.GraphWidgetView', function () {
 
     beforeEach(function() {
       sinon.stub(view, 'adjustData', function (dataLinks) {
-        dataLinks['m1'][1] = [3, 1112];
+        dataLinks.m1[1] = [3, 1112];
       });
     });
 

Reply via email to