From 4001746f4ad3000960a7830beb5d3778363d4f8b Mon Sep 17 00:00:00 2001 From: "SHAKIR, Muhammad" Date: Tue, 21 Apr 2026 13:33:14 +0100 Subject: [PATCH] Allowed case api to pull up to 25 academies APi records --- .../SystemIntegration/SigChangeIntegration.cs | 2 +- .../Repositories/ISigChangeRepository.cs | 8 +--- .../Gateways/SignificantChangeApiClient.cs | 4 +- .../SigChangeIntegrationTests.cs | 2 +- .../SignificantChangeApiClientTests.cs | 37 +++++++++++++------ ...CaseAggregationService.Tests.Common.csproj | 3 +- 6 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src/Dfe.CaseAggregationService.Application/Services/SystemIntegration/SigChangeIntegration.cs b/src/Dfe.CaseAggregationService.Application/Services/SystemIntegration/SigChangeIntegration.cs index ed213d8..b21c6f9 100644 --- a/src/Dfe.CaseAggregationService.Application/Services/SystemIntegration/SigChangeIntegration.cs +++ b/src/Dfe.CaseAggregationService.Application/Services/SystemIntegration/SigChangeIntegration.cs @@ -22,7 +22,7 @@ public Task> GetCasesForQuery(GetCasesForUserQuery que if (query.IncludeSignificantChange) { - return repo.GetSigChangeSummaries(query.UserName, cancellationToken) + return repo.GetSigChangeSummaries(query.UserName, query.RecordCount, cancellationToken) .ContinueWith(ProcessResult, cancellationToken); } diff --git a/src/Dfe.CaseAggregationService.Domain/Interfaces/Repositories/ISigChangeRepository.cs b/src/Dfe.CaseAggregationService.Domain/Interfaces/Repositories/ISigChangeRepository.cs index 978a3b3..75bc141 100644 --- a/src/Dfe.CaseAggregationService.Domain/Interfaces/Repositories/ISigChangeRepository.cs +++ b/src/Dfe.CaseAggregationService.Domain/Interfaces/Repositories/ISigChangeRepository.cs @@ -1,15 +1,9 @@ using Dfe.CaseAggregationService.Domain.Entities.SigChange; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; namespace Dfe.CaseAggregationService.Domain.Interfaces.Repositories { public interface ISigChangeRepository { - Task> GetSigChangeSummaries(string? userName, CancellationToken cancellationToken); + Task> GetSigChangeSummaries(string? userName, int recordCount, CancellationToken cancellationToken); } } diff --git a/src/Dfe.CaseAggregationService.Infrastructure/Gateways/SignificantChangeApiClient.cs b/src/Dfe.CaseAggregationService.Infrastructure/Gateways/SignificantChangeApiClient.cs index 44cea56..ead8810 100644 --- a/src/Dfe.CaseAggregationService.Infrastructure/Gateways/SignificantChangeApiClient.cs +++ b/src/Dfe.CaseAggregationService.Infrastructure/Gateways/SignificantChangeApiClient.cs @@ -9,10 +9,10 @@ public class SignificantChangeApiClient(ISignificantChangesV4Client significantC { const string format = "dd/MM/yyyy"; - public async Task> GetSigChangeSummaries(string? userName, CancellationToken cancellationToken) + public async Task> GetSigChangeSummaries(string? userName, int recordCount, CancellationToken cancellationToken) { - var response = await significantChangesClient.SearchSignificantChangesAsync(userName, null, null, null, null, cancellationToken); + var response = await significantChangesClient.SearchSignificantChangesAsync(userName, null, null, null, recordCount, cancellationToken); if (response.Data == null) throw new Exception(); diff --git a/src/Tests/Dfe.CaseAggregationService.Application.Tests/Services/SystemIntegration/SigChangeIntegrationTests.cs b/src/Tests/Dfe.CaseAggregationService.Application.Tests/Services/SystemIntegration/SigChangeIntegrationTests.cs index ac27df8..224f3da 100644 --- a/src/Tests/Dfe.CaseAggregationService.Application.Tests/Services/SystemIntegration/SigChangeIntegrationTests.cs +++ b/src/Tests/Dfe.CaseAggregationService.Application.Tests/Services/SystemIntegration/SigChangeIntegrationTests.cs @@ -69,7 +69,7 @@ private SigChangeIntegration CreateSigChangeIntegration() IGetCaseInfo mapper = Substitute.For>(); ILogger logger = Substitute.For>(); - repo.GetSigChangeSummaries(Arg.Any(), Arg.Any()).Returns([_fixture.Create() + repo.GetSigChangeSummaries(Arg.Any(), Arg.Any(), Arg.Any()).Returns([_fixture.Create() ]); mapper.GetCaseInfo(Arg.Any()).Returns(_fixture.Create()); diff --git a/src/Tests/Dfe.CaseAggregationService.Infrastructure.Tests/Gateways/SignificantChangeApiClientTests.cs b/src/Tests/Dfe.CaseAggregationService.Infrastructure.Tests/Gateways/SignificantChangeApiClientTests.cs index 06259c7..7d07c91 100644 --- a/src/Tests/Dfe.CaseAggregationService.Infrastructure.Tests/Gateways/SignificantChangeApiClientTests.cs +++ b/src/Tests/Dfe.CaseAggregationService.Infrastructure.Tests/Gateways/SignificantChangeApiClientTests.cs @@ -1,6 +1,5 @@ using Dfe.AcademiesApi.Client.Contracts; using Dfe.CaseAggregationService.Infrastructure.Gateways; -using Microsoft.Extensions.Logging; using NSubstitute; namespace Dfe.CaseAggregationService.Infrastructure.Tests.Gateways @@ -8,13 +7,12 @@ namespace Dfe.CaseAggregationService.Infrastructure.Tests.Gateways public class SignificantChangeApiClientTests { private const string DeliveryOfficer = "Delivery Officer"; + private const int MaxRecordCount = 25; private readonly SignificantChangeApiClient _repo; public SignificantChangeApiClientTests() { - var httpClient = Substitute.For(); - var logger = Substitute.For>(); var sigChangeProjects = Substitute.For(); var results = new PagedDataResponseOfSignificantChangeDto() @@ -47,12 +45,27 @@ public SignificantChangeApiClientTests() DecisionDate = "10/02/2026", ChangeCreationDate = "2026-02-10T00:00:00Z", ChangeEditDate = "2026-02-10T00:00:00Z" + }, + + new() + { + SigChangeId = 3, + AcademyName = "Academy 3", + TypeOfSigChangeMapped = "Type 3", + TrustName = "Trust 3", + Urn = 123457, + LocalAuthority = "LA 3", + Region = "Region 3", + DecisionDate = null, + ChangeCreationDate = "2026-02-10T00:00:00Z", + ChangeEditDate = null, } + ] }; sigChangeProjects.SearchSignificantChangesAsync(Arg.Is(DeliveryOfficer), - null, null, null, null, + null, null, null, Arg.Is(MaxRecordCount), Arg.Any()) .Returns(Task.FromResult(results)); @@ -62,9 +75,9 @@ public SignificantChangeApiClientTests() [Fact] public async Task GivenCorrectCallReturnSummary() { - var result = await _repo.GetSigChangeSummaries(DeliveryOfficer, CancellationToken.None); + var result = await _repo.GetSigChangeSummaries(DeliveryOfficer, MaxRecordCount, CancellationToken.None); - Assert.Equal(2, result.Count()); + Assert.Equal(3, result.Count()); var first = result.First(); @@ -74,9 +87,9 @@ public async Task GivenCorrectCallReturnSummary() Assert.Equal("123456", first.Urn); Assert.Equal("LA 1", first.LocalAuthority); Assert.Equal("Region 1", first.Region); - Assert.Equal(new DateTime(2026, 2, 10), first.DateOfDecision); - Assert.Equal(new DateTime(2026, 2, 10), first.CreatedDate); - Assert.Equal(new DateTime(2026, 2, 10), first.UpdatedDate); + Assert.Equal(new DateTime(2026, 2, 10, 0, 0, 0, DateTimeKind.Utc), first.DateOfDecision); + Assert.Equal(new DateTime(2026, 2, 10, 0, 0, 0, DateTimeKind.Utc), first.CreatedDate); + Assert.Equal(new DateTime(2026, 2, 10, 0, 0, 0, DateTimeKind.Utc), first.UpdatedDate); var second = result.Skip(1).First(); @@ -86,9 +99,9 @@ public async Task GivenCorrectCallReturnSummary() Assert.Equal("123457", second.Urn); Assert.Equal("LA 2", second.LocalAuthority); Assert.Equal("Region 2", second.Region); - Assert.Equal(new DateTime(2026, 2, 10), second.DateOfDecision); - Assert.Equal(new DateTime(2026, 2, 10), second.CreatedDate); - Assert.Equal(new DateTime(2026, 2, 10), second.UpdatedDate); + Assert.Equal(new DateTime(2026, 2, 10, 0, 0, 0, DateTimeKind.Utc), second.DateOfDecision); + Assert.Equal(new DateTime(2026, 2, 10, 0, 0, 0, DateTimeKind.Utc), second.CreatedDate); + Assert.Equal(new DateTime(2026, 2, 10, 0, 0, 0, DateTimeKind.Utc), second.UpdatedDate); } } diff --git a/src/Tests/Dfe.CaseAggregationService.Tests.Common/Dfe.CaseAggregationService.Tests.Common.csproj b/src/Tests/Dfe.CaseAggregationService.Tests.Common/Dfe.CaseAggregationService.Tests.Common.csproj index c91835f..8d553c9 100644 --- a/src/Tests/Dfe.CaseAggregationService.Tests.Common/Dfe.CaseAggregationService.Tests.Common.csproj +++ b/src/Tests/Dfe.CaseAggregationService.Tests.Common/Dfe.CaseAggregationService.Tests.Common.csproj @@ -1,7 +1,6 @@  - - +