### Question:
RepositoryServiceV1 extends AbstractService { @Post("/projects/{projectName}/repos") @StatusCode(201) @ResponseConverter(CreateApiResponseConverter.class) @RequiresRole(roles = ProjectRole.OWNER) public CompletableFuture<RepositoryDto> createRepository(ServiceRequestContext ctx, Project project, CreateRepositoryRequest request, Author author) { if (Project.isReservedRepoName(request.name())) { return HttpApiUtil.throwResponse(ctx, HttpStatus.FORBIDDEN, "A reserved repository cannot be created."); } return execute(Command.createRepository(author, project.name(), request.name())) .thenCompose(unused -> mds.addRepo(author, project.name(), request.name())) .handle(returnOrThrow(() -> DtoConverter.convert(project.repos().get(request.name())))); } RepositoryServiceV1(ProjectManager projectManager, CommandExecutor executor,
                               MetadataService mds); @Get("/projects/{projectName}/repos") CompletableFuture<List<RepositoryDto>> listRepositories(ServiceRequestContext ctx, Project project,
                                                                   @Param @Nullable String status, User user); @Post("/projects/{projectName}/repos") @StatusCode(201) @ResponseConverter(CreateApiResponseConverter.class) @RequiresRole(roles = ProjectRole.OWNER) CompletableFuture<RepositoryDto> createRepository(ServiceRequestContext ctx, Project project,
                                                             CreateRepositoryRequest request,
                                                             Author author); @Delete("/projects/{projectName}/repos/{repoName}") @RequiresRole(roles = ProjectRole.OWNER) CompletableFuture<Void> removeRepository(ServiceRequestContext ctx,
                                                    @Param String repoName,
                                                    Repository repository,
                                                    Author author); @Delete("/projects/{projectName}/repos/{repoName}/removed") @RequiresRole(roles = ProjectRole.OWNER) CompletableFuture<Void> purgeRepository(@Param String repoName,
                                                   Project project, Author author); @Consumes("application/json-patch+json") @Patch("/projects/{projectName}/repos/{repoName}") @RequiresRole(roles = ProjectRole.OWNER) CompletableFuture<RepositoryDto> patchRepository(@Param String repoName,
                                                            Project project,
                                                            JsonNode node,
                                                            Author author); @Get("/projects/{projectName}/repos/{repoName}/revision/{revision}") @RequiresReadPermission Map<String, Integer> normalizeRevision(Repository repository, @Param String revision);  }### Answer:
@Test void createRepository() throws IOException { final WebClient client = dogma.httpClient(); final AggregatedHttpResponse aRes = createRepository(client, "myRepo"); final ResponseHeaders headers = ResponseHeaders.of(aRes.headers()); assertThat(headers.status()).isEqualTo(HttpStatus.CREATED); final String location = headers.get(HttpHeaderNames.LOCATION); assertThat(location).isEqualTo("/api/v1/projects/myPro/repos/myRepo"); final JsonNode jsonNode = Jackson.readTree(aRes.contentUtf8()); assertThat(jsonNode.get("name").asText()).isEqualTo("myRepo"); assertThat(jsonNode.get("headRevision").asInt()).isOne(); assertThat(jsonNode.get("createdAt").asText()).isNotNull(); }
@Test void createRepositoryWithSameName() { final WebClient client = dogma.httpClient(); createRepository(client, "myNewRepo"); final AggregatedHttpResponse aRes = createRepository(client, "myNewRepo"); assertThat(ResponseHeaders.of(aRes.headers()).status()).isEqualTo(HttpStatus.CONFLICT); final String expectedJson = '{' + " \"exception\": \"" + RepositoryExistsException.class.getName() + "\"," + " \"message\": \"Repository 'myPro/myNewRepo' exists already.\"" + '}'; assertThatJson(aRes.contentUtf8()).isEqualTo(expectedJson); }