ProjectResource { @Get("/:id") public Project getProject(String id) { Project project = repository.getProject(id); return project == null ? project(id):project; } @Inject  ProjectResource(Repository repository, Indexer indexer); @Get("/:id") Project getProject(String id); @Get("/isDownloadAllowed/:id") Payload isProjectAllowed(String id, Context context); @Options("/:id") Payload deleteProjectOpt(String id); @Delete("/:id") Payload deleteProject(String id, Context context);  }
@Test public void test_get_project() { when(repository.getProject("projectId")).thenReturn(new Project("projectId")); get("/api/project/projectId").should().respond(200).contain("projectId"); }
@Test public void test_is_allowed() { when(repository.getProject("projectId")).thenReturn(new Project("projectId", "127.0.0.1")); get("/api/project/isDownloadAllowed/projectId").should().respond(200); }
@Test public void test_is_not_allowed() { when(repository.getProject("projectId")).thenReturn(new Project("projectId", "127.0.0.2")); get("/api/project/isDownloadAllowed/projectId").should().respond(403); }