diff options
Diffstat (limited to 'vid-app-common/src')
7 files changed, 77 insertions, 41 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/properties/Features.java b/vid-app-common/src/main/java/org/onap/vid/properties/Features.java index dfe3185b2..1c68e8292 100644 --- a/vid-app-common/src/main/java/org/onap/vid/properties/Features.java +++ b/vid-app-common/src/main/java/org/onap/vid/properties/Features.java @@ -62,6 +62,7 @@ public enum Features implements Feature { FLAG_1902_NEW_VIEW_EDIT, FLAG_EXP_USE_DEFAULT_HOST_NAME_VERIFIER, FLAG_1902_VNF_GROUPING, + FLAG_HANDLE_SO_WORKFLOWS ; public boolean isActive() { diff --git a/vid-app-common/src/main/webapp/WEB-INF/conf/dev.features.properties b/vid-app-common/src/main/webapp/WEB-INF/conf/dev.features.properties index d82b043c5..8ba148465 100644 --- a/vid-app-common/src/main/webapp/WEB-INF/conf/dev.features.properties +++ b/vid-app-common/src/main/webapp/WEB-INF/conf/dev.features.properties @@ -8,6 +8,7 @@ FLAG_COLLECTION_RESOURCE_SUPPORT = true FLAG_NETWORK_TO_ASYNC_INSTANTIATION = false FLAG_SERVICE_MODEL_CACHE = true FLAG_SHOW_ASSIGNMENTS = true +FLAG_HANDLE_SO_WORKFLOWS = true FLAG_SHOW_VERIFY_SERVICE = true FLAG_DUPLICATE_VNF = true diff --git a/vid-app-common/src/main/webapp/WEB-INF/conf/features.properties b/vid-app-common/src/main/webapp/WEB-INF/conf/features.properties index 36f607f62..4cf42f235 100644 --- a/vid-app-common/src/main/webapp/WEB-INF/conf/features.properties +++ b/vid-app-common/src/main/webapp/WEB-INF/conf/features.properties @@ -20,11 +20,12 @@ FLAG_SHOW_ASSIGNMENTS = true FLAG_SHOW_VERIFY_SERVICE = false FLAG_FABRIC_CONFIGURATION_ASSIGNMENTS = true FLAG_PRESENT_PROVIDER_NETWORKS_ASSOCIATIONS = true -FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST=true -FLAG_1810_CR_LET_SELECTING_COLLECTOR_TYPE_UNCONDITIONALLY=true +FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST = true +FLAG_1810_CR_LET_SELECTING_COLLECTOR_TYPE_UNCONDITIONALLY = true FLAG_1810_CR_SOFT_DELETE_ALACARTE_VF_MODULE = true FLAG_1810_AAI_LOCAL_CACHE = true FLAG_EXP_USE_DEFAULT_HOST_NAME_VERIFIER = false +FLAG_HANDLE_SO_WORKFLOWS = false # Modern UI (Drawing-Board; View/Edit) # - - - - - - - - - - - - - - - - - - diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js b/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js index dbf6588ce..fc3d8f792 100755 --- a/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/constants/componentConstants.js @@ -257,7 +257,8 @@ appDS2 FLAG_PRESENT_PROVIDER_NETWORKS_ASSOCIATIONS: "FLAG_PRESENT_PROVIDER_NETWORKS_ASSOCIATIONS", FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST: "FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST", FLAG_1810_CR_LET_SELECTING_COLLECTOR_TYPE_UNCONDITIONALLY: "FLAG_1810_CR_LET_SELECTING_COLLECTOR_TYPE_UNCONDITIONALLY", - FLAG_1810_CR_SOFT_DELETE_ALACARTE_VF_MODULE: "FLAG_1810_CR_SOFT_DELETE_ALACARTE_VF_MODULE" + FLAG_1810_CR_SOFT_DELETE_ALACARTE_VF_MODULE: "FLAG_1810_CR_SOFT_DELETE_ALACARTE_VF_MODULE", + FLAG_HANDLE_SO_WORKFLOWS: "FLAG_HANDLE_SO_WORKFLOWS" } }; diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js index 8a7d59a62..88caef29e 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js @@ -634,16 +634,20 @@ }; vm.loadWorkFlows = function () { - // Should be corrected when VID-397 will be closed. At the moment there is a need - // to merge local and remote workflows not to broke current functionality. - return vm.loadLocalWorkFlows() - .then(vm.loadLocalWorkFlowsParameters) - .then(vm.loadRemoteWorkFlows) - .then(function () { - vm.workflows = vm.localWorkflows.concat(vm.remoteWorkflows.map(item => item.name)); - }).then(function () { - vm.loadRemoteWorkFlowsParameters(); - }); + if (featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_HANDLE_SO_WORKFLOWS)) { + return vm.loadRemoteWorkFlows() + .then(function () { + vm.workflows = vm.remoteWorkflows.map(item => item.name); + }).then(function () { + vm.loadRemoteWorkFlowsParameters(); + }); + }else{ + return vm.loadLocalWorkFlows() + .then(vm.loadLocalWorkFlowsParameters) + .then(function () { + vm.workflows = vm.localWorkflows; + }) + } }; vm.loadLocalWorkFlows = function () { diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js index 5f3669152..9810c0013 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.test.js @@ -25,6 +25,8 @@ describe('Testing workFlows from SO', () => { let $notNeeded; let $controller; let $changeManagementService; + let $featureFlags; + beforeEach( angular.mock.module('app') ); @@ -38,6 +40,10 @@ describe('Testing workFlows from SO', () => { // mock q $q = jestMock.fn(); $defer = jestMock.fn(); + $flags = jestMock.fn(); + $flags.FEATURE_FLAGS = {FLAG_HANDLE_SO_WORKFLOWS: ''}; + $featureFlags = jestMock.fn(); + $featureFlags.isOn = jestMock.fn(() => true); $q.defer = jestMock.fn(() => $defer); $defer.promise = Promise.resolve({}); // mock AaiService @@ -53,10 +59,10 @@ describe('Testing workFlows from SO', () => { Upload: $notNeeded, $log: $notNeeded, _: $notNeeded, - COMPONENT: $notNeeded, + COMPONENT: $flags, VIDCONFIGURATION: $notNeeded, DataService: $notNeeded, - featureFlags: $notNeeded, + featureFlags: $featureFlags, $scope: $notNeeded, }); })); @@ -77,10 +83,23 @@ describe('Testing workFlows from SO', () => { ); }); - test('Verify load workflows will call load from SO and join workflow lists', () => { + test('Verify load workflows wont load parameters from local service', () => { // given let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["workflow 0"]}}); - let getLocalWorkflowsParametersStub = Promise.resolve({"data": {}}); + let getLocalWorkflowsParametersStub = Promise.resolve({"data":{ + "parameterDefinitions": [ + { + "id": 1, + "name": "Configuration Parameters", + "required": true, + "type": "STRING", + "pattern": ".*", + "msgOnPatternError": null, + "msgOnContentError": null, + "acceptableFileType": null + } + ], + }}); let getSOWorkflowsPromiseStub = Promise.resolve({"data": [{"id": "1", "name": "workflow 1"}, {"id": "2", "name": "workflow 2"}]}); let getSOWorkflowsParametersPromiseStub = Promise.resolve({"data":{"parameterDefinitions": []}}); @@ -91,7 +110,6 @@ describe('Testing workFlows from SO', () => { $changeManagementService.getSOWorkflowParameter = () => getSOWorkflowsParametersPromiseStub; // when return $controller.loadWorkFlows().then(() => { - expect($controller.workflows).toContain('workflow 0'); expect($controller.workflows).toContain('workflow 1'); expect($controller.workflows).toContain('workflow 2'); }); @@ -122,8 +140,33 @@ describe('Testing workFlows from SO', () => { }); }); + test('Verify load workflows wont load workflows parameters from SO if feature flag is disabled', () => { + // given + $featureFlags.isOn = jestMock.fn(() => false); + let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["workflow 0"]}}); + let getLocalWorkflowsParametersStub = Promise.resolve({"data": {}}); + let getSOWorkflowsPromiseStub = Promise.resolve({"data": [{"id": "1", "name": "workflow 0"}]}); + let getSOWorkflowsParametersPromiseStub = Promise.resolve({"data":{"parameterDefinitions": [ + {"id": 1, "name": "parameter 1", "required": true, "type": "STRING", "pattern": "[0-9]*"}, + {"id": 2, "name": "parameter 2", "required": true, "type": "STRING", "pattern": ".*"}, + {"id": 3, "name": "parameter 3", "required": false, "type": "STRING", "pattern": "[0-9]*"}]}}); + + $controller.changeManagement.vnfNames = [{name: 'test1'}, {name: "test2"}]; + $changeManagementService.getWorkflows = () => getWorkflowsStub; + $changeManagementService.getLocalWorkflowParameter = () => getLocalWorkflowsParametersStub; + $changeManagementService.getSOWorkflows = () => getSOWorkflowsPromiseStub; + $changeManagementService.getSOWorkflowParameter = () => getSOWorkflowsParametersPromiseStub; + // when + return $controller.loadWorkFlows() + .then(() => { + expect($controller.workflows).toEqual(["workflow 0"]); + expect($controller.remoteWorkflowsParameters).toEqual(undefined); + }); + }); + test('Verify load workflows will call load workflows parameters from local service', () => { // given + $featureFlags.isOn = jestMock.fn(() => false); let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["VNF Scale Out"]}}); let getLocalWorkflowsParametersStub = Promise.resolve({"data":{ "parameterDefinitions": [ @@ -139,14 +182,10 @@ describe('Testing workFlows from SO', () => { } ], }}); - let getSOWorkflowsPromiseStub = Promise.resolve({"data": [{}]}); - let getSOWorkflowsParametersPromiseStub = Promise.resolve({"data":{}}); $controller.changeManagement.vnfNames = [{name: 'test1'}]; $changeManagementService.getWorkflows = () => getWorkflowsStub; $changeManagementService.getLocalWorkflowParameter = () => getLocalWorkflowsParametersStub; - $changeManagementService.getSOWorkflows = () => getSOWorkflowsPromiseStub; - $changeManagementService.getSOWorkflowParameter = () => getSOWorkflowsParametersPromiseStub; // when let result = new Map(); @@ -172,23 +211,22 @@ describe('Testing workFlows from SO', () => { }); }); - test('Verify broken SO workflows wont change content of local workflows', () => { + test('Verify broken SO workflows will return empty list of workflows', () => { // given - let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["workflow 0"]}}); let getSOWorkflowsPromiseStub = Promise.reject(new Error("Broken SO workflows service.")); - $controller.changeManagement.vnfNames = "any"; - $changeManagementService.getWorkflows = () => getWorkflowsStub; + $controller.changeManagement.vnfNames = [{name:"any"}]; $changeManagementService.getSOWorkflows = () => getSOWorkflowsPromiseStub; // when $controller.loadWorkFlows() .then(() => { - expect($controller.workflows).toEqual(['workflow 0']); + expect($controller.workflows).toEqual([]); }); }); test('Verify get internal workflow parameters should return an empty list if not such workflow exist', () => { // given + $featureFlags.isOn = jestMock.fn(() => false); let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["VNF Scale Out"]}}); let getLocalWorkflowsParametersStub = Promise.resolve({"data":{ "parameterDefinitions": [ @@ -204,14 +242,10 @@ describe('Testing workFlows from SO', () => { } ], }}); - let getSOWorkflowsPromiseStub = Promise.resolve({"data": [{}]}); - let getSOWorkflowsParametersPromiseStub = Promise.resolve({"data":{}}); $controller.changeManagement.vnfNames = [{name: 'test1'}]; $changeManagementService.getWorkflows = () => getWorkflowsStub; $changeManagementService.getLocalWorkflowParameter = () => getLocalWorkflowsParametersStub; - $changeManagementService.getSOWorkflows = () => getSOWorkflowsPromiseStub; - $changeManagementService.getSOWorkflowParameter = () => getSOWorkflowsParametersPromiseStub; // when return $controller.loadWorkFlows() .then(() => { @@ -222,6 +256,7 @@ describe('Testing workFlows from SO', () => { test('Verify get internal workflow parameters should return an empty list if not such type exist', () => { // given + $featureFlags.isOn = jestMock.fn(() => false); let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["VNF Scale Out"]}}); let getLocalWorkflowsParametersStub = Promise.resolve({"data":{ "parameterDefinitions": [ @@ -237,14 +272,10 @@ describe('Testing workFlows from SO', () => { } ], }}); - let getSOWorkflowsPromiseStub = Promise.resolve({"data": [{}]}); - let getSOWorkflowsParametersPromiseStub = Promise.resolve({"data":{}}); $controller.changeManagement.vnfNames = [{name: 'test1'}]; $changeManagementService.getWorkflows = () => getWorkflowsStub; $changeManagementService.getLocalWorkflowParameter = () => getLocalWorkflowsParametersStub; - $changeManagementService.getSOWorkflows = () => getSOWorkflowsPromiseStub; - $changeManagementService.getSOWorkflowParameter = () => getSOWorkflowsParametersPromiseStub; // when return $controller.loadWorkFlows() .then(() => { @@ -255,6 +286,7 @@ describe('Testing workFlows from SO', () => { test('Verify get internal workflow parameters should return a list if such workflow and type exist', () => { // given + $featureFlags.isOn = jestMock.fn(() => false); let getWorkflowsStub = Promise.resolve({"data": {"workflows": ["VNF Scale Out"]}}); let getLocalWorkflowsParametersStub = Promise.resolve({"data":{ "parameterDefinitions": [ @@ -270,14 +302,9 @@ describe('Testing workFlows from SO', () => { } ], }}); - let getSOWorkflowsPromiseStub = Promise.resolve({"data": [{}]}); - let getSOWorkflowsParametersPromiseStub = Promise.resolve({"data":{}}); - $controller.changeManagement.vnfNames = [{name: 'test1'}]; $changeManagementService.getWorkflows = () => getWorkflowsStub; $changeManagementService.getLocalWorkflowParameter = () => getLocalWorkflowsParametersStub; - $changeManagementService.getSOWorkflows = () => getSOWorkflowsPromiseStub; - $changeManagementService.getSOWorkflowParameter = () => getSOWorkflowsParametersPromiseStub; let result = [{ "acceptableFileType": null, diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js index 45aedd1a1..2a06e75b1 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/change-management.service.js @@ -45,7 +45,8 @@ return $http.get(COMPONENT.GET_SO_WORKFLOWS, {params: {vnfName: vnfNames}}) .success(function (response) { return {data: response}; - }).catch(function () { + }).catch(function (ex) { + console.error("Problem when getting workflows from SO API occurred.", ex.stack); return {data: []}; }); }; |