aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common
diff options
context:
space:
mode:
authorIttay Stern <ittay.stern@att.com>2019-03-24 19:16:51 +0200
committerIttay Stern <ittay.stern@att.com>2019-03-24 19:18:24 +0200
commitab7debfa76efa8cce94bb1244ec6b9ad7add427d (patch)
treed5f868b67d44317bf611c636b309541e259f8bef /vid-app-common
parent926100a4e3d59d0dbee1f79570fca98d177d323b (diff)
Ingest SO Task fields: 'timeout' and 'description'
Follows discussion in SO-1594 Issue-ID: VID-403 Change-Id: I04b793d730c9a26d140f52197c103b14d1babd72 Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-app-common')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/mso/rest/Task.kt5
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.controller.js8
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/change-management-manual-tasks-controller/change-management-manual-tasks.controller.test.js61
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/mso/rest/TaskTest.java64
4 files changed, 113 insertions, 25 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();
diff --git a/vid-app-common/src/test/java/org/onap/vid/mso/rest/TaskTest.java b/vid-app-common/src/test/java/org/onap/vid/mso/rest/TaskTest.java
index f6d0c763f..d78627557 100644
--- a/vid-app-common/src/test/java/org/onap/vid/mso/rest/TaskTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/mso/rest/TaskTest.java
@@ -34,25 +34,36 @@ import org.testng.annotations.Test;
public class TaskTest {
private final ObjectMapper mapper = new ObjectMapper();
- private final String TASK_JSON = ""
- + "{ "
- + " \"taskId\": \"taskId\", "
- + " \"type\": \"type\", "
- + " \"nfRole\": \"nfRole\", "
- + " \"subscriptionServiceType\": \"subscriptionServiceType\", "
- + " \"originalRequestId\": \"originalRequestId\", "
- + " \"originalRequestorId\": \"originalRequestorId\", "
- + " \"buildingBlockName\": \"buildingBlockName\", "
- + " \"buildingBlockStep\": \"buildingBlockStep\", "
- + " \"errorSource\": \"errorSource\", "
- + " \"errorCode\": \"errorCode\", "
- + " \"errorMessage\": \"errorMessage\", "
- + " \"validResponses\": [ "
- + " \"a\", "
- + " \"b\", "
- + " \"c\" "
- + " ] "
- + "} ";
+
+ private String templateTaskJson(String insertion) {
+ return ""
+ + "{ "
+ + " \"taskId\": \"taskId\", "
+ + " \"type\": \"type\", "
+ + " \"nfRole\": \"nfRole\", "
+ + " \"subscriptionServiceType\": \"subscriptionServiceType\", "
+ + " \"originalRequestId\": \"originalRequestId\", "
+ + " \"originalRequestorId\": \"originalRequestorId\", "
+ + " \"buildingBlockName\": \"buildingBlockName\", "
+ + " \"buildingBlockStep\": \"buildingBlockStep\", "
+ + " \"errorSource\": \"errorSource\", "
+ + " \"errorCode\": \"errorCode\", "
+ + " \"errorMessage\": \"errorMessage\", "
+ + insertion
+ + " \"validResponses\": [ "
+ + " \"a\", "
+ + " \"b\", "
+ + " \"c\" "
+ + " ] "
+ + "} ";
+ }
+
+ private final String TASK_JSON = templateTaskJson(""
+ + " \"description\": \"description\", "
+ + " \"timeout\": \"timeout\", "
+ );
+
+ private final String TASK_JSON_WITHOUT_TIMEOUT = templateTaskJson("");
private Task newTaskWithPopulatedFields() {
Task task = TestUtils.setStringsInStringProperties(new Task());
@@ -80,4 +91,19 @@ public class TaskTest {
is(newTaskWithPopulatedFields())
);
}
+
+ @Test
+ public void deserializeTaskWithoutTimeout() throws IOException {
+ /*
+ SO may return no timeout, and therefore no description as well
+ */
+ final Task taskWithoutTimeout = newTaskWithPopulatedFields();
+ taskWithoutTimeout.setDescription(null);
+ taskWithoutTimeout.setTimeout(null);
+
+ assertThat(
+ mapper.readValue(TASK_JSON_WITHOUT_TIMEOUT, Task.class),
+ is(taskWithoutTimeout)
+ );
+ }
}