Commit 47e56e5e authored by Greg Messner's avatar Greg Messner
Browse files

Fixed parameter based createProject().

parent 4d36f708
...@@ -240,13 +240,14 @@ public class ProjectApi extends AbstractApi { ...@@ -240,13 +240,14 @@ public class ProjectApi extends AbstractApi {
* @param mergeRequestsEnabled Whether Merge Requests should be enabled, otherwise null indicates to use GitLab default * @param mergeRequestsEnabled Whether Merge Requests should be enabled, otherwise null indicates to use GitLab default
* @param wikiEnabled Whether a Wiki should be enabled, otherwise null indicates to use GitLab default * @param wikiEnabled Whether a Wiki should be enabled, otherwise null indicates to use GitLab default
* @param snippetsEnabled Whether Snippets should be enabled, otherwise null indicates to use GitLab default * @param snippetsEnabled Whether Snippets should be enabled, otherwise null indicates to use GitLab default
* @param isPublic Whether the project is public or private * @param isPublic Whether the project is public or private, if true same as setting visibilityLevel = 20, otherwise null indicates to use GitLab default
* @param visibilityLevel The visibility level of the project, otherwise null indicates to use GitLab default
* @param importUrl The Import URL for the project, otherwise null * @param importUrl The Import URL for the project, otherwise null
* @return the GitLab Project * @return the GitLab Project
* @throws GitLabApiException if any exception occurs * @throws GitLabApiException if any exception occurs
*/ */
public Project createProject(String name, Integer namespaceId, String description, Boolean issuesEnabled, Boolean mergeRequestsEnabled, public Project createProject(String name, Integer namespaceId, String description, Boolean issuesEnabled, Boolean mergeRequestsEnabled,
Boolean wikiEnabled, Boolean snippetsEnabled, Boolean isPublic, String importUrl) throws GitLabApiException { Boolean wikiEnabled, Boolean snippetsEnabled, Boolean isPublic, Integer visibilityLevel, String importUrl) throws GitLabApiException {
if (name == null || name.trim().length() == 0) { if (name == null || name.trim().length() == 0) {
return (null); return (null);
...@@ -254,14 +255,15 @@ public class ProjectApi extends AbstractApi { ...@@ -254,14 +255,15 @@ public class ProjectApi extends AbstractApi {
GitLabApiForm formData = new GitLabApiForm() GitLabApiForm formData = new GitLabApiForm()
.withParam("name", name, true) .withParam("name", name, true)
.withParam("namespace_id", namespaceId, false) .withParam("namespace_id", namespaceId)
.withParam("description", description, false) .withParam("description", description)
.withParam("issues_enabled", issuesEnabled, false) .withParam("issues_enabled", issuesEnabled)
.withParam("merge_requests_enabled", mergeRequestsEnabled, false) .withParam("merge_requests_enabled", mergeRequestsEnabled)
.withParam("wiki_enabled", wikiEnabled, false) .withParam("wiki_enabled", wikiEnabled)
.withParam("snippets_enabled", snippetsEnabled, false) .withParam("snippets_enabled", snippetsEnabled)
.withParam("visibility", (isPublic != null && isPublic ? "public" : "private"), false) .withParam("public", isPublic)
.withParam("import_url", importUrl, false); .withParam("visibility_level", visibilityLevel)
.withParam("import_url", importUrl);
Response response = post(Response.Status.CREATED, formData, "projects"); Response response = post(Response.Status.CREATED, formData, "projects");
return (response.readEntity(Project.class)); return (response.readEntity(Project.class));
......
...@@ -123,4 +123,24 @@ public class TestProjectApi { ...@@ -123,4 +123,24 @@ public class TestProjectApi {
Project project = gitLabApi.getProjectApi().getProject(TEST_NAMESPACE, TEST_PROJECT_NAME); Project project = gitLabApi.getProjectApi().getProject(TEST_NAMESPACE, TEST_PROJECT_NAME);
gitLabApi.getProjectApi().deleteProject(project); gitLabApi.getProjectApi().deleteProject(project);
} }
@Test
public void testParameterBasedCreate() throws GitLabApiException {
Project newProject = gitLabApi.getProjectApi().createProject(
TEST_PROJECT_NAME + "-2", null, "GitLab4J test project.", true, true, true, true, true, null, null);
assertNotNull(newProject);
assertEquals(TEST_PROJECT_NAME + "-2", newProject.getName());
assertEquals("GitLab4J test project.", newProject.getDescription());
assertEquals(true, newProject.getIssuesEnabled());
assertEquals(true, newProject.getMergeRequestsEnabled());
assertEquals(true, newProject.getWikiEnabled());
assertEquals(true, newProject.getSnippetsEnabled());
assertEquals(true, newProject.getPublic());
try {
gitLabApi.getProjectApi().deleteProject(newProject);
} catch (Exception ignore) {
}
}
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment