IGNITE-5271 Use same blank cluster for basic and advanced configuration.

Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/d52aa800
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/d52aa800
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/d52aa800

Branch: refs/heads/ignite-2.1.2-exchange
Commit: d52aa800c95f1b9fa6c2fcc2e349fc88a259102c
Parents: f6df8fb
Author: Ilya Borisov <[email protected]>
Authored: Fri Jun 16 20:40:34 2017 +0700
Committer: Andrey Novikov <[email protected]>
Committed: Fri Jun 16 20:40:34 2017 +0700

----------------------------------------------------------------------
 modules/web-console/frontend/.eslintrc          |   2 +-
 .../page-configure-basic/controller.js          |  50 +++---
 .../page-configure-basic/controller.spec.js     | 159 ++++++++++++++++---
 .../components/page-configure-basic/reducer.js  |  20 +--
 .../page-configure-basic/reducer.spec.js        |   2 +-
 .../components/page-configure-basic/service.js  |   6 +-
 .../page-configure-basic/service.spec.js        |  24 ++-
 .../page-configure-basic/template.pug           |   2 +-
 .../frontend/app/services/Clusters.js           |  52 ++++++
 .../frontend/app/services/Clusters.spec.js      |  55 +++++++
 .../frontend/controllers/clusters-controller.js |  45 +-----
 11 files changed, 306 insertions(+), 111 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d52aa800/modules/web-console/frontend/.eslintrc
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/.eslintrc 
b/modules/web-console/frontend/.eslintrc
index 9680678..6778b86 100644
--- a/modules/web-console/frontend/.eslintrc
+++ b/modules/web-console/frontend/.eslintrc
@@ -120,7 +120,7 @@ rules:
     no-loop-func: 2
     no-mixed-requires: [0, false]
     no-mixed-spaces-and-tabs: [2, true]
-    no-multi-spaces: 2
+    no-multi-spaces: ["error", {"exceptions": { "VariableDeclarator": true }}]
     no-multi-str: 2
     no-multiple-empty-lines: [0, {"max": 2}]
     no-native-reassign: 2

http://git-wip-us.apache.org/repos/asf/ignite/blob/d52aa800/modules/web-console/frontend/app/components/page-configure-basic/controller.js
----------------------------------------------------------------------
diff --git 
a/modules/web-console/frontend/app/components/page-configure-basic/controller.js
 
b/modules/web-console/frontend/app/components/page-configure-basic/controller.js
index 4a67c6a..ac99977 100644
--- 
a/modules/web-console/frontend/app/components/page-configure-basic/controller.js
+++ 
b/modules/web-console/frontend/app/components/page-configure-basic/controller.js
@@ -34,21 +34,7 @@ export default class PageConfigureBasicController {
     }
 
     $onInit() {
-        this.subscription = this.ConfigureState.state$
-        .combineLatest(this.Version.currentSbj)
-        .do(([state, version]) => {
-            this.$scope.$applyAsync(() => {
-                this.clusters = state.list.clusters;
-                this.caches = state.list.caches;
-                this.state = state.configureBasic;
-                this.allClusterCaches = this.getAllClusterCaches();
-                this.cachesMenu = this.getCachesMenu();
-                this.clustersMenu = this.getClustersMenu();
-                this.defaultMemoryPolicy = 
this.getDefaultClusterMemoryPolicy(this.state.cluster);
-                this.memorySizeInputVisible = 
this.getMemorySizeInputVisibility(version);
-            });
-        }).subscribe();
-
+        this.subscription = this.getObservable(this.ConfigureState.state$, 
this.Version.currentSbj).subscribe();
         this.discoveries = this.Clusters.discoveries;
         this.minMemorySize = this.Clusters.minMemoryPolicySize;
 
@@ -63,6 +49,24 @@ export default class PageConfigureBasicController {
         this.pageService.setCluster(-1);
     }
 
+    getObservable(state$, version$) {
+        return state$.combineLatest(version$, (state, version) => ({
+            clusters: state.list.clusters,
+            caches: state.list.caches,
+            state: state.configureBasic,
+            allClusterCaches: this.getAllClusterCaches(state.configureBasic),
+            cachesMenu: this.getCachesMenu(state.list.caches),
+            clustersMenu: this.getClustersMenu(state.list.clusters),
+            defaultMemoryPolicy: 
this.getDefaultClusterMemoryPolicy(state.configureBasic.cluster),
+            memorySizeInputVisible: this.getMemorySizeInputVisibility(version)
+        }))
+        .do((value) => this.applyValue(value));
+    }
+
+    applyValue(value) {
+        this.$scope.$applyAsync(() => Object.assign(this, value));
+    }
+
     $onDestroy() {
         this.subscription.unsubscribe();
     }
@@ -106,21 +110,19 @@ export default class PageConfigureBasicController {
         ));
     }
 
