diff --git a/ambari-web/app/assets/test/tests.js 
b/ambari-web/app/assets/test/tests.js
index 2f809ec6424..bd17989dfaa 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -406,6 +406,11 @@ var files = [
   'test/views/main/service/widgets/create/step3_view_test',
   'test/views/main/service/widgets/create/step2_view_test',
   'test/views/main/service/widgets/create/step1_view_test',
+  'test/views/main/service/reassign/step1_view_test',
+  'test/views/main/service/reassign/step2_view_test',
+  'test/views/main/service/reassign/step3_view_test',
+  'test/views/main/service/reassign/step4_view_test',
+  'test/views/main/service/reassign/step5_view_test',
   'test/views/main/admin/highAvailability/nameNode/step1_view_test',
   'test/views/main/admin/highAvailability/nameNode/step3_view_test',
   'test/views/main/admin/highAvailability/nameNode/step4_view_test',
diff --git a/ambari-web/test/views/main/service/reassign/step1_view_test.js 
b/ambari-web/test/views/main/service/reassign/step1_view_test.js
new file mode 100644
index 00000000000..1d6980fbfae
--- /dev/null
+++ b/ambari-web/test/views/main/service/reassign/step1_view_test.js
@@ -0,0 +1,151 @@
+/**
+ * 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 stringUtils = require('utils/string_utils');
+
+describe('App.MainServiceItemView', function () {
+  var view;
+
+  beforeEach(function() {
+    view = App.ReassignMasterWizardStep1View.create({});
+  });
+
+  describe('#message', function () {
+    var listOfServices = [
+      Em.Object.create({serviceName: 'test'}),
+      Em.Object.create({serviceName: 'test2'}),
+      Em.Object.create({serviceName: 'HDFS'})
+    ];
+    it('should return 2 msgs if componentsToStopAllServices contains 
componentName and hasManualSteps is false with installed services', function () 
{
+      view.set('controller', Em.Object.create({
+        content: Em.Object.create({
+          reassign: Em.Object.create({component_name: 'test', display_name: 
'test_display'}),
+          componentsToStopAllServices: ['test'],
+          hasManualSteps: false
+        })
+      }));
+      sinon.stub(App.Service, 'find').returns(listOfServices);
+      expect(view.get('message')).to.be.eql([
+        Em.I18n.t('services.reassign.step1.message1').format('test_display'),
+        Em.I18n.t('services.reassign.step1.message3').format(
+          
stringUtils.getFormattedStringFromArray(listOfServices.mapProperty('serviceName')),
+          'test_display')
+      ]);
+      App.Service.find.restore();
+    });
+
+    it('should return 3 msgs if componentsToStopAllServices contains 
componentName and hasManualSteps is true with installed services', function () {
+      view.set('controller', Em.Object.create({
+        content: Em.Object.create({
+          reassign: Em.Object.create({component_name: 'test', display_name: 
'test_display'}),
+          componentsToStopAllServices: ['test'],
+          hasManualSteps: true
+        })
+      }));
+      sinon.stub(App.Service, 'find').returns(listOfServices);
+      expect(view.get('message')).to.be.eql([
+        Em.I18n.t('services.reassign.step1.message1').format('test_display'),
+        Em.I18n.t('services.reassign.step1.message2').format('test_display'),
+        Em.I18n.t('services.reassign.step1.message3').format(
+          
stringUtils.getFormattedStringFromArray(listOfServices.mapProperty('serviceName')),
+          'test_display')
+      ]);
+      App.Service.find.restore();
+    });
+
+    it('should return 2 msgs if componentsToStopAllServices contains 
componentName and hasManualSteps is false with installed services without 
HDFS', function () {
+      view.set('controller', Em.Object.create({
+        content: Em.Object.create({
+          reassign: Em.Object.create({component_name: 'test', display_name: 
'test_display'}),
+          componentsToStopAllServices: [],
+          hasManualSteps: false
+        }),
+        target: Em.Object.create({
+          reassignMasterController: Em.Object.create({
+            relatedServicesMap: {
+              'test': []
+            }
+          })
+        })
+      }));
+
+      sinon.stub(App.Service, 'find').returns(listOfServices);
+      expect(view.get('message')).to.be.eql([
+        Em.I18n.t('services.reassign.step1.message1').format('test_display'),
+        Em.I18n.t('services.reassign.step1.message3').format(
+          stringUtils.getFormattedStringFromArray(listOfServices.slice(0, 
2).mapProperty('serviceName')),
+          'test_display')
+      ]);
+      App.Service.find.restore();
+    });
+
+    it('should return 3 msgs if componentsToStopAllServices contains 
componentName and hasManualSteps is false with installed services without 
HDFS', function () {
+      view.set('controller', Em.Object.create({
+        content: Em.Object.create({
+          reassign: Em.Object.create({component_name: 'test', display_name: 
'test_display'}),
+          componentsToStopAllServices: [],
+          hasManualSteps: true
+        }),
+        target: Em.Object.create({
+          reassignMasterController: Em.Object.create({
+            relatedServicesMap: {
+              'test': []
+            }
+          })
+        })
+      }));
+
+      sinon.stub(App.Service, 'find').returns(listOfServices);
+      expect(view.get('message')).to.be.eql([
+        Em.I18n.t('services.reassign.step1.message1').format('test_display'),
+        Em.I18n.t('services.reassign.step1.message2').format('test_display'),
+        Em.I18n.t('services.reassign.step1.message3').format(
+          stringUtils.getFormattedStringFromArray(listOfServices.slice(0, 
2).mapProperty('serviceName')),
+          'test_display')
+      ]);
+      App.Service.find.restore();
+    });
+
+    it('should return 2 msgs if componentsToStopAllServices contains 
componentName and hasManualSteps is false with installed services without 
HDFS', function () {
+      view.set('controller', Em.Object.create({
+        content: Em.Object.create({
+          reassign: Em.Object.create({component_name: 'test', display_name: 
'test_display'}),
+          componentsToStopAllServices: [],
+          hasManualSteps: false
+        }),
+        target: Em.Object.create({
+          reassignMasterController: Em.Object.create({
+            relatedServicesMap: {
+              'test': ['HDFS', 'test2']
+            }
+          })
+        })
+      }));
+
+      sinon.stub(App.Service, 'find').returns(listOfServices);
+      expect(view.get('message')).to.be.eql([
+        Em.I18n.t('services.reassign.step1.message1').format('test_display'),
+        Em.I18n.t('services.reassign.step1.message3').format(
+          stringUtils.getFormattedStringFromArray(['HDFS', 'test2']),
+          'test_display')
+      ]);
+      App.Service.find.restore();
+    });
+  });
+});
\ No newline at end of file
diff --git a/ambari-web/test/views/main/service/reassign/step2_view_test.js 
b/ambari-web/test/views/main/service/reassign/step2_view_test.js
new file mode 100644
index 00000000000..a6f045c62d8
--- /dev/null
+++ b/ambari-web/test/views/main/service/reassign/step2_view_test.js
@@ -0,0 +1,54 @@
+/**
+ * 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');
+
+describe('App.MainServiceItemView', function () {
+  var view;
+
+  beforeEach(function () {
+    view = App.ReassignMasterWizardStep2View.create({});
+  });
+
+  describe('#alertMessage', function () {
+    it('should return services.reassign.step2.body if component_name is not 
equal to NAMENODE or isHAEnabled is false', function () {
+      view.set('controller', Em.Object.create({
+        content: {
+          reassign: {
+            display_name: 'test'
+          }
+        }
+      }));
+      
expect(view.get('alertMessage')).to.be.equal(Em.I18n.t('services.reassign.step2.body').format('test'));
+    });
+
+    it('should return services.reassign.step2.body if component_name is not 
equal to NAMENODE or isHAEnabled is false', function () {
+      view.set('controller', Em.Object.create({
+        content: {
+          reassign: {
+            display_name: 'test_display',
+            component_name: 'NAMENODE'
+          }
+        }
+      }));
+      sinon.stub(App, 'get').returns(true);
+      
expect(view.get('alertMessage')).to.be.equal(Em.I18n.t('services.reassign.step2.body.namenodeHA').format('test_display'));
+      App.get.restore();
+    });
+  });
+});
\ No newline at end of file
diff --git a/ambari-web/test/views/main/service/reassign/step3_view_test.js 
b/ambari-web/test/views/main/service/reassign/step3_view_test.js
new file mode 100644
index 00000000000..59249d07958
--- /dev/null
+++ b/ambari-web/test/views/main/service/reassign/step3_view_test.js
@@ -0,0 +1,78 @@
+/**
+ * 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');
+
+describe('App.ReassignMasterWizardStep3View', function () {
+  var view;
+
+  beforeEach(function () {
+    view = App.ReassignMasterWizardStep3View.create({});
+  });
+
+  describe('#jdbcSetupMessage', function () {
+    it('should return jdbcSetupMessage false if component_name is not in 
HIVE_SERVER, HIVE_METASTORE, OOZIE_SERVER', function () {
+      view.set('controller', Em.Object.create({
+        content: {
+          reassign: {
+            component_name: 'test'
+          }
+        }
+      }));
+      expect(view.get('jdbcSetupMessage')).to.be.equal(false);
+    });
+
+    it('should return jdbcSetupMessage false if component_name is OOZIE_SERVER 
and database type is derby', function () {
+      view.set('controller', Em.Object.create({
+        content: {
+          reassign: {
+            component_name: 'OOZIE_SERVER'
+          },
+          databaseType: 'derby'
+        }
+      }));
+      expect(view.get('jdbcSetupMessage')).to.be.equal(false);
+    });
+
+    it('should return formated jdbcSetupMessage if component_name is 
OOZIE_SERVER and database type is not derby', function () {
+      view.set('controller', Em.Object.create({
+        content: {
+          reassign: {
+            component_name: 'OOZIE_SERVER'
+          },
+          databaseType: 'test'
+        }
+      }));
+      expect(view.get('jdbcSetupMessage')).to.be.equal(
+        
Em.I18n.t('services.service.config.database.msg.jdbcSetup').format('test', 
'test'));
+    });
+
+    it('should return formated jdbcSetupMessage if component_name is 
HIVE_METASTORE', function () {
+      view.set('controller', Em.Object.create({
+        content: {
+          reassign: {
+            component_name: 'HIVE_METASTORE'
+          },
+          databaseType: 'derby'
+        }
+      }));
+      expect(view.get('jdbcSetupMessage')).to.be.equal(
+        
Em.I18n.t('services.service.config.database.msg.jdbcSetup').format('derby', 
'derby'));
+    });
+  });
+});
\ No newline at end of file
diff --git a/ambari-web/test/views/main/service/reassign/step4_view_test.js 
b/ambari-web/test/views/main/service/reassign/step4_view_test.js
new file mode 100644
index 00000000000..51fc1f19305
--- /dev/null
+++ b/ambari-web/test/views/main/service/reassign/step4_view_test.js
@@ -0,0 +1,54 @@
+/**
+ * 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');
+
+describe('App.ReassignMasterWizardStep4View', function () {
+  var view;
+
+  beforeEach(function () {
+    view = App.ReassignMasterWizardStep4View.create({});
+  });
+
+  describe('#noticeCompleted', function () {
+    it('should return formatted 
services.reassign.step4.status.success.withManualSteps msg if hasManualSteps is 
true', function () {
+      view.set('controller', Em.Object.create({
+        content: {
+          reassign: {
+            component_name: 'test'
+          },
+          hasManualSteps: true
+        }
+      }));
+      
expect(view.get('noticeCompleted')).to.be.equal(Em.I18n.t('services.reassign.step4.status.success.withManualSteps').format('test'));
+    });
+
+    it('should return formatted services.reassign.step4.status.success msg if 
hasManualSteps is false', function () {
+      view.set('controller', Em.Object.create({
+        content: {
+          reassign: {
+            component_name: 'test'
+          },
+          hasManualSteps: false
+        }
+      }));
+      
expect(view.get('noticeCompleted')).to.be.equal(Em.I18n.t('services.reassign.step4.status.success').format('Test'));
+    });
+  });
+});
\ No newline at end of file
diff --git a/ambari-web/test/views/main/service/reassign/step5_view_test.js 
b/ambari-web/test/views/main/service/reassign/step5_view_test.js
new file mode 100644
index 00000000000..47b87ccd609
--- /dev/null
+++ b/ambari-web/test/views/main/service/reassign/step5_view_test.js
@@ -0,0 +1,91 @@
+/**
+ * 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 stringUtils = require('utils/string_utils');
+
+describe('App.ReassignMasterWizardStep5View', function () {
+  var view;
+
+  beforeEach(function () {
+    view = App.ReassignMasterWizardStep5View.create({});
+  });
+
+  describe('#manualCommands', function () {
+    it('should return empty string if component has not manual commands', 
function () {
+      view.set('controller', Em.Object.create({
+        content: {
+          componentsWithManualCommands: [],
+          reassign: {
+            component_name: 'test'
+          }
+        }
+      }));
+      expect(view.get('manualCommands')).to.be.equal('');
+    });
+
+    it('should return correct message if component has manual commands without 
nn started hosts', function () {
+      view.set('controller', Em.Object.create({
+        content: {
+          componentsWithManualCommands: ['namenode'],
+          reassign: {
+            component_name: 'namenode',
+          },
+          reassignHosts: {
+            source: 'source_host',
+            target: 'target_host'
+          },
+          componentDir: 'test_dir',
+          hdfsUser: 'hdfs_user',
+          group: 'group'
+        }
+      }));
+      expect(view.get('manualCommands')).to.be.equal(
+        Em.I18n.t('services.reassign.step5.body.namenode').format('test_dir', 
'source_host', 'target_host', 'hdfs_user', undefined, 'group', 'test_dir', 
'leveldb-timeline-store.ldb')
+      );
+    });
+
+    it('should return correct message if component has manual commands with nn 
started hosts', function () {
+      view.set('controller', Em.Object.create({
+        content: {
+          componentsWithManualCommands: ['NAMENODE'],
+          reassign: {
+            component_name: 'NAMENODE',
+          },
+          reassignHosts: {
+            source: 'source_host',
+            target: 'target_host'
+          },
+          componentDir: 'test_dir',
+          hdfsUser: 'hdfs_user',
+          group: 'group',
+          masterComponentHosts: [
+            Em.Object.create({component: 'NAMENODE', hostName: 'source_host'}),
+            Em.Object.create({component: 'NAMENODE', hostName: 'test_host'}),
+            Em.Object.create({component: 'NAMENODE', hostName: 'target_host'}),
+          ]
+        }
+      }));
+      sinon.stub(App, 'get').returns(true);
+      expect(view.get('manualCommands')).to.be.equal(
+        
Em.I18n.t('services.reassign.step5.body.namenode_ha').format('test_dir', 
'source_host', 'target_host', 'hdfs_user', ['test_host'], 'group', 'test_dir', 
'leveldb-timeline-store.ldb')
+      );
+      App.get.restore();
+    });
+  });
+});
\ No newline at end of file


With regards,
Apache Git Services

Reply via email to