From 8c9eadbec85b9f8dd9596d45fd5241c91403fe04 Mon Sep 17 00:00:00 2001 From: Maxime Vanza Date: Tue, 31 Mar 2020 15:22:18 +0000 Subject: [PATCH] [refactoring] rename API endpoints for ReadBy funcs (back) --- .../icij/datashare/web/DocumentResource.java | 20 +++++++++---------- .../datashare/web/DocumentResourceTest.java | 10 +++++----- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/datashare-app/src/main/java/org/icij/datashare/web/DocumentResource.java b/datashare-app/src/main/java/org/icij/datashare/web/DocumentResource.java index aeb98e2fb..4232cd5f6 100644 --- a/datashare-app/src/main/java/org/icij/datashare/web/DocumentResource.java +++ b/datashare-app/src/main/java/org/icij/datashare/web/DocumentResource.java @@ -267,9 +267,9 @@ public List 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 getMarkedReadDocumentUsers(final String projectId, final String docId) { return repository.getMarkedReadDocumentUsers(project(projectId),docId); } @@ -283,9 +283,9 @@ public List 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 groupMarkReadProject(final String projectId, final List docIds, Context context) { return new Result(repository.markRead(project(projectId), (HashMapUser)context.currentUser(), docIds)); } @@ -300,9 +300,9 @@ public Result groupMarkReadProject(final String projectId, final List groupUnmarkReadProject(final String projectId, final List docIds, Context context) { return new Result(repository.unmarkRead(project(projectId), (HashMapUser)context.currentUser(), docIds)); } @@ -314,9 +314,9 @@ public Result 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 getProjectMarkReadUsers(final String projectId) { return repository.getAllMarkReadUsers(project(projectId)); } @@ -332,9 +332,9 @@ public List 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 getProjectMarkedReadDocuments(final String projectId, final String comaSeparatedUsers) { return repository.getMarkedReadDocuments(project(projectId), stream(comaSeparatedUsers.split(",")).map(User::new).collect(Collectors.toList())); } diff --git a/datashare-app/src/test/java/org/icij/datashare/web/DocumentResourceTest.java b/datashare-app/src/test/java/org/icij/datashare/web/DocumentResourceTest.java index a7524db55..a5fc62dd7 100644 --- a/datashare-app/src/test/java/org/icij/datashare/web/DocumentResourceTest.java +++ b/datashare-app/src/test/java/org/icij/datashare/web/DocumentResourceTest.java @@ -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