Fix orphan list for VLMs 53/15853/1
authorilanap <ilanap@amdocs.com>
Wed, 27 Sep 2017 08:41:19 +0000 (11:41 +0300)
committerilanap <ilanap@amdocs.com>
Wed, 27 Sep 2017 08:41:19 +0000 (11:41 +0300)
Fix the orphan list where feature groups stayed orphans after a license
agreement that contains them was created.

Issue-ID: SDC-407

Change-Id: I80b20e46fb4077ba0632e897437cfd795f134ad1
Signed-off-by: ilanap <ilanap@amdocs.com>
openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementActionHelper.js
openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementConstants.js
openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementListReducer.js
openecomp-ui/test/licenseModel/licenseAgreement/test.js

index efc4fb7..e9d922c 100644 (file)
@@ -83,21 +83,13 @@ export default {
        saveLicenseAgreement(dispatch, {licenseModelId, previousLicenseAgreement, licenseAgreement, version}) {
                if (previousLicenseAgreement) {
                        return putLicenseAgreement(licenseModelId, previousLicenseAgreement, licenseAgreement, version).then(() => {
-                               dispatch({
-                                       type: licenseAgreementActionTypes.EDIT_LICENSE_AGREEMENT,
-                                       licenseAgreement
-                               });
+                               this.fetchLicenseAgreementList(dispatch, {licenseModelId, version});
                        });
                }
                else {
-                       return postLicenseAgreement(licenseModelId, licenseAgreement, version).then(response => {
-                               dispatch({
-                                       type: licenseAgreementActionTypes.ADD_LICENSE_AGREEMENT,
-                                       licenseAgreement: {
-                                               ...licenseAgreement,
-                                               id: response.value
-                                       }
-                               });
+                       return postLicenseAgreement(licenseModelId, licenseAgreement, version).then(() => {
+                               this.fetchLicenseAgreementList(dispatch, {licenseModelId, version});
+                               FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, {licenseModelId, version});
                        });
                }
        },
index 40bef2c..181171d 100644 (file)
@@ -19,8 +19,6 @@ import InputOptions, {other as optionInputOther} from 'nfvo-components/input/val
 
 export const actionTypes = keyMirror({
        LICENSE_AGREEMENT_LIST_LOADED: null,
-       ADD_LICENSE_AGREEMENT: null,
-       EDIT_LICENSE_AGREEMENT: null,
        DELETE_LICENSE_AGREEMENT: null,
 
        licenseAgreementEditor: {
index e6a8f34..7d1a5ef 100644 (file)
@@ -19,11 +19,6 @@ export default (state = [], action) => {
        switch (action.type) {
                case licenseAgreementActionTypes.LICENSE_AGREEMENT_LIST_LOADED:
                        return [...action.response.results];
-               case licenseAgreementActionTypes.ADD_LICENSE_AGREEMENT:
-                       return [...state, action.licenseAgreement];
-               case licenseAgreementActionTypes.EDIT_LICENSE_AGREEMENT:
-                       const indexForEdit = state.findIndex(licenseAgreement => licenseAgreement.id === action.licenseAgreement.id);
-                       return [...state.slice(0, indexForEdit), action.licenseAgreement, ...state.slice(indexForEdit + 1)];
                case licenseAgreementActionTypes.DELETE_LICENSE_AGREEMENT:
                        return state.filter(licenseAgreement => licenseAgreement.id !== action.licenseAgreementId);
                default:
index 442f7bf..40b60da 100644 (file)
@@ -93,7 +93,9 @@ describe('License Agreement Module Tests', () => {
                        id: licenseAgreementIdFromResponse
                });
                deepFreeze(licenseAgreementAfterAdd);
+               const licenseAgreementList = [licenseAgreementAfterAdd];
 
+               const featureGroupsList = licenseAgreementList.featureGroupsIds;
                const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseAgreement.licenseAgreementList', [licenseAgreementAfterAdd]);
 
                mockRest.addHandler('post', ({options, data, baseUrl}) => {
@@ -104,7 +106,18 @@ describe('License Agreement Module Tests', () => {
                                value: licenseAgreementIdFromResponse
                        };
                });
-
+               mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+                       expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-agreements`);
+                       expect(data).toEqual(undefined);
+                       expect(options).toEqual(undefined);
+                       return {results: licenseAgreementList};
+               });
+               mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+                       expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/feature-groups`);
+                       expect(data).toEqual(undefined);
+                       expect(options).toEqual(undefined);
+                       return {results: featureGroupsList};
+               });
                return LicenseAgreementActionHelper.saveLicenseAgreement(store.dispatch, {
                        licenseAgreement: licenseAgreementToAdd,
                        licenseModelId: LICENSE_MODEL_ID,
@@ -151,7 +164,18 @@ describe('License Agreement Module Tests', () => {
                        expect(data).toEqual(LicenseAgreementPutFactoryRequest);
                        expect(options).toEqual(undefined);
                });
-
+               mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+                       expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-agreements`);
+                       expect(data).toEqual(undefined);
+                       expect(options).toEqual(undefined);
+                       return {results: [licenseAgreementUpdateData]};
+               });
+               mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+                       expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/feature-groups`);
+                       expect(data).toEqual(undefined);
+                       expect(options).toEqual(undefined);
+                       return {results: newFeatureGroupsIds};
+               });
                return LicenseAgreementActionHelper.saveLicenseAgreement(store.dispatch, {
                        licenseModelId: LICENSE_MODEL_ID,
                        version,