-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from testit-tms/feature/add_export_iterations_…
…from_zephyr_scale_server Added export of iterations for ZephyrScaleServerExporter.
- Loading branch information
Showing
11 changed files
with
334 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Models; | ||
|
||
namespace ZephyrScaleServerExporter.Models; | ||
|
||
public class StepsData | ||
{ | ||
public List<Step> Steps { get; set; } | ||
public List<Iteration> Iterations { get; set; } | ||
} |
7 changes: 7 additions & 0 deletions
7
Migrators/ZephyrScaleServerExporter/Models/ZephyrParameterType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace ZephyrScaleServerExporter.Models; | ||
|
||
public class ZephyrParameterType | ||
{ | ||
public const string TEST_DATA = "TEST_DATA"; | ||
public const string PARAMETER = "PARAMETER"; | ||
} |
63 changes: 63 additions & 0 deletions
63
Migrators/ZephyrScaleServerExporter/Models/ZephyrParametersData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace ZephyrScaleServerExporter.Models; | ||
|
||
public class ZephyrParametersData | ||
{ | ||
[JsonPropertyName("paramType")] | ||
public string Type { get; set; } | ||
|
||
[JsonPropertyName("testData")] | ||
public List<Dictionary<string, object>> TestData { get; set; } | ||
|
||
[JsonPropertyName("name")] | ||
public string Name { get; set; } | ||
|
||
[JsonPropertyName("id")] | ||
public int Id { get; set; } | ||
|
||
[JsonPropertyName("parameters")] | ||
public List<ZephyrParameter> Parameters { get; set; } | ||
} | ||
|
||
public class ParametersData | ||
{ | ||
public string Type { get; set; } | ||
public List<Dictionary<string, ZephyrDataParameter>> TestData { get; set; } | ||
public List<ZephyrParameter> Parameters { get; set; } | ||
} | ||
|
||
public class ZephyrDataParameter | ||
{ | ||
[JsonPropertyName("index")] | ||
public int Index { get; set; } | ||
|
||
[JsonPropertyName("value")] | ||
public string Value { get; set; } | ||
|
||
[JsonPropertyName("type")] | ||
public string Type { get; set; } | ||
|
||
[JsonPropertyName("dataSetItemId")] | ||
public int DataSetItemId { get; set; } | ||
} | ||
|
||
public class DataParameter | ||
{ | ||
List<ZephyrParameter> Parameters; | ||
} | ||
|
||
public class ZephyrParameter | ||
{ | ||
[JsonPropertyName("defaultValue")] | ||
public string Value { get; set; } | ||
|
||
[JsonPropertyName("name")] | ||
public string Name { get; set; } | ||
|
||
[JsonPropertyName("index")] | ||
public int Index { get; set; } | ||
|
||
[JsonPropertyName("id")] | ||
public int Id { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
Migrators/ZephyrScaleServerExporter/Services/IParameterService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Models; | ||
|
||
namespace ZephyrScaleServerExporter.Services; | ||
|
||
public interface IParameterService | ||
{ | ||
Task<List<Iteration>> ConvertParameters(string testCaseKey); | ||
List<Iteration> MergeIterations(List<Iteration> mainIterations, List<Iteration> subIterations); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
Migrators/ZephyrScaleServerExporter/Services/ParameterService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
using ZephyrScaleServerExporter.Client; | ||
using ZephyrScaleServerExporter.Models; | ||
using Microsoft.Extensions.Logging; | ||
using Models; | ||
using Microsoft.VisualBasic; | ||
|
||
namespace ZephyrScaleServerExporter.Services; | ||
|
||
public class ParameterService : IParameterService | ||
{ | ||
private readonly ILogger<ParameterService> _logger; | ||
private readonly IClient _client; | ||
|
||
public ParameterService(ILogger<ParameterService> logger, IClient client) | ||
{ | ||
_logger = logger; | ||
_client = client; | ||
} | ||
|
||
public async Task<List<Iteration>> ConvertParameters(string testCaseKey) | ||
{ | ||
_logger.LogInformation("Converting parameters"); | ||
|
||
var parametersData = await _client.GetParametersByTestCaseKey(testCaseKey); | ||
|
||
switch (parametersData.Type) | ||
{ | ||
case ZephyrParameterType.TEST_DATA: | ||
return ConvertParametersWithTestDataType(parametersData.TestData); | ||
case ZephyrParameterType.PARAMETER: | ||
return ConvertParametersWithParameterType(parametersData.Parameters); | ||
default: | ||
return new List<Iteration>(); | ||
} | ||
} | ||
|
||
public List<Iteration> MergeIterations(List<Iteration> mainIterations, List<Iteration> subIterations) | ||
{ | ||
_logger.LogInformation("Merging parameters:\nMain: {@MainParameters}\n Sub: {@SubParameters}", | ||
mainIterations, subIterations); | ||
|
||
foreach (var mainIteration in mainIterations) | ||
{ | ||
foreach (var subIteration in subIterations) | ||
{ | ||
var nonconflictingIterationParameters = subIteration.Parameters.Where( | ||
subp => mainIteration.Parameters.FirstOrDefault( | ||
mainp => subp.Name == mainp.Name) == null); | ||
|
||
mainIteration.Parameters.AddRange(nonconflictingIterationParameters); | ||
} | ||
} | ||
|
||
_logger.LogInformation("Merged parameters: {@Parameters}", mainIterations); | ||
|
||
return mainIterations; | ||
} | ||
|
||
private List<Iteration> ConvertParametersWithTestDataType(List<Dictionary<string, ZephyrDataParameter>> ZephyrTestData) | ||
{ | ||
var iterations = new List<Iteration>(); | ||
|
||
foreach (var zephyrDataParameters in ZephyrTestData) | ||
{ | ||
var iteration = new Iteration | ||
{ | ||
Parameters = new List<Parameter>() | ||
}; | ||
|
||
foreach (var name in zephyrDataParameters.Keys) | ||
{ | ||
iteration.Parameters.Add( | ||
new Parameter | ||
{ | ||
Name = name, | ||
Value = zephyrDataParameters[name].Value | ||
}); | ||
} | ||
|
||
iterations.Add(iteration); | ||
} | ||
|
||
_logger.LogInformation("Converted parameters: {@Parameters}", iterations); | ||
|
||
return iterations; | ||
} | ||
|
||
private List<Iteration> ConvertParametersWithParameterType(List<ZephyrParameter> zephyrParameters) | ||
{ | ||
var parameters = new List<Parameter>(); | ||
|
||
|
||
foreach (var zephyrParameter in zephyrParameters) | ||
{ | ||
parameters.Add( | ||
new Parameter | ||
{ | ||
Name = zephyrParameter.Name, | ||
Value = zephyrParameter.Value | ||
}); | ||
} | ||
|
||
_logger.LogInformation("Converted parameters: {@Parameters}", parameters); | ||
|
||
return new List<Iteration> | ||
{ | ||
new Iteration | ||
{ | ||
Parameters = parameters | ||
} | ||
}; | ||
} | ||
} |
Oops, something went wrong.