add CardCommentsService #9
@ -11,9 +11,9 @@ public interface CardCommentService {
|
|||||||
/**
|
/**
|
||||||
* Get all comments attached to a card.
|
* Get all comments attached to a card.
|
||||||
*
|
*
|
||||||
* @param boardId The ID of the board
|
* @param boardId The ID of the board
|
||||||
* @param cardId The ID of the card
|
* @param cardId The ID of the card
|
||||||
* @return The list of the comments
|
* @return The list of the comments
|
||||||
*/
|
*/
|
||||||
@GET("/api/boards/{boardId}/cards/{cardId}/comments")
|
@GET("/api/boards/{boardId}/cards/{cardId}/comments")
|
||||||
Call<List<Comment>> getAllComments(
|
Call<List<Comment>> getAllComments(
|
||||||
@ -24,11 +24,11 @@ public interface CardCommentService {
|
|||||||
/**
|
/**
|
||||||
* Post new comment attached on the give card.
|
* Post new comment attached on the give card.
|
||||||
*
|
*
|
||||||
* @param boardId The ID of the board
|
* @param boardId The ID of the board
|
||||||
* @param cardId The ID of the card
|
* @param cardId The ID of the card
|
||||||
* @param authorId The ID of the author
|
* @param authorId The ID of the author
|
||||||
* @param comment The comment
|
* @param comment The comment
|
||||||
* @return The id of the new comment
|
* @return The id of the new comment
|
||||||
*/
|
*/
|
||||||
@FormUrlEncoded
|
@FormUrlEncoded
|
||||||
@POST("/api/boards/{boardId}/cards/{cardId}/comments")
|
@POST("/api/boards/{boardId}/cards/{cardId}/comments")
|
||||||
@ -38,4 +38,33 @@ public interface CardCommentService {
|
|||||||
@Field("authorId") String authorId,
|
@Field("authorId") String authorId,
|
||||||
@Field("comment") String comment
|
@Field("comment") String comment
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a comment attached to a card.
|
||||||
|
*
|
||||||
|
* @param boardId The ID of the board
|
||||||
|
* @param cardId The ID of the card
|
||||||
|
* @param commentId The ID of the comment
|
||||||
|
* @return The comment
|
||||||
|
*/
|
||||||
|
@GET("/api/boards/{boardId}/cards/{cardId}/comments/{commentId}")
|
||||||
|
Call<Comment> getComment(
|
||||||
|
@Path("boardId") String boardId,
|
||||||
|
@Path("cardId") String cardId,
|
||||||
|
@Path("commentId") String commentId
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a comment attached to a card.
|
||||||
|
*
|
||||||
|
* @param boardId The ID of the board
|
||||||
|
* @param cardId The ID of the card
|
||||||
|
* @param commentId The ID of the comment
|
||||||
|
*/
|
||||||
|
@DELETE("/api/boards/{boardId}/cards/{cardId}/comments/{commentId}")
|
||||||
|
Call<Void> deleteComment(
|
||||||
|
@Path("boardId") String boardId,
|
||||||
|
@Path("cardId") String cardId,
|
||||||
|
@Path("commentId") String commentId
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,17 @@ package wekan.wrapper.entity;
|
|||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
public class Comment {
|
public class Comment {
|
||||||
@SerializedName("_id")
|
@SerializedName("_id")
|
||||||
private String id;
|
private String id;
|
||||||
private String comment;
|
private String comment;
|
||||||
private String authorId;
|
private String authorId;
|
||||||
|
private String boardId;
|
||||||
|
private String cardId;
|
||||||
|
private Date createdAt;
|
||||||
|
private Date modifiedAt;
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
@ -26,6 +32,10 @@ public class Comment {
|
|||||||
"id='" + id + '\'' +
|
"id='" + id + '\'' +
|
||||||
", comment='" + comment + '\'' +
|
", comment='" + comment + '\'' +
|
||||||
", authorId='" + authorId + '\'' +
|
", authorId='" + authorId + '\'' +
|
||||||
|
", boardId='" + boardId + '\'' +
|
||||||
|
", cardId='" + cardId + '\'' +
|
||||||
|
", createdAt=" + createdAt +
|
||||||
|
", modifiedAt=" + modifiedAt +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,7 @@ import org.junit.Before;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
import retrofit2.converter.gson.GsonConverterFactory;
|
import retrofit2.converter.gson.GsonConverterFactory;
|
||||||
import wekan.wrapper.entity.Color;
|
|
||||||
import wekan.wrapper.entity.Comment;
|
import wekan.wrapper.entity.Comment;
|
||||||
import wekan.wrapper.entity.Swimlane;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
@ -89,6 +87,27 @@ public class CardCommentServiceTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getComment() {
|
||||||
|
MockResponse response = new MockResponse()
|
||||||
|
.setResponseCode(HttpURLConnection.HTTP_OK)
|
||||||
|
.setBody(COMMENT_3);
|
||||||
|
|
||||||
|
mockWebServer.enqueue(response);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Comment comment = service.getComment(
|
||||||
|
"board id",
|
||||||
|
"card id",
|
||||||
|
"comment id"
|
||||||
|
).execute().body();
|
||||||
|
|
||||||
|
assertNotNull(comment);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private final static String COMMENT_1 = "{" +
|
private final static String COMMENT_1 = "{" +
|
||||||
"\"_id\":\"zwzAgjHdW4fNJ9YLc\"," +
|
"\"_id\":\"zwzAgjHdW4fNJ9YLc\"," +
|
||||||
"\"comment\":\"comment 1\"," +
|
"\"comment\":\"comment 1\"," +
|
||||||
@ -100,8 +119,12 @@ public class CardCommentServiceTest {
|
|||||||
"\"authorId\":\"Si69gNgkJfQuk6uiJ\"" +
|
"\"authorId\":\"Si69gNgkJfQuk6uiJ\"" +
|
||||||
"}";
|
"}";
|
||||||
private final static String COMMENT_3 = "{" +
|
private final static String COMMENT_3 = "{" +
|
||||||
"\"_id\":\"zwzAgjHdW4fNJ9YLf\"," +
|
"\"_id\":\"DofhD9v96DbX7Wirp\"," +
|
||||||
"\"comment\":\"comment 3\"," +
|
"\"userId\":\"Si69gNgkJfQuk6uiJ\"," +
|
||||||
"\"authorId\":\"Si69gNgkJfQuk6uiJ\"" +
|
"\"text\":\"commento api\"," +
|
||||||
|
"\"cardId\":\"XQtnuqWEJnEcm6iy2\"," +
|
||||||
|
"\"boardId\":\"TtjXrJyvPkG3xsbkw\"," +
|
||||||
|
"\"createdAt\":\"2019-11-12T20:12:55.749Z\"," +
|
||||||
|
"\"modifiedAt\":\"2019-11-12T20:12:55.749Z\"" +
|
||||||
"}";
|
"}";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user