-    getClustersMenu() {
+    getClustersMenu(clusters = new Map()) {
         const newOne = {_id: -1, name: '+ Add new cluster'};
-        return get(this, 'clusters.size')
-            ? [newOne, {}, ...this.clusters.values()]
+        return clusters.size
+            ? [newOne, {}, ...clusters.values()]
             : [newOne];
     }
 
-    getCachesMenu() {
-        return [...(this.caches || []).values()].map((c) => ({_id: c._id, 
name: c.name}));
+    getCachesMenu(caches = []) {
+        return [...caches.values()].map((c) => ({_id: c._id, name: c.name}));
     }
 
-    getAllClusterCaches() {
-        return this.state
-            ? [...this.state.oldClusterCaches, ...this.state.newClusterCaches]
-            : [];
+    getAllClusterCaches(state = {oldClusterCaches: [], newClusterCaches: []}) {
+        return [...state.oldClusterCaches, ...state.newClusterCaches];
     }
 
     getDefaultClusterMemoryPolicy(cluster) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/d52aa800/modules/web-console/frontend/app/components/page-configure-basic/controller.spec.js
----------------------------------------------------------------------
diff --git 
a/modules/web-console/frontend/app/components/page-configure-basic/controller.spec.js
 
b/modules/web-console/frontend/app/components/page-configure-basic/controller.spec.js
index a9de1ec..4798219 100644
--- 
a/modules/web-console/frontend/app/components/page-configure-basic/controller.spec.js
+++ 
b/modules/web-console/frontend/app/components/page-configure-basic/controller.spec.js
@@ -19,14 +19,15 @@ import {suite, test} from 'mocha';
 import {assert} from 'chai';
 import {spy} from 'sinon';
 
+import {TestScheduler} from 'rxjs/testing/TestScheduler';
 import {Subject} from 'rxjs/Subject';
+import {BehaviorSubject} from 'rxjs/BehaviorSubject';
+import {Subscriber} from 'rxjs/Subscriber';
 import Controller from './controller';
 
 const mocks = () => new Map([
     ['$scope', {
-        $applyAsync: spy(function() {
-            this._fn = fn;
-        })
+        $applyAsync: spy((fn) => fn())
     }],
     ['pageService', {
         setCluster: spy()
@@ -42,14 +43,22 @@ const mocks = () => new Map([
         downloadClusterConfiguration: spy()
     }],
     ['IgniteVersion', {
-        currentSbj: new BehaviorSubject({ignite: '1.9.0'})
+        currentSbj: new BehaviorSubject({ignite: '1.9.0'}),
+        since: (a, b) => a === b
     }]
 ]);
 
 suite('page-configure-basic component controller', () => {
-    test('$onInit', () => {
+    test('$onInit method', () => {
         const c = new Controller(...mocks().values());
+        c.getObservable = spy(c.getObservable.bind(c));
         c.$onInit();
+        assert.deepEqual(
+            c.getObservable.lastCall.args,
+            [c.ConfigureState.state$, c.Version.currentSbj],
+            'calls getObservable with correct arguments'
+        );
+        assert.instanceOf(c.subscription, Subscriber, 'stores subscription for 
later');
         assert.equal(c.discoveries, 1, 'exposes discoveries');
         assert.equal(c.minMemorySize, 1000, 'exposes minMemorySize');
         assert.deepEqual(
@@ -62,34 +71,138 @@ suite('page-configure-basic component controller', () => {
             'exposes sizesMenu'
         );
         assert.equal(c.memorySizeScale, c.sizesMenu[2], 'sets default 
memorySizeScale to Gb');
-        assert.deepEqual(c.pageService.setCluster.getCall(0).args, [-1], 'sets 
cluster to -1');
+        assert.deepEqual(c.pageService.setCluster.lastCall.args, [-1], 'sets 
cluster to -1');
     });
-    // TODO IGNITE-5271 Cover rest of controller features with tests
-    test.skip('State subscription', () => {
+
+    test('$onDestroy method', () => {
         const c = new Controller(...mocks().values());
         c.$onInit();
-        const state = {
-            list: {
+        c.subscription.unsubscribe = spy(c.subscription.unsubscribe);
+        c.$onDestroy();
+        assert(c.subscription.unsubscribe.calledOnce, 'unsubscribes from 
Observable');
+    });
+
+    test('getObservable method', () => {
+        const testScheduler = new TestScheduler((...args) => 
assert.deepEqual(...args));
+        const c = new Controller(...mocks().values());
+
+        c.applyValue = spy(c.applyValue.bind(c));
+
+        const version  = 'a-b-';
+        const state    = '-a-b';
+        const expected = '-abc';
+
+        const version$ = testScheduler.createHotObservable(version, {
+            a: {ignite: '1.9.0'},
+            b: {ignite: '2.0.0'}
+        });
+
+        const state$ = testScheduler.createHotObservable(state, {
+            a: {
+                list: {
+                    clusters: new Map(),
+                    caches: new Map()
+                },
+                configureBasic: {
+                    newClusterCaches: [],
+                    oldClusterCaches: [],
+                    cluster: null
+                }
+            },
+            b: {
+                list: {
+                    clusters: new Map([
+                        [1, {_id: 1, name: '1', caches: [1, 2]}],
+                        [2, {_id: 2, name: '2'}]
+                    ]),
+                    caches: new Map([
+                        [1, {_id: 1, name: '1'}],
+                        [2, {_id: 2, name: '2'}]
+                    ])
+                },
+                configureBasic: {
+                    newClusterCaches: [],
+                    oldClusterCaches: [
+                        {_id: 1, name: '1'},
+                        {_id: 2, name: '2'}
+                    ],
+                    cluster: {_id: 1, name: '1', caches: [1, 2]}
+                }
+            }
+        });
+
+
+        const expectedValues = {
+            a: {
+                clusters: new Map(),
+                caches: new Map(),
+                state: {
+                    newClusterCaches: [],
+                    oldClusterCaches: [],
+                    cluster: null
+                },
+                allClusterCaches: [],
+                cachesMenu: [],
+                clustersMenu: [{_id: -1, name: '+ Add new cluster'}],
+                defaultMemoryPolicy: void 0,
+                memorySizeInputVisible: false
+            },
+            b: {
+                clusters: new Map(),
+                caches: new Map(),
+                state: {
+                    newClusterCaches: [],
+                    oldClusterCaches: [],
+                    cluster: null
+                },
+                allClusterCaches: [],
+                cachesMenu: [],
+                clustersMenu: [{_id: -1, name: '+ Add new cluster'}],
+                defaultMemoryPolicy: void 0,
+                memorySizeInputVisible: true
+            },
+            c: {
                 clusters: new Map([
-                    [1, {_id: 1, name: '1'}],
+                    [1, {_id: 1, name: '1', caches: [1, 2]}],
                     [2, {_id: 2, name: '2'}]
                 ]),
                 caches: new Map([
                     [1, {_id: 1, name: '1'}],
                     [2, {_id: 2, name: '2'}]
-                ])
-            },
-            configureBasic: {
-                newClusterCaches: [1, 2, 3],
-                oldClusterCaches: [4, 5, 6],
-                cluster: {
-                    memoryConfiguration: {
-                        memoryPolicies: [{name: 'Default'}]
-                    }
-                }
+                ]),
+                state: {
+                    newClusterCaches: [],
+                    oldClusterCaches: [
+                        {_id: 1, name: '1'},
+                        {_id: 2, name: '2'}
+                    ],
+                    cluster: {_id: 1, name: '1', caches: [1, 2]}
+                },
+                allClusterCaches: [
+                    {_id: 1, name: '1'},
+                    {_id: 2, name: '2'}
+                ],
+                cachesMenu: [
+                    {_id: 1, name: '1'},
+                    {_id: 2, name: '2'}
+                ],
+                clustersMenu: [
+                    {_id: -1, name: '+ Add new cluster'},
+                    {},
+                    {_id: 1, name: '1', caches: [1, 2]},
+                    {_id: 2, name: '2'}
+                ],
+                defaultMemoryPolicy: void 0,
+                memorySizeInputVisible: true
             }
         };
-        c.ConfigureState.state$.next(state);
-        assert.equal(c.clusters, state.list.clusters, 'gets clusters from 
state');
+
+        testScheduler.expectObservable(c.getObservable(state$, 
version$)).toBe(expected, expectedValues);
+        testScheduler.flush();
+
+        assert.deepEqual(c.applyValue.getCall(0).args[0], expectedValues.a, 
'applies value a');
+        assert.deepEqual(c.applyValue.getCall(1).args[0], expectedValues.b, 
'applies value b');
+        assert.deepEqual(c.applyValue.getCall(2).args[0], expectedValues.c, 
'applies value c');
+        assert.equal(c.applyValue.callCount, 3, 'applyValue was called correct 
amount of times');
     });
 });

http://git-wip-us.apache.org/repos/asf/ignite/blob/d52aa800/modules/web-console/frontend/app/components/page-configure-basic/reducer.js
----------------------------------------------------------------------
diff --git 
a/modules/web-console/frontend/app/components/page-configure-basic/reducer.js 
b/modules/web-console/frontend/app/components/page-configure-basic/reducer.js
index 1eca38e..ff02a05 100644
--- 
a/modules/web-console/frontend/app/components/page-configure-basic/reducer.js
+++ 
b/modules/web-console/frontend/app/components/page-configure-basic/reducer.js
@@ -53,25 +53,11 @@ export const reducer = (state = defaults, action, root) => {
         case SET_CLUSTER: {
             const cluster = !isNewItem(action)
                 ? cloneDeep(root.list.clusters.get(action._id))
-                : {
+                : Object.assign({}, action.cluster, {
                     _id: -1,
-                    discovery: {
-                        kind: 'Multicast',
-                        Vm: {addresses: ['127.0.0.1:47500..47510']},
-                        Multicast: {addresses: ['127.0.0.1:47500..47510']},
-                        Jdbc: {initSchema: true},
-                        Cloud: {regions: [], zones: []}
-                    },
                     space: defaultSpace(root),
-                    name: uniqueName('New cluster', 
[...root.list.clusters.values()]),
-                    memoryConfiguration: {
-                        memoryPolicies: [{
-                            name: 'default',
-                            maxSize: null
-                        }]
-                    },
-                    caches: []
-                };
+                    name: uniqueName('New cluster', 
[...root.list.clusters.values()])
+                });
             const value = Object.assign({}, state, {
                 clusterID: cluster._id,
                 cluster,

http://git-wip-us.apache.org/repos/asf/ignite/blob/d52aa800/modules/web-console/frontend/app/components/page-configure-basic/reducer.spec.js
----------------------------------------------------------------------
diff --git 
a/modules/web-console/frontend/app/components/page-configure-basic/reducer.spec.js
 
b/modules/web-console/frontend/app/components/page-configure-basic/reducer.spec.js
index 4a84183..01aad14 100644
--- 
a/modules/web-console/frontend/app/components/page-configure-basic/reducer.spec.js
+++ 
b/modules/web-console/frontend/app/components/page-configure-basic/reducer.spec.js
@@ -63,7 +63,7 @@ suite('page-configure-basic component reducer', () => {
             caches: []
         };
         assert.deepEqual(
-            reducer(void 0, {type: SET_CLUSTER, _id: -1}, root),
+            reducer(void 0, {type: SET_CLUSTER, _id: -1, cluster: 
defaultCluster}, root),
             {
                 clusterID: -1,
                 cluster: Object.assign({}, defaultCluster, {

http://git-wip-us.apache.org/repos/asf/ignite/blob/d52aa800/modules/web-console/frontend/app/components/page-configure-basic/service.js
----------------------------------------------------------------------
diff --git 
a/modules/web-console/frontend/app/components/page-configure-basic/service.js 
b/modules/web-console/frontend/app/components/page-configure-basic/service.js
index 5940058..4db61ea 100644
--- 
a/modules/web-console/frontend/app/components/page-configure-basic/service.js
+++ 
b/modules/web-console/frontend/app/components/page-configure-basic/service.js
@@ -113,7 +113,11 @@ export default class PageConfigureBasic {
     }
 
     setCluster(_id) {
-        this.ConfigureState.dispatchAction({type: SET_CLUSTER, _id});
+        this.ConfigureState.dispatchAction(
+            isNewItem({_id})
+            ? {type: SET_CLUSTER, _id, cluster: 
this.clusters.getBlankCluster()}
+            : {type: SET_CLUSTER, _id}
+        );
     }
 
     addCache() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/d52aa800/modules/web-console/frontend/app/components/page-configure-basic/service.spec.js
----------------------------------------------------------------------
diff --git 
a/modules/web-console/frontend/app/components/page-configure-basic/service.spec.js
 
b/modules/web-console/frontend/app/components/page-configure-basic/service.spec.js
index a5ba658..7d8d30c 100644
--- 
a/modules/web-console/frontend/app/components/page-configure-basic/service.spec.js
+++ 
b/modules/web-console/frontend/app/components/page-configure-basic/service.spec.js
@@ -38,7 +38,8 @@ const mocks = () => new Map([
         saveCluster: spy(function(c) {
             if (this._nextID === 2) return Promise.reject(`Cluster with name 
${c.name} already exists`);
             return Promise.resolve({data: this._nextID++});
-        })
+        }),
+        getBlankCluster: spy(() => ({name: 'Cluster'}))
     }],
     ['caches', {
         _nextID: 1,
@@ -298,4 +299,25 @@ suite('page-configure-basic service', () => {
             );
         });
     });
+    suite('setCluster', () => {
+        test('new cluster', () => {
+            const service = new Provider(...mocks().values());
+            service.setCluster(-1);
+            assert.isOk(service.clusters.getBlankCluster.calledOnce, 'calls 
clusters.getBlankCluster');
+            assert.deepEqual(
+                service.ConfigureState.dispatchAction.lastCall.args[0],
+                {type: SET_CLUSTER, _id: -1, cluster: 
service.clusters.getBlankCluster.returnValues[0]},
+                'dispatches correct action'
+            );
+        });
+        test('existing cluster', () => {
+            const service = new Provider(...mocks().values());
+            service.setCluster(1);
+            assert.deepEqual(
+                service.ConfigureState.dispatchAction.lastCall.args[0],
+                {type: SET_CLUSTER, _id: 1},
+                'dispatches correct action'
+            );
+        });
+    });
 });

http://git-wip-us.apache.org/repos/asf/ignite/blob/d52aa800/modules/web-console/frontend/app/components/page-configure-basic/template.pug
----------------------------------------------------------------------
diff --git 
a/modules/web-console/frontend/app/components/page-configure-basic/template.pug 
b/modules/web-console/frontend/app/components/page-configure-basic/template.pug
index e6d479c..91b0692 100644
--- 
a/modules/web-console/frontend/app/components/page-configure-basic/template.pug
+++ 
b/modules/web-console/frontend/app/components/page-configure-basic/template.pug
@@ -45,7 +45,7 @@ form(novalidate name=form)
                 | You can create a new one on this tab or 
#[a(ui-sref='^.advanced.clusters') edit existing ones].
 
     .settings-row
-        +ignite-form-field-dropdown('Cluster:', '$ctrl.clusterID', 
'"clusters"', false, true, false, 'Select a cluster', '', '$ctrl.clustersMenu')(
+        +ignite-form-field-dropdown('Cluster:', '$ctrl.clusterID', 
'"clusters"', false, true, false, 'Select a cluster', '', '$ctrl.clustersMenu', 
'Add new cluster or select existing one.')(
             bs-options='cluster._id as cluster.name for cluster in 
$ctrl.clustersMenu'
         )
     .settings-row

http://git-wip-us.apache.org/repos/asf/ignite/blob/d52aa800/modules/web-console/frontend/app/services/Clusters.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/services/Clusters.js 
b/modules/web-console/frontend/app/services/Clusters.js
index 0192c5a..4e38a58 100644
--- a/modules/web-console/frontend/app/services/Clusters.js
+++ b/modules/web-console/frontend/app/services/Clusters.js
@@ -40,4 +40,56 @@ export default class Clusters {
     saveCluster(cluster) {
         return this.$http.post('/api/v1/configuration/clusters/save', cluster);
     }
+
+    getBlankCluster() {
+        return {
+            activeOnStart: true,
+            cacheSanityCheckEnabled: true,
+            atomicConfiguration: {},
+            cacheKeyConfiguration: [],
+            deploymentSpi: {
+                URI: {
+                    uriList: [],
+                    scanners: []
+                }
+            },
+            marshaller: {},
+            peerClassLoadingLocalClassPathExclude: [],
+            sslContextFactory: {
+                trustManagers: []
+            },
+            swapSpaceSpi: {},
+            transactionConfiguration: {},
+            memoryConfiguration: {
+                memoryPolicies: [{
+                    name: 'default',
+                    maxSize: null
+                }]
+            },
+            hadoopConfiguration: {
+                nativeLibraryNames: []
+            },
+            serviceConfigurations: [],
+            executorConfiguration: [],
+            sqlConnectorConfiguration: {
+                tcpNoDelay: true
+            },
+            space: void 0,
+            discovery: {
+                kind: 'Multicast',
+                Vm: {addresses: ['127.0.0.1:47500..47510']},
+                Multicast: {addresses: ['127.0.0.1:47500..47510']},
+                Jdbc: {initSchema: true},
+                Cloud: {regions: [], zones: []}
+            },
+            binaryConfiguration: {typeConfigurations: [], compactFooter: true},
+            communication: {tcpNoDelay: true},
+            connector: {noDelay: true},
+            collision: {kind: 'Noop', JobStealing: {stealingEnabled: true}, 
PriorityQueue: {starvationPreventionEnabled: true}},
+            failoverSpi: [],
+            logger: {Log4j: { mode: 'Default'}},
+            caches: [],
+            igfss: []
+        };
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/d52aa800/modules/web-console/frontend/app/services/Clusters.spec.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/app/services/Clusters.spec.js 
b/modules/web-console/frontend/app/services/Clusters.spec.js
new file mode 100644
index 0000000..92bfa2e
--- /dev/null
+++ b/modules/web-console/frontend/app/services/Clusters.spec.js
@@ -0,0 +1,55 @@
+/*
+ * 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 {suite, test} from 'mocha';
+import {assert} from 'chai';
+import {spy} from 'sinon';
+
+import Provider from './Clusters.js';
+
+const mocks = () => new Map([
+    ['$http', {
+        post: spy()
+    }]
+]);
+
+suite('Clusters service', () => {
+    test('discoveries', () => {
+        const s = new Provider(...mocks().values());
+        assert.isArray(s.discoveries, 'has discoveries array');
+        assert.isOk(s.discoveries.every((d) => d.value && d.label), 
'discoveries have correct format');
+    });
+
+    test('minMemoryPolicySize', () => {
+        const s = new Provider(...mocks().values());
+        assert.isNumber(s.minMemoryPolicySize, 'has minMemoryPolicySize 
number');
+    });
+
+    test('saveCluster', () => {
+        const s = new Provider(...mocks().values());
+        const cluster = {id: 1, name: 'Test'};
+        s.saveCluster(cluster);
+        assert.isOk(s.$http.post.called, 'calls $http.post');
+        assert.equal(s.$http.post.lastCall.args[0], 
'/api/v1/configuration/clusters/save', 'uses correct API URL');
+        assert.deepEqual(s.$http.post.lastCall.args[1], cluster, 'sends 
cluster');
+    });
+
+    test('getBlankCluster', () => {
+        const s = new Provider(...mocks().values());
+        assert.isObject(s.getBlankCluster());
+    });
+});

http://git-wip-us.apache.org/repos/asf/ignite/blob/d52aa800/modules/web-console/frontend/controllers/clusters-controller.js
----------------------------------------------------------------------
diff --git a/modules/web-console/frontend/controllers/clusters-controller.js 
b/modules/web-console/frontend/controllers/clusters-controller.js
index cb59c20..8340b4d 100644
--- a/modules/web-console/frontend/controllers/clusters-controller.js
+++ b/modules/web-console/frontend/controllers/clusters-controller.js
@@ -16,8 +16,8 @@
  */
 
 // Controller for Clusters screen.
-export default ['$rootScope', '$scope', '$http', '$state', '$timeout', 
'IgniteLegacyUtils', 'IgniteMessages', 'IgniteConfirm', 'IgniteInput', 
'IgniteLoading', 'IgniteModelNormalizer', 'IgniteUnsavedChangesGuard', 
'IgniteEventGroups', 'DemoInfo', 'IgniteLegacyTable', 
'IgniteConfigurationResource', 'IgniteErrorPopover', 'IgniteFormUtils', 
'IgniteVersion',
-    function($root, $scope, $http, $state, $timeout, LegacyUtils, Messages, 
Confirm, Input, Loading, ModelNormalizer, UnsavedChangesGuard, 
igniteEventGroups, DemoInfo, LegacyTable, Resource, ErrorPopover, FormUtils, 
Version) {
+export default ['$rootScope', '$scope', '$http', '$state', '$timeout', 
'IgniteLegacyUtils', 'IgniteMessages', 'IgniteConfirm', 'IgniteInput', 
'IgniteLoading', 'IgniteModelNormalizer', 'IgniteUnsavedChangesGuard', 
'IgniteEventGroups', 'DemoInfo', 'IgniteLegacyTable', 
'IgniteConfigurationResource', 'IgniteErrorPopover', 'IgniteFormUtils', 
'IgniteVersion', 'Clusters',
+    function($root, $scope, $http, $state, $timeout, LegacyUtils, Messages, 
Confirm, Input, Loading, ModelNormalizer, UnsavedChangesGuard, 
igniteEventGroups, DemoInfo, LegacyTable, Resource, ErrorPopover, FormUtils, 
Version, Clusters) {
         let __original_value;
 
         this.available = Version.available.bind(Version);
@@ -75,46 +75,7 @@ export default ['$rootScope', '$scope', '$http', '$state', 
'$timeout', 'IgniteLe
 
         const emptyCluster = {empty: true};
 
-        const blank = {
-            activeOnStart: true,
-            cacheSanityCheckEnabled: true,
-            atomicConfiguration: {},
-            binaryConfiguration: {},
-            cacheKeyConfiguration: [],
-            communication: {},
-            connector: {},
-            deploymentSpi: {
-                URI: {
-                    uriList: [],
-                    scanners: []
-                }
-            },
-            discovery: {
-                Cloud: {
-                    regions: [],
-                    zones: []
-                }
-            },
-            marshaller: {},
-            peerClassLoadingLocalClassPathExclude: [],
-            sslContextFactory: {
-                trustManagers: []
-            },
-            swapSpaceSpi: {},
-            transactionConfiguration: {},
-            collision: {},
-            memoryConfiguration: {
-                memoryPolicies: []
-            },
-            hadoopConfiguration: {
-                nativeLibraryNames: []
-            },
-            serviceConfigurations: [],
-            executorConfiguration: [],
-            sqlConnectorConfiguration: {
-                tcpNoDelay: true
-            }
-        };
+        const blank = Clusters.getBlankCluster();
 
         const pairFields = {
             attributes: {id: 'Attribute', idPrefix: 'Key', searchCol: 'name', 
valueCol: 'key', dupObjName: 'name', group: 'attributes'},

Reply via email to