summaryrefslogtreecommitdiffstats
path: root/openecomp-ui/test
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-ui/test')
-rw-r--r--openecomp-ui/test/flows/FlowsListEditor.test.js279
-rw-r--r--openecomp-ui/test/flows/flowsEditorModal.test.js89
-rw-r--r--openecomp-ui/test/flows/test.js497
-rw-r--r--openecomp-ui/test/licenseModel/entitlementPools/test.js244
-rw-r--r--openecomp-ui/test/licenseModel/featureGroups/test.js212
-rw-r--r--openecomp-ui/test/licenseModel/licenseAgreement/test.js205
-rw-r--r--openecomp-ui/test/licenseModel/licenseKeyGroups/test.js197
-rw-r--r--openecomp-ui/test/licenseModel/test.js66
-rw-r--r--openecomp-ui/test/nfvo-components/input/dualListBox/dualListbox.test.js94
-rw-r--r--openecomp-ui/test/nfvo-components/listEditor/listEditor.test.js96
-rw-r--r--openecomp-ui/test/nfvo-components/notifications/notificationsModal.test.js144
-rw-r--r--openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js44
-rw-r--r--openecomp-ui/test/nfvo-components/panel/VersionController/versionControllerUtils.test.js172
-rw-r--r--openecomp-ui/test/setup.test.js25
-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
-rw-r--r--openecomp-ui/test/utils/errorResponseHandler.test.js135
-rw-r--r--openecomp-ui/test/utils/restApiUtil.test.js149
-rw-r--r--openecomp-ui/test/utils/uuid.test.js52
36 files changed, 6250 insertions, 0 deletions
diff --git a/openecomp-ui/test/flows/FlowsListEditor.test.js b/openecomp-ui/test/flows/FlowsListEditor.test.js
new file mode 100644
index 0000000000..534253567e
--- /dev/null
+++ b/openecomp-ui/test/flows/FlowsListEditor.test.js
@@ -0,0 +1,279 @@
+/*-
+ * ============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/flows/FlowsListEditor.js';
+import FlowsListEditorView from 'sdc-app/flows/FlowsListEditorView.jsx';
+
+describe('Flows List Editor Mapper and View Classes: ', function () {
+
+ it('mapStateToProps mapper exists', () => {
+ expect(mapStateToProps).toExist();
+ });
+
+ it('mapStateToProps mapper - without flowList', () => {
+ let flows = {
+ isDisplayModal: true,
+ isModalInEditMode: false,
+ shouldShowWorkflowsEditor: undefined
+ };
+ let results = mapStateToProps({flows});
+ expect(results.flowList).toExist();
+ expect(results.flowList.length).toEqual(0);
+ expect(results.shouldShowWorkflowsEditor).toBe(true);
+ });
+
+ it('mapStateToProps mapper - populated flowList', () => {
+ let artifactName = 'test1', description = 'desc';
+ let flows = {
+ flowList: [{artifactName, description}],
+ isDisplayModal: true,
+ isModalInEditMode: false,
+ shouldShowWorkflowsEditor: false
+ };
+ let results = mapStateToProps({flows});
+ expect(results.flowList).toExist();
+ expect(results.flowList.length).toEqual(1);
+ expect(results.shouldShowWorkflowsEditor).toBe(false);
+ });
+
+ it('mapStateToProps mapper - populated flowList and currentFlow is in readonly', () => {
+ let artifactName = 'test1', description = 'desc';
+ let currentFlow = {artifactName, description, readonly: true};
+ let flows = {
+ flowList: [currentFlow],
+ currentFlow,
+ isDisplayModal: true,
+ isModalInEditMode: false,
+ shouldShowWorkflowsEditor: false
+ };
+ let results = mapStateToProps({flows});
+ expect(results.currentFlow).toExist();
+ expect(results.isCheckedOut).toEqual(false);
+ });
+
+ it('mapStateToProps mapper - populated flowList and currentFlow is in not readonly', () => {
+ let artifactName = 'test1', description = 'desc';
+ let currentFlow = {artifactName, description, readonly: false};
+ let flows = {
+ flowList: [currentFlow],
+ currentFlow,
+ isDisplayModal: true,
+ isModalInEditMode: false,
+ shouldShowWorkflowsEditor: false
+ };
+ let results = mapStateToProps({flows});
+ expect(results.currentFlow).toExist();
+ expect(results.isCheckedOut).toEqual(true);
+ });
+
+ it('basic view component run with empty flowList and should show the list', () => {
+ let renderer = TestUtils.createRenderer();
+ let artifactName = 'test1', description = 'desc';
+ let currentFlow = {artifactName, description, readonly: false};
+ renderer.render(<FlowsListEditorView shouldShowWorkflowsEditor={true} flowList={[currentFlow]}/>);
+ let renderedOutput = renderer.getRenderOutput();
+ expect(renderedOutput).toExist();
+ });
+
+ it('basic view component run with empty flowList and should show the diagram', () => {
+ const flow = {
+ 'artifactType': 'WORKFLOW',
+ 'participants': [
+ {
+ 'id': '1',
+ 'name': 'Customer'
+ },
+ {
+ 'id': '2',
+ 'name': 'CCD'
+ },
+ {
+ 'id': '3',
+ 'name': 'Infrastructure'
+ },
+ {
+ 'id': '4',
+ 'name': 'MSO'
+ },
+ {
+ 'id': '5',
+ 'name': 'SDN-C'
+ },
+ {
+ 'id': '6',
+ 'name': 'A&AI'
+ },
+ {
+ 'id': '7',
+ 'name': 'APP-C'
+ },
+ {
+ 'id': '8',
+ 'name': 'Cloud'
+ },
+ {
+ 'id': '9',
+ 'name': 'DCAE'
+ },
+ {
+ 'id': '10',
+ 'name': 'ALTS'
+ },
+ {
+ 'id': '11',
+ 'name': 'VF'
+ }
+ ],
+ 'serviceID': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b',
+ 'artifactDisplayName': 'zizizi',
+ 'artifactGroupType': 'INFORMATIONAL',
+ 'uniqueId': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi',
+ 'artifactName': 'zizizi',
+ 'artifactLabel': 'zizizi',
+ 'artifactUUID': '0295a7cc-8c02-4105-9d7e-c30ce67ecd07',
+ 'artifactVersion': '1',
+ 'creationDate': 1470144601623,
+ 'lastUpdateDate': 1470144601623,
+ 'description': 'aslkjdfl asfdasdf',
+ 'mandatory': false,
+ 'timeout': 0,
+ 'esId': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi',
+ 'artifactChecksum': 'NjBmYjc4NGM5MWIwNmNkMDhmMThhMDAwYmQxYjBiZTU=',
+ 'heatParameters': [],
+ 'sequenceDiagramModel': {
+ 'diagram': {
+ 'metadata': {
+ 'id': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi',
+ 'name': 'zizizi',
+ 'ref': 'BLANK'
+ },
+ 'lifelines': [
+ {
+ 'id': '1',
+ 'name': 'Customer',
+ 'index': 1,
+ 'x': 175
+ },
+ {
+ 'id': '2',
+ 'name': 'CCD',
+ 'index': 2,
+ 'x': 575
+ },
+ {
+ 'id': '3',
+ 'name': 'Infrastructure',
+ 'index': 3,
+ 'x': 975
+ },
+ {
+ 'id': '4',
+ 'name': 'MSO',
+ 'index': 4,
+ 'x': 1375
+ },
+ {
+ 'id': '5',
+ 'name': 'SDN-C',
+ 'index': 5,
+ 'x': 1775
+ },
+ {
+ 'id': '6',
+ 'name': 'A&AI',
+ 'index': 6,
+ 'x': 2175
+ },
+ {
+ 'id': '7',
+ 'name': 'APP-C',
+ 'index': 7,
+ 'x': 2575
+ },
+ {
+ 'id': '8',
+ 'name': 'Cloud',
+ 'index': 8,
+ 'x': 2975
+ },
+ {
+ 'id': '9',
+ 'name': 'DCAE',
+ 'index': 9,
+ 'x': 3375
+ },
+ {
+ 'id': '10',
+ 'name': 'ALTS',
+ 'index': 10,
+ 'x': 3775
+ },
+ {
+ 'id': '11',
+ 'name': 'VF',
+ 'index': 11,
+ 'x': 4175
+ }
+ ],
+ 'steps': [
+ {
+ 'message': {
+ 'id': '9377-5036-c011-cb95-3a8b-82c6-bbb5-bc84',
+ 'name': '[Unnamed Message]',
+ 'type': 'request',
+ 'from': '1',
+ 'to': '2',
+ 'index': 1
+ }
+ },
+ {
+ 'message': {
+ 'id': '64c4-4fd1-b1da-4355-a060-6e48-ee47-c85c',
+ 'name': '[Unnamed Message]',
+ 'type': 'request',
+ 'from': '1',
+ 'to': '2',
+ 'index': 2
+ }
+ }
+ ]
+ }
+ }
+ };
+ let renderer = TestUtils.createRenderer();
+ renderer.render(<FlowsListEditorView currentFlow={flow} shouldShowWorkflowsEditor={false} flowList={[flow]}/>);
+ let renderedOutput = renderer.getRenderOutput();
+ expect(renderedOutput).toExist();
+ });
+
+ it('basic view component run with empty flowList and should show popup modal', () => {
+ let renderer = TestUtils.createRenderer();
+ let artifactName = 'test1', description = 'desc';
+ let currentFlow = {artifactName, description, readonly: false};
+ renderer.render(<FlowsListEditorView isDisplayModal={true} shouldShowWorkflowsEditor={true} flowList={[currentFlow]}/>);
+ let renderedOutput = renderer.getRenderOutput();
+ expect(renderedOutput).toExist();
+ });
+
+
+});
diff --git a/openecomp-ui/test/flows/flowsEditorModal.test.js b/openecomp-ui/test/flows/flowsEditorModal.test.js
new file mode 100644
index 0000000000..d8da97af4e
--- /dev/null
+++ b/openecomp-ui/test/flows/flowsEditorModal.test.js
@@ -0,0 +1,89 @@
+/*-
+ * ============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/flows/FlowsEditorModal.js';
+import FlowsEditorModalView from 'sdc-app/flows/FlowsEditorModalView.jsx';
+
+describe('Flows Editor Modal Mapper and View Classes: ', function () {
+
+ it('mapStateToProps mapper exists', () => {
+ expect(mapStateToProps).toExist();
+ });
+
+ it('mapStateToProps mapper - without currentFlow', () => {
+ var flows = {
+ serviceID: '123',
+ diagramType: 'SOME_TYPE'
+ };
+ var results = mapStateToProps({flows});
+ expect(results.currentFlow).toExist();
+ expect(results.currentFlow.artifactName).toBe('');
+ expect(results.currentFlow.description).toBe('');
+ });
+
+ it('mapStateToProps mapper - populated currentFlow', () => {
+ let artifactName = 'test1', description = 'desc';
+ var flows = {
+ currentFlow: {artifactName, description},
+ serviceID: '123',
+ diagramType: 'SOME_TYPE'
+ };
+ var results = mapStateToProps({flows});
+ expect(results.currentFlow).toExist();
+ expect(results.currentFlow.artifactName).toBe(artifactName);
+ expect(results.currentFlow.description).toBe(description);
+ expect(results.currentFlow.serviceID).toBe(flows.serviceID);
+ expect(results.currentFlow.artifactType).toBe(flows.diagramType);
+ });
+
+ it('basic modal view component run with empty artifact', () => {
+ let renderer = TestUtils.createRenderer();
+ renderer.render(
+ <FlowsEditorModalView
+ onCancel={()=>{}}
+ onDataChanged={()=>{}}
+ currentFlow={{artifactName: '', description: ''}}/>);
+ let renderedOutput = renderer.getRenderOutput();
+ expect(renderedOutput).toExist();
+ });
+
+ it('modal view component run with data changed handler', done => {
+ let handler = () => done();
+ let document = TestUtils.renderIntoDocument(
+ <FlowsEditorModalView
+ onCancel={()=>{}}
+ onDataChanged={handler}
+ currentFlow={{artifactName: '', description: ''}}/>);
+ let result = TestUtils.scryRenderedDOMComponentsWithTag(document, 'input');
+ expect(result).toExist();
+ expect(result.length).toExist();
+ TestUtils.Simulate.change(result[0]);
+ });
+
+ it('modal view component - on save click', done => {
+ let handler = () => done();
+ var flowsEditorModalView = new FlowsEditorModalView({currentFlow: {}, onSubmit: handler});
+ flowsEditorModalView.onSaveClicked();
+ });
+
+});
diff --git a/openecomp-ui/test/flows/test.js b/openecomp-ui/test/flows/test.js
new file mode 100644
index 0000000000..4c5ab78640
--- /dev/null
+++ b/openecomp-ui/test/flows/test.js
@@ -0,0 +1,497 @@
+/*-
+ * ============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 store from 'sdc-app/AppStore.js';
+import FlowsActions from 'sdc-app/flows/FlowsActions.js';
+import {enums} from 'sdc-app/flows/FlowsConstants.js';
+
+const NEW_FLOW = true;
+
+let assertFlowDataAfterCreateFetchAndUpdate = (data) => {
+ let {flowList, serviceID, diagramType} = store.getState().flows;
+ expect(serviceID).toBe(data.serviceID);
+ expect(diagramType).toBe(data.artifactType);
+ let uniqueId = data.uniqueId || `${data.serviceID}.${data.artifactName}`;
+ let index = flowList.findIndex(flow => flow.uniqueId === uniqueId);
+ expect(index).toNotBe(-1);
+};
+
+describe('Workflows and Management Flows Module Tests:', function () {
+
+
+ it('empty artifact should open flow creation modal', done => {
+
+ const artifacts = {};
+
+ deepFreeze(store.getState());
+ deepFreeze(artifacts);
+ FlowsActions.fetchFlowArtifacts(store.dispatch, {
+ artifacts,
+ diagramType: enums.WORKFLOW,
+ participants: [],
+ serviceID: '1234'
+ });
+ setTimeout(() => {
+ let state = store.getState();
+ expect(state.flows.isDisplayModal).toBe(true);
+ expect(state.flows.isModalInEditMode).toBe(false);
+ done();
+ }, 50);
+ });
+
+ it('Close flow details editor modal', done => {
+ deepFreeze(store.getState());
+ FlowsActions.closeFlowDetailsEditor(store.dispatch);
+ setTimeout(() => {
+ let state = store.getState();
+ expect(state.flows.isDisplayModal).toBe(false);
+ expect(state.flows.isModalInEditMode).toBe(false);
+ done();
+ }, 50);
+ });
+
+ it('Get Flows List from loaded artifact', done => {
+
+ deepFreeze(store.getState());
+
+ const artifacts = {
+ 'test1': {
+ 'uniqueId': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.test1',
+ 'artifactType': 'NETWORK_CALL_FLOW',
+ 'artifactName': 'test1',
+ 'artifactChecksum': 'MzYxZGIyNjlkNjRmMTM4ZWMxM2FjNDUyNDQwMTI3NzM=',
+ 'attUidLastUpdater': 'cs0008',
+ 'updaterFullName': 'Carlos Santana',
+ 'creationDate': 1468164899724,
+ 'lastUpdateDate': 1468164899724,
+ 'esId': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.test1',
+ 'artifactLabel': 'test1',
+ 'artifactCreator': 'cs0008',
+ 'description': 'www',
+ 'mandatory': false,
+ 'artifactDisplayName': 'test1',
+ 'serviceApi': false,
+ 'artifactGroupType': 'INFORMATIONAL',
+ 'timeout': 0,
+ 'artifactVersion': '1',
+ 'artifactUUID': '28d4cb95-bb46-4666-b858-e333671e6444',
+ 'payloadUpdateDate': 1468164900232
+ },
+ 'kukuriku': {
+ 'uniqueId': '0280b577-2c7b-426e-b7a2-f0dc16508c37.kukuriku',
+ 'artifactType': 'PUPPET',
+ 'artifactName': 'fuel.JPG',
+ 'artifactChecksum': 'OWEyYTVjMWFiNWQ4ZDIwZDUxYTE3Y2EzZmI3YTYyMjA=',
+ 'attUidLastUpdater': 'cs0008',
+ 'updaterFullName': 'Carlos Santana',
+ 'creationDate': 1467877631512,
+ 'lastUpdateDate': 1467877631512,
+ 'esId': '0280b577-2c7b-426e-b7a2-f0dc16508c37.kukuriku',
+ 'artifactLabel': 'kukuriku',
+ 'artifactCreator': 'cs0008',
+ 'description': 'asdfasdf',
+ 'mandatory': false,
+ 'artifactDisplayName': 'kukuriku',
+ 'serviceApi': false,
+ 'artifactGroupType': 'INFORMATIONAL',
+ 'timeout': 0,
+ 'artifactVersion': '1',
+ 'artifactUUID': 'c1e98336-03f4-4b2a-b6a5-08eca44fe3c4',
+ 'payloadUpdateDate': 1467877632722
+ },
+ 'test3': {
+ 'uniqueId': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.test3',
+ 'artifactType': 'NETWORK_CALL_FLOW',
+ 'artifactName': 'test3',
+ 'artifactChecksum': 'ZmJkZGU1M2M2ZWUxZTdmNGU5NTNiNTdiYTAzMmM1YzU=',
+ 'attUidLastUpdater': 'cs0008',
+ 'updaterFullName': 'Carlos Santana',
+ 'creationDate': 1468165068570,
+ 'lastUpdateDate': 1468165128827,
+ 'esId': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.test3',
+ 'artifactLabel': 'test3',
+ 'artifactCreator': 'cs0008',
+ 'description': '333',
+ 'mandatory': false,
+ 'artifactDisplayName': 'test3',
+ 'serviceApi': false,
+ 'artifactGroupType': 'INFORMATIONAL',
+ 'timeout': 0,
+ 'artifactVersion': '2',
+ 'artifactUUID': '0988027c-d19c-43db-8315-2c68fc773775',
+ 'payloadUpdateDate': 1468165129335
+ }
+ };
+
+ const artifactsArray = Object.keys(artifacts).map(artifact => artifact);
+
+ deepFreeze(artifacts);
+
+ deepFreeze(store.getState());
+
+ let actionData = {
+ artifacts,
+ diagramType: enums.WORKFLOW,
+ participants: [],
+ serviceID: '1234'
+ };
+ FlowsActions.fetchFlowArtifacts(store.dispatch, actionData);
+
+ setTimeout(() => {
+ let state = store.getState();
+ expect(state.flows.isDisplayModal).toBe(false);
+ expect(state.flows.isModalInEditMode).toBe(false);
+ expect(state.flows.flowList.length).toEqual(artifactsArray.length);
+ expect(state.flows.flowParticipants).toEqual(actionData.participants);
+ expect(state.flows.serviceID).toBe(actionData.serviceID);
+ expect(state.flows.diagramType).toBe(actionData.diagramType);
+ done();
+ }, 50);
+
+ });
+
+
+ it('Add New Flow', done => {
+
+ deepFreeze(store.getState());
+
+ const flowCreateData = deepFreeze({
+ artifactName: 'zizizi',
+ artifactType: 'WORKFLOW',
+ description: 'aslkjdfl asfdasdf',
+ serviceID: '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b',
+ });
+
+
+ let expectedDataToBeSentInTheRequest = {
+ artifactGroupType: 'INFORMATIONAL',
+ artifactLabel: 'zizizi',
+ artifactName: 'zizizi',
+ artifactType: 'WORKFLOW',
+ description: 'aslkjdfl asfdasdf',
+ payloadData: 'eyJWRVJTSU9OIjp7Im1ham9yIjoxLCJtaW5vciI6MH0sImRlc2NyaXB0aW9uIjoiYXNsa2pkZmwgYXNmZGFzZGYifQ=='
+ };
+ mockRest.addHandler('create', ({data, baseUrl, options}) => {
+ expect(baseUrl).toBe(`/sdc1/feProxy/rest/v1/catalog/services/${flowCreateData.serviceID}/artifacts/`);
+ expect(data.artifactLabel).toBe(expectedDataToBeSentInTheRequest.artifactLabel);
+ expect(data.artifactName).toBe(expectedDataToBeSentInTheRequest.artifactName);
+ expect(data.artifactType).toBe(expectedDataToBeSentInTheRequest.artifactType);
+ expect(data.description).toBe(expectedDataToBeSentInTheRequest.description);
+ expect(data.payloadData).toBe(expectedDataToBeSentInTheRequest.payloadData);
+ expect(options.md5).toBe(true);
+ return {
+ artifactChecksum: 'NjBmYjc4NGM5MWIwNmNkMDhmMThhMDAwYmQxYjBiZTU=',
+ artifactCreator: 'cs0008',
+ artifactDisplayName: 'zizizi',
+ artifactGroupType: 'INFORMATIONAL',
+ artifactLabel: 'zizizi',
+ artifactName: 'zizizi',
+ artifactType: 'WORKFLOW',
+ artifactUUID: '0295a7cc-8c02-4105-9d7e-c30ce67ecd07',
+ artifactVersion: '1',
+ attUidLastUpdater: 'cs0008',
+ creationDate: 1470144601623,
+ description: 'aslkjdfl asfdasdf',
+ esId: '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi',
+ lastUpdateDate: 1470144601623,
+ mandatory: false,
+ payloadUpdateDate: 1470144602131,
+ serviceApi: false,
+ timeout: 0,
+ uniqueId: '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi',
+ updaterFullName: 'Carlos Santana',
+ };
+ });
+
+ FlowsActions.createOrUpdateFlow(store.dispatch, {flow: flowCreateData}, NEW_FLOW);
+
+ setTimeout(() => {
+ assertFlowDataAfterCreateFetchAndUpdate(flowCreateData);
+ done();
+ }, 50);
+ });
+
+ it('Fetch Flow', done => {
+
+ deepFreeze(store.getState());
+
+ const flowFetchData = {
+ artifactName: 'zizizi',
+ artifactType: 'WORKFLOW',
+ description: 'aslkjdfl asfdasdf',
+ serviceID: '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b',
+ uniqueId: '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi',
+ participants: []
+ };
+
+ mockRest.addHandler('fetch', ({baseUrl}) => {
+ //sdc1/feProxy/rest/v1/catalog/services/338d75f0-aec8-4eb4-89c9-8733fcd9bf3b/artifacts/338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi
+ expect(baseUrl).toBe(`/sdc1/feProxy/rest/v1/catalog/services/${flowFetchData.serviceID}/artifacts/${flowFetchData.uniqueId}`);
+ return {
+ artifactName: 'zizizi',
+ base64Contents: 'eyJWRVJTSU9OIjp7Im1ham9yIjoxLCJtaW5vciI6MH0sImRlc2NyaXB0aW9uIjoiYXNsa2pkZmwgYXNmZGFzZGYifQ=='
+ };
+ });
+
+ FlowsActions.fetchArtifact(store.dispatch, {flow: flowFetchData});
+
+ setTimeout(() => {
+ assertFlowDataAfterCreateFetchAndUpdate(flowFetchData);
+ done();
+ }, 50);
+ });
+
+ it('Update Existing Flow', done => {
+
+ deepFreeze(store.getState());
+
+ const flowUpdateData = {
+ 'artifactType': 'WORKFLOW',
+ 'participants': [
+ {
+ 'id': '1',
+ 'name': 'Customer'
+ },
+ {
+ 'id': '2',
+ 'name': 'CCD'
+ },
+ {
+ 'id': '3',
+ 'name': 'Infrastructure'
+ },
+ {
+ 'id': '4',
+ 'name': 'MSO'
+ },
+ {
+ 'id': '5',
+ 'name': 'SDN-C'
+ },
+ {
+ 'id': '6',
+ 'name': 'A&AI'
+ },
+ {
+ 'id': '7',
+ 'name': 'APP-C'
+ },
+ {
+ 'id': '8',
+ 'name': 'Cloud'
+ },
+ {
+ 'id': '9',
+ 'name': 'DCAE'
+ },
+ {
+ 'id': '10',
+ 'name': 'ALTS'
+ },
+ {
+ 'id': '11',
+ 'name': 'VF'
+ }
+ ],
+ 'serviceID': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b',
+ 'artifactDisplayName': 'zizizi',
+ 'artifactGroupType': 'INFORMATIONAL',
+ 'uniqueId': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi',
+ 'artifactName': 'zizizi',
+ 'artifactLabel': 'zizizi',
+ 'artifactUUID': '0295a7cc-8c02-4105-9d7e-c30ce67ecd07',
+ 'artifactVersion': '1',
+ 'creationDate': 1470144601623,
+ 'lastUpdateDate': 1470144601623,
+ 'description': 'aslkjdfl asfdasdf',
+ 'mandatory': false,
+ 'timeout': 0,
+ 'esId': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi',
+ 'artifactChecksum': 'NjBmYjc4NGM5MWIwNmNkMDhmMThhMDAwYmQxYjBiZTU=',
+ 'heatParameters': [],
+ 'sequenceDiagramModel': {
+ 'diagram': {
+ 'metadata': {
+ 'id': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi',
+ 'name': 'zizizi',
+ 'ref': 'BLANK'
+ },
+ 'lifelines': [
+ {
+ 'id': '1',
+ 'name': 'Customer',
+ 'index': 1,
+ 'x': 175
+ },
+ {
+ 'id': '2',
+ 'name': 'CCD',
+ 'index': 2,
+ 'x': 575
+ },
+ {
+ 'id': '3',
+ 'name': 'Infrastructure',
+ 'index': 3,
+ 'x': 975
+ },
+ {
+ 'id': '4',
+ 'name': 'MSO',
+ 'index': 4,
+ 'x': 1375
+ },
+ {
+ 'id': '5',
+ 'name': 'SDN-C',
+ 'index': 5,
+ 'x': 1775
+ },
+ {
+ 'id': '6',
+ 'name': 'A&AI',
+ 'index': 6,
+ 'x': 2175
+ },
+ {
+ 'id': '7',
+ 'name': 'APP-C',
+ 'index': 7,
+ 'x': 2575
+ },
+ {
+ 'id': '8',
+ 'name': 'Cloud',
+ 'index': 8,
+ 'x': 2975
+ },
+ {
+ 'id': '9',
+ 'name': 'DCAE',
+ 'index': 9,
+ 'x': 3375
+ },
+ {
+ 'id': '10',
+ 'name': 'ALTS',
+ 'index': 10,
+ 'x': 3775
+ },
+ {
+ 'id': '11',
+ 'name': 'VF',
+ 'index': 11,
+ 'x': 4175
+ }
+ ],
+ 'steps': [
+ {
+ 'message': {
+ 'id': '9377-5036-c011-cb95-3a8b-82c6-bbb5-bc84',
+ 'name': '[Unnamed Message]',
+ 'type': 'request',
+ 'from': '1',
+ 'to': '2',
+ 'index': 1
+ }
+ },
+ {
+ 'message': {
+ 'id': '64c4-4fd1-b1da-4355-a060-6e48-ee47-c85c',
+ 'name': '[Unnamed Message]',
+ 'type': 'request',
+ 'from': '1',
+ 'to': '2',
+ 'index': 2
+ }
+ }
+ ]
+ }
+ }
+ };
+
+ mockRest.addHandler('create', ({baseUrl}) => {
+ expect(baseUrl).toBe(`/sdc1/feProxy/rest/v1/catalog/services/${flowUpdateData.serviceID}/artifacts/${flowUpdateData.uniqueId}`);
+
+ return {
+ artifactChecksum: 'MmE5MWJmN2ZlN2FhM2JhMzA0NGQ1ODMyOWFhNWI0NDA=',
+ artifactCreator: 'cs0008',
+ artifactDisplayName: 'zizizi',
+ artifactGroupType: 'INFORMATIONAL',
+ artifactLabel: 'zizizi',
+ artifactName: 'zizizi',
+ artifactType: 'WORKFLOW',
+ artifactUUID: '3319335b-969e-4d72-b5a2-409645de6d64',
+ artifactVersion: '3',
+ attUidLastUpdater: 'cs0008',
+ creationDate: 1470144601623,
+ description: 'aslkjdfl asfdasdf',
+ esId: '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi',
+ lastUpdateDate: 1470208425904,
+ mandatory: false,
+ payloadUpdateDate: 1470208426424,
+ serviceApi: false,
+ timeout: 0,
+ uniqueId: '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi',
+ updaterFullName: 'Carlos Santana'
+ };
+ });
+
+ FlowsActions.createOrUpdateFlow(store.dispatch, {flow: flowUpdateData}, !NEW_FLOW);
+
+ setTimeout(() => {
+ assertFlowDataAfterCreateFetchAndUpdate(flowUpdateData);
+ done();
+ }, 50);
+ });
+
+ it('Delete Flow', done => {
+
+ deepFreeze(store.getState());
+
+ const flowDeleteData = deepFreeze({
+ artifactName: 'zizizi',
+ artifactType: 'WORKFLOW',
+ description: 'aslkjdfl asfdasdf',
+ serviceID: '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b',
+ uniqueId: '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi',
+ participants: []
+ });
+
+ mockRest.addHandler('destroy', ({baseUrl}) => {
+ expect(baseUrl).toBe(`/sdc1/feProxy/rest/v1/catalog/services/${flowDeleteData.serviceID}/artifacts/${flowDeleteData.uniqueId}`);
+ return {};
+ });
+
+ FlowsActions.deleteFlow(store.dispatch, {flow: flowDeleteData});
+
+ setTimeout(() => {
+ let {flowList} = store.getState().flows;
+ let index = flowList.findIndex(flow => flow.uniqueId === flowDeleteData.uniqueId);
+ expect(index).toBe(-1);
+ done();
+ }, 50);
+ });
+
+});
+
diff --git a/openecomp-ui/test/licenseModel/entitlementPools/test.js b/openecomp-ui/test/licenseModel/entitlementPools/test.js
new file mode 100644
index 0000000000..32705385b4
--- /dev/null
+++ b/openecomp-ui/test/licenseModel/entitlementPools/test.js
@@ -0,0 +1,244 @@
+/*-
+ * ============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 deepFreeze from 'deep-freeze';
+import {expect} from 'chai';
+import mockRest from 'test-utils/MockRest.js';
+import {cloneAndSet} from 'test-utils/Util.js';
+import {storeCreator} from 'sdc-app/AppStore.js';
+import EntitlementPoolsActionHelper from 'sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js';
+
+describe('Entitlement Pools Module Tests', function () {
+
+ const LICENSE_MODEL_ID = '555';
+
+ it('Load Entitlement Pools List', () => {
+ const entitlementPoolsList = [
+ {
+ name: 'ep1',
+ description: 'string',
+ thresholdValue: 75,
+ thresholdUnits: '%',
+ entitlementMetric: {'choice': 'User', 'other': ''},
+ increments: 'string',
+ aggregationFunction: {'choice': 'Average', 'other': ''},
+ operationalScope: {'choices': ['Other'], 'other': 'blabla'},
+ time: {'choice': 'Hour', 'other': ''},
+ sku: 'DEF2-385A-4521-AAAA',
+ id: '1',
+ referencingFeatureGroups: [],
+ partNumber: '51529'
+ }
+ ];
+ deepFreeze(entitlementPoolsList);
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', entitlementPoolsList);
+
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/entitlement-pools`);
+ expect(data).to.equal(undefined);
+ expect(options).to.equal(undefined);
+ return {results: entitlementPoolsList};
+ });
+
+ return EntitlementPoolsActionHelper.fetchEntitlementPoolsList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID}).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+
+ it('Delete Entitlement Pool', () => {
+ const entitlementPoolsList = [
+ {
+ name: 'ep1',
+ description: 'string',
+ thresholdValue: 75,
+ thresholdUnits: '%',
+ entitlementMetric: {'choice': 'User', 'other': ''},
+ increments: 'string',
+ aggregationFunction: {'choice': 'Average', 'other': ''},
+ operationalScope: {'choices': ['Other'], 'other': 'blabla'},
+ time: {'choice': 'Hour', 'other': ''},
+ sku: 'DEF2-385A-4521-AAAA',
+ id: '1',
+ referencingFeatureGroups: [],
+ partNumber: '51529'
+ }
+ ];
+
+ deepFreeze(entitlementPoolsList);
+ const store = storeCreator({
+ licenseModel: {
+ entitlementPool: {
+ entitlementPoolsList
+ }
+ }
+ });
+ deepFreeze(store.getState());
+
+ const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', []);
+
+ mockRest.addHandler('destroy', ({data, options, baseUrl}) => {
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/entitlement-pools/${entitlementPoolsList[0].id}`);
+ expect(data).to.equal(undefined);
+ expect(options).to.equal(undefined);
+ return {
+ results: {
+ returnCode: 'OK'
+ }
+ };
+ });
+
+ return EntitlementPoolsActionHelper.deleteEntitlementPool(store.dispatch, {
+ licenseModelId: LICENSE_MODEL_ID,
+ entitlementPoolId: entitlementPoolsList[0].id
+ }).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+
+ it('Add Entitlement Pool', () => {
+
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const entitlementPoolPostRequest = {
+ name: 'ep1',
+ description: 'string',
+ thresholdValue: 75,
+ thresholdUnits: '%',
+ entitlementMetric: {'choice': 'User', 'other': ''},
+ increments: 'string',
+ aggregationFunction: {'choice': 'Average', 'other': ''},
+ operationalScope: {'choices': ['Other'], 'other': 'blabla'},
+ time: {'choice': 'Hour', 'other': ''},
+ manufacturerReferenceNumber: 'DEF2-385A-4521-AAAA',
+ };
+ const entitlementPoolToAdd = {
+ name: 'ep1',
+ description: 'string',
+ thresholdValue: 75,
+ thresholdUnits: '%',
+ entitlementMetric: {'choice': 'User', 'other': ''},
+ increments: 'string',
+ aggregationFunction: {'choice': 'Average', 'other': ''},
+ operationalScope: {'choices': ['Other'], 'other': 'blabla'},
+ time: {'choice': 'Hour', 'other': ''},
+ manufacturerReferenceNumber: 'DEF2-385A-4521-AAAA',
+ referencingFeatureGroups: []
+ };
+ const entitlementPoolIdFromResponse = 'ADDED_ID';
+ const entitlementPoolAfterAdd = {
+ ...entitlementPoolToAdd,
+ id: entitlementPoolIdFromResponse
+ };
+
+ const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', [entitlementPoolAfterAdd]);
+
+ mockRest.addHandler('create', ({data, options, baseUrl}) => {
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/entitlement-pools`);
+ expect(data).to.deep.equal(entitlementPoolPostRequest);
+ expect(options).to.equal(undefined);
+ return {
+ returnCode: 'OK',
+ value: entitlementPoolIdFromResponse
+ };
+ });
+
+ return EntitlementPoolsActionHelper.saveEntitlementPool(store.dispatch,
+ {
+ licenseModelId: LICENSE_MODEL_ID,
+ previousEntitlementPool: null,
+ entitlementPool: entitlementPoolToAdd
+ }
+ ).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+
+ it('Update Entitlement Pool', () => {
+ const entitlementPoolsList = [{
+ name: 'ep1',
+ id: '0',
+ description: 'string',
+ thresholdValue: 75,
+ thresholdUnits: '%',
+ entitlementMetric: {'choice': 'User', 'other': ''},
+ increments: 'string',
+ aggregationFunction: {'choice': 'Average', 'other': ''},
+ operationalScope: {'choices': ['Other'], 'other': 'blabla'},
+ time: {'choice': 'Hour', 'other': ''},
+ manufacturerReferenceNumber: 'DEF2-385A-4521-AAAA'
+ }];
+ deepFreeze(entitlementPoolsList);
+
+ const store = storeCreator({
+ licenseModel: {
+ entitlementPool: {
+ entitlementPoolsList
+ }
+ }
+ });
+ deepFreeze(store.getState());
+
+ const toBeUpdatedEntitlementPoolId = entitlementPoolsList[0].id;
+ const previousEntitlementPoolData = entitlementPoolsList[0];
+ const entitlementPoolUpdateData = {
+ ...entitlementPoolsList[0],
+ name: 'ep1_UPDATED',
+ description: 'string_UPDATED'
+ };
+ deepFreeze(entitlementPoolUpdateData);
+
+ const entitlementPoolPutRequest = {
+ name: 'ep1_UPDATED',
+ description: 'string_UPDATED',
+ thresholdValue: 75,
+ thresholdUnits: '%',
+ entitlementMetric: {'choice': 'User', 'other': ''},
+ increments: 'string',
+ aggregationFunction: {'choice': 'Average', 'other': ''},
+ operationalScope: {'choices': ['Other'], 'other': 'blabla'},
+ time: {'choice': 'Hour', 'other': ''},
+ manufacturerReferenceNumber: 'DEF2-385A-4521-AAAA'
+ };
+ deepFreeze(entitlementPoolPutRequest);
+
+ const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', [entitlementPoolUpdateData]);
+
+
+ mockRest.addHandler('save', ({data, options, baseUrl}) => {
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/entitlement-pools/${toBeUpdatedEntitlementPoolId}`);
+ expect(data).to.deep.equal(entitlementPoolPutRequest);
+ expect(options).to.equal(undefined);
+ return {returnCode: 'OK'};
+ });
+
+ return EntitlementPoolsActionHelper.saveEntitlementPool(store.dispatch, {
+ licenseModelId: LICENSE_MODEL_ID,
+ previousEntitlementPool: previousEntitlementPoolData,
+ entitlementPool: entitlementPoolUpdateData
+ }).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+
+});
diff --git a/openecomp-ui/test/licenseModel/featureGroups/test.js b/openecomp-ui/test/licenseModel/featureGroups/test.js
new file mode 100644
index 0000000000..d334ab758e
--- /dev/null
+++ b/openecomp-ui/test/licenseModel/featureGroups/test.js
@@ -0,0 +1,212 @@
+/*-
+ * ============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 FeatureGroupsActionHelper from 'sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js';
+
+
+describe('Feature Groups Module Tests', function () {
+
+ const LICENSE_MODEL_ID = '555';
+
+ it('Load Feature Groups List', () => {
+ const featureGroupsList = [
+ {
+ name: 'fs1',
+ id: 0,
+ description: 'fs1-d',
+ licenseKeyGroupsIds: [1],
+ entitlementPoolsIds: [1],
+ refCount: 0
+ }
+ ];
+ deepFreeze(featureGroupsList);
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const expectedStore = cloneAndSet(store.getState(), 'licenseModel.featureGroup.featureGroupsList', featureGroupsList);
+
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/feature-groups`);
+ expect(data).to.equal(undefined);
+ expect(options).to.equal(undefined);
+ return {results: featureGroupsList};
+ });
+
+ return FeatureGroupsActionHelper.fetchFeatureGroupsList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID}).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+
+ it('Delete Feature Group', () => {
+ const featureGroupsList = [
+ {
+ name: 'fs1',
+ id: 0,
+ description: 'fs1-d',
+ licenseKeyGroupsIds: [1],
+ entitlementPoolsIds: [1],
+ refCount: 0
+ }
+ ];
+ deepFreeze(featureGroupsList);
+ const store = storeCreator({
+ licenseModel: {
+ featureGroup: {
+ featureGroupsList
+ }
+ }
+ });
+ deepFreeze(store.getState());
+
+ const expectedStore = cloneAndSet(store.getState(), 'licenseModel.featureGroup.featureGroupsList', []);
+
+ mockRest.addHandler('destroy', ({data, options, baseUrl}) => {
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/feature-groups/${featureGroupsList[0].id}`);
+ expect(data).to.equal(undefined);
+ expect(options).to.equal(undefined);
+ return {
+ results: {
+ returnCode: 'OK'
+ }
+ };
+ });
+
+ return FeatureGroupsActionHelper.deleteFeatureGroup(store.dispatch, {
+ licenseModelId: LICENSE_MODEL_ID,
+ featureGroupId: featureGroupsList[0].id
+ }).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+
+ it('Add Feature Group', () => {
+
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const featureGroupPostRequest = {
+ name: 'fs1',
+ description: 'fs1-d',
+ partNumber: '123',
+ addedLicenseKeyGroupsIds: [1],
+ addedEntitlementPoolsIds: [1]
+ };
+ const featureGroupToAdd = {
+ name: 'fs1',
+ description: 'fs1-d',
+ partNumber: '123',
+ licenseKeyGroupsIds: [1],
+ entitlementPoolsIds: [1]
+ };
+ const featureGroupIdFromResponse = 'ADDED_ID';
+ const featureGroupAfterAdd = {
+ ...featureGroupToAdd,
+ id: featureGroupIdFromResponse
+ };
+
+ const expectedStore = cloneAndSet(store.getState(), 'licenseModel.featureGroup.featureGroupsList', [featureGroupAfterAdd]);
+
+ mockRest.addHandler('create', ({data, options, baseUrl}) => {
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/feature-groups`);
+ expect(data).to.deep.equal(featureGroupPostRequest);
+ expect(options).to.equal(undefined);
+ return {
+ returnCode: 'OK',
+ value: featureGroupIdFromResponse
+ };
+ });
+
+ return FeatureGroupsActionHelper.saveFeatureGroup(store.dispatch, {
+ licenseModelId: LICENSE_MODEL_ID,
+ featureGroup: featureGroupToAdd
+ }).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+
+ it('Update Feature Group', () => {
+ const featureGroupsList = [{
+ name: 'fs1',
+ id: 0,
+ description: 'fs1-d',
+ partNumber: '123',
+ licenseKeyGroupsIds: [1],
+ entitlementPoolsIds: [1],
+ refCount: 0
+ }];
+ deepFreeze(featureGroupsList);
+
+ const store = storeCreator({
+ licenseModel: {
+ featureGroup: {
+ featureGroupsList
+ }
+ }
+ });
+ deepFreeze(store.getState());
+
+ const toBeUpdatedFeatureGroupId = featureGroupsList[0].id;
+ const previousFeatureGroupData = featureGroupsList[0];
+ const featureGroupUpdateData = {
+ ...featureGroupsList[0],
+ name: 'fs_UPDATED',
+ description: 'description_UPDATED',
+ partNumber: '123_UPDATED',
+ licenseKeyGroupsIds: [7],
+ entitlementPoolsIds: [7]
+ };
+ deepFreeze(featureGroupUpdateData);
+
+ const featureGroupPutRequest = {
+ name: 'fs_UPDATED',
+ description: 'description_UPDATED',
+ partNumber: '123_UPDATED',
+ addedLicenseKeyGroupsIds: [7],
+ addedEntitlementPoolsIds: [7],
+ removedLicenseKeyGroupsIds: [1],
+ removedEntitlementPoolsIds: [1]
+ };
+ deepFreeze(featureGroupPutRequest);
+
+ const expectedStore = cloneAndSet(store.getState(), 'licenseModel.featureGroup.featureGroupsList', [featureGroupUpdateData]);
+
+
+ mockRest.addHandler('save', ({data, options, baseUrl}) => {
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/feature-groups/${toBeUpdatedFeatureGroupId}`);
+ expect(data).to.deep.equal(featureGroupPutRequest);
+ expect(options).to.equal(undefined);
+ return {returnCode: 'OK'};
+ });
+
+ return FeatureGroupsActionHelper.saveFeatureGroup(store.dispatch, {
+ licenseModelId: LICENSE_MODEL_ID,
+ previousFeatureGroup: previousFeatureGroupData,
+ featureGroup: featureGroupUpdateData
+ }).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+
+});
diff --git a/openecomp-ui/test/licenseModel/licenseAgreement/test.js b/openecomp-ui/test/licenseModel/licenseAgreement/test.js
new file mode 100644
index 0000000000..a6e8a3d363
--- /dev/null
+++ b/openecomp-ui/test/licenseModel/licenseAgreement/test.js
@@ -0,0 +1,205 @@
+/*-
+ * ============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 LicenseAgreementActionHelper from 'sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementActionHelper.js';
+
+
+describe('License Agreement Module Tests', () => {
+
+ const LICENSE_MODEL_ID = '777';
+
+ it('Load License Agreement List', () => {
+ const licenseAgreementList = [
+ {
+ id: '0',
+ name: 'name0',
+ description: 'description0',
+ licenseTerm: 'licenseTerm0',
+ requirementsAndConstrains: 'req_and_constraints0',
+ featureGroupsIds: ['77']
+ }
+ ];
+ deepFreeze(licenseAgreementList);
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseAgreement.licenseAgreementList', licenseAgreementList);
+
+ mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/license-agreements`);
+ expect(data).to.equal(undefined);
+ expect(options).to.equal(undefined);
+ return {results: licenseAgreementList};
+ });
+ return LicenseAgreementActionHelper.fetchLicenseAgreementList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID}).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+
+ it('Delete License Agreement', () => {
+ const licenseAgreementList = [
+ {
+ id: '0',
+ name: 'name0',
+ description: 'description0',
+ licenseTerm: 'licenseTerm0',
+ requirementsAndConstrains: 'req_and_constraints0',
+ featureGroupsIds: ['77']
+ }
+ ];
+ deepFreeze(licenseAgreementList);
+ const store = storeCreator({
+ licenseModel: {
+ licenseAgreement: {
+ licenseAgreementList
+ }
+ }
+ });
+ deepFreeze(store.getState());
+ const toBeDeletedLicenseAgreementId = '0';
+ const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseAgreement.licenseAgreementList', []);
+
+ mockRest.addHandler('destroy', ({data, options, baseUrl}) => {
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/license-agreements/${toBeDeletedLicenseAgreementId}`);
+ expect(data).to.equal(undefined);
+ expect(options).to.equal(undefined);
+ });
+
+ return LicenseAgreementActionHelper.deleteLicenseAgreement(store.dispatch, {
+ licenseAgreementId: toBeDeletedLicenseAgreementId,
+ licenseModelId: LICENSE_MODEL_ID
+ }).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+
+ it('Add License Agreement', () => {
+ const store = storeCreator();
+ deepFreeze(store.getState());
+ const licenseAgreementPostRequest = {
+ name: 'name_ADDED_LA',
+ description: 'description_ADDED_LA',
+ licenseTerm: 'licenseTerm_ADDED_LA',
+ requirementsAndConstrains: 'req_and_constraints_ADDED_LA',
+ addedFeatureGroupsIds: []
+ };
+ deepFreeze(licenseAgreementPostRequest);
+
+ const licenseAgreementToAdd = {
+ name: 'name_ADDED_LA',
+ description: 'description_ADDED_LA',
+ licenseTerm: 'licenseTerm_ADDED_LA',
+ requirementsAndConstrains: 'req_and_constraints_ADDED_LA',
+ featureGroupsIds: []
+ };
+ deepFreeze(licenseAgreementToAdd);
+
+ const licenseAgreementIdFromResponse = 'ADDED_ID';
+ const licenseAgreementAfterAdd = {
+ ...licenseAgreementToAdd,
+ id: licenseAgreementIdFromResponse
+ };
+ deepFreeze(licenseAgreementAfterAdd);
+
+ const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseAgreement.licenseAgreementList', [licenseAgreementAfterAdd]);
+
+ mockRest.addHandler('create', ({options, data, baseUrl}) => {
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/license-agreements`);
+ expect(data).to.deep.equal(licenseAgreementPostRequest);
+ expect(options).to.equal(undefined);
+ return {
+ value: licenseAgreementIdFromResponse
+ };
+ });
+
+ return LicenseAgreementActionHelper.saveLicenseAgreement(store.dispatch, {
+ licenseAgreement: licenseAgreementToAdd,
+ licenseModelId: LICENSE_MODEL_ID
+ }).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+
+ it('Update License Agreement', () => {
+ const licenseAgreementList = [
+ {
+ id: '0',
+ name: 'name0',
+ description: 'description0',
+ licenseTerm: 'licenseTerm0',
+ requirementsAndConstrains: 'req_and_constraints0',
+ featureGroupsIds: ['77']
+ }
+ ];
+ const store = storeCreator({
+ licenseModel: {
+ licenseAgreement: {
+ licenseAgreementList
+ }
+ }
+ });
+ deepFreeze(store.getState());
+
+ const toBeUpdatedLicenseAgreementId = licenseAgreementList[0].id;
+ const previousLicenseAgreementData = licenseAgreementList[0];
+
+ const licenseAgreementUpdateData = {
+ ...licenseAgreementList[0],
+ name: 'name_UPDATED',
+ description: 'description_UPDATED',
+ licenseTerm: 'licenseTerm_UPDATED_LA',
+ requirementsAndConstrains: 'req_and_constraints_UPDATED_LA',
+ featureGroupsIds: ['update_id_1', 'update_id_2']
+ };
+ deepFreeze(licenseAgreementUpdateData);
+
+ const licenseAgreementPutRequest = {
+ name: 'name_UPDATED',
+ description: 'description_UPDATED',
+ licenseTerm: 'licenseTerm_UPDATED_LA',
+ requirementsAndConstrains: 'req_and_constraints_UPDATED_LA',
+ addedFeatureGroupsIds: ['update_id_1', 'update_id_2'],
+ removedFeatureGroupsIds: ['77']
+ };
+ deepFreeze(licenseAgreementPutRequest);
+
+ const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseAgreement.licenseAgreementList', [licenseAgreementUpdateData]);
+
+ mockRest.addHandler('save', ({data, options, baseUrl}) => {
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/license-agreements/${toBeUpdatedLicenseAgreementId}`);
+ expect(data).to.deep.equal(licenseAgreementPutRequest);
+ expect(options).to.equal(undefined);
+ });
+
+ return LicenseAgreementActionHelper.saveLicenseAgreement(store.dispatch, {
+ licenseModelId: LICENSE_MODEL_ID,
+ previousLicenseAgreement: previousLicenseAgreementData,
+ licenseAgreement: licenseAgreementUpdateData
+ }).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+
+});
diff --git a/openecomp-ui/test/licenseModel/licenseKeyGroups/test.js b/openecomp-ui/test/licenseModel/licenseKeyGroups/test.js
new file mode 100644
index 0000000000..944bd44e49
--- /dev/null
+++ b/openecomp-ui/test/licenseModel/licenseKeyGroups/test.js
@@ -0,0 +1,197 @@
+/*-
+ * ============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 LicenseKeyGroupsActionHelper from 'sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsActionHelper.js';
+
+describe('License Key Groups Module Tests', function () {
+
+ const LICENSE_MODEL_ID = '555';
+ it('Load License Key Group', () => {
+ const licenseKeyGroupsList = [
+ {
+ name: 'lsk1',
+ description: 'string',
+ type: 'Unique',
+ operationalScope: {'choices': ['Data_Center'], 'other': ''},
+ id: '0'
+ }
+ ];
+ deepFreeze(licenseKeyGroupsList);
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsList', licenseKeyGroupsList);
+
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/license-key-groups`);
+ expect(data).to.equal(undefined);
+ expect(options).to.equal(undefined);
+ return {results: licenseKeyGroupsList};
+ });
+
+ return LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID}).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+
+ it('Delete License Key Group', () => {
+ const licenseKeyGroupsList = [
+ {
+ name: 'lsk1',
+ description: 'string',
+ type: 'Unique',
+ operationalScope: {'choices': ['Data_Center'], 'other': ''},
+ id: '0'
+ }
+ ];
+ deepFreeze(licenseKeyGroupsList);
+ const store = storeCreator({
+ licenseModel: {
+ licenseKeyGroup: {
+ licenseKeyGroupsList
+ }
+ }
+ });
+ deepFreeze(store.getState());
+ const toBeDeletedLicenseKeyGroupId = '0';
+ const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsList', []);
+
+ mockRest.addHandler('destroy', ({data, options, baseUrl}) => {
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/license-key-groups/${toBeDeletedLicenseKeyGroupId}`);
+ expect(data).to.equal(undefined);
+ expect(options).to.equal(undefined);
+ });
+
+ return LicenseKeyGroupsActionHelper.deleteLicenseKeyGroup(store.dispatch, {
+ licenseKeyGroupId: toBeDeletedLicenseKeyGroupId,
+ licenseModelId: LICENSE_MODEL_ID
+ }).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+
+ it('Add License Key Group', () => {
+
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const licenseKeyGroupPostRequest = {
+ name: 'lsk1_ADDED',
+ description: 'string_ADDED',
+ type: 'Unique_ADDED',
+ operationalScope: {'choices': ['Data_Center'], 'other': ''}
+ };
+ deepFreeze(licenseKeyGroupPostRequest);
+
+ const licenseKeyGroupToAdd = {
+ ...licenseKeyGroupPostRequest
+ };
+
+ deepFreeze(licenseKeyGroupToAdd);
+
+ const licenseKeyGroupIdFromResponse = 'ADDED_ID';
+ const licenseKeyGroupAfterAdd = {
+ ...licenseKeyGroupToAdd,
+ id: licenseKeyGroupIdFromResponse
+ };
+ deepFreeze(licenseKeyGroupAfterAdd);
+
+ const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsList', [licenseKeyGroupAfterAdd]);
+
+ mockRest.addHandler('create', ({options, data, baseUrl}) => {
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/license-key-groups`);
+ expect(data).to.deep.equal(licenseKeyGroupPostRequest);
+ expect(options).to.equal(undefined);
+ return {
+ value: licenseKeyGroupIdFromResponse
+ };
+ });
+
+ return LicenseKeyGroupsActionHelper.saveLicenseKeyGroup(store.dispatch, {
+ licenseKeyGroup: licenseKeyGroupToAdd,
+ licenseModelId: LICENSE_MODEL_ID
+ }).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+
+ it('Update License Key Group', () => {
+ const licenseKeyGroupsList = [
+ {
+ name: 'lsk1',
+ description: 'string',
+ type: 'Unique',
+ operationalScope: {'choices': ['Data_Center'], 'other': ''},
+ id: '0'
+ }
+ ];
+ deepFreeze(licenseKeyGroupsList);
+ const store = storeCreator({
+ licenseModel: {
+ licenseKeyGroup: {
+ licenseKeyGroupsList
+ }
+ }
+ });
+
+ const toBeUpdatedLicenseKeyGroupId = licenseKeyGroupsList[0].id;
+ const previousLicenseKeyGroupData = licenseKeyGroupsList[0];
+
+ const licenseKeyGroupUpdateData = {
+ ...licenseKeyGroupsList[0],
+ name: 'lsk1_UPDATE',
+ description: 'string_UPDATE',
+ type: 'Unique',
+ operationalScope: {'choices': ['Data_Center'], 'other': ''}
+ };
+ deepFreeze(licenseKeyGroupUpdateData);
+
+ const licenseKeyGroupPutRequest = {
+ name: 'lsk1_UPDATE',
+ description: 'string_UPDATE',
+ type: 'Unique',
+ operationalScope: {'choices': ['Data_Center'], 'other': ''}
+ };
+ deepFreeze(licenseKeyGroupPutRequest);
+
+ const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsList', [licenseKeyGroupUpdateData]);
+
+ mockRest.addHandler('save', ({data, options, baseUrl}) => {
+ expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/license-key-groups/${toBeUpdatedLicenseKeyGroupId}`);
+ expect(data).to.deep.equal(licenseKeyGroupPutRequest);
+ expect(options).to.equal(undefined);
+ });
+
+ return LicenseKeyGroupsActionHelper.saveLicenseKeyGroup(store.dispatch, {
+ previousLicenseKeyGroup: previousLicenseKeyGroupData,
+ licenseKeyGroup: licenseKeyGroupUpdateData,
+ licenseModelId: LICENSE_MODEL_ID
+ }).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+
+});
diff --git a/openecomp-ui/test/licenseModel/test.js b/openecomp-ui/test/licenseModel/test.js
new file mode 100644
index 0000000000..c21d18f146
--- /dev/null
+++ b/openecomp-ui/test/licenseModel/test.js
@@ -0,0 +1,66 @@
+/*-
+ * ============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 LicenseModelCreationActionHelper from 'sdc-app/onboarding/licenseModel/creation/LicenseModelCreationActionHelper.js';
+
+describe('License Model Module Tests', function () {
+ it('Add License Model', () => {
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const licenseModelPostRequest = deepFreeze({
+ vendorName: 'vlm1',
+ description: 'string',
+ iconRef: 'icon'
+ });
+
+ const licenseModelToAdd = deepFreeze({
+ ...licenseModelPostRequest
+ });
+
+ const licenseModelIdFromResponse = 'ADDED_ID';
+ const licenseModelAfterAdd = deepFreeze({
+ ...licenseModelToAdd,
+ id: licenseModelIdFromResponse
+ });
+
+ const expectedStore = cloneAndSet(store.getState(), 'licenseModelList', [licenseModelAfterAdd]);
+
+ mockRest.addHandler('create', ({options, data, baseUrl}) => {
+ expect(baseUrl).to.equal('/onboarding-api/v1.0/vendor-license-models/');
+ expect(data).to.deep.equal(licenseModelPostRequest);
+ expect(options).to.equal(undefined);
+ return {
+ value: licenseModelIdFromResponse
+ };
+ });
+
+ return LicenseModelCreationActionHelper.createLicenseModel(store.dispatch, {
+ licenseModel: licenseModelToAdd
+ }).then(() => {
+ expect(store.getState()).to.deep.equal(expectedStore);
+ });
+ });
+});
diff --git a/openecomp-ui/test/nfvo-components/input/dualListBox/dualListbox.test.js b/openecomp-ui/test/nfvo-components/input/dualListBox/dualListbox.test.js
new file mode 100644
index 0000000000..eaa06eedf4
--- /dev/null
+++ b/openecomp-ui/test/nfvo-components/input/dualListBox/dualListbox.test.js
@@ -0,0 +1,94 @@
+/*-
+ * ============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 DualListboxView from 'nfvo-components/input/dualListbox/DualListboxView.jsx';
+
+const ITEMS = [{id: '1', name: 'aaa'}, {id: '2', name: 'bbb'}, {id: '3', name: 'ccc'}];
+
+describe('dualListBox Module Tests', function () {
+
+
+ it('should render basically', () => {
+ var renderer = TestUtils.createRenderer();
+ renderer.render(<DualListboxView onChange={()=>{}}/>);
+ var renderedOutput = renderer.getRenderOutput();
+ expect(renderedOutput).toExist();
+ });
+
+ it('should render with available list and 4 control buttons', () => {
+ var view = TestUtils.renderIntoDocument(<DualListboxView availableList={ITEMS} onChange={()=>{}}/>);
+ expect(view).toExist();
+ var results = TestUtils.scryRenderedDOMComponentsWithClass(view, 'dual-list-option');
+ expect(results.length).toBe(4);
+ });
+
+ it('should add item to selected list', done => {
+ const newItemValue = 'new item';
+ let onChange = (value)=> {
+ expect(value).toEqual(newItemValue);
+ done();
+ };
+ var view = new DualListboxView({availableList:ITEMS, onChange, selectedValuesList:[]});
+ expect(view).toExist();
+ view.refs = {
+ availableValues: {getValue(){return newItemValue;}}
+ };
+ view.addToSelectedList();
+ });
+
+ it('should remove item from selected list', done => {
+ const selectedValuesList = ['a','b'];
+ let onChange = (value)=> {
+ expect(value).toEqual(selectedValuesList[1]);
+ done();
+ };
+ var view = new DualListboxView({availableList:ITEMS, onChange, selectedValuesList});
+ expect(view).toExist();
+ view.refs = {
+ selectedValues: {getValue(){return ['a'];}}
+ };
+ view.removeFromSelectedList();
+ });
+
+ it('should add all items to selected list', done => {
+ let onChange = (value)=> {
+ expect(value).toEqual(ITEMS.map(item => item.id));
+ done();
+ };
+ var view = new DualListboxView({availableList:ITEMS, onChange, selectedValuesList:[]});
+ expect(view).toExist();
+ view.addAllToSelectedList();
+ });
+
+ it('should remove all items from selected list', done => {
+ let onChange = (value)=> {
+ expect(value.length).toBe(0);
+ done();
+ };
+ var view = new DualListboxView({availableList:ITEMS, onChange, selectedValuesList:[]});
+ expect(view).toExist();
+ view.removeAllFromSelectedList();
+ });
+
+
+});
diff --git a/openecomp-ui/test/nfvo-components/listEditor/listEditor.test.js b/openecomp-ui/test/nfvo-components/listEditor/listEditor.test.js
new file mode 100644
index 0000000000..a3b098f611
--- /dev/null
+++ b/openecomp-ui/test/nfvo-components/listEditor/listEditor.test.js
@@ -0,0 +1,96 @@
+/*-
+ * ============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 ListEditorView from 'src/nfvo-components/listEditor/ListEditorView.jsx';
+import ListEditorItemView from 'src/nfvo-components/listEditor/ListEditorItemView.jsx';
+
+describe('listEditor Module Tests', function () {
+
+
+ it('list editor view should exist', () => {
+ expect(ListEditorView).toExist();
+ });
+
+ it('list editor item view should exist', () => {
+ expect(ListEditorItemView).toExist();
+ });
+
+ it('should render list and list item and call onEdit', done => {
+ let itemView = TestUtils.renderIntoDocument(
+ <ListEditorView title='some title'>
+ <ListEditorItemView onEdit={done}>
+ <div></div>
+ </ListEditorItemView>
+ </ListEditorView>
+ );
+ expect(itemView).toExist();
+ let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'fa-sliders');
+ TestUtils.Simulate.click(sliderIcon);
+ });
+
+ it('should render list and list item and call onFilter', done => {
+ let itemView = TestUtils.renderIntoDocument(
+ <ListEditorView onFilter={()=>{done();}}>
+ <ListEditorItemView>
+ <div></div>
+ </ListEditorItemView>
+ </ListEditorView>
+ );
+ expect(itemView).toExist();
+ let filterInput = TestUtils.findRenderedDOMComponentWithTag(itemView, 'input');
+ TestUtils.Simulate.change(filterInput);
+ });
+
+ it('should render READONLY list item and not call onEdit', done => {
+ let itemView = TestUtils.renderIntoDocument(
+ <ListEditorItemView onEdit={done} isReadOnlyMode={true}>
+ <div></div>
+ </ListEditorItemView>
+ );
+ expect(itemView).toExist();
+ let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'fa-sliders');
+ TestUtils.Simulate.click(sliderIcon);
+ });
+
+ it('should render list item and call onDelete', done => {
+ let itemView = TestUtils.renderIntoDocument(
+ <ListEditorItemView onDelete={done} isReadOnlyMode={false}>
+ <div></div>
+ </ListEditorItemView>
+ );
+ expect(itemView).toExist();
+ let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'fa-trash-o');
+ TestUtils.Simulate.click(sliderIcon);
+ });
+
+ it('should render READONLY list item and not call onDelete', () => {
+ let itemView = TestUtils.renderIntoDocument(
+ <ListEditorItemView onDelete={()=>{}} isReadOnlyMode={true}>
+ <div></div>
+ </ListEditorItemView>
+ );
+ expect(itemView).toExist();
+ let sliderIcon = TestUtils.scryRenderedDOMComponentsWithClass(itemView, 'fa-trash-o');
+ expect(sliderIcon).toEqual(0);
+ });
+});
diff --git a/openecomp-ui/test/nfvo-components/notifications/notificationsModal.test.js b/openecomp-ui/test/nfvo-components/notifications/notificationsModal.test.js
new file mode 100644
index 0000000000..f84d38246d
--- /dev/null
+++ b/openecomp-ui/test/nfvo-components/notifications/notificationsModal.test.js
@@ -0,0 +1,144 @@
+/*-
+ * ============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 store from 'sdc-app/AppStore.js';
+import ConnectedNotificationModal, {NotificationModal} from 'nfvo-components/notifications/NotificationModal.jsx';
+import NotificationConstants from 'nfvo-components/notifications/NotificationConstants.js';
+
+const title = 'test title';
+const msg = 'test msg';
+
+describe('Notification Modal Mapper and View Class: ', function () {
+
+ it('notification should show with type error', done => {
+ store.dispatch({type: NotificationConstants.NOTIFY_ERROR, data: {title, msg}});
+ setTimeout(()=> {
+ expect(store.getState().notification).toExist();
+ expect(store.getState().notification.type).toBe('error');
+ done();
+ }, 0);
+ });
+
+ it('notification should show with type default', done => {
+ store.dispatch({type: NotificationConstants.NOTIFY_INFO, data: {title, msg}});
+ setTimeout(()=> {
+ expect(store.getState().notification).toExist();
+ expect(store.getState().notification.type).toBe('default');
+ done();
+ }, 0);
+ });
+
+ it('notification should show with type warning', done => {
+ store.dispatch({type: NotificationConstants.NOTIFY_WARNING, data: {title, msg}});
+ setTimeout(()=> {
+ expect(store.getState().notification).toExist();
+ expect(store.getState().notification.type).toBe('warning');
+ done();
+ }, 0);
+ });
+
+ it('notification should show with type success', done => {
+ store.dispatch({type: NotificationConstants.NOTIFY_SUCCESS, data: {title, msg}});
+ setTimeout(()=> {
+ expect(store.getState().notification).toExist();
+ expect(store.getState().notification.type).toBe('success');
+ done();
+ }, 0);
+ });
+
+ it('notification should show with type success with connected component', done => {
+ store.dispatch({type: NotificationConstants.NOTIFY_SUCCESS, data: {title, msg}});
+ setTimeout(()=> {
+ expect(store.getState().notification).toExist();
+ expect(store.getState().notification.type).toBe('success');
+ let renderer = TestUtils.createRenderer();
+ renderer.render(<ConnectedNotificationModal store={store}/>);
+ let renderedOutput = renderer.getRenderOutput();
+ expect(renderedOutput).toExist();
+ done();
+ }, 0);
+ });
+
+ it('notification should hide with connected component', done => {
+ setTimeout(()=> {
+ expect(store.getState().notification).toNotExist();
+ let renderer = TestUtils.createRenderer();
+ renderer.render(<ConnectedNotificationModal store={store}/>);
+ let renderedOutput = renderer.getRenderOutput();
+ expect(renderedOutput).toExist();
+ done();
+ }, 0);
+ store.dispatch({type: NotificationConstants.NOTIFY_CLOSE});
+ });
+
+ it('notification should hide', done => {
+ store.dispatch({type: NotificationConstants.NOTIFY_CLOSE});
+ setTimeout(()=> {
+ expect(store.getState().notification).toNotExist();
+ done();
+ }, 0);
+ });
+
+ it('NotificationModal should not render', ()=> {
+ let renderer = TestUtils.createRenderer();
+ renderer.render(<NotificationModal show={false} title={title} msg={msg} type='error'/>);
+ let renderedOutput = renderer.getRenderOutput();
+ expect(renderedOutput).toExist();
+ });
+
+ it('NotificationModal basic default render', ()=> {
+ expect(window.document).toExist();
+ let document = TestUtils.renderIntoDocument(
+ <NotificationModal show={true} title={title} msg={msg} type='default' onCloseClick={()=>{}}/>
+ );
+ var result = TestUtils.findAllInRenderedTree(document, element => element.props.className === 'notification-modal primary');
+ expect(result.length).toBeGreaterThan(0);
+ });
+
+ it('NotificationModal basic error render', ()=> {
+ expect(window.document).toExist();
+ let document = TestUtils.renderIntoDocument(
+ <NotificationModal show={true} title={title} msg={msg} type='error' onCloseClick={()=>{}}/>
+ );
+ var result = TestUtils.findAllInRenderedTree(document, element => element.props.className === 'notification-modal danger');
+ expect(result.length).toBeGreaterThan(0);
+ });
+
+ it('NotificationModal basic warning render', ()=> {
+ expect(window.document).toExist();
+ let document = TestUtils.renderIntoDocument(
+ <NotificationModal show={true} title={title} msg={msg} type='warning' onCloseClick={()=>{}}/>
+ );
+ var result = TestUtils.findAllInRenderedTree(document, element => element.props.className === 'notification-modal warning');
+ expect(result.length).toBeGreaterThan(0);
+ });
+
+ it('NotificationModal basic success render', ()=> {
+ expect(window.document).toExist();
+ let document = TestUtils.renderIntoDocument(
+ <NotificationModal show={true} title={title} msg={msg} type='success' onCloseClick={()=>{}}/>
+ );
+ var result = TestUtils.findAllInRenderedTree(document, element => element.props.className === 'notification-modal success');
+ expect(result.length).toBeGreaterThan(0);
+ });
+});
diff --git a/openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js b/openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js
new file mode 100644
index 0000000000..9ab18137cf
--- /dev/null
+++ b/openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js
@@ -0,0 +1,44 @@
+/*-
+ * ============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 VersionController from 'nfvo-components/panel/versionController/VersionController.jsx';
+import {actionsEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
+
+describe('versionController UI Component', () => {
+
+ it('function does exist', () => {
+ var renderer = TestUtils.createRenderer();
+ renderer.render(<VersionController isCheckedOut={false} status={'OUT'} />);
+ var renderedOutput = renderer.getRenderOutput();
+ expect(renderedOutput).toExist();
+ });
+
+ it('validating checkin function', () => {
+
+ let versionController = TestUtils.renderIntoDocument(<VersionController isCheckedOut={false} status={'OUT'} onSave={()=>{return Promise.resolve();}}/>);
+ let cb = action => expect(action).toBe(actionsEnum.CHECK_IN);
+ versionController.checkin(cb);
+
+ });
+
+});
diff --git a/openecomp-ui/test/nfvo-components/panel/VersionController/versionControllerUtils.test.js b/openecomp-ui/test/nfvo-components/panel/VersionController/versionControllerUtils.test.js
new file mode 100644
index 0000000000..0e4a92118e
--- /dev/null
+++ b/openecomp-ui/test/nfvo-components/panel/VersionController/versionControllerUtils.test.js
@@ -0,0 +1,172 @@
+/*-
+ * ============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 Configuration from 'sdc-app/config/Configuration.js';
+import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js';
+import {statusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
+
+const status = 'testStatus';
+
+describe('versionController UI Component', () => {
+
+ it('function does exist', () => {
+ expect(VersionControllerUtils).toExist();
+ });
+
+ it('validating getCheckOutStatusKindByUserID - without "UserID"', () => {
+ var result = VersionControllerUtils.getCheckOutStatusKindByUserID(status);
+ expect(result.status).toBe(status);
+ expect(result.isCheckedOut).toBe(true);
+ });
+
+ it('validating getCheckOutStatusKindByUserID - without "UserID" with locking user', () => {
+ var result = VersionControllerUtils.getCheckOutStatusKindByUserID(status, 'locking user');
+ expect(result.status).toBe(statusEnum.LOCK_STATUS);
+ expect(result.isCheckedOut).toBe(false);
+ });
+
+ it('validating getCheckOutStatusKindByUserID - with "UserID" with configuration set', () => {
+ const userId = 'att';
+
+ Configuration.set('ATTUserID', userId);
+ var result = VersionControllerUtils.getCheckOutStatusKindByUserID(status, userId);
+ Configuration.set('ATTUserID', undefined);
+
+ expect(result.status).toBe(status);
+ expect(result.isCheckedOut).toBe(true);
+ });
+
+
+
+ it('validating isCheckedOutByCurrentUser - when resource is not checked out', () => {
+ const currentUser = 'current';
+ const resource = deepFreeze({
+ version: '0.6',
+ viewableVersions: ['0.1', '0.2', '0.3', '0.4', '0.5', '0.6'],
+ status: 'Final'
+ });
+
+ Configuration.set('ATTUserID', currentUser);
+ const result = VersionControllerUtils.isCheckedOutByCurrentUser(resource);
+ Configuration.set('ATTUserID', undefined);
+
+ expect(result).toBe(false);
+ });
+
+ it('validating isCheckedOutByCurrentUser - when resource is checked out', () => {
+ const currentUser = 'current';
+ const resource = deepFreeze({
+ version: '0.6',
+ viewableVersions: ['0.1', '0.2', '0.3', '0.4', '0.5', '0.6'],
+ status: 'Locked',
+ lockingUser: 'current'
+ });
+
+ Configuration.set('ATTUserID', currentUser);
+ const result = VersionControllerUtils.isCheckedOutByCurrentUser(resource);
+ Configuration.set('ATTUserID', undefined);
+
+ expect(result).toBe(true);
+ });
+
+ it('validating isCheckedOutByCurrentUser - when resource is checked out by another user', () => {
+ const currentUser = 'current';
+ const resource = deepFreeze({
+ version: '0.6',
+ viewableVersions: ['0.1', '0.2', '0.3', '0.4', '0.5', '0.6'],
+ status: 'Locked',
+ lockingUser: 'another'
+ });
+
+ Configuration.set('ATTUserID', currentUser);
+ const result = VersionControllerUtils.isCheckedOutByCurrentUser(resource);
+ Configuration.set('ATTUserID', undefined);
+
+ expect(result).toBe(false);
+ });
+
+
+
+ it('validating isReadOnly - when resource is not checked out', () => {
+ const currentUser = 'current';
+ const resource = deepFreeze({
+ version: '0.6',
+ viewableVersions: ['0.1', '0.2', '0.3', '0.4', '0.5', '0.6'],
+ status: 'Final'
+ });
+
+ Configuration.set('ATTUserID', currentUser);
+ const result = VersionControllerUtils.isReadOnly(resource);
+ Configuration.set('ATTUserID', undefined);
+
+ expect(result).toBe(true);
+ });
+
+ it('validating isReadOnly - when resource is checked out', () => {
+ const currentUser = 'current';
+ const resource = deepFreeze({
+ version: '0.6',
+ viewableVersions: ['0.1', '0.2', '0.3', '0.4', '0.5', '0.6'],
+ status: 'Locked',
+ lockingUser: 'current'
+ });
+
+ Configuration.set('ATTUserID', currentUser);
+ const result = VersionControllerUtils.isReadOnly(resource);
+ Configuration.set('ATTUserID', undefined);
+
+ expect(result).toBe(false);
+ });
+
+ it('validating isReadOnly - when version of resource is not latest', () => {
+ const currentUser = 'current';
+ const resource = deepFreeze({
+ version: '0.2',
+ viewableVersions: ['0.1', '0.2', '0.3', '0.4', '0.5', '0.6'],
+ status: 'Locked',
+ lockingUser: 'current'
+ });
+
+ Configuration.set('ATTUserID', currentUser);
+ const result = VersionControllerUtils.isReadOnly(resource);
+ Configuration.set('ATTUserID', undefined);
+
+ expect(result).toBe(true);
+ });
+
+ it('validating isReadOnly - when resource is checked out by another user', () => {
+ const currentUser = 'current';
+ const resource = deepFreeze({
+ version: '0.6',
+ viewableVersions: ['0.1', '0.2', '0.3', '0.4', '0.5', '0.6'],
+ status: 'Locked',
+ lockingUser: 'another'
+ });
+
+ Configuration.set('ATTUserID', currentUser);
+ const result = VersionControllerUtils.isReadOnly(resource);
+ Configuration.set('ATTUserID', undefined);
+
+ expect(result).toBe(true);
+ });
+});
+
diff --git a/openecomp-ui/test/setup.test.js b/openecomp-ui/test/setup.test.js
new file mode 100644
index 0000000000..72f8b954b8
--- /dev/null
+++ b/openecomp-ui/test/setup.test.js
@@ -0,0 +1,25 @@
+/*-
+ * ============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 mockRest from 'test-utils/MockRest.js';
+
+beforeEach(function() {
+ mockRest.resetQueue();
+});
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);
+ });
+});
+
diff --git a/openecomp-ui/test/utils/errorResponseHandler.test.js b/openecomp-ui/test/utils/errorResponseHandler.test.js
new file mode 100644
index 0000000000..fd9dec6a8d
--- /dev/null
+++ b/openecomp-ui/test/utils/errorResponseHandler.test.js
@@ -0,0 +1,135 @@
+/*-
+ * ============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 deepFreeze from 'deep-freeze';
+import expect from 'expect';
+import {cloneAndSet} from '../../test-utils/Util.js';
+import store from 'sdc-app/AppStore.js';
+import errorResponseHandler from 'nfvo-utils/ErrorResponseHandler.js';
+
+describe('Error Response Handler Util', () => {
+
+ beforeEach(function () {
+ deepFreeze(store.getState());
+ });
+
+ it('validating error in policyException', done => {
+ let textStatus = '', errorThrown = '';
+ let xhr = {
+ responseJSON: {
+ requestError: {
+ policyException: {
+ messageId: 'SVC4122',
+ text: 'Error: Invalid data.'
+ }
+ }
+ }
+ };
+ deepFreeze(xhr);
+
+ const errorNotification = {
+ type: 'error', title: 'Error: SVC4122', msg: 'Error: Invalid data.', timeout: undefined,
+ validationResponse: undefined
+ };
+ const expectedStore = cloneAndSet(store.getState(), 'notification', errorNotification);
+
+ errorResponseHandler(xhr, textStatus, errorThrown);
+
+ setTimeout(function () {
+ expect(store.getState()).toEqual(expectedStore);
+ done();
+ }, 100);
+ });
+
+ it('validating error in serviceException with variables', done => {
+ let textStatus = '', errorThrown = '';
+ let xhr = {
+ responseJSON: {
+ requestError: {
+ serviceException: {
+ messageId: 'SVC4122',
+ text: "Error: Invalid artifact type '%1'.",
+ variables: ['newType']
+ }
+ }
+ }
+ };
+ deepFreeze(xhr);
+
+ const errorNotification = {
+ type: 'error', title: 'Error: SVC4122', msg: 'Error: Invalid artifact type newType.', timeout: undefined,
+ validationResponse: undefined
+ };
+ const expectedStore = cloneAndSet(store.getState(), 'notification', errorNotification);
+
+ errorResponseHandler(xhr, textStatus, errorThrown);
+
+ setTimeout(function () {
+ expect(store.getState()).toEqual(expectedStore);
+ done();
+ }, 100);
+ });
+
+ it('validating error in response', done => {
+ let textStatus = '', errorThrown = '';
+ let xhr = {
+ responseJSON: {
+ status: 'AA',
+ message: 'Error: Invalid data.'
+ }
+ };
+ deepFreeze(xhr);
+
+ const errorNotification = {
+ type: 'error', title: 'AA', msg: 'Error: Invalid data.', timeout: undefined,
+ validationResponse: undefined
+ };
+ const expectedStore = cloneAndSet(store.getState(), 'notification', errorNotification);
+
+ errorResponseHandler(xhr, textStatus, errorThrown);
+
+ setTimeout(function () {
+ expect(store.getState()).toEqual(expectedStore);
+ done();
+ }, 100);
+ });
+
+ it('validating error in request', done => {
+ let textStatus = '', errorThrown = '';
+ let xhr = {
+ statusText: '500',
+ responseText: 'Internal server error.'
+ };
+ deepFreeze(xhr);
+
+ const errorNotification = {
+ type: 'error', title: '500', msg: 'Internal server error.', timeout: undefined,
+ validationResponse: undefined
+ };
+ const expectedStore = cloneAndSet(store.getState(), 'notification', errorNotification);
+
+ errorResponseHandler(xhr, textStatus, errorThrown);
+
+ setTimeout(function () {
+ expect(store.getState()).toEqual(expectedStore);
+ done();
+ }, 100);
+ });
+});
diff --git a/openecomp-ui/test/utils/restApiUtil.test.js b/openecomp-ui/test/utils/restApiUtil.test.js
new file mode 100644
index 0000000000..2a5e69b02e
--- /dev/null
+++ b/openecomp-ui/test/utils/restApiUtil.test.js
@@ -0,0 +1,149 @@
+/*-
+ * ============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 $ from 'jquery';
+import RestAPIUtil, {makeQueryParams} from 'src/nfvo-utils/RestAPIUtil';
+
+const URL = 'http://bla.ble.blu/';
+
+describe('RestAPIUtil Util class', () => {
+
+ beforeEach(()=> {
+ $.ajax = (options) => options;
+ });
+
+ it('RestAPIUtil does exist', () => {
+ expect(RestAPIUtil).toExist();
+ });
+
+ it('RestAPIUtil makeQueryParams does exist', () => {
+ expect(makeQueryParams).toExist();
+ });
+
+ it('RestAPIUtil makeQueryParams params', () => {
+ const pageStart = 1, pageSize = 25;
+ const response = makeQueryParams({pagination: {pageStart, pageSize}});
+ expect(response.pageStart).toBe(pageStart);
+ expect(response.pageSize).toBe(pageSize);
+ });
+
+ it('normal basic fetch', () => {
+ const response = RestAPIUtil.fetch(URL);
+ expect(response).toExist();
+ });
+
+ it('no url', function () {
+ expect(function () {
+ RestAPIUtil.fetch();
+ }).toThrow(/url/);
+ });
+
+ it('fetch with pagination', () => {
+ const pageStart = 1, pageSize = 25;
+ const response = RestAPIUtil.fetch(URL, {pagination: {pageStart, pageSize}});
+ expect(response.pagination).toExist();
+ expect(response.url).toInclude(`?pageStart=${pageStart}&pageSize=${pageSize}`);
+ });
+
+ it('fetch with sorting', () => {
+ const sortField = 'name', sortDir = 'ASCENDING';
+ const response = RestAPIUtil.fetch(URL, {sorting: {sortField, sortDir}});
+ expect(response.sorting).toExist();
+ expect(response.url).toInclude(`?sortField=${sortField}&sortDir=${sortDir}`);
+ });
+
+ it('fetch with filtering', () => {
+ const baseFilter = [
+ {
+ criterionValue: 'service',
+ fieldName: 'Brand',
+ operator: 'EQUALS',
+ type: 'STRING'
+ },
+ {
+ criterionValue: 'resource',
+ fieldName: 'Brand',
+ operator: 'EQUALS',
+ type: 'STRING'
+ }
+ ];
+ const response = RestAPIUtil.fetch(URL, {filtering: {filterCriteria: baseFilter, logicalRelation: 'OR'}});
+ expect(response.filtering).toExist();
+ expect(response.url).toInclude('?filter=');
+ });
+
+ it('fetch with qParams', () => {
+ const response = RestAPIUtil.fetch(URL, {qParams: {pageStart: 1, pageSize: 10}});
+ expect(response.qParams).toExist();
+ });
+
+ it('fetch with url on options', () => {
+ const response = RestAPIUtil.fetch(URL, {url:'12345', qParams: {pageStart: 1, pageSize: 10}});
+ expect(response.qParams).toExist();
+ });
+
+ it('fetch with url path param', () => {
+ let someData = 'data';
+ const response = RestAPIUtil.fetch(`${URL}{someData}/`, {params: {someData}});
+ expect(response.url).toInclude(`/${someData}/`);
+ });
+
+ it('fetch with url undefined path param', () => {
+ const response = RestAPIUtil.fetch(`${URL}{someData}/`, {params: {someData: undefined}});
+ expect(response.url).toInclude('/undefined/');
+ });
+
+ it('normal basic create', () => {
+ const response = RestAPIUtil.create(URL);
+ expect(response).toExist();
+ });
+
+ it('create with FormData', () => {
+ let formData = new FormData();
+ formData.append('username', 'Chris');
+ const response = RestAPIUtil.create(URL, formData);
+ expect(response).toExist();
+ });
+
+ it('create with FormData with md5', () => {
+ let formData = new FormData();
+ formData.append('username', 'Chris');
+ const response = RestAPIUtil.create(URL, formData, {md5: true});
+ expect(response).toExist();
+ });
+
+ it('create with file', () => {
+ let progressCallback = () => {};
+ const response = RestAPIUtil.create(URL, {}, {progressCallback, fileSize: 123});
+ expect(response).toExist();
+ });
+
+ it('normal basic save', () => {
+ const response = RestAPIUtil.save(URL);
+ expect(response).toExist();
+ });
+
+ it('normal basic delete', () => {
+ const response = RestAPIUtil.destroy(URL);
+ expect(response).toExist();
+ });
+
+});
diff --git a/openecomp-ui/test/utils/uuid.test.js b/openecomp-ui/test/utils/uuid.test.js
new file mode 100644
index 0000000000..cd55baadea
--- /dev/null
+++ b/openecomp-ui/test/utils/uuid.test.js
@@ -0,0 +1,52 @@
+/*-
+ * ============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 uuid from 'src/nfvo-utils/UUID.js';
+import expect from 'expect';
+
+describe('UUID', () => {
+
+ it('function does exist', () => {
+ expect(uuid).toExist();
+ });
+
+ it('generate UUID synchronously', () => {
+ let result = uuid(undefined, true);
+ expect(result).toExist();
+ });
+
+ it('generate UUID synchronously with number', () => {
+ let result = uuid(5, true);
+ expect(result).toExist();
+ });
+
+ it('generate UUID synchronously with number', () => {
+ let result = uuid(1, true);
+ expect(result).toExist();
+ });
+
+ it('generate UUID asynchronously', done => {
+ uuid().then(result => {
+ expect(result).toExist();
+ done();
+ });
+ });
+
+});