Repository: ambari
Updated Branches:
  refs/heads/trunk 83432d70b -> 4001428d8


AMBARI-18116. Fix UT issues (onechiporenko)


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

Branch: refs/heads/trunk
Commit: 4001428d86fc9cd305d2bf14f29690f0b8b074c0
Parents: 83432d7
Author: Oleg Nechiporenko <onechipore...@apache.org>
Authored: Thu Aug 11 16:01:11 2016 +0300
Committer: Oleg Nechiporenko <onechipore...@apache.org>
Committed: Thu Aug 11 16:01:11 2016 +0300

----------------------------------------------------------------------
 ..._with_override_recommendation_parser_test.js |   4 +-
 .../common/configs/configs_loader_test.js       |  14 +-
 .../common/configs/enhanced_configs_test.js     | 157 ++++++++++++-------
 3 files changed, 106 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/4001428d/ambari-web/test/mixins/common/configs/config_with_override_recommendation_parser_test.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/test/mixins/common/configs/config_with_override_recommendation_parser_test.js
 
b/ambari-web/test/mixins/common/configs/config_with_override_recommendation_parser_test.js
index a14a14f..5b7b48c 100644
--- 
a/ambari-web/test/mixins/common/configs/config_with_override_recommendation_parser_test.js
+++ 
b/ambari-web/test/mixins/common/configs/config_with_override_recommendation_parser_test.js
@@ -194,12 +194,12 @@ describe('App.ConfigWithOverrideRecommendationParser', 
function() {
 
     it("modify attributes on existing group", function() {
       mixin._updateOverrideBoundaries(stackProperty, 'attr1', 'false', 
Em.Object.create({name: 'g1'}));
-      
expect(stackProperty.valueAttributes['g1']['attr1']).to.be.equal('false');
+      expect(stackProperty.valueAttributes.g1.attr1).to.be.equal('false');
     });
 
     it("modify attributes on new group", function() {
       mixin._updateOverrideBoundaries(stackProperty, 'attr1', 'true', 
Em.Object.create({name: 'g2'}));
-      expect(stackProperty.valueAttributes['g2']['attr1']).to.be.equal('true');
+      expect(stackProperty.valueAttributes.g2.attr1).to.be.equal('true');
     });
   });
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/4001428d/ambari-web/test/mixins/common/configs/configs_loader_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/common/configs/configs_loader_test.js 
b/ambari-web/test/mixins/common/configs/configs_loader_test.js
index 4154e8c..75f5107 100644
--- a/ambari-web/test/mixins/common/configs/configs_loader_test.js
+++ b/ambari-web/test/mixins/common/configs/configs_loader_test.js
@@ -364,13 +364,13 @@ describe('App.ConfigsLoader', function() {
     it("loadCurrentVersions should be called", function() {
       mixin.loadSelectedVersion('v1', null);
       expect(mixin.loadCurrentVersions.calledOnce).to.be.true;
-      expect(mixin.get('selectedVersion', 'v1'));
+      expect(mixin.get('selectedVersion')).to.be.equal('v1');
     });
 
     it("loadCurrentVersions should be called, default", function() {
       mixin.loadSelectedVersion('v1', Em.Object.create({isDefault: true}));
       expect(mixin.loadCurrentVersions.calledOnce).to.be.true;
-      expect(mixin.get('selectedVersion', 'v1'));
+      expect(mixin.get('selectedVersion')).to.be.equal('v1');
     });
   });
 
