This is an automated email from the ASF dual-hosted git repository.

hapylestat pushed a commit to branch branch-2.7
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/branch-2.7 by this push:
     new c7250ab  AMBARI-25532. Unit tests coverage improvement for hawq wizard 
controllers (dpidhaiets via dgrinenko) (#3207)
c7250ab is described below

commit c7250abce4ae12ba6f21eeab3f4a7bb3da601054
Author: pidhaietsdp <[email protected]>
AuthorDate: Wed Jul 15 16:21:00 2020 +0300

    AMBARI-25532. Unit tests coverage improvement for hawq wizard controllers 
(dpidhaiets via dgrinenko) (#3207)
---
 ambari-web/app/assets/test/tests.js                |   6 +
 .../hawq/activateStandby/step2_controller_test.js  | 185 +++++++++++--
 .../hawq/activateStandby/step3_controller_test.js  | 247 +++++++++++++++++
 .../hawq/activateStandby/wizard_controller_test.js | 290 ++++++++++++++++++++
 .../hawq/addStandby/step3_controller_test.js       | 111 ++++++++
 .../hawq/addStandby/step4_controller_test.js       | 187 +++++++++++++
 .../hawq/addStandby/wizard_controller_test.js      | 298 +++++++++++++++++++++
 .../hawq/removeStandby/step2_controller_test.js    |  70 +++--
 .../hawq/removeStandby/step3_controller_test.js    | 188 +++++++++++++
 .../hawq/removeStandby/wizard_controller_test.js   | 290 ++++++++++++++++++++
 10 files changed, 1831 insertions(+), 41 deletions(-)

diff --git a/ambari-web/app/assets/test/tests.js 
b/ambari-web/app/assets/test/tests.js
index 381c144..ee54082 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -86,8 +86,14 @@ var files = [
   
'test/controllers/main/admin/highAvailability/resourceManager/step4_controller_test',
   
'test/controllers/main/admin/highAvailability/resourceManager/wizard_controller_test',
   
'test/controllers/main/admin/highAvailability/hawq/addStandby/step3_controller_test',
+  
'test/controllers/main/admin/highAvailability/hawq/addStandby/step4_controller_test',
+  
'test/controllers/main/admin/highAvailability/hawq/addStandby/wizard_controller_test',
   
'test/controllers/main/admin/highAvailability/hawq/removeStandby/step2_controller_test',
+  
'test/controllers/main/admin/highAvailability/hawq/removeStandby/step3_controller_test',
+  
'test/controllers/main/admin/highAvailability/hawq/removeStandby/wizard_controller_test',
   
'test/controllers/main/admin/highAvailability/hawq/activateStandby/step2_controller_test',
+  
'test/controllers/main/admin/highAvailability/hawq/activateStandby/step3_controller_test',
+  
'test/controllers/main/admin/highAvailability/hawq/activateStandby/wizard_controller_test',
   
'test/controllers/main/admin/highAvailability/journalNode/progress_controller_test',
   
'test/controllers/main/admin/highAvailability/journalNode/step1_controller_test',
   
'test/controllers/main/admin/highAvailability/journalNode/step2_controller_test',
diff --git 
a/ambari-web/test/controllers/main/admin/highAvailability/hawq/activateStandby/step2_controller_test.js
 
b/ambari-web/test/controllers/main/admin/highAvailability/hawq/activateStandby/step2_controller_test.js
index 845c932..f7af2a1 100644
--- 
a/ambari-web/test/controllers/main/admin/highAvailability/hawq/activateStandby/step2_controller_test.js
+++ 
b/ambari-web/test/controllers/main/admin/highAvailability/hawq/activateStandby/step2_controller_test.js
@@ -19,28 +19,37 @@
 var App = require('app');
 
require('controllers/main/admin/highAvailability/hawq/activateStandby/step2_controller');
 
+function getController() {
+  return App.ActivateHawqStandbyWizardStep2Controller.create({});
+}
+
 describe('App.ActivateHawqStandbyWizardStep2Controller', function () {
+  var controller;
+
+  beforeEach(function () {
+    controller = getController();
+  });
 
   describe('#isSubmitDisabled', function () {
 
-    var controller = App.ActivateHawqStandbyWizardStep2Controller.create({
-        content: Em.Object.create({})
-      }),
-      cases = [
-        {
-          isLoaded: false,
-          isSubmitDisabled: true,
-          title: 'wizard step content not loaded'
-        },
-        {
-          isLoaded: true,
-          isSubmitDisabled: false,
-          title: 'wizard step content loaded'
-        }
-      ];
+    var cases = [
+      {
+        isLoaded: false,
+        isSubmitDisabled: true,
+        title: 'wizard step content not loaded'
+      },
+      {
+        isLoaded: true,
+        isSubmitDisabled: false,
+        title: 'wizard step content loaded'
+      }
+    ];
 
     cases.forEach(function (item) {
       it(item.title, function () {
+        controller.reopen({
+          content: Em.Object.create({})
+        });
         controller.set('isLoaded', item.isLoaded);
         
expect(controller.get('isSubmitDisabled')).to.equal(item.isSubmitDisabled);
       });
@@ -48,10 +57,18 @@ describe('App.ActivateHawqStandbyWizardStep2Controller', 
function () {
 
   });
 
-
   describe('#setDynamicConfigValues', function () {
 
-    var controller = App.ActivateHawqStandbyWizardStep2Controller.create({
+    var configs = {
+      configs: [
+        Em.Object.create({
+          name: 'hawq_master_address_host'
+        })
+      ]
+    };
+
+    beforeEach(function () {
+      controller.reopen({
         content: Em.Object.create({
           masterComponentHosts: [
             {component: 'HAWQMASTER', hostName: 'h0', isInstalled: true},
@@ -62,25 +79,141 @@ describe('App.ActivateHawqStandbyWizardStep2Controller', 
function () {
             hawqStandby: 'h1'
           }
         })
-      }),
-      configs = {
+      });
+      controller.setDynamicConfigValues(configs);
+    });
+
+    it('hawq_master_address_host value', function () {
+      expect(configs.configs.findProperty('name', 
'hawq_master_address_host').get('value')).to.equal('h1');
+    });
+    it('hawq_master_address_host recommendedValue', function () {
+      expect(configs.configs.findProperty('name', 
'hawq_master_address_host').get('recommendedValue')).to.equal('h1');
+    });
+  });
+
+  describe("#loadStep()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'renderConfigs')
+    });
+
+    afterEach(function() {
+      controller.renderConfigs.restore();
+    });
+
+    it("should execute renderConfigs function", function() {
+      controller.loadStep();
+      expect(controller.renderConfigs.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#submit()", function () {
+
+    var mock = {
+      getKDCSessionState: Em.clb
+    };
+
+    beforeEach(function() {
+      sinon.spy(mock, 'getKDCSessionState');
+      sinon.stub(App, 'get').returns(mock);
+      sinon.stub(App.router, 'send');
+    });
+    afterEach(function() {
+      App.get.restore();
+      App.router.send.restore();
+      mock.getKDCSessionState.restore();
+    });
+
+    it('App.router.send should be called', function() {
+      controller.set('isLoaded', true);
+      controller.submit();
+      expect(mock.getKDCSessionState.calledOnce).to.be.true;
+      expect(App.router.send.calledOnce).to.be.true;
+    });
+
+    it('App.router.send should not be called', function() {
+      controller.set('isLoaded', false);
+      controller.submit();
+      expect(mock.getKDCSessionState.calledOnce).to.be.false;
+      expect(App.router.send.calledOnce).to.be.false;
+    });
+  });
+
+  describe("#renderConfigProperties()", function () {
+
+    beforeEach(function() {
+      sinon.stub(App.ServiceConfigProperty, 'create', function(obj) {
+        return obj;
+      });
+    });
+
+    afterEach(function() {
+      App.ServiceConfigProperty.create.restore();
+    });
+
+    it("config should be added", function() {
+      var componentConfig = {
+        configs: []
+      };
+      var _componentConfig = {
         configs: [
           Em.Object.create({
-            name: 'hawq_master_address_host'
+            isReconfigurable: true
           })
         ]
       };
+      controller.renderConfigProperties(_componentConfig, componentConfig);
+      expect(componentConfig.configs[0].get('isEditable')).to.be.true;
+    });
+  });
 
+  describe("#renderConfigs()", function () {
 
-    beforeEach(function () {
-      controller.setDynamicConfigValues(configs);
+    beforeEach(function() {
+      newHawqMaster = '';
+      sinon.stub(App.ServiceConfigProperty, 'create', function(obj) {
+        return obj;
+      });
+      sinon.stub(App.HostComponent, 'find').returns([
+        Em.Object.create({
+          componentName: 'HAWQSTANDBY',
+          hostName: 'host1'
+        })
+      ]);
+      sinon.stub(controller, 'renderConfigProperties');
+      sinon.stub(controller, 'setDynamicConfigValues');
+      sinon.stub(controller, 'setProperties');
+      this.mock = sinon.stub(App.Service, 'find');
     });
 
-    it('hawq_master_address_host value', function () {
-      expect(configs.configs.findProperty('name', 
'hawq_master_address_host').get('value')).to.equal('h1');
+    afterEach(function() {
+      App.ServiceConfigProperty.create.restore();
+      App.HostComponent.find.restore();
+      controller.renderConfigProperties.restore();
+      controller.setDynamicConfigValues.restore();
+      controller.setProperties.restore();
+      this.mock.restore();
     });
-    it('hawq_master_address_host recommendedValue', function () {
-      expect(configs.configs.findProperty('name', 
'hawq_master_address_host').get('recommendedValue')).to.equal('h1');
+
+    it("configs should be rendered{1}", function() {
+      this.mock.returns([
+        {serviceName: 'HAWQ'},
+        {serviceName: 'YARN'}
+      ]);
+      controller.renderConfigs();
+      expect(controller.renderConfigProperties.calledOnce).to.be.true;
+      expect(controller.setDynamicConfigValues.calledOnce).to.be.true;
+      expect(controller.setProperties.calledOnce).to.be.true;
+    });
+
+    it("configs should be rendered{2}", function() {
+      this.mock.returns([
+        {serviceName: 'YARN'}
+      ]);
+      controller.renderConfigs();
+      expect(controller.renderConfigProperties.calledOnce).to.be.true;
+      expect(controller.setDynamicConfigValues.calledOnce).to.be.true;
+      expect(controller.setProperties.calledOnce).to.be.true;
     });
   });
 
diff --git 
a/ambari-web/test/controllers/main/admin/highAvailability/hawq/activateStandby/step3_controller_test.js
 
b/ambari-web/test/controllers/main/admin/highAvailability/hawq/activateStandby/step3_controller_test.js
new file mode 100644
index 0000000..fb7f9a2
--- /dev/null
+++ 
b/ambari-web/test/controllers/main/admin/highAvailability/hawq/activateStandby/step3_controller_test.js
@@ -0,0 +1,247 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+var testHelpers = require('test/helpers');
+require('controllers/main/admin/highAvailability/hawq/activateStandby/step3_controller');
+
+function getController() {
+  return App.ActivateHawqStandbyWizardStep3Controller.create({});
+}
+
+describe('App.ActivateHawqStandbyWizardStep3Controller', function () {
+  var controller;
+
+  beforeEach(function () {
+    controller = getController();
+  });
+
+  describe("#stopRequiredServices()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'stopServices');
+    });
+
+    afterEach(function() {
+      controller.stopServices.restore();
+    });
+
+    it("should stop services", function() {
+      controller.stopRequiredServices();
+      expect(controller.stopServices.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#startRequiredServices()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'startServices');
+    });
+
+    afterEach(function() {
+      controller.startServices.restore();
+    });
+
+    it("should start services", function() {
+      controller.startRequiredServices();
+      expect(controller.startServices.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#onSaveConfigs()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'onTaskCompleted');
+    });
+
+    afterEach(function() {
+      controller.onTaskCompleted.restore();
+    });
+
+    it("should execute onTaskCompleted function", function() {
+      controller.onSaveConfigs();
+      expect(controller.onTaskCompleted.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#installHawqMaster()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'createInstallComponentTask');
+    });
+
+    afterEach(function() {
+      controller.createInstallComponentTask.restore();
+    });
+
+    it("should execute createInstallComponentTask function", function() {
+      controller.reopen({
+        content: {
+          hawqHosts: {
+            hawqMaster: 'host1',
+            hawqStandby: 'host1'
+          }
+        }
+      });
+      controller.installHawqMaster();
+      expect(controller.createInstallComponentTask.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#deleteOldHawqMaster()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'deleteComponent');
+    });
+
+    afterEach(function() {
+      controller.deleteComponent.restore();
+    });
+
+    it("should execute deleteComponent function", function() {
+      controller.reopen({
+        content: {
+          hawqHosts: {
+            hawqMaster: 'host1',
+            hawqStandby: 'host1'
+          }
+        }
+      });
+      controller.deleteOldHawqMaster();
+      expect(controller.deleteComponent.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#deleteHawqStandby()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'deleteComponent');
+    });
+
+    afterEach(function() {
+      controller.deleteComponent.restore();
+    });
+
+    it("should execute deleteComponent function", function() {
+      controller.reopen({
+        content: {
+          hawqHosts: {
+            hawqMaster: 'host1',
+            hawqStandby: 'host1'
+          }
+        }
+      });
+      controller.deleteHawqStandby();
+      expect(controller.deleteComponent.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#onLoadConfigs()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'reconfigureSites').returns({});
+      controller.set('content.configs', [
+        {
+          filename: 't1',
+          name: 'p1',
+          value: 'val1'
+        }
+      ]);
+      sinon.stub(App.format, 'role').returns('comp1');
+    });
+
+    afterEach(function() {
+      controller.reconfigureSites.restore();
+      App.format.role.restore();
+    });
+
+    it("reconfigureSites should be called", function() {
+      var data = {
+        items: [{
+          properties: {}
+        }]
+      };
+      var str = 
Em.I18n.t('admin.activateHawqStandby.step4.save.configuration.note').format('comp1');
+      controller.onLoadConfigs(data, {}, {type: 't1'});
+      expect(controller.reconfigureSites.getCall(0).args).to.be.eql([['t1'], 
data, str]);
+    });
+
+    it("App.ajax.send should be called", function() {
+      var data = {
+        items: [{
+          properties: {}
+        }]
+      };
+      controller.onLoadConfigs(data, {}, {type: 't1'});
+      var args = testHelpers.findAjaxRequest('name', 
'common.service.configurations');
+      expect(args[0]).to.be.eql({
+        name: 'common.service.configurations',
+        sender: controller,
+        data: {
+          desired_config: {}
+        },
+        success: 'onSaveConfigs',
+        error: 'onTaskError'
+      });
+    });
+  });
+
+  describe("#onLoadHawqConfigsTags()", function () {
+
+    it("App.ajax.send should be called", function() {
+      var data = {
+        Clusters: {
+          desired_configs: {
+            'hawq-site': {
+              tag: 1
+            }
+          }
+        }
+      };
+      controller.onLoadHawqConfigsTags(data);
+      var args = testHelpers.findAjaxRequest('name', 'reassign.load_configs');
+      expect(args[0]).to.be.eql({
+        name: 'reassign.load_configs',
+        sender: controller,
+        data: {
+          urlParams: '(type=hawq-site&tag=1)',
+          type: 'hawq-site'
+        },
+        success: 'onLoadConfigs',
+        error: 'onTaskError'
+      });
+    });
+  });
+
+  describe("#reconfigureHAWQ()", function () {
+
+    it("should send ajax request", function() {
+      controller.reconfigureHAWQ();
+      expect(App.ajax.send.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#activateStandby()", function () {
+
+    it("should send ajax request", function() {
+      controller.activateStandby();
+      expect(App.ajax.send.calledOnce).to.be.true;
+    });
+  });
+
+});
diff --git 
a/ambari-web/test/controllers/main/admin/highAvailability/hawq/activateStandby/wizard_controller_test.js
 
b/ambari-web/test/controllers/main/admin/highAvailability/hawq/activateStandby/wizard_controller_test.js
new file mode 100644
index 0000000..9dcb100
--- /dev/null
+++ 
b/ambari-web/test/controllers/main/admin/highAvailability/hawq/activateStandby/wizard_controller_test.js
@@ -0,0 +1,290 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+require('controllers/main/admin/highAvailability/hawq/activateStandby/wizard_controller');
+
+function getController() {
+  return App.ActivateHawqStandbyWizardController.create({});
+}
+
+describe('App.ActivateHawqStandbyWizardController', function () {
+  var controller;
+
+  beforeEach(function () {
+    controller = getController();
+  });
+
+  describe("#setCurrentStep()", function () {
+
+    beforeEach(function() {
+      sinon.stub(App.clusterStatus, 'setClusterStatus');
+    });
+
+    afterEach(function() {
+      App.clusterStatus.setClusterStatus.restore();
+    });
+
+    it("should set current step", function() {
+      controller.setCurrentStep();
+      expect(App.clusterStatus.setClusterStatus.calledOnce).to.be.true;
+    });
+  });
+
+  describe('#loadMap', function() {
+
+    describe('should load cluster', function() {
+      var loadCluster = false;
+      var checker = {
+        load: function() {
+          loadCluster = true;
+        }
+      };
+
+      beforeEach(function () {
+        controller.loadMap['1'][0].callback.call(checker);
+      });
+
+      it('cluster info is loaded', function () {
+        expect(loadCluster).to.be.true;
+      });
+    });
+
+    describe ('should load service hosts', function() {
+      var loadServicesFromServer = false;
+      var loadMasterComponentHosts = false;
+      var loadHawqHosts = false;
+
+      var checker = {
+        loadServicesFromServer: function () {
+          loadServicesFromServer = true;
+        },
+        loadMasterComponentHosts: function () {
+          loadMasterComponentHosts = true;
+          return $.Deferred().resolve().promise();
+        },
+        loadHawqHosts: function () {
+          loadHawqHosts = true;
+        }
+      };
+
+      beforeEach(function () {
+        controller.loadMap['2'][0].callback.call(checker);
+      });
+
+      it('services from server are loaded', function () {
+        expect(loadServicesFromServer).to.be.true;
+      });
+
+      it('master component hosts are loaded', function () {
+        expect(loadMasterComponentHosts).to.be.true;
+      });
+
+      it('Hawq hosts are loaded', function () {
+        expect(loadHawqHosts).to.be.true;
+      });
+    });
+
+    describe ('should load tasks', function() {
+      var loadConfigs = false;
+      var loadTasksStatuses = false;
+      var loadTasksRequestIds = false;
+      var loadRequestIds = false;
+
+      var checker = {
+        loadConfigs: function () {
+          loadConfigs = true;
+        },
+        loadTasksStatuses: function () {
+          loadTasksStatuses = true;
+          return $.Deferred().resolve().promise();
+        },
+        loadTasksRequestIds: function () {
+          loadTasksRequestIds = true;
+        },
+        loadRequestIds: function () {
+          loadRequestIds = true;
+        }
+      };
+
+      beforeEach(function () {
+        controller.loadMap['3'][0].callback.call(checker);
+      });
+
+      it('service config properties are loaded', function () {
+        expect(loadConfigs).to.be.true;
+      });
+
+      it('task statuses are loaded', function () {
+        expect(loadTasksStatuses).to.be.true;
+      });
+
+      it('task request ids are loaded', function () {
+        expect(loadTasksRequestIds).to.be.true;
+      });
+
+      it('request ids are loaded', function () {
+        expect(loadRequestIds).to.be.true;
+      });
+    });
+  });
+
+  describe("#setCurrentStep()", function () {
+
+    beforeEach(function() {
+      sinon.stub(App.clusterStatus, 'setClusterStatus');
+    });
+
+    afterEach(function() {
+      App.clusterStatus.setClusterStatus.restore();
+    });
+
+    it("App.clusterStatus.setClusterStatus should be called", function() {
+      controller.setCurrentStep();
+      expect(App.clusterStatus.setClusterStatus.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#saveHawqHosts()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'setDBProperty');
+    });
+
+    afterEach(function() {
+      controller.setDBProperty.restore();
+    });
+
+    it("hawqHosts should be set", function() {
+      controller.saveHawqHosts(['host1']);
+      expect(controller.get('content.hawqHosts')).to.be.eql(['host1']);
+    });
+
+    it("setDBProperty should be called", function() {
+      controller.saveHawqHosts(['host1']);
+      expect(controller.setDBProperty.calledWith('hawqHosts', 
['host1'])).to.be.true;
+    });
+  });
+
+  describe("#loadHawqHosts()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'getDBProperty').returns(['host1']);
+    });
+
+    afterEach(function() {
+      controller.getDBProperty.restore();
+    });
+
+    it("hawqHosts should be set", function() {
+      controller.loadHawqHosts();
+      expect(controller.get('content.hawqHosts')).to.be.eql(['host1']);
+    });
+  });
+
+  describe("#saveConfigs()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'setDBProperty');
+    });
+
+    afterEach(function() {
+      controller.setDBProperty.restore();
+    });
+
+    it("configs should be set", function() {
+      controller.saveConfigs([{}]);
+      expect(controller.get('content.configs')).to.be.eql([{}]);
+    });
+
+    it("setDBProperty should be called", function() {
+      controller.saveConfigs([{}]);
+      expect(controller.setDBProperty.calledWith('configs', [{}])).to.be.true;
+    });
+  });
+
+  describe("#loadConfigs()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'getDBProperty').returns([{}]);
+    });
+
+    afterEach(function() {
+      controller.getDBProperty.restore();
+    });
+
+    it("configs should be set", function() {
+      controller.loadConfigs();
+      expect(controller.get('content.configs')).to.be.eql([{}]);
+    });
+  });
+
+  describe("#clearAllSteps()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'clearInstallOptions');
+      sinon.stub(controller, 'getCluster').returns({});
+      controller.clearAllSteps();
+    });
+
+    afterEach(function() {
+      controller.clearInstallOptions.restore();
+      controller.getCluster.restore();
+    });
+
+    it("clearInstallOptions should be called", function() {
+      expect(controller.clearInstallOptions.calledOnce).to.be.true;
+    });
+
+    it("cluster should be set", function() {
+      expect(controller.get('content.cluster')).to.be.eql({});
+    });
+  });
+
+  describe("#finish()", function () {
+    var container = {
+      updateAll: Em.K
+    };
+
+    beforeEach(function() {
+      sinon.stub(controller, 'resetDbNamespace');
+      sinon.stub(App.router, 'get').returns(container);
+      sinon.stub(container, 'updateAll');
+      controller.finish();
+    });
+
+    afterEach(function() {
+      controller.resetDbNamespace.restore();
+      App.router.get.restore();
+      container.updateAll.restore();
+    });
+
+    it("resetDbNamespace should be called", function() {
+      expect(controller.resetDbNamespace.calledOnce).to.be.true;
+    });
+
+    it("updateAll should be called", function() {
+      expect(container.updateAll.calledOnce).to.be.true;
+    });
+
+    it("isFinished should be true", function() {
+      expect(controller.get('isFinished')).to.be.true;
+    });
+  });
+
+});
diff --git 
a/ambari-web/test/controllers/main/admin/highAvailability/hawq/addStandby/step3_controller_test.js
 
b/ambari-web/test/controllers/main/admin/highAvailability/hawq/addStandby/step3_controller_test.js
index 2180248..2bd1bd4 100644
--- 
a/ambari-web/test/controllers/main/admin/highAvailability/hawq/addStandby/step3_controller_test.js
+++ 
b/ambari-web/test/controllers/main/admin/highAvailability/hawq/addStandby/step3_controller_test.js
@@ -183,4 +183,115 @@ describe('App.AddHawqStandbyWizardStep3Controller', 
function () {
     });
   });
 
+  describe("#loadStep()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'renderConfigs')
+    });
+
+    afterEach(function() {
+      controller.renderConfigs.restore();
+    });
+
+    it("should execute renderConfigs function", function() {
+      controller.loadStep();
+      expect(controller.renderConfigs.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#submit()", function () {
+
+    beforeEach(function() {
+      dataDir = '';
+      hawqStandby = '';
+      sinon.stub(App, 'showConfirmationPopup');
+    });
+    afterEach(function() {
+      App.showConfirmationPopup.restore();
+    });
+
+    it('confirmation popup should be called', function() {
+      controller.set('isLoaded', true);
+      controller.set('hawqProps', {items: [{properties: 
{hawq_master_directory: '/dir'}}]});
+      controller.submit();
+      expect(App.showConfirmationPopup.calledOnce).to.be.true;
+    });
+
+    it('confirmation popup should not be called', function() {
+      controller.set('isLoaded', false);
+      controller.set('hawqProps', {items: [{properties: 
{hawq_master_directory: '/dir'}}]});
+      controller.submit();
+      expect(App.showConfirmationPopup.calledOnce).to.be.false;
+    });
+  });
+
+  describe("#renderConfigProperties()", function () {
+
+    beforeEach(function() {
+      sinon.stub(App.ServiceConfigProperty, 'create', function(obj) {
+        return obj;
+      });
+    });
+
+    afterEach(function() {
+      App.ServiceConfigProperty.create.restore();
+    });
+
+    it("config should be added", function() {
+      var componentConfig = {
+        configs: []
+      };
+      var _componentConfig = {
+        configs: [
+          Em.Object.create({
+            isReconfigurable: true
+          })
+        ]
+      };
+      controller.renderConfigProperties(_componentConfig, componentConfig);
+      expect(componentConfig.configs[0].get('isEditable')).to.be.true;
+    });
+  });
+
+  describe("#renderConfigs()", function () {
+
+    beforeEach(function() {
+      sinon.stub(App.ServiceConfigProperty, 'create', function(obj) {
+        return obj;
+      });
+      sinon.stub(App.HostComponent, 'find').returns([
+        Em.Object.create({
+          componentName: 'HAWQSTANDBY',
+          hostName: 'host1'
+        })
+      ]);
+      sinon.stub(controller, 'renderConfigProperties');
+      this.mock = sinon.stub(App.Service, 'find');
+    });
+
+    afterEach(function() {
+      App.ServiceConfigProperty.create.restore();
+      App.HostComponent.find.restore();
+      controller.renderConfigProperties.restore();
+      this.mock.restore();
+    });
+
+    it("configs should be rendered{1}", function() {
+      this.mock.returns([
+        {serviceName: 'HAWQ'},
+        {serviceName: 'YARN'}
+      ]);
+      controller.renderConfigs();
+      expect(controller.renderConfigProperties.calledOnce).to.be.true;
+    });
+
+    it("configs should be rendered{2}", function() {
+      this.mock.returns([
+        {serviceName: 'YARN'}
+      ]);
+      controller.renderConfigs();
+      expect(controller.renderConfigProperties.calledOnce).to.be.true;
+    });
+  });
+
 });
diff --git 
a/ambari-web/test/controllers/main/admin/highAvailability/hawq/addStandby/step4_controller_test.js
 
b/ambari-web/test/controllers/main/admin/highAvailability/hawq/addStandby/step4_controller_test.js
new file mode 100644
index 0000000..b46a43a
--- /dev/null
+++ 
b/ambari-web/test/controllers/main/admin/highAvailability/hawq/addStandby/step4_controller_test.js
@@ -0,0 +1,187 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+require('controllers/main/admin/highAvailability/hawq/addStandby/step4_controller');
+var testHelpers = require('test/helpers');
+
+function getController() {
+  return App.AddHawqStandbyWizardStep4Controller.create({});
+}
+
+describe('App.AddHawqStandbyWizardStep4Controller', function () {
+  var controller;
+
+  beforeEach(function () {
+    controller = getController();
+  });
+
+  describe("#installHawqStandbyMaster()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'createInstallComponentTask');
+    });
+
+    afterEach(function() {
+      controller.createInstallComponentTask.restore();
+    });
+
+    it("should execute createInstallComponentTask function", function() {
+      controller.reopen({
+        content: {
+          hawqHosts: {
+            newHawqStandby: 'host1'
+          }
+        }
+      });
+      controller.installHawqStandbyMaster();
+      expect(controller.createInstallComponentTask.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#stopRequiredServices()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'stopServices');
+    });
+
+    afterEach(function() {
+      controller.stopServices.restore();
+    });
+
+    it("stopServices should be called", function() {
+      controller.stopRequiredServices();
+      expect(controller.stopServices.calledWith(['HAWQ'])).to.be.true;
+    });
+  });
+
+  describe("#reconfigureHAWQ()", function () {
+
+    it("ajax send should be called", function() {
+      controller.reconfigureHAWQ();
+      expect(App.ajax.send.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#onLoadHawqConfigsTags()", function () {
+
+    it("App.ajax.send should be called", function() {
+      var data = {
+        Clusters: {
+          desired_configs: {
+            'hawq-site': {
+              tag: 1
+            }
+          }
+        }
+      };
+      controller.onLoadHawqConfigsTags(data);
+      var args = testHelpers.findAjaxRequest('name', 'reassign.load_configs');
+      expect(args[0]).to.be.eql({
+        name: 'reassign.load_configs',
+        sender: controller,
+        data: {
+          urlParams: '(type=hawq-site&tag=1)',
+          type: 'hawq-site'
+        },
+        success: 'onLoadConfigs',
+        error: 'onTaskError'
+      });
+    });
+  });
+
+  describe("#onLoadConfigs()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'reconfigureSites').returns({});
+      controller.set('content.configs', [
+        {
+          filename: 't1',
+          name: 'p1',
+          value: 'val1'
+        }
+      ]);
+    });
+
+    afterEach(function() {
+      controller.reconfigureSites.restore();
+    });
+
+    it("reconfigureSites should be called", function() {
+      var data = {
+        items: [{
+          properties: {}
+        }]
+      };
+      controller.onLoadConfigs(data, {}, {type: 't1'});
+      expect(controller.reconfigureSites.getCall(0).args).to.be.eql([['t1'], 
data, 'This configuration is created by Add HAWQ Standby wizard']);
+    });
+
+    it("App.ajax.send should be called", function() {
+      var data = {
+        items: [{
+          properties: {}
+        }]
+      };
+      controller.onLoadConfigs(data, {}, {type: 't1'});
+      var args = testHelpers.findAjaxRequest('name', 
'common.service.configurations');
+      expect(args[0]).to.be.eql({
+        name: 'common.service.configurations',
+        sender: controller,
+        data: {
+          desired_config: {}
+        },
+        success: 'onSaveConfigs',
+        error: 'onTaskError'
+      });
+    });
+  });
+
+  describe("#onSaveConfigs()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'onTaskCompleted');
+    });
+
+    afterEach(function() {
+      controller.onTaskCompleted.restore();
+    });
+
+    it("onTaskCompleted should be called", function() {
+      controller.onSaveConfigs();
+      expect(controller.onTaskCompleted.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#startRequiredServices()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'startServices');
+    });
+
+    afterEach(function() {
+      controller.startServices.restore();
+    });
+
+    it("startServices should be called", function() {
+      controller.startRequiredServices();
+      expect(controller.startServices.calledWith(false, ["HAWQ"], 
true)).to.be.true;
+    });
+  });
+
+});
diff --git 
a/ambari-web/test/controllers/main/admin/highAvailability/hawq/addStandby/wizard_controller_test.js
 
b/ambari-web/test/controllers/main/admin/highAvailability/hawq/addStandby/wizard_controller_test.js
new file mode 100644
index 0000000..7657650
--- /dev/null
+++ 
b/ambari-web/test/controllers/main/admin/highAvailability/hawq/addStandby/wizard_controller_test.js
@@ -0,0 +1,298 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+require('controllers/main/admin/highAvailability/hawq/addStandby/wizard_controller');
+
+function getController() {
+  return App.AddHawqStandbyWizardController.create({});
+}
+
+describe('App.AddHawqStandbyWizardController', function () {
+  var controller;
+
+  beforeEach(function () {
+    controller = getController();
+  });
+
+  describe("#setCurrentStep()", function () {
+
+    beforeEach(function() {
+      sinon.stub(App.clusterStatus, 'setClusterStatus');
+    });
+
+    afterEach(function() {
+      App.clusterStatus.setClusterStatus.restore();
+    });
+
+    it("should set current step", function() {
+      controller.setCurrentStep();
+      expect(App.clusterStatus.setClusterStatus.calledOnce).to.be.true;
+    });
+  });
+
+  describe('#loadMap', function() {
+
+    describe('should load cluster', function() {
+      var loadCluster = false;
+      var checker = {
+        load: function() {
+          loadCluster = true;
+        }
+      };
+
+      beforeEach(function () {
+        controller.loadMap['1'][0].callback.call(checker);
+      });
+
+      it('cluster info is loaded', function () {
+        expect(loadCluster).to.be.true;
+      });
+    });
+
+    describe ('should load service hosts', function() {
+      var loadServicesFromServer = false;
+      var loadMasterComponentHosts = false;
+      var loadHawqHosts = false;
+      var loadConfirmedHosts = false;
+
+      var checker = {
+        loadServicesFromServer: function () {
+          loadServicesFromServer = true;
+        },
+        loadMasterComponentHosts: function () {
+          loadMasterComponentHosts = true;
+          return $.Deferred().resolve().promise();
+        },
+        loadHawqHosts: function () {
+          loadHawqHosts = true;
+        },
+        loadConfirmedHosts: function () {
+          loadConfirmedHosts = true;
+        }
+      };
+
+      beforeEach(function () {
+        controller.loadMap['2'][0].callback.call(checker);
+      });
+
+      it('services from server are loaded', function () {
+        expect(loadServicesFromServer).to.be.true;
+      });
+
+      it('master component hosts are loaded', function () {
+        expect(loadMasterComponentHosts).to.be.true;
+      });
+
+      it('Hawq hosts are loaded', function () {
+        expect(loadHawqHosts).to.be.true;
+      });
+
+      it('confirmed hosts are loaded', function () {
+        expect(loadConfirmedHosts).to.be.true;
+      });
+    });
+
+    describe ('should load tasks', function() {
+      var loadConfigs = false;
+      var loadTasksStatuses = false;
+      var loadTasksRequestIds = false;
+      var loadRequestIds = false;
+
+      var checker = {
+        loadConfigs: function () {
+          loadConfigs = true;
+        },
+        loadTasksStatuses: function () {
+          loadTasksStatuses = true;
+          return $.Deferred().resolve().promise();
+        },
+        loadTasksRequestIds: function () {
+          loadTasksRequestIds = true;
+        },
+        loadRequestIds: function () {
+          loadRequestIds = true;
+        }
+      };
+
+      beforeEach(function () {
+        controller.loadMap['4'][0].callback.call(checker);
+      });
+
+      it('service config properties are loaded', function () {
+        expect(loadConfigs).to.be.true;
+      });
+
+      it('task statuses are loaded', function () {
+        expect(loadTasksStatuses).to.be.true;
+      });
+
+      it('task request ids are loaded', function () {
+        expect(loadTasksRequestIds).to.be.true;
+      });
+
+      it('request ids are loaded', function () {
+        expect(loadRequestIds).to.be.true;
+      });
+    });
+  });
+
+  describe("#setCurrentStep()", function () {
+
+    beforeEach(function() {
+      sinon.stub(App.clusterStatus, 'setClusterStatus');
+    });
+
+    afterEach(function() {
+      App.clusterStatus.setClusterStatus.restore();
+    });
+
+    it("App.clusterStatus.setClusterStatus should be called", function() {
+      controller.setCurrentStep();
+      expect(App.clusterStatus.setClusterStatus.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#saveHawqHosts()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'setDBProperty');
+    });
+
+    afterEach(function() {
+      controller.setDBProperty.restore();
+    });
+
+    it("hawqHosts should be set", function() {
+      controller.saveHawqHosts(['host1']);
+      expect(controller.get('content.hawqHosts')).to.be.eql(['host1']);
+    });
+
+    it("setDBProperty should be called", function() {
+      controller.saveHawqHosts(['host1']);
+      expect(controller.setDBProperty.calledWith('hawqHosts', 
['host1'])).to.be.true;
+    });
+  });
+
+  describe("#loadHawqHosts()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'getDBProperty').returns(['host1']);
+    });
+
+    afterEach(function() {
+      controller.getDBProperty.restore();
+    });
+
+    it("hawqHosts should be set", function() {
+      controller.loadHawqHosts();
+      expect(controller.get('content.hawqHosts')).to.be.eql(['host1']);
+    });
+  });
+
+  describe("#saveConfigs()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'setDBProperty');
+    });
+
+    afterEach(function() {
+      controller.setDBProperty.restore();
+    });
+
+    it("configs should be set", function() {
+      controller.saveConfigs([{}]);
+      expect(controller.get('content.configs')).to.be.eql([{}]);
+    });
+
+    it("setDBProperty should be called", function() {
+      controller.saveConfigs([{}]);
+      expect(controller.setDBProperty.calledWith('configs', [{}])).to.be.true;
+    });
+  });
+
+  describe("#loadConfigs()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'getDBProperty').returns([{}]);
+    });
+
+    afterEach(function() {
+      controller.getDBProperty.restore();
+    });
+
+    it("configs should be set", function() {
+      controller.loadConfigs();
+      expect(controller.get('content.configs')).to.be.eql([{}]);
+    });
+  });
+
+  describe("#clearAllSteps()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'clearInstallOptions');
+      sinon.stub(controller, 'getCluster').returns({});
+      controller.clearAllSteps();
+    });
+
+    afterEach(function() {
+      controller.clearInstallOptions.restore();
+      controller.getCluster.restore();
+    });
+
+    it("clearInstallOptions should be called", function() {
+      expect(controller.clearInstallOptions.calledOnce).to.be.true;
+    });
+
+    it("cluster should be set", function() {
+      expect(controller.get('content.cluster')).to.be.eql({});
+    });
+  });
+
+  describe("#finish()", function () {
+    var container = {
+      updateAll: Em.K
+    };
+
+    beforeEach(function() {
+      sinon.stub(controller, 'resetDbNamespace');
+      sinon.stub(App.router, 'get').returns(container);
+      sinon.stub(container, 'updateAll');
+      controller.finish();
+    });
+
+    afterEach(function() {
+      controller.resetDbNamespace.restore();
+      App.router.get.restore();
+      container.updateAll.restore();
+    });
+
+    it("resetDbNamespace should be called", function() {
+      expect(controller.resetDbNamespace.calledOnce).to.be.true;
+    });
+
+    it("updateAll should be called", function() {
+      expect(container.updateAll.calledOnce).to.be.true;
+    });
+
+    it("isFinished should be true", function() {
+      expect(controller.get('isFinished')).to.be.true;
+    });
+  });
+
+});
diff --git 
a/ambari-web/test/controllers/main/admin/highAvailability/hawq/removeStandby/step2_controller_test.js
 
