Skip to content

Commit

Permalink
[refactoring] rename API endpoints for ReadBy funcs (back)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvanzalu committed Mar 31, 2020
1 parent 5ce5d62 commit 8c9eadb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,9 @@ public List<Document> getStarredDocuments(Context context) {
* @return 200 and the list of tags
*
* Example :
* $(curl http://localhost:8080/api/apigen-datashare/documents/markedRead/bd2ef02d39043cc5cd8c5050e81f6e73c608cafde339c9b7ed68b2919482e8dc7da92e33aea9cafec2419c97375f684f)
* $(curl http://localhost:8080/api/apigen-datashare/documents/readBy/bd2ef02d39043cc5cd8c5050e81f6e73c608cafde339c9b7ed68b2919482e8dc7da92e33aea9cafec2419c97375f684f)
*/
@Get("/:project/documents/markedRead/:docId")
@Get("/:project/documents/readBy/:docId")
public List<User> getMarkedReadDocumentUsers(final String projectId, final String docId) {
return repository.getMarkedReadDocumentUsers(project(projectId),docId);
}
Expand All @@ -283,9 +283,9 @@ public List<User> getMarkedReadDocumentUsers(final String projectId, final Strin
* @return 200 and the number of documents marked
*
* Example :
* $(curl -i -XPOST -H "Content-Type: application/json" localhost:8080/api/apigen-datashare/documents/batchUpdate/markRead -d '["bd2ef02d39043cc5cd8c5050e81f6e73c608cafde339c9b7ed68b2919482e8dc7da92e33aea9cafec2419c97375f684f"]')
* $(curl -i -XPOST -H "Content-Type: application/json" localhost:8080/api/apigen-datashare/documents/batchUpdate/markReadBy -d '["bd2ef02d39043cc5cd8c5050e81f6e73c608cafde339c9b7ed68b2919482e8dc7da92e33aea9cafec2419c97375f684f"]')
*/
@Post("/:projectId/documents/batchUpdate/markRead")
@Post("/:projectId/documents/batchUpdate/markReadBy")
public Result<Integer> groupMarkReadProject(final String projectId, final List<String> docIds, Context context) {
return new Result(repository.markRead(project(projectId), (HashMapUser)context.currentUser(), docIds));
}
Expand All @@ -300,9 +300,9 @@ public Result<Integer> groupMarkReadProject(final String projectId, final List<S
* @return 200 and the number of documents unmarked
*
* Example :
* $(curl -i -XPOST -H "Content-Type: application/json" localhost:8080/api/apigen-datashare/documents/batchUpdate/unmarkRead -d '["bd2ef02d39043cc5cd8c5050e81f6e73c608cafde339c9b7ed68b2919482e8dc7da92e33aea9cafec2419c97375f684f"]')
* $(curl -i -XPOST -H "Content-Type: application/json" localhost:8080/api/apigen-datashare/documents/batchUpdate/unmarkReadBy -d '["bd2ef02d39043cc5cd8c5050e81f6e73c608cafde339c9b7ed68b2919482e8dc7da92e33aea9cafec2419c97375f684f"]')
*/
@Post("/:project/documents/batchUpdate/unmarkRead")
@Post("/:project/documents/batchUpdate/unmarkReadBy")
public Result<Integer> groupUnmarkReadProject(final String projectId, final List<String> docIds, Context context) {
return new Result(repository.unmarkRead(project(projectId), (HashMapUser)context.currentUser(), docIds));
}
Expand All @@ -314,9 +314,9 @@ public Result<Integer> groupUnmarkReadProject(final String projectId, final List
* @return 200
*
* Example :
* $(curl -i localhost:8080/api/apigen-datashare/documents/markReadUsers)
* $(curl -i localhost:8080/api/apigen-datashare/documents/readBy)
*/
@Get("/:project/documents/markReadUsers")
@Get("/:project/documents/readBy")
public List<User> getProjectMarkReadUsers(final String projectId) {
return repository.getAllMarkReadUsers(project(projectId));
}
Expand All @@ -332,9 +332,9 @@ public List<User> getProjectMarkReadUsers(final String projectId) {
* @return 200
*
* Example :
* $(curl -i localhost:8080/api/apigen-datashare/documents/markedReadDocuments/apigen)
* $(curl -i localhost:8080/api/apigen-datashare/documents/documentsReadBy/apigen)
*/
@Get("/:project/documents/markedReadDocuments/:coma_separated_tags")
@Get("/:project/documents/documentsReadBy/:coma_separated_tags")
public Set<String> getProjectMarkedReadDocuments(final String projectId, final String comaSeparatedUsers) {
return repository.getMarkedReadDocuments(project(projectId), stream(comaSeparatedUsers.split(",")).map(User::new).collect(Collectors.toList()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,31 +120,31 @@ public void test_group_unstar_document_with_project() {
@Test
public void test_group_mark_read_document_with_project() {
when(repository.markRead(project("prj1"), User.local(), asList("id1", "id2"))).thenReturn(2);
post("/api/prj1/documents/batchUpdate/markRead", "[\"id1\", \"id2\"]").should().respond(200);
post("/api/prj1/documents/batchUpdate/markReadBy", "[\"id1\", \"id2\"]").should().respond(200);
}

@Test
public void test_group_unmark_read_document_with_project() {
when(repository.unmarkRead(project("prj1"), User.local(), asList("id1", "id2"))).thenReturn(2);
post("/api/prj1/documents/batchUpdate/unmarkRead", "[\"id1\", \"id2\"]").should().respond(200);
post("/api/prj1/documents/batchUpdate/unmarkReadBy", "[\"id1\", \"id2\"]").should().respond(200);
}

@Test
public void test_get_marked_read_document_users() {
when(repository.getMarkedReadDocumentUsers(eq(project("prj")), eq("docId"))).thenReturn(asList(new User("user1"), new User("user2")));
get("/api/prj/documents/markedRead/docId").should().respond(200).contain("user1").contain("user2");
get("/api/prj/documents/readBy/docId").should().respond(200).contain("user1").contain("user2");
}

@Test
public void test_get_all_mark_read_users() {
when(repository.getAllMarkReadUsers(eq(project("prj")))).thenReturn(asList(new User("user1"), new User("user2")));
get("/api/prj/documents/markReadUsers").should().respond(200).contain("user1").contain("user2");
get("/api/prj/documents/readBy").should().respond(200).contain("user1").contain("user2");
}

@Test
public void test_get_marked_read_documents() {
when(repository.getMarkedReadDocuments(eq(project("prj")),eq(asList(new User("user1"), new User("user2"))))).thenReturn(Stream.of("doc1","doc2").collect(Collectors.toSet()));
get("/api/prj/documents/markedReadDocuments/user1,user2").should().respond(200).contain("doc1").contain("doc2");
get("/api/prj/documents/documentsReadBy/user1,user2").should().respond(200).contain("doc1").contain("doc2");
}

@Test
Expand Down

0 comments on commit 8c9eadb

Please sign in to comment.