Skip to content

Commit

Permalink
Merge branch 'main' into task/cdms-118-coding-standards
Browse files Browse the repository at this point in the history
  • Loading branch information
ishimmings authored Dec 12, 2024
2 parents 1e36712 + 2c10d51 commit 93f06de
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 41 deletions.
2 changes: 2 additions & 0 deletions Btms.Analytics/MovementsAggregationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using Btms.Model;
using MongoDB.Bson;
using MongoDB.Driver;
using Btms.Analytics.Extensions;

Check failure on line 9 in Btms.Analytics/MovementsAggregationService.cs

View workflow job for this annotation

GitHub Actions / Run Pull Request Checks

The using directive for 'Btms.Analytics.Extensions' appeared previously in this namespace
using Microsoft.EntityFrameworkCore.Query.SqlExpressions;

namespace Btms.Analytics;

Expand Down
69 changes: 35 additions & 34 deletions Btms.Business.Tests/Commands/SyncClearanceRequestsCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,40 @@ namespace Btms.Business.Tests.Commands;

public class SyncClearanceRequestsCommandTests(ITestOutputHelper outputHelper)
{
[Fact]
public async Task WhenClearanceRequestBlobsExist_ThenTheyShouldBePlacedOnInternalBus()
{
var clearanceRequest = ClearanceRequestBuilder.Default().Build();
var command = new SyncClearanceRequestsCommand();
var jobStore = new SyncJobStore();
jobStore.CreateJob(command.JobId, SyncPeriod.All.ToString(), "ClearanceRequests");


var bus = Substitute.For<IPublishBus>();
var blob = Substitute.For<IBlobService>();
blob.GetResourcesAsync(Arg.Any<string>(), Arg.Any<CancellationToken>())
.Returns(
new TestBlobItem(clearanceRequest.Header!.EntryReference!, clearanceRequest.ToJsonString())
.ToAsyncEnumerator());

blob.GetResource(Arg.Any<IBlobItem>(), Arg.Any<CancellationToken>())
.Returns(clearanceRequest.ToJsonString());


var handler = new SyncClearanceRequestsCommand.Handler(
new SyncMetrics(new DummyMeterFactory()),
bus,
TestLogger.Create<SyncClearanceRequestsCommand>(outputHelper),
new SensitiveDataSerializer(Options.Create(SensitiveDataOptions.WithSensitiveData), NullLogger<SensitiveDataSerializer>.Instance),
blob,
Options.Create(new BusinessOptions()),
jobStore);

await handler.Handle(command, CancellationToken.None);

// ASSERT
await bus.Received(1).Publish(Arg.Any<AlvsClearanceRequest>(), "ALVS",
Arg.Any<IDictionary<string, object>>(), Arg.Any<CancellationToken>());
[Fact]
public async Task WhenClearanceRequestBlobsExist_ThenTheyShouldBePlacedOnInternalBus()
{
var clearanceRequest = ClearanceRequestBuilder.Default().Build();
var command = new SyncClearanceRequestsCommand();
var jobStore = new SyncJobStore();
jobStore.CreateJob(command.JobId, SyncPeriod.All.ToString(), "ClearanceRequests");


var bus = Substitute.For<IPublishBus>();
var blob = Substitute.For<IBlobService>();
blob.GetResourcesAsync(Arg.Any<string>(), Arg.Any<CancellationToken>())
.Returns(
new TestBlobItem(clearanceRequest!.Header!.EntryReference!, clearanceRequest.ToJsonString())
.ToAsyncEnumerator());

blob.GetResource(Arg.Any<IBlobItem>(), Arg.Any<CancellationToken>())
.Returns(clearanceRequest.ToJsonString());


var handler = new SyncClearanceRequestsCommand.Handler(
new SyncMetrics(new DummyMeterFactory()),
bus,
TestLogger.Create<SyncClearanceRequestsCommand>(outputHelper),
new SensitiveDataSerializer(Options.Create(SensitiveDataOptions.WithSensitiveData), NullLogger<SensitiveDataSerializer>.Instance),
blob,
Options.Create(new BusinessOptions()),
jobStore);

await handler.Handle(command, CancellationToken.None);

// ASSERT
await bus.Received(1).Publish(Arg.Any<AlvsClearanceRequest>(), "CLEARANCEREQUESTS",
Arg.Any<IDictionary<string, object>>(), Arg.Any<CancellationToken>());
}
}
}

Check failure on line 56 in Btms.Business.Tests/Commands/SyncClearanceRequestsCommandTests.cs

View workflow job for this annotation

GitHub Actions / Run Pull Request Checks

Type or namespace definition, or end-of-file expected
9 changes: 4 additions & 5 deletions Btms.Business.Tests/Services/Linking/LinkingServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Btms.Business.Tests.Services.Linking;

public class LinkingServiceTests
{
private static readonly Random Random = new ();
private static readonly Random random = new ();
private readonly IMongoDbContext dbContext = new MemoryMongoDbContext();
private readonly LinkingMetrics linkingMetrics = new(new DummyMeterFactory());
private static string GenerateDocumentReference(int id) => $"GBCVD2024.{id}";
Expand Down Expand Up @@ -295,8 +295,7 @@ private MovementLinkContext CreateMovementContext(Movement? movement, List<Impor
Items = chedReferences.Select(x => new Items
{
Documents = [ new Document { DocumentReference = GenerateDocumentReference(x) } ]
}).ToList(),
ClearanceRequests = []
}).ToList()
};

var existingMovement = createExistingMovement ?
Expand All @@ -309,10 +308,10 @@ private MovementLinkContext CreateMovementContext(Movement? movement, List<Impor
Documents = fieldsOfInterest
? []
: [ new Document { DocumentReference = GenerateDocumentReference(x) } ]
}).ToList(),
ClearanceRequests = []
}).ToList()
} : null;


var changeSet = mov.GenerateChangeSet(existingMovement);
var output = LinkContext.ForMovement(mov, createExistingMovement ? changeSet : null);

Expand Down
1 change: 1 addition & 0 deletions Btms.Business/BusinessOptions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
using Btms.Azure;
using Btms.Business.Commands;

namespace Btms.Business;
Expand Down
3 changes: 1 addition & 2 deletions Btms.Business/Commands/SyncNotificationsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ internal class Handler(
IBlobService blobService,
IOptions<BusinessOptions> businessOptions,
ISyncJobStore syncJobStore)
: Handler<SyncNotificationsCommand>(syncMetrics, bus, logger, sensitiveDataSerializer,
blobService, businessOptions, syncJobStore)
: Handler<SyncNotificationsCommand>(syncMetrics, bus, logger, sensitiveDataSerializer, blobService, businessOptions, syncJobStore)
{
public override async Task Handle(SyncNotificationsCommand request, CancellationToken cancellationToken)
{
Expand Down
2 changes: 2 additions & 0 deletions Btms.Consumers/Extensions/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Configuration;
using Btms.Common.Extensions;
using Btms.Consumers.Interceptors;
using Btms.Consumers.MemoryQueue;
Expand All @@ -6,6 +7,7 @@
using Btms.Types.Ipaffs;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using SlimMessageBus.Host;
using SlimMessageBus.Host.Interceptor;
using SlimMessageBus.Host.Memory;
Expand Down

0 comments on commit 93f06de

Please sign in to comment.