diff --git a/CallbackHandler.BusinessLogic.Tests/Mediator/MediatorTests.cs b/CallbackHandler.BusinessLogic.Tests/Mediator/MediatorTests.cs index 8e276be..9850102 100644 --- a/CallbackHandler.BusinessLogic.Tests/Mediator/MediatorTests.cs +++ b/CallbackHandler.BusinessLogic.Tests/Mediator/MediatorTests.cs @@ -41,8 +41,7 @@ public async Task Mediator_Send_RequestHandled() ServiceRegistry services = new(); IConfigurationRoot configurationRoot = new ConfigurationBuilder().AddInMemoryCollection(TestData.DefaultAppSettings).Build(); - //ConfigurationReader.Initialise(configurationRoot); - + this.AddTestRegistrations(services, hostingEnvironment.Instance(), configurationRoot); services.AddCallbackHandlerRegistries(configurationRoot); Container container = new(services); @@ -55,7 +54,7 @@ public async Task Mediator_Send_RequestHandled() { try { - await mediator.Send(baseRequest); + await mediator.Send(baseRequest, TestContext.Current.CancellationToken); } catch (Exception ex) { diff --git a/CallbackHandler.BusinessLogic/Services/CallbackDomainService.cs b/CallbackHandler.BusinessLogic/Services/CallbackDomainService.cs index cb4ca93..f0f3485 100644 --- a/CallbackHandler.BusinessLogic/Services/CallbackDomainService.cs +++ b/CallbackHandler.BusinessLogic/Services/CallbackDomainService.cs @@ -103,27 +103,23 @@ public static async Task> GetToken(TokenResponse currentTo // Get a token to talk to the estate service String clientId = ConfigurationReader.GetValue("AppSettings", "ClientId"); String clientSecret = ConfigurationReader.GetValue("AppSettings", "ClientSecret"); - Logger.LogDebug($"Client Id is {clientId}"); - Logger.LogDebug($"Client Secret is {clientSecret}"); - + if (currentToken == null) { Result tokenResult = await securityServiceClient.GetToken(clientId, clientSecret, cancellationToken); if (tokenResult.IsFailed) return ResultHelpers.CreateFailure(tokenResult); TokenResponse token = tokenResult.Data; - Logger.LogDebug($"Token is {token.AccessToken}"); return Result.Success(token); } if (currentToken.Expires.UtcDateTime.Subtract(DateTime.UtcNow) < TimeSpan.FromMinutes(2)) { - Logger.LogDebug($"Token is about to expire at {currentToken.Expires.DateTime:O}"); + Logger.LogDebug("Token is about to expire at {tokenExpiry}", currentToken.Expires.DateTime); Result tokenResult = await securityServiceClient.GetToken(clientId, clientSecret, cancellationToken); if (tokenResult.IsFailed) return ResultHelpers.CreateFailure(tokenResult); TokenResponse token = tokenResult.Data; - Logger.LogDebug($"Token is {token.AccessToken}"); return Result.Success(token); } diff --git a/CallbackHandler.IntegrationTests/Common/DockerHelper.cs b/CallbackHandler.IntegrationTests/Common/DockerHelper.cs index bd8fa22..0045a7a 100644 --- a/CallbackHandler.IntegrationTests/Common/DockerHelper.cs +++ b/CallbackHandler.IntegrationTests/Common/DockerHelper.cs @@ -16,9 +16,7 @@ public DockerHelper() { public ISecurityServiceClient SecurityServiceClient; public ITransactionProcessorClient TransactionProcessorClient; - - public EventStoreProjectionManagementClient LegacyProjectionManagementClient; - + public KurrentDBProjectionManagementClient ProjectionManagementClient; public String AccessToken; @@ -87,7 +85,6 @@ public override async Task StartContainersForScenarioRun(String scenarioName, this.SecurityServiceClient = new SecurityServiceClient(SecurityServiceBaseAddressResolver, httpClient, Serialise, Deserialise); this.TransactionProcessorClient = new TransactionProcessorClient(TransactionProcessorBaseAddressResolver, httpClient, Serialise, Deserialise); this.ProjectionManagementClient = new KurrentDBProjectionManagementClient(this.ConfigureKurrentDbSettings()); - this.LegacyProjectionManagementClient = new EventStoreProjectionManagementClient(this.ConfigureLegacyEventstoreDbSettings()); this.TestHostHttpClient = new HttpClient(clientHandler); this.TestHostHttpClient.BaseAddress = new Uri($"http://127.0.0.1:{this.TestHostServicePort}"); this.AgencyBankingClient = new AgencyBankingClient(TestHostServiceBaseAddressResolver, httpClient, Serialise_CamelCase, this.Deserialise_CamelCase); diff --git a/CallbackHandler.IntegrationTests/Common/GenericSteps.cs b/CallbackHandler.IntegrationTests/Common/GenericSteps.cs index d335804..4206360 100644 --- a/CallbackHandler.IntegrationTests/Common/GenericSteps.cs +++ b/CallbackHandler.IntegrationTests/Common/GenericSteps.cs @@ -27,7 +27,8 @@ public async Task StartSystem() String scenarioName = this.ScenarioContext.ScenarioInfo.Title.Replace(" ", ""); NlogLogger logger = new(); logger.Initialise(LogManager.GetLogger(scenarioName), scenarioName); - LogManager.AddHiddenAssembly(typeof(NlogLogger).Assembly); + LogManager.Setup().SetupLogFactory(setup => + setup.AddCallSiteHiddenAssembly(typeof(NlogLogger).Assembly)); DockerServices dockerServices = DockerServices.SecurityService | DockerServices.TransactionProcessor | DockerServices.CallbackHandler | DockerServices.KurrentDb | diff --git a/CallbackHandler.IntegrationTests/Features/BankDepositCallback.feature.cs b/CallbackHandler.IntegrationTests/Features/BankDepositCallback.feature.cs index 36a70f1..8cab40a 100644 --- a/CallbackHandler.IntegrationTests/Features/BankDepositCallback.feature.cs +++ b/CallbackHandler.IntegrationTests/Features/BankDepositCallback.feature.cs @@ -229,13 +229,11 @@ await testRunner.GivenAsync("I have a token to access the estate management and [global::NUnit.Framework.TestAttribute()] [global::NUnit.Framework.DescriptionAttribute("Process a Bank Deposit Callback")] - [global::NUnit.Framework.TestCaseAttribute("1", "0", null)] - public async global::System.Threading.Tasks.Task ProcessABankDepositCallback(string aPIVersion, string @__pickleIndex, string[] exampleTags) + public async global::System.Threading.Tasks.Task ProcessABankDepositCallback() { - string[] tagsOfScenario = exampleTags; + string[] tagsOfScenario = ((string[])(null)); global::System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new global::System.Collections.Specialized.OrderedDictionary(); - argumentsOfScenario.Add("APIVersion", aPIVersion); - string pickleIndex = @__pickleIndex; + string pickleIndex = "0"; global::Reqnroll.ScenarioInfo scenarioInfo = new global::Reqnroll.ScenarioInfo("Process a Bank Deposit Callback", null, tagsOfScenario, argumentsOfScenario, featureTags, pickleIndex); string[] tagsOfRule = ((string[])(null)); global::Reqnroll.RuleInfo ruleInfo = null; diff --git a/CallbackHandler.IntegrationTests/Shared/SharedSteps.cs b/CallbackHandler.IntegrationTests/Shared/SharedSteps.cs index 4935bdb..1b275b6 100644 --- a/CallbackHandler.IntegrationTests/Shared/SharedSteps.cs +++ b/CallbackHandler.IntegrationTests/Shared/SharedSteps.cs @@ -38,7 +38,7 @@ public SharedSteps(ScenarioContext scenarioContext, this.SecurityServiceSteps = new SecurityServiceSteps(testingContext.DockerHelper.SecurityServiceClient, testingContext.DockerHelper.AccessToken); this.TransactionProcessorSteps = new TransactionProcessorSteps(testingContext.DockerHelper.TransactionProcessorClient, testingContext.DockerHelper.TestHostHttpClient, - testingContext.DockerHelper.LegacyProjectionManagementClient, testingContext.DockerHelper.AgencyBankingClient); + testingContext.DockerHelper.ProjectionManagementClient, testingContext.DockerHelper.AgencyBankingClient); } diff --git a/CallbackHandler/Common/JsonSerializerConfiguration.cs b/CallbackHandler/Common/JsonSerializerConfiguration.cs index 55ec382..565e635 100644 --- a/CallbackHandler/Common/JsonSerializerConfiguration.cs +++ b/CallbackHandler/Common/JsonSerializerConfiguration.cs @@ -1,6 +1,5 @@ -using System; +using Shared.Serialisation; using System.Text.Json; -using Shared.Serialisation; namespace CallbackHandler.Common; diff --git a/CallbackHandler/Program.cs b/CallbackHandler/Program.cs index c489cfe..d027b8c 100644 --- a/CallbackHandler/Program.cs +++ b/CallbackHandler/Program.cs @@ -1,5 +1,6 @@ using CallbackHandler.Endpoints; using CallbackHandler.Bootstrapper; +using CallbackHandler.Common; using HealthChecks.UI.Client; using JasperFx.CommandLine.Descriptions; using Lamar; @@ -78,8 +79,9 @@ public static void Main(string[] args) WebApplication app = builder.Build(); - Microsoft.Extensions.Logging.ILogger logger = app.Services.GetRequiredService().CreateLogger("CallbackHandler"); - Shared.Logger.Logger.Initialise(logger); + LogManager.Setup().LoadConfigurationFromFile("NLog.config"); + NLog.Logger logger = LogManager.GetLogger("CallbackHandler"); + Shared.Logger.Logger.Initialise(logger, "callbackhandler"); IConfigurationRoot appConfiguration = (IConfigurationRoot)app.Configuration; appConfiguration.LogConfiguration(Shared.Logger.Logger.LogWarning); ConfigurationReader.Initialise(appConfiguration); @@ -91,6 +93,7 @@ public static void Main(string[] args) app.UseMiddleware(); app.AddRequestResponseLogging(); + //app.UseMiddleware(); app.AddExceptionHandler(); app.UseRouting(); diff --git a/CallbackHandler/nlog.config b/CallbackHandler/nlog.config index e223e44..94546a1 100644 --- a/CallbackHandler/nlog.config +++ b/CallbackHandler/nlog.config @@ -4,22 +4,37 @@ - - + maxArchiveFiles="2"> + + + + + + + + + + + + + + + diff --git a/Directory.Packages.props b/Directory.Packages.props index 78a37a9..8974779 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -4,17 +4,17 @@ - + - + - + @@ -25,20 +25,20 @@ - - - - - - + + + + + + - - + + - +