Skip to content

Commit

Permalink
Use IList for responses (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
nvborisenko authored Apr 27, 2023
1 parent bc3a928 commit e32d461
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public interface ITestItemResource
/// <param name="request">Information about test items and their issues.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>A list of assigned issues.</returns>
Task<IEnumerable<Issue>> AssignIssuesAsync(AssignTestItemIssuesRequest request, CancellationToken cancellationToken = default);
Task<IList<Issue>> AssignIssuesAsync(AssignTestItemIssuesRequest request, CancellationToken cancellationToken = default);

/// <summary>
/// Deletes specified test item.
Expand Down
2 changes: 1 addition & 1 deletion src/ReportPortal.Client/Abstractions/Responses/Content.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace ReportPortal.Client.Abstractions.Responses
public class Content<T>
{
[JsonPropertyName("content")]
public IEnumerable<T> Items { get; set; }
public IList<T> Items { get; set; }

public Page Page { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class LaunchResponse

public bool HasRetries { get; set; }

public IEnumerable<ItemAttribute> Attributes { get; set; }
public IList<ItemAttribute> Attributes { get; set; }

public Statistic Statistics { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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<T>
{
[DataMember(Name = "responses")]
public IEnumerable<T> Items { get; set; }
[JsonPropertyName("responses")]
public IList<T> Items { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -11,7 +10,7 @@ public class TestItemHistoryContainer
{
public string GroupingField { get; set; }

public IEnumerable<TestItemHistoryElement> Resources { get; set; }
public IList<TestItemHistoryElement> Resources { get; set; }
}

public class TestItemHistoryElement
Expand All @@ -31,6 +30,6 @@ public class TestItemHistoryElement
[JsonConverter(typeof(JsonStringEnumConverterEx<Status>))]
public Status LaunchStatus { get; set; }

public IEnumerable<TestItemResponse> Resources { get; set; }
public IList<TestItemResponse> Resources { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class TestItemResponse
[JsonConverter(typeof(NullableDateTimeUnixEpochConverter))]
public DateTime? EndTime { get; set; }

public IEnumerable<TestItemResponse> Retries { get; set; }
public IList<TestItemResponse> Retries { get; set; }

[JsonConverter(typeof(JsonStringEnumConverterEx<Status>))]
public Status Status { get; set; }
Expand All @@ -39,7 +39,7 @@ public class TestItemResponse

public bool HasChildren { get; set; }

public List<KeyValuePair<string, string>> Parameters { get; set; }
public IList<KeyValuePair<string, string>> Parameters { get; set; }

public string UniqueId { get; set; }

Expand All @@ -52,7 +52,7 @@ public class TestItemResponse
/// <summary>
/// Test item attributes.
/// </summary>
public IEnumerable<ItemAttribute> Attributes { get; set; }
public IList<ItemAttribute> Attributes { get; set; }
}

public class PathNames
Expand Down Expand Up @@ -87,7 +87,7 @@ public class Issue

public bool IgnoreAnalyzer { get; set; }

public List<ExternalSystemIssue> ExternalSystemIssues { get; set; }
public IList<ExternalSystemIssue> ExternalSystemIssues { get; set; }
}

public class ExternalSystemIssue
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
using System.Runtime.Serialization;

namespace ReportPortal.Client.Abstractions.Responses
namespace ReportPortal.Client.Abstractions.Responses
{
[DataContract]
public class UserFilterCreatedResponse
{
/// <summary>
/// ID of created user filter
/// </summary>
[DataMember(Name = "id")]
public long Id { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class UserFilterResponse
/// <summary>
/// List of conditions to filter data.
/// </summary>
public IEnumerable<Condition> Conditions { get; set; }
public IList<Condition> Conditions { get; set; }

/// <summary>
/// Name of user filter.
Expand All @@ -31,7 +31,7 @@ public class UserFilterResponse
/// <summary>
/// list of parameters of selection.
/// </summary>
public IEnumerable<FilterOrder> Orders { get; set; }
public IList<FilterOrder> Orders { get; set; }

/// <summary>
/// Is filter shared.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace ReportPortal.Client.Converters
[JsonSerializable(typeof(Abstractions.Responses.TestItemResponse))]
[JsonSerializable(typeof(Abstractions.Responses.Content<Abstractions.Responses.TestItemResponse>))]
[JsonSerializable(typeof(Abstractions.Responses.TestItemCreatedResponse))]
[JsonSerializable(typeof(IEnumerable<Abstractions.Responses.Issue>))]
[JsonSerializable(typeof(IList<Abstractions.Responses.Issue>))]
[JsonSerializable(typeof(Abstractions.Responses.Content<Abstractions.Responses.TestItemHistoryContainer>))]

[JsonSerializable(typeof(Abstractions.Requests.CreateLogItemRequest))]
Expand Down
4 changes: 2 additions & 2 deletions src/ReportPortal.Client/Resources/ServiceTestItemResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ public async Task<MessageResponse> DeleteAsync(long id, CancellationToken cancel
return await DeleteAsJsonAsync<MessageResponse>($"v1/{ProjectName}/item/{id}", cancellationToken).ConfigureAwait(false);
}

public async Task<IEnumerable<Issue>> AssignIssuesAsync(AssignTestItemIssuesRequest request, CancellationToken cancellationToken)
public async Task<IList<Issue>> AssignIssuesAsync(AssignTestItemIssuesRequest request, CancellationToken cancellationToken)
{
return await PutAsJsonAsync<IEnumerable<Issue>, AssignTestItemIssuesRequest>(
return await PutAsJsonAsync<IList<Issue>, AssignTestItemIssuesRequest>(
$"v1/{ProjectName}/item", request, cancellationToken).ConfigureAwait(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
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;

namespace ReportPortal.Client.IntegrationTests.LogItem
{
public class AsyncLogItemFixture : IClassFixture<LogItemFixtureBase>, IClassFixture<BaseFixture>
{
private LogItemFixtureBase _fixture;
private readonly LogItemFixtureBase _fixture;

Service Service { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace ReportPortal.Client.IntegrationTests.LogItem
{
public class LogItemFixture : IClassFixture<LogItemFixtureBase>, IClassFixture<BaseFixture>
{
private LogItemFixtureBase _fixture;
private readonly LogItemFixtureBase _fixture;

Service Service { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public async Task GetProjectInfo()
VerifyDefectTypesModel(projectInfo.Configuration.DefectSubTypes.NoDefectTypes);
}

private void VerifyDefectTypesModel(IList<ProjectDefectSubType> defectTypes)
private void VerifyDefectTypesModel(IEnumerable<ProjectDefectSubType> defectTypes)
{
defectTypes.Should().NotBeEmpty();
foreach (var defectType in defectTypes)
Expand Down

0 comments on commit e32d461

Please sign in to comment.