diff --git a/Documentation/OMC - Documentation.md b/Documentation/OMC - Documentation.md index c16d28d8..9cc84f79 100644 --- a/Documentation/OMC - Documentation.md +++ b/Documentation/OMC - Documentation.md @@ -1,6 +1,6 @@ # OMC Documentation -v.1.6.8 +v.1.6.9 © 2024, Worth Systems. diff --git a/EventsHandler/Api/EventsHandler/Configuration/WebApiConfiguration.cs b/EventsHandler/Api/EventsHandler/Configuration/WebApiConfiguration.cs index 1d6d1870..4252c275 100644 --- a/EventsHandler/Api/EventsHandler/Configuration/WebApiConfiguration.cs +++ b/EventsHandler/Api/EventsHandler/Configuration/WebApiConfiguration.cs @@ -12,6 +12,9 @@ namespace EventsHandler.Configuration /// public sealed record WebApiConfiguration { + /// + internal IConfiguration AppSettings { get; } + /// /// Gets the configuration for OMC (internal) system. /// @@ -25,9 +28,15 @@ public sealed record WebApiConfiguration /// /// Initializes a new instance of the class. /// + /// The application configurations stored in "appsettings.json" file. /// The strategy context using a specific data provider configuration loader. - public WebApiConfiguration(ILoadersContext loaderContext) // NOTE: The only constructor to be used with Dependency Injection + public WebApiConfiguration( + IConfiguration appSettings, + ILoadersContext loaderContext) // NOTE: The only constructor to be used with Dependency Injection { + // Mapping configurations from "appsettings.json" file => because these should be always accessible, regardless ILoadingService (in ILoadersContext) + this.AppSettings = appSettings; + // Recreating structure of "appsettings.json" or "secrets.json" files to use them later as objects this.OMC = new OmcComponent(loaderContext, nameof(this.OMC)); this.User = new UserComponent(loaderContext, nameof(this.User)); diff --git a/EventsHandler/Api/EventsHandler/Constants/DefaultValues.cs b/EventsHandler/Api/EventsHandler/Constants/DefaultValues.cs index 361f0728..4660de95 100644 --- a/EventsHandler/Api/EventsHandler/Constants/DefaultValues.cs +++ b/EventsHandler/Api/EventsHandler/Constants/DefaultValues.cs @@ -12,7 +12,7 @@ internal static class ApiController { internal const string Route = "[controller]"; - internal const string Version = "1.68"; + internal const string Version = "1.69"; } #endregion diff --git a/EventsHandler/Api/EventsHandler/Extensions/ConfigurationExtensions.cs b/EventsHandler/Api/EventsHandler/Extensions/ConfigurationExtensions.cs index 3a34832e..b2b13f8a 100644 --- a/EventsHandler/Api/EventsHandler/Extensions/ConfigurationExtensions.cs +++ b/EventsHandler/Api/EventsHandler/Extensions/ConfigurationExtensions.cs @@ -27,6 +27,9 @@ internal static LogLevel GetApplicationInsightsLogLevel(this IConfiguration conf internal static bool IsEncryptionAsymmetric(this IConfiguration configuration) => configuration.GetValue("Encryption:IsAsymmetric"); + internal static bool UseNewOpenKlant(this IConfiguration configuration) + => configuration.GetValue("Features:UseNewOpenKlant"); + /// /// Gets the value from the configuration. /// diff --git a/EventsHandler/Api/EventsHandler/Program.cs b/EventsHandler/Api/EventsHandler/Program.cs index 576363c1..37c10367 100644 --- a/EventsHandler/Api/EventsHandler/Program.cs +++ b/EventsHandler/Api/EventsHandler/Program.cs @@ -49,6 +49,7 @@ using SecretsManager.Services.Authentication.Encryptions.Strategy.Interfaces; using Swashbuckle.AspNetCore.Filters; using System.Reflection; +using QueryContext = EventsHandler.Services.DataQuerying.ApiDataQuery.QueryContext; namespace EventsHandler { @@ -187,27 +188,37 @@ private static WebApplicationBuilder AddNetServices(this WebApplicationBuilder b /// Partially-configured with custom services. private static WebApplicationBuilder AddCustomServices(this WebApplicationBuilder builder) { + // Configurations builder.Services.AddSingleton(); - builder.RegisterEncryptionStrategy(); builder.Services.RegisterLoadingStrategies(); - builder.Services.AddSingleton(); + + // Business logic builder.Services.AddSingleton, NotificationValidator>(); - builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton, NotifyProcessor>(); + builder.Services.AddSingleton, NotifyTemplatesAnalyzer>(); + builder.Services.AddSingleton, NotifySender>(); builder.Services.RegisterNotifyStrategies(); + + // Queries and HTTP resources builder.Services.AddSingleton, ApiDataQuery>(); + builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.RegisterClientFactories(); - builder.Services.AddSingleton, NotifyTemplatesAnalyzer>(); - builder.Services.AddSingleton, NotifySender>(); + + // Feedback and telemetry + builder.Services.AddSingleton(); builder.Services.AddSingleton(); + + // User Interaction builder.Services.RegisterResponders(); + builder.Services.AddSingleton(); return builder; } + #region Aggregated registrations private static void RegisterEncryptionStrategy(this WebApplicationBuilder builder) { // Strategies @@ -259,6 +270,7 @@ private static void RegisterResponders(this IServiceCollection services) // Explicit interfaces services.AddSingleton, NotifyResponder>(); } + #endregion /// /// Configures the HTTP pipeline with middlewares. diff --git a/EventsHandler/Api/EventsHandler/Services/DataQuerying/ApiDataQuery.cs b/EventsHandler/Api/EventsHandler/Services/DataQuerying/ApiDataQuery.cs index 8de23741..d0d5c880 100644 --- a/EventsHandler/Api/EventsHandler/Services/DataQuerying/ApiDataQuery.cs +++ b/EventsHandler/Api/EventsHandler/Services/DataQuerying/ApiDataQuery.cs @@ -1,6 +1,5 @@ // © 2023, Worth Systems. -using EventsHandler.Behaviors.Mapping.Models.Interfaces; using EventsHandler.Behaviors.Mapping.Models.POCOs.NotificatieApi; using EventsHandler.Behaviors.Mapping.Models.POCOs.OpenKlant; using EventsHandler.Behaviors.Mapping.Models.POCOs.OpenZaak; @@ -17,80 +16,60 @@ namespace EventsHandler.Services.DataQuerying /// internal sealed class ApiDataQuery : IDataQueryService { - private readonly ISerializationService _serializer; - private readonly IHttpSupplierService _httpSupplier; - - private QueryContext? _notificationBuilder; + private readonly IQueryContext _queryContext; /// - IHttpSupplierService IDataQueryService.HttpSupplier => this._httpSupplier; + public IHttpSupplierService HttpSupplier { get; } /// /// Initializes a new instance of the class. /// - public ApiDataQuery( - ISerializationService serializer, - IHttpSupplierService httpSupplier) + public ApiDataQuery(IQueryContext queryContext, IHttpSupplierService httpSupplier) { - this._serializer = serializer; - this._httpSupplier = httpSupplier; + this._queryContext = queryContext; + + this.HttpSupplier = httpSupplier; } /// - QueryContext IDataQueryService.From(NotificationEvent notification) + IQueryContext IDataQueryService.From(NotificationEvent notification) { - // To optimize the workflow keep the notification builder cached - if (this._notificationBuilder == null) - { - return this._notificationBuilder ??= - new QueryContext(this._httpSupplier.Configuration, this._serializer, this._httpSupplier, notification); - } - // Update only the current notification in cached builder - this._notificationBuilder.Notification = notification; + this._queryContext.Notification = notification; - return this._notificationBuilder; + return this._queryContext; } - /// - /// The nested builder operating on . - /// - internal sealed class QueryContext // TODO: Introduce service "IQueryContext" here + /// + internal sealed class QueryContext : IQueryContext { private readonly WebApiConfiguration _configuration; private readonly ISerializationService _serializer; private readonly IHttpSupplierService _httpSupplier; - /// - /// The notification from "Notificatie API" Web service. - /// - internal NotificationEvent Notification { private get; set; } + /// + NotificationEvent IQueryContext.Notification { get; set; } /// /// Initializes a new instance of the nested class. /// - internal QueryContext( + public QueryContext( WebApiConfiguration configuration, ISerializationService serializer, - IHttpSupplierService httpSupplier, - NotificationEvent notification) + IHttpSupplierService httpSupplier) { this._configuration = configuration; this._serializer = serializer; this._httpSupplier = httpSupplier; - - this.Notification = notification; } - /// - /// Sends the request to the specified URI and deserializes received JSON result. - /// + #region General HTTP methods + /// /// /// - internal async Task ProcessGetAsync(HttpClientTypes httpsClientType, Uri uri, string fallbackErrorMessage) - where TModel : struct, IJsonSerializable + async Task IQueryContext.ProcessGetAsync(HttpClientTypes httpsClientType, Uri uri, string fallbackErrorMessage) { - string organizationId = this.Notification.GetOrganizationId(); + string organizationId = ((IQueryContext)this).Notification.GetOrganizationId(); (bool isSuccess, string jsonResult) = await this._httpSupplier.GetAsync(httpsClientType, organizationId, uri); @@ -98,76 +77,79 @@ internal async Task ProcessGetAsync(HttpClientTypes httpsClientT : throw new HttpRequestException($"{fallbackErrorMessage} | URI: {uri} | JSON response: {jsonResult}"); } - /// - /// Sends the request to the specified URI and deserializes received JSON result. - /// + /// /// /// - internal async Task ProcessPostAsync(HttpClientTypes httpsClientType, Uri uri, HttpContent body, string fallbackErrorMessage) - where TModel : struct, IJsonSerializable + async Task IQueryContext.ProcessPostAsync(HttpClientTypes httpsClientType, Uri uri, HttpContent body, string fallbackErrorMessage) { - string organizationId = this.Notification.GetOrganizationId(); + string organizationId = ((IQueryContext)this).Notification.GetOrganizationId(); (bool isSuccess, string jsonResult) = await this._httpSupplier.PostAsync(httpsClientType, organizationId, uri, body); return isSuccess ? this._serializer.Deserialize(jsonResult) : throw new HttpRequestException($"{fallbackErrorMessage} | URI: {uri} | JSON response: {jsonResult}"); } + #endregion #region Internal query methods - /// - /// Gets the from "OpenZaak" Web service. - /// - internal async Task GetMainObjectAsync() // TODO: This method is not yet used - { - return await ProcessGetAsync(HttpClientTypes.Data, this.Notification.MainObject, Resources.HttpRequest_ERROR_NoMainObject); - } - - /// - /// Gets the from "OpenZaak" Web service. - /// - internal async Task GetCaseAsync() + /// + /// + /// + async Task IQueryContext.GetCaseAsync() { - return await ProcessGetAsync(HttpClientTypes.Data, await GetCaseTypeAsync(), Resources.HttpRequest_ERROR_NoCase); + return await ((IQueryContext)this).ProcessGetAsync(HttpClientTypes.Data, await GetCaseTypeAsync(), Resources.HttpRequest_ERROR_NoCase); } - /// - /// Gets the details of a specific citizen from "OpenKlant" Web service. - /// - internal async Task GetCitizenDetailsAsync() + /// + /// + /// + async Task IQueryContext.GetCitizenDetailsAsync() { // Predefined URL components - string citizensEndpoint = $"https://{GetSpecificOpenKlantDomain()}/klanten/api/v1/klanten"; - + string citizensEndpoint; + // Request URL - Uri citizenByBsnUri = new($"{citizensEndpoint}?subjectNatuurlijkPersoon__inpBsn={await GetBsnNumberAsync()}"); - - return await ProcessGetAsync(HttpClientTypes.Data, citizenByBsnUri, Resources.HttpRequest_ERROR_NoCitizenDetails); + Uri citizenByBsnUri; + + if (!this._configuration.AppSettings.UseNewOpenKlant()) + { + // Open Klant 1.0 + citizensEndpoint = $"https://{GetSpecificOpenKlantDomain()}/klanten/api/v1/klanten"; + citizenByBsnUri = new Uri($"{citizensEndpoint}?subjectNatuurlijkPersoon__inpBsn={await GetBsnNumberAsync()}"); + } + else + { + // Open Klant 2.0 + citizensEndpoint = $"https://{GetSpecificOpenKlantDomain()}/"; // TODO: To be finished + citizenByBsnUri = new Uri(citizensEndpoint); // TODO: To be finished + } + + return await ((IQueryContext)this).ProcessGetAsync(HttpClientTypes.Data, citizenByBsnUri, Resources.HttpRequest_ERROR_NoCitizenDetails); } - - /// - /// Gets the status(es) of the specific from "OpenZaak" Web service. - /// - internal async Task GetCaseStatusesAsync() + + /// + /// + /// + async Task IQueryContext.GetCaseStatusesAsync() { // Predefined URL components string statusesEndpoint = $"https://{GetSpecificOpenZaakDomain()}/zaken/api/v1/statussen"; // Request URL - Uri caseStatuses = new($"{statusesEndpoint}?zaak={this.Notification.MainObject}"); + Uri caseStatuses = new($"{statusesEndpoint}?zaak={((IQueryContext)this).Notification.MainObject}"); - return await ProcessGetAsync(HttpClientTypes.Data, caseStatuses, Resources.HttpRequest_ERROR_NoCaseStatuses); + return await ((IQueryContext)this).ProcessGetAsync(HttpClientTypes.Data, caseStatuses, Resources.HttpRequest_ERROR_NoCaseStatuses); } - - /// - /// Gets the type of . - /// - internal async Task GetLastCaseStatusTypeAsync(CaseStatuses statuses) + + /// + /// + /// + async Task IQueryContext.GetLastCaseStatusTypeAsync(CaseStatuses statuses) { // Request URL Uri lastStatusTypeUri = statuses.LastStatus().Type; - return await ProcessGetAsync(HttpClientTypes.Data, lastStatusTypeUri, Resources.HttpRequest_ERROR_NoCaseStatusType); + return await ((IQueryContext)this).ProcessGetAsync(HttpClientTypes.Data, lastStatusTypeUri, Resources.HttpRequest_ERROR_NoCaseStatusType); } #endregion @@ -177,7 +159,7 @@ internal async Task GetLastCaseStatusTypeAsync(CaseStatuses stat /// private async Task GetCaseTypeAsync() { - return this.Notification.Attributes.CaseType ?? (await GetCaseDetailsAsync()).CaseType; + return ((IQueryContext)this).Notification.Attributes.CaseType ?? (await GetCaseDetailsAsync()).CaseType; } /// @@ -185,7 +167,7 @@ private async Task GetCaseTypeAsync() /// private async Task GetCaseDetailsAsync() { - return await ProcessGetAsync(HttpClientTypes.Data, this.Notification.MainObject, Resources.HttpRequest_ERROR_NoCaseDetails); + return await ((IQueryContext)this).ProcessGetAsync(HttpClientTypes.Data, ((IQueryContext)this).Notification.MainObject, Resources.HttpRequest_ERROR_NoCaseDetails); } /// @@ -203,9 +185,9 @@ private async Task GetCaseRoleAsync() const string roleType = "natuurlijk_persoon"; // Request URL - Uri caseWithRoleUri = new($"{rolesEndpoint}?zaak={this.Notification.MainObject}&betrokkeneType={roleType}"); + Uri caseWithRoleUri = new($"{rolesEndpoint}?zaak={((IQueryContext)this).Notification.MainObject}&betrokkeneType={roleType}"); - return await ProcessGetAsync(HttpClientTypes.Data, caseWithRoleUri, Resources.HttpRequest_ERROR_NoCaseRole); + return await ((IQueryContext)this).ProcessGetAsync(HttpClientTypes.Data, caseWithRoleUri, Resources.HttpRequest_ERROR_NoCaseRole); } #endregion diff --git a/EventsHandler/Api/EventsHandler/Services/DataQuerying/Interfaces/IDataQueryService.cs b/EventsHandler/Api/EventsHandler/Services/DataQuerying/Interfaces/IDataQueryService.cs index 8b5c6cf8..5ab7aa5b 100644 --- a/EventsHandler/Api/EventsHandler/Services/DataQuerying/Interfaces/IDataQueryService.cs +++ b/EventsHandler/Api/EventsHandler/Services/DataQuerying/Interfaces/IDataQueryService.cs @@ -2,7 +2,6 @@ using EventsHandler.Behaviors.Mapping.Models.Interfaces; using EventsHandler.Services.DataReceiving.Interfaces; -using static EventsHandler.Services.DataQuerying.ApiDataQuery; namespace EventsHandler.Services.DataQuerying.Interfaces { @@ -18,6 +17,6 @@ public interface IDataQueryService /// /// Gets the query context of or sets it first if not yet existing. /// - internal QueryContext From(TModel model); + internal IQueryContext From(TModel model); } } \ No newline at end of file diff --git a/EventsHandler/Api/EventsHandler/Services/DataQuerying/Interfaces/IQueryContext.cs b/EventsHandler/Api/EventsHandler/Services/DataQuerying/Interfaces/IQueryContext.cs new file mode 100644 index 00000000..9b1502f4 --- /dev/null +++ b/EventsHandler/Api/EventsHandler/Services/DataQuerying/Interfaces/IQueryContext.cs @@ -0,0 +1,53 @@ +// © 2024, Worth Systems. + +using EventsHandler.Behaviors.Mapping.Models.Interfaces; +using EventsHandler.Behaviors.Mapping.Models.POCOs.NotificatieApi; +using EventsHandler.Behaviors.Mapping.Models.POCOs.OpenKlant; +using EventsHandler.Behaviors.Mapping.Models.POCOs.OpenZaak; +using EventsHandler.Services.DataReceiving.Enums; + +namespace EventsHandler.Services.DataQuerying.Interfaces +{ + /// + /// The nested query context (following loosely Builder pattern) operating on . + /// + internal interface IQueryContext + { + /// + /// The notification from "Notificatie API" Web service. + /// + internal NotificationEvent Notification { get; set; } + + /// + /// Sends the request to the specified URI and deserializes received JSON result. + /// + internal Task ProcessGetAsync(HttpClientTypes httpsClientType, Uri uri, string fallbackErrorMessage) + where TModel : struct, IJsonSerializable; + + /// + /// Sends the request to the specified URI and deserializes received JSON result. + /// + internal Task ProcessPostAsync(HttpClientTypes httpsClientType, Uri uri, HttpContent body, string fallbackErrorMessage) + where TModel : struct, IJsonSerializable; + + /// + /// Gets the from "OpenZaak" Web service. + /// + internal Task GetCaseAsync(); + + /// + /// Gets the details of a specific citizen from "OpenKlant" Web service. + /// + internal Task GetCitizenDetailsAsync(); + + /// + /// Gets the status(es) of the specific from "OpenZaak" Web service. + /// + internal Task GetCaseStatusesAsync(); + + /// + /// Gets the type of . + /// + internal Task GetLastCaseStatusTypeAsync(CaseStatuses statuses); + } +} \ No newline at end of file diff --git a/EventsHandler/Api/EventsHandler/appsettings.Development.json b/EventsHandler/Api/EventsHandler/appsettings.Development.json index 3f6a9ce5..3aefd19b 100644 --- a/EventsHandler/Api/EventsHandler/appsettings.Development.json +++ b/EventsHandler/Api/EventsHandler/appsettings.Development.json @@ -9,5 +9,8 @@ "Encryption": { "IsAsymmetric": false }, + "Features": { + "UseNewOpenKlant": true + }, "AllowedHosts": "*" } \ No newline at end of file diff --git a/EventsHandler/Api/EventsHandler/appsettings.Production.json b/EventsHandler/Api/EventsHandler/appsettings.Production.json index e1d4c248..d3cf0937 100644 --- a/EventsHandler/Api/EventsHandler/appsettings.Production.json +++ b/EventsHandler/Api/EventsHandler/appsettings.Production.json @@ -4,15 +4,13 @@ "Default": "Information", "Microsoft.AspNetCore": "Information", "Microsoft.Hosting.Lifetime": "Information" - }, - "ApplicationInsights": { - "LogLevel": { - "Default": "Information" - } } }, "Encryption": { "IsAsymmetric": false }, + "Features": { + "UseNewOpenKlant": false + }, "AllowedHosts": "*" } \ No newline at end of file diff --git a/EventsHandler/Api/EventsHandler/appsettings.Test.json b/EventsHandler/Api/EventsHandler/appsettings.Test.json index 3e5c7dfa..fa7387c1 100644 --- a/EventsHandler/Api/EventsHandler/appsettings.Test.json +++ b/EventsHandler/Api/EventsHandler/appsettings.Test.json @@ -9,5 +9,8 @@ "Encryption": { "IsAsymmetric": false }, + "Features": { + "UseNewOpenKlant": true + }, "AllowedHosts": "*" } \ No newline at end of file diff --git a/EventsHandler/Api/EventsHandler/appsettings.json b/EventsHandler/Api/EventsHandler/appsettings.json index e1d4c248..358a0283 100644 --- a/EventsHandler/Api/EventsHandler/appsettings.json +++ b/EventsHandler/Api/EventsHandler/appsettings.json @@ -14,5 +14,8 @@ "Encryption": { "IsAsymmetric": false }, + "Features": { + "UseNewOpenKlant": false + }, "AllowedHosts": "*" } \ No newline at end of file diff --git a/EventsHandler/Tests/IntegrationTests/EventsHandler.IntegrationTests/Services/DataQuerying/ApiDataQueryTests.cs b/EventsHandler/Tests/IntegrationTests/EventsHandler.IntegrationTests/Services/DataQuerying/ApiDataQueryTests.cs index 1edc44ca..54c7b790 100644 --- a/EventsHandler/Tests/IntegrationTests/EventsHandler.IntegrationTests/Services/DataQuerying/ApiDataQueryTests.cs +++ b/EventsHandler/Tests/IntegrationTests/EventsHandler.IntegrationTests/Services/DataQuerying/ApiDataQueryTests.cs @@ -11,9 +11,8 @@ using EventsHandler.Services.DataReceiving.Factories; using EventsHandler.Services.DataReceiving.Factories.Interfaces; using EventsHandler.Services.DataReceiving.Interfaces; -using EventsHandler.Services.Serialization; -using EventsHandler.Services.Serialization.Interfaces; using EventsHandler.Utilities._TestHelpers; +using Microsoft.Extensions.Configuration; using SecretsManager.Services.Authentication.Encryptions.Strategy; using SecretsManager.Services.Authentication.Encryptions.Strategy.Context; using System.Text.Json; @@ -29,14 +28,21 @@ public sealed class ApiDataQueryTests [OneTimeSetUp] public void InitializeTests() { - // Arrange - ISerializationService serializer = new SpecificSerializer(); - WebApiConfiguration configuration = new(new Mock().Object); + // Mocked IQueryContext + IQueryContext queryContext = new Mock().Object; // TODO: MockBehavior.Strict + + // Mocked IHttpSupplier + IConfiguration appSettings = ConfigurationHandler.GetConfiguration(); + ILoadersContext loadersContext = new Mock().Object; // TODO: MockBehavior.Strict + WebApiConfiguration configuration = new(appSettings, loadersContext); EncryptionContext encryptionContext = new(new SymmetricEncryptionStrategy()); IHttpClientFactory httpClientFactory = new HeadersHttpClientFactory(); IHttpSupplierService supplier = new JwtHttpSupplier(configuration, encryptionContext, httpClientFactory); - this._dataQuery = new ApiDataQuery(serializer, supplier); + // Larger services + this._dataQuery = new ApiDataQuery(queryContext, supplier); + + // Notification this._notification = NotificationEventHandler.GetNotification_Test_WithOrphans_ManuallyCreated(); } diff --git a/EventsHandler/Tests/UnitTests/EventsHandler.Tests/Behaviors/Communication/Manager/ScenariosResolverTests.cs b/EventsHandler/Tests/UnitTests/EventsHandler.Tests/Behaviors/Communication/Manager/ScenariosResolverTests.cs index f518d5b2..60bfc087 100644 --- a/EventsHandler/Tests/UnitTests/EventsHandler.Tests/Behaviors/Communication/Manager/ScenariosResolverTests.cs +++ b/EventsHandler/Tests/UnitTests/EventsHandler.Tests/Behaviors/Communication/Manager/ScenariosResolverTests.cs @@ -9,6 +9,8 @@ using EventsHandler.Configuration; using EventsHandler.Services.DataLoading.Strategy.Interfaces; using EventsHandler.Services.DataQuerying.Interfaces; +using EventsHandler.Utilities._TestHelpers; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Moq; @@ -26,7 +28,9 @@ public sealed class ScenariosResolverTests [OneTimeSetUp] public void InitializeTests() { - var webApiConfiguration = new WebApiConfiguration(new Mock().Object); + IConfiguration appSettings = ConfigurationHandler.GetConfiguration(); + ILoadersContext loadersContext = new Mock().Object; + WebApiConfiguration webApiConfiguration = new(appSettings, loadersContext); // Mocked services this._mockedNotifyScenario = new Mock(MockBehavior.Strict); @@ -99,4 +103,4 @@ private static NotificationEvent GetTestNotificationEvent() } #endregion } -} +} \ No newline at end of file diff --git a/EventsHandler/Tests/Utilities/EventsHandler.Utilities/_TestHelpers/ConfigurationHandler.cs b/EventsHandler/Tests/Utilities/EventsHandler.Utilities/_TestHelpers/ConfigurationHandler.cs index a44a311f..8004e5cb 100644 --- a/EventsHandler/Tests/Utilities/EventsHandler.Utilities/_TestHelpers/ConfigurationHandler.cs +++ b/EventsHandler/Tests/Utilities/EventsHandler.Utilities/_TestHelpers/ConfigurationHandler.cs @@ -160,6 +160,9 @@ internal static ILoadingService GetEnvironmentLoader(bool isValid = true) #region Web API Configuration internal static WebApiConfiguration GetWebApiConfiguration(ILoadingService loadingService) { + // "appSettings.json" configuration + IConfiguration appSettings = GetConfiguration(); + // Service Provider (does not require mocking) using ServiceProvider serviceProvider = new ServiceCollection().BuildServiceProvider(); @@ -167,7 +170,7 @@ internal static WebApiConfiguration GetWebApiConfiguration(ILoadingService loadi var loadersContext = new LoadersContext(serviceProvider, loadingService); // Web API Configuration - return new WebApiConfiguration(loadersContext); + return new WebApiConfiguration(appSettings, loadersContext); } #endregion }