Commit 054754d5 authored by Greg Messner's avatar Greg Messner
Browse files

Mods related to create project fixes.

parent 0c6e6baa
......@@ -229,7 +229,7 @@ public abstract class AbstractApi {
* the returned secret token, if either is not correct will throw a GitLabApiException.
*
* @param response response
* @param expected expected respone status
* @param expected expected response status
* @return original response if the response status is expected
* @throws GitLabApiException if HTTP status is not as expected, or the secret token doesn't match
*/
......
......@@ -12,6 +12,7 @@ public class GitLabApi {
private CommitsApi commitsApi;
private GroupApi groupApi;
private MergeRequestApi mergeRequestApi;
private NamespaceApi namespaceApi;
private ProjectApi projectApi;
private RepositoryApi repositoryApi;
private RepositoryFileApi repositoryFileApi;
......@@ -61,6 +62,7 @@ public class GitLabApi {
commitsApi = new CommitsApi(this);
groupApi = new GroupApi(this);
mergeRequestApi = new MergeRequestApi(this);
setNamespaceApi(new NamespaceApi(this));
projectApi = new ProjectApi(this);
repositoryApi = new RepositoryApi(this);
servicesApi = new ServicesApi(this);
......@@ -99,6 +101,20 @@ public class GitLabApi {
return (mergeRequestApi);
}
/**
* Gets the NamespaceApi instance owned by this GitLabApi instance. The NamespaceApi is used
* to perform all namespace related API calls.
*
* @return the NamespaceApi instance owned by this GitLabApi instance
*/
public NamespaceApi getNamespaceApi() {
return namespaceApi;
}
public void setNamespaceApi(NamespaceApi namespaceApi) {
this.namespaceApi = namespaceApi;
}
/**
* Gets the GroupApi instance owned by this GitLabApi instance. The GroupApi is used
* to perform all group related API calls.
......
......@@ -280,7 +280,10 @@ public class GitLabApiClient {
* @return a ClientResponse instance with the data returned from the endpoint
*/
protected Response post(Form formData, URL url) {
return (invocation(url, null).post(Entity.entity(formData, MediaType.APPLICATION_FORM_URLENCODED_TYPE)));
if (formData instanceof GitLabApiForm)
return (invocation(url, null).post(Entity.entity(formData.asMap(), MediaType.APPLICATION_FORM_URLENCODED_TYPE)));
else
return (invocation(url, null).post(Entity.entity(formData, MediaType.APPLICATION_FORM_URLENCODED_TYPE)));
}
/**
......
package org.gitlab4j.api;
import javax.ws.rs.core.Form;
import javax.ws.rs.core.MultivaluedHashMap;
/**
* This class extends the standard JAX-RS Form class to make it fluent.
*/
public class GitLabApiForm extends Form {
public GitLabApiForm() {
super();
}
public GitLabApiForm(MultivaluedHashMap<String, String> map) {
super(map);
}
/**
* Fluent method for adding query and form parameters to a get() or post() call.
*
......@@ -47,4 +56,4 @@ public class GitLabApiForm extends Form {
this.param(name, stringValue);
return (this);
}
}
}
\ No newline at end of file
......@@ -100,14 +100,14 @@ public class ProjectApi extends AbstractApi {
throw new RuntimeException("project cannot be null");
}
String pid = null;
String projectPath = null;
try {
pid = URLEncoder.encode(namespace + "/" + project, "UTF-8");
projectPath = URLEncoder.encode(namespace + "/" + project, "UTF-8");
} catch (UnsupportedEncodingException uee) {
throw (new GitLabApiException(uee));
}
Response response = get(Response.Status.OK, null, "projects", pid);
Response response = get(Response.Status.OK, null, "projects", projectPath);
return (response.readEntity(Project.class));
}
......@@ -129,6 +129,22 @@ public class ProjectApi extends AbstractApi {
return (response.readEntity(Project.class));
}
/**
* Create a new project with the current user's namespace.
*
* @param projectName the name of the project top create
* @return the created project
* @throws GitLabApiException if any exception occurs
*/
public Project createProject(String projectName) throws GitLabApiException {
GitLabApiForm formData = new GitLabApiForm()
.withParam("name", projectName, true);
Response response = post(Response.Status.CREATED, formData, "projects");
return (response.readEntity(Project.class));
}
/**
* Creates new project owned by the current user.
*
......@@ -144,15 +160,26 @@ public class ProjectApi extends AbstractApi {
* Creates new project owned by the current user. The following properties on the Project instance
* are utilized in the creation of the project:
*
* name (required) - new project name
* name (name or path are required) - new project name
* path (name or path are required) - new project path
* defaultBranch (optional) - master by default
* description (optional) - short project description
* issuesEnabled (optional)
* wallEnabled (optional)
* mergeRequestsEnabled (optional)
* wikiEnabled (optional)
* snippetsEnabled (optional)
* isPublic (optional) - if true same as setting visibility_level = 20
* public (optional) - if true same as setting visibility_level = 20
* visibilityLevel (optional)
* issuesEnabled (optional) - Enable issues for this project
* mergeRequestsEnabled (optional) - Enable merge requests for this project
* wikiEnabled (optional) - Enable wiki for this project
* snippetsEnabled (optional) - Enable snippets for this project
* jobsEnabled (optional) - Enable jobs for this project
* containerRegistryEnabled (optional) - Enable container registry for this project
* sharedRunnersEnabled (optional) - Enable shared runners for this project
* publicJobs (optional) - If true, jobs can be viewed by non-project-members
* onlyAllowMergeIfPipelineSucceeds (optional) - Set whether merge requests can only be merged with successful jobs
* onlyAllowMergeIfAllDiscussionsAreResolved (optional) - Set whether merge requests can only be merged when all the discussions are resolved
* lLfsEnabled (optional) - Enable LFS
* requestAccessEnabled (optional) - Allow users to request member access
* repositoryStorage (optional) - Which storage shard the repository is on. Available only to admins
* approvalsBeforeMerge (optional) - How many approvers should approve merge request by default
*
* @param project the Project instance with the configuration for the new project
* @param importUrl the URL to import the repository from
......@@ -166,20 +193,33 @@ public class ProjectApi extends AbstractApi {
}
String name = project.getName();
if (name == null || name.trim().length() == 0) {
String path = project.getPath();
if ((name == null || name.trim().length() == 0) && (path == null || path.trim().length() == 0)) {
return (null);
}
GitLabApiForm formData = new GitLabApiForm()
.withParam("name", name, true)
.withParam("name", name)
.withParam("path", path)
.withParam("default_branch", project.getDefaultBranch())
.withParam("description", project.getDescription())
.withParam("issues_enabled", project.getIssuesEnabled())
.withParam("wall_enabled", project.getWallEnabled())
.withParam("merge_requests_enabled", project.getMergeRequestsEnabled())
.withParam("jobs_enabled", project.getJobsEnabled())
.withParam("wiki_enabled", project.getWikiEnabled())
.withParam("container_registry_enabled", project.getContainerRegistryEnabled())
.withParam("snippets_enabled", project.getSnippetsEnabled())
.withParam("shared_runners_enabled", project.getSharedRunnersEnabled())
.withParam("public_jobs", project.getPublicJobs())
.withParam("public", project.getPublic())
.withParam("visibility_level", project.getVisibilityLevel())
.withParam("only_allow_merge_if_pipeline_succeeds", project.getOnlyAllowMergeIfPipelineSucceeds())
.withParam("only_allow_merge_if_all_discussions_are_resolved", project.getOnlyAllowMergeIfAllDiscussionsAreResolved())
.withParam("lfs_enabled", project.getLfsEnabled())
.withParam("request_access_enabled", project.getRequestAccessEnabled())
.withParam("repository_storage", project.getRepositoryStorage())
.withParam("approvals_before_merge", project.getApprovalsBeforeMerge())
.withParam("import_url", importUrl);
if (project.getNamespace() != null) {
......@@ -197,18 +237,16 @@ public class ProjectApi extends AbstractApi {
* @param namespaceId The Namespace for the new project, otherwise null indicates to use the GitLab default (user)
* @param description A description for the project, null otherwise
* @param issuesEnabled Whether Issues should be enabled, otherwise null indicates to use GitLab default
* @param wallEnabled Whether The Wall 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 snippetsEnabled Whether Snippets should be enabled, otherwise null indicates to use GitLab default
* @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 isPublic Whether the project is public or private
* @param importUrl The Import URL for the project, otherwise null
* @return the GitLab Project
* @throws GitLabApiException if any exception occurs
*/
public Project createProject(String name, Integer namespaceId, String description, Boolean issuesEnabled, Boolean wallEnabled, Boolean mergeRequestsEnabled,
Boolean wikiEnabled, Boolean snippetsEnabled, Boolean isPublic, Integer visibilityLevel, String importUrl) throws GitLabApiException {
public Project createProject(String name, Integer namespaceId, String description, Boolean issuesEnabled, Boolean mergeRequestsEnabled,
Boolean wikiEnabled, Boolean snippetsEnabled, Boolean isPublic, String importUrl) throws GitLabApiException {
if (name == null || name.trim().length() == 0) {
return (null);
......@@ -216,16 +254,14 @@ public class ProjectApi extends AbstractApi {
GitLabApiForm formData = new GitLabApiForm()
.withParam("name", name, true)
.withParam("namespace_id", namespaceId)
.withParam("description", description)
.withParam("issues_enabled", issuesEnabled)
.withParam("wall_enabled", wallEnabled)
.withParam("merge_requests_enabled", mergeRequestsEnabled)
.withParam("wiki_enabled", wikiEnabled)
.withParam("snippets_enabled", snippetsEnabled)
.withParam("public", isPublic)
.withParam("visibility_level", visibilityLevel)
.withParam("import_url", importUrl);
.withParam("namespace_id", namespaceId, false)
.withParam("description", description, false)
.withParam("issues_enabled", issuesEnabled, false)
.withParam("merge_requests_enabled", mergeRequestsEnabled, false)
.withParam("wiki_enabled", wikiEnabled, false)
.withParam("snippets_enabled", snippetsEnabled, false)
.withParam("visibility", (isPublic != null && isPublic ? "public" : "private"), false)
.withParam("import_url", importUrl, false);
Response response = post(Response.Status.CREATED, formData, "projects");
return (response.readEntity(Project.class));
......
......@@ -12,9 +12,9 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlAccessorType(XmlAccessType.FIELD)
public class Project {
private Integer approvalsBeforeMerge;
private Boolean archived;
private String avatarUrl;
private Boolean buildsEnabled;
private Boolean containerRegistryEnabled;
private Date createdAt;
private Integer creatorId;
......@@ -24,23 +24,25 @@ public class Project {
private Project forkedFromProject;
private String httpUrlToRepo;
private Integer id;
private Boolean isPublic;
private Boolean issuesEnabled;
private Boolean jobsEnabled;
private Date lastActivityAt;
private Boolean lfsEnabled;
private Boolean mergeRequestsEnabled;
private String name;
private Namespace namespace;
private String nameWithNamespace;
private Boolean onlyAllowMergeIfBuildSucceeds;
private Boolean onlyAllowMergeIfPipelineSucceeds;
private Boolean onlyAllowMergeIfAllDiscussionsAreResolved;
private Integer openIssuesCount;
private Owner owner;
private String path;
private String pathWithNamespace;
private Permissions permissions;
private Boolean isPublic;
private Boolean publicBuilds;
private Boolean publicJobs;
private String repositoryStorage;
private Boolean request_access_enabled;
private Boolean requestAccessEnabled;
private String runnersToken;
private Boolean sharedRunnersEnabled;
private List<ProjectSharedGroup> sharedWithGroups;
......@@ -49,10 +51,24 @@ public class Project {
private Integer starCount;
private List<String> tagList;
private Integer visibilityLevel;
private Visibility visibility;
private Boolean wallEnabled;
private String webUrl;
private Boolean wikiEnabled;
public Integer getApprovalsBeforeMerge() {
return approvalsBeforeMerge;
}
public void setApprovalsBeforeMerge(Integer approvalsBeforeMerge) {
this.approvalsBeforeMerge = approvalsBeforeMerge;
}
public Project withApprovalsBeforeMerge(Integer approvalsBeforeMerge) {
this.approvalsBeforeMerge = approvalsBeforeMerge;
return (this);
}
public Boolean getArchived() {
return archived;
}
......@@ -69,14 +85,6 @@ public class Project {
this.avatarUrl = avatarUrl;
}
public Boolean getBuildsEnabled() {
return buildsEnabled;
}
public void setBuildsEnabled(Boolean buildsEnabled) {
this.buildsEnabled = buildsEnabled;
}
public Boolean getContainerRegistryEnabled() {
return containerRegistryEnabled;
}
......@@ -85,6 +93,11 @@ public class Project {
this.containerRegistryEnabled = containerRegistryEnabled;
}
public Project withContainerRegistryEnabled(boolean containerRegistryEnabled) {
this.containerRegistryEnabled = containerRegistryEnabled;
return (this);
}
public Date getCreatedAt() {
return createdAt;
}
......@@ -109,6 +122,11 @@ public class Project {
this.defaultBranch = defaultBranch;
}
public Project withDefaultBranch(String defaultBranch) {
this.defaultBranch = defaultBranch;
return (this);
}
public String getDescription() {
return description;
}
......@@ -117,6 +135,11 @@ public class Project {
this.description = description;
}
public Project withDescription(String description) {
this.description = description;
return (this);
}
public Integer getForksCount() {
return forksCount;
}
......@@ -157,6 +180,24 @@ public class Project {
this.issuesEnabled = issuesEnabled;
}
public Project withIssuesEnabled(boolean issuesEnabled) {
this.issuesEnabled = issuesEnabled;
return (this);
}
public Boolean getJobsEnabled() {
return jobsEnabled;
}
public void setJobsEnabled(Boolean jobsEnabled) {
this.jobsEnabled = jobsEnabled;
}
public Project withJobsEnabled(boolean jobsEnabled) {
this.jobsEnabled = jobsEnabled;
return (this);
}
public Date getLastActivityAt() {
return lastActivityAt;
}
......@@ -165,6 +206,19 @@ public class Project {
this.lastActivityAt = lastActivityAt;
}
public Boolean getLfsEnabled() {
return lfsEnabled;
}
public void setLfsEnabled(Boolean lfsEnabled) {
this.lfsEnabled = lfsEnabled;
}
public Project withLfsEnabled(Boolean lfsEnabled) {
this.lfsEnabled = lfsEnabled;
return (this);
}
public Boolean getMergeRequestsEnabled() {
return mergeRequestsEnabled;
}
......@@ -173,6 +227,11 @@ public class Project {
this.mergeRequestsEnabled = mergeRequestsEnabled;
}
public Project withMergeRequestsEnabled(boolean mergeRequestsEnabled) {
this.mergeRequestsEnabled = mergeRequestsEnabled;
return (this);
}
public String getName() {
return name;
}
......@@ -181,6 +240,11 @@ public class Project {
this.name = name;
}
public Project withName(String name) {
this.name = name;
return (this);
}
public Namespace getNamespace() {
return namespace;
}
......@@ -189,6 +253,17 @@ public class Project {
this.namespace = namespace;
}
public Project withNamespace(Namespace namespace) {
this.namespace = namespace;
return (this);
}
public Project withNamespaceId(int namespaceId) {
this.namespace = new Namespace();
this.namespace.setId(namespaceId);
return (this);
}
public String getNameWithNamespace() {
return nameWithNamespace;
}
......@@ -197,12 +272,17 @@ public class Project {
this.nameWithNamespace = nameWithNamespace;
}
public Boolean getOnlyAllowMergeIfBuildSucceeds() {
return onlyAllowMergeIfBuildSucceeds;
public Boolean getOnlyAllowMergeIfPipelineSucceeds() {
return onlyAllowMergeIfPipelineSucceeds;
}
public void setOnlyAllowMergeIfBuildSucceeds(Boolean onlyAllowMergeIfBuildSucceeds) {
this.onlyAllowMergeIfBuildSucceeds = onlyAllowMergeIfBuildSucceeds;
public void setOnlyAllowMergeIfPipelineSucceeds(Boolean onlyAllowMergeIfPipelineSucceeds) {
this.onlyAllowMergeIfPipelineSucceeds = onlyAllowMergeIfPipelineSucceeds;
}
public Project withOnlyAllowMergeIfPipelineSucceeds(Boolean onlyAllowMergeIfPipelineSucceeds) {
this.onlyAllowMergeIfPipelineSucceeds = onlyAllowMergeIfPipelineSucceeds;
return (this);
}
public Boolean getOnlyAllowMergeIfAllDiscussionsAreResolved() {
......@@ -213,6 +293,11 @@ public class Project {
this.onlyAllowMergeIfAllDiscussionsAreResolved = onlyAllowMergeIfAllDiscussionsAreResolved;
}
public Project withOnlyAllowMergeIfAllDiscussionsAreResolved(Boolean onlyAllowMergeIfAllDiscussionsAreResolved) {
this.onlyAllowMergeIfAllDiscussionsAreResolved = onlyAllowMergeIfAllDiscussionsAreResolved;
return (this);
}
public Integer getOpenIssuesCount() {
return openIssuesCount;
}
......@@ -237,6 +322,11 @@ public class Project {
this.path = path;
}
public Project withPath(String path) {
this.path = path;
return (this);
}
public String getPathWithNamespace() {
return pathWithNamespace;
}
......@@ -261,12 +351,22 @@ public class Project {
this.isPublic = isPublic;
}
public Boolean getPublicBuilds() {
return publicBuilds;
public Project withPublic(Boolean isPublic) {
this.isPublic = isPublic;
return (this);
}
public Boolean getPublicJobs() {
return publicJobs;
}
public void setPublicBuilds(Boolean publicBuilds) {
this.publicBuilds = publicBuilds;
public void setPublicJobs(Boolean publicJobs) {
this.publicJobs = publicJobs;
}
public Project withPublicJobs(boolean publicJobs) {
this.publicJobs = publicJobs;
return (this);
}
public String getRepositoryStorage() {
......@@ -277,12 +377,22 @@ public class Project {
this.repositoryStorage = repositoryStorage;
}
public Boolean getRequest_access_enabled() {
return request_access_enabled;
public Project withRepositoryStorage(String repositoryStorage) {
this.repositoryStorage = repositoryStorage;
return (this);
}
public Boolean getRequestAccessEnabled() {
return requestAccessEnabled;
}
public void setRequest_access_enabled(Boolean request_access_enabled) {
this.request_access_enabled = request_access_enabled;
public void setRequestAccessEnabled(Boolean request_access_enabled) {
this.requestAccessEnabled = request_access_enabled;
}
public Project withRequestAccessEnabled(boolean requestAccessEnabled) {
this.requestAccessEnabled = requestAccessEnabled;
return (this);
}
public String getRunnersToken() {
......@@ -309,6 +419,11 @@ public class Project {
this.sharedWithGroups = sharedWithGroups;
}
public Project withSharedRunnersEnabled(boolean sharedRunnersEnabled) {
this.sharedRunnersEnabled = sharedRunnersEnabled;
return (this);
}
public Boolean getSnippetsEnabled() {
return snippetsEnabled;
}
......@@ -317,6 +432,11 @@ public class Project {
this.snippetsEnabled = snippetsEnabled;
}
public Project withSnippetsEnabled(boolean snippetsEnabled) {
this.snippetsEnabled = snippetsEnabled;
return (this);
}
public String getSshUrlToRepo() {
return sshUrlToRepo;
}
......@@ -341,6 +461,19 @@ public class Project {
this.tagList = tagList;
}
public Visibility getVisibility() {
return visibility;
}
public void setVisibility(Visibility visibility) {
this.visibility = visibility;
}
public Project withVisibility(Visibility visibility) {
this.visibility = visibility;
return (this);
}
public Integer getVisibilityLevel() {
return visibilityLevel;
}
......@@ -349,6 +482,11 @@ public class Project {
this.visibilityLevel = visibilityLevel;
}
public Project withVisibilityLevel(Integer visibilityLevel) {
this.visibilityLevel = visibilityLevel;
return (this);
}
public Boolean getWallEnabled() {
return wallEnabled;
}
......@@ -373,6 +511,11 @@ public class Project {
this.wikiEnabled = wikiEnabled;
}
public Project withWikiEnabled(boolean wikiEnabled) {
this.wikiEnabled = wikiEnabled;
return (this);
}
public static final boolean isValid(Project project) {
return (project != null && project.getId() != null);
}
......
......@@ -13,8 +13,6 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;
import org.gitlab4j.api.models.AccessLevel;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.core.JsonGenerator;
......@@ -65,7 +63,6 @@ public class JacksonJson extends JacksonJaxbJsonProvider implements ContextResol
SimpleModule module = new SimpleModule("GitLabApiJsonModule");
module.addSerializer(Date.class, new JsonDateSerializer());
module.addDeserializer(Date.class, new JsonDateDeserializer());
module.addSerializer(AccessLevel.class, new JsonAccessLevelSerializer());
objectMapper.registerModule(module);
}
......@@ -171,15 +168,4 @@ public class JacksonJson extends JacksonJaxbJsonProvider implements ContextResol
}
}
}
/**
* JsonSerializer for serializing AccessLevel values.
*/
public static class JsonAccessLevelSerializer extends JsonSerializer<AccessLevel> {
@Override
public void serialize(AccessLevel accessLevel, JsonGenerator gen, SerializerProvider provider) throws IOException, JsonProcessingException {
gen.writeNumber(accessLevel.value);
}
}
}
\ No newline at end of file
package org.gitlab4j.api;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;
import java.io.File;
......@@ -12,14 +12,14 @@ import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.List;
import org.gitlab4j.api.GitLabApi;
import org.gitlab4j.api.GitLabApiException;
import org.gitlab4j.api.models.Branch;
import org.gitlab4j.api.models.Project;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
/**
* In order for these tests to run you must set the following systems properties:
......@@ -35,7 +35,9 @@ import org.junit.Test;
* mvn test -DTEST_PRIVATE_TOKEN=your_private_token -DTEST_HOST_URL=https://gitlab.com \
* -DTEST_NAMESPACE=your_namespace -DTEST_PROJECT_NAME=test-project
*
* NOTE: &amp;FixMethodOrder(MethodSorters.NAME_ASCENDING) is very important to insure that testCreate() is executed first.
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestGitLabApi {
// The following needs to be set to your test repository
......@@ -87,6 +89,7 @@ public class TestGitLabApi {
@AfterClass
public static void teardown() throws GitLabApiException {
if (gitLabApi != null) {
try {
Project project = gitLabApi.getProjectApi().getProject(TEST_NAMESPACE, TEST_PROJECT_NAME);
gitLabApi.getRepositoryApi().deleteBranch(project.getId(), TEST_BRANCH_NAME);
......@@ -121,6 +124,14 @@ public class TestGitLabApi {
assertNotNull(branch);
}
@Test
public void testDeleteBranch() throws GitLabApiException {
Project project = gitLabApi.getProjectApi().getProject(TEST_NAMESPACE, TEST_PROJECT_NAME);
assertNotNull(project);
gitLabApi.getRepositoryApi().deleteBranch(project.getId(), TEST_BRANCH_NAME);
}
@Test
public void testRepositoryArchiveViaInputStream() throws GitLabApiException, IOException {
......@@ -135,7 +146,7 @@ public class TestGitLabApi {
assertTrue(target.toFile().length() > 0);
Files.delete(target);
}
@Test
public void testRepositoryArchiveViaFile() throws GitLabApiException, IOException {
......@@ -145,7 +156,7 @@ public class TestGitLabApi {
File file = gitLabApi.getRepositoryApi().getRepositoryArchive(project.getId(), "master", null);
assertTrue(file.length() > 0);
file.delete();
file = gitLabApi.getRepositoryApi().getRepositoryArchive(project.getId(), "master", new File("."));
assertTrue(file.length() > 0);
file.delete();
......
......@@ -31,6 +31,7 @@ import org.junit.BeforeClass;
import org.junit.Test;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonNode;
......@@ -292,7 +293,18 @@ public class TestGitLabApiBeans {
String objectJson = jacksonJson.marshal(apiObject);
JsonNode tree1 = jacksonJson.getObjectMapper().readTree(objectJson.getBytes());
JsonNode tree2 = jacksonJson.getObjectMapper().readTree(reader);
boolean sameJson = tree1.equals(tree2);
if (!sameJson) {
System.out.println("JSON did not match:");
sortedDump(tree1);
sortedDump(tree2);
}
return (sameJson);
}
private void sortedDump(final JsonNode node) throws JsonProcessingException {
final Object obj = jacksonJson.getObjectMapper().treeToValue(node, Object.class);
System.out.println(jacksonJson.getObjectMapper().writeValueAsString(obj));
}
}
......@@ -29,7 +29,6 @@
"git_ssh_url": "git@192.168.64.1:gitlab-org/gitlab-test.git",
"description": "Atque in sunt eos similique dolores voluptatem.",
"homepage": "http://192.168.64.1:3005/gitlab-org/gitlab-test",
"git_ssh_url": "git@192.168.64.1:gitlab-org/gitlab-test.git",
"git_http_url": "http://192.168.64.1:3005/gitlab-org/gitlab-test.git",
"visibility_level": 20
}
......
......@@ -22,7 +22,7 @@
"issues_enabled": true,
"open_issues_count": 1,
"merge_requests_enabled": true,
"builds_enabled": true,
"jobs_enabled": true,
"wiki_enabled": true,
"snippets_enabled": false,
"container_registry_enabled": false,
......@@ -54,7 +54,7 @@
"forks_count": 0,
"star_count": 0,
"runners_token": "b8bc4a7a29eb76ea83cf79e4908c2b",
"public_builds": true,
"public_jobs": true,
"shared_with_groups": [
{
"group_id": 4,
......@@ -68,7 +68,7 @@
}
],
"repository_storage": "default",
"only_allow_merge_if_build_succeeds": false,
"only_allow_merge_if_pipeline_succeeds": false,
"only_allow_merge_if_all_discussions_are_resolved": false,
"request_access_enabled": false
}
\ No newline at end of file
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