diff --git a/wrapper/src/main/java/wekan/wrapper/api/BoardService.java b/wrapper/src/main/java/wekan/wrapper/api/BoardService.java index 00fc8f3..5670561 100644 --- a/wrapper/src/main/java/wekan/wrapper/api/BoardService.java +++ b/wrapper/src/main/java/wekan/wrapper/api/BoardService.java @@ -1,10 +1,7 @@ package wekan.wrapper.api; import retrofit2.Call; -import retrofit2.http.Body; -import retrofit2.http.GET; -import retrofit2.http.POST; -import retrofit2.http.Path; +import retrofit2.http.*; import wekan.wrapper.entity.Board; import wekan.wrapper.entity.BoardPrototype; @@ -19,4 +16,10 @@ public interface BoardService { @GET("api/boards/{boardId}") Call getBoard(@Path("boardId") String boardId); + + @DELETE("api/boards/{boardId}") + Call deleteBoard(@Path("boardId") String boardId); + + @GET("api/users/{userId}/boards") + Call> getBoardsFromUser(@Path("userId") String userId); } diff --git a/wrapper/src/test/java/wekan/wrapper/api/BoardServiceTest.java b/wrapper/src/test/java/wekan/wrapper/api/BoardServiceTest.java index bcb8a95..5ea31c7 100644 --- a/wrapper/src/test/java/wekan/wrapper/api/BoardServiceTest.java +++ b/wrapper/src/test/java/wekan/wrapper/api/BoardServiceTest.java @@ -103,27 +103,7 @@ public class BoardServiceTest { public void getBoardTest() { MockResponse response = new MockResponse() .setResponseCode(HttpURLConnection.HTTP_OK) - .setBody( - "{" + - "\"_id\":\"id\"," + - "\"title\":\"my title\"," + - "\"members\":[{\"userId\":\"Si69gNgkJfQuk6uiJ\",\"isAdmin\":true,\"isActive\":true,\"isNoComments\":false,\"isCommentOnly\":false}]," + - "\"permission\":\"private\"," + - "\"color\":\"corteza\"," + - "\"slug\":\"my-title\"," + - "\"archived\":false," + - "\"createdAt\":\"2019-11-09T10:01:21.280Z\"," + - "\"modifiedAt\":\"2019-11-09T10:01:21.280Z\"," + - "\"stars\":0," + - "\"labels\":[{\"color\":\"green\",\"_id\":\"3NvZnG\",\"name\":\"\"},{\"color\":\"yellow\",\"_id\":\"AcBqR9\",\"name\":\"\"},{\"color\":\"orange\",\"_id\":\"JxEw9Z\",\"name\":\"\"},{\"color\":\"red\",\"_id\":\"grdRCS\",\"name\":\"\"},{\"color\":\"purple\",\"_id\":\"buMfKA\",\"name\":\"\"},{\"color\":\"blue\",\"_id\":\"sbi9FZ\",\"name\":\"\"}]," + - "\"subtasksDefaultBoardId\":null," + - "\"subtasksDefaultListId\":null," + - "\"allowsSubtasks\":true," + - "\"presentParentTask\":\"no-parent\"," + - "\"isOvertime\":false," + - "\"type\":\"board\"" + - "}" - ); + .setBody(board1); mockWebServer.enqueue(response); @@ -132,9 +112,9 @@ public class BoardServiceTest { .execute().body(); assertNotNull(board); - assertEquals("id", board.getId()); - assertEquals("my title", board.getTitle()); - assertEquals("my-title", board.getSlug()); + assertEquals("id1", board.getId()); + assertEquals("my title1", board.getTitle()); + assertEquals("my-title-1", board.getSlug()); assertFalse(board.isArchived()); assertEquals(0, board.getStarts()); assertEquals(Permission.PRIVATE, board.getPermission()); @@ -149,4 +129,85 @@ public class BoardServiceTest { e.printStackTrace(); } } + + @Test + public void getBoardsFromUser() { + MockResponse response = new MockResponse() + .setResponseCode(HttpURLConnection.HTTP_OK) + .setBody("[ " + board1 + ", " + board2 + ", " + board3 + " ]"); + + mockWebServer.enqueue(response); + + try { + List boards = service.getBoardsFromUser("user-id") + .execute().body(); + + assertNotNull(boards); + assertEquals(3, boards.size()); + + } catch (IOException e) { + e.printStackTrace(); + } + } + + private static final String board1 = + "{" + + "\"_id\":\"id1\"," + + "\"title\":\"my title1\"," + + "\"members\":[{\"userId\":\"Si69gNgkJfQuk6uiJ\",\"isAdmin\":true,\"isActive\":true,\"isNoComments\":false,\"isCommentOnly\":false}]," + + "\"permission\":\"private\"," + + "\"color\":\"corteza\"," + + "\"slug\":\"my-title-1\"," + + "\"archived\":false," + + "\"createdAt\":\"2019-11-09T10:01:21.280Z\"," + + "\"modifiedAt\":\"2019-11-09T10:01:21.280Z\"," + + "\"stars\":0," + + "\"labels\":[{\"color\":\"green\",\"_id\":\"3NvZnG\",\"name\":\"\"},{\"color\":\"yellow\",\"_id\":\"AcBqR9\",\"name\":\"\"},{\"color\":\"orange\",\"_id\":\"JxEw9Z\",\"name\":\"\"},{\"color\":\"red\",\"_id\":\"grdRCS\",\"name\":\"\"},{\"color\":\"purple\",\"_id\":\"buMfKA\",\"name\":\"\"},{\"color\":\"blue\",\"_id\":\"sbi9FZ\",\"name\":\"\"}]," + + "\"subtasksDefaultBoardId\":null," + + "\"subtasksDefaultListId\":null," + + "\"allowsSubtasks\":true," + + "\"presentParentTask\":\"no-parent\"," + + "\"isOvertime\":false," + + "\"type\":\"board\"" + + "}"; + private static final String board2 = + "{" + + "\"_id\":\"id2\"," + + "\"title\":\"my title2\"," + + "\"members\":[{\"userId\":\"Si69gNgkJfQuk6uiJ\",\"isAdmin\":true,\"isActive\":true,\"isNoComments\":false,\"isCommentOnly\":false}]," + + "\"permission\":\"private\"," + + "\"color\":\"corteza\"," + + "\"slug\":\"my-title-2\"," + + "\"archived\":false," + + "\"createdAt\":\"2019-11-09T10:01:21.280Z\"," + + "\"modifiedAt\":\"2019-11-09T10:01:21.280Z\"," + + "\"stars\":0," + + "\"labels\":[{\"color\":\"green\",\"_id\":\"3NvZnG\",\"name\":\"\"},{\"color\":\"yellow\",\"_id\":\"AcBqR9\",\"name\":\"\"},{\"color\":\"orange\",\"_id\":\"JxEw9Z\",\"name\":\"\"},{\"color\":\"red\",\"_id\":\"grdRCS\",\"name\":\"\"},{\"color\":\"purple\",\"_id\":\"buMfKA\",\"name\":\"\"},{\"color\":\"blue\",\"_id\":\"sbi9FZ\",\"name\":\"\"}]," + + "\"subtasksDefaultBoardId\":null," + + "\"subtasksDefaultListId\":null," + + "\"allowsSubtasks\":true," + + "\"presentParentTask\":\"no-parent\"," + + "\"isOvertime\":false," + + "\"type\":\"board\"" + + "}"; + private static final String board3 = + "{" + + "\"_id\":\"id3\"," + + "\"title\":\"my title3\"," + + "\"members\":[{\"userId\":\"Si69gNgkJfQuk6uiJ\",\"isAdmin\":true,\"isActive\":true,\"isNoComments\":false,\"isCommentOnly\":false}]," + + "\"permission\":\"private\"," + + "\"color\":\"corteza\"," + + "\"slug\":\"my-title-3\"," + + "\"archived\":false," + + "\"createdAt\":\"2019-11-09T10:01:21.280Z\"," + + "\"modifiedAt\":\"2019-11-09T10:01:21.280Z\"," + + "\"stars\":0," + + "\"labels\":[{\"color\":\"green\",\"_id\":\"3NvZnG\",\"name\":\"\"},{\"color\":\"yellow\",\"_id\":\"AcBqR9\",\"name\":\"\"},{\"color\":\"orange\",\"_id\":\"JxEw9Z\",\"name\":\"\"},{\"color\":\"red\",\"_id\":\"grdRCS\",\"name\":\"\"},{\"color\":\"purple\",\"_id\":\"buMfKA\",\"name\":\"\"},{\"color\":\"blue\",\"_id\":\"sbi9FZ\",\"name\":\"\"}]," + + "\"subtasksDefaultBoardId\":null," + + "\"subtasksDefaultListId\":null," + + "\"allowsSubtasks\":true," + + "\"presentParentTask\":\"no-parent\"," + + "\"isOvertime\":false," + + "\"type\":\"board\"" + + "}"; }