Merge branch 'feature_list' of kanban/wedroid into develop
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
commit
29b6057fe6
54
wrapper/src/main/java/wekan/wrapper/api/ListService.java
Normal file
54
wrapper/src/main/java/wekan/wrapper/api/ListService.java
Normal file
@ -0,0 +1,54 @@
|
||||
package wekan.wrapper.api;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.*;
|
||||
import wekan.wrapper.entity.WList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public interface ListService {
|
||||
|
||||
/**
|
||||
* Get the list of Lists attached to a board
|
||||
*
|
||||
* @param boardId the ID of the board
|
||||
* @return the list of all lists
|
||||
*/
|
||||
@GET("/api/boards/{board}/lists")
|
||||
Call<List<WList>> getAllList(@Path("board") String boardId);
|
||||
|
||||
/**
|
||||
* Add a List to a board
|
||||
*
|
||||
* @param boardId the ID of the string
|
||||
* @param title title of the new list
|
||||
* @return the new list
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("/api/boards/{board}/lists")
|
||||
Call<WList> newList(
|
||||
@Path("board") String boardId,
|
||||
@Field("title") String title
|
||||
);
|
||||
|
||||
/**
|
||||
* Get a List attached to a board
|
||||
* @param boardId the ID of the board
|
||||
* @param listId the ID of the list
|
||||
* @return the list
|
||||
*/
|
||||
@GET("/api/boards/{board}/lists/{list}")
|
||||
Call<WList> getList(@Path("board") String boardId, @Path("list") String listId);
|
||||
|
||||
/**
|
||||
* Delete a List
|
||||
* @param boardId the ID of the board
|
||||
* @param listId the ID of the list
|
||||
* @return ID of the delete list
|
||||
*/
|
||||
@DELETE("/api/boards/{board}/lists/{list}")
|
||||
Call<WList> deleteList (@Path("board") String boardId, @Path("list") String listId);
|
||||
|
||||
|
||||
}
|
91
wrapper/src/main/java/wekan/wrapper/entity/WList.java
Normal file
91
wrapper/src/main/java/wekan/wrapper/entity/WList.java
Normal file
@ -0,0 +1,91 @@
|
||||
package wekan.wrapper.entity;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class WList {
|
||||
@SerializedName("_id")
|
||||
private String id;
|
||||
private String title;
|
||||
private Boolean starred;
|
||||
private Boolean archived;
|
||||
private String boardId;
|
||||
private String swimlanedId;
|
||||
private String createdAt;
|
||||
private int sort;
|
||||
private String updateAt;
|
||||
private String modifiedAt;
|
||||
private WipLimit wipLimit;
|
||||
private Color color;
|
||||
private String type;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public Boolean getStarred() {
|
||||
return starred;
|
||||
}
|
||||
|
||||
public Boolean getArchived() {
|
||||
return archived;
|
||||
}
|
||||
|
||||
public String getBoardId() {
|
||||
return boardId;
|
||||
}
|
||||
|
||||
public String getSwimlanedId() {
|
||||
return swimlanedId;
|
||||
}
|
||||
|
||||
public String getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public int getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
public String getUpdateAt() {
|
||||
return updateAt;
|
||||
}
|
||||
|
||||
public String getModifiedAt() {
|
||||
return modifiedAt;
|
||||
}
|
||||
|
||||
public WipLimit getWipLimit() {
|
||||
return wipLimit;
|
||||
}
|
||||
|
||||
public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WList{" +
|
||||
"id='" + id + '\'' +
|
||||
", title='" + title + '\'' +
|
||||
", starred=" + starred +
|
||||
", archived=" + archived +
|
||||
", boardId='" + boardId + '\'' +
|
||||
", swimlanedId='" + swimlanedId + '\'' +
|
||||
", createdAt='" + createdAt + '\'' +
|
||||
", sort=" + sort +
|
||||
", updateAt='" + updateAt + '\'' +
|
||||
", modifiedAt='" + modifiedAt + '\'' +
|
||||
", wipLimit=" + wipLimit +
|
||||
", color='" + color + '\'' +
|
||||
", type='" + type + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
19
wrapper/src/main/java/wekan/wrapper/entity/WipLimit.java
Normal file
19
wrapper/src/main/java/wekan/wrapper/entity/WipLimit.java
Normal file
@ -0,0 +1,19 @@
|
||||
package wekan.wrapper.entity;
|
||||
|
||||
class WipLimit {
|
||||
private int value;
|
||||
private boolean enable;
|
||||
private boolean soft;
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean isEnable() {
|
||||
return enable;
|
||||
}
|
||||
|
||||
public boolean isSoft() {
|
||||
return soft;
|
||||
}
|
||||
}
|
148
wrapper/src/test/java/wekan/wrapper/api/ListServiceTest.java
Normal file
148
wrapper/src/test/java/wekan/wrapper/api/ListServiceTest.java
Normal file
@ -0,0 +1,148 @@
|
||||
package wekan.wrapper.api;
|
||||
|
||||
import okhttp3.mockwebserver.MockResponse;
|
||||
import okhttp3.mockwebserver.MockWebServer;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
import wekan.wrapper.entity.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class ListServiceTest {
|
||||
private MockWebServer mockWebServer = new MockWebServer();
|
||||
private ListService service = null;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
try {
|
||||
mockWebServer.start();
|
||||
service = new Retrofit.Builder()
|
||||
.baseUrl(mockWebServer.url("/"))
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.build()
|
||||
.create(ListService.class);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
public void teardown() {
|
||||
try {
|
||||
mockWebServer.shutdown();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllList() {
|
||||
MockResponse response = new MockResponse()
|
||||
.setResponseCode(HttpURLConnection.HTTP_OK)
|
||||
.setBody(
|
||||
"[ " + WLIST_1 + ", " + WLIST_2 + " ]"
|
||||
);
|
||||
|
||||
mockWebServer.enqueue(response);
|
||||
|
||||
try {
|
||||
List<WList> lists = service.getAllList("boardId")
|
||||
.execute().body();
|
||||
|
||||
assertNotNull(lists);
|
||||
assertEquals(2, lists.size());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getList() {
|
||||
MockResponse response = new MockResponse()
|
||||
.setResponseCode(HttpURLConnection.HTTP_OK)
|
||||
.setBody(WLIST_1);
|
||||
|
||||
mockWebServer.enqueue(response);
|
||||
|
||||
try {
|
||||
WList list = service.getList("boardId", "listId")
|
||||
.execute().body();
|
||||
|
||||
assertNotNull(list);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void newList() {
|
||||
MockResponse response = new MockResponse()
|
||||
.setResponseCode(HttpURLConnection.HTTP_OK)
|
||||
.setBody(WLIST_2);
|
||||
|
||||
mockWebServer.enqueue(response);
|
||||
|
||||
try {
|
||||
WList list = service.newList("boardId", "body")
|
||||
.execute().body();
|
||||
|
||||
assertNotNull(list);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteList() {
|
||||
MockResponse response = new MockResponse()
|
||||
.setResponseCode(HttpURLConnection.HTTP_OK)
|
||||
.setBody("{ \"_id\": \"list id\" }");
|
||||
|
||||
mockWebServer.enqueue(response);
|
||||
|
||||
try {
|
||||
WList list = service.deleteList("boardId", "listId")
|
||||
.execute().body();
|
||||
|
||||
assertNotNull(list);
|
||||
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static final String WLIST_1 = "{\"_id\":\"j3gzdbCJQYGnzuLhu\"," +
|
||||
"\"title\":\"list 1\"," +
|
||||
"\"boardId\":\"9QttSbCKjJ8v7zB3g\"," +
|
||||
"\"sort\":1," +
|
||||
"\"type\":\"list\"," +
|
||||
"\"starred\":false," +
|
||||
"\"archived\":false," +
|
||||
"\"swimlaneId\":\"\"," +
|
||||
"\"createdAt\":\"2019-11-14T10:34:14.120Z\"," +
|
||||
"\"updatedAt\":\"2019-11-14T10:34:14.120Z\"," +
|
||||
"\"modifiedAt\":\"2019-11-14T10:34:14.666Z\"," +
|
||||
"\"wipLimit\":{\"value\":1,\"enabled\":false,\"soft\":false}" +
|
||||
"}";
|
||||
private static final String WLIST_2 = "{\"_id\":\"j3gzdbCJQYGnzuLhu\"," +
|
||||
"\"title\":\"list 2\"," +
|
||||
"\"boardId\":\"9QttSbCKjJ8v7zB3d\"," +
|
||||
"\"sort\":1," +
|
||||
"\"type\":\"list\"," +
|
||||
"\"starred\":false," +
|
||||
"\"archived\":false," +
|
||||
"\"swimlaneId\":\"\"," +
|
||||
"\"createdAt\":\"2019-11-14T10:34:14.120Z\"," +
|
||||
"\"updatedAt\":\"2019-11-14T10:34:14.120Z\"," +
|
||||
"\"modifiedAt\":\"2019-11-14T10:34:14.666Z\"," +
|
||||
"\"wipLimit\":{\"value\":1,\"enabled\":false,\"soft\":false}" +
|
||||
"}";
|
||||
}
|
Loading…
Reference in New Issue
Block a user