From e32d461ec035c79bfcdeca1197ab48f463c0a30a Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Thu, 27 Apr 2023 11:41:34 +0300 Subject: [PATCH] Use IList for responses (#121) --- .../Abstractions/Resources/ITestItemResource.cs | 2 +- src/ReportPortal.Client/Abstractions/Responses/Content.cs | 2 +- .../Abstractions/Responses/LaunchResponse.cs | 2 +- .../Abstractions/Responses/LogItemResponse.cs | 1 - .../Abstractions/Responses/ResponsesList.cs | 7 +++---- .../Abstractions/Responses/TestItemHistoryResponse.cs | 5 ++--- .../Abstractions/Responses/TestItemResponse.cs | 8 ++++---- .../Abstractions/Responses/UserFilterCreatedResponse.cs | 6 +----- .../Abstractions/Responses/UserFilterResponse.cs | 4 ++-- .../Converters/ClientSourceGenerationContext.cs | 2 +- .../Resources/ServiceTestItemResource.cs | 4 ++-- .../LaunchFixtureBase.cs | 7 +++++-- .../LaunchesFixtureBase.cs | 7 +++++-- .../LogItem/AsyncLogItemFixture.cs | 5 +---- .../LogItem/LogItemFixture.cs | 2 +- .../LogItemFixtureBase.cs | 5 +++-- .../Project/Project.cs | 2 +- 17 files changed, 34 insertions(+), 37 deletions(-) diff --git a/src/ReportPortal.Client/Abstractions/Resources/ITestItemResource.cs b/src/ReportPortal.Client/Abstractions/Resources/ITestItemResource.cs index 1a33ba50..138b4de5 100644 --- a/src/ReportPortal.Client/Abstractions/Resources/ITestItemResource.cs +++ b/src/ReportPortal.Client/Abstractions/Resources/ITestItemResource.cs @@ -18,7 +18,7 @@ public interface ITestItemResource /// Information about test items and their issues. /// Cancellation token. /// A list of assigned issues. - Task> AssignIssuesAsync(AssignTestItemIssuesRequest request, CancellationToken cancellationToken = default); + Task> AssignIssuesAsync(AssignTestItemIssuesRequest request, CancellationToken cancellationToken = default); /// /// Deletes specified test item. diff --git a/src/ReportPortal.Client/Abstractions/Responses/Content.cs b/src/ReportPortal.Client/Abstractions/Responses/Content.cs index 041d8244..a47eacf0 100644 --- a/src/ReportPortal.Client/Abstractions/Responses/Content.cs +++ b/src/ReportPortal.Client/Abstractions/Responses/Content.cs @@ -6,7 +6,7 @@ namespace ReportPortal.Client.Abstractions.Responses public class Content { [JsonPropertyName("content")] - public IEnumerable Items { get; set; } + public IList Items { get; set; } public Page Page { get; set; } } diff --git a/src/ReportPortal.Client/Abstractions/Responses/LaunchResponse.cs b/src/ReportPortal.Client/Abstractions/Responses/LaunchResponse.cs index 97c9fe1a..0cfd67e4 100644 --- a/src/ReportPortal.Client/Abstractions/Responses/LaunchResponse.cs +++ b/src/ReportPortal.Client/Abstractions/Responses/LaunchResponse.cs @@ -29,7 +29,7 @@ public class LaunchResponse public bool HasRetries { get; set; } - public IEnumerable Attributes { get; set; } + public IList Attributes { get; set; } public Statistic Statistics { get; set; } } diff --git a/src/ReportPortal.Client/Abstractions/Responses/LogItemResponse.cs b/src/ReportPortal.Client/Abstractions/Responses/LogItemResponse.cs index 27d8066f..ad6f8bff 100644 --- a/src/ReportPortal.Client/Abstractions/Responses/LogItemResponse.cs +++ b/src/ReportPortal.Client/Abstractions/Responses/LogItemResponse.cs @@ -1,7 +1,6 @@ using ReportPortal.Client.Abstractions.Models; using ReportPortal.Client.Converters; using System; -using System.Runtime.Serialization; using System.Text.Json.Serialization; namespace ReportPortal.Client.Abstractions.Responses diff --git a/src/ReportPortal.Client/Abstractions/Responses/ResponsesList.cs b/src/ReportPortal.Client/Abstractions/Responses/ResponsesList.cs index e61fd94d..b11a6e48 100644 --- a/src/ReportPortal.Client/Abstractions/Responses/ResponsesList.cs +++ b/src/ReportPortal.Client/Abstractions/Responses/ResponsesList.cs @@ -1,12 +1,11 @@ using System.Collections.Generic; -using System.Runtime.Serialization; +using System.Text.Json.Serialization; namespace ReportPortal.Client.Abstractions.Responses { - [DataContract] public class ResponsesList { - [DataMember(Name = "responses")] - public IEnumerable Items { get; set; } + [JsonPropertyName("responses")] + public IList Items { get; set; } } } diff --git a/src/ReportPortal.Client/Abstractions/Responses/TestItemHistoryResponse.cs b/src/ReportPortal.Client/Abstractions/Responses/TestItemHistoryResponse.cs index d25599fe..56f97bdb 100644 --- a/src/ReportPortal.Client/Abstractions/Responses/TestItemHistoryResponse.cs +++ b/src/ReportPortal.Client/Abstractions/Responses/TestItemHistoryResponse.cs @@ -2,7 +2,6 @@ using ReportPortal.Client.Converters; using System; using System.Collections.Generic; -using System.Runtime.Serialization; using System.Text.Json.Serialization; namespace ReportPortal.Client.Abstractions.Responses @@ -11,7 +10,7 @@ public class TestItemHistoryContainer { public string GroupingField { get; set; } - public IEnumerable Resources { get; set; } + public IList Resources { get; set; } } public class TestItemHistoryElement @@ -31,6 +30,6 @@ public class TestItemHistoryElement [JsonConverter(typeof(JsonStringEnumConverterEx))] public Status LaunchStatus { get; set; } - public IEnumerable Resources { get; set; } + public IList Resources { get; set; } } } diff --git a/src/ReportPortal.Client/Abstractions/Responses/TestItemResponse.cs b/src/ReportPortal.Client/Abstractions/Responses/TestItemResponse.cs index 8e50a905..01e247b9 100644 --- a/src/ReportPortal.Client/Abstractions/Responses/TestItemResponse.cs +++ b/src/ReportPortal.Client/Abstractions/Responses/TestItemResponse.cs @@ -25,7 +25,7 @@ public class TestItemResponse [JsonConverter(typeof(NullableDateTimeUnixEpochConverter))] public DateTime? EndTime { get; set; } - public IEnumerable Retries { get; set; } + public IList Retries { get; set; } [JsonConverter(typeof(JsonStringEnumConverterEx))] public Status Status { get; set; } @@ -39,7 +39,7 @@ public class TestItemResponse public bool HasChildren { get; set; } - public List> Parameters { get; set; } + public IList> Parameters { get; set; } public string UniqueId { get; set; } @@ -52,7 +52,7 @@ public class TestItemResponse /// /// Test item attributes. /// - public IEnumerable Attributes { get; set; } + public IList Attributes { get; set; } } public class PathNames @@ -87,7 +87,7 @@ public class Issue public bool IgnoreAnalyzer { get; set; } - public List ExternalSystemIssues { get; set; } + public IList ExternalSystemIssues { get; set; } } public class ExternalSystemIssue diff --git a/src/ReportPortal.Client/Abstractions/Responses/UserFilterCreatedResponse.cs b/src/ReportPortal.Client/Abstractions/Responses/UserFilterCreatedResponse.cs index f23fda77..37394883 100644 --- a/src/ReportPortal.Client/Abstractions/Responses/UserFilterCreatedResponse.cs +++ b/src/ReportPortal.Client/Abstractions/Responses/UserFilterCreatedResponse.cs @@ -1,14 +1,10 @@ -using System.Runtime.Serialization; - -namespace ReportPortal.Client.Abstractions.Responses +namespace ReportPortal.Client.Abstractions.Responses { - [DataContract] public class UserFilterCreatedResponse { /// /// ID of created user filter /// - [DataMember(Name = "id")] public long Id { get; set; } } } diff --git a/src/ReportPortal.Client/Abstractions/Responses/UserFilterResponse.cs b/src/ReportPortal.Client/Abstractions/Responses/UserFilterResponse.cs index 8edd2d18..5f96e3db 100644 --- a/src/ReportPortal.Client/Abstractions/Responses/UserFilterResponse.cs +++ b/src/ReportPortal.Client/Abstractions/Responses/UserFilterResponse.cs @@ -21,7 +21,7 @@ public class UserFilterResponse /// /// List of conditions to filter data. /// - public IEnumerable Conditions { get; set; } + public IList Conditions { get; set; } /// /// Name of user filter. @@ -31,7 +31,7 @@ public class UserFilterResponse /// /// list of parameters of selection. /// - public IEnumerable Orders { get; set; } + public IList Orders { get; set; } /// /// Is filter shared. diff --git a/src/ReportPortal.Client/Converters/ClientSourceGenerationContext.cs b/src/ReportPortal.Client/Converters/ClientSourceGenerationContext.cs index 4caa0d1e..fbd683da 100644 --- a/src/ReportPortal.Client/Converters/ClientSourceGenerationContext.cs +++ b/src/ReportPortal.Client/Converters/ClientSourceGenerationContext.cs @@ -28,7 +28,7 @@ namespace ReportPortal.Client.Converters [JsonSerializable(typeof(Abstractions.Responses.TestItemResponse))] [JsonSerializable(typeof(Abstractions.Responses.Content))] [JsonSerializable(typeof(Abstractions.Responses.TestItemCreatedResponse))] - [JsonSerializable(typeof(IEnumerable))] + [JsonSerializable(typeof(IList))] [JsonSerializable(typeof(Abstractions.Responses.Content))] [JsonSerializable(typeof(Abstractions.Requests.CreateLogItemRequest))] diff --git a/src/ReportPortal.Client/Resources/ServiceTestItemResource.cs b/src/ReportPortal.Client/Resources/ServiceTestItemResource.cs index c9d77bbc..c042da1d 100644 --- a/src/ReportPortal.Client/Resources/ServiceTestItemResource.cs +++ b/src/ReportPortal.Client/Resources/ServiceTestItemResource.cs @@ -70,9 +70,9 @@ public async Task DeleteAsync(long id, CancellationToken cancel return await DeleteAsJsonAsync($"v1/{ProjectName}/item/{id}", cancellationToken).ConfigureAwait(false); } - public async Task> AssignIssuesAsync(AssignTestItemIssuesRequest request, CancellationToken cancellationToken) + public async Task> AssignIssuesAsync(AssignTestItemIssuesRequest request, CancellationToken cancellationToken) { - return await PutAsJsonAsync, AssignTestItemIssuesRequest>( + return await PutAsJsonAsync, AssignTestItemIssuesRequest>( $"v1/{ProjectName}/item", request, cancellationToken).ConfigureAwait(false); } diff --git a/test/ReportPortal.Client.IntegrationTests/LaunchFixtureBase.cs b/test/ReportPortal.Client.IntegrationTests/LaunchFixtureBase.cs index e27af70b..d956357f 100644 --- a/test/ReportPortal.Client.IntegrationTests/LaunchFixtureBase.cs +++ b/test/ReportPortal.Client.IntegrationTests/LaunchFixtureBase.cs @@ -22,8 +22,11 @@ public LaunchFixtureBase() public void Dispose() { - Task.Run(async () => await Service.Launch.StopAsync(LaunchId, new FinishLaunchRequest { EndTime = DateTime.UtcNow })).GetAwaiter().GetResult(); - Task.Run(async () => await Service.Launch.DeleteAsync(LaunchId)).GetAwaiter().GetResult(); + Task.Run(async () => + { + await Service.Launch.StopAsync(LaunchId, new FinishLaunchRequest { EndTime = DateTime.UtcNow }); + await Service.Launch.DeleteAsync(LaunchId); + }).GetAwaiter().GetResult(); } } } diff --git a/test/ReportPortal.Client.IntegrationTests/LaunchesFixtureBase.cs b/test/ReportPortal.Client.IntegrationTests/LaunchesFixtureBase.cs index a6e9cc3e..b8d63e3f 100644 --- a/test/ReportPortal.Client.IntegrationTests/LaunchesFixtureBase.cs +++ b/test/ReportPortal.Client.IntegrationTests/LaunchesFixtureBase.cs @@ -35,9 +35,12 @@ public void Dispose() { foreach (var createdLaunch in CreatedLaunches) { - var gotCreatedLaunch = Task.Run(async () => await Service.Launch.GetAsync(createdLaunch.Uuid)).GetAwaiter().GetResult(); + Task.Run(async () => + { + var launch = await Service.Launch.GetAsync(createdLaunch.Uuid); + await Service.Launch.DeleteAsync(launch.Id); - Task.Run(async () => await Service.Launch.DeleteAsync(gotCreatedLaunch.Id)).GetAwaiter().GetResult(); + }).GetAwaiter().GetResult(); } } } diff --git a/test/ReportPortal.Client.IntegrationTests/LogItem/AsyncLogItemFixture.cs b/test/ReportPortal.Client.IntegrationTests/LogItem/AsyncLogItemFixture.cs index 4863d2d7..e19d1b3c 100644 --- a/test/ReportPortal.Client.IntegrationTests/LogItem/AsyncLogItemFixture.cs +++ b/test/ReportPortal.Client.IntegrationTests/LogItem/AsyncLogItemFixture.cs @@ -1,12 +1,9 @@ using FluentAssertions; -using ReportPortal.Client.Abstractions.Filtering; using ReportPortal.Client.Abstractions.Models; using ReportPortal.Client.Abstractions.Requests; using System; using System.Collections.Generic; -using System.Linq; using System.Text; -using System.Threading; using System.Threading.Tasks; using Xunit; @@ -14,7 +11,7 @@ namespace ReportPortal.Client.IntegrationTests.LogItem { public class AsyncLogItemFixture : IClassFixture, IClassFixture { - private LogItemFixtureBase _fixture; + private readonly LogItemFixtureBase _fixture; Service Service { get; } diff --git a/test/ReportPortal.Client.IntegrationTests/LogItem/LogItemFixture.cs b/test/ReportPortal.Client.IntegrationTests/LogItem/LogItemFixture.cs index 1e31605f..4a7eb3d2 100644 --- a/test/ReportPortal.Client.IntegrationTests/LogItem/LogItemFixture.cs +++ b/test/ReportPortal.Client.IntegrationTests/LogItem/LogItemFixture.cs @@ -14,7 +14,7 @@ namespace ReportPortal.Client.IntegrationTests.LogItem { public class LogItemFixture : IClassFixture, IClassFixture { - private LogItemFixtureBase _fixture; + private readonly LogItemFixtureBase _fixture; Service Service { get; } diff --git a/test/ReportPortal.Client.IntegrationTests/LogItemFixtureBase.cs b/test/ReportPortal.Client.IntegrationTests/LogItemFixtureBase.cs index 3a3d7035..0003f666 100644 --- a/test/ReportPortal.Client.IntegrationTests/LogItemFixtureBase.cs +++ b/test/ReportPortal.Client.IntegrationTests/LogItemFixtureBase.cs @@ -5,7 +5,7 @@ namespace ReportPortal.Client.IntegrationTests { - public class LogItemFixtureBase : BaseFixture + public class LogItemFixtureBase : BaseFixture, IDisposable { public string LaunchUuid { get; set; } public long LaunchId { get; set; } @@ -41,7 +41,8 @@ public void Dispose() { Task.Run(async () => { - await Service.Launch.FinishAsync(LaunchUuid, new FinishLaunchRequest { EndTime = DateTime.UtcNow }); + await Service.TestItem.FinishAsync(TestUuid, new FinishTestItemRequest()); + await Service.Launch.FinishAsync(LaunchUuid, new FinishLaunchRequest()); await Service.Launch.DeleteAsync(LaunchId); }).GetAwaiter().GetResult(); } diff --git a/test/ReportPortal.Client.IntegrationTests/Project/Project.cs b/test/ReportPortal.Client.IntegrationTests/Project/Project.cs index f9d51ca2..c772780a 100644 --- a/test/ReportPortal.Client.IntegrationTests/Project/Project.cs +++ b/test/ReportPortal.Client.IntegrationTests/Project/Project.cs @@ -46,7 +46,7 @@ public async Task GetProjectInfo() VerifyDefectTypesModel(projectInfo.Configuration.DefectSubTypes.NoDefectTypes); } - private void VerifyDefectTypesModel(IList defectTypes) + private void VerifyDefectTypesModel(IEnumerable defectTypes) { defectTypes.Should().NotBeEmpty(); foreach (var defectType in defectTypes)