step4_test.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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', 'HCATALOG').get('isSelected')).to.equal(true);
  73. expect(controller.findProperty('serviceName', 'WEBHCAT').get('isSelected')).to.equal(true);
  74. })
  75. })
  76. describe('#selectAll()', function () {
  77. it('should select all services', function () {
  78. controller.setEach('isSelected', false);
  79. controller.selectAll();
  80. expect(controller.filterProperty('canBeSelected', true).everyProperty('isSelected', true)).to.equal(true);
  81. })
  82. })
  83. describe('#selectMinimum()', function () {
  84. it('should set isSelected false for all not disabled services', function () {
  85. controller.setEach('isSelected', true);
  86. controller.selectMinimum();
  87. expect(controller.findProperty('serviceName', 'HDFS').get('isSelected')).to.equal(true);
  88. expect(controller.filterProperty('isDisabled', false).everyProperty('isSelected', false)).to.equal(true);
  89. })
  90. })
  91. describe('#needToAddMapReduce()', function () {
  92. it('should return true if Pig is selected and MapReduce is not selected', function () {
  93. controller.setEach('isSelected', false);
  94. controller.findProperty('serviceName', 'PIG').set('isSelected', true);
  95. expect(controller.needToAddMapReduce()).to.equal(true);
  96. })
  97. it('should return true if Oozie is selected and MapReduce is not selected', function () {
  98. controller.setEach('isSelected', false);
  99. controller.findProperty('serviceName', 'OOZIE').set('isSelected', true);
  100. expect(controller.needToAddMapReduce()).to.equal(true);
  101. })
  102. it('should return true if Hive is selected and MapReduce is not selected', function () {
  103. controller.setEach('isSelected', false);
  104. controller.findProperty('serviceName', 'HIVE').set('isSelected', true);
  105. expect(controller.needToAddMapReduce()).to.equal(true);
  106. })
  107. it('should return false if MapReduce is selected or Pig, Oozie and Hive are not selected', function () {
  108. controller.findProperty('serviceName', 'MAPREDUCE').set('isSelected', true);
  109. expect(controller.needToAddMapReduce()).to.equal(false);
  110. controller.setEach('isSelected', false);
  111. expect(controller.needToAddMapReduce()).to.equal(false);
  112. })
  113. })
  114. describe('#gangliaOrNagiosNotSelected()', function () {
  115. it('should return true if Nagios or Ganglia is not selected', function () {
  116. controller.setEach('isSelected', true);
  117. controller.findProperty('serviceName', 'NAGIOS').set('isSelected', false);
  118. expect(controller.gangliaOrNagiosNotSelected()).to.equal(true);
  119. controller.setEach('isSelected', true);
  120. controller.findProperty('serviceName', 'GANGLIA').set('isSelected', false);
  121. expect(controller.gangliaOrNagiosNotSelected()).to.equal(true);
  122. })
  123. it('should return false if Nagios and Ganglia is selected', function () {
  124. controller.setEach('isSelected', false);
  125. controller.findProperty('serviceName', 'GANGLIA').set('isSelected', true);
  126. controller.findProperty('serviceName', 'NAGIOS').set('isSelected', true);
  127. expect(controller.gangliaOrNagiosNotSelected()).to.equal(false);
  128. })
  129. })
  130. })