-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: replaced ICommands with MediatR.NET
moved command used classes in Shared namespace
- Loading branch information
1 parent
a018859
commit 652d8ea
Showing
43 changed files
with
210 additions
and
215 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...test/ConsumerApi.Tests.Performance.SnapshotCreator.Tests/Base/SnapshotCreatorTestsBase.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
2 changes: 1 addition & 1 deletion
2
...ions/ConsumerApi/test/ConsumerApi.Tests.Performance.SnapshotCreator.Tests/GlobalUsings.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 |
---|---|---|
@@ -1 +1 @@ | ||
global using static Backbone.ConsumerApi.Tests.Performance.SnapshotCreator.V2.Constants.Resources; | ||
global using static Backbone.ConsumerApi.Tests.Performance.SnapshotCreator.V2.Features.Shared.Constants.Resources; |
2 changes: 1 addition & 1 deletion
2
...Performance.SnapshotCreator.Tests/Readers/PerformanceTestConfigurationExcelReaderTests.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
2 changes: 1 addition & 1 deletion
2
....Performance.SnapshotCreator.Tests/Readers/PerformanceTestConfigurationJsonReaderTests.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
4 changes: 2 additions & 2 deletions
4
...v2/Features/Create/Mediator/AddDevices.cs → ...-creator-v2/Features/Create/AddDevices.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
4 changes: 2 additions & 2 deletions
4
...tures/Create/Mediator/CreateChallenges.cs → ...or-v2/Features/Create/CreateChallenges.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
4 changes: 2 additions & 2 deletions
4
...tures/Create/Mediator/CreateIdentities.cs → ...or-v2/Features/Create/CreateIdentities.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
4 changes: 2 additions & 2 deletions
4
...e/Mediator/CreateRelationshipTemplates.cs → ...res/Create/CreateRelationshipTemplates.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
6 changes: 3 additions & 3 deletions
6
...es/Create/Mediator/CreateRelationships.cs → ...v2/Features/Create/CreateRelationships.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
63 changes: 63 additions & 0 deletions
63
...ConsumerApi.Tests.Performance/tools/snapshot-creator-v2/Features/Create/CreateSnapshot.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; | ||
using Backbone.ConsumerApi.Sdk.Authentication; | ||
using Backbone.ConsumerApi.Tests.Performance.SnapshotCreator.V2.Features.Shared.Interfaces; | ||
using Backbone.ConsumerApi.Tests.Performance.SnapshotCreator.V2.Features.Shared.Models; | ||
using MediatR; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Backbone.ConsumerApi.Tests.Performance.SnapshotCreator.V2.Features.Create; | ||
|
||
public record CreateSnapshot | ||
{ | ||
public record Command( | ||
string BaseAddress, | ||
string ClientId, | ||
string ClientSecret, | ||
string JsonFilePath) : IRequest<StatusMessage>; | ||
|
||
public record CommandHandler( | ||
ILogger<CommandHandler> Logger, | ||
IPerformanceTestConfigurationJsonReader PerformanceTestConfigurationJsonReader, | ||
IMediator Mediator) | ||
: IRequestHandler<Command, StatusMessage> | ||
{ | ||
public async Task<StatusMessage> Handle(Command request, CancellationToken cancellationToken) | ||
{ | ||
try | ||
{ | ||
Logger.LogInformation("Creating pool configuration with relationships and messages ..."); | ||
|
||
var poolConfig = await PerformanceTestConfigurationJsonReader.Read(request.JsonFilePath); | ||
var clientCredentials = new ClientCredentials(request.ClientId, request.ClientSecret); | ||
|
||
var identities = await Mediator.Send(new CreateIdentities.Command(poolConfig.IdentityPoolConfigurations, request.BaseAddress, clientCredentials), cancellationToken); | ||
Logger.LogInformation("Identities created"); | ||
|
||
identities = await Mediator.Send(new AddDevices.Command(identities, request.BaseAddress, clientCredentials), cancellationToken); | ||
Logger.LogInformation("Devices added"); | ||
|
||
identities = await Mediator.Send(new CreateRelationshipTemplates.Command(identities, request.BaseAddress, clientCredentials), cancellationToken); | ||
Logger.LogInformation("Relationship templates created"); | ||
|
||
identities = await Mediator.Send(new CreateRelationships.Command(poolConfig.RelationshipAndMessages, identities, request.BaseAddress, clientCredentials), cancellationToken); | ||
Logger.LogInformation("Relationships created"); | ||
|
||
identities = await Mediator.Send(new CreateChallenges.Command(identities, request.BaseAddress, clientCredentials), cancellationToken); | ||
|
||
// Create Messages | ||
|
||
// Create DatawalletModifications | ||
|
||
|
||
Logger.LogInformation("Pool configuration with relationships and messages created successfully."); | ||
} | ||
catch (Exception e) | ||
{ | ||
return new StatusMessage(false, e.Message); | ||
} | ||
|
||
|
||
return new StatusMessage(true, "Pool configuration with relationships and messages created successfully."); | ||
} | ||
} | ||
} |
58 changes: 0 additions & 58 deletions
58
...ance/tools/snapshot-creator-v2/Features/Create/PoolConfigurationSnapshotCreatorCommand.cs
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
.../tools/snapshot-creator-v2/Features/Create/PoolConfigurationSnapshotCreatorCommandArgs.cs
This file was deleted.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
...nsumerApi.Tests.Performance/tools/snapshot-creator-v2/Features/Generate/GenerateConfig.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,51 @@ | ||
using Backbone.ConsumerApi.Tests.Performance.SnapshotCreator.V2.Features.Shared.Interfaces; | ||
using Backbone.ConsumerApi.Tests.Performance.SnapshotCreator.V2.Features.Shared.Models; | ||
using MediatR; | ||
|
||
namespace Backbone.ConsumerApi.Tests.Performance.SnapshotCreator.V2.Features.Generate; | ||
|
||
public record GenerateConfig | ||
{ | ||
public record Command(string ExcelFilePath, string WorkSheetName) : IRequest<StatusMessage>; | ||
|
||
public class CommandHandler( | ||
IPerformanceTestConfigurationExcelReader performanceTestConfigurationExcelReader, | ||
IRelationshipAndMessagesGenerator relationshipAndMessagesGenerator, | ||
IPoolConfigurationJsonWriter poolConfigurationJsonWriter) | ||
: IRequestHandler<Command, StatusMessage> | ||
{ | ||
public async Task<StatusMessage> Handle(Command request, CancellationToken cancellationToken) | ||
{ | ||
StatusMessage result; | ||
try | ||
{ | ||
var poolConfigFromExcel = await performanceTestConfigurationExcelReader.Read(request.ExcelFilePath, request.WorkSheetName); | ||
|
||
var relationshipAndMessages = relationshipAndMessagesGenerator.Generate(poolConfigFromExcel); | ||
|
||
poolConfigFromExcel.RelationshipAndMessages.Clear(); | ||
poolConfigFromExcel.RelationshipAndMessages.AddRange(relationshipAndMessages); | ||
|
||
var path = Path.GetDirectoryName(request.ExcelFilePath); | ||
|
||
var snapshotFolder = Path.Combine(path!, $"{DateTime.Now:yyyyMMddHHmmss}-snapshot-{request.WorkSheetName}"); | ||
|
||
if (Directory.Exists(snapshotFolder)) | ||
{ | ||
Directory.Delete(snapshotFolder, true); | ||
} | ||
|
||
Directory.CreateDirectory(snapshotFolder); | ||
|
||
var poolConfigJsonFilePath = Path.Combine(snapshotFolder!, $"{POOL_CONFIG_JSON_WITH_RELATIONSHIP_AND_MESSAGES}.{request.WorkSheetName}.{JSON_FILE_EXT}"); | ||
result = await poolConfigurationJsonWriter.Write(poolConfigFromExcel, poolConfigJsonFilePath); | ||
} | ||
catch (Exception e) | ||
{ | ||
return new StatusMessage(false, e.Message); | ||
} | ||
|
||
return result; | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...s.Performance/tools/snapshot-creator-v2/Features/Generate/IPoolConfigurationJsonWriter.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
2 changes: 1 addition & 1 deletion
2
...formance/tools/snapshot-creator-v2/Features/Generate/IRelationshipAndMessagesGenerator.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
45 changes: 0 additions & 45 deletions
45
...formance/tools/snapshot-creator-v2/Features/Generate/PoolConfigurationGeneratorCommand.cs
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
...ance/tools/snapshot-creator-v2/Features/Generate/PoolConfigurationGeneratorCommandArgs.cs
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...ts.Performance/tools/snapshot-creator-v2/Features/Generate/PoolConfigurationJsonWriter.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
4 changes: 2 additions & 2 deletions
4
...rformance/tools/snapshot-creator-v2/Features/Generate/RelationshipAndMessagesGenerator.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
2 changes: 1 addition & 1 deletion
2
...napshot-creator-v2/Constants/Resources.cs → ...v2/Features/Shared/Constants/Resources.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
2 changes: 1 addition & 1 deletion
2
...shot-creator-v2/Enums/IdentityPoolType.cs → ...Features/Shared/Enums/IdentityPoolType.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
4 changes: 2 additions & 2 deletions
4
...erformanceTestConfigurationExcelReader.cs → ...erformanceTestConfigurationExcelReader.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
4 changes: 2 additions & 2 deletions
4
...es/IPerformanceTestConfigurationReader.cs → ...es/IPerformanceTestConfigurationReader.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
4 changes: 2 additions & 2 deletions
4
...pshot-creator-v2/Models/DomainIdentity.cs → .../Features/Shared/Models/DomainIdentity.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
Oops, something went wrong.