123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- /**
- * 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 Ember = require('ember');
- var App = require('app');
- require('controllers/wizard/step4_controller');
- describe('App.WizardStep4Controller', function () {
- var services = [
- 'HDFS', 'MAPREDUCE', 'NAGIOS', 'GANGLIA', 'OOZIE', 'HIVE', 'HBASE', 'PIG', 'SCOOP', 'ZOOKEEPER', 'HCATALOG', 'WEBHCAT'
- ]
- var controller = App.WizardStep4Controller.create();
- services.forEach(function(serviceName, index){
- controller.pushObject(Ember.Object.create({
- 'serviceName':serviceName, 'isSelected': true, 'canBeSelected': true, 'isInstalled': false, 'isDisabled': index == 0
- }));
- });
- describe('#isSubmitDisabled', function () {
- it('should return false if at least one selected service is not installed', function () {
- expect(controller.get('isSubmitDisabled')).to.equal(false);
- })
- it('should return true if all selected services are already installed', function () {
- controller.setEach('isInstalled', true);
- controller.findProperty('serviceName', 'HDFS').set('isSelected', false);
- expect(controller.get('isSubmitDisabled')).to.equal(true);
- })
- })
- describe('#isAll', function () {
- it('should return true if all services are selected', function () {
- controller.findProperty('serviceName', 'HDFS').set('isSelected', true);
- expect(controller.get('isAll')).to.equal(true);
- })
- it('should return false if at least one service is not selected', function () {
- controller.findProperty('serviceName', 'HDFS').set('isSelected', false);
- expect(controller.get('isAll')).to.equal(false);
- })
- })
- describe('#isMinimum', function () {
- it('should return true if there are no services selected, except disabled', function () {
- controller.setEach('isSelected', false);
- expect(controller.get('isMinimum')).to.equal(true);
- })
- it('should return false if at least one service is selected, except disabled', function () {
- controller.findProperty('serviceName', 'MAPREDUCE').set('isSelected', true);
- expect(controller.get('isMinimum')).to.equal(false);
- })
- })
- describe('#checkDependencies()', function () {
- it('should set ZooKeeper isSelected property like in HBase', function () {
- controller.setEach('isSelected', false);
- controller.findProperty('serviceName', 'HBASE').set('isSelected', true);
- controller.checkDependencies();
- expect(controller.findProperty('serviceName', 'ZOOKEEPER').get('isSelected')).to.equal(true);
- })
- it('should set ZooKeeper, HCatalog, WebHCatalog isSelected property like in Hive', function () {
- controller.setEach('isSelected', false);
- controller.findProperty('serviceName', 'HIVE').set('isSelected', true);
- controller.checkDependencies();
- expect(controller.findProperty('serviceName', 'ZOOKEEPER').get('isSelected')).to.equal(true);
- expect(controller.findProperty('serviceName', 'HCATALOG').get('isSelected')).to.equal(true);
- expect(controller.findProperty('serviceName', 'WEBHCAT').get('isSelected')).to.equal(true);
- })
- })
- describe('#selectAll()', function () {
- it('should select all services', function () {
- controller.setEach('isSelected', false);
- controller.selectAll();
- expect(controller.filterProperty('canBeSelected', true).everyProperty('isSelected', true)).to.equal(true);
- })
- })
- describe('#selectMinimum()', function () {
- it('should set isSelected false for all not disabled services', function () {
- controller.setEach('isSelected', true);
- controller.selectMinimum();
- expect(controller.findProperty('serviceName', 'HDFS').get('isSelected')).to.equal(true);
- expect(controller.filterProperty('isDisabled', false).everyProperty('isSelected', false)).to.equal(true);
- })
- })
- describe('#needToAddMapReduce()', function () {
- it('should return true if Pig is selected and MapReduce is not selected', function () {
- controller.setEach('isSelected', false);
- controller.findProperty('serviceName', 'PIG').set('isSelected', true);
- expect(controller.needToAddMapReduce()).to.equal(true);
- })
- it('should return true if Oozie is selected and MapReduce is not selected', function () {
- controller.setEach('isSelected', false);
- controller.findProperty('serviceName', 'OOZIE').set('isSelected', true);
- expect(controller.needToAddMapReduce()).to.equal(true);
- })
- it('should return true if Hive is selected and MapReduce is not selected', function () {
- controller.setEach('isSelected', false);
- controller.findProperty('serviceName', 'HIVE').set('isSelected', true);
- expect(controller.needToAddMapReduce()).to.equal(true);
- })
- it('should return false if MapReduce is selected or Pig, Oozie and Hive are not selected', function () {
- controller.findProperty('serviceName', 'MAPREDUCE').set('isSelected', true);
- expect(controller.needToAddMapReduce()).to.equal(false);
- controller.setEach('isSelected', false);
- expect(controller.needToAddMapReduce()).to.equal(false);
- })
- })
- describe('#gangliaOrNagiosNotSelected()', function () {
- it('should return true if Nagios or Ganglia is not selected', function () {
- controller.setEach('isSelected', true);
- controller.findProperty('serviceName', 'NAGIOS').set('isSelected', false);
- expect(controller.gangliaOrNagiosNotSelected()).to.equal(true);
- controller.setEach('isSelected', true);
- controller.findProperty('serviceName', 'GANGLIA').set('isSelected', false);
- expect(controller.gangliaOrNagiosNotSelected()).to.equal(true);
- })
- it('should return false if Nagios and Ganglia is selected', function () {
- controller.setEach('isSelected', false);
- controller.findProperty('serviceName', 'GANGLIA').set('isSelected', true);
- controller.findProperty('serviceName', 'NAGIOS').set('isSelected', true);
- expect(controller.gangliaOrNagiosNotSelected()).to.equal(false);
- })
- })
- })
|