diff options
Diffstat (limited to 'openecomp-ui/test/softwareProduct/components')
13 files changed, 553 insertions, 717 deletions
diff --git a/openecomp-ui/test/softwareProduct/components/compute/test.js b/openecomp-ui/test/softwareProduct/components/compute/test.js index 925de302b8..8d2d1fbb2f 100644 --- a/openecomp-ui/test/softwareProduct/components/compute/test.js +++ b/openecomp-ui/test/softwareProduct/components/compute/test.js @@ -1,24 +1,19 @@ -/*- - * ============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 - * + * + * 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========================================================= + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. */ -import expect from 'expect'; import deepFreeze from 'deep-freeze'; import mockRest from 'test-utils/MockRest.js'; import {cloneAndSet} from 'test-utils/Util.js'; @@ -26,14 +21,18 @@ 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'; +import {default as VSPComponentsComputeFactory, VSPComponentsComputeDataMapFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsComputeFactory.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; + const softwareProductId = '123'; const vspComponentId = '111'; +const version = VersionControllerUtilsFactory.build().version; describe('Software Product Components Compute Module Tests', function () { let restPrefix = ''; - before(function() { + beforeAll(function() { restPrefix = Configuration.get('restPrefix'); deepFreeze(restPrefix); }); @@ -42,28 +41,32 @@ describe('Software Product Components Compute Module Tests', function () { const store = storeCreator(); deepFreeze(store.getState()); + const compute = VSPComponentsComputeFactory.build(); + const dataMap = VSPComponentsComputeDataMapFactory.build(); + const softwareProductComponentCompute = { - data: JSON.stringify({'vmSizing':{'numOfCPUs':'3','fileSystemSizeGB':'888'},'numOfVMs':{'minimum':'2'}}), - schema: JSON.stringify({'vmSizing':{'numOfCPUs':'3','fileSystemSizeGB':'888'},'numOfVMs':{'minimum':'2'}}) + data: JSON.stringify(compute), + schema: JSON.stringify(compute) }; deepFreeze(softwareProductComponentCompute); const softwareProductComponentComputeData = { - qdata: JSON.parse(softwareProductComponentCompute.data), - qschema: JSON.parse(softwareProductComponentCompute.schema) + qdata: compute, + dataMap, + qgenericFieldInfo: {} }; 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(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/questionnaire`); expect(data).toEqual(undefined); expect(options).toEqual(undefined); return softwareProductComponentCompute; }); - return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, vspComponentId}).then(() => { + return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, version, vspComponentId}).then(() => { expect(store.getState()).toEqual(expectedStore); }); }); @@ -72,61 +75,33 @@ describe('Software Product Components Compute Module Tests', function () { const store = storeCreator(); deepFreeze(store.getState()); + const compute = VSPComponentsComputeFactory.build(); + const softwareProductComponentQuestionnaire = { data: null, - schema: JSON.stringify({'vmSizing':{'numOfCPUs':'3','fileSystemSizeGB':'888'},'numOfVMs':{'minimum':'2'}}) + schema: JSON.stringify(compute) }; deepFreeze(softwareProductComponentQuestionnaire); const softwareProductComponentQuestionnaireData = { qdata: {}, - qschema: JSON.parse(softwareProductComponentQuestionnaire.schema) + dataMap: {}, + qgenericFieldInfo: {} }; 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(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/questionnaire`); expect(data).toEqual(undefined); expect(options).toEqual(undefined); return softwareProductComponentQuestionnaire; }); - return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, vspComponentId}).then(() => { + return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, version, 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 index ce2152b29b..4f6512ad15 100644 --- a/openecomp-ui/test/softwareProduct/components/general/SoftwareProductComponentsGeneral.test.js +++ b/openecomp-ui/test/softwareProduct/components/general/SoftwareProductComponentsGeneral.test.js @@ -1,113 +1,73 @@ -/*- - * ============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 - * + * + * 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========================================================= + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. */ -import 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'; +//import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; + +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; +import {VSPComponentsVersionControllerFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js'; +import {SoftwareProductFactory} from 'test-utils/factories/softwareProduct/SoftwareProductFactory.js'; +import VSPQSchemaFactory from 'test-utils/factories/softwareProduct/SoftwareProductQSchemaFactory.js'; describe('SoftwareProductComponentsGeneral Mapper and View Classes', () => { it('mapStateToProps mapper exists', () => { - expect(mapStateToProps).toExist(); + expect(mapStateToProps).toBeTruthy(); }); 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 currentSoftwareProduct = VSPEditorFactory.build(); var obj = { - softwareProduct: { + softwareProduct: SoftwareProductFactory.build({ softwareProductEditor: { data: currentSoftwareProduct }, softwareProductComponents: { componentEditor: { data: {}, - qdata: {}, - qschema: {} + qdata: {} } } - } + }) }; var results = mapStateToProps(obj); - expect(results.componentData).toExist(); - expect(results.qdata).toExist(); - expect(results.qschema).toExist(); + expect(results.componentData).toBeTruthy(); + expect(results.qdata).toBeTruthy(); }); 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 currentSoftwareProduct = VSPEditorFactory.build(); const softwareProductComponents = { componentEditor: { data: {}, qdata: {}, - qschema: { - $schema: 'http://json-schema.org/draft-04/schema#', - type: 'object', - properties: { - general: { - type: 'object', - properties: {} - } - } - } + qschema: VSPQSchemaFactory.build() } }; - const versionControllerData = { - version: '1', - viewableVersions: [], - status: 'locked', - isCheckedOut: true - }; + const versionControllerData = VSPComponentsVersionControllerFactory.build(); const componentData = { name: '', @@ -122,7 +82,7 @@ describe('SoftwareProductComponentsGeneral Mapper and View Classes', () => { versionControllerData={versionControllerData} currentSoftwareProduct={currentSoftwareProduct}/>); var renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); }); diff --git a/openecomp-ui/test/softwareProduct/components/loadBalancing/softwareProductComponentLoadbalancing.test.js b/openecomp-ui/test/softwareProduct/components/loadBalancing/softwareProductComponentLoadbalancing.test.js index 69a93b69e1..0ee9c76961 100644 --- a/openecomp-ui/test/softwareProduct/components/loadBalancing/softwareProductComponentLoadbalancing.test.js +++ b/openecomp-ui/test/softwareProduct/components/loadBalancing/softwareProductComponentLoadbalancing.test.js @@ -1,110 +1,69 @@ -/*- - * ============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 - * + * + * 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========================================================= + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. */ -import 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'; + +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; +import {SoftwareProductFactory} from 'test-utils/factories/softwareProduct/SoftwareProductFactory.js'; +import {VSPComponentsVersionControllerFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js'; +import VSPQSchemaFactory from 'test-utils/factories/softwareProduct/SoftwareProductQSchemaFactory.js'; describe('SoftwareProductComponentLoadBalancing Mapper and View Classes', () => { it('mapStateToProps mapper exists', () => { - expect(mapStateToProps).toExist(); + expect(mapStateToProps).toBeTruthy(); }); 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 currentSoftwareProduct = VSPEditorFactory.build(); var obj = { - softwareProduct: { + softwareProduct: SoftwareProductFactory.build({ softwareProductEditor: { data: currentSoftwareProduct }, softwareProductComponents: { componentEditor: { - qdata: {}, - qschema: {} + qdata: {} } } - } + }) }; var results = mapStateToProps(obj); - expect(results.qdata).toExist(); - expect(results.qschema).toExist(); + expect(results.qdata).toBeTruthy(); }); 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 currentSoftwareProduct = VSPEditorFactory.build(); const softwareProductComponents = { componentEditor: { qdata: {}, - qschema: { - $schema: 'http://json-schema.org/draft-04/schema#', - type: 'object', - properties: { - general: { - type: 'object', - properties: {} - } - } - } + qschema: VSPQSchemaFactory.build() } }; - const versionControllerData = { - version: '1', - viewableVersions: [], - status: 'locked', - isCheckedOut: true - }; + const versionControllerData = VSPComponentsVersionControllerFactory.build(); var renderer = TestUtils.createRenderer(); renderer.render( @@ -115,7 +74,7 @@ describe('SoftwareProductComponentLoadBalancing Mapper and View Classes', () => softwareProductId='123' componentId='321'/>); var renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); }); diff --git a/openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js b/openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js index 2f1ea12c01..24658f1b30 100644 --- a/openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js +++ b/openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js @@ -1,57 +1,53 @@ -/*- - * ============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 - * + * + * 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========================================================= + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. */ -import 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'; +import {VSPComponentsMonitoringViewFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsMonitoringFactories.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; + +const version = VersionControllerUtilsFactory.build(); + describe('SoftwareProductComponentsMonitoring Module Tests', function () { it('should mapper exist', () => { - expect(mapStateToProps).toExist(); + expect(mapStateToProps).toBeTruthy(); }); it('should return empty file names', () => { - let softwareProduct = {softwareProductEditor: {data: {}}, softwareProductComponents: {monitoring: {}}}; + let softwareProduct = {softwareProductEditor: {data: {...version}}, 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}}; + const monitoring = VSPComponentsMonitoringViewFactory.build({}, {snmpTrapFlag: true}); + let softwareProduct = {softwareProductEditor: {data: {...version}}, 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}}; + const monitoring = VSPComponentsMonitoringViewFactory.build({}, {snmpPollFlag: true}); + let softwareProduct = {softwareProductEditor: {data: {...version}}, softwareProductComponents: {monitoring}}; var results = mapStateToProps({softwareProduct}); expect(results.trapFilename).toEqual(undefined); expect(results.pollFilename).toEqual(monitoring.pollFilename); @@ -59,15 +55,12 @@ describe('SoftwareProductComponentsMonitoring Module Tests', function () { let renderer = TestUtils.createRenderer(); renderer.render(<SoftwareProductComponentsMonitoringView {...results} />); let renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); }); it('should return both file names', () => { - const monitoring = { - trapFilename: '1234', - trapFilename: '123' - }; - let softwareProduct = {softwareProductEditor: {data: {}}, softwareProductComponents: {monitoring}}; + const monitoring = VSPComponentsMonitoringViewFactory.build({}, {snmpTrapFlag: true, snmpPollFlag: true}); + let softwareProduct = {softwareProductEditor: {data: {...version}}, softwareProductComponents: {monitoring}}; var results = mapStateToProps({softwareProduct}); expect(results.trapFilename).toEqual(monitoring.trapFilename); expect(results.pollFilename).toEqual(monitoring.pollFilename); @@ -75,7 +68,7 @@ describe('SoftwareProductComponentsMonitoring Module Tests', function () { let renderer = TestUtils.createRenderer(); renderer.render(<SoftwareProductComponentsMonitoringView {...results} />); let renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); }); it('should change state to dragging', done => { diff --git a/openecomp-ui/test/softwareProduct/components/monitoring/test.js b/openecomp-ui/test/softwareProduct/components/monitoring/test.js index 172db653e9..dd0f850a89 100644 --- a/openecomp-ui/test/softwareProduct/components/monitoring/test.js +++ b/openecomp-ui/test/softwareProduct/components/monitoring/test.js @@ -1,31 +1,30 @@ -/*- - * ============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 - * + * + * 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========================================================= + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. */ -import 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'; +import {VSPComponentsMonitoringRestFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsMonitoringFactories.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; + const softwareProductId = '123'; const componentId = '123'; +const version = VersionControllerUtilsFactory.build().version; describe('Software Product Components Monitoring Module Tests', function () { @@ -38,18 +37,16 @@ describe('Software Product Components Monitoring Module Tests', function () { it('Fetch for existing files - no files', done => { - let emptyResult = Object.freeze({ - snmpTrap: undefined, - snmpPoll: undefined - }); + let emptyResult = VSPComponentsMonitoringRestFactory.build(); mockRest.addHandler('fetch', ({ baseUrl}) => { - expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp`); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp`); return emptyResult; }); SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, { softwareProductId, + version, componentId }); setTimeout(()=> { @@ -62,18 +59,16 @@ describe('Software Product Components Monitoring Module Tests', function () { }); it('Fetch for existing files - only snmp trap file exists', done => { - let response = Object.freeze({ - snmpTrap: 'asdfasdf', - snmpPoll: undefined - }); + let response = VSPComponentsMonitoringRestFactory.build({}, {snmpTrapFlag: true}); mockRest.addHandler('fetch', ({ baseUrl}) => { - expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp`); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp`); return response; }); SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, { softwareProductId, + version, componentId }); setTimeout(()=> { @@ -85,18 +80,16 @@ describe('Software Product Components Monitoring Module Tests', function () { }); it('Fetch for existing files - only snmp poll file exists', done => { - let response = Object.freeze({ - snmpPoll: 'asdfasdf', - snmpTrap: undefined - }); + let response = VSPComponentsMonitoringRestFactory.build({}, {snmpPollFlag: true}); mockRest.addHandler('fetch', ({baseUrl}) => { - expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp`); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp`); return response; }); SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, { softwareProductId, + version, componentId }); setTimeout(()=> { @@ -108,18 +101,16 @@ describe('Software Product Components Monitoring Module Tests', function () { }); it('Fetch for existing files - both files exist', done => { - let response = Object.freeze({ - snmpPoll: 'asdfasdf', - snmpTrap: 'asdfgg' - }); + let response = VSPComponentsMonitoringRestFactory.build({}, {snmpTrapFlag: true, snmpPollFlag: true}); mockRest.addHandler('fetch', ({baseUrl}) => { - expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp`); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp`); return response; }); SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, { softwareProductId, + version, componentId }); setTimeout(()=> { @@ -132,8 +123,8 @@ describe('Software Product Components Monitoring Module Tests', function () { 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`); + mockRest.addHandler('post', ({baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp-trap/upload`); return {}; }); var debug = {hello: 'world'}; @@ -142,6 +133,7 @@ describe('Software Product Components Monitoring Module Tests', function () { formData.append('upload', file); SoftwareProductComponentsMonitoringActionHelper.uploadSnmpFile(store.dispatch, { softwareProductId, + version, componentId, formData, fileSize: file.size, @@ -156,8 +148,8 @@ describe('Software Product Components Monitoring Module Tests', function () { }); 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`); + mockRest.addHandler('post', ({baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp/upload`); return {}; }); var debug = {hello: 'world'}; @@ -166,6 +158,7 @@ describe('Software Product Components Monitoring Module Tests', function () { formData.append('upload', file); SoftwareProductComponentsMonitoringActionHelper.uploadSnmpFile(store.dispatch, { softwareProductId, + version, componentId, formData, fileSize: file.size, @@ -181,11 +174,12 @@ describe('Software Product Components Monitoring Module Tests', function () { 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`); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp-trap`); return {}; }); SoftwareProductComponentsMonitoringActionHelper.deleteSnmpFile(store.dispatch, { softwareProductId, + version, componentId, type: SoftwareProductComponentsMonitoringConstants.SNMP_TRAP }); @@ -198,11 +192,12 @@ describe('Software Product Components Monitoring Module Tests', function () { 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`); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp`); return {}; }); SoftwareProductComponentsMonitoringActionHelper.deleteSnmpFile(store.dispatch, { softwareProductId, + version, componentId, type: SoftwareProductComponentsMonitoringConstants.SNMP_POLL }); diff --git a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNICEditor.test.js b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNICEditor.test.js index c9760f7799..094b95a091 100644 --- a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNICEditor.test.js +++ b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNICEditor.test.js @@ -1,55 +1,42 @@ -/*- - * ============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 - * + * + * 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========================================================= + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. */ -import 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'; - +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; +import {SoftwareProductFactory} from 'test-utils/factories/softwareProduct/SoftwareProductFactory.js'; +import {VSPComponentsNicFactory, VSPComponentsNetworkQDataFactory, VSPComponentsNicFactoryQGenericFieldInfo, + VSPComponentsNicFactoryGenericFieldInfo, VSPComponentsNetworkDataMapFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js'; describe('Software Product Component Network NIC Editor and View Classes', () => { it('mapStateToProps mapper exists', () => { - expect(mapStateToProps).toExist(); + expect(mapStateToProps).toBeTruthy(); }); 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' - }; + const currentSoftwareProduct = VSPEditorFactory.build(); var obj = { - softwareProduct: { + softwareProduct: SoftwareProductFactory.build({ softwareProductEditor: { data: currentSoftwareProduct }, @@ -58,40 +45,42 @@ describe('Software Product Component Network NIC Editor and View Classes', () => nicEditor: { data: {}, qdata: {}, - qschema: {} + dataMap: {}, + qgenericFieldInfo: {}, + genericFieldInfo: {} } } } - } + }) }; var results = mapStateToProps(obj); - expect(results.currentSoftwareProduct).toExist(); - expect(results.qdata).toExist(); - expect(results.qschema).toExist(); - expect(results.data).toExist(); + expect(results.currentSoftwareProduct).toBeTruthy(); + expect(results.qdata).toBeTruthy(); + expect(results.dataMap).toBeTruthy(); + expect(results.genericFieldInfo).toBeTruthy(); + expect(results.qgenericFieldInfo).toBeTruthy(); + expect(results.data).toBeTruthy(); }); it('Software Product Component Network NIC Editor View Test', () => { - const data = { - name: '', - description: '', - networkName: '' + const props = { + data: VSPComponentsNicFactory.build(), + qdata: VSPComponentsNetworkQDataFactory.build(), + dataMap: VSPComponentsNetworkDataMapFactory.build(), + genericFieldInfo: VSPComponentsNicFactoryGenericFieldInfo.build(), + qgenericFieldInfo: VSPComponentsNicFactoryQGenericFieldInfo.build(), + isFormValid: true, + formReady: false, + protocols: [] }; - const qdata = {}; - const qschema = {}; - var renderer = TestUtils.createRenderer(); - renderer.render( - <SoftwareProductComponentsNICEditorView - data={data} - qdata={qdata} - qschema={qschema}/>); + renderer.render(<SoftwareProductComponentsNICEditorView {...props}/>); var renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); }); }); diff --git a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetwork.test.js b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetwork.test.js index 520fde7403..d35659c93b 100644 --- a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetwork.test.js +++ b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetwork.test.js @@ -1,110 +1,75 @@ -/*- - * ============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 - * + * + * 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========================================================= + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. */ -import 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'; +import {SoftwareProductFactory} from 'test-utils/factories/softwareProduct/SoftwareProductFactory.js'; +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; +import {VSPComponentsNicWithIdFactory, VSPComponentsVersionControllerFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js'; describe('Software Product Component Network Mapper and View Classes', () => { it('mapStateToProps mapper exists', () => { - expect(mapStateToProps).toExist(); + expect(mapStateToProps).toBeTruthy(); }); 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 currentSoftwareProduct = VSPEditorFactory.build(); var obj = { - softwareProduct: { + softwareProduct: SoftwareProductFactory.build({ softwareProductEditor: { data: currentSoftwareProduct }, softwareProductComponents: { componentEditor: { qdata: {}, - qschema: {}, - data: {} + data: {}, + dataMap: {}, + qgenericFieldInfo: {}, + isFormValid: true, + formReady: false }, network: { nicEditor: {}, nicList: [] } } - } + }) }; var results = mapStateToProps(obj); - expect(results.qdata).toExist(); - expect(results.qschema).toExist(); - expect(results.componentData).toExist(); + expect(results.qdata).toBeTruthy(); + expect(results.dataMap).toBeTruthy(); + expect(results.qgenericFieldInfo).toBeTruthy(); + expect(results.componentData).toBeTruthy(); }); 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 currentSoftwareProduct = VSPEditorFactory.build(); - const versionControllerData = { - version: '1', - viewableVersions: [], - status: 'locked', - isCheckedOut: true - }; + const versionControllerData = VSPComponentsVersionControllerFactory.build(); - const nicList = [ - { - name: 'name', - networkId: 'network', - id: '122', - networkName: 'nname' - } - ]; + const nicList = VSPComponentsNicWithIdFactory.buildList(1); var renderer = TestUtils.createRenderer(); renderer.render( @@ -115,7 +80,7 @@ describe('Software Product Component Network Mapper and View Classes', () => { componentId='321' nicList={nicList}/>); var renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); diff --git a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js index 8c23267c89..f5a10e23c9 100644 --- a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js +++ b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js @@ -1,33 +1,33 @@ -/*- - * ============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 - * + * + * 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========================================================= + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. */ - -import {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'; +import {VSPComponentsNicFactory, VSPComponentsNetworkFactory, VSPComponentsNetworkQDataFactory, VSPComponentsNetworkDataMapFactory, VSPComponentsNicFactoryGenericFieldInfo} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; +import VSPQSchemaFactory from 'test-utils/factories/softwareProduct/SoftwareProductQSchemaFactory.js'; +import {forms} from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js'; + const softwareProductId = '123'; const componentId = '321'; const nicId = '111'; +const version = VersionControllerUtilsFactory.build().version; describe('Software Product Components Network Action Helper Tests', function () { @@ -35,23 +35,7 @@ describe('Software Product Components Network Action Helper Tests', function () 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' - } - - ]; + const NICList = VSPComponentsNicFactory.buildList(2); deepFreeze(NICList); @@ -60,14 +44,14 @@ describe('Software Product Components Network Action Helper Tests', function () 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); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); return {results: NICList}; }); - return SoftwareProductComponentsNetworkActionHelper.fetchNICsList(store.dispatch, {softwareProductId, componentId}).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + return SoftwareProductComponentsNetworkActionHelper.fetchNICsList(store.dispatch, {softwareProductId, version, componentId}).then(() => { + expect(store.getState()).toEqual(expectedStore); }); }); @@ -76,12 +60,8 @@ describe('Software Product Components Network Action Helper Tests', function () const store = storeCreator(); deepFreeze(store.getState()); - const data = { - name: 'oam01_port_0', - description: 'bbbbbbb', - networkId: 'A0E578751B284D518ED764D5378EA97C', - networkName: 'csb_net' - }; + const data = VSPComponentsNicFactory.build(); + const genericFieldInfo = VSPComponentsNicFactoryGenericFieldInfo.build(); const nic = {id: '444'}; deepFreeze(data); @@ -91,20 +71,19 @@ describe('Software Product Components Network Action Helper Tests', function () deepFreeze(expectedData); - const network = { + const network = VSPComponentsNetworkFactory.build({ nicEditor: { - data: expectedData - }, - nicList: [] - }; + data: expectedData, + formName: forms.NIC_EDIT_FORM, + genericFieldInfo + } + }); 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); + expect(store.getState()).toEqual(expectedStore); }); it('close NICE editor', () => { @@ -112,41 +91,31 @@ describe('Software Product Components Network Action Helper Tests', function () const store = storeCreator(); deepFreeze(store.getState()); - const network = { - nicEditor: {}, - nicList: [] - }; + const network = VSPComponentsNetworkFactory.build(); 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); + expect(store.getState()).toEqual(expectedStore); }); it('Load NIC data', () => { - const expectedData = { - description: 'bbbbbbb', - name: 'oam01_port_0', - networkId: 'A0E578751B284D518ED764D5378EA97C', - networkName: 'csb_net' - }; + const expectedData = VSPComponentsNicFactory.build(); 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); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics/${nicId}`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); return (expectedData); }); - return SoftwareProductComponentsNetworkActionHelper.loadNICData({softwareProductId, componentId, nicId}).then((data) => { - expect(data).to.deep.equal(expectedData); + return SoftwareProductComponentsNetworkActionHelper.loadNICData({softwareProductId, version, componentId, nicId}).then((data) => { + expect(data).toEqual(expectedData); }); }); @@ -156,119 +125,47 @@ describe('Software Product Components Network Action Helper Tests', function () 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: {} - } - } - }; + const qdata = VSPComponentsNetworkQDataFactory.build(); + const dataMap = VSPComponentsNetworkDataMapFactory.build(); + const qgenericFieldInfo = {}; + const qschema = VSPQSchemaFactory.build(); deepFreeze(qdata); + deepFreeze(dataMap); deepFreeze(qschema); - const network = { + const network = VSPComponentsNetworkFactory.build({ nicEditor: { qdata, - qschema - }, - nicList: [] - }; + dataMap, + qgenericFieldInfo + } + }); 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); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics/${nicId}/questionnaire`); + expect(data).toEqual(undefined); + expect(options).toEqual(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); + return SoftwareProductComponentsNetworkActionHelper.loadNICQuestionnaire(store.dispatch, {softwareProductId, version, componentId, nicId}).then(() => { + expect(store.getState()).toEqual(expectedStore); + expect(store.getState()).toEqual(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 qdata = VSPComponentsNetworkQDataFactory.build(); + const data = VSPComponentsNicFactory.build(); const expectedData = {...data, id: nicId}; @@ -282,22 +179,22 @@ describe('Software Product Components Network Action Helper Tests', function () 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); + mockRest.addHandler('put', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics/${nicId}/questionnaire`); + expect(data).toEqual(qdata); + expect(options).toEqual(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); + mockRest.addHandler('put', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics/${nicId}`); + expect(data).toEqual(data); + expect(options).toEqual(undefined); return {returnCode: 'OK'}; }); - return SoftwareProductComponentsNetworkActionHelper.saveNICDataAndQuestionnaire(store.dispatch, {softwareProductId, componentId, qdata, data: expectedData}).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + return SoftwareProductComponentsNetworkActionHelper.saveNICDataAndQuestionnaire(store.dispatch, {softwareProductId, version, componentId, qdata, data: expectedData}).then(() => { + expect(store.getState()).toEqual(expectedStore); }); }); diff --git a/openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesEditor.test.js b/openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesEditor.test.js new file mode 100644 index 0000000000..f3653fbcac --- /dev/null +++ b/openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesEditor.test.js @@ -0,0 +1,57 @@ +/*! + * 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. + */ + +import React from 'react'; +import TestUtils from 'react-addons-test-utils'; +import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesEditor.js'; +import SoftwareProductComponentProcessesEditorView from 'sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesEditorView.jsx'; + +describe('Software Product Components Processes Editor Module Tests', function () { + + it('should mapper exist', () => { + expect(mapStateToProps).toBeTruthy(); + }); + + it('should return empty data', () => { + + var state = { + softwareProduct: { + softwareProductComponents: { + componentProcesses: { + processesList: [], + processesEditor: {data: {}} + } + } + } + }; + + var results = mapStateToProps(state); + expect(results.data).toEqual({}); + expect(results.previousData).toEqual(undefined); + }); + + it('jsx view test', () => { + var view = TestUtils.renderIntoDocument( + <SoftwareProductComponentProcessesEditorView + isReadOnlyMode={true} + data={{name: '1', description: '1', artifactName: '1'}} + previousData={{}} + onDataChanged={() => {}} + onSubmit={() => {}} + onClose={() => {}}/>); + expect(view).toBeTruthy(); + }); +}); diff --git a/openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesView.test.js b/openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesView.test.js new file mode 100644 index 0000000000..ac866727a6 --- /dev/null +++ b/openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesView.test.js @@ -0,0 +1,77 @@ +/*! +* 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. +*/ + +import React from 'react'; +import TestUtils from 'react-addons-test-utils'; + +import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesList.js'; +import SoftwareProductComponentsProcessesView from 'sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentsProcessesListView.jsx'; + +import {VSPProcessStoreFactory} from 'test-utils/factories/softwareProduct/SoftwareProductProcessFactories.js'; +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; +import {VSPComponentsFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsFactories.js'; + +describe('SoftwareProductComponetsProcesses Mapper and View Classes', () => { + it('mapStateToProps mapper exists', () => { + expect(mapStateToProps).toBeTruthy(); + }); + + it('mapStateToProps data test', () => { + const currentSoftwareProduct = VSPEditorFactory.build(); + + const processesList = VSPProcessStoreFactory.buildList(2); + + var state = { + softwareProduct: { + softwareProductEditor: { + data: currentSoftwareProduct + }, + softwareProductComponents: { + componentProcesses: { + processesList, + processesEditor: { + data: {} + } + } + } + } + }; + var results = mapStateToProps(state); + expect(results.processesList.length).toBe(2); + }); + + it('view simple test', () => { + const currentSoftwareProduct = VSPEditorFactory.build(); + const currentSoftwareProductComponent = VSPComponentsFactory.build(); + const processesList = VSPProcessStoreFactory.buildList(2); + + var renderer = TestUtils.createRenderer(); + renderer.render( + <SoftwareProductComponentsProcessesView + processesList={processesList} + currentSoftwareProduct={currentSoftwareProduct} + softwareProductId={currentSoftwareProduct.id} + componentId={currentSoftwareProductComponent.id} + onAddProcess={() => {}} + onEditProcessClick={() => {}} + onDeleteProcessClick={() => {}} + isDisplayEditor={false} + isReadOnlyMode={false}/> + ); + var renderedOutput = renderer.getRenderOutput(); + expect(renderedOutput).toBeTruthy(); + }); +}); diff --git a/openecomp-ui/test/softwareProduct/components/processes/test.js b/openecomp-ui/test/softwareProduct/components/processes/test.js index 67427d3c05..02009e6542 100644 --- a/openecomp-ui/test/softwareProduct/components/processes/test.js +++ b/openecomp-ui/test/softwareProduct/components/processes/test.js @@ -1,51 +1,43 @@ -/*- - * ============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 - * + * + * 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========================================================= + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. */ - -import {expect} from 'chai'; import deepFreeze from 'deep-freeze'; import mockRest from 'test-utils/MockRest.js'; +import {buildFromExistingObject} from 'test-utils/Util.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'; +import { + VSPProcessStoreWithArtifactNameFactory, + VSPProcessPostFactory, + VSPProcessStoreFactory, + VSPProcessPostFactoryWithType, + VSPProcessStoreFactoryWithType} from 'test-utils/factories/softwareProduct/SoftwareProductProcessFactories.js'; + const softwareProductId = '123'; const componentId = '222'; +const versionId = '1'; +const version = {id: versionId, label: versionId}; + 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' - } - ]; + const softwareProductProcessesList = VSPProcessStoreWithArtifactNameFactory.buildList(2); deepFreeze(softwareProductProcessesList); @@ -54,25 +46,20 @@ describe('Software Product Component Processes Module Tests', function () { 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); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/components/${componentId}/processes`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); return {results: softwareProductProcessesList}; }); + - return SoftwareProductComponentProcessesActionHelper.fetchProcessesList(store.dispatch, {softwareProductId, componentId}).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + return SoftwareProductComponentProcessesActionHelper.fetchProcessesList(store.dispatch, {softwareProductId, componentId, version}).then(() => { + expect(store.getState()).toEqual(expectedStore); }); }); it('Delete Software Products Processes', () => { - const softwareProductProcessesList = [ - { - name: 'Pr1', - description: 'hjhj', - id: 'EBADF561B7FA4A788075E1840D0B5971', - artifactName: 'artifact' - } - ]; + let process = VSPProcessStoreWithArtifactNameFactory.build(); + const softwareProductProcessesList = [process]; deepFreeze(softwareProductProcessesList); const store = storeCreator({ @@ -83,15 +70,15 @@ describe('Software Product Component Processes Module Tests', function () { } }); - const processId = 'EBADF561B7FA4A788075E1840D0B5971'; + const processId = process.id; 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); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/components/${componentId}/processes/${processId}`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); return { results: { returnCode: 'OK' @@ -101,9 +88,10 @@ describe('Software Product Component Processes Module Tests', function () { return SoftwareProductComponentProcessesActionHelper.deleteProcess(store.dispatch, { process: softwareProductProcessesList[0], - softwareProductId, componentId + softwareProductId, componentId, + version }).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); @@ -112,27 +100,18 @@ describe('Software Product Component Processes Module Tests', function () { 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 softwareProductProcessAfterAdd = VSPProcessStoreFactory.build({id: softwareProductProcessFromResponse}); + const softwareProductPostRequest = buildFromExistingObject(VSPProcessPostFactory, softwareProductProcessAfterAdd); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentProcesses.processesList', [softwareProductProcessAfterAdd]); - mockRest.addHandler('create', ({data, options, baseUrl}) => { + mockRest.addHandler('post', ({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); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/components/${componentId}/processes`); + expect(data).toEqual(softwareProductPostRequest); + expect(options).toEqual(undefined); return { returnCode: 'OK', value: softwareProductProcessFromResponse @@ -143,23 +122,55 @@ describe('Software Product Component Processes Module Tests', function () { { softwareProductId, previousProcess: null, - process: softwareProductProcessToAdd, - componentId + process: softwareProductPostRequest, + componentId, + version } ).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); - it('Update Software Products Processes', () => { - const softwareProductProcessesList = [ + it('Add Software Products Processes with type', () => { + + const store = storeCreator(); + deepFreeze(store.getState()); + + const softwareProductPostRequest = VSPProcessPostFactoryWithType.build(); + + const softwareProductProcessAfterAdd = VSPProcessStoreFactoryWithType.build(softwareProductPostRequest); + const softwareProductProcessFromResponse = softwareProductProcessAfterAdd.id; + + const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentProcesses.processesList', [softwareProductProcessAfterAdd]); + + mockRest.addHandler('post', ({data, options, baseUrl}) => { + + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/components/${componentId}/processes`); + expect(data).toEqual(softwareProductPostRequest); + expect(options).toEqual(undefined); + return { + returnCode: 'OK', + value: softwareProductProcessFromResponse + }; + }); + + return SoftwareProductComponentProcessesActionHelper.saveProcess(store.dispatch, { - name: 'Pr1', - description: 'string', - id: 'EBADF561B7FA4A788075E1840D0B5971', - artifactName: 'artifact' + softwareProductId, + previousProcess: null, + process: softwareProductPostRequest, + componentId, + version } - ]; + ).then(() => { + expect(store.getState()).toEqual(expectedStore); + }); + }); + + it('Update Software Products Processes', () => { + let process = VSPProcessStoreWithArtifactNameFactory.build(); + + const softwareProductProcessesList = [process]; deepFreeze(softwareProductProcessesList); const store = storeCreator({ @@ -173,28 +184,30 @@ describe('Software Product Component Processes Module Tests', function () { }); deepFreeze(store.getState()); - const toBeUpdatedProcessId = softwareProductProcessesList[0].id; - const previousProcessData = softwareProductProcessesList[0]; - const processUpdateData = { - ...softwareProductProcessesList[0], + const toBeUpdatedProcessId = process.id; + const previousProcessData = process; + const processUpdateData = VSPProcessStoreWithArtifactNameFactory.build({ + ...process, name: 'Pr1_UPDATED', - description: 'string_UPDATED' - }; + description: 'string_UPDATED', + type: 'Other' + }); deepFreeze(processUpdateData); - const processPutRequest = { + const processPutRequest = VSPProcessPostFactory.build({ name: 'Pr1_UPDATED', - description: 'string_UPDATED' - }; + description: 'string_UPDATED', + type: 'Other' + }); 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); + mockRest.addHandler('put', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/components/${componentId}/processes/${toBeUpdatedProcessId}`); + expect(data).toEqual(processPutRequest); + expect(options).toEqual(undefined); return {returnCode: 'OK'}; }); @@ -203,12 +216,12 @@ describe('Software Product Component Processes Module Tests', function () { softwareProductId: softwareProductId, componentId, previousProcess: previousProcessData, - process: processUpdateData + process: processUpdateData, + version } ).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); }); - diff --git a/openecomp-ui/test/softwareProduct/components/storage/test.js b/openecomp-ui/test/softwareProduct/components/storage/test.js index 87cad368be..138c4da7d6 100644 --- a/openecomp-ui/test/softwareProduct/components/storage/test.js +++ b/openecomp-ui/test/softwareProduct/components/storage/test.js @@ -1,24 +1,19 @@ -/*- - * ============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 - * + * + * 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========================================================= + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. */ -import expect from 'expect'; import deepFreeze from 'deep-freeze'; import mockRest from 'test-utils/MockRest.js'; import {cloneAndSet} from 'test-utils/Util.js'; @@ -26,14 +21,18 @@ 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'; +import {default as VSPComponentsStorageFactory, VSPComponentsStorageDataMapFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsStorageFactory.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; + const softwareProductId = '123'; const vspComponentId = '111'; +const version = VersionControllerUtilsFactory.build().version; describe('Software Product Components Storage Module Tests', function () { let restPrefix = ''; - before(function() { + beforeAll(function() { restPrefix = Configuration.get('restPrefix'); deepFreeze(restPrefix); }); @@ -42,28 +41,32 @@ describe('Software Product Components Storage Module Tests', function () { const store = storeCreator(); deepFreeze(store.getState()); + const storage = VSPComponentsStorageFactory.build(); + const dataMap = VSPComponentsStorageDataMapFactory.build(); + const softwareProductComponentStorage = { - data: JSON.stringify({'backup':{'backupType':'OnSite','backupSolution':'76333'},'snapshotBackup':{'snapshotFrequency':'2'}}), - schema: JSON.stringify({'backup':{'backupType':'OnSite','backupSolution':'76333'},'snapshotBackup':{'snapshotFrequency':'2'}}) + data: JSON.stringify(storage), + schema: JSON.stringify(storage) }; deepFreeze(softwareProductComponentStorage); const softwareProductComponentStorageData = { - qdata: JSON.parse(softwareProductComponentStorage.data), - qschema: JSON.parse(softwareProductComponentStorage.schema) + qdata: storage, + dataMap: dataMap, + qgenericFieldInfo: {} }; 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(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/questionnaire`); expect(data).toEqual(undefined); expect(options).toEqual(undefined); return softwareProductComponentStorage; }); - return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, vspComponentId}).then(() => { + return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, version, vspComponentId}).then(() => { expect(store.getState()).toEqual(expectedStore); }); }); @@ -72,61 +75,33 @@ describe('Software Product Components Storage Module Tests', function () { const store = storeCreator(); deepFreeze(store.getState()); + const storage = VSPComponentsStorageFactory.build(); + const softwareProductComponentQuestionnaire = { data: null, - schema: JSON.stringify({'backup':{'backupType':'OnSite','backupSolution':'76333'},'snapshotBackup':{'snapshotFrequency':'2'}}) + schema: JSON.stringify(storage) }; deepFreeze(softwareProductComponentQuestionnaire); const softwareProductComponentQuestionnaireData = { qdata: {}, - qschema: JSON.parse(softwareProductComponentQuestionnaire.schema) + dataMap: {}, + qgenericFieldInfo: {} }; 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(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/questionnaire`); expect(data).toEqual(undefined); expect(options).toEqual(undefined); return softwareProductComponentQuestionnaire; }); - return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, vspComponentId}).then(() => { + return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, version, 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 index 839e1b7cf7..b3994b1461 100644 --- a/openecomp-ui/test/softwareProduct/components/test.js +++ b/openecomp-ui/test/softwareProduct/components/test.js @@ -1,32 +1,30 @@ -/*- - * ============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 + * 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========================================================= + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. */ - -import {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'; +import {VSPComponentsFactory, VSPComponentsGeneralFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsFactories.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; + const softwareProductId = '123'; const vspComponentId = '321'; +const version = VersionControllerUtilsFactory.build().version; describe('Software Product Components Module Tests', function () { it('Get Software Products Components List', () => { @@ -34,18 +32,8 @@ describe('Software Product Components Module Tests', function () { 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' - } + VSPComponentsFactory.build({}, {componentName: 'sd', componentType: 'server'}), + VSPComponentsFactory.build({}, {componentName: 'pd', componentType: 'server'}) ]; deepFreeze(softwareProductComponentsList); @@ -55,14 +43,14 @@ describe('Software Product Components Module Tests', function () { 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); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); return {results: softwareProductComponentsList}; }); - return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(store.dispatch, {softwareProductId}).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(store.dispatch, {softwareProductId, version}).then(() => { + expect(store.getState()).toEqual(expectedStore); }); }); @@ -70,27 +58,21 @@ describe('Software Product Components Module Tests', function () { const store = storeCreator(); const qdataUpdated = { - general: { - hypervisor: { - containerFeatureDescription: 'aaaUpdated', - drivers: 'bbbUpdated', - hypervisor: 'cccUpdated' - } - } + general: VSPComponentsGeneralFactory.build() }; 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); + mockRest.addHandler('put', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/questionnaire`); + expect(data).toEqual(qdataUpdated); + expect(options).toEqual(undefined); return {returnCode: 'OK'}; }); - return SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, vspComponentId, qdata: qdataUpdated}).then(() => { + return SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, version, vspComponentId, qdata: qdataUpdated}).then(() => { //TODO think should we add here something or not }); @@ -98,4 +80,3 @@ describe('Software Product Components Module Tests', function () { }); }); - |