import org.onap.sdc.workflow.services.types.RequestSpec;
import org.onap.sdc.workflow.services.types.Sort;
import org.onap.sdc.workflow.services.types.Workflow;
+import org.onap.sdc.workflow.services.types.WorkflowStatus;
import org.onap.sdc.workflow.services.utilities.JsonUtil;
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
import org.springframework.test.web.servlet.MockMvc;
.andExpect(status().isBadRequest()).andExpect(jsonPath("$.message", is(MISSING_USER_HEADER_ERROR)));
}
+ @Test
+ public void shouldReturnOkWhenArchivingWorkflow() throws Exception {
+ Workflow workflowMock = createWorkflow(1, true);
+ mockMvc.perform(post(RestPath.getArchiveWorkflowPath(workflowMock.getId())).header(USER_ID_HEADER, USER_ID)
+ .contentType(APPLICATION_JSON).content("{\"status\": \"ARCHIVED\"}")).andExpect(status().isOk());
+ verify(workflowManagerMock).updateStatus(workflowMock.getId(),WorkflowStatus.ARCHIVED);
+ }
+
+ @Test
+ public void shouldReturnOkWhenRestoringWorkflow() throws Exception {
+ Workflow workflowMock = createWorkflow(1, true);
+ mockMvc.perform(post(RestPath.getArchiveWorkflowPath(workflowMock.getId())).header(USER_ID_HEADER, USER_ID)
+ .contentType(APPLICATION_JSON).content("{\"status\": \"ACTIVE\"}")).andExpect(status().isOk());
+ verify(workflowManagerMock).updateStatus(workflowMock.getId(),WorkflowStatus.ACTIVE);
+ }
+
@Test
public void listWhenExist() throws Exception {
mockManagerList3();
result.andExpect(jsonPath(String.format("$.items[%s].id", i), is(String.valueOf(i + 1))));
}
- verify(workflowManagerMock).list(any(), any(), requestSpecArg.capture());
+ verify(workflowManagerMock).list(any(), any(), any(), requestSpecArg.capture());
assertRequestSpec(requestSpecArg.getValue(), DEFAULT_OFFSET, DEFAULT_LIMIT, Collections.emptyList());
}
mockMvc.perform(get(RestPath.getWorkflowsPathAllQueryParams(DEFAULT_SORT_VALUE, "2", "1"))
.header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON))
.andExpect(status().isOk()).andExpect(jsonPath("$.items", hasSize(3)));
- verify(workflowManagerMock).list(any(), any(), requestSpecArg.capture());
+ verify(workflowManagerMock).list(any(), any(), any(), requestSpecArg.capture());
assertRequestSpec(requestSpecArg.getValue(), 1, 2, Collections.singletonList(new Sort("name", true)));
}
mockMvc.perform(get(RestPath.getWorkflowsPathAllQueryParams(DEFAULT_SORT_VALUE, "-2", "1"))
.header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON))
.andExpect(status().isOk()).andExpect(jsonPath("$.items", hasSize(3)));
- verify(workflowManagerMock).list(any(), any(), requestSpecArg.capture());
+ verify(workflowManagerMock).list(any(), any(), any(), requestSpecArg.capture());
assertRequestSpec(requestSpecArg.getValue(), 1, DEFAULT_LIMIT,
Collections.singletonList(new Sort("name", true)));
}
mockMvc.perform(get(RestPath.getWorkflowsPathAllQueryParams(DEFAULT_SORT_VALUE, "2", "-1"))
.header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON))
.andExpect(status().isOk()).andExpect(jsonPath("$.items", hasSize(3)));
- verify(workflowManagerMock).list(any(), any(), requestSpecArg.capture());
+ verify(workflowManagerMock).list(any(), any(), any(), requestSpecArg.capture());
assertRequestSpec(requestSpecArg.getValue(), DEFAULT_OFFSET, 2,
Collections.singletonList(new Sort("name", true)));
}
mockMvc.perform(get(RestPath.getWorkflowsPathAllQueryParams(DEFAULT_SORT_VALUE, "abc", "0"))
.header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON))
.andExpect(status().isOk()).andExpect(jsonPath("$.items", hasSize(3)));
- verify(workflowManagerMock).list(any(), any(), requestSpecArg.capture());
+ verify(workflowManagerMock).list(any(), any(), any(), requestSpecArg.capture());
assertRequestSpec(requestSpecArg.getValue(), 0, DEFAULT_LIMIT,
Collections.singletonList(new Sort("name", true)));
}
mockMvc.perform(get(RestPath.getWorkflowsPathAllQueryParams(DEFAULT_SORT_VALUE, "2", "abc"))
.header(USER_ID_HEADER, USER_ID).contentType(APPLICATION_JSON))
.andExpect(jsonPath("$.items", hasSize(3)));
- verify(workflowManagerMock).list(any(), any(), requestSpecArg.capture());
+ verify(workflowManagerMock).list(any(), any(), any(), requestSpecArg.capture());
assertRequestSpec(requestSpecArg.getValue(), DEFAULT_OFFSET, 2,
Collections.singletonList(new Sort("name", true)));
}
mockMvc.perform(get(RestPath.getWorkflowsPathNoSortAndLimit("1")).header(USER_ID_HEADER, USER_ID)
.contentType(APPLICATION_JSON))
.andExpect(jsonPath("$.items", hasSize(3)));
- verify(workflowManagerMock).list(any(), any(), requestSpecArg.capture());
+ verify(workflowManagerMock).list(any(), any(), any(), requestSpecArg.capture());
assertRequestSpec(requestSpecArg.getValue(), 1, DEFAULT_LIMIT, Collections.emptyList());
}
mockMvc.perform(get(RestPath.getWorkflowsPathNoSortAndOffset("1")).header(USER_ID_HEADER, USER_ID)
.contentType(APPLICATION_JSON))
.andExpect(status().isOk()).andExpect(jsonPath("$.items", hasSize(3)));
- verify(workflowManagerMock).list(any(), any(), requestSpecArg.capture());
+ verify(workflowManagerMock).list(any(), any(), any(), requestSpecArg.capture());
assertRequestSpec(requestSpecArg.getValue(), DEFAULT_OFFSET, 1, Collections.emptyList());
}
doReturn(new Page<>(Arrays.asList(createWorkflow(1, true),
createWorkflow(2, true), createWorkflow(3, true)),
new PagingRequest(DEFAULT_OFFSET, DEFAULT_LIMIT), 3)).when(workflowManagerMock)
- .list(any(), any(), any());
+ .list(any(), any(), any(), any());
}
private static void assertRequestSpec(RequestSpec actual, int expectedOffset, int expectedLimit,