Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public Task<IEnumerable<UserCaseInfo>> GetCasesForQuery(GetCasesForUserQuery que

if (query.IncludeSignificantChange)
{
return repo.GetSigChangeSummaries(query.UserName, cancellationToken)
return repo.GetSigChangeSummaries(query.UserName, query.RecordCount, cancellationToken)
.ContinueWith(ProcessResult, cancellationToken);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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<IEnumerable<SigChangeSummary>> GetSigChangeSummaries(string? userName, CancellationToken cancellationToken);
Task<IEnumerable<SigChangeSummary>> GetSigChangeSummaries(string? userName, int recordCount, CancellationToken cancellationToken);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ public class SignificantChangeApiClient(ISignificantChangesV4Client significantC
{
const string format = "dd/MM/yyyy";

public async Task<IEnumerable<SigChangeSummary>> GetSigChangeSummaries(string? userName, CancellationToken cancellationToken)
public async Task<IEnumerable<SigChangeSummary>> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private SigChangeIntegration CreateSigChangeIntegration()
IGetCaseInfo<SigChangeSummary> mapper = Substitute.For<IGetCaseInfo<SigChangeSummary>>();
ILogger<SigChangeIntegration> logger = Substitute.For<ILogger<SigChangeIntegration>>();

repo.GetSigChangeSummaries(Arg.Any<string>(), Arg.Any<CancellationToken>()).Returns([_fixture.Create<SigChangeSummary>()
repo.GetSigChangeSummaries(Arg.Any<string>(), Arg.Any<int>(), Arg.Any<CancellationToken>()).Returns([_fixture.Create<SigChangeSummary>()
]);
mapper.GetCaseInfo(Arg.Any<SigChangeSummary>()).Returns(_fixture.Create<UserCaseInfo>());

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
using Dfe.AcademiesApi.Client.Contracts;
using Dfe.CaseAggregationService.Infrastructure.Gateways;
using Microsoft.Extensions.Logging;
using NSubstitute;

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<IHttpClientFactory>();
var logger = Substitute.For<ILogger<ApiClient>>();
var sigChangeProjects = Substitute.For<ISignificantChangesV4Client>();

var results = new PagedDataResponseOfSignificantChangeDto()
Expand Down Expand Up @@ -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<CancellationToken>())
.Returns(Task.FromResult(results));

Expand All @@ -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();

Expand All @@ -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();

Expand All @@ -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);
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
</PropertyGroup>
<PropertyGroup />

<ItemGroup>
<Compile Remove="Customizations\Handlers\**" />
Expand Down
Loading