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