123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405 |
- /**
- * 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 App = require('app');
- require('views/wizard/controls_view');
- describe('App.ServiceConfigRadioButtons', function () {
- describe('#didInsertElement', function () {
- var view = App.ServiceConfigRadioButtons.create({
- categoryConfigsAll: [],
- controller: Em.Object.create({
- wizardController: Em.Object.create({})
- }),
- serviceConfig: Em.Object.create({
- value: null
- })
- }),
- cases = [
- {
- wizardControllerName: 'addServiceController',
- serviceConfigValue: 'New MySQL Database',
- onOptionsChangeCalledTwice: true,
- handleDBConnectionPropertyCalledTwice: false,
- title: 'Add Service Wizard, New MySQL Database'
- },
- {
- wizardControllerName: 'addServiceController',
- serviceConfigValue: 'Existing MySQL Database',
- onOptionsChangeCalledTwice: false,
- handleDBConnectionPropertyCalledTwice: true,
- title: 'Add Service Wizard, Existing MySQL Database'
- },
- {
- wizardControllerName: 'installerController',
- serviceConfigValue: 'New MySQL Database',
- onOptionsChangeCalledTwice: true,
- handleDBConnectionPropertyCalledTwice: false,
- title: 'Install Wizard, New MySQL Database'
- },
- {
- wizardControllerName: 'installerController',
- serviceConfigValue: 'Existing MySQL Database',
- onOptionsChangeCalledTwice: false,
- handleDBConnectionPropertyCalledTwice: true,
- title: 'Install Wizard, Existing MySQL Database'
- },
- {
- wizardControllerName: null,
- serviceConfigValue: null,
- onOptionsChangeCalledTwice: false,
- handleDBConnectionPropertyCalledTwice: false,
- title: 'Service Configs Page'
- }
- ];
- beforeEach(function () {
- sinon.stub(view, 'onOptionsChange', Em.K);
- sinon.stub(view, 'handleDBConnectionProperty', Em.K);
- });
- afterEach(function () {
- view.onOptionsChange.restore();
- view.handleDBConnectionProperty.restore();
- });
- cases.forEach(function (item) {
- it(item.title, function () {
- view.set('controller.wizardController.name', item.wizardControllerName);
- view.set('serviceConfig.value', item.serviceConfigValue);
- view.didInsertElement();
- expect(view.onOptionsChange.calledTwice).to.equal(item.onOptionsChangeCalledTwice);
- expect(view.handleDBConnectionProperty.calledTwice).to.equal(item.handleDBConnectionPropertyCalledTwice);
- });
- });
- });
- describe('#databaseNameProperty', function () {
- var view = App.ServiceConfigRadioButtons.create({
- serviceConfig: Em.Object.create(),
- categoryConfigsAll: [
- {
- name: 'ambari.hive.db.schema.name',
- value: 'db0'
- },
- {
- name: 'sink.db.schema.name',
- value: 'db1'
- },
- {
- name: 'oozie.db.schema.name',
- value: 'db2'
- }
- ]
- }),
- cases = [
- {
- serviceName: 'HIVE',
- value: 'db0'
- },
- {
- serviceName: 'HDFS',
- value: 'db1'
- },
- {
- serviceName: 'OOZIE',
- value: 'db2'
- }
- ];
- cases.forEach(function (item) {
- it(item.serviceName, function () {
- view.set('serviceConfig.serviceName', item.serviceName);
- expect(view.get('databaseNameProperty.value')).to.equal(item.value);
- expect(view.get('databaseName')).to.equal(item.value);
- });
- });
- it('default case', function () {
- view.set('serviceConfig.serviceName', 'YARN');
- expect(view.get('databaseNameProperty')).to.be.null;
- expect(view.get('databaseName')).to.be.null;
- });
- });
- describe('#hostNameProperty', function () {
- var view = App.ServiceConfigRadioButtons.create({
- serviceConfig: Em.Object.create(),
- categoryConfigsAll: [
- {
- name: 'hive_ambari_host',
- value: 'h0'
- },
- {
- name: 'hive_existing_mysql_host',
- value: 'h1'
- },
- {
- name: 'hive_existing_postgresql_host',
- value: 'h2'
- },
- {
- name: 'hive_existing_oracle_host',
- value: 'h3'
- },
- {
- name: 'hive_existing_mssql_server_host',
- value: 'h4'
- },
- {
- name: 'hive_existing_mssql_server_2_host',
- value: 'h5'
- },
- {
- name: 'hive_hostname',
- value: 'h6'
- },
- {
- name: 'sink_existing_mssql_server_host',
- value: 'h7'
- },
- {
- name: 'sink_existing_mssql_server_2_host',
- value: 'h8'
- },
- {
- name: 'sink.dbservername',
- value: 'h9'
- },
- {
- name: 'oozie_ambari_host',
- value: 'h10'
- },
- {
- name: 'oozie_existing_mysql_host',
- value: 'h11'
- },
- {
- name: 'oozie_existing_postgresql_host',
- value: 'h12'
- },
- {
- name: 'oozie_existing_oracle_host',
- value: 'h13'
- },
- {
- name: 'oozie_existing_mssql_server_host',
- value: 'h14'
- },
- {
- name: 'oozie_existing_mssql_server_2_host',
- value: 'h15'
- },
- {
- name: 'oozie_hostname',
- value: 'h16'
- }
- ]
- }),
- cases = [
- {
- serviceName: 'HIVE',
- value: 'New MySQL Database',
- expected: 'h0'
- },
- {
- serviceName: 'HIVE',
- value: 'Existing MySQL Database',
- expected: 'h1'
- },
- {
- serviceName: 'HIVE',
- value: Em.I18n.t('services.service.config.hive.oozie.postgresql'),
- expected: 'h2'
- },
- {
- serviceName: 'HIVE',
- value: 'Existing Oracle Database',
- expected: 'h3'
- },
- {
- serviceName: 'HIVE',
- value: 'Existing MSSQL Server database with integrated authentication',
- expected: 'h4'
- },
- {
- serviceName: 'HIVE',
- value: 'Existing MSSQL Server database with sql auth',
- expected: 'h5'
- },
- {
- serviceName: 'HIVE',
- value: 'default case',
- expected: 'h6'
- },
- {
- serviceName: 'HDFS',
- value: 'Existing MSSQL Server database with integrated authentication',
- expected: 'h7'
- },
- {
- serviceName: 'HDFS',
- value: 'Existing MSSQL Server database with sql auth',
- expected: 'h8'
- },
- {
- serviceName: 'HDFS',
- value: 'default case',
- expected: 'h9'
- },
- {
- serviceName: 'OOZIE',
- value: 'New Derby Database',
- expected: 'h10'
- },
- {
- serviceName: 'OOZIE',
- value: 'Existing MySQL Database',
- expected: 'h11'
- },
- {
- serviceName: 'OOZIE',
- value: Em.I18n.t('services.service.config.hive.oozie.postgresql'),
- expected: 'h12'
- },
- {
- serviceName: 'OOZIE',
- value: 'Existing Oracle Database',
- expected: 'h13'
- },
- {
- serviceName: 'OOZIE',
- value: 'Existing MSSQL Server database with integrated authentication',
- expected: 'h14'
- },
- {
- serviceName: 'OOZIE',
- value: 'Existing MSSQL Server database with sql auth',
- expected: 'h15'
- },
- {
- serviceName: 'OOZIE',
- value: 'default case',
- expected: 'h16'
- }
- ];
- before(function () {
- sinon.stub(view, 'handleDBConnectionProperty', Em.K);
- });
- after(function () {
- view.handleDBConnectionProperty.restore();
- });
- cases.forEach(function (item) {
- it(item.serviceName + ', ' + item.value, function () {
- view.get('serviceConfig').setProperties({
- serviceName: item.serviceName,
- value: item.value
- });
- expect(view.get('hostNameProperty.value')).to.equal(item.expected);
- expect(view.get('hostName')).to.equal(item.expected);
- });
- });
- });
- });
- describe('App.ServiceConfigRadioButton', function () {
- describe('#disabled', function () {
- var cases = [
- {
- wizardControllerName: 'addServiceController',
- value: 'New MySQL Database',
- title: 'Add Service Wizard, new database',
- disabled: false
- },
- {
- wizardControllerName: 'installerController',
- value: 'New MySQL Database',
- title: 'Install Wizard, new database',
- disabled: false
- },
- {
- wizardControllerName: 'addServiceController',
- value: 'Existing MySQL Database',
- title: 'Add Service Wizard, existing database',
- disabled: false
- },
- {
- wizardControllerName: 'installerController',
- value: 'Existing MySQL Database',
- title: 'Install Wizard, existing database',
- disabled: false
- },
- {
- wizardControllerName: null,
- value: 'New MySQL Database',
- title: 'No installer, new database',
- disabled: true
- },
- {
- wizardControllerName: null,
- value: 'Existing MySQL Database',
- title: 'No installer, existing database',
- disabled: false
- }
- ];
- cases.forEach(function (item) {
- it(item.title, function () {
- var view = App.ServiceConfigRadioButton.create({
- parentView: Em.Object.create({
- serviceConfig: Em.Object.create()
- }),
- controller: Em.Object.create({
- wizardController: Em.Object.create({
- name: null
- })
- })
- });
- view.set('value', item.value);
- view.set('controller.wizardController.name', item.wizardControllerName);
- view.set('parentView.serviceConfig.isEditable', true);
- expect(view.get('disabled')).to.equal(item.disabled);
- });
- });
- it('parent view is disabled', function () {
- var view = view = App.ServiceConfigRadioButton.create({
- parentView: Em.Object.create({
- serviceConfig: Em.Object.create()
- })
- });
- view.set('parentView.serviceConfig.isEditable', false);
- expect(view.get('disabled')).to.be.true;
- });
- });
- });
|