-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathSearchFlakyTests.java
More file actions
55 lines (51 loc) · 2.62 KB
/
SearchFlakyTests.java
File metadata and controls
55 lines (51 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Search flaky tests returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.TestOptimizationApi;
import com.datadog.api.client.v2.api.TestOptimizationApi.SearchFlakyTestsOptionalParameters;
import com.datadog.api.client.v2.model.FlakyTestsSearchFilter;
import com.datadog.api.client.v2.model.FlakyTestsSearchPageOptions;
import com.datadog.api.client.v2.model.FlakyTestsSearchRequest;
import com.datadog.api.client.v2.model.FlakyTestsSearchRequestAttributes;
import com.datadog.api.client.v2.model.FlakyTestsSearchRequestData;
import com.datadog.api.client.v2.model.FlakyTestsSearchRequestDataType;
import com.datadog.api.client.v2.model.FlakyTestsSearchResponse;
import com.datadog.api.client.v2.model.FlakyTestsSearchSort;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setUnstableOperationEnabled("v2.searchFlakyTests", true);
TestOptimizationApi apiInstance = new TestOptimizationApi(defaultClient);
FlakyTestsSearchRequest body =
new FlakyTestsSearchRequest()
.data(
new FlakyTestsSearchRequestData()
.attributes(
new FlakyTestsSearchRequestAttributes()
.filter(
new FlakyTestsSearchFilter()
.includeHistory(true)
.query(
"""
flaky_test_state:active @git.repository.id_v2:"github.com/datadog/shopist"
"""))
.page(
new FlakyTestsSearchPageOptions()
.cursor(
"eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==")
.limit(25L))
.sort(FlakyTestsSearchSort.FAILURE_RATE_ASCENDING))
.type(FlakyTestsSearchRequestDataType.SEARCH_FLAKY_TESTS_REQUEST));
try {
FlakyTestsSearchResponse result =
apiInstance.searchFlakyTests(new SearchFlakyTestsOptionalParameters().body(body));
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling TestOptimizationApi#searchFlakyTests");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}