diff options
Diffstat (limited to 'vid-app-common/src/main')
3 files changed, 68 insertions, 6 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.kt b/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.kt index 311b0fbbe..7d2a41a6a 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.kt +++ b/vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.kt @@ -32,12 +32,15 @@ data class Task( var errorMessage: String?, var buildingBlockName: String?, var buildingBlockStep: String?, + var description: String?, + var timeout: String?, var validResponses: List<String>? ) { // i.e. "default constructor", no params constructor() : this( null, null, null, null, null, null, null, null, - null, null, null, null + null, null, null, + null, null, null ) } diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.controller.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.controller.js index bfe733023..c4f8f14a9 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.controller.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.controller.js @@ -43,10 +43,12 @@ }; function loadAvailableTasks(requestId) { - MsoService.getManualTasks(requestId) + return MsoService.getManualTasks(requestId) .then(function(response) { vm.task = response.data[0]; vm.manualTasks = vm.task && vm.task.validResponses; + vm.description = vm.task && vm.task.description || null; + vm.timeout = vm.task && vm.task.timeout || null; }) .catch(function(error) { $log.error(error); @@ -73,6 +75,10 @@ return vm.manualTasks.includes(task); }; + vm.__test_only__ = { + loadAvailableTasks: loadAvailableTasks, + }; + init(); } })(); diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.controller.test.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.controller.test.js index f5821f7de..93bc1c2de 100644 --- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.controller.test.js +++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.controller.test.js @@ -32,9 +32,10 @@ describe('changeManagementManualTasksController testing', () => { ); beforeEach(inject(function (_$controller_) { - $MsoService.getManualTasks = jestMock.fn().mockResolvedValue( - {data: [manualTaskResponse]}); $log.error = jestMock.fn(); + $uibModalInstance.close = jestMock.fn(); + + mockManualTaskResponse(manualTaskResponse); $controller = _$controller_('changeManagementManualTasksController', { "MsoService": $MsoService, @@ -51,6 +52,12 @@ describe('changeManagementManualTasksController testing', () => { }); })); + function mockManualTaskResponse(manualTaskResponse) { + $MsoService.getManualTasks = jestMock.fn().mockResolvedValue( + {data: [manualTaskResponse]} + ); + } + const job = { "requestId": "db775fac-d9b5-480e-8b3e-4f0d0ae67890", "requestScope": "vnf", @@ -69,16 +76,34 @@ describe('changeManagementManualTasksController testing', () => { } }; - const manualTaskResponse = { + const manualTaskResponseWithoutValidResponses = { "taskId": "db775fac-d9b5-480e-8b3e-4f0d0ae67890", - "validResponses": ["rollback", "abort", "skip", "resume", "retry"] }; + const manualTaskResponse = Object.assign({ + "validResponses": ["rollback", "abort", "skip", "resume", "retry"], + }, manualTaskResponseWithoutValidResponses); + + const manualTaskResponseWithTimeout = Object.assign({ + description: 'description', + timeout: 'timeout', + }, manualTaskResponse); + test('should populate vm.manualTasks (while init)', () => { expect($controller.manualTasks).toEqual( manualTaskResponse.validResponses); }); + test('should undefine vm.manualTasks when ValidResponses not given', () => { + // given + mockManualTaskResponse(manualTaskResponseWithoutValidResponses); + // when + return $controller.__test_only__.loadAvailableTasks('anything') + .then(() => { + expect($controller.manualTasks).toBeUndefined() + }); + }); + test('should populate vm.MANUAL_TASKS from COMPONENT (while init)', () => { expect($controller.MANUAL_TASKS).toEqual( ["manualTaskName1", "manualTaskName2"]); @@ -88,6 +113,34 @@ describe('changeManagementManualTasksController testing', () => { expect($controller.task).toEqual(manualTaskResponse); }); + test('should nullify vm.description (while init)', () => { + expect($controller.description).toBeNull(); + }); + + test('should nullify vm.timeout (while init)', () => { + expect($controller.timeout).toBeNull(); + }); + + test('should populate vm.description', () => { + // given + mockManualTaskResponse(manualTaskResponseWithTimeout); + // when + return $controller.__test_only__.loadAvailableTasks('anything') + .then(() => { + expect($controller.description).toEqual('description'); + }); + }); + + test('should populate vm.timeout', () => { + // given + mockManualTaskResponse(manualTaskResponseWithTimeout); + // when + return $controller.__test_only__.loadAvailableTasks('anything') + .then(() => { + expect($controller.timeout).toEqual('timeout'); + }); + }); + test('should find manual task using isTaskAvailable', () => { expect($controller.isTaskAvailable('abort')).toBeTruthy(); expect($controller.isTaskAvailable('resume')).toBeTruthy(); |