diff --git a/infrastructure/environments/perf-ukw/main.tf b/infrastructure/environments/perf-ukw/main.tf index 0e6797ad5..0d14e0346 100644 --- a/infrastructure/environments/perf-ukw/main.tf +++ b/infrastructure/environments/perf-ukw/main.tf @@ -121,6 +121,9 @@ module "mya_application_perf" { cosmos_aggregation_autoscale_settings = [{ max_throughput = 10000 }] + cosmos_booking_reference_data_autoscale_settings = [{ + max_throughput = 25000 + }] cosmos_core_autoscale_settings = [{ max_throughput = 25000 }] diff --git a/infrastructure/environments/perf/main.tf b/infrastructure/environments/perf/main.tf index 36d6cdb8e..7201ad22c 100644 --- a/infrastructure/environments/perf/main.tf +++ b/infrastructure/environments/perf/main.tf @@ -128,6 +128,9 @@ module "mya_application_perf" { cosmos_aggregation_autoscale_settings = [{ max_throughput = 10000 }] + cosmos_booking_reference_data_autoscale_settings = [{ + max_throughput = 25000 + }] cosmos_core_autoscale_settings = [{ max_throughput = 25000 }] diff --git a/infrastructure/environments/prod-ukw/main.tf b/infrastructure/environments/prod-ukw/main.tf index 7f83437d2..f0fd28405 100644 --- a/infrastructure/environments/prod-ukw/main.tf +++ b/infrastructure/environments/prod-ukw/main.tf @@ -131,6 +131,9 @@ module "mya_application_prod_ukw" { cosmos_aggregation_autoscale_settings = [{ max_throughput = 10000 }] + cosmos_booking_reference_data_autoscale_settings = [{ + max_throughput = 25000 + }] cosmos_core_autoscale_settings = [{ max_throughput = 25000 }] diff --git a/infrastructure/environments/prod/main.tf b/infrastructure/environments/prod/main.tf index bd2a852bb..29f615ff4 100644 --- a/infrastructure/environments/prod/main.tf +++ b/infrastructure/environments/prod/main.tf @@ -138,6 +138,9 @@ module "mya_application_prod" { cosmos_aggregation_autoscale_settings = [{ max_throughput = 10000 }] + cosmos_booking_reference_data_autoscale_settings = [{ + max_throughput = 25000 + }] cosmos_core_autoscale_settings = [{ max_throughput = 25000 }] diff --git a/infrastructure/environments/stag-ukw/main.tf b/infrastructure/environments/stag-ukw/main.tf index 3ccf80b64..a66dffac8 100644 --- a/infrastructure/environments/stag-ukw/main.tf +++ b/infrastructure/environments/stag-ukw/main.tf @@ -121,6 +121,9 @@ module "mya_application_stag_ukw" { cosmos_aggregation_autoscale_settings = [{ max_throughput = 10000 }] + cosmos_booking_reference_data_autoscale_settings = [{ + max_throughput = 25000 + }] cosmos_core_autoscale_settings = [{ max_throughput = 25000 }] diff --git a/infrastructure/environments/stag/main.tf b/infrastructure/environments/stag/main.tf index c5bd297f4..ccbf8d14d 100644 --- a/infrastructure/environments/stag/main.tf +++ b/infrastructure/environments/stag/main.tf @@ -128,6 +128,9 @@ module "mya_application_stag" { cosmos_aggregation_autoscale_settings = [{ max_throughput = 10000 }] + cosmos_booking_reference_data_autoscale_settings = [{ + max_throughput = 25000 + }] cosmos_core_autoscale_settings = [{ max_throughput = 25000 }] diff --git a/infrastructure/resources/cosmosdb.tf b/infrastructure/resources/cosmosdb.tf index 341edfd89..c604683be 100644 --- a/infrastructure/resources/cosmosdb.tf +++ b/infrastructure/resources/cosmosdb.tf @@ -116,6 +116,22 @@ resource "azurerm_cosmosdb_sql_container" "nbs_mya_core_container" { } } +resource "azurerm_cosmosdb_sql_container" "nbs_mya_booking_reference_container" { + count = var.create_cosmos_db ? 1 : 0 + name = "booking_reference_data" + resource_group_name = local.resource_group_name + account_name = azurerm_cosmosdb_account.nbs_mya_cosmos_db[0].name + database_name = azurerm_cosmosdb_sql_database.nbs_appts_database[0].name + partition_key_paths = ["/docType"] + + dynamic "autoscale_settings" { + for_each = var.cosmos_booking_reference_data_autoscale_settings + content { + max_throughput = autoscale_settings.value["max_throughput"] + } + } +} + resource "azurerm_cosmosdb_sql_container" "nbs_mya_aggregation_container" { count = var.create_cosmos_db ? 1 : 0 name = "aggregated_data" diff --git a/infrastructure/resources/high_load_functions.tf b/infrastructure/resources/high_load_functions.tf index ca2358f48..a6ac18d01 100644 --- a/infrastructure/resources/high_load_functions.tf +++ b/infrastructure/resources/high_load_functions.tf @@ -52,6 +52,8 @@ resource "azurerm_windows_function_app" "nbs_mya_high_load_func_app" { ALLSITES_SLIDING_CACHE_ENABLED = var.allsites_sliding_cache_enabled ALLSITES_CACHE_DURATION_MINUTES = var.allsites_cache_duration_minutes ALLSITES_SLIDING_CACHE_DURATION_MINUTES = var.allsites_sliding_cache_duration_minutes + SITE_CACHE_DURATION_MINUTES = var.site_cache_duration_minutes + SITE_SLIDING_CACHE_DURATION_MINUTES = var.site_sliding_cache_duration_minutes DISABLE_SITE_CACHE = var.disable_site_cache SITE_SUPPORTS_SERVICE_SLIDING_CACHE_ABSOLUTE_EXPIRATION_SECONDS = var.site_supports_service_sliding_cache_absolute_expiration_seconds SITE_SUPPORTS_SERVICE_SLIDING_CACHE_SLIDE_THRESHOLD_SECONDS = var.site_supports_service_sliding_cache_slide_threshold_seconds @@ -205,6 +207,8 @@ resource "azurerm_windows_function_app_slot" "nbs_mya_high_load_func_app_preview ALLSITES_SLIDING_CACHE_ENABLED = var.allsites_sliding_cache_enabled ALLSITES_CACHE_DURATION_MINUTES = var.allsites_cache_duration_minutes ALLSITES_SLIDING_CACHE_DURATION_MINUTES = var.allsites_sliding_cache_duration_minutes + SITE_CACHE_DURATION_MINUTES = var.site_cache_duration_minutes + SITE_SLIDING_CACHE_DURATION_MINUTES = var.site_sliding_cache_duration_minutes DISABLE_SITE_CACHE = var.disable_site_cache SITE_SUPPORTS_SERVICE_SLIDING_CACHE_ABSOLUTE_EXPIRATION_SECONDS = var.site_supports_service_sliding_cache_absolute_expiration_seconds SITE_SUPPORTS_SERVICE_SLIDING_CACHE_SLIDE_THRESHOLD_SECONDS = var.site_supports_service_sliding_cache_slide_threshold_seconds diff --git a/infrastructure/resources/http_functions.tf b/infrastructure/resources/http_functions.tf index 05a5f2640..dd6370e82 100644 --- a/infrastructure/resources/http_functions.tf +++ b/infrastructure/resources/http_functions.tf @@ -76,6 +76,8 @@ resource "azurerm_windows_function_app" "nbs_mya_http_func_app" { ALLSITES_SLIDING_CACHE_ENABLED = var.allsites_sliding_cache_enabled ALLSITES_CACHE_DURATION_MINUTES = var.allsites_cache_duration_minutes ALLSITES_SLIDING_CACHE_DURATION_MINUTES = var.allsites_sliding_cache_duration_minutes + SITE_CACHE_DURATION_MINUTES = var.site_cache_duration_minutes + SITE_SLIDING_CACHE_DURATION_MINUTES = var.site_sliding_cache_duration_minutes DISABLE_SITE_CACHE = var.disable_site_cache SITE_SUPPORTS_SERVICE_SLIDING_CACHE_ABSOLUTE_EXPIRATION_SECONDS = var.site_supports_service_sliding_cache_absolute_expiration_seconds SITE_SUPPORTS_SERVICE_SLIDING_CACHE_SLIDE_THRESHOLD_SECONDS = var.site_supports_service_sliding_cache_slide_threshold_seconds @@ -183,6 +185,8 @@ resource "azurerm_windows_function_app_slot" "nbs_mya_http_func_app_preview" { ALLSITES_SLIDING_CACHE_ENABLED = var.allsites_sliding_cache_enabled ALLSITES_CACHE_DURATION_MINUTES = var.allsites_cache_duration_minutes ALLSITES_SLIDING_CACHE_DURATION_MINUTES = var.allsites_sliding_cache_duration_minutes + SITE_CACHE_DURATION_MINUTES = var.site_cache_duration_minutes + SITE_SLIDING_CACHE_DURATION_MINUTES = var.site_sliding_cache_duration_minutes DISABLE_SITE_CACHE = var.disable_site_cache SITE_SUPPORTS_SERVICE_SLIDING_CACHE_ABSOLUTE_EXPIRATION_SECONDS = var.site_supports_service_sliding_cache_absolute_expiration_seconds SITE_SUPPORTS_SERVICE_SLIDING_CACHE_SLIDE_THRESHOLD_SECONDS = var.site_supports_service_sliding_cache_slide_threshold_seconds diff --git a/infrastructure/resources/servicebus_functions.tf b/infrastructure/resources/servicebus_functions.tf index 3958ab555..d18407b66 100644 --- a/infrastructure/resources/servicebus_functions.tf +++ b/infrastructure/resources/servicebus_functions.tf @@ -54,6 +54,8 @@ resource "azurerm_windows_function_app" "nbs_mya_service_bus_func_app" { ALLSITES_SLIDING_CACHE_ENABLED = var.allsites_sliding_cache_enabled ALLSITES_CACHE_DURATION_MINUTES = var.allsites_cache_duration_minutes ALLSITES_SLIDING_CACHE_DURATION_MINUTES = var.allsites_sliding_cache_duration_minutes + SITE_CACHE_DURATION_MINUTES = var.site_cache_duration_minutes + SITE_SLIDING_CACHE_DURATION_MINUTES = var.site_sliding_cache_duration_minutes DISABLE_SITE_CACHE = var.disable_site_cache CANCEL_A_DATE_RANGE_MAXIMUM_DAYS = var.cancel_a_date_range_maximum_days APPLICATION_NAME = "Service Bus Function App" @@ -185,6 +187,8 @@ resource "azurerm_windows_function_app_slot" "nbs_mya_service_bus_func_app_previ ALLSITES_SLIDING_CACHE_ENABLED = var.allsites_sliding_cache_enabled ALLSITES_CACHE_DURATION_MINUTES = var.allsites_sliding_cache_duration_minutes ALLSITES_SLIDING_CACHE_DURATION_MINUTES = var.allsites_cache_duration_minutes + SITE_CACHE_DURATION_MINUTES = var.site_cache_duration_minutes + SITE_SLIDING_CACHE_DURATION_MINUTES = var.site_sliding_cache_duration_minutes DISABLE_SITE_CACHE = var.disable_site_cache SITE_SUMMARY_DAYS_FORWARD = var.site_summary_days_forward SITE_SUMMARY_DAYS_CHUNK_SIZE = var.site_summary_days_chunk_size diff --git a/infrastructure/resources/timer_functions.tf b/infrastructure/resources/timer_functions.tf index 6e966a1b2..f11074527 100644 --- a/infrastructure/resources/timer_functions.tf +++ b/infrastructure/resources/timer_functions.tf @@ -55,6 +55,8 @@ resource "azurerm_windows_function_app" "nbs_mya_timer_func_app" { ALLSITES_SLIDING_CACHE_ENABLED = var.allsites_sliding_cache_enabled ALLSITES_CACHE_DURATION_MINUTES = var.allsites_cache_duration_minutes ALLSITES_SLIDING_CACHE_DURATION_MINUTES = var.allsites_sliding_cache_duration_minutes + SITE_CACHE_DURATION_MINUTES = var.site_cache_duration_minutes + SITE_SLIDING_CACHE_DURATION_MINUTES = var.site_sliding_cache_duration_minutes DISABLE_SITE_CACHE = var.disable_site_cache SPLUNK_HOST_URL = var.splunk_host_url SPLUNK_HEC_TOKEN = var.splunk_hec_token @@ -195,6 +197,8 @@ resource "azurerm_windows_function_app_slot" "nbs_mya_timer_func_app_preview" { ALLSITES_SLIDING_CACHE_ENABLED = var.allsites_sliding_cache_enabled ALLSITES_CACHE_DURATION_MINUTES = var.allsites_sliding_cache_duration_minutes ALLSITES_SLIDING_CACHE_DURATION_MINUTES = var.allsites_cache_duration_minutes + SITE_CACHE_DURATION_MINUTES = var.site_cache_duration_minutes + SITE_SLIDING_CACHE_DURATION_MINUTES = var.site_sliding_cache_duration_minutes DISABLE_SITE_CACHE = var.disable_site_cache SPLUNK_HOST_URL = var.splunk_host_url SPLUNK_HEC_TOKEN = var.splunk_hec_token diff --git a/infrastructure/resources/variables.tf b/infrastructure/resources/variables.tf index 0e56cd3c8..09b55a5b5 100644 --- a/infrastructure/resources/variables.tf +++ b/infrastructure/resources/variables.tf @@ -194,6 +194,11 @@ variable "cosmos_core_autoscale_settings" { default = [] } +variable "cosmos_booking_reference_data_autoscale_settings" { + type = list(any) + default = [] +} + variable "cosmos_index_autoscale_settings" { type = list(any) default = [] @@ -476,6 +481,16 @@ variable "allsites_sliding_cache_duration_minutes" { default = 20 } +variable "site_cache_duration_minutes" { + type = number + default = 20 +} + +variable "site_sliding_cache_duration_minutes" { + type = number + default = 10 +} + variable "auditor_enable" { type = bool } diff --git a/src/api/Nhs.Appointments.Api/FunctionConfigurationExtensions.cs b/src/api/Nhs.Appointments.Api/FunctionConfigurationExtensions.cs index ef927209c..5392c92e8 100644 --- a/src/api/Nhs.Appointments.Api/FunctionConfigurationExtensions.cs +++ b/src/api/Nhs.Appointments.Api/FunctionConfigurationExtensions.cs @@ -161,6 +161,7 @@ private static async Task SetupCosmosDatabase(CosmosClient cosmosClient) var database = await cosmosClient.CreateDatabaseIfNotExistsAsync(id: "appts"); await database.Database.CreateContainerIfNotExistsAsync(id: "booking_data", partitionKeyPath: "/site"); await database.Database.CreateContainerIfNotExistsAsync(id: "core_data", partitionKeyPath: "/docType"); + await database.Database.CreateContainerIfNotExistsAsync(id: "booking_reference_data", partitionKeyPath: "/docType"); await database.Database.CreateContainerIfNotExistsAsync(id: "index_data", partitionKeyPath: "/docType"); await database.Database.CreateContainerIfNotExistsAsync(id: "audit_data", partitionKeyPath: "/user"); await database.Database.CreateContainerIfNotExistsAsync(id: "aggregated_data", partitionKeyPath: "/date"); diff --git a/src/api/Nhs.Appointments.Api/Functions/HttpFunctions/GetSiteFunction.cs b/src/api/Nhs.Appointments.Api/Functions/HttpFunctions/GetSiteFunction.cs index be050a6a9..8c2a282e0 100644 --- a/src/api/Nhs.Appointments.Api/Functions/HttpFunctions/GetSiteFunction.cs +++ b/src/api/Nhs.Appointments.Api/Functions/HttpFunctions/GetSiteFunction.cs @@ -47,7 +47,7 @@ public override Task RunAsync( protected override async Task> HandleRequest(SiteBasedResourceRequest request, ILogger logger) { - var site = await siteService.GetSiteByIdAsync(request.Site, request.Scope); + var site = await siteService.GetSiteByIdAsync(request.Site, request.IgnoreCache, request.Scope); if (site != null) { return ApiResult.Success(site); diff --git a/src/api/Nhs.Appointments.Api/Functions/HttpFunctions/GetSiteMetaDataFunction.cs b/src/api/Nhs.Appointments.Api/Functions/HttpFunctions/GetSiteMetaDataFunction.cs index 5ec6f9077..7160568a4 100644 --- a/src/api/Nhs.Appointments.Api/Functions/HttpFunctions/GetSiteMetaDataFunction.cs +++ b/src/api/Nhs.Appointments.Api/Functions/HttpFunctions/GetSiteMetaDataFunction.cs @@ -53,7 +53,7 @@ protected override async Task> HandleRequest( ILogger logger) { const string scope = "site_details"; - var site = await siteService.GetSiteByIdAsync(request.Site, scope); + var site = await siteService.GetSiteByIdAsync(request.Site, false, scope); if (site != null) { var patientInformation = site.Accessibilities.Any() diff --git a/src/api/Nhs.Appointments.Api/Functions/HttpFunctions/SiteBasedResourceFunction.cs b/src/api/Nhs.Appointments.Api/Functions/HttpFunctions/SiteBasedResourceFunction.cs index 78f98f77c..d2fa957b1 100644 --- a/src/api/Nhs.Appointments.Api/Functions/HttpFunctions/SiteBasedResourceFunction.cs +++ b/src/api/Nhs.Appointments.Api/Functions/HttpFunctions/SiteBasedResourceFunction.cs @@ -15,14 +15,15 @@ public abstract class SiteBasedResourceFunction(IValidator errors, SiteBasedResourceRequest request)> ReadRequestAsync(HttpRequest req) { var requestedScope = req.Query.Keys.Contains("scope") ? req.Query["scope"].ToString() : "*"; + var requestedIgnoreCache = req.Query.Keys.Contains("ignoreCache") && bool.Parse(req.Query["ignoreCache"]); if (req.Query.Keys.Contains("site")) { var site = req.Query["site"]; - return Task.FromResult((ErrorMessageResponseItem.None, new SiteBasedResourceRequest(site, requestedScope))); + return Task.FromResult((ErrorMessageResponseItem.None, new SiteBasedResourceRequest(site, requestedIgnoreCache, requestedScope))); } var siteId = RestUriHelper.GetResourceIdFromPath(req.Path.ToUriComponent(), "sites"); - return Task.FromResult((ErrorMessageResponseItem.None, new SiteBasedResourceRequest(siteId, requestedScope))); + return Task.FromResult((ErrorMessageResponseItem.None, new SiteBasedResourceRequest(siteId, requestedIgnoreCache, requestedScope))); } } diff --git a/src/api/Nhs.Appointments.Api/Models/SiteBasedResourceRequest.cs b/src/api/Nhs.Appointments.Api/Models/SiteBasedResourceRequest.cs index 3229c5304..500574f14 100644 --- a/src/api/Nhs.Appointments.Api/Models/SiteBasedResourceRequest.cs +++ b/src/api/Nhs.Appointments.Api/Models/SiteBasedResourceRequest.cs @@ -1,3 +1,3 @@ namespace Nhs.Appointments.Api.Models; -public record SiteBasedResourceRequest(string Site, string Scope); +public record SiteBasedResourceRequest(string Site, bool IgnoreCache, string Scope); diff --git a/src/api/Nhs.Appointments.Api/Notifications/UserRolesChangedNotifier.cs b/src/api/Nhs.Appointments.Api/Notifications/UserRolesChangedNotifier.cs index 023b88d26..f332828e5 100644 --- a/src/api/Nhs.Appointments.Api/Notifications/UserRolesChangedNotifier.cs +++ b/src/api/Nhs.Appointments.Api/Notifications/UserRolesChangedNotifier.cs @@ -34,7 +34,7 @@ public async Task Notify(string eventType, string user, string siteId, string[] var rolesAddedNames = GetRoleNames(roles, rolesAdded); var rolesRemovedNames = GetRoleNames(roles, rolesRemoved); - var site = await siteService.GetSiteByIdAsync(siteId, "*"); + var site = await siteService.GetSiteByIdAsync(siteId); var siteName = site == null ? $"Unknown site ({siteId})" : site.Name; var templateValues = new Dictionary diff --git a/src/api/Nhs.Appointments.Core/Availability/IAvailabilityStore.cs b/src/api/Nhs.Appointments.Core/Availability/IAvailabilityStore.cs index 1b214bc3f..136591059 100644 --- a/src/api/Nhs.Appointments.Core/Availability/IAvailabilityStore.cs +++ b/src/api/Nhs.Appointments.Core/Availability/IAvailabilityStore.cs @@ -7,7 +7,7 @@ Task ApplyAvailabilityTemplate(string site, DateOnly date, Session[] sessions, A Session sessionToEdit = null); Task> GetDailyAvailability(string site, DateOnly from, DateOnly to); Task CancelSession(string site, DateOnly date, Session session); - Task SiteSupportsAllServicesOnSingleDateInRangeAsync(string siteId, List services, List datesInPeriod); + Task SiteSupportsAllServicesOnSingleDateInRangeAsync(string siteId, List services, DateOnly from, DateOnly until); Task CancelDayAsync(string site, DateOnly date); Task EditSessionsAsync(string site, DateOnly from, DateOnly until, Session sessionMatcher, Session sessionReplacement); Task CancelMultipleSessions(string site, DateOnly from, DateOnly until, Session sessionMatcher = null); diff --git a/src/api/Nhs.Appointments.Core/Bookings/IReferenceNumberDocumentStore.cs b/src/api/Nhs.Appointments.Core/Bookings/IReferenceNumberDocumentStore.cs new file mode 100644 index 000000000..a1bbe5494 --- /dev/null +++ b/src/api/Nhs.Appointments.Core/Bookings/IReferenceNumberDocumentStore.cs @@ -0,0 +1,7 @@ +namespace Nhs.Appointments.Core.Bookings; + +public interface IReferenceNumberDocumentStore +{ + Task AssignReferenceGroup(); + Task GetNextSequenceNumber(int prefix); +} diff --git a/src/api/Nhs.Appointments.Core/Bookings/ReferenceNumberProvider.cs b/src/api/Nhs.Appointments.Core/Bookings/ReferenceNumberProvider.cs index dc759108c..07f3470dd 100644 --- a/src/api/Nhs.Appointments.Core/Bookings/ReferenceNumberProvider.cs +++ b/src/api/Nhs.Appointments.Core/Bookings/ReferenceNumberProvider.cs @@ -1,3 +1,4 @@ +using Nhs.Appointments.Core.Caching; using Nhs.Appointments.Core.Sites; namespace Nhs.Appointments.Core.Bookings; @@ -9,37 +10,51 @@ public interface IReferenceNumberProvider public class ReferenceNumberProvider : IReferenceNumberProvider { - private readonly ISiteStore _siteStore; + private readonly ISiteService _siteService; + private readonly ICacheService _cacheService; private readonly IReferenceNumberDocumentStore _referenceNumberDocumentStore; private readonly TimeProvider _timeProvider; public ReferenceNumberProvider( - ISiteStore siteStore, + ISiteService siteService, + ICacheService cacheService, IReferenceNumberDocumentStore referenceNumberDocumentStore, TimeProvider timeProvider) { - _siteStore = siteStore; + _siteService = siteService; + _cacheService = cacheService; _referenceNumberDocumentStore = referenceNumberDocumentStore; _timeProvider = timeProvider; } public async Task GetReferenceNumber(string siteId) - { - var referenceGroup = await _siteStore.GetReferenceNumberGroup(siteId); - if (referenceGroup == 0) - { - referenceGroup = await _referenceNumberDocumentStore.AssignReferenceGroup(); - await _siteStore.AssignPrefix(siteId, referenceGroup); - } + { + var referenceNumberGroup = + await _cacheService.GetCacheValue( + $"site:referenceNumberGroup:{siteId}", + new CacheOptions( + async () => await GetSitesAssignedReferenceGroup(siteId), + TimeSpan.FromHours(24))); - var sequence = await _referenceNumberDocumentStore.GetNextSequenceNumber(referenceGroup); + var sequence = await _referenceNumberDocumentStore.GetNextSequenceNumber(referenceNumberGroup); var now = _timeProvider.GetUtcNow(); var rng = now.Day + now.Second; - return $"{referenceGroup:00}-{rng:00}-{sequence:000000}"; + return $"{referenceNumberGroup:00}-{rng:00}-{sequence:000000}"; } -} + + private async Task GetSitesAssignedReferenceGroup(string siteId) + { + var site = await _siteService.GetSiteByIdAsync(siteId, true); + if (!SiteHasNotBeenAssignedReferenceGroup(site)) + { + return site.ReferenceNumberGroup; + } -public interface IReferenceNumberDocumentStore -{ - Task AssignReferenceGroup(); - Task GetNextSequenceNumber(int prefix); + var referenceGroup = await _referenceNumberDocumentStore.AssignReferenceGroup(); + await _siteService.AssignPrefix(siteId, referenceGroup); + + return referenceGroup; + + } + + private static bool SiteHasNotBeenAssignedReferenceGroup(Site site) => site.ReferenceNumberGroup == 0; } diff --git a/src/api/Nhs.Appointments.Core/ServiceRegistration.cs b/src/api/Nhs.Appointments.Core/ServiceRegistration.cs index 05b360393..0570b2b24 100644 --- a/src/api/Nhs.Appointments.Core/ServiceRegistration.cs +++ b/src/api/Nhs.Appointments.Core/ServiceRegistration.cs @@ -30,6 +30,8 @@ public static IServiceCollection ConfigureSiteService(this IServiceCollection se opts.AllSitesSlidingCacheEnabled = configuration.GetValue("ALLSITES_SLIDING_CACHE_ENABLED", true); opts.AllSitesCacheDurationMinutes = configuration.GetValue("ALLSITES_CACHE_DURATION_MINUTES", 60); opts.AllSitesSlideCacheDurationMinutes = configuration.GetValue("ALLSITES_SLIDING_CACHE_DURATION_MINUTES", 20); + opts.SiteCacheDurationMinutes = configuration.GetValue("SITE_CACHE_DURATION_MINUTES", 5); + opts.SiteSlideCacheDurationMinutes = configuration.GetValue("SITE_SLIDING_CACHE_DURATION_MINUTES", 1); opts.DisableSiteCache = configuration.GetValue("DISABLE_SITE_CACHE", false); //default 4 hours opts.SiteSupportsServiceSlidingCacheAbsoluteExpirationSeconds = configuration.GetValue("SITE_SUPPORTS_SERVICE_SLIDING_CACHE_ABSOLUTE_EXPIRATION_SECONDS", 14400); diff --git a/src/api/Nhs.Appointments.Core/Sites/ISiteStore.cs b/src/api/Nhs.Appointments.Core/Sites/ISiteStore.cs index 5a3758761..4ea0f4d79 100644 --- a/src/api/Nhs.Appointments.Core/Sites/ISiteStore.cs +++ b/src/api/Nhs.Appointments.Core/Sites/ISiteStore.cs @@ -14,7 +14,6 @@ Task UpdateSiteDetails(string siteId, string name, string addre Task UpdateSiteReferenceDetails(string siteId, string odsCode, string icb, string region); Task AssignPrefix(string site, int prefix); - Task GetReferenceNumberGroup(string site); Task> GetAllSites(); Task SaveSiteAsync(string siteId, string odsCode, string name, string address, string phoneNumber, diff --git a/src/api/Nhs.Appointments.Core/Sites/Site.cs b/src/api/Nhs.Appointments.Core/Sites/Site.cs index 335193b38..09c194cb8 100644 --- a/src/api/Nhs.Appointments.Core/Sites/Site.cs +++ b/src/api/Nhs.Appointments.Core/Sites/Site.cs @@ -18,13 +18,17 @@ public record Site( [JsonProperty("location")] Location location, [JsonProperty("status")] SiteStatus? status, [JsonProperty("isDeleted")] bool? isDeleted, - [JsonProperty("type")] string Type + [JsonProperty("type")] string Type, + int ReferenceNumberGroup ) { public IEnumerable Accessibilities { get; set; } = Accessibilities?.Select(a => new Accessibility(a.Id, a.Value.ToLower())); private Location Location { get; } = location; + [JsonIgnore] + public int ReferenceNumberGroup { get; } = ReferenceNumberGroup; + public Coordinates Coordinates { get diff --git a/src/api/Nhs.Appointments.Core/Sites/SiteService.cs b/src/api/Nhs.Appointments.Core/Sites/SiteService.cs index 9797f8892..184c91bd4 100644 --- a/src/api/Nhs.Appointments.Core/Sites/SiteService.cs +++ b/src/api/Nhs.Appointments.Core/Sites/SiteService.cs @@ -10,7 +10,7 @@ namespace Nhs.Appointments.Core.Sites; public interface ISiteService { - Task GetSiteByIdAsync(string siteId, string scope = "*"); + Task GetSiteByIdAsync(string siteId, bool ignoreCache = false, string scope = "*"); Task> GetSitesPreview(bool includeDeleted = false); Task> GetAllSites(bool includeDeleted = false, bool ignoreCache = false); Task UpdateAccessibilities(string siteId, IEnumerable accessibilities); @@ -30,6 +30,8 @@ Task SaveSiteAsync(string siteId, string odsCode, string name, Task> GetSitesInIcbAsync(string icb); Task> QuerySitesAsync(SiteFilter[] filters, int maxRecords, bool ignoreCache); Task ToggleSiteSoftDeletionAsync(string siteId); + + Task AssignPrefix(string site, int prefix); } public class SiteService( @@ -133,9 +135,24 @@ private static List GetDateStringsInRange(DateOnly from, DateOnly to) return result; } - public async Task GetSiteByIdAsync(string siteId, string scope = "*") + public async Task GetSiteByIdAsync(string siteId, bool ignoreCache = false, string scope = "*") { - var site = await siteStore.GetSiteById(siteId); + Site site; + if (options.Value.DisableSiteCache || ignoreCache) + { + site = await siteStore.GetSiteById(siteId); + } + else + { + site = await cacheService.GetLazySlidingCacheValue($"site:{siteId}", + new LazySlideCacheOptions( + async () => + await siteStore.GetSiteById(siteId), + TimeSpan.FromMinutes(options.Value.SiteSlideCacheDurationMinutes), + TimeSpan.FromMinutes(options.Value.SiteCacheDurationMinutes))); + } + + if (site is null || site.isDeleted is true) { return default; @@ -224,6 +241,11 @@ public async Task ToggleSiteSoftDeletionAsync(string siteId) return await siteStore.ToggleSiteSoftDeletionAsync(siteId); } + public async Task AssignPrefix(string site, int prefix) + { + await siteStore.AssignPrefix(site, prefix); + } + public async Task> QuerySitesAsync(SiteFilter[] filters, int maxRecords, bool ignoreCache) { @@ -414,6 +436,6 @@ private async Task FetchSiteOffersServiceDuringPeriod(string siteId, List< var dateStringsInRange = GetDateStringsInRange(from, until); return await availabilityStore.SiteSupportsAllServicesOnSingleDateInRangeAsync(siteId, services, - dateStringsInRange); + from, until); } } diff --git a/src/api/Nhs.Appointments.Core/Sites/SiteServiceOptions.cs b/src/api/Nhs.Appointments.Core/Sites/SiteServiceOptions.cs index 0ae08ced1..58414d708 100644 --- a/src/api/Nhs.Appointments.Core/Sites/SiteServiceOptions.cs +++ b/src/api/Nhs.Appointments.Core/Sites/SiteServiceOptions.cs @@ -45,4 +45,14 @@ public class SiteServiceOptions /// i.e. when SiteSupportsServiceBatchMultiplier = 2, and maxRecords = 50 - then service will fetch data in batches of 100, until 50 valid sites are returned. /// public int SiteSupportsServiceBatchMultiplier { get; set; } + + /// + /// The duration, in minutes, to cache site for. + /// + public int SiteCacheDurationMinutes { get; set; } + + /// + /// The duration, in minutes, to wait before sliding the cache for a site. + /// + public int SiteSlideCacheDurationMinutes { get; set; } } diff --git a/src/api/Nhs.Appointments.Persistance/AvailabilityDocumentStore.cs b/src/api/Nhs.Appointments.Persistance/AvailabilityDocumentStore.cs index 6f42d0d16..c7db5f9c5 100644 --- a/src/api/Nhs.Appointments.Persistance/AvailabilityDocumentStore.cs +++ b/src/api/Nhs.Appointments.Persistance/AvailabilityDocumentStore.cs @@ -95,31 +95,15 @@ public async Task CancelSession(string site, DateOnly date, Ses }; } - public async Task SiteSupportsAllServicesOnSingleDateInRangeAsync(string siteId, List services, List datesInPeriod) + public async Task SiteSupportsAllServicesOnSingleDateInRangeAsync(string siteId, List services, DateOnly from, DateOnly until) { - var docType = documentStore.GetDocumentType(); + var documents = await GetDailyAvailability(siteId, from, until); + var matchingSessions = documents.Where(document => document.Sessions + .SelectMany(s => s.Services) + .Distinct() + .Count(services.Contains) == services.Count); - var query = @" - SELECT VALUE COUNT(1) - FROM booking_data bd - WHERE ARRAY_CONTAINS(@docIds, bd.id) - AND bd.site = @site - AND bd.docType = @docType - AND ARRAY_LENGTH(SETINTERSECT( - ARRAY( - SELECT VALUE svc FROM session IN bd.sessions JOIN svc IN session.services - ), @services)) = @requestedServiceCount"; - - var queryDef = new QueryDefinition(query) - .WithParameter("@docType", docType) - .WithParameter("@docIds", datesInPeriod) - .WithParameter("@site", siteId) - .WithParameter("@services", services.ToArray()) - .WithParameter("@requestedServiceCount", services.Count); - - var dailyAvailabilityCount = (await documentStore.RunSqlQueryAsync(queryDef)).Single(); - - return dailyAvailabilityCount > 0; + return matchingSessions.Any(); } public async Task CancelDayAsync(string site, DateOnly date) diff --git a/src/api/Nhs.Appointments.Persistance/CoreReferenceGroupCosmosDocumentStore.cs b/src/api/Nhs.Appointments.Persistance/CoreReferenceGroupCosmosDocumentStore.cs new file mode 100644 index 000000000..37245caea --- /dev/null +++ b/src/api/Nhs.Appointments.Persistance/CoreReferenceGroupCosmosDocumentStore.cs @@ -0,0 +1,73 @@ +using Microsoft.Azure.Cosmos; +using Microsoft.Extensions.Options; +using Nhs.Appointments.Core.Bookings; +using Nhs.Appointments.Persistance.Models; + +namespace Nhs.Appointments.Persistance +{ + public class CoreReferenceNumberGroupCosmosDocumentStore : IReferenceNumberDocumentStore, ICoreReferenceNumberMigrationDocumentStore + { + private const string DocumentId = "main"; + private readonly ITypedDocumentCosmosStore _cosmosStore; + private readonly ReferenceGroupOptions _options; + + public CoreReferenceNumberGroupCosmosDocumentStore(ITypedDocumentCosmosStore cosmosStore, IOptions options) + { + _cosmosStore = cosmosStore; + _options = options.Value; + } + + public async Task AssignReferenceGroup() + { + var docType = _cosmosStore.GetDocumentType(); + var referenceGroupDocument = await Get(); + + var target = referenceGroupDocument!.Groups.Where(g => g.Prefix > 0).OrderBy(g => g.SiteCount).ThenBy(g => g.Prefix).First(); + var siteCountIncrement = PatchOperation.Increment($"/Groups/{target.Prefix}/SiteCount", 1); + + await _cosmosStore.PatchDocument(docType, DocumentId, siteCountIncrement); + return target.Prefix; + } + + public async Task GetNextSequenceNumber(int prefix) + { + var incrementSequencePatch = PatchOperation.Increment($"/Groups/{prefix}/Sequence", 1); + var docType = _cosmosStore.GetDocumentType(); + var referenceGroupDocument = await _cosmosStore.PatchDocument(docType, DocumentId, incrementSequencePatch); + return referenceGroupDocument.Groups.Single(gr => gr.Prefix == prefix).Sequence; + } + + public async Task Get() + { + CoreReferenceGroupDocument referenceGroupDocument; + var docType = _cosmosStore.GetDocumentType(); + try + { + referenceGroupDocument = await _cosmosStore.GetByIdAsync(DocumentId); + } + catch(CosmosException ex) when (ex.StatusCode == System.Net.HttpStatusCode.NotFound) + { + referenceGroupDocument = new CoreReferenceGroupDocument + { + DocumentType = docType, + Id = DocumentId, + Groups = Enumerable.Range(0, _options.InitialGroupCount).Select(x => new ReferenceGroup + { + Prefix = x, + Sequence = 0, + SiteCount = 0 + }).ToArray() + }; + + await _cosmosStore.WriteAsync(referenceGroupDocument); + } + + return referenceGroupDocument; + } + } + + public class ReferenceGroupOptions + { + public int InitialGroupCount { get; set; } + } +} diff --git a/src/api/Nhs.Appointments.Persistance/ICoreReferenceNumberMigrationDocumentStore.cs b/src/api/Nhs.Appointments.Persistance/ICoreReferenceNumberMigrationDocumentStore.cs new file mode 100644 index 000000000..2e28db79a --- /dev/null +++ b/src/api/Nhs.Appointments.Persistance/ICoreReferenceNumberMigrationDocumentStore.cs @@ -0,0 +1,8 @@ +using Nhs.Appointments.Persistance.Models; + +namespace Nhs.Appointments.Persistance; + +public interface ICoreReferenceNumberMigrationDocumentStore +{ + Task Get(); +} diff --git a/src/api/Nhs.Appointments.Persistance/Models/GeneralCosmosDocument.cs b/src/api/Nhs.Appointments.Persistance/Models/GeneralCosmosDocument.cs index 15684c1d4..1b28bdc35 100644 --- a/src/api/Nhs.Appointments.Persistance/Models/GeneralCosmosDocument.cs +++ b/src/api/Nhs.Appointments.Persistance/Models/GeneralCosmosDocument.cs @@ -33,6 +33,12 @@ public class CoreDataCosmosDocument : LastUpdatedByCosmosDocument } +[CosmosDocument("booking_reference_data", "docType")] +public class BookingReferenceDataCosmosDocument : TypedCosmosDocument +{ + +} + [CosmosDocument("aggregated_data", "date")] public class AggregatedDataCosmosDocument : TypedCosmosDocument { diff --git a/src/api/Nhs.Appointments.Persistance/Models/ReferenceGroupDocument.cs b/src/api/Nhs.Appointments.Persistance/Models/ReferenceGroupDocument.cs index a1e22c0bb..04c1bd25d 100644 --- a/src/api/Nhs.Appointments.Persistance/Models/ReferenceGroupDocument.cs +++ b/src/api/Nhs.Appointments.Persistance/Models/ReferenceGroupDocument.cs @@ -1,11 +1,18 @@ namespace Nhs.Appointments.Persistance.Models; [CosmosDocumentType("reference_group")] -public class ReferenceGroupDocument : CoreDataCosmosDocument +public class CoreReferenceGroupDocument : CoreDataCosmosDocument { public ReferenceGroup[] Groups { get; set; } } +[CosmosDocumentType("reference_group")] +public class BookingReferenceGroupDocument : BookingReferenceDataCosmosDocument +{ + public int SiteCount { get; set; } + public int Sequence { get; set; } +} + public class ReferenceGroup { public int Prefix { get; set; } diff --git a/src/api/Nhs.Appointments.Persistance/ReferenceGroupCosmosDocumentStore.cs b/src/api/Nhs.Appointments.Persistance/ReferenceGroupCosmosDocumentStore.cs index f8e55c6ea..b6b611d90 100644 --- a/src/api/Nhs.Appointments.Persistance/ReferenceGroupCosmosDocumentStore.cs +++ b/src/api/Nhs.Appointments.Persistance/ReferenceGroupCosmosDocumentStore.cs @@ -1,5 +1,4 @@ using Microsoft.Azure.Cosmos; -using Microsoft.Extensions.Options; using Nhs.Appointments.Core.Bookings; using Nhs.Appointments.Persistance.Models; @@ -7,59 +6,78 @@ namespace Nhs.Appointments.Persistance { public class ReferenceGroupCosmosDocumentStore : IReferenceNumberDocumentStore { - private const string DocumentId = "main"; - private readonly ITypedDocumentCosmosStore _cosmosStore; - private readonly ReferenceGroupOptions _options; + private readonly ITypedDocumentCosmosStore _cosmosStore; + private readonly ICoreReferenceNumberMigrationDocumentStore _numberMigrationDocumentStore; - public ReferenceGroupCosmosDocumentStore(ITypedDocumentCosmosStore cosmosStore, IOptions options) + public ReferenceGroupCosmosDocumentStore( + ITypedDocumentCosmosStore cosmosStore, + ICoreReferenceNumberMigrationDocumentStore numberMigrationDocumentStore) { _cosmosStore = cosmosStore; - _options = options.Value; + _numberMigrationDocumentStore = numberMigrationDocumentStore; } public async Task AssignReferenceGroup() { - ReferenceGroupDocument referenceGroupDocument; + IEnumerable referenceGroupDocuments; var docType = _cosmosStore.GetDocumentType(); + + referenceGroupDocuments = (await _cosmosStore.RunQueryAsync(x => x.DocumentType == docType)).ToArray(); + + if (!referenceGroupDocuments.Any()) + { + referenceGroupDocuments = await MigrateFromAllOldDocument(); + } + + var target = referenceGroupDocuments.Where(g => g.Id != 0.ToString()).OrderBy(g => g.SiteCount).ThenBy(g => g.Id).First(); + var siteCountIncrement = PatchOperation.Increment($"/SiteCount", 1); + + await _cosmosStore.PatchDocument(docType, target.Id, siteCountIncrement); + return int.Parse(target.Id); + } + + public async Task GetNextSequenceNumber(int prefix) + { + var incrementSequencePatch = PatchOperation.Increment($"/Sequence", 1); + var docType = _cosmosStore.GetDocumentType(); + BookingReferenceGroupDocument referenceGroupDocument; try { - referenceGroupDocument = await _cosmosStore.GetByIdAsync("main"); + referenceGroupDocument = await _cosmosStore.PatchDocument(docType, prefix.ToString(), incrementSequencePatch); } catch(CosmosException ex) when (ex.StatusCode == System.Net.HttpStatusCode.NotFound) { - referenceGroupDocument = new ReferenceGroupDocument - { - DocumentType = docType, - Id = DocumentId, - Groups = Enumerable.Range(0, _options.InitialGroupCount).Select(x => new ReferenceGroup - { - Prefix = x, - Sequence = 0, - SiteCount = 0 - }).ToArray() - }; - - await _cosmosStore.WriteAsync(referenceGroupDocument); + await MigrateFromAllOldDocument(); + referenceGroupDocument = await _cosmosStore.PatchDocument(docType, prefix.ToString(), incrementSequencePatch); } - var target = referenceGroupDocument!.Groups.Where(g => g.Prefix > 0).OrderBy(g => g.SiteCount).ThenBy(g => g.Prefix).First(); - var siteCountIncrement = PatchOperation.Increment($"/Groups/{target.Prefix}/SiteCount", 1); - - await _cosmosStore.PatchDocument(docType, DocumentId, siteCountIncrement); - return target.Prefix; + return referenceGroupDocument.Sequence; } - public async Task GetNextSequenceNumber(int prefix) + private async Task> MigrateFromAllOldDocument() { - var incrementSequencePatch = PatchOperation.Increment($"/Groups/{prefix}/Sequence", 1); + // Acquire a lock + // Check has migration happened already? + // YES - return + // No - migrate + // Release lock var docType = _cosmosStore.GetDocumentType(); - var referenceGroupDocument = await _cosmosStore.PatchDocument(docType, DocumentId, incrementSequencePatch); - return referenceGroupDocument.Groups.Single(gr => gr.Prefix == prefix).Sequence; - } - } + var oldDocument = await _numberMigrationDocumentStore.Get(); - public class ReferenceGroupOptions - { - public int InitialGroupCount { get; set; } + var referenceGroupDocuments = oldDocument.Groups.Select(g => new BookingReferenceGroupDocument + { + DocumentType = docType, + Id = g.Prefix.ToString(), + Sequence = g.Sequence, + SiteCount = g.SiteCount, + }).ToList(); + + foreach (var referenceGroupDocument in referenceGroupDocuments) + { + await _cosmosStore.WriteAsync(referenceGroupDocument); + } + + return referenceGroupDocuments; + } } } diff --git a/src/api/Nhs.Appointments.Persistance/ServiceRegistration.cs b/src/api/Nhs.Appointments.Persistance/ServiceRegistration.cs index 3612756c3..919a51975 100644 --- a/src/api/Nhs.Appointments.Persistance/ServiceRegistration.cs +++ b/src/api/Nhs.Appointments.Persistance/ServiceRegistration.cs @@ -41,6 +41,7 @@ public static IServiceCollection AddDocumentStores(this IServiceCollection servi .AddScoped() .AddScoped() .AddScoped() + .AddScoped() .AddScoped() .AddScoped() .AddScoped() diff --git a/src/api/Nhs.Appointments.Persistance/SiteStore.cs b/src/api/Nhs.Appointments.Persistance/SiteStore.cs index 0878a5bfb..00343ec6a 100644 --- a/src/api/Nhs.Appointments.Persistance/SiteStore.cs +++ b/src/api/Nhs.Appointments.Persistance/SiteStore.cs @@ -16,12 +16,6 @@ public async Task GetSiteById(string siteId) public async Task> GetAllSites() => await cosmosStore.RunQueryAsync(sd => sd.DocumentType == "site"); - public async Task GetReferenceNumberGroup(string site) - { - var siteDocument = await cosmosStore.GetDocument(site); - return siteDocument.ReferenceNumberGroup; - } - public async Task UpdateSiteReferenceDetails(string siteId, string odsCode, string icb, string region) { var originalDocument = await GetOrDefault(siteId); diff --git a/src/client/src/app/lib/services/appointmentsService.ts b/src/client/src/app/lib/services/appointmentsService.ts index 7bacfa5a5..585be8bb3 100644 --- a/src/client/src/app/lib/services/appointmentsService.ts +++ b/src/client/src/app/lib/services/appointmentsService.ts @@ -141,9 +141,10 @@ export const fetchUsers = async ( export const fetchSite = async ( siteId: string, + ignoreCache: boolean, ): Promise> => appointmentsApi - .get(`sites/${siteId}?scope=*`, { + .get(`sites/${siteId}?ignoreCache=${ignoreCache}&scope=*`, { next: { tags: ['site'] }, }) .then(response => handleBodyResponse(response)); diff --git a/src/client/src/app/site/[site]/appointment/[reference]/cancel/page.tsx b/src/client/src/app/site/[site]/appointment/[reference]/cancel/page.tsx index 9c593fbd6..6e9317dd7 100644 --- a/src/client/src/app/site/[site]/appointment/[reference]/cancel/page.tsx +++ b/src/client/src/app/site/[site]/appointment/[reference]/cancel/page.tsx @@ -24,7 +24,7 @@ const Page = async ({ params }: PageProps) => { await fromServer(assertPermission(siteFromPath, 'booking:cancel')); const [site, booking, clinicalServices] = await Promise.all([ - fromServer(fetchSite(siteFromPath)), + fromServer(fetchSite(siteFromPath, false)), fromServer(fetchBooking(reference, siteFromPath)), fromServer(fetchClinicalServices()), ]); diff --git a/src/client/src/app/site/[site]/availability/cancel/confirmation/page.tsx b/src/client/src/app/site/[site]/availability/cancel/confirmation/page.tsx index b7a4fa943..a1eaf490f 100644 --- a/src/client/src/app/site/[site]/availability/cancel/confirmation/page.tsx +++ b/src/client/src/app/site/[site]/availability/cancel/confirmation/page.tsx @@ -30,7 +30,7 @@ const Page = async ({ searchParams, params }: PageProps) => { await assertPermission(siteFromPath, 'availability:setup'); const parsedDate = parseToUkDatetime(date); - const site = await fromServer(fetchSite(siteFromPath)); + const site = await fromServer(fetchSite(siteFromPath, false)); const sessionSummary: SessionSummary = JSON.parse(atob(session)); const availabilityRequest: AvailabilityChangeProposalRequest = { from: date, diff --git a/src/client/src/app/site/[site]/availability/cancel/confirmed/page.tsx b/src/client/src/app/site/[site]/availability/cancel/confirmed/page.tsx index b748f3b62..53c0fd897 100644 --- a/src/client/src/app/site/[site]/availability/cancel/confirmed/page.tsx +++ b/src/client/src/app/site/[site]/availability/cancel/confirmed/page.tsx @@ -49,7 +49,7 @@ const Page = async ({ searchParams, params }: PageProps) => { } const [site, clinicalServices] = await Promise.all([ - fromServer(fetchSite(siteFromPath)), + fromServer(fetchSite(siteFromPath, false)), fromServer(fetchClinicalServices()), ]); diff --git a/src/client/src/app/site/[site]/availability/cancel/page.tsx b/src/client/src/app/site/[site]/availability/cancel/page.tsx index 89f7d5c8c..e0bd7b244 100644 --- a/src/client/src/app/site/[site]/availability/cancel/page.tsx +++ b/src/client/src/app/site/[site]/availability/cancel/page.tsx @@ -30,7 +30,7 @@ const Page = async ({ searchParams, params }: PageProps) => { await fromServer(assertPermission(siteFromPath, 'availability:setup')); const [site, clinicalServices] = await Promise.all([ - fromServer(fetchSite(siteFromPath)), + fromServer(fetchSite(siteFromPath, false)), fromServer(fetchClinicalServices()), ]); diff --git a/src/client/src/app/site/[site]/availability/edit-services/confirmation/page.tsx b/src/client/src/app/site/[site]/availability/edit-services/confirmation/page.tsx index e2c29b3e6..32674daa8 100644 --- a/src/client/src/app/site/[site]/availability/edit-services/confirmation/page.tsx +++ b/src/client/src/app/site/[site]/availability/edit-services/confirmation/page.tsx @@ -47,7 +47,7 @@ const Page = async ({ searchParams, params }: PageProps) => { await assertPermission(siteFromPath, 'availability:setup'); const parsedDate = parseToUkDatetime(date); - const site = await fromServer(fetchSite(siteFromPath)); + const site = await fromServer(fetchSite(siteFromPath, false)); const sessionSummary: SessionSummary = JSON.parse(atob(session)); const removedServicesSessionDetails: AvailabilitySession = JSON.parse( atob(removedServicesSession), diff --git a/src/client/src/app/site/[site]/availability/edit-services/confirmed/page.tsx b/src/client/src/app/site/[site]/availability/edit-services/confirmed/page.tsx index 4273ce113..682f1f866 100644 --- a/src/client/src/app/site/[site]/availability/edit-services/confirmed/page.tsx +++ b/src/client/src/app/site/[site]/availability/edit-services/confirmed/page.tsx @@ -45,7 +45,7 @@ const Page = async ({ searchParams, params }: PageProps) => { await fromServer(assertPermission(siteFromPath, 'availability:setup')); const [site, clinicalServices] = await Promise.all([ - fromServer(fetchSite(siteFromPath)), + fromServer(fetchSite(siteFromPath, false)), fromServer(fetchClinicalServices()), ]); diff --git a/src/client/src/app/site/[site]/availability/edit-services/no-notifications/page.tsx b/src/client/src/app/site/[site]/availability/edit-services/no-notifications/page.tsx index 3cb0e97cc..b5c2f1cad 100644 --- a/src/client/src/app/site/[site]/availability/edit-services/no-notifications/page.tsx +++ b/src/client/src/app/site/[site]/availability/edit-services/no-notifications/page.tsx @@ -43,7 +43,7 @@ const Page = async ({ params, searchParams }: PageProps) => { }; const [site, cancelledBookings, clinicalServices] = await Promise.all([ - fromServer(fetchSite(siteFromPath)), + fromServer(fetchSite(siteFromPath, false)), fromServer(fetchBookings(fetchBookingsRequest, ['Cancelled'])), fromServer(fetchClinicalServices()), ]); diff --git a/src/client/src/app/site/[site]/availability/edit-services/page.tsx b/src/client/src/app/site/[site]/availability/edit-services/page.tsx index 198cf5888..1fda3dcf1 100644 --- a/src/client/src/app/site/[site]/availability/edit-services/page.tsx +++ b/src/client/src/app/site/[site]/availability/edit-services/page.tsx @@ -31,7 +31,7 @@ const Page = async ({ searchParams, params }: PageProps) => { await fromServer(assertPermission(siteFromPath, 'availability:setup')); const [site, clinicalServices] = await Promise.all([ - fromServer(fetchSite(siteFromPath)), + fromServer(fetchSite(siteFromPath, false)), fromServer(fetchClinicalServices()), ]); diff --git a/src/client/src/app/site/[site]/availability/edit/confirmation/page.tsx b/src/client/src/app/site/[site]/availability/edit/confirmation/page.tsx index 732c60291..715609648 100644 --- a/src/client/src/app/site/[site]/availability/edit/confirmation/page.tsx +++ b/src/client/src/app/site/[site]/availability/edit/confirmation/page.tsx @@ -45,7 +45,7 @@ const Page = async ({ searchParams, params }: PageProps) => { await assertPermission(siteFromPath, 'availability:setup'); const parsedDate = parseToUkDatetime(date); - const site = await fromServer(fetchSite(siteFromPath)); + const site = await fromServer(fetchSite(siteFromPath, false)); const sessionSummary: SessionSummary = JSON.parse(atob(session)); const newSessionDetails: Session = JSON.parse(atob(sessionToEdit)); const newSessionSummary: SessionSummary = { diff --git a/src/client/src/app/site/[site]/availability/edit/confirmed/page.tsx b/src/client/src/app/site/[site]/availability/edit/confirmed/page.tsx index cda2f5f85..acfcd1f2b 100644 --- a/src/client/src/app/site/[site]/availability/edit/confirmed/page.tsx +++ b/src/client/src/app/site/[site]/availability/edit/confirmed/page.tsx @@ -46,7 +46,7 @@ const Page = async ({ searchParams, params }: PageProps) => { await fromServer(assertPermission(siteFromPath, 'availability:setup')); const [site, clinicalServices] = await Promise.all([ - fromServer(fetchSite(siteFromPath)), + fromServer(fetchSite(siteFromPath, false)), fromServer(fetchClinicalServices()), ]); diff --git a/src/client/src/app/site/[site]/availability/edit/edit-start-time/page.tsx b/src/client/src/app/site/[site]/availability/edit/edit-start-time/page.tsx index b40cca3dd..fd3710fac 100644 --- a/src/client/src/app/site/[site]/availability/edit/edit-start-time/page.tsx +++ b/src/client/src/app/site/[site]/availability/edit/edit-start-time/page.tsx @@ -32,7 +32,7 @@ const Page = async ({ searchParams, params }: PageProps) => { await fromServer(assertPermission(siteFromPath, 'availability:setup')); const parsedDate = parseToUkDatetime(date); - const site = await fromServer(fetchSite(siteFromPath)); + const site = await fromServer(fetchSite(siteFromPath, false)); const existing: SessionSummary = JSON.parse(atob(existingSession)); const updated: AvailabilitySession = JSON.parse(atob(updatedSession)); diff --git a/src/client/src/app/site/[site]/availability/edit/no-notifications/page.tsx b/src/client/src/app/site/[site]/availability/edit/no-notifications/page.tsx index 3cb0e97cc..b5c2f1cad 100644 --- a/src/client/src/app/site/[site]/availability/edit/no-notifications/page.tsx +++ b/src/client/src/app/site/[site]/availability/edit/no-notifications/page.tsx @@ -43,7 +43,7 @@ const Page = async ({ params, searchParams }: PageProps) => { }; const [site, cancelledBookings, clinicalServices] = await Promise.all([ - fromServer(fetchSite(siteFromPath)), + fromServer(fetchSite(siteFromPath, false)), fromServer(fetchBookings(fetchBookingsRequest, ['Cancelled'])), fromServer(fetchClinicalServices()), ]); diff --git a/src/client/src/app/site/[site]/availability/edit/page.tsx b/src/client/src/app/site/[site]/availability/edit/page.tsx index f8fc9eb27..99cfe9735 100644 --- a/src/client/src/app/site/[site]/availability/edit/page.tsx +++ b/src/client/src/app/site/[site]/availability/edit/page.tsx @@ -26,7 +26,7 @@ const Page = async ({ searchParams, params }: PageProps) => { await fromServer(assertPermission(siteFromPath, 'availability:setup')); const parsedDate = parseToUkDatetime(date); - const site = await fromServer(fetchSite(siteFromPath)); + const site = await fromServer(fetchSite(siteFromPath, false)); const sessionSummary: SessionSummary = JSON.parse(atob(session)); diff --git a/src/client/src/app/site/[site]/cancel-day/cancelled-appointments/page.tsx b/src/client/src/app/site/[site]/cancel-day/cancelled-appointments/page.tsx index f061cc054..445b84d76 100644 --- a/src/client/src/app/site/[site]/cancel-day/cancelled-appointments/page.tsx +++ b/src/client/src/app/site/[site]/cancel-day/cancelled-appointments/page.tsx @@ -45,7 +45,7 @@ const Page = async ({ params, searchParams }: PageProps) => { }; const [site, bookings, clinicalServices] = await Promise.all([ - fromServer(fetchSite(siteFromPath)), + fromServer(fetchSite(siteFromPath, false)), fromServer(fetchBookings(fetchBookingsRequest, ['Cancelled'])), fromServer(fetchClinicalServices()), ]); diff --git a/src/client/src/app/site/[site]/cancel-day/confirmed/page.tsx b/src/client/src/app/site/[site]/cancel-day/confirmed/page.tsx index afece712c..822f46c49 100644 --- a/src/client/src/app/site/[site]/cancel-day/confirmed/page.tsx +++ b/src/client/src/app/site/[site]/cancel-day/confirmed/page.tsx @@ -28,7 +28,7 @@ const Page = async ({ searchParams, params }: PageProps) => { notFound(); } - const site = await fromServer(fetchSite(siteFromPath)); + const site = await fromServer(fetchSite(siteFromPath, false)); const dayCancellationSummary: CancelDayResponse = { cancelledBookingCount: cancelledBookingCount ?? 0, diff --git a/src/client/src/app/site/[site]/cancel-day/page.tsx b/src/client/src/app/site/[site]/cancel-day/page.tsx index f468055dc..569f7809f 100644 --- a/src/client/src/app/site/[site]/cancel-day/page.tsx +++ b/src/client/src/app/site/[site]/cancel-day/page.tsx @@ -30,7 +30,7 @@ const Page = async ({ searchParams, params }: PageProps) => { const [daySummary, site, clinicalServices] = await Promise.all([ fromServer(fetchDaySummary(siteFromPath, date)), - fromServer(fetchSite(siteFromPath)), + fromServer(fetchSite(siteFromPath, false)), fromServer(fetchClinicalServices()), ]); diff --git a/src/client/src/app/site/[site]/create-availability/page.tsx b/src/client/src/app/site/[site]/create-availability/page.tsx index 6c7f58dad..abfc304e0 100644 --- a/src/client/src/app/site/[site]/create-availability/page.tsx +++ b/src/client/src/app/site/[site]/create-availability/page.tsx @@ -18,7 +18,7 @@ const Page = async ({ params }: PageProps) => { const { site: siteFromPath } = { ...(await params) }; const [site, cancelADateRange, sitePermissions] = await Promise.all([ - fromServer(fetchSite(siteFromPath)), + fromServer(fetchSite(siteFromPath, false)), fromServer(fetchFeatureFlag('CancelADateRange')), fromServer(fetchPermissions(siteFromPath)), ]); diff --git a/src/client/src/app/site/[site]/create-availability/wizard/page.tsx b/src/client/src/app/site/[site]/create-availability/wizard/page.tsx index fac9de21e..d893ceeed 100644 --- a/src/client/src/app/site/[site]/create-availability/wizard/page.tsx +++ b/src/client/src/app/site/[site]/create-availability/wizard/page.tsx @@ -23,7 +23,7 @@ const Page = async ({ params, searchParams }: PageProps) => { await fromServer(assertPermission(siteFromPath, 'availability:setup')); const [site, clinicalServices] = await Promise.all([ - fromServer(fetchSite(siteFromPath)), + fromServer(fetchSite(siteFromPath, false)), fromServer(fetchClinicalServices()), ]); diff --git a/src/client/src/app/site/[site]/details/edit-accessibilities/edit-accessibilities-page.tsx b/src/client/src/app/site/[site]/details/edit-accessibilities/edit-accessibilities-page.tsx index 688cf13e3..75add7b20 100644 --- a/src/client/src/app/site/[site]/details/edit-accessibilities/edit-accessibilities-page.tsx +++ b/src/client/src/app/site/[site]/details/edit-accessibilities/edit-accessibilities-page.tsx @@ -17,7 +17,7 @@ const EditAccessibilitiesPage = async ({ site }: Props) => { const accessibilityAccessibilityDefinitions = AccessibilityDefinitions.filter( ad => ad.id.startsWith('accessibility'), ); - const siteDetails = await fromServer(fetchSite(site)); + const siteDetails = await fromServer(fetchSite(site, true)); return ( <> diff --git a/src/client/src/app/site/[site]/details/edit-accessibilities/site-accessibilities-page.test.tsx b/src/client/src/app/site/[site]/details/edit-accessibilities/site-accessibilities-page.test.tsx index fc8dbcebf..0fe8d2e92 100644 --- a/src/client/src/app/site/[site]/details/edit-accessibilities/site-accessibilities-page.test.tsx +++ b/src/client/src/app/site/[site]/details/edit-accessibilities/site-accessibilities-page.test.tsx @@ -79,7 +79,7 @@ describe('Manage Accessibilities Page', () => { permissions: mockPermissions, }); render(jsx); - expect(fetchSite).toHaveBeenCalledWith('TEST'); + expect(fetchSite).toHaveBeenCalledWith('TEST', true); }); it('passes props to form component', async () => { diff --git a/src/client/src/app/site/[site]/details/edit-details/edit-details-page.tsx b/src/client/src/app/site/[site]/details/edit-details/edit-details-page.tsx index 9f979df20..1c4a49c41 100644 --- a/src/client/src/app/site/[site]/details/edit-details/edit-details-page.tsx +++ b/src/client/src/app/site/[site]/details/edit-details/edit-details-page.tsx @@ -8,7 +8,7 @@ type Props = { }; export const EditDetailsPage = async ({ siteId }: Props) => { - const siteDetails = await fromServer(fetchSite(siteId)); + const siteDetails = await fromServer(fetchSite(siteId, true)); return ( <> diff --git a/src/client/src/app/site/[site]/details/edit-reference-details/edit-reference-details-page.tsx b/src/client/src/app/site/[site]/details/edit-reference-details/edit-reference-details-page.tsx index 38a9d2cdb..9c44475b4 100644 --- a/src/client/src/app/site/[site]/details/edit-reference-details/edit-reference-details-page.tsx +++ b/src/client/src/app/site/[site]/details/edit-reference-details/edit-reference-details-page.tsx @@ -12,7 +12,7 @@ type Props = { export const EditReferenceDetailsPage = async ({ siteId }: Props) => { const [siteDetails, wellKnownOdsCodeEntries] = await Promise.all([ - fromServer(fetchSite(siteId)), + fromServer(fetchSite(siteId, true)), fromServer(fetchWellKnownOdsCodeEntries()), ]); diff --git a/src/client/src/app/site/[site]/details/edit-site-status/edit-site-status-page.tsx b/src/client/src/app/site/[site]/details/edit-site-status/edit-site-status-page.tsx index 956651e8d..a0cf8cab1 100644 --- a/src/client/src/app/site/[site]/details/edit-site-status/edit-site-status-page.tsx +++ b/src/client/src/app/site/[site]/details/edit-site-status/edit-site-status-page.tsx @@ -9,7 +9,7 @@ type Props = { }; export const EditSiteStatusPage = async ({ siteId }: Props) => { - const siteDetails = await fromServer(fetchSite(siteId)); + const siteDetails = await fromServer(fetchSite(siteId, true)); const siteStatus = siteDetails.status; const summaryList: SummaryListItem[] = [ diff --git a/src/client/src/app/site/[site]/details/page.tsx b/src/client/src/app/site/[site]/details/page.tsx index c64d5d595..cfb961744 100644 --- a/src/client/src/app/site/[site]/details/page.tsx +++ b/src/client/src/app/site/[site]/details/page.tsx @@ -22,7 +22,7 @@ const Page = async ({ params }: PageProps) => { ); const [site, wellKnownOdsCodeEntries, sitePermissions] = await Promise.all([ - fromServer(fetchSite(siteFromPath)), + fromServer(fetchSite(siteFromPath, false)), fromServer(fetchWellKnownOdsCodeEntries()), fromServer(fetchPermissions(siteFromPath)), ]); diff --git a/src/client/src/app/site/[site]/details/site-details-page.tsx b/src/client/src/app/site/[site]/details/site-details-page.tsx index ee4d39d5a..eef8312e2 100644 --- a/src/client/src/app/site/[site]/details/site-details-page.tsx +++ b/src/client/src/app/site/[site]/details/site-details-page.tsx @@ -23,7 +23,7 @@ const SiteDetailsPage = async ({ }: Props) => { const [accessibilityDefinitions, site] = await Promise.all([ fromServer(fetchAccessibilityDefinitions()), - fromServer(fetchSite(siteId)), + fromServer(fetchSite(siteId, true)), ]); const siteReferenceSummaryData = mapSiteReferenceSummaryData( diff --git a/src/client/src/app/site/[site]/page.tsx b/src/client/src/app/site/[site]/page.tsx index 5fab418ad..db4038033 100644 --- a/src/client/src/app/site/[site]/page.tsx +++ b/src/client/src/app/site/[site]/page.tsx @@ -29,7 +29,7 @@ const Page = async ({ params }: PageProps) => { const [site, wellKnownOdsCodeEntries, sitePermissions, permissionsAtAnySite] = await Promise.all([ - fromServer(fetchSite(siteFromPath)), + fromServer(fetchSite(siteFromPath, true)), fromServer(fetchWellKnownOdsCodeEntries()), fromServer(fetchPermissions(siteFromPath)), fromServer(fetchPermissions('*')), diff --git a/src/client/src/app/site/[site]/users/manage/page.tsx b/src/client/src/app/site/[site]/users/manage/page.tsx index 9d8c2c395..5a80a7502 100644 --- a/src/client/src/app/site/[site]/users/manage/page.tsx +++ b/src/client/src/app/site/[site]/users/manage/page.tsx @@ -28,7 +28,7 @@ const AssignRolesPage = async ({ params, searchParams }: UserPageProps) => { const email = userFromParams?.toLowerCase(); const [site, userProfile, roleOptions, userToEdit] = await Promise.all([ - fromServer(fetchSite(siteFromPath)), + fromServer(fetchSite(siteFromPath, false)), fromServer(fetchUserProfile()), fromServer(fetchRoles()), fromServer(fetchUsers(siteFromPath)).then(users => diff --git a/src/client/src/app/site/[site]/users/page.tsx b/src/client/src/app/site/[site]/users/page.tsx index a88c2c146..915b0bdeb 100644 --- a/src/client/src/app/site/[site]/users/page.tsx +++ b/src/client/src/app/site/[site]/users/page.tsx @@ -28,7 +28,7 @@ const Page = async ({ params }: PageProps) => { fromServer(fetchUserProfile()), fromServer(fetchUsers(siteFromPath)), fromServer(fetchRoles()), - fromServer(fetchSite(siteFromPath)), + fromServer(fetchSite(siteFromPath, false)), fromServer(fetchPermissions(siteFromPath)), ]); diff --git a/src/client/src/app/site/[site]/users/remove/page.tsx b/src/client/src/app/site/[site]/users/remove/page.tsx index 9545c0013..02c395795 100644 --- a/src/client/src/app/site/[site]/users/remove/page.tsx +++ b/src/client/src/app/site/[site]/users/remove/page.tsx @@ -30,7 +30,7 @@ const Page = async ({ params, searchParams }: UserPageProps) => { await fromServer(assertPermission(siteFromPath, 'users:manage')); const [site, users, userProfile] = await Promise.all([ - fromServer(fetchSite(siteFromPath)), + fromServer(fetchSite(siteFromPath, false)), fromServer(fetchUsers(siteFromPath)), fromServer(fetchUserProfile()), ]); diff --git a/src/client/src/app/site/[site]/view-availability/(nhs-layout)/daily-appointments/page.tsx b/src/client/src/app/site/[site]/view-availability/(nhs-layout)/daily-appointments/page.tsx index c23f8b354..7976faa34 100644 --- a/src/client/src/app/site/[site]/view-availability/(nhs-layout)/daily-appointments/page.tsx +++ b/src/client/src/app/site/[site]/view-availability/(nhs-layout)/daily-appointments/page.tsx @@ -50,7 +50,7 @@ const Page = async ({ params, searchParams }: PageProps) => { const [site, bookings, clinicalServices, cancelADateRange, sitePermissions] = await Promise.all([ - fromServer(fetchSite(siteFromPath)), + fromServer(fetchSite(siteFromPath, false)), fromServer(fetchBookings(fetchBookingsRequest, ['Booked', 'Cancelled'])), fromServer(fetchClinicalServices()), fromServer(fetchFeatureFlag('CancelADateRange')), diff --git a/src/client/src/app/site/[site]/view-availability/(nhs-layout)/layout.tsx b/src/client/src/app/site/[site]/view-availability/(nhs-layout)/layout.tsx index 6fa673b24..866dbe007 100644 --- a/src/client/src/app/site/[site]/view-availability/(nhs-layout)/layout.tsx +++ b/src/client/src/app/site/[site]/view-availability/(nhs-layout)/layout.tsx @@ -12,7 +12,7 @@ type LayoutProps = { export default async function Layout({ children, params }: LayoutProps) { const { site: siteFromPath } = { ...(await params) }; - const site = await fromServer(fetchSite(siteFromPath)); + const site = await fromServer(fetchSite(siteFromPath, false)); return ( { const [cancelADateRange, site, sitePermissions] = await Promise.all([ fromServer(fetchFeatureFlag('CancelADateRange')), - fromServer(fetchSite(siteFromPath)), + fromServer(fetchSite(siteFromPath, false)), fromServer(fetchPermissions(siteFromPath)), ]); diff --git a/src/client/src/app/site/[site]/view-availability/(nhs-layout)/week/page.tsx b/src/client/src/app/site/[site]/view-availability/(nhs-layout)/week/page.tsx index 02d8b0b68..78cad52d0 100644 --- a/src/client/src/app/site/[site]/view-availability/(nhs-layout)/week/page.tsx +++ b/src/client/src/app/site/[site]/view-availability/(nhs-layout)/week/page.tsx @@ -32,7 +32,7 @@ const Page = async ({ searchParams, params }: PageProps) => { const [cancelADateRange, site, sitePermissions] = await Promise.all([ fromServer(fetchFeatureFlag('CancelADateRange')), - fromServer(fetchSite(siteFromPath)), + fromServer(fetchSite(siteFromPath, false)), fromServer(fetchPermissions(siteFromPath)), ]); diff --git a/src/client/src/app/site/[site]/view-availability/(transactional-layout)/week/edit-session/page.tsx b/src/client/src/app/site/[site]/view-availability/(transactional-layout)/week/edit-session/page.tsx index f56728e86..5f7143005 100644 --- a/src/client/src/app/site/[site]/view-availability/(transactional-layout)/week/edit-session/page.tsx +++ b/src/client/src/app/site/[site]/view-availability/(transactional-layout)/week/edit-session/page.tsx @@ -29,7 +29,7 @@ const Page = async ({ searchParams, params }: PageProps) => { await fromServer(assertPermission(siteFromPath, 'availability:setup')); const [site, clinicalServices] = await Promise.all([ - fromServer(fetchSite(siteFromPath)), + fromServer(fetchSite(siteFromPath, false)), fromServer(fetchClinicalServices()), ]); diff --git a/tests/Nhs.Appointments.Api.Integration/Scenarios/BulkImport/SiteBulkImportFeatureSteps.cs b/tests/Nhs.Appointments.Api.Integration/Scenarios/BulkImport/SiteBulkImportFeatureSteps.cs index 7a314c7ee..222eeec74 100644 --- a/tests/Nhs.Appointments.Api.Integration/Scenarios/BulkImport/SiteBulkImportFeatureSteps.cs +++ b/tests/Nhs.Appointments.Api.Integration/Scenarios/BulkImport/SiteBulkImportFeatureSteps.cs @@ -63,7 +63,8 @@ public async Task AssertSite(DataTable dataTable) location: new Location("Point", [double.Parse(row.Cells.ElementAt(9).Value), double.Parse(row.Cells.ElementAt(10).Value)]), status: SiteStatus.Online, isDeleted: dataTable.GetBoolRowValueOrDefault(row, "IsDeleted"), - Type: dataTable.GetRowValueOrDefault(row, "Type") + Type: dataTable.GetRowValueOrDefault(row, "Type"), + ReferenceNumberGroup: 0 ); Response.StatusCode.Should().Be(HttpStatusCode.OK); (_, ActualResponse) = diff --git a/tests/Nhs.Appointments.Api.Integration/Scenarios/SiteManagement/GetSiteByIdFeatureSteps.cs b/tests/Nhs.Appointments.Api.Integration/Scenarios/SiteManagement/GetSiteByIdFeatureSteps.cs index 098d7c086..1fcc9372d 100644 --- a/tests/Nhs.Appointments.Api.Integration/Scenarios/SiteManagement/GetSiteByIdFeatureSteps.cs +++ b/tests/Nhs.Appointments.Api.Integration/Scenarios/SiteManagement/GetSiteByIdFeatureSteps.cs @@ -45,7 +45,8 @@ public async Task AssertSite(DataTable dataTable) OutOfTheWayLocation, status: null, isDeleted: dataTable.GetBoolRowValueOrDefault(row, "IsDeleted"), - Type: dataTable.GetRowValueOrDefault(row, "Type") + Type: dataTable.GetRowValueOrDefault(row, "Type"), + ReferenceNumberGroup: 0 ); Response.StatusCode.Should().Be(HttpStatusCode.OK); (_, ActualResponse) = diff --git a/tests/Nhs.Appointments.Api.Integration/Scenarios/SiteManagement/SiteLocationDependentFeatureSteps.cs b/tests/Nhs.Appointments.Api.Integration/Scenarios/SiteManagement/SiteLocationDependentFeatureSteps.cs index 4dc35c4f2..1e4d3775e 100644 --- a/tests/Nhs.Appointments.Api.Integration/Scenarios/SiteManagement/SiteLocationDependentFeatureSteps.cs +++ b/tests/Nhs.Appointments.Api.Integration/Scenarios/SiteManagement/SiteLocationDependentFeatureSteps.cs @@ -99,7 +99,8 @@ public async Task AssertSiteInformation(DataTable dataTable) Coordinates: [double.Parse(row.Cells.ElementAt(8).Value), double.Parse(row.Cells.ElementAt(9).Value)]), status: null, isDeleted: dataTable.GetBoolRowValueOrDefault(row, "IsDeleted"), - Type: dataTable.GetRowValueOrDefault(row, "Type") + Type: dataTable.GetRowValueOrDefault(row, "Type"), + ReferenceNumberGroup: 0 ); Response.StatusCode.Should().Be(HttpStatusCode.OK); @@ -394,7 +395,8 @@ public void AssertSites(DataTable dataTable) ]), status: null, isDeleted: dataTable.GetBoolRowValueOrDefault(row, "IsDeleted"), - Type: dataTable.GetRowValueOrDefault(row, "Type") + Type: dataTable.GetRowValueOrDefault(row, "Type"), + ReferenceNumberGroup: 0 ), Distance: int.Parse(row.Cells.ElementAt(11).Value) )).ToList(); diff --git a/tests/Nhs.Appointments.Api.Integration/Scenarios/SiteManagement/SiteManagementBaseFeatureSteps.cs b/tests/Nhs.Appointments.Api.Integration/Scenarios/SiteManagement/SiteManagementBaseFeatureSteps.cs index 8b5e912d7..60ec0c3c4 100644 --- a/tests/Nhs.Appointments.Api.Integration/Scenarios/SiteManagement/SiteManagementBaseFeatureSteps.cs +++ b/tests/Nhs.Appointments.Api.Integration/Scenarios/SiteManagement/SiteManagementBaseFeatureSteps.cs @@ -77,7 +77,8 @@ public async Task AssertSiteInformation(DataTable dataTable) Coordinates: [double.Parse(row.Cells.ElementAt(8).Value), double.Parse(row.Cells.ElementAt(9).Value)]), status: null, isDeleted: dataTable.GetBoolRowValueOrDefault(row, "IsDeleted"), - Type: dataTable.GetRowValueOrDefault(row, "Type") + Type: dataTable.GetRowValueOrDefault(row, "Type"), + ReferenceNumberGroup: 0 ); Response.StatusCode.Should().Be(HttpStatusCode.OK); diff --git a/tests/Nhs.Appointments.Api.UnitTests/Auth/PermissionCheckerTests.cs b/tests/Nhs.Appointments.Api.UnitTests/Auth/PermissionCheckerTests.cs index 7f9fd2cd4..91759ae19 100644 --- a/tests/Nhs.Appointments.Api.UnitTests/Auth/PermissionCheckerTests.cs +++ b/tests/Nhs.Appointments.Api.UnitTests/Auth/PermissionCheckerTests.cs @@ -43,7 +43,8 @@ private Site GenerateSite(string id) => new Location("Location", new[] { 0.0 }), SiteStatus.Online, null, - string.Empty); + string.Empty, + ReferenceNumberGroup: 0); [Fact] public async Task HasPermissions_ReturnsTrue_WhenPermissionAssignedGloballyAndGeneralRequest() @@ -474,7 +475,8 @@ public async Task HasPermissionAsync_ReturnsTrue_WhenUserHasRegionOnlyLevelPermi _siteService.Setup(x => x.GetSitesInRegion(It.IsAny())) .ReturnsAsync(new List { - new("1", "TestSite", "TestAddress", "N", "T1", "R1", "ICB", string.Empty, [], new Location("Test", [0,0]), SiteStatus.Online, null, string.Empty) + new("1", "TestSite", "TestAddress", "N", "T1", "R1", "ICB", string.Empty, [], new Location("Test", [0,0]), SiteStatus.Online, null, string.Empty, + ReferenceNumberGroup: 0) }); var result = await _sut.HasPermissionAsync(userId, ["1"], "TestPermission"); @@ -504,7 +506,8 @@ public async Task GetPermissionsAsync_FiltersPermissionsOnRegion() _siteService.Setup(x => x.GetSitesInRegion(It.IsAny())) .ReturnsAsync(new List { - new("2", "TestSite", "TestAddress", "N", "T1", "R1", "ICB", string.Empty, [], new Location("Test", [0,0]), SiteStatus.Online, null, string.Empty) + new("2", "TestSite", "TestAddress", "N", "T1", "R1", "ICB", string.Empty, [], new Location("Test", [0,0]), SiteStatus.Online, null, string.Empty, + ReferenceNumberGroup: 0) }); var result = await _sut.GetPermissionsAsync(userId, "2"); @@ -556,7 +559,8 @@ public async Task GetPermissionsAsync_FiltersPermissionsOnIcb() _siteService.Setup(x => x.GetSitesInIcbAsync(It.IsAny())) .ReturnsAsync(new List { - new("2", "TestSite", "TestAddress", "N", "T1", "R1", "ICB1", string.Empty, [], new Location("Test", [0,0]), SiteStatus.Online, null, string.Empty) + new("2", "TestSite", "TestAddress", "N", "T1", "R1", "ICB1", string.Empty, [], new Location("Test", [0,0]), SiteStatus.Online, null, string.Empty, + ReferenceNumberGroup: 0) }); var result = await _sut.GetPermissionsAsync(userId, "2"); diff --git a/tests/Nhs.Appointments.Api.UnitTests/Functions/ApplyAvailabilityTemplateFunctionTests.cs b/tests/Nhs.Appointments.Api.UnitTests/Functions/ApplyAvailabilityTemplateFunctionTests.cs index 7f355cae4..7f674776f 100644 --- a/tests/Nhs.Appointments.Api.UnitTests/Functions/ApplyAvailabilityTemplateFunctionTests.cs +++ b/tests/Nhs.Appointments.Api.UnitTests/Functions/ApplyAvailabilityTemplateFunctionTests.cs @@ -44,7 +44,7 @@ public ApplyAvailabilityTemplateFunctionTests() [Fact] public async Task RunAsync_ReturnsNotFound_WhenSiteIsNull() { - _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(null as Site); var sessions = new List @@ -89,7 +89,7 @@ public async Task RunAsync_AppliesNewAvailabilityTemplate() var userPrincipal = UserDataGenerator.CreateUserPrincipal("test.user3@nhs.net"); _userContextProvider.Setup(x => x.UserPrincipal) .Returns(userPrincipal); - _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(new Site( "test-site", "Test Site", @@ -106,7 +106,8 @@ public async Task RunAsync_AppliesNewAvailabilityTemplate() new Location("Coords", [1.234, 5.678]), null, false, - string.Empty + string.Empty, + ReferenceNumberGroup: 0 )); var sessions = new List diff --git a/tests/Nhs.Appointments.Api.UnitTests/Functions/CancelBookingFunctionTests.cs b/tests/Nhs.Appointments.Api.UnitTests/Functions/CancelBookingFunctionTests.cs index 85d873cf5..c40fa21b2 100644 --- a/tests/Nhs.Appointments.Api.UnitTests/Functions/CancelBookingFunctionTests.cs +++ b/tests/Nhs.Appointments.Api.UnitTests/Functions/CancelBookingFunctionTests.cs @@ -51,7 +51,7 @@ public async Task RunAsync_ReturnsSuccessResponse_WhenBookingCancelled() _bookingWriteService.Setup(x => x.CancelBooking(bookingRef, site, CancellationReason.CancelledByCitizen, It.IsAny(), It.IsAny())) .Returns(Task.FromResult(BookingCancellationResult.Success)); - _siteService.Setup(x => x.GetSiteByIdAsync(site, It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(site, It.IsAny(), It.IsAny())) .ReturnsAsync(new Site( site, "test site", @@ -68,7 +68,8 @@ public async Task RunAsync_ReturnsSuccessResponse_WhenBookingCancelled() new Location("Coords", [1.234, 5.678]), null, false, - string.Empty + string.Empty, + ReferenceNumberGroup: 0 )); var request = BuildRequest(bookingRef, site); @@ -86,7 +87,7 @@ public async Task RunAsync_CallsBookingServiceOnce_WhenCancellationReasonIsNull( _bookingWriteService.Setup(x => x.CancelBooking(bookingRef, site, CancellationReason.CancelledByCitizen, It.IsAny(), It.IsAny())) .Returns(Task.FromResult(BookingCancellationResult.Success)).Verifiable(Times.Once); - _siteService.Setup(x => x.GetSiteByIdAsync(site, It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(site, It.IsAny(), It.IsAny())) .ReturnsAsync(new Site( site, "test site", @@ -103,7 +104,8 @@ public async Task RunAsync_CallsBookingServiceOnce_WhenCancellationReasonIsNull( new Location("Coords", [1.234, 5.678]), null, false, - string.Empty + string.Empty, + ReferenceNumberGroup: 0 )); var request = BuildRequest(bookingRef, site); @@ -121,7 +123,7 @@ public async Task RunAsync_ReturnsNotFoundResponse_WhenBookingInvalid() _bookingWriteService.Setup(x => x.CancelBooking(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .Returns(Task.FromResult(BookingCancellationResult.NotFound)); - _siteService.Setup(x => x.GetSiteByIdAsync(site, It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(site, It.IsAny(), It.IsAny())) .ReturnsAsync(new Site( site, "test site", @@ -138,7 +140,8 @@ public async Task RunAsync_ReturnsNotFoundResponse_WhenBookingInvalid() new Location("Coords", [1.234, 5.678]), null, false, - string.Empty + string.Empty, + ReferenceNumberGroup: 0 )); var request = BuildRequest(bookingRef, site); @@ -157,7 +160,7 @@ public async Task RunAsync_Fails_WhenServiceReturnsUnexpected() _bookingWriteService.Setup(x => x.CancelBooking(It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny(), It.IsAny())) .Returns(Task.FromResult((BookingCancellationResult)invalidResultCode)); - _siteService.Setup(x => x.GetSiteByIdAsync(site, It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(site, It.IsAny(), It.IsAny())) .ReturnsAsync(new Site( site, "test site", @@ -174,7 +177,8 @@ public async Task RunAsync_Fails_WhenServiceReturnsUnexpected() new Location("Coords", [1.234, 5.678]), null, false, - string.Empty + string.Empty, + ReferenceNumberGroup: 0 )); var request = BuildRequest(bookingRef, site); @@ -197,7 +201,7 @@ public async Task RunAsync_PassesCancellationReasonToService(string cancellation _bookingWriteService .Setup(x => x.CancelBooking(bookingRef, site, expectedCancellationReason, It.IsAny(), It.IsAny())) .Returns(Task.FromResult(BookingCancellationResult.Success)).Verifiable(); - _siteService.Setup(x => x.GetSiteByIdAsync(site, It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(site, It.IsAny(), It.IsAny())) .ReturnsAsync(new Site( site, "test site", @@ -214,7 +218,8 @@ public async Task RunAsync_PassesCancellationReasonToService(string cancellation new Location("Coords", [1.234, 5.678]), null, false, - string.Empty + string.Empty, + ReferenceNumberGroup: 0 )); var request = BuildRequest(bookingRef, site, cancellationReason); @@ -231,7 +236,7 @@ public async Task RunAsync_ReturnsNotFound_WhenSiteHasBeenDeleted() var bookingRef = "some-booking"; var site = "TEST01"; - _siteService.Setup(x => x.GetSiteByIdAsync(site, It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(site, It.IsAny(), It.IsAny())) .ReturnsAsync(null as Site); var request = BuildRequest(bookingRef, site); diff --git a/tests/Nhs.Appointments.Api.UnitTests/Functions/ConfirmProvisionalBookingFunctionTests.cs b/tests/Nhs.Appointments.Api.UnitTests/Functions/ConfirmProvisionalBookingFunctionTests.cs index 300284e3f..5e6326c95 100644 --- a/tests/Nhs.Appointments.Api.UnitTests/Functions/ConfirmProvisionalBookingFunctionTests.cs +++ b/tests/Nhs.Appointments.Api.UnitTests/Functions/ConfirmProvisionalBookingFunctionTests.cs @@ -51,7 +51,7 @@ public async Task RunAsync_CallsConfirmProvisionalBooking_WhenNoChildBookings() Reference = "booking-ref", Site = "test-site" }); - _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(new Site( "test-site", "test site", @@ -68,7 +68,8 @@ public async Task RunAsync_CallsConfirmProvisionalBooking_WhenNoChildBookings() new Location("Coords", [1.234, 5.678]), null, false, - string.Empty + string.Empty, + ReferenceNumberGroup: 0 )); var request = CreateRequest([]); @@ -89,7 +90,7 @@ public async Task RunAsync_CallsConfirmProvisionalBookingWithChildren(params str Reference = "booking-ref", Site = "test-site" }); - _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(new Site( "test-site", "test site", @@ -106,7 +107,8 @@ public async Task RunAsync_CallsConfirmProvisionalBookingWithChildren(params str new Location("Coords", [1.234, 5.678]), null, false, - string.Empty + string.Empty, + ReferenceNumberGroup: 0 )); var request = CreateRequest(relatedBookings); @@ -125,7 +127,7 @@ public async Task RunAsync_ReturnsNotFound_WhenSiteHasBeenDeleted() Reference = "booking-ref", Site = "test-site" }); - _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(null as Site); var request = CreateRequest([]); diff --git a/tests/Nhs.Appointments.Api.UnitTests/Functions/GetSiteMetaDataFunctionTests.cs b/tests/Nhs.Appointments.Api.UnitTests/Functions/GetSiteMetaDataFunctionTests.cs index 8ddfceb5a..5d3c06244 100644 --- a/tests/Nhs.Appointments.Api.UnitTests/Functions/GetSiteMetaDataFunctionTests.cs +++ b/tests/Nhs.Appointments.Api.UnitTests/Functions/GetSiteMetaDataFunctionTests.cs @@ -45,7 +45,7 @@ public async Task RunAsync_ReturnsNotFound_WhenRequestedSiteIsNotConfigured() [InlineData("attr_one/test_attr", "Another test", "")] public async Task RunAsync_ReturnsInformationForCitizen(string attrId, string attrVal, string expectedInformation) { - _siteService.Setup(x => x.GetSiteByIdAsync("6877d86e-c2df-4def-8508-e1eccf0ea6ba", "site_details")) + _siteService.Setup(x => x.GetSiteByIdAsync("6877d86e-c2df-4def-8508-e1eccf0ea6ba", It.IsAny(), "site_details")) .ReturnsAsync(new Site ( Id: "6877d86e-c2df-4def-8508-e1eccf0ea6ba", @@ -60,7 +60,8 @@ public async Task RunAsync_ReturnsInformationForCitizen(string attrId, string at new Location("Test", [123.1, 321.3]), status: SiteStatus.Online, isDeleted: null, - Type: null + Type: null, + ReferenceNumberGroup: 0 )); var request = CreateRequest(); diff --git a/tests/Nhs.Appointments.Api.UnitTests/Functions/GetSitesPreviewFunctionTests.cs b/tests/Nhs.Appointments.Api.UnitTests/Functions/GetSitesPreviewFunctionTests.cs index 53b70a3e0..0f582f61b 100644 --- a/tests/Nhs.Appointments.Api.UnitTests/Functions/GetSitesPreviewFunctionTests.cs +++ b/tests/Nhs.Appointments.Api.UnitTests/Functions/GetSitesPreviewFunctionTests.cs @@ -106,7 +106,8 @@ public async Task RunsAsync_UserFound_GetsUsersSites() new Location("point", [0.1, 10]), status: SiteStatus.Online, isDeleted: null, - Type: null + Type: null, + ReferenceNumberGroup: 0 ); var site2 = new Site( @@ -122,7 +123,8 @@ public async Task RunsAsync_UserFound_GetsUsersSites() new Location("point", [0.1, 10]), status: SiteStatus.Online, isDeleted: null, - Type: null + Type: null, + ReferenceNumberGroup: 0 ); var icbs = new List diff --git a/tests/Nhs.Appointments.Api.UnitTests/Functions/GetUserProfileFunctionTests.cs b/tests/Nhs.Appointments.Api.UnitTests/Functions/GetUserProfileFunctionTests.cs index d26f62da5..bc9c89d76 100644 --- a/tests/Nhs.Appointments.Api.UnitTests/Functions/GetUserProfileFunctionTests.cs +++ b/tests/Nhs.Appointments.Api.UnitTests/Functions/GetUserProfileFunctionTests.cs @@ -94,10 +94,10 @@ public async Task RunAsync_ReturnsCorrectHasSites(bool hasSites) { new Site("1", "Alpha", "somewhere", "0113 1111111", "odsCode1", "R1", "ICB1", string.Empty, new[] { new Accessibility(Id: "Accessibility 1", Value: "true") }, - new Location("point", new[] { 0.1, 10 }), SiteStatus.Online, null, string.Empty), + new Location("point", new[] { 0.1, 10 }), SiteStatus.Online, null, string.Empty, ReferenceNumberGroup: 0), new Site("2", "Beta", "somewhere else", "0113 222222", "odsCode2", "R2", "ICB2", string.Empty, new[] { new Accessibility(Id: "Accessibility 2", Value: "true") }, - new Location("point", new[] { 0.2, 11 }), SiteStatus.Online, null, string.Empty) + new Location("point", new[] { 0.2, 11 }), SiteStatus.Online, null, string.Empty, ReferenceNumberGroup: 0) }; var result = await _sut.RunAsync(request) as ContentResult; diff --git a/tests/Nhs.Appointments.Api.UnitTests/Functions/MakeBookingFunctionTests.cs b/tests/Nhs.Appointments.Api.UnitTests/Functions/MakeBookingFunctionTests.cs index 4ddcb884e..2be684605 100644 --- a/tests/Nhs.Appointments.Api.UnitTests/Functions/MakeBookingFunctionTests.cs +++ b/tests/Nhs.Appointments.Api.UnitTests/Functions/MakeBookingFunctionTests.cs @@ -40,10 +40,10 @@ public async Task RunAsync_ReturnsSuccessResponse_WhenAppointmentIsRequested() { var slots = AvailabilityHelper.CreateTestSlots(Date, new TimeOnly(10, 0), new TimeOnly(11, 0), TimeSpan.FromMinutes(5)); - _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny())).ReturnsAsync( + _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync( new Site("6877d86e-c2df-4def-8508-e1eccf0ea6ba", "Test Site", "Nowhere", "2929292", "15N", "North", "Test Board", "Information For Citizen 123", Enumerable.Empty(), - new Location("Point", [0, 0]), SiteStatus.Online, null, string.Empty)); + new Location("Point", [0, 0]), SiteStatus.Online, null, string.Empty, ReferenceNumberGroup: 0)); _bookingWriteService.Setup(x => x.MakeBooking(It.IsAny())).ReturnsAsync((true, "TEST01")); var request = CreateRequest("34e990af-5dc9-43a6-8895-b9123216d699", "2077-01-01 10:30", "COVID", "9999999999", @@ -59,7 +59,7 @@ public async Task RunAsync_ReturnsSuccessResponse_WhenAppointmentIsRequested() [Fact] public async Task RunAsync_ReturnsError_WhenSiteDoesNotExist() { - _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny())).ReturnsAsync((Site)null); + _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync((Site)null); var request = CreateRequest("34e990af-5dc9-43a6-8895-b9123216d699", "2077-01-01 09:30", "COVID", "9999999999", "FirstName", "LastName", @@ -74,10 +74,10 @@ public async Task RunAsync_ReturnsError_WhenSiteDoesNotExist() [Fact] public async Task RunAsync_ReturnsError_WhenAppointmentSlotIsNotAvailable() { - _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny())).ReturnsAsync( + _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync( new Site("6877d86e-c2df-4def-8508-e1eccf0ea6ba", "Test Site", "Nowhere", "2929292", "15N", "North", "Test Board", "Information For Citizens 123", Enumerable.Empty(), - new Location("Point", [0, 0]), SiteStatus.Online, null, string.Empty)); + new Location("Point", [0, 0]), SiteStatus.Online, null, string.Empty, ReferenceNumberGroup: 0)); var slots = AvailabilityHelper.CreateTestSlots(Date, new TimeOnly(10, 0), new TimeOnly(11, 0), TimeSpan.FromMinutes(5)); @@ -94,10 +94,10 @@ public async Task RunAsync_ReturnsError_WhenAppointmentSlotIsNotAvailable() [Fact] public void RunAsync_InvokesBookingService_WithCorrectDetails() { - _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny())).ReturnsAsync( + _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny(), It.IsAny())).ReturnsAsync( new Site("6877d86e-c2df-4def-8508-e1eccf0ea6ba", "Test Site", "Nowhere", "2929292", "15N", "North", "Test Board", "Information For Citizens 123", Enumerable.Empty(), - new Location("Point", [0, 0]), SiteStatus.Online, null, string.Empty)); + new Location("Point", [0, 0]), SiteStatus.Online, null, string.Empty, ReferenceNumberGroup: 0)); var slots = AvailabilityHelper.CreateTestSlots(Date, new TimeOnly(10, 0), new TimeOnly(11, 0), TimeSpan.FromMinutes(5)); diff --git a/tests/Nhs.Appointments.Api.UnitTests/Functions/QueryAvailabilityByDaysFunctionTests.cs b/tests/Nhs.Appointments.Api.UnitTests/Functions/QueryAvailabilityByDaysFunctionTests.cs index ae35bc147..28214a47c 100644 --- a/tests/Nhs.Appointments.Api.UnitTests/Functions/QueryAvailabilityByDaysFunctionTests.cs +++ b/tests/Nhs.Appointments.Api.UnitTests/Functions/QueryAvailabilityByDaysFunctionTests.cs @@ -94,7 +94,8 @@ public async Task RunAsync_ReturnsSlots_SingleUser_SingleService() new Location("Coords", [1.234, 5.678]), null, null, - string.Empty + string.Empty, + ReferenceNumberGroup: 0 ) }); _bookingAvailabilityStateService.Setup(x => x.GetAvailableSlots(It.IsAny(), It.IsAny(), It.IsAny())) @@ -153,7 +154,8 @@ public async Task RunAsync_ReturnsSlots_TwoAttendees_SingleService() new Location("Coords", [1.234, 5.678]), null, null, - string.Empty + string.Empty, + ReferenceNumberGroup: 0 ) }); _bookingAvailabilityStateService.Setup(x => x.GetAvailableSlots(It.IsAny(), It.IsAny(), It.IsAny())) @@ -222,7 +224,8 @@ public async Task RunAsync_ReturnsSlots_TwoAttendees_MultipleServices() new Location("Coords", [1.234, 5.678]), null, null, - string.Empty + string.Empty, + ReferenceNumberGroup: 0 ) }); _bookingAvailabilityStateService.Setup(x => x.GetAvailableSlots(It.IsAny(), It.IsAny(), It.IsAny())) diff --git a/tests/Nhs.Appointments.Api.UnitTests/Functions/QueryAvailabilityByHoursFunctionTests.cs b/tests/Nhs.Appointments.Api.UnitTests/Functions/QueryAvailabilityByHoursFunctionTests.cs index 3912547e7..b1b56ab9b 100644 --- a/tests/Nhs.Appointments.Api.UnitTests/Functions/QueryAvailabilityByHoursFunctionTests.cs +++ b/tests/Nhs.Appointments.Api.UnitTests/Functions/QueryAvailabilityByHoursFunctionTests.cs @@ -67,7 +67,7 @@ public async Task RunAsync_ReturnsNotFound_WhenSiteIsInactive() { _featureToggleHelper.Setup(x => x.IsFeatureEnabled(Flags.MultiServiceJointBookings)) .ReturnsAsync(true); - _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(null as Site); var payload = new AvailabilityQueryByHoursRequest( @@ -99,7 +99,7 @@ public async Task RunAsync_ReturnAvailabilityByHours() _featureToggleHelper.Setup(x => x.IsFeatureEnabled(Flags.MultiServiceJointBookings)) .ReturnsAsync(true); - _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(new Site( "2de5bb57-060f-4cb5-b14d-16587d0c2e8f", "Test Site", @@ -116,7 +116,8 @@ public async Task RunAsync_ReturnAvailabilityByHours() new Location("Coords", [1.234, 5.678]), null, null, - string.Empty)); + string.Empty, + ReferenceNumberGroup: 0)); _bookingAvailabilityStateService.Setup(x => x.GetAvailableSlots(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(slots); _availableSlotsFilter.Setup(x => x.FilterAvailableSlots(It.IsAny>(), It.IsAny>())) @@ -153,7 +154,7 @@ public async Task RunAsync_DoesNotShowFollowingHour_IfSlotSpillsOver() _featureToggleHelper.Setup(x => x.IsFeatureEnabled(Flags.MultiServiceJointBookings)) .ReturnsAsync(true); - _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(new Site( "2de5bb57-060f-4cb5-b14d-16587d0c2e8f", "Test Site", @@ -170,7 +171,8 @@ public async Task RunAsync_DoesNotShowFollowingHour_IfSlotSpillsOver() new Location("Coords", [1.234, 5.678]), null, null, - string.Empty)); + string.Empty, + ReferenceNumberGroup: 0)); _bookingAvailabilityStateService.Setup(x => x.GetAvailableSlots(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(slots); _availableSlotsFilter.Setup(x => x.FilterAvailableSlots(It.IsAny>(), It.IsAny>())) @@ -203,7 +205,7 @@ public async Task RunAsync_ReturnsEmptyHoursArray() _featureToggleHelper.Setup(x => x.IsFeatureEnabled(Flags.MultiServiceJointBookings)) .ReturnsAsync(true); - _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(new Site( "2de5bb57-060f-4cb5-b14d-16587d0c2e8f", "Test Site", @@ -220,7 +222,8 @@ public async Task RunAsync_ReturnsEmptyHoursArray() new Location("Coords", [1.234, 5.678]), null, null, - string.Empty)); + string.Empty, + ReferenceNumberGroup: 0)); _bookingAvailabilityStateService.Setup(x => x.GetAvailableSlots(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(slots); _availableSlotsFilter.Setup(x => x.FilterAvailableSlots(It.IsAny>(), It.IsAny>())) diff --git a/tests/Nhs.Appointments.Api.UnitTests/Functions/QueryAvailabilityBySlotsFunctionTests.cs b/tests/Nhs.Appointments.Api.UnitTests/Functions/QueryAvailabilityBySlotsFunctionTests.cs index bdb726aac..4fccedb5e 100644 --- a/tests/Nhs.Appointments.Api.UnitTests/Functions/QueryAvailabilityBySlotsFunctionTests.cs +++ b/tests/Nhs.Appointments.Api.UnitTests/Functions/QueryAvailabilityBySlotsFunctionTests.cs @@ -68,7 +68,7 @@ public async Task RunAsync_ReturnsNotFound_WhenSiteIsInactive() { _featureToggleHelper.Setup(x => x.IsFeatureEnabled(Flags.MultiServiceJointBookings)) .ReturnsAsync(true); - _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(null as Site); var payload = new AvailabilityQueryBySlotsRequest( @@ -94,7 +94,7 @@ public async Task RunAsync_ReturnsEmptySlotArray() _featureToggleHelper.Setup(x => x.IsFeatureEnabled(Flags.MultiServiceJointBookings)) .ReturnsAsync(true); - _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(new Site( "2de5bb57-060f-4cb5-b14d-16587d0c2e8f", "Test Site", @@ -111,7 +111,8 @@ public async Task RunAsync_ReturnsEmptySlotArray() new Location("Coords", [1.234, 5.678]), null, null, - string.Empty)); + string.Empty, + ReferenceNumberGroup: 0)); _bookingAvailabilityStateService.Setup(x => x.GetAvailableSlots(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(slots); _availableSlotsFilter.Setup(x => x.FilterAvailableSlots(It.IsAny>(), It.IsAny>())) @@ -148,7 +149,7 @@ public async Task RunAsync_ReturnsAvailabilityBySlots() _featureToggleHelper.Setup(x => x.IsFeatureEnabled(Flags.MultiServiceJointBookings)) .ReturnsAsync(true); - _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(new Site( "2de5bb57-060f-4cb5-b14d-16587d0c2e8f", "Test Site", @@ -165,7 +166,8 @@ public async Task RunAsync_ReturnsAvailabilityBySlots() new Location("Coords", [1.234, 5.678]), null, null, - string.Empty)); + string.Empty, + ReferenceNumberGroup: 0)); _bookingAvailabilityStateService.Setup(x => x.GetAvailableSlots(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(slots); _availableSlotsFilter.Setup(x => x.FilterAvailableSlots(It.IsAny>(), It.IsAny>())) diff --git a/tests/Nhs.Appointments.Api.UnitTests/Functions/QueryAvailabilityFunctionTests.cs b/tests/Nhs.Appointments.Api.UnitTests/Functions/QueryAvailabilityFunctionTests.cs index 69a0261cd..29766f567 100644 --- a/tests/Nhs.Appointments.Api.UnitTests/Functions/QueryAvailabilityFunctionTests.cs +++ b/tests/Nhs.Appointments.Api.UnitTests/Functions/QueryAvailabilityFunctionTests.cs @@ -84,7 +84,8 @@ public async Task RunAsync_ReturnsSuccessResponse_WhenMultipleSitesAreQueried() new Location("Coords", [1.234, 5.678]), null, null, - string.Empty + string.Empty, + ReferenceNumberGroup: 0 ), new( "34e990af-5dc9-43a6-8895-b9123216d699", @@ -102,7 +103,8 @@ public async Task RunAsync_ReturnsSuccessResponse_WhenMultipleSitesAreQueried() new Location("Coords", [1.234, 5.678]), null, null, - string.Empty + string.Empty, + ReferenceNumberGroup: 0 ) }); @@ -163,7 +165,8 @@ public async Task RunAsync_ReturnsCorrectAvailabilityGrouper_WhenCalledWithConfi new Location("Coords", [1.234, 5.678]), null, null, - string.Empty + string.Empty, + ReferenceNumberGroup: 0 ) }); @@ -210,7 +213,8 @@ public async Task RunAsync_ReturnsResults_ForEachDayInRequest() new Location("Coords", [1.234, 5.678]), null, null, - string.Empty + string.Empty, + ReferenceNumberGroup: 0 ) }); @@ -267,7 +271,8 @@ public async Task RunAsync_RunsJointBookings() new Location("Coords", [1.234, 5.678]), null, null, - string.Empty + string.Empty, + ReferenceNumberGroup: 0 ) }); @@ -322,7 +327,8 @@ public async Task RunAsync_CallsGrouperWithCorrectSlots_ForEachDayInRequest() new Location("Coords", [1.234, 5.678]), null, null, - string.Empty + string.Empty, + ReferenceNumberGroup: 0 ) }); @@ -379,7 +385,8 @@ public async Task RunAsync_CallsBookingAvailabilityStateService() new Location("Coords", [1.234, 5.678]), null, null, - string.Empty + string.Empty, + ReferenceNumberGroup: 0 ) }); @@ -422,7 +429,8 @@ public async Task RunAsync_ReturnsEmptyArray_WhenAllRequestedSites_HaveBeenSoftD new Location("Coords", [1.234, 5.678]), null, true, - string.Empty + string.Empty, + ReferenceNumberGroup: 0 ), new( "34e990af-5dc9-43a6-8895-b9123216d699", @@ -440,7 +448,8 @@ public async Task RunAsync_ReturnsEmptyArray_WhenAllRequestedSites_HaveBeenSoftD new Location("Coords", [1.234, 5.678]), null, true, - string.Empty + string.Empty, + ReferenceNumberGroup: 0 ) }); @@ -492,7 +501,8 @@ public async Task RunAsync_OnlyProcessesActiveSites() new Location("Coords", [1.234, 5.678]), null, false, - string.Empty + string.Empty, + ReferenceNumberGroup: 0 ), new( "34e990af-5dc9-43a6-8895-b9123216d699", @@ -510,7 +520,8 @@ public async Task RunAsync_OnlyProcessesActiveSites() new Location("Coords", [1.234, 5.678]), null, true, - string.Empty + string.Empty, + ReferenceNumberGroup: 0 ) }); diff --git a/tests/Nhs.Appointments.Api.UnitTests/Functions/QueryBookingByReferenceFunctionTests.cs b/tests/Nhs.Appointments.Api.UnitTests/Functions/QueryBookingByReferenceFunctionTests.cs index f980b82dd..b9c69db32 100644 --- a/tests/Nhs.Appointments.Api.UnitTests/Functions/QueryBookingByReferenceFunctionTests.cs +++ b/tests/Nhs.Appointments.Api.UnitTests/Functions/QueryBookingByReferenceFunctionTests.cs @@ -61,7 +61,7 @@ public async Task RunAsync_ReturnsSuccessResponse_AndBookingWhenFound() _bookingQueryService.Setup(x => x.GetBookingByReference(It.IsAny())) .ReturnsAsync(booking); - _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(new Site( site, "Test Site", @@ -78,7 +78,8 @@ public async Task RunAsync_ReturnsSuccessResponse_AndBookingWhenFound() new Location("Coords", [1.234, 5.678]), null, false, - string.Empty + string.Empty, + ReferenceNumberGroup: 0 )); var request = new QueryBookingByReferenceRequest(bookingRef, site); @@ -111,7 +112,7 @@ public async Task RunAsync_ReturnsNotFoundResponse_WhenReferenceAndSiteDoNotMatc _bookingQueryService.Setup(x => x.GetBookingByReference(It.IsAny())) .ReturnsAsync(booking); - _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(new Site( "Test Site", "Test Site", @@ -128,7 +129,8 @@ public async Task RunAsync_ReturnsNotFoundResponse_WhenReferenceAndSiteDoNotMatc new Location("Coords", [1.234, 5.678]), null, false, - string.Empty + string.Empty, + ReferenceNumberGroup: 0 )); var request = new QueryBookingByReferenceRequest(bookingRef, "TEST03"); @@ -159,7 +161,7 @@ public async Task ReturnsNotFound_WhenSiteHasBeenSoftDeleted() _bookingQueryService.Setup(x => x.GetBookingByReference(It.IsAny())) .ReturnsAsync(booking); - _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(null as Site); var request = new QueryBookingByReferenceRequest(bookingRef, "TEST03"); @@ -186,7 +188,7 @@ public async Task ReturnsNotFound_WhenProvisionalBookingNotFound() var result = await _sut.RunAsync(httpRequest) as ContentResult; result.StatusCode.Should().Be(404); - _siteService.Verify(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny()), Times.Never); + _siteService.Verify(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny(), It.IsAny()), Times.Never); } private static HttpRequest CreateRequest(string site) diff --git a/tests/Nhs.Appointments.Api.UnitTests/Functions/SetAvailabilityFunctionTests.cs b/tests/Nhs.Appointments.Api.UnitTests/Functions/SetAvailabilityFunctionTests.cs index febfcb090..a74a5fd47 100644 --- a/tests/Nhs.Appointments.Api.UnitTests/Functions/SetAvailabilityFunctionTests.cs +++ b/tests/Nhs.Appointments.Api.UnitTests/Functions/SetAvailabilityFunctionTests.cs @@ -41,7 +41,7 @@ public async Task InvokeAvailabilityService_WhenSettingAvailability() var userPrincipal = UserDataGenerator.CreateUserPrincipal("test.user3@nhs.net"); _userContext.Setup(x => x.UserPrincipal) .Returns(userPrincipal); - _siteService.Setup(x => x.GetSiteByIdAsync("test-site", It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync("test-site", It.IsAny(), It.IsAny())) .ReturnsAsync(new Site( "test-site", "Test Site", @@ -58,7 +58,8 @@ public async Task InvokeAvailabilityService_WhenSettingAvailability() new Location("Coords", [1.234, 5.678]), null, false, - string.Empty + string.Empty, + ReferenceNumberGroup: 0 )); var sessions = new List @@ -91,7 +92,7 @@ public async Task InvokeAvailabilityService_WhenSettingAvailability() [Fact] public async Task DoesNotInvokeAvailabilityService_WhenSiteIsInactive() { - _siteService.Setup(x => x.GetSiteByIdAsync("test-site", It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync("test-site", It.IsAny(), It.IsAny())) .ReturnsAsync(null as Site); var sessions = new List diff --git a/tests/Nhs.Appointments.Api.UnitTests/Functions/SetSiteAccessibilitiesFunctionTests.cs b/tests/Nhs.Appointments.Api.UnitTests/Functions/SetSiteAccessibilitiesFunctionTests.cs index 4fda679b1..cc33d29cd 100644 --- a/tests/Nhs.Appointments.Api.UnitTests/Functions/SetSiteAccessibilitiesFunctionTests.cs +++ b/tests/Nhs.Appointments.Api.UnitTests/Functions/SetSiteAccessibilitiesFunctionTests.cs @@ -47,7 +47,7 @@ public async Task InvokeSiteService_WhenSettingSiteAccessibilities(bool operatio _siteService.Setup(x => x.UpdateAccessibilities(site, accessibilities)) .ReturnsAsync(operationalResult); - _siteService.Setup(x => x.GetSiteByIdAsync(site, It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(site, It.IsAny(), It.IsAny())) .ReturnsAsync(new Site( site, "test site", @@ -61,7 +61,8 @@ public async Task InvokeSiteService_WhenSettingSiteAccessibilities(bool operatio new Location("Coords", [1.234, 5.678]), null, false, - string.Empty + string.Empty, + ReferenceNumberGroup: 0 )); var result = await _sut.Invoke(request); @@ -84,7 +85,7 @@ public async Task DoesNotInvokeService_WhenSiteIsInactive() }; var request = new SetSiteAccessibilitiesRequest(site, accessibilities); - _siteService.Setup(x => x.GetSiteByIdAsync("test-site", It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync("test-site", It.IsAny(), It.IsAny())) .ReturnsAsync(null as Site); var result = await _sut.Invoke(request); diff --git a/tests/Nhs.Appointments.Api.UnitTests/Functions/SetSiteDetailsFunctionTests.cs b/tests/Nhs.Appointments.Api.UnitTests/Functions/SetSiteDetailsFunctionTests.cs index 40b3e3500..855e053ab 100644 --- a/tests/Nhs.Appointments.Api.UnitTests/Functions/SetSiteDetailsFunctionTests.cs +++ b/tests/Nhs.Appointments.Api.UnitTests/Functions/SetSiteDetailsFunctionTests.cs @@ -47,7 +47,7 @@ public async Task InvokeSiteService_WhenSettingSiteDetails(bool operationSuccess _siteService.Setup(x => x.UpdateSiteDetailsAsync(site, name, address, phoneNo, decimal.Parse($"{longitude}"), decimal.Parse($"{latitude}"))) .ReturnsAsync(operationalResult); - _siteService.Setup(x => x.GetSiteByIdAsync(site, It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(site, It.IsAny(), It.IsAny())) .ReturnsAsync(new Site( site, name, @@ -64,7 +64,8 @@ public async Task InvokeSiteService_WhenSettingSiteDetails(bool operationSuccess new Location("Coords", [1.234, 5.678]), null, false, - string.Empty + string.Empty, + ReferenceNumberGroup: 0 )); var result = await _sut.Invoke(request); @@ -87,7 +88,7 @@ public async Task DoesNotInvokeService_WhenSiteIsInactive() var latitude = 4.567; var request = new SetSiteDetailsRequest(site, name, address, phoneNo, $"{longitude}", $"{latitude}"); - _siteService.Setup(x => x.GetSiteByIdAsync("test-site", It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync("test-site", It.IsAny(), It.IsAny())) .ReturnsAsync(null as Site); var result = await _sut.Invoke(request); diff --git a/tests/Nhs.Appointments.Api.UnitTests/Functions/SetSiteInformationForCitizensFunctionTests.cs b/tests/Nhs.Appointments.Api.UnitTests/Functions/SetSiteInformationForCitizensFunctionTests.cs index e8c156d79..4a79bda76 100644 --- a/tests/Nhs.Appointments.Api.UnitTests/Functions/SetSiteInformationForCitizensFunctionTests.cs +++ b/tests/Nhs.Appointments.Api.UnitTests/Functions/SetSiteInformationForCitizensFunctionTests.cs @@ -48,7 +48,7 @@ public async Task InvokeSiteService_WhenSettingInformationForCitizens(bool opera _userContext.Setup(x => x.UserPrincipal).Returns(userPrincipal); _siteService.Setup(x => x.UpdateInformationForCitizens(It.IsAny(), It.IsAny())) .ReturnsAsync(operationalResult); - _siteService.Setup(x => x.GetSiteByIdAsync(site, It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(site, It.IsAny(), It.IsAny())) .ReturnsAsync(new Site( site, "Test Site", @@ -65,7 +65,8 @@ public async Task InvokeSiteService_WhenSettingInformationForCitizens(bool opera new Location("Coords", [1.234, 5.678]), null, false, - string.Empty + string.Empty, + ReferenceNumberGroup: 0 )); var result = await _sut.Invoke(request); @@ -83,7 +84,7 @@ public async Task DoesNotInvokeService_WhenSiteIsInactive() var infoForCitizens = "Some information for citizens."; var request = new SetSiteInformationForCitizensRequest(site, infoForCitizens); - _siteService.Setup(x => x.GetSiteByIdAsync("test-site", It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync("test-site", It.IsAny(), It.IsAny())) .ReturnsAsync(null as Site); var result = await _sut.Invoke(request); diff --git a/tests/Nhs.Appointments.Api.UnitTests/Functions/SetSiteReferenceDetailsFunctionTests.cs b/tests/Nhs.Appointments.Api.UnitTests/Functions/SetSiteReferenceDetailsFunctionTests.cs index fcd770a0e..dae1be836 100644 --- a/tests/Nhs.Appointments.Api.UnitTests/Functions/SetSiteReferenceDetailsFunctionTests.cs +++ b/tests/Nhs.Appointments.Api.UnitTests/Functions/SetSiteReferenceDetailsFunctionTests.cs @@ -46,7 +46,7 @@ public async Task InvokeSiteService_WhenSettingSiteReferenceDetails(bool operati _siteService.Setup(x => x.UpdateSiteReferenceDetailsAsync(site, odsCode, icb, region)) .ReturnsAsync(operationalResult); - _siteService.Setup(x => x.GetSiteByIdAsync(site, It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(site, It.IsAny(), It.IsAny())) .ReturnsAsync(new Site( site, "Test Site", @@ -63,7 +63,8 @@ public async Task InvokeSiteService_WhenSettingSiteReferenceDetails(bool operati new Location("Coords", [1.234, 5.678]), null, false, - string.Empty + string.Empty, + ReferenceNumberGroup: 0 )); var result = await _sut.Invoke(request); @@ -83,7 +84,7 @@ public async Task DoesNotInvokeService_WhenSiteIsInactive() var region = "R1"; var request = new SetSiteReferenceDetailsRequest(site, odsCode, icb, region); - _siteService.Setup(x => x.GetSiteByIdAsync("test-site", It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync("test-site", It.IsAny(), It.IsAny())) .ReturnsAsync(null as Site); var result = await _sut.Invoke(request); diff --git a/tests/Nhs.Appointments.Api.UnitTests/Notifications/BookingNotifierTests.cs b/tests/Nhs.Appointments.Api.UnitTests/Notifications/BookingNotifierTests.cs index 627221f32..264bfafc1 100644 --- a/tests/Nhs.Appointments.Api.UnitTests/Notifications/BookingNotifierTests.cs +++ b/tests/Nhs.Appointments.Api.UnitTests/Notifications/BookingNotifierTests.cs @@ -49,9 +49,10 @@ public async Task PassesValuesToEmailGovNotifyService() _notificationConfigurationService .Setup(x => x.GetNotificationConfigurationsAsync(It.IsAny(), It.IsAny())).ReturnsAsync( new NotificationConfiguration { EmailTemplateId = EmailTemplateId, SmsTemplateId = SmsTemplateId }); - _siteService.Setup(x => x.GetSiteByIdAsync(It.Is(s => s == Site), It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(It.Is(s => s == Site), It.IsAny(), It.IsAny())) .Returns(Task.FromResult(new Site(Site, "A Clinical Site", "123 Surgery Street", "0113 1111111", "15N", - "R1", "ICB1", "Information For Citizens 123", null, null, SiteStatus.Online, null, string.Empty))); + "R1", "ICB1", "Information For Citizens 123", null, null, SiteStatus.Online, null, string.Empty, + ReferenceNumberGroup: 0))); _clinicalServiceProviderMock.Setup(x => x.Get(Service)).ReturnsAsync(clinicalService); _notificationClient.Setup(x => x.SendEmailAsync(Email, EmailTemplateId, It.Is>( dic => @@ -82,9 +83,10 @@ public async Task PassesValuesToSmsGovNotifyService() _notificationConfigurationService .Setup(x => x.GetNotificationConfigurationsAsync(It.IsAny(), It.IsAny())).ReturnsAsync( new NotificationConfiguration { EmailTemplateId = EmailTemplateId, SmsTemplateId = SmsTemplateId }); - _siteService.Setup(x => x.GetSiteByIdAsync(It.Is(s => s == Site), It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(It.Is(s => s == Site), It.IsAny(), It.IsAny())) .Returns(Task.FromResult(new Site(Site, "A Clinical Site", "123 Surgery Street", "0113 1111111", "15N", - "R1", "ICB1", "Information For Citizens 123", null, null, SiteStatus.Online, null, string.Empty))); + "R1", "ICB1", "Information For Citizens 123", null, null, SiteStatus.Online, null, string.Empty, + ReferenceNumberGroup: 0))); _clinicalServiceProviderMock.Setup(x => x.Get(Service)).ReturnsAsync(clinicalService); _notificationClient.Setup(x => x.SendSmsAsync(PhoneNumber, SmsTemplateId, It.Is>( dic => @@ -130,9 +132,10 @@ public async Task SiteLocationIsRenderedCorrectly(string informationForCitizens, _notificationConfigurationService .Setup(x => x.GetNotificationConfigurationsAsync(It.IsAny(), It.IsAny())).ReturnsAsync( new NotificationConfiguration { EmailTemplateId = EmailTemplateId, SmsTemplateId = SmsTemplateId }); - _siteService.Setup(x => x.GetSiteByIdAsync(It.Is(s => s == Site), It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(It.Is(s => s == Site), It.IsAny(), It.IsAny())) .Returns(Task.FromResult(new Site(Site, "A Clinical Site", "123 Surgery Street", "0113 1111111", "15N", - "R1", "ICB1", informationForCitizens, null, null, SiteStatus.Online, null, string.Empty))); + "R1", "ICB1", informationForCitizens, null, null, SiteStatus.Online, null, string.Empty, + ReferenceNumberGroup: 0))); _clinicalServiceProviderMock.Setup(x => x.Get(Service)).ReturnsAsync(clinicalService); _notificationClient.Setup(x => x.SendEmailAsync(Email, EmailTemplateId, It.Is>( dic => @@ -169,9 +172,10 @@ public async Task GetsNameOfSite() _notificationConfigurationService .Setup(x => x.GetNotificationConfigurationsAsync(It.IsAny(), It.IsAny())).ReturnsAsync( new NotificationConfiguration { EmailTemplateId = EmailTemplateId, SmsTemplateId = SmsTemplateId }); - _siteService.Setup(x => x.GetSiteByIdAsync(It.Is(s => s == Site), It.IsAny())).Returns( + _siteService.Setup(x => x.GetSiteByIdAsync(It.Is(s => s == Site), It.IsAny(), It.IsAny())).Returns( Task.FromResult(new Site(Site, "A Clinical Site", "123 Surgery Street", "0113 1111111", "15N", "R1", "ICB1", "Information For Citizens 123", - Array.Empty(), new Location("point", [0, 0]), SiteStatus.Online, null, string.Empty))).Verifiable(); + Array.Empty(), new Location("point", [0, 0]), SiteStatus.Online, null, string.Empty, + ReferenceNumberGroup: 0))).Verifiable(); _clinicalServiceProviderMock.Setup(x => x.Get(Service)).ReturnsAsync(clinicalService); _notificationClient.Setup( x => x.SendEmailAsync(Email, EmailTemplateId, It.IsAny>())); @@ -193,9 +197,10 @@ public async Task GetsCorrectNotificationConfiguration() _notificationConfigurationService .Setup(x => x.GetNotificationConfigurationsAsync(It.IsAny(), It.IsAny())).ReturnsAsync( new NotificationConfiguration { EmailTemplateId = EmailTemplateId, SmsTemplateId = SmsTemplateId }); - _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny())).Returns( + _siteService.Setup(x => x.GetSiteByIdAsync(It.IsAny(), It.IsAny(), It.IsAny())).Returns( Task.FromResult(new Site(Site, "A Clinical Site", "123 Surgery Street", "0113 1111111", "15N", "R1", "ICB1", "Information For Citizens 123", - Array.Empty(), new Location("point", [0, 0]), SiteStatus.Online, null, string.Empty))); + Array.Empty(), new Location("point", [0, 0]), SiteStatus.Online, null, string.Empty, + ReferenceNumberGroup: 0))); _clinicalServiceProviderMock.Setup(x => x.Get(Service)).ReturnsAsync(clinicalService); _notificationClient.Setup( x => x.SendEmailAsync(Email, EmailTemplateId, It.IsAny>())); diff --git a/tests/Nhs.Appointments.Api.UnitTests/Notifications/UserRolesChangedNotifierTests.cs b/tests/Nhs.Appointments.Api.UnitTests/Notifications/UserRolesChangedNotifierTests.cs index 43f495552..6f955bcd6 100644 --- a/tests/Nhs.Appointments.Api.UnitTests/Notifications/UserRolesChangedNotifierTests.cs +++ b/tests/Nhs.Appointments.Api.UnitTests/Notifications/UserRolesChangedNotifierTests.cs @@ -36,9 +36,10 @@ public async Task PassesValuesToGovNotifyService() _rolesStore.Setup(x => x.GetRoles()).Returns(Task.FromResult>([ new Role { Id = "newRole", Name = "New Role" }, new Role { Id = "removedRole", Name = "Removed Role" } ])); - _siteService.Setup(x => x.GetSiteByIdAsync(It.Is(s => s == Site), It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(It.Is(s => s == Site), It.IsAny(), It.IsAny())) .Returns(Task.FromResult(new Site(Site, "A Clinical Site", "123 Surgery Street", "0113 1111111", "15N", - "R1", "ICB1", "Information For Citizens 123", Array.Empty(), new Location("point", [0, 0]), SiteStatus.Online, null, string.Empty))); + "R1", "ICB1", "Information For Citizens 123", Array.Empty(), new Location("point", [0, 0]), SiteStatus.Online, null, string.Empty, + ReferenceNumberGroup: 0))); _notificationClient.Setup(x => x.SendEmailAsync(Email, TemplateId, It.Is>(dic => @@ -56,9 +57,10 @@ public async Task GetsNameOfSite() _rolesStore.Setup(x => x.GetRoles()).Returns(Task.FromResult>([ new Role { Id = "newRole", Name = "New Role" }, new Role { Id = "removedRole", Name = "Removed Role" } ])); - _siteService.Setup(x => x.GetSiteByIdAsync(It.Is(s => s == Site), It.IsAny())).Returns( + _siteService.Setup(x => x.GetSiteByIdAsync(It.Is(s => s == Site), It.IsAny(), It.IsAny())).Returns( Task.FromResult(new Site(Site, "A Clinical Site", "123 Surgery Street", "0113 1111111", "15N", "R1", "ICB1", "Information For Citizens 123", - Array.Empty(), new Location("point", [0, 0]), SiteStatus.Online, null, string.Empty))).Verifiable(); + Array.Empty(), new Location("point", [0, 0]), SiteStatus.Online, null, string.Empty, + ReferenceNumberGroup: 0))).Verifiable(); await _sut.Notify(nameof(UserRolesChanged), Email, Site, ["newRole"], ["removedRole"]); _siteService.Verify(); @@ -72,9 +74,10 @@ public async Task GetsNamesOfRoles() _rolesStore.Setup(x => x.GetRoles()).Returns(Task.FromResult>([ new Role { Id = "newRole", Name = "New Role" }, new Role { Id = "removedRole", Name = "Removed Role" } ])).Verifiable(); - _siteService.Setup(x => x.GetSiteByIdAsync(It.Is(s => s == Site), It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(It.Is(s => s == Site), It.IsAny(), It.IsAny())) .Returns(Task.FromResult(new Site(Site, "A Clinical Site", "123 Surgery Street", "0113 1111111", "15N", - "R1", "ICB1", "Information For Citizens 123", Array.Empty(), new Location("point", [0, 0]), SiteStatus.Online, null, string.Empty))); + "R1", "ICB1", "Information For Citizens 123", Array.Empty(), new Location("point", [0, 0]), SiteStatus.Online, null, string.Empty, + ReferenceNumberGroup: 0))); await _sut.Notify(nameof(UserRolesChanged), Email, Site, ["newRole"], ["removedRole"]); _rolesStore.Verify(); @@ -88,9 +91,10 @@ public async Task DoesNotSendNotificationIfNoChanges() _rolesStore.Setup(x => x.GetRoles()).Returns(Task.FromResult>([ new Role { Id = "newRole", Name = "New Role" }, new Role { Id = "removedRole", Name = "Removed Role" } ])); - _siteService.Setup(x => x.GetSiteByIdAsync(It.Is(s => s == Site), It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(It.Is(s => s == Site), It.IsAny(), It.IsAny())) .Returns(Task.FromResult(new Site(Site, "A Clinical Site", "123 Surgery Street", "0113 1111111", "15N", - "R1", "ICB1", "Information For Citizens 123", Array.Empty(), new Location("point", [0, 0]), SiteStatus.Online, null, string.Empty))); + "R1", "ICB1", "Information For Citizens 123", Array.Empty(), new Location("point", [0, 0]), SiteStatus.Online, null, string.Empty, + ReferenceNumberGroup: 0))); await _sut.Notify(nameof(UserRolesChanged), Email, Site, [], []); _notificationClient.Verify(x => @@ -106,9 +110,10 @@ public async Task UsesFriendlyNamesForRoles() _rolesStore.Setup(x => x.GetRoles()).Returns(Task.FromResult>([ new Role { Id = "newRole", Name = "New Role" }, new Role { Id = "removedRole", Name = "Removed Role" } ])); - _siteService.Setup(x => x.GetSiteByIdAsync(It.Is(s => s == Site), It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(It.Is(s => s == Site), It.IsAny(), It.IsAny())) .Returns(Task.FromResult(new Site(Site, "A Clinical Site", "123 Surgery Street", "0113 1111111", "15N", - "R1", "ICB1", "Information For Citizens 123", Array.Empty(), new Location("point", [0, 0]), SiteStatus.Online, null, string.Empty))); + "R1", "ICB1", "Information For Citizens 123", Array.Empty(), new Location("point", [0, 0]), SiteStatus.Online, null, string.Empty, + ReferenceNumberGroup: 0))); _notificationClient.Setup(x => x.SendEmailAsync(Email, TemplateId, It.Is>(dic => @@ -127,9 +132,10 @@ public async Task GetsFriendlyRoleNameWhenIdContainsScopePrefixButDatabaseValues _rolesStore.Setup(x => x.GetRoles()).Returns(Task.FromResult>([ new Role { Id = "newRole", Name = "New Role" }, new Role { Id = "removedRole", Name = "Removed Role" } ])); - _siteService.Setup(x => x.GetSiteByIdAsync(It.Is(s => s == Site), It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(It.Is(s => s == Site), It.IsAny(), It.IsAny())) .Returns(Task.FromResult(new Site(Site, "A Clinical Site", "123 Surgery Street", "0113 1111111", "15N", - "R1", "ICB1", "Information For Citizens 123", Array.Empty(), new Location("point", [0, 0]), SiteStatus.Online, null, string.Empty))); + "R1", "ICB1", "Information For Citizens 123", Array.Empty(), new Location("point", [0, 0]), SiteStatus.Online, null, string.Empty, + ReferenceNumberGroup: 0))); _notificationClient.Setup(x => x.SendEmailAsync(Email, TemplateId, It.Is>(dic => @@ -149,9 +155,10 @@ public async Task GetsCorrectNotificationConfiguration() _rolesStore.Setup(x => x.GetRoles()).Returns(Task.FromResult>([ new Role { Id = "newRole", Name = "New Role" }, new Role { Id = "removedRole", Name = "Removed Role" } ])); - _siteService.Setup(x => x.GetSiteByIdAsync(It.Is(s => s == Site), It.IsAny())) + _siteService.Setup(x => x.GetSiteByIdAsync(It.Is(s => s == Site), It.IsAny(), It.IsAny())) .Returns(Task.FromResult(new Site(Site, "A Clinical Site", "123 Surgery Street", "0113 1111111", "15N", - "R1", "ICB1", "Information For Citizens 123", Array.Empty(), new Location("point", [0, 0]), SiteStatus.Online, null, string.Empty))); + "R1", "ICB1", "Information For Citizens 123", Array.Empty(), new Location("point", [0, 0]), SiteStatus.Online, null, string.Empty, + ReferenceNumberGroup: 0))); await _sut.Notify(nameof(UserRolesChanged), Email, Site, ["newRole"], ["removedRole"]); _notificationConfigurationService.Verify(); diff --git a/tests/Nhs.Appointments.Api.UnitTests/Validators/SiteBasedResourceRequestValidatorTests.cs b/tests/Nhs.Appointments.Api.UnitTests/Validators/SiteBasedResourceRequestValidatorTests.cs index 12a48c6d2..80115db09 100644 --- a/tests/Nhs.Appointments.Api.UnitTests/Validators/SiteBasedResourceRequestValidatorTests.cs +++ b/tests/Nhs.Appointments.Api.UnitTests/Validators/SiteBasedResourceRequestValidatorTests.cs @@ -11,7 +11,7 @@ public class SiteBasedRequestValidatorTests [Fact] public void Validate_ReturnsError_WhenSiteIsBlank() { - var testRequest = new SiteBasedResourceRequest("", "*"); + var testRequest = new SiteBasedResourceRequest("", false,"*"); var result = _sut.Validate(testRequest); result.IsValid.Should().BeFalse(); result.Errors.Should().HaveCount(1); @@ -21,7 +21,7 @@ public void Validate_ReturnsError_WhenSiteIsBlank() [Fact] public void Validate_ReturnsSuccess_WhenSiteBasedRequestIsValid() { - var testRequest = new SiteBasedResourceRequest("site", "*"); + var testRequest = new SiteBasedResourceRequest("test", false,"*"); var result = _sut.Validate(testRequest); result.IsValid.Should().BeTrue(); result.Errors.Should().HaveCount(0); diff --git a/tests/Nhs.Appointments.Core.UnitTests/BulkImport/SiteStatusDataImportHandlerTests.cs b/tests/Nhs.Appointments.Core.UnitTests/BulkImport/SiteStatusDataImportHandlerTests.cs index 28fa83af9..c71db92bc 100644 --- a/tests/Nhs.Appointments.Core.UnitTests/BulkImport/SiteStatusDataImportHandlerTests.cs +++ b/tests/Nhs.Appointments.Core.UnitTests/BulkImport/SiteStatusDataImportHandlerTests.cs @@ -44,7 +44,8 @@ public async Task CanReadSiteData() new Location("Test", [1.123, 3.321]), null, null, - string.Empty), + string.Empty, + ReferenceNumberGroup: 0), new( id2.ToString(), "Test Site 2", @@ -58,7 +59,8 @@ public async Task CanReadSiteData() new Location("Test", [1.123, 3.321]), null, null, - string.Empty) + string.Empty, + ReferenceNumberGroup: 0) }; var input = CsvFileBuilder.BuildInputCsv(Headers, inputRows); @@ -146,7 +148,8 @@ public async Task FailsToMatchSite_ReportsBadData() new Location("Test", [1.123, 3.321]), null, null, - string.Empty), + string.Empty, + ReferenceNumberGroup: 0), new( Guid.NewGuid().ToString(), "Test Site 2", @@ -160,7 +163,8 @@ public async Task FailsToMatchSite_ReportsBadData() new Location("Test", [1.123, 3.321]), null, null, - string.Empty) + string.Empty, + ReferenceNumberGroup: 0) }; var input = CsvFileBuilder.BuildInputCsv(Headers, inputRows); @@ -207,7 +211,8 @@ public async Task FailsToUpdateSiteSoftDeletionStatus_ReportsFailure() new Location("Test", [1.123, 3.321]), null, null, - string.Empty), + string.Empty, + ReferenceNumberGroup: 0), new( id2.ToString(), "Test Site 2", @@ -221,7 +226,8 @@ public async Task FailsToUpdateSiteSoftDeletionStatus_ReportsFailure() new Location("Test", [1.123, 3.321]), null, null, - string.Empty) + string.Empty, + ReferenceNumberGroup: 0) }; var input = CsvFileBuilder.BuildInputCsv(Headers, inputRows); diff --git a/tests/Nhs.Appointments.Core.UnitTests/BulkImport/UserDataImportHandlerTests.cs b/tests/Nhs.Appointments.Core.UnitTests/BulkImport/UserDataImportHandlerTests.cs index ec0a1ff8b..f920d4472 100644 --- a/tests/Nhs.Appointments.Core.UnitTests/BulkImport/UserDataImportHandlerTests.cs +++ b/tests/Nhs.Appointments.Core.UnitTests/BulkImport/UserDataImportHandlerTests.cs @@ -39,7 +39,7 @@ public async Task CanReadUserData_AndSetsSiteScopedPermissions() var file = new FormFile(stream, 0, stream.Length, "Test", "test.csv"); var sites = GetSites(); - _siteServiceMock.SetupSequence(s => s.GetSiteByIdAsync(It.IsAny(), "*")) + _siteServiceMock.SetupSequence(s => s.GetSiteByIdAsync(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(sites[0]) .ReturnsAsync(sites[1]) .ReturnsAsync(sites[2]) @@ -77,7 +77,7 @@ public async Task OktaIsDisabled_OktaUsersNotProcessed() var sites = GetSites(); - _siteServiceMock.SetupSequence(s => s.GetSiteByIdAsync(It.IsAny(), "*")) + _siteServiceMock.SetupSequence(s => s.GetSiteByIdAsync(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(sites[0]) .ReturnsAsync(sites[1]); _userServiceMock.Setup(x => x.UpdateUserRoleAssignmentsAsync(It.IsAny(), It.IsAny(), It.IsAny>(), false)) @@ -108,7 +108,7 @@ public async Task OktaIsEnabled_OktaUsersProcessed() var sites = GetSites(); - _siteServiceMock.SetupSequence(s => s.GetSiteByIdAsync(It.IsAny(), "*")) + _siteServiceMock.SetupSequence(s => s.GetSiteByIdAsync(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(sites[0]) .ReturnsAsync(sites[1]); _userServiceMock.Setup(x => x.UpdateUserRoleAssignmentsAsync(It.IsAny(), It.IsAny(), It.IsAny>(), false)) @@ -147,7 +147,7 @@ public async Task CanValidateOktaUser() var sites = GetSites(); - _siteServiceMock.SetupSequence(s => s.GetSiteByIdAsync(It.IsAny(), "*")) + _siteServiceMock.SetupSequence(s => s.GetSiteByIdAsync(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(sites[0]) .ReturnsAsync(sites[1]) .ReturnsAsync(sites[2]) @@ -173,7 +173,7 @@ public async Task ReportsIncorrectSiteId_WhenNotFound() var sites = GetSites(); - _siteServiceMock.Setup(s => s.GetSiteByIdAsync(It.IsAny(), "*")) + _siteServiceMock.Setup(s => s.GetSiteByIdAsync(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(null as Site); _emailWhitelistStore.Setup(x => x.GetWhitelistedEmails()) .ReturnsAsync(["@nhs.net"]); @@ -195,7 +195,7 @@ public async Task ReportsInvalidUserRoles() var sites = GetSites(); - _siteServiceMock.SetupSequence(s => s.GetSiteByIdAsync(It.IsAny(), "*")) + _siteServiceMock.SetupSequence(s => s.GetSiteByIdAsync(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(sites[0]) .ReturnsAsync(sites[1]) .ReturnsAsync(sites[2]) @@ -276,7 +276,7 @@ public async Task ReadsUserData_AndAddsUserToOkta() var sites = GetSites(); - _siteServiceMock.SetupSequence(s => s.GetSiteByIdAsync(It.IsAny(), "*")) + _siteServiceMock.SetupSequence(s => s.GetSiteByIdAsync(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(sites[0]) .ReturnsAsync(sites[1]); _userServiceMock.Setup(x => x.UpdateUserRoleAssignmentsAsync(It.IsAny(), It.IsAny(), It.IsAny>(), false)) @@ -312,7 +312,7 @@ public async Task ReadsUserData_AndReportsUnsuccessfulOktaReason_AndDoesntCallUs var sites = GetSites(); - _siteServiceMock.SetupSequence(s => s.GetSiteByIdAsync(It.IsAny(), "*")) + _siteServiceMock.SetupSequence(s => s.GetSiteByIdAsync(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(sites[0]) .ReturnsAsync(sites[1]); _userServiceMock.Setup(x => x.UpdateUserRoleAssignmentsAsync(It.IsAny(), It.IsAny(), It.IsAny>(), false)) @@ -349,7 +349,7 @@ public async Task ReadsUserData_AndReportsUnsuccesfulOktaCreation_WhenEmailDomai var sites = GetSites(); - _siteServiceMock.SetupSequence(s => s.GetSiteByIdAsync(It.IsAny(), "*")) + _siteServiceMock.SetupSequence(s => s.GetSiteByIdAsync(It.IsAny(), It.IsAny(), It.IsAny())) .ReturnsAsync(sites[0]) .ReturnsAsync(sites[1]); _userServiceMock.Setup(x => x.UpdateUserRoleAssignmentsAsync(It.IsAny(), It.IsAny(), It.IsAny>(), false)) @@ -611,7 +611,8 @@ private List GetSites() foreach (var row in InputRows) { - sites.Add(new Site(row.Split(',')[3], "Test", "Test Address", "07777777777", "ABC123", "Test Region", "ICB", "", [], new Location("Test", [1.0, 60.0]), SiteStatus.Online, null, string.Empty)); + sites.Add(new Site(row.Split(',')[3], "Test", "Test Address", "07777777777", "ABC123", "Test Region", "ICB", "", [], new Location("Test", [1.0, 60.0]), SiteStatus.Online, null, string.Empty, + ReferenceNumberGroup: 0)); } return sites; diff --git a/tests/Nhs.Appointments.Core.UnitTests/ReferenceNumberProviderTests.cs b/tests/Nhs.Appointments.Core.UnitTests/ReferenceNumberProviderTests.cs index 6439a0ea3..d9ae21bb5 100644 --- a/tests/Nhs.Appointments.Core.UnitTests/ReferenceNumberProviderTests.cs +++ b/tests/Nhs.Appointments.Core.UnitTests/ReferenceNumberProviderTests.cs @@ -1,4 +1,6 @@ +using Microsoft.Extensions.Caching.Memory; using Nhs.Appointments.Core.Bookings; +using Nhs.Appointments.Core.Caching; using Nhs.Appointments.Core.Sites; namespace Nhs.Appointments.Core.UnitTests; @@ -6,47 +8,60 @@ namespace Nhs.Appointments.Core.UnitTests; public class ReferenceNumberProviderTests { private readonly ReferenceNumberProvider _sut; - private readonly Mock _siteStore = new(); + private readonly Mock _siteService = new(); private readonly Mock _referenceNumberDocumentStore = new(); private readonly Mock _timeProvider = new(); - + private readonly Mock _memoryCache = new(); + private readonly Mock _cacheEntry = new(); public ReferenceNumberProviderTests() { - _sut = new ReferenceNumberProvider(_siteStore.Object, _referenceNumberDocumentStore.Object, _timeProvider.Object); + _sut = new ReferenceNumberProvider(_siteService.Object, new CacheService(_memoryCache.Object, TimeProvider.System), _referenceNumberDocumentStore.Object, _timeProvider.Object); } [Fact] public async Task GetReferenceNumber_AssignsRefGroup_WhenNotCurrentAssigned() { - _siteStore.Setup(x => x.GetReferenceNumberGroup("test")).ReturnsAsync(0); + _memoryCache.Setup(x => x.CreateEntry(It.IsAny())).Returns(_cacheEntry.Object); + _siteService.Setup(x => x.GetSiteByIdAsync("test", It.IsAny(), It.IsAny())).ReturnsAsync(new Site("test", "NAME", "ADDRESS", + "PHONENUMBER", "ODSCODE", "REGION", "ICB", "INFO", + new List(), new Location("",[0, 0]), SiteStatus.Online, false, "TYPE", 0)); _referenceNumberDocumentStore.Setup(x => x.AssignReferenceGroup()).ReturnsAsync(14); await _sut.GetReferenceNumber("test"); _referenceNumberDocumentStore.Verify(x => x.AssignReferenceGroup(), Times.Once()); - _siteStore.Verify(x => x.AssignPrefix("test", 14), Times.Once()); + _siteService.Verify(x => x.AssignPrefix("test", 14), Times.Once()); } [Fact] public async Task GetReferenceNumber_DoesNotAssignsRefGroup_WhenAlreadyAssigned() { - _siteStore.Setup(x => x.GetReferenceNumberGroup("test")).ReturnsAsync(14); + _memoryCache.Setup(x => x.CreateEntry(It.IsAny())).Returns(_cacheEntry.Object); + _siteService.Setup(x => x.GetSiteByIdAsync("test", It.IsAny(), It.IsAny())).ReturnsAsync(new Site( + "test", "NAME", "ADDRESS", "PHONENUMBER", "ODSCODE", "REGION", + "ICB", "INFO", new List(), new Location("", + [0, 0]), SiteStatus.Online, false, "TYPE", 14)); await _sut.GetReferenceNumber("test"); _referenceNumberDocumentStore.Verify(x => x.AssignReferenceGroup(), Times.Never); - _siteStore.Verify(x => x.AssignPrefix("test", It.IsAny()), Times.Never); + _siteService.Verify(x => x.AssignPrefix("test", It.IsAny()), Times.Never); } [Fact] public async Task GetReferenceNumber_GeneratesCorrectlyFormattedNumber() { + _memoryCache.Setup(x => x.CreateEntry(It.IsAny())).Returns(_cacheEntry.Object); _timeProvider.Setup(x => x.GetUtcNow()).Returns(new DateTime(2077, 1, 31, 9, 0, 59)); _referenceNumberDocumentStore.Setup(x => x.GetNextSequenceNumber(14)).ReturnsAsync(2345); - _siteStore.Setup(x => x.GetReferenceNumberGroup("test")).ReturnsAsync(14); + _siteService.Setup(x => x.GetSiteByIdAsync("test", It.IsAny(), It.IsAny())).ReturnsAsync(new Site( + "test", "NAME", "ADDRESS", "PHONENUMBER", "ODSCODE", "REGION", + "ICB", "INFO", new List(), new Location("", + [0, 0]), SiteStatus.Online, false, "TYPE", 14)); var result = await _sut.GetReferenceNumber("test"); + result.Should().Be("14-90-002345"); } } diff --git a/tests/Nhs.Appointments.Core.UnitTests/Reports/SiteReportServiceMockData.cs b/tests/Nhs.Appointments.Core.UnitTests/Reports/SiteReportServiceMockData.cs index e9f1767e9..dd18806d7 100644 --- a/tests/Nhs.Appointments.Core.UnitTests/Reports/SiteReportServiceMockData.cs +++ b/tests/Nhs.Appointments.Core.UnitTests/Reports/SiteReportServiceMockData.cs @@ -29,7 +29,8 @@ public static class SiteReportServiceMockData InformationForCitizens: "", Accessibilities: new List { new("accessibility/access_need_1", "true") }, status: SiteStatus.Online, isDeleted: null, - Type: "GP Practice"), + Type: "GP Practice", + ReferenceNumberGroup: 0), new( Site2Guid.ToString(), "Site 2", @@ -42,7 +43,8 @@ public static class SiteReportServiceMockData InformationForCitizens: "", Accessibilities: new List { new("accessibility/access_need_1", "true") }, status: SiteStatus.Offline, isDeleted: null, - Type: "GP Practice"), + Type: "GP Practice", + ReferenceNumberGroup: 0), new( Site3Guid.ToString(), "Site 3", @@ -55,7 +57,8 @@ public static class SiteReportServiceMockData InformationForCitizens: "", Accessibilities: new List { new("accessibility/access_need_1", "true") }, status: null, isDeleted: null, - Type: "GP Practice") + Type: "GP Practice", + ReferenceNumberGroup: 0) ]; public static readonly ClinicalServiceType[] MockClinicalServices = diff --git a/tests/Nhs.Appointments.Core.UnitTests/Reports/SiteSummary/SiteSummaryTriggerTests.cs b/tests/Nhs.Appointments.Core.UnitTests/Reports/SiteSummary/SiteSummaryTriggerTests.cs index 1b26d31ae..16c0787ff 100644 --- a/tests/Nhs.Appointments.Core.UnitTests/Reports/SiteSummary/SiteSummaryTriggerTests.cs +++ b/tests/Nhs.Appointments.Core.UnitTests/Reports/SiteSummary/SiteSummaryTriggerTests.cs @@ -40,7 +40,8 @@ public async Task When_LastRun_Null() new Location("test", [0.0]), SiteStatus.Online, null, - string.Empty) + string.Empty, + ReferenceNumberGroup: 0) }); await _sut.Trigger(); @@ -78,7 +79,8 @@ public async Task When_LastRun_Finished_DayOld() new Location("test", [0.0]), SiteStatus.Online, null, - string.Empty) + string.Empty, + ReferenceNumberGroup: 0) }); var site = "site-1"; @@ -121,7 +123,8 @@ public async Task When_RunningFullDay_Iterates_AsExpected() new Location("test", [0.0]), null, null, - string.Empty) + string.Empty, + ReferenceNumberGroup: 0) }); var site = "site-1"; @@ -235,7 +238,8 @@ public async Task When_LastRun_NotFinished_DayOld() "INFO", new Accessibility[] { }, new Location("test", [0.0]), - null, null, string.Empty) + null, null, string.Empty, + ReferenceNumberGroup: 0) }); var site = "site-1"; @@ -276,7 +280,8 @@ public async Task When_LastRun_NotFinished_SameDay() "INFO", new Accessibility[] { }, new Location("test", [0.0]), - null, null, string.Empty) + null, null, string.Empty, + ReferenceNumberGroup: 0) }); var site = "site-1"; @@ -338,7 +343,8 @@ public async Task When_Multiple_Sites() "INFO", new Accessibility[] { }, new Location("test", [0.0]), - SiteStatus.Online, null, string.Empty), + SiteStatus.Online, null, string.Empty, + ReferenceNumberGroup: 0), new ( "site-2", "site-name-2", @@ -350,7 +356,8 @@ public async Task When_Multiple_Sites() "INFO", new Accessibility[] { }, new Location("test", [0.0]), - SiteStatus.Online, null, string.Empty) + SiteStatus.Online, null, string.Empty, + ReferenceNumberGroup: 0) }); var site1 = "site-1"; diff --git a/tests/Nhs.Appointments.Core.UnitTests/SiteServiceCacheTestsMockData.cs b/tests/Nhs.Appointments.Core.UnitTests/SiteServiceCacheTestsMockData.cs index 4e5f34827..2892dd66c 100644 --- a/tests/Nhs.Appointments.Core.UnitTests/SiteServiceCacheTestsMockData.cs +++ b/tests/Nhs.Appointments.Core.UnitTests/SiteServiceCacheTestsMockData.cs @@ -18,7 +18,8 @@ public static class SiteServiceCacheTestsMockData InformationForCitizens: "", Accessibilities: new List { new("accessibility/access_need_1", "true") }, status: SiteStatus.Online, isDeleted: false, - Type: string.Empty), + Type: string.Empty, + ReferenceNumberGroup: 0), new( "3ad2deb1-791b-452d-95dc-7090edd97f9a", "Site 2", @@ -31,7 +32,8 @@ public static class SiteServiceCacheTestsMockData InformationForCitizens: "", Accessibilities: new List { new("accessibility/access_need_1", "true") }, status: SiteStatus.Offline, isDeleted: true, - Type: string.Empty), + Type: string.Empty, + ReferenceNumberGroup: 0), new( "0c06c137-2f8a-4334-a594-0632d0407966", "Site 3", @@ -44,7 +46,8 @@ public static class SiteServiceCacheTestsMockData InformationForCitizens: "", Accessibilities: new List { new("accessibility/access_need_1", "true") }, status: SiteStatus.Offline, isDeleted: null, - Type: string.Empty), + Type: string.Empty, + ReferenceNumberGroup: 0), new( "b40d5219-e1c5-4f28-a2c4-d40f68bcde36", "Site 4", @@ -57,7 +60,8 @@ public static class SiteServiceCacheTestsMockData InformationForCitizens: "", Accessibilities: new List { new("accessibility/access_need_1", "true") }, status: SiteStatus.Online, isDeleted: true, - Type: string.Empty) + Type: string.Empty, + ReferenceNumberGroup: 0) ]; public static readonly Site[] MockOnlyNonDeletedSites = @@ -74,7 +78,8 @@ public static class SiteServiceCacheTestsMockData InformationForCitizens: "", Accessibilities: new List { new("accessibility/access_need_1", "true") }, status: SiteStatus.Online, isDeleted: false, - Type: string.Empty), + Type: string.Empty, + ReferenceNumberGroup: 0), new( "0c06c137-2f8a-4334-a594-0632d0407966", "Site 3", @@ -87,7 +92,8 @@ public static class SiteServiceCacheTestsMockData InformationForCitizens: "", Accessibilities: new List { new("accessibility/access_need_1", "true") }, status: SiteStatus.Offline, isDeleted: null, - Type: string.Empty) + Type: string.Empty, + ReferenceNumberGroup: 0) ]; public static Site CreateMockSite(string id, string name) @@ -104,6 +110,7 @@ public static Site CreateMockSite(string id, string name) InformationForCitizens: "", Accessibilities: new List { new("accessibility/access_need_1", "true") }, status: SiteStatus.Offline, isDeleted: null, - Type: string.Empty); + Type: string.Empty, + ReferenceNumberGroup: 0); } } diff --git a/tests/Nhs.Appointments.Core.UnitTests/SiteServiceTests.cs b/tests/Nhs.Appointments.Core.UnitTests/SiteServiceTests.cs index 0e162f976..c885cc961 100644 --- a/tests/Nhs.Appointments.Core.UnitTests/SiteServiceTests.cs +++ b/tests/Nhs.Appointments.Core.UnitTests/SiteServiceTests.cs @@ -27,6 +27,8 @@ public SiteServiceTests() SiteSupportsServiceSlidingCacheSlideThresholdSeconds = 900, SiteSupportsServiceSlidingCacheAbsoluteExpirationSeconds = 14400, SiteSupportsServiceBatchMultiplier = 2, + SiteCacheDurationMinutes = 5, + SiteSlideCacheDurationMinutes = 1, }); var cacheService = new CacheService(_memoryCache.Object, TimeProvider.System); @@ -51,7 +53,8 @@ public async Task GetSiteByIdAsync_ReturnsRequestedSite() InformationForCitizens: "", Accessibilities: new List { new Accessibility(Id: "Accessibility 1", Value: "true") }, status: SiteStatus.Online, isDeleted: null, - Type: string.Empty); + Type: string.Empty, + ReferenceNumberGroup: 0); var expectedSite = new Site( Id: siteId, @@ -65,7 +68,8 @@ public async Task GetSiteByIdAsync_ReturnsRequestedSite() InformationForCitizens: "", Accessibilities: new List { new Accessibility(Id: "Accessibility 1", Value: "true") }, status: SiteStatus.Online, isDeleted: null, - Type: string.Empty); + Type: string.Empty, + ReferenceNumberGroup: 0); _siteStore.Setup(x => x.GetSiteById("6877d86e-c2df-4def-8508-e1eccf0ea6ba")).ReturnsAsync(site); var result = await _sut.GetSiteByIdAsync(siteId); @@ -80,7 +84,7 @@ public async Task GetSiteByIdAsync_ReturnsDefault_WhenSiteIsNotFound(string scop const string siteId = "9a06bacd-e916-4c10-8263-21451ca751b8"; _siteStore.Setup(x => x.GetSiteById(siteId)).ReturnsAsync((Site)null!); - var result = await _sut.GetSiteByIdAsync(siteId, scope); + var result = await _sut.GetSiteByIdAsync(siteId, true, scope); result.Should().BeNull(); } @@ -101,7 +105,8 @@ public async Task GetSitesPreview_CachedSitesFound_ReturningCachedSites() InformationForCitizens: "", Accessibilities: new List() {new (Id: "accessibility/access_need_1", Value: "true")}, status: SiteStatus.Online, isDeleted: null, - Type: string.Empty), + Type: string.Empty, + ReferenceNumberGroup: 0), new Site( Id: "ABC02", Name: "Site 2", @@ -114,7 +119,8 @@ public async Task GetSitesPreview_CachedSitesFound_ReturningCachedSites() InformationForCitizens: "", Accessibilities: new List() {new (Id: "accessibility/access_need_1", Value: "false")}, status: SiteStatus.Online, isDeleted: null, - Type: string.Empty) + Type: string.Empty, + ReferenceNumberGroup: 0) }; object outSites = new CacheService.CacheObject>(sites); _memoryCache.Setup(x => x.TryGetValue("sites", out outSites)).Returns(true); @@ -142,7 +148,8 @@ public async Task GetSitesPreview_CachedSitesNotFound_ReturningAllSitesFromSiteS InformationForCitizens: "", Accessibilities: new List() {new (Id: "accessibility/access_need_1", Value: "true")}, status: SiteStatus.Online, isDeleted: null, - Type: string.Empty), + Type: string.Empty, + ReferenceNumberGroup: 0), new Site( Id: "ABC02", Name: "Site 2", @@ -155,7 +162,8 @@ public async Task GetSitesPreview_CachedSitesNotFound_ReturningAllSitesFromSiteS InformationForCitizens: "", Accessibilities: new List() {new (Id: "accessibility/access_need_1", Value: "false")}, status: SiteStatus.Online, isDeleted: null, - Type: string.Empty) + Type: string.Empty, + ReferenceNumberGroup: 0) }; object outSites = null; _memoryCache.Setup(x => x.TryGetValue("sites", out outSites)).Returns(false); @@ -186,7 +194,8 @@ public async Task GetSitesInRegion_CachedSitesNotFound_ReturnsAllSitesFilteredWi InformationForCitizens: "", Accessibilities: new List() {new (Id: "accessibility/access_need_1", Value: "true")}, status: SiteStatus.Online, isDeleted: null, - Type: string.Empty), + Type: string.Empty, + ReferenceNumberGroup: 0), }; _siteStore.Setup(x => x.GetSitesInRegionAsync("R1")).ReturnsAsync(sites); @@ -228,7 +237,8 @@ public async Task QuerySitesAsync_FiltersSitesOnAccessNeeds() new Location("Point", [-1.6610648, 53.795467]), null, null, - string.Empty), + string.Empty, + ReferenceNumberGroup: 0), new("test321", "Test Site 2", string.Empty, @@ -243,7 +253,8 @@ public async Task QuerySitesAsync_FiltersSitesOnAccessNeeds() new Location("Point", [-1.6610648, 53.795467]), null, null, - string.Empty), + string.Empty, + ReferenceNumberGroup: 0), new("test456", "Test Site 3", string.Empty, @@ -258,7 +269,8 @@ public async Task QuerySitesAsync_FiltersSitesOnAccessNeeds() new Location("Point", [-1.6610648, 53.795467]), null, null, - string.Empty), + string.Empty, + ReferenceNumberGroup: 0), }; _siteStore.Setup(x => x.GetAllSites()) @@ -269,7 +281,7 @@ public async Task QuerySitesAsync_FiltersSitesOnAccessNeeds() result.Count().Should().Be(2); result.Any(r => r.Site.Id == "test456").Should().BeFalse(); - _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny>()), Times.Never); + _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); } [Fact] @@ -296,7 +308,8 @@ public async Task QuerySitesAsync_FiltersSitesOnDistance() new Location("Point", [-1.6610648, 53.795467]), null, null, - string.Empty), + string.Empty, + ReferenceNumberGroup: 0), new("test321", "Test Site 2", string.Empty, @@ -307,7 +320,8 @@ public async Task QuerySitesAsync_FiltersSitesOnDistance() new Location("Point", [-1.6610648, 53.795467]), null, null, - string.Empty), + string.Empty, + ReferenceNumberGroup: 0), new("test456", "Test Site 3", string.Empty, @@ -318,7 +332,8 @@ public async Task QuerySitesAsync_FiltersSitesOnDistance() new Location("Point", [1.6610648, 45.795467]), null, null, - string.Empty), + string.Empty, + ReferenceNumberGroup: 0), }; _siteStore.Setup(x => x.GetAllSites()) @@ -329,7 +344,7 @@ public async Task QuerySitesAsync_FiltersSitesOnDistance() result.Count().Should().Be(2); result.Any(r => r.Site.Id == "test456").Should().BeFalse(); - _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny>()), Times.Never); + _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); } [Fact] @@ -362,7 +377,8 @@ public async Task QuerySitesAsync_FiltersSitesOnService() new Location("Point", [-1.6610648, 53.795467]), null, null, - string.Empty), + string.Empty, + ReferenceNumberGroup: 0), new("test321", "Test Site 2", string.Empty, @@ -373,7 +389,8 @@ public async Task QuerySitesAsync_FiltersSitesOnService() new Location("Point", [-1.6610648, 53.795467]), null, null, - string.Empty), + string.Empty, + ReferenceNumberGroup: 0), new("test456", "Test Site 3", string.Empty, @@ -384,12 +401,13 @@ public async Task QuerySitesAsync_FiltersSitesOnService() new Location("Point", [-1.6610648, 53.795467]), null, null, - string.Empty), + string.Empty, + ReferenceNumberGroup: 0), }; _siteStore.Setup(x => x.GetAllSites()) .ReturnsAsync(sites); - _availabilityStore.SetupSequence(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny>())) + _availabilityStore.SetupSequence(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny())) .ReturnsAsync(true) .ReturnsAsync(true) .ReturnsAsync(false); @@ -399,7 +417,7 @@ public async Task QuerySitesAsync_FiltersSitesOnService() result.Count().Should().Be(2); result.Any(r => r.Site.Id == "test456").Should().BeFalse(); - _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny>()), Times.Exactly(3)); + _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Exactly(3)); } [Fact] @@ -437,7 +455,8 @@ public async Task QuerySitesAsync_RemovesDuplicates() new Location("Point", [-1.6610648, 53.795467]), null, null, - string.Empty), + string.Empty, + ReferenceNumberGroup: 0), new("test321", "Test Site 2", string.Empty, @@ -452,7 +471,8 @@ public async Task QuerySitesAsync_RemovesDuplicates() new Location("Point", [-1.6610648, 53.795467]), null, null, - string.Empty), + string.Empty, + ReferenceNumberGroup: 0), new("test321", "Test Site 2", string.Empty, @@ -467,19 +487,20 @@ public async Task QuerySitesAsync_RemovesDuplicates() new Location("Point", [-1.6610648, 53.795467]), null, null, - string.Empty), + string.Empty, + ReferenceNumberGroup: 0), }; _siteStore.Setup(x => x.GetAllSites()) .ReturnsAsync(sites); - _availabilityStore.Setup(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny>())) + _availabilityStore.Setup(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny())) .ReturnsAsync(true); var result = await _sut.QuerySitesAsync([.. filters], 50, true); result.Count().Should().Be(2); - _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny>()), Times.Exactly(3)); + _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Exactly(3)); } [Fact] @@ -523,7 +544,8 @@ public async Task QuerySitesAsync_CorrectlyHandlesMultipleFilters_AndReturnsAllS new Location("Point", [-1.6610648, 53.795467]), null, null, - string.Empty), + string.Empty, + ReferenceNumberGroup: 0), new("test321", "Test Site 2", string.Empty, @@ -538,7 +560,8 @@ public async Task QuerySitesAsync_CorrectlyHandlesMultipleFilters_AndReturnsAllS new Location("Point", [-1.6610648, 53.795467]), null, null, - string.Empty), + string.Empty, + ReferenceNumberGroup: 0), new("test456", "Test Site 3", string.Empty, @@ -553,19 +576,20 @@ public async Task QuerySitesAsync_CorrectlyHandlesMultipleFilters_AndReturnsAllS new Location("Point", [-1.6610648, 53.795467]), null, null, - string.Empty), + string.Empty, + ReferenceNumberGroup: 0), }; _siteStore.Setup(x => x.GetAllSites()) .ReturnsAsync(sites); - _availabilityStore.Setup(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny>())) + _availabilityStore.Setup(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny())) .ReturnsAsync(true); var result = await _sut.QuerySitesAsync([.. filters], 50, true); result.Count().Should().Be(3); - _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny>()), Times.Exactly(3)); + _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Exactly(3)); } [Fact] @@ -609,7 +633,8 @@ public async Task QuerySitesAsync_CorrectlyHandlesMultipleFilters_AndFiltersOutI new Location("Point", [-1.6610648, 53.795467]), null, null, - string.Empty), + string.Empty, + ReferenceNumberGroup: 0), new("test321", "Test Site 2", string.Empty, @@ -624,7 +649,8 @@ public async Task QuerySitesAsync_CorrectlyHandlesMultipleFilters_AndFiltersOutI new Location("Point", [-1.6610648, 53.795467]), null, null, - string.Empty), + string.Empty, + ReferenceNumberGroup: 0), new("test456", "Test Site 3", string.Empty, @@ -639,7 +665,8 @@ public async Task QuerySitesAsync_CorrectlyHandlesMultipleFilters_AndFiltersOutI new Location("Point", [-1.6610648, 53.795467]), null, null, - string.Empty), + string.Empty, + ReferenceNumberGroup: 0), new("test654", "Test Site 4", string.Empty, @@ -654,12 +681,13 @@ public async Task QuerySitesAsync_CorrectlyHandlesMultipleFilters_AndFiltersOutI new Location("Point", [-1.6610648, 53.795467]), null, null, - string.Empty), + string.Empty, + ReferenceNumberGroup: 0), }; _siteStore.Setup(x => x.GetAllSites()) .ReturnsAsync(sites); - _availabilityStore.SetupSequence(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny>())) + _availabilityStore.SetupSequence(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny())) .ReturnsAsync(true) .ReturnsAsync(true) .ReturnsAsync(true) @@ -669,7 +697,7 @@ public async Task QuerySitesAsync_CorrectlyHandlesMultipleFilters_AndFiltersOutI result.Count().Should().Be(3); - _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny>()), Times.Exactly(4)); + _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Exactly(4)); } [Fact] @@ -697,7 +725,8 @@ public async Task QuerySitesAsync_FiltersBySiteType() new Location("Point", [-1.6610648, 53.795467]), null, null, - "Pharmacy"), + "Pharmacy", + ReferenceNumberGroup: 0), new("test321", "Test Site 2", string.Empty, @@ -708,7 +737,8 @@ public async Task QuerySitesAsync_FiltersBySiteType() new Location("Point", [-1.6610648, 53.795467]), null, null, - "gp PrActiCE"), // Ensure the filter is case insensitive + "gp PrActiCE", + ReferenceNumberGroup: 0), // Ensure the filter is case insensitive new("test456", "Test Site 3", string.Empty, @@ -719,7 +749,8 @@ public async Task QuerySitesAsync_FiltersBySiteType() new Location("Point", [-1.6610648, 53.795467]), null, null, - "PCN Site"), + "PCN Site", + ReferenceNumberGroup: 0), new("test654", "Test Site 4", string.Empty, @@ -730,7 +761,8 @@ public async Task QuerySitesAsync_FiltersBySiteType() new Location("Point", [-1.6610648, 53.795467]), null, null, - "Some other site type"), + "Some other site type", + ReferenceNumberGroup: 0), }; _siteStore.Setup(x => x.GetAllSites()) @@ -740,7 +772,7 @@ public async Task QuerySitesAsync_FiltersBySiteType() result.Count().Should().Be(1); - _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny>()), Times.Never); + _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); } [Fact] @@ -769,7 +801,8 @@ public async Task QuerySitesAsync_FiltersBySiteType_AndOdsCode() new Location("Point", [-1.6610648, 53.795467]), null, null, - "Pharmacy"), + "Pharmacy", + ReferenceNumberGroup: 0), new("test321", "Test Site 2", string.Empty, @@ -780,7 +813,8 @@ public async Task QuerySitesAsync_FiltersBySiteType_AndOdsCode() new Location("Point", [-1.6610648, 53.795467]), null, null, - "gp PrActiCE"), // Ensure the filter is case insensitive + "gp PrActiCE", + ReferenceNumberGroup: 0), // Ensure the filter is case insensitive new("test456", "Test Site 3", string.Empty, @@ -791,7 +825,8 @@ public async Task QuerySitesAsync_FiltersBySiteType_AndOdsCode() new Location("Point", [-1.6610648, 53.795467]), null, null, - "PCN Site"), + "PCN Site", + ReferenceNumberGroup: 0), new("test654", "Test Site 4", string.Empty, @@ -802,7 +837,8 @@ public async Task QuerySitesAsync_FiltersBySiteType_AndOdsCode() new Location("Point", [-1.6610648, 53.795467]), null, null, - "Some other site type"), + "Some other site type", + ReferenceNumberGroup: 0), }; _siteStore.Setup(x => x.GetAllSites()) @@ -812,7 +848,7 @@ public async Task QuerySitesAsync_FiltersBySiteType_AndOdsCode() result.Count().Should().Be(1); - _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny>()), Times.Never); + _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); } [Fact] @@ -841,7 +877,8 @@ public async Task QuerySitesAsync_FiltersBySiteType_AndOdsCode_AndDoesNotReturnA new Location("Point", [-1.6610648, 53.795467]), null, null, - "Pharmacy"), + "Pharmacy", + ReferenceNumberGroup: 0), new("test321", "Test Site 2", string.Empty, @@ -852,7 +889,8 @@ public async Task QuerySitesAsync_FiltersBySiteType_AndOdsCode_AndDoesNotReturnA new Location("Point", [-1.6610648, 53.795467]), null, null, - "gp PrActiCE"), // Ensure the filter is case insensitive + "gp PrActiCE", + ReferenceNumberGroup: 0), // Ensure the filter is case insensitive new("test456", "Test Site 3", string.Empty, @@ -863,7 +901,8 @@ public async Task QuerySitesAsync_FiltersBySiteType_AndOdsCode_AndDoesNotReturnA new Location("Point", [-1.6610648, 53.795467]), null, null, - "PCN Site"), + "PCN Site", + ReferenceNumberGroup: 0), new("test654", "Test Site 4", string.Empty, @@ -874,7 +913,8 @@ public async Task QuerySitesAsync_FiltersBySiteType_AndOdsCode_AndDoesNotReturnA new Location("Point", [-1.6610648, 53.795467]), null, null, - "Some other site type"), + "Some other site type", + ReferenceNumberGroup: 0), }; _siteStore.Setup(x => x.GetAllSites()) @@ -884,7 +924,7 @@ public async Task QuerySitesAsync_FiltersBySiteType_AndOdsCode_AndDoesNotReturnA result.Count().Should().Be(0); - _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny>()), Times.Never); + _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); } [Fact] @@ -912,7 +952,8 @@ public async Task QuerySitesAsync_FiltersByOdsCode() new Location("Point", [-1.6610648, 53.795467]), null, null, - "Pharmacy"), + "Pharmacy", + ReferenceNumberGroup: 0), new("test321", "Test Site 2", string.Empty, @@ -923,7 +964,8 @@ public async Task QuerySitesAsync_FiltersByOdsCode() new Location("Point", [-1.6610648, 53.795467]), null, null, - "gp PrActiCE"), // Ensure the filter is case insensitive + "gp PrActiCE", + ReferenceNumberGroup: 0), // Ensure the filter is case insensitive new("test456", "Test Site 3", string.Empty, @@ -934,7 +976,8 @@ public async Task QuerySitesAsync_FiltersByOdsCode() new Location("Point", [-1.6610648, 53.795467]), null, null, - "PCN Site"), + "PCN Site", + ReferenceNumberGroup: 0), new("test654", "Test Site 4", string.Empty, @@ -945,7 +988,8 @@ public async Task QuerySitesAsync_FiltersByOdsCode() new Location("Point", [-1.6610648, 53.795467]), null, null, - "Some other site type"), + "Some other site type", + ReferenceNumberGroup: 0), }; _siteStore.Setup(x => x.GetAllSites()) @@ -955,7 +999,7 @@ public async Task QuerySitesAsync_FiltersByOdsCode() result.Count().Should().Be(1); - _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny>()), Times.Never); + _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); } [Fact] @@ -995,7 +1039,8 @@ public async Task QuerySitesAsync_FiltersSitesInPriorityOrder_AndStopsFilteringA new Location("Point", [-1.6610648, 53.795467]), null, null, - "GP Practice")); + "GP Practice", + ReferenceNumberGroup: 0)); } sites.Add(new( @@ -1013,7 +1058,8 @@ public async Task QuerySitesAsync_FiltersSitesInPriorityOrder_AndStopsFilteringA new Location("Point", [-1.6610648, 53.795467]), null, null, - "Pharmacy")); + "Pharmacy", + ReferenceNumberGroup: 0)); _siteStore.Setup(x => x.GetAllSites()) .ReturnsAsync(sites); @@ -1023,7 +1069,7 @@ public async Task QuerySitesAsync_FiltersSitesInPriorityOrder_AndStopsFilteringA result.Count().Should().Be(50); result.Any(x => x.Site.Id == "test51").Should().BeFalse(); - _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny>()), Times.Never); + _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); } [Fact] @@ -1051,7 +1097,8 @@ public async Task QuerySitesAsync_ShouldExcludeSiteTypesFromResults() new Location("Point", [-1.6610648, 53.795467]), null, null, - "Pharmacy"), + "Pharmacy", + ReferenceNumberGroup: 0), new("test321", "Test Site 2", string.Empty, @@ -1062,7 +1109,8 @@ public async Task QuerySitesAsync_ShouldExcludeSiteTypesFromResults() new Location("Point", [-1.6610648, 53.795467]), null, null, - "GP Practice"), + "GP Practice", + ReferenceNumberGroup: 0), new("test456", "Test Site 3", string.Empty, @@ -1073,7 +1121,8 @@ public async Task QuerySitesAsync_ShouldExcludeSiteTypesFromResults() new Location("Point", [-1.6610648, 53.795467]), null, null, - "PCN Site"), + "PCN Site", + ReferenceNumberGroup: 0), new("test654", "Test Site 4", string.Empty, @@ -1084,7 +1133,8 @@ public async Task QuerySitesAsync_ShouldExcludeSiteTypesFromResults() new Location("Point", [-1.6610648, 53.795467]), null, null, - "Some other site type"), + "Some other site type", + ReferenceNumberGroup: 0), }; _siteStore.Setup(x => x.GetAllSites()) @@ -1095,7 +1145,7 @@ public async Task QuerySitesAsync_ShouldExcludeSiteTypesFromResults() result.Count().Should().Be(3); result.Any(r => r.Site.Id == "test321").Should().BeFalse(); - _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny>()), Times.Never); + _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); } [Fact] @@ -1118,7 +1168,8 @@ public async Task QuerySitesAsync_CallsAvailabilityStoreForEachSite_WhenSiteSupp new(Id: "accessibility/access_need_1", Value: "true") }, status: SiteStatus.Online, isDeleted: null, - Type: string.Empty), + Type: string.Empty, + ReferenceNumberGroup: 0), Distance: 2858), new(new Site( Id: "6877d86e-c2df-4def-8508-e1eccf0ea6bb", @@ -1135,11 +1186,12 @@ public async Task QuerySitesAsync_CallsAvailabilityStoreForEachSite_WhenSiteSupp new(Id: "accessibility/access_need_1", Value: "false") }, status: SiteStatus.Online, isDeleted: null, - Type: string.Empty), + Type: string.Empty, + ReferenceNumberGroup: 0), Distance: 3573) }; _siteStore.Setup(x => x.GetAllSites()).ReturnsAsync(sites.Select(s => s.Site)); - _availabilityStore.Setup(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny>())).ReturnsAsync(true); + _availabilityStore.Setup(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny())).ReturnsAsync(true); //set up a cache, but it's for a different date range, so its not used object outResult = new CacheService.LazySlideCacheObject(true, DateTimeOffset.UtcNow); @@ -1165,10 +1217,11 @@ public async Task QuerySitesAsync_CallsAvailabilityStoreForEachSite_WhenSiteSupp var result = await _sut.QuerySitesAsync(filters, 50, false); result.Should().BeEquivalentTo(sites); - var docIds = new List() { "20251003", "20251004", "20251005","20251006","20251007","20251008","20251009","20251010", "20251011", "20251012","20251013","20251014","20251015"}; + var from = new DateOnly(2025, 10, 3); + var to = new DateOnly(2025, 10, 15); - _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync("6877d86e-c2df-4def-8508-e1eccf0ea6ba", new List { "RSV:Adult" }, docIds), Times.Once); - _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync("6877d86e-c2df-4def-8508-e1eccf0ea6bb", new List { "RSV:Adult" }, docIds), Times.Once); + _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync("6877d86e-c2df-4def-8508-e1eccf0ea6ba", new List { "RSV:Adult" }, from, to), Times.Once); + _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync("6877d86e-c2df-4def-8508-e1eccf0ea6bb", new List { "RSV:Adult" }, from, to), Times.Once); //creates new correct cache for queried date range _memoryCache.Verify(x => x.CreateEntry("LazySlide:site_6877d86e-c2df-4def-8508-e1eccf0ea6ba_supports_RSV:Adult_in_20251003_20251015"), Times.Once); @@ -1206,7 +1259,8 @@ public async Task QuerySitesAsync_CallsAvailabilityStoreForEachSite_WhenSiteSupp new(Id: "accessibility/access_need_1", Value: "true") }, status: SiteStatus.Online, isDeleted: null, - Type: string.Empty), + Type: string.Empty, + ReferenceNumberGroup: 0), Distance: 2858), new(new Site( Id: "6877d86e-c2df-4def-8508-e1eccf0ea6bb", @@ -1223,7 +1277,8 @@ public async Task QuerySitesAsync_CallsAvailabilityStoreForEachSite_WhenSiteSupp new(Id: "accessibility/access_need_1", Value: "false") }, status: SiteStatus.Online, isDeleted: null, - Type: string.Empty), + Type: string.Empty, + ReferenceNumberGroup: 0), Distance: 3573) }; _siteStore.Setup(x => x.GetAllSites()).ReturnsAsync(sites.Select(s => s.Site)); @@ -1251,11 +1306,12 @@ public async Task QuerySitesAsync_CallsAvailabilityStoreForEachSite_WhenSiteSupp var result = await _sut.QuerySitesAsync(filters, 50, false); result.Should().BeEquivalentTo(sites); - var docIds = new List() { "20251003", "20251004", "20251005","20251006","20251007","20251008","20251009","20251010", "20251011", "20251012","20251013","20251014","20251015"}; + var from = new DateOnly(2025, 10, 3); + var to = new DateOnly(2025, 10, 15); //doesn't call the store if cached - _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync("6877d86e-c2df-4def-8508-e1eccf0ea6ba", new List { "RSV:Adult" }, docIds), Times.Never); - _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync("6877d86e-c2df-4def-8508-e1eccf0ea6bb", new List { "RSV:Adult" }, docIds), Times.Never); + _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync("6877d86e-c2df-4def-8508-e1eccf0ea6ba", new List { "RSV:Adult" }, from, to), Times.Never); + _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync("6877d86e-c2df-4def-8508-e1eccf0ea6bb", new List { "RSV:Adult" }, from, to), Times.Never); _memoryCache.Verify(x => x.CreateEntry("LazySlide:site_6877d86e-c2df-4def-8508-e1eccf0ea6ba_supports_RSV:Adult_in_20251003_20251015"), Times.Never); _memoryCache.Verify(x => x.CreateEntry("LazySlide:site_6877d86e-c2df-4def-8508-e1eccf0ea6bb_supports_RSV:Adult_in_20251003_20251015"), Times.Never); @@ -1313,7 +1369,8 @@ public async Task QuerySitesAsync_CallsAvailabilityStoreForEachSiteBatched_WhenS new(Id: "accessibility/access_need_1", Value: "false") }, status: SiteStatus.Online, isDeleted: null, - Type: string.Empty), + Type: string.Empty, + ReferenceNumberGroup: 0), Distance: 3500+i)); //invalid site results happen to not be cached @@ -1342,7 +1399,8 @@ public async Task QuerySitesAsync_CallsAvailabilityStoreForEachSiteBatched_WhenS new(Id: "accessibility/access_need_1", Value: "false") }, status: SiteStatus.Online, isDeleted: null, - Type: string.Empty), + Type: string.Empty, + ReferenceNumberGroup: 0), Distance: (int)(3700+i))); //valid site results happen to be cached @@ -1358,7 +1416,7 @@ public async Task QuerySitesAsync_CallsAvailabilityStoreForEachSiteBatched_WhenS for (var i = 1; i < siteCount; i++) { var id = $"{i:00}"; - _availabilityStore.Setup(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync($"6877d86e-c2df-4def-8508-e1eccf0ea6{id}", It.IsAny>(), It.IsAny>())).ReturnsAsync(false); + _availabilityStore.Setup(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync($"6877d86e-c2df-4def-8508-e1eccf0ea6{id}", It.IsAny>(), It.IsAny(), It.IsAny())).ReturnsAsync(false); } var filters = new List @@ -1379,20 +1437,21 @@ public async Task QuerySitesAsync_CallsAvailabilityStoreForEachSiteBatched_WhenS var result = await _sut.QuerySitesAsync(filters, 1, false); result.Single().Site.Id.Should().Be(validSites.First().Site.Id); - - var docIds = new List() { "20251003", "20251004", "20251005", "20251006"}; + + var from = new DateOnly(2025, 10, 3); + var to = new DateOnly(2025, 10, 6); for (var i = 1; i < siteCount; i++) { var id = $"{i:00}"; - _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync($"6877d86e-c2df-4def-8508-e1eccf0ea6{id}", new List { "RSV:Adult" }, docIds), Times.Once); + _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync($"6877d86e-c2df-4def-8508-e1eccf0ea6{id}", new List { "RSV:Adult" }, from, to), Times.Once); } for (var i = 1; i < siteCount; i++) { //since the valid sites were cached, it shouldn't look up via DB var id = $"{i:00}"; - _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync($"6877d86e-c2df-4def-8508-e1eccf0ea7{id}", new List { "RSV:Adult" }, docIds), Times.Never); + _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync($"6877d86e-c2df-4def-8508-e1eccf0ea7{id}", new List { "RSV:Adult" }, from, to), Times.Never); } _logger.Verify(x => x.Log( @@ -1436,7 +1495,8 @@ public async Task GetSiteByIdAsync_ReturnsDefault_WhenSiteIsSoftDeleted() InformationForCitizens: "", Accessibilities: new List { new(Id: "Accessibility 1", Value: "true") }, status: SiteStatus.Online, isDeleted: true, - Type: string.Empty); + Type: string.Empty, + ReferenceNumberGroup: 0); _siteStore.Setup(x => x.GetSiteById(siteId)).ReturnsAsync(site); var result = await _sut.GetSiteByIdAsync(siteId); @@ -1507,7 +1567,8 @@ public async Task QuerySitesAsync_FiltersInIndexOrder_WhenPrioritiesAreTheSame() new Location("Point", [-1.6610648, 53.795467]), null, null, - "Pharmacy")); + "Pharmacy", + ReferenceNumberGroup: 0)); } sites.Add(new( @@ -1521,7 +1582,8 @@ public async Task QuerySitesAsync_FiltersInIndexOrder_WhenPrioritiesAreTheSame() new Location("Point", [-1.6610648, 53.795467]), null, null, - "GP Practice")); + "GP Practice", + ReferenceNumberGroup: 0)); _siteStore.Setup(x => x.GetAllSites()) .ReturnsAsync(sites); @@ -1531,7 +1593,7 @@ public async Task QuerySitesAsync_FiltersInIndexOrder_WhenPrioritiesAreTheSame() result.Count().Should().Be(50); result.Any(x => x.Site.Id == "test51").Should().BeFalse(); - _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny>()), Times.Never); + _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); } [Fact] @@ -1570,7 +1632,8 @@ public async Task QuerySitesAsync_FiltersOnPriority_WhenOnlyOneFilterHasPriority new Location("Point", [-1.6610648, 53.795467]), null, null, - "GP Practice")); + "GP Practice", + ReferenceNumberGroup: 0)); } sites.Add(new( @@ -1588,7 +1651,8 @@ public async Task QuerySitesAsync_FiltersOnPriority_WhenOnlyOneFilterHasPriority new Location("Point", [-1.6610648, 53.795467]), null, null, - "Pharmacy")); + "Pharmacy", + ReferenceNumberGroup: 0)); _siteStore.Setup(x => x.GetAllSites()) .ReturnsAsync(sites); @@ -1598,7 +1662,7 @@ public async Task QuerySitesAsync_FiltersOnPriority_WhenOnlyOneFilterHasPriority result.Count().Should().Be(50); result.Any(x => x.Site.Id == "test51").Should().BeFalse(); - _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny>()), Times.Never); + _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); } [Fact] @@ -1633,7 +1697,8 @@ public async Task QuerySitesAsync_OnlyReturnsSiteOnce_WhenItMatchesMultipleFilte new Location("Point", [-1.6610648, 53.795467]), null, null, - "Pharmacy"), + "Pharmacy", + ReferenceNumberGroup: 0), new("test321", "Test Site 2", string.Empty, @@ -1648,7 +1713,8 @@ public async Task QuerySitesAsync_OnlyReturnsSiteOnce_WhenItMatchesMultipleFilte new Location("Point", [-1.6610648, 53.795467]), null, null, - "GP Practice"), + "GP Practice", + ReferenceNumberGroup: 0), new("test456", "Test Site 3", string.Empty, @@ -1659,7 +1725,8 @@ public async Task QuerySitesAsync_OnlyReturnsSiteOnce_WhenItMatchesMultipleFilte new Location("Point", [-1.6610648, 53.795467]), null, null, - "PCN Site"), + "PCN Site", + ReferenceNumberGroup: 0), new("test654", "Test Site 4", string.Empty, @@ -1670,7 +1737,8 @@ public async Task QuerySitesAsync_OnlyReturnsSiteOnce_WhenItMatchesMultipleFilte new Location("Point", [-1.6610648, 53.795467]), null, null, - "Some other site type"), + "Some other site type", + ReferenceNumberGroup: 0), }; _siteStore.Setup(x => x.GetAllSites()) .ReturnsAsync(sites); @@ -1680,7 +1748,7 @@ public async Task QuerySitesAsync_OnlyReturnsSiteOnce_WhenItMatchesMultipleFilte result.Count().Should().Be(1); result.First().Site.Id.Should().Be("test321"); - _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny>()), Times.Never); + _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); } [Fact] @@ -1714,7 +1782,8 @@ public async Task QuerySitesAsync_ReturnsSitesOnlyWhenAllServicesMatch() new Location("Point", [-1.6610648, 53.795467]), null, null, - "Pharmacy"), + "Pharmacy", + ReferenceNumberGroup: 0), new("test321", "Test Site 2", string.Empty, @@ -1729,7 +1798,8 @@ public async Task QuerySitesAsync_ReturnsSitesOnlyWhenAllServicesMatch() new Location("Point", [-1.6610648, 53.795467]), null, null, - "GP Practice"), + "GP Practice", + ReferenceNumberGroup: 0), new("test456", "Test Site 3", string.Empty, @@ -1740,7 +1810,8 @@ public async Task QuerySitesAsync_ReturnsSitesOnlyWhenAllServicesMatch() new Location("Point", [-1.6610648, 53.795467]), null, null, - "PCN Site"), + "PCN Site", + ReferenceNumberGroup: 0), new("test654", "Test Site 4", string.Empty, @@ -1751,11 +1822,12 @@ public async Task QuerySitesAsync_ReturnsSitesOnlyWhenAllServicesMatch() new Location("Point", [-1.6610648, 53.795467]), null, null, - "Some other site type"), + "Some other site type", + ReferenceNumberGroup: 0), }; _siteStore.Setup(x => x.GetAllSites()) .ReturnsAsync(sites); - _availabilityStore.SetupSequence(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny>())) + _availabilityStore.SetupSequence(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny())) .ReturnsAsync(true) .ReturnsAsync(false) .ReturnsAsync(true) @@ -1768,7 +1840,7 @@ public async Task QuerySitesAsync_ReturnsSitesOnlyWhenAllServicesMatch() result.Any(x => x.Site.Id == "test321").Should().BeFalse(); _availabilityStore.Verify( - x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.Is>(l => l.SequenceEqual(services)), It.IsAny>()), + x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.Is>(l => l.SequenceEqual(services)), It.IsAny(), It.IsAny()), Times.Exactly(4)); } @@ -1809,13 +1881,13 @@ public async Task QuerySitesAsync_SameOrderedCacheKeyUsedForUnorderedAndDuplicat new Location("Point", [-1.6610648, 53.795467]), null, null, - "Pharmacy") + "Pharmacy", + ReferenceNumberGroup: 0) }; _siteStore.Setup(x => x.GetAllSites()) .ReturnsAsync(sites); _availabilityStore.Setup(x => - x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.Is>(l => l.SequenceEqual(orderedServices)), - It.IsAny>())) + x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.Is>(l => l.SequenceEqual(orderedServices)), It.IsAny(), It.IsAny())) .ReturnsAsync(true); filters.Single().Availability.Services = services1.ToArray(); @@ -1824,32 +1896,32 @@ public async Task QuerySitesAsync_SameOrderedCacheKeyUsedForUnorderedAndDuplicat result1.Count().Should().Be(1); _availabilityStore.Verify( - x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.Is>(l => l.SequenceEqual(orderedServices)), It.IsAny>()), + x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.Is>(l => l.SequenceEqual(orderedServices)), It.IsAny(), It.IsAny()), Times.Once); _availabilityStore.Verify( - x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.Is>(l => l.SequenceEqual(services1)), It.IsAny>()), + x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.Is>(l => l.SequenceEqual(services1)), It.IsAny(), It.IsAny()), Times.Never); filters.Single().Availability.Services = services2.ToArray(); var result2 = await _sut.QuerySitesAsync([.. filters], 50, true); result2.Count().Should().Be(1); _availabilityStore.Verify( - x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.Is>(l => l.SequenceEqual(services2)), It.IsAny>()), + x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.Is>(l => l.SequenceEqual(services2)), It.IsAny(), It.IsAny()), Times.Never); filters.Single().Availability.Services = services3.ToArray(); var result3 = await _sut.QuerySitesAsync([.. filters], 50, true); result3.Count().Should().Be(1); _availabilityStore.Verify( - x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.Is>(l => l.SequenceEqual(services3)), It.IsAny>()), + x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.Is>(l => l.SequenceEqual(services3)), It.IsAny(), It.IsAny()), Times.Never); filters.Single().Availability.Services = services4.ToArray(); var result4 = await _sut.QuerySitesAsync([.. filters], 50, true); result4.Count().Should().Be(1); _availabilityStore.Verify( - x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.Is>(l => l.SequenceEqual(services4)), It.IsAny>()), + x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.Is>(l => l.SequenceEqual(services4)), It.IsAny(), It.IsAny()), Times.Never); } @@ -1884,7 +1956,8 @@ public async Task QuerySitesAsync_CachingKeyUsedForFullServiceList() new Location("Point", [-1.6610648, 53.795467]), null, null, - "Pharmacy"), + "Pharmacy", + ReferenceNumberGroup: 0), new("test321", "Test Site 2", string.Empty, @@ -1899,7 +1972,8 @@ public async Task QuerySitesAsync_CachingKeyUsedForFullServiceList() new Location("Point", [-1.6610648, 53.795467]), null, null, - "GP Practice"), + "GP Practice", + ReferenceNumberGroup: 0), new("test456", "Test Site 3", string.Empty, @@ -1910,7 +1984,8 @@ public async Task QuerySitesAsync_CachingKeyUsedForFullServiceList() new Location("Point", [-1.6610648, 53.795467]), null, null, - "PCN Site"), + "PCN Site", + ReferenceNumberGroup: 0), new("test654", "Test Site 4", string.Empty, @@ -1921,7 +1996,8 @@ public async Task QuerySitesAsync_CachingKeyUsedForFullServiceList() new Location("Point", [-1.6610648, 53.795467]), null, null, - "Some other site type"), + "Some other site type", + ReferenceNumberGroup: 0), }; _siteStore.Setup(x => x.GetAllSites()) .ReturnsAsync(sites); @@ -1939,7 +2015,7 @@ public async Task QuerySitesAsync_CachingKeyUsedForFullServiceList() _memoryCache.Verify(x => x.CreateEntry(CacheService.LazySlideCacheKey("site_test456_supports_COVID:5_11_RSV:Adult_in_20250901_20251001")), Times.Never); _memoryCache.Verify(x => x.CreateEntry(CacheService.LazySlideCacheKey("site_test654_supports_COVID:5_11_RSV:Adult_in_20250901_20251001")), Times.Never); - _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny>()), Times.Never); + _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Never); } [Fact] @@ -1973,7 +2049,8 @@ public async Task QuerySitesAsync_WritesToCache_WhenKeyNotPresentInitially() new Location("Point", [-1.6610648, 53.795467]), null, null, - "Pharmacy"), + "Pharmacy", + ReferenceNumberGroup: 0), new("test321", "Test Site 2", string.Empty, @@ -1988,7 +2065,8 @@ public async Task QuerySitesAsync_WritesToCache_WhenKeyNotPresentInitially() new Location("Point", [-1.6610648, 53.795467]), null, null, - "GP Practice"), + "GP Practice", + ReferenceNumberGroup: 0), new("test456", "Test Site 3", string.Empty, @@ -1999,7 +2077,8 @@ public async Task QuerySitesAsync_WritesToCache_WhenKeyNotPresentInitially() new Location("Point", [-1.6610648, 53.795467]), null, null, - "PCN Site"), + "PCN Site", + ReferenceNumberGroup: 0), new("test654", "Test Site 4", string.Empty, @@ -2010,7 +2089,8 @@ public async Task QuerySitesAsync_WritesToCache_WhenKeyNotPresentInitially() new Location("Point", [-1.6610648, 53.795467]), null, null, - "Some other site type"), + "Some other site type", + ReferenceNumberGroup: 0), }; _siteStore.Setup(x => x.GetAllSites()) .ReturnsAsync(sites); @@ -2028,7 +2108,7 @@ public async Task QuerySitesAsync_WritesToCache_WhenKeyNotPresentInitially() _memoryCache.Verify(x => x.CreateEntry(CacheService.LazySlideCacheKey("site_test456_supports_COVID:5_11_RSV:Adult_in_20250901_20251001")), Times.Once); _memoryCache.Verify(x => x.CreateEntry(CacheService.LazySlideCacheKey("site_test654_supports_COVID:5_11_RSV:Adult_in_20250901_20251001")), Times.Once); - _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny>()), Times.Exactly(4)); + _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.IsAny>(), It.IsAny(), It.IsAny()), Times.Exactly(4)); } [Fact] @@ -2062,7 +2142,8 @@ public async Task QuerySitesAsync_WriteToCache_CacheKeyHasUniqueServicesInAlphab new Location("Point", [-1.6610648, 53.795467]), null, null, - "Pharmacy"), + "Pharmacy", + ReferenceNumberGroup: 0), new("test321", "Test Site 2", string.Empty, @@ -2077,7 +2158,8 @@ public async Task QuerySitesAsync_WriteToCache_CacheKeyHasUniqueServicesInAlphab new Location("Point", [-1.6610648, 53.795467]), null, null, - "GP Practice"), + "GP Practice", + ReferenceNumberGroup: 0), new("test456", "Test Site 3", string.Empty, @@ -2088,7 +2170,8 @@ public async Task QuerySitesAsync_WriteToCache_CacheKeyHasUniqueServicesInAlphab new Location("Point", [-1.6610648, 53.795467]), null, null, - "PCN Site"), + "PCN Site", + ReferenceNumberGroup: 0), new("test654", "Test Site 4", string.Empty, @@ -2099,7 +2182,8 @@ public async Task QuerySitesAsync_WriteToCache_CacheKeyHasUniqueServicesInAlphab new Location("Point", [-1.6610648, 53.795467]), null, null, - "Some other site type"), + "Some other site type", + ReferenceNumberGroup: 0), }; _siteStore.Setup(x => x.GetAllSites()) .ReturnsAsync(sites); @@ -2117,7 +2201,7 @@ public async Task QuerySitesAsync_WriteToCache_CacheKeyHasUniqueServicesInAlphab _memoryCache.Verify(x => x.CreateEntry(CacheService.LazySlideCacheKey("site_test456_supports_COVID:5_11_RSV:Adult_in_20250901_20251001")), Times.Once); _memoryCache.Verify(x => x.CreateEntry(CacheService.LazySlideCacheKey("site_test654_supports_COVID:5_11_RSV:Adult_in_20250901_20251001")), Times.Once); - _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.Is>(l => l.SequenceEqual(expectedServices)), It.IsAny>()), Times.Exactly(4)); + _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.Is>(l => l.SequenceEqual(expectedServices)), It.IsAny(), It.IsAny()), Times.Exactly(4)); } [Fact] @@ -2151,7 +2235,8 @@ public async Task QuerySitesAsync_ReadsFromCache_CacheKeyHasUniqueServicesInAlph new Location("Point", [-1.6610648, 53.795467]), null, null, - "Pharmacy"), + "Pharmacy", + ReferenceNumberGroup: 0), new("test321", "Test Site 2", string.Empty, @@ -2166,7 +2251,8 @@ public async Task QuerySitesAsync_ReadsFromCache_CacheKeyHasUniqueServicesInAlph new Location("Point", [-1.6610648, 53.795467]), null, null, - "GP Practice"), + "GP Practice", + ReferenceNumberGroup: 0), new("test456", "Test Site 3", string.Empty, @@ -2177,7 +2263,8 @@ public async Task QuerySitesAsync_ReadsFromCache_CacheKeyHasUniqueServicesInAlph new Location("Point", [-1.6610648, 53.795467]), null, null, - "PCN Site"), + "PCN Site", + ReferenceNumberGroup: 0), new("test654", "Test Site 4", string.Empty, @@ -2188,7 +2275,8 @@ public async Task QuerySitesAsync_ReadsFromCache_CacheKeyHasUniqueServicesInAlph new Location("Point", [-1.6610648, 53.795467]), null, null, - "Some other site type"), + "Some other site type", + ReferenceNumberGroup: 0), }; _siteStore.Setup(x => x.GetAllSites()) .ReturnsAsync(sites); @@ -2206,7 +2294,7 @@ public async Task QuerySitesAsync_ReadsFromCache_CacheKeyHasUniqueServicesInAlph _memoryCache.Verify(x => x.CreateEntry(CacheService.LazySlideCacheKey("site_test456_supports_COVID:5_11_RSV:Adult_in_20250901_20251001")), Times.Never); _memoryCache.Verify(x => x.CreateEntry(CacheService.LazySlideCacheKey("site_test654_supports_COVID:5_11_RSV:Adult_in_20250901_20251001")), Times.Never); - _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.Is>(l => l.SequenceEqual(expectedServices)), It.IsAny>()), Times.Exactly(0)); + _availabilityStore.Verify(x => x.SiteSupportsAllServicesOnSingleDateInRangeAsync(It.IsAny(), It.Is>(l => l.SequenceEqual(expectedServices)), It.IsAny(), It.IsAny()), Times.Exactly(0)); } [Fact] @@ -2224,7 +2312,8 @@ public async Task GetAllSites_ReturnsFromBasicCache_WhenOptionsSiteSlidingCache_ new Location("Point", [-1.6610648, 53.795467]), null, null, - "Pharmacy"), + "Pharmacy", + ReferenceNumberGroup: 0), new("test321", "Test Site 2", string.Empty, @@ -2239,7 +2328,8 @@ public async Task GetAllSites_ReturnsFromBasicCache_WhenOptionsSiteSlidingCache_ new Location("Point", [-1.6610648, 53.795467]), null, null, - "GP Practice"), + "GP Practice", + ReferenceNumberGroup: 0), }; object outResult = new CacheService.CacheObject>(sites); @@ -2274,7 +2364,8 @@ public async Task GetAllSites_ReturnsFromBasicCache_WhenOptionsSiteSlidingCache_ new Location("Point", [-1.6610648, 53.795467]), null, null, - "Pharmacy"), + "Pharmacy", + ReferenceNumberGroup: 0), new("test321", "Test Site 2", string.Empty, @@ -2289,7 +2380,8 @@ public async Task GetAllSites_ReturnsFromBasicCache_WhenOptionsSiteSlidingCache_ new Location("Point", [-1.6610648, 53.795467]), null, null, - "GP Practice"), + "GP Practice", + ReferenceNumberGroup: 0), }; object outResult = new CacheService.LazySlideCacheObject(sites, DateTime.UtcNow); @@ -2326,7 +2418,8 @@ public async Task GetAllSites_ReturnsFromStore_WhenOptionsSiteSlidingCache_Disab new Location("Point", [-1.6610648, 53.795467]), null, null, - "Pharmacy"), + "Pharmacy", + ReferenceNumberGroup: 0), new("test321", "Test Site 2", string.Empty, @@ -2341,7 +2434,8 @@ public async Task GetAllSites_ReturnsFromStore_WhenOptionsSiteSlidingCache_Disab new Location("Point", [-1.6610648, 53.795467]), null, null, - "GP Practice"), + "GP Practice", + ReferenceNumberGroup: 0), }; object outResult = null; @@ -2377,7 +2471,8 @@ public async Task GetAllSites_ReturnsFromStore_WhenOptionsSiteSlidingCache_Disab new Location("Point", [-1.6610648, 53.795467]), null, null, - "Pharmacy"), + "Pharmacy", + ReferenceNumberGroup: 0), new("test321", "Test Site 2", string.Empty, @@ -2392,7 +2487,8 @@ public async Task GetAllSites_ReturnsFromStore_WhenOptionsSiteSlidingCache_Disab new Location("Point", [-1.6610648, 53.795467]), null, null, - "GP Practice"), + "GP Practice", + ReferenceNumberGroup: 0), }; object outResult = new CacheService.CacheObject>(null); @@ -2428,7 +2524,8 @@ public async Task GetAllSites_ReturnsFromStore_WhenOptionsSiteSlidingCache_Enabl new Location("Point", [-1.6610648, 53.795467]), null, null, - "Pharmacy"), + "Pharmacy", + ReferenceNumberGroup: 0), new("test321", "Test Site 2", string.Empty, @@ -2443,7 +2540,8 @@ public async Task GetAllSites_ReturnsFromStore_WhenOptionsSiteSlidingCache_Enabl new Location("Point", [-1.6610648, 53.795467]), null, null, - "GP Practice"), + "GP Practice", + ReferenceNumberGroup: 0), }; object outResult = null; diff --git a/tests/Nhs.Appointments.Persistance.UnitTests/SiteStoreTests.cs b/tests/Nhs.Appointments.Persistance.UnitTests/SiteStoreTests.cs index d2fda1ec0..4dc1baabc 100644 --- a/tests/Nhs.Appointments.Persistance.UnitTests/SiteStoreTests.cs +++ b/tests/Nhs.Appointments.Persistance.UnitTests/SiteStoreTests.cs @@ -46,7 +46,8 @@ public async Task UpdateSiteStatusAsync_AddsStatusPropertyToDocument() [], new Location("Coordinates", [-1.75, 52.76]), null, null, - string.Empty)); + string.Empty, + ReferenceNumberGroup: 0)); _siteStore.Setup(x => x.PatchDocument(It.IsAny(), It.IsAny(), It.IsAny())) .Callback((site, reference, patches) => patchOperations = [.. patches]) @@ -81,7 +82,8 @@ public async Task UpdateSiteStatusAsync_UpdatesStatusPropertyOnDocument() [], new Location("Coordinates", [-1.75, 52.76]), SiteStatus.Online, null, - string.Empty)); + string.Empty, + ReferenceNumberGroup: 0)); _siteStore.Setup(x => x.PatchDocument(It.IsAny(), It.IsAny(), It.IsAny())) .Callback((site, reference, patches) => patchOperations = [.. patches]) @@ -116,7 +118,8 @@ public async Task ToggleSiteSoftDeletionAsync_UpdatesSiteSoftDeletionStatus() [], new Location("Coordinates", [-1.75, 52.76]), SiteStatus.Online, false, - string.Empty)); + string.Empty, + ReferenceNumberGroup: 0)); _siteStore.Setup(x => x.PatchDocument(It.IsAny(), It.IsAny(), It.IsAny())) .Callback((site, reference, patches) => patchOperations = [.. patches]) @@ -151,7 +154,8 @@ public async Task ToggleSiteSoftDeletionAsync_AddIsDeletedProperty() [], new Location("Coordinates", [-1.75, 52.76]), SiteStatus.Online, null, - string.Empty)); + string.Empty, + ReferenceNumberGroup: 0)); _siteStore.Setup(x => x.PatchDocument(It.IsAny(), It.IsAny(), It.IsAny())) .Callback((site, reference, patches) => patchOperations = [.. patches]) @@ -211,7 +215,8 @@ public async Task UpdateSiteDetails_FailsToFindSite_WhenItHasBeenSoftDeleted() new Location("Coordinates", [-1.75, 52.76]), SiteStatus.Online, true, - string.Empty)); + string.Empty, + ReferenceNumberGroup: 0)); var result = await _sut.UpdateSiteDetails("some-site-id", "Site Name", "1 Site Lane", "N", (decimal)-0.751, (decimal)50.369); @@ -238,7 +243,8 @@ public async Task UpdateSiteDetails_PatchesSiteDetails_ButNotSiteType() [], new Location("Coordinates", [-1.75, 52.76]), SiteStatus.Online, null, - string.Empty)); + string.Empty, + ReferenceNumberGroup: 0)); _siteStore.Setup(x => x.PatchDocument(It.IsAny(), It.IsAny(), It.IsAny())) .Callback((site, reference, patches) => patchOperations = [.. patches]) @@ -272,7 +278,8 @@ public async Task UpdateSiteDetails_PatchesSiteDetails_AndAddsSiteType() [], new Location("Coordinates", [-1.75, 52.76]), SiteStatus.Online, null, - null)); + null, + ReferenceNumberGroup: 0)); _siteStore.Setup(x => x.PatchDocument(It.IsAny(), It.IsAny(), It.IsAny())) .Callback((site, reference, patches) => patchOperations = [.. patches]) @@ -307,7 +314,8 @@ public async Task UpdateSiteDetails_PatchesSiteDetails_AndReplacesSiteType() [], new Location("Coordinates", [-1.75, 52.76]), SiteStatus.Online, null, - "GP Practice")); + "GP Practice", + ReferenceNumberGroup: 0)); _siteStore.Setup(x => x.PatchDocument(It.IsAny(), It.IsAny(), It.IsAny())) .Callback((site, reference, patches) => patchOperations = [.. patches])