Skip to content

Commit bc2b753

Browse files
committed
1 parent 05d4eb9 commit bc2b753

File tree

7 files changed

+276
-0
lines changed

7 files changed

+276
-0
lines changed

gitlab4j-api/src/main/java/org/gitlab4j/api/PipelineApi.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.gitlab4j.api.models.PipelineFilter;
1515
import org.gitlab4j.api.models.PipelineSchedule;
1616
import org.gitlab4j.api.models.PipelineStatus;
17+
import org.gitlab4j.api.models.TestReportSummary;
1718
import org.gitlab4j.api.models.Trigger;
1819
import org.gitlab4j.api.models.Variable;
1920
import org.gitlab4j.models.Constants;
@@ -794,6 +795,28 @@ public void deletePipelineScheduleVariable(Object projectIdOrPath, Long pipeline
794795
key);
795796
}
796797

798+
/**
799+
* Get the test report summary for a pipeline.
800+
*
801+
* <pre><code>GET /projects/:id/pipelines/:pipeline_id/test_report_summary</code></pre>
802+
*
803+
* @param projectIdOrPath projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance, required
804+
* @param pipelineId the pipeline ID
805+
* @return the test report summary for the pipeline
806+
*/
807+
public TestReportSummary getTestReportSummaryForPipeline(Object projectIdOrPath, long pipelineId)
808+
throws GitLabApiException {
809+
Response response = get(
810+
Response.Status.OK,
811+
null,
812+
"projects",
813+
getProjectIdOrPath(projectIdOrPath),
814+
"pipelines",
815+
pipelineId,
816+
"test_report_summary");
817+
return response.readEntity(TestReportSummary.class);
818+
}
819+
797820
/**
798821
* Get a list of the project pipeline triggers for the specified project.
799822
*

gitlab4j-api/src/test/java/org/gitlab4j/api/TestPipelineApi.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.gitlab4j.api.models.Project;
2323
import org.gitlab4j.api.models.RepositoryFile;
2424
import org.gitlab4j.api.models.RepositoryFileResponse;
25+
import org.gitlab4j.api.models.TestReportSummary;
2526
import org.gitlab4j.api.models.Trigger;
2627
import org.gitlab4j.api.models.Variable;
2728
import org.gitlab4j.models.Constants;
@@ -401,4 +402,12 @@ public void testGetBridges() throws GitLabApiException {
401402
.collect(Collectors.toSet());
402403
assertNotNull(bridges);
403404
}
405+
406+
@Test
407+
@Disabled("disable till 'Move the test infrastructure to Testcontainers #925'")
408+
public void testGetTestReportSummary() throws GitLabApiException {
409+
TestReportSummary testReportSummary =
410+
gitLabApi.getPipelineApi().getTestReportSummaryForPipeline(testProject, 4L);
411+
assertNotNull(testReportSummary);
412+
}
404413
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package org.gitlab4j.api.models;
2+
3+
import org.gitlab4j.models.utils.JacksonJson;
4+
5+
import java.io.Serializable;
6+
import java.util.Date;
7+
8+
public class TestReportStats implements Serializable {
9+
private static final long serialVersionUID = 1L;
10+
11+
private Long time;
12+
private Long count;
13+
private Long success;
14+
private Long failed;
15+
private Long skipped;
16+
private Long error;
17+
private String suiteError;
18+
19+
public Long getTime() {
20+
return time;
21+
}
22+
23+
public void setTime(Long time) {
24+
this.time = time;
25+
}
26+
27+
public Long getCount() {
28+
return count;
29+
}
30+
31+
public void setCount(Long count) {
32+
this.count = count;
33+
}
34+
35+
public Long getSuccess() {
36+
return success;
37+
}
38+
39+
public void setSuccess(Long success) {
40+
this.success = success;
41+
}
42+
43+
public Long getFailed() {
44+
return failed;
45+
}
46+
47+
public void setFailed(Long failed) {
48+
this.failed = failed;
49+
}
50+
51+
public Long getSkipped() {
52+
return skipped;
53+
}
54+
55+
public void setSkipped(Long skipped) {
56+
this.skipped = skipped;
57+
}
58+
59+
public Long getError() {
60+
return error;
61+
}
62+
63+
public void setError(Long error) {
64+
this.error = error;
65+
}
66+
67+
public String getSuiteError() {
68+
return suiteError;
69+
}
70+
71+
public void setSuiteError(String suiteError) {
72+
this.suiteError = suiteError;
73+
}
74+
75+
@Override
76+
public String toString() {
77+
return (JacksonJson.toJsonString(this));
78+
}
79+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package org.gitlab4j.api.models;
2+
3+
import org.gitlab4j.models.utils.JacksonJson;
4+
5+
import java.io.Serializable;
6+
import java.util.Date;
7+
import java.util.List;
8+
9+
public class TestReportSummary implements Serializable {
10+
private static final long serialVersionUID = 1L;
11+
12+
private TestReportStats total;
13+
private List<TestSuite> testSuites;
14+
15+
public TestReportStats getTotal() {
16+
return total;
17+
}
18+
19+
public void setTotal(TestReportStats total) {
20+
this.total = total;
21+
}
22+
23+
public List<TestSuite> getTestSuites() {
24+
return testSuites;
25+
}
26+
27+
public void setTestSuites(List<TestSuite> testSuites) {
28+
this.testSuites = testSuites;
29+
}
30+
31+
@Override
32+
public String toString() {
33+
return (JacksonJson.toJsonString(this));
34+
}
35+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
package org.gitlab4j.api.models;
2+
3+
import org.gitlab4j.models.utils.JacksonJson;
4+
5+
import java.io.Serializable;
6+
import java.util.Date;
7+
import java.util.List;
8+
9+
public class TestSuite implements Serializable {
10+
private static final long serialVersionUID = 1L;
11+
12+
private String name;
13+
private Long totalTime;
14+
private Long totalCount;
15+
private Long successCount;
16+
private Long failedCount;
17+
private Long skippedCount;
18+
private Long errorCount;
19+
private List<Long> buildIds;
20+
private String suiteError;
21+
22+
public String getName() {
23+
return name;
24+
}
25+
26+
public void setName(String name) {
27+
this.name = name;
28+
}
29+
30+
public Long getTotalTime() {
31+
return totalTime;
32+
}
33+
34+
public void setTotalTime(Long totalTime) {
35+
this.totalTime = totalTime;
36+
}
37+
38+
public Long getTotalCount() {
39+
return totalCount;
40+
}
41+
42+
public void setTotalCount(Long totalCount) {
43+
this.totalCount = totalCount;
44+
}
45+
46+
public Long getSuccessCount() {
47+
return successCount;
48+
}
49+
50+
public void setSuccessCount(Long successCount) {
51+
this.successCount = successCount;
52+
}
53+
54+
public Long getFailedCount() {
55+
return failedCount;
56+
}
57+
58+
public void setFailedCount(Long failedCount) {
59+
this.failedCount = failedCount;
60+
}
61+
62+
public Long getSkippedCount() {
63+
return skippedCount;
64+
}
65+
66+
public void setSkippedCount(Long skippedCount) {
67+
this.skippedCount = skippedCount;
68+
}
69+
70+
public Long getErrorCount() {
71+
return errorCount;
72+
}
73+
74+
public void setErrorCount(Long errorCount) {
75+
this.errorCount = errorCount;
76+
}
77+
78+
public List<Long> getBuildIds() {
79+
return buildIds;
80+
}
81+
82+
public void setBuildIds(List<Long> buildIds) {
83+
this.buildIds = buildIds;
84+
}
85+
86+
public String getSuiteError() {
87+
return suiteError;
88+
}
89+
90+
public void setSuiteError(String suiteError) {
91+
this.suiteError = suiteError;
92+
}
93+
94+
@Override
95+
public String toString() {
96+
return (JacksonJson.toJsonString(this));
97+
}
98+
}

gitlab4j-models/src/test/java/org/gitlab4j/models/TestGitLabApiBeans.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,12 @@ public void testPipelineSchedule() throws Exception {
410410
assertTrue(compareJson(pipelineSchedule, "pipeline-schedule.json"));
411411
}
412412

413+
@Test
414+
public void testPipelineTestReportSummary() throws Exception {
415+
TestReportSummary testReportSummary = unmarshalResource(TestReportSummary.class, "pipeline-test-report-summary.json");
416+
assertTrue(compareJson(testReportSummary, "pipeline-test-report-summary.json"));
417+
}
418+
413419
@Test
414420
public void testPipelineVariables() throws Exception {
415421
List<Variable> variables = unmarshalResourceList(Variable.class, "pipeline-variables.json");
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"total": {
3+
"time": 1904,
4+
"count": 3363,
5+
"success": 3351,
6+
"failed": 0,
7+
"skipped": 12,
8+
"error": 0,
9+
"suite_error": "An error"
10+
},
11+
"test_suites": [
12+
{
13+
"name": "test",
14+
"total_time": 1904,
15+
"total_count": 3363,
16+
"success_count": 3351,
17+
"failed_count": 0,
18+
"skipped_count": 12,
19+
"error_count": 0,
20+
"build_ids": [
21+
66004
22+
],
23+
"suite_error": "Another error"
24+
}
25+
]
26+
}

0 commit comments

Comments
 (0)