b/ambari-web/test/controllers/main/admin/highAvailability/hawq/removeStandby/step2_controller_test.js
index 0a55445..5027582 100644
--- 
a/ambari-web/test/controllers/main/admin/highAvailability/hawq/removeStandby/step2_controller_test.js
+++ 
b/ambari-web/test/controllers/main/admin/highAvailability/hawq/removeStandby/step2_controller_test.js
@@ -19,28 +19,37 @@
 var App = require('app');
 
require('controllers/main/admin/highAvailability/hawq/removeStandby/step2_controller');
 
+function getController() {
+  return App.RemoveHawqStandbyWizardStep2Controller.create({});
+}
+
 describe('App.RemoveHawqStandbyWizardStep2Controller', function () {
+  var controller;
+
+  beforeEach(function () {
+    controller = getController();
+  });
 
   describe('#isSubmitDisabled', function () {
 
-    var controller = App.RemoveHawqStandbyWizardStep2Controller.create({
-        content: Em.Object.create({})
-      }),
-      cases = [
-        {
-          isLoaded: false,
-          isSubmitDisabled: true,
-          title: 'wizard step content not loaded'
-        },
-        {
-          isLoaded: true,
-          isSubmitDisabled: false,
-          title: 'wizard step content loaded'
-        }
-      ];
+    var cases = [
+      {
+        isLoaded: false,
+        isSubmitDisabled: true,
+        title: 'wizard step content not loaded'
+      },
+      {
+        isLoaded: true,
+        isSubmitDisabled: false,
+        title: 'wizard step content loaded'
+      }
+    ];
 
     cases.forEach(function (item) {
       it(item.title, function () {
+        controller.reopen({
+          content: Em.Object.create({})
+        });
         controller.set('isLoaded', item.isLoaded);
         
expect(controller.get('isSubmitDisabled')).to.equal(item.isSubmitDisabled);
       });
@@ -48,5 +57,36 @@ describe('App.RemoveHawqStandbyWizardStep2Controller', 
function () {
 
   });
 
+  describe("#submit()", function () {
+
+    var mock = {
+      getKDCSessionState: Em.clb
+    };
+
+    beforeEach(function() {
+      sinon.spy(mock, 'getKDCSessionState');
+      sinon.stub(App, 'get').returns(mock);
+      sinon.stub(App.router, 'send');
+    });
+    afterEach(function() {
+      App.get.restore();
+      App.router.send.restore();
+      mock.getKDCSessionState.restore();
+    });
+
+    it('App.router.send should be called', function() {
+      controller.set('isLoaded', true);
+      controller.submit();
+      expect(mock.getKDCSessionState.calledOnce).to.be.true;
+      expect(App.router.send.calledOnce).to.be.true;
+    });
+
+    it('App.router.send should not be called', function() {
+      controller.set('isLoaded', false);
+      controller.submit();
+      expect(mock.getKDCSessionState.calledOnce).to.be.false;
+      expect(App.router.send.calledOnce).to.be.false;
+    });
+  });
 
 });
diff --git 
a/ambari-web/test/controllers/main/admin/highAvailability/hawq/removeStandby/step3_controller_test.js
 
b/ambari-web/test/controllers/main/admin/highAvailability/hawq/removeStandby/step3_controller_test.js
new file mode 100644
index 0000000..23d17bb
--- /dev/null
+++ 
b/ambari-web/test/controllers/main/admin/highAvailability/hawq/removeStandby/step3_controller_test.js
@@ -0,0 +1,188 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+require('controllers/main/admin/highAvailability/hawq/removeStandby/step3_controller');
+var testHelpers = require('test/helpers');
+
+function getController() {
+  return App.RemoveHawqStandbyWizardStep3Controller.create({});
+}
+
+describe('App.RemoveHawqStandbyWizardStep3Controller', function () {
+  var controller;
+
+  beforeEach(function () {
+    controller = getController();
+  });
+
+  describe("#removeStandby()", function () {
+
+    it("ajax send should be called", function() {
+      controller.removeStandby();
+      expect(App.ajax.send.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#stopRequiredServices()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'stopServices');
+    });
+
+    afterEach(function() {
+      controller.stopServices.restore();
+    });
+
+    it("stopServices should be called", function() {
+      controller.stopRequiredServices();
+      expect(controller.stopServices.calledWith(['HAWQ'])).to.be.true;
+    });
+  });
+
+  describe("#reconfigureHAWQ()", function () {
+
+    it("ajax send should be called", function() {
+      controller.reconfigureHAWQ();
+      expect(App.ajax.send.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#onLoadHawqConfigsTags()", function () {
+
+    it("App.ajax.send should be called", function() {
+      var data = {
+        Clusters: {
+          desired_configs: {
+            'hawq-site': {
+              tag: 1
+            }
+          }
+        }
+      };
+      controller.onLoadHawqConfigsTags(data);
+      var args = testHelpers.findAjaxRequest('name', 'reassign.load_configs');
+      expect(args[0]).to.be.eql({
+        name: 'reassign.load_configs',
+        sender: controller,
+        data: {
+          urlParams: '(type=hawq-site&tag=1)',
+          type: 'hawq-site'
+        },
+        success: 'onLoadConfigs',
+        error: 'onTaskError'
+      });
+    });
+  });
+
+  describe("#onLoadConfigs()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'reconfigureSites').returns({});
+      controller.set('content.configs', [
+        {
+          filename: 't1',
+          name: 'p1',
+          value: 'val1'
+        }
+      ]);
+    });
+
+    afterEach(function() {
+      controller.reconfigureSites.restore();
+    });
+
+    it("reconfigureSites should be called", function() {
+      var data = {
+        items: [{
+          properties: {}
+        }]
+      };
+      controller.onLoadConfigs(data, {}, {type: 't1'});
+      expect(controller.reconfigureSites.getCall(0).args).to.be.eql([['t1'], 
data, 'This configuration was created by Remove HAWQ Standby wizard']);
+    });
+
+    it("App.ajax.send should be called", function() {
+      var data = {
+        items: [{
+          properties: {}
+        }]
+      };
+      controller.onLoadConfigs(data, {}, {type: 't1'});
+      var args = testHelpers.findAjaxRequest('name', 
'common.service.configurations');
+      expect(args[0]).to.be.eql({
+        name: 'common.service.configurations',
+        sender: controller,
+        data: {
+          desired_config: {}
+        },
+        success: 'onSaveConfigs',
+        error: 'onTaskError'
+      });
+    });
+  });
+
+  describe("#onSaveConfigs()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'onTaskCompleted');
+    });
+
+    afterEach(function() {
+      controller.onTaskCompleted.restore();
+    });
+
+    it("onTaskCompleted should be called", function() {
+      controller.onSaveConfigs();
+      expect(controller.onTaskCompleted.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#deleteHawqStandbyComponent()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'deleteComponent');
+    });
+
+    afterEach(function() {
+      controller.deleteComponent.restore();
+    });
+
+    it("deleteComponent should be called", function() {
+      controller.deleteHawqStandbyComponent();
+      expect(controller.deleteComponent.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#startRequiredServices()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'startServices');
+    });
+
+    afterEach(function() {
+      controller.startServices.restore();
+    });
+
+    it("startServices should be called", function() {
+      controller.startRequiredServices();
+      expect(controller.startServices.calledWith(false, ["HAWQ"], 
true)).to.be.true;
+    });
+  });
+
+});
diff --git 
a/ambari-web/test/controllers/main/admin/highAvailability/hawq/removeStandby/wizard_controller_test.js
 
b/ambari-web/test/controllers/main/admin/highAvailability/hawq/removeStandby/wizard_controller_test.js
new file mode 100644
index 0000000..b26dbce
--- /dev/null
+++ 
b/ambari-web/test/controllers/main/admin/highAvailability/hawq/removeStandby/wizard_controller_test.js
@@ -0,0 +1,290 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+require('controllers/main/admin/highAvailability/hawq/removeStandby/wizard_controller');
+
+function getController() {
+  return App.RemoveHawqStandbyWizardController.create({});
+}
+
+describe('App.RemoveHawqStandbyWizardController', function () {
+  var controller;
+
+  beforeEach(function () {
+    controller = getController();
+  });
+
+  describe("#setCurrentStep()", function () {
+
+    beforeEach(function() {
+      sinon.stub(App.clusterStatus, 'setClusterStatus');
+    });
+
+    afterEach(function() {
+      App.clusterStatus.setClusterStatus.restore();
+    });
+
+    it("should set current step", function() {
+      controller.setCurrentStep();
+      expect(App.clusterStatus.setClusterStatus.calledOnce).to.be.true;
+    });
+  });
+
+  describe('#loadMap', function() {
+
+    describe('should load cluster', function() {
+      var loadCluster = false;
+      var checker = {
+        load: function() {
+          loadCluster = true;
+        }
+      };
+
+      beforeEach(function () {
+        controller.loadMap['1'][0].callback.call(checker);
+      });
+
+      it('cluster info is loaded', function () {
+        expect(loadCluster).to.be.true;
+      });
+    });
+
+    describe ('should load service hosts', function() {
+      var loadServicesFromServer = false;
+      var loadMasterComponentHosts = false;
+      var loadHawqHosts = false;
+
+      var checker = {
+        loadServicesFromServer: function () {
+          loadServicesFromServer = true;
+        },
+        loadMasterComponentHosts: function () {
+          loadMasterComponentHosts = true;
+          return $.Deferred().resolve().promise();
+        },
+        loadHawqHosts: function () {
+          loadHawqHosts = true;
+        }
+      };
+
+      beforeEach(function () {
+        controller.loadMap['2'][0].callback.call(checker);
+      });
+
+      it('services from server are loaded', function () {
+        expect(loadServicesFromServer).to.be.true;
+      });
+
+      it('master component hosts are loaded', function () {
+        expect(loadMasterComponentHosts).to.be.true;
+      });
+
+      it('Hawq hosts are loaded', function () {
+        expect(loadHawqHosts).to.be.true;
+      });
+    });
+
+    describe ('should load tasks', function() {
+      var loadConfigs = false;
+      var loadTasksStatuses = false;
+      var loadTasksRequestIds = false;
+      var loadRequestIds = false;
+
+      var checker = {
+        loadConfigs: function () {
+          loadConfigs = true;
+        },
+        loadTasksStatuses: function () {
+          loadTasksStatuses = true;
+          return $.Deferred().resolve().promise();
+        },
+        loadTasksRequestIds: function () {
+          loadTasksRequestIds = true;
+        },
+        loadRequestIds: function () {
+          loadRequestIds = true;
+        }
+      };
+
+      beforeEach(function () {
+        controller.loadMap['3'][0].callback.call(checker);
+      });
+
+      it('service config properties are loaded', function () {
+        expect(loadConfigs).to.be.true;
+      });
+
+      it('task statuses are loaded', function () {
+        expect(loadTasksStatuses).to.be.true;
+      });
+
+      it('task request ids are loaded', function () {
+        expect(loadTasksRequestIds).to.be.true;
+      });
+
+      it('request ids are loaded', function () {
+        expect(loadRequestIds).to.be.true;
+      });
+    });
+  });
+
+  describe("#setCurrentStep()", function () {
+
+    beforeEach(function() {
+      sinon.stub(App.clusterStatus, 'setClusterStatus');
+    });
+
+    afterEach(function() {
+      App.clusterStatus.setClusterStatus.restore();
+    });
+
+    it("App.clusterStatus.setClusterStatus should be called", function() {
+      controller.setCurrentStep();
+      expect(App.clusterStatus.setClusterStatus.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#saveHawqHosts()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'setDBProperty');
+    });
+
+    afterEach(function() {
+      controller.setDBProperty.restore();
+    });
+
+    it("hawqHosts should be set", function() {
+      controller.saveHawqHosts(['host1']);
+      expect(controller.get('content.hawqHosts')).to.be.eql(['host1']);
+    });
+
+    it("setDBProperty should be called", function() {
+      controller.saveHawqHosts(['host1']);
+      expect(controller.setDBProperty.calledWith('hawqHosts', 
['host1'])).to.be.true;
+    });
+  });
+
+  describe("#loadHawqHosts()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'getDBProperty').returns(['host1']);
+    });
+
+    afterEach(function() {
+      controller.getDBProperty.restore();
+    });
+
+    it("hawqHosts should be set", function() {
+      controller.loadHawqHosts();
+      expect(controller.get('content.hawqHosts')).to.be.eql(['host1']);
+    });
+  });
+
+  describe("#saveConfigs()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'setDBProperty');
+    });
+
+    afterEach(function() {
+      controller.setDBProperty.restore();
+    });
+
+    it("configs should be set", function() {
+      controller.saveConfigs([{}]);
+      expect(controller.get('content.configs')).to.be.eql([{}]);
+    });
+
+    it("setDBProperty should be called", function() {
+      controller.saveConfigs([{}]);
+      expect(controller.setDBProperty.calledWith('configs', [{}])).to.be.true;
+    });
+  });
+
+  describe("#loadConfigs()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'getDBProperty').returns([{}]);
+    });
+
+    afterEach(function() {
+      controller.getDBProperty.restore();
+    });
+
+    it("configs should be set", function() {
+      controller.loadConfigs();
+      expect(controller.get('content.configs')).to.be.eql([{}]);
+    });
+  });
+
+  describe("#clearAllSteps()", function () {
+
+    beforeEach(function() {
+      sinon.stub(controller, 'clearInstallOptions');
+      sinon.stub(controller, 'getCluster').returns({});
+      controller.clearAllSteps();
+    });
+
+    afterEach(function() {
+      controller.clearInstallOptions.restore();
+      controller.getCluster.restore();
+    });
+
+    it("clearInstallOptions should be called", function() {
+      expect(controller.clearInstallOptions.calledOnce).to.be.true;
+    });
+
+    it("cluster should be set", function() {
+      expect(controller.get('content.cluster')).to.be.eql({});
+    });
+  });
+
+  describe("#finish()", function () {
+    var container = {
+      updateAll: Em.K
+    };
+
+    beforeEach(function() {
+      sinon.stub(controller, 'resetDbNamespace');
+      sinon.stub(App.router, 'get').returns(container);
+      sinon.stub(container, 'updateAll');
+      controller.finish();
+    });
+
+    afterEach(function() {
+      controller.resetDbNamespace.restore();
+      App.router.get.restore();
+      container.updateAll.restore();
+    });
+
+    it("resetDbNamespace should be called", function() {
+      expect(controller.resetDbNamespace.calledOnce).to.be.true;
+    });
+
+    it("updateAll should be called", function() {
+      expect(container.updateAll.calledOnce).to.be.true;
+    });
+
+    it("isFinished should be true", function() {
+      expect(controller.get('isFinished')).to.be.true;
+    });
+  });
+
+});

Reply via email to