Skip to content

Commit

Permalink
Merge pull request #59 from reportportal/develop
Browse files Browse the repository at this point in the history
Release preparation
  • Loading branch information
nvborisenko authored Aug 5, 2020
2 parents 45f4825 + 6157e12 commit dfddd14
Show file tree
Hide file tree
Showing 26 changed files with 282 additions and 98 deletions.
Binary file modified Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 11 additions & 3 deletions src/ReportPortal.Client/Abstractions/Models/ItemAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
using System.Runtime.Serialization;
using ReportPortal.Client.Converters;
using System.Runtime.Serialization;

namespace ReportPortal.Client.Abstractions.Models
{
[DataContract]
public class ItemAttribute
{
public const int MAX_KEY_SIZE = 128;
public const int MAX_VALUE_SIZE = 128;

private string _key;

[DataMember(Name = "key")]
public string Key { get; set; }
public string Key { get { return _key; } set { _key = StringTrimmer.Trim(value, MAX_KEY_SIZE); } }

private string _value;

[DataMember(Name = "value")]
public string Value { get; set; }
public string Value { get { return _value; } set { _value = StringTrimmer.Trim(value, MAX_VALUE_SIZE); } }

[DataMember(Name = "system")]
public bool IsSystem { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions src/ReportPortal.Client/Abstractions/Models/Status.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public enum Status
Interrupted,
[DataMember(Name = "CANCELLED")]
Cancelled,
[DataMember(Name = "STOPPED")]
Stopped,
[DataMember(Name = "INFO")]
Info,
[DataMember(Name = "WARN")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ReportPortal.Client.Abstractions.Models;
using ReportPortal.Client.Abstractions.Responses;
using ReportPortal.Client.Converters;
using System;
using System.Runtime.Serialization;
Expand Down Expand Up @@ -28,7 +27,7 @@ public class CreateLogItemRequest
/// Date time of log item.
/// </summary>
[DataMember(Name = "time")]
public string TimeString { get; set; }
public string TimeString { get; set; } = DateTimeConverter.ConvertFrom(DateTime.UtcNow);

public DateTime Time
{
Expand All @@ -48,7 +47,7 @@ public DateTime Time
[DataMember(Name = "level")]
public string LevelString { get { return EnumConverter.ConvertFrom(Level); } set { Level = EnumConverter.ConvertTo<LogLevel>(value); } }

public LogLevel Level = LogLevel.Info;
public LogLevel Level { get; set; } = LogLevel.Info;

/// <summary>
/// Message of log item.
Expand All @@ -59,7 +58,32 @@ public DateTime Time
/// <summary>
/// Specify an attachment of log item.
/// </summary>
[DataMember(Name = "file")]
public Attach Attach { get; set; }
[DataMember(Name = "file", EmitDefaultValue = false)]
public LogItemAttach Attach { get; set; }
}

[DataContract]
public class LogItemAttach
{
// empty ctor for json serialization
public LogItemAttach()
{

}

public LogItemAttach(string mimeType, byte[] data)
{
MimeType = mimeType;
Data = data;
}

[DataMember(Name = "name")]
public string Name { get; set; } = Guid.NewGuid().ToString();

[IgnoreDataMember]
public byte[] Data { get; set; }

[IgnoreDataMember]
public string MimeType { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class FinishLaunchRequest
/// Date time when launch execution is finished.
/// </summary>
[DataMember(Name = "endTime")]
public string EndTimeString { get; set; }
public string EndTimeString { get; set; } = DateTimeConverter.ConvertFrom(DateTime.UtcNow);

public DateTime EndTime
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public class FinishTestItemRequest
/// <summary>
/// Date time when test item is finished.
/// </summary>
[DataMember(Name = "end_time")]
public string EndTimeString { get; set; }
[DataMember(Name = "endTime")]
public string EndTimeString { get; set; } = DateTimeConverter.ConvertFrom(DateTime.UtcNow);

public DateTime EndTime
{
Expand All @@ -43,7 +43,7 @@ public DateTime EndTime
[DataMember(Name = "status")]
public string StatusString { get { return EnumConverter.ConvertFrom(Status); } set { Status = EnumConverter.ConvertTo<Status>(value); } }

public Status Status = Status.Passed;
public Status Status { get; set; } = Status.Passed;

/// <summary>
/// A issue of test item if execution was proceeded with error.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ public class StartLaunchRequest
[DataMember(Name = "mode")]
public string ModeString { get { return EnumConverter.ConvertFrom(Mode); } set { Mode = EnumConverter.ConvertTo<LaunchMode>(value); } }

public LaunchMode Mode = LaunchMode.Default;
public LaunchMode Mode { get; set; } = LaunchMode.Default;

/// <summary>
/// Date time when the launch is executed.
/// </summary>
[DataMember(Name = "startTime")]
public string StartTimeString { get; set; }
public string StartTimeString { get; set; } = DateTimeConverter.ConvertFrom(DateTime.UtcNow);

public DateTime StartTime
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class StartTestItemRequest
/// A short name of test item.
/// </summary>
[DataMember(Name = "name")]
public string Name { get { return _name; } set { _name = StringTrimmer.Trim(value, 256); } }
public string Name { get { return _name; } set { _name = StringTrimmer.Trim(value, 1024); } }

/// <summary>
/// A long description of test item.
Expand All @@ -36,7 +36,7 @@ public class StartTestItemRequest
/// Date time when new test item is created.
/// </summary>
[DataMember(Name = "startTime")]
public string StartTimeString { get; set; }
public string StartTimeString { get; set; } = DateTimeConverter.ConvertFrom(DateTime.UtcNow);

public DateTime StartTime
{
Expand All @@ -56,7 +56,7 @@ public DateTime StartTime
[DataMember(Name = "type")]
public string TypeString { get { return EnumConverter.ConvertFrom(Type); } set { Type = EnumConverter.ConvertTo<TestItemType>(value); } }

public TestItemType Type = TestItemType.Test;
public TestItemType Type { get; set; } = TestItemType.Test;

/// <summary>
/// A list of tags.
Expand Down Expand Up @@ -89,6 +89,12 @@ public DateTime StartTime
[DataMember(Name = "testCaseId")]
public string TestCaseId { get; set; }

/// <summary>
/// Code reference for test. Example: namespace + classname + methodname
/// </summary>
[DataMember(Name = "codeRef")]
public string CodeReference { get; set; }

/// <summary>
/// Define if test item has stats. If false - considered as nested step.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using ReportPortal.Client.Abstractions.Filtering;
using ReportPortal.Client.Abstractions.Requests;
using ReportPortal.Client.Abstractions.Responses;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace ReportPortal.Client.Abstractions.Resources
Expand All @@ -10,14 +11,24 @@ namespace ReportPortal.Client.Abstractions.Resources
/// </summary>
public interface ILogItemResource
{

/// <summary>
/// Creates a new log item.
/// </summary>
/// <param name="request">Information about representation of log item.</param>
/// <returns>Representation of just created log item.</returns>
//Task<LogItemCreatedResponse> CreateAsync(CreateLogItemRequest request);

Task<LogItemCreatedResponse> CreateAsync(CreateLogItemRequest request);

/// <summary>
/// Creates a new log item.
/// </summary>
/// <param name="requests">Information about representation of log item.</param>
/// <returns>Representation of just created log item.</returns>
//Task<LogItemCreatedResponse> CreateAsync(CreateLogItemRequest request);

Task<LogItemsCreatedResponse> CreateAsync(params CreateLogItemRequest[] requests);

/// <summary>
/// Deletes specified log item.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ public interface ITestItemResource
/// <summary>
/// Finishes specified test item.
/// </summary>
/// <param name="id">ID of specified test item.</param>
/// <param name="uuid">ID of specified test item.</param>
/// <param name="request">Information about representation of test item to finish.</param>
/// <returns>A message from service.</returns>
Task<MessageResponse> FinishAsync(string id, FinishTestItemRequest request);
Task<MessageResponse> FinishAsync(string uuid, FinishTestItemRequest request);

/// <summary>
/// Returns specified test item by ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace ReportPortal.Client.Abstractions.Responses
public class LaunchFinishedResponse
{
[DataMember(Name = "id")]
public string Id { get; set; }
public string Uuid { get; set; }

[DataMember(Name = "link")]
public string Link { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
using System.Runtime.Serialization;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace ReportPortal.Client.Abstractions.Responses
{
[DataContract]
public class LogItemsCreatedResponse
{
[DataMember(Name = "responses")]
public IList<LogItemCreatedResponse> LogItems { get; set; }
}

[DataContract]
public class LogItemCreatedResponse
{
Expand Down
25 changes: 0 additions & 25 deletions src/ReportPortal.Client/Abstractions/Responses/LogItemResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,29 +59,4 @@ public class BinaryContent
[DataMember(Name = "thumbnailId")]
public string ThumbnailId { get; set; }
}

[DataContract]
public class Attach
{
public Attach()
{

}

public Attach(string name, string mimeType, byte[] data)
{
Name = name;
MimeType = mimeType;
Data = data;
}

[DataMember(Name = "name")]
public string Name { get; set; }

[IgnoreDataMember]
public byte[] Data { get; set; }

[IgnoreDataMember]
public string MimeType { get; set; }
}
}
12 changes: 12 additions & 0 deletions src/ReportPortal.Client/Abstractions/Responses/ResponsesList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace ReportPortal.Client.Abstractions.Responses
{
[DataContract]
public class ResponsesList<T>
{
[DataMember(Name = "responses")]
public IEnumerable<T> Items { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,28 @@ namespace ReportPortal.Client.Abstractions.Responses
[DataContract]
public class TestItemHistoryContainer
{
[DataMember(Name = "testCaseHash")]
public string TestCaseHash { get; set; }
[DataMember(Name = "groupingField")]
public string GroupingField { get; set; }

[DataMember(Name = "resources")]
public IEnumerable<TestItemHistoryResponse> Resources { get; set; }
public IEnumerable<TestItemHistoryElement> Resources { get; set; }
}

[DataContract]
public class TestItemHistoryResponse
public class TestItemHistoryElement
{
[DataMember(Name = "name")]
public string Name { get; set; }

[DataMember(Name = "status")]
public string StatusString { get; set; }

public Status Status
{
get => EnumConverter.ConvertTo<Status>(StatusString);
set => StatusString = EnumConverter.ConvertFrom(value);
}

[DataMember(Name = "launchNumber")]
public long LaunchNumber { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ public TestItemType Type
[DataMember(Name = "uniqueId")]
public string UniqueId { get; set; }

/// <summary>
/// Code reference for test. Example: namespace + classname + methodname
/// </summary>
[DataMember(Name = "codeRef")]
public string CodeReference { get; set; }

/// <summary>
/// Test item attributes.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions src/ReportPortal.Client/Converters/StringTrimmer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ public class StringTrimmer
{
public static string Trim(string value, int maxSize)
{
if (value is string && (value).Length > maxSize)
if (value != null && value.Length > maxSize)
{
value = (value).Substring(0, maxSize);
value = value.Substring(0, maxSize);
}

return value;
Expand Down
5 changes: 5 additions & 0 deletions src/ReportPortal.Client/Resources/ServiceBaseResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ private async Task<TResponse> SendAsJsonAsync<TResponse, TRequest>(HttpMethod ht
httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
}

return await SendHttpRequestAsync<TResponse>(httpMethod, uri, httpContent).ConfigureAwait(false);
}

protected async Task<TResponse> SendHttpRequestAsync<TResponse>(HttpMethod httpMethod, string uri, HttpContent httpContent)
{
using (var httpRequest = new HttpRequestMessage(httpMethod, uri))
{
using (httpContent)
Expand Down
Loading

0 comments on commit dfddd14

Please sign in to comment.