Added comments and changed default sorting for actions.

This commit is contained in:
Kai Zimmermann
2016-03-03 20:46:50 +01:00
parent e7173aa846
commit 794db18673
3 changed files with 31 additions and 22 deletions

View File

@@ -23,11 +23,6 @@ import org.springframework.data.domain.Sort.Direction;
/**
* Utility class for for paged body generation.
*
*
*
*
*
*
*/
public final class PagingUtility {
/*
@@ -90,8 +85,9 @@ public final class PagingUtility {
if (sortParam != null) {
sorting = new Sort(SortUtility.parse(ActionFields.class, sortParam));
} else {
// default sort
sorting = new Sort(Direction.ASC, ActionFields.ID.getFieldName());
// default sort is DESC in case of action to match behavior
// of management UI (last entry on top)
sorting = new Sort(Direction.DESC, ActionFields.ID.getFieldName());
}
return sorting;
}
@@ -101,7 +97,8 @@ public final class PagingUtility {
if (sortParam != null) {
sorting = new Sort(SortUtility.parse(ActionStatusFields.class, sortParam));
} else {
// default sort
// default sort is DESC in case of action status to match behavior
// of management UI (last entry on top)
sorting = new Sort(Direction.DESC, ActionStatusFields.ID.getFieldName());
}
return sorting;

View File

@@ -833,7 +833,8 @@ public class TargetResourceTest extends AbstractIntegrationTest {
final List<Action> actions = generateTargetWithTwoUpdatesWithOneOverride(knownTargetId);
mvc.perform(get(
RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + RestConstants.TARGET_V1_ACTIONS))
RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + RestConstants.TARGET_V1_ACTIONS)
.param(RestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC"))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
.andExpect(jsonPath("content.[1].id", equalTo(actions.get(1).getId().intValue())))
.andExpect(jsonPath("content.[1].type", equalTo("update")))
@@ -960,7 +961,8 @@ public class TargetResourceTest extends AbstractIntegrationTest {
// page 1: one entry
mvc.perform(get(
RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + RestConstants.TARGET_V1_ACTIONS)
.param(RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(1)))
.param(RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(1))
.param(RestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC"))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
.andExpect(jsonPath("content.[0].id", equalTo(actions.get(0).getId().intValue())))
.andExpect(jsonPath("content.[0].type", equalTo("cancel")))
@@ -976,7 +978,8 @@ public class TargetResourceTest extends AbstractIntegrationTest {
RestConstants.TARGET_V1_REQUEST_MAPPING + "/" + knownTargetId + "/" + RestConstants.TARGET_V1_ACTIONS)
.param(RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(1))
.param(RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(1))
.param(RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(1)))
.param(RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(1))
.param(RestConstants.REQUEST_PARAMETER_SORTING, "ID:ASC"))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
.andExpect(jsonPath("content.[0].id", equalTo(actions.get(1).getId().intValue())))
.andExpect(jsonPath("content.[0].type", equalTo("update")))