DocumentResource { @Get("/documents/starred") public List<Document> getStarredDocuments(Context context) { return repository.getStarredDocuments((DatashareUser)context.currentUser()); } @Inject  DocumentResource(Repository repository, Indexer indexer); @Get("/:project/documents/src/:id?routing=:routing") Payload getSourceFile(final String project, final String id,
                                 final String routing, final Context context); @Post("/:project/documents/batchUpdate/star") Result<Integer> groupStarProject(final String projectId, final List<String> docIds, Context context); @Post("/:project/documents/batchUpdate/unstar") Result<Integer> groupUnstarProject(final String projectId, final List<String> docIds, Context context); @Get("/:project/documents/starred") List<String> getProjectStarredDocuments(final String projectId, Context context); @Get("/:projects/documents/tagged/:coma_separated_tags") List<String> getProjectTaggedDocuments(final String projectId, final String comaSeparatedTags); @Options("/:project/documents/tags/:docId") Payload tagDocument(final String projectId, final String docId); @Put("/:project/documents/tags/:docId?routing=:routing") Payload tagDocument(final String projectId, final String docId, String routing, Tag[] tags); @Get("/:project/documents/tags/:docId") List<Tag> getDocumentTags(final String projectId, final String docId); @Post("/:project/documents/batchUpdate/tag") Payload groupTagDocument(final String projectId, BatchTagQuery query, Context context); @Post("/:project/documents/batchUpdate/untag") Payload groupUntagDocument(final String projectId, BatchTagQuery query,  Context context); @Options("/:project/documents/untag/:docId") Payload untagDocument(final String projectId, final String docId); @Put("/:project/documents/untag/:docId?routing=:routing") Payload untagDocument(final String projectId, final String docId, String routing, Tag[] tags); @Get("/documents/starred") List<Document> getStarredDocuments(Context context); @Get("/users/recommendations?project=:project") AggregateList<User> getProjectRecommendations(final String projectId); @Get("/users/recommendationsby?project=:project&docIds=:coma_separated_docIds") AggregateList<User> getProjectRecommendations(final String projectId, final String comaSeparatedDocIds); @Get("/:project/documents/recommendations?userids=:coma_separated_users") Set<String> getProjectRecommentationsBy(final String projectId, final String comaSeparatedUsers); @Post("/:project/documents/batchUpdate/recommend") Result<Integer> groupRecommend(final String projectId, final List<String> docIds, Context context); @Post("/:project/documents/batchUpdate/unrecommend") Result<Integer> groupUnrecommend(final String projectId, final List<String> docIds, Context context);  }
@Test public void test_get_starred_documents_with_project() { when(repository.getStarredDocuments(project("local-datashare"), User.local())).thenReturn(asList("id1", "id2")); get("/api/local-datashare/documents/starred").should().respond(200).contain("id1").contain("id2"); }
@Test public void test_get_starred_documents() { when(repository.getStarredDocuments(any())).thenReturn(asList(createDoc("doc1").build(), createDoc("doc2").build())); get("/api/documents/starred").should().respond(200).haveType("application/json").contain("\"doc1\"").contain("\"doc2\""); }