step4_test.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var Ember = require('ember');
  19. var App = require('app');
  20. require('controllers/wizard/step4_controller');
  21. describe('App.WizardStep4Controller', function () {
  22. var services = [
  23. 'HDFS', 'MAPREDUCE', 'NAGIOS', 'GANGLIA', 'OOZIE', 'HIVE', 'HBASE', 'PIG', 'SCOOP', 'ZOOKEEPER', 'HCATALOG', 'WEBHCAT'
  24. ]
  25. var controller = App.WizardStep4Controller.create();
  26. services.forEach(function(serviceName, index){
  27. controller.pushObject(Ember.Object.create({
  28. 'serviceName':serviceName, 'isSelected': true, 'canBeSelected': true, 'isInstalled': false, 'isDisabled': index == 0
  29. }));
  30. });
  31. describe('#isSubmitDisabled', function () {
  32. it('should return false if at least one selected service is not installed', function () {
  33. expect(controller.get('isSubmitDisabled')).to.equal(false);
  34. })
  35. it('should return true if all selected services are already installed', function () {
  36. controller.setEach('isInstalled', true);
  37. controller.findProperty('serviceName', 'HDFS').set('isSelected', false);
  38. expect(controller.get('isSubmitDisabled')).to.equal(true);
  39. })
  40. })
  41. describe('#isAll', function () {
  42. it('should return true if all services are selected', function () {
  43. controller.findProperty('serviceName', 'HDFS').set('isSelected', true);
  44. expect(controller.get('isAll')).to.equal(true);
  45. })
  46. it('should return false if at least one service is not selected', function () {
  47. controller.findProperty('serviceName', 'HDFS').set('isSelected', false);
  48. expect(controller.get('isAll')).to.equal(false);
  49. })
  50. })
  51. describe('#isMinimum', function () {
  52. it('should return true if there are no services selected, except disabled', function () {
  53. controller.setEach('isSelected', false);
  54. expect(controller.get('isMinimum')).to.equal(true);
  55. })
  56. it('should return false if at least one service is selected, except disabled', function () {
  57. controller.findProperty('serviceName', 'MAPREDUCE').set('isSelected', true);
  58. expect(controller.get('isMinimum')).to.equal(false);
  59. })
  60. })
  61. describe('#checkDependencies()', function () {
  62. it('should set ZooKeeper isSelected property like in HBase', function () {
  63. controller.setEach('isSelected', false);
  64. controller.findProperty('serviceName', 'HBASE').set('isSelected', true);
  65. controller.checkDependencies();
  66. expect(controller.findProperty('serviceName', 'ZOOKEEPER').get('isSelected')).to.equal(true);
  67. })
  68. it('should set ZooKeeper, HCatalog, WebHCatalog isSelected property like in Hive', function () {
  69. controller.setEach('isSelected', false);
  70. controller.findProperty('serviceName', 'HIVE').set('isSelected', true);
  71. controller.checkDependencies();
  72. expect(controller.findProperty('serviceName', 'ZOOKEEPER').get('isSelected')).to.equal(true);
  73. expect(controller.findProperty('serviceName', 'HCATALOG').get('isSelected')).to.equal(true);
  74. expect(controller.findProperty('serviceName', 'WEBHCAT').get('isSelected')).to.equal(true);
  75. })
  76. })
  77. describe('#selectAll()', function () {
  78. it('should select all services', function () {
  79. controller.setEach('isSelected', false);
  80. controller.selectAll();
  81. expect(controller.filterProperty('canBeSelected', true).everyProperty('isSelected', true)).to.equal(true);
  82. })
  83. })
  84. describe('#selectMinimum()', function () {
  85. it('should set isSelected false for all not disabled services', function () {
  86. controller.setEach('isSelected', true);
  87. controller.selectMinimum();
  88. expect(controller.findProperty('serviceName', 'HDFS').get('isSelected')).to.equal(true);
  89. expect(controller.filterProperty('isDisabled', false).everyProperty('isSelected', false)).to.equal(true);
  90. })
  91. })
  92. describe('#needToAddMapReduce()', function () {
  93. it('should return true if Pig is selected and MapReduce is not selected', function () {
  94. controller.setEach('isSelected', false);
  95. controller.findProperty('serviceName', 'PIG').set('isSelected', true);
  96. expect(controller.needToAddMapReduce()).to.equal(true);
  97. })
  98. it('should return true if Oozie is selected and MapReduce is not selected', function () {
  99. controller.setEach('isSelected', false);
  100. controller.findProperty('serviceName', 'OOZIE').set('isSelected', true);
  101. expect(controller.needToAddMapReduce()).to.equal(true);
  102. })
  103. it('should return true if Hive is selected and MapReduce is not selected', function () {
  104. controller.setEach('isSelected', false);
  105. controller.findProperty('serviceName', 'HIVE').set('isSelected', true);
  106. expect(controller.needToAddMapReduce()).to.equal(true);
  107. })
  108. it('should return false if MapReduce is selected or Pig, Oozie and Hive are not selected', function () {
  109. controller.findProperty('serviceName', 'MAPREDUCE').set('isSelected', true);
  110. expect(controller.needToAddMapReduce()).to.equal(false);
  111. controller.setEach('isSelected', false);
  112. expect(controller.needToAddMapReduce()).to.equal(false);
  113. })
  114. })
  115. describe('#gangliaOrNagiosNotSelected()', function () {
  116. it('should return true if Nagios or Ganglia is not selected', function () {
  117. controller.setEach('isSelected', true);
  118. controller.findProperty('serviceName', 'NAGIOS').set('isSelected', false);
  119. expect(controller.gangliaOrNagiosNotSelected()).to.equal(true);
  120. controller.setEach('isSelected', true);
  121. controller.findProperty('serviceName', 'GANGLIA').set('isSelected', false);
  122. expect(controller.gangliaOrNagiosNotSelected()).to.equal(true);
  123. })
  124. it('should return false if Nagios and Ganglia is selected', function () {
  125. controller.setEach('isSelected', false);
  126. controller.findProperty('serviceName', 'GANGLIA').set('isSelected', true);
  127. controller.findProperty('serviceName', 'NAGIOS').set('isSelected', true);
  128. expect(controller.gangliaOrNagiosNotSelected()).to.equal(false);
  129. })
  130. })
  131. })