Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions gitlab4j-api/src/main/java/org/gitlab4j/api/PipelineApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.gitlab4j.api.models.PipelineFilter;
import org.gitlab4j.api.models.PipelineSchedule;
import org.gitlab4j.api.models.PipelineStatus;
import org.gitlab4j.api.models.TestReportSummary;
import org.gitlab4j.api.models.Trigger;
import org.gitlab4j.api.models.Variable;
import org.gitlab4j.models.Constants;
Expand Down Expand Up @@ -794,6 +795,28 @@ public void deletePipelineScheduleVariable(Object projectIdOrPath, Long pipeline
key);
}

/**
* Get the test report summary for a pipeline.
*
* <pre><code>GET /projects/:id/pipelines/:pipeline_id/test_report_summary</code></pre>
*
* @param projectIdOrPath projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance, required
* @param pipelineId the pipeline ID
* @return the test report summary for the pipeline
*/
public TestReportSummary getTestReportSummaryForPipeline(Object projectIdOrPath, long pipelineId)
throws GitLabApiException {
Response response = get(
Response.Status.OK,
null,
"projects",
getProjectIdOrPath(projectIdOrPath),
"pipelines",
pipelineId,
"test_report_summary");
return response.readEntity(TestReportSummary.class);
}

/**
* Get a list of the project pipeline triggers for the specified project.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.gitlab4j.api.models.Project;
import org.gitlab4j.api.models.RepositoryFile;
import org.gitlab4j.api.models.RepositoryFileResponse;
import org.gitlab4j.api.models.TestReportSummary;
import org.gitlab4j.api.models.Trigger;
import org.gitlab4j.api.models.Variable;
import org.gitlab4j.models.Constants;
Expand Down Expand Up @@ -401,4 +402,12 @@ public void testGetBridges() throws GitLabApiException {
.collect(Collectors.toSet());
assertNotNull(bridges);
}

@Test
@Disabled("disable till 'Move the test infrastructure to Testcontainers #925'")
public void testGetTestReportSummary() throws GitLabApiException {
TestReportSummary testReportSummary =
gitLabApi.getPipelineApi().getTestReportSummaryForPipeline(testProject, 4L);
assertNotNull(testReportSummary);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package org.gitlab4j.api.models;

import java.io.Serializable;

import org.gitlab4j.models.utils.JacksonJson;

public class TestReportStats implements Serializable {
private static final long serialVersionUID = 1L;

private Long time;
private Long count;
private Long success;
private Long failed;
private Long skipped;
private Long error;
private String suiteError;

public Long getTime() {
return time;
}

public void setTime(Long time) {
this.time = time;
}

public Long getCount() {
return count;
}

public void setCount(Long count) {
this.count = count;
}

public Long getSuccess() {
return success;
}

public void setSuccess(Long success) {
this.success = success;
}

public Long getFailed() {
return failed;
}

public void setFailed(Long failed) {
this.failed = failed;
}

public Long getSkipped() {
return skipped;
}

public void setSkipped(Long skipped) {
this.skipped = skipped;
}

public Long getError() {
return error;
}

public void setError(Long error) {
this.error = error;
}

public String getSuiteError() {
return suiteError;
}

public void setSuiteError(String suiteError) {
this.suiteError = suiteError;
}

@Override
public String toString() {
return (JacksonJson.toJsonString(this));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.gitlab4j.api.models;

import java.io.Serializable;
import java.util.List;

import org.gitlab4j.models.utils.JacksonJson;

public class TestReportSummary implements Serializable {
private static final long serialVersionUID = 1L;

private TestReportStats total;
private List<TestSuite> testSuites;

public TestReportStats getTotal() {
return total;
}

public void setTotal(TestReportStats total) {
this.total = total;
}

public List<TestSuite> getTestSuites() {
return testSuites;
}

public void setTestSuites(List<TestSuite> testSuites) {
this.testSuites = testSuites;
}

@Override
public String toString() {
return (JacksonJson.toJsonString(this));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package org.gitlab4j.api.models;

import java.io.Serializable;
import java.util.List;

import org.gitlab4j.models.utils.JacksonJson;

public class TestSuite implements Serializable {
private static final long serialVersionUID = 1L;

private String name;
private Long totalTime;
private Long totalCount;
private Long successCount;
private Long failedCount;
private Long skippedCount;
private Long errorCount;
private List<Long> buildIds;
private String suiteError;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public Long getTotalTime() {
return totalTime;
}

public void setTotalTime(Long totalTime) {
this.totalTime = totalTime;
}

public Long getTotalCount() {
return totalCount;
}

public void setTotalCount(Long totalCount) {
this.totalCount = totalCount;
}

public Long getSuccessCount() {
return successCount;
}

public void setSuccessCount(Long successCount) {
this.successCount = successCount;
}

public Long getFailedCount() {
return failedCount;
}

public void setFailedCount(Long failedCount) {
this.failedCount = failedCount;
}

public Long getSkippedCount() {
return skippedCount;
}

public void setSkippedCount(Long skippedCount) {
this.skippedCount = skippedCount;
}

public Long getErrorCount() {
return errorCount;
}

public void setErrorCount(Long errorCount) {
this.errorCount = errorCount;
}

public List<Long> getBuildIds() {
return buildIds;
}

public void setBuildIds(List<Long> buildIds) {
this.buildIds = buildIds;
}

public String getSuiteError() {
return suiteError;
}

public void setSuiteError(String suiteError) {
this.suiteError = suiteError;
}

@Override
public String toString() {
return (JacksonJson.toJsonString(this));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,13 @@ public void testPipelineSchedule() throws Exception {
assertTrue(compareJson(pipelineSchedule, "pipeline-schedule.json"));
}

@Test
public void testPipelineTestReportSummary() throws Exception {
TestReportSummary testReportSummary =
unmarshalResource(TestReportSummary.class, "pipeline-test-report-summary.json");
assertTrue(compareJson(testReportSummary, "pipeline-test-report-summary.json"));
}

@Test
public void testPipelineVariables() throws Exception {
List<Variable> variables = unmarshalResourceList(Variable.class, "pipeline-variables.json");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"total": {
"time": 1904,
"count": 3363,
"success": 3351,
"failed": 0,
"skipped": 12,
"error": 0,
"suite_error": "An error"
},
"test_suites": [
{
"name": "test",
"total_time": 1904,
"total_count": 3363,
"success_count": 3351,
"failed_count": 0,
"skipped_count": 12,
"error_count": 0,
"build_ids": [
66004
],
"suite_error": "Another error"
}
]
}
Loading