summaryrefslogtreecommitdiffstats
path: root/openecomp-ui/test/softwareProduct/components
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2017-02-19 12:57:33 +0200
committerMichael Lando <ml636r@att.com>2017-02-19 13:47:13 +0200
commitefa037d34be7b1570efdc767c79fad8d4005f10e (patch)
treecf1036ba2728dea8a61492b678fa91954e629403 /openecomp-ui/test/softwareProduct/components
parentf5f13c4f6b6fe3b4d98e349dfd7db59339803436 (diff)
Add new code new version
Change-Id: Ic02a76313503b526f17c3df29eb387a29fe6a42a Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'openecomp-ui/test/softwareProduct/components')
-rw-r--r--openecomp-ui/test/softwareProduct/components/compute/test.js132
-rw-r--r--openecomp-ui/test/softwareProduct/components/general/SoftwareProductComponentsGeneral.test.js129
-rw-r--r--openecomp-ui/test/softwareProduct/components/loadBalancing/softwareProductComponentLoadbalancing.test.js122
-rw-r--r--openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js101
-rw-r--r--openecomp-ui/test/softwareProduct/components/monitoring/test.js215
-rw-r--r--openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNICEditor.test.js97
-rw-r--r--openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetwork.test.js125
-rw-r--r--openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js305
-rw-r--r--openecomp-ui/test/softwareProduct/components/processes/test.js214
-rw-r--r--openecomp-ui/test/softwareProduct/components/storage/test.js132
-rw-r--r--openecomp-ui/test/softwareProduct/components/test.js101
11 files changed, 1673 insertions, 0 deletions
diff --git a/openecomp-ui/test/softwareProduct/components/compute/test.js b/openecomp-ui/test/softwareProduct/components/compute/test.js
new file mode 100644
index 0000000000..925de302b8
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/components/compute/test.js
@@ -0,0 +1,132 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+import expect from 'expect';
+import deepFreeze from 'deep-freeze';
+import mockRest from 'test-utils/MockRest.js';
+import {cloneAndSet} from 'test-utils/Util.js';
+import {storeCreator} from 'sdc-app/AppStore.js';
+import Configuration from 'sdc-app/config/Configuration.js';
+import SoftwareProductComponentsActionHelper from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js';
+
+const softwareProductId = '123';
+const vspComponentId = '111';
+
+describe('Software Product Components Compute Module Tests', function () {
+
+ let restPrefix = '';
+
+ before(function() {
+ restPrefix = Configuration.get('restPrefix');
+ deepFreeze(restPrefix);
+ });
+
+ it('Get Software Products Components Compute', () => {
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const softwareProductComponentCompute = {
+ data: JSON.stringify({'vmSizing':{'numOfCPUs':'3','fileSystemSizeGB':'888'},'numOfVMs':{'minimum':'2'}}),
+ schema: JSON.stringify({'vmSizing':{'numOfCPUs':'3','fileSystemSizeGB':'888'},'numOfVMs':{'minimum':'2'}})
+ };
+ deepFreeze(softwareProductComponentCompute);
+
+ const softwareProductComponentComputeData = {
+ qdata: JSON.parse(softwareProductComponentCompute.data),
+ qschema: JSON.parse(softwareProductComponentCompute.schema)
+ };
+ deepFreeze(softwareProductComponentComputeData);
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor', softwareProductComponentComputeData);
+
+ mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+ expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/components/${vspComponentId}/questionnaire`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return softwareProductComponentCompute;
+ });
+
+ return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, vspComponentId}).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
+ it('Get Empty Software Products Components Compute', () => {
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const softwareProductComponentQuestionnaire = {
+ data: null,
+ schema: JSON.stringify({'vmSizing':{'numOfCPUs':'3','fileSystemSizeGB':'888'},'numOfVMs':{'minimum':'2'}})
+ };
+ deepFreeze(softwareProductComponentQuestionnaire);
+
+ const softwareProductComponentQuestionnaireData = {
+ qdata: {},
+ qschema: JSON.parse(softwareProductComponentQuestionnaire.schema)
+ };
+ deepFreeze(softwareProductComponentQuestionnaireData);
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor', softwareProductComponentQuestionnaireData);
+
+ mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+ expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/components/${vspComponentId}/questionnaire`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return softwareProductComponentQuestionnaire;
+ });
+
+ return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, vspComponentId}).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
+ it('Update Software Products Components Compute', () => {
+ const store = storeCreator({
+ softwareProduct: {
+ softwareProductComponents: {
+ componentEditor: {
+ qdata: {
+ numOfCPUs: 3,
+ fileSystemSizeGB: 999
+ },
+ qschema: {
+ type: 'object',
+ properties: {
+ numOfCPUs: {type: 'number'},
+ fileSystemSizeGB: {type: 'number'}
+ }
+ }
+ }
+ }
+ }
+ });
+ deepFreeze(store);
+
+ const data = {numOfCPUs: 5, fileSystemSizeGB: 300};
+ deepFreeze(data);
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor.qdata', data);
+
+ SoftwareProductComponentsActionHelper.componentQuestionnaireUpdated(store.dispatch, {data});
+
+ expect(store.getState()).toEqual(expectedStore);
+ });
+});
diff --git a/openecomp-ui/test/softwareProduct/components/general/SoftwareProductComponentsGeneral.test.js b/openecomp-ui/test/softwareProduct/components/general/SoftwareProductComponentsGeneral.test.js
new file mode 100644
index 0000000000..ce2152b29b
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/components/general/SoftwareProductComponentsGeneral.test.js
@@ -0,0 +1,129 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+import expect from 'expect';
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/components/general/SoftwareProductComponentsGeneral.js';
+import SoftwareProductComponentsGeneralView from 'sdc-app/onboarding/softwareProduct/components/general/SoftwareProductComponentsGeneralView.jsx';
+import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
+
+
+describe('SoftwareProductComponentsGeneral Mapper and View Classes', () => {
+ it('mapStateToProps mapper exists', () => {
+ expect(mapStateToProps).toExist();
+ });
+
+ it('mapStateToProps data test', () => {
+
+ const currentSoftwareProduct = {
+ name: 'VSp',
+ description: 'dfdf',
+ vendorName: 'V1',
+ vendorId: '97B3E2525E0640ACACF87CE6B3753E80',
+ category: 'resourceNewCategory.application l4+',
+ subCategory: 'resourceNewCategory.application l4+.database',
+ id: 'D4774719D085414E9D5642D1ACD59D20',
+ version: '0.10',
+ viewableVersions: ['0.1', '0.2'],
+ status: versionStatusEnum.CHECK_OUT_STATUS,
+ lockingUser: 'cs0008'
+ };
+
+ var obj = {
+ softwareProduct: {
+ softwareProductEditor: {
+ data: currentSoftwareProduct
+ },
+ softwareProductComponents: {
+ componentEditor: {
+ data: {},
+ qdata: {},
+ qschema: {}
+ }
+ }
+ }
+ };
+
+ var results = mapStateToProps(obj);
+ expect(results.componentData).toExist();
+ expect(results.qdata).toExist();
+ expect(results.qschema).toExist();
+ });
+
+
+ it('VSP Components general view test', () => {
+
+ const currentSoftwareProduct = {
+ name: 'VSp',
+ description: 'dfdf',
+ vendorName: 'V1',
+ vendorId: '97B3E2525E0640ACACF87CE6B3753E80',
+ category: 'resourceNewCategory.application l4+',
+ subCategory: 'resourceNewCategory.application l4+.database',
+ id: 'D4774719D085414E9D5642D1ACD59D20',
+ version: '0.10',
+ viewableVersions: ['0.1', '0.2'],
+ status: versionStatusEnum.CHECK_OUT_STATUS,
+ lockingUser: 'cs0008'
+ };
+
+ const softwareProductComponents = {
+ componentEditor: {
+ data: {},
+ qdata: {},
+ qschema: {
+ $schema: 'http://json-schema.org/draft-04/schema#',
+ type: 'object',
+ properties: {
+ general: {
+ type: 'object',
+ properties: {}
+ }
+ }
+ }
+ }
+ };
+
+ const versionControllerData = {
+ version: '1',
+ viewableVersions: [],
+ status: 'locked',
+ isCheckedOut: true
+ };
+
+ const componentData = {
+ name: '',
+ description: ''
+ };
+
+ var renderer = TestUtils.createRenderer();
+ renderer.render(
+ <SoftwareProductComponentsGeneralView
+ componentData={componentData}
+ softwareProductComponents={softwareProductComponents}
+ versionControllerData={versionControllerData}
+ currentSoftwareProduct={currentSoftwareProduct}/>);
+ var renderedOutput = renderer.getRenderOutput();
+ expect(renderedOutput).toExist();
+
+ });
+
+});
diff --git a/openecomp-ui/test/softwareProduct/components/loadBalancing/softwareProductComponentLoadbalancing.test.js b/openecomp-ui/test/softwareProduct/components/loadBalancing/softwareProductComponentLoadbalancing.test.js
new file mode 100644
index 0000000000..69a93b69e1
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/components/loadBalancing/softwareProductComponentLoadbalancing.test.js
@@ -0,0 +1,122 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+import expect from 'expect';
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/components/loadBalancing/SoftwareProductComponentLoadBalancing.js';
+import SoftwareProductComponentLoadBalancingView from 'sdc-app/onboarding/softwareProduct/components/loadBalancing/SoftwareProductComponentLoadBalancingRefView.jsx';
+import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
+
+
+describe('SoftwareProductComponentLoadBalancing Mapper and View Classes', () => {
+ it('mapStateToProps mapper exists', () => {
+ expect(mapStateToProps).toExist();
+ });
+
+ it('mapStateToProps data test', () => {
+
+ const currentSoftwareProduct = {
+ name: 'VSp',
+ description: 'dfdf',
+ vendorName: 'V1',
+ vendorId: '97B3E2525E0640ACACF87CE6B3753E80',
+ category: 'resourceNewCategory.application l4+',
+ subCategory: 'resourceNewCategory.application l4+.database',
+ id: 'D4774719D085414E9D5642D1ACD59D20',
+ version: '0.10',
+ viewableVersions: ['0.1', '0.2'],
+ status: versionStatusEnum.CHECK_OUT_STATUS,
+ lockingUser: 'cs0008'
+ };
+
+ var obj = {
+ softwareProduct: {
+ softwareProductEditor: {
+ data: currentSoftwareProduct
+ },
+ softwareProductComponents: {
+ componentEditor: {
+ qdata: {},
+ qschema: {}
+ }
+ }
+ }
+ };
+
+ var results = mapStateToProps(obj);
+ expect(results.qdata).toExist();
+ expect(results.qschema).toExist();
+ });
+
+
+ it('VSP Components LoadBalancing view test', () => {
+
+ const currentSoftwareProduct = {
+ name: 'VSp',
+ description: 'dfdf',
+ vendorName: 'V1',
+ vendorId: '97B3E2525E0640ACACF87CE6B3753E80',
+ category: 'resourceNewCategory.application l4+',
+ subCategory: 'resourceNewCategory.application l4+.database',
+ id: 'D4774719D085414E9D5642D1ACD59D20',
+ version: '0.10',
+ viewableVersions: ['0.1', '0.2'],
+ status: versionStatusEnum.CHECK_OUT_STATUS,
+ lockingUser: 'cs0008'
+ };
+
+ const softwareProductComponents = {
+ componentEditor: {
+ qdata: {},
+ qschema: {
+ $schema: 'http://json-schema.org/draft-04/schema#',
+ type: 'object',
+ properties: {
+ general: {
+ type: 'object',
+ properties: {}
+ }
+ }
+ }
+ }
+ };
+
+ const versionControllerData = {
+ version: '1',
+ viewableVersions: [],
+ status: 'locked',
+ isCheckedOut: true
+ };
+
+ var renderer = TestUtils.createRenderer();
+ renderer.render(
+ <SoftwareProductComponentLoadBalancingView
+ softwareProductComponents={softwareProductComponents}
+ versionControllerData={versionControllerData}
+ currentSoftwareProduct={currentSoftwareProduct}
+ softwareProductId='123'
+ componentId='321'/>);
+ var renderedOutput = renderer.getRenderOutput();
+ expect(renderedOutput).toExist();
+
+ });
+
+});
diff --git a/openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js b/openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js
new file mode 100644
index 0000000000..2f1ea12c01
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js
@@ -0,0 +1,101 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+import expect from 'expect';
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.js';
+import SoftwareProductComponentsMonitoringView from 'sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringView.jsx';
+
+describe('SoftwareProductComponentsMonitoring Module Tests', function () {
+
+ it('should mapper exist', () => {
+ expect(mapStateToProps).toExist();
+ });
+
+ it('should return empty file names', () => {
+ let softwareProduct = {softwareProductEditor: {data: {}}, softwareProductComponents: {monitoring: {}}};
+ var results = mapStateToProps({softwareProduct});
+ expect(results.trapFilename).toEqual(undefined);
+ expect(results.pollFilename).toEqual(undefined);
+ });
+
+ it('should return trap file name', () => {
+ const monitoring = {
+ trapFilename: '123'
+ };
+ let softwareProduct = {softwareProductEditor: {data: {}}, softwareProductComponents: {monitoring}};
+ var results = mapStateToProps({softwareProduct});
+ expect(results.trapFilename).toEqual(monitoring.trapFilename);
+ expect(results.pollFilename).toEqual(undefined);
+ });
+
+ it('should return poll file names', () => {
+ const monitoring = {
+ pollFilename: '123'
+ };
+ let softwareProduct = {softwareProductEditor: {data: {}}, softwareProductComponents: {monitoring}};
+ var results = mapStateToProps({softwareProduct});
+ expect(results.trapFilename).toEqual(undefined);
+ expect(results.pollFilename).toEqual(monitoring.pollFilename);
+
+ let renderer = TestUtils.createRenderer();
+ renderer.render(<SoftwareProductComponentsMonitoringView {...results} />);
+ let renderedOutput = renderer.getRenderOutput();
+ expect(renderedOutput).toExist();
+ });
+
+ it('should return both file names', () => {
+ const monitoring = {
+ trapFilename: '1234',
+ trapFilename: '123'
+ };
+ let softwareProduct = {softwareProductEditor: {data: {}}, softwareProductComponents: {monitoring}};
+ var results = mapStateToProps({softwareProduct});
+ expect(results.trapFilename).toEqual(monitoring.trapFilename);
+ expect(results.pollFilename).toEqual(monitoring.pollFilename);
+
+ let renderer = TestUtils.createRenderer();
+ renderer.render(<SoftwareProductComponentsMonitoringView {...results} />);
+ let renderedOutput = renderer.getRenderOutput();
+ expect(renderedOutput).toExist();
+ });
+
+ it('should change state to dragging', done => {
+ var view = TestUtils.renderIntoDocument(<SoftwareProductComponentsMonitoringView />);
+ expect(view.state.dragging).toBe(false);
+ view.handleOnDragEnter(false);
+ setTimeout(()=> {
+ expect(view.state.dragging).toBe(true);
+ done();
+ }, 100);
+ });
+
+ it('should not change state to dragging', done => {
+ var view = TestUtils.renderIntoDocument(<SoftwareProductComponentsMonitoringView />);
+ expect(view.state.dragging).toBe(false);
+ view.handleOnDragEnter(true);
+ setTimeout(()=> {
+ expect(view.state.dragging).toBe(false);
+ done();
+ }, 0);
+ });
+
+});
diff --git a/openecomp-ui/test/softwareProduct/components/monitoring/test.js b/openecomp-ui/test/softwareProduct/components/monitoring/test.js
new file mode 100644
index 0000000000..172db653e9
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/components/monitoring/test.js
@@ -0,0 +1,215 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+import expect from 'expect';
+import mockRest from 'test-utils/MockRest.js';
+import {storeCreator} from 'sdc-app/AppStore.js';
+import SoftwareProductComponentsMonitoringConstants from 'sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringConstants.js';
+import SoftwareProductComponentsMonitoringActionHelper from 'sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringActionHelper.js';
+
+const softwareProductId = '123';
+const componentId = '123';
+
+describe('Software Product Components Monitoring Module Tests', function () {
+
+ let store;
+
+ beforeEach(()=> {
+ store = storeCreator();
+ });
+
+
+ it('Fetch for existing files - no files', done => {
+
+ let emptyResult = Object.freeze({
+ snmpTrap: undefined,
+ snmpPoll: undefined
+ });
+
+ mockRest.addHandler('fetch', ({ baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp`);
+ return emptyResult;
+ });
+
+ SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, {
+ softwareProductId,
+ componentId
+ });
+ setTimeout(()=> {
+ var {softwareProduct: {softwareProductComponents: {monitoring}}} = store.getState();
+ expect(monitoring.pollFilename).toEqual(emptyResult.snmpPoll);
+ expect(monitoring.trapFilename).toEqual(emptyResult.snmpTrap);
+ done();
+ }, 0);
+
+ });
+
+ it('Fetch for existing files - only snmp trap file exists', done => {
+ let response = Object.freeze({
+ snmpTrap: 'asdfasdf',
+ snmpPoll: undefined
+ });
+
+ mockRest.addHandler('fetch', ({ baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp`);
+ return response;
+ });
+
+ SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, {
+ softwareProductId,
+ componentId
+ });
+ setTimeout(()=> {
+ var {softwareProduct: {softwareProductComponents: {monitoring}}} = store.getState();
+ expect(monitoring.pollFilename).toEqual(response.snmpPoll);
+ expect(monitoring.trapFilename).toEqual(response.snmpTrap);
+ done();
+ }, 0);
+ });
+
+ it('Fetch for existing files - only snmp poll file exists', done => {
+ let response = Object.freeze({
+ snmpPoll: 'asdfasdf',
+ snmpTrap: undefined
+ });
+
+ mockRest.addHandler('fetch', ({baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp`);
+ return response;
+ });
+
+ SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, {
+ softwareProductId,
+ componentId
+ });
+ setTimeout(()=> {
+ var {softwareProduct: {softwareProductComponents: {monitoring}}} = store.getState();
+ expect(monitoring.pollFilename).toEqual(response.snmpPoll);
+ expect(monitoring.trapFilename).toEqual(response.snmpTrap);
+ done();
+ }, 0);
+ });
+
+ it('Fetch for existing files - both files exist', done => {
+ let response = Object.freeze({
+ snmpPoll: 'asdfasdf',
+ snmpTrap: 'asdfgg'
+ });
+
+ mockRest.addHandler('fetch', ({baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp`);
+ return response;
+ });
+
+ SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, {
+ softwareProductId,
+ componentId
+ });
+ setTimeout(()=> {
+ var {softwareProduct: {softwareProductComponents: {monitoring}}} = store.getState();
+ expect(monitoring.pollFilename).toEqual(response.snmpPoll);
+ expect(monitoring.trapFilename).toEqual(response.snmpTrap);
+ done();
+ }, 0);
+ });
+
+ it('Upload snmp trap file', done => {
+
+ mockRest.addHandler('create', ({baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp-trap/upload`);
+ return {};
+ });
+ var debug = {hello: 'world'};
+ let file = new Blob([JSON.stringify(debug, null, 2)], {type: 'application/json'});;
+ let formData = new FormData();
+ formData.append('upload', file);
+ SoftwareProductComponentsMonitoringActionHelper.uploadSnmpFile(store.dispatch, {
+ softwareProductId,
+ componentId,
+ formData,
+ fileSize: file.size,
+ type: SoftwareProductComponentsMonitoringConstants.SNMP_TRAP
+ });
+ setTimeout(()=> {
+ var {softwareProduct: {softwareProductComponents: {monitoring}}} = store.getState();
+ expect(monitoring.pollFilename).toEqual(undefined);
+ expect(monitoring.trapFilename).toEqual('blob');
+ done();
+ }, 0);
+ });
+
+ it('Upload snmp poll file', done => {
+ mockRest.addHandler('create', ({baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp/upload`);
+ return {};
+ });
+ var debug = {hello: 'world'};
+ let file = new Blob([JSON.stringify(debug, null, 2)], {type: 'application/json'});;
+ let formData = new FormData();
+ formData.append('upload', file);
+ SoftwareProductComponentsMonitoringActionHelper.uploadSnmpFile(store.dispatch, {
+ softwareProductId,
+ componentId,
+ formData,
+ fileSize: file.size,
+ type: SoftwareProductComponentsMonitoringConstants.SNMP_POLL
+ });
+ setTimeout(()=> {
+ var {softwareProduct: {softwareProductComponents: {monitoring}}} = store.getState();
+ expect(monitoring.pollFilename).toEqual('blob');
+ expect(monitoring.trapFilename).toEqual(undefined);
+ done();
+ }, 0);
+ });
+
+ it('Delete snmp trap file', done => {
+ mockRest.addHandler('destroy', ({baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp-trap`);
+ return {};
+ });
+ SoftwareProductComponentsMonitoringActionHelper.deleteSnmpFile(store.dispatch, {
+ softwareProductId,
+ componentId,
+ type: SoftwareProductComponentsMonitoringConstants.SNMP_TRAP
+ });
+ setTimeout(()=> {
+ var {softwareProduct: {softwareProductComponents: {monitoring}}} = store.getState();
+ expect(monitoring.trapFilename).toEqual(undefined);
+ done();
+ }, 0);
+ });
+
+ it('Delete snmp poll file', done => {
+ mockRest.addHandler('destroy', ({baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp`);
+ return {};
+ });
+ SoftwareProductComponentsMonitoringActionHelper.deleteSnmpFile(store.dispatch, {
+ softwareProductId,
+ componentId,
+ type: SoftwareProductComponentsMonitoringConstants.SNMP_POLL
+ });
+ setTimeout(()=> {
+ var {softwareProduct: {softwareProductComponents: {monitoring}}} = store.getState();
+ expect(monitoring.pollFilename).toEqual(undefined);
+ done();
+ }, 0);
+ });
+});
diff --git a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNICEditor.test.js b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNICEditor.test.js
new file mode 100644
index 0000000000..c9760f7799
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNICEditor.test.js
@@ -0,0 +1,97 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+import expect from 'expect';
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNICEditor.js';
+import SoftwareProductComponentsNICEditorView from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNICEditorView.jsx';
+
+
+
+describe('Software Product Component Network NIC Editor and View Classes', () => {
+ it('mapStateToProps mapper exists', () => {
+ expect(mapStateToProps).toExist();
+ });
+
+
+ it('mapStateToProps data test', () => {
+
+ const currentSoftwareProduct = {
+ name: 'VSp',
+ description: 'dfdf',
+ vendorName: 'V1',
+ vendorId: '97B3E2525E0640ACACF87CE6B3753E80',
+ category: 'resourceNewCategory.application l4+',
+ subCategory: 'resourceNewCategory.application l4+.database',
+ id: 'D4774719D085414E9D5642D1ACD59D20',
+ version: '0.10',
+ viewableVersions: ['0.1', '0.2'],
+ lockingUser: 'cs0008'
+ };
+
+
+ var obj = {
+ softwareProduct: {
+ softwareProductEditor: {
+ data: currentSoftwareProduct
+ },
+ softwareProductComponents: {
+ network: {
+ nicEditor: {
+ data: {},
+ qdata: {},
+ qschema: {}
+ }
+ }
+ }
+ }
+ };
+
+ var results = mapStateToProps(obj);
+ expect(results.currentSoftwareProduct).toExist();
+ expect(results.qdata).toExist();
+ expect(results.qschema).toExist();
+ expect(results.data).toExist();
+ });
+
+
+ it('Software Product Component Network NIC Editor View Test', () => {
+
+ const data = {
+ name: '',
+ description: '',
+ networkName: ''
+ };
+
+ const qdata = {};
+ const qschema = {};
+
+ var renderer = TestUtils.createRenderer();
+ renderer.render(
+ <SoftwareProductComponentsNICEditorView
+ data={data}
+ qdata={qdata}
+ qschema={qschema}/>);
+ var renderedOutput = renderer.getRenderOutput();
+ expect(renderedOutput).toExist();
+
+ });
+});
diff --git a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetwork.test.js b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetwork.test.js
new file mode 100644
index 0000000000..520fde7403
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetwork.test.js
@@ -0,0 +1,125 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+import expect from 'expect';
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkList.js';
+import SoftwareProductComponentsNetworkListView from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkListView.jsx';
+import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
+
+
+describe('Software Product Component Network Mapper and View Classes', () => {
+
+ it('mapStateToProps mapper exists', () => {
+ expect(mapStateToProps).toExist();
+ });
+
+ it('mapStateToProps data test', () => {
+
+ const currentSoftwareProduct = {
+ name: 'VSp',
+ description: 'dfdf',
+ vendorName: 'V1',
+ vendorId: '97B3E2525E0640ACACF87CE6B3753E80',
+ category: 'resourceNewCategory.application l4+',
+ subCategory: 'resourceNewCategory.application l4+.database',
+ id: 'D4774719D085414E9D5642D1ACD59D20',
+ version: '0.10',
+ viewableVersions: ['0.1', '0.2'],
+ status: versionStatusEnum.CHECK_OUT_STATUS,
+ lockingUser: 'cs0008'
+ };
+
+
+ var obj = {
+ softwareProduct: {
+ softwareProductEditor: {
+ data: currentSoftwareProduct
+ },
+ softwareProductComponents: {
+ componentEditor: {
+ qdata: {},
+ qschema: {},
+ data: {}
+ },
+ network: {
+ nicEditor: {},
+ nicList: []
+ }
+ }
+ }
+ };
+
+ var results = mapStateToProps(obj);
+ expect(results.qdata).toExist();
+ expect(results.qschema).toExist();
+ expect(results.componentData).toExist();
+ });
+
+ it('Software Product Component Network List View Test', () => {
+
+ const currentSoftwareProduct = {
+ name: 'VSp',
+ description: 'dfdf',
+ vendorName: 'V1',
+ vendorId: '97B3E2525E0640ACACF87CE6B3753E80',
+ category: 'resourceNewCategory.application l4+',
+ subCategory: 'resourceNewCategory.application l4+.database',
+ id: 'D4774719D085414E9D5642D1ACD59D20',
+ version: '0.10',
+ viewableVersions: ['0.1', '0.2'],
+ status: versionStatusEnum.CHECK_IN_STATUS,
+ lockingUser: 'cs0008'
+ };
+
+ const versionControllerData = {
+ version: '1',
+ viewableVersions: [],
+ status: 'locked',
+ isCheckedOut: true
+ };
+
+ const nicList = [
+ {
+ name: 'name',
+ networkId: 'network',
+ id: '122',
+ networkName: 'nname'
+ }
+ ];
+
+ var renderer = TestUtils.createRenderer();
+ renderer.render(
+ <SoftwareProductComponentsNetworkListView
+ versionControllerData={versionControllerData}
+ currentSoftwareProduct={currentSoftwareProduct}
+ softwareProductId='123'
+ componentId='321'
+ nicList={nicList}/>);
+ var renderedOutput = renderer.getRenderOutput();
+ expect(renderedOutput).toExist();
+
+
+
+
+ });
+
+});
diff --git a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js
new file mode 100644
index 0000000000..8c23267c89
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js
@@ -0,0 +1,305 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+import {expect} from 'chai';
+import deepFreeze from 'deep-freeze';
+import mockRest from 'test-utils/MockRest.js';
+import {cloneAndSet} from 'test-utils/Util.js';
+import {storeCreator} from 'sdc-app/AppStore.js';
+import SoftwareProductComponentsNetworkActionHelper from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.js';
+
+const softwareProductId = '123';
+const componentId = '321';
+const nicId = '111';
+
+describe('Software Product Components Network Action Helper Tests', function () {
+
+ it('Fetch NICs List', () => {
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const NICList = [
+ {
+ name:'oam01_port_0',
+ description:'bbbbbbb',
+ networkId:'A0E578751B284D518ED764D5378EA97C',
+ id:'96D3648338F94DAA9889E9FBB8E59895',
+ networkName:'csb_net'
+ },
+ {
+ name:'oam01_port_1',
+ description:'bbbbbbb',
+ networkId:'378EA97CA0E578751B284D518ED764D5',
+ id:'8E5989596D3648338F94DAA9889E9FBB',
+ networkName:'csb_net_2'
+ }
+
+ ];
+
+ deepFreeze(NICList);
+
+ deepFreeze(store.getState());
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network.nicList', NICList);
+
+ mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/nics`);
+ expect(data).to.deep.equal(undefined);
+ expect(options).to.equal(undefined);
+ return {results: NICList};
+ });
+
+ return SoftwareProductComponentsNetworkActionHelper.fetchNICsList(store.dispatch, {softwareProductId, componentId}).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+
+ });
+
+ it('open NICE editor', () => {
+
+ const store = storeCreator();
+ deepFreeze(store.getState());
+ const data = {
+ name: 'oam01_port_0',
+ description: 'bbbbbbb',
+ networkId: 'A0E578751B284D518ED764D5378EA97C',
+ networkName: 'csb_net'
+ };
+
+ const nic = {id: '444'};
+ deepFreeze(data);
+ deepFreeze(nic);
+
+ const expectedData = {...data, id: nic.id};
+
+ deepFreeze(expectedData);
+
+ const network = {
+ nicEditor: {
+ data: expectedData
+ },
+ nicList: []
+ };
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', network);
+
+ SoftwareProductComponentsNetworkActionHelper.openNICEditor(store.dispatch, {nic, data});
+
+ return setTimeout(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ }, 100);
+ });
+
+ it('close NICE editor', () => {
+
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const network = {
+ nicEditor: {},
+ nicList: []
+ };
+ deepFreeze(network);
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', network);
+
+ SoftwareProductComponentsNetworkActionHelper.closeNICEditor(store.dispatch);
+
+ return setTimeout(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ }, 100);
+ });
+
+ it('Load NIC data', () => {
+
+ const expectedData = {
+ description: 'bbbbbbb',
+ name: 'oam01_port_0',
+ networkId: 'A0E578751B284D518ED764D5378EA97C',
+ networkName: 'csb_net'
+ };
+
+ deepFreeze(expectedData);
+
+ mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/nics/${nicId}`);
+ expect(data).to.deep.equal(undefined);
+ expect(options).to.equal(undefined);
+ return (expectedData);
+ });
+
+ return SoftwareProductComponentsNetworkActionHelper.loadNICData({softwareProductId, componentId, nicId}).then((data) => {
+ expect(data).to.deep.equal(expectedData);
+ });
+ });
+
+
+ it('load NIC Questionnaire', () => {
+
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const qdata = {
+ protocols: {
+ protocolWithHighestTrafficProfile: 'UDP',
+ protocols: ['UDP']
+ },
+ ipConfiguration: {
+ ipv4Required: true
+ }
+ };
+
+ const qschema = {
+ $schema: 'http://json-schema.org/draft-04/schema#',
+ type: 'object',
+ properties: {
+ 'protocols': {
+ type: 'object',
+ properties: {}
+ }
+ }
+ };
+
+ deepFreeze(qdata);
+ deepFreeze(qschema);
+
+
+ const network = {
+ nicEditor: {
+ qdata,
+ qschema
+ },
+ nicList: []
+ };
+ deepFreeze(network);
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', network);
+
+ mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/nics/${nicId}/questionnaire`);
+ expect(data).to.deep.equal(undefined);
+ expect(options).to.equal(undefined);
+ return ({data: JSON.stringify(qdata), schema: JSON.stringify(qschema)});
+ });
+
+ return SoftwareProductComponentsNetworkActionHelper.loadNICQuestionnaire(store.dispatch, {softwareProductId, componentId, nicId}).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+
+ it('update NIC Data', () => {
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const data = {test: '123'};
+ deepFreeze(data);
+
+ const network = {
+ nicEditor: {
+ data
+ },
+ nicList: []
+ };
+
+ deepFreeze(network);
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', network);
+
+ SoftwareProductComponentsNetworkActionHelper.updateNICData(store.dispatch, {deltaData:data});
+
+ return setTimeout(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ }, 100);
+
+ });
+
+ it('update NIC Questionnaire', () => {
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const qdata = {
+ test: '123'
+ };
+ const network = {
+ nicEditor: {
+ qdata,
+ qschema: undefined
+ },
+ nicList: []
+ };
+ deepFreeze(network);
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', network);
+
+ SoftwareProductComponentsNetworkActionHelper.updateNICQuestionnaire(store.dispatch, {data:qdata});
+
+ return setTimeout(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ }, 100);
+
+ });
+
+ it('save NIC Data And Questionnaire', () => {
+
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const qdata = {
+ qtest: '111'
+ };
+ const data = {
+ name: '2222',
+ description: 'blabla',
+ networkId: '123445'
+ };
+
+ const expectedData = {...data, id: nicId};
+
+ const network = {
+ nicEditor: {},
+ nicList: [
+ expectedData
+ ]
+ };
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', network);
+ deepFreeze(expectedStore);
+
+ mockRest.addHandler('save', ({options, data, baseUrl}) => {
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/nics/${nicId}/questionnaire`);
+ expect(data).to.deep.equal(qdata);
+ expect(options).to.equal(undefined);
+ return {returnCode: 'OK'};
+ });
+
+ mockRest.addHandler('save', ({options, data, baseUrl}) => {
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/nics/${nicId}`);
+ expect(data).to.deep.equal(data);
+ expect(options).to.equal(undefined);
+ return {returnCode: 'OK'};
+ });
+
+ return SoftwareProductComponentsNetworkActionHelper.saveNICDataAndQuestionnaire(store.dispatch, {softwareProductId, componentId, qdata, data: expectedData}).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+
+
+});
diff --git a/openecomp-ui/test/softwareProduct/components/processes/test.js b/openecomp-ui/test/softwareProduct/components/processes/test.js
new file mode 100644
index 0000000000..67427d3c05
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/components/processes/test.js
@@ -0,0 +1,214 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+import {expect} from 'chai';
+import deepFreeze from 'deep-freeze';
+import mockRest from 'test-utils/MockRest.js';
+import {cloneAndSet} from 'test-utils/Util.js';
+import {storeCreator} from 'sdc-app/AppStore.js';
+import SoftwareProductComponentProcessesActionHelper from 'sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesActionHelper.js';
+
+const softwareProductId = '123';
+const componentId = '222';
+describe('Software Product Component Processes Module Tests', function () {
+ it('Get Software Products Processes List', () => {
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const softwareProductProcessesList = [
+ {
+ name: 'Pr1',
+ description: 'hjhj',
+ id: 'EBADF561B7FA4A788075E1840D0B5971',
+ artifactName: 'artifact'
+ },
+ {
+ name: 'Pr1',
+ description: 'hjhj',
+ id: '2F47447D22DB4C53B020CA1E66201EF2',
+ artifactName: 'artifact'
+ }
+ ];
+
+ deepFreeze(softwareProductProcessesList);
+
+ deepFreeze(store.getState());
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentProcesses.processesList', softwareProductProcessesList);
+
+ mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/processes`);
+ expect(data).to.deep.equal(undefined);
+ expect(options).to.equal(undefined);
+ return {results: softwareProductProcessesList};
+ });
+
+ return SoftwareProductComponentProcessesActionHelper.fetchProcessesList(store.dispatch, {softwareProductId, componentId}).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+ it('Delete Software Products Processes', () => {
+ const softwareProductProcessesList = [
+ {
+ name: 'Pr1',
+ description: 'hjhj',
+ id: 'EBADF561B7FA4A788075E1840D0B5971',
+ artifactName: 'artifact'
+ }
+ ];
+
+ deepFreeze(softwareProductProcessesList);
+ const store = storeCreator({
+ softwareProduct: {
+ softwareProductProcesses: {
+ processesList: softwareProductProcessesList
+ }
+ }
+ });
+
+ const processId = 'EBADF561B7FA4A788075E1840D0B5971';
+ deepFreeze(store.getState());
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentProcesses.processesList', []);
+
+ mockRest.addHandler('destroy', ({data, options, baseUrl}) => {
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/processes/${processId}`);
+ expect(data).to.equal(undefined);
+ expect(options).to.equal(undefined);
+ return {
+ results: {
+ returnCode: 'OK'
+ }
+ };
+ });
+
+ return SoftwareProductComponentProcessesActionHelper.deleteProcess(store.dispatch, {
+ process: softwareProductProcessesList[0],
+ softwareProductId, componentId
+ }).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+
+ it('Add Software Products Processes', () => {
+
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const softwareProductPostRequest = {
+ name: 'Pr1',
+ description: 'string'
+ };
+ const softwareProductProcessToAdd = {
+ name: 'Pr1',
+ description: 'string'
+ };
+ const softwareProductProcessFromResponse = 'ADDED_ID';
+ const softwareProductProcessAfterAdd = {
+ ...softwareProductProcessToAdd,
+ id: softwareProductProcessFromResponse
+ };
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentProcesses.processesList', [softwareProductProcessAfterAdd]);
+
+ mockRest.addHandler('create', ({data, options, baseUrl}) => {
+
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/processes`);
+ expect(data).to.deep.equal(softwareProductPostRequest);
+ expect(options).to.equal(undefined);
+ return {
+ returnCode: 'OK',
+ value: softwareProductProcessFromResponse
+ };
+ });
+
+ return SoftwareProductComponentProcessesActionHelper.saveProcess(store.dispatch,
+ {
+ softwareProductId,
+ previousProcess: null,
+ process: softwareProductProcessToAdd,
+ componentId
+ }
+ ).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+
+ it('Update Software Products Processes', () => {
+ const softwareProductProcessesList = [
+ {
+ name: 'Pr1',
+ description: 'string',
+ id: 'EBADF561B7FA4A788075E1840D0B5971',
+ artifactName: 'artifact'
+ }
+ ];
+ deepFreeze(softwareProductProcessesList);
+
+ const store = storeCreator({
+ softwareProduct: {
+ softwareProductComponents: {
+ componentProcesses: {
+ processesList: softwareProductProcessesList
+ }
+ }
+ }
+ });
+ deepFreeze(store.getState());
+
+ const toBeUpdatedProcessId = softwareProductProcessesList[0].id;
+ const previousProcessData = softwareProductProcessesList[0];
+ const processUpdateData = {
+ ...softwareProductProcessesList[0],
+ name: 'Pr1_UPDATED',
+ description: 'string_UPDATED'
+ };
+ deepFreeze(processUpdateData);
+
+ const processPutRequest = {
+ name: 'Pr1_UPDATED',
+ description: 'string_UPDATED'
+ };
+ deepFreeze(processPutRequest);
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentProcesses.processesList', [processUpdateData]);
+
+
+ mockRest.addHandler('save', ({data, options, baseUrl}) => {
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/processes/${toBeUpdatedProcessId}`);
+ expect(data).to.deep.equal(processPutRequest);
+ expect(options).to.equal(undefined);
+ return {returnCode: 'OK'};
+ });
+
+ return SoftwareProductComponentProcessesActionHelper.saveProcess(store.dispatch,
+ {
+ softwareProductId: softwareProductId,
+ componentId,
+ previousProcess: previousProcessData,
+ process: processUpdateData
+ }
+ ).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+
+});
+
diff --git a/openecomp-ui/test/softwareProduct/components/storage/test.js b/openecomp-ui/test/softwareProduct/components/storage/test.js
new file mode 100644
index 0000000000..87cad368be
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/components/storage/test.js
@@ -0,0 +1,132 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+import expect from 'expect';
+import deepFreeze from 'deep-freeze';
+import mockRest from 'test-utils/MockRest.js';
+import {cloneAndSet} from 'test-utils/Util.js';
+import {storeCreator} from 'sdc-app/AppStore.js';
+import Configuration from 'sdc-app/config/Configuration.js';
+import SoftwareProductComponentsActionHelper from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js';
+
+const softwareProductId = '123';
+const vspComponentId = '111';
+
+describe('Software Product Components Storage Module Tests', function () {
+
+ let restPrefix = '';
+
+ before(function() {
+ restPrefix = Configuration.get('restPrefix');
+ deepFreeze(restPrefix);
+ });
+
+ it('Get Software Products Components Storage', () => {
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const softwareProductComponentStorage = {
+ data: JSON.stringify({'backup':{'backupType':'OnSite','backupSolution':'76333'},'snapshotBackup':{'snapshotFrequency':'2'}}),
+ schema: JSON.stringify({'backup':{'backupType':'OnSite','backupSolution':'76333'},'snapshotBackup':{'snapshotFrequency':'2'}})
+ };
+ deepFreeze(softwareProductComponentStorage);
+
+ const softwareProductComponentStorageData = {
+ qdata: JSON.parse(softwareProductComponentStorage.data),
+ qschema: JSON.parse(softwareProductComponentStorage.schema)
+ };
+ deepFreeze(softwareProductComponentStorageData);
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor', softwareProductComponentStorageData);
+
+ mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+ expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/components/${vspComponentId}/questionnaire`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return softwareProductComponentStorage;
+ });
+
+ return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, vspComponentId}).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
+ it('Get Empty Software Products Components Storage', () => {
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const softwareProductComponentQuestionnaire = {
+ data: null,
+ schema: JSON.stringify({'backup':{'backupType':'OnSite','backupSolution':'76333'},'snapshotBackup':{'snapshotFrequency':'2'}})
+ };
+ deepFreeze(softwareProductComponentQuestionnaire);
+
+ const softwareProductComponentQuestionnaireData = {
+ qdata: {},
+ qschema: JSON.parse(softwareProductComponentQuestionnaire.schema)
+ };
+ deepFreeze(softwareProductComponentQuestionnaireData);
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor', softwareProductComponentQuestionnaireData);
+
+ mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+ expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/components/${vspComponentId}/questionnaire`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return softwareProductComponentQuestionnaire;
+ });
+
+ return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, vspComponentId}).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
+ it('Update Software Products Components Storage', () => {
+ const store = storeCreator({
+ softwareProduct: {
+ softwareProductComponents: {
+ componentEditor: {
+ qdata: {
+ backupType: 'OnSite',
+ backupStorageSize: 30
+ },
+ qschema: {
+ type: 'object',
+ properties: {
+ backupType: {type: 'string'},
+ backupStorageSize: {type: 'number'}
+ }
+ }
+ }
+ }
+ }
+ });
+ deepFreeze(store);
+
+ const data = {backupType: 'OffSite', backupStorageSize: 30};
+ deepFreeze(data);
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor.qdata', data);
+
+ SoftwareProductComponentsActionHelper.componentQuestionnaireUpdated(store.dispatch, {data});
+
+ expect(store.getState()).toEqual(expectedStore);
+ });
+});
diff --git a/openecomp-ui/test/softwareProduct/components/test.js b/openecomp-ui/test/softwareProduct/components/test.js
new file mode 100644
index 0000000000..839e1b7cf7
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/components/test.js
@@ -0,0 +1,101 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+import {expect} from 'chai';
+import deepFreeze from 'deep-freeze';
+import mockRest from 'test-utils/MockRest.js';
+import {cloneAndSet} from 'test-utils/Util.js';
+import {storeCreator} from 'sdc-app/AppStore.js';
+import SoftwareProductComponentsActionHelper from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js';
+
+const softwareProductId = '123';
+const vspComponentId = '321';
+
+describe('Software Product Components Module Tests', function () {
+ it('Get Software Products Components List', () => {
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const softwareProductComponentsList = [
+ {
+ name: 'com.d2.resource.vfc.nodes.heat.sm_server',
+ displayName: 'sm_server',
+ description: 'hjhj',
+ id: 'EBADF561B7FA4A788075E1840D0B5971'
+ },
+ {
+ name: 'com.d2.resource.vfc.nodes.heat.pd_server',
+ displayName: 'pd_server',
+ description: 'hjhj',
+ id: '2F47447D22DB4C53B020CA1E66201EF2'
+ }
+ ];
+
+ deepFreeze(softwareProductComponentsList);
+
+ deepFreeze(store.getState());
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentsList', softwareProductComponentsList);
+
+ mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components`);
+ expect(data).to.deep.equal(undefined);
+ expect(options).to.equal(undefined);
+ return {results: softwareProductComponentsList};
+ });
+
+ return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(store.dispatch, {softwareProductId}).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+
+ it('Update SoftwareProduct Component Questionnaire', () => {
+ const store = storeCreator();
+
+ const qdataUpdated = {
+ general: {
+ hypervisor: {
+ containerFeatureDescription: 'aaaUpdated',
+ drivers: 'bbbUpdated',
+ hypervisor: 'cccUpdated'
+ }
+ }
+ };
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor.qdata', qdataUpdated);
+ deepFreeze(expectedStore);
+
+
+ mockRest.addHandler('save', ({options, data, baseUrl}) => {
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${vspComponentId}/questionnaire`);
+ expect(data).to.deep.equal(qdataUpdated);
+ expect(options).to.equal(undefined);
+ return {returnCode: 'OK'};
+ });
+
+ return SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, vspComponentId, qdata: qdataUpdated}).then(() => {
+ //TODO think should we add here something or not
+ });
+
+
+ });
+
+});
+