Skip to content

Commit

Permalink
Add: query todoList and create todoList API, and integration test for…
Browse files Browse the repository at this point in the history
… todoList controller
  • Loading branch information
HarryQin99 committed Sep 29, 2021
1 parent b61ebac commit 8a82883
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ public ResponseResult<Object> getAllTodoListData(@RequestParam("topNTodoListData
Integer userId = userService.getId();
List<ToDoList> toDoListsActive = toDoListService.queryToDoListByUserId(userId, ToDoListStatus.ACTIVE);
List<ToDoList> toDoListsDone = toDoListService.queryToDoListByUserId(userId, ToDoListStatus.DONE);
List<ToDoList> toDoListDelete = toDoListService.queryToDoListByUserId(userId, ToDoListStatus.DELETED);
toDoListsActive.addAll(toDoListsDone);
if (toDoListsActive.size() > topNTodoListData) {
toDoListsActive.addAll(toDoListDelete);
if (topNTodoListData == -1 && toDoListsActive.size() > topNTodoListData) {
toDoListsActive.subList(0, topNTodoListData);
}
return ResponseResult.suc("Query user's todoList", toDoListsActive);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ spring:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/testdb?serverTimezone=Australia/Victoria
username: root
password: Qyf270999
password: 415623
schema: classpath:db/schema-test.sql
data: classpath:db/data-test.sql
initialization-mode: always
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void testAAddNewTodoListData() throws Exception {
* @throws Exception
*/
@Test
@Order(1)
@Order(2)
public void testBQueryNewTodoListData() throws Exception {

MvcResult mvcResult = mvc.perform(MockMvcRequestBuilders.get("/toDoList").param("topNTodoListData", String.valueOf(2)).header(SecurityConstants.TOKEN_HEADER,token))
Expand Down

0 comments on commit 8a82883

Please sign in to comment.