Add BoardService implementation. #3
@ -1,10 +1,7 @@
|
|||||||
package wekan.wrapper.api;
|
package wekan.wrapper.api;
|
||||||
|
|
||||||
import retrofit2.Call;
|
import retrofit2.Call;
|
||||||
import retrofit2.http.Body;
|
import retrofit2.http.*;
|
||||||
import retrofit2.http.GET;
|
|
||||||
import retrofit2.http.POST;
|
|
||||||
import retrofit2.http.Path;
|
|
||||||
import wekan.wrapper.entity.Board;
|
import wekan.wrapper.entity.Board;
|
||||||
import wekan.wrapper.entity.BoardPrototype;
|
import wekan.wrapper.entity.BoardPrototype;
|
||||||
|
|
||||||
@ -19,4 +16,10 @@ public interface BoardService {
|
|||||||
|
|
||||||
@GET("api/boards/{boardId}")
|
@GET("api/boards/{boardId}")
|
||||||
Call<Board> getBoard(@Path("boardId") String 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);
|
||||||
}
|
}
|
||||||
|
@ -103,27 +103,7 @@ public class BoardServiceTest {
|
|||||||
public void getBoardTest() {
|
public void getBoardTest() {
|
||||||
MockResponse response = new MockResponse()
|
MockResponse response = new MockResponse()
|
||||||
.setResponseCode(HttpURLConnection.HTTP_OK)
|
.setResponseCode(HttpURLConnection.HTTP_OK)
|
||||||
.setBody(
|
.setBody(board1);
|
||||||
"{" +
|
|
||||||
"\"_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\"" +
|
|
||||||
"}"
|
|
||||||
);
|
|
||||||
|
|
||||||
mockWebServer.enqueue(response);
|
mockWebServer.enqueue(response);
|
||||||
|
|
||||||
@ -132,9 +112,9 @@ public class BoardServiceTest {
|
|||||||
.execute().body();
|
.execute().body();
|
||||||
|
|
||||||
assertNotNull(board);
|
assertNotNull(board);
|
||||||
assertEquals("id", board.getId());
|
assertEquals("id1", board.getId());
|
||||||
assertEquals("my title", board.getTitle());
|
assertEquals("my title1", board.getTitle());
|
||||||
assertEquals("my-title", board.getSlug());
|
assertEquals("my-title-1", board.getSlug());
|
||||||
assertFalse(board.isArchived());
|
assertFalse(board.isArchived());
|
||||||
assertEquals(0, board.getStarts());
|
assertEquals(0, board.getStarts());
|
||||||
assertEquals(Permission.PRIVATE, board.getPermission());
|
assertEquals(Permission.PRIVATE, board.getPermission());
|
||||||
@ -149,4 +129,85 @@ public class BoardServiceTest {
|
|||||||
e.printStackTrace();
|
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\"" +
|
||||||
|
"}";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user