step1_controller_test.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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 App = require('app');
  19. require('controllers/main/service/reassign/step1_controller');
  20. require('models/host_component');
  21. describe('App.ReassignMasterWizardStep1Controller', function () {
  22. var controller = App.ReassignMasterWizardStep1Controller.create({
  23. content: Em.Object.create({
  24. reassign: Em.Object.create({}),
  25. services: []
  26. })
  27. });
  28. controller.set('_super', Em.K);
  29. describe('#loadConfigTags', function() {
  30. beforeEach(function() {
  31. sinon.stub(App.ajax, 'send', Em.K);
  32. });
  33. afterEach(function() {
  34. App.ajax.send.restore();
  35. });
  36. it('tests loadConfigTags', function() {
  37. controller.loadConfigsTags();
  38. expect(App.ajax.send.calledOnce).to.be.true;
  39. });
  40. it('tests saveDatabaseType with type', function() {
  41. sinon.stub(App.router, 'get', function() {
  42. return { saveDatabaseType: Em.K};
  43. });
  44. controller.saveDatabaseType(true);
  45. expect(App.router.get.calledOnce).to.be.true;
  46. App.router.get.restore();
  47. });
  48. it('tests saveDatabaseType without type', function() {
  49. sinon.stub(App.router, 'get', function() {
  50. return { saveDatabaseType: Em.K};
  51. });
  52. controller.saveDatabaseType(false);
  53. expect(App.router.get.called).to.be.false;
  54. App.router.get.restore();
  55. });
  56. it('tests saveServiceProperties with propertie', function() {
  57. sinon.stub(App.router, 'get', function() {
  58. return { saveServiceProperties: Em.K};
  59. });
  60. controller.saveServiceProperties(true);
  61. expect(App.router.get.calledOnce).to.be.true;
  62. App.router.get.restore();
  63. });
  64. it('tests saveServiceProperties without properties', function() {
  65. sinon.stub(App.router, 'get', function() {
  66. return { saveServiceProperties: Em.K};
  67. });
  68. controller.saveServiceProperties(false);
  69. expect(App.router.get.called).to.be.false;
  70. App.router.get.restore();
  71. });
  72. it('tests getDatabaseHost', function() {
  73. controller.set('content.serviceProperties', {
  74. 'javax.jdo.option.ConnectionURL': "jdbc:mysql://c6401/hive?createDatabaseIfNotExist=true"
  75. });
  76. controller.set('content.reassign.service_id', 'HIVE');
  77. controller.set('databaseType', 'mysql');
  78. expect(controller.getDatabaseHost()).to.equal('c6401')
  79. });
  80. });
  81. describe('#onLoadConfigs', function() {
  82. var controller;
  83. var reassignCtrl;
  84. beforeEach(function() {
  85. controller = App.ReassignMasterWizardStep1Controller.create({
  86. content: Em.Object.create({
  87. reassign: Em.Object.create({
  88. 'component_name': 'OOZIE_SERVER',
  89. 'service_id': 'OOZIE'
  90. }),
  91. services: []
  92. })
  93. });
  94. controller.set('_super', Em.K);
  95. sinon.stub(controller, 'getDatabaseHost', Em.K);
  96. sinon.stub(controller, 'saveDatabaseType', Em.K);
  97. sinon.stub(controller, 'saveServiceProperties', Em.K);
  98. reassignCtrl = App.router.reassignMasterController;
  99. reassignCtrl.set('content.hasManualSteps', true);
  100. });
  101. afterEach(function() {
  102. controller.getDatabaseHost.restore();
  103. controller.saveDatabaseType.restore();
  104. controller.saveServiceProperties.restore();
  105. });
  106. it('should not set hasManualSteps to false for oozie with derby db', function() {
  107. var data = {
  108. items: [
  109. {
  110. properties: {
  111. 'oozie.service.JPAService.jdbc.driver': 'jdbc:derby:${oozie.data.dir}/${oozie.db.schema.name}-db;create=true'
  112. }
  113. }
  114. ]
  115. };
  116. expect(reassignCtrl.get('content.hasManualSteps')).to.be.true;
  117. controller.onLoadConfigs(data);
  118. expect(reassignCtrl.get('content.hasManualSteps')).to.be.true;
  119. });
  120. it('should set hasManualSteps to false for oozie without derby db', function() {
  121. var data = {
  122. items: [
  123. {
  124. properties: {
  125. 'oozie.service.JPAService.jdbc.driver': 'mysql'
  126. }
  127. }
  128. ]
  129. };
  130. expect(reassignCtrl.get('content.hasManualSteps')).to.be.true;
  131. controller.onLoadConfigs(data);
  132. expect(reassignCtrl.get('content.hasManualSteps')).to.be.false;
  133. });
  134. });
  135. });