summaryrefslogtreecommitdiffstats
path: root/workflow
diff options
context:
space:
mode:
authoravigaffa <avi.gaffa@amdocs.com>2018-07-19 17:01:34 +0300
committeravigaffa <avi.gaffa@amdocs.com>2018-07-19 17:01:34 +0300
commit7b29a376f0b211dccc35cb1d7f73e011bcad016b (patch)
tree002b4a2e79c3b65bbef64d2c4d3827b16edc1cd8 /workflow
parent8f3c7f04827505fb9feb5f53d1e150069445498d (diff)
Pagination of workflow list API
Changing pagination parameters names in response Change-Id: Ie9d9a5160d011c471566bccaba6bc3c24619de89 Issue-ID: SDC-1483 Signed-off-by: avigaffa <avi.gaffa@amdocs.com>
Diffstat (limited to 'workflow')
-rw-r--r--workflow/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/RestConstants.java8
-rw-r--r--workflow/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowController.java4
-rw-r--r--workflow/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/CollectionWrapper.java17
-rw-r--r--workflow/workflow-designer-be/src/test/java/org/onap/sdc/workflow/RestPath.java32
-rw-r--r--workflow/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowControllerTest.java115
5 files changed, 82 insertions, 94 deletions
diff --git a/workflow/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/RestConstants.java b/workflow/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/RestConstants.java
index 47a757e2..fc2e4408 100644
--- a/workflow/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/RestConstants.java
+++ b/workflow/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/RestConstants.java
@@ -6,10 +6,10 @@ public class RestConstants {
}
public static final String USER_ID_HEADER_PARAM = "USER_ID";
- public static final String LIMIT_PARAM = "size";
- public static final String OFFSET_PARAM = "page";
+ public static final String SIZE_PARAM = "size";
+ public static final String PAGE_PARAM = "page";
public static final String SORT_PARAM = "sort";
public static final String SORT_FIELD_NAME = "name";
- public static final int LIMIT_DEFAULT = 20;
- public static final int OFFSET_DEFAULT = 0;
+ public static final int SIZE_DEFAULT = 20;
+ public static final int PAGE_DEFAULT = 0;
}
diff --git a/workflow/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowController.java b/workflow/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowController.java
index de35320d..b0ae7cc1 100644
--- a/workflow/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowController.java
+++ b/workflow/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/WorkflowController.java
@@ -1,6 +1,6 @@
package org.onap.sdc.workflow.api;
-import static org.onap.sdc.workflow.api.RestConstants.LIMIT_DEFAULT;
+import static org.onap.sdc.workflow.api.RestConstants.SIZE_DEFAULT;
import static org.onap.sdc.workflow.api.RestConstants.SORT_FIELD_NAME;
import static org.onap.sdc.workflow.api.RestConstants.SORT_PARAM;
import static org.onap.sdc.workflow.api.RestConstants.USER_ID_HEADER_PARAM;
@@ -50,7 +50,7 @@ public class WorkflowController {
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation("List workflows")
public CollectionWrapper<Workflow> list(@RequestHeader(USER_ID_HEADER_PARAM) String user,
- @PageableDefault(size = LIMIT_DEFAULT)
+ @PageableDefault(size = SIZE_DEFAULT)
@SortDefault.SortDefaults({
@SortDefault(sort = SORT_FIELD_NAME, direction = Sort.Direction.ASC)
}) Pageable pageable) {
diff --git a/workflow/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/CollectionWrapper.java b/workflow/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/CollectionWrapper.java
index 1d583dd9..6a437a74 100644
--- a/workflow/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/CollectionWrapper.java
+++ b/workflow/workflow-designer-be/src/main/java/org/onap/sdc/workflow/api/types/CollectionWrapper.java
@@ -2,24 +2,21 @@ package org.onap.sdc.workflow.api.types;
import java.util.Collection;
import lombok.Data;
+import lombok.NoArgsConstructor;
@Data
+@NoArgsConstructor
public class CollectionWrapper<T> {
private int total;
- private int limit;
- private int offset;
+ private int size;
+ private int page;
private Collection<T> results;
-
- public CollectionWrapper() {
- //Default constructor for object mappers
- }
-
- public CollectionWrapper(int limit, int offset, Collection<T> results) {
+ public CollectionWrapper(int size, int page, Collection<T> results) {
this.results = results;
- this.limit = limit;
- this.offset = offset;
+ this.size = size;
+ this.page = page;
this.total = results.size();
}
diff --git a/workflow/workflow-designer-be/src/test/java/org/onap/sdc/workflow/RestPath.java b/workflow/workflow-designer-be/src/test/java/org/onap/sdc/workflow/RestPath.java
index ba99996a..06d55479 100644
--- a/workflow/workflow-designer-be/src/test/java/org/onap/sdc/workflow/RestPath.java
+++ b/workflow/workflow-designer-be/src/test/java/org/onap/sdc/workflow/RestPath.java
@@ -1,7 +1,7 @@
package org.onap.sdc.workflow;
-import static org.onap.sdc.workflow.api.RestConstants.LIMIT_PARAM;
-import static org.onap.sdc.workflow.api.RestConstants.OFFSET_PARAM;
+import static org.onap.sdc.workflow.api.RestConstants.SIZE_PARAM;
+import static org.onap.sdc.workflow.api.RestConstants.PAGE_PARAM;
import static org.onap.sdc.workflow.api.RestConstants.SORT_PARAM;
public class RestPath {
@@ -14,32 +14,32 @@ public class RestPath {
private static final String VERSIONS_URL_FORMATTER = WORKFLOWS_URL + "/%s/versions";
private static final String VERSION_URL_FORMATTER = WORKFLOWS_URL + "/%s/versions/%s";
private static final String SORT_QUERY_STRING_FORMATTER = SORT_PARAM + "=%s";
- private static final String LIMIT_QUERY_STRING_FORMATTER = LIMIT_PARAM + "=%s";
- private static final String OFFSET_QUERY_STRING_FORMATTER = OFFSET_PARAM + "=%s";
+ private static final String SIZE_QUERY_STRING_FORMATTER = SIZE_PARAM + "=%s";
+ private static final String OFFSET_QUERY_STRING_FORMATTER = PAGE_PARAM + "=%s";
private static final String WORKFLOW_URL_FORMATTER_QUERY_PARAMS_ALL =
- WORKFLOWS_URL + "?" + SORT_QUERY_STRING_FORMATTER+ "&" + LIMIT_QUERY_STRING_FORMATTER + "&" +
+ WORKFLOWS_URL + "?" + SORT_QUERY_STRING_FORMATTER+ "&" + SIZE_QUERY_STRING_FORMATTER + "&" +
OFFSET_QUERY_STRING_FORMATTER;
private static final String WORKFLOW_URL_FORMATTER_QUERY_PARAMS_NO_SORT =
- WORKFLOWS_URL + "?" + LIMIT_QUERY_STRING_FORMATTER + "&" + OFFSET_QUERY_STRING_FORMATTER;
- private static final String WORKFLOW_URL_FORMATTER_QUERY_PARAMS_NO_SORT_AND_LIMIT =
+ WORKFLOWS_URL + "?" + SIZE_QUERY_STRING_FORMATTER + "&" + OFFSET_QUERY_STRING_FORMATTER;
+ private static final String WORKFLOW_URL_FORMATTER_QUERY_PARAMS_NO_SORT_AND_SIZE =
WORKFLOWS_URL + "?" + OFFSET_QUERY_STRING_FORMATTER;
private static final String WORKFLOW_URL_FORMATTER_QUERY_PARAMS_NO_SORT_AND_OFFSET =
- WORKFLOWS_URL + "?" + LIMIT_QUERY_STRING_FORMATTER;
+ WORKFLOWS_URL + "?" + SIZE_QUERY_STRING_FORMATTER;
- public static String getWorkflowsPathAllQueryParams(String sort, String limit, String offset){
- return String.format(WORKFLOW_URL_FORMATTER_QUERY_PARAMS_ALL, sort, limit, offset);
+ public static String getWorkflowsPathAllQueryParams(String sort, String size, String offset){
+ return String.format(WORKFLOW_URL_FORMATTER_QUERY_PARAMS_ALL, sort, size, offset);
}
- public static String getWorkflowsPathNoSort(String limit, String offset){
- return String.format(WORKFLOW_URL_FORMATTER_QUERY_PARAMS_NO_SORT, limit, offset);
+ public static String getWorkflowsPathNoSort(String size, String offset){
+ return String.format(WORKFLOW_URL_FORMATTER_QUERY_PARAMS_NO_SORT, size, offset);
}
- public static String getWorkflowsPathNoSortAndLimit(String offset){
- return String.format(WORKFLOW_URL_FORMATTER_QUERY_PARAMS_NO_SORT_AND_LIMIT, offset);
+ public static String getWorkflowsPathNoSortAndSize(String offset){
+ return String.format(WORKFLOW_URL_FORMATTER_QUERY_PARAMS_NO_SORT_AND_SIZE, offset);
}
- public static String getWorkflowsPathNoSortAndOffset(String limit){
- return String.format(WORKFLOW_URL_FORMATTER_QUERY_PARAMS_NO_SORT_AND_OFFSET, limit);
+ public static String getWorkflowsPathNoSortAndOffset(String size){
+ return String.format(WORKFLOW_URL_FORMATTER_QUERY_PARAMS_NO_SORT_AND_OFFSET, size);
}
public static String getWorkflowsPath(){
diff --git a/workflow/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowControllerTest.java b/workflow/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowControllerTest.java
index 1f36759d..c9400224 100644
--- a/workflow/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowControllerTest.java
+++ b/workflow/workflow-designer-be/src/test/java/org/onap/sdc/workflow/api/WorkflowControllerTest.java
@@ -5,17 +5,14 @@ import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
import static org.onap.sdc.workflow.TestUtil.createWorkflow;
-import static org.onap.sdc.workflow.api.RestConstants.LIMIT_DEFAULT;
-import static org.onap.sdc.workflow.api.RestConstants.OFFSET_DEFAULT;
+import static org.onap.sdc.workflow.api.RestConstants.PAGE_DEFAULT;
+import static org.onap.sdc.workflow.api.RestConstants.SIZE_DEFAULT;
import static org.onap.sdc.workflow.api.RestConstants.SORT_FIELD_NAME;
import static org.onap.sdc.workflow.api.RestConstants.SORT_PARAM;
import static org.onap.sdc.workflow.api.RestConstants.USER_ID_HEADER_PARAM;
import static org.springframework.http.MediaType.APPLICATION_JSON;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@@ -23,11 +20,9 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableSet;
import com.google.gson.Gson;
-
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -39,12 +34,9 @@ import org.onap.sdc.workflow.api.exceptionshandlers.CustomizedResponseEntityExce
import org.onap.sdc.workflow.api.types.CollectionWrapper;
import org.onap.sdc.workflow.persistence.types.Workflow;
import org.onap.sdc.workflow.services.WorkflowManager;
-import org.openecomp.sdc.versioning.types.Item;
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
-import org.springframework.http.MediaType;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.test.web.servlet.MockMvc;
-import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
@RunWith(MockitoJUnitRunner.class)
@@ -73,9 +65,8 @@ public class WorkflowControllerTest {
public void setUp() {
mockMvc = MockMvcBuilders.standaloneSetup(workflowController).build();
mockMvc = MockMvcBuilders.standaloneSetup(workflowController)
- .setCustomArgumentResolvers(new PageableHandlerMethodArgumentResolver())
- .setControllerAdvice(new CustomizedResponseEntityExceptionHandler())
- .build();
+ .setCustomArgumentResolvers(new PageableHandlerMethodArgumentResolver())
+ .setControllerAdvice(new CustomizedResponseEntityExceptionHandler()).build();
}
@Test
@@ -85,17 +76,17 @@ public class WorkflowControllerTest {
mockMvc.perform(get(RestPath.getWorkflowPath(workflowMock.getId())).contentType(APPLICATION_JSON))
.andDo(print()).andExpect(status().isBadRequest()).andExpect(status().is(400)).andReturn()
.getResponse();
- assertEquals(String.format(MISSING_REQUEST_HEADER_ERRROR_FORMAT, USER_ID_HEADER), response.getContentAsString());
+ assertEquals(String.format(MISSING_REQUEST_HEADER_ERRROR_FORMAT, USER_ID_HEADER),
+ response.getContentAsString());
}
@Test
public void shouldReturnWorkflowDataWhenRequestPathIsOk() throws Exception {
Workflow workflowMock = createWorkflow(1, true);
doReturn(workflowMock).when(workflowManagerMock).get(any(Workflow.class));
- mockMvc.perform(
- get(RestPath.getWorkflowPath(workflowMock.getId())).header(USER_ID_HEADER_PARAM, USER_ID)
- .contentType(APPLICATION_JSON)).andDo(print())
- .andExpect(status().isOk()).andExpect(jsonPath("$.id", is(workflowMock.getId())))
+ mockMvc.perform(get(RestPath.getWorkflowPath(workflowMock.getId())).header(USER_ID_HEADER_PARAM, USER_ID)
+ .contentType(APPLICATION_JSON))
+ .andDo(print()).andExpect(status().isOk()).andExpect(jsonPath("$.id", is(workflowMock.getId())))
.andExpect(jsonPath("$.name", is(workflowMock.getName())));
}
@@ -104,7 +95,8 @@ public class WorkflowControllerTest {
MockHttpServletResponse response =
mockMvc.perform(get(RestPath.getWorkflowsPath()).contentType(APPLICATION_JSON)).andDo(print())
.andExpect(status().isBadRequest()).andExpect(status().is(400)).andReturn().getResponse();
- assertEquals(String.format(MISSING_REQUEST_HEADER_ERRROR_FORMAT, USER_ID_HEADER_PARAM), response.getContentAsString());
+ assertEquals(String.format(MISSING_REQUEST_HEADER_ERRROR_FORMAT, USER_ID_HEADER_PARAM),
+ response.getContentAsString());
}
@Test
@@ -118,28 +110,27 @@ public class WorkflowControllerTest {
}
@Test
- public void shouldReturnSortedLimitOffsetAppliedWorkflows() throws Exception {
- List<Workflow> workflowMocks = createLimit2AndOffset1For5WorkflowList();
+ public void shouldReturnSortedSizeOffsetAppliedWorkflows() throws Exception {
+ List<Workflow> workflowMocks = createSize2AndOffset1For5WorkflowList();
doReturn(workflowMocks).when(workflowManagerMock).list(any());
- mockMvc.perform(
- get(RestPath.getWorkflowsPathAllQueryParams(DEFAULT_SORT_VALUE, "2", "1"))
- .header(RestConstants.USER_ID_HEADER_PARAM, USER_ID).contentType(APPLICATION_JSON))
- .andDo(print()).andExpect(status().isOk()).andExpect(jsonPath("$.results", hasSize(2)));
+ mockMvc.perform(get(RestPath.getWorkflowsPathAllQueryParams(DEFAULT_SORT_VALUE, "2", "1"))
+ .header(RestConstants.USER_ID_HEADER_PARAM, USER_ID).contentType(APPLICATION_JSON))
+ .andDo(print()).andExpect(status().isOk()).andExpect(jsonPath("$.results", hasSize(2)));
}
@Test
- public void shouldReturnResultsWithDefaultWhenLimitIsNegative() throws Exception {
- List<Workflow> workflowMocks = createLimit2AndOffset1For5WorkflowList();
+ public void shouldReturnResultsWithDefaultWhenSizeIsNegative() throws Exception {
+ List<Workflow> workflowMocks = createSize2AndOffset1For5WorkflowList();
doReturn(workflowMocks).when(workflowManagerMock).list(any());
MockHttpServletResponse response = mockMvc.perform(
get(RestPath.getWorkflowsPathAllQueryParams(DEFAULT_SORT_VALUE, "-2", "1"))
.header(RestConstants.USER_ID_HEADER_PARAM, USER_ID).contentType(APPLICATION_JSON))
- .andDo(print()).andExpect(status().isOk()).andExpect(status().is(200)).andReturn()
- .getResponse();
+ .andDo(print()).andExpect(status().isOk()).andExpect(status().is(200))
+ .andReturn().getResponse();
CollectionWrapper workflowListResponse =
new ObjectMapper().readValue(response.getContentAsString(), CollectionWrapper.class);
- assertEquals(LIMIT_DEFAULT, workflowListResponse.getLimit());
- assertEquals(1, workflowListResponse.getOffset());
+ assertEquals(SIZE_DEFAULT, workflowListResponse.getSize());
+ assertEquals(1, workflowListResponse.getPage());
assertEquals(2, workflowListResponse.getTotal());
}
@@ -148,26 +139,26 @@ public class WorkflowControllerTest {
MockHttpServletResponse response = mockMvc.perform(
get(RestPath.getWorkflowsPathAllQueryParams(DEFAULT_SORT_VALUE, "2", "-1"))
.header(RestConstants.USER_ID_HEADER_PARAM, USER_ID).contentType(APPLICATION_JSON))
- .andDo(print()).andExpect(status().isOk()).andExpect(status().is(200)).andReturn()
- .getResponse();
+ .andDo(print()).andExpect(status().isOk()).andExpect(status().is(200))
+ .andReturn().getResponse();
CollectionWrapper workflowListResponse =
new ObjectMapper().readValue(response.getContentAsString(), CollectionWrapper.class);
- assertEquals(2, workflowListResponse.getLimit());
- assertEquals(OFFSET_DEFAULT, workflowListResponse.getOffset());
+ assertEquals(2, workflowListResponse.getSize());
+ assertEquals(PAGE_DEFAULT, workflowListResponse.getPage());
assertEquals(0, workflowListResponse.getTotal());
}
@Test
- public void shouldFallbackOnDefaultLimitWhenLimitIsNotAnInteger() throws Exception {
+ public void shouldFallbackOnDefaultSizeWhenSizeIsNotAnInteger() throws Exception {
MockHttpServletResponse response = mockMvc.perform(
get(RestPath.getWorkflowsPathAllQueryParams(DEFAULT_SORT_VALUE, "abc", "0"))
.header(RestConstants.USER_ID_HEADER_PARAM, USER_ID).contentType(APPLICATION_JSON))
- .andDo(print()).andExpect(status().isOk()).andExpect(status().is(200)).andReturn()
- .getResponse();
+ .andDo(print()).andExpect(status().isOk()).andExpect(status().is(200))
+ .andReturn().getResponse();
CollectionWrapper workflowListResponse =
new ObjectMapper().readValue(response.getContentAsString(), CollectionWrapper.class);
- assertEquals(LIMIT_DEFAULT, workflowListResponse.getLimit());
- assertEquals(0, workflowListResponse.getOffset());
+ assertEquals(SIZE_DEFAULT, workflowListResponse.getSize());
+ assertEquals(0, workflowListResponse.getPage());
assertEquals(0, workflowListResponse.getTotal());
}
@@ -176,12 +167,12 @@ public class WorkflowControllerTest {
MockHttpServletResponse response = mockMvc.perform(
get(RestPath.getWorkflowsPathAllQueryParams(DEFAULT_SORT_VALUE, "2", "abc"))
.header(RestConstants.USER_ID_HEADER_PARAM, USER_ID).contentType(APPLICATION_JSON))
- .andDo(print()).andExpect(status().isOk()).andExpect(status().is(200)).andReturn()
- .getResponse();
+ .andDo(print()).andExpect(status().isOk()).andExpect(status().is(200))
+ .andReturn().getResponse();
CollectionWrapper workflowListResponse =
new ObjectMapper().readValue(response.getContentAsString(), CollectionWrapper.class);
- assertEquals(2, workflowListResponse.getLimit());
- assertEquals(OFFSET_DEFAULT, workflowListResponse.getOffset());
+ assertEquals(2, workflowListResponse.getSize());
+ assertEquals(PAGE_DEFAULT, workflowListResponse.getPage());
assertEquals(0, workflowListResponse.getTotal());
}
@@ -190,41 +181,41 @@ public class WorkflowControllerTest {
MockHttpServletResponse response = mockMvc.perform(
get(RestPath.getWorkflowsPathAllQueryParams("invalidSortField,asc", "2", "1"))
.header(RestConstants.USER_ID_HEADER_PARAM, USER_ID).contentType(APPLICATION_JSON))
- .andDo(print()).andExpect(status().isBadRequest()).andExpect(status().is(400)).andReturn()
- .getResponse();
+ .andDo(print()).andExpect(status().isBadRequest())
+ .andExpect(status().is(400)).andReturn().getResponse();
assertEquals(String.format(INVALID_PAGINATION_PARAMETER_FORMAT, SORT_PARAM, "invalidSortField",
PAGINATION_PARAMETER_INVALID_SORT_FIELD_SUFFIX + getSupportedSortFields()),
response.getContentAsString());
}
@Test
- public void shouldReturnAscSortedLimitOffsetAppliedWorkflowsWhenSortIsNotSpecified() throws Exception {
- List<Workflow> workflowMocks = createLimit2AndOffset1For5WorkflowList();
+ public void shouldReturnAscSortedSizeOffsetAppliedWorkflowsWhenSortIsNotSpecified() throws Exception {
+ List<Workflow> workflowMocks = createSize2AndOffset1For5WorkflowList();
doReturn(workflowMocks).when(workflowManagerMock).list(any());
mockMvc.perform(
- get(RestPath.getWorkflowsPathNoSort("2", "1"))
- .header(RestConstants.USER_ID_HEADER_PARAM, USER_ID).contentType(APPLICATION_JSON))
- .andDo(print()).andExpect(status().isOk()).andExpect(jsonPath("$.results", hasSize(2)));
+ get(RestPath.getWorkflowsPathNoSort("2", "1")).header(RestConstants.USER_ID_HEADER_PARAM, USER_ID)
+ .contentType(APPLICATION_JSON)).andDo(print())
+ .andExpect(status().isOk()).andExpect(jsonPath("$.results", hasSize(2)));
}
@Test
- public void shouldReturnDefaultLimitOffsetAppliedWorkflowsWhenLimitIsNotSpecified() throws Exception {
- List<Workflow> workflowMocks = createLimit2AndOffset1For5WorkflowList();
+ public void shouldReturnDefaultSizeOffsetAppliedWorkflowsWhenSizeIsNotSpecified() throws Exception {
+ List<Workflow> workflowMocks = createSize2AndOffset1For5WorkflowList();
doReturn(workflowMocks).when(workflowManagerMock).list(any());
mockMvc.perform(
- get(RestPath.getWorkflowsPathNoSortAndLimit("1"))
- .header(RestConstants.USER_ID_HEADER_PARAM, USER_ID).contentType(APPLICATION_JSON))
- .andDo(print()).andExpect(status().isOk()).andExpect(jsonPath("$.results", hasSize(2)));
+ get(RestPath.getWorkflowsPathNoSortAndSize("1")).header(RestConstants.USER_ID_HEADER_PARAM, USER_ID)
+ .contentType(APPLICATION_JSON)).andDo(print())
+ .andExpect(status().isOk()).andExpect(jsonPath("$.results", hasSize(2)));
}
@Test
public void shouldReturnDefaultOffsetAppliedWorkflowsWhenOffsetIsNotSpecified() throws Exception {
- List<Workflow> workflowMocks = createLimit1WorkflowList();
+ List<Workflow> workflowMocks = createSize1WorkflowList();
doReturn(workflowMocks).when(workflowManagerMock).list(any());
mockMvc.perform(
- get(RestPath.getWorkflowsPathNoSortAndOffset("1"))
- .header(RestConstants.USER_ID_HEADER_PARAM, USER_ID).contentType(APPLICATION_JSON))
- .andDo(print()).andExpect(status().isOk()).andExpect(jsonPath("$.results", hasSize(1)));
+ get(RestPath.getWorkflowsPathNoSortAndOffset("1")).header(RestConstants.USER_ID_HEADER_PARAM, USER_ID)
+ .contentType(APPLICATION_JSON)).andDo(print())
+ .andExpect(status().isOk()).andExpect(jsonPath("$.results", hasSize(1)));
}
/* @Test
@@ -248,14 +239,14 @@ public class WorkflowControllerTest {
return workflowList;
}
- private List<Workflow> createLimit2AndOffset1For5WorkflowList() {
+ private List<Workflow> createSize2AndOffset1For5WorkflowList() {
List<Workflow> workflowList = new ArrayList<>();
workflowList.add(createWorkflow(2, true));
workflowList.add(createWorkflow(3, true));
return workflowList;
}
- private List<Workflow> createLimit1WorkflowList() {
+ private List<Workflow> createSize1WorkflowList() {
List<Workflow> workflowList = new ArrayList<>();
workflowList.add(createWorkflow(0, true));
return workflowList;