diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data.Tests/Dfe.PrepareConversions.Data.Tests.csproj b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data.Tests/Dfe.PrepareConversions.Data.Tests.csproj index 75c5336d6..47d28666c 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data.Tests/Dfe.PrepareConversions.Data.Tests.csproj +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data.Tests/Dfe.PrepareConversions.Data.Tests.csproj @@ -9,6 +9,7 @@ + diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data.Tests/Services/EstablishmentServiceTests.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data.Tests/Services/EstablishmentServiceTests.cs index e2a4377a1..63471732f 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data.Tests/Services/EstablishmentServiceTests.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data.Tests/Services/EstablishmentServiceTests.cs @@ -56,7 +56,7 @@ public async Task Should_search_by_urn( // Assert httpService.Verify(m => m.Get>( - It.IsAny(), $"establishments?urn={urn}"), Times.Once); + It.IsAny(), $"/v4/establishments?urn={urn}"), Times.Once); } [Theory] @@ -78,7 +78,7 @@ public async Task Should_search_by_name( // Assert httpService.Verify(m => m.Get>( - It.IsAny(), $"establishments?name={name}"), Times.Once); + It.IsAny(), $"/v4/establishments?name={name}"), Times.Once); } [Theory] diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data.Tests/Services/SchoolPerformanceServiceTests.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data.Tests/Services/SchoolPerformanceServiceTests.cs index c677bbd46..353c722d7 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data.Tests/Services/SchoolPerformanceServiceTests.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data.Tests/Services/SchoolPerformanceServiceTests.cs @@ -45,7 +45,7 @@ public async Task Should_get_school_performance_by_urn(AcademyConversionProject establishmentMockData.MisEstablishment.InspectionEndDate = "15/01/2020"; establishmentMockData.MisEstablishment.DateOfLatestSection8Inspection = "15/01/2020"; _mockHandler - .Expect($"/establishment/urn/{project.Urn}") + .Expect($"/v4/establishment/urn/{project.Urn}") .Respond("application/json", JsonConvert.SerializeObject(establishmentMockData)); SchoolPerformance schoolPerformance = await _schoolPerformanceService.GetSchoolPerformanceByUrn(project.Urn.ToString()); @@ -67,7 +67,7 @@ public async Task Should_get_school_performance_by_urn(AcademyConversionProject public async Task Should_log_warning_when_school_performance_not_found(AcademyConversionProject project) { _mockHandler - .Expect($"/establishment/urn/{project.Urn}") + .Expect($"/v4/establishment/urn/{project.Urn}") .Respond(HttpStatusCode.NotFound); await _schoolPerformanceService.GetSchoolPerformanceByUrn(project.Urn.ToString()); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data.Tests/Services/TrustsRespositoryTests.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data.Tests/Services/TrustsRespositoryTests.cs index 9ffcba7a7..bc29a1c66 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data.Tests/Services/TrustsRespositoryTests.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data.Tests/Services/TrustsRespositoryTests.cs @@ -21,17 +21,17 @@ public class TrustsRespositoryTests [AutoMoqData] public async Task SearchTrusts_ReturnsTrusts( [Frozen] Mock httpService, - TrustSummaryResponse expectedResponse, + TrustDtoResponse expectedResponse, MockHttpMessageHandler mockHandler, string name) { // Arrange TrustsRepository sut = new(new DfeHttpClientFactory(new MockHttpClientFactory(mockHandler), new CorrelationContext()), httpService.Object); - httpService.Setup(m => m.Get(It.IsAny(), It.IsAny())) - .ReturnsAsync(new ApiResponse(HttpStatusCode.OK, expectedResponse)); + httpService.Setup(m => m.Get(It.IsAny(), It.IsAny())) + .ReturnsAsync(new ApiResponse(HttpStatusCode.OK, expectedResponse)); // Act - TrustSummaryResponse results = await sut.SearchTrusts(name); + TrustDtoResponse results = await sut.SearchTrusts(name); // Assert Assert.Equivalent(expectedResponse, results); @@ -41,14 +41,14 @@ public async Task SearchTrusts_ReturnsTrusts( [AutoMoqData] public async Task Should_throw_exception( [Frozen] Mock httpService, - TrustSummaryResponse expectedResponse, + TrustDtoResponse expectedResponse, MockHttpMessageHandler mockHandler, string name) { // Arrange TrustsRepository sut = new(new DfeHttpClientFactory(new MockHttpClientFactory(mockHandler), new CorrelationContext()), httpService.Object); - httpService.Setup(m => m.Get(It.IsAny(), It.IsAny())) - .ReturnsAsync(new ApiResponse(HttpStatusCode.InternalServerError, expectedResponse)); + httpService.Setup(m => m.Get(It.IsAny(), It.IsAny())) + .ReturnsAsync(new ApiResponse(HttpStatusCode.InternalServerError, expectedResponse)); // Act ApiResponseException ex = await Assert.ThrowsAsync(() => sut.SearchTrusts(name)); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Dfe.PrepareConversions.Data.csproj b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Dfe.PrepareConversions.Data.csproj index 78edf1440..5d96222ec 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Dfe.PrepareConversions.Data.csproj +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Dfe.PrepareConversions.Data.csproj @@ -11,6 +11,7 @@ + diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademisationApplication/AcademisationApplication.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademisationApplication/AcademisationApplication.cs index 5fac93a3c..6e408e47d 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademisationApplication/AcademisationApplication.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/AcademisationApplication/AcademisationApplication.cs @@ -23,7 +23,7 @@ public static Application.Application MapToApplication(AcademisationApplication { // Following the fields used by the front end Application.Application academiesApplication = PopulateOverview(academisationApplication, out School academisationApplicationSchool, out ApplyingSchool academiesApplicationSchool, schoolName); - if(academiesApplication.ApplicationType.Equals(GlobalStrings.FormAMat)) PopulateFormAMatTrustInformation(academiesApplication, academisationApplication); + if (academiesApplication.ApplicationType.Equals(GlobalStrings.FormAMat)) PopulateFormAMatTrustInformation(academiesApplication, academisationApplication); PopulateSchoolDetails(academiesApplicationSchool, academisationApplicationSchool); PopulateFurtherInformation(academiesApplicationSchool, academisationApplicationSchool); PopulateSchoolFinances(academiesApplicationSchool, academisationApplicationSchool); @@ -63,7 +63,7 @@ public static void PopulateDeclaration(ApplyingSchool academiesApplicationSchool School academisationApplicationSchool) { academiesApplicationSchool.DeclarationBodyAgree = academisationApplicationSchool.DeclarationBodyAgree; - + } public static void PopulateConsultation(ApplyingSchool academiesApplicationSchool, @@ -92,7 +92,7 @@ public static void PopulateLandAndBuildings(ApplyingSchool academiesApplicationS academisationApplicationSchool.LandAndBuildings.FacilitiesSharedExplained; academiesApplicationSchool.SchoolBuildLandGrants = academisationApplicationSchool.LandAndBuildings.Grants; academiesApplicationSchool.SchoolBuildLandGrantsExplained = - academisationApplicationSchool.LandAndBuildings.GrantsAwardingBodies; + academisationApplicationSchool.LandAndBuildings.GrantsAwardingBodies; academiesApplicationSchool.SchoolBuildLandPFIScheme = academisationApplicationSchool.LandAndBuildings.PartOfPfiScheme; academiesApplicationSchool.SchoolBuildLandPFISchemeType = @@ -225,31 +225,31 @@ public static void PopulateFurtherInformation(ApplyingSchool academiesApplicatio // Further Information academiesApplicationSchool.SchoolAdSchoolContributionToTrust = academisationApplicationSchool - .TrustBenefitDetails; - academiesApplicationSchool.SchoolAdInspectedButReportNotPublished = !academisationApplicationSchool.OfstedInspectionDetails.IsNullOrEmpty(); + .TrustBenefitDetails; + academiesApplicationSchool.SchoolAdInspectedButReportNotPublished = !academisationApplicationSchool.OfstedInspectionDetails.IsNullOrEmpty(); academiesApplicationSchool.SchoolAdInspectedButReportNotPublishedExplain = academisationApplicationSchool.OfstedInspectionDetails; academiesApplicationSchool.SchoolOngoingSafeguardingInvestigations = - academisationApplicationSchool.Safeguarding; + academisationApplicationSchool.Safeguarding; // Questions regarding the below are outstanding // academiesApplicationSchool.SchoolOngoingSafeguardingDetails = academisationApplicationSchool.SafeguardingDetails; academiesApplicationSchool.SchoolPartOfLaReorganizationPlan = !academisationApplicationSchool.LocalAuthorityReorganisationDetails - .IsNullOrEmpty(); + .IsNullOrEmpty(); academiesApplicationSchool.SchoolLaReorganizationDetails = academisationApplicationSchool.LocalAuthorityReorganisationDetails; academiesApplicationSchool.SchoolPartOfLaClosurePlan = !academisationApplicationSchool.LocalAuthorityClosurePlanDetails.IsNullOrEmpty(); academiesApplicationSchool.SchoolLaClosurePlanDetails = academisationApplicationSchool - .LocalAuthorityClosurePlanDetails; + .LocalAuthorityClosurePlanDetails; academiesApplicationSchool.SchoolFaithSchool = !academisationApplicationSchool.DioceseName - .IsNullOrEmpty(); + .IsNullOrEmpty(); academiesApplicationSchool.SchoolFaithSchoolDioceseName = academisationApplicationSchool.DioceseName; academiesApplicationSchool.SchoolIsPartOfFederation = academisationApplicationSchool.PartOfFederation; academiesApplicationSchool.SchoolIsSupportedByFoundation = - !academisationApplicationSchool.FoundationTrustOrBodyName.IsNullOrEmpty(); + !academisationApplicationSchool.FoundationTrustOrBodyName.IsNullOrEmpty(); academiesApplicationSchool.SchoolSupportedFoundationBodyName = academisationApplicationSchool.FoundationTrustOrBodyName; if (academisationApplicationSchool.ExemptionEndDate is not null) @@ -268,9 +268,9 @@ public static void PopulateFurtherInformation(ApplyingSchool academiesApplicatio _ => string.Empty }; academiesApplicationSchool.SchoolAdditionalInformationAdded = - !academisationApplicationSchool.FurtherInformation.IsNullOrEmpty(); + !academisationApplicationSchool.FurtherInformation.IsNullOrEmpty(); academiesApplicationSchool.SchoolAdditionalInformation = - academisationApplicationSchool.FurtherInformation; + academisationApplicationSchool.FurtherInformation; } public static void PopulateSchoolDetails(ApplyingSchool academiesApplicationSchool, @@ -355,8 +355,8 @@ public static Application.Application PopulateOverview(AcademisationApplication academiesApplication.ChangesToLaGovernanceExplained = academisationApplication.JoinTrustDetails.ChangesToLaGovernanceExplained; } - - + + return academiesApplication; } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/Establishment/EstablishmentResponse.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/Establishment/EstablishmentResponse.cs index 83b2676b7..314b9b1b6 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/Establishment/EstablishmentResponse.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/Establishment/EstablishmentResponse.cs @@ -1,7 +1,7 @@ namespace Dfe.PrepareConversions.Data.Models.Establishment; /// -/// Copy of TramsDataApi.ResponseModels.EstablishmentResponse with most properties omitted +/// Copy of TramsDataApi.ResponseModels.EstablishmentDto with most properties omitted /// public class EstablishmentResponse { @@ -10,23 +10,23 @@ public class EstablishmentResponse public string LocalAuthorityCode { get; set; } public string LocalAuthorityName { get; set; } public string EstablishmentNumber { get; set; } - public string EstablishmentName { get; set; } - public NameAndCodeResponse EstablishmentType { get; set; } - public NameAndCodeResponse PhaseOfEducation { get; set; } - public NameAndCodeResponse ReligiousCharacter { get; set; } + public string Name { get; set; } + public NameAndCodeDto EstablishmentType { get; set; } + public NameAndCodeDto PhaseOfEducation { get; set; } + public NameAndCodeDto ReligiousCharacter { get; set; } public string OfstedRating { get; set; } public string OfstedLastInspection { get; set; } public string StatutoryLowAge { get; set; } public string StatutoryHighAge { get; set; } - public NameAndCodeResponse Diocese { get; set; } + public NameAndCodeDto Diocese { get; set; } public string SchoolCapacity { get; set; } public CensusResponse Census { get; set; } - public NameAndCodeResponse ParliamentaryConstituency { get; set; } + public NameAndCodeDto ParliamentaryConstituency { get; set; } public MisEstablishmentResponse MISEstablishment { get; set; } public AddressResponse Address { get; set; } public ViewAcademyConversion ViewAcademyConversion { get; set; } public string OpenDate { get; set; } - + public Region Gor { get; set; } public class Region diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/Establishment/NameAndCodeResponse.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/Establishment/NameAndCodeResponse.cs index db70141aa..f84bcca59 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/Establishment/NameAndCodeResponse.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/Establishment/NameAndCodeResponse.cs @@ -1,6 +1,6 @@ namespace Dfe.PrepareConversions.Data.Models.Establishment; -public class NameAndCodeResponse +public class NameAndCodeDto { public string Name { get; set; } public string Code { get; set; } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/Trust/TrustDetailResponse.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/Trust/TrustDetailResponse.cs index 292305f42..e4fe498fe 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/Trust/TrustDetailResponse.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/Trust/TrustDetailResponse.cs @@ -1,22 +1,11 @@ -using System.Collections.Generic; - -namespace Dfe.PrepareConversions.Data.Models.Trust; - -public class TrustDetailResponse -{ - public List Data { get; set; } -} +namespace Dfe.PrepareConversions.Data.Models.Trust; public class TrustDetail { - public GiasData GiasData { get; set; } -} - -public class GiasData -{ - public string GroupId { get; set; } - public string GroupName { get; set; } + public string ReferenceNumber { get; set; } + public string Name { get; set; } public string GroupType { get; set; } - public int CompaniesHouseNumber { get; set; } + public string CompaniesHouseNumber { get; set; } public string Ukprn { get; set; } } + diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/Trust/TrustSummaryResponse.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/Trust/TrustSummaryResponse.cs index 88aa0ee2b..84c6f3ae5 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/Trust/TrustSummaryResponse.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Models/Trust/TrustSummaryResponse.cs @@ -1,35 +1,9 @@ -using System.Collections.Generic; +using Dfe.Academies.Contracts.V4.Trusts; +using System.Collections.Generic; namespace Dfe.PrepareConversions.Data.Models.Trust; -public class TrustSummaryResponse +public class TrustDtoResponse { - public List Data { get; set; } -} - -public class TrustSummary -{ - public string Ukprn { get; set; } - public string GroupName { get; set; } - public string CompaniesHouseNumber { get; set; } - public string TrustType { get; set; } - public TrustAddress TrustAddress { get; set; } - public List Establishments { get; set; } -} - -public class TrustAddress -{ - public string Street { get; set; } - public string Locality { get; set; } - public string AdditionalLine { get; set; } - public string Town { get; set; } - public string County { get; set; } - public string Postcode { get; set; } -} - -public class EstablishmentDetail -{ - public string Urn { get; set; } - public string Name { get; set; } - public string Ukprn { get; set; } -} + public List Data { get; set; } +} \ No newline at end of file diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/EstablishmentService.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/EstablishmentService.cs index aa9496fd4..caf496987 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/EstablishmentService.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/EstablishmentService.cs @@ -6,6 +6,7 @@ using System.Net.Http; using System.Net.Http.Json; using System.Threading.Tasks; +using EstablishmentDto = Dfe.Academies.Contracts.V4.Establishments.EstablishmentDto; namespace Dfe.PrepareConversions.Data.Services; @@ -24,23 +25,23 @@ public EstablishmentService(IDfeHttpClientFactory httpClientFactory, _httpClientService = httpClientService; } - public async Task GetEstablishmentByUrn(string urn) + public async Task GetEstablishmentByUrn(string urn) { - HttpResponseMessage response = await _httpClient.GetAsync($"/establishment/urn/{urn}"); + HttpResponseMessage response = await _httpClient.GetAsync($"/v4/establishment/urn/{urn}"); if (!response.IsSuccessStatusCode) { _logger.LogWarning("Unable to get establishment data for establishment with URN: {urn}", urn); - return new EstablishmentResponse(); + return new EstablishmentDto(); } - return await response.Content.ReadFromJsonAsync(); + return await response.Content.ReadFromJsonAsync(); } public async Task> SearchEstablishments(string searchQuery) { string path = int.TryParse(searchQuery, out int urn) - ? $"establishments?urn={urn}" - : $"establishments?name={searchQuery}"; + ? $"/v4/establishments?urn={urn}" + : $"/v4/establishments?name={searchQuery}"; ApiResponse> result = await _httpClientService.Get>(_httpClient, path); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/IGetEstablishment.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/IGetEstablishment.cs index 36ba7ad80..965c8642a 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/IGetEstablishment.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/IGetEstablishment.cs @@ -6,6 +6,6 @@ namespace Dfe.PrepareConversions.Data.Services; public interface IGetEstablishment { - Task GetEstablishmentByUrn(string urn); + Task GetEstablishmentByUrn(string urn); Task> SearchEstablishments(string searchQuery); } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/Interfaces/ITrustsRepository.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/Interfaces/ITrustsRepository.cs index 7ded1ab72..06cb79369 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/Interfaces/ITrustsRepository.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/Interfaces/ITrustsRepository.cs @@ -1,11 +1,12 @@ -using Dfe.PrepareConversions.Data.Models.Trust; +using Dfe.Academies.Contracts.V4.Trusts; +using Dfe.PrepareConversions.Data.Models.Trust; using System.Threading.Tasks; namespace Dfe.PrepareConversions.Data.Services.Interfaces; public interface ITrustsRepository { - Task SearchTrusts(string searchQuery); + Task SearchTrusts(string searchQuery); - Task GetTrustByUkprn(string ukprn); + Task GetTrustByUkprn(string ukprn); } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/SchoolOverviewService.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/SchoolOverviewService.cs index fc806d56d..dad813df8 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/SchoolOverviewService.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/SchoolOverviewService.cs @@ -1,5 +1,5 @@ -using Dfe.PrepareConversions.Data.Models; -using Dfe.PrepareConversions.Data.Models.Establishment; +using Dfe.Academies.Contracts.V4.Establishments; +using Dfe.PrepareConversions.Data.Models; using System; using System.Threading.Tasks; @@ -16,7 +16,7 @@ public SchoolOverviewService(IGetEstablishment getEstablishment) public async Task GetSchoolOverviewByUrn(string urn) { - EstablishmentResponse establishment = await _getEstablishment.GetEstablishmentByUrn(urn); + EstablishmentDto establishment = await _getEstablishment.GetEstablishmentByUrn(urn); SchoolOverview schoolOverview = new() { SchoolPostcode = establishment.Address?.Postcode, @@ -34,7 +34,7 @@ public async Task GetSchoolOverviewByUrn(string urn) return schoolOverview; } - private static string IsPartOfADiocesanTrust(NameAndCodeResponse nameAndCode) + private static string IsPartOfADiocesanTrust(NameAndCodeDto nameAndCode) { if (nameAndCode == null) { diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/SchoolPerformanceService.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/SchoolPerformanceService.cs index bd3d4a1aa..27b8bfe62 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/SchoolPerformanceService.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/SchoolPerformanceService.cs @@ -1,5 +1,6 @@ -using Dfe.PrepareConversions.Data.Models; -using Dfe.PrepareConversions.Data.Models.Establishment; +using Dfe.Academies.Contracts.V4.Establishments; +using Dfe.PrepareConversions.Data.Models; + using System; using System.Globalization; using System.Threading.Tasks; @@ -17,7 +18,7 @@ public SchoolPerformanceService(IGetEstablishment getEstablishment) public async Task GetSchoolPerformanceByUrn(string urn) { - EstablishmentResponse establishment = await _getEstablishment.GetEstablishmentByUrn(urn); + EstablishmentDto establishment = await _getEstablishment.GetEstablishmentByUrn(urn); SchoolPerformance schoolPerformance = new(); if (establishment.MISEstablishment != null) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/TrustsRepository.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/TrustsRepository.cs index 4c290f8de..efb67956a 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/TrustsRepository.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Data/Services/TrustsRepository.cs @@ -1,6 +1,8 @@ -using Dfe.PrepareConversions.Data.Exceptions; +using Dfe.Academies.Contracts.V4.Trusts; +using Dfe.PrepareConversions.Data.Exceptions; using Dfe.PrepareConversions.Data.Models.Trust; using Dfe.PrepareConversions.Data.Services.Interfaces; +using System.Collections.Generic; using System.Linq; using System.Net.Http; using System.Threading.Tasks; @@ -20,25 +22,23 @@ public TrustsRepository( _httpClientService = httpClientService; } - public async Task SearchTrusts(string searchQuery) + public async Task SearchTrusts(string searchQuery) { - string path = $"/v2/trusts?groupName={searchQuery}&ukPrn={searchQuery}&companiesHouseNumber={searchQuery}&page=1&count=1000000"; + string trustPath = $"/v4/trusts?groupName={searchQuery}&ukPrn={searchQuery}&companiesHouseNumber={searchQuery}&page=1&count=1000000"; - ApiResponse result = await _httpClientService.Get(_httpClient, path); + ApiResponse result = await _httpClientService.Get(_httpClient, trustPath); if (result.Success is false) throw new ApiResponseException($"Request to Api failed | StatusCode - {result.StatusCode}"); return result.Body; } - public async Task GetTrustByUkprn(string ukprn) + public async Task GetTrustByUkprn(string ukprn) { if (string.IsNullOrWhiteSpace(ukprn)) return default; - - string path = $@"/v2/trusts/bulk?Ukprn={ukprn.Trim()}&Establishments=false"; - - ApiResponse result = await _httpClientService.Get(_httpClient, path); - - return result.Body.Data.FirstOrDefault(); + string[] array = new string[] { ukprn.Trim() }; + string path = $@"/v4/trusts/bulk?Ukprns={array[0]}"; + ApiResponse> result = await _httpClientService.Get>(_httpClient, path); + return result.Body.FirstOrDefault(); } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.DocumentGeneration.Tests/Dfe.PrepareConversions.DocumentGeneration.Tests.csproj b/Dfe.PrepareConversions/Dfe.PrepareConversions.DocumentGeneration.Tests/Dfe.PrepareConversions.DocumentGeneration.Tests.csproj index 6173cdb39..d275087e2 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.DocumentGeneration.Tests/Dfe.PrepareConversions.DocumentGeneration.Tests.csproj +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.DocumentGeneration.Tests/Dfe.PrepareConversions.DocumentGeneration.Tests.csproj @@ -7,6 +7,7 @@ + diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.DocumentGeneration/Dfe.PrepareConversions.DocumentGeneration.csproj b/Dfe.PrepareConversions/Dfe.PrepareConversions.DocumentGeneration/Dfe.PrepareConversions.DocumentGeneration.csproj index 43a7f9c6a..92810895c 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.DocumentGeneration/Dfe.PrepareConversions.DocumentGeneration.csproj +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.DocumentGeneration/Dfe.PrepareConversions.DocumentGeneration.csproj @@ -10,6 +10,7 @@ + diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Redirector/Dfe.PrepareConversions.Redirector.csproj b/Dfe.PrepareConversions/Dfe.PrepareConversions.Redirector/Dfe.PrepareConversions.Redirector.csproj index 70f0505ea..57ab39f19 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Redirector/Dfe.PrepareConversions.Redirector.csproj +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Redirector/Dfe.PrepareConversions.Redirector.csproj @@ -9,6 +9,7 @@ + diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Dfe.PrepareConversions.Tests.csproj b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Dfe.PrepareConversions.Tests.csproj index 9dfacad79..20129959c 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Dfe.PrepareConversions.Tests.csproj +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Dfe.PrepareConversions.Tests.csproj @@ -17,6 +17,7 @@ + diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Mappings/CreateSponsoredProjectMapperTests.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Mappings/CreateSponsoredProjectMapperTests.cs index 610d8a380..8d4020714 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Mappings/CreateSponsoredProjectMapperTests.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Mappings/CreateSponsoredProjectMapperTests.cs @@ -1,6 +1,6 @@ using AutoFixture; -using Dfe.PrepareConversions.Data.Models.Establishment; -using Dfe.PrepareConversions.Data.Models.Trust; +using Dfe.Academies.Contracts.V4.Establishments; +using Dfe.Academies.Contracts.V4.Trusts; using Dfe.PrepareConversions.Mappings; using FluentAssertions; using FluentAssertions.Execution; @@ -17,25 +17,21 @@ public void Should_Map_Establishment_With_PfiScheme_And_Trust_Into_Dto_CreateSpo // Arrange var fixture = new AutoFixture.Fixture(); - EstablishmentResponse establishment = new() + EstablishmentDto establishment = new() { - EstablishmentName = fixture.Create(), + Name = fixture.Create(), Urn = Guid.NewGuid().ToString(), - ViewAcademyConversion = new() { Pfi = "some-text" }, + Pfi = "some-text", LocalAuthorityName = fixture.Create(), - Gor = new EstablishmentResponse.Region() { Name = fixture.Create() } + Gor = new NameAndCodeDto { Name = fixture.Create() } }; - TrustDetail trust = new() + TrustDto trust = new() { - GiasData = new() - { - Ukprn = fixture.Create(), - GroupId = fixture.Create(), - GroupName = fixture.Create(), - GroupType = fixture.Create(), - CompaniesHouseNumber = fixture.Create() - } + Ukprn = fixture.Create(), + ReferenceNumber = fixture.Create(), + Name = fixture.Create(), + CompaniesHouseNumber = fixture.Create() }; // Act @@ -46,8 +42,8 @@ public void Should_Map_Establishment_With_PfiScheme_And_Trust_Into_Dto_CreateSpo result.School.Region.Should().BeEquivalentTo(establishment.Gor.Name); result.Trust.Should().NotBeNull().And.BeEquivalentTo(trust, cfg => cfg.ExcludingMissingMembers()); result.School.Should().NotBeNull().And.BeEquivalentTo(establishment, cfg => cfg.ExcludingMissingMembers()); - - + + } [Theory] @@ -62,25 +58,21 @@ public void Should_Map_Establishment_Without_PfiScheme_And_Trust_Into_Dto_Create // Arrange var fixture = new AutoFixture.Fixture(); - EstablishmentResponse establishment = new() + EstablishmentDto establishment = new() { - EstablishmentName = fixture.Create(), + Name = fixture.Create(), Urn = Guid.NewGuid().ToString(), - ViewAcademyConversion = new() { Pfi = pfiScheme }, + Pfi = pfiScheme, LocalAuthorityName = fixture.Create(), - Gor = new EstablishmentResponse.Region() { Name = fixture.Create() } + Gor = new NameAndCodeDto() { Name = fixture.Create() } }; - TrustDetail trust = new() + TrustDto trust = new() { - GiasData = new() - { - Ukprn = fixture.Create(), - GroupId = fixture.Create(), - GroupName = fixture.Create(), - GroupType = fixture.Create(), - CompaniesHouseNumber = fixture.Create() - } + Ukprn = fixture.Create(), + ReferenceNumber = fixture.Create(), + Name = fixture.Create(), + CompaniesHouseNumber = fixture.Create() }; // Act diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/BaseIntegrationTests.MockData.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/BaseIntegrationTests.MockData.cs index 7cbc5f17d..e29df88f4 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/BaseIntegrationTests.MockData.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/BaseIntegrationTests.MockData.cs @@ -1,9 +1,9 @@ using AutoFixture; using AutoFixture.Dsl; +using Dfe.Academies.Contracts.V4.Establishments; using Dfe.PrepareConversions.Data.Features; using Dfe.PrepareConversions.Data.Models; using Dfe.PrepareConversions.Data.Models.AcademisationApplication; -using Dfe.PrepareConversions.Data.Models.Establishment; using Dfe.PrepareConversions.Data.Models.KeyStagePerformance; using Dfe.PrepareConversions.Data.Services; using Dfe.PrepareConversions.Tests.Customisations; @@ -171,23 +171,23 @@ public void AddProjectNotePostError(int id) _factory.AddErrorResponse($"/project-notes/{id}", "post"); } - public EstablishmentResponse AddGetEstablishmentResponse(string urn, bool empty = false) + public EstablishmentDto AddGetEstablishmentDto(string urn, bool empty = false) { - EstablishmentResponse establishmentResponse; + EstablishmentDto EstablishmentDto; if (empty) { - establishmentResponse = _fixture.Build().OmitAutoProperties().Create(); + EstablishmentDto = _fixture.Build().OmitAutoProperties().Create(); } else { _fixture.Customizations.Add(new OfstedRatingSpecimenBuilder()); - establishmentResponse = _fixture.Build().Create(); - establishmentResponse.Census.NumberOfPupils = _fixture.Create().ToString(); - establishmentResponse.SchoolCapacity = _fixture.Create().ToString(); + EstablishmentDto = _fixture.Build().Create(); + EstablishmentDto.Census.NumberOfPupils = _fixture.Create().ToString(); + EstablishmentDto.SchoolCapacity = _fixture.Create().ToString(); } - _factory.AddGetWithJsonResponse($"/establishment/urn/{urn}", establishmentResponse); - return establishmentResponse; + _factory.AddGetWithJsonResponse($"/v4/establishment/urn/{urn}", EstablishmentDto); + return EstablishmentDto; } public AcademisationApplication AddGetApplication(Action postSetup = null) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/SponsoredProject/SearchSchoolIntegrationTests.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/SponsoredProject/SearchSchoolIntegrationTests.cs index 8e4db8611..e1e464c2b 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/SponsoredProject/SearchSchoolIntegrationTests.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/SponsoredProject/SearchSchoolIntegrationTests.cs @@ -1,6 +1,6 @@ using AngleSharp.Dom; using AngleSharp.Html.Dom; -using Dfe.PrepareConversions.Data.Models.Establishment; +using Dfe.Academies.Contracts.V4.Establishments; using FluentAssertions; using System.Collections.Generic; using System.Threading.Tasks; @@ -42,13 +42,13 @@ public async Task Should_show_school_not_found_error() string schoolName = "fakeschoolname"; _factory.AddGetWithJsonResponse("/establishments", - new List { new() }); + new List { new() }); Document.QuerySelector("#SearchQuery")!.Value = schoolName; await Document.QuerySelector("[data-id=submit]")!.SubmitAsync(); - Document.QuerySelector("[data-cy=error-summary]")!.Text().Trim().Should() - .Be("We could not find any schools matching your search criteria"); + Document.QuerySelector("[data-cy=error-summary]")!.Text().Trim().Should() + .Be("We could not find any schools matching your search criteria"); } [Fact] @@ -58,12 +58,12 @@ public async Task Should_school_not_found_error_when_ukprn_is_incorrect() string schoolName = "fakeschoolname(22222)"; _factory.AddGetWithJsonResponse("/establishments", - new List { new() }); + new List { new() }); Document.QuerySelector("#SearchQuery")!.Value = schoolName; await Document.QuerySelector("[data-id=submit]")!.SubmitAsync(); - Document.QuerySelector("[data-cy=error-summary]")!.Text().Trim().Should() - .Be("We could not find a school matching your search criteria"); + Document.QuerySelector("[data-cy=error-summary]")!.Text().Trim().Should() + .Be("We could not find a school matching your search criteria"); } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/SponsoredProject/SearchSchoolModelUnitTests.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/SponsoredProject/SearchSchoolModelUnitTests.cs index 41f06b10e..182a34a52 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/SponsoredProject/SearchSchoolModelUnitTests.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/SponsoredProject/SearchSchoolModelUnitTests.cs @@ -12,6 +12,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using Xunit; +using EstablishmentDto = Dfe.Academies.Contracts.V4.Establishments.EstablishmentDto; namespace Dfe.PrepareConversions.Tests.Pages.SponsoredProject; @@ -96,15 +97,15 @@ public async Task OnGetSearch_SearchSchool_Prepopulated([Frozen] Mock(), Mock.Of()) }; - EstablishmentResponse establishmentResponse = new() { EstablishmentName = "Bristol", Urn = "100" }; - getEstablishment.Setup(m => m.GetEstablishmentByUrn(It.IsAny())).ReturnsAsync(establishmentResponse); + EstablishmentDto EstablishmentDto = new() { Name = "Bristol", Urn = "100" }; + getEstablishment.Setup(m => m.GetEstablishmentByUrn(It.IsAny())).ReturnsAsync(EstablishmentDto); // Act - await sut.OnGet(establishmentResponse.Urn); + await sut.OnGet(EstablishmentDto.Urn); // Assert - Assert.Equal($"{establishmentResponse.EstablishmentName} ({establishmentResponse.Urn})", sut.SearchQuery); + Assert.Equal($"{EstablishmentDto.Name} ({EstablishmentDto.Urn})", sut.SearchQuery); } private static T ExtractType(JsonResult result) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/SponsoredProject/SearchTrustsIntegrationTests.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/SponsoredProject/SearchTrustsIntegrationTests.cs index eee87fb5d..1235ad8ee 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/SponsoredProject/SearchTrustsIntegrationTests.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/SponsoredProject/SearchTrustsIntegrationTests.cs @@ -1,6 +1,6 @@ using AngleSharp.Dom; using AngleSharp.Html.Dom; -using Dfe.PrepareConversions.Data.Models.Establishment; +using Dfe.Academies.Contracts.V4.Establishments; using FluentAssertions; using System.Collections.Generic; using System.Threading.Tasks; @@ -32,7 +32,7 @@ public async Task Should_show_trust_not_found_error() string trustName = "faketrustname"; _factory.AddGetWithJsonResponse("/establishments", - new List { new() }); + new List { new() }); Document.QuerySelector("#SearchQuery")!.Value = trustName; await Document.QuerySelector("[data-id=submit]")!.SubmitAsync(); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/SponsoredProject/SearchTrustsModelUnitTests.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/SponsoredProject/SearchTrustsModelUnitTests.cs index 8f9aecab8..a09df10c3 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/SponsoredProject/SearchTrustsModelUnitTests.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/SponsoredProject/SearchTrustsModelUnitTests.cs @@ -1,8 +1,8 @@ using AutoFixture.Xunit2; +using Dfe.Academies.Contracts.V4.Trusts; using Dfe.Academisation.ExtensionMethods; using Dfe.PrepareConversions.Data.Models.Trust; using Dfe.PrepareConversions.Data.Services.Interfaces; -using Dfe.PrepareConversions.Extensions; using Dfe.PrepareConversions.Pages.SponsoredProject; using Dfe.PrepareConversions.Services; using Dfe.PrepareConversions.Tests.Customisations; @@ -19,7 +19,7 @@ public class SearchTrustModelUnitTests { [Theory] [AutoMoqData] - public async Task OnGetSearch_ReturnsTrustNames([Frozen] Mock trustsRepository, TrustSummaryResponse trusts) + public async Task OnGetSearch_ReturnsTrustNames([Frozen] Mock trustsRepository, TrustDtoResponse trusts) { // Arrange SearchTrustModel sut = new(trustsRepository.Object, new ErrorService()); @@ -30,9 +30,9 @@ public async Task OnGetSearch_ReturnsTrustNames([Frozen] Mock List json = ExtractType>(Assert.IsType(result)); // Assert - Assert.Equal($"{trusts.Data[0].GroupName.ToTitleCase()} ({trusts.Data[0].Ukprn})", json[0].value); - Assert.Equal($"{trusts.Data[1].GroupName.ToTitleCase()} ({trusts.Data[1].Ukprn})", json[1].value); - Assert.Equal($"{trusts.Data[2].GroupName.ToTitleCase()} ({trusts.Data[2].Ukprn})", json[2].value); + Assert.Equal($"{trusts.Data[0].Name.ToTitleCase()} ({trusts.Data[0].Ukprn})", json[0].value); + Assert.Equal($"{trusts.Data[1].Name.ToTitleCase()} ({trusts.Data[1].Ukprn})", json[1].value); + Assert.Equal($"{trusts.Data[2].Name.ToTitleCase()} ({trusts.Data[2].Ukprn})", json[2].value); } [Theory] @@ -41,12 +41,12 @@ public async Task OnGetSearch_ReturnsSuggestion([Frozen] Mock { // Arrange SearchTrustModel sut = new(trustsRepository.Object, new ErrorService()); - TrustSummary trust = new() { GroupName = "bristol", Ukprn = "100", CompaniesHouseNumber = "100" }; + TrustDto trust = new() { Name = "bristol", Ukprn = "100", CompaniesHouseNumber = "100" }; trustsRepository.Setup(m => m.SearchTrusts(It.IsAny())).ReturnsAsync( - new TrustSummaryResponse { Data = new List { trust } }); + new TrustDtoResponse { Data = new List { trust } }); // Act - IActionResult result = await sut.OnGetSearch(trust.GroupName); + IActionResult result = await sut.OnGetSearch(trust.Name); List json = ExtractType>(Assert.IsType(result)); // Assert @@ -60,18 +60,18 @@ public async Task OnGetSearch_ReturnsSuggestion_WhenUkprnIsIncludedInSearch([Fro { // Arrange SearchTrustModel sut = new(trustsRepository.Object, new ErrorService()); - TrustSummary trust = new() { GroupName = "Bristol", Ukprn = "100", CompaniesHouseNumber = "100" }; + TrustDto trust = new() { Name = "Bristol", Ukprn = "100", CompaniesHouseNumber = "100" }; trustsRepository.Setup(m => m.SearchTrusts(It.IsAny())).ReturnsAsync( - new TrustSummaryResponse { Data = new List { trust } }); + new TrustDtoResponse { Data = new List { trust } }); // Act - IActionResult result = await sut.OnGetSearch($"{trust.GroupName} ({trust.Ukprn})"); + IActionResult result = await sut.OnGetSearch($"{trust.Name} ({trust.Ukprn})"); List json = ExtractType>(Assert.IsType(result)); // Assert Assert.Equal($"Bristol (100)
Companies House number: {trust.CompaniesHouseNumber}", SanatiseString(json[0].suggestion)); - Assert.Equal($"{trust.GroupName} ({trust.Ukprn})", json[0].value); + Assert.Equal($"{trust.Name} ({trust.Ukprn})", json[0].value); } [Theory] @@ -80,12 +80,12 @@ public async Task OnGetSearch_DoesNotThrow_WhenEmptyTrust([Frozen] Mock m.SearchTrusts(It.IsAny())).ReturnsAsync( - new TrustSummaryResponse { Data = new List { trust } }); + new TrustDtoResponse { Data = new List { trust } }); // Act - IActionResult result = await sut.OnGetSearch(trust.GroupName); + IActionResult result = await sut.OnGetSearch(trust.Name); List json = ExtractType>(Assert.IsType(result)); // Assert @@ -98,15 +98,15 @@ public async Task OnGetSearch_SearchTrust_Prepopulated([Frozen] Mock m.SearchTrusts(It.IsAny())).ReturnsAsync( - new TrustSummaryResponse { Data = new List { trust } }); + new TrustDtoResponse { Data = new List { trust } }); // Act await sut.OnGet(trust.Ukprn, string.Empty); // Assert - Assert.Equal($"{trust.GroupName} ({trust.Ukprn})", sut.SearchQuery); + Assert.Equal($"{trust.Name} ({trust.Ukprn})", sut.SearchQuery); } private static string SanatiseString(string input) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/SponsoredProject/SummaryIntegrationTests.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/SponsoredProject/SummaryIntegrationTests.cs index a858d30fe..b2833c0ce 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/SponsoredProject/SummaryIntegrationTests.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/SponsoredProject/SummaryIntegrationTests.cs @@ -1,11 +1,10 @@ using AngleSharp.Dom; using AngleSharp.Html.Dom; -using Dfe.PrepareConversions.Data.Models.Establishment; +using Dfe.Academies.Contracts.V4.Establishments; using Dfe.PrepareConversions.Data.Models.Trust; using Dfe.PrepareConversions.Tests.Customisations; using FluentAssertions; using System; -using System.Globalization; using System.Threading.Tasks; using Xunit; @@ -19,41 +18,19 @@ public SummaryIntegrationTests(IntegrationTestingWebApplicationFactory factory) [Theory] [AutoMoqData] - public async Task Should_render_summary_page_with_school_and_trust(EstablishmentResponse establishment, TrustSummaryResponse trustSummaryResponse) + public async Task Should_render_summary_page_with_school_and_trust(EstablishmentDto establishment, TrustDtoResponse TrustDtoResponse) { establishment.OfstedLastInspection = DateTime.Now.ToString("dd-mm-yyyy"); - string ukprn = trustSummaryResponse.Data[0].Ukprn; - _factory.AddGetWithJsonResponse($"/establishment/urn/{establishment.Urn}", establishment); - _factory.AddGetWithJsonResponse("/v2/trusts*", trustSummaryResponse); + string ukprn = TrustDtoResponse.Data[0].Ukprn; + _factory.AddGetWithJsonResponse($"/v4/establishment/urn/{establishment.Urn}", establishment); + _factory.AddGetWithJsonResponse("/v4/trusts*", TrustDtoResponse); await OpenAndConfirmPathAsync($"/start-new-project/check-school-trust-details?ukprn={ukprn}&urn={establishment.Urn}"); Document.QuerySelector("[data-cy=school-name]")!.Text().Trim().Should() - .Be(establishment.EstablishmentName); + .Be(establishment.Name); Document.QuerySelector("[data-cy=trust-name]")!.Text().Trim().Should() - .Be(trustSummaryResponse.Data[0].GroupName); + .Be(TrustDtoResponse.Data[0].Name); } - [Theory] - [AutoMoqData] - public async Task Should_submit_and_redirect_to_listing(EstablishmentResponse establishment, - TrustSummaryResponse trustSummaryResponse, - TrustDetailResponse trustDetail) - { - establishment.OfstedLastInspection = DateTime.Now.ToString("dd-mm-yyyy"); - establishment.OpenDate = DateTime.Now.ToString(CultureInfo.InvariantCulture); - string ukprn = trustSummaryResponse.Data[0].Ukprn; - _factory.AddGetWithJsonResponse($"/establishment/urn/{establishment.Urn}", establishment); - _factory.AddGetWithJsonResponse("/v2/trusts*", trustSummaryResponse); - - await OpenAndConfirmPathAsync($"/start-new-project/check-school-trust-details?ukprn={ukprn}&urn={establishment.Urn}"); - - _factory.AddGetWithJsonResponse(@"/v2/trusts/bulk*", trustDetail); - _factory.AddAnyPostWithJsonRequest("/legacy/project/sponsored-conversion-project", ""); - - await Document.QuerySelector("[data-id=submit]")!.SubmitAsync(); - - Document.Url.Should().Contain("project-list"); - Document.QuerySelector("h1")!.Text().Should().Be("Manage an academy conversion"); - } } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/PreviewHTBTemplate/PreviewHTBIntegrationTests.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/PreviewHTBTemplate/PreviewHTBIntegrationTests.cs index d1253b3a3..9ddbaaeb8 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/PreviewHTBTemplate/PreviewHTBIntegrationTests.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/PreviewHTBTemplate/PreviewHTBIntegrationTests.cs @@ -1,11 +1,10 @@ using AngleSharp.Dom; using AngleSharp.Html.Dom; using AutoFixture; +using Dfe.Academies.Contracts.V4.Establishments; using Dfe.Academisation.ExtensionMethods; using Dfe.PrepareConversions.Data.Models; -using Dfe.PrepareConversions.Data.Models.Establishment; using Dfe.PrepareConversions.Data.Models.KeyStagePerformance; -using Dfe.PrepareConversions.Extensions; using Dfe.PrepareConversions.Tests.Customisations; using Dfe.PrepareConversions.Tests.Extensions; using Dfe.PrepareConversions.Tests.TestHelpers; @@ -83,7 +82,7 @@ public async Task Should_navigate_between_preview_htb_template_and_generate_htb_ public async Task Should_display_error_summary_on_preview_htb_template_when_generate_button_clicked_if_no_htb_date_set() { AcademyConversionProject project = AddGetProject(p => p.HeadTeacherBoardDate = null); - + var pageObject = new PreviewHtbTemplatePageModel(); var document = await OpenAndConfirmPathAsync($"/task-list/{project.Id}/preview-project-template"); document = await pageObject.NavigateToGenerateHtbTemplate(document, project.Id, expectFailure: true); @@ -104,7 +103,7 @@ public async Task Should_display_error_summary_on_preview_htb_template_when_gene public async Task Should_display_school_overview_section() { AcademyConversionProject project = AddGetProject(); - EstablishmentResponse establishment = AddGetEstablishmentResponse(project.Urn.ToString()); + EstablishmentDto establishment = AddGetEstablishmentDto(project.Urn.ToString()); await OpenAndConfirmPathAsync($"/task-list/{project.Id}/preview-project-template"); Document.Url.Should().Contain($"/task-list/{project.Id}/preview-project-template"); @@ -258,7 +257,7 @@ public async Task Should_navigate_school_budget_additional_information_and_back( public async Task Should_display_school_pupil_forecasts_section() { AcademyConversionProject project = AddGetProject(); - EstablishmentResponse establishment = AddGetEstablishmentResponse(project.Urn.ToString()); + EstablishmentDto establishment = AddGetEstablishmentDto(project.Urn.ToString()); await OpenAndConfirmPathAsync($"/task-list/{project.Id}/preview-project-template"); Document.Url.Should().Contain($"/task-list/{project.Id}/preview-project-template"); @@ -787,7 +786,8 @@ public async Task Should_navigate_to_school_and_trust_prev_htb_input_page_and_ba [Fact] public async Task Should_navigate_to_school_and_trust_prev_htb_input_page_and_back_to_question_and_submit_to_input_and_back() { - AcademyConversionProject project = AddGetProject(p => { + AcademyConversionProject project = AddGetProject(p => + { p.PreviousHeadTeacherBoardDateQuestion = "Yes"; p.AcademyTypeAndRoute = AcademyTypeAndRoutes.Voluntary; }); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolOverview/ConfirmSchoolOverviewIntegrationTests.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolOverview/ConfirmSchoolOverviewIntegrationTests.cs index afa8c0e46..b43b2a202 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolOverview/ConfirmSchoolOverviewIntegrationTests.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolOverview/ConfirmSchoolOverviewIntegrationTests.cs @@ -1,9 +1,8 @@ using AngleSharp.Dom; using AngleSharp.Html.Dom; +using Dfe.Academies.Contracts.V4.Establishments; using Dfe.Academisation.ExtensionMethods; using Dfe.PrepareConversions.Data.Models; -using Dfe.PrepareConversions.Data.Models.Establishment; -using Dfe.PrepareConversions.Extensions; using Dfe.PrepareConversions.Tests.Extensions; using FluentAssertions; using System.Threading.Tasks; @@ -19,7 +18,7 @@ public ConfirmSchoolOverviewIntegrationTests(IntegrationTestingWebApplicationFac public async Task Should_be_in_progress_and_display_school_overview() { AcademyConversionProject project = AddGetProject(p => p.SchoolOverviewSectionComplete = false); - EstablishmentResponse establishment = AddGetEstablishmentResponse(project.Urn.ToString()); + EstablishmentDto establishment = AddGetEstablishmentDto(project.Urn.ToString()); await OpenAndConfirmPathAsync($"/task-list/{project.Id}"); @@ -88,7 +87,7 @@ public async Task Should_display_change_on_pfi_scheme() public async Task Should_be_completed_and_checked_when_school_overview_complete() { AcademyConversionProject project = AddGetProject(project => project.SchoolOverviewSectionComplete = true); - AddGetEstablishmentResponse(project.Urn.ToString()); + AddGetEstablishmentDto(project.Urn.ToString()); AddPatchConfiguredProject(project, x => { x.SchoolOverviewSectionComplete = true; @@ -123,7 +122,7 @@ public async Task Should_be_not_started_and_display_empty_when_school_overview_n project.SchoolOverviewSectionComplete = false; project.MemberOfParliamentNameAndParty = null; }); - AddGetEstablishmentResponse(project.Urn.ToString(), true); + AddGetEstablishmentDto(project.Urn.ToString(), true); AddPatchConfiguredProject(project, x => { x.SchoolOverviewSectionComplete = false; @@ -163,7 +162,7 @@ public async Task Should_be_not_started_and_display_empty_when_school_overview_n public async Task Should_show_error_summary_when_there_is_an_API_error() { AcademyConversionProject project = AddGetProject(); - AddGetEstablishmentResponse(project.Urn.ToString()); + AddGetEstablishmentDto(project.Urn.ToString()); AddPatchError(project.Id); await OpenAndConfirmPathAsync($"/task-list/{project.Id}/school-overview"); @@ -177,7 +176,7 @@ public async Task Should_show_error_summary_when_there_is_an_API_error() public async Task Back_link_should_navigate_from_school_overview_to_task_list() { AcademyConversionProject project = AddGetProject(); - AddGetEstablishmentResponse(project.Urn.ToString()); + AddGetEstablishmentDto(project.Urn.ToString()); await OpenAndConfirmPathAsync($"/task-list/{project.Id}"); await NavigateAsync("School overview"); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolOverview/DistanceFromSchoolToTrustHeadquartersIntegrationTests.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolOverview/DistanceFromSchoolToTrustHeadquartersIntegrationTests.cs index 1028e07ae..0885df7c0 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolOverview/DistanceFromSchoolToTrustHeadquartersIntegrationTests.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolOverview/DistanceFromSchoolToTrustHeadquartersIntegrationTests.cs @@ -18,7 +18,7 @@ public DistanceFromTrustHeadquartersIntegrationTests(IntegrationTestingWebApplic public async Task Should_navigate_to_and_update_distance_to_trust_headquarters() { AcademyConversionProject project = AddGetProject(); - AddGetEstablishmentResponse(project.Urn.ToString()); + AddGetEstablishmentDto(project.Urn.ToString()); UpdateAcademyConversionProject request = AddPatchProjectMany(project, composer => composer .With(r => r.DistanceFromSchoolToTrustHeadquarters) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolOverview/FinancialDeficitIntegrationTests.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolOverview/FinancialDeficitIntegrationTests.cs index 109b42be3..f424ca3cb 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolOverview/FinancialDeficitIntegrationTests.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolOverview/FinancialDeficitIntegrationTests.cs @@ -17,7 +17,7 @@ public async Task Should_navigate_to_and_update_financial_deficit() { (RadioButton selected, RadioButton toSelect) = RandomRadioButtons("financial-deficit", "Yes", "No"); AcademyConversionProject project = AddGetProject(p => p.FinancialDeficit = selected.Value); - AddGetEstablishmentResponse(project.Urn.ToString()); + AddGetEstablishmentDto(project.Urn.ToString()); AddPatchConfiguredProject(project, x => { x.FinancialDeficit = toSelect.Value; diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolOverview/MPDetailsIntegrationTests.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolOverview/MPDetailsIntegrationTests.cs index 54b735141..4292e6428 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolOverview/MPDetailsIntegrationTests.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolOverview/MPDetailsIntegrationTests.cs @@ -1,7 +1,7 @@ using AngleSharp.Dom; using AngleSharp.Html.Dom; +using Dfe.Academies.Contracts.V4.Establishments; using Dfe.PrepareConversions.Data.Models; -using Dfe.PrepareConversions.Data.Models.Establishment; using Dfe.PrepareConversions.Tests.Extensions; using FluentAssertions; using System.Threading.Tasks; @@ -27,7 +27,7 @@ public async Task Should_display_MP_Name_and_Party() public async Task Should_display_link_to_external_page() { AcademyConversionProject project = AddGetProject(); - AddGetEstablishmentResponse(project.Urn.ToString()); + AddGetEstablishmentDto(project.Urn.ToString()); await OpenAndConfirmPathAsync($"/task-list/{project.Id}/confirm-school-overview/enter-MP-name-and-political-party"); @@ -40,7 +40,7 @@ public async Task Should_display_link_to_external_page() public async Task Should_display_school_postcode() { AcademyConversionProject project = AddGetProject(); - EstablishmentResponse establishment = AddGetEstablishmentResponse(project.Urn.ToString()); + EstablishmentDto establishment = AddGetEstablishmentDto(project.Urn.ToString()); await OpenAndConfirmPathAsync($"/task-list/{project.Id}/confirm-school-overview/enter-MP-name-and-political-party"); @@ -52,7 +52,7 @@ public async Task Should_display_school_postcode() public async Task Should_display_message_when_school_postcode_not_available() { AcademyConversionProject project = AddGetProject(); - AddGetEstablishmentResponse(project.Urn.ToString(), true); + AddGetEstablishmentDto(project.Urn.ToString(), true); await OpenAndConfirmPathAsync($"/task-list/{project.Id}/confirm-school-overview/enter-MP-name-and-political-party"); @@ -64,7 +64,7 @@ public async Task Should_display_message_when_school_postcode_not_available() public async Task Should_navigate_to_and_update_mp_name_and_party() { AcademyConversionProject project = AddGetProject(); - AddGetEstablishmentResponse(project.Urn.ToString()); + AddGetEstablishmentDto(project.Urn.ToString()); UpdateAcademyConversionProject request = AddPatchProjectMany(project, composer => composer .With(r => r.MemberOfParliamentNameAndParty) diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolOverview/PublishedAdmissionNumberIntegrationTests.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolOverview/PublishedAdmissionNumberIntegrationTests.cs index fc229f6ce..cf61bc7ff 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolOverview/PublishedAdmissionNumberIntegrationTests.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolOverview/PublishedAdmissionNumberIntegrationTests.cs @@ -17,7 +17,7 @@ public PublishedAdmissionNumberIntegrationTests(IntegrationTestingWebApplication public async Task Should_navigate_to_and_update_published_admission_number() { AcademyConversionProject project = AddGetProject(); - AddGetEstablishmentResponse(project.Urn.ToString()); + AddGetEstablishmentDto(project.Urn.ToString()); UpdateAcademyConversionProject request = AddPatchConfiguredProject(project, x => { x.PublishedAdmissionNumber = _fixture.Create(); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolOverview/ViabilityIssuesIntegrationTests.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolOverview/ViabilityIssuesIntegrationTests.cs index 2ac32d60d..16d8c6456 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolOverview/ViabilityIssuesIntegrationTests.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolOverview/ViabilityIssuesIntegrationTests.cs @@ -17,7 +17,7 @@ public async Task Should_navigate_to_and_update_viability_issues() { (RadioButton selected, RadioButton toSelect) = RandomRadioButtons("viability-issues", "Yes", "No"); AcademyConversionProject project = AddGetProject(p => p.ViabilityIssues = selected.Value); - AddGetEstablishmentResponse(project.Urn.ToString()); + AddGetEstablishmentDto(project.Urn.ToString()); AddPatchConfiguredProject(project, x => { x.ViabilityIssues = toSelect.Value; diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolPerformance/ConfirmSchoolPerformanceIntegrationTests.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolPerformance/ConfirmSchoolPerformanceIntegrationTests.cs index 315e184f0..82cbaed88 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolPerformance/ConfirmSchoolPerformanceIntegrationTests.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolPerformance/ConfirmSchoolPerformanceIntegrationTests.cs @@ -1,5 +1,5 @@ -using Dfe.PrepareConversions.Data.Models; -using Dfe.PrepareConversions.Data.Models.Establishment; +using Dfe.Academies.Contracts.V4.Establishments; +using Dfe.PrepareConversions.Data.Models; using Dfe.PrepareConversions.Extensions; using Dfe.PrepareConversions.Tests.Extensions; using FluentAssertions; @@ -16,7 +16,7 @@ public ConfirmSchoolPerformanceIntegrationTests(IntegrationTestingWebApplication public async Task Should_be_reference_only_and_display_school_performance() { AcademyConversionProject project = AddGetProject(); - EstablishmentResponse schoolPerformance = AddGetEstablishmentResponse(project.Urn.ToString()); + EstablishmentDto schoolPerformance = AddGetEstablishmentDto(project.Urn.ToString()); await OpenAndConfirmPathAsync($"/task-list/{project.Id}"); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolPupilForecasts/AdditionalInformationIntegrationTests.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolPupilForecasts/AdditionalInformationIntegrationTests.cs index 98e169b25..f099cfe2d 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolPupilForecasts/AdditionalInformationIntegrationTests.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolPupilForecasts/AdditionalInformationIntegrationTests.cs @@ -17,7 +17,7 @@ public AdditionalInformationIntegrationTests(IntegrationTestingWebApplicationFac public async Task Should_navigate_to_and_update_additional_information() { AcademyConversionProject project = AddGetProject(); - AddGetEstablishmentResponse(project.Urn.ToString()); + AddGetEstablishmentDto(project.Urn.ToString()); UpdateAcademyConversionProject request = AddPatchConfiguredProject(project, x => { @@ -42,7 +42,7 @@ public async Task Should_navigate_to_and_update_additional_information() public async Task Should_show_error_summary_when_there_is_an_API_error() { AcademyConversionProject project = AddGetProject(); - AddGetEstablishmentResponse(project.Urn.ToString()); + AddGetEstablishmentDto(project.Urn.ToString()); AddPatchError(project.Id); @@ -57,7 +57,7 @@ public async Task Should_show_error_summary_when_there_is_an_API_error() public async Task Should_navigate_back_to_confirm_school_pupil_forecasts() { AcademyConversionProject project = AddGetProject(); - AddGetEstablishmentResponse(project.Urn.ToString()); + AddGetEstablishmentDto(project.Urn.ToString()); await OpenAndConfirmPathAsync($"/task-list/{project.Id}/confirm-school-pupil-forecasts/additional-information"); await NavigateAsync("Back"); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolPupilForecasts/ConfirmSchoolPupilForecastsIntegrationTests.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolPupilForecasts/ConfirmSchoolPupilForecastsIntegrationTests.cs index 22c148df4..09b245a43 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolPupilForecasts/ConfirmSchoolPupilForecastsIntegrationTests.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions.Tests/Pages/TaskList/SchoolPupilForecasts/ConfirmSchoolPupilForecastsIntegrationTests.cs @@ -1,9 +1,9 @@ using AngleSharp.Dom; using AngleSharp.Html.Dom; using AutoFixture; +using Dfe.Academies.Contracts.V4.Establishments; using Dfe.Academisation.ExtensionMethods; using Dfe.PrepareConversions.Data.Models; -using Dfe.PrepareConversions.Data.Models.Establishment; using Dfe.PrepareConversions.Tests.Extensions; using FluentAssertions; using System.Threading.Tasks; @@ -28,7 +28,7 @@ public async Task Should_be_reference_only_and_display_school_pupil_forecasts_ta p.YearThreeProjectedCapacity = _fixture.Create(); p.YearThreeProjectedPupilNumbers = _fixture.Create(); }); - EstablishmentResponse establishment = AddGetEstablishmentResponse(project.Urn.ToString()); + EstablishmentDto establishment = AddGetEstablishmentDto(project.Urn.ToString()); await OpenAndConfirmPathAsync($"/task-list/{project.Id}"); @@ -66,7 +66,7 @@ public async Task Should_display_school_pupil_forecasts_table_when_values_are_nu p.YearThreeProjectedCapacity = null; p.YearThreeProjectedPupilNumbers = null; }); - AddGetEstablishmentResponse(project.Urn.ToString(), true); + AddGetEstablishmentDto(project.Urn.ToString(), true); await OpenAndConfirmPathAsync($"/task-list/{project.Id}"); @@ -96,7 +96,7 @@ public async Task Should_display_school_pupil_forecasts_table_when_values_are_nu public async Task Should_navigate_between_task_list_and_confirm_school_pupil_forecasts() { AcademyConversionProject project = AddGetProject(); - AddGetEstablishmentResponse(project.Urn.ToString()); + AddGetEstablishmentDto(project.Urn.ToString()); await OpenAndConfirmPathAsync($"/task-list/{project.Id}"); await NavigateAsync("Pupil forecasts"); @@ -111,7 +111,7 @@ public async Task Should_navigate_between_task_list_and_confirm_school_pupil_for public async Task Back_link_should_navigate_from_confirm_school_pupil_forecasts_to_task_list() { AcademyConversionProject project = AddGetProject(); - AddGetEstablishmentResponse(project.Urn.ToString()); + AddGetEstablishmentDto(project.Urn.ToString()); await OpenAndConfirmPathAsync($"/task-list/{project.Id}"); await NavigateAsync("Pupil forecasts"); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Dfe.PrepareConversions.csproj b/Dfe.PrepareConversions/Dfe.PrepareConversions/Dfe.PrepareConversions.csproj index 8a58d30ef..5f2804eb8 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Dfe.PrepareConversions.csproj +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Dfe.PrepareConversions.csproj @@ -28,6 +28,7 @@ + diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Mappings/CreateSponsoredProjectMapper.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Mappings/CreateSponsoredProjectMapper.cs index 48af6922d..3a5d6e0b2 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Mappings/CreateSponsoredProjectMapper.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Mappings/CreateSponsoredProjectMapper.cs @@ -1,27 +1,27 @@ -using Dfe.PrepareConversions.Data.Models.Establishment; +using Dfe.Academies.Contracts.V4.Establishments; +using Dfe.Academies.Contracts.V4.Trusts; using Dfe.PrepareConversions.Data.Models.SponsoredProject; -using Dfe.PrepareConversions.Data.Models.Trust; using System; namespace Dfe.PrepareConversions.Mappings; public static class CreateSponsoredProjectMapper { - public static CreateSponsoredProject MapToDto(EstablishmentResponse establishment, TrustDetail trust) + public static CreateSponsoredProject MapToDto(EstablishmentDto establishment, TrustDto trust) { - var partOfPfiScheme = !string.IsNullOrWhiteSpace(establishment.ViewAcademyConversion?.Pfi) - && establishment.ViewAcademyConversion?.Pfi.Equals("No", StringComparison.InvariantCultureIgnoreCase) == false; - + var partOfPfiScheme = !string.IsNullOrWhiteSpace(establishment?.Pfi) + && establishment?.Pfi.Equals("No", StringComparison.InvariantCultureIgnoreCase) == false; + SponsoredProjectSchool createSchool = new( - establishment.EstablishmentName, + establishment.Name, establishment.Urn, partOfPfiScheme, establishment.LocalAuthorityName, establishment.Gor.Name); - + SponsoredProjectTrust createTrust = new( - trust.GiasData.GroupName, - trust.GiasData.GroupId); + trust.Name, + trust.ReferenceNumber); return new CreateSponsoredProject(createSchool, createTrust); } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/SponsoredProject/SearchSchool.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/SponsoredProject/SearchSchool.cshtml.cs index 92c79d4d1..82c02d0e8 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/SponsoredProject/SearchSchool.cshtml.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/SponsoredProject/SearchSchool.cshtml.cs @@ -9,6 +9,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using EstablishmentDto = Dfe.Academies.Contracts.V4.Establishments.EstablishmentDto; namespace Dfe.PrepareConversions.Pages.SponsoredProject; @@ -26,8 +27,8 @@ public SearchSchoolModel(IGetEstablishment getEstablishment, ErrorService errorS } [BindProperty] - - public string SearchQuery { get; set; } = ""; + + public string SearchQuery { get; set; } = ""; public AutoCompleteSearchModel AutoCompleteSearchModel { get; set; } @@ -35,10 +36,10 @@ public async Task OnGet(string urn) { ProjectListFilters.ClearFiltersFrom(TempData); - EstablishmentResponse establishment = await _getEstablishment.GetEstablishmentByUrn(urn); + EstablishmentDto establishment = await _getEstablishment.GetEstablishmentByUrn(urn); if (!string.IsNullOrWhiteSpace(establishment.Urn)) { - SearchQuery = $"{establishment.EstablishmentName} ({establishment.Urn})"; + SearchQuery = $"{establishment.Name} ({establishment.Urn})"; } AutoCompleteSearchModel = new AutoCompleteSearchModel(SEARCH_LABEL, SearchQuery, SEARCH_ENDPOINT); @@ -78,8 +79,8 @@ public async Task OnPost(string ukprn, string redirect) var expectedEstablishment = await _getEstablishment.GetEstablishmentByUrn(expectedUkprn); - if (expectedEstablishment.EstablishmentName == null) - { + if (expectedEstablishment.Name == null) + { ModelState.AddModelError(nameof(SearchQuery), "We could not find a school matching your search criteria"); _errorService.AddErrors(ModelState.Keys, ModelState); return Page(); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/SponsoredProject/SearchTrust.cshtml.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/SponsoredProject/SearchTrust.cshtml.cs index 5c5a187ed..32cc05e3b 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/SponsoredProject/SearchTrust.cshtml.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/SponsoredProject/SearchTrust.cshtml.cs @@ -1,7 +1,7 @@ +using Dfe.Academies.Contracts.V4.Trusts; using Dfe.Academisation.ExtensionMethods; using Dfe.PrepareConversions.Data.Models.Trust; using Dfe.PrepareConversions.Data.Services.Interfaces; -using Dfe.PrepareConversions.Extensions; using Dfe.PrepareConversions.Models; using Dfe.PrepareConversions.Services; using Microsoft.AspNetCore.Mvc; @@ -42,11 +42,11 @@ public async Task OnGet(string ukprn, string urn) if (string.IsNullOrWhiteSpace(ukprn)) return Page(); - TrustSummaryResponse trusts = await _trustsRepository.SearchTrusts(ukprn); + TrustDtoResponse trusts = await _trustsRepository.SearchTrusts(ukprn); if (trusts.Data.Any()) { - TrustSummary trust = trusts.Data[0]; - SearchQuery = $"{trust.GroupName} ({trust.Ukprn})"; + TrustDto trust = trusts.Data[0]; + SearchQuery = $"{trust.Name} ({trust.Ukprn})"; } AutoCompleteSearchModel = new AutoCompleteSearchModel(SEARCH_LABEL, SearchQuery, SEARCH_ENDPOINT); @@ -58,15 +58,15 @@ public async Task OnGetSearch(string searchQuery) { string[] searchSplit = SplitOnBrackets(searchQuery); - TrustSummaryResponse trusts = await _trustsRepository.SearchTrusts(searchSplit[0].Trim()); + TrustDtoResponse trusts = await _trustsRepository.SearchTrusts(searchSplit[0].Trim()); return new JsonResult(trusts.Data.Select(t => { string displayUkprn = string.IsNullOrWhiteSpace(t.Ukprn) ? string.Empty : $"({t.Ukprn})"; - string suggestion = $@"{t.GroupName.ToTitleCase()} {displayUkprn} + string suggestion = $@"{t.Name?.ToTitleCase() ?? ""} {displayUkprn}
- Companies House number: {t.CompaniesHouseNumber}"; - return new { suggestion = HighlightSearchMatch(suggestion, searchSplit[0].Trim(), t), value = $"{t.GroupName.ToTitleCase()} ({t.Ukprn})" }; + Companies House number: {t.CompaniesHouseNumber ?? ""}"; + return new { suggestion = HighlightSearchMatch(suggestion, searchSplit[0].Trim(), t), value = $"{t.Name?.ToTitleCase() ?? ""} ({t.Ukprn})" }; })); } @@ -90,11 +90,11 @@ public async Task OnPost(string urn) string ukprn = searchSplit[1]; - TrustSummaryResponse trusts = await _trustsRepository.SearchTrusts(ukprn); - + TrustDtoResponse trusts = await _trustsRepository.SearchTrusts(ukprn); + if (trusts.Data.Count != 1) { - ModelState.AddModelError(nameof(SearchQuery), "We could not find a trust matching your search criteria"); + ModelState.AddModelError(nameof(SearchQuery), "We could not find a trust matching your search criteria"); _errorService.AddErrors(ModelState.Keys, ModelState); return Page(); } @@ -102,10 +102,10 @@ public async Task OnPost(string urn) return RedirectToPage(Links.SponsoredProject.Summary.Page, new { ukprn, urn }); } - private static string HighlightSearchMatch(string input, string toReplace, TrustSummary trust) + private static string HighlightSearchMatch(string input, string toReplace, TrustDto trust) { if (trust == null || - string.IsNullOrWhiteSpace(trust.GroupName)) + string.IsNullOrWhiteSpace(trust.Name)) { return string.Empty; } diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/SponsoredProject/Summary.cshtml b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/SponsoredProject/Summary.cshtml index 9bfdde107..ab10f240b 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/SponsoredProject/Summary.cshtml +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Pages/SponsoredProject/Summary.cshtml @@ -48,7 +48,7 @@ Name
- @Model.Establishment.EstablishmentName + @Model.Establishment.Name
PFI (private finance initiative) -
@(Model.Establishment?.ViewAcademyConversion?.Pfi ?? "Does not apply")
+
@(Model.Establishment?.Pfi ?? "Does not apply")
@@ -153,7 +153,7 @@ Name
- @Model.Trust.GroupName + @Model.Trust.Name
OnGetAsync(string urn, string ukprn) @@ -41,8 +40,8 @@ public async Task OnGetAsync(string urn, string ukprn) public async Task OnPostAsync(string urn, string ukprn) { - EstablishmentResponse establishment = await _getEstablishment.GetEstablishmentByUrn(urn); - TrustDetail trust = await _trustRepository.GetTrustByUkprn(ukprn); + Academies.Contracts.V4.Establishments.EstablishmentDto establishment = await _getEstablishment.GetEstablishmentByUrn(urn); + TrustDto trust = await _trustRepository.GetTrustByUkprn(ukprn); await _academyConversionProjectRepository.CreateSponsoredProject(CreateSponsoredProjectMapper.MapToDto(establishment, trust)); diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/GetEstablishmentItemCacheDecorator.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/GetEstablishmentItemCacheDecorator.cs index 8bbe3e554..39e1ae40d 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/GetEstablishmentItemCacheDecorator.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/Services/GetEstablishmentItemCacheDecorator.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Http; using System.Collections.Generic; using System.Threading.Tasks; +using EstablishmentDto = Dfe.Academies.Contracts.V4.Establishments.EstablishmentDto; namespace Dfe.PrepareConversions.Services; @@ -17,15 +18,15 @@ public GetEstablishmentItemCacheDecorator(IGetEstablishment getEstablishment, IH _httpContext = httpContextAccessor.HttpContext; } - public async Task GetEstablishmentByUrn(string urn) + public async Task GetEstablishmentByUrn(string urn) { string key = $"establishment-{urn}"; - if (_httpContext.Items.ContainsKey(key) && _httpContext.Items[key] is EstablishmentResponse cached) + if (_httpContext.Items.ContainsKey(key) && _httpContext.Items[key] is EstablishmentDto cached) { return cached; } - EstablishmentResponse establishment = await _getEstablishment.GetEstablishmentByUrn(urn); + EstablishmentDto establishment = await _getEstablishment.GetEstablishmentByUrn(urn); _httpContext.Items[key] = establishment; diff --git a/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewComponents/SchoolPupilForecastsCurrentYearViewComponent.cs b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewComponents/SchoolPupilForecastsCurrentYearViewComponent.cs index e5ccb2653..ce885cab6 100644 --- a/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewComponents/SchoolPupilForecastsCurrentYearViewComponent.cs +++ b/Dfe.PrepareConversions/Dfe.PrepareConversions/ViewComponents/SchoolPupilForecastsCurrentYearViewComponent.cs @@ -1,7 +1,7 @@ -using Dfe.Academisation.ExtensionMethods; +using Dfe.Academies.Contracts.V4.Establishments; +using Dfe.Academisation.ExtensionMethods; using Dfe.PrepareConversions.Data; using Dfe.PrepareConversions.Data.Models; -using Dfe.PrepareConversions.Data.Models.Establishment; using Dfe.PrepareConversions.Data.Services; using Dfe.PrepareConversions.ViewModels; using Microsoft.AspNetCore.Mvc; @@ -33,7 +33,7 @@ public async Task InvokeAsync() } AcademyConversionProject project = response.Body; - EstablishmentResponse establishment = await _establishmentService.GetEstablishmentByUrn(project.Urn.ToString()); + EstablishmentDto establishment = await _establishmentService.GetEstablishmentByUrn(project.Urn.ToString()); SchoolPupilForecastsCurrentYearViewModel viewModel = new() {