From 73b8aed62c7aec4b1a653b34a7dc033ce20a49c3 Mon Sep 17 00:00:00 2001 From: Salamon Date: Mon, 4 Dec 2023 10:44:16 +0300 Subject: [PATCH 1/5] Support for bridges. Realted to issues/697 --- src/main/java/org/gitlab4j/api/JobApi.java | 31 +++ .../java/org/gitlab4j/api/models/Bridge.java | 185 ++++++++++++++++++ .../api/models/DownstreamPipeline.java | 76 +++++++ .../org/gitlab4j/api/TestGitLabApiBeans.java | 83 +------- .../java/org/gitlab4j/api/TestJobApi.java | 10 + .../resources/org/gitlab4j/api/bridge.json | 60 ++++++ 6 files changed, 369 insertions(+), 76 deletions(-) create mode 100644 src/main/java/org/gitlab4j/api/models/Bridge.java create mode 100644 src/main/java/org/gitlab4j/api/models/DownstreamPipeline.java create mode 100644 src/test/resources/org/gitlab4j/api/bridge.json diff --git a/src/main/java/org/gitlab4j/api/JobApi.java b/src/main/java/org/gitlab4j/api/JobApi.java index 6b2d4d4c0..3da07901e 100644 --- a/src/main/java/org/gitlab4j/api/JobApi.java +++ b/src/main/java/org/gitlab4j/api/JobApi.java @@ -15,6 +15,7 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import org.gitlab4j.api.models.ArtifactsFile; +import org.gitlab4j.api.models.Bridge; import org.gitlab4j.api.models.Job; import org.gitlab4j.api.models.JobAttributes; @@ -222,6 +223,36 @@ public Optional getOptionalJob(Object projectIdOrPath, Long jobId) { } } + + /** + * Get a Pager of bridges in a pipeline. + * + *
GitLab Endpoint: GET /projects/:id/pipelines/:pipeline_id/bridges 
+ * + * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path to get the pipelines for + * @param pipelineId the pipeline ID to get the list of bridges for + * @param itemsPerPage the number of Bridge instances that will be fetched per page + * @return a list containing the bridges for the specified project ID and pipeline ID + * @throws GitLabApiException if any exception occurs during execution + */ + public Pager getBridgesForPipeline(Object projectIdOrPath, long pipelineId, int itemsPerPage, JobScope scope) throws GitLabApiException { + return (new Pager<>(this, Bridge.class, itemsPerPage, getDefaultPerPageParam(), + "projects", getProjectIdOrPath(projectIdOrPath), "pipelines", pipelineId, "bridges", scope)); + } + + /** + * Get a Stream of bridges in a pipeline. + *
GitLab Endpoint: GET /projects/:id/pipelines/:pipeline_id/bridges
+ * + * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path + * @param pipelineId the pipeline ID to get the list of bridges for + * @return a Stream containing the bridges for the specified project ID + * @throws GitLabApiException if any exception occurs during execution + */ + public Stream getBridgesStream(Object projectIdOrPath, long pipelineId, JobScope scope) throws GitLabApiException { + return (getBridgesForPipeline(projectIdOrPath, pipelineId, getDefaultPerPage(), scope).stream()); + } + /** * Download the artifacts file from the given reference name and job provided the job finished successfully. * The file will be saved to the specified directory. If the file already exists in the directory it will diff --git a/src/main/java/org/gitlab4j/api/models/Bridge.java b/src/main/java/org/gitlab4j/api/models/Bridge.java new file mode 100644 index 000000000..999e6fea1 --- /dev/null +++ b/src/main/java/org/gitlab4j/api/models/Bridge.java @@ -0,0 +1,185 @@ +package org.gitlab4j.api.models; + +import org.gitlab4j.api.utils.JacksonJson; + +import java.util.Date; + +public class Bridge { + private Commit commit; + private boolean allowFailure; + private Date createdAt; + private Date startedAt; + private Date finishedAt; + private Date erasedAt; + private Double duration; + private Double queuedDuration; + private int id; + private String name; + private String coverage; + private Pipeline pipeline; + private String ref; + private String stage; + private String status; + private boolean tag; + private String webUrl; + private User user; + private DownstreamPipeline downstreamPipeline; + + public Commit getCommit() { + return commit; + } + + public void setCommit(Commit commit) { + this.commit = commit; + } + + public boolean isAllowFailure() { + return allowFailure; + } + + public void setAllowFailure(boolean allowFailure) { + this.allowFailure = allowFailure; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getStartedAt() { + return startedAt; + } + + public void setStartedAt(Date startedAt) { + this.startedAt = startedAt; + } + + public Date getFinishedAt() { + return finishedAt; + } + + public void setFinishedAt(Date finishedAt) { + this.finishedAt = finishedAt; + } + + public Date getErasedAt() { + return erasedAt; + } + + public void setErasedAt(Date erasedAt) { + this.erasedAt = erasedAt; + } + + public Double getDuration() { + return duration; + } + + public void setDuration(Double duration) { + this.duration = duration; + } + + public Double getQueuedDuration() { + return queuedDuration; + } + + public void setQueuedDuration(Double queuedDuration) { + this.queuedDuration = queuedDuration; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCoverage() { + return coverage; + } + + public void setCoverage(String coverage) { + this.coverage = coverage; + } + + public Pipeline getPipeline() { + return pipeline; + } + + public void setPipeline(Pipeline pipeline) { + this.pipeline = pipeline; + } + + public String getRef() { + return ref; + } + + public void setRef(String ref) { + this.ref = ref; + } + + public String getStage() { + return stage; + } + + public void setStage(String stage) { + this.stage = stage; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public boolean isTag() { + return tag; + } + + public void setTag(boolean tag) { + this.tag = tag; + } + + public String getWebUrl() { + return webUrl; + } + + public void setWebUrl(String webUrl) { + this.webUrl = webUrl; + } + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + public DownstreamPipeline getDownstreamPipeline() { + return downstreamPipeline; + } + + public void setDownstreamPipeline(DownstreamPipeline downstreamPipeline) { + this.downstreamPipeline = downstreamPipeline; + } + + @Override + public String toString() { + return (JacksonJson.toJsonString(this)); + } + +} diff --git a/src/main/java/org/gitlab4j/api/models/DownstreamPipeline.java b/src/main/java/org/gitlab4j/api/models/DownstreamPipeline.java new file mode 100644 index 000000000..ff8cb2378 --- /dev/null +++ b/src/main/java/org/gitlab4j/api/models/DownstreamPipeline.java @@ -0,0 +1,76 @@ +package org.gitlab4j.api.models; + +import org.gitlab4j.api.utils.JacksonJson; + +import java.util.Date; + +public class DownstreamPipeline { + private int id; + private String sha; + private String ref; + private String status; + private Date createdAt; + private Date updatedAt; + private String webUrl; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getSha() { + return sha; + } + + public void setSha(String sha) { + this.sha = sha; + } + + public String getRef() { + return ref; + } + + public void setRef(String ref) { + this.ref = ref; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + } + + public String getWebUrl() { + return webUrl; + } + + public void setWebUrl(String webUrl) { + this.webUrl = webUrl; + } + + @Override + public String toString() { + return (JacksonJson.toJsonString(this)); + } +} diff --git a/src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java b/src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java index 77a3c424a..f3090de25 100644 --- a/src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java +++ b/src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java @@ -33,83 +33,8 @@ import java.util.List; import java.util.Map; -import org.gitlab4j.api.models.AccessRequest; -import org.gitlab4j.api.models.Application; -import org.gitlab4j.api.models.ApplicationSettings; -import org.gitlab4j.api.models.ApprovalRule; -import org.gitlab4j.api.models.ApprovalState; -import org.gitlab4j.api.models.ArtifactsFile; -import org.gitlab4j.api.models.AuditEvent; -import org.gitlab4j.api.models.AwardEmoji; -import org.gitlab4j.api.models.Badge; -import org.gitlab4j.api.models.Blame; -import org.gitlab4j.api.models.Board; -import org.gitlab4j.api.models.Branch; -import org.gitlab4j.api.models.Comment; -import org.gitlab4j.api.models.Commit; -import org.gitlab4j.api.models.CommitPayload; -import org.gitlab4j.api.models.CommitStatus; -import org.gitlab4j.api.models.CompareResults; -import org.gitlab4j.api.models.Contributor; -import org.gitlab4j.api.models.DeployKey; -import org.gitlab4j.api.models.DeployToken; -import org.gitlab4j.api.models.Deployment; -import org.gitlab4j.api.models.Diff; -import org.gitlab4j.api.models.Discussion; -import org.gitlab4j.api.models.Email; -import org.gitlab4j.api.models.Environment; -import org.gitlab4j.api.models.Epic; -import org.gitlab4j.api.models.EpicIssue; -import org.gitlab4j.api.models.Event; -import org.gitlab4j.api.models.ExportStatus; -import org.gitlab4j.api.models.FileUpload; -import org.gitlab4j.api.models.GpgSignature; -import org.gitlab4j.api.models.Group; -import org.gitlab4j.api.models.HealthCheckInfo; -import org.gitlab4j.api.models.ImpersonationToken; -import org.gitlab4j.api.models.ImportStatus; -import org.gitlab4j.api.models.Issue; -import org.gitlab4j.api.models.IssueLink; -import org.gitlab4j.api.models.IssuesStatistics; -import org.gitlab4j.api.models.Job; -import org.gitlab4j.api.models.Key; -import org.gitlab4j.api.models.Label; -import org.gitlab4j.api.models.LabelEvent; -import org.gitlab4j.api.models.Member; -import org.gitlab4j.api.models.MergeRequest; -import org.gitlab4j.api.models.MergeRequestDiff; -import org.gitlab4j.api.models.Milestone; -import org.gitlab4j.api.models.Note; -import org.gitlab4j.api.models.NotificationSettings; -import org.gitlab4j.api.models.OauthTokenResponse; +import org.gitlab4j.api.models.*; import org.gitlab4j.api.models.Package; -import org.gitlab4j.api.models.PackageFile; -import org.gitlab4j.api.models.Pipeline; -import org.gitlab4j.api.models.PipelineSchedule; -import org.gitlab4j.api.models.Project; -import org.gitlab4j.api.models.ProjectApprovalsConfig; -import org.gitlab4j.api.models.ProjectFetches; -import org.gitlab4j.api.models.ProjectHook; -import org.gitlab4j.api.models.ProjectUser; -import org.gitlab4j.api.models.ProtectedBranch; -import org.gitlab4j.api.models.ProtectedTag; -import org.gitlab4j.api.models.PushRules; -import org.gitlab4j.api.models.RegistryRepository; -import org.gitlab4j.api.models.Release; -import org.gitlab4j.api.models.RemoteMirror; -import org.gitlab4j.api.models.RepositoryFile; -import org.gitlab4j.api.models.Runner; -import org.gitlab4j.api.models.RunnerDetail; -import org.gitlab4j.api.models.SearchBlob; -import org.gitlab4j.api.models.Snippet; -import org.gitlab4j.api.models.SshKey; -import org.gitlab4j.api.models.SystemHook; -import org.gitlab4j.api.models.Tag; -import org.gitlab4j.api.models.Todo; -import org.gitlab4j.api.models.TreeItem; -import org.gitlab4j.api.models.Trigger; -import org.gitlab4j.api.models.User; -import org.gitlab4j.api.models.Variable; import org.gitlab4j.api.services.JiraService; import org.gitlab4j.api.services.SlackService; import org.junit.jupiter.api.Test; @@ -416,6 +341,12 @@ public void testJob() throws Exception { assertTrue(compareJson(job, "job.json")); } + @Test + public void testBridge() throws Exception { + Bridge bridge = unmarshalResource(Bridge.class, "bridge.json"); + assertTrue(compareJson(bridge, "bridge.json")); + } + @Test public void testDeployKeys() throws Exception { List deployKeys = unmarshalResourceList(DeployKey.class, "deploy-keys.json"); diff --git a/src/test/java/org/gitlab4j/api/TestJobApi.java b/src/test/java/org/gitlab4j/api/TestJobApi.java index d25372e89..c77a19ba7 100644 --- a/src/test/java/org/gitlab4j/api/TestJobApi.java +++ b/src/test/java/org/gitlab4j/api/TestJobApi.java @@ -27,7 +27,10 @@ import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; +import org.gitlab4j.api.models.Bridge; import org.gitlab4j.api.models.Job; import org.gitlab4j.api.models.Project; import org.junit.jupiter.api.AfterAll; @@ -79,4 +82,11 @@ public void testGetJobs() throws GitLabApiException { List jobs = gitLabApi.getJobApi().getJobs(testProject); assertNotNull(jobs); } + + @Test + public void test() throws GitLabApiException { + Set bridges = gitLabApi.getJobApi().getBridgesStream(testProject, 4L, Constants.JobScope.SUCCESS).collect(Collectors.toSet()); + assertNotNull(bridges); + } + } diff --git a/src/test/resources/org/gitlab4j/api/bridge.json b/src/test/resources/org/gitlab4j/api/bridge.json new file mode 100644 index 000000000..38c5ab467 --- /dev/null +++ b/src/test/resources/org/gitlab4j/api/bridge.json @@ -0,0 +1,60 @@ +{ + "commit": { + "author_email": "admin@example.com", + "author_name": "Administrator", + "created_at": "2015-12-24T15:51:21.802Z", + "id": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd", + "message": "Test the CI integration.", + "short_id": "0ff3ae19", + "title": "Test the CI integration." + }, + "allow_failure": false, + "created_at": "2015-12-24T15:51:21.802Z", + "started_at": "2015-12-24T17:54:27.722Z", + "finished_at": "2015-12-24T17:58:27.895Z", + "erased_at": "2015-12-24T17:58:27.895Z", + "duration": 240.0, + "queued_duration": 0.123, + "id": 7, + "name": "teaspoon", + "pipeline": { + "id": 6, + "ref": "main", + "sha": "0ff3ae198f8601a285adcf5c0fff204ee6fba5fd", + "status": "pending", + "created_at": "2012-09-20T06:06:12Z", + "updated_at": "2012-09-20T06:06:12Z", + "web_url": "https://example.com/foo/bar/pipelines/6" + }, + "ref": "main", + "stage": "test", + "status": "pending", + "tag": false, + "web_url": "https://example.com/foo/bar/-/jobs/7", + "user": { + "id": 1, + "name": "Administrator", + "username": "root", + "state": "active", + "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", + "web_url": "http://gitlab.dev/root", + "created_at": "2012-09-20T06:06:12Z", + "bio": "some bio", + "location": "any location", + "public_email": "", + "skype": "", + "linkedin": "", + "twitter": "", + "website_url": "", + "organization": "" + }, + "downstream_pipeline": { + "id": 5, + "sha": "f62a4b2fb89754372a346f24659212eb8da13601", + "ref": "main", + "status": "pending", + "created_at": "2012-09-20T06:06:12Z", + "updated_at": "2012-09-20T06:06:12Z", + "web_url": "https://example.com/diaspora/diaspora-client/pipelines/5" + } +} From d998afc047bd6211b44dfd584db7ad2f4d4881fe Mon Sep 17 00:00:00 2001 From: Salamon Date: Mon, 4 Dec 2023 10:55:20 +0300 Subject: [PATCH 2/5] Resolving imports conflict in pull request --- .../org/gitlab4j/api/TestGitLabApiBeans.java | 78 ++++++++++++++++++- 1 file changed, 77 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java b/src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java index f3090de25..d3f72fa04 100644 --- a/src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java +++ b/src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java @@ -33,8 +33,84 @@ import java.util.List; import java.util.Map; -import org.gitlab4j.api.models.*; +import org.gitlab4j.api.models.AccessRequest; +import org.gitlab4j.api.models.Application; +import org.gitlab4j.api.models.ApplicationSettings; +import org.gitlab4j.api.models.ApprovalRule; +import org.gitlab4j.api.models.ApprovalState; +import org.gitlab4j.api.models.ArtifactsFile; +import org.gitlab4j.api.models.AuditEvent; +import org.gitlab4j.api.models.AwardEmoji; +import org.gitlab4j.api.models.Badge; +import org.gitlab4j.api.models.Blame; +import org.gitlab4j.api.models.Board; +import org.gitlab4j.api.models.Branch; +import org.gitlab4j.api.models.Bridge; +import org.gitlab4j.api.models.Comment; +import org.gitlab4j.api.models.Commit; +import org.gitlab4j.api.models.CommitPayload; +import org.gitlab4j.api.models.CommitStatus; +import org.gitlab4j.api.models.CompareResults; +import org.gitlab4j.api.models.Contributor; +import org.gitlab4j.api.models.DeployKey; +import org.gitlab4j.api.models.DeployToken; +import org.gitlab4j.api.models.Deployment; +import org.gitlab4j.api.models.Diff; +import org.gitlab4j.api.models.Discussion; +import org.gitlab4j.api.models.Email; +import org.gitlab4j.api.models.Environment; +import org.gitlab4j.api.models.Epic; +import org.gitlab4j.api.models.EpicIssue; +import org.gitlab4j.api.models.Event; +import org.gitlab4j.api.models.ExportStatus; +import org.gitlab4j.api.models.FileUpload; +import org.gitlab4j.api.models.GpgSignature; +import org.gitlab4j.api.models.Group; +import org.gitlab4j.api.models.HealthCheckInfo; +import org.gitlab4j.api.models.ImpersonationToken; +import org.gitlab4j.api.models.ImportStatus; +import org.gitlab4j.api.models.Issue; +import org.gitlab4j.api.models.IssueLink; +import org.gitlab4j.api.models.IssuesStatistics; +import org.gitlab4j.api.models.Job; +import org.gitlab4j.api.models.Key; +import org.gitlab4j.api.models.Label; +import org.gitlab4j.api.models.LabelEvent; +import org.gitlab4j.api.models.Member; +import org.gitlab4j.api.models.MergeRequest; +import org.gitlab4j.api.models.MergeRequestDiff; +import org.gitlab4j.api.models.Milestone; +import org.gitlab4j.api.models.Note; +import org.gitlab4j.api.models.NotificationSettings; +import org.gitlab4j.api.models.OauthTokenResponse; import org.gitlab4j.api.models.Package; +import org.gitlab4j.api.models.PackageFile; +import org.gitlab4j.api.models.Pipeline; +import org.gitlab4j.api.models.PipelineSchedule; +import org.gitlab4j.api.models.Project; +import org.gitlab4j.api.models.ProjectApprovalsConfig; +import org.gitlab4j.api.models.ProjectFetches; +import org.gitlab4j.api.models.ProjectHook; +import org.gitlab4j.api.models.ProjectUser; +import org.gitlab4j.api.models.ProtectedBranch; +import org.gitlab4j.api.models.ProtectedTag; +import org.gitlab4j.api.models.PushRules; +import org.gitlab4j.api.models.RegistryRepository; +import org.gitlab4j.api.models.Release; +import org.gitlab4j.api.models.RemoteMirror; +import org.gitlab4j.api.models.RepositoryFile; +import org.gitlab4j.api.models.Runner; +import org.gitlab4j.api.models.RunnerDetail; +import org.gitlab4j.api.models.SearchBlob; +import org.gitlab4j.api.models.Snippet; +import org.gitlab4j.api.models.SshKey; +import org.gitlab4j.api.models.SystemHook; +import org.gitlab4j.api.models.Tag; +import org.gitlab4j.api.models.Todo; +import org.gitlab4j.api.models.TreeItem; +import org.gitlab4j.api.models.Trigger; +import org.gitlab4j.api.models.User; +import org.gitlab4j.api.models.Variable; import org.gitlab4j.api.services.JiraService; import org.gitlab4j.api.services.SlackService; import org.junit.jupiter.api.Test; From 64cae25f4ae97c5ea15bb5c82255050935f956b1 Mon Sep 17 00:00:00 2001 From: Salamon Date: Mon, 4 Dec 2023 12:39:41 +0300 Subject: [PATCH 3/5] Moving bridge api to appropriate classes --- src/main/java/org/gitlab4j/api/JobApi.java | 31 ------------------- .../java/org/gitlab4j/api/PipelineApi.java | 31 +++++++++++++++++++ .../java/org/gitlab4j/api/TestJobApi.java | 6 ---- .../org/gitlab4j/api/TestPipelineApi.java | 15 ++++++--- 4 files changed, 41 insertions(+), 42 deletions(-) diff --git a/src/main/java/org/gitlab4j/api/JobApi.java b/src/main/java/org/gitlab4j/api/JobApi.java index 0bbceb55b..46f1499ca 100644 --- a/src/main/java/org/gitlab4j/api/JobApi.java +++ b/src/main/java/org/gitlab4j/api/JobApi.java @@ -15,7 +15,6 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import org.gitlab4j.api.models.ArtifactsFile; -import org.gitlab4j.api.models.Bridge; import org.gitlab4j.api.models.Job; import org.gitlab4j.api.models.JobAttributes; @@ -288,36 +287,6 @@ public Optional getOptionalJob(Object projectIdOrPath, Long jobId) { } } - - /** - * Get a Pager of bridges in a pipeline. - * - *
GitLab Endpoint: GET /projects/:id/pipelines/:pipeline_id/bridges 
- * - * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path to get the pipelines for - * @param pipelineId the pipeline ID to get the list of bridges for - * @param itemsPerPage the number of Bridge instances that will be fetched per page - * @return a list containing the bridges for the specified project ID and pipeline ID - * @throws GitLabApiException if any exception occurs during execution - */ - public Pager getBridgesForPipeline(Object projectIdOrPath, long pipelineId, int itemsPerPage, JobScope scope) throws GitLabApiException { - return (new Pager<>(this, Bridge.class, itemsPerPage, getDefaultPerPageParam(), - "projects", getProjectIdOrPath(projectIdOrPath), "pipelines", pipelineId, "bridges", scope)); - } - - /** - * Get a Stream of bridges in a pipeline. - *
GitLab Endpoint: GET /projects/:id/pipelines/:pipeline_id/bridges
- * - * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path - * @param pipelineId the pipeline ID to get the list of bridges for - * @return a Stream containing the bridges for the specified project ID - * @throws GitLabApiException if any exception occurs during execution - */ - public Stream getBridgesStream(Object projectIdOrPath, long pipelineId, JobScope scope) throws GitLabApiException { - return (getBridgesForPipeline(projectIdOrPath, pipelineId, getDefaultPerPage(), scope).stream()); - } - /** * Download the artifacts file from the given reference name and job provided the job finished successfully. * The file will be saved to the specified directory. If the file already exists in the directory it will diff --git a/src/main/java/org/gitlab4j/api/PipelineApi.java b/src/main/java/org/gitlab4j/api/PipelineApi.java index 15e2019dd..5d296c4d2 100644 --- a/src/main/java/org/gitlab4j/api/PipelineApi.java +++ b/src/main/java/org/gitlab4j/api/PipelineApi.java @@ -9,6 +9,7 @@ import javax.ws.rs.core.GenericType; import javax.ws.rs.core.Response; +import org.gitlab4j.api.models.Bridge; import org.gitlab4j.api.models.Pipeline; import org.gitlab4j.api.models.PipelineFilter; import org.gitlab4j.api.models.PipelineSchedule; @@ -856,4 +857,34 @@ public Pager getPipelineVariables(Object projectIdOrPath, Long pipelin public Stream getPipelineVariablesStream(Object projectIdOrPath, Long pipelineId) throws GitLabApiException { return (getPipelineVariables(projectIdOrPath, pipelineId, getDefaultPerPage()).stream()); } + + /** + * Get a Pager of bridges in a pipeline. + * + *
GitLab Endpoint: GET /projects/:id/pipelines/:pipeline_id/bridges 
+ * + * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path to get the pipelines for + * @param pipelineId the pipeline ID to get the list of bridges for + * @param itemsPerPage the number of Bridge instances that will be fetched per page + * @return a list containing the bridges for the specified project ID and pipeline ID + * @throws GitLabApiException if any exception occurs during execution + */ + public Pager getBridgesForPipeline(Object projectIdOrPath, long pipelineId, int itemsPerPage, JobScope scope) throws GitLabApiException { + return (new Pager<>(this, Bridge.class, itemsPerPage, getDefaultPerPageParam(), + "projects", getProjectIdOrPath(projectIdOrPath), "pipelines", pipelineId, "bridges", scope)); + } + + /** + * Get a Stream of bridges in a pipeline. + *
GitLab Endpoint: GET /projects/:id/pipelines/:pipeline_id/bridges
+ * + * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID or path + * @param pipelineId the pipeline ID to get the list of bridges for + * @return a Stream containing the bridges for the specified project ID + * @throws GitLabApiException if any exception occurs during execution + */ + public Stream getBridgesStream(Object projectIdOrPath, long pipelineId, JobScope scope) throws GitLabApiException { + return (getBridgesForPipeline(projectIdOrPath, pipelineId, getDefaultPerPage(), scope).stream()); + } + } diff --git a/src/test/java/org/gitlab4j/api/TestJobApi.java b/src/test/java/org/gitlab4j/api/TestJobApi.java index c77a19ba7..6ba87a1b9 100644 --- a/src/test/java/org/gitlab4j/api/TestJobApi.java +++ b/src/test/java/org/gitlab4j/api/TestJobApi.java @@ -83,10 +83,4 @@ public void testGetJobs() throws GitLabApiException { assertNotNull(jobs); } - @Test - public void test() throws GitLabApiException { - Set bridges = gitLabApi.getJobApi().getBridgesStream(testProject, 4L, Constants.JobScope.SUCCESS).collect(Collectors.toSet()); - assertNotNull(bridges); - } - } diff --git a/src/test/java/org/gitlab4j/api/TestPipelineApi.java b/src/test/java/org/gitlab4j/api/TestPipelineApi.java index 47dcf7cca..ea5c9051f 100644 --- a/src/test/java/org/gitlab4j/api/TestPipelineApi.java +++ b/src/test/java/org/gitlab4j/api/TestPipelineApi.java @@ -7,13 +7,11 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assumptions.assumeTrue; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; +import java.util.*; +import java.util.stream.Collectors; import java.util.stream.Stream; +import org.gitlab4j.api.models.Bridge; import org.gitlab4j.api.models.Pipeline; import org.gitlab4j.api.models.PipelineSchedule; import org.gitlab4j.api.models.Project; @@ -350,4 +348,11 @@ public void testPipelineVariables() throws GitLabApiException { gitLabApi.getPipelineApi().deletePipeline(testProject, pipeline.getId()); } } + + @Test + public void testGetBridges() throws GitLabApiException { + Set bridges = gitLabApi.getPipelineApi().getBridgesStream(testProject, 4L, Constants.JobScope.SUCCESS).collect(Collectors.toSet()); + assertNotNull(bridges); + } + } From 0a4e76285d38d66648d40f0ceb87cebfe061984a Mon Sep 17 00:00:00 2001 From: Salamon Date: Mon, 4 Dec 2023 12:54:54 +0300 Subject: [PATCH 4/5] Refactoring --- .../org/gitlab4j/api/TestGitLabApiBeans.java | 21 +++++++++++++++++++ .../java/org/gitlab4j/api/TestJobApi.java | 1 - .../org/gitlab4j/api/TestPipelineApi.java | 7 ++++++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java b/src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java index 7f6e59031..025f7eeab 100644 --- a/src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java +++ b/src/test/java/org/gitlab4j/api/TestGitLabApiBeans.java @@ -46,12 +46,16 @@ import org.gitlab4j.api.models.Board; import org.gitlab4j.api.models.Branch; import org.gitlab4j.api.models.Bridge; +import org.gitlab4j.api.models.ChildEpic; +import org.gitlab4j.api.models.GitLabCiTemplate; +import org.gitlab4j.api.models.GitLabCiTemplateElement; import org.gitlab4j.api.models.Comment; import org.gitlab4j.api.models.Commit; import org.gitlab4j.api.models.CommitPayload; import org.gitlab4j.api.models.CommitStatus; import org.gitlab4j.api.models.CompareResults; import org.gitlab4j.api.models.Contributor; +import org.gitlab4j.api.models.CreatedChildEpic; import org.gitlab4j.api.models.DeployKey; import org.gitlab4j.api.models.DeployToken; import org.gitlab4j.api.models.Deployment; @@ -61,24 +65,34 @@ import org.gitlab4j.api.models.Environment; import org.gitlab4j.api.models.Epic; import org.gitlab4j.api.models.EpicIssue; +import org.gitlab4j.api.models.EpicIssueLink; import org.gitlab4j.api.models.Event; import org.gitlab4j.api.models.ExportStatus; +import org.gitlab4j.api.models.ExternalStatusCheck; +import org.gitlab4j.api.models.ExternalStatusCheckResult; +import org.gitlab4j.api.models.ExternalStatusCheckStatus; import org.gitlab4j.api.models.FileUpload; import org.gitlab4j.api.models.GpgSignature; import org.gitlab4j.api.models.Group; +import org.gitlab4j.api.models.GroupAccessToken; import org.gitlab4j.api.models.HealthCheckInfo; import org.gitlab4j.api.models.ImpersonationToken; import org.gitlab4j.api.models.ImportStatus; import org.gitlab4j.api.models.Issue; import org.gitlab4j.api.models.IssueLink; import org.gitlab4j.api.models.IssuesStatistics; +import org.gitlab4j.api.models.Iteration; import org.gitlab4j.api.models.Job; import org.gitlab4j.api.models.Key; import org.gitlab4j.api.models.Label; import org.gitlab4j.api.models.LabelEvent; +import org.gitlab4j.api.models.LdapGroupLink; +import org.gitlab4j.api.models.Link; import org.gitlab4j.api.models.Member; import org.gitlab4j.api.models.MergeRequest; import org.gitlab4j.api.models.MergeRequestDiff; +import org.gitlab4j.api.models.MergeRequestVersion; +import org.gitlab4j.api.models.Metadata; import org.gitlab4j.api.models.Milestone; import org.gitlab4j.api.models.Note; import org.gitlab4j.api.models.NotificationSettings; @@ -88,31 +102,38 @@ import org.gitlab4j.api.models.Pipeline; import org.gitlab4j.api.models.PipelineSchedule; import org.gitlab4j.api.models.Project; +import org.gitlab4j.api.models.ProjectAccessToken; import org.gitlab4j.api.models.ProjectApprovalsConfig; import org.gitlab4j.api.models.ProjectFetches; +import org.gitlab4j.api.models.ProjectGroup; import org.gitlab4j.api.models.ProjectHook; import org.gitlab4j.api.models.ProjectUser; import org.gitlab4j.api.models.ProtectedBranch; import org.gitlab4j.api.models.ProtectedTag; import org.gitlab4j.api.models.PushRules; import org.gitlab4j.api.models.RegistryRepository; +import org.gitlab4j.api.models.RelatedEpic; +import org.gitlab4j.api.models.RelatedEpicLink; import org.gitlab4j.api.models.Release; import org.gitlab4j.api.models.RemoteMirror; import org.gitlab4j.api.models.RepositoryFile; import org.gitlab4j.api.models.Runner; import org.gitlab4j.api.models.RunnerDetail; +import org.gitlab4j.api.models.SamlGroupLink; import org.gitlab4j.api.models.SearchBlob; import org.gitlab4j.api.models.Snippet; import org.gitlab4j.api.models.SshKey; import org.gitlab4j.api.models.SystemHook; import org.gitlab4j.api.models.Tag; import org.gitlab4j.api.models.Todo; +import org.gitlab4j.api.models.Topic; import org.gitlab4j.api.models.TreeItem; import org.gitlab4j.api.models.Trigger; import org.gitlab4j.api.models.User; import org.gitlab4j.api.models.Variable; import org.gitlab4j.api.services.JiraService; import org.gitlab4j.api.services.SlackService; +import org.gitlab4j.api.webhook.ExternalStatusCheckEvent; import org.junit.jupiter.api.Test; import com.fasterxml.jackson.databind.JsonNode; diff --git a/src/test/java/org/gitlab4j/api/TestJobApi.java b/src/test/java/org/gitlab4j/api/TestJobApi.java index 6ba87a1b9..ad19183f4 100644 --- a/src/test/java/org/gitlab4j/api/TestJobApi.java +++ b/src/test/java/org/gitlab4j/api/TestJobApi.java @@ -82,5 +82,4 @@ public void testGetJobs() throws GitLabApiException { List jobs = gitLabApi.getJobApi().getJobs(testProject); assertNotNull(jobs); } - } diff --git a/src/test/java/org/gitlab4j/api/TestPipelineApi.java b/src/test/java/org/gitlab4j/api/TestPipelineApi.java index ea5c9051f..cec5ddc8f 100644 --- a/src/test/java/org/gitlab4j/api/TestPipelineApi.java +++ b/src/test/java/org/gitlab4j/api/TestPipelineApi.java @@ -7,7 +7,12 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assumptions.assumeTrue; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; From 4886960d60c97b2d46c851bd84e9dd0fb80475af Mon Sep 17 00:00:00 2001 From: Salamon Date: Wed, 6 Dec 2023 22:31:29 +0300 Subject: [PATCH 5/5] Disable testGetBridges by the reason old version of gitlab in test --- src/test/java/org/gitlab4j/api/TestPipelineApi.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/test/java/org/gitlab4j/api/TestPipelineApi.java b/src/test/java/org/gitlab4j/api/TestPipelineApi.java index cec5ddc8f..5cb59c191 100644 --- a/src/test/java/org/gitlab4j/api/TestPipelineApi.java +++ b/src/test/java/org/gitlab4j/api/TestPipelineApi.java @@ -23,11 +23,7 @@ import org.gitlab4j.api.models.RepositoryFile; import org.gitlab4j.api.models.Trigger; import org.gitlab4j.api.models.Variable; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.*; import org.junit.jupiter.api.extension.ExtendWith; @Tag("integration") @@ -355,6 +351,7 @@ public void testPipelineVariables() throws GitLabApiException { } @Test + @Disabled("disable till 'Move the test infrastructure to Testcontainers #925'") public void testGetBridges() throws GitLabApiException { Set bridges = gitLabApi.getPipelineApi().getBridgesStream(testProject, 4L, Constants.JobScope.SUCCESS).collect(Collectors.toSet()); assertNotNull(bridges);