| /** |
| * 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, '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.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); |
| }) |
| }) |
| |
| }) |
| |