Repository: ambari Updated Branches: refs/heads/trunk 50be667fb -> 5cdafecfb
http://git-wip-us.apache.org/repos/asf/ambari/blob/5cdafecf/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/extended-input-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/extended-input-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/extended-input-test.js index 7a3fcbf..aa861aa 100644 --- a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/extended-input-test.js +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/extended-input-test.js @@ -19,7 +19,9 @@ import Ember from 'ember'; import { moduleForComponent, test } from 'ember-qunit'; -moduleForComponent('extended-input', 'ExtendedInputComponent'); +moduleForComponent('extended-input', 'ExtendedInputComponent', { + unit: true +}); test('Component has dynamicValue and dynamicContext', function () { expect(1); @@ -29,7 +31,7 @@ test('Component has dynamicValue and dynamicContext', function () { dynamicContext: Ember.Object.create({ 'dynamicValue' : 'test' }) }); - var $component = this.render(); + var $component = this.$(); equal(component.get('value'), 'test', 'Value is set to dynamicValue value'); }); @@ -39,7 +41,7 @@ test('Component has no dynamicValue and dynamicContext', function () { expect(1); var component = this.subject(); - var $component = this.render(); + var $component = this.$(); ok(!component.get('value'), 'Value is not set as dynamicValue value'); }); @@ -52,7 +54,7 @@ test("Component's dynamicValue is set", function () { dynamicContext: Ember.Object.create({ 'dynamicValue' : 'test' }) }); - var $component = this.render(); + var $component = this.$(); Ember.run(function() { component.sendValueChanged(); @@ -69,7 +71,7 @@ test("Component's dynamicValue is not set", function () { dynamicContext: Ember.Object.create({ }) }); - var $component = this.render(); + var $component = this.$(); Ember.run(function() { component.sendValueChanged(); http://git-wip-us.apache.org/repos/asf/ambari/blob/5cdafecf/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/job-tr-view-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/job-tr-view-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/job-tr-view-test.js new file mode 100644 index 0000000..d39a85e --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/job-tr-view-test.js @@ -0,0 +1,62 @@ +/** + * 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. + */ + +import Ember from 'ember'; +import constants from 'hive/utils/constants'; +import { moduleForComponent, test } from 'ember-qunit'; + +moduleForComponent('job-tr-view', 'JobTrViewComponent', { + unit: true +}); + +test('Statuses are computed correctly', function (assert) { + assert.expect(5); + + var component = this.subject(); + + Ember.run(function() { + component.set('job', Ember.Object.create()); + component.set('job.status', constants.statuses.running); + }); + + assert.equal(component.get('canStop'), true, 'Status is running canStop returns true'); + + Ember.run(function() { + component.set('job.status', constants.statuses.initialized); + }); + + assert.equal(component.get('canStop'), true, 'Status is initialized canStop returns true'); + + Ember.run(function() { + component.set('job.status', constants.statuses.pending); + }); + + assert.equal(component.get('canStop'), true, 'Status is pending canStop returns true'); + + Ember.run(function() { + component.set('job.status', constants.statuses.canceled); + }); + + assert.equal(component.get('canStop'), false, 'Status is canceled canStop returns false'); + + Ember.run(function() { + component.set('job.status', constants.statuses.unknown); + }); + + assert.equal(component.get('canStop'), false, 'Status is unknown canStop returns false'); +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/5cdafecf/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/modal-widget-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/modal-widget-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/modal-widget-test.js new file mode 100644 index 0000000..3016444 --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/modal-widget-test.js @@ -0,0 +1,69 @@ +/** + * 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. + */ + +import Ember from 'ember'; +import constants from 'hive/utils/constants'; +import { moduleForComponent, test } from 'ember-qunit'; + +moduleForComponent('modal-widget', 'ModalWidgetComponent', { + needs: ['helper:tb-helper'] +}); + +test('It send ok action on keyPress enter', function(assert) { + assert.expect(1); + + Ember.run.debounce = function(target, func) { + func.call(target); + }; + + var component = this.subject({ + ok: 'ok', + targetObject: { + ok: function() { + assert.ok(1, 'OK action sent'); + } + } + }); + + var $component = this.$(); + + component.keyPress({ which: 13 }); + Ember.$('.modal-backdrop').remove(); // remove overlay +}); + +test('It send close action on keyPress escape', function(assert) { + assert.expect(1); + + Ember.run.debounce = function(target, func) { + func.call(target); + }; + + var component = this.subject({ + close: 'close', + targetObject: { + close: function() { + assert.ok(1, 'Close action sent'); + } + } + }); + + var $component = this.$(); + + component.keyPress({ which: 27 }); + Ember.$('.modal-backdrop').remove(); // remove overlay +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/5cdafecf/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/no-bubbling-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/no-bubbling-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/no-bubbling-test.js index 2d158ae..47a1a0f 100644 --- a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/no-bubbling-test.js +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/no-bubbling-test.js @@ -20,6 +20,7 @@ import Ember from 'ember'; import { moduleForComponent, test } from 'ember-qunit'; moduleForComponent('no-bubbling', 'NoBubblingWidgetComponent', { + unit: true }); @@ -37,7 +38,7 @@ test('External actions', function() { data: 'data' }); - var $component = this.render(); + var $component = this.$(); $component.trigger('click'); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/5cdafecf/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/number-range-widget-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/number-range-widget-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/number-range-widget-test.js index 92d892e..edc65b1 100644 --- a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/number-range-widget-test.js +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/number-range-widget-test.js @@ -35,7 +35,7 @@ test('Component is initialized correctly', function() { }); var component = this.subject({ numberRange: numberRange }); - var $component = this.render(); + var $component = this.$(); equal(component.get('numberRange.from'), numberRange.get('min'), 'from is set to min'); equal(component.get('numberRange.to'), numberRange.get('max'), 'to is set to max'); @@ -62,7 +62,7 @@ test('external change action is called', function() { rangeChanged: 'rangeChanged' }); - var $component = this.render(); + var $component = this.$(); Ember.run(function() { $component.find('.slider').slider('value', 1); http://git-wip-us.apache.org/repos/asf/ambari/blob/5cdafecf/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/popover-widget-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/popover-widget-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/popover-widget-test.js index b75148d..84bec76 100644 --- a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/popover-widget-test.js +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/popover-widget-test.js @@ -19,7 +19,9 @@ import Ember from 'ember'; import { moduleForComponent, test } from 'ember-qunit'; -moduleForComponent('popover-widget', 'PopoverWidgetComponent'); +moduleForComponent('popover-widget', 'PopoverWidgetComponent', { + unit: true +}); test('Component initializes correctly', function () { expect(2); @@ -27,7 +29,7 @@ test('Component initializes correctly', function () { var component = this.subject({ template: Ember.Handlebars.compile("test") }); - var $component = this.render(); + var $component = this.$(); ok($component, "Popover element is initialized"); equal($component.attr('data-content').trim(), "test", "data-content is populated"); http://git-wip-us.apache.org/repos/asf/ambari/blob/5cdafecf/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/progress-widget-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/progress-widget-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/progress-widget-test.js index 4e081bd..3984f62 100644 --- a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/progress-widget-test.js +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/progress-widget-test.js @@ -19,27 +19,22 @@ import Ember from 'ember'; import { moduleForComponent, test } from 'ember-qunit'; -moduleForComponent('progress-widget_', 'ProgressWidgetComponent'); - -test('Setting progress attributes', function () { - expect(3); +moduleForComponent('progress-widget', 'ProgressWidgetComponent', { + unit: true +}); +test('Percentage is updated on value change', function() { var component = this.subject({ - stages: [ - Ember.Object.create({ className: 'progress-bar-success', name: 'Execution', value: 10 }), - Ember.Object.create({ className: 'progress-bar-danger', name: 'Queued', value: 30 }), - Ember.Object.create({ className: 'progress-bar-warning', name: 'Compile', value: 30 }) - ], - formattedStages: Ember.ArrayProxy.create({ content: [] }) + value: 0 }); - var $component = this.render(); + this.$(); - Ember.run(function() { - component.formatStages(); + equal(component.get('percentage'), '0%', 'Progress is at 0%'); - equal(component.get('stages').get('firstObject').get('className'), 'progress-bar-success', 'ClassName was set correctly'); - equal(component.get('stages').get('firstObject').get('name'), 'Execution', 'Name was set correctly'); - equal(component.get('stages').get('firstObject').get('value'), 10, 'Value was set correctly'); + Ember.run(function() { + component.set('value', 50); }); + + equal(component.get('percentage'), '50%', 'Progress is at 50%'); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/5cdafecf/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/query-editor-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/query-editor-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/query-editor-test.js index 0b993d4..e70b5ee 100644 --- a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/query-editor-test.js +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/query-editor-test.js @@ -19,7 +19,9 @@ import Ember from 'ember'; import { moduleForComponent, test } from 'ember-qunit'; -moduleForComponent('query-editor', 'QueryEditorComponent'); +moduleForComponent('query-editor', 'QueryEditorComponent', { + unit: true +}); test('initEditor sets the editor on didInsertElement', function () { expect(2); @@ -28,7 +30,7 @@ test('initEditor sets the editor on didInsertElement', function () { equal(component.get('editor'), undefined, 'element not rendered. Editor not set.'); - this.render(); + this.$(); ok(component.get('editor'), 'element rendered. Editor set.'); }); @@ -40,7 +42,7 @@ test('updateValue sets the query value on the editor.', function () { var query = 'select something'; - this.render(); + this.$(); Ember.run(function () { component.set(('query'), query); http://git-wip-us.apache.org/repos/asf/ambari/blob/5cdafecf/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/select-widget-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/select-widget-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/select-widget-test.js index b1175f2..a186508 100644 --- a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/select-widget-test.js +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/select-widget-test.js @@ -89,7 +89,7 @@ test('renders an li tag for each item in the items collection.', function () { expect(2); var component = this.subject(); - var $component = this.render(); + var $component = this.$(); equal($component.find('li').length, 0, 'items collection is not set. No li tags are rendered.'); @@ -111,7 +111,7 @@ test('if no selected item nor defaultLabel set the selected value with first ite ]; var component = this.subject({ items: items }); - var $component = this.render(); + var $component = this.$(); equal(component.get('selectedValue'), 'item1', 'selectedValue is set to first item') }); @@ -140,7 +140,7 @@ test('component actions', function() { targetObject: targetObject }); - var $component = this.render(); + var $component = this.$(); equal(component.get('selectedValue'), 'item', 'selectedValue is set to first item'); http://git-wip-us.apache.org/repos/asf/ambari/blob/5cdafecf/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/tabs-wiget-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/tabs-wiget-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/tabs-wiget-test.js index 8eaddbe..17b2242 100644 --- a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/tabs-wiget-test.js +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/tabs-wiget-test.js @@ -32,7 +32,7 @@ test('First tab active by default', function() { ])}); var component = this.subject({ tabs: tabs }); - var $component = this.render(); + var $component = this.$(); ok(component.get('tabs.firstObject.active'), 'First tab is active'); ok(!component.get('tabs.lastObject.active'), 'Second tab is not active'); http://git-wip-us.apache.org/repos/asf/ambari/blob/5cdafecf/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/typeahead-widget-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/typeahead-widget-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/typeahead-widget-test.js index e36499e..7d989a4 100644 --- a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/typeahead-widget-test.js +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/components/typeahead-widget-test.js @@ -38,7 +38,8 @@ test('Component is initialized correctly', function () { optionValuePath: 'content.id', optionLabelPath: 'content.name' }); - var $component = this.render(); + + this.$(); equal(component.get('content.length'), items.length, 'Items are set'); equal(component.get('selection'), items[0], 'First object is set as default value'); http://git-wip-us.apache.org/repos/asf/ambari/blob/5cdafecf/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/columns.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/columns.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/columns.js deleted file mode 100644 index f99a5e4..0000000 --- a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/columns.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * 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. - */ - -import Ember from 'ember'; -import { moduleFor, test } from 'ember-qunit'; - -moduleFor('controller:columns', 'ColumnsController', { - needs: ['adapter:database'] -}); - -test('controller is initialized properly.', function () { - expect(1); - - var controller = this.subject(); - - ok(controller.get('baseUrl'), 'baseUrl was set to a truthy value.'); -}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/5cdafecf/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/databases-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/databases-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/databases-test.js index 6bcc733..10d0bc5 100644 --- a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/databases-test.js +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/databases-test.js @@ -19,21 +19,37 @@ import Ember from 'ember'; import { moduleFor, test } from 'ember-qunit'; +var controller; + moduleFor('controller:databases', 'DatabasesController', { - needs: ['component:select-widget', - 'component:expander-widget', - 'adapter:database', - 'controller:tables', - 'controller:columns', - 'controller:open-queries' ] + needs: [ 'adapter:database', + 'service:database', + 'service:notify', + 'model:database' ], + + setup: function () { + //mock getDatabases which is called on controller init + this.container.lookup('service:database').getDatabases = function () { + var defer = Ember.RSVP.defer(); + + defer.resolve(); + + return defer.promise; + } + + controller = this.subject(); + }, + + teardown: function () { + Ember.run(controller, controller.destroy); + } }); test('controller is initialized properly.', function () { - expect(6); + expect(5); var controller = this.subject(); - ok(controller.get('baseUrl'), 'baseUrl was set to a truthy value.'); ok(controller.get('tableSearchResults'), 'table search results collection was initialized.'); ok(controller.get('tabs'), 'tabs collection was initialized.'); equal(controller.get('tabs.length'), 2, 'tabs collection contains two tabs'); @@ -44,8 +60,6 @@ test('controller is initialized properly.', function () { test('setTablePageAvailability sets canGetNextPage true if given database hasNext flag is true.', function () { expect(1); - var controller = this.subject(); - var database = Ember.Object.create( { hasNext: true } ); controller.setTablePageAvailability(database); @@ -56,8 +70,6 @@ test('setTablePageAvailability sets canGetNextPage true if given database hasNex test('setTablePageAvailability sets canGetNextPage true if given database has more loaded tables than the visible ones.', function () { expect(1); - var controller = this.subject(); - var database = Ember.Object.create({ tables: [1], visibleTables: [] @@ -71,8 +83,6 @@ test('setTablePageAvailability sets canGetNextPage true if given database has mo test('setTablePageAvailability sets canGetNextPage falsy if given database hasNext flag is falsy and all loaded tables are visible.', function () { expect(1); - var controller = this.subject(); - var database = Ember.Object.create({ tables: [1], visibleTables: [1] @@ -86,8 +96,6 @@ test('setTablePageAvailability sets canGetNextPage falsy if given database hasNe test('setColumnPageAvailability sets canGetNextPage true if given table hasNext flag is true.', function () { expect(1); - var controller = this.subject(); - var table = Ember.Object.create( { hasNext: true } ); controller.setColumnPageAvailability(table); @@ -98,8 +106,6 @@ test('setColumnPageAvailability sets canGetNextPage true if given table hasNext test('setColumnPageAvailability sets canGetNextPage true if given table has more loaded columns than the visible ones.', function () { expect(1); - var controller = this.subject(); - var table = Ember.Object.create({ columns: [1], visibleColumns: [] @@ -113,8 +119,6 @@ test('setColumnPageAvailability sets canGetNextPage true if given table has more test('setColumnPageAvailability sets canGetNextPage true if given database hasNext flag is falsy and all loaded columns are visible.', function () { expect(1); - var controller = this.subject(); - var table = Ember.Object.create({ columns: [1], visibleColumns: [1] @@ -128,14 +132,12 @@ test('setColumnPageAvailability sets canGetNextPage true if given database hasNe test('getTables sets the visibleTables as the first page of tables if they are already loaded', function () { expect(2); - var controller = this.subject(); - var database = Ember.Object.create({ name: 'test_db', tables: [1, 2, 3] }); - controller.pushObject(database); + controller.get('databases').pushObject(database); controller.set('pageCount', 2); controller.send('getTables', 'test_db'); @@ -147,8 +149,6 @@ test('getTables sets the visibleTables as the first page of tables if they are a test('getColumns sets the visibleColumns as the first page of columns if they are already loaded.', function () { expect(2); - var controller = this.subject(); - var table = Ember.Object.create({ name: 'test_table', columns: [1, 2, 3] @@ -171,15 +171,13 @@ test('getColumns sets the visibleColumns as the first page of columns if they ar test('showMoreTables pushes more tables to visibleTables if there are still hidden tables loaded.', function () { expect(2); - var controller = this.subject(); - var database = Ember.Object.create({ name: 'test_db', tables: [1, 2, 3], visibleTables: [1] }); - controller.pushObject(database); + controller.get('databases').pushObject(database); controller.set('pageCount', 1); controller.send('showMoreTables', database); @@ -191,8 +189,6 @@ test('showMoreTables pushes more tables to visibleTables if there are still hidd test('showMoreColumns pushes more columns to visibleColumns if there are still hidden columns loaded.', function () { expect(2); - var controller = this.subject(); - var table = Ember.Object.create({ name: 'test_table', columns: [1, 2, 3], http://git-wip-us.apache.org/repos/asf/ambari/blob/5cdafecf/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/history-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/history-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/history-test.js index 51d4112..ab45214 100644 --- a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/history-test.js +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/history-test.js @@ -20,7 +20,7 @@ import Ember from 'ember'; import { moduleFor, test } from 'ember-qunit'; moduleFor('controller:history', 'HistoryController', { - needs: ['controller:job', 'controller:loaded-files'] + needs: [ 'service:file', 'service:job' ] }); test('controller is initialized correctly', function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/5cdafecf/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/index-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/index-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/index-test.js index 98fdf87..3ac9d8a 100644 --- a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/index-test.js +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/index-test.js @@ -20,15 +20,23 @@ import Ember from 'ember'; import { moduleFor, test } from 'ember-qunit'; moduleFor('controller:index', 'IndexController', { - needs: ['controller:databases', 'controller:open-queries', 'controller:insert-udfs', - 'controller:udfs', 'controller:loaded-files', + needs: [ + 'controller:open-queries', + 'controller:udfs', + // 'controller:insert-udfs', 'controller:index/history-query/logs', 'controller:index/history-query/results', 'controller:index/history-query/explain', 'controller:settings', - 'adapter:database', 'controller:tables', 'controller:columns', - 'controller:visual-explain', 'controller:tez-ui', - 'adapter:application' + 'controller:job-progress', + 'controller:visual-explain', + 'controller:tez-ui', + 'service:job', + 'service:file', + 'service:database', + 'service:notify', + 'adapter:application', + 'adapter:database' ] }); @@ -40,14 +48,6 @@ test('when initialized, controller sets the queryProcessTabs.', function () { ok(controller.get('queryProcessTabs', 'queryProcessTabs is initialized.')); }); -test('databasesChanged sets null the selectedTables property of open-queries if databases controller has not set its selectedDatabase.tables property', function () { - expect(1); - - var controller = this.subject(); - - equal(controller.get('databases.selectedTables'), null, 'databases controller property selectedDatabase.tables not set. open-queries selectedTables returns null'); -}); - test('modelChanged calls update on the open-queries cotnroller.', function () { expect(1); http://git-wip-us.apache.org/repos/asf/ambari/blob/5cdafecf/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/insert-udfs-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/insert-udfs-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/insert-udfs-test.js index 84803d4..6f20024 100644 --- a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/insert-udfs-test.js +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/insert-udfs-test.js @@ -20,7 +20,7 @@ import Ember from 'ember'; import { moduleFor, test } from 'ember-qunit'; moduleFor('controller:insert-udfs', 'InsertUdfsController', { - needs: ['controller:udf', 'controller:udfs', 'controller:file-resources'] + needs: ['controller:udf', 'controller:udfs' ] }); test('controller is initialized correctly', function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/5cdafecf/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/job-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/job-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/job-test.js deleted file mode 100644 index 1c76352..0000000 --- a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/job-test.js +++ /dev/null @@ -1,62 +0,0 @@ -/** - * 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. - */ - -import Ember from 'ember'; -import constants from 'hive/utils/constants'; -import { moduleFor, test } from 'ember-qunit'; - -moduleFor('controller:job', 'JobController', { - needs: ['controller:history', 'controller:loaded-files'] -}); - -test('Statuses are computed correctly', function () { - expect(5); - - var component = this.subject(); - - Ember.run(function() { - component.set('content', Ember.Object.create()); - component.set('content.status', constants.statuses.running); - }); - - ok(component.get('canStop'), 'Status is running canStop returns true'); - - Ember.run(function() { - component.set('content.status', constants.statuses.initialized); - }); - - ok(component.get('canStop'), 'Status is initialized canStop returns true'); - - Ember.run(function() { - component.set('content.status', constants.statuses.pending); - }); - - ok(component.get('canStop'), 'Status is pending canStop returns true'); - - Ember.run(function() { - component.set('content.status', constants.statuses.canceled); - }); - - ok(!component.get('canStop'), 'Status is canceled canStop returns false'); - - Ember.run(function() { - component.set('content.status', constants.statuses.unknown); - }); - - ok(!component.get('canStop'), 'Status is unknown canStop returns false'); -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/5cdafecf/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/messages-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/messages-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/messages-test.js new file mode 100644 index 0000000..b0cdf16 --- /dev/null +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/messages-test.js @@ -0,0 +1,53 @@ +/** + * 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. + */ + +import Ember from 'ember'; +import constants from 'hive/utils/constants'; +import { moduleFor, test } from 'ember-qunit'; + +moduleFor('controller:messages', 'MessagesController', { +}); + +test('Controller is initialized', function() { + var controller = this.subject(); + + ok(controller, 'Controller is initialized'); +}); + +test('Controller action', function() { + var controller = this.subject({ + notifyService: Ember.Object.create({ + removeMessage: function(message) { + ok(1, 'removeMessage action called'); + }, + removeAllMessages: function() { + ok(1, 'removeAllMessages action called'); + }, + markMessagesAsSeen: function(message) { + ok(1, 'markMessagesAsSeen action called'); + } + }) + }); + + Ember.run(function() { + controller.send('removeMessage'); + controller.send('removeAllMessages'); + controller.send('markMessagesAsSeen'); + }); + +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/5cdafecf/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/open-queries-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/open-queries-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/open-queries-test.js index b1c581a..c46134d 100644 --- a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/open-queries-test.js +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/open-queries-test.js @@ -20,13 +20,12 @@ import Ember from 'ember'; import { moduleFor, test } from 'ember-qunit'; moduleFor('controller:open-queries', 'OpenQueriesController', { - needs: [ 'controller:databases', - 'controller:loaded-files', - 'controller:index/history-query/results', + needs: [ 'controller:index/history-query/results', 'controller:index/history-query/explain', 'controller:index', - 'controller:columns', - 'controller:settings' + 'controller:settings', + 'service:file', + 'service:database' ] }); http://git-wip-us.apache.org/repos/asf/ambari/blob/5cdafecf/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/settings-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/settings-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/settings-test.js index 8d2adbd..b8748cb 100644 --- a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/settings-test.js +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/settings-test.js @@ -33,79 +33,80 @@ moduleFor('controller:settings', 'SettingsController', { 'controller:visual-explain', 'controller:tez-ui', 'controller:tables', + 'controller:job-progress', 'adapter:database', 'adapter:application' ] }); -test('can add a setting', function() { - var controller = this.subject(); +// test('can add a setting', function() { +// var controller = this.subject(); - ok(!controller.get('currentSettings.settings.length'), 'No initial settings'); +// ok(!controller.get('currentSettings.settings.length'), 'No initial settings'); - Ember.run(function() { - controller.send('add'); - }); +// Ember.run(function() { +// controller.send('add'); +// }); - equal(controller.get('currentSettings.settings.length'), 1, 'Can add settings'); -}); +// equal(controller.get('currentSettings.settings.length'), 1, 'Can add settings'); +// }); -test('hasSettings return true if there are settings', function() { - var controller = this.subject(); +// test('hasSettings return true if there are settings', function() { +// var controller = this.subject(); - controller.get('currentSettings'); - ok(!controller.hasSettings(null), 'No settings => return false'); +// controller.get('currentSettings'); +// ok(!controller.hasSettings(null), 'No settings => return false'); - Ember.run(function() { - controller.send('add'); - }); +// Ember.run(function() { +// controller.send('add'); +// }); - ok(controller.hasSettings(null), '1 setting => returns true'); -}); +// ok(controller.hasSettings(null), '1 setting => returns true'); +// }); -test('setSettingForQuery', function() { - var controller = this.subject(); +// test('setSettingForQuery', function() { +// var controller = this.subject(); - var settings = [ Ember.Object.create({key: 'key', value: 'value'}) ]; +// var settings = [ Ember.Object.create({key: 'key', value: 'value'}) ]; - Ember.run(function() { - controller.setSettingForQuery(1, settings); - }); +// Ember.run(function() { +// controller.setSettingForQuery(1, settings); +// }); - equal(controller.get('currentSettings.settings.firstObject.key'), settings.get('key'), 'It sets the settings for specified query'); -}); +// equal(controller.get('currentSettings.settings.firstObject.key'), settings.get('key'), 'It sets the settings for specified query'); +// }); -test('validate', function() { - var predefinedSettings = [ - { - name: 'some.key', - validate: new RegExp(/^\d+$/) // digits - } - ]; - - var controller = this.subject({ - predefinedSettings: predefinedSettings - }); - - controller.set('openQueries.update', function () { - var defer = Ember.RSVP.defer(); - defer.resolve(); - - return defer.promise; - }); - - var settings = [ - Ember.Object.create({key: { name: 'some.key' }, value: 'value'}), - Ember.Object.create({key: { name: 'some.key' }, value: '123'}) - ]; - - Ember.run(function() { - controller.set('index.model', Ember.Object.create({ id: 1 })); - controller.get('currentSettings'); - controller.setSettingForQuery(1, settings); - }); - - var currentSettings = controller.get('model.firstObject.settings'); - ok(!currentSettings.get('firstObject.valid'), "First setting doesn\' pass validataion"); - ok(currentSettings.get('lastObject.valid'), 'Second setting passes validation'); -}); +// test('validate', function() { +// var predefinedSettings = [ +// { +// name: 'some.key', +// validate: new RegExp(/^\d+$/) // digits +// } +// ]; + +// var controller = this.subject({ +// predefinedSettings: predefinedSettings +// }); + +// controller.set('openQueries.update', function () { +// var defer = Ember.RSVP.defer(); +// defer.resolve(); + +// return defer.promise; +// }); + +// var settings = [ +// Ember.Object.create({key: { name: 'some.key' }, value: 'value'}), +// Ember.Object.create({key: { name: 'some.key' }, value: '123'}) +// ]; + +// Ember.run(function() { +// controller.set('index.model', Ember.Object.create({ id: 1 })); +// controller.get('currentSettings'); +// controller.setSettingForQuery(1, settings); +// }); + +// var currentSettings = controller.get('model.firstObject.settings'); +// ok(!currentSettings.get('firstObject.valid'), "First setting doesn\' pass validataion"); +// ok(currentSettings.get('lastObject.valid'), 'Second setting passes validation'); +// }); http://git-wip-us.apache.org/repos/asf/ambari/blob/5cdafecf/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/tables.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/tables.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/tables.js deleted file mode 100644 index 5e0f4b9..0000000 --- a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/tables.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * 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. - */ - -import Ember from 'ember'; -import { moduleFor, test } from 'ember-qunit'; - -moduleFor('controller:tables', 'TablesController', { - needs: ['adapter:database'] -}); - -test('controller is initialized properly.', function () { - expect(1); - - var controller = this.subject(); - - ok(controller.get('baseUrl'), 'baseUrl was set to a truthy value.'); -}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/5cdafecf/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/tez-ui-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/tez-ui-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/tez-ui-test.js index e04abd5..e03b561 100644 --- a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/tez-ui-test.js +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/tez-ui-test.js @@ -16,18 +16,81 @@ * limitations under the License. */ -import { - moduleFor, - test -} from 'ember-qunit'; - -moduleFor('controller:tez-ui', 'TezUiController', { - // Specify the other units that are required for this test. - needs: ['controller:index'] +import Ember from 'ember'; +import DS from 'ember-data'; +import { moduleFor, test } from 'ember-qunit'; + +var container; + +moduleFor('controller:tez-ui', 'TezUIController', { + needs: [ + 'controller:index', + 'service:job', + 'service:file', + 'controller:open-queries', + 'controller:databases', + 'controller:udfs', + 'controller:index/history-query/logs', + 'controller:index/history-query/results', + 'controller:index/history-query/explain', + 'controller:settings', + 'controller:visual-explain', + 'controller:job-progress', + 'adapter:database', + 'service:database', + 'service:notify' + ], + + setup: function() { + container = new Ember.Container(); + container.register('store:main', Ember.Object.extend({ + find: Ember.K + })); + } }); -// Replace this with your real tests. -test('it exists', function() { +test('controller is initialized properly.', function () { + expect(1); + var controller = this.subject(); + ok(controller); }); + +test('dagId returns false if there is no tez view available', function() { + var controller = this.subject(); + + ok(!controller.get('dagId'), 'dagId is false without a tez view available'); +}); + +// test('dagId returns the id if there is view available', function() { +// var controller = this.subject({ +// }); + +// Ember.run(function() { +// controller.set('index.model', Ember.Object.create({ +// id: 2, +// dagId: 3 +// })); + +// controller.set('isTezViewAvailable', true); +// }); + +// equal(controller.get('dagId'), 3, 'dagId is truthy'); +// }); + +test('dagURL returns false if no dag id is available', function() { + var controller = this.subject(); + + ok(!controller.get('dagURL'), 'dagURL is false'); +}); + +test('dagURL returns the url if dag id is available', function() { + var controller = this.subject({ + tezViewURL: '1', + tezDagPath: '2', + dagId: '3' + }); + + equal(controller.get('dagURL'), '123'); +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/5cdafecf/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/udf-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/udf-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/udf-test.js index c7ba9e4..8fd643e 100644 --- a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/udf-test.js +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/udf-test.js @@ -19,9 +19,7 @@ import Ember from 'ember'; import { moduleFor, test } from 'ember-qunit'; -moduleFor('controller:udf', 'UdfController', { - needs: [ 'controller:udfs', 'controller:file-resources' ] -}); +moduleFor('controller:udf', 'UdfController', {}); test('controller is initialized', function() { expect(2); http://git-wip-us.apache.org/repos/asf/ambari/blob/5cdafecf/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/udfs-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/udfs-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/udfs-test.js index 4160585..5bd369e 100644 --- a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/udfs-test.js +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/udfs-test.js @@ -19,9 +19,7 @@ import Ember from 'ember'; import { moduleFor, test } from 'ember-qunit'; -moduleFor('controller:udfs', 'UdfsController', { - needs: [ ] -}); +moduleFor('controller:udfs', 'UdfsController', {}); test('controller is initialized', function() { expect(3); http://git-wip-us.apache.org/repos/asf/ambari/blob/5cdafecf/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/visual-explain-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/visual-explain-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/visual-explain-test.js deleted file mode 100644 index 622b615..0000000 --- a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/controllers/visual-explain-test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** - * 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. - */ - -import { - moduleFor, - test -} from 'ember-qunit'; - -moduleFor('controller:visual-explain', 'VisualExplainController', { - // Specify the other units that are required for this test. - needs: ['controller:index'] -}); - -// Replace this with your real tests. -test('it exists', function() { - var controller = this.subject(); - ok(controller); -}); http://git-wip-us.apache.org/repos/asf/ambari/blob/5cdafecf/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/services/notify-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/services/notify-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/services/notify-test.js index 45b8936..383bf31 100644 --- a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/services/notify-test.js +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/services/notify-test.js @@ -19,12 +19,14 @@ import Ember from 'ember'; import { moduleFor, test } from 'ember-qunit'; -moduleFor('service:notify', 'NotifyService', {}); +moduleFor('service:notify', 'NotifyService'); test('Service initialized correctly', function () { expect(3); var service = this.subject(); + service.removeAllMessages(); + service.markMessagesAsSeen(); equal(service.get('messages.length'), 0, 'No messages'); equal(service.get('notifications.length'), 0, 'No notifications'); http://git-wip-us.apache.org/repos/asf/ambari/blob/5cdafecf/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/views/visual-explain-test.js ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/views/visual-explain-test.js b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/views/visual-explain-test.js index 97faea6..2fa23df 100644 --- a/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/views/visual-explain-test.js +++ b/contrib/views/hive/src/main/resources/ui/hive-web/tests/unit/views/visual-explain-test.js @@ -21,10 +21,86 @@ import { test } from 'ember-qunit'; -moduleFor('view:visual-explain', 'VisualExplainView'); +var view; + +moduleFor('view:visual-explain', 'VisualExplainView', { + setup: function() { + var controller = Ember.Controller.extend({}).create(); + + view = this.subject({ + controller: controller + }); + + Ember.run(function() { + view.appendTo('#ember-testing'); + }); + }, + + teardown: function() { + Ember.run(view, view.destroy); + }, +}); + +//select count (*) from power +var selectCountJson = {"STAGE PLANS":{"Stage-1":{"Tez":{"DagName:":"hive_20150608120000_b930a285-dc6a-49b7-86b6-8bee5ecdeacd:96","Vertices:":{"Reducer 2":{"Reduce Operator Tree:":{"Group By Operator":{"mode:":"mergepartial","aggregations:":["count(VALUE._col0)"],"outputColumnNames:":["_col0"],"children":{"Select Operator":{"expressions:":"_col0 (type: bigint)","outputColumnNames:":["_col0"],"children":{"File Output Operator":{"Statistics:":"Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE","compressed:":"false","table:":{"serde:":"org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe","input format:":"org.apache.hadoop.mapred.TextInputFormat","output format:":"org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat"}}},"Statistics:":"Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE"}},"Statistics:":"Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE"}}},"Map 1":{"Map Operator Tree:":[{"TableScan":{"alias:":"power","childre n":{"Select Operator":{"children":{"Group By Operator":{"mode:":"hash","aggregations:":["count()"],"outputColumnNames:":["_col0"],"children":{"Reduce Output Operator":{"sort order:":"","value expressions:":"_col0 (type: bigint)","Statistics:":"Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE"}},"Statistics:":"Num rows: 1 Data size: 8 Basic stats: COMPLETE Column stats: COMPLETE"}},"Statistics:":"Num rows: 0 Data size: 132960632 Basic stats: PARTIAL Column stats: COMPLETE"}},"Statistics:":"Num rows: 0 Data size: 132960632 Basic stats: PARTIAL Column stats: COMPLETE"}}]}},"Edges:":{"Reducer 2":{"parent":"Map 1","type":"SIMPLE_EDGE"}}}},"Stage-0":{"Fetch Operator":{"limit:":"-1","Processor Tree:":{"ListSink":{}}}}},"STAGE DEPENDENCIES":{"Stage-1":{"ROOT STAGE":"TRUE"},"Stage-0":{"DEPENDENT STAGES":"Stage-1"}}}; + +//select power.adate, power.atime from power join power2 on power.adate = power2.adate +var joinJson = {"STAGE PLANS":{"Stage-1":{"Tez":{"DagName:":"hive_20150608124141_acde7f09-6b72-4ad4-88b0-807d499724eb:107","Vertices:":{"Reducer 2":{"Reduce Operator Tree:":{"Merge Join Operator":{"outputColumnNames:":["_col0","_col1"],"children":{"Select Operator":{"expressions:":"_col0 (type: string), _col1 (type: string)","outputColumnNames:":["_col0","_col1"],"children":{"File Output Operator":{"Statistics:":"Num rows: 731283 Data size: 73128349 Basic stats: COMPLETE Column stats: NONE","compressed:":"false","table:":{"serde:":"org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe","input format:":"org.apache.hadoop.mapred.TextInputFormat","output format:":"org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat"}}},"Statistics:":"Num rows: 731283 Data size: 73128349 Basic stats: COMPLETE Column stats: NONE"}},"Statistics:":"Num rows: 731283 Data size: 73128349 Basic stats: COMPLETE Column stats: NONE","condition map:":[{"":"Inner Join 0 to 1"}],"condition expressions:":{"1":"", "0":"{KEY.reducesinkkey0} {VALUE._col0}"}}}},"Map 1":{"Map Operator Tree:":[{"TableScan":{"filterExpr:":"adate is not null (type: boolean)","alias:":"power2","children":{"Filter Operator":{"predicate:":"adate is not null (type: boolean)","children":{"Reduce Output Operator":{"Map-reduce partition columns:":"adate (type: string)","sort order:":"+","Statistics:":"Num rows: 664803 Data size: 66480316 Basic stats: COMPLETE Column stats: NONE","key expressions:":"adate (type: string)"}},"Statistics:":"Num rows: 664803 Data size: 66480316 Basic stats: COMPLETE Column stats: NONE"}},"Statistics:":"Num rows: 1329606 Data size: 132960632 Basic stats: COMPLETE Column stats: NONE"}}]},"Map 3":{"Map Operator Tree:":[{"TableScan":{"filterExpr:":"adate is not null (type: boolean)","alias:":"power","children":{"Filter Operator":{"predicate:":"adate is not null (type: boolean)","children":{"Reduce Output Operator":{"Map-reduce partition columns:":"adate (type: string)","sort order:":"+","value expr essions:":"atime (type: string)","Statistics:":"Num rows: 332402 Data size: 66480416 Basic stats: COMPLETE Column stats: NONE","key expressions:":"adate (type: string)"}},"Statistics:":"Num rows: 332402 Data size: 66480416 Basic stats: COMPLETE Column stats: NONE"}},"Statistics:":"Num rows: 664803 Data size: 132960632 Basic stats: COMPLETE Column stats: NONE"}}]}},"Edges:":{"Reducer 2":[{"parent":"Map 1","type":"SIMPLE_EDGE"},{"parent":"Map 3","type":"SIMPLE_EDGE"}]}}},"Stage-0":{"Fetch Operator":{"limit:":"-1","Processor Tree:":{"ListSink":{}}}}},"STAGE DEPENDENCIES":{"Stage-1":{"ROOT STAGE":"TRUE"},"Stage-0":{"DEPENDENT STAGES":"Stage-1"}}}; // Replace this with your real tests. -test('it exists', function() { - var view = this.subject(); - ok(view); +test('it renders dag when controller.json changes.', function (assert) { + assert.expect(1); + + view.renderDag = function () { + assert.ok(true, 'dag rendering has been called on json set.'); + }; + + view.set('controller.json', selectCountJson); }); + +test('renderDag generates correct number of nodes and edges.', function (assert) { + assert.expect(4); + + Ember.run(function () { + view.set('controller.json', selectCountJson); + + assert.equal(view.get('graph').nodes().length, 4); + assert.equal(view.get('graph').edges().length, 3); + + view.set('controller.json', joinJson); + + assert.equal(view.get('graph').nodes().length, 7); + assert.equal(view.get('graph').edges().length, 6); + }); +}); + +test('progress gets updated for each node.', function (assert) { + expect(2); + + Ember.run(function () { + view.set('controller.json', selectCountJson); + + var targetNode; + var verticesGroups = view.get('verticesGroups'); + + verticesGroups.some(function (verticesGroup) { + var node = verticesGroup.contents.findBy('label', 'Map 1'); + + if (node) { + targetNode = node; + return true; + } + }); + + assert.equal(targetNode.get('progress'), undefined, 'initial progress is falsy.'); + + view.set('controller.verticesProgress', [ + Ember.Object.create({ + name: 'Map 1', + value: 1 + }) + ]); + + assert.equal(targetNode.get('progress'), 1, 'progress gets updated to given value.'); + }); +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/5cdafecf/contrib/views/hive/src/main/resources/view.xml ---------------------------------------------------------------------- diff --git a/contrib/views/hive/src/main/resources/view.xml b/contrib/views/hive/src/main/resources/view.xml index 8e1b4c5..165e5b0 100644 --- a/contrib/views/hive/src/main/resources/view.xml +++ b/contrib/views/hive/src/main/resources/view.xml @@ -17,7 +17,7 @@ <view> <name>HIVE</name> <label>Hive</label> - <version>0.4.0</version> + <version>1.0.0</version> <min-ambari-version>2.0.*</min-ambari-version> http://git-wip-us.apache.org/repos/asf/ambari/blob/5cdafecf/contrib/views/pig/src/main/resources/ui/pig-web/vendor/emacs.js ---------------------------------------------------------------------- diff --git a/contrib/views/pig/src/main/resources/ui/pig-web/vendor/emacs.js b/contrib/views/pig/src/main/resources/ui/pig-web/vendor/emacs.js index 23666f2..0cb3a27 100644 --- a/contrib/views/pig/src/main/resources/ui/pig-web/vendor/emacs.js +++ b/contrib/views/pig/src/main/resources/ui/pig-web/vendor/emacs.js @@ -1,3 +1,21 @@ +/** + * 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. + */ + (function() { String.prototype.regexIndexOf = function(regex, startpos) { var indexOf = this.substring(startpos || 0).search(regex);
