Skip to content

Commit d5ef273

Browse files
committed
Added async methods
1 parent 24af515 commit d5ef273

File tree

1 file changed

+64
-5
lines changed

1 file changed

+64
-5
lines changed

azd/src/main/java/org/azd/test/results/ResultsRequestBuilder.java

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
package org.azd.test.results;
22

33
import org.azd.abstractions.BaseRequestBuilder;
4-
import org.azd.abstractions.QueryParameter;
54
import org.azd.authentication.AccessTokenCredential;
65
import org.azd.common.ApiVersion;
7-
import org.azd.enums.TestRunPublishContext;
8-
import org.azd.enums.TestRunState;
96
import org.azd.exceptions.AzDException;
10-
import org.azd.test.types.*;
7+
import org.azd.test.types.TestCaseResult;
8+
import org.azd.test.types.TestCaseResults;
9+
import org.azd.test.types.TestRuns;
1110

1211
import java.util.concurrent.CompletableFuture;
13-
import java.util.function.Consumer;
1412

1513
/**
1614
* Provides functionality to work with Test results Api.
@@ -26,6 +24,67 @@ public ResultsRequestBuilder(String organizationUrl, AccessTokenCredential acces
2624
super(organizationUrl, accessTokenCredential, "test", "4637d869-3a76-4468-8057-0bb02aa385cf", ApiVersion.TEST_RESULTS);
2725
}
2826

27+
/**
28+
* Get a test case results for a test run.
29+
*
30+
* @param runId ID of the run to get.
31+
* @param testCaseResultId ID of the test case result to get.
32+
* @return TestCaseResult Object {@link TestCaseResult}
33+
* @throws AzDException Default Api Exception handler.
34+
**/
35+
public CompletableFuture<TestCaseResult> getAsync(int runId, int testCaseResultId) throws AzDException {
36+
return builder()
37+
.serviceEndpoint("runId", runId)
38+
.serviceEndpoint("testCaseResultId", testCaseResultId)
39+
.build()
40+
.executeAsync(TestCaseResult.class);
41+
}
42+
43+
/**
44+
* Get a list of test results by run ID.
45+
*
46+
* @param runId ID of the run.
47+
* @return Collection of TestCaseResults Object {@link TestRuns}
48+
* @throws AzDException Default Api Exception handler.
49+
**/
50+
public CompletableFuture<TestCaseResults> listAsync(int runId) throws AzDException {
51+
return builder()
52+
.serviceEndpoint("runId", runId)
53+
.build()
54+
.executeAsync(TestCaseResults.class);
55+
}
56+
57+
/**
58+
* Create test results by run ID.
59+
*
60+
* @param runId ID of the run to update.
61+
* @param testCaseResults Test case results object to update.
62+
* @return Test case results object {@link TestCaseResults}
63+
* @throws AzDException Default Api Exception handler.
64+
*/
65+
public CompletableFuture<TestCaseResults> createAsync(int runId, TestCaseResults testCaseResults) throws AzDException {
66+
return builder()
67+
.POST(testCaseResults.getResults())
68+
.serviceEndpoint("runId", runId)
69+
.build()
70+
.executeAsync(TestCaseResults.class);
71+
}
72+
73+
/**
74+
* Update test results by run ID.
75+
*
76+
* @param runId ID of the run to update.
77+
* @param testCaseResults Test case results object to update.
78+
* @return Test case results object {@link TestCaseResults}
79+
* @throws AzDException Default Api Exception handler.
80+
*/
81+
public CompletableFuture<TestCaseResults> updateAsync(int runId, TestCaseResults testCaseResults) throws AzDException {
82+
return builder()
83+
.PATCH(testCaseResults.getResults())
84+
.serviceEndpoint("runId", runId)
85+
.build()
86+
.executeAsync(TestCaseResults.class);
87+
}
2988

3089
/**
3190
* Get a test case results for a test run.

0 commit comments

Comments
 (0)