Skip to content

Commit

Permalink
Fixed up warnings introduced in merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Shimmings committed Dec 12, 2024
1 parent 93f06de commit e193f1d
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 49 deletions.
2 changes: 0 additions & 2 deletions Btms.Analytics/MovementsAggregationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
using Btms.Model;
using MongoDB.Bson;
using MongoDB.Driver;
using Btms.Analytics.Extensions;
using Microsoft.EntityFrameworkCore.Query.SqlExpressions;

namespace Btms.Analytics;

Expand Down
71 changes: 35 additions & 36 deletions Btms.Business.Tests/Commands/SyncClearanceRequestsCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,39 @@ 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>(), "CLEARANCEREQUESTS",
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>());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace Btms.Business.Tests.Services.Decisions.Finders;

// ReSharper disable once InconsistentNaming
public class ChedPPDecisionFinderTests
{
[Fact]
Expand Down
8 changes: 5 additions & 3 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,7 +295,8 @@ private MovementLinkContext CreateMovementContext(Movement? movement, List<Impor
Items = chedReferences.Select(x => new Items
{
Documents = [ new Document { DocumentReference = GenerateDocumentReference(x) } ]
}).ToList()
}).ToList(),
ClearanceRequests = new()
};

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


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

namespace Btms.Business;
Expand Down
4 changes: 2 additions & 2 deletions Btms.Business/Commands/SyncHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected async Task SyncBlobPath<TRequest>(string path, SyncPeriod period, stri
var result = blobService.GetResourcesAsync($"{path}{period.GetPeriodPath()}", cancellationToken);
var degreeOfParallelism = options.Value.GetConcurrency<T>(BusinessOptions.Feature.BlobItems);

await Parallel.ForEachAsync(result, new ParallelOptions() { CancellationToken = cancellationToken, MaxDegreeOfParallelism = degreeOfParallelism }, async (item, token) =>
await Parallel.ForEachAsync(result, new ParallelOptions() { CancellationToken = cancellationToken, MaxDegreeOfParallelism = degreeOfParallelism }, async (item, _) =>
{
await SyncBlob<TRequest>(path, topic, item, job, cancellationToken);
});
Expand All @@ -121,7 +121,7 @@ protected async Task SyncBlobs<TRequest>(SyncPeriod period, string topic, Guid j
var degreeOfParallelism = options.Value.GetConcurrency<T>(BusinessOptions.Feature.BlobItems);

job?.Start();
logger.LogInformation("SyncNotifications period: {Period}, maxDegreeOfParallelism={degreeOfParallelism}, Environment.ProcessorCount={ProcessorCount}", period.ToString(), degreeOfParallelism, Environment.ProcessorCount);
logger.LogInformation("SyncNotifications period: {Period}, maxDegreeOfParallelism={DegreeOfParallelism}, Environment.ProcessorCount={ProcessorCount}", period.ToString(), degreeOfParallelism, Environment.ProcessorCount);
try
{
foreach (var path in paths)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Btms.Business.Services.Decisions.Finders;

// ReSharper disable once InconsistentNaming
public class ChedPPDecisionFinder : IDecisionFinder
{
public DecisionResult FindDecision(ImportNotification notification)
Expand Down
3 changes: 0 additions & 3 deletions Btms.Consumers/ConsumerOptions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System.ComponentModel.DataAnnotations;
using Btms.Azure;

namespace Btms.Consumers;

public class ConsumerOptions
Expand Down
2 changes: 0 additions & 2 deletions Btms.Consumers/Extensions/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Configuration;
using Btms.Common.Extensions;
using Btms.Consumers.Interceptors;
using Btms.Consumers.MemoryQueue;
Expand All @@ -7,7 +6,6 @@
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
1 change: 1 addition & 0 deletions Btms.Types.Gvms.Mapping.V1/GrmWithTransformMapper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Btms.Model.Extensions;
using Btms.Model.Relationships;

// ReSharper disable once CheckNamespace
namespace Btms.Types.Gvms.Mapping;

public static class GrmWithTransformMapper
Expand Down
1 change: 1 addition & 0 deletions Btms.Types.Ipaffs.Mapping.V1/DateTimeMapper.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// ReSharper disable once CheckNamespace
namespace Btms.Types.Ipaffs.Mapping;

public static class DateTimeMapper
Expand Down
1 change: 1 addition & 0 deletions Btms.Types.Ipaffs.Mapping.V1/DictionaryMapper.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// ReSharper disable once CheckNamespace
namespace Btms.Types.Ipaffs.Mapping;

public static class DictionaryMapper
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// ReSharper disable once CheckNamespace
namespace Btms.Types.Ipaffs.Mapping;

public static class ImportNotificationWithTransformMapper
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Text.Json;
using System.Text.Json.Serialization;

// ReSharper disable once CheckNamespace
namespace Btms.Types.Ipaffs;

public class KeyDataPairsToDictionaryStringObjectJsonConverter : JsonConverter<Dictionary<string, object?>>
Expand Down

0 comments on commit e193f1d

Please sign in to comment.