in src/it/java/com/epam/digital/data/platform/bphistory/service/api/controller/ProcessHistoryControllerIT.java [138:168]
void shouldReturnSortedByStatusAndStartTimeAsc() throws Exception {
createBpmHistoryProcessAndSaveToDatabase("Process1", "processDefinition",
LocalDateTime.of(2022, 1, 11, 12, 37), "COMPLETED", "testuser", null);
createBpmHistoryProcessAndSaveToDatabase("Process4", "processDefinition",
LocalDateTime.of(2022, 1, 11, 12, 38), "EXTERNALLY_TERMINATED", "testuser", null);
createBpmHistoryProcessAndSaveToDatabase("Process2", "processDefinition",
LocalDateTime.of(2022, 1, 11, 12, 16), "COMPLETED", "testuser", null);
createBpmHistoryProcessAndSaveToDatabase("Process5", "processDefinition",
LocalDateTime.of(2022, 1, 11, 12, 15), "EXTERNALLY_TERMINATED", "testuser", null);
createBpmHistoryProcessAndSaveToDatabase("Process3", "processDefinition",
LocalDateTime.of(2022, 1, 11, 12, 44), "COMPLETED", "testuser", null);
createBpmHistoryProcessAndSaveToDatabase("Process6", "processDefinition",
LocalDateTime.of(2022, 1, 11, 12, 46), "EXTERNALLY_TERMINATED", "testuser", null);
mockMvc.perform(get("/api/history/process-instances")
.header(X_ACCESS_TOKEN.getHeaderName(), OFFICER_TOKEN)
.queryParam("sort", "asc(statusTitle)"))
.andExpect(status().is2xxSuccessful())
.andExpect(jsonPath("$[0].startTime", is("2022-01-11T12:46:00.000Z")))
.andExpect(jsonPath("$[0].status.code", is("EXTERNALLY_TERMINATED")))
.andExpect(jsonPath("$[1].startTime", is("2022-01-11T12:38:00.000Z")))
.andExpect(jsonPath("$[1].status.code", is("EXTERNALLY_TERMINATED")))
.andExpect(jsonPath("$[2].startTime", is("2022-01-11T12:15:00.000Z")))
.andExpect(jsonPath("$[2].status.code", is("EXTERNALLY_TERMINATED")))
.andExpect(jsonPath("$[3].startTime", is("2022-01-11T12:44:00.000Z")))
.andExpect(jsonPath("$[3].status.code", is("COMPLETED")))
.andExpect(jsonPath("$[4].startTime", is("2022-01-11T12:37:00.000Z")))
.andExpect(jsonPath("$[4].status.code", is("COMPLETED")))
.andExpect(jsonPath("$[5].startTime", is("2022-01-11T12:16:00.000Z")))
.andExpect(jsonPath("$[5].status.code", is("COMPLETED")));
}