summaryrefslogtreecommitdiffstats
path: root/openecomp-ui/test/softwareProduct
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
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')
-rw-r--r--openecomp-ui/test/softwareProduct/attachments/SoftwareProductAttachmentsView.test.js198
-rw-r--r--openecomp-ui/test/softwareProduct/attachments/SoftwareproductAttachmentsHelper.test.js153
-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
-rw-r--r--openecomp-ui/test/softwareProduct/details/detailsView.test.js438
-rw-r--r--openecomp-ui/test/softwareProduct/details/test.js383
-rw-r--r--openecomp-ui/test/softwareProduct/details/vspQschema.js61
-rw-r--r--openecomp-ui/test/softwareProduct/networks/SoftwareProductNetworksView.test.js122
-rw-r--r--openecomp-ui/test/softwareProduct/networks/softwareProductNetworksActionHelper.test.js63
-rw-r--r--openecomp-ui/test/softwareProduct/processes/test.js459
19 files changed, 3550 insertions, 0 deletions
diff --git a/openecomp-ui/test/softwareProduct/attachments/SoftwareProductAttachmentsView.test.js b/openecomp-ui/test/softwareProduct/attachments/SoftwareProductAttachmentsView.test.js
new file mode 100644
index 0000000000..839176c970
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/attachments/SoftwareProductAttachmentsView.test.js
@@ -0,0 +1,198 @@
+/*-
+ * ============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/attachments/SoftwareProductAttachments.js';
+
+import SoftwareProductAttachmentsView from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsView.jsx';
+import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
+
+
+describe('SoftwareProductAttachments Modal Mapper and View Classes', () => {
+
+ it ('mapStateToProps mapper exists', () => {
+ expect(mapStateToProps).toExist();
+ });
+
+
+ it ('mapStateToProps check data', () => {
+
+ 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 atTree = {
+ 'children': [
+ {
+ 'name': 'HEAT',
+ 'expanded': true,
+ 'type': 'heat',
+ 'children': [
+ {
+ 'name': 'heat_zxeyCtMHhf2.yaml',
+ 'expanded': true,
+ 'type': 'heat',
+ 'errors': [
+ {
+ 'level': 'WARNING',
+ 'message': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4'
+ }
+ ],
+ 'children': [
+ {
+ 'name': 'heat_env_zxeyCtMHhf2.env',
+ 'type': 'env'
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ };
+ const errorList = [
+ {
+ 'errorLevel': 'WARNING',
+ 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4',
+ 'name': 'heat_zxeyCtMHhf2.yaml',
+ 'hasParent': false,
+ 'parentName': 'HEAT',
+ 'type': 'heat'
+ },
+ {
+ 'errorLevel': 'WARNING',
+ 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_3',
+ 'name': 'heat_zxeyCtMHhf2.yaml',
+ 'hasParent': false,
+ 'parentName': 'HEAT',
+ 'type': 'heat'
+ }
+ ];
+
+ var obj = {
+ softwareProduct: {
+ softwareProductEditor: {
+ data:currentSoftwareProduct
+ }, softwareProductAttachments:
+ {
+ attachmentsTree: atTree,
+ errorList: errorList
+ }
+ }
+ };
+
+ var results = mapStateToProps(obj);
+ expect(results.attachmentsTree).toExist();
+ expect(results.errorList).toExist();
+ expect(results.hoveredNode).toBe(undefined);
+ expect(results.selectedNode).toBe(undefined);
+ });
+
+
+ it('function does exist', () => {
+
+ 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 versionControllerData = {
+ version: currentSoftwareProduct.version,
+ viewableVersions:currentSoftwareProduct.viewableVersions,
+ status: currentSoftwareProduct.status,
+ isCheckedOut: true
+ };
+ const atTree = {
+ 'children': [
+ {
+ 'name': 'HEAT',
+ 'expanded': true,
+ 'type': 'heat',
+ 'children': [
+ {
+ 'name': 'heat_zxeyCtMHhf2.yaml',
+ 'expanded': true,
+ 'type': 'heat',
+ 'errors': [
+ {
+ 'level': 'WARNING',
+ 'message': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4'
+ }
+ ],
+ 'children': [
+ {
+ 'name': 'heat_env_zxeyCtMHhf2.env',
+ 'type': 'env'
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ };
+ const errorList = [
+ {
+ 'errorLevel': 'WARNING',
+ 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4',
+ 'name': 'heat_zxeyCtMHhf2.yaml',
+ 'hasParent': false,
+ 'parentName': 'HEAT',
+ 'type': 'heat'
+ },
+ {
+ 'errorLevel': 'WARNING',
+ 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_3',
+ 'name': 'heat_zxeyCtMHhf2.yaml',
+ 'hasParent': false,
+ 'parentName': 'HEAT',
+ 'type': 'heat'
+ }
+ ];
+
+
+ var renderer = TestUtils.createRenderer();
+ renderer.render(<SoftwareProductAttachmentsView
+ versionControllerData={versionControllerData}
+ currentSoftwareProduct={currentSoftwareProduct}
+ attachmentsTree={atTree}
+ errorList={errorList}/>);
+ var renderedOutput = renderer.getRenderOutput();
+ expect(renderedOutput).toExist();
+ });
+
+});
diff --git a/openecomp-ui/test/softwareProduct/attachments/SoftwareproductAttachmentsHelper.test.js b/openecomp-ui/test/softwareProduct/attachments/SoftwareproductAttachmentsHelper.test.js
new file mode 100644
index 0000000000..851560caa8
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/attachments/SoftwareproductAttachmentsHelper.test.js
@@ -0,0 +1,153 @@
+/*-
+ * ============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 SoftwareProductAttachmentsActionHelper from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsActionHelper.js';
+import {storeCreator} from 'sdc-app/AppStore.js';
+import deepFreeze from 'deep-freeze';
+import {actionTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js';
+
+
+
+
+
+
+describe('SoftwareProductAttachments ActionHelper', () => {
+
+ it('function does exist', () => {
+ expect(SoftwareProductAttachmentsActionHelper).toExist();
+ });
+
+ it('toggleExpanded function check', () => {
+
+
+ const validationData = {
+ importStructure: {
+ HEAT: [
+ {
+ fileName: 'hot-mog-0108-bs1271.yml',
+ env: {
+ fileName: 'hot-mog-0108-bs1271.env'
+ },
+ errors: [
+ {
+ 'level': 'WARNING',
+ 'message': 'Port not bind to any NOVA Server, Resource Id [sm02_port_2]'
+ },
+ {
+ 'level': 'WARNING',
+ 'message': 'Port not bind to any NOVA Server, Resource Id [sm01_port_2]'
+ }
+ ]
+ }
+ ]
+ }
+ };
+
+ 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: 'Locked',
+ lockingUser: 'cs0008',
+ validationData
+ };
+
+
+ const store = storeCreator();
+ deepFreeze(store.getState());
+ deepFreeze(currentSoftwareProduct);
+
+ store.dispatch({
+ type:actionTypes.SOFTWARE_PRODUCT_LOADED,
+ response: currentSoftwareProduct
+ });
+
+ expect(store.getState().softwareProduct.softwareProductAttachments.attachmentsTree.children[0].expanded).toBe(true);
+ SoftwareProductAttachmentsActionHelper.toggleExpanded(store.dispatch, {path:[0]});
+ expect(store.getState().softwareProduct.softwareProductAttachments.attachmentsTree.children[0].expanded).toBe(false);
+ });
+
+ it('onSelectNode & onUnselectNode function check', () => {
+
+
+ const validationData = {
+ importStructure: {
+ HEAT: [
+ {
+ fileName: 'hot-mog-0108-bs1271.yml',
+ env: {
+ fileName: 'hot-mog-0108-bs1271.env'
+ },
+ errors: [
+ {
+ 'level': 'WARNING',
+ 'message': 'Port not bind to any NOVA Server, Resource Id [sm02_port_2]'
+ },
+ {
+ 'level': 'WARNING',
+ 'message': 'Port not bind to any NOVA Server, Resource Id [sm01_port_2]'
+ }
+ ]
+ }
+ ]
+ }
+ };
+
+ 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: 'Locked',
+ lockingUser: 'cs0008',
+ validationData
+ };
+
+ deepFreeze(currentSoftwareProduct);
+
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ store.dispatch({
+ type:actionTypes.SOFTWARE_PRODUCT_LOADED,
+ response: currentSoftwareProduct
+ });
+ let expectedNodeName = 'name';
+ expect(store.getState().softwareProduct.softwareProductAttachments.selectedNode).toBe(undefined);
+ SoftwareProductAttachmentsActionHelper.onSelectNode(store.dispatch, {nodeName:expectedNodeName});
+ expect(store.getState().softwareProduct.softwareProductAttachments.selectedNode).toBe(expectedNodeName);
+ SoftwareProductAttachmentsActionHelper.onUnselectNode(store.dispatch);
+ expect(store.getState().softwareProduct.softwareProductAttachments.selectedNode).toBe(undefined);
+ });
+
+
+});
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
+ });
+
+
+ });
+
+});
+
diff --git a/openecomp-ui/test/softwareProduct/details/detailsView.test.js b/openecomp-ui/test/softwareProduct/details/detailsView.test.js
new file mode 100644
index 0000000000..b6a8ca5d4e
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/details/detailsView.test.js
@@ -0,0 +1,438 @@
+/*-
+ * ============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/details/SoftwareProductDetails.js';
+import SoftwareProductDetailsView from 'sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsView.jsx';
+import {vspQschema as vspQuestionnaireSchema} from './vspQschema.js';
+
+describe('Software Product Details: ', function () {
+
+ let currentSoftwareProduct = {}, categories = [], finalizedLicenseModelList, licenseAgreementList, featureGroupsList, vspQschema;
+ let dummyFunc = () => {};
+
+ before(function() {
+ currentSoftwareProduct = {
+ id: 'D4774719D085414E9D5642D1ACD59D20',
+ name: 'VSP',
+ description: 'dfdf',
+ category: 'category1',
+ subCategory: 'category1.subCategory',
+ vendorId: 'VLM_ID1',
+ vendorName: 'VLM1',
+ licensingVersion: '1.0',
+ licensingData: {}
+ };
+ categories = [{
+ uniqueId: 'category1',
+ subcategories: [{
+ uniqueId: 'subCategory'
+ }]
+ }, {
+ uniqueId: 'category2',
+ subcategories: [{
+ uniqueId: 'subCategory2'
+ }]
+ }];
+ finalizedLicenseModelList = [{
+ id: 'VLM_ID1',
+ name: 'VLM1'
+ }];
+ licenseAgreementList = [{id: 'LA_ID1'}, {id: 'LA_ID2'}];
+ featureGroupsList = [
+ {id: 'FG_ID1', name: 'FG1', referencingLicenseAgreements: ['LA_ID1']},
+ {id: 'FG_ID2', name: 'FG2', referencingLicenseAgreements: ['LA_ID1']}
+ ];
+ vspQschema = vspQuestionnaireSchema;
+ });
+
+ it('should mapper exist', () => {
+ expect(mapStateToProps).toExist();
+ });
+
+ it('should mapper return vsp basic data', () => {
+ var obj = {
+ softwareProduct: {
+ softwareProductEditor: {
+ data: currentSoftwareProduct
+ },
+ softwareProductCategories: categories,
+ softwareProductQuestionnaire: {
+ qdata: {},
+ qschema: vspQschema
+ }
+ },
+ finalizedLicenseModelList: finalizedLicenseModelList,
+ licenseModel: {
+ licenseAgreement: {
+ licenseAgreementList: []
+ },
+ featureGroup: {
+ featureGroupsList: []
+ }
+ }
+ };
+
+ var result = mapStateToProps(obj);
+ expect(result.currentSoftwareProduct).toEqual(currentSoftwareProduct);
+ expect(result.finalizedLicenseModelList).toEqual(finalizedLicenseModelList);
+ expect(result.finalizedLicenseModelList.length).toBeGreaterThan(0);
+ expect(finalizedLicenseModelList).toInclude({
+ id: result.currentSoftwareProduct.vendorId,
+ name: result.currentSoftwareProduct.vendorName
+ });
+ expect(result.softwareProductCategories).toEqual(categories);
+ expect(result.licenseAgreementList).toEqual([]);
+ expect(result.featureGroupsList).toEqual([]);
+ expect(result.qdata).toEqual({});
+ expect(result.qschema).toEqual(vspQschema);
+ expect(result.isReadOnlyMode).toEqual(true);
+ });
+
+ it('should mapper return vsp data with selected licenseAgreement and featureGroup', () => {
+ let vspWithLicensingData = {
+ ...currentSoftwareProduct,
+ licensingData: {
+ licenseAgreement: 'LA_ID1',
+ featureGroups: [{enum: 'FG_ID1', title: 'FG1'}]
+ }
+ };
+ var obj = {
+ softwareProduct: {
+ softwareProductEditor: {
+ data: vspWithLicensingData
+ },
+ softwareProductCategories: categories,
+ softwareProductQuestionnaire: {
+ qdata: {},
+ qschema: vspQschema
+ }
+ },
+ finalizedLicenseModelList: finalizedLicenseModelList,
+ licenseModel: {
+ licenseAgreement: {
+ licenseAgreementList: licenseAgreementList
+ },
+ featureGroup: {
+ featureGroupsList: featureGroupsList
+ }
+ }
+ };
+
+ var result = mapStateToProps(obj);
+ expect(result.currentSoftwareProduct).toEqual(vspWithLicensingData);
+ expect(result.finalizedLicenseModelList).toEqual(finalizedLicenseModelList);
+ expect(result.finalizedLicenseModelList.length).toBeGreaterThan(0);
+ expect(result.finalizedLicenseModelList).toInclude({
+ id: result.currentSoftwareProduct.vendorId,
+ name: result.currentSoftwareProduct.vendorName
+ });
+ expect(result.softwareProductCategories).toEqual(categories);
+ expect(result.licenseAgreementList).toEqual(licenseAgreementList);
+ expect(result.licenseAgreementList).toInclude({id: result.currentSoftwareProduct.licensingData.licenseAgreement});
+ result.currentSoftwareProduct.licensingData.featureGroups.forEach(fg => {
+ expect(featureGroupsList).toInclude({
+ id: fg.enum,
+ name: fg.title,
+ referencingLicenseAgreements: [result.currentSoftwareProduct.licensingData.licenseAgreement]
+ });
+ expect(result.featureGroupsList).toInclude(fg);
+ });
+ expect(result.qdata).toEqual({});
+ expect(result.qschema).toEqual(vspQschema);
+ expect(result.isReadOnlyMode).toEqual(true);
+ });
+
+ it('VSP Details view test', () => {
+ let params = {
+ currentSoftwareProduct: currentSoftwareProduct,
+ softwareProductCategories: categories,
+ qdata: {},
+ qschema: vspQschema,
+ finalizedLicenseModelList: [{
+ id: 'VLM_ID1',
+ vendorName: 'VLM1',
+ version: '2.0',
+ viewableVersions: ['1.0', '2.0']
+ }, {
+ id: 'VLM_ID2',
+ vendorName: 'VLM2',
+ version: '3.0',
+ viewableVersions: ['1.0', '2.0', '3.0']
+ }],
+ licenseAgreementList: [{id: 'LA_ID1'}, {id: 'LA_ID2'}],
+ featureGroupsList: [
+ {id: 'FG_ID1', name: 'FG1', referencingLicenseAgreements: ['LA_ID1']},
+ {id: 'FG_ID2', name: 'FG2', referencingLicenseAgreements: ['LA_ID1']}
+ ]
+ };
+ var renderer = TestUtils.createRenderer();
+ renderer.render(
+ <SoftwareProductDetailsView
+ {...params}
+ onSubmit = {dummyFunc}
+ onDataChanged = {dummyFunc}
+ onValidityChanged = {dummyFunc}
+ onQDataChanged = {dummyFunc}
+ onVendorParamChanged = {dummyFunc}/>
+ );
+ let renderedOutput = renderer.getRenderOutput();
+ expect(renderedOutput).toExist();
+ });
+
+ it('in view: should change vendorId and update vsp licensing-version', done => {
+ let vspWithLicensingData = {
+ ...currentSoftwareProduct,
+ licensingData: {
+ licenseAgreement: 'LA_ID1',
+ featureGroups: [{enum: 'FG_ID1', title: 'FG1'}]
+ }
+ };
+ let params = {
+ currentSoftwareProduct: vspWithLicensingData,
+ softwareProductCategories: categories,
+ qdata: {},
+ qschema: vspQschema,
+ finalizedLicenseModelList: [{
+ id: 'VLM_ID1',
+ vendorName: 'VLM1',
+ version: '2.0',
+ viewableVersions: ['1.0', '2.0']
+ }, {
+ id: 'VLM_ID2',
+ vendorName: 'VLM2',
+ version: '3.0',
+ viewableVersions: ['1.0', '2.0', '3.0']
+ }],
+ licenseAgreementList: [{id: 'LA_ID1'}, {id: 'LA_ID2'}],
+ featureGroupsList: [
+ {id: 'FG_ID1', name: 'FG1', referencingLicenseAgreements: ['LA_ID1']},
+ {id: 'FG_ID2', name: 'FG2', referencingLicenseAgreements: ['LA_ID1']}
+ ]
+ };
+ const onVendorChangedListener = (deltaData) => {
+ expect(deltaData.vendorId).toEqual('VLM_ID2');
+ expect(deltaData.vendorName).toEqual('VLM2');
+ expect(deltaData.licensingVersion).toEqual('');
+ expect(deltaData.licensingData).toEqual({});
+ done();
+ };
+
+ var vspDetailsView = TestUtils.renderIntoDocument(<SoftwareProductDetailsView
+ currentSoftwareProduct = {params.currentSoftwareProduct}
+ softwareProductCategories = {params.softwareProductCategories}
+ qdata = {params.qdata}
+ qschema = {params.qschema}
+ finalizedLicenseModelList = {params.finalizedLicenseModelList}
+ licenseAgreementList = {params.licenseAgreementList}
+ featureGroupsList = {params.featureGroupsList}
+ onSubmit = {dummyFunc}
+ onDataChanged = {dummyFunc}
+ onValidityChanged = {dummyFunc}
+ onQDataChanged = {dummyFunc}
+ onVendorParamChanged = {(deltaData) => onVendorChangedListener(deltaData)}/>);
+ expect(vspDetailsView).toExist();
+ vspDetailsView.onVendorParamChanged({vendorId: 'VLM_ID2'});
+ });
+
+ it('in view: should change licensing-version and update licensing data', done => {
+ let params = {
+ currentSoftwareProduct: currentSoftwareProduct,
+ softwareProductCategories: categories,
+ qdata: {},
+ qschema: vspQschema,
+ finalizedLicenseModelList: [{
+ id: 'VLM_ID1',
+ vendorName: 'VLM1',
+ version: '2.0',
+ viewableVersions: ['1.0', '2.0']
+ }, {
+ id: 'VLM_ID2',
+ vendorName: 'VLM2',
+ version: '3.0',
+ viewableVersions: ['1.0', '2.0', '3.0']
+ }],
+ licenseAgreementList: [{id: 'LA_ID1'}, {id: 'LA_ID2'}],
+ featureGroupsList: [
+ {id: 'FG_ID1', name: 'FG1', referencingLicenseAgreements: ['LA_ID1']},
+ {id: 'FG_ID2', name: 'FG2', referencingLicenseAgreements: ['LA_ID1']}
+ ]
+ };
+ const onVendorChangedListener = (deltaData) => {
+ expect(deltaData.vendorId).toEqual('VLM_ID2');
+ expect(deltaData.vendorName).toEqual('VLM2');
+ expect(deltaData.licensingVersion).toEqual('2.0');
+ expect(deltaData.licensingData).toEqual({});
+ done();
+ };
+
+ let vspDetailsView = TestUtils.renderIntoDocument(<SoftwareProductDetailsView
+ {...params}
+ onSubmit = {dummyFunc}
+ onDataChanged = {dummyFunc}
+ onValidityChanged = {dummyFunc}
+ onQDataChanged = {dummyFunc}
+ onVendorParamChanged = {(deltaData) => onVendorChangedListener(deltaData)}/>);
+ expect(vspDetailsView).toExist();
+ vspDetailsView.onVendorParamChanged({vendorId: 'VLM_ID2', licensingVersion: '2.0'});
+ });
+
+ it('in view: should change subcategory', done => {
+ let params = {
+ currentSoftwareProduct: currentSoftwareProduct,
+ softwareProductCategories: categories,
+ qdata: {},
+ qschema: vspQschema,
+ finalizedLicenseModelList: [{
+ id: 'VLM_ID1',
+ vendorName: 'VLM1',
+ version: '2.0',
+ viewableVersions: ['1.0', '2.0']
+ }, {
+ id: 'VLM_ID2',
+ vendorName: 'VLM2',
+ version: '3.0',
+ viewableVersions: ['1.0', '2.0', '3.0']
+ }],
+ licenseAgreementList: [{id: 'LA_ID1'}, {id: 'LA_ID2'}],
+ featureGroupsList: [
+ {id: 'FG_ID1', name: 'FG1', referencingLicenseAgreements: ['LA_ID1']},
+ {id: 'FG_ID2', name: 'FG2', referencingLicenseAgreements: ['LA_ID1']}
+ ]
+ };
+ const onDataChangedListener = ({category, subCategory}) => {
+ expect(category).toEqual('category2');
+ expect(subCategory).toEqual('subCategory2');
+ done();
+ };
+
+ let vspDetailsView = TestUtils.renderIntoDocument(<SoftwareProductDetailsView
+ {...params}
+ onSubmit = {dummyFunc}
+ onDataChanged = {({category, subCategory}) => onDataChangedListener({category, subCategory})}
+ onValidityChanged = {dummyFunc}
+ onQDataChanged = {dummyFunc}
+ onVendorParamChanged = {dummyFunc}/>);
+ expect(vspDetailsView).toExist();
+ vspDetailsView.onSelectSubCategory('subCategory2');
+ });
+
+ it('in view: should change feature groups', done => {
+ let vspWithLicensingData = {
+ ...currentSoftwareProduct,
+ licensingData: {
+ licenseAgreement: 'LA_ID1',
+ featureGroups: [{enum: 'FG_ID1', title: 'FG1'}]
+ }
+ };
+ let params = {
+ currentSoftwareProduct: vspWithLicensingData,
+ softwareProductCategories: categories,
+ qdata: {},
+ qschema: vspQschema,
+ finalizedLicenseModelList: [{
+ id: 'VLM_ID1',
+ vendorName: 'VLM1',
+ version: '2.0',
+ viewableVersions: ['1.0', '2.0']
+ }, {
+ id: 'VLM_ID2',
+ vendorName: 'VLM2',
+ version: '3.0',
+ viewableVersions: ['1.0', '2.0', '3.0']
+ }],
+ licenseAgreementList: [{id: 'LA_ID1'}, {id: 'LA_ID2'}],
+ featureGroupsList: [
+ {id: 'FG_ID1', name: 'FG1', referencingLicenseAgreements: ['LA_ID1']},
+ {id: 'FG_ID2', name: 'FG2', referencingLicenseAgreements: ['LA_ID1']}
+ ]
+ };
+ const onDataChangedListener = ({licensingData}) => {
+ expect(licensingData.licenseAgreement).toEqual('LA_ID1');
+ expect(licensingData.featureGroups).toEqual([
+ {enum: 'FG_ID1', title: 'FG1'},
+ {enum: 'FG_ID2', title: 'FG2'}
+ ]);
+ done();
+ };
+
+ let vspDetailsView = TestUtils.renderIntoDocument(<SoftwareProductDetailsView
+ {...params}
+ onSubmit = {dummyFunc}
+ onDataChanged = {({licensingData}) => onDataChangedListener({licensingData})}
+ onValidityChanged = {dummyFunc}
+ onQDataChanged = {dummyFunc}
+ onVendorParamChanged = {dummyFunc}/>);
+ expect(vspDetailsView).toExist();
+ vspDetailsView.onFeatureGroupsChanged({featureGroups: [
+ {enum: 'FG_ID1', title: 'FG1'},
+ {enum: 'FG_ID2', title: 'FG2'}
+ ]});
+ });
+
+ it('in view: should change license agreement', done => {
+ let vspWithLicensingData = {
+ ...currentSoftwareProduct,
+ licensingData: {
+ licenseAgreement: 'LA_ID1',
+ featureGroups: [{enum: 'FG_ID1', title: 'FG1'}]
+ }
+ };
+ let params = {
+ currentSoftwareProduct: vspWithLicensingData,
+ softwareProductCategories: categories,
+ qdata: {},
+ qschema: vspQschema,
+ finalizedLicenseModelList: [{
+ id: 'VLM_ID1',
+ vendorName: 'VLM1',
+ version: '2.0',
+ viewableVersions: ['1.0', '2.0']
+ }, {
+ id: 'VLM_ID2',
+ vendorName: 'VLM2',
+ version: '3.0',
+ viewableVersions: ['1.0', '2.0', '3.0']
+ }],
+ licenseAgreementList: [{id: 'LA_ID1'}, {id: 'LA_ID2'}],
+ featureGroupsList: [
+ {id: 'FG_ID1', name: 'FG1', referencingLicenseAgreements: ['LA_ID1']},
+ {id: 'FG_ID2', name: 'FG2', referencingLicenseAgreements: ['LA_ID1']}
+ ]
+ };
+ const onDataChangedListener = ({licensingData}) => {
+ expect(licensingData.licenseAgreement).toEqual('LA_ID2');
+ expect(licensingData.featureGroups).toEqual([]);
+ done();
+ };
+
+ let vspDetailsView = TestUtils.renderIntoDocument(<SoftwareProductDetailsView
+ {...params}
+ onSubmit = {dummyFunc}
+ onDataChanged = {({licensingData}) => onDataChangedListener({licensingData})}
+ onValidityChanged = {dummyFunc}
+ onQDataChanged = {dummyFunc}
+ onVendorParamChanged = {dummyFunc}/>);
+ expect(vspDetailsView).toExist();
+ vspDetailsView.onLicensingDataChanged({licenseAgreement: 'LA_ID2', featureGroups: []});
+ });
+});
diff --git a/openecomp-ui/test/softwareProduct/details/test.js b/openecomp-ui/test/softwareProduct/details/test.js
new file mode 100644
index 0000000000..9803b1611d
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/details/test.js
@@ -0,0 +1,383 @@
+/*-
+ * ============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 SoftwareProductCreationActionHelper from 'sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationActionHelper.js';
+import SoftwareProductActionHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js';
+import SoftwareProductCategoriesHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductCategoriesHelper.js';
+
+describe('Software Product Module Tests', function () {
+ it('Get Software Products List', () => {
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const softwareProductList = [
+ {
+ name: 'VSP1',
+ description: 'hjhj',
+ version: '0.1',
+ id: 'EBADF561B7FA4A788075E1840D0B5971',
+ subCategory: 'resourceNewCategory.network connectivity.virtual links',
+ category: 'resourceNewCategory.network connectivity',
+ vendorId: '5259EDE4CC814DC9897BA6F69E2C971B',
+ vendorName: 'Vendor',
+ checkinStatus: 'CHECK_OUT',
+ licensingData: {
+ 'featureGroups': []
+ }
+ },
+ {
+ name: 'VSP2',
+ description: 'dfdfdfd',
+ version: '0.1',
+ id: '2F47447D22DB4C53B020CA1E66201EF2',
+ subCategory: 'resourceNewCategory.network connectivity.virtual links',
+ category: 'resourceNewCategory.network connectivity',
+ vendorId: '5259EDE4CC814DC9897BA6F69E2C971B',
+ vendorName: 'Vendor',
+ checkinStatus: 'CHECK_OUT',
+ licensingData: {
+ featureGroups: []
+ }
+ }
+ ];
+
+ deepFreeze(softwareProductList);
+
+ deepFreeze(store.getState());
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProductList', softwareProductList);
+
+ mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+ expect(baseUrl).to.equal('/onboarding-api/v1.0/vendor-software-products/');
+ expect(data).to.deep.equal(undefined);
+ expect(options).to.equal(undefined);
+ return {results: softwareProductList};
+ });
+
+ return SoftwareProductActionHelper.fetchSoftwareProductList(store.dispatch).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+
+ it('Add Software Product', () => {
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const softwareProductPostRequest = deepFreeze({
+ name: 'vsp1',
+ description: 'string',
+ vendorId: '1',
+ vendorName: 'Vendor',
+ icon: 'icon',
+ subCategory: 'resourceNewCategory.network connectivity.virtual links',
+ category: 'resourceNewCategory.network connectivity',
+ licensingData: {}
+ });
+
+ const softwareProductToAdd = deepFreeze({
+ ...softwareProductPostRequest
+ });
+
+ const softwareProductIdFromResponse = 'ADDED_ID';
+ const softwareProductAfterAdd = deepFreeze({
+ ...softwareProductToAdd,
+ id: softwareProductIdFromResponse
+ });
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProductList', [softwareProductAfterAdd]);
+
+ mockRest.addHandler('create', ({options, data, baseUrl}) => {
+ expect(baseUrl).to.equal('/onboarding-api/v1.0/vendor-software-products/');
+ expect(data).to.deep.equal(softwareProductPostRequest);
+ expect(options).to.equal(undefined);
+ return {
+ vspId: softwareProductIdFromResponse
+ };
+ });
+
+ return SoftwareProductCreationActionHelper.createSoftwareProduct(store.dispatch, {
+ softwareProduct: softwareProductToAdd
+ }).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+ it('Save Software product', () => {
+ const softwareProduct = {
+ name: 'VSP5',
+ id: '4730033D16C64E3CA556AB0AC4478218',
+ description: 'A software model for Fortigate.',
+ subCategory: 'resourceNewCategory.network connectivity.virtual links',
+ category: 'resourceNewCategory.network connectivity',
+ vendorId: '1',
+ vendorName: 'Vendor',
+ licensingVersion: '1.0',
+ icon: 'icon',
+ licensingData: {
+ licenceAgreement: '123',
+ featureGroups: [
+ '123', '234'
+ ]
+ }
+ };
+ deepFreeze(softwareProduct);
+
+ const store = storeCreator({
+ softwareProduct: {
+ softwareProductEditor: {data: softwareProduct},
+ softwareProductQuestionnaire: {qdata: 'test', qschema: {type: 'string'}}
+ }
+ });
+ deepFreeze(store.getState());
+
+ const toBeUpdatedSoftwareProductId = softwareProduct.id;
+ const softwareProductUpdateData = {
+ ...softwareProduct,
+ name: 'VSP5_UPDATED',
+ description: 'A software model for Fortigate._UPDATED'
+ };
+ deepFreeze(softwareProductUpdateData);
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProductList', [softwareProductUpdateData]);
+ const questionnaireData = {
+ general: {
+ affinityData: {
+ affinityGrouping: true,
+ antiAffinityGrouping: false
+ }
+ }
+ };
+ deepFreeze(questionnaireData);
+
+ mockRest.addHandler('save', ({data, options, baseUrl}) => {
+ const expectedData = {
+ name: 'VSP5_UPDATED',
+ description: 'A software model for Fortigate._UPDATED',
+ subCategory: 'resourceNewCategory.network connectivity.virtual links',
+ category: 'resourceNewCategory.network connectivity',
+ vendorId: '1',
+ vendorName: 'Vendor',
+ licensingVersion: '1.0',
+ icon: 'icon',
+ licensingData: {
+ licenceAgreement: '123',
+ featureGroups: [
+ '123', '234'
+ ]
+ }
+ };
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}`);
+ expect(data).to.deep.equal(expectedData);
+ expect(options).to.equal(undefined);
+ return {returnCode: 'OK'};
+ });
+ mockRest.addHandler('save', ({data, options, baseUrl}) => {
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/questionnaire`);
+ expect(data).to.deep.equal(questionnaireData);
+ expect(options).to.equal(undefined);
+ return {returnCode: 'OK'};
+ });
+
+ return SoftwareProductActionHelper.updateSoftwareProduct(store.dispatch, {
+ softwareProduct: softwareProductUpdateData,
+ qdata: questionnaireData
+ }).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+ it('Save Software product data only', () => {
+ const softwareProduct = {
+ name: 'VSP5',
+ id: '4730033D16C64E3CA556AB0AC4478218',
+ description: 'A software model for Fortigate.',
+ subCategory: 'resourceNewCategory.network connectivity.virtual links',
+ category: 'resourceNewCategory.network connectivity',
+ vendorId: '1',
+ vendorName: 'Vendor',
+ licensingVersion: '1.0',
+ icon: 'icon',
+ licensingData: {
+ licenceAgreement: '123',
+ featureGroups: [
+ '123', '234'
+ ]
+ }
+ };
+ deepFreeze(softwareProduct);
+
+ const store = storeCreator({
+ softwareProduct: {
+ softwareProductEditor: {data: softwareProduct},
+ softwareProductQuestionnaire: {qdata: 'test', qschema: {type: 'string'}}
+ }
+ });
+ deepFreeze(store.getState());
+ const expectedStore = store.getState();
+
+ const toBeUpdatedSoftwareProductId = softwareProduct.id;
+ const softwareProductUpdateData = {
+ ...softwareProduct,
+ name: 'VSP5_UPDATED',
+ description: 'A software model for Fortigate._UPDATED'
+ };
+ deepFreeze(softwareProductUpdateData);
+
+ mockRest.addHandler('save', ({data, options, baseUrl}) => {
+ const expectedData = {
+ name: 'VSP5_UPDATED',
+ description: 'A software model for Fortigate._UPDATED',
+ subCategory: 'resourceNewCategory.network connectivity.virtual links',
+ category: 'resourceNewCategory.network connectivity',
+ vendorId: '1',
+ vendorName: 'Vendor',
+ licensingVersion: '1.0',
+ icon: 'icon',
+ licensingData: {
+ licenceAgreement: '123',
+ featureGroups: [
+ '123', '234'
+ ]
+ }
+ };
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}`);
+ expect(data).to.deep.equal(expectedData);
+ expect(options).to.equal(undefined);
+ return {returnCode: 'OK'};
+ });
+
+ return SoftwareProductActionHelper.updateSoftwareProductData(store.dispatch, {
+ softwareProduct: softwareProductUpdateData
+ }).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+
+ it('Save Software product questionnaire only', () => {
+ const softwareProduct = {
+ name: 'VSP5',
+ id: '4730033D16C64E3CA556AB0AC4478218',
+ description: 'A software model for Fortigate.',
+ subCategory: 'resourceNewCategory.network connectivity.virtual links',
+ category: 'resourceNewCategory.network connectivity',
+ vendorId: '1',
+ vendorName: 'Vendor',
+ icon: 'icon',
+ licensingData: {
+ licenceAgreement: '123',
+ featureGroups: [
+ '123', '234'
+ ]
+ }
+ };
+ deepFreeze(softwareProduct);
+
+ const store = storeCreator({
+ softwareProduct: {
+ softwareProductEditor: {data: softwareProduct},
+ softwareProductQuestionnaire: {qdata: 'test', qschema: {type: 'string'}}
+ }
+ });
+ deepFreeze(store.getState());
+ const expectedStore = store.getState();
+
+ const toBeUpdatedSoftwareProductId = softwareProduct.id;
+ const questionnaireData = {
+ general: {
+ affinityData: {
+ affinityGrouping: true,
+ antiAffinityGrouping: false
+ }
+ }
+ };
+ deepFreeze(questionnaireData);
+
+ mockRest.addHandler('save', ({data, options, baseUrl}) => {
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/questionnaire`);
+ expect(data).to.deep.equal(questionnaireData);
+ expect(options).to.equal(undefined);
+ return {returnCode: 'OK'};
+ });
+
+ return SoftwareProductActionHelper.updateSoftwareProductQuestionnaire(store.dispatch, {
+ softwareProductId: softwareProduct.id,
+ qdata: questionnaireData
+ }).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+
+ it('Handle category without subcategories', () => {
+ const categories = deepFreeze([
+ {
+ name: 'Resource Category 1',
+ normalizedName: 'resource category 1',
+ uniqueId: 'resourceNewCategory.resource category 1',
+ subcategories: [
+ {
+ name: 'Sub Category for RC 1',
+ normalizedName: 'sub category for rc 1',
+ uniqueId: 'resourceNewCategory.resource category 1.sub category for rc 1'
+ },
+ {
+ name: 'SC4RC2',
+ normalizedName: 'sc4rc2',
+ uniqueId: 'resourceNewCategory.resource category 1.sc4rc2'
+ },
+ {
+ name: 'SC4RC1',
+ normalizedName: 'sc4rc1',
+ uniqueId: 'resourceNewCategory.resource category 1.sc4rc1'
+ }
+ ]
+ },
+ {
+ name: 'Eeeeee',
+ normalizedName: 'eeeeee',
+ uniqueId: 'resourceNewCategory.eeeeee'
+ },
+ {
+ name: 'Some Recource',
+ normalizedName: 'some recource',
+ uniqueId: 'resourceNewCategory.some recource',
+ subcategories: [
+ {
+ name: 'Second Sub Category for S',
+ normalizedName: 'second sub category for s',
+ uniqueId: 'resourceNewCategory.some recource.second sub category for s'
+ },
+ {
+ name: 'Sub Category for Some Rec',
+ normalizedName: 'sub category for some rec',
+ uniqueId: 'resourceNewCategory.some recource.sub category for some rec'
+ }
+ ]
+ }
+ ]);
+ const category = SoftwareProductCategoriesHelper.getCurrentCategoryOfSubCategory('resourceNewCategory.some recource.sub category for some rec', categories);
+ expect(category).to.equal('resourceNewCategory.some recource');
+ });
+
+});
+
diff --git a/openecomp-ui/test/softwareProduct/details/vspQschema.js b/openecomp-ui/test/softwareProduct/details/vspQschema.js
new file mode 100644
index 0000000000..5612b19991
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/details/vspQschema.js
@@ -0,0 +1,61 @@
+/*-
+ * ============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=========================================================
+ */
+
+export const vspQschema = {
+ '$schema': 'http://json-schema.org/draft-04/schema#',
+ 'type': 'object',
+ 'properties': {
+ 'general': {
+ 'type': 'object',
+ 'properties': {
+ 'affinityData': {
+ 'type': 'object',
+ 'properties': {
+ 'affinityGrouping': {},
+ 'antiAffinityGrouping': {}
+ }
+ },
+ 'availability': {
+ 'type': 'object',
+ 'properties': {
+ 'useAvailabilityZonesForHighAvailability': {}
+ }
+ },
+ 'regionsData': {
+ 'type': 'object',
+ 'properties': {
+ 'multiRegion': {},
+ 'regions': {}
+ }
+ },
+ 'storageDataReplication': {
+ 'type': 'object',
+ 'properties': {
+ 'storageReplicationAcrossRegion': {},
+ 'storageReplicationSize': {},
+ 'storageReplicationFrequency': {},
+ 'storageReplicationSource': {},
+ 'storageReplicationDestination': {}
+ }
+ }
+ }
+ }
+ }
+};
diff --git a/openecomp-ui/test/softwareProduct/networks/SoftwareProductNetworksView.test.js b/openecomp-ui/test/softwareProduct/networks/SoftwareProductNetworksView.test.js
new file mode 100644
index 0000000000..a7f7b2b0c2
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/networks/SoftwareProductNetworksView.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/networks/SoftwareProductNetworks.js';
+import SoftwareProductNetworksView from 'sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksView.jsx';
+import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
+
+describe('SoftwareProductNetworks 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'
+ };
+
+ const networksList = [
+ {
+ name:'dummy_net_1',
+ dhcp:true,
+ 'id':'7F60CD390458421DA588AF4AD217B93F'
+ },
+ {
+ name:'dummy_net_2',
+ dhcp:true,
+ 'id':'AD217B93F7F60CD390458421DA588AF4'
+ }
+ ];
+
+ var obj = {
+ softwareProduct: {
+ softwareProductEditor: {
+ data:currentSoftwareProduct
+ },
+ softwareProductNetworks:
+ {
+ networksList
+ }
+ }
+ };
+ var results = mapStateToProps(obj);
+ expect(results.networksList,).toExist();
+ });
+
+ it ('view simple 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 networksList = [
+ {
+ name:'dummy_net_1',
+ dhcp:true,
+ 'id':'7F60CD390458421DA588AF4AD217B93F'
+ },
+ {
+ name:'dummy_net_2',
+ dhcp:true,
+ 'id':'AD217B93F7F60CD390458421DA588AF4'
+ }
+ ];
+
+ const versionControllerData = {
+ version: '1',
+ viewableVersions: [],
+ status: 'locked',
+ isCheckedOut: true
+ };
+
+ var renderer = TestUtils.createRenderer();
+ renderer.render(<SoftwareProductNetworksView networksList={networksList} versionControllerData={versionControllerData} currentSoftwareProduct={currentSoftwareProduct}/>);
+ var renderedOutput = renderer.getRenderOutput();
+ expect(renderedOutput).toExist();
+
+ });
+
+
+
+});
diff --git a/openecomp-ui/test/softwareProduct/networks/softwareProductNetworksActionHelper.test.js b/openecomp-ui/test/softwareProduct/networks/softwareProductNetworksActionHelper.test.js
new file mode 100644
index 0000000000..2920803c64
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/networks/softwareProductNetworksActionHelper.test.js
@@ -0,0 +1,63 @@
+/*-
+ * ============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 SoftwareProductNetworksActionHelper from 'sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksActionHelper.js';
+
+const softwareProductId = '123';
+
+describe('Software Product Networks ActionHelper Tests', function () {
+ it('Get Software Products Networks List', () => {
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const networksList = [
+ {
+ name:'dummy_net_1',
+ dhcp:true,
+ 'id':'7F60CD390458421DA588AF4AD217B93F'
+ },
+ {
+ name:'dummy_net_2',
+ dhcp:true,
+ 'id':'AD217B93F7F60CD390458421DA588AF4'
+ }
+ ];
+
+ deepFreeze(networksList);
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductNetworks.networksList', networksList);
+
+ mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/networks`);
+ expect(data).to.deep.equal(undefined);
+ expect(options).to.equal(undefined);
+ return {results: networksList};
+ });
+
+ return SoftwareProductNetworksActionHelper.fetchNetworksList(store.dispatch, {softwareProductId}).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+
+ });
+});
diff --git a/openecomp-ui/test/softwareProduct/processes/test.js b/openecomp-ui/test/softwareProduct/processes/test.js
new file mode 100644
index 0000000000..73f22a7898
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/processes/test.js
@@ -0,0 +1,459 @@
+/*-
+ * ============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 Configuration from 'sdc-app/config/Configuration.js';
+import SoftwareProductProcessesActionHelper from 'sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesActionHelper.js';
+
+const softwareProductId = '123';
+
+describe('Software Product Processes Module Tests', function () {
+
+ let restPrefix = '';
+
+ before(function() {
+ restPrefix = Configuration.get('restPrefix');
+ deepFreeze(restPrefix);
+ });
+
+ //**
+ //** ADD
+ //**
+ 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.softwareProductProcesses.processesList', [softwareProductProcessAfterAdd]);
+
+ mockRest.addHandler('create', ({data, options, baseUrl}) => {
+
+ expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes`);
+ expect(data).to.deep.equal(softwareProductPostRequest);
+ expect(options).to.equal(undefined);
+ return {
+ returnCode: 'OK',
+ value: softwareProductProcessFromResponse
+ };
+ });
+
+ return SoftwareProductProcessesActionHelper.saveProcess(store.dispatch,
+ {
+ softwareProductId: softwareProductId,
+ previousProcess: null,
+ process: softwareProductProcessToAdd
+ }
+ ).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+
+ it('Add Software Products Processes with uploaded file', () => {
+
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const softwareProductPostRequest = {
+ name: 'Pr1',
+ description: 'string'
+ };
+ const softwareProductProcessToAdd = {
+ name: 'Pr1',
+ description: 'string',
+ formData: {
+ name: 'new artifact name'
+ }
+ };
+ const softwareProductProcessFromResponse = 'ADDED_ID';
+ const softwareProductProcessAfterAdd = {
+ ...softwareProductProcessToAdd,
+ id: softwareProductProcessFromResponse
+ };
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesList', [softwareProductProcessAfterAdd]);
+
+ mockRest.addHandler('create', ({data, options, baseUrl}) => {
+ expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes`);
+ expect(data).to.deep.equal(softwareProductPostRequest);
+ expect(options).to.equal(undefined);
+ return {
+ returnCode: 'OK',
+ value: softwareProductProcessFromResponse
+ };
+ });
+
+ mockRest.addHandler('create', ({data, options, baseUrl}) => {
+ expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes/${softwareProductProcessAfterAdd.id}/upload`);
+ expect(data).to.deep.equal(softwareProductProcessToAdd.formData);
+ expect(options).to.equal(undefined);
+ return {returnCode: 'OK'};
+ });
+
+ return SoftwareProductProcessesActionHelper.saveProcess(store.dispatch,
+ {
+ softwareProductId: softwareProductId,
+ previousProcess: null,
+ process: softwareProductProcessToAdd
+ }
+ ).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+
+ //**
+ //** UPDATE
+ //**
+ it('Update Software Products Processes', () => {
+ const softwareProductProcessesList = [
+ {
+ name: 'Pr1',
+ description: 'string',
+ id: 'EBADF561B7FA4A788075E1840D0B5971',
+ artifactName: 'artifact'
+ }
+ ];
+ deepFreeze(softwareProductProcessesList);
+
+ const store = storeCreator({
+ softwareProduct: {
+ softwareProductProcesses: {
+ 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.softwareProductProcesses.processesList', [processUpdateData]);
+
+
+ mockRest.addHandler('save', ({data, options, baseUrl}) => {
+ expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes/${toBeUpdatedProcessId}`);
+ expect(data).to.deep.equal(processPutRequest);
+ expect(options).to.equal(undefined);
+ return {returnCode: 'OK'};
+ });
+
+ return SoftwareProductProcessesActionHelper.saveProcess(store.dispatch,
+ {
+ softwareProductId: softwareProductId,
+ previousProcess: previousProcessData,
+ process: processUpdateData
+ }
+ ).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+
+ it('Update Software Products Processes and uploaded file', () => {
+ const previousProcessData = {
+ id: 'EBADF561B7FA4A788075E1840D0B5971',
+ name: 'p1',
+ description: 'string',
+ artifactName: 'artifact'
+ };
+ deepFreeze(previousProcessData);
+
+ const store = storeCreator({
+ softwareProduct: {
+ softwareProductProcesses: {
+ processesList: [previousProcessData]
+ }
+ }
+ });
+ deepFreeze(store.getState());
+
+ const newProcessToUpdate = {
+ ...previousProcessData,
+ name: 'new name',
+ formData: {
+ name: 'new artifact name'
+ }
+ };
+ deepFreeze(newProcessToUpdate);
+
+ const newProcessToPutRequest = {
+ name: newProcessToUpdate.name,
+ description: previousProcessData.description
+ };
+ deepFreeze(newProcessToPutRequest);
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesList', [newProcessToUpdate]);
+
+ mockRest.addHandler('save', ({data, options, baseUrl}) => {
+ expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes/${previousProcessData.id}`);
+ expect(data).to.deep.equal(newProcessToPutRequest);
+ expect(options).to.equal(undefined);
+ return {returnCode: 'OK'};
+ });
+
+ mockRest.addHandler('create', ({data, options, baseUrl}) => {
+ expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes/${previousProcessData.id}/upload`);
+ expect(data).to.deep.equal(newProcessToUpdate.formData);
+ expect(options).to.equal(undefined);
+ return {returnCode: 'OK'};
+ });
+
+ return SoftwareProductProcessesActionHelper.saveProcess(store.dispatch,
+ {
+ softwareProductId: softwareProductId,
+ previousProcess: previousProcessData,
+ process: newProcessToUpdate
+ }
+ ).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+
+ //**
+ //** GET
+ //**
+ 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.softwareProductProcesses.processesList', softwareProductProcessesList);
+
+ mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+ expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes`);
+ expect(data).to.deep.equal(undefined);
+ expect(options).to.equal(undefined);
+ return {results: softwareProductProcessesList};
+ });
+
+ return SoftwareProductProcessesActionHelper.fetchProcessesList(store.dispatch, {softwareProductId}).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+
+ //**
+ //** DELETE
+ //**
+ 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.softwareProductProcesses.processesList', []);
+
+ mockRest.addHandler('destroy', ({data, options, baseUrl}) => {
+ expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes/${processId}`);
+ expect(data).to.equal(undefined);
+ expect(options).to.equal(undefined);
+ return {
+ results: {
+ returnCode: 'OK'
+ }
+ };
+ });
+
+ return SoftwareProductProcessesActionHelper.deleteProcess(store.dispatch, {
+ process: softwareProductProcessesList[0],
+ softwareProductId
+ }).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+
+ it('Validating Software Products Processes Delete confirmation', done => {
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ let process = {
+ id: 'p_id',
+ name: 'p_name'
+ };
+ deepFreeze(process);
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processToDelete', process);
+
+ SoftwareProductProcessesActionHelper.openDeleteProcessesConfirm(store.dispatch, {process});
+
+ setTimeout(function(){
+ expect(store.getState()).to.deep.equal(expectedStore);
+ done();
+ }, 100);
+ });
+
+ it('Validating Software Products Processes Cancel Delete', done => {
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processToDelete', false);
+
+ SoftwareProductProcessesActionHelper.hideDeleteConfirm(store.dispatch);
+
+ setTimeout(function(){
+ expect(store.getState()).to.deep.equal(expectedStore);
+ done();
+ }, 100);
+ });
+
+ //**
+ //** CREATE/EDIT
+ //**
+ it('Validating open Software Products Processes for create', done => {
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ let process = {};
+ deepFreeze(process);
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesEditor.data', process);
+
+ SoftwareProductProcessesActionHelper.openEditor(store.dispatch);
+
+ setTimeout(function(){
+ expect(store.getState()).to.deep.equal(expectedStore);
+ done();
+ }, 100);
+ });
+
+ it('Validating close Software Products Processes from editing mode', done => {
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesEditor', {});
+
+ SoftwareProductProcessesActionHelper.closeEditor(store.dispatch);
+
+ setTimeout(function(){
+ expect(store.getState()).to.deep.equal(expectedStore);
+ done();
+ }, 100);
+ });
+
+ it('Validating open Software Products Processes for editing', done => {
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ let process = {name: 'aa', description: 'xx'};
+ deepFreeze(process);
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesEditor.data', process);
+
+ SoftwareProductProcessesActionHelper.openEditor(store.dispatch, process);
+
+ setTimeout(function(){
+ expect(store.getState()).to.deep.equal(expectedStore);
+ done();
+ }, 100);
+ });
+
+ it('Validating Software Products Processes dataChanged event', done => {
+ let process = {name: 'aa', description: 'xx'};
+ deepFreeze(process);
+
+ const store = storeCreator({
+ softwareProduct: {
+ softwareProductProcesses: {
+ processesEditor: {
+ data: process
+ }
+ }
+ }
+ });
+ deepFreeze(store.getState());
+
+ let deltaData = {name: 'bb'};
+ deepFreeze(deltaData);
+
+ let expectedProcess = {name: 'bb', description: 'xx'};
+ deepFreeze(expectedProcess);
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesEditor.data', expectedProcess);
+
+ SoftwareProductProcessesActionHelper.processEditorDataChanged(store.dispatch, {deltaData});
+
+ setTimeout(function(){
+ expect(store.getState()).to.deep.equal(expectedStore);
+ done();
+ }, 100);
+ });
+});
+