123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290 |
- /**
- * 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 Ember = require('ember');
- var App = require('app');
- require('mappers/server_data_mapper');
- require('mappers/stack_mapper');
- require('models/stack');
- require('models/operating_system');
- require('models/repository');
- describe('App.stackMapper', function () {
- describe("#map", function() {
-
- var test_data = {
- items: [{
- "Versions" : {
- "active" : true,
- "min_upgrade_version" : null,
- "parent_stack_version" : "1.3.3",
- "stack_name" : "HDP",
- "stack_version" : "1.3"
- },
- "operating_systems" : [
- {
- "OperatingSystems" : {
- "os_type" : "redhat5",
- "stack_name" : "HDP",
- "stack_version" : "1.3"
- },
- "repositories" : [
- {
- "Repositories" : {
- "base_url" : "http://public-repo-1.hortonworks.com/HDP/centos5/1.x/updates/1.3.7.0",
- "default_base_url" : "http://public-repo-1.hortonworks.com/HDP/centos5/1.x/updates/1.3.7.0",
- "latest_base_url" : "http://public-repo-1.hortonworks.com/HDP/centos5/1.x/updates/1.3.8.0",
- "mirrors_list" : null,
- "os_type" : "redhat5",
- "repo_id" : "HDP-1.3",
- "repo_name" : "HDP",
- "stack_name" : "HDP",
- "stack_version" : "1.3"
- }
- },{
- "Repositories" : {
- "base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.16/repos/centos5",
- "default_base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.16/repos/centos5",
- "latest_base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.16/repos/centos5",
- "mirrors_list" : null,
- "os_type" : "redhat5",
- "repo_id" : "HDP-UTILS-1.1.0.16",
- "repo_name" : "HDP-UTILS",
- "stack_name" : "HDP",
- "stack_version" : "1.3"
- }
- }]
- },{
- "OperatingSystems" : {
- "os_type" : "redhat6",
- "stack_name" : "HDP",
- "stack_version" : "1.3"
- }, "repositories" : [
- {
- "Repositories" : {
- "base_url" : "http://public-repo-1.hortonworks.com/HDP/centos6/1.x/updates/1.3.7.0",
- "default_base_url" : "http://public-repo-1.hortonworks.com/HDP/centos6/1.x/updates/1.3.7.0",
- "latest_base_url" : "http://public-repo-1.hortonworks.com/HDP/centos6/1.x/updates/1.3.8.0",
- "mirrors_list" : null,
- "os_type" : "redhat6",
- "repo_id" : "HDP-1.3",
- "repo_name" : "HDP",
- "stack_name" : "HDP",
- "stack_version" : "1.3"
- }
- },
- {
- "Repositories" : {
- "base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.16/repos/centos6",
- "default_base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.16/repos/centos6",
- "latest_base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.16/repos/centos6",
- "mirrors_list" : null,
- "os_type" : "redhat6",
- "repo_id" : "HDP-UTILS-1.1.0.16",
- "repo_name" : "HDP-UTILS",
- "stack_name" : "HDP",
- "stack_version" : "1.3"
- }
- }
- ]
- }]
- },{
- "Versions" : {
- "active" : false,
- "min_upgrade_version" : null,
- "parent_stack_version" : null,
- "stack_name" : "HDP",
- "stack_version" : "2.0.6"
- },
- "operating_systems" : [
- {
- "OperatingSystems" : {
- "os_type" : "redhat5",
- "stack_name" : "HDP",
- "stack_version" : "2.0.6"
- },
- "repositories" : [
- {
- "Repositories" : {
- "base_url" : "http://public-repo-1.hortonworks.com/HDP/centos5/2.x/updates/2.0.6.1",
- "default_base_url" : "http://public-repo-1.hortonworks.com/HDP/centos5/2.x/updates/2.0.6.1",
- "latest_base_url" : "http://public-repo-1.hortonworks.com/HDP/centos5/2.x/updates/2.0.6.1",
- "mirrors_list" : null,
- "os_type" : "redhat5",
- "repo_id" : "HDP-2.0.6",
- "repo_name" : "HDP",
- "stack_name" : "HDP",
- "stack_version" : "2.0.6"
- }
- },
- {
- "Repositories" : {
- "base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.17/repos/centos5",
- "default_base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.17/repos/centos5",
- "latest_base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.17/repos/centos5",
- "mirrors_list" : null,
- "os_type" : "redhat5",
- "repo_id" : "HDP-UTILS-1.1.0.17",
- "repo_name" : "HDP-UTILS",
- "stack_name" : "HDP",
- "stack_version" : "2.0.6"
- }
- }]
- }, {
- "OperatingSystems" : {
- "os_type" : "redhat6",
- "stack_name" : "HDP",
- "stack_version" : "2.0.6"
- },
- "repositories" : [
- {
- "Repositories" : {
- "base_url" : "http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.0.6.1",
- "default_base_url" : "http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.0.6.1",
- "latest_base_url" : "http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.0.6.1",
- "mirrors_list" : null,
- "os_type" : "redhat6",
- "repo_id" : "HDP-2.0.6",
- "repo_name" : "HDP",
- "stack_name" : "HDP",
- "stack_version" : "2.0.6"
- }
- }, {
- "Repositories" : {
- "base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.17/repos/centos6",
- "default_base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.17/repos/centos6",
- "latest_base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.17/repos/centos6",
- "mirrors_list" : null,
- "os_type" : "redhat6",
- "repo_id" : "HDP-UTILS-1.1.0.17",
- "repo_name" : "HDP-UTILS",
- "stack_name" : "HDP",
- "stack_version" : "2.0.6"
- }
- }]
- }]
- },{
- "Versions" : {
- "active" : true,
- "min_upgrade_version" : null,
- "parent_stack_version" : null,
- "stack_name" : "HDP",
- "stack_version" : "2.1"
- },
- "operating_systems" : [
- {
- "OperatingSystems" : {
- "os_type" : "redhat5",
- "stack_name" : "HDP",
- "stack_version" : "2.1"
- },
- "repositories" : [
- {
- "Repositories" : {
- "base_url" : "http://public-repo-1.hortonworks.com/HDP/centos5/2.x/updates/2.0.6.1",
- "default_base_url" : "http://public-repo-1.hortonworks.com/HDP/centos5/2.x/updates/2.0.6.1",
- "latest_base_url" : "http://public-repo-1.hortonworks.com/HDP/centos5/2.x/updates/2.0.6.1",
- "mirrors_list" : null,
- "os_type" : "redhat5",
- "repo_id" : "HDP-2.1",
- "repo_name" : "HDP",
- "stack_name" : "HDP",
- "stack_version" : "2.1"
- }
- },
- {
- "Repositories" : {
- "base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.17/repos/centos5",
- "default_base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.17/repos/centos5",
- "latest_base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.17/repos/centos5",
- "mirrors_list" : null,
- "os_type" : "redhat5",
- "repo_id" : "HDP-UTILS-1.1.0.17",
- "repo_name" : "HDP-UTILS",
- "stack_name" : "HDP",
- "stack_version" : "2.1"
- }
- }]
- }, {
- "OperatingSystems" : {
- "os_type" : "redhat6",
- "stack_name" : "HDP",
- "stack_version" : "2.1"
- },
- "repositories" : [
- {
- "Repositories" : {
- "base_url" : "http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.0.6.1",
- "default_base_url" : "http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.0.6.1",
- "latest_base_url" : "http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.0.6.1",
- "mirrors_list" : null,
- "os_type" : "redhat6",
- "repo_id" : "HDP-2.1",
- "repo_name" : "HDP",
- "stack_name" : "HDP",
- "stack_version" : "2.1"
- }
- }, {
- "Repositories" : {
- "base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.17/repos/centos6",
- "default_base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.17/repos/centos6",
- "latest_base_url" : "http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.17/repos/centos6",
- "mirrors_list" : null,
- "os_type" : "redhat6",
- "repo_id" : "HDP-UTILS-1.1.0.17",
- "repo_name" : "HDP-UTILS",
- "stack_name" : "HDP",
- "stack_version" : "2.1"
- }
- }]
- }]
- }]
- };
- beforeEach(function () {
- App.resetDsStoreTypeMap(App.Repository);
- App.resetDsStoreTypeMap(App.OperatingSystem);
- App.resetDsStoreTypeMap(App.Stack);
- sinon.stub(App.store, 'commit', Em.K);
- });
- afterEach(function(){
- App.store.commit.restore();
- });
-
- it ('should map active Stack data', function() {
- App.stackMapper.map(test_data);
- expect(App.Stack.find().get('length')).to.equal(2);
- expect(App.Stack.find().everyProperty('active')).to.equal(true);
- expect(App.Stack.find().everyProperty('isSelected')).to.equal(false);
- expect(App.Stack.find().mapProperty('id')).to.eql(['HDP-2.1','HDP-1.3']);
- });
- it ('should map Operating System data', function() {
- App.stackMapper.map(test_data);
- expect(App.OperatingSystem.find().get('length')).to.equal(4);
- expect(App.OperatingSystem.find().mapProperty('id')).to.eql(['HDP-2.1-redhat5', 'HDP-2.1-redhat6', 'HDP-1.3-redhat5', 'HDP-1.3-redhat6']);
- });
-
- it ('should map Repository data', function() {
- App.stackMapper.map(test_data);
- expect(App.Repository.find().get('length')).to.equal(8);
- expect(App.Repository.find().mapProperty('id')).to.eql(["HDP-2.1-redhat5-HDP-2.1", "HDP-2.1-redhat5-HDP-UTILS-1.1.0.17", "HDP-2.1-redhat6-HDP-2.1", "HDP-2.1-redhat6-HDP-UTILS-1.1.0.17", "HDP-1.3-redhat5-HDP-1.3", "HDP-1.3-redhat5-HDP-UTILS-1.1.0.16", "HDP-1.3-redhat6-HDP-1.3", "HDP-1.3-redhat6-HDP-UTILS-1.1.0.16"]);
- });
- });
- });
|