|
1 | 1 | package datadog.trace.civisibility.config;
|
2 | 2 |
|
3 | 3 | import com.squareup.moshi.FromJson;
|
| 4 | +import com.squareup.moshi.Json; |
4 | 5 | import com.squareup.moshi.JsonAdapter;
|
5 | 6 | import com.squareup.moshi.Moshi;
|
6 | 7 | import com.squareup.moshi.ToJson;
|
@@ -65,6 +66,7 @@ public class ConfigurationApiImpl implements ConfigurationApi {
|
65 | 66 | private final JsonAdapter<EnvelopeDto<CiVisibilitySettings>> settingsResponseAdapter;
|
66 | 67 | private final JsonAdapter<MultiEnvelopeDto<TestIdentifierJson>> testIdentifiersResponseAdapter;
|
67 | 68 | private final JsonAdapter<EnvelopeDto<KnownTestsDto>> testFullNamesResponseAdapter;
|
| 69 | + private final JsonAdapter<EnvelopeDto<TestManagementDto>> testManagementRequestAdapter; |
68 | 70 | private final JsonAdapter<EnvelopeDto<TestManagementTestsDto>> testManagementTestsResponseAdapter;
|
69 | 71 | private final JsonAdapter<EnvelopeDto<ChangedFiles>> changedFilesResponseAdapter;
|
70 | 72 |
|
@@ -108,6 +110,11 @@ public ConfigurationApiImpl(BackendApi backendApi, CiVisibilityMetricCollector m
|
108 | 110 | ConfigurationApiImpl.class, EnvelopeDto.class, KnownTestsDto.class);
|
109 | 111 | testFullNamesResponseAdapter = moshi.adapter(testFullNamesResponseType);
|
110 | 112 |
|
| 113 | + ParameterizedType testManagementRequestType = |
| 114 | + Types.newParameterizedTypeWithOwner( |
| 115 | + ConfigurationApiImpl.class, EnvelopeDto.class, TestManagementDto.class); |
| 116 | + testManagementRequestAdapter = moshi.adapter(testManagementRequestType); |
| 117 | + |
111 | 118 | ParameterizedType testManagementTestsResponseType =
|
112 | 119 | Types.newParameterizedTypeWithOwner(
|
113 | 120 | ConfigurationApiImpl.class, EnvelopeDto.class, TestManagementTestsDto.class);
|
@@ -329,9 +336,16 @@ public Map<TestSetting, Map<String, Collection<TestFQN>>> getTestManagementTests
|
329 | 336 | .build();
|
330 | 337 |
|
331 | 338 | String uuid = uuidGenerator.get();
|
332 |
| - EnvelopeDto<TracerEnvironment> request = |
333 |
| - new EnvelopeDto<>(new DataDto<>(uuid, "ci_app_libraries_tests_request", tracerEnvironment)); |
334 |
| - String json = requestAdapter.toJson(request); |
| 339 | + EnvelopeDto<TestManagementDto> request = |
| 340 | + new EnvelopeDto<>( |
| 341 | + new DataDto<>( |
| 342 | + uuid, |
| 343 | + "ci_app_libraries_tests_request", |
| 344 | + new TestManagementDto( |
| 345 | + tracerEnvironment.getRepositoryUrl(), |
| 346 | + tracerEnvironment.getCommitMessage(), |
| 347 | + tracerEnvironment.getConfigurations().getTestBundle()))); |
| 348 | + String json = testManagementRequestAdapter.toJson(request); |
335 | 349 | RequestBody requestBody = RequestBody.create(JSON, json);
|
336 | 350 | TestManagementTestsDto testManagementTestsDto =
|
337 | 351 | backendApi.post(
|
@@ -520,6 +534,22 @@ private KnownTestsDto(Map<String, Map<String, List<String>>> tests) {
|
520 | 534 | }
|
521 | 535 | }
|
522 | 536 |
|
| 537 | + private static final class TestManagementDto { |
| 538 | + @Json(name = "repository_url") |
| 539 | + private final String repositoryUrl; |
| 540 | + |
| 541 | + @Json(name = "commit_message") |
| 542 | + private final String commitMessage; |
| 543 | + |
| 544 | + private final String module; |
| 545 | + |
| 546 | + private TestManagementDto(String repositoryUrl, String commitMessage, String module) { |
| 547 | + this.repositoryUrl = repositoryUrl; |
| 548 | + this.commitMessage = commitMessage; |
| 549 | + this.module = module; |
| 550 | + } |
| 551 | + } |
| 552 | + |
523 | 553 | private static final class TestManagementTestsDto {
|
524 | 554 | private static final class Properties {
|
525 | 555 | private final Map<String, Boolean> properties;
|
|
0 commit comments