Add BoardService implementation. #3
@ -3,22 +3,98 @@ package wekan.wrapper.entity;
|
|||||||
public class BoardPrototype {
|
public class BoardPrototype {
|
||||||
private String title;
|
private String title;
|
||||||
private String owner;
|
private String owner;
|
||||||
private boolean isAdmin = true;
|
private boolean isAdmin;
|
||||||
private boolean isActive = true;
|
private boolean isActive;
|
||||||
private boolean isNoComments = false;
|
private boolean isNoComments;
|
||||||
private boolean isCommentOnly = false;
|
private boolean isCommentOnly;
|
||||||
private Permission permission = Permission.PRIVATE;
|
private Permission permission;
|
||||||
private Color color = Color.BELIZE;
|
private Color color;
|
||||||
|
|
||||||
public BoardPrototype(String title, String owner) {
|
private BoardPrototype(
|
||||||
|
String title,
|
||||||
|
String owner,
|
||||||
|
boolean isAdmin,
|
||||||
|
boolean isActive,
|
||||||
|
boolean isNoComments,
|
||||||
|
boolean isCommentOnly,
|
||||||
|
Permission permission,
|
||||||
|
Color color
|
||||||
|
) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
|
this.isAdmin = isAdmin;
|
||||||
|
this.isActive = isActive;
|
||||||
|
this.isNoComments = isNoComments;
|
||||||
|
this.isCommentOnly = isCommentOnly;
|
||||||
|
this.permission = permission;
|
||||||
|
this.color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BoardPrototype(String title, String owner, Color color) {
|
public static class Builder {
|
||||||
this.title = title;
|
private String title;
|
||||||
this.owner = owner;
|
private String owner;
|
||||||
this.color = color;
|
private boolean isAdmin = true;
|
||||||
|
private boolean isActive = true;
|
||||||
|
private boolean isNoComments = false;
|
||||||
|
private boolean isCommentOnly = false;
|
||||||
|
private Permission permission = Permission.PRIVATE;
|
||||||
|
private Color color = Color.BELIZE;
|
||||||
|
|
||||||
|
public Builder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public BoardPrototype build() {
|
||||||
|
return new BoardPrototype(
|
||||||
|
title,
|
||||||
|
owner,
|
||||||
|
isAdmin,
|
||||||
|
isActive,
|
||||||
|
isNoComments,
|
||||||
|
isCommentOnly,
|
||||||
|
permission,
|
||||||
|
color
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setOwner(String owner) {
|
||||||
|
this.owner = owner;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setAdmin(boolean admin) {
|
||||||
|
isAdmin = admin;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setActive(boolean active) {
|
||||||
|
isActive = active;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setNoComments(boolean noComments) {
|
||||||
|
isNoComments = noComments;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setCommentOnly(boolean commentOnly) {
|
||||||
|
isCommentOnly = commentOnly;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setPermission(Permission permission) {
|
||||||
|
this.permission = permission;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setColor(Color color) {
|
||||||
|
this.color = color;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,12 @@ public class BoardServiceTest {
|
|||||||
mockWebServer.enqueue(response);
|
mockWebServer.enqueue(response);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Board board = service.newBoard(new BoardPrototype("title", "owner"))
|
Board board = service.newBoard(
|
||||||
|
new BoardPrototype.Builder()
|
||||||
|
.setTitle("title")
|
||||||
|
.setOwner("owner")
|
||||||
|
.build()
|
||||||
|
)
|
||||||
.execute().body();
|
.execute().body();
|
||||||
|
|
||||||
assertNotNull(board);
|
assertNotNull(board);
|
||||||
@ -99,25 +104,25 @@ public class BoardServiceTest {
|
|||||||
MockResponse response = new MockResponse()
|
MockResponse response = new MockResponse()
|
||||||
.setResponseCode(HttpURLConnection.HTTP_OK)
|
.setResponseCode(HttpURLConnection.HTTP_OK)
|
||||||
.setBody(
|
.setBody(
|
||||||
"{" +
|
"{" +
|
||||||
"\"_id\":\"id\"," +
|
"\"_id\":\"id\"," +
|
||||||
"\"title\":\"my title\"," +
|
"\"title\":\"my title\"," +
|
||||||
"\"members\":[{\"userId\":\"Si69gNgkJfQuk6uiJ\",\"isAdmin\":true,\"isActive\":true,\"isNoComments\":false,\"isCommentOnly\":false}]," +
|
"\"members\":[{\"userId\":\"Si69gNgkJfQuk6uiJ\",\"isAdmin\":true,\"isActive\":true,\"isNoComments\":false,\"isCommentOnly\":false}]," +
|
||||||
"\"permission\":\"private\"," +
|
"\"permission\":\"private\"," +
|
||||||
"\"color\":\"corteza\"," +
|
"\"color\":\"corteza\"," +
|
||||||
"\"slug\":\"my-title\"," +
|
"\"slug\":\"my-title\"," +
|
||||||
"\"archived\":false," +
|
"\"archived\":false," +
|
||||||
"\"createdAt\":\"2019-11-09T10:01:21.280Z\"," +
|
"\"createdAt\":\"2019-11-09T10:01:21.280Z\"," +
|
||||||
"\"modifiedAt\":\"2019-11-09T10:01:21.280Z\"," +
|
"\"modifiedAt\":\"2019-11-09T10:01:21.280Z\"," +
|
||||||
"\"stars\":0," +
|
"\"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\":\"\"}]," +
|
"\"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," +
|
"\"subtasksDefaultBoardId\":null," +
|
||||||
"\"subtasksDefaultListId\":null," +
|
"\"subtasksDefaultListId\":null," +
|
||||||
"\"allowsSubtasks\":true," +
|
"\"allowsSubtasks\":true," +
|
||||||
"\"presentParentTask\":\"no-parent\"," +
|
"\"presentParentTask\":\"no-parent\"," +
|
||||||
"\"isOvertime\":false," +
|
"\"isOvertime\":false," +
|
||||||
"\"type\":\"board\"" +
|
"\"type\":\"board\"" +
|
||||||
"}"
|
"}"
|
||||||
);
|
);
|
||||||
|
|
||||||
mockWebServer.enqueue(response);
|
mockWebServer.enqueue(response);
|
||||||
|
Loading…
Reference in New Issue
Block a user