add deleteBoard and getBoardsFromUser
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Raffaele Mignone 2019-11-09 14:39:30 +01:00
parent 9ea7914e91
commit f4df78dc73
Signed by: norangebit
GPG Key ID: F5255658CB220573
2 changed files with 92 additions and 28 deletions

View File

@ -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<Board> getBoard(@Path("boardId") String boardId);
@DELETE("api/boards/{boardId}")
Call<Void> deleteBoard(@Path("boardId") String boardId);
@GET("api/users/{userId}/boards")
Call<List<Board>> getBoardsFromUser(@Path("userId") String userId);
}

View File

@ -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<Board> 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\"" +
"}";
}