@@ -457,7 +457,7 @@ describe('App.ConfigsLoader', function() {
         dataIsLoaded: true,
         isVersionDefault: true,
         switchToGroup: null,
-        expected: null
+        expected: {isDefault: true}
       },
       {
         dataIsLoaded: false,
@@ -468,11 +468,13 @@ describe('App.ConfigsLoader', function() {
     ];
 
     testCases.forEach(function(test) {
-      it("dataIsLoaded = " +test.dataIsLoaded +
-         "isVersionDefault = " + test.isVersionDefault +
-         "switchToGroup = "+ test.switchToGroup , function() {
+      it("dataIsLoaded = " +test.dataIsLoaded + " " +
+         "isVersionDefault = " + test.isVersionDefault + " " +
+         "switchToGroup = "+ test.switchToGroup, function() {
         this.mock.returns(test.isVersionDefault);
+        mixin.set('dataIsLoaded', test.dataIsLoaded);
         mixin.setSelectedConfigGroup('v1', test.switchToGroup);
+        expect(mixin.get('selectedConfigGroup')).to.be.eql(test.expected);
       });
     });
   });

http://git-wip-us.apache.org/repos/asf/ambari/blob/4001428d/ambari-web/test/mixins/common/configs/enhanced_configs_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/common/configs/enhanced_configs_test.js 
b/ambari-web/test/mixins/common/configs/enhanced_configs_test.js
index ac83f59..79a7ef7 100644
--- a/ambari-web/test/mixins/common/configs/enhanced_configs_test.js
+++ b/ambari-web/test/mixins/common/configs/enhanced_configs_test.js
@@ -1127,7 +1127,7 @@ describe('App.EnhancedConfigsMixin', function () {
     };
 
     beforeEach(function() {
-      sinon.stub(App, 'showDependentConfigsPopup', function(r, callback, s) {
+      sinon.stub(App, 'showDependentConfigsPopup', function(r, callback) {
         callback();
       });
       sinon.stub(mixin, 'onSaveRecommendedPopup');
@@ -1255,68 +1255,103 @@ describe('App.EnhancedConfigsMixin', function () {
       mixin.setRecommendedForGroup.restore();
     });
 
-    it("redo is true, default group, setRecommendedForDefaultGroup should be 
called", function() {
-      mixin.set('stepConfigs', [Em.Object.create({
-        serviceName: 'S1',
-        configs: [
-          Em.Object.create({ name: 'p1', filename: 'file1'})
-        ]
-      })]);
-      var propertiesToUpdate = [Em.Object.create({
-        initialValue: 'val1',
-        recommendedValue: 'val2',
-        serviceName: 'S1',
-        propertyName: 'p1',
-        configGroup: 'g1'
-      })];
-      mixin.undoRedoRecommended(propertiesToUpdate, true);
-      
expect(mixin.setRecommendedForDefaultGroup.getCall(0).args[0]).to.be.equal('val2');
-      
expect(JSON.stringify(mixin.setRecommendedForDefaultGroup.getCall(0).args[1])).to.be.eql(JSON.stringify(Em.Object.create({
-        serviceName: 'S1',
-        configs: [
-          Em.Object.create({ name: 'p1', filename: 'file1'})
-        ]
-      })));
-      
expect(mixin.setRecommendedForDefaultGroup.getCall(0).args[2]).to.be.eql(Em.Object.create({
-        initialValue: 'val1',
-        recommendedValue: 'val2',
-        serviceName: 'S1',
-        propertyName: 'p1',
-        configGroup: 'g1'
-      }));
-      
expect(mixin.setRecommendedForDefaultGroup.getCall(0).args[3]).to.be.equal('val1');
-      
expect(mixin.setRecommendedForDefaultGroup.getCall(0).args[4]).to.be.eql(Em.Object.create({
-        name: 'p1',
-        filename: 'file1'
-      }));
+    describe("redo is true, default group, setRecommendedForDefaultGroup 
should be called", function() {
+
+      beforeEach(function () {
+        mixin.set('stepConfigs', [Em.Object.create({
+          serviceName: 'S1',
+          configs: [
+            Em.Object.create({ name: 'p1', filename: 'file1'})
+          ]
+        })]);
+        var propertiesToUpdate = [Em.Object.create({
+          initialValue: 'val1',
+          recommendedValue: 'val2',
+          serviceName: 'S1',
+          propertyName: 'p1',
+          configGroup: 'g1'
+        })];
+        mixin.undoRedoRecommended(propertiesToUpdate, true);
+      });
+
+      it('setRecommendedForDefaultGroup arg 0', function () {
+        
expect(mixin.setRecommendedForDefaultGroup.getCall(0).args[0]).to.be.equal('val2');
+      });
+
+      it('setRecommendedForDefaultGroup arg 1', function () {
+        
expect(JSON.stringify(mixin.setRecommendedForDefaultGroup.getCall(0).args[1])).to.be.eql(JSON.stringify(Em.Object.create({
+          serviceName: 'S1',
+          configs: [
+            Em.Object.create({ name: 'p1', filename: 'file1'})
+          ]
+        })));
+      });
+
+      it('setRecommendedForDefaultGroup arg 2', function () {
+        
expect(mixin.setRecommendedForDefaultGroup.getCall(0).args[2]).to.be.eql(Em.Object.create({
+          initialValue: 'val1',
+          recommendedValue: 'val2',
+          serviceName: 'S1',
+          propertyName: 'p1',
+          configGroup: 'g1'
+        }));
+      })
+
+      it('setRecommendedForDefaultGroup arg 3', function () {
+        
expect(mixin.setRecommendedForDefaultGroup.getCall(0).args[3]).to.be.equal('val1');
+      });
+
+      it('setRecommendedForDefaultGroup arg 4', function () {
+        
expect(mixin.setRecommendedForDefaultGroup.getCall(0).args[4]).to.be.eql(Em.Object.create({
+          name: 'p1',
+          filename: 'file1'
+        }));
+      });
+
     });
 
-    it("redo is false, non-default group, setRecommendedForGroup should be 
called", function() {
-      mixin.set('stepConfigs', [Em.Object.create({
-        serviceName: 'S1',
-        configs: [
-          Em.Object.create({ name: 'p1', filename: 'file1'})
-        ]
-      })]);
-      var propertiesToUpdate = [Em.Object.create({
-        initialValue: 'val1',
-        recommendedValue: 'val2',
-        serviceName: 'S1',
-        propertyName: 'p1',
-        configGroup: 'g2'
-      })];
-      mixin.undoRedoRecommended(propertiesToUpdate, false);
-      
expect(mixin.setRecommendedForGroup.getCall(0).args[0]).to.be.equal('val1');
-      
expect(mixin.setRecommendedForGroup.getCall(0).args[1]).to.be.eql(Em.Object.create({
-        serviceName: 'S1',
-        name: 'g2',
-        isDefault: false
-      }));
-      
expect(mixin.setRecommendedForGroup.getCall(0).args[2]).to.be.eql(Em.Object.create({
-        name: 'p1',
-        filename: 'file1'
-      }));
-      
expect(mixin.setRecommendedForGroup.getCall(0).args[3]).to.be.equal('val2');
+    describe("redo is false, non-default group, setRecommendedForGroup should 
be called", function() {
+
+      beforeEach(function () {
+        mixin.set('stepConfigs', [Em.Object.create({
+          serviceName: 'S1',
+          configs: [
+            Em.Object.create({ name: 'p1', filename: 'file1'})
+          ]
+        })]);
+        var propertiesToUpdate = [Em.Object.create({
+          initialValue: 'val1',
+          recommendedValue: 'val2',
+          serviceName: 'S1',
+          propertyName: 'p1',
+          configGroup: 'g2'
+        })];
+        mixin.undoRedoRecommended(propertiesToUpdate, false);
+      });
+
+      it('setRecommendedForGroup arg 0', function () {
+        
expect(mixin.setRecommendedForGroup.getCall(0).args[0]).to.be.equal('val1');
+      });
+
+      it('setRecommendedForGroup arg 1', function () {
+        
expect(mixin.setRecommendedForGroup.getCall(0).args[1]).to.be.eql(Em.Object.create({
+          serviceName: 'S1',
+          name: 'g2',
+          isDefault: false
+        }));
+      });
+
+      it('setRecommendedForGroup arg 2', function () {
+        
expect(mixin.setRecommendedForGroup.getCall(0).args[2]).to.be.eql(Em.Object.create({
+          name: 'p1',
+          filename: 'file1'
+        }));
+      });
+
+      it('setRecommendedForGroup arg 3', function () {
+        
expect(mixin.setRecommendedForGroup.getCall(0).args[3]).to.be.equal('val2');
+      });
+
     });
   });
 

Reply via email to