summaryrefslogtreecommitdiffstats
path: root/openecomp-ui/test/softwareProduct/details
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-ui/test/softwareProduct/details')
-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
3 files changed, 882 insertions, 0 deletions
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': {}
+ }
+ }
+ }
+ }
+ }
+};