From 02dc5e2dd8b84029af8c55407f871316373b42a4 Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Thu, 17 Oct 2024 21:59:32 +0100 Subject: [PATCH] DP-724: Expose PendingRoles in the Organisation response --- .../AuthorizationTests.cs | 17 +++++++------- .../FormsEngineTests.cs | 2 +- .../OrganisationEmailModelTest.cs | 2 +- .../OrganisationIdentificationModelTest.cs | 23 +++++-------------- .../Organisation/OrganisationNameModelTest.cs | 3 +-- .../OrganisationRegisteredAddressModelTest.cs | 6 ++--- .../Pages/OrganisationOverviewTest.cs | 2 +- .../OrganisationDetailsSummaryModelTest.cs | 2 +- .../Registration/OrganisationEntityFactory.cs | 2 +- .../OrganisationIdentificationTests.cs | 14 +++++------ .../ConnectedEntityQuestionTest.cs | 6 +++-- .../Supplier/LegalFormFormationDateTest.cs | 2 +- .../LegalFormLawRegisteredModelTests.cs | 2 +- .../LegalFormSelectOrganisationModelTests.cs | 4 +++- .../Pages/Supplier/SupplierDetailsFactory.cs | 5 ++-- .../Supplier/SupplierEmailAddressTest.cs | 6 +++-- .../Pages/Supplier/SupplierVatQuestionTest.cs | 8 +++---- .../SupplierWebsiteModelQuestionTest.cs | 6 +++-- .../Pages/Support/OrganisationApprovalTest.cs | 5 ++-- .../Api/OrganisationEndpointsTests.cs | 6 +++-- .../UseCase/GetMyOrganisationUseCaseTest.cs | 3 ++- .../UseCase/GetOrganisationUseCaseTest.cs | 10 ++++++-- .../UseCase/LookupOrganisationUseCaseTest.cs | 3 ++- .../RegisterOrganisationUseCaseTest.cs | 3 ++- .../AutoMapper/WebApiToPersistenceProfile.cs | 6 ++++- .../Model/Details.cs | 22 ++++++++++++++++++ .../Model/Organisation.cs | 1 + .../Model/OrganisationExtended.cs | 18 --------------- 28 files changed, 104 insertions(+), 85 deletions(-) create mode 100644 Services/CO.CDP.Organisation.WebApi/Model/Details.cs diff --git a/Frontend/CO.CDP.OrganisationApp.Tests/AuthorizationTests.cs b/Frontend/CO.CDP.OrganisationApp.Tests/AuthorizationTests.cs index be23ea590..0d8272e40 100644 --- a/Frontend/CO.CDP.OrganisationApp.Tests/AuthorizationTests.cs +++ b/Frontend/CO.CDP.OrganisationApp.Tests/AuthorizationTests.cs @@ -74,14 +74,15 @@ [ organisation ] organisationClient.Setup(client => client.GetOrganisationAsync(testOrganisationId)) .ReturnsAsync( new CO.CDP.Organisation.WebApiClient.Organisation( - [], - [], - null, - new ContactPoint("a@b.com", "Contact", "123", new Uri("http://whatever")), - testOrganisationId, - new Identifier("asd", "asd", "asd", new Uri("http://whatever")), - "Org name", - [ CO.CDP.Organisation.WebApiClient.PartyRole.Supplier, CO.CDP.Organisation.WebApiClient.PartyRole.Tenderer ] + additionalIdentifiers: [], + addresses: [], + approvedOn: null, + contactPoint: new ContactPoint("a@b.com", "Contact", "123", new Uri("http://whatever")), + id: testOrganisationId, + identifier: new Identifier("asd", "asd", "asd", new Uri("http://whatever")), + name: "Org name", + roles: [ Organisation.WebApiClient.PartyRole.Supplier, Organisation.WebApiClient.PartyRole.Tenderer ], + details: new Details(approval: null, pendingRoles: []) ) ); diff --git a/Frontend/CO.CDP.OrganisationApp.Tests/FormsEngineTests.cs b/Frontend/CO.CDP.OrganisationApp.Tests/FormsEngineTests.cs index d3ca753c8..fe0c7be0a 100644 --- a/Frontend/CO.CDP.OrganisationApp.Tests/FormsEngineTests.cs +++ b/Frontend/CO.CDP.OrganisationApp.Tests/FormsEngineTests.cs @@ -358,7 +358,7 @@ public async Task GetFormSectionAsync_ShouldFetchChoicesFromCustomChoiceProvider null )); _organisationClientMock.Setup(c => c.GetOrganisationAsync(organisationId)) - .ReturnsAsync(new Organisation.WebApiClient.Organisation([], [], null, null, organisationId, null, "User's current organisation", [])); + .ReturnsAsync(new Organisation.WebApiClient.Organisation(additionalIdentifiers: [], addresses: [], approvedOn: null, contactPoint: null, id: organisationId, identifier: null, name: "User's current organisation", roles: [], details: new Details(approval: null, pendingRoles: []))); _userInfoServiceMock.Setup(u => u.GetOrganisationId()).Returns(organisationId); _tempDataServiceMock.Setup(t => t.Peek(sessionKey)) .Returns((SectionQuestionsResponse?)null); diff --git a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Organisation/OrganisationEmailModelTest.cs b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Organisation/OrganisationEmailModelTest.cs index 7123f1798..eacdf52f2 100644 --- a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Organisation/OrganisationEmailModelTest.cs +++ b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Organisation/OrganisationEmailModelTest.cs @@ -128,7 +128,7 @@ public async Task OnGet_ValidSession_ReturnsOrganisationDetailsAsync() private static CO.CDP.Organisation.WebApiClient.Organisation GivenOrganisationClientModel(Guid? id) { - return new CO.CDP.Organisation.WebApiClient.Organisation(null, null,null, new ContactPoint("Main Contact", "contact@test.com", "123456789", null), id!.Value, null, null, []); + return new CO.CDP.Organisation.WebApiClient.Organisation(additionalIdentifiers: null, addresses: null,approvedOn: null, contactPoint: new ContactPoint("Main Contact", "contact@test.com", "123456789", null), id: id ?? Guid.NewGuid(), identifier: null, name: null, roles: [], details: new Details(approval: null, pendingRoles: [])); } private OrganisationEmailModel GivenOrganisationEmailModel() diff --git a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Organisation/OrganisationIdentificationModelTest.cs b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Organisation/OrganisationIdentificationModelTest.cs index ae16ab04b..557ece667 100644 --- a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Organisation/OrganisationIdentificationModelTest.cs +++ b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Organisation/OrganisationIdentificationModelTest.cs @@ -1,14 +1,9 @@ -using Xunit; -using Moq; -using FluentAssertions; using CO.CDP.Organisation.WebApiClient; using CO.CDP.OrganisationApp.Pages.Organisation; +using FluentAssertions; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using CO.CDP.OrganisationApp.Tests.Pages; +using Moq; public class OrganisationIdentificationModelTest { @@ -16,9 +11,9 @@ public class OrganisationIdentificationModelTest private readonly OrganisationIdentificationModel _pageModel; public OrganisationIdentificationModelTest() - { + { _organisationClientMock = new Mock(); - + _pageModel = new OrganisationIdentificationModel(_organisationClientMock.Object) { Id = Guid.NewGuid(), @@ -28,17 +23,14 @@ public OrganisationIdentificationModelTest() [Fact] public async Task OnGet_Should_ReturnPageResult_When_OrganisationIsValid() { - var id = Guid.NewGuid(); _pageModel.Id = id; _pageModel.CharityCommissionEnglandWalesNumber = "Charity Org"; _organisationClientMock.Setup(x => x.GetOrganisationAsync(It.IsAny())) .ReturnsAsync(GivenOrganisationClientModel(id)); - var result = await _pageModel.OnGet(); - result.Should().BeOfType(); _pageModel.CharityCommissionEnglandWalesNumber.Should().Be("Charity Org"); } @@ -46,14 +38,11 @@ public async Task OnGet_Should_ReturnPageResult_When_OrganisationIsValid() [Fact] public async Task OnGet_Should_RedirectToPageNotFound_When_OrganisationIsNotFound() { - _organisationClientMock.Setup(x => x.GetOrganisationAsync(It.IsAny())) .ReturnsAsync((Organisation?)null); - var result = await _pageModel.OnGet(); - result.Should().BeOfType() .Which.Url.Should().Be("/page-not-found"); } @@ -105,7 +94,7 @@ public async Task OnPost_Should_RedirectToPageNotFound_When_OrganisationIsNotFou .Which.Url.Should().Be("/page-not-found"); } - private static CO.CDP.Organisation.WebApiClient.Organisation GivenOrganisationClientModel(Guid? id) + private static Organisation GivenOrganisationClientModel(Guid? id) { var identifier = new Identifier("asd", "asd", "asd", new Uri("http://whatever")); var additionalIdentifiers = new List @@ -118,6 +107,6 @@ private static CO.CDP.Organisation.WebApiClient.Organisation GivenOrganisationCl ) }; - return new CO.CDP.Organisation.WebApiClient.Organisation(additionalIdentifiers, null, null, null, id!.Value, identifier, "Test Org", []); + return new Organisation(additionalIdentifiers: additionalIdentifiers, addresses: null, approvedOn: null, contactPoint: null, id: id ?? Guid.NewGuid(), identifier: identifier, name: "Test Org", roles: [], details: new Details(approval: null, pendingRoles: [])); } } diff --git a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Organisation/OrganisationNameModelTest.cs b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Organisation/OrganisationNameModelTest.cs index b0e102d7a..c852cda2d 100644 --- a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Organisation/OrganisationNameModelTest.cs +++ b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Organisation/OrganisationNameModelTest.cs @@ -100,10 +100,9 @@ public async Task OnGet_ValidSession_ReturnsOrganisationDetailsAsync() organisationClientMock.Verify(c => c.GetOrganisationAsync(id), Times.Once); } - private static CO.CDP.Organisation.WebApiClient.Organisation GivenOrganisationClientModel(Guid? id) { - return new CO.CDP.Organisation.WebApiClient.Organisation(null, null,null, null, id!.Value, null, "Test Org", []); + return new CO.CDP.Organisation.WebApiClient.Organisation(additionalIdentifiers: null, addresses: null,approvedOn: null, contactPoint: null, id: id ?? Guid.NewGuid(), identifier: null, name: "Test Org", roles: [], details: new Details(approval: null, pendingRoles: [])); } private OrganisationNameModel GivenOrganisationNameModel() diff --git a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Organisation/OrganisationRegisteredAddressModelTest.cs b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Organisation/OrganisationRegisteredAddressModelTest.cs index c54c1f758..6487372c8 100644 --- a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Organisation/OrganisationRegisteredAddressModelTest.cs +++ b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Organisation/OrganisationRegisteredAddressModelTest.cs @@ -139,8 +139,8 @@ public async Task OnPost_WhenValidModel_ShouldSaveRegistratedAddress() var result = await _model.OnPost(); result.Should().BeOfType() - .Which.PageName.Should().Be("OrganisationOverview"); - } + .Which.PageName.Should().Be("OrganisationOverview"); + } [Fact] public async Task OnGet_ValidSession_ReturnsRegistrationDetails() @@ -169,7 +169,7 @@ private static CO.CDP.Organisation.WebApiClient.Organisation GivenOrganisationCl streetAddress: "1 street lane", type: CDP.Organisation.WebApiClient.AddressType.Registered)); - return new CO.CDP.Organisation.WebApiClient.Organisation(null, addresses,null, null, id!.Value, null, null, []); + return new CO.CDP.Organisation.WebApiClient.Organisation(additionalIdentifiers: null, addresses: addresses,approvedOn: null, contactPoint: null, id: id ?? Guid.NewGuid(), identifier: null, name: null, roles: [], details: new Details(approval: null, pendingRoles: [])); } private OrganisationRegisteredAddressModel GivenOrganisationAddressModel() diff --git a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/OrganisationOverviewTest.cs b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/OrganisationOverviewTest.cs index b64fa244e..610571e9d 100644 --- a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/OrganisationOverviewTest.cs +++ b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/OrganisationOverviewTest.cs @@ -45,6 +45,6 @@ public async Task OnGet_PageNotFound() private static CO.CDP.Organisation.WebApiClient.Organisation GivenOrganisationClientModel(Guid? id) { - return new CO.CDP.Organisation.WebApiClient.Organisation(null, null,null, null, id!.Value, null, "Test Org", []); + return new CO.CDP.Organisation.WebApiClient.Organisation(additionalIdentifiers: null, addresses: null,approvedOn: null, contactPoint: null, id: id ?? Guid.NewGuid(), identifier: null, name: "Test Org", roles: [], details: new Details(approval: null, pendingRoles: [])); } } \ No newline at end of file diff --git a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Registration/OrganisationDetailsSummaryModelTest.cs b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Registration/OrganisationDetailsSummaryModelTest.cs index 6a58bda06..6d9396096 100644 --- a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Registration/OrganisationDetailsSummaryModelTest.cs +++ b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Registration/OrganisationDetailsSummaryModelTest.cs @@ -222,7 +222,7 @@ private RegistrationDetails DummyRegistrationDetails() private static CO.CDP.Organisation.WebApiClient.Organisation GivenOrganisationClientModel() { - return new CO.CDP.Organisation.WebApiClient.Organisation(null, null, null, null, _organisationId, null, "Test Org", []); + return new CO.CDP.Organisation.WebApiClient.Organisation(additionalIdentifiers: null, addresses: null, approvedOn: null, contactPoint: null, id: _organisationId, identifier: null, name: "Test Org", roles: [], details: new Details(approval: null, pendingRoles: [])); } private OrganisationDetailsSummaryModel GivenOrganisationDetailModel() diff --git a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Registration/OrganisationEntityFactory.cs b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Registration/OrganisationEntityFactory.cs index a42f52444..7144e0b07 100644 --- a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Registration/OrganisationEntityFactory.cs +++ b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Registration/OrganisationEntityFactory.cs @@ -6,7 +6,7 @@ public static class OrganisationEntityFactory { public static OrganisationWebApiClient.Organisation GivenClientModel() { - return new OrganisationWebApiClient.Organisation(null, null, null, null, Guid.NewGuid(), null, "Test Org", []); + return new OrganisationWebApiClient.Organisation(additionalIdentifiers: null, addresses: null, approvedOn: null, contactPoint: null, id: Guid.NewGuid(), identifier: null, name: "Test Org", roles: [], details: new Details(approval: null, pendingRoles: [])); } public static ProblemDetails GivenProblemDetails( diff --git a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Registration/OrganisationIdentificationTests.cs b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Registration/OrganisationIdentificationTests.cs index 272edceae..65be4679e 100644 --- a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Registration/OrganisationIdentificationTests.cs +++ b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Registration/OrganisationIdentificationTests.cs @@ -74,7 +74,7 @@ public void OnGet_WhenValidSession_ShouldSaveRegistrationDetails() case "GB-UKPRN": model.UKLearningProviderReferenceNumber.Should().Be(registrationDetails.OrganisationIdentificationNumber); - break; + break; } } @@ -257,7 +257,7 @@ public async Task OnPost_WhenOrganisationTypeIsUKPRNAndUKLearningProviderReferen result.Should().BeOfType(); model.ModelState.IsValid.Should().BeFalse(); - } + } [Fact] public async Task OnPost_WhenModelStateIsValid_ShouldRedirectToOrganisationName() @@ -294,7 +294,7 @@ public async Task OnPost_WhenSchemeNotOtherAndOrganisationExistsInOganisationSer { var model = new OrganisationIdentificationModel(sessionMock.Object, organisationClientMock.Object, _pponClientMock.Object) { - OrganisationScheme = "JE-FSC", + OrganisationScheme = "JE-FSC", RedirectToSummary = true }; GivenRegistrationIsInProgress(); @@ -313,7 +313,7 @@ public async Task OnPost_WhenSchemeNotOtherAndIdentifierExistsInEntityVerificati { var model = new OrganisationIdentificationModel(sessionMock.Object, organisationClientMock.Object, _pponClientMock.Object) { - OrganisationScheme = "JE-FSC", + OrganisationScheme = "JE-FSC", RedirectToSummary = true }; GivenRegistrationIsInProgress(); @@ -332,7 +332,7 @@ public async Task OnPost_WhenSchemeNotOtherAndEntityVerificationServiceOffLine_S { var model = new OrganisationIdentificationModel(sessionMock.Object, organisationClientMock.Object, _pponClientMock.Object) { - OrganisationScheme = "JE-FSC", + OrganisationScheme = "JE-FSC", RedirectToSummary = true }; @@ -355,7 +355,7 @@ public async Task OnPost_WhenSchemeNotOtherAndEntityVerificationServiceOffLine_S [InlineData("JE-FSC", "JFSC123")] [InlineData("IM-CR", "IMCR123")] [InlineData("GB-NHS", "STUVWX")] - [InlineData("GB-UKPRN", "PRN1234")] + [InlineData("GB-UKPRN", "PRN1234")] public async Task OnPost_WhenModelStateIsValid_ShouldStoreOrganisationTypeAndIdentificationNumberInSession(string organisationType, string identificationNumber) { var model = new OrganisationIdentificationModel(sessionMock.Object, organisationClientMock.Object, _pponClientMock.Object) @@ -410,7 +410,7 @@ private static void SetIdentificationNumber(OrganisationIdentificationModel mode private static OrganisationWebApiClient.Organisation GivenOrganisationClientModel() { - return new OrganisationWebApiClient.Organisation(null, null, null, null, _organisationId, null, "Test Org", []); + return new OrganisationWebApiClient.Organisation(additionalIdentifiers: null, addresses: null, approvedOn: null, contactPoint: null, id: _organisationId, identifier: null, name: "Test Org", roles: [], details: new Details(approval: null, pendingRoles: [])); } private static ICollection GivenEntityVerificationIdentifiers() diff --git a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/ConnectedEntity/ConnectedEntityQuestionTest.cs b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/ConnectedEntity/ConnectedEntityQuestionTest.cs index 6342df2ae..9b13e6eec 100644 --- a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/ConnectedEntity/ConnectedEntityQuestionTest.cs +++ b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/ConnectedEntity/ConnectedEntityQuestionTest.cs @@ -154,10 +154,12 @@ private static CO.CDP.Organisation.WebApiClient.Organisation OrganisationClientM new( additionalIdentifiers: [new Identifier(id: "FakeId", legalName: "FakeOrg", scheme: "VAT", uri: null)], addresses: null, - null, + approvedOn: null, contactPoint: new ContactPoint(email: "test@test.com", name: null, telephone: null, url: new Uri("https://xyz.com")), id: id, identifier: null, name: "Test Org", - roles: [PartyRole.Supplier]); + roles: [PartyRole.Supplier], + details: new Details(approval: null, pendingRoles: []) + ); } \ No newline at end of file diff --git a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/LegalFormFormationDateTest.cs b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/LegalFormFormationDateTest.cs index 5302af3d7..ab81a89c9 100644 --- a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/LegalFormFormationDateTest.cs +++ b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/LegalFormFormationDateTest.cs @@ -205,6 +205,6 @@ private void SetFutureDate() private static OrganisationWebApiClient.Organisation GivenOrganisationClientModel(Guid? id) { - return new OrganisationWebApiClient.Organisation(null, null, null, null, id!.Value, null, "Test Org", []); + return new OrganisationWebApiClient.Organisation(additionalIdentifiers: null, addresses: null, approvedOn: null, contactPoint: null, id: id ?? Guid.NewGuid(), identifier: null, name: "Test Org", roles: [], details: new OrganisationWebApiClient.Details(approval: null, pendingRoles: [])); } } \ No newline at end of file diff --git a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/LegalFormLawRegisteredModelTests.cs b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/LegalFormLawRegisteredModelTests.cs index b557386a1..ef9a67224 100644 --- a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/LegalFormLawRegisteredModelTests.cs +++ b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/LegalFormLawRegisteredModelTests.cs @@ -87,6 +87,6 @@ public void OnPost_UpdatesLawRegisteredInTempData_AndRedirects() private static CO.CDP.Organisation.WebApiClient.Organisation GivenOrganisationClientModel(Guid? id) { - return new CO.CDP.Organisation.WebApiClient.Organisation(null, null, null, null, id!.Value, null, "Test Org", []); + return new CO.CDP.Organisation.WebApiClient.Organisation(additionalIdentifiers: null, addresses: null, approvedOn: null, contactPoint: null, id: id ?? Guid.NewGuid(), identifier: null, name: "Test Org", roles: [], details: new Details(approval: null, pendingRoles: [])); } } \ No newline at end of file diff --git a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/LegalFormSelectOrganisationModelTests.cs b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/LegalFormSelectOrganisationModelTests.cs index 60027749c..39a0bc5b1 100644 --- a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/LegalFormSelectOrganisationModelTests.cs +++ b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/LegalFormSelectOrganisationModelTests.cs @@ -1,8 +1,10 @@ +using CO.CDP.Organisation.WebApiClient; using CO.CDP.OrganisationApp.Pages.Supplier; using FluentAssertions; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Moq; +using LegalForm = CO.CDP.OrganisationApp.Pages.Supplier.LegalForm; namespace CO.CDP.OrganisationApp.Tests.Pages.Supplier; @@ -108,6 +110,6 @@ public void OrganisationLegalForm_ShouldReturnCorrectDictionary() private static CO.CDP.Organisation.WebApiClient.Organisation GivenOrganisationClientModel(Guid? id) { - return new CO.CDP.Organisation.WebApiClient.Organisation(null, null, null, null, id!.Value, null, "Test Org", []); + return new CO.CDP.Organisation.WebApiClient.Organisation(additionalIdentifiers: null, addresses: null, approvedOn: null, contactPoint: null, id: id ?? Guid.NewGuid(), identifier: null, name: "Test Org", roles: [], details: new Details(approval: null, pendingRoles: [])); } } \ No newline at end of file diff --git a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/SupplierDetailsFactory.cs b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/SupplierDetailsFactory.cs index 8c4cd662e..a175cb68d 100644 --- a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/SupplierDetailsFactory.cs +++ b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/SupplierDetailsFactory.cs @@ -39,12 +39,13 @@ public static CO.CDP.Organisation.WebApiClient.Organisation GivenOrganisationCli new Address(countryName: "United Kingdom", country: "GB", locality: "London", postalCode: "L1", region: "South", streetAddress: "1 London Street", type: AddressType.Registered), new Address(countryName: "France", country: "FR", locality: "Paris", postalCode: "F1", region: "North", streetAddress: "1 Paris Street", type: AddressType.Postal) ], - null, + approvedOn: null, contactPoint: new ContactPoint(email: "test@test.com", name: "fakecontact", telephone: "0123456789", url: new Uri("https://test.com")), id: id, identifier: null, name: "Test Org", - roles: [PartyRole.Supplier] + roles: [PartyRole.Supplier], + details: new Details(approval: null, pendingRoles: []) ); } } \ No newline at end of file diff --git a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/SupplierEmailAddressTest.cs b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/SupplierEmailAddressTest.cs index f9a5c013c..b5e56df1b 100644 --- a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/SupplierEmailAddressTest.cs +++ b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/SupplierEmailAddressTest.cs @@ -122,10 +122,12 @@ private static CO.CDP.Organisation.WebApiClient.Organisation OrganisationClientM new( additionalIdentifiers: [new Identifier(id: "FakeId", legalName: "FakeOrg", scheme: "VAT", uri: null)], addresses: null, - null, + approvedOn: null, contactPoint: new ContactPoint(email: "test@test.com", name: null, telephone: null, url: new Uri("https://xyz.com")), id: id, identifier: null, name: "Test Org", - roles: [PartyRole.Supplier]); + roles: [PartyRole.Supplier], + details: new Details(approval: null, pendingRoles: []) + ); } \ No newline at end of file diff --git a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/SupplierVatQuestionTest.cs b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/SupplierVatQuestionTest.cs index 152346f81..6e9abac24 100644 --- a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/SupplierVatQuestionTest.cs +++ b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/SupplierVatQuestionTest.cs @@ -25,7 +25,7 @@ public SupplierVatModelQuestionTest() _organisationClientMock = new Mock(); _pponClientMock = new Mock(); _model = new SupplierVatQuestionModel(_organisationClientMock.Object, _pponClientMock.Object, contextAccessor.Object); - + _organisationClientMock.Setup(api => api.LookupOrganisationAsync(It.IsAny(), It.IsAny())) .ThrowsAsync(new CO.CDP.Organisation.WebApiClient.ApiException("Organisation does not exist", 404, "", null, null)); _pponClientMock.Setup(api => api.GetIdentifiersAsync(It.IsAny())) @@ -117,8 +117,8 @@ public async Task OnPost_WhenNoChangeToVatNumber_ShouldNotUpdateOrganisationAndR _organisationClientMock.Setup(client => client.GetOrganisationAsync(id)) .ReturnsAsync(fakeOrg); - var result = await _model.OnPost(); - + await _model.OnPost(); + _organisationClientMock.Verify(o => o.UpdateOrganisationAsync(It.IsAny(), It.IsAny()), Times.Never); _organisationClientMock.Verify(o => o.UpdateSupplierInformationAsync(It.IsAny(), It.Is(u => u.Type == SupplierInformationUpdateType.CompletedVat)), Times.Never); @@ -220,7 +220,7 @@ public async Task OnPost_OrganisationNotFound_ReturnsRedirectToPageNotFound() private static CO.CDP.Organisation.WebApiClient.Organisation GivenOrganisationClientModel() { - return new CO.CDP.Organisation.WebApiClient.Organisation(null, null, null, null, _organisationId, null, "Test Org", []); + return new CO.CDP.Organisation.WebApiClient.Organisation(additionalIdentifiers: null, addresses: null, approvedOn: null, contactPoint: null, id: _organisationId, identifier: null, name: "Test Org", roles: [], details: new Details(approval: null, pendingRoles: [])); } private static ICollection GivenEntityVerificationIdentifiers() diff --git a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/SupplierWebsiteModelQuestionTest.cs b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/SupplierWebsiteModelQuestionTest.cs index d7ce7e76b..3bd584166 100644 --- a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/SupplierWebsiteModelQuestionTest.cs +++ b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Supplier/SupplierWebsiteModelQuestionTest.cs @@ -134,10 +134,12 @@ private static CO.CDP.Organisation.WebApiClient.Organisation OrganisationClientM new( additionalIdentifiers: [new Identifier(id: "FakeId", legalName: "FakeOrg", scheme: "VAT", uri: null)], addresses: null, - null, + approvedOn: null, contactPoint: new ContactPoint(email: null, name: null, telephone: null, url: new Uri("https://xyz.com")), id: id, identifier: null, name: "Test Org", - roles: [PartyRole.Supplier]); + roles: [PartyRole.Supplier], + details: new Details(approval: null, pendingRoles: []) + ); } \ No newline at end of file diff --git a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Support/OrganisationApprovalTest.cs b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Support/OrganisationApprovalTest.cs index 32e2177e8..c7bba01c1 100644 --- a/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Support/OrganisationApprovalTest.cs +++ b/Frontend/CO.CDP.OrganisationApp.Tests/Pages/Support/OrganisationApprovalTest.cs @@ -36,12 +36,13 @@ public async Task OnGet_WhenOrganisationExists_ShouldReturnPageResult() var expectedOrganisation = new CDP.Organisation.WebApiClient.Organisation( additionalIdentifiers: new List(), addresses: new List
(), - null, + approvedOn: null, contactPoint: null, id: organisationId, identifier: null, name: "Test Organisation", - roles: new List() + roles: new List(), + details: new Details(approval: null, pendingRoles: []) ); _mockOrganisationClient diff --git a/Services/CO.CDP.Organisation.WebApi.Tests/Api/OrganisationEndpointsTests.cs b/Services/CO.CDP.Organisation.WebApi.Tests/Api/OrganisationEndpointsTests.cs index dd65d06a3..4d0401587 100644 --- a/Services/CO.CDP.Organisation.WebApi.Tests/Api/OrganisationEndpointsTests.cs +++ b/Services/CO.CDP.Organisation.WebApi.Tests/Api/OrganisationEndpointsTests.cs @@ -197,7 +197,8 @@ public static Model.Organisation GivenOrganisation(Guid organisationId) AdditionalIdentifiers = command.AdditionalIdentifiers.AsView(), Addresses = command.Addresses.AsView(), ContactPoint = command.ContactPoint.AsView(), - Roles = command.Roles + Roles = command.Roles, + Details = new Details() }; } @@ -253,7 +254,8 @@ private Model.Organisation SetupRegisterOrganisationUseCaseMock(RegisterOrganisa AdditionalIdentifiers = command.AdditionalIdentifiers.AsView(), Addresses = command.Addresses.AsView(), ContactPoint = command.ContactPoint.AsView(), - Roles = command.Roles + Roles = command.Roles, + Details = new Details() }; _registerOrganisationUseCase.Setup(useCase => useCase.Execute(It.IsAny())) diff --git a/Services/CO.CDP.Organisation.WebApi.Tests/UseCase/GetMyOrganisationUseCaseTest.cs b/Services/CO.CDP.Organisation.WebApi.Tests/UseCase/GetMyOrganisationUseCaseTest.cs index 925d9025f..6cd92d86a 100644 --- a/Services/CO.CDP.Organisation.WebApi.Tests/UseCase/GetMyOrganisationUseCaseTest.cs +++ b/Services/CO.CDP.Organisation.WebApi.Tests/UseCase/GetMyOrganisationUseCaseTest.cs @@ -121,7 +121,8 @@ public async Task ItReturnsTheFoundOrganisation() Telephone = "123-456-7890", Url = new Uri("https://contact.test.org") }, - Roles = [PartyRole.Buyer] + Roles = [PartyRole.Buyer], + Details = new Details() }; found.Should().BeEquivalentTo(expectedModelOrganisation, options => options.ComparingByMembers()); diff --git a/Services/CO.CDP.Organisation.WebApi.Tests/UseCase/GetOrganisationUseCaseTest.cs b/Services/CO.CDP.Organisation.WebApi.Tests/UseCase/GetOrganisationUseCaseTest.cs index 004978a62..4288ebea6 100644 --- a/Services/CO.CDP.Organisation.WebApi.Tests/UseCase/GetOrganisationUseCaseTest.cs +++ b/Services/CO.CDP.Organisation.WebApi.Tests/UseCase/GetOrganisationUseCaseTest.cs @@ -1,3 +1,4 @@ +using CO.CDP.Organisation.WebApi.Model; using CO.CDP.Organisation.WebApi.Tests.AutoMapper; using CO.CDP.Organisation.WebApi.UseCase; using CO.CDP.OrganisationInformation; @@ -73,7 +74,8 @@ public async Task ItReturnsTheFoundOrganisation() Telephone = "123-456-7890", Url = "https://contact.test.org" }], - Roles = [PartyRole.Buyer] + Roles = [PartyRole.Buyer], + PendingRoles = [PartyRole.Consortium] }; _repository.Setup(r => r.Find(organisationId)).ReturnsAsync(persistenceOrganisation); @@ -117,7 +119,11 @@ public async Task ItReturnsTheFoundOrganisation() Telephone = "123-456-7890", Url = new Uri("https://contact.test.org") }, - Roles = [PartyRole.Buyer] + Roles = [PartyRole.Buyer], + Details = new Details + { + PendingRoles = [PartyRole.Consortium] + } }; found.Should().BeEquivalentTo(expectedModelOrganisation, options => options.ComparingByMembers()); diff --git a/Services/CO.CDP.Organisation.WebApi.Tests/UseCase/LookupOrganisationUseCaseTest.cs b/Services/CO.CDP.Organisation.WebApi.Tests/UseCase/LookupOrganisationUseCaseTest.cs index 182f60d69..f6a74a816 100644 --- a/Services/CO.CDP.Organisation.WebApi.Tests/UseCase/LookupOrganisationUseCaseTest.cs +++ b/Services/CO.CDP.Organisation.WebApi.Tests/UseCase/LookupOrganisationUseCaseTest.cs @@ -180,7 +180,8 @@ private Model.Organisation GivenModelOrganisationInfo(Guid organisationId) Telephone = "123-456-7890", Url = new Uri("https://contact.test.org") }, - Roles = [PartyRole.Tenderer] + Roles = [PartyRole.Tenderer], + Details = new Details() }; } } \ No newline at end of file diff --git a/Services/CO.CDP.Organisation.WebApi.Tests/UseCase/RegisterOrganisationUseCaseTest.cs b/Services/CO.CDP.Organisation.WebApi.Tests/UseCase/RegisterOrganisationUseCaseTest.cs index 9e938d27b..3a9eb22c4 100644 --- a/Services/CO.CDP.Organisation.WebApi.Tests/UseCase/RegisterOrganisationUseCaseTest.cs +++ b/Services/CO.CDP.Organisation.WebApi.Tests/UseCase/RegisterOrganisationUseCaseTest.cs @@ -119,7 +119,8 @@ public async Task ItReturnsTheRegisteredOrganisation() AdditionalIdentifiers = command.AdditionalIdentifiers.AsView(), Addresses = command.Addresses.AsView(), ContactPoint = command.ContactPoint.AsView(), - Roles = command.Roles + Roles = command.Roles, + Details = new Details() }; createdOrganisation.Should().BeEquivalentTo(expectedOrganisation, diff --git a/Services/CO.CDP.Organisation.WebApi/AutoMapper/WebApiToPersistenceProfile.cs b/Services/CO.CDP.Organisation.WebApi/AutoMapper/WebApiToPersistenceProfile.cs index 64c416fe8..00c56311a 100644 --- a/Services/CO.CDP.Organisation.WebApi/AutoMapper/WebApiToPersistenceProfile.cs +++ b/Services/CO.CDP.Organisation.WebApi/AutoMapper/WebApiToPersistenceProfile.cs @@ -18,7 +18,11 @@ public WebApiToPersistenceProfile() .ForMember(m => m.Id, o => o.MapFrom(m => m.Guid)) .ForMember(m => m.Identifier, o => o.MapFrom(m => m.Identifiers.FirstOrDefault(i => i.Primary))) .ForMember(m => m.AdditionalIdentifiers, o => o.MapFrom(m => m.Identifiers.Where(i => !i.Primary))) - .ForMember(m => m.ContactPoint, o => o.MapFrom(m => m.ContactPoints.FirstOrDefault() ?? new Persistence.Organisation.ContactPoint())); + .ForMember(m => m.ContactPoint, o => o.MapFrom(m => m.ContactPoints.FirstOrDefault() ?? new Persistence.Organisation.ContactPoint())) + .ForMember(m => m.Details, o => o.MapFrom(m => new Details + { + PendingRoles = m.PendingRoles + })); CreateMap() .ForMember(m => m.Id, o => o.MapFrom(m => m.Guid)) diff --git a/Services/CO.CDP.Organisation.WebApi/Model/Details.cs b/Services/CO.CDP.Organisation.WebApi/Model/Details.cs new file mode 100644 index 000000000..3ada2bde4 --- /dev/null +++ b/Services/CO.CDP.Organisation.WebApi/Model/Details.cs @@ -0,0 +1,22 @@ +using CO.CDP.OrganisationInformation; + +namespace CO.CDP.Organisation.WebApi.Model; + +public record Details +{ + public Approval? Approval { get; init; } + public List PendingRoles { get; init; } = []; +} + +public record Approval +{ + public DateTimeOffset? ApprovedOn { get; init; } + public ReviewedBy? ReviewedBy { get; init; } + public string? Comment { get; init; } +} + +public record ReviewedBy +{ + public required Guid Id { get; init; } + public required string Name { get; init; } +} diff --git a/Services/CO.CDP.Organisation.WebApi/Model/Organisation.cs b/Services/CO.CDP.Organisation.WebApi/Model/Organisation.cs index 8dbfcefa2..f9d08e3e5 100644 --- a/Services/CO.CDP.Organisation.WebApi/Model/Organisation.cs +++ b/Services/CO.CDP.Organisation.WebApi/Model/Organisation.cs @@ -26,6 +26,7 @@ public record Organisation public required List Roles { get; init; } public DateTimeOffset? ApprovedOn { get; init; } + public required Details Details { get; init; } } public record SupplierInformation diff --git a/Services/CO.CDP.Organisation.WebApi/Model/OrganisationExtended.cs b/Services/CO.CDP.Organisation.WebApi/Model/OrganisationExtended.cs index 584b9342f..f6fae57be 100644 --- a/Services/CO.CDP.Organisation.WebApi/Model/OrganisationExtended.cs +++ b/Services/CO.CDP.Organisation.WebApi/Model/OrganisationExtended.cs @@ -22,21 +22,3 @@ public record OrganisationExtended public required Details Details { get; init; } } - -public record Details -{ - public Approval? Approval { get; init; } -} - -public record Approval -{ - public DateTimeOffset? ApprovedOn { get; init; } - public ReviewedBy? ReviewedBy { get; init; } - public string? Comment { get; init; } -} - -public record ReviewedBy -{ - public required Guid Id { get; init; } - public required string Name { get; init; } -}