step1_controller_test.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. });