From 239f98ccdf7cd86c4ca0c311e076d304e2cdffe4 Mon Sep 17 00:00:00 2001 From: marcogagliardi <marco.gagliardi@justice.gov.uk> Date: Thu, 5 Dec 2024 15:23:09 +0000 Subject: [PATCH 1/2] VIH-10346 - Manage team page is not cleared (#1454) * added clearUsers function * test fix * added test * Update justice-users.service.spec.ts * Update justice-users.service.spec.ts * Update justice-users.service.spec.ts * Update justice-users.service.spec.ts * Update justice-users.service.spec.ts * updated test --------- Co-authored-by: William Craig <mr.craig1991@gmail.com> --- .../manage-team/manage-team.component.spec.ts | 3 ++- .../manage-team/manage-team.component.ts | 6 ++++- .../services/justice-users.service.spec.ts | 25 +++++++++++++++++++ .../src/app/services/justice-users.service.ts | 9 +++++++ 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/manage-team/manage-team/manage-team.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/manage-team/manage-team/manage-team.component.spec.ts index f7fb75e28..fc61e01e1 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/manage-team/manage-team/manage-team.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/manage-team/manage-team/manage-team.component.spec.ts @@ -29,7 +29,8 @@ describe('ManageTeamComponent', () => { justiceUsersServiceSpy = jasmine.createSpyObj<JusticeUsersService>('JusticeUsersService', [ 'allUsers$', 'filteredUsers$', - 'search' + 'search', + 'clearUsers' ]); justiceUsersServiceSpy.filteredUsers$ = filteredUsers$; diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/manage-team/manage-team/manage-team.component.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/manage-team/manage-team/manage-team.component.ts index 5752ea522..a35034d59 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/manage-team/manage-team/manage-team.component.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/manage-team/manage-team/manage-team.component.ts @@ -57,13 +57,17 @@ export class ManageTeamComponent implements OnInit, OnDestroy { } ngOnDestroy(): void { + this.clearUsers(); this.destroyed$.next(); } + clearUsers() { + this.justiceUserService.clearUsers(); + } + ngOnInit() { this.form.controls.inputSearch.valueChanges.subscribe(() => this.displayAddButton$.next(false)); this.isAnErrorMessage$.pipe(takeUntil(this.destroyed$)).subscribe(isAnErrorMessage => (this.isAnErrorMessage = isAnErrorMessage)); - this.users$ = this.justiceUserService.filteredUsers$.pipe( takeUntil(this.destroyed$), tap(users => { diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/justice-users.service.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/justice-users.service.spec.ts index b0657b878..316569cca 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/justice-users.service.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/justice-users.service.spec.ts @@ -134,6 +134,31 @@ describe('JusticeUsersService', () => { }); }); + describe('clearUsers', () => { + it('should clear the search term', (done: DoneFn) => { + // arrange + clientApiSpy.getUserList.and.returnValue( + of([{ username: 'test', first_name: 'test', lastname: 'test', contact_email: 'test' } as JusticeUserResponse]) + ); + // assert + const emittedValues: JusticeUserResponse[][] = []; + service.filteredUsers$.pipe(take(2)).subscribe({ + next: users => emittedValues.push(users), + complete: () => { + // Assert + // First emission should have 1 user from searching for 'test' + expect(emittedValues[0].length).toBe(1); + // Second emission should have 0 users after clearing the search term + expect(emittedValues[1].length).toBe(0); + done(); + } + }); + + service.search('test'); + service.clearUsers(); + }); + }); + describe('addNewJusticeUser', () => { it('should call the api to save a new user & again to get the users list', (done: DoneFn) => { const username = 'john@doe.com'; diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/justice-users.service.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/justice-users.service.ts index 99fd6dee5..30af71334 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/justice-users.service.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/justice-users.service.ts @@ -40,11 +40,20 @@ export class JusticeUsersService { this.refresh$.next(); } + clearUsers() { + this.searchTerm$.next(''); + } + search(searchTerm: string) { this.searchTerm$.next(searchTerm); } applyFilter(searchTerm: string, users: JusticeUserResponse[]): JusticeUserResponse[] { + // Clear all users + if (searchTerm === '') { + return []; + } + if (!searchTerm) { return users; } From 02d0cf9917e82337cff00bb1c7d00fb9ec439efb Mon Sep 17 00:00:00 2001 From: shaed-parkar <41630528+shaed-parkar@users.noreply.github.com> Date: Thu, 5 Dec 2024 18:05:40 +0000 Subject: [PATCH 2/2] VIH-10899 upgrade bookings api client (#1449) * VIH-10899 remove obsolete hearing types and case roles * get venue name and case type name on get using the codes and service ids * move hearingTypes to reference data service --- .../packages.lock.json | 45 +- .../HearingInputSanitizerAttributeTest.cs | 22 +- .../Controllers/BookingListControllerTest.cs | 65 +- .../HearingsController/BookNewHearingTests.cs | 4 +- .../HearingsController/CancelHearingTests.cs | 11 +- .../CancelMultiDayHearingTests.cs | 19 +- .../HearingsController/EditHearingTests.cs | 55 +- .../EditMultiDayHearingTests.cs | 28 +- .../HearingsController/FailHearingTests.cs | 9 +- .../HearingsController/GetHearingTests.cs | 40 +- .../GetStatusHearingTests.cs | 37 +- .../HearingsControllerTests.cs | 99 +- .../HearingsController/PostHearingTests.cs | 64 +- .../SearchForAudioRecordedHearingsTests.cs | 38 +- .../GetPersonForUpdateByContactEmailTests.cs | 8 +- .../UpdatePersonDetailsTests.cs | 16 +- .../Controllers/PersonsControllerTest.cs | 32 +- .../HearingRolesControllerTests.cs | 4 +- .../HearingTypesControllerTests.cs | 98 -- .../InterpreterLanguagesControllerTests.cs | 4 +- .../ParticipantRolesControllerTests.cs | 87 -- .../GetUnallocatedHearingsTests.cs | 11 +- .../HearingDetailsResponseExtensionsTests.cs | 246 +--- .../Helper/HearingResponseBuilder.cs | 43 - .../Helper/HearingResponseV2Builder.cs | 11 +- .../BookingsHearingResponseMapperTests.cs | 1 - ...HearingParticipantsRequestV2MapperTests.cs | 1 - .../EditParticipantRequestMapperTest.cs | 21 - .../Mappers/EndpointResponseMapperTests.cs | 5 +- .../HearingDetailsResponseMapperTests.cs | 2 - .../Mappers/HearingUpdateRequestMapperTest.cs | 6 +- .../JudiciaryParticipantRequestMapperTests.cs | 4 +- ...JudiciaryParticipantResponseMapperTests.cs | 11 +- .../NewParticipantRequestMapperTest.cs | 29 - .../Mappers/ParticipantResponseMapperTest.cs | 53 +- .../UnallocatedHearingsForVHOMapperTests.cs | 6 +- .../UpdateParticipantRequestMapperTest.cs | 6 +- .../Services/HearingServiceTests.cs | 52 +- .../Services/ReferenceDataServiceTests.cs | 30 +- .../TestParticipantRequest.cs | 18 - .../Validators/CaseRequestValidationTest.cs | 53 - .../EditHearingRequestValidatorTest.cs | 73 -- .../ParticipantRequestValidationTest.cs | 73 -- .../AdminWebsite.UnitTests/packages.lock.json | 42 +- AdminWebsite/AdminWebsite/AdminWebsite.csproj | 8 +- .../HearingInputSanitizerAttribute.cs | 5 +- .../AdminWebsite/ClientApp/package-lock.json | 448 +------ .../AdminWebsite/ClientApp/package.json | 3 +- .../add-participant-base.component.ts | 38 +- .../add-participant.component.html | 3 +- .../add-participant.component.spec.ts | 255 +--- .../add-participant.component.ts | 34 +- .../assign-judge.component.spec.ts | 1 - .../assign-judge/assign-judge.component.ts | 1 - .../create-hearing.component.spec.ts | 20 +- .../create-hearing.component.ts | 59 +- .../endpoints/endpoints.component.spec.ts | 1 - .../hearing-schedule.component.spec.ts | 6 +- .../hearing-schedule.component.ts | 5 +- .../item/participant-item.component.html | 12 - .../item/participant-item.component.spec.ts | 27 - .../item/participant-item.component.ts | 8 - .../list/participant-list.component.spec.ts | 71 +- .../list/participant-list.component.ts | 32 +- .../search-email.component.spec.ts | 2 - .../search-email/search-email.component.ts | 2 - .../services/participant.service.spec.ts | 22 +- .../booking/services/participant.service.ts | 15 +- .../booking/summary/summary.component.html | 1 - .../booking/summary/summary.component.spec.ts | 26 +- .../app/booking/summary/summary.component.ts | 2 - .../booking-details.component.spec.ts | 4 - ...booking-participant-list.component.spec.ts | 60 +- .../booking-participant-list.component.ts | 27 +- .../bookings-list.component.spec.ts | 33 +- .../hearing-details.component.html | 3 - .../hearing-details.component.spec.ts | 3 - .../participant-details.component.html | 21 +- .../participant-details.component.spec.ts | 3 - .../common/model/booking-list.model.spec.ts | 3 - .../app/common/model/bookings-list.model.ts | 3 - .../src/app/common/model/hearing.model.ts | 3 - .../model/participant-details.model.spec.ts | 137 +- .../common/model/participant-details.model.ts | 17 - .../common/model/participant-model.spec.ts | 8 +- .../src/app/common/model/participant.model.ts | 5 +- .../src/app/common/model/party.model.ts | 12 - .../services/booking-details.service.spec.ts | 10 - .../app/services/booking-details.service.ts | 2 - .../services/bookings-list.service.spec.ts | 25 +- .../src/app/services/bookings-list.service.ts | 1 - .../services/bookings-persist.service.spec.ts | 1 - .../src/app/services/clients/api-client.ts | 1144 ++++++----------- .../participant-edit-service.service.spec.ts | 4 +- .../app/services/reference-data.service.ts | 17 +- .../src/app/services/search.service.spec.ts | 4 +- .../src/app/services/search.service.ts | 4 +- .../services/video-hearings.service.spec.ts | 57 +- .../app/services/video-hearings.service.ts | 53 +- .../case-types-menu.component.spec.ts | 16 +- .../case-types-menu.component.ts | 6 +- .../app/testing/data/response-test-data.ts | 15 - .../app/testing/stubs/service-service-stub.ts | 4 +- .../Requests/BookingDetailsRequest.cs | 1 - .../Contracts/Requests/ParticipantRequest.cs | 2 - .../Responses/BookingsHearingResponse.cs | 1 - .../Responses/HearingDetailsResponse.cs | 30 +- .../Responses/HearingTypeResponse.cs | 12 +- .../Responses/ParticipantResponse.cs | 1 - .../Controllers/BookingListController.cs | 2 +- .../Controllers/HearingsController.cs | 38 +- .../Controllers/PersonsController.cs | 25 +- .../HearingRolesController.cs | 2 +- .../ReferenceData/HearingTypesController.cs | 19 +- .../ParticipantRolesController.cs | 60 - .../Controllers/WorkAllocationController.cs | 7 +- .../Extensions/ConfigureServicesExtensions.cs | 7 +- .../HearingDetailsResponseExtensions.cs | 206 +-- .../AvailableLanguageResponseMapper.cs | 2 +- .../Mappers/BookingDetailsRequestMapper.cs | 2 +- .../Mappers/BookingsHearingResponseMapper.cs | 2 - .../Mappers/EditEndpointRequestMapper.cs | 4 +- .../HearingChangesMapper.cs | 3 +- .../Mappers/EditParticipantRequestMapper.cs | 5 +- .../Mappers/HearingDetailsResponseMapper.cs | 5 +- .../Mappers/JudgeResponseMapper.cs | 12 - .../JudiciaryParticipantRequestMapper.cs | 6 +- .../JudiciaryParticipantResponseMapper.cs | 2 +- .../Mappers/JudiciaryPersonResponseMapper.cs | 5 +- .../LinkedParticipantResponseMapper.cs | 9 - .../Mappers/NewParticipantRequestMapper.cs | 20 - .../Mappers/ParticipantResponseMapper.cs | 24 - .../TelephoneParticipantResponseMapper.cs | 25 - .../UnallocatedHearingsForVHOMapper.cs | 13 +- .../Mappers/UpdateParticipantRequestMapper.cs | 16 - .../Mappers/UserResponseMapper.cs | 7 +- .../Models/CaseAndHearingRolesResponse.cs | 10 - .../Models/EditParticipantRequest.cs | 5 - .../AdminWebsite/Services/HearingsService.cs | 35 - .../Services/ReferenceDataService.cs | 11 +- AdminWebsite/AdminWebsite/Startup.cs | 2 +- .../Validators/CaseRequestValidation.cs | 24 - .../Validators/EditHearingRequestValidator.cs | 28 - .../EditParticipantRequestValidation.cs | 37 - .../Validators/EditRequestValidation.cs | 24 - .../ParticipantRequestValidation.cs | 37 - AdminWebsite/AdminWebsite/packages.lock.json | 42 +- AdminWebsite/nuget.config | 1 + 148 files changed, 1136 insertions(+), 4089 deletions(-) rename AdminWebsite/AdminWebsite.UnitTests/Controllers/{ => ReferenceData}/HearingRolesControllerTests.cs (94%) delete mode 100644 AdminWebsite/AdminWebsite.UnitTests/Controllers/ReferenceData/HearingTypesControllerTests.cs delete mode 100644 AdminWebsite/AdminWebsite.UnitTests/Controllers/ReferenceData/ParticipantRolesControllerTests.cs delete mode 100644 AdminWebsite/AdminWebsite.UnitTests/Helper/HearingResponseBuilder.cs delete mode 100644 AdminWebsite/AdminWebsite.UnitTests/TestParticipantRequest.cs delete mode 100644 AdminWebsite/AdminWebsite.UnitTests/Validators/CaseRequestValidationTest.cs delete mode 100644 AdminWebsite/AdminWebsite.UnitTests/Validators/EditHearingRequestValidatorTest.cs delete mode 100644 AdminWebsite/AdminWebsite.UnitTests/Validators/ParticipantRequestValidationTest.cs delete mode 100644 AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/party.model.ts rename AdminWebsite/AdminWebsite/Controllers/{ => ReferenceData}/HearingRolesController.cs (96%) delete mode 100644 AdminWebsite/AdminWebsite/Controllers/ReferenceData/ParticipantRolesController.cs delete mode 100644 AdminWebsite/AdminWebsite/Mappers/TelephoneParticipantResponseMapper.cs delete mode 100644 AdminWebsite/AdminWebsite/Models/CaseAndHearingRolesResponse.cs delete mode 100644 AdminWebsite/AdminWebsite/Validators/CaseRequestValidation.cs delete mode 100644 AdminWebsite/AdminWebsite/Validators/EditHearingRequestValidator.cs delete mode 100644 AdminWebsite/AdminWebsite/Validators/EditParticipantRequestValidation.cs delete mode 100644 AdminWebsite/AdminWebsite/Validators/EditRequestValidation.cs delete mode 100644 AdminWebsite/AdminWebsite/Validators/ParticipantRequestValidation.cs diff --git a/AdminWebsite/AdminWebsite.IntegrationTests/packages.lock.json b/AdminWebsite/AdminWebsite.IntegrationTests/packages.lock.json index 7b144dea7..22fbf400f 100644 --- a/AdminWebsite/AdminWebsite.IntegrationTests/packages.lock.json +++ b/AdminWebsite/AdminWebsite.IntegrationTests/packages.lock.json @@ -113,10 +113,20 @@ }, "BookingsApi.Client": { "type": "Transitive", - "resolved": "2.3.9", - "contentHash": "Bzwufird9sw4QpyCuJBQpcNDuAZXmZWCjLMdoYyFUDdRlJm1xE9uMXaaOyYK2FFPE5WfLAftC/o0nYhhSgFeiQ==", + "resolved": "3.1.9", + "contentHash": "szk1pTukvzHsprWASvwtdTvoHCbm5RC5Lnj1wYmSC+/I/s1uyoL7uLbauV2s84znk2xssLpol4N7Fyxl5wJGAw==", "dependencies": { - "Microsoft.AspNetCore.Mvc.Core": "2.2.5" + "BookingsApi.Common.DotNet6": "3.1.9", + "Microsoft.AspNetCore.Mvc.Core": "2.2.5", + "System.Text.Json": "8.0.5" + } + }, + "BookingsApi.Common.DotNet6": { + "type": "Transitive", + "resolved": "3.1.9", + "contentHash": "3rSoSlmcZw4+uxPIj+KpBAI6WjIk2ntsEGc75oGDD7fQM+qpEDCuIn4xSid1fcO6sdQ2Dkd/8/3c0k2dyL+yeg==", + "dependencies": { + "System.Text.Json": "8.0.5" } }, "Castle.Core": { @@ -933,8 +943,8 @@ }, "Microsoft.Identity.Client": { "type": "Transitive", - "resolved": "4.61.0", - "contentHash": "3TDPEie+9t/NgBhoNifLFwM6nkypYUa8GUHfMnkYtovDDTQM8bsS2KEIP5tAh28BgfJZgof/KlCEKvGxz0H3Eg==", + "resolved": "4.61.3", + "contentHash": "naJo/Qm35Caaoxp5utcw+R8eU8ZtLz2ALh8S+gkekOYQ1oazfCQMWVT4NJ/FnHzdIJlm8dMz0oMpMGCabx5odA==", "dependencies": { "Microsoft.IdentityModel.Abstractions": "6.35.0", "System.Diagnostics.DiagnosticSource": "6.0.1" @@ -1170,8 +1180,8 @@ }, "NotificationApi.Client": { "type": "Transitive", - "resolved": "2.3.4", - "contentHash": "BwxsCI+DORSasyvqktvdWt2jUJIrxwTgLDVx/3sOBDJkqMKJsn+glINBsQ7/kgyldaZningYYuasa3+JIFSVKA==", + "resolved": "3.0.5", + "contentHash": "UErWgWJUm2TEb9yqEHxIzaGr7AFcqnjqRLu8legaYNOMFd1WVzuKYEBzEdMM1x8gHjTLofcIAIaRUqUx0LIFLg==", "dependencies": { "Microsoft.AspNetCore.Mvc.Core": "2.2.5", "Newtonsoft.Json": "13.0.3" @@ -2026,11 +2036,8 @@ }, "System.Text.Json": { "type": "Transitive", - "resolved": "8.0.0", - "contentHash": "OdrZO2WjkiEG6ajEFRABTRCi/wuXQPxeV6g8xvUJqdxMvvuCCEk86zPla8UiIQJz3durtUEbNyY/3lIhS0yZvQ==", - "dependencies": { - "System.Text.Encodings.Web": "8.0.0" - } + "resolved": "8.0.5", + "contentHash": "0f1B50Ss7rqxXiaBJyzUu9bWFOO2/zSlifZ/UNMdiIpDYe4cY4LQQicP4nirK1OS31I43rn062UIJ1Q9bpmHpg==" }, "System.Text.RegularExpressions": { "type": "Transitive", @@ -2143,18 +2150,18 @@ }, "VideoApi.Client": { "type": "Transitive", - "resolved": "2.2.26", - "contentHash": "tkKsLUUKliw5iPA8It+R/Fv+oKsCwdeQfWFWHVhU+/mfNG2bT89L9SHDvjqLIXawTV35pigCRuidPaYt641sow==", + "resolved": "3.1.7", + "contentHash": "l7/NvSybO0/k+rAg1jY78hjZrQ1v2P/qdmh75gJeK+tax3Ukwc0G6+QvKbvlbetzU1TjKf2GFrublKZ5h1OdMg==", "dependencies": { "Microsoft.AspNetCore.Mvc.Core": "2.2.5", - "Newtonsoft.Json": "13.0.3" + "System.Text.Json": "8.0.4" } }, "adminwebsite": { "type": "Project", "dependencies": { "AspNetCore.HealthChecks.Uris": "[8.0.1, )", - "BookingsApi.Client": "[2.3.9, )", + "BookingsApi.Client": "[3.1.9, )", "FluentValidation.AspNetCore": "[11.3.0, )", "LaunchDarkly.ServerSdk": "[8.5.0, )", "MicroElements.Swashbuckle.FluentValidation": "[6.0.0, )", @@ -2165,11 +2172,11 @@ "Microsoft.AspNetCore.SpaServices": "[3.1.32, )", "Microsoft.AspNetCore.SpaServices.Extensions": "[8.0.4, )", "Microsoft.Graph": "[5.52.0, )", - "Microsoft.Identity.Client": "[4.61.0, )", + "Microsoft.Identity.Client": "[4.61.3, )", "Microsoft.OpenApi": "[1.6.14, )", "Microsoft.VisualStudio.Azure.Containers.Tools.Targets": "[1.20.1, )", "NWebsec.AspNetCore.Middleware": "[3.0.0, )", - "NotificationApi.Client": "[2.3.4, )", + "NotificationApi.Client": "[3.0.5, )", "Polly": "[8.4.0, )", "Swashbuckle.AspNetCore": "[6.6.1, )", "Swashbuckle.AspNetCore.Annotations": "[6.6.1, )", @@ -2177,7 +2184,7 @@ "Swashbuckle.AspNetCore.Swagger": "[6.6.1, )", "TimeZoneConverter": "[6.1.0, )", "UserApi.Client": "[2.1.1, )", - "VideoApi.Client": "[2.2.26, )" + "VideoApi.Client": "[3.1.7, )" } }, "adminwebsite.testing.common": { diff --git a/AdminWebsite/AdminWebsite.UnitTests/Attributes/HearingInputSanitizerAttributeTest.cs b/AdminWebsite/AdminWebsite.UnitTests/Attributes/HearingInputSanitizerAttributeTest.cs index 7237c2715..389282695 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Attributes/HearingInputSanitizerAttributeTest.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Attributes/HearingInputSanitizerAttributeTest.cs @@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Routing; using AdminWebsite.Models; using AdminWebsite.UnitTests.Controllers; -using BookingsApi.Contract.V1.Requests; +using BookingsApi.Contract.V2.Requests; namespace AdminWebsite.UnitTests.Attributes { @@ -29,12 +29,11 @@ public void OnActionExecuting_Strips_Out_Invalid_Characters_BookNewHearingReques var request = context.ActionArguments .Should().NotBeNull() .And.ContainKey("request") - .WhoseValue.As<BookNewHearingRequest>() + .WhoseValue.As<BookNewHearingRequestV2>() .Should().NotBeNull() - .And.Subject.As<BookNewHearingRequest>(); + .And.Subject.As<BookNewHearingRequestV2>(); request.HearingRoomName.Should().BeEquivalentTo(expectedText); - request.HearingVenueName.Should().BeEquivalentTo(expectedText); request.OtherInformation.Should().BeEquivalentTo(expectedText); request.Cases.Should().OnlyContain(x => x.Name == expectedText && x.Number == expectedText); request.Participants.Should().OnlyContain @@ -90,9 +89,9 @@ public void OnActionExecuting_invalid_request_will_not_sanitizer(string inputTex var request = context.ActionArguments .Should().NotBeNull() .And.ContainKey("nothing") - .WhoseValue.As<BookNewHearingRequest>() + .WhoseValue.As<BookNewHearingRequestV2>() .Should().NotBeNull() - .And.Subject.As<BookNewHearingRequest>(); + .And.Subject.As<BookNewHearingRequestV2>(); request.HearingRoomName.Should().BeEquivalentTo(inputText); @@ -102,18 +101,17 @@ private static ActionExecutingContext CreateBookNewHearingRequestContext(string { var actionArguments = new Dictionary<string, object> { - { requestKey, new BookNewHearingRequest + { requestKey, new BookNewHearingRequestV2 { HearingRoomName = text, - HearingVenueName = text, OtherInformation = text, - Cases = new List<CaseRequest> + Cases = new List<CaseRequestV2> { - new CaseRequest{Name = text, Number = text} + new(){Name = text, Number = text} }, - Participants = new List<BookingsApi.Contract.V1.Requests.ParticipantRequest> + Participants = new List<ParticipantRequestV2> { - new BookingsApi.Contract.V1.Requests.ParticipantRequest + new() { Title = text, FirstName = text, diff --git a/AdminWebsite/AdminWebsite.UnitTests/Controllers/BookingListControllerTest.cs b/AdminWebsite/AdminWebsite.UnitTests/Controllers/BookingListControllerTest.cs index 8c28003a1..d8b4f26ca 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Controllers/BookingListControllerTest.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Controllers/BookingListControllerTest.cs @@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Mvc; using System.Text.Encodings.Web; using System.Threading.Tasks; +using BookingsApi.Contract.V2.Responses; namespace AdminWebsite.UnitTests.Controllers { @@ -56,7 +57,7 @@ public async Task Should_return_booking_list_if_cursor_is_not_null() .ReturnsAsync(new BookingsResponse()); _userIdentity.Setup(x => x.GetGroupDisplayNames()).Returns(new List<string> { "type1", "type2" }); - _bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(new List<CaseTypeResponse>()); + _bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(new List<CaseTypeResponseV2>()); var request = new BookingSearchRequest { @@ -115,8 +116,8 @@ public async Task Should_throw_exception_for_booking_list_and_returns_bad_result public async Task Should_return_ok_for_booking_list_with_null_types_in_database() { SetupTestCase(); - List<CaseTypeResponse> response = null; - _bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(response); + List<CaseTypeResponseV2> response = null; + _bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(response); var request = new BookingSearchRequest { @@ -135,8 +136,8 @@ public async Task Should_return_ok_for_booking_list_with_empty_list_of_types() { SetupTestCase(); - var response = new List<CaseTypeResponse>(); - _bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(response); + var response = new List<CaseTypeResponseV2>(); + _bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(response); var request = new BookingSearchRequest { @@ -156,19 +157,19 @@ public async Task { SetupTestCase(); - var response = new List<CaseTypeResponse> + var response = new List<CaseTypeResponseV2> { - new CaseTypeResponse + new CaseTypeResponseV2() { - HearingTypes = new List<HearingTypeResponse>(), Id = 1, Name = "type3" + Id = 1, Name = "type3" }, - new CaseTypeResponse + new CaseTypeResponseV2 { - HearingTypes = new List<HearingTypeResponse>(), Id = 2, Name = "type4" + Id = 2, Name = "type4" } }; - _bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(response); + _bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(response); var request = new BookingSearchRequest { @@ -194,7 +195,7 @@ public async Task Should_return_ok_for_booking_list_with_defined_types_list() _userIdentity.Setup(x => x.GetGroupDisplayNames()).Returns(new List<string> { "type1", "type2" }); - _bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(() => GetCaseTypesList()); + _bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(() => GetCaseTypesList()); var request = new BookingSearchRequest { @@ -207,7 +208,7 @@ public async Task Should_return_ok_for_booking_list_with_defined_types_list() okResult.StatusCode.Should().Be(200); _userIdentity.Verify(x => x.IsATeamLead(), Times.Once); - _bookingsApiClient.Verify(s => s.GetCaseTypesAsync(true), Times.Once); + _bookingsApiClient.Verify(s => s.GetCaseTypesV2Async(true), Times.Once); _bookingsApiClient.Verify(x => x.GetHearingsByTypesAsync(It.IsAny<GetHearingRequest>()), Times.Once); } @@ -224,7 +225,7 @@ public async Task Should_return_ok_for_booking_list_and_exclude_repeated_types() _userIdentity.Setup(x => x.GetGroupDisplayNames()).Returns(new List<string> { "type1", "type2", "type2" }); - _bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(() => GetCaseTypesList()); + _bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(() => GetCaseTypesList()); var request = new BookingSearchRequest { @@ -238,7 +239,7 @@ public async Task Should_return_ok_for_booking_list_and_exclude_repeated_types() okResult.StatusCode.Should().Be(200); _userIdentity.Verify(x => x.IsATeamLead(), Times.Once); - _bookingsApiClient.Verify(s => s.GetCaseTypesAsync(true), Times.Once); + _bookingsApiClient.Verify(s => s.GetCaseTypesV2Async(true), Times.Once); _bookingsApiClient.Verify(x => x.GetHearingsByTypesAsync(It.IsAny<GetHearingRequest>()), Times.Once); } @@ -247,7 +248,7 @@ public async Task Should_return_booking_list_when_admin_search_by_case_number() { SetupTestCase(); - _bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(default(List<CaseTypeResponse>)); + _bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(default(List<CaseTypeResponseV2>)); var request = new BookingSearchRequest { @@ -268,7 +269,7 @@ public async Task Should_return_booking_list_when_admin_search_by_venue_ids() { SetupTestCase(); - _bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(default(List<CaseTypeResponse>)); + _bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(default(List<CaseTypeResponseV2>)); var request = new BookingSearchRequest { @@ -288,7 +289,7 @@ public async Task Should_return_booking_list_when_admin_search_by_last_name() { SetupTestCase(); - _bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(default(List<CaseTypeResponse>)); + _bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(default(List<CaseTypeResponseV2>)); var request = new BookingSearchRequest { @@ -311,7 +312,7 @@ public async Task Should_return_booking_list_when_admin_search_by_case_types() { SetupTestCase(); - _bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(default(List<CaseTypeResponse>)); + _bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(default(List<CaseTypeResponseV2>)); var request = new BookingSearchRequest { @@ -334,7 +335,7 @@ public async Task Should_return_bookings_list_when_admin_search_by_start_date() var startDate = new DateTime(2022, 3, 25, 0, 0, 0, DateTimeKind.Utc); - _bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(default(List<CaseTypeResponse>)); + _bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(default(List<CaseTypeResponseV2>)); var request = new BookingSearchRequest { @@ -359,7 +360,7 @@ public async Task Should_return_bookings_list_when_admin_search_by_end_date() var endDate = new DateTime(2022, 3, 25, 0, 0, 0, DateTimeKind.Utc); - _bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(default(List<CaseTypeResponse>)); + _bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(default(List<CaseTypeResponseV2>)); var request = new BookingSearchRequest { @@ -384,7 +385,7 @@ public async Task Should_return_bookings_list_when_admin_search_by_start_and_end var startDate = new DateTime(2022, 3, 24, 0, 0, 0, DateTimeKind.Utc); var endDate = new DateTime(2022, 3, 25, 0, 0, 0, DateTimeKind.Utc); - _bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(default(List<CaseTypeResponse>)); + _bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(default(List<CaseTypeResponseV2>)); var request = new BookingSearchRequest { @@ -411,7 +412,7 @@ public async Task Should_return_bad_request_when_admin_search_with_start_date_af var startDate = new DateTime(2022, 3, 25, 0, 0, 0, DateTimeKind.Utc); var endDate = new DateTime(2022, 3, 24, 0, 0, 0, DateTimeKind.Utc); - _bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(default(List<CaseTypeResponse>)); + _bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(default(List<CaseTypeResponseV2>)); var request = new BookingSearchRequest { @@ -433,7 +434,7 @@ public async Task Should_return_booking_list_when_admin_search_by_multiple_crite { SetupTestCase(); - _bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(default(List<CaseTypeResponse>)); + _bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(default(List<CaseTypeResponseV2>)); var request = new BookingSearchRequest { @@ -452,21 +453,21 @@ public async Task Should_return_booking_list_when_admin_search_by_multiple_crite okResult.StatusCode.Should().Be(200); } - private static List<CaseTypeResponse> GetCaseTypesList() + private static List<CaseTypeResponseV2> GetCaseTypesList() { - return new List<CaseTypeResponse> + return new List<CaseTypeResponseV2> { - new CaseTypeResponse + new() { - HearingTypes = new List<HearingTypeResponse>(), Id = 1, Name = "type1" + Id = 1, Name = "type1" }, - new CaseTypeResponse + new() { - HearingTypes = new List<HearingTypeResponse>(), Id = 2, Name = "type2" + Id = 2, Name = "type2" }, - new CaseTypeResponse + new() { - HearingTypes = new List<HearingTypeResponse>(), Id = 3, Name = "type3" + Id = 3, Name = "type3" } }; } diff --git a/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/BookNewHearingTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/BookNewHearingTests.cs index f3046307e..a63323ecf 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/BookNewHearingTests.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/BookNewHearingTests.cs @@ -12,6 +12,7 @@ using BookingsApi.Contract.V2.Requests; using Microsoft.AspNetCore.Mvc; using VideoApi.Contract.Responses; +using JudiciaryParticipantRequest = AdminWebsite.Contracts.Requests.JudiciaryParticipantRequest; using LinkedParticipantType = AdminWebsite.Contracts.Enums.LinkedParticipantType; namespace AdminWebsite.UnitTests.Controllers.HearingsController @@ -76,7 +77,8 @@ public async Task Should_book_hearing() result.Result.Should().BeOfType<CreatedResult>(); var createdObjectResult = (CreatedResult) result.Result; createdObjectResult.StatusCode.Should().Be(201); - createdObjectResult.Value.Should().BeEquivalentTo(hearingDetailsResponse, options => options.ExcludingMissingMembers()); + createdObjectResult.Value.Should().BeEquivalentTo(hearingDetailsResponse, + options => options.ExcludingMissingMembers().Excluding(x => x.HearingVenueName)); bookingDetails.Participants.Exists(x => string.IsNullOrWhiteSpace(x.Username)).Should().BeFalse(); diff --git a/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/CancelHearingTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/CancelHearingTests.cs index c5b41f21b..2b702043e 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/CancelHearingTests.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/CancelHearingTests.cs @@ -5,12 +5,11 @@ using Microsoft.AspNetCore.Mvc; using System.Threading.Tasks; using BookingsApi.Client; -using BookingsApi.Contract.V1.Requests.Enums; using Autofac.Extras.Moq; using BookingsApi.Contract.V1.Requests; -using BookingsApi.Contract.V1.Responses; +using BookingsApi.Contract.V2.Responses; +using VideoApi.Contract.Consts; using VideoApi.Contract.Responses; -using ParticipantResponse = BookingsApi.Contract.V1.Responses.ParticipantResponse; namespace AdminWebsite.UnitTests.Controllers.HearingsController { @@ -36,10 +35,10 @@ public void Setup() TelephoneConferenceId = "expected_conference_phone_id" } }); - _mocker.Mock<IBookingsApiClient>().Setup(bs => bs.GetHearingDetailsByIdAsync(It.IsAny<Guid>())) - .ReturnsAsync(new HearingDetailsResponse + _mocker.Mock<IBookingsApiClient>().Setup(bs => bs.GetHearingDetailsByIdV2Async(It.IsAny<Guid>())) + .ReturnsAsync(new HearingDetailsResponseV2() { - Participants = [new ParticipantResponse { HearingRoleName = "Judge" }] + Participants = [new ParticipantResponseV2 { HearingRoleName = HearingRoleName.Representative }] }); _controller = _mocker.Create<AdminWebsite.Controllers.HearingsController>(); } diff --git a/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/CancelMultiDayHearingTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/CancelMultiDayHearingTests.cs index b06f32d87..11d6b364b 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/CancelMultiDayHearingTests.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/CancelMultiDayHearingTests.cs @@ -4,9 +4,8 @@ using AdminWebsite.Contracts.Requests; using AdminWebsite.Models; using BookingsApi.Client; -using BookingsApi.Contract.V1.Enums; using BookingsApi.Contract.V1.Requests; -using BookingsApi.Contract.V1.Responses; +using BookingsApi.Contract.V2.Enums; using BookingsApi.Contract.V2.Responses; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; @@ -41,9 +40,9 @@ public async Task should_cancel_multi_day_hearing(bool updateFutureDays) DateTime.UtcNow.AddDays(5).AddHours(10), }; var existingHearingsInMultiDayGroup = CreateListOfV2HearingsInMultiDayGroup(groupId, hearingId, scheduledDates: hearingDates); - existingHearingsInMultiDayGroup[3].Status = BookingStatus.Cancelled; - existingHearingsInMultiDayGroup[4].Status = BookingStatus.Failed; - BookingsApiClient.Setup(x => x.GetHearingsByGroupIdAsync(groupId)).ReturnsAsync(existingHearingsInMultiDayGroup); + existingHearingsInMultiDayGroup[3].Status = BookingStatusV2.Cancelled; + existingHearingsInMultiDayGroup[4].Status = BookingStatusV2.Failed; + BookingsApiClient.Setup(x => x.GetHearingsByGroupIdV2Async(groupId)).ReturnsAsync(existingHearingsInMultiDayGroup); var hearing = existingHearingsInMultiDayGroup.First(x => x.Id == hearingId); var mappedHearing = MapHearingDetailsForV2(hearing); BookingsApiClient.Setup(x => x.GetHearingDetailsByIdV2Async(hearingId)).ReturnsAsync(mappedHearing); @@ -59,7 +58,7 @@ public async Task should_cancel_multi_day_hearing(bool updateFutureDays) result.StatusCode.Should().Be(StatusCodes.Status200OK); result.Value.Should().NotBeNull().And.BeAssignableTo<UpdateBookingStatusResponse>().Subject.Success.Should().BeTrue(); - var expectedUpdatedHearings = new List<HearingDetailsResponse>(); + var expectedUpdatedHearings = new List<HearingDetailsResponseV2>(); if (updateFutureDays) { expectedUpdatedHearings.AddRange(existingHearingsInMultiDayGroup); @@ -71,8 +70,8 @@ public async Task should_cancel_multi_day_hearing(bool updateFutureDays) expectedUpdatedHearings = expectedUpdatedHearings .Where(h => - h.Status != BookingStatus.Cancelled && - h.Status != BookingStatus.Failed) + h.Status != BookingStatusV2.Cancelled && + h.Status != BookingStatusV2.Failed) .ToList(); BookingsApiClient.Verify(x => x.CancelHearingsInGroupAsync( @@ -114,7 +113,7 @@ public async Task Should_return_bad_request_when_hearing_is_not_multi_day() // Arrange var hearingId = Guid.NewGuid(); var groupId = Guid.NewGuid(); - var existingHearingsInMultiDayGroup = CreateListOfV1HearingsInMultiDayGroup(groupId, hearingId); + var existingHearingsInMultiDayGroup = CreateListOfV2HearingsInMultiDayGroup(groupId, hearingId); var hearing = existingHearingsInMultiDayGroup.First(x => x.Id == hearingId); hearing.GroupId = null; @@ -145,7 +144,7 @@ private static CancelMultiDayHearingRequest CreateRequest() => CancelReason = "cancellation reason" }; - private static HearingDetailsResponseV2 MapHearingDetailsForV2(HearingDetailsResponse hearing) => + private static HearingDetailsResponseV2 MapHearingDetailsForV2(HearingDetailsResponseV2 hearing) => new() { Id = hearing.Id, diff --git a/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/EditHearingTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/EditHearingTests.cs index 95c8e9aaa..baab8cdfa 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/EditHearingTests.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/EditHearingTests.cs @@ -1,27 +1,19 @@ using System.Linq; -using System.Threading; using System.Threading.Tasks; using AdminWebsite.Configuration; using AdminWebsite.Models; using AdminWebsite.Security; using AdminWebsite.Services; using BookingsApi.Client; -using BookingsApi.Contract.V1.Requests; -using BookingsApi.Contract.V1.Requests.Enums; -using BookingsApi.Contract.V1.Responses; using BookingsApi.Contract.V2.Enums; using BookingsApi.Contract.V2.Requests; using BookingsApi.Contract.V2.Responses; -using FluentValidation; -using FluentValidation.Results; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using VideoApi.Contract.Consts; using VideoApi.Contract.Responses; -using CaseResponse = BookingsApi.Contract.V1.Responses.CaseResponse; using JudiciaryParticipantRequest = AdminWebsite.Contracts.Requests.JudiciaryParticipantRequest; -using ParticipantResponse = BookingsApi.Contract.V1.Responses.ParticipantResponse; namespace AdminWebsite.UnitTests.Controllers.HearingsController { @@ -33,11 +25,10 @@ public class EditHearingTests private AdminWebsite.Controllers.HearingsController _controller; private EditHearingRequest _editEndpointOnHearingRequestWithJudge; - private Mock<IValidator<EditHearingRequest>> _editHearingRequestValidator; private IHearingsService _hearingsService; private Mock<ILogger<HearingsService>> _participantGroupLogger; - private HearingDetailsResponse _updatedExistingParticipantHearingOriginal; + private HearingDetailsResponseV2 _updatedExistingParticipantHearingOriginal; private Mock<IUserIdentity> _userIdentity; private HearingDetailsResponseV2 _v2HearingDetailsResponse; @@ -50,7 +41,6 @@ public void Setup() { _bookingsApiClient = new Mock<IBookingsApiClient>(); _userIdentity = new Mock<IUserIdentity>(); - _editHearingRequestValidator = new Mock<IValidator<EditHearingRequest>>(); _conferencesServiceMock = new Mock<IConferenceDetailsService>(); _conferencesServiceMock.Setup(cs => cs.GetConferenceDetailsByHearingId(It.IsAny<Guid>(), false)) .ReturnsAsync(new ConferenceDetailsResponse @@ -74,7 +64,6 @@ public void Setup() _hearingsService = new HearingsService(_bookingsApiClient.Object, _participantGroupLogger.Object); _controller = new AdminWebsite.Controllers.HearingsController(_bookingsApiClient.Object, _userIdentity.Object, - _editHearingRequestValidator.Object, new Mock<ILogger<AdminWebsite.Controllers.HearingsController>>().Object, _hearingsService, _conferencesServiceMock.Object); @@ -98,17 +87,17 @@ public void Setup() }, }; - var cases = new List<CaseResponse> + var cases = new List<CaseResponseV2> { - new CaseResponse {Name = "Case", Number = "123"} + new() {Name = "Case", Number = "123"} }; - _updatedExistingParticipantHearingOriginal = new HearingDetailsResponse + _updatedExistingParticipantHearingOriginal = new HearingDetailsResponseV2() { Id = _validId, GroupId = _validId, Participants = [ - new ParticipantResponse + new ParticipantResponseV2() { Id = Guid.NewGuid(), UserRoleName = "Individual", @@ -116,7 +105,7 @@ public void Setup() Username = "old@domain.net" }], Cases = cases, - CaseTypeName = "Unit Test", + ServiceId = "ABC123", ScheduledDateTime = DateTime.UtcNow.AddHours(3), OtherInformation = "" }; @@ -139,10 +128,9 @@ public void Setup() }, Participants = new List<EditParticipantRequest>() { - new EditParticipantRequest() { + new() { Id = participantId1, - CaseRoleName = "judge", - HearingRoleName = HearingRoleName.Judge, + HearingRoleName = HearingRoleName.Expert, FirstName = "FirstName", LastName = "LastName", ContactEmail = "judge@email.com", @@ -164,12 +152,9 @@ public void Setup() } }; - _bookingsApiClient.Setup(x => x.GetHearingDetailsByIdAsync(It.IsAny<Guid>())) + _bookingsApiClient.Setup(x => x.GetHearingDetailsByIdV2Async(It.IsAny<Guid>())) .ReturnsAsync(_updatedExistingParticipantHearingOriginal); - _editHearingRequestValidator.Setup(x => x.ValidateAsync(It.IsAny<EditHearingRequest>(), It.IsAny<CancellationToken>())) - .ReturnsAsync(new ValidationResult()); - _v2HearingDetailsResponse = new HearingDetailsResponseV2 { Id = _validId, @@ -215,7 +200,7 @@ public void Setup() Sip = "sip" } }, - JudiciaryParticipants = new List<JudiciaryParticipantResponse>() + JudicialOfficeHolders = new List<JudiciaryParticipantResponse>() { new (){FullName = "Judge Fudge", FirstName = "John", LastName = "Doe", HearingRoleCode = JudiciaryParticipantHearingRoleCode.Judge, PersonalCode = "1234"}, new (){FullName = "Jane Doe", FirstName = "Jane", LastName = "Doe", HearingRoleCode = JudiciaryParticipantHearingRoleCode.PanelMember, PersonalCode = "4567"}, @@ -279,7 +264,7 @@ public async Task Should_return_updated_hearing2() } }, }); - var existingJudiciaryParticipants = updatedHearing.JudiciaryParticipants.ToList(); + var existingJudiciaryParticipants = updatedHearing.JudicialOfficeHolders.ToList(); _addNewParticipantRequest.JudiciaryParticipants = existingJudiciaryParticipants.Select(x => new JudiciaryParticipantRequest { PersonalCode = x.PersonalCode, @@ -321,7 +306,7 @@ public async Task Should_return_updated_hearing2() _bookingsApiClient.Verify(x => x.AddJudiciaryParticipantsToHearingAsync( hearing.Id, - It.Is<List<BookingsApi.Contract.V1.Requests.JudiciaryParticipantRequest>>(r => + It.Is<List<BookingsApi.Contract.V2.Requests.JudiciaryParticipantRequest>>(r => r.Any(y => y.PersonalCode == panelMemberToAdd.PersonalCode))), Times.Once); } @@ -336,7 +321,7 @@ public async Task Should_return_updated_hearingV2() .ReturnsAsync(updatedHearing) .ReturnsAsync(updatedHearing); - var existingJudge = updatedHearing.JudiciaryParticipants + var existingJudge = updatedHearing.JudicialOfficeHolders .Find(x => x.HearingRoleCode == JudiciaryParticipantHearingRoleCode.Judge); var request = new EditHearingRequest @@ -372,7 +357,7 @@ public async Task Should_return_updated_hearingV2_with_no_judiciary_participants { var updatedHearing = _v2HearingDetailsResponse; updatedHearing.Participants.Clear(); - updatedHearing.JudiciaryParticipants.Clear(); + updatedHearing.JudicialOfficeHolders.Clear(); _bookingsApiClient.SetupSequence(x => x.GetHearingDetailsByIdV2Async(It.IsAny<Guid>())) .ReturnsAsync(updatedHearing) .ReturnsAsync(updatedHearing) @@ -418,7 +403,7 @@ public async Task Should_return_updated_hearingV2_with_new_judge_different_to_ol Role = JudiciaryParticipantHearingRoleCode.Judge.ToString() }; - var existingPanelMembers = updatedHearing.JudiciaryParticipants + var existingPanelMembers = updatedHearing.JudicialOfficeHolders .Where(x => x.HearingRoleCode == JudiciaryParticipantHearingRoleCode.PanelMember); var request = new EditHearingRequest @@ -452,7 +437,7 @@ public async Task Should_return_updated_hearingV2_with_new_judge_and_no_old_judg { var updatedHearing = _v2HearingDetailsResponse; updatedHearing.Participants.Clear(); - updatedHearing.JudiciaryParticipants.Clear(); + updatedHearing.JudicialOfficeHolders.Clear(); _bookingsApiClient.SetupSequence(x => x.GetHearingDetailsByIdV2Async(It.IsAny<Guid>())) .ReturnsAsync(updatedHearing) .ReturnsAsync(updatedHearing) @@ -528,7 +513,7 @@ public async Task Should_reassign_a_generic_judge_booked_with_v1_to_ejud_judge_o HearingRoleCode = "Judge" }); - updatedHearing.JudiciaryParticipants.Clear(); + updatedHearing.JudicialOfficeHolders.Clear(); _bookingsApiClient.Setup(x => x.GetHearingDetailsByIdV2Async(It.IsAny<Guid>())) .ReturnsAsync(updatedHearing); @@ -570,9 +555,9 @@ public async Task Should_return_updated_hearingV2_with_participants_unchanged_an .ReturnsAsync(updatedHearing) .ReturnsAsync(updatedHearing); - var existingJudge = updatedHearing.JudiciaryParticipants + var existingJudge = updatedHearing.JudicialOfficeHolders .Find(x => x.HearingRoleCode == JudiciaryParticipantHearingRoleCode.Judge); - var existingPanelMembers = updatedHearing.JudiciaryParticipants + var existingPanelMembers = updatedHearing.JudicialOfficeHolders .Where(x => x.HearingRoleCode == JudiciaryParticipantHearingRoleCode.PanelMember); var request = new EditHearingRequest @@ -633,7 +618,7 @@ private void AssertJudiciaryJudgeReassigned( _bookingsApiClient.Verify(x => x.AddJudiciaryParticipantsToHearingAsync( It.IsAny<Guid>(), - It.IsAny<List<BookingsApi.Contract.V1.Requests.JudiciaryParticipantRequest>>()), + It.IsAny<List<BookingsApi.Contract.V2.Requests.JudiciaryParticipantRequest>>()), Times.Never); } diff --git a/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/EditMultiDayHearingTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/EditMultiDayHearingTests.cs index 75b498672..16aabe812 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/EditMultiDayHearingTests.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/EditMultiDayHearingTests.cs @@ -5,8 +5,6 @@ using AdminWebsite.Mappers; using AdminWebsite.Models; using BookingsApi.Client; -using BookingsApi.Contract.V1.Requests.Enums; -using BookingsApi.Contract.V1.Responses; using BookingsApi.Contract.V2.Enums; using BookingsApi.Contract.V2.Requests; using BookingsApi.Contract.V2.Responses; @@ -279,7 +277,7 @@ public async Task Should_not_overwrite_data_for_future_days_when_only_specific_d Id = Guid.NewGuid(), DisplayName = "Endpoint X" }); - day1Hearing.JudiciaryParticipants.Add(new JudiciaryParticipantResponse + day1Hearing.JudicialOfficeHolders.Add(new JudiciaryParticipantResponse { PersonalCode = Guid.NewGuid().ToString(), DisplayName = "PanelMemberDay1", @@ -310,7 +308,7 @@ public async Task Should_not_overwrite_data_for_future_days_when_only_specific_d Id = Guid.NewGuid(), DisplayName = "Endpoint C" }); - day2Hearing.JudiciaryParticipants.Add(new JudiciaryParticipantResponse + day2Hearing.JudicialOfficeHolders.Add(new JudiciaryParticipantResponse { PersonalCode = Guid.NewGuid().ToString(), DisplayName = "PanelMemberDay2", @@ -372,7 +370,7 @@ public async Task Should_not_overwrite_data_for_future_days_when_only_specific_d h.Endpoints.NewEndpoints.Count == 0 && h.Endpoints.RemovedEndpointIds.Count == 0 && h.JudiciaryParticipants.NewJudiciaryParticipants.Count == 0 && - h.JudiciaryParticipants.ExistingJudiciaryParticipants.Count == day1Hearing.JudiciaryParticipants.Count && + h.JudiciaryParticipants.ExistingJudiciaryParticipants.Count == day1Hearing.JudicialOfficeHolders.Count && h.JudiciaryParticipants.RemovedJudiciaryParticipantPersonalCodes.Count == 0 )))); @@ -396,7 +394,7 @@ public async Task Should_not_overwrite_data_for_future_days_when_only_specific_d h.Endpoints.NewEndpoints.Count == 0 && h.Endpoints.RemovedEndpointIds.Count == 0 && h.JudiciaryParticipants.NewJudiciaryParticipants.Count == 0 && - h.JudiciaryParticipants.ExistingJudiciaryParticipants.Count == day2Hearing.JudiciaryParticipants.Count && + h.JudiciaryParticipants.ExistingJudiciaryParticipants.Count == day2Hearing.JudicialOfficeHolders.Count && h.JudiciaryParticipants.RemovedJudiciaryParticipantPersonalCodes.Count == 0 )))); } @@ -438,7 +436,7 @@ public async Task Should_update_multi_day_hearing_when_updated_participants_and_ Id = Guid.NewGuid(), DisplayName = "Endpoint C" }); - day1Hearing.JudiciaryParticipants.Add(new JudiciaryParticipantResponse + day1Hearing.JudicialOfficeHolders.Add(new JudiciaryParticipantResponse { PersonalCode = Guid.NewGuid().ToString(), DisplayName = "PanelMember", @@ -487,7 +485,7 @@ public async Task Should_update_multi_day_hearing_when_updated_participants_and_ h.Endpoints.ExistingEndpoints.Count == day1Hearing.Endpoints.Count && h.Endpoints.NewEndpoints.Count == 0 && h.Endpoints.RemovedEndpointIds.Count == 0 && - h.JudiciaryParticipants.ExistingJudiciaryParticipants.Count == day1Hearing.JudiciaryParticipants.Count && + h.JudiciaryParticipants.ExistingJudiciaryParticipants.Count == day1Hearing.JudicialOfficeHolders.Count && h.JudiciaryParticipants.NewJudiciaryParticipants.Count == 0 && h.JudiciaryParticipants.RemovedJudiciaryParticipantPersonalCodes.Count == 0 )))); @@ -505,7 +503,7 @@ public async Task Should_update_multi_day_hearing_when_updated_participants_and_ h.Endpoints.ExistingEndpoints.Count == day2Hearing.Endpoints.Count && h.Endpoints.NewEndpoints.Count == 0 && h.Endpoints.RemovedEndpointIds.Count == 0 && - h.JudiciaryParticipants.ExistingJudiciaryParticipants.Count == day2Hearing.JudiciaryParticipants.Count && + h.JudiciaryParticipants.ExistingJudiciaryParticipants.Count == day2Hearing.JudicialOfficeHolders.Count && h.JudiciaryParticipants.NewJudiciaryParticipants.Count == 0 && h.JudiciaryParticipants.RemovedJudiciaryParticipantPersonalCodes.Count == 0 )))); @@ -675,8 +673,8 @@ public async Task Should_reassign_judge_when_future_day_hearing_is_assigned_to_d // Assign day 2 to a different judge var day1Hearing = existingHearingsInMultiDayGroup[0]; var day2Hearing = existingHearingsInMultiDayGroup[1]; - var day1OldJudge = day1Hearing.JudiciaryParticipants.Find(x => x.HearingRoleCode == JudiciaryParticipantHearingRoleCode.Judge); - var day2OldJudge = day2Hearing.JudiciaryParticipants.Find(x => x.HearingRoleCode == JudiciaryParticipantHearingRoleCode.Judge); + var day1OldJudge = day1Hearing.JudicialOfficeHolders.Find(x => x.HearingRoleCode == JudiciaryParticipantHearingRoleCode.Judge); + var day2OldJudge = day2Hearing.JudicialOfficeHolders.Find(x => x.HearingRoleCode == JudiciaryParticipantHearingRoleCode.Judge); day2OldJudge.PersonalCode = Guid.NewGuid().ToString(); day2OldJudge.Email = "day2Judge@email.com"; @@ -721,7 +719,7 @@ public async Task Should_reassign_judge_when_future_day_hearing_is_assigned_to_d h.JudiciaryParticipants.NewJudiciaryParticipants.Exists(x => x.PersonalCode == newJudge.PersonalCode) && h.JudiciaryParticipants.RemovedJudiciaryParticipantPersonalCodes.Count == 1 && h.JudiciaryParticipants.RemovedJudiciaryParticipantPersonalCodes.Contains(day1OldJudge.PersonalCode) && - h.JudiciaryParticipants.ExistingJudiciaryParticipants.Count == day1Hearing.JudiciaryParticipants.Count - 1 + h.JudiciaryParticipants.ExistingJudiciaryParticipants.Count == day1Hearing.JudicialOfficeHolders.Count - 1 )))); // Day 2 @@ -734,7 +732,7 @@ public async Task Should_reassign_judge_when_future_day_hearing_is_assigned_to_d h.JudiciaryParticipants.NewJudiciaryParticipants.Exists(x => x.PersonalCode == newJudge.PersonalCode) && h.JudiciaryParticipants.RemovedJudiciaryParticipantPersonalCodes.Count == 1 && h.JudiciaryParticipants.RemovedJudiciaryParticipantPersonalCodes.Contains(day2OldJudge.PersonalCode) && - h.JudiciaryParticipants.ExistingJudiciaryParticipants.Count == day2Hearing.JudiciaryParticipants.Count - 1 + h.JudiciaryParticipants.ExistingJudiciaryParticipants.Count == day2Hearing.JudicialOfficeHolders.Count - 1 )))); } @@ -810,7 +808,7 @@ private static HearingDetailsResponseV2 MapUpdatedHearingV2( ContactEmail = x.ContactEmail, DisplayName = x.DisplayName }).ToList(), - JudiciaryParticipants = request.JudiciaryParticipants.Select(x => new JudiciaryParticipantResponse + JudicialOfficeHolders = request.JudiciaryParticipants.Select(x => new JudiciaryParticipantResponse { DisplayName = x.DisplayName, PersonalCode = x.PersonalCode, @@ -852,7 +850,7 @@ private static EditMultiDayHearingRequest CreateV2EditMultiDayHearingRequest(Hea Id = x.Id, DisplayName = x.DisplayName }).ToList(), - JudiciaryParticipants = hearing.JudiciaryParticipants.Select(x => new JudiciaryParticipantRequest + JudiciaryParticipants = hearing.JudicialOfficeHolders.Select(x => new JudiciaryParticipantRequest { PersonalCode = x.PersonalCode, Role = x.HearingRoleCode.ToString(), diff --git a/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/FailHearingTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/FailHearingTests.cs index 3d893efdb..f7c74ae49 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/FailHearingTests.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/FailHearingTests.cs @@ -1,15 +1,14 @@ using System.Threading.Tasks; -using AdminWebsite.Configuration; using AdminWebsite.Models; using AdminWebsite.Security; using AdminWebsite.Services; using Autofac.Extras.Moq; using BookingsApi.Client; -using BookingsApi.Contract.V1.Responses; +using BookingsApi.Contract.V2.Responses; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using VideoApi.Contract.Responses; -using ParticipantResponse = BookingsApi.Contract.V1.Responses.ParticipantResponse; +using ParticipantResponse = BookingsApi.Contract.V2.Responses.ParticipantResponseV2; namespace AdminWebsite.UnitTests.Controllers.HearingsController { @@ -36,8 +35,8 @@ public void Setup() TelephoneConferenceId = "expected_conference_phone_id" } }); - _mocker.Mock<IBookingsApiClient>().Setup(bs => bs.GetHearingDetailsByIdAsync(It.IsAny<Guid>())) - .ReturnsAsync(new HearingDetailsResponse + _mocker.Mock<IBookingsApiClient>().Setup(bs => bs.GetHearingDetailsByIdV2Async(It.IsAny<Guid>())) + .ReturnsAsync(new HearingDetailsResponseV2 { Participants = [new ParticipantResponse { HearingRoleName = "Judge" }] }); diff --git a/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/GetHearingTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/GetHearingTests.cs index 94b440c4d..bfe78faaf 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/GetHearingTests.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/GetHearingTests.cs @@ -1,15 +1,11 @@ using AdminWebsite.Services; -using AdminWebsite.UnitTests.Helper; using Microsoft.AspNetCore.Mvc; using System.Linq; -using System.Net; using System.Threading.Tasks; -using AdminWebsite.Configuration; using AdminWebsite.Contracts.Responses; using AdminWebsite.Mappers; using BookingsApi.Client; using Autofac.Extras.Moq; -using BookingsApi.Contract.V1.Enums; using BookingsApi.Contract.V2.Enums; using BookingsApi.Contract.V2.Responses; using VideoApi.Contract.Responses; @@ -20,9 +16,7 @@ public class GetHearingTests { private AutoMock _mocker; private AdminWebsite.Controllers.HearingsController _controller; - - private BookingsApi.Contract.V1.Responses.HearingDetailsResponse _vhExistingHearingV1; - private Guid _v1HearingId; + private Guid _V2HearingId; private Guid _v2HearingId; private HearingDetailsResponseV2 _vhExistingHearingV2; @@ -51,40 +45,32 @@ public void Setup() public void Initialise() { - _v1HearingId = Guid.NewGuid(); - _vhExistingHearingV1 = new BookingsApi.Contract.V1.Responses.HearingDetailsResponse + _V2HearingId = Guid.NewGuid(); + _vhExistingHearingV2 = new HearingDetailsResponseV2() { - Cases = new List<BookingsApi.Contract.V1.Responses.CaseResponse>() + Cases = new List<CaseResponseV2>() { - new BookingsApi.Contract.V1.Responses.CaseResponse - {Name = "BBC vs ITV", Number = "TX/12345/2019", IsLeadCase = false} + new() {Name = "BBC vs ITV", Number = "TX/12345/2019", IsLeadCase = false} }, - CaseTypeName = "Generic", + ServiceId = "Generic", CreatedBy = "CaseAdministrator", CreatedDate = DateTime.UtcNow, HearingRoomName = "Room 6.41D", - HearingTypeName = "Automated Test", HearingVenueName = "Manchester Civil and Family Justice Centre", - Id = _v1HearingId, + Id = _V2HearingId, OtherInformation = "Any other information about the hearing", - Participants = new List<BookingsApi.Contract.V1.Responses.ParticipantResponse>() + Participants = new List<ParticipantResponseV2>() { new () { - CaseRoleName = "Judge", ContactEmail = "Judge.Lumb@hmcts.net", DisplayName = "Judge Lumb", - FirstName = "Judge", HearingRoleName = "Judge", LastName = "Lumb", MiddleNames = string.Empty, - TelephoneNumber = string.Empty, Title = "Judge", Username = "Judge.Lumb@hmcts.net" - }, - new () - { - CaseRoleName = "Applicant", ContactEmail = "test.applicant@hmcts.net", + ContactEmail = "test.applicant@hmcts.net", DisplayName = "Test Applicant", FirstName = "Test", HearingRoleName = "Litigant in person", LastName = "Applicant", MiddleNames = string.Empty, TelephoneNumber = string.Empty, Title = "Mr", Username = "Test.Applicant@hmcts.net" }, new () { - CaseRoleName = "Respondent", ContactEmail = "test.respondent@hmcts.net", + ContactEmail = "test.respondent@hmcts.net", DisplayName = "Test Respondent", FirstName = "Test", HearingRoleName = "Representative", LastName = "Respondent", MiddleNames = string.Empty, TelephoneNumber = string.Empty, Title = "Mr", Username = "Test.Respondent@hmcts.net" @@ -92,7 +78,7 @@ public void Initialise() }, ScheduledDateTime = DateTime.UtcNow.AddDays(10), ScheduledDuration = 60, - Status = BookingStatus.Booked, + Status = BookingStatusV2.Booked, UpdatedBy = string.Empty, UpdatedDate = DateTime.UtcNow }; @@ -145,8 +131,8 @@ public void Initialise() } }; - _mocker.Mock<IBookingsApiClient>().Setup(x => x.GetHearingDetailsByIdAsync(It.IsAny<Guid>())) - .ReturnsAsync(_vhExistingHearingV1); + _mocker.Mock<IBookingsApiClient>().Setup(x => x.GetHearingDetailsByIdV2Async(It.IsAny<Guid>())) + .ReturnsAsync(_vhExistingHearingV2); } diff --git a/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/GetStatusHearingTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/GetStatusHearingTests.cs index b94898f96..7ff207aac 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/GetStatusHearingTests.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/GetStatusHearingTests.cs @@ -7,13 +7,12 @@ using VideoApi.Contract.Responses; using AdminWebsite.Security; using BookingsApi.Contract.V1.Enums; -using BookingsApi.Contract.V1.Responses; using BookingsApi.Contract.V2.Enums; using FluentValidation; using Microsoft.Extensions.Logging; using BookingsApi.Contract.V2.Responses; -using CaseResponse = BookingsApi.Contract.V1.Responses.CaseResponse; -using ParticipantResponse = BookingsApi.Contract.V1.Responses.ParticipantResponse; +using CaseResponse = BookingsApi.Contract.V2.Responses.CaseResponseV2; +using ParticipantResponse = BookingsApi.Contract.V2.Responses.ParticipantResponseV2; namespace AdminWebsite.UnitTests.Controllers.HearingsController { @@ -23,7 +22,7 @@ public class GetStatusHearingTests private Mock<IBookingsApiClient> _bookingsApiClientMock; private Mock<IConferenceDetailsService> _conferenceDetailsServiceMock; private Mock<IHearingsService> _hearingServiceMock; - private HearingDetailsResponse _vhExistingHearing; + private HearingDetailsResponseV2 _vhExistingHearing; private HearingDetailsResponseV2 _vhExistingHearingV2; private Guid _guid; @@ -35,7 +34,6 @@ public void Setup() _hearingServiceMock = new Mock<IHearingsService>(); _controller = new AdminWebsite.Controllers.HearingsController(_bookingsApiClientMock.Object, new Mock<IUserIdentity>().Object, - new Mock<IValidator<EditHearingRequest>>().Object, new Mock<ILogger<AdminWebsite.Controllers.HearingsController>>().Object, _hearingServiceMock.Object, _conferenceDetailsServiceMock.Object); @@ -47,42 +45,31 @@ public void Setup() public void Initialise() { _guid = Guid.NewGuid(); - _vhExistingHearing = new HearingDetailsResponse + _vhExistingHearing = new HearingDetailsResponseV2 { Cases = new List<CaseResponse> { new CaseResponse {Name = "BBC vs ITV", Number = "TX/12345/2019", IsLeadCase = false} }, - CaseTypeName = "Generic", + ServiceId = "Generic", CreatedBy = "CaseAdministrator", CreatedDate = DateTime.UtcNow, HearingRoomName = "Room 6.41D", - HearingTypeName = "Automated Test", HearingVenueName = "Manchester Civil and Family Justice Centre", Id = _guid, OtherInformation = "Any other information about the hearing", Participants = [ new ParticipantResponse - { - CaseRoleName = "Judge", ContactEmail = "Judge.Lumb@hmcts.net", DisplayName = "Judge Lumb", - FirstName = "Judge", HearingRoleName = "Judge", LastName = "Lumb", MiddleNames = string.Empty, - TelephoneNumber = string.Empty, Title = "Judge", Username = "Judge.Lumb@hearings.net", - UserRoleName = "Judge" - }, - - new ParticipantResponse - { - CaseRoleName = "Applicant", ContactEmail = "test.applicant@hmcts.net", + {ContactEmail = "test.applicant@hmcts.net", DisplayName = "Test Applicant", FirstName = "Test", HearingRoleName = "Litigant in person", LastName = "Applicant", MiddleNames = string.Empty, TelephoneNumber = string.Empty, Title = "Mr", Username = "Test.Applicant@hearings.net", UserRoleName = "Individual" }, new ParticipantResponse - { - CaseRoleName = "Respondent", ContactEmail = "test.respondent@hmcts.net", + {ContactEmail = "test.respondent@hmcts.net", DisplayName = "Test Respondent", FirstName = "Test", HearingRoleName = "Representative", LastName = "Respondent", MiddleNames = string.Empty, TelephoneNumber = string.Empty, Title = "Mr", Username = "Test.Respondent@hearings.net", UserRoleName = "Represntative" @@ -91,16 +78,16 @@ public void Initialise() ], ScheduledDateTime = DateTime.UtcNow.AddDays(10), ScheduledDuration = 60, - Status = BookingStatus.Booked, + Status = BookingStatusV2.Booked, UpdatedBy = string.Empty, UpdatedDate = DateTime.UtcNow }; - _bookingsApiClientMock.Setup(x => x.GetHearingDetailsByIdAsync(It.IsAny<Guid>())) + _bookingsApiClientMock.Setup(x => x.GetHearingDetailsByIdV2Async(It.IsAny<Guid>())) .ReturnsAsync(_vhExistingHearing); _bookingsApiClientMock.Setup(x => x.GetHearingDetailsByIdV2Async(It.IsAny<Guid>())) - .ReturnsAsync(GetHearingDetailsResponseV2(BookingsApi.Contract.V2.Enums.BookingStatusV2.Created)); + .ReturnsAsync(GetHearingDetailsResponseV2(BookingStatusV2.Created)); } [Test] @@ -127,7 +114,7 @@ public async Task Should_return_BadRequest_when_issue_with_finding_hearing_with_ // Arrange - _vhExistingHearing.Status = BookingStatus.Created; + _vhExistingHearing.Status = BookingStatusV2.Created; _conferenceDetailsServiceMock.Setup(x => x.GetConferenceDetailsByHearingId(It.IsAny<Guid>(), false)).Throws(new VideoApiException("Error", 400, null, null, null)); // Act var result = await _controller.GetHearingConferenceStatus(_guid); @@ -168,7 +155,7 @@ public async Task Should_return_ok_with_false_when_hearing_status_is_created_and // Arrange _conferenceDetailsServiceMock.Setup(x => x.GetConferenceDetailsByHearingId(It.IsAny<Guid>(), false)) .ReturnsAsync(conferenceResponse); - _vhExistingHearing.Status = BookingStatus.Created; + _vhExistingHearing.Status = BookingStatusV2.Created; // Act var result = await _controller.GetHearingConferenceStatus(_guid); diff --git a/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/HearingsControllerTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/HearingsControllerTests.cs index 35d8aa01b..34598c472 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/HearingsControllerTests.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/HearingsControllerTests.cs @@ -3,9 +3,6 @@ using AdminWebsite.Security; using AdminWebsite.Services; using BookingsApi.Client; -using BookingsApi.Contract.V1.Enums; -using BookingsApi.Contract.V1.Requests.Enums; -using BookingsApi.Contract.V1.Responses; using BookingsApi.Contract.V2.Enums; using BookingsApi.Contract.V2.Responses; using FizzWare.NBuilder; @@ -13,8 +10,6 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using VideoApi.Contract.Responses; -using EndpointResponse = BookingsApi.Contract.V1.Responses.EndpointResponse; -using ParticipantResponse = BookingsApi.Contract.V1.Responses.ParticipantResponse; namespace AdminWebsite.UnitTests.Controllers.HearingsController { @@ -22,7 +17,6 @@ public abstract class HearingsControllerTests { private Mock<IConferenceDetailsService> _conferencesServiceMock; - private Mock<IValidator<EditHearingRequest>> _editHearingRequestValidator; private IHearingsService _hearingsService; private Mock<ILogger<HearingsService>> _participantGroupLogger; private Mock<VodafoneConfiguration> _VodafoneConfigurationMock; @@ -37,7 +31,6 @@ protected virtual void Setup() { BookingsApiClient = new Mock<IBookingsApiClient>(); UserIdentity = new Mock<IUserIdentity>(); - _editHearingRequestValidator = new Mock<IValidator<EditHearingRequest>>(); _conferencesServiceMock = new Mock<IConferenceDetailsService>(); FeatureToggle = new Mock<IFeatureToggles>(); _conferencesServiceMock.Setup(cs => cs.GetConferenceDetailsByHearingId(It.IsAny<Guid>(), false)) @@ -63,87 +56,11 @@ protected virtual void Setup() Controller = new AdminWebsite.Controllers.HearingsController(BookingsApiClient.Object, UserIdentity.Object, - _editHearingRequestValidator.Object, new Mock<ILogger<AdminWebsite.Controllers.HearingsController>>().Object, _hearingsService, _conferencesServiceMock.Object); } - protected static List<HearingDetailsResponse> CreateListOfV1HearingsInMultiDayGroup( - Guid groupId, Guid initialHearingId) - { - var hearingDates = new List<DateTime> - { - DateTime.Today.AddDays(1).AddHours(10), - DateTime.UtcNow.AddDays(2).AddHours(10), - DateTime.UtcNow.AddDays(3).AddHours(10) - }; - - return CreateListOfV1HearingsInMultiDayGroup(groupId, initialHearingId, hearingDates); - } - - protected static List<HearingDetailsResponse> CreateListOfV1HearingsInMultiDayGroup( - Guid groupId, Guid initialHearingId, List<DateTime> scheduledDates) - { - var hearingsInMultiDay = new List<HearingDetailsResponse>(); - var i = 0; - foreach (var date in scheduledDates) - { - var hearing = Builder<HearingDetailsResponse>.CreateNew().Build(); - - hearing.Participants = new List<ParticipantResponse> - { - new() - { - Id = Guid.NewGuid(), - FirstName = "Judge", - LastName = "Test", - ContactEmail = "judge@email.com", - Username = "judge@hearings.reform.hmcts.net", - HearingRoleName = "Judge", - UserRoleName = "Judge" - }, - new() - { - Id = Guid.NewGuid(), - FirstName = "Applicant", - LastName = "Test", - ContactEmail = "applicant@email.com", - Username = "applicant@hearings.reform.hmcts.net", - HearingRoleName = "Applicant", - UserRoleName = "Individual" - } - }; - - hearing.Endpoints = - [ - new EndpointResponse - { - Id = Guid.NewGuid(), - DisplayName = "Endpoint A" - }, - - new EndpointResponse - { - Id = Guid.NewGuid(), - DisplayName = "Endpoint B" - } - ]; - - hearing.GroupId = groupId; - hearing.ScheduledDateTime = date; - hearing.ScheduledDuration = 45; - hearing.Status = BookingStatus.Created; - hearing.Id = i == 0 ? initialHearingId : Guid.NewGuid(); - - hearingsInMultiDay.Add(hearing); - - i++; - } - - return hearingsInMultiDay; - } - protected static List<HearingDetailsResponseV2> CreateListOfV2HearingsInMultiDayGroup( Guid groupId, Guid initialHearingId) { @@ -157,16 +74,16 @@ protected static List<HearingDetailsResponseV2> CreateListOfV2HearingsInMultiDay return CreateListOfV2HearingsInMultiDayGroupAsV2(groupId, initialHearingId, hearingDates); } - protected static List<HearingDetailsResponse> CreateListOfV2HearingsInMultiDayGroup( + protected static List<HearingDetailsResponseV2> CreateListOfV2HearingsInMultiDayGroup( Guid groupId, Guid initialHearingId, List<DateTime> scheduledDates) { - var hearingsInMultiDay = new List<HearingDetailsResponse>(); + var hearingsInMultiDay = new List<HearingDetailsResponseV2>(); var i = 0; foreach (var date in scheduledDates) { - var hearing = Builder<HearingDetailsResponse>.CreateNew().Build(); + var hearing = Builder<HearingDetailsResponseV2>.CreateNew().Build(); - hearing.Participants = new List<ParticipantResponse> + hearing.Participants = new List<ParticipantResponseV2> { new() { @@ -180,7 +97,7 @@ protected static List<HearingDetailsResponse> CreateListOfV2HearingsInMultiDayGr } }; - hearing.JudiciaryParticipants = new List<JudiciaryParticipantResponse> + hearing.JudicialOfficeHolders = new List<JudiciaryParticipantResponse> { new() { @@ -193,7 +110,7 @@ protected static List<HearingDetailsResponse> CreateListOfV2HearingsInMultiDayGr } }; - hearing.Endpoints = new List<EndpointResponse> + hearing.Endpoints = new List<EndpointResponseV2> { new() { @@ -210,7 +127,7 @@ protected static List<HearingDetailsResponse> CreateListOfV2HearingsInMultiDayGr hearing.GroupId = groupId; hearing.ScheduledDateTime = date; hearing.ScheduledDuration = 45; - hearing.Status = BookingStatus.Created; + hearing.Status = BookingStatusV2.Created; hearing.Id = i == 0 ? initialHearingId : Guid.NewGuid(); hearingsInMultiDay.Add(hearing); @@ -287,7 +204,7 @@ protected static List<HearingDetailsResponseV2> CreateListOfV2HearingsInMultiDay } }; - hearing.JudiciaryParticipants = new List<JudiciaryParticipantResponse> + hearing.JudicialOfficeHolders = new List<JudiciaryParticipantResponse> { new() { diff --git a/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/PostHearingTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/PostHearingTests.cs index 287fa1f43..2be47cd92 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/PostHearingTests.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/PostHearingTests.cs @@ -1,18 +1,18 @@ +using System.Linq; using AdminWebsite.Models; using AdminWebsite.Services; using AdminWebsite.UnitTests.Helper; using Microsoft.AspNetCore.Mvc; -using System.Linq; using System.Net; using System.Threading.Tasks; using AdminWebsite.Contracts.Requests; using BookingsApi.Client; using Autofac.Extras.Moq; -using BookingsApi.Contract.V1.Requests; +using BookingsApi.Contract.V2.Enums; using BookingsApi.Contract.V2.Requests; +using BookingsApi.Contract.V2.Responses; using VideoApi.Contract.Responses; using ParticipantRequest = AdminWebsite.Contracts.Requests.ParticipantRequest; -using V1 = BookingsApi.Contract.V1; namespace AdminWebsite.UnitTests.Controllers.HearingsController { @@ -39,14 +39,14 @@ public void Setup() TelephoneConferenceId = "expected_conference_phone_id" } }); - _mocker.Mock<IBookingsApiClient>().Setup(bs => bs.GetHearingDetailsByIdAsync(It.IsAny<Guid>())) - .ReturnsAsync(new V1.Responses.HearingDetailsResponse + _mocker.Mock<IBookingsApiClient>().Setup(bs => bs.GetHearingDetailsByIdV2Async(It.IsAny<Guid>())) + .ReturnsAsync(new HearingDetailsResponseV2() { - Participants = new List<V1.Responses.ParticipantResponse> + Participants = new List<ParticipantResponseV2> { new () {HearingRoleName = "Judge"} }, - CaseTypeName = "Generic" + ServiceId = "Generic" }); _controller = _mocker.Create<AdminWebsite.Controllers.HearingsController>(); } @@ -98,22 +98,22 @@ public async Task Should_clone_hearing() { var request = GetMultiHearingRequest(); request.ScheduledDuration = 120; - var groupedHearings = new List<V1.Responses.HearingDetailsResponse> + var groupedHearings = new List<HearingDetailsResponseV2> { new() { - Status = V1.Enums.BookingStatus.Booked, + Status = BookingStatusV2.Booked, GroupId = Guid.NewGuid(), Id = Guid.NewGuid(), } }; _mocker.Mock<IBookingsApiClient>() - .Setup(x => x.GetHearingsByGroupIdAsync(It.IsAny<Guid>())) + .Setup(x => x.GetHearingsByGroupIdV2Async(It.IsAny<Guid>())) .ReturnsAsync(groupedHearings); _mocker.Mock<IBookingsApiClient>() - .Setup(x => x.CloneHearingAsync(It.IsAny<Guid>(), It.IsAny<CloneHearingRequest>())) + .Setup(x => x.CloneHearingAsync(It.IsAny<Guid>(), It.IsAny<CloneHearingRequestV2>())) .Verifiable(); var response = await _controller.CloneHearing(Guid.NewGuid(), request); @@ -121,7 +121,7 @@ public async Task Should_clone_hearing() response.Should().BeOfType<NoContentResult>(); _mocker.Mock<IBookingsApiClient>().Verify( - x => x.CloneHearingAsync(It.IsAny<Guid>(), It.Is<CloneHearingRequest>( + x => x.CloneHearingAsync(It.IsAny<Guid>(), It.Is<CloneHearingRequestV2>( y => y.ScheduledDuration == request.ScheduledDuration)), Times.Exactly(1)); } @@ -131,24 +131,24 @@ public async Task Should_clone_and_confirm_hearing_for_large_booking() { var request = GetMultiHearingRequest(); var hearingGroupId = Guid.NewGuid(); - var groupedHearings = new List<V1.Responses.HearingDetailsResponse>(); + var groupedHearings = new List<HearingDetailsResponseV2>(); var batchSize = 30; for (var i = 1; i <= batchSize; i++) { - groupedHearings.Add(new V1.Responses.HearingDetailsResponse + groupedHearings.Add(new HearingDetailsResponseV2 { - Status = V1.Enums.BookingStatus.Booked, + Status = BookingStatusV2.Booked, GroupId = hearingGroupId, Id = Guid.NewGuid() }); } _mocker.Mock<IBookingsApiClient>() - .Setup(x => x.GetHearingsByGroupIdAsync(It.IsAny<Guid>())) + .Setup(x => x.GetHearingsByGroupIdV2Async(It.IsAny<Guid>())) .ReturnsAsync(groupedHearings); _mocker.Mock<IBookingsApiClient>() - .Setup(x => x.CloneHearingAsync(It.IsAny<Guid>(), It.IsAny<CloneHearingRequest>())) + .Setup(x => x.CloneHearingAsync(It.IsAny<Guid>(), It.IsAny<CloneHearingRequestV2>())) .Verifiable(); var response = await _controller.CloneHearing(Guid.NewGuid(), request); @@ -156,7 +156,7 @@ public async Task Should_clone_and_confirm_hearing_for_large_booking() response.Should().BeOfType<NoContentResult>(); _mocker.Mock<IBookingsApiClient>().Verify( - x => x.CloneHearingAsync(It.IsAny<Guid>(), It.IsAny<CloneHearingRequest>()), + x => x.CloneHearingAsync(It.IsAny<Guid>(), It.IsAny<CloneHearingRequestV2>()), Times.Exactly(1)); } @@ -178,7 +178,7 @@ public async Task Should_catch_BookingsApiException_by_clone_hearing() { var request = GetMultiHearingRequest(); _mocker.Mock<IBookingsApiClient>() - .Setup(x => x.CloneHearingAsync(It.IsAny<Guid>(), It.IsAny<CloneHearingRequest>())) + .Setup(x => x.CloneHearingAsync(It.IsAny<Guid>(), It.IsAny<CloneHearingRequestV2>())) .Throws(new BookingsApiException("Error", (int)HttpStatusCode.BadRequest, "response", null, null)); var response = await _controller.CloneHearing(Guid.NewGuid(), request); @@ -191,7 +191,7 @@ public async Task Should_catch_InternalError_by_clone_hearing() { var request = GetMultiHearingRequest(); _mocker.Mock<IBookingsApiClient>() - .Setup(x => x.CloneHearingAsync(It.IsAny<Guid>(), It.IsAny<CloneHearingRequest>())) + .Setup(x => x.CloneHearingAsync(It.IsAny<Guid>(), It.IsAny<CloneHearingRequestV2>())) .Throws(new BookingsApiException("Error", (int)HttpStatusCode.InternalServerError, "response", null, null)); var response = await _controller.CloneHearing(Guid.NewGuid(), request); @@ -206,18 +206,18 @@ public async Task Should_catch_InternalError_by_clone_hearing() public async Task Should_clone_hearings_on_weekends_when_start_or_end_date_are_on_weekends(DateTime startDate, DateTime endDate) { var request = new MultiHearingRequest { StartDate = startDate, EndDate = endDate}; - var groupedHearings = new List<V1.Responses.HearingDetailsResponse> + var groupedHearings = new List<HearingDetailsResponseV2> { new() { - Status = V1.Enums.BookingStatus.Booked, + Status = BookingStatusV2.Booked, GroupId = Guid.NewGuid(), Id = Guid.NewGuid(), } }; _mocker.Mock<IBookingsApiClient>() - .Setup(x => x.GetHearingsByGroupIdAsync(It.IsAny<Guid>())) + .Setup(x => x.GetHearingsByGroupIdV2Async(It.IsAny<Guid>())) .ReturnsAsync(groupedHearings); var expectedDates = new List<DateTime>(); @@ -232,7 +232,7 @@ public async Task Should_clone_hearings_on_weekends_when_start_or_end_date_are_o _mocker.Mock<IBookingsApiClient>().Verify( x => x.CloneHearingAsync(It.IsAny<Guid>(), - It.Is<CloneHearingRequest>(r => r.Dates.All(d => expectedDates.Contains(d)))), + It.Is<CloneHearingRequestV2>(r => r.Dates.All(d => expectedDates.Contains(d)))), Times.Exactly(1)); } @@ -242,18 +242,18 @@ public async Task Should_not_clone_hearings_on_weekends_when_start_or_end_date_a var startDate = new DateTime(2022, 12, 15, 0, 0, 0, DateTimeKind.Utc); var endDate = new DateTime(2022, 12, 20, 0, 0, 0, DateTimeKind.Utc); var request = new MultiHearingRequest { StartDate = startDate, EndDate = endDate}; - var groupedHearings = new List<V1.Responses.HearingDetailsResponse> + var groupedHearings = new List<HearingDetailsResponseV2> { new() { - Status = V1.Enums.BookingStatus.Booked, + Status = BookingStatusV2.Booked, GroupId = Guid.NewGuid(), Id = Guid.NewGuid(), } }; _mocker.Mock<IBookingsApiClient>() - .Setup(x => x.GetHearingsByGroupIdAsync(It.IsAny<Guid>())) + .Setup(x => x.GetHearingsByGroupIdV2Async(It.IsAny<Guid>())) .ReturnsAsync(groupedHearings); var expectedDates = new List<DateTime> @@ -271,7 +271,7 @@ public async Task Should_not_clone_hearings_on_weekends_when_start_or_end_date_a _mocker.Mock<IBookingsApiClient>().Verify( x => x.CloneHearingAsync(It.IsAny<Guid>(), - It.Is<CloneHearingRequest>(r => r.Dates.All(d => expectedDates.Contains(d)))), + It.Is<CloneHearingRequestV2>(r => r.Dates.All(d => expectedDates.Contains(d)))), Times.Exactly(1)); } @@ -285,18 +285,18 @@ public async Task Should_clone_hearings_using_hearing_dates() new (2023, 1, 8, 0, 0, 0, DateTimeKind.Utc) }; var request = new MultiHearingRequest { HearingDates = hearingDates }; - var groupedHearings = new List<V1.Responses.HearingDetailsResponse> + var groupedHearings = new List<HearingDetailsResponseV2> { new() { - Status = V1.Enums.BookingStatus.Booked, + Status = BookingStatusV2.Booked, GroupId = Guid.NewGuid(), Id = Guid.NewGuid(), } }; _mocker.Mock<IBookingsApiClient>() - .Setup(x => x.GetHearingsByGroupIdAsync(It.IsAny<Guid>())) + .Setup(x => x.GetHearingsByGroupIdV2Async(It.IsAny<Guid>())) .ReturnsAsync(groupedHearings); var expectedDates = new List<DateTime> @@ -312,7 +312,7 @@ public async Task Should_clone_hearings_using_hearing_dates() _mocker.Mock<IBookingsApiClient>().Verify( x => x.CloneHearingAsync(It.IsAny<Guid>(), - It.Is<CloneHearingRequest>(r => r.Dates.All(d => expectedDates.Contains(d)))), + It.Is<CloneHearingRequestV2>(r => r.Dates.All(d => expectedDates.Contains(d)))), Times.Exactly(1)); } diff --git a/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/SearchForAudioRecordedHearingsTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/SearchForAudioRecordedHearingsTests.cs index b2e12b1c4..3a2eb413b 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/SearchForAudioRecordedHearingsTests.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/SearchForAudioRecordedHearingsTests.cs @@ -6,12 +6,11 @@ using System.Net; using System.Threading.Tasks; using BookingsApi.Client; -using BookingsApi.Contract.V1.Enums; -using BookingsApi.Contract.V1.Responses; using Autofac.Extras.Moq; +using BookingsApi.Contract.V1.Responses; +using BookingsApi.Contract.V2.Enums; +using BookingsApi.Contract.V2.Responses; using VideoApi.Contract.Responses; -using CaseResponse = BookingsApi.Contract.V1.Responses.CaseResponse; -using ParticipantResponse = BookingsApi.Contract.V1.Responses.ParticipantResponse; namespace AdminWebsite.UnitTests.Controllers.HearingsController { @@ -21,7 +20,7 @@ public class SearchForAudioRecordedHearingsTests private AdminWebsite.Controllers.HearingsController _controller; private Guid _guid; - private HearingDetailsResponse _vhExistingHearing; + private HearingDetailsResponseV2 _vhExistingHearing; [SetUp] @@ -50,41 +49,32 @@ public void Setup() public void InitialiseHearing() { _guid = Guid.NewGuid(); - _vhExistingHearing = new HearingDetailsResponse + _vhExistingHearing = new HearingDetailsResponseV2() { - Cases = new List<CaseResponse> + Cases = new List<CaseResponseV2> { - new CaseResponse {Name = "BBC vs ITV", Number = "TX/12345/2019", IsLeadCase = false} + new CaseResponseV2 {Name = "BBC vs ITV", Number = "TX/12345/2019", IsLeadCase = false} }, - CaseTypeName = "Generic", + ServiceId = "Generic", CreatedBy = "CaseAdministrator", CreatedDate = DateTime.UtcNow, HearingRoomName = "Room 6.41D", - HearingTypeName = "Automated Test", HearingVenueName = "Manchester Civil and Family Justice Centre", Id = _guid, OtherInformation = "Any other information about the hearing", Participants = [ - new ParticipantResponse - { - CaseRoleName = "Judge", ContactEmail = "Judge.Lumb@hmcts.net", - DisplayName = "Judge Lumb", FirstName = "Judge", HearingRoleName = "Judge", - LastName = "Lumb", MiddleNames = string.Empty, TelephoneNumber = string.Empty, - Title = "Judge", Username = "Judge.Lumb@hmcts.net" - }, - - new ParticipantResponse + new ParticipantResponseV2 { - CaseRoleName = "Applicant", ContactEmail = "test.Applicant@hmcts.net", + ContactEmail = "test.Applicant@hmcts.net", DisplayName = "Test Applicant", FirstName = "Test", HearingRoleName = "Litigant in person", LastName = "Applicant", MiddleNames = string.Empty, TelephoneNumber = string.Empty, Title = "Mr", Username = "Test.Applicant@hmcts.net" }, - new ParticipantResponse + new ParticipantResponseV2 { - CaseRoleName = "Respondent", ContactEmail = "test.respondent@hmcts.net", + ContactEmail = "test.respondent@hmcts.net", DisplayName = "Test Respondent", FirstName = "Test", HearingRoleName = "Representative", LastName = "Respondent", MiddleNames = string.Empty, TelephoneNumber = string.Empty, Title = "Mr", Username = "Test.Respondent@hmcts.net" @@ -93,12 +83,12 @@ public void InitialiseHearing() ], ScheduledDateTime = DateTime.UtcNow.AddDays(10), ScheduledDuration = 60, - Status = BookingStatus.Booked, + Status = BookingStatusV2.Booked, UpdatedBy = string.Empty, UpdatedDate = DateTime.UtcNow }; - _mocker.Mock<IBookingsApiClient>().Setup(x => x.GetHearingDetailsByIdAsync(It.IsAny<Guid>())) + _mocker.Mock<IBookingsApiClient>().Setup(x => x.GetHearingDetailsByIdV2Async(It.IsAny<Guid>())) .ReturnsAsync(_vhExistingHearing); } diff --git a/AdminWebsite/AdminWebsite.UnitTests/Controllers/PersonController/GetPersonForUpdateByContactEmailTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Controllers/PersonController/GetPersonForUpdateByContactEmailTests.cs index 389a363af..45b7dd520 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Controllers/PersonController/GetPersonForUpdateByContactEmailTests.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Controllers/PersonController/GetPersonForUpdateByContactEmailTests.cs @@ -5,7 +5,7 @@ using AdminWebsite.Services; using AdminWebsite.UnitTests.Helper; using BookingsApi.Client; -using BookingsApi.Contract.V1.Responses; +using BookingsApi.Contract.V2.Responses; using FizzWare.NBuilder; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; @@ -36,9 +36,9 @@ public void Setup() public async Task should_return_ok_with_person() { var contactEmail = "john@hmcts.net"; - var person = Builder<PersonResponse>.CreateNew().Build(); + var person = Builder<PersonResponseV2>.CreateNew().Build(); _bookingsApiClient - .Setup(x => x.SearchForNonJudgePersonsByContactEmailAsync(contactEmail)) + .Setup(x => x.SearchForNonJudgePersonsByContactEmailV2Async(contactEmail)) .ReturnsAsync(person); var actionResult = await _controller.GetPersonForUpdateByContactEmail(contactEmail); @@ -53,7 +53,7 @@ public async Task should_return_status_code_from_bookings_api_exception() { var contactEmail = "john@hmcts.net"; _bookingsApiClient - .Setup(x => x.SearchForNonJudgePersonsByContactEmailAsync(contactEmail)) + .Setup(x => x.SearchForNonJudgePersonsByContactEmailV2Async(contactEmail)) .Throws(ClientException.ForBookingsAPI(HttpStatusCode.NotFound)); var actionResult = await _controller.GetPersonForUpdateByContactEmail(contactEmail); diff --git a/AdminWebsite/AdminWebsite.UnitTests/Controllers/PersonController/UpdatePersonDetailsTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Controllers/PersonController/UpdatePersonDetailsTests.cs index 7d4e30cc5..706a1c2f7 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Controllers/PersonController/UpdatePersonDetailsTests.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Controllers/PersonController/UpdatePersonDetailsTests.cs @@ -6,7 +6,7 @@ using AdminWebsite.Services; using AdminWebsite.UnitTests.Helper; using BookingsApi.Client; -using BookingsApi.Contract.V1.Requests; +using BookingsApi.Contract.V2.Requests; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; using UserApi.Contract.Responses; @@ -78,8 +78,8 @@ public async Task should_return_accepted_when_person_is_updated_successfully() { var actionResult = await _controller.UpdatePersonDetails(_personId, _payload); - actionResult.Result.Should().BeOfType<AcceptedResult>(); - var result = (AcceptedResult) actionResult.Result; + actionResult.Should().BeOfType<AcceptedResult>(); + var result = (AcceptedResult) actionResult; result.StatusCode.Should().Be((int) HttpStatusCode.Accepted); } @@ -92,8 +92,8 @@ public async Task should_return_status_code_from_user_api_exception() var actionResult = await _controller.UpdatePersonDetails(_personId, _payload); - actionResult.Result.Should().BeOfType<ObjectResult>(); - var result = (ObjectResult) actionResult.Result; + actionResult.Should().BeOfType<ObjectResult>(); + var result = (ObjectResult) actionResult; result.StatusCode.Should().Be((int) HttpStatusCode.NotFound); } @@ -101,13 +101,13 @@ public async Task should_return_status_code_from_user_api_exception() public async Task should_return_status_code_from_bookings_api_exception() { _bookingsApiClient - .Setup(x => x.UpdatePersonDetailsAsync(_personId, It.IsAny<UpdatePersonDetailsRequest>())) + .Setup(x => x.UpdatePersonDetailsV2Async(_personId, It.IsAny<UpdatePersonDetailsRequestV2>())) .Throws(ClientException.ForBookingsAPI(HttpStatusCode.NotFound)); var actionResult = await _controller.UpdatePersonDetails(_personId, _payload); - actionResult.Result.Should().BeOfType<ObjectResult>(); - var result = (ObjectResult) actionResult.Result; + actionResult.Should().BeOfType<ObjectResult>(); + var result = (ObjectResult) actionResult; result.StatusCode.Should().Be((int) HttpStatusCode.NotFound); } } diff --git a/AdminWebsite/AdminWebsite.UnitTests/Controllers/PersonsControllerTest.cs b/AdminWebsite/AdminWebsite.UnitTests/Controllers/PersonsControllerTest.cs index 14c476dd1..a85c66d36 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Controllers/PersonsControllerTest.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Controllers/PersonsControllerTest.cs @@ -1,15 +1,15 @@ -using FluentAssertions; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using System.Net; using System.Threading.Tasks; using System.Text.Encodings.Web; using AdminWebsite.UnitTests.Helper; using AdminWebsite.Configuration; -using AdminWebsite.Contracts.Responses; using AdminWebsite.Services; using BookingsApi.Client; using BookingsApi.Contract.V1.Requests; using BookingsApi.Contract.V1.Responses; +using BookingsApi.Contract.V2.Requests; +using BookingsApi.Contract.V2.Responses; using Microsoft.Extensions.Options; namespace AdminWebsite.UnitTests.Controllers @@ -20,7 +20,7 @@ public class PersonsControllerTest private AdminWebsite.Controllers.PersonsController _controller; private Mock<IBookingsApiClient> _bookingsApiClient; private Mock<IUserAccountService> _userAccountService; - private List<PersonResponse> _response; + private List<PersonResponseV2> _response; [SetUp] public void Setup() @@ -35,9 +35,9 @@ public void Setup() _controller = new AdminWebsite.Controllers.PersonsController(_bookingsApiClient.Object, JavaScriptEncoder.Default, Options.Create(testSettings), _userAccountService.Object); - _response = new List<PersonResponse> + _response = new List<PersonResponseV2> { - new PersonResponse + new PersonResponseV2 { Id = Guid.NewGuid(), ContactEmail = "adoman@hmcts.net", @@ -55,7 +55,7 @@ public void Setup() public async Task Should_return_searched_participants() { // Arrange - var additionalParticipantToReturn = new PersonResponse + var additionalParticipantToReturn = new PersonResponseV2 { Id = Guid.NewGuid(), ContactEmail = "jackfilter@hmcts.net", @@ -70,13 +70,13 @@ public async Task Should_return_searched_participants() var searchTerm = "ado"; - var expectedResponse = new List<PersonResponse> + var expectedResponse = new List<PersonResponseV2> { _response[0], additionalParticipantToReturn }; - _bookingsApiClient.Setup(x => x.PostPersonBySearchTermAsync(It.Is<SearchTermRequest>(searchTermRequest => searchTermRequest.Term == searchTerm))) + _bookingsApiClient.Setup(x => x.SearchForPersonV2Async(It.Is<SearchTermRequestV2>(searchTermRequest => searchTermRequest.Term == searchTerm))) .ReturnsAsync(_response); @@ -86,7 +86,7 @@ public async Task Should_return_searched_participants() // Assert var okObjectResult = result.Result.Should().BeAssignableTo<OkObjectResult>().Which; okObjectResult.Value.Should().BeEquivalentTo(expectedResponse); - _bookingsApiClient.Verify(x => x.PostPersonBySearchTermAsync(It.Is<SearchTermRequest>(request => request.Term == searchTerm)), Times.Once); + _bookingsApiClient.Verify(x => x.SearchForPersonV2Async(It.Is<SearchTermRequestV2>(request => request.Term == searchTerm)), Times.Once); } @@ -96,7 +96,7 @@ public async Task Should_return_searched_participants() public async Task Should_filter_TestUsernameStem() { // Arrange - var participantToFilter = new PersonResponse + var participantToFilter = new PersonResponseV2 { Id = Guid.NewGuid(), ContactEmail = "jackfilter@hmcts.net1", @@ -111,12 +111,12 @@ public async Task Should_filter_TestUsernameStem() var searchTerm = "ado"; - var expectedResponse = new List<PersonResponse> + var expectedResponse = new List<PersonResponseV2> { _response[0] }; - _bookingsApiClient.Setup(x => x.PostPersonBySearchTermAsync(It.Is<SearchTermRequest>(searchTermRequest => searchTermRequest.Term == searchTerm))) + _bookingsApiClient.Setup(x => x.SearchForPersonV2Async(It.Is<SearchTermRequestV2>(searchTermRequest => searchTermRequest.Term == searchTerm))) .ReturnsAsync(_response); // Act @@ -125,7 +125,7 @@ public async Task Should_filter_TestUsernameStem() // Assert var okObjectResult = result.Result.Should().BeAssignableTo<OkObjectResult>().Which; okObjectResult.Value.Should().BeEquivalentTo(expectedResponse); - _bookingsApiClient.Verify(x => x.PostPersonBySearchTermAsync(It.Is<SearchTermRequest>(request => request.Term == searchTerm)), Times.Once); + _bookingsApiClient.Verify(x => x.SearchForPersonV2Async(It.Is<SearchTermRequestV2>(request => request.Term == searchTerm)), Times.Once); } @@ -135,7 +135,7 @@ public async Task Should_pass_on_bad_request_from_bookings_api() _bookingsApiClient.Setup(x => x.PostJudiciaryPersonBySearchTermAsync(It.IsAny<SearchTermRequest>())) .ReturnsAsync(new List<JudiciaryPersonResponse>()); - _bookingsApiClient.Setup(x => x.PostPersonBySearchTermAsync(It.IsAny<SearchTermRequest>())) + _bookingsApiClient.Setup(x => x.SearchForPersonV2Async(It.IsAny<SearchTermRequestV2>())) .ThrowsAsync(ClientException.ForBookingsAPI(HttpStatusCode.BadRequest)); var response = await _controller.PostPersonBySearchTerm("term"); @@ -148,7 +148,7 @@ public void Should_pass_on_exception_request_from_bookings_api() _bookingsApiClient.Setup(x => x.PostJudiciaryPersonBySearchTermAsync(It.IsAny<SearchTermRequest>())) .ReturnsAsync(new List<JudiciaryPersonResponse>()); - _bookingsApiClient.Setup(x => x.PostPersonBySearchTermAsync(It.IsAny<SearchTermRequest>())) + _bookingsApiClient.Setup(x => x.SearchForPersonV2Async(It.IsAny<SearchTermRequestV2>())) .ThrowsAsync(ClientException.ForBookingsAPI(HttpStatusCode.InternalServerError)); Assert.ThrowsAsync<BookingsApiException>(() => _controller.PostPersonBySearchTerm("term")); } diff --git a/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingRolesControllerTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Controllers/ReferenceData/HearingRolesControllerTests.cs similarity index 94% rename from AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingRolesControllerTests.cs rename to AdminWebsite/AdminWebsite.UnitTests/Controllers/ReferenceData/HearingRolesControllerTests.cs index f707ae1bf..a0248e9a4 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingRolesControllerTests.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Controllers/ReferenceData/HearingRolesControllerTests.cs @@ -1,11 +1,11 @@ using System.Threading; using System.Threading.Tasks; -using AdminWebsite.Controllers; +using AdminWebsite.Controllers.ReferenceData; using AdminWebsite.Services; using BookingsApi.Contract.V2.Responses; using Microsoft.AspNetCore.Mvc; -namespace AdminWebsite.UnitTests.Controllers +namespace AdminWebsite.UnitTests.Controllers.ReferenceData { public class HearingRolesControllerTests { diff --git a/AdminWebsite/AdminWebsite.UnitTests/Controllers/ReferenceData/HearingTypesControllerTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Controllers/ReferenceData/HearingTypesControllerTests.cs deleted file mode 100644 index 7a97e8647..000000000 --- a/AdminWebsite/AdminWebsite.UnitTests/Controllers/ReferenceData/HearingTypesControllerTests.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System.Threading; -using System.Threading.Tasks; -using AdminWebsite.Controllers.ReferenceData; -using AdminWebsite.Security; -using AdminWebsite.Services; -using Autofac.Extras.Moq; -using BookingsApi.Contract.V1.Responses; -using Microsoft.AspNetCore.Mvc; -using HearingTypeResponse = BookingsApi.Contract.V1.Responses.HearingTypeResponse; - -namespace AdminWebsite.UnitTests.Controllers.ReferenceData -{ - public class HearingTypesControllerTests - { - private Mock<IReferenceDataService> _referenceDataServiceMock; - private Mock<IUserIdentity> _userIdentityMock; - private HearingTypesController _controller; - private AutoMock _mocker; - - [SetUp] - public void Setup() - { - _mocker = AutoMock.GetLoose(); - _userIdentityMock = _mocker.Mock<IUserIdentity>(); - _referenceDataServiceMock = _mocker.Mock<IReferenceDataService>(); - _controller = _mocker.Create<HearingTypesController>(); - } - - [Test] - public async Task Should_return_all_hearing_types_and_case_types_where_hearing_type_is_empty() - { - // Arrange - var includeDeleted = true; - _userIdentityMock.Setup(x => x.IsATeamLead()) - .Returns(true); - _referenceDataServiceMock.Setup(x => - x.GetNonDeletedCaseTypesAsync(It.IsAny<CancellationToken>())) - .ReturnsAsync(GetCaseTypesList()); - - // Act - var result = await _controller.GetHearingTypes(includeDeleted); - - // Assert - var okObjectResult = result.Result.Should().BeAssignableTo<OkObjectResult>().Which; - okObjectResult.Value.Should().BeEquivalentTo(GetHearingTypes()); - } - - private static List<CaseTypeResponse> GetCaseTypesList() - { - return new List<CaseTypeResponse> - { - new () - { - Id = 1, Name = "type1", ServiceId = "AA1", - HearingTypes = new List<HearingTypeResponse>() - { - new () {Id = 10, Name = "HType10", Code = "Code10"}, - } - }, - new() - { - Id = 2, Name = "type2", ServiceId = "AA2", - HearingTypes = new List<HearingTypeResponse>() - { - new () {Id = 20, Name = "HType20", Code = "Code20"}, - } - }, - new() - { - Id = 3, Name = "type3", ServiceId = "AA3", - HearingTypes = new List<HearingTypeResponse>() - { - new () {Id = 25, Name = "HType25", Code = "Code25"}, - new () {Id = 29, Name = "HType29", Code = "Code29"}, - } - }, - new() - { - Id = 4, Name = "type4", ServiceId = "AA4", - HearingTypes = new List<HearingTypeResponse>() - } - }; - } - - private static List<AdminWebsite.Contracts.Responses.HearingTypeResponse> GetHearingTypes() - { - var result = new List<AdminWebsite.Contracts.Responses.HearingTypeResponse>() - { - new () {Id = 10, Name = "HType10", Group = "type1", ServiceId = "AA1", Code = "Code10"}, - new () {Id = 20, Name = "HType20", Group = "type2", ServiceId = "AA2", Code = "Code20"}, - new () {Id = 25, Name = "HType25", Group = "type3", ServiceId = "AA3", Code = "Code25"}, - new () {Id = 29, Name = "HType29", Group = "type3", ServiceId = "AA3", Code = "Code29"}, - new () {Group = "type4", ServiceId = "AA4"}, - }; - return result; - } - } -} diff --git a/AdminWebsite/AdminWebsite.UnitTests/Controllers/ReferenceData/InterpreterLanguagesControllerTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Controllers/ReferenceData/InterpreterLanguagesControllerTests.cs index f1e384e9c..bb3f65db8 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Controllers/ReferenceData/InterpreterLanguagesControllerTests.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Controllers/ReferenceData/InterpreterLanguagesControllerTests.cs @@ -5,8 +5,8 @@ using AdminWebsite.Mappers; using AdminWebsite.Services; using Autofac.Extras.Moq; -using BookingsApi.Contract.V1.Enums; -using BookingsApi.Contract.V1.Responses; +using BookingsApi.Contract.V2.Enums; +using BookingsApi.Contract.V2.Responses; using Microsoft.AspNetCore.Mvc; namespace AdminWebsite.UnitTests.Controllers.ReferenceData diff --git a/AdminWebsite/AdminWebsite.UnitTests/Controllers/ReferenceData/ParticipantRolesControllerTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Controllers/ReferenceData/ParticipantRolesControllerTests.cs deleted file mode 100644 index 3ea98173d..000000000 --- a/AdminWebsite/AdminWebsite.UnitTests/Controllers/ReferenceData/ParticipantRolesControllerTests.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System.Linq; -using System.Threading.Tasks; -using AdminWebsite.Controllers.ReferenceData; -using AdminWebsite.Models; -using AdminWebsite.Security; -using Autofac.Extras.Moq; -using BookingsApi.Client; -using BookingsApi.Contract.Interfaces.Response; -using BookingsApi.Contract.V2.Responses; -using Microsoft.AspNetCore.Mvc; - -namespace AdminWebsite.UnitTests.Controllers.ReferenceData -{ - public class ParticipantRolesControllerTests - { - private Mock<IBookingsApiClient> _bookingsApiClientMock; - private Mock<IUserIdentity> _userIdentityMock; - private ParticipantRolesController _controller; - private AutoMock _mocker; - - [SetUp] - public void Setup() - { - _mocker = AutoMock.GetLoose(); - _bookingsApiClientMock = _mocker.Mock<IBookingsApiClient>(); - _userIdentityMock = _mocker.Mock<IUserIdentity>(); - _controller = _mocker.Create<ParticipantRolesController>(); - } - - [Test] - public async Task Should_return_participants_roles() - { - List<ICaseRoleResponse> listTypes; - listTypes = new List<ICaseRoleResponse> { new CaseRoleResponseV2 { Name = "type1" } }; - SetTestCase(listTypes); - - var response = await _controller.GetParticipantRoles("type1"); - response.Should().NotBeNull(); - var result = (OkObjectResult)response.Result; - var caseRoles = (List<CaseAndHearingRolesResponse>)result.Value; - caseRoles[0].Name.Should().Be("type1"); - caseRoles[0].HearingRoles.Should().NotBeNull(); - caseRoles[0].HearingRoles.Count().Should().Be(1); - caseRoles[0].HearingRoles.First().Name.Should().Be("type1"); - caseRoles[0].HearingRoles.First().UserRole.Should().Be("role1"); - } - - [Test] - public async Task Should_return_empty_list_of_participants_roles() - { - var listTypes = new List<ICaseRoleResponse>(); - SetTestCase(listTypes); - - var response = await _controller.GetParticipantRoles("type1"); - response.Should().NotBeNull(); - var result = (OkObjectResult)response.Result; - List<CaseAndHearingRolesResponse> caseRoles = (List<CaseAndHearingRolesResponse>)result.Value; - caseRoles.Count.Should().Be(0); - } - - [Test] - public async Task Should_return_empty_list_of_participants_roles_if_list_types_is_null() - { - List<ICaseRoleResponse> listTypes = null; - SetTestCase(listTypes); - - var response = await _controller.GetParticipantRoles("type1"); - response.Should().NotBeNull(); - var result = (OkObjectResult)response.Result; - List<CaseAndHearingRolesResponse> caseRoles = (List<CaseAndHearingRolesResponse>)result.Value; - caseRoles.Count.Should().Be(0); - } - - private void SetTestCase(List<ICaseRoleResponse> listTypes) - { - var listHearingRoles2 = new List<HearingRoleResponseV2> { new HearingRoleResponseV2 { Name = "type1", UserRole = "role1"} }; - - _userIdentityMock.Setup(x => x.GetAdministratorCaseTypes()).Returns(new List<string> { "type1", "type2" }); - - //v2 endpoints - var casetypeV2Response = listTypes?.Select(e => (CaseRoleResponseV2)e).ToList(); - _bookingsApiClientMock.Setup(x => x.GetCaseRolesForCaseServiceAsync(It.IsAny<string>())).ReturnsAsync(casetypeV2Response); - _bookingsApiClientMock.Setup(x => x.GetHearingRolesForCaseRoleV2Async(It.IsAny<string>(), It.IsAny<string>())).ReturnsAsync(listHearingRoles2); - - } - } -} diff --git a/AdminWebsite/AdminWebsite.UnitTests/Controllers/WorkAllocationController/GetUnallocatedHearingsTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Controllers/WorkAllocationController/GetUnallocatedHearingsTests.cs index 7420ccc0e..f1d133f35 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Controllers/WorkAllocationController/GetUnallocatedHearingsTests.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Controllers/WorkAllocationController/GetUnallocatedHearingsTests.cs @@ -2,10 +2,9 @@ using AdminWebsite.Contracts.Responses; using Autofac.Extras.Moq; using BookingsApi.Client; -using BookingsApi.Contract.V1.Responses; +using BookingsApi.Contract.V2.Responses; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using HearingDetailsResponse = BookingsApi.Contract.V1.Responses.HearingDetailsResponse; namespace AdminWebsite.UnitTests.Controllers.WorkAllocationController; @@ -25,8 +24,8 @@ public void Setup() public async Task Should_get_unallocated_hearings() { // Arrange - _mocker.Mock<IBookingsApiClient>().Setup(client => client.GetUnallocatedHearingsAsync()) - .ReturnsAsync(new List<HearingDetailsResponse> {new ()}); + _mocker.Mock<IBookingsApiClient>().Setup(client => client.GetUnallocatedHearingsV2Async()) + .ReturnsAsync(new List<HearingDetailsResponseV2> {new ()}); // Act var response = await _controller.GetUnallocatedHearings(); @@ -41,8 +40,8 @@ public async Task Should_get_unallocated_hearings() public async Task Should_try_get_unallocated_hearings_and_return_empty_list() { // Arrange - _mocker.Mock<IBookingsApiClient>().Setup(client => client.GetUnallocatedHearingsAsync()) - .ReturnsAsync(new List<HearingDetailsResponse>()); + _mocker.Mock<IBookingsApiClient>().Setup(client => client.GetUnallocatedHearingsV2Async()) + .ReturnsAsync(new List<HearingDetailsResponseV2>()); // Act var response = await _controller.GetUnallocatedHearings(); diff --git a/AdminWebsite/AdminWebsite.UnitTests/Extensions/HearingDetailsResponseExtensionsTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Extensions/HearingDetailsResponseExtensionsTests.cs index eb2644421..3994db2d0 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Extensions/HearingDetailsResponseExtensionsTests.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Extensions/HearingDetailsResponseExtensionsTests.cs @@ -1,247 +1,43 @@ -using AdminWebsite.Extensions; -using AdminWebsite.Models; -using FizzWare.NBuilder; using AdminWebsite.Contracts.Responses; -using VideoApi.Contract.Enums; +using AdminWebsite.Extensions; namespace AdminWebsite.UnitTests.Extensions { public class HearingDetailsResponseExtensionsTests { - private HearingDetailsResponse _hearing; - - [SetUp] - public void Setup() - { - _hearing = new HearingDetailsResponse - { - Id = Guid.NewGuid(), - Participants = new List<ParticipantResponse>() - }; - } - - [Test] - public void Should_Return_True_If_Judge_Phone_Exists() - { - var otherInfo = new OtherInformationDetails { JudgePhone = "1234564978" }; - _hearing.OtherInformation = otherInfo.ToOtherInformationString(); - - _hearing.DoesJudgePhoneExist().Should().BeTrue(); - } - - [Test] - public void Should_Return_False_If_Judge_Phone_Does_Not_Exist() - { - _hearing.DoesJudgePhoneExist().Should().BeFalse(); - } - - [Test] - public void Should_Return_True_If_Judge_Email_Exists() - { - var otherInfo = new OtherInformationDetails { JudgeEmail = "judge@hmcts.net" }; - _hearing.OtherInformation = otherInfo.ToOtherInformationString(); - - _hearing.DoesJudgeEmailExist().Should().BeTrue(); - } - - [Test] - public void Should_Return_False_If_Judge_Email_Does_Not_Exist() - { - _hearing.DoesJudgeEmailExist().Should().BeFalse(); - } - - [Test] - public void Should_Return_False_If_Judge_Email_is_empty() - { - var otherInfo = new OtherInformationDetails { JudgeEmail = "" }; - _hearing.OtherInformation = otherInfo.ToOtherInformationString(); - _hearing.DoesJudgeEmailExist().Should().BeFalse(); - } - - [Test] - public void Should_Return_False_If_Judge_Email_is_null() - { - var otherInfo = new OtherInformationDetails { JudgeEmail = null }; - _hearing.OtherInformation = otherInfo.ToOtherInformationString(); - _hearing.DoesJudgeEmailExist().Should().BeFalse(); - } - - [Test] - public void Should_Return_False_If_OtherInformation_Is_Null_When_Comparing_Judge_Emails() - { - _hearing.HasJudgeEmailChanged(new HearingDetailsResponse { Id = Guid.NewGuid(), Participants = new List<ParticipantResponse>() }).Should().BeFalse(); - } - - [Test] - public void Should_Return_False_If_Judge_Has_Not_Changed_When_Comparing_Judge_Emails() - { - var otherInfo = new OtherInformationDetails { JudgeEmail = "judge@hmcts.net" }; - _hearing.OtherInformation = otherInfo.ToOtherInformationString(); - - var hearing2 = new HearingDetailsResponse { Id = Guid.NewGuid(), Participants = new List<ParticipantResponse>() }; - var hearing2OtherInfo = new OtherInformationDetails { JudgeEmail = "judge@hmcts.net" }; - hearing2.OtherInformation = hearing2OtherInfo.ToOtherInformationString(); - - _hearing.HasJudgeEmailChanged(hearing2).Should().BeFalse(); - } - - [Test] - public void Should_Return_True_If_Judge_Has_Changed_When_Comparing_Judge_Emails() - { - var otherInfo = new OtherInformationDetails { JudgeEmail = "judge@hmcts.net" }; - _hearing.OtherInformation = otherInfo.ToOtherInformationString(); - - var hearing2 = new HearingDetailsResponse { Id = Guid.NewGuid(), Participants = new List<ParticipantResponse>() }; - var hearing2OtherInfo = new OtherInformationDetails { JudgeEmail = "judge2@hmcts.net" }; - hearing2.OtherInformation = hearing2OtherInfo.ToOtherInformationString(); - - _hearing.HasJudgeEmailChanged(hearing2).Should().BeTrue(); - } [Test] - public void Should_Return_False_If_Judge_Has_Changed_When_Comparing_Generic_Hearing_Judges() + public void HasScheduleAmended__True_WhenDatesHaveChanged() { - _hearing.CaseTypeName = "Generic"; - var existingJudge = Builder<ParticipantResponse>.CreateNew() - .With(x => x.UserRoleName = UserRole.Judge.ToString()) - .With(x => x.Username = "old@judge.com") - .Build(); - _hearing.Participants.Add(existingJudge); - - var newJudge = Builder<ParticipantResponse>.CreateNew() - .With(x => x.Id = Guid.NewGuid()) - .With(x => x.UserRoleName = UserRole.Judge.ToString()) - .With(x => x.ContactEmail = "new@judge.com") - .Build(); - - var updatedHearing = new HearingDetailsResponse + var hearing = new HearingDetailsResponse { - Id = _hearing.Id, - Participants = new List<ParticipantResponse> { newJudge } + ScheduledDateTime = DateTime.UtcNow }; - - _hearing.JudgeHasNotChangedForGenericHearing(updatedHearing).Should().BeFalse(); - } - [Test] - public void Should_Return_True_If_Judge_Has_Changed_When_Comparing_Non_Generic_Hearing_Judges() - { - _hearing.CaseTypeName = "Unit Test"; - var existingJudge = Builder<ParticipantResponse>.CreateNew() - .With(x => x.UserRoleName = UserRole.Judge.ToString()) - .With(x => x.Username = "old@judge.com") - .Build(); - _hearing.Participants.Add(existingJudge); - - var newJudge = Builder<ParticipantResponse>.CreateNew() - .With(x => x.Id = Guid.NewGuid()) - .With(x => x.UserRoleName = UserRole.Judge.ToString()) - .With(x => x.ContactEmail = "new@judge.com") - .Build(); - - var updatedHearing = new HearingDetailsResponse + var anotherHearing = new HearingDetailsResponse { - Id = _hearing.Id, - Participants = new List<ParticipantResponse> { newJudge } + ScheduledDateTime = DateTime.UtcNow.AddHours(1) }; - - _hearing.JudgeHasNotChangedForGenericHearing(updatedHearing).Should().BeTrue(); + + var result = hearing.HasScheduleAmended(anotherHearing); + + result.Should().BeTrue(); } + [Test] - public void Should_Return_True_If_Judge_Has_Not_Changed_When_Comparing_Generic_Hearing_Judges() + public void HasScheduleAmended__False_WhenDatesAreTheSame() { - _hearing.CaseTypeName = "Generic"; - var existingJudge = Builder<ParticipantResponse>.CreateNew() - .With(x => x.UserRoleName = UserRole.Judge.ToString()) - .With(x => x.Username = "old@judge.com") - .Build(); - _hearing.Participants.Add(existingJudge); - - var newJudge = Builder<ParticipantResponse>.CreateNew() - .With(x => x.Id = existingJudge.Id) - .With(x => x.UserRoleName = UserRole.Judge.ToString()) - .With(x => x.ContactEmail = "new@judge.com") - .Build(); - - var updatedHearing = new HearingDetailsResponse + var now = DateTime.UtcNow; + var hearing = new HearingDetailsResponse { - Id = _hearing.Id, - Participants = new List<ParticipantResponse> { newJudge } + ScheduledDateTime = now }; - - _hearing.JudgeHasNotChangedForGenericHearing(updatedHearing).Should().BeTrue(); - } - - [Test] - public void Should_return_true_when_ejud_email_has_been_assigned_from_no_judge() - { - var judge = Builder<ParticipantResponse>.CreateNew() - .With(x => x.UserRoleName = UserRole.Judge.ToString()) - .With(x => x.Username = "new@judiciaryejud.com") - .Build(); - var newHearing = new HearingDetailsResponse - { - Id = Guid.NewGuid(), - Participants = new List<ParticipantResponse> { judge } - }; - _hearing.HasJudgeEmailChanged(newHearing).Should().BeTrue(); - } - - [Test] - public void Should_return_true_when_ejud_email_has_changed_to_another_ejud() - { - var existingEJudJudge = Builder<ParticipantResponse>.CreateNew() - .With(x => x.UserRoleName = UserRole.Judge.ToString()) - .With(x => x.Username = "old@judiciaryejud.com") - .Build(); - _hearing.Participants.Add(existingEJudJudge); - - var newEJudJudge = Builder<ParticipantResponse>.CreateNew() - .With(x => x.UserRoleName = UserRole.Judge.ToString()) - .With(x => x.ContactEmail = "new@judiciaryejud.com") - .Build(); - var newHearing = new HearingDetailsResponse - { - Id = Guid.NewGuid(), - Participants = new List<ParticipantResponse> { newEJudJudge } - }; - _hearing.HasJudgeEmailChanged(newHearing).Should().BeTrue(); - } - - [Test] - public void Should_return_true_when_ejud_email_has_changed_to_vh_judge() - { - var otherInfo = new OtherInformationDetails { JudgeEmail = "judge@hmcts.net" }; - _hearing.OtherInformation = otherInfo.ToOtherInformationString(); - - var newEJudJudge = Builder<ParticipantResponse>.CreateNew() - .With(x => x.UserRoleName = UserRole.Judge.ToString()) - .With(x => x.ContactEmail = "new@judiciaryejud.com") - .Build(); - var newHearing = new HearingDetailsResponse - { - Id = Guid.NewGuid(), - Participants = new List<ParticipantResponse> { newEJudJudge } - }; - _hearing.HasJudgeEmailChanged(newHearing).Should().BeTrue(); - } - - [Test] - public void Should_return_true_when_vh_judge_has_changed_to_ejud_judge() - { - var existingEJudJudge = Builder<ParticipantResponse>.CreateNew() - .With(x => x.UserRoleName = UserRole.Judge.ToString()) - .With(x => x.ContactEmail = "old@judiciaryejud.com") - .Build(); - _hearing.Participants.Add(existingEJudJudge); - - - var otherInfo = new OtherInformationDetails { JudgeEmail = "judge@hmcts.net" }; - var newHearing = new HearingDetailsResponse + var anotherHearing = new HearingDetailsResponse { - Id = Guid.NewGuid(), - Participants = new List<ParticipantResponse>(), - OtherInformation = otherInfo.ToOtherInformationString() + ScheduledDateTime = now }; - _hearing.HasJudgeEmailChanged(newHearing).Should().BeTrue(); + + var result = hearing.HasScheduleAmended(anotherHearing); + + result.Should().BeFalse(); } } } \ No newline at end of file diff --git a/AdminWebsite/AdminWebsite.UnitTests/Helper/HearingResponseBuilder.cs b/AdminWebsite/AdminWebsite.UnitTests/Helper/HearingResponseBuilder.cs deleted file mode 100644 index c23ba47d6..000000000 --- a/AdminWebsite/AdminWebsite.UnitTests/Helper/HearingResponseBuilder.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System.Linq; -using BookingsApi.Contract.V1.Responses; -using FizzWare.NBuilder; - -namespace AdminWebsite.UnitTests.Helper -{ - public static class HearingResponseBuilder - { - public static HearingDetailsResponse Build() - { - return Builder<HearingDetailsResponse>.CreateNew() - .With(x => x.Participants = new List<ParticipantResponse>()) - .With(x => x.Cases = new List<CaseResponse> { Builder<CaseResponse>.CreateNew().Build() }) - .Build(); - } - - public static HearingDetailsResponse WithEndPoints(this HearingDetailsResponse hearingDetailsResponse, int size) - { - var endPoints = Builder<EndpointResponse>.CreateListOfSize(size).Build().ToList(); - - hearingDetailsResponse.Endpoints = endPoints; - - return hearingDetailsResponse; - } - - public static HearingDetailsResponse WithParticipant(this HearingDetailsResponse hearingDetailsResponse, string userRoleName, string userName =null) - { - var participant = Builder<ParticipantResponse>.CreateNew() - .With(x => x.Id = Guid.NewGuid()) - .With(x => x.UserRoleName = userRoleName); - - if(!string.IsNullOrEmpty(userName)) - { - participant.With(x => x.Username = userName); - } - - hearingDetailsResponse.Participants.Add(participant.Build()); - - return hearingDetailsResponse; - } - - } -} diff --git a/AdminWebsite/AdminWebsite.UnitTests/Helper/HearingResponseV2Builder.cs b/AdminWebsite/AdminWebsite.UnitTests/Helper/HearingResponseV2Builder.cs index b3b92e121..b1a8a1d39 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Helper/HearingResponseV2Builder.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Helper/HearingResponseV2Builder.cs @@ -1,7 +1,4 @@ using System.Linq; -using BookingsApi.Contract.V1.Requests; -using BookingsApi.Contract.V1.Requests.Enums; -using BookingsApi.Contract.V1.Responses; using BookingsApi.Contract.V2.Enums; using BookingsApi.Contract.V2.Responses; using FizzWare.NBuilder; @@ -14,7 +11,7 @@ public static HearingDetailsResponseV2 Build() { return Builder<HearingDetailsResponseV2>.CreateNew() .With(x => x.Participants = new List<ParticipantResponseV2>()) - .With(x => x.JudiciaryParticipants = new List<JudiciaryParticipantResponse>()) + .With(x => x.JudicialOfficeHolders = new List<JudiciaryParticipantResponse>()) .With(x => x.Cases = new List<CaseResponseV2> { Builder<CaseResponseV2>.CreateNew().Build() }) .Build(); } @@ -45,7 +42,7 @@ public static HearingDetailsResponseV2 WithSupplier(this HearingDetailsResponseV public static HearingDetailsResponseV2 WithParticipant(this HearingDetailsResponseV2 hearingDetailsResponse, string userRoleName, string contactEmail =null) { - var judicialRoles = new string[] {"Judicial Office Holder", "Panel Member"}; + var judicialRoles = new[] {"Judicial Office Holder", "Panel Member"}; if (userRoleName == "Judge") { var joh = Builder<JudiciaryParticipantResponse>.CreateNew() @@ -62,7 +59,7 @@ public static HearingDetailsResponseV2 WithParticipant(this HearingDetailsRespon }) .Build(); - hearingDetailsResponse.JudiciaryParticipants.Add(joh); + hearingDetailsResponse.JudicialOfficeHolders.Add(joh); } else if (judicialRoles.Contains(userRoleName)) { @@ -79,7 +76,7 @@ public static HearingDetailsResponseV2 WithParticipant(this HearingDetailsRespon Value = "Spanish" }) .Build(); - hearingDetailsResponse.JudiciaryParticipants.Add(joh); + hearingDetailsResponse.JudicialOfficeHolders.Add(joh); } else { diff --git a/AdminWebsite/AdminWebsite.UnitTests/Mappers/BookingsHearingResponseMapperTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Mappers/BookingsHearingResponseMapperTests.cs index fb358fe0d..f820dd9cf 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Mappers/BookingsHearingResponseMapperTests.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Mappers/BookingsHearingResponseMapperTests.cs @@ -29,7 +29,6 @@ public void Should_map_all_properties_for_BookingsResponse_V1() ScheduledDateTime = DateTime.UtcNow, ScheduledDuration = 1, CaseTypeName = "caseTypeName", - HearingTypeName = "hearingTypeName", CourtRoom = "courtRoom", CourtAddress = "courtAddress", JudgeName = "judgeName", diff --git a/AdminWebsite/AdminWebsite.UnitTests/Mappers/EditMultiDayHearing/UpdateHearingParticipantsRequestV2MapperTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Mappers/EditMultiDayHearing/UpdateHearingParticipantsRequestV2MapperTests.cs index b49687f3d..75b3ef666 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Mappers/EditMultiDayHearing/UpdateHearingParticipantsRequestV2MapperTests.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Mappers/EditMultiDayHearing/UpdateHearingParticipantsRequestV2MapperTests.cs @@ -83,7 +83,6 @@ public void Should_map_participants_for_future_day_hearing() ContactEmail = "litigant@email.com", TelephoneNumber = "0845", DisplayName = "Litigant", - CaseRoleName = null, HearingRoleName = "Applicant", HearingRoleCode = "APPL", Representee = null, diff --git a/AdminWebsite/AdminWebsite.UnitTests/Mappers/EditParticipantRequestMapperTest.cs b/AdminWebsite/AdminWebsite.UnitTests/Mappers/EditParticipantRequestMapperTest.cs index 2e5f5560f..0b0394590 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Mappers/EditParticipantRequestMapperTest.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Mappers/EditParticipantRequestMapperTest.cs @@ -5,27 +5,6 @@ namespace AdminWebsite.UnitTests.Mappers { public class UpdateParticipantRequestMapperTest { - [Test] - public void Should_map_all_properties_for_update_participant_request() - { - var source = new EditParticipantRequest - { - Title = "mr", - DisplayName = "display name", - OrganisationName = "organisation", - TelephoneNumber = "01234567890", - Representee = "representee" - }; - - var result = UpdateParticipantRequestMapper.MapTo(source); - - result.Title.Should().Be(source.Title); - result.DisplayName.Should().Be(source.DisplayName); - result.OrganisationName.Should().Be(source.OrganisationName); - result.TelephoneNumber.Should().Be(source.TelephoneNumber); - result.Representee.Should().Be(source.Representee); - } - [Test] public void Should_map_all_properties_for_Update_participant_request_v2() { diff --git a/AdminWebsite/AdminWebsite.UnitTests/Mappers/EndpointResponseMapperTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Mappers/EndpointResponseMapperTests.cs index 98114039c..92505796e 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Mappers/EndpointResponseMapperTests.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Mappers/EndpointResponseMapperTests.cs @@ -1,9 +1,6 @@ -using AdminWebsite.Contracts.Responses; using AdminWebsite.Mappers; using AdminWebsite.UnitTests.Helper; -using BookingsApi.Contract.V1.Enums; using BookingsApi.Contract.V2.Enums; -using V1 = BookingsApi.Contract.V1.Responses; using V2 = BookingsApi.Contract.V2.Responses; namespace AdminWebsite.UnitTests.Mappers @@ -33,7 +30,7 @@ public void Should_map_v2() Sip = "Sip", Pin = "Pin", DefenceAdvocateId = Guid.NewGuid(), - InterpreterLanguage = new V1.InterpreterLanguagesResponse + InterpreterLanguage = new V2.InterpreterLanguagesResponse { Code = "spa", Value = "Spanish", diff --git a/AdminWebsite/AdminWebsite.UnitTests/Mappers/HearingDetailsResponseMapperTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Mappers/HearingDetailsResponseMapperTests.cs index b6f1d5511..b01a2a516 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Mappers/HearingDetailsResponseMapperTests.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Mappers/HearingDetailsResponseMapperTests.cs @@ -27,10 +27,8 @@ public void should_map_v2_model_to_hearing_detail_response() actual.Id.Should().Be(hearing.Id); actual.ScheduledDateTime.Should().Be(hearing.ScheduledDateTime); actual.ScheduledDuration.Should().Be(hearing.ScheduledDuration); - actual.HearingVenueName.Should().Be(hearing.HearingVenueName); actual.HearingVenueCode.Should().Be(hearing.HearingVenueCode); actual.ServiceId.Should().Be(hearing.ServiceId); - actual.CaseTypeName.Should().Be(hearing.ServiceName); actual.ConferenceSupplier.Should().Be(AdminWebsite.Contracts.Enums.VideoSupplier.Vodafone); actual.AllocatedToUsername.Should().Be(hearing.AllocatedToUsername); } diff --git a/AdminWebsite/AdminWebsite.UnitTests/Mappers/HearingUpdateRequestMapperTest.cs b/AdminWebsite/AdminWebsite.UnitTests/Mappers/HearingUpdateRequestMapperTest.cs index a38db53df..166e80bd4 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Mappers/HearingUpdateRequestMapperTest.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Mappers/HearingUpdateRequestMapperTest.cs @@ -1,6 +1,6 @@ using AdminWebsite.Mappers; using AdminWebsite.Models; -using BookingsApi.Contract.V1.Requests; +using BookingsApi.Contract.V2.Requests; namespace AdminWebsite.UnitTests.Mappers { @@ -9,7 +9,7 @@ public class HearingUpdateRequestMapperTest private EditHearingRequest _newParticipantRequest; private readonly string _username = "username"; private readonly DateTime _scheduledDateTime = new(2020, 12, 12, 8, 0, 0, DateTimeKind.Utc); - private readonly CaseRequest _caseRequest = new() {Name = "casename", Number = "casenumber"}; + private readonly CaseRequestV2 _caseRequest = new() {Name = "casename", Number = "casenumber"}; [SetUp] public void Setup() @@ -38,7 +38,7 @@ public void Should_map_properties_for_update_hearing_request() result.OtherInformation.Should().Be(_newParticipantRequest.OtherInformation); // Create a collection for the expected cases - var expectedCases = new List<CaseRequest> { _caseRequest }; + var expectedCases = new List<CaseRequestV2> { _caseRequest }; result.Cases.Should().BeEquivalentTo(expectedCases); result.AudioRecordingRequired.Should().Be(_newParticipantRequest.AudioRecordingRequired); diff --git a/AdminWebsite/AdminWebsite.UnitTests/Mappers/JudiciaryParticipantRequestMapperTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Mappers/JudiciaryParticipantRequestMapperTests.cs index c083f6bf1..e89f464b5 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Mappers/JudiciaryParticipantRequestMapperTests.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Mappers/JudiciaryParticipantRequestMapperTests.cs @@ -1,6 +1,6 @@ using AdminWebsite.Contracts.Requests; using AdminWebsite.Mappers; -using BookingsApi.Contract.V1.Requests.Enums; +using BookingsApi.Contract.V2.Enums; namespace AdminWebsite.UnitTests.Mappers { @@ -21,7 +21,7 @@ public void Should_map_to_v1() }; // Act - var result = request.MapToV1(); + var result = request.MapToV2(); // Assert result.DisplayName.Should().Be(request.DisplayName); diff --git a/AdminWebsite/AdminWebsite.UnitTests/Mappers/JudiciaryParticipantResponseMapperTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Mappers/JudiciaryParticipantResponseMapperTests.cs index a48794892..a7e735c13 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Mappers/JudiciaryParticipantResponseMapperTests.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Mappers/JudiciaryParticipantResponseMapperTests.cs @@ -1,7 +1,6 @@ using AdminWebsite.Mappers; -using BookingsApi.Contract.V1.Enums; -using BookingsApi.Contract.V1.Requests.Enums; -using V1 = BookingsApi.Contract.V1.Responses; +using BookingsApi.Contract.V2.Enums; +using V2 = BookingsApi.Contract.V2.Responses; namespace AdminWebsite.UnitTests.Mappers { @@ -11,7 +10,7 @@ public class JudiciaryParticipantResponseMapperTests public void Should_map_response() { // Arrange - var response = new V1.JudiciaryParticipantResponse + var response = new V2.JudiciaryParticipantResponse { Email = "email@email.com", Title = "Title", @@ -22,7 +21,7 @@ public void Should_map_response() HearingRoleCode = JudiciaryParticipantHearingRoleCode.Judge, WorkPhone = "1234", DisplayName = "DisplayName", - InterpreterLanguage = new V1.InterpreterLanguagesResponse + InterpreterLanguage = new V2.InterpreterLanguagesResponse { Code = "spa", Value = "Spanish", @@ -52,7 +51,7 @@ public void Should_map_response() public void Should_map_response_without_interpreter_language() { // Arrange - var response = new V1.JudiciaryParticipantResponse + var response = new V2.JudiciaryParticipantResponse { Email = "email@email.com", Title = "Title", diff --git a/AdminWebsite/AdminWebsite.UnitTests/Mappers/NewParticipantRequestMapperTest.cs b/AdminWebsite/AdminWebsite.UnitTests/Mappers/NewParticipantRequestMapperTest.cs index 5583f6458..145631200 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Mappers/NewParticipantRequestMapperTest.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Mappers/NewParticipantRequestMapperTest.cs @@ -5,35 +5,6 @@ namespace AdminWebsite.UnitTests.Mappers { public class NewParticipantRequestMapperTest { - [Test] - public void Should_map_all_properties_for_new_participant_request() - { - var source = new EditParticipantRequest(); - source.CaseRoleName = "caserolename"; - source.ContactEmail = "contactemail"; - source.DisplayName = "displayname"; - source.FirstName = "firstname"; - source.LastName = "lastname"; - source.MiddleNames = "middle name"; - source.Representee = "representee"; - source.TelephoneNumber = "01234567489"; - source.Title = "mr"; - source.OrganisationName = "organisation"; - - var result = NewParticipantRequestMapper.MapTo(source); - - result.CaseRoleName.Should().Be(source.CaseRoleName); - result.ContactEmail.Should().Be(source.ContactEmail); - result.DisplayName.Should().Be(source.DisplayName); - result.FirstName.Should().Be(source.FirstName); - result.LastName.Should().Be(source.LastName); - result.HearingRoleName.Should().Be(source.HearingRoleName); - result.MiddleNames.Should().Be(source.MiddleNames); - result.Representee.Should().Be(source.Representee); - result.TelephoneNumber.Should().Be(source.TelephoneNumber); - result.Title.Should().Be(source.Title); - result.OrganisationName.Should().Be(source.OrganisationName); - } [Test] public void Should_map_to_v2() diff --git a/AdminWebsite/AdminWebsite.UnitTests/Mappers/ParticipantResponseMapperTest.cs b/AdminWebsite/AdminWebsite.UnitTests/Mappers/ParticipantResponseMapperTest.cs index 85984b865..44e226106 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Mappers/ParticipantResponseMapperTest.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Mappers/ParticipantResponseMapperTest.cs @@ -1,64 +1,13 @@ using System.Diagnostics; -using AdminWebsite.Contracts.Responses; using AdminWebsite.Mappers; using AdminWebsite.UnitTests.Helper; -using BookingsApi.Contract.V1.Enums; using BookingsApi.Contract.V2.Enums; using BookingsApi.Contract.V2.Responses; -using V1 = BookingsApi.Contract.V1.Responses; namespace AdminWebsite.UnitTests.Mappers { public class ParticipantResponseMapperTest { - [Test] - public void Should_map_participant_response_V1() - { - var id = Guid.NewGuid(); - var participants = new List<V1.ParticipantResponse>(); - var participant = new V1.ParticipantResponse - { - FirstName = "Sam", - LastName = "Smith", - ContactEmail = "judge@personal.com", - HearingRoleName = "Judge", - DisplayName = "Display Name", - Id = id, - CaseRoleName = "Case Role Name", - UserRoleName = "Judge", - Title = "Title", - MiddleNames = "Middle Names", - TelephoneNumber = "01223445532", - Username = "UserName", - Organisation = "Pluto", - Representee = "Representee", - LinkedParticipants = new List<V1.LinkedParticipantResponse>(), - }; - participants.Add(participant); - - var participantsResponse = participants.Map(); - - foreach (var participantResponse in participantsResponse) - { - participantResponse.FirstName.Should().Be(participant.FirstName); - participantResponse.LastName.Should().Be(participant.LastName); - participantResponse.ContactEmail.Should().Be(participant.ContactEmail); - participantResponse.HearingRoleName.Should().Be(participant.HearingRoleName); - participantResponse.DisplayName.Should().Be(participant.DisplayName); - participantResponse.Id.Should().Be(participant.Id); - participantResponse.CaseRoleName.Should().Be(participant.CaseRoleName); - participantResponse.HearingRoleName.Should().Be(participant.HearingRoleName); - participantResponse.UserRoleName.Should().Be(participant.UserRoleName); - participantResponse.Title.Should().Be(participant.Title); - participantResponse.MiddleNames.Should().Be(participant.MiddleNames); - participantResponse.TelephoneNumber.Should().Be(participant.TelephoneNumber); - participantResponse.Username.Should().Be(participant.Username); - participantResponse.Organisation.Should().Be(participant.Organisation); - participantResponse.Representee.Should().Be(participant.Representee); - participantResponse.LinkedParticipants.Should().AllBeEquivalentTo(participant.LinkedParticipants); - } - } - [Test] public void Should_map_participant_response_V2() { @@ -94,7 +43,7 @@ public void Should_map_participant_response_V2() Username = "UserName", Organisation = "Pluto", Representee = "Representee", - InterpreterLanguage = new V1.InterpreterLanguagesResponse + InterpreterLanguage = new InterpreterLanguagesResponse { Code = "spa", Value = "Spanish", diff --git a/AdminWebsite/AdminWebsite.UnitTests/Mappers/UnallocatedHearingsForVHOMapperTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Mappers/UnallocatedHearingsForVHOMapperTests.cs index 89ad28deb..a55e71348 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Mappers/UnallocatedHearingsForVHOMapperTests.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Mappers/UnallocatedHearingsForVHOMapperTests.cs @@ -1,5 +1,5 @@ using AdminWebsite.Mappers; -using BookingsApi.Contract.V1.Responses; +using BookingsApi.Contract.V2.Responses; namespace AdminWebsite.UnitTests.Mappers; @@ -10,7 +10,7 @@ public class UnallocatedHearingsForVhoMapperTests [Test] public void Should_map_HearingDetailsResponse_to_UnallocatedHearingsForVHOResponse() { - var hearingDetailsResponse = new List<HearingDetailsResponse> + var hearingDetailsResponse = new List<HearingDetailsResponseV2> { new(){ ScheduledDateTime = _testDate //today @@ -49,7 +49,7 @@ public void Should_map_HearingDetailsResponse_to_UnallocatedHearingsForVHORespon [Test] public void Should_map_empty_HearingDetailsResponse_to_UnallocatedHearingsForVHOResponse() { - var hearingDetailsResponse = new List<HearingDetailsResponse>(); + var hearingDetailsResponse = new List<HearingDetailsResponseV2>(); var response = UnallocatedHearingsForVhoMapper.MapFrom(hearingDetailsResponse, _testDate); diff --git a/AdminWebsite/AdminWebsite.UnitTests/Mappers/UpdateParticipantRequestMapperTest.cs b/AdminWebsite/AdminWebsite.UnitTests/Mappers/UpdateParticipantRequestMapperTest.cs index 3210691a9..f5d4b55b6 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Mappers/UpdateParticipantRequestMapperTest.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Mappers/UpdateParticipantRequestMapperTest.cs @@ -1,5 +1,5 @@ using AdminWebsite.Mappers; -using BookingsApi.Contract.V1.Responses; +using BookingsApi.Contract.V2.Responses; namespace AdminWebsite.UnitTests.Mappers { @@ -8,7 +8,7 @@ public class EditParticipantRequestMapperTest [Test] public void Should_map_all_properties_for_Edit_participant_request() { - var source = new ParticipantResponse + var source = new ParticipantResponseV2 { Id = Guid.NewGuid(), Title = "Mr", @@ -18,7 +18,6 @@ public void Should_map_all_properties_for_Edit_participant_request() ContactEmail = "test@test.com", TelephoneNumber = "123", DisplayName = "test", - CaseRoleName = "test Case Role Name", HearingRoleName = "test Hearting Role Name", Representee = "test Re", Organisation = "test Or" @@ -32,7 +31,6 @@ public void Should_map_all_properties_for_Edit_participant_request() result.ContactEmail.Should().Be(source.ContactEmail); result.TelephoneNumber.Should().Be(source.TelephoneNumber); result.DisplayName.Should().Be(source.DisplayName); - result.CaseRoleName.Should().Be(source.CaseRoleName); result.HearingRoleName.Should().Be(source.HearingRoleName); result.Representee.Should().Be(source.Representee); result.OrganisationName.Should().Be(source.Organisation); diff --git a/AdminWebsite/AdminWebsite.UnitTests/Services/HearingServiceTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Services/HearingServiceTests.cs index b70709cfd..47760ae3b 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Services/HearingServiceTests.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Services/HearingServiceTests.cs @@ -4,13 +4,11 @@ using AdminWebsite.Services; using Autofac.Extras.Moq; using BookingsApi.Client; -using BookingsApi.Contract.V1.Requests; -using BookingsApi.Contract.V1.Responses; +using BookingsApi.Contract.V2.Requests; +using BookingsApi.Contract.V2.Responses; using FizzWare.NBuilder; using Microsoft.Extensions.Options; using VideoApi.Contract.Responses; -using CaseResponse = BookingsApi.Contract.V1.Responses.CaseResponse; -using ParticipantResponse = BookingsApi.Contract.V1.Responses.ParticipantResponse; namespace AdminWebsite.UnitTests.Services { @@ -18,7 +16,7 @@ public class HearingServiceTests { private const string ExpectedTeleConferencePhoneNumber = "expected_conference_phone_number"; private const string ExpectedTeleConferenceId = "expected_conference_phone_id"; - private HearingDetailsResponse _hearing; + private HearingDetailsResponseV2 _hearing; private AutoMock _mocker; private HearingsService _service; @@ -46,8 +44,8 @@ public void Setup() } }); _mocker.Mock<IBookingsApiClient>() - .Setup(c => c.GetHearingsByGroupIdAsync(It.IsAny<Guid>())) - .ReturnsAsync(new List<HearingDetailsResponse> { _hearing }); + .Setup(c => c.GetHearingsByGroupIdV2Async(It.IsAny<Guid>())) + .ReturnsAsync(new List<HearingDetailsResponseV2> { _hearing }); _service = _mocker.Create<HearingsService>(); _hearing = InitHearing(); @@ -96,54 +94,54 @@ public void Should_have_one_added_participant() [Test] public async Task Should_process_participants() { - var existingParticipants = new List<UpdateParticipantRequest>(); - var newParticipants = new List<ParticipantRequest>(); + var existingParticipants = new List<UpdateParticipantRequestV2>(); + var newParticipants = new List<ParticipantRequestV2>(); var removedParticipantIds = new List<Guid>(); - var linkedParticipants = new List<LinkedParticipantRequest>(); + var linkedParticipants = new List<LinkedParticipantRequestV2>(); _mocker.Mock<IBookingsApiClient>() - .Setup(x => x.GetHearingsByGroupIdAsync(_hearing.GroupId.Value)) - .ReturnsAsync(new List<HearingDetailsResponse> { _hearing }); + .Setup(x => x.GetHearingsByGroupIdV2Async(_hearing.GroupId.Value)) + .ReturnsAsync(new List<HearingDetailsResponseV2> { _hearing }); - await _service.ProcessParticipants(_hearing.Id, existingParticipants, newParticipants, removedParticipantIds, linkedParticipants); + await _service.ProcessParticipantsV2(_hearing.Id, existingParticipants, newParticipants, removedParticipantIds, linkedParticipants); _mocker.Mock<IBookingsApiClient>() .Verify( - x => x.UpdateHearingParticipantsAsync(_hearing.Id, It.Is<UpdateHearingParticipantsRequest>(x => - x.ExistingParticipants == existingParticipants - && x.NewParticipants == newParticipants - && x.RemovedParticipantIds == removedParticipantIds - && x.LinkedParticipants == linkedParticipants)), Times.Once); + x => x.UpdateHearingParticipantsV2Async(_hearing.Id, It.Is<UpdateHearingParticipantsRequestV2>(requestV2 => + requestV2.ExistingParticipants == existingParticipants + && requestV2.NewParticipants == newParticipants + && requestV2.RemovedParticipantIds == removedParticipantIds + && requestV2.LinkedParticipants == linkedParticipants)), Times.Once); } - private static HearingDetailsResponse InitHearing() + private static HearingDetailsResponseV2 InitHearing() { - var cases = new List<CaseResponse> { new CaseResponse { Name = "Test", Number = "123456" } }; - var rep = Builder<ParticipantResponse>.CreateNew() + var cases = new List<CaseResponseV2> { new() { Name = "Test", Number = "123456" } }; + var rep = Builder<ParticipantResponseV2>.CreateNew() .With(x => x.Id = Guid.NewGuid()) .With(x => x.UserRoleName = "Representative") .Build(); - var ind = Builder<ParticipantResponse>.CreateNew() + var ind = Builder<ParticipantResponseV2>.CreateNew() .With(x => x.Id = Guid.NewGuid()) .With(x => x.UserRoleName = "Individual") .Build(); - var joh = Builder<ParticipantResponse>.CreateNew() + var joh = Builder<ParticipantResponseV2>.CreateNew() .With(x => x.Id = Guid.NewGuid()) .With(x => x.UserRoleName = "Judicial Office Holder") .Build(); - var judge = Builder<ParticipantResponse>.CreateNew() + var judge = Builder<ParticipantResponseV2>.CreateNew() .With(x => x.Id = Guid.NewGuid()) .With(x => x.UserRoleName = "Judge") .With(x => x.ContactEmail = "Judge@court.com") .With(x => x.HearingRoleName = "Judge") .Build(); - var staffMember = Builder<ParticipantResponse>.CreateNew() + var staffMember = Builder<ParticipantResponseV2>.CreateNew() .With(x => x.Id = Guid.NewGuid()) .With(x => x.UserRoleName = "Staff Member") .Build(); - return Builder<HearingDetailsResponse>.CreateNew() - .With(h => h.Participants = new List<ParticipantResponse> { rep, ind, joh, judge, staffMember }) + return Builder<HearingDetailsResponseV2>.CreateNew() + .With(h => h.Participants = new List<ParticipantResponseV2> { rep, ind, joh, judge, staffMember }) .With(x => x.Cases = cases) .With(x => x.Id = Guid.NewGuid()) .Build(); diff --git a/AdminWebsite/AdminWebsite.UnitTests/Services/ReferenceDataServiceTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Services/ReferenceDataServiceTests.cs index 3ccdcb98b..f75681333 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Services/ReferenceDataServiceTests.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Services/ReferenceDataServiceTests.cs @@ -4,8 +4,8 @@ using Autofac; using Autofac.Extras.Moq; using BookingsApi.Client; -using BookingsApi.Contract.V1.Enums; using BookingsApi.Contract.V1.Responses; +using BookingsApi.Contract.V2.Enums; using BookingsApi.Contract.V2.Responses; using Microsoft.Extensions.Caching.Memory; @@ -33,8 +33,8 @@ public async Task Should_initialise_cache() .ReturnsAsync(new List<InterpreterLanguagesResponse>()); _mocker.Mock<IBookingsApiClient>().Setup(x => x.GetHearingVenuesAsync(true, It.IsAny<CancellationToken>())) .ReturnsAsync(new List<HearingVenueResponse>()); - _mocker.Mock<IBookingsApiClient>().Setup(x => x.GetCaseTypesAsync(false, It.IsAny<CancellationToken>())) - .ReturnsAsync(new List<CaseTypeResponse>()); + _mocker.Mock<IBookingsApiClient>().Setup(x => x.GetCaseTypesV2Async(false, It.IsAny<CancellationToken>())) + .ReturnsAsync(new List<CaseTypeResponseV2>()); _mocker.Mock<IBookingsApiClient>().Setup(x => x.GetHearingRolesAsync(It.IsAny<CancellationToken>())) .ReturnsAsync(new List<HearingRoleResponseV2>()); @@ -44,48 +44,34 @@ public async Task Should_initialise_cache() // assert _mocker.Mock<IBookingsApiClient>().Verify(x => x.GetAvailableInterpreterLanguagesAsync(It.IsAny<CancellationToken>()), Times.Once); _mocker.Mock<IBookingsApiClient>().Verify(x => x.GetHearingVenuesAsync(true, It.IsAny<CancellationToken>()), Times.Once); - _mocker.Mock<IBookingsApiClient>().Verify(x => x.GetCaseTypesAsync(false, It.IsAny<CancellationToken>()), Times.Once); + _mocker.Mock<IBookingsApiClient>().Verify(x => x.GetCaseTypesV2Async(false, It.IsAny<CancellationToken>()), Times.Once); _mocker.Mock<IBookingsApiClient>().Verify(x => x.GetHearingRolesAsync(It.IsAny<CancellationToken>()), Times.Once); } [Test] public async Task should_return_non_deleted_case_types() { - var caseTypes = new List<CaseTypeResponse> + var caseTypes = new List<CaseTypeResponseV2> { new () { - Id = 1, Name = "type1", ServiceId = "AA1", - HearingTypes = - [ - new() { Id = 10, Name = "HType10", Code = "Code10" } - ] + Id = 1, Name = "type1", ServiceId = "AA1" }, new() { Id = 2, Name = "type2", ServiceId = "AA2", - HearingTypes = - [ - new() { Id = 20, Name = "HType20", Code = "Code20" } - ] }, new() { Id = 3, Name = "type3", ServiceId = "AA3", - HearingTypes = - [ - new() { Id = 25, Name = "HType25", Code = "Code25" }, - new() { Id = 29, Name = "HType29", Code = "Code29" } - ] }, new() { - Id = 4, Name = "type4", ServiceId = "AA4", - HearingTypes = new List<HearingTypeResponse>() + Id = 4, Name = "type4", ServiceId = "AA4" } }; - _mocker.Mock<IBookingsApiClient>().Setup(x => x.GetCaseTypesAsync(false, It.IsAny<CancellationToken>())) + _mocker.Mock<IBookingsApiClient>().Setup(x => x.GetCaseTypesV2Async(false, It.IsAny<CancellationToken>())) .ReturnsAsync(caseTypes); // act diff --git a/AdminWebsite/AdminWebsite.UnitTests/TestParticipantRequest.cs b/AdminWebsite/AdminWebsite.UnitTests/TestParticipantRequest.cs deleted file mode 100644 index 2024a1f2c..000000000 --- a/AdminWebsite/AdminWebsite.UnitTests/TestParticipantRequest.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace AdminWebsite.UnitTests -{ - internal class TestParticipantRequest - { - public TestParticipantRequest() - { - } - - public string DisplayName { get; set; } - public string Email { get; set; } - public string FirstName { get; set; } - public string LastName { get; set; } - public string Phone { get; set; } - public string Role { get; set; } - public string Title { get; set; } - public string Username { get; set; } - } -} \ No newline at end of file diff --git a/AdminWebsite/AdminWebsite.UnitTests/Validators/CaseRequestValidationTest.cs b/AdminWebsite/AdminWebsite.UnitTests/Validators/CaseRequestValidationTest.cs deleted file mode 100644 index 51fcbc079..000000000 --- a/AdminWebsite/AdminWebsite.UnitTests/Validators/CaseRequestValidationTest.cs +++ /dev/null @@ -1,53 +0,0 @@ -using AdminWebsite.Validators; -using System.Linq; -using BookingsApi.Contract.V1.Requests; - -namespace AdminWebsite.UnitTests.Validators -{ - public class CaseRequestValidationTest - { - private CaseRequestValidation _validator; - - [SetUp] - public void SetUp() - { - _validator = new CaseRequestValidation(); - } - - [Test] - public void Should_validate_CaseNumber_and_name_with_length_greater_then_255_as_error() - { - const string CaseNumber_MESSAGE = "Case number is required between 1 - 255 characters"; - const string CaseName_MESSAGE = "Case name is required between 1 - 255 characters"; - - var longString = new String('a', 257); - var testRequest = new CaseRequest { Number = longString, Name=longString }; - var result = _validator.Validate(testRequest); - Assert.That(result.Errors.Exists(o => o.PropertyName == "Number" && o.ErrorMessage == CaseNumber_MESSAGE)); - Assert.That(result.Errors.Exists(o => o.PropertyName == "Name" && o.ErrorMessage == CaseName_MESSAGE)); - } - - [Test] - public void Should_validate_CaseNumber_and_name_with_length_zero_as_error() - { - var shortString = ""; - var testRequest = new CaseRequest { Number = shortString, Name = shortString }; - var result = _validator.Validate(testRequest); - Assert.That(result.Errors.TrueForAll(o => o.ErrorMessage.Contains("must not be empty."))); - Assert.That(result.Errors.Count == 2); - } - - [Test] - public void Should_validate_case_request() - { - var testRequest = new CaseRequest - { - Name = "case name", - Number = "case number 1" - }; - - var result = _validator.Validate(testRequest); - Assert.That(result.Errors.Count == 0); - } - } -} diff --git a/AdminWebsite/AdminWebsite.UnitTests/Validators/EditHearingRequestValidatorTest.cs b/AdminWebsite/AdminWebsite.UnitTests/Validators/EditHearingRequestValidatorTest.cs deleted file mode 100644 index 0e8cefdf2..000000000 --- a/AdminWebsite/AdminWebsite.UnitTests/Validators/EditHearingRequestValidatorTest.cs +++ /dev/null @@ -1,73 +0,0 @@ -using AdminWebsite.Models; -using AdminWebsite.Validators; -using System.Linq; -using AdminWebsite.Contracts.Requests; - -namespace AdminWebsite.UnitTests.Validators -{ - public class EditHearingRequestValidatorTest - { - private EditHearingRequestValidator _validator; - - [SetUp] - public void SetUp() - { - _validator = new EditHearingRequestValidator(); - } - - [Test] - public void Should_validate_participants_with_value_null_as_error() - { - const string PARTICIPANT_MSG = "Please provide at least one participant"; - - var testRequest = new EditHearingRequest { Participants = null }; - var result = _validator.Validate(testRequest); - ClassicAssert.That(result.Errors.Exists(o => o.PropertyName == "Participants" && o.ErrorMessage == PARTICIPANT_MSG)); - } - - [Test] - public void Should_validate_participants_with_empty_list_as_error() - { - const string PARTICIPANT_MSG = "Please provide at least one participant"; - - var testRequest = new EditHearingRequest { Participants = new List<EditParticipantRequest>() }; - var result = _validator.Validate(testRequest); - ClassicAssert.That(result.Errors.Exists(o => o.PropertyName == "Participants" && o.ErrorMessage == PARTICIPANT_MSG)); - } - - [Test] - public void Should_validate_participants_as_valid() - { - var testRequest = new EditHearingRequest { - Participants = new List<EditParticipantRequest> { new EditParticipantRequest() }, - Case = new EditCaseRequest(), - }; - var result = _validator.Validate(testRequest); - ClassicAssert.That(!result.Errors.Exists(o => o.PropertyName == "Participants")); - } - - [Test] - public void Should_validate_participants_as_valid_when_judiciary_participants_are_provided() - { - var testRequest = new EditHearingRequest { - JudiciaryParticipants = new List<JudiciaryParticipantRequest> { new() }, - Case = new EditCaseRequest(), - }; - var result = _validator.Validate(testRequest); - ClassicAssert.That(!result.Errors.Exists(o => o.PropertyName == "Participants")); - } - - [Test] - public void Should_validate_scheduled_date_time_as_error_when_time_is_thirty_minutes_or_more() - { - const string SCHEDLUED_TIME_MSG = "You can't edit a confirmed hearing within 30 minutes of it starting"; - - var testRequest = new EditHearingRequest - { - ScheduledDateTime = DateTime.Now.AddMinutes(30) - }; - var result = _validator.Validate(testRequest); - ClassicAssert.That(!result.Errors.Exists(o => o.ErrorMessage == SCHEDLUED_TIME_MSG)); - } - } -} diff --git a/AdminWebsite/AdminWebsite.UnitTests/Validators/ParticipantRequestValidationTest.cs b/AdminWebsite/AdminWebsite.UnitTests/Validators/ParticipantRequestValidationTest.cs deleted file mode 100644 index fd2ffb58c..000000000 --- a/AdminWebsite/AdminWebsite.UnitTests/Validators/ParticipantRequestValidationTest.cs +++ /dev/null @@ -1,73 +0,0 @@ -using AdminWebsite.Validators; -using System.Linq; - -namespace AdminWebsite.UnitTests.Validators -{ - public class ParticipantRequestValidationTest - { - private ParticipantRequestValidation _validator; - - [SetUp] - public void SetUp() - { - _validator = new ParticipantRequestValidation(); - } - - [Test] - public void Should_validate_fields_with_length_greater_then_255_as_error() - { - const string EMAIL_MSG = "Email is required in the correct format and between 1 - 255 characters"; - const string DisplayName_MSG = "Display name is required and between 1 - 255 characters"; - const string FirstName_MSG = "First name is required and between 1 - 255 characters"; - const string LASTNAME_MSG = "Lastname is required and between 1 - 255 characters"; - - - var longString = new String('a', 257); - var testRequest = new BookingsApi.Contract.V1.Requests.ParticipantRequest - { - ContactEmail = longString, - DisplayName = longString, - FirstName = longString, - LastName = longString - }; - - var result = _validator.Validate(testRequest); - Assert.That(result.Errors.Exists(o => o.PropertyName == "ContactEmail" && o.ErrorMessage == EMAIL_MSG)); - Assert.That(result.Errors.Exists(o => o.PropertyName == "DisplayName" && o.ErrorMessage == DisplayName_MSG)); - Assert.That(result.Errors.Exists(o => o.PropertyName == "FirstName" && o.ErrorMessage == FirstName_MSG)); - Assert.That(result.Errors.Exists(o => o.PropertyName == "LastName" && o.ErrorMessage == LASTNAME_MSG)); - - } - - [Test] - public void Should_validate_fields_with_length_zero_as_error() - { - var shortString = ""; - var testRequest = new BookingsApi.Contract.V1.Requests.ParticipantRequest - { - ContactEmail = shortString, - DisplayName = shortString, - FirstName = shortString, - LastName = shortString - }; - var result = _validator.Validate(testRequest); - Assert.That(result.Errors.Exists(o => o.ErrorMessage.Contains("must not be empty."))); - Assert.That(result.Errors.Count == 5); - } - - [Test] - public void Should_validate_participant_request() - { - var testRequest = new BookingsApi.Contract.V1.Requests.ParticipantRequest - { - ContactEmail = "aa@hmcts.net", - FirstName = "Adam", - LastName = "Adams", - DisplayName = "Adam" - }; - - var result = _validator.Validate(testRequest); - ClassicAssert.That(result.Errors.Count == 0); - } - } -} diff --git a/AdminWebsite/AdminWebsite.UnitTests/packages.lock.json b/AdminWebsite/AdminWebsite.UnitTests/packages.lock.json index c4eb576c3..ed601330c 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/packages.lock.json +++ b/AdminWebsite/AdminWebsite.UnitTests/packages.lock.json @@ -109,10 +109,20 @@ }, "BookingsApi.Client": { "type": "Transitive", - "resolved": "2.3.9", - "contentHash": "Bzwufird9sw4QpyCuJBQpcNDuAZXmZWCjLMdoYyFUDdRlJm1xE9uMXaaOyYK2FFPE5WfLAftC/o0nYhhSgFeiQ==", + "resolved": "3.1.9", + "contentHash": "szk1pTukvzHsprWASvwtdTvoHCbm5RC5Lnj1wYmSC+/I/s1uyoL7uLbauV2s84znk2xssLpol4N7Fyxl5wJGAw==", "dependencies": { - "Microsoft.AspNetCore.Mvc.Core": "2.2.5" + "BookingsApi.Common.DotNet6": "3.1.9", + "Microsoft.AspNetCore.Mvc.Core": "2.2.5", + "System.Text.Json": "8.0.5" + } + }, + "BookingsApi.Common.DotNet6": { + "type": "Transitive", + "resolved": "3.1.9", + "contentHash": "3rSoSlmcZw4+uxPIj+KpBAI6WjIk2ntsEGc75oGDD7fQM+qpEDCuIn4xSid1fcO6sdQ2Dkd/8/3c0k2dyL+yeg==", + "dependencies": { + "System.Text.Json": "8.0.5" } }, "Castle.Core": { @@ -851,8 +861,8 @@ }, "Microsoft.Identity.Client": { "type": "Transitive", - "resolved": "4.61.0", - "contentHash": "3TDPEie+9t/NgBhoNifLFwM6nkypYUa8GUHfMnkYtovDDTQM8bsS2KEIP5tAh28BgfJZgof/KlCEKvGxz0H3Eg==", + "resolved": "4.61.3", + "contentHash": "naJo/Qm35Caaoxp5utcw+R8eU8ZtLz2ALh8S+gkekOYQ1oazfCQMWVT4NJ/FnHzdIJlm8dMz0oMpMGCabx5odA==", "dependencies": { "Microsoft.IdentityModel.Abstractions": "6.35.0", "System.Diagnostics.DiagnosticSource": "6.0.1" @@ -1088,8 +1098,8 @@ }, "NotificationApi.Client": { "type": "Transitive", - "resolved": "2.3.4", - "contentHash": "BwxsCI+DORSasyvqktvdWt2jUJIrxwTgLDVx/3sOBDJkqMKJsn+glINBsQ7/kgyldaZningYYuasa3+JIFSVKA==", + "resolved": "3.0.5", + "contentHash": "UErWgWJUm2TEb9yqEHxIzaGr7AFcqnjqRLu8legaYNOMFd1WVzuKYEBzEdMM1x8gHjTLofcIAIaRUqUx0LIFLg==", "dependencies": { "Microsoft.AspNetCore.Mvc.Core": "2.2.5", "Newtonsoft.Json": "13.0.3" @@ -2101,8 +2111,8 @@ }, "System.Text.Json": { "type": "Transitive", - "resolved": "4.7.2", - "contentHash": "TcMd95wcrubm9nHvJEQs70rC0H/8omiSGGpU4FQ/ZA1URIqD4pjmFJh2Mfv1yH1eHgJDWTi2hMDXwTET+zOOyg==" + "resolved": "8.0.5", + "contentHash": "0f1B50Ss7rqxXiaBJyzUu9bWFOO2/zSlifZ/UNMdiIpDYe4cY4LQQicP4nirK1OS31I43rn062UIJ1Q9bpmHpg==" }, "System.Text.RegularExpressions": { "type": "Transitive", @@ -2210,18 +2220,18 @@ }, "VideoApi.Client": { "type": "Transitive", - "resolved": "2.2.26", - "contentHash": "tkKsLUUKliw5iPA8It+R/Fv+oKsCwdeQfWFWHVhU+/mfNG2bT89L9SHDvjqLIXawTV35pigCRuidPaYt641sow==", + "resolved": "3.1.7", + "contentHash": "l7/NvSybO0/k+rAg1jY78hjZrQ1v2P/qdmh75gJeK+tax3Ukwc0G6+QvKbvlbetzU1TjKf2GFrublKZ5h1OdMg==", "dependencies": { "Microsoft.AspNetCore.Mvc.Core": "2.2.5", - "Newtonsoft.Json": "13.0.3" + "System.Text.Json": "8.0.4" } }, "adminwebsite": { "type": "Project", "dependencies": { "AspNetCore.HealthChecks.Uris": "[8.0.1, )", - "BookingsApi.Client": "[2.3.9, )", + "BookingsApi.Client": "[3.1.9, )", "FluentValidation.AspNetCore": "[11.3.0, )", "LaunchDarkly.ServerSdk": "[8.5.0, )", "MicroElements.Swashbuckle.FluentValidation": "[6.0.0, )", @@ -2232,11 +2242,11 @@ "Microsoft.AspNetCore.SpaServices": "[3.1.32, )", "Microsoft.AspNetCore.SpaServices.Extensions": "[8.0.4, )", "Microsoft.Graph": "[5.52.0, )", - "Microsoft.Identity.Client": "[4.61.0, )", + "Microsoft.Identity.Client": "[4.61.3, )", "Microsoft.OpenApi": "[1.6.14, )", "Microsoft.VisualStudio.Azure.Containers.Tools.Targets": "[1.20.1, )", "NWebsec.AspNetCore.Middleware": "[3.0.0, )", - "NotificationApi.Client": "[2.3.4, )", + "NotificationApi.Client": "[3.0.5, )", "Polly": "[8.4.0, )", "Swashbuckle.AspNetCore": "[6.6.1, )", "Swashbuckle.AspNetCore.Annotations": "[6.6.1, )", @@ -2244,7 +2254,7 @@ "Swashbuckle.AspNetCore.Swagger": "[6.6.1, )", "TimeZoneConverter": "[6.1.0, )", "UserApi.Client": "[2.1.1, )", - "VideoApi.Client": "[2.2.26, )" + "VideoApi.Client": "[3.1.7, )" } }, "adminwebsite.testing.common": { diff --git a/AdminWebsite/AdminWebsite/AdminWebsite.csproj b/AdminWebsite/AdminWebsite/AdminWebsite.csproj index 5d0b0a5b1..8a323dde3 100644 --- a/AdminWebsite/AdminWebsite/AdminWebsite.csproj +++ b/AdminWebsite/AdminWebsite/AdminWebsite.csproj @@ -30,10 +30,10 @@ </PropertyGroup> <ItemGroup> <PackageReference Include="AspNetCore.HealthChecks.Uris" Version="8.0.1" /> - <PackageReference Include="BookingsApi.Client" Version="2.3.9" /> + <PackageReference Include="BookingsApi.Client" Version="3.1.9" /> <PackageReference Include="LaunchDarkly.ServerSdk" Version="8.5.0" /> <PackageReference Include="MicroElements.Swashbuckle.FluentValidation" Version="6.0.0" /> - <PackageReference Include="Microsoft.Identity.Client" Version="4.61.0" /> + <PackageReference Include="Microsoft.Identity.Client" Version="4.61.3" /> <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.1" /> <PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" /> <PackageReference Include="Microsoft.ApplicationInsights" Version="2.22.0" /> @@ -44,7 +44,7 @@ <PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="8.0.4" /> <PackageReference Include="Microsoft.Graph" Version="5.52.0" /> <PackageReference Include="Microsoft.OpenApi" Version="1.6.14" /> - <PackageReference Include="NotificationApi.Client" Version="2.3.4" /> + <PackageReference Include="NotificationApi.Client" Version="3.0.5" /> <PackageReference Include="NWebsec.AspNetCore.Middleware" Version="3.0.0" /> <PackageReference Include="Polly" Version="8.4.0" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.1" /> @@ -57,7 +57,7 @@ </PackageReference> <PackageReference Include="TimeZoneConverter" Version="6.1.0" /> <PackageReference Include="UserApi.Client" Version="2.1.1" /> - <PackageReference Include="VideoApi.Client" Version="2.2.26" /> + <PackageReference Include="VideoApi.Client" Version="3.1.7" /> </ItemGroup> <ItemGroup> diff --git a/AdminWebsite/AdminWebsite/Attributes/HearingInputSanitizerAttribute.cs b/AdminWebsite/AdminWebsite/Attributes/HearingInputSanitizerAttribute.cs index 63d2c5824..bc4033f5c 100644 --- a/AdminWebsite/AdminWebsite/Attributes/HearingInputSanitizerAttribute.cs +++ b/AdminWebsite/AdminWebsite/Attributes/HearingInputSanitizerAttribute.cs @@ -2,7 +2,7 @@ using AdminWebsite.Models; using Microsoft.AspNetCore.Mvc.Filters; using System.Text.RegularExpressions; -using BookingsApi.Contract.V1.Requests; +using BookingsApi.Contract.V2.Requests; namespace AdminWebsite.Attributes { @@ -15,9 +15,8 @@ public override void OnActionExecuting(ActionExecutingContext context) { switch (argument) { - case BookNewHearingRequest newHearingRequest: + case BookNewHearingRequestV2 newHearingRequest: newHearingRequest.HearingRoomName = Sanitize(newHearingRequest.HearingRoomName); - newHearingRequest.HearingVenueName = Sanitize(newHearingRequest.HearingVenueName); newHearingRequest.OtherInformation = Sanitize(newHearingRequest.OtherInformation); newHearingRequest.Cases?.ForEach(x => diff --git a/AdminWebsite/AdminWebsite/ClientApp/package-lock.json b/AdminWebsite/AdminWebsite/ClientApp/package-lock.json index 8067ef6ec..bae7243ef 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/package-lock.json +++ b/AdminWebsite/AdminWebsite/ClientApp/package-lock.json @@ -73,9 +73,8 @@ "karma-jasmine-html-reporter": "^2.1.0", "karma-junit-reporter": "^2.0.1", "nswag": "^13.19.0", - "pa11y": "^6.2.3", "prettier": "^2.8.8", - "puppeteer": "^23.6.0", + "puppeteer": "^23.9.0", "run-script-os": "^1.1.6", "sass": "^1.32.12", "typescript": "^5.4.4", @@ -4726,13 +4725,12 @@ } }, "node_modules/@puppeteer/browsers": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-2.4.0.tgz", - "integrity": "sha512-x8J1csfIygOwf6D6qUAZ0ASk3z63zPb7wkNeHRerCMh82qWKUrOgkuP005AJC8lDL6/evtXETGEJVcwykKT4/g==", + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-2.4.1.tgz", + "integrity": "sha512-0kdAbmic3J09I6dT8e9vE2JOCSt13wHCW5x/ly8TSt2bDtuIWe2TgLZZDHdcziw9AVCzflMAXCrVyRIhIs44Ng==", "dev": true, - "license": "Apache-2.0", "dependencies": { - "debug": "^4.3.6", + "debug": "^4.3.7", "extract-zip": "^2.0.1", "progress": "^2.0.3", "proxy-agent": "^6.4.0", @@ -4753,7 +4751,6 @@ "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", "dev": true, - "license": "ISC", "bin": { "semver": "bin/semver.js" }, @@ -5060,8 +5057,7 @@ "version": "0.23.0", "resolved": "https://registry.npmjs.org/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz", "integrity": "sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==", - "dev": true, - "license": "MIT" + "dev": true }, "node_modules/@tufjs/canonical-json": { "version": "2.0.0", @@ -6524,7 +6520,6 @@ "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.13.4.tgz", "integrity": "sha512-x1FCFnFifvYDDzTaLII71vG5uvDwgtmDTEVWAxrgeiR8VjMONcCXJx7E+USjDtHlwFmt9MysbqgF9b9Vjr6w+w==", "dev": true, - "license": "MIT", "dependencies": { "tslib": "^2.0.1" }, @@ -6596,15 +6591,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/axe-core": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.2.4.tgz", - "integrity": "sha512-9AiDKFKUCWEQm1Kj4lcq7KFavLqSXdf2m/zJo+NVh4VXlW5iwXRJ6alkKmipCyYorsRnqsICH9XLubP1jBF+Og==", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/axios": { "version": "1.6.8", "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.8.tgz", @@ -6629,8 +6615,7 @@ "version": "1.6.7", "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.6.7.tgz", "integrity": "sha512-OnAYlL5b7LEkALw87fUVafQw5rVR9RjwGd4KUwNQ6DrrNmaVaUCgLipfVlzrPQ4tWOR9P0IXGNOx50jYCCdSJg==", - "dev": true, - "license": "Apache-2.0" + "dev": true }, "node_modules/babel-loader": { "version": "9.1.3", @@ -6756,7 +6741,6 @@ "resolved": "https://registry.npmjs.org/bare-events/-/bare-events-2.5.0.tgz", "integrity": "sha512-/E8dDe9dsbLyh2qrZ64PEPadOQ0F4gbl1sUJOrmph7xOiIxfY8vwab/4bFLh4Y88/Hk/ujKcrQKc+ps0mv873A==", "dev": true, - "license": "Apache-2.0", "optional": true }, "node_modules/bare-fs": { @@ -6764,7 +6748,6 @@ "resolved": "https://registry.npmjs.org/bare-fs/-/bare-fs-2.3.5.tgz", "integrity": "sha512-SlE9eTxifPDJrT6YgemQ1WGFleevzwY+XAP1Xqgl56HtcrisC2CHCZ2tq6dBpcH2TnNxwUEUGhweo+lrQtYuiw==", "dev": true, - "license": "Apache-2.0", "optional": true, "dependencies": { "bare-events": "^2.0.0", @@ -6777,7 +6760,6 @@ "resolved": "https://registry.npmjs.org/bare-os/-/bare-os-2.4.4.tgz", "integrity": "sha512-z3UiI2yi1mK0sXeRdc4O1Kk8aOa/e+FNWZcTiPB/dfTWyLypuE99LibgRaQki914Jq//yAWylcAt+mknKdixRQ==", "dev": true, - "license": "Apache-2.0", "optional": true }, "node_modules/bare-path": { @@ -6785,18 +6767,16 @@ "resolved": "https://registry.npmjs.org/bare-path/-/bare-path-2.1.3.tgz", "integrity": "sha512-lh/eITfU8hrj9Ru5quUp0Io1kJWIk1bTjzo7JH1P5dWmQ2EL4hFUlfI8FonAhSlgIfhn63p84CDY/x+PisgcXA==", "dev": true, - "license": "Apache-2.0", "optional": true, "dependencies": { "bare-os": "^2.1.0" } }, "node_modules/bare-stream": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/bare-stream/-/bare-stream-2.3.2.tgz", - "integrity": "sha512-EFZHSIBkDgSHIwj2l2QZfP4U5OcD4xFAOwhSb/vlr9PIqyGJGvB/nfClJbcnh3EY4jtPE4zsb5ztae96bVF79A==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/bare-stream/-/bare-stream-2.4.0.tgz", + "integrity": "sha512-sd96/aZ8LjF1uJbEHzIo1LrERPKRFPEy1nZ1eOILftBxrVsFDAQkimHIIq87xrHcubzjNeETsD9PwN0wp+vLiQ==", "dev": true, - "license": "Apache-2.0", "optional": true, "dependencies": { "streamx": "^2.20.0" @@ -6835,7 +6815,6 @@ "resolved": "https://registry.npmjs.org/basic-ftp/-/basic-ftp-5.0.5.tgz", "integrity": "sha512-4Bcg1P8xhUuqcii/S0Z9wiHIrQVPMermM1any+MX5GeGD7faD3/msQUDGLol9wOcz4/jbg/WJnGqoJF6LiBdtg==", "dev": true, - "license": "MIT", "engines": { "node": ">=10.0.0" } @@ -6846,21 +6825,6 @@ "integrity": "sha512-x+VAiMRL6UPkx+kudNvxTl6hB2XNNCG2r+7wixVfIYwu/2HKRXimwQyaumLjMveWvT2Hkd/cAJw+QBMfJ/EKVw==", "dev": true }, - "node_modules/bfj": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/bfj/-/bfj-7.0.2.tgz", - "integrity": "sha512-+e/UqUzwmzJamNF50tBV6tZPTORow7gQ96iFow+8b562OdMpEK0BcJEq2OSPEDmAbSMBQ7PKZ87ubFkgxpYWgw==", - "dev": true, - "dependencies": { - "bluebird": "^3.5.5", - "check-types": "^11.1.1", - "hoopy": "^0.1.4", - "tryer": "^1.0.1" - }, - "engines": { - "node": ">= 8.0.0" - } - }, "node_modules/big.js": { "version": "5.2.2", "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", @@ -6892,12 +6856,6 @@ "readable-stream": "^3.4.0" } }, - "node_modules/bluebird": { - "version": "3.7.2", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", - "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==", - "dev": true - }, "node_modules/body-parser": { "version": "1.20.2", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", @@ -7200,12 +7158,6 @@ "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", "dev": true }, - "node_modules/check-types": { - "version": "11.2.3", - "resolved": "https://registry.npmjs.org/check-types/-/check-types-11.2.3.tgz", - "integrity": "sha512-+67P1GkJRaxQD6PKK0Et9DhwQB+vGg3PM5+aavopCpZT1lj9jeqfvpgTLAWErNj8qApkkmXlu/Ug74kmhagkXg==", - "dev": true - }, "node_modules/chokidar": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", @@ -7252,7 +7204,6 @@ "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-0.8.0.tgz", "integrity": "sha512-uJydbGdTw0DEUjhoogGveneJVWX/9YuqkWePzMmkBYwtdAqo5d3J/ovNKFr+/2hWXYmYCr6it8mSSTIj6SS6Ug==", "dev": true, - "license": "Apache-2.0", "dependencies": { "mitt": "3.0.1", "urlpattern-polyfill": "10.0.0", @@ -7428,15 +7379,6 @@ "node": ">= 0.8" } }, - "node_modules/commander": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-8.0.0.tgz", - "integrity": "sha512-Xvf85aAtu6v22+E5hfVoLHqyul/jyxh91zvqk/ioJTQuJR7Z78n7H558vMPKanPSRgIEeZemT92I2g9Y8LPbSQ==", - "dev": true, - "engines": { - "node": ">= 12" - } - }, "node_modules/common-path-prefix": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/common-path-prefix/-/common-path-prefix-3.0.0.tgz", @@ -7939,7 +7881,6 @@ "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-6.0.2.tgz", "integrity": "sha512-7hvf7/GW8e86rW0ptuwS3OcBGDjIi6SZva7hCyWC0yYry2cOPmLIjXAUHI6DK2HsnwJd9ifmt57i8eV2n4YNpw==", "dev": true, - "license": "MIT", "engines": { "node": ">= 14" } @@ -8099,7 +8040,6 @@ "resolved": "https://registry.npmjs.org/degenerator/-/degenerator-5.0.1.tgz", "integrity": "sha512-TllpMR/t0M5sqCXfj85i4XaAzxmS5tVA16dqvdkMwGmzI+dXLXnw3J+3Vdv7VKw+ThlTMboK6i9rnZ6Nntj5CQ==", "dev": true, - "license": "MIT", "dependencies": { "ast-types": "^0.13.4", "escodegen": "^2.1.0", @@ -8153,11 +8093,10 @@ "dev": true }, "node_modules/devtools-protocol": { - "version": "0.0.1354347", - "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1354347.tgz", - "integrity": "sha512-BlmkSqV0V84E2WnEnoPnwyix57rQxAM5SKJjf4TbYOCGLAWtz8CDH8RIaGOjPgPCXo2Mce3kxSY497OySidY3Q==", - "dev": true, - "license": "BSD-3-Clause" + "version": "0.0.1367902", + "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1367902.tgz", + "integrity": "sha512-XxtPuC3PGakY6PD7dG66/o8KwJ/LkH2/EKe19Dcw58w53dv4/vSQEkn/SzuyhHE2q4zPgCkxQBxus3VV4ql+Pg==", + "dev": true }, "node_modules/di": { "version": "0.0.1", @@ -8500,18 +8439,6 @@ "node": ">=6" } }, - "node_modules/envinfo": { - "version": "7.8.1", - "resolved": "https://registry.npmjs.org/envinfo/-/envinfo-7.8.1.tgz", - "integrity": "sha512-/o+BXHmB7ocbHEAs6F2EnG0ogybVVUdkRunTT2glZU9XAaGmhqskrvKwqXuDfNjEO0LZKWdejEEpnq8aM0tOaw==", - "dev": true, - "bin": { - "envinfo": "dist/cli.js" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/err-code": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/err-code/-/err-code-2.0.3.tgz", @@ -8757,7 +8684,6 @@ "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.1.0.tgz", "integrity": "sha512-2NlIDTwUWJN0mRPQOdtQBzbUHvdGY2P1VXSyU83Q3xKxM7WHX2Ql8dKq782Q9TgQUNOLEzEYu9bzLNj1q88I5w==", "dev": true, - "license": "BSD-2-Clause", "dependencies": { "esprima": "^4.0.1", "estraverse": "^5.2.0", @@ -8779,7 +8705,6 @@ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true, - "license": "BSD-3-Clause", "optional": true, "engines": { "node": ">=0.10.0" @@ -9570,8 +9495,7 @@ "version": "1.3.2", "resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.2.tgz", "integrity": "sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==", - "dev": true, - "license": "MIT" + "dev": true }, "node_modules/fast-glob": { "version": "3.3.2", @@ -10067,7 +9991,6 @@ "resolved": "https://registry.npmjs.org/get-uri/-/get-uri-6.0.3.tgz", "integrity": "sha512-BzUrJBS9EcUb4cFol8r4W3v1cPsSyajLSthNkz5BxbpDcHN5tIrM10E2eNvfnvBn3DaT3DUgx0OpsBKkaOpanw==", "dev": true, - "license": "MIT", "dependencies": { "basic-ftp": "^5.0.2", "data-uri-to-buffer": "^6.0.2", @@ -10298,15 +10221,6 @@ "node": ">= 0.4" } }, - "node_modules/hoopy": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/hoopy/-/hoopy-0.1.4.tgz", - "integrity": "sha512-HRcs+2mr52W0K+x8RzcLzuPPmVIKMSv97RGHy0Ea9y/mpcaK+xTrjICA04KAHi4GRzxliNqNJEFYWHghy3rSfQ==", - "dev": true, - "engines": { - "node": ">= 6.0.0" - } - }, "node_modules/hosted-git-info": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-7.0.1.tgz", @@ -10376,15 +10290,6 @@ "safe-buffer": "~5.1.0" } }, - "node_modules/html_codesniffer": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/html_codesniffer/-/html_codesniffer-2.5.1.tgz", - "integrity": "sha512-vcz0yAaX/OaV6sdNHuT9alBOKkSxYb8h5Yq26dUqgi7XmCgGUSa7U9PiY1PBXQFMjKv1wVPs5/QzHlGuxPDUGg==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/html-entities": { "version": "2.5.2", "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-2.5.2.tgz", @@ -10776,15 +10681,6 @@ "node": ">= 10" } }, - "node_modules/is": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/is/-/is-3.3.0.tgz", - "integrity": "sha512-nW24QBoPcFGGHJGUwnfpI7Yc5CdqWNdsyHQszVE/z2pKHXzh7FZ5GWhJqSyaQ9wMkQnsTx+kAI8bHlCX4tKdbg==", - "dev": true, - "engines": { - "node": "*" - } - }, "node_modules/is-array-buffer": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.4.tgz", @@ -11915,15 +11811,6 @@ "node": ">=0.10.0" } }, - "node_modules/kleur": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz", - "integrity": "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/klona": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/klona/-/klona-2.0.6.tgz", @@ -12692,8 +12579,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/mitt/-/mitt-3.0.1.tgz", "integrity": "sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==", - "dev": true, - "license": "MIT" + "dev": true }, "node_modules/mkdirp": { "version": "0.5.6", @@ -12707,12 +12593,6 @@ "mkdirp": "bin/cmd.js" } }, - "node_modules/mkdirp-classic": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", - "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==", - "dev": true - }, "node_modules/moment": { "version": "2.30.1", "resolved": "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz", @@ -12749,15 +12629,6 @@ "multicast-dns": "cli.js" } }, - "node_modules/mustache": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz", - "integrity": "sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==", - "dev": true, - "bin": { - "mustache": "bin/mustache" - } - }, "node_modules/mute-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-1.0.0.tgz", @@ -12841,7 +12712,6 @@ "resolved": "https://registry.npmjs.org/netmask/-/netmask-2.0.2.tgz", "integrity": "sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg==", "dev": true, - "license": "MIT", "engines": { "node": ">= 0.4.0" } @@ -12932,26 +12802,6 @@ "integrity": "sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A==", "dev": true }, - "node_modules/node-fetch": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", - "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", - "dev": true, - "dependencies": { - "whatwg-url": "^5.0.0" - }, - "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } - } - }, "node_modules/node-forge": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.1.tgz", @@ -13053,19 +12903,6 @@ "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz", "integrity": "sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw==" }, - "node_modules/node.extend": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/node.extend/-/node.extend-2.0.3.tgz", - "integrity": "sha512-xwADg/okH48PvBmRZyoX8i8GJaKuJ1CqlqotlZOhUio8egD1P5trJupHKBzcPjSF9ifK2gPcEICRBnkfPqQXZw==", - "dev": true, - "dependencies": { - "hasown": "^2.0.0", - "is": "^3.3.0" - }, - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/nopt": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/nopt/-/nopt-7.2.0.tgz", @@ -13854,15 +13691,6 @@ "node": ">= 4" } }, - "node_modules/p-timeout": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-4.1.0.tgz", - "integrity": "sha512-+/wmHtzJuWii1sXn3HCuH/FTwGhrp4tmJTxSKJbfS+vkipci6osxXM5mY0jUiRzWKMTgUT8l7HFbeSwZAynqHw==", - "dev": true, - "engines": { - "node": ">=10" - } - }, "node_modules/p-try": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", @@ -13872,177 +13700,11 @@ "node": ">=6" } }, - "node_modules/pa11y": { - "version": "6.2.3", - "resolved": "https://registry.npmjs.org/pa11y/-/pa11y-6.2.3.tgz", - "integrity": "sha512-69JoUlfW2QVmrgQAm+17XBxIvmd1u0ImFBYIHPyjC61CzAkmxO3kkbqDVxIcl0OKLvAMYSMbvfCH8kMFE9xsbg==", - "dev": true, - "dependencies": { - "axe-core": "~4.2.1", - "bfj": "~7.0.2", - "commander": "~8.0.0", - "envinfo": "~7.8.1", - "html_codesniffer": "~2.5.1", - "kleur": "~4.1.4", - "mustache": "~4.2.0", - "node.extend": "~2.0.2", - "p-timeout": "~4.1.0", - "puppeteer": "~9.1.1", - "semver": "~7.3.5" - }, - "bin": { - "pa11y": "bin/pa11y.js" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/pa11y/node_modules/agent-base": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", - "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", - "dev": true, - "dependencies": { - "debug": "4" - }, - "engines": { - "node": ">= 6.0.0" - } - }, - "node_modules/pa11y/node_modules/chownr": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", - "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==", - "dev": true - }, - "node_modules/pa11y/node_modules/devtools-protocol": { - "version": "0.0.869402", - "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.869402.tgz", - "integrity": "sha512-VvlVYY+VDJe639yHs5PHISzdWTLL3Aw8rO4cvUtwvoxFd6FHbE4OpHHcde52M6096uYYazAmd4l0o5VuFRO2WA==", - "dev": true - }, - "node_modules/pa11y/node_modules/https-proxy-agent": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", - "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", - "dev": true, - "dependencies": { - "agent-base": "6", - "debug": "4" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/pa11y/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/pa11y/node_modules/pkg-dir": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", - "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", - "dev": true, - "dependencies": { - "find-up": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/pa11y/node_modules/puppeteer": { - "version": "9.1.1", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-9.1.1.tgz", - "integrity": "sha512-W+nOulP2tYd/ZG99WuZC/I5ljjQQ7EUw/jQGcIb9eu8mDlZxNY2SgcJXTLG9h5gRvqA3uJOe4hZXYsd3EqioMw==", - "deprecated": "< 21.8.0 is no longer supported", - "dev": true, - "hasInstallScript": true, - "dependencies": { - "debug": "^4.1.0", - "devtools-protocol": "0.0.869402", - "extract-zip": "^2.0.0", - "https-proxy-agent": "^5.0.0", - "node-fetch": "^2.6.1", - "pkg-dir": "^4.2.0", - "progress": "^2.0.1", - "proxy-from-env": "^1.1.0", - "rimraf": "^3.0.2", - "tar-fs": "^2.0.0", - "unbzip2-stream": "^1.3.3", - "ws": "^7.2.3" - }, - "engines": { - "node": ">=10.18.1" - } - }, - "node_modules/pa11y/node_modules/semver": { - "version": "7.3.8", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", - "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/pa11y/node_modules/tar-fs": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz", - "integrity": "sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==", - "dev": true, - "dependencies": { - "chownr": "^1.1.1", - "mkdirp-classic": "^0.5.2", - "pump": "^3.0.0", - "tar-stream": "^2.1.4" - } - }, - "node_modules/pa11y/node_modules/ws": { - "version": "7.5.9", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", - "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", - "dev": true, - "engines": { - "node": ">=8.3.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } - }, - "node_modules/pa11y/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true - }, "node_modules/pac-proxy-agent": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-7.0.2.tgz", "integrity": "sha512-BFi3vZnO9X5Qt6NRz7ZOaPja3ic0PhlsmCRYLOpN11+mWBCR6XJDqW5RF3j8jm4WGGQZtBA+bTfxYzeKW73eHg==", "dev": true, - "license": "MIT", "dependencies": { "@tootallnate/quickjs-emscripten": "^0.23.0", "agent-base": "^7.0.2", @@ -14062,7 +13724,6 @@ "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.5.tgz", "integrity": "sha512-1e4Wqeblerz+tMKPIq2EMGiiWW1dIjZOksyHWSUm1rmuvw/how9hBHZ38lAGj5ID4Ik6EdkOw7NmWPy6LAwalw==", "dev": true, - "license": "MIT", "dependencies": { "agent-base": "^7.0.2", "debug": "4" @@ -14076,7 +13737,6 @@ "resolved": "https://registry.npmjs.org/pac-resolver/-/pac-resolver-7.0.1.tgz", "integrity": "sha512-5NPgf87AT2STgwa2ntRMr45jTKrYBGkVU36yT0ig/n/GMAa3oPqhZfIQ2kMEimReg0+t9kZViDVZ83qfVUlckg==", "dev": true, - "license": "MIT", "dependencies": { "degenerator": "^5.0.0", "netmask": "^2.0.2" @@ -14699,7 +14359,6 @@ "resolved": "https://registry.npmjs.org/proxy-agent/-/proxy-agent-6.4.0.tgz", "integrity": "sha512-u0piLU+nCOHMgGjRbimiXmA9kM/L9EHh3zL81xCdp7m+Y2pHIsnmbdDoEDoAz5geaonNR6q6+yOPQs6n4T6sBQ==", "dev": true, - "license": "MIT", "dependencies": { "agent-base": "^7.0.2", "debug": "^4.3.4", @@ -14719,7 +14378,6 @@ "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz", "integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==", "dev": true, - "license": "ISC", "engines": { "node": ">=12" } @@ -14757,18 +14415,17 @@ } }, "node_modules/puppeteer": { - "version": "23.6.1", - "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-23.6.1.tgz", - "integrity": "sha512-8+ALGQgwXd3P/tGcuSsxTPGDaOQIjcDIm04I5hpWZv/PiN5q8bQNHRUyfYrifT+flnM9aTWCP7tLEzuB6SlIgA==", + "version": "23.9.0", + "resolved": "https://registry.npmjs.org/puppeteer/-/puppeteer-23.9.0.tgz", + "integrity": "sha512-WfB8jGwFV+qrD9dcJJVvWPFJBU6kxeu2wxJz9WooDGfM3vIiKLgzImEDBxUQnCBK/2cXB3d4dV6gs/LLpgfLDg==", "dev": true, "hasInstallScript": true, - "license": "Apache-2.0", "dependencies": { - "@puppeteer/browsers": "2.4.0", + "@puppeteer/browsers": "2.4.1", "chromium-bidi": "0.8.0", "cosmiconfig": "^9.0.0", - "devtools-protocol": "0.0.1354347", - "puppeteer-core": "23.6.1", + "devtools-protocol": "0.0.1367902", + "puppeteer-core": "23.9.0", "typed-query-selector": "^2.12.0" }, "bin": { @@ -14779,16 +14436,15 @@ } }, "node_modules/puppeteer-core": { - "version": "23.6.1", - "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-23.6.1.tgz", - "integrity": "sha512-DoNLAzQfGklPauEn33N4h9cM9GubJSINEn+AUMwAXwW159Y9JLk5y34Jsbv4c7kG8P0puOYWV9leu2siMZ/QpQ==", + "version": "23.9.0", + "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-23.9.0.tgz", + "integrity": "sha512-hLVrav2HYMVdK0YILtfJwtnkBAwNOztUdR4aJ5YKDvgsbtagNr6urUJk9HyjRA9e+PaLI3jzJ0wM7A4jSZ7Qxw==", "dev": true, - "license": "Apache-2.0", "dependencies": { - "@puppeteer/browsers": "2.4.0", + "@puppeteer/browsers": "2.4.1", "chromium-bidi": "0.8.0", "debug": "^4.3.7", - "devtools-protocol": "0.0.1354347", + "devtools-protocol": "0.0.1367902", "typed-query-selector": "^2.12.0", "ws": "^8.18.0" }, @@ -14843,8 +14499,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/queue-tick/-/queue-tick-1.0.1.tgz", "integrity": "sha512-kJt5qhMxoszgU/62PLP1CJytzd2NKetjSRnyuj31fDd3Rlcz3fzlFdFLD1SItunPwyqEOkca6GbV612BWfaBag==", - "dev": true, - "license": "MIT" + "dev": true }, "node_modules/randombytes": { "version": "2.1.0", @@ -16103,11 +15758,10 @@ } }, "node_modules/streamx": { - "version": "2.20.1", - "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.20.1.tgz", - "integrity": "sha512-uTa0mU6WUC65iUvzKH4X9hEdvSW7rbPxPtwfWiLMSj3qTdQbAiUboZTxauKfpFuGIGa1C2BYijZ7wgdUXICJhA==", + "version": "2.20.2", + "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.20.2.tgz", + "integrity": "sha512-aDGDLU+j9tJcUdPGOaHmVF1u/hhI+CsGkT02V3OKlHDV7IukOI+nTWAGkiZEKCO35rWN1wIr4tS7YFr1f4qSvA==", "dev": true, - "license": "MIT", "dependencies": { "fast-fifo": "^1.3.2", "queue-tick": "^1.0.1", @@ -16337,7 +15991,6 @@ "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-3.0.6.tgz", "integrity": "sha512-iokBDQQkUyeXhgPYaZxmczGPhnhXZ0CmrqI+MOb/WFGS9DW5wnfrLgtjUJBvz50vQ3qfRwJ62QVoCFu8mPVu5w==", "dev": true, - "license": "MIT", "dependencies": { "pump": "^3.0.0", "tar-stream": "^3.1.5" @@ -16352,7 +16005,6 @@ "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.1.7.tgz", "integrity": "sha512-qJj60CXt7IU1Ffyc3NJMjh6EkuCFej46zUqJ4J7pqYlThyd9bO0XBTmcOIhSzZJVWfsLks0+nle/j538YAW9RQ==", "dev": true, - "license": "MIT", "dependencies": { "b4a": "^1.6.4", "fast-fifo": "^1.2.0", @@ -16573,8 +16225,7 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/text-decoder/-/text-decoder-1.2.1.tgz", "integrity": "sha512-x9v3H/lTKIJKQQe7RPQkLfKAnc9lUTkWDypIQgTzPJAq+5/GCDHonmshfvlsNSj58yyshbIJJDLmU15qNERrXQ==", - "dev": true, - "license": "Apache-2.0" + "dev": true }, "node_modules/text-table": { "version": "0.2.0", @@ -16631,12 +16282,6 @@ "node": ">=0.6" } }, - "node_modules/tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", - "dev": true - }, "node_modules/tree-kill": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", @@ -16646,12 +16291,6 @@ "tree-kill": "cli.js" } }, - "node_modules/tryer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/tryer/-/tryer-1.0.1.tgz", - "integrity": "sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA==", - "dev": true - }, "node_modules/ts-api-utils": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz", @@ -16978,8 +16617,7 @@ "version": "2.12.0", "resolved": "https://registry.npmjs.org/typed-query-selector/-/typed-query-selector-2.12.0.tgz", "integrity": "sha512-SbklCd1F0EiZOyPiW192rrHZzZ5sBijB6xM+cpmrwDqObvdtunOHHIk9fCGsoK5JVIYXoyEp4iEdE3upFH3PAg==", - "dev": true, - "license": "MIT" + "dev": true }, "node_modules/typescript": { "version": "5.4.4", @@ -17180,8 +16818,7 @@ "version": "10.0.0", "resolved": "https://registry.npmjs.org/urlpattern-polyfill/-/urlpattern-polyfill-10.0.0.tgz", "integrity": "sha512-H/A06tKD7sS1O1X2SshBVeA5FLycRpjqiBeqGKmBwBDBy28EnRjORxTNe269KSSr5un5qyWi1iL61wLxpd+ZOg==", - "dev": true, - "license": "MIT" + "dev": true }, "node_modules/util-deprecate": { "version": "1.0.2", @@ -17749,12 +17386,6 @@ "defaults": "^1.0.3" } }, - "node_modules/webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", - "dev": true - }, "node_modules/webpack": { "version": "5.90.3", "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.90.3.tgz", @@ -18056,16 +17687,6 @@ "node": ">=0.8.0" } }, - "node_modules/whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", - "dev": true, - "dependencies": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" - } - }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -18398,7 +18019,6 @@ "resolved": "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz", "integrity": "sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==", "dev": true, - "license": "MIT", "funding": { "url": "https://github.com/sponsors/colinhacks" } diff --git a/AdminWebsite/AdminWebsite/ClientApp/package.json b/AdminWebsite/AdminWebsite/ClientApp/package.json index 6955b34cd..5d06f7533 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/package.json +++ b/AdminWebsite/AdminWebsite/ClientApp/package.json @@ -86,9 +86,8 @@ "karma-jasmine-html-reporter": "^2.1.0", "karma-junit-reporter": "^2.0.1", "nswag": "^13.19.0", - "pa11y": "^6.2.3", "prettier": "^2.8.8", - "puppeteer": "^23.6.0", + "puppeteer": "^23.9.0", "run-script-os": "^1.1.6", "sass": "^1.32.12", "typescript": "^5.4.4", diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant-base/add-participant-base.component.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant-base/add-participant-base.component.ts index ebbba9b2b..5e180bfd1 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant-base/add-participant-base.component.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant-base/add-participant-base.component.ts @@ -5,7 +5,6 @@ import { Constants } from 'src/app/common/constants'; import { HearingRoles } from 'src/app/common/model/hearing-roles.model'; import { HearingModel } from 'src/app/common/model/hearing.model'; import { ParticipantModel } from 'src/app/common/model/participant.model'; -import { PartyModel } from 'src/app/common/model/party.model'; import { BookingService } from 'src/app/services/booking.service'; import { Logger } from 'src/app/services/logger'; import { VideoHearingsService } from 'src/app/services/video-hearings.service'; @@ -17,7 +16,6 @@ import { InterpreterFormComponent } from '../interpreter-form/interpreter-form.c @Directive() export abstract class AddParticipantBaseDirective extends BookingBaseComponent implements OnInit { isShowErrorSummary = false; - caseAndHearingRoles: PartyModel[] = []; hearingRoles: HearingRoleModel[] = []; participantDetails: ParticipantModel; @@ -54,7 +52,6 @@ export abstract class AddParticipantBaseDirective extends BookingBaseComponent i role: FormControl; interpreterFor: FormControl; lastName: FormControl; - party: FormControl; phone: FormControl; representing: FormControl; title: FormControl; @@ -89,10 +86,6 @@ export abstract class AddParticipantBaseDirective extends BookingBaseComponent i return this.phone.invalid && (this.phone.dirty || this.phone.touched || this.isShowErrorSummary); } - get partyInvalid() { - return this.party.invalid && (this.party.dirty || this.party.touched || this.isShowErrorSummary); - } - get roleInvalid() { return this.role.invalid && (this.role.dirty || this.role.touched || this.isShowErrorSummary); } @@ -124,7 +117,6 @@ export abstract class AddParticipantBaseDirective extends BookingBaseComponent i Validators.required, Validators.pattern(this.constants.PleaseSelectPattern) ]); - this.party = new FormControl(this.constants.PleaseSelect); this.title = new FormControl(this.constants.PleaseSelect); this.firstName = new FormControl('', [ Validators.required, @@ -153,7 +145,6 @@ export abstract class AddParticipantBaseDirective extends BookingBaseComponent i this.form = new FormGroup({ role: this.role, - party: this.party, title: this.title, firstName: this.firstName, lastName: this.lastName, @@ -223,7 +214,6 @@ export abstract class AddParticipantBaseDirective extends BookingBaseComponent i this.resetPartyAndRole(); this.isRepresentative = this.isRoleRepresentative(this.participantDetails.hearing_role_name); const formControlsObj = { - party: this.participantDetails.case_role_name, role: this.participantDetails.hearing_role_name, title: this.participantDetails.title ?? this.constants.PleaseSelect, firstName: this.participantDetails.first_name?.trim(), @@ -256,7 +246,6 @@ export abstract class AddParticipantBaseDirective extends BookingBaseComponent i } protected disableCaseAndHearingRoles() { - this.form.get('party').disable(); this.form.get('role').disable(); } @@ -283,21 +272,10 @@ export abstract class AddParticipantBaseDirective extends BookingBaseComponent i this.emailDisabled = false; this.form.get('lastName').enable(); this.form.get('firstName').enable(); - this.form.get('party').enable(); this.form.get('role').enable(); } resetPartyAndRole() { - if (this.participantDetails.case_role_name) { - this.setupHearingRoles(this.participantDetails.case_role_name); - } - if ( - this.isPartySelected && - !this.existingParticipant && - (!this.participantDetails.case_role_name || this.participantDetails.case_role_name.length === 0) - ) { - this.participantDetails.case_role_name = this.party.value; - } if ( this.isRoleSelected && !this.existingParticipant && @@ -307,15 +285,6 @@ export abstract class AddParticipantBaseDirective extends BookingBaseComponent i } } - setupHearingRoles(caseRoleName: string) { - const list = this.caseAndHearingRoles.find(x => x.name === caseRoleName && x.name !== 'Judge' && x.name !== 'Staff Member'); - this.hearingRoleList = list ? list.hearingRoles.map(x => x.name) : []; - this.updateHearingRoleList(this.hearingRoleList); - if (!this.hearingRoleList.find(s => s === this.constants.PleaseSelect)) { - this.hearingRoleList.unshift(this.constants.PleaseSelect); - } - } - setupHearingRolesWithoutCaseRole() { this.hearingRoleList = this.hearingRoles ? this.hearingRoles.map(x => x.name) : []; this.updateHearingRoleList(this.hearingRoleList); @@ -429,11 +398,8 @@ export abstract class AddParticipantBaseDirective extends BookingBaseComponent i this.interpreterForm?.forceValidation(); } - protected isAnObserver(participant): boolean { - return ( - participant.hearing_role_name === Constants.HearingRoles.Observer || - participant.case_role_name === Constants.HearingRoles.Observer - ); + protected isAnObserver(participant: ParticipantModel): boolean { + return participant.hearing_role_name === Constants.HearingRoles.Observer; } private setRepresenteeLabel() { diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.html b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.html index 8f4104c2b..3c546e881 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.html +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.html @@ -54,8 +54,7 @@ <h2 class="govuk-heading-m">Add a participant</h2> [disabled]="emailDisabled" (findParticipant)="getParticipant($event)" (emailChanged)="emailChanged()" - [hearingRoleParticipant]="role.value" - [caseRole]="party.value" + [hearingRoleParticipant]="constants.Citizen" > </app-search-email> diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.spec.ts index b193a6204..264415464 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.spec.ts @@ -1,5 +1,5 @@ import { ComponentFixture, fakeAsync, flush, TestBed, tick, waitForAsync } from '@angular/core/testing'; -import { AbstractControl, Validators } from '@angular/forms'; +import { AbstractControl } from '@angular/forms'; import { NavigationEnd, Router, RouterModule } from '@angular/router'; import { of, Subscription } from 'rxjs'; import { SharedModule } from 'src/app/shared/shared.module'; @@ -7,9 +7,8 @@ import { SearchServiceStub } from 'src/app/testing/stubs/service-service-stub'; import { Constants } from '../../common/constants'; import { HearingModel } from '../../common/model/hearing.model'; import { ParticipantModel } from '../../common/model/participant.model'; -import { PartyModel } from '../../common/model/party.model'; import { BookingService } from '../../services/booking.service'; -import { CaseAndHearingRolesResponse, ClientSettingsResponse, HearingRole, HearingRoleResponse } from '../../services/clients/api-client'; +import { ClientSettingsResponse, HearingRoleResponse } from '../../services/clients/api-client'; import { ConfigService } from '../../services/config.service'; import { Logger } from '../../services/logger'; import { SearchService } from '../../services/search.service'; @@ -23,7 +22,6 @@ import { LinkedParticipantModel, LinkedParticipantType } from 'src/app/common/mo import { BookingModule } from '../booking.module'; import { PopupModule } from 'src/app/popups/popup.module'; import { TestingModule } from 'src/app/testing/testing.module'; -import { By } from '@angular/platform-browser'; import { HearingRoles } from '../../common/model/hearing-roles.model'; import { FeatureFlags, LaunchDarklyService } from 'src/app/services/launch-darkly.service'; import { InterpreterFormComponent } from '../interpreter-form/interpreter-form.component'; @@ -34,17 +32,6 @@ import { FeatureFlagDirective } from 'src/app/src/app/shared/feature-flag.direct let component: AddParticipantComponent; let fixture: ComponentFixture<AddParticipantComponent>; -const roleList: CaseAndHearingRolesResponse[] = [ - new CaseAndHearingRolesResponse({ - name: 'Applicant', - hearing_roles: [ - new HearingRole({ name: 'Representative', user_role: 'Representative' }), - new HearingRole({ name: 'Litigant in person', user_role: 'Individual' }), - new HearingRole({ name: 'presenting officer', user_role: 'Representative' }), - new HearingRole({ name: 'Interpreter', user_role: 'Individual' }) - ] - }) -]; const flatRoleList: HearingRoleResponse[] = [ new HearingRoleResponse({ name: 'Applicant', @@ -88,19 +75,9 @@ const flatRoleList: HearingRoleResponse[] = [ }) ]; -const partyR = new PartyModel('Applicant'); -partyR.hearingRoles = [ - new HearingRoleModel('Representative', 'Representative'), - new HearingRoleModel('Litigant in person', 'Individual'), - new HearingRoleModel('presenting officer', 'Representative'), - new HearingRoleModel('Interpreter', 'Interpreter') -]; -const partyList: PartyModel[] = [partyR]; - const mappedHearingRoles: HearingRoleModel[] = flatRoleList.map(x => new HearingRoleModel(x.name, x.user_role, x.code)); let role: AbstractControl; -let party: AbstractControl; let title: AbstractControl; let firstName: AbstractControl; let lastName: AbstractControl; @@ -123,7 +100,6 @@ p1.title = 'Mr.'; p1.email = 'test1@hmcts.net'; p1.phone = '32332'; p1.hearing_role_name = 'Representative'; -p1.case_role_name = 'Applicant'; p1.company = 'CN'; p1.representee = 'representee'; p1.user_role_name = 'Representative'; @@ -138,7 +114,6 @@ p2.title = 'Mr.'; p2.email = 'test2@hmcts.net'; p2.phone = '32332'; p2.hearing_role_name = 'Representative'; -p2.case_role_name = 'Applicant'; p2.company = 'CN'; p2.representee = 'representee'; p2.user_role_name = 'Representative'; @@ -153,7 +128,6 @@ p3.title = 'Mr.'; p3.email = 'test3@hmcts.net'; p3.phone = '32332'; p3.hearing_role_name = 'Representative'; -p3.case_role_name = 'Applicant'; p3.company = 'CN'; p3.is_exist_person = true; p3.id = '1234'; @@ -168,7 +142,6 @@ p4.title = 'Mr.'; p4.email = 'test4@hmcts.net'; p4.phone = '32332'; p4.hearing_role_name = 'Litigant in person'; -p4.case_role_name = 'Applicant'; p4.company = 'CN'; p4.id = '1234'; p4.user_role_name = 'Individual'; @@ -182,7 +155,6 @@ p5.title = 'Mr.'; p5.email = 'test7@hmcts.net'; p5.phone = '32332'; p5.hearing_role_name = 'Interpreter'; -p5.case_role_name = 'Applicant'; p5.company = 'CN'; p5.id = '1234666'; p5.user_role_name = 'Individual'; @@ -197,7 +169,6 @@ p6.title = 'Mr.'; p6.email = 'test8@hmcts.net'; p6.phone = '32332'; p6.hearing_role_name = 'Litigant in Person'; -p6.case_role_name = 'Applicant'; p6.company = 'CN'; p6.id = '1234555'; p6.user_role_name = 'Individual'; @@ -210,7 +181,6 @@ participants.push(p4); function initHearingRequest(): HearingModel { const newHearing = new HearingModel(); newHearing.cases = []; - newHearing.hearing_type_id = -1; newHearing.hearing_venue_id = -1; newHearing.scheduled_duration = 0; newHearing.participants = participants; @@ -223,7 +193,6 @@ function initExistHearingRequest(): HearingModel { const newHearing = new HearingModel(); newHearing.cases = []; newHearing.hearing_id = '12345'; - newHearing.hearing_type_id = 1; newHearing.hearing_venue_id = 1; newHearing.scheduled_duration = 20; newHearing.participants = participants; @@ -244,7 +213,6 @@ function initParticipant() { participant.display_name = 'Sam Green'; participant.title = 'Mr'; participant.hearing_role_name = 'Representative'; - participant.case_role_name = 'Applicant'; participant.company = 'CN'; participant.representee = 'test representee'; participant.user_role_name = 'Individual'; @@ -258,7 +226,6 @@ const routerSpy: jasmine.SpyObj<Router> = { let videoHearingsServiceSpy: jasmine.SpyObj<VideoHearingsService>; videoHearingsServiceSpy = jasmine.createSpyObj<VideoHearingsService>([ - 'getParticipantRoles', 'getCurrentRequest', 'setBookingHasChanged', 'unsetBookingHasChanged', @@ -279,7 +246,6 @@ const loggerSpy = jasmine.createSpyObj<Logger>('Logger', ['error', 'debug', 'war let participantServiceSpy = jasmine.createSpyObj<ParticipantService>('ParticipantService', [ 'checkDuplication', 'removeParticipant', - 'mapParticipantsRoles', 'mapParticipantHearingRoles' ]); @@ -293,18 +259,15 @@ describe('AddParticipantComponent', () => { initParticipant(); const hearing = initHearingRequest(); - videoHearingsServiceSpy.getParticipantRoles.and.returnValue(Promise.resolve(roleList)); videoHearingsServiceSpy.getCurrentRequest.and.returnValue(hearing); videoHearingsServiceSpy.getHearingRoles.and.returnValue(Promise.resolve(flatRoleList)); participantServiceSpy = jasmine.createSpyObj<ParticipantService>([ - 'mapParticipantsRoles', 'checkDuplication', 'removeParticipant', 'mapParticipantHearingRoles' ]); launchDarklyServiceSpy.getFlag.withArgs(FeatureFlags.interpreterEnhancements).and.returnValue(of(false)); launchDarklyServiceSpy.getFlag.withArgs(FeatureFlags.specialMeasures).and.returnValue(of(false)); - participantServiceSpy.mapParticipantsRoles.and.returnValue(partyList); participantServiceSpy.mapParticipantHearingRoles.and.returnValue(mappedHearingRoles); bookingServiceSpy = jasmine.createSpyObj<BookingService>(['isEditMode', 'resetEditMode']); bookingServiceSpy.isEditMode.and.returnValue(false); @@ -336,7 +299,6 @@ describe('AddParticipantComponent', () => { component.ngOnInit(); role = component.form.controls['role']; - party = component.form.controls['party']; title = component.form.controls['title']; firstName = component.form.controls['firstName']; lastName = component.form.controls['lastName']; @@ -383,7 +345,6 @@ describe('AddParticipantComponent', () => { component.ngOnInit(); tick(500); expect(role.value).toBe(Constants.PleaseSelect); - expect(party.value).toBe(Constants.PleaseSelect); expect(firstName.value).toBe(''); expect(lastName.value).toBe(''); expect(email.value).toBe(''); @@ -431,31 +392,9 @@ describe('AddParticipantComponent', () => { component.roleSelected(); expect(role.valid && component.isRoleSelected).toBeTruthy(); }); - it('should reset undefined value for party and role to Please select', () => { - participant.case_role_name = undefined; - participant.hearing_role_name = undefined; - component.getParticipant(participant); - - expect(component.participantDetails.case_role_name).toBeTruthy(); - expect(component.participantDetails.case_role_name).toEqual(Constants.PleaseSelect); - expect(component.participantDetails.hearing_role_name).toEqual(Constants.PleaseSelect); - }); - it('should reset empty party and role to Please select', () => { - participant.case_role_name = ''; - participant.hearing_role_name = ''; - - component.isPartySelected = true; - component.isRoleSelected = true; - component.getParticipant(participant); - - expect(component.participantDetails.case_role_name).toBeTruthy(); - expect(component.participantDetails.case_role_name).toEqual(Constants.PleaseSelect); - expect(component.participantDetails.hearing_role_name).toEqual(Constants.PleaseSelect); - }); it('should populate the form fields if the participant is found in data store', () => { participant.id = '2345'; component.isPartySelected = true; - component.form.get('party').setValue('Applicant'); component.isRoleSelected = true; component.form.get('role').setValue('Representative'); @@ -465,7 +404,6 @@ describe('AddParticipantComponent', () => { participant.last_name = participant.last_name + ' '; component.getParticipant(participant); expect(role.value).toBe(participant.hearing_role_name); - expect(party.value).toBe(participant.case_role_name); expect(firstName.value).toBe(originalFirstName); expect(lastName.value).toBe(originalLastName); expect(email.value).toBe(participant.email); @@ -495,7 +433,6 @@ describe('AddParticipantComponent', () => { component.getParticipant(participant); component.clearForm(); expect(role.value).toBe(Constants.PleaseSelect); - expect(party.value).toBe(Constants.PleaseSelect); expect(firstName.value).toBe(''); expect(lastName.value).toBe(''); expect(email.value).toBe(''); @@ -504,7 +441,6 @@ describe('AddParticipantComponent', () => { expect(displayName.value).toBe(''); expect(companyName.value).toBe(''); expect(role.untouched).toBeTruthy(); - expect(party.untouched).toBeTruthy(); expect(firstName.untouched).toBeTruthy(); expect(interpretee.value).toBe(Constants.PleaseSelect); }); @@ -530,7 +466,6 @@ describe('AddParticipantComponent', () => { component.searchEmail.initialValue = 'mockInitialValue@hmcts.net'; component.searchEmail.email = 'mock@hmcts.net'; role.setValue('Litigant in person'); - party.setValue('Applicant'); firstName.setValue('Sam'); lastName.setValue('Green'); email.setValue('Sam.Green@litigant.com'); @@ -634,41 +569,6 @@ describe('AddParticipantComponent', () => { component.next(); expect(routerSpy.navigate).toHaveBeenCalledWith(['/video-access-points']); }); - it('the case roles and hearing roles were populated', () => { - component.setupRoles(roleList); - expect(component.roleList.length).toBe(2); - expect(component.roleList[0]).toEqual(Constants.PleaseSelect); - - expect(component.hearingRoleList.length).toBe(5); - expect(component.hearingRoleList[0]).toEqual(Constants.PleaseSelect); - }); - it('party selected will reset hearing roles', () => { - role.setValue('Applicant'); - component.partySelected(); - expect(component.isRoleSelected).toBeTruthy(); - expect(component.hearingRoleList.length).toBe(1); - }); - it('should not add second time value: Please select to a hearing role list', () => { - const roles = new PartyModel('Applicant'); - roles.hearingRoles = [ - new HearingRoleModel(Constants.PleaseSelect, 'None'), - new HearingRoleModel('Representative', 'Representative') - ]; - component.caseAndHearingRoles = [roles]; - role.setValue('Applicant'); - component.setupHearingRoles('Applicant'); - expect(component.hearingRoleList.length).toBe(2); - }); - it('the hearing role list should be empty if selected party name was not found, ', () => { - const roles = new PartyModel('Applicant'); - roles.hearingRoles = [ - new HearingRoleModel(Constants.PleaseSelect, 'None'), - new HearingRoleModel('Representative', 'Representative') - ]; - component.caseAndHearingRoles = [roles]; - component.setupHearingRoles('Respondent'); - expect(component.hearingRoleList.length).toBe(1); - }); it('should set to true isTitleSelected', () => { title.setValue('Mr'); component.titleSelected(); @@ -692,83 +592,7 @@ describe('AddParticipantComponent', () => { component.handleContinueBooking(); expect(component.showCancelPopup).toBeFalsy(); }); - it('should not list an interpreter in hearing roles if there are no interpretees in the participant list', fakeAsync(() => { - component.ngOnInit(); - component.ngAfterViewInit(); - tick(1000); - expect(component.hearingRoleList).toContain('Interpreter'); - component.hearing.participants = []; - component.setupHearingRoles('Claimant'); - tick(1000); - expect(component.hearingRoleList).not.toContain('Interpreter'); - })); - it('should show the interpreter in hearings role if lip or witness is added', fakeAsync(() => { - component.ngOnInit(); - component.ngAfterViewInit(); - tick(1000); - component.setupHearingRoles('Claimant'); - expect(component.hearingRoleList).not.toContain('Interpreter'); - })); - it('should not show the interpreter option in hearings role if an interpreter participant is added', fakeAsync(() => { - component.ngOnInit(); - component.ngAfterViewInit(); - tick(1000); - component.hearing.participants = []; - component.setupHearingRoles('Claimant'); - expect(component.hearingRoleList).not.toContain('Interpreter'); - let participant01 = new ParticipantModel(); - participant01.first_name = 'firstName'; - participant01.last_name = 'lastName'; - participant01.hearing_role_name = 'Witness'; - participant01.user_role_name = 'Individual'; - component.hearing.participants.push(participant01); - participant01 = new ParticipantModel(); - participant01.first_name = 'firstName'; - participant01.last_name = 'lastName'; - participant01.hearing_role_name = 'Interpreter'; - participant01.user_role_name = 'Individual'; - component.hearing.participants.push(participant01); - component.setupHearingRoles('Claimant'); - tick(1000); - expect(component.hearingRoleList).not.toContain('Interpreter'); - })); - it('should not show the interpreter option in hearings role if observer/appraiser participant is added.', fakeAsync(() => { - component.ngOnInit(); - component.ngAfterViewInit(); - tick(1000); - component.hearing.participants = []; - expect(component.hearingRoleList).toContain('Interpreter'); - let participant01 = new ParticipantModel(); - participant01.first_name = 'firstName'; - participant01.last_name = 'lastName'; - participant01.hearing_role_name = 'Observer'; - participant01.case_role_name = 'Observer'; - participant01.user_role_name = 'Individual'; - component.hearing.participants.push(participant01); - participant01 = new ParticipantModel(); - participant01.first_name = 'firstName'; - participant01.last_name = 'lastName'; - participant01.hearing_role_name = 'Appraiser'; - participant01.case_role_name = 'Observer'; - participant01.user_role_name = 'Individual'; - component.hearing.participants.push(participant01); - participant01 = new ParticipantModel(); - participant01.first_name = 'firstName'; - participant01.last_name = 'lastName'; - participant01.hearing_role_name = 'Observer'; - participant01.case_role_name = 'Vets UK'; - participant01.user_role_name = 'Individual'; - component.hearing.participants.push(participant01); - participant01 = new ParticipantModel(); - participant01.first_name = 'firstName'; - participant01.last_name = 'lastName'; - participant01.hearing_role_name = 'Observer'; - participant01.case_role_name = Constants.None; - participant01.user_role_name = 'Individual'; - component.hearing.participants.push(participant01); - component.setupHearingRoles('Applicant'); - expect(component.hearingRoleList).not.toContain('Interpreter'); - })); + it('should not show observers in the interpretee list', fakeAsync(() => { component.ngOnInit(); component.ngAfterViewInit(); @@ -778,23 +602,13 @@ describe('AddParticipantComponent', () => { observer01.first_name = 'firstName'; observer01.last_name = 'lastName'; observer01.hearing_role_name = 'Observer'; - observer01.case_role_name = 'Observer'; observer01.user_role_name = 'Individual'; component.hearing.participants.push(observer01); - const observer02 = new ParticipantModel(); - observer02.id = 'Observer Appraiser'; - observer02.first_name = 'firstName'; - observer02.last_name = 'lastName'; - observer02.hearing_role_name = 'Appraiser'; - observer02.case_role_name = 'Observer'; - observer02.user_role_name = 'Individual'; - component.hearing.participants.push(observer02); const observer03 = new ParticipantModel(); observer03.id = 'Vets UK Observer'; observer03.first_name = 'firstName'; observer03.last_name = 'lastName'; observer03.hearing_role_name = 'Observer'; - observer03.case_role_name = 'Vets UK'; observer03.user_role_name = 'Individual'; component.hearing.participants.push(observer03); const observer04 = new ParticipantModel(); @@ -802,12 +616,10 @@ describe('AddParticipantComponent', () => { observer04.first_name = 'firstName'; observer04.last_name = 'lastName'; observer04.hearing_role_name = 'Observer'; - observer04.case_role_name = Constants.None; observer04.user_role_name = 'Individual'; component.hearing.participants.push(observer04); component.populateInterpretedForList(); expect(component.interpreteeList.find(i => i.id === observer01.id)).toBeUndefined(); - expect(component.interpreteeList.find(i => i.id === observer02.id)).toBeUndefined(); expect(component.interpreteeList.find(i => i.id === observer03.id)).toBeUndefined(); expect(component.interpreteeList.find(i => i.id === observer04.id)).toBeUndefined(); })); @@ -842,7 +654,6 @@ describe('AddParticipantComponent', () => { pa1.is_judge = false; pa1.email = 'firstname.lastname-interpretee@email.com'; pa1.hearing_role_name = 'Litigant in Person'; - pa1.case_role_name = 'Claimant'; const pa2 = new ParticipantModel(); pa2.first_name = 'firstname'; @@ -851,7 +662,6 @@ describe('AddParticipantComponent', () => { pa2.is_judge = false; pa2.email = 'firstname.lastname-interpreter@email.com'; pa2.hearing_role_name = 'Interpreter'; - pa2.case_role_name = 'Claimant'; pa2.interpreterFor = 'firstname.lastname-interpretee@email.com'; component.hearing.participants.push(pa1); component.hearing.participants.push(pa2); @@ -878,7 +688,6 @@ describe('AddParticipantComponent', () => { part1.is_judge = false; part1.email = 'firstname.lastname-interpretee@email.com'; part1.hearing_role_name = 'Litigant in Person'; - part1.case_role_name = 'Claimant'; const part2 = new ParticipantModel(); part2.first_name = 'firstname'; @@ -887,7 +696,6 @@ describe('AddParticipantComponent', () => { part2.is_judge = false; part2.email = 'firstname.lastname-interpreter@email.com'; part2.hearing_role_name = 'Interpreter'; - part2.case_role_name = 'Claimant'; part2.interpreterFor = 'firstname.lastname-interpretee@email.com'; component.hearing.participants.push(part1); component.hearing.participants.push(part2); @@ -1025,7 +833,6 @@ describe('AddParticipantComponent edit mode', () => { beforeEach(waitForAsync(() => { videoHearingsServiceSpy = jasmine.createSpyObj<VideoHearingsService>([ 'getCurrentRequest', - 'getParticipantRoles', 'setBookingHasChanged', 'unsetBookingHasChanged', 'updateHearingRequest', @@ -1055,10 +862,8 @@ describe('AddParticipantComponent edit mode', () => { launchDarklyServiceSpy.getFlag.withArgs(FeatureFlags.specialMeasures).and.returnValue(of(false)); const hearing = initExistHearingRequest(); - videoHearingsServiceSpy.getParticipantRoles.and.returnValue(Promise.resolve(roleList)); videoHearingsServiceSpy.getCurrentRequest.and.returnValue(hearing); videoHearingsServiceSpy.getHearingRoles.and.returnValue(Promise.resolve(flatRoleList)); - participantServiceSpy.mapParticipantsRoles.and.returnValue(partyList); participantServiceSpy.mapParticipantHearingRoles.and.returnValue(mappedHearingRoles); bookingServiceSpy.isEditMode.and.returnValue(true); bookingServiceSpy.getParticipantEmail.and.returnValue('test3@hmcts.net'); @@ -1072,7 +877,6 @@ describe('AddParticipantComponent edit mode', () => { fixture.detectChanges(); role = component.form.controls['role']; - party = component.form.controls['party']; title = component.form.controls['title']; firstName = component.form.controls['firstName']; lastName = component.form.controls['lastName']; @@ -1084,9 +888,7 @@ describe('AddParticipantComponent edit mode', () => { interpretee = component.form.controls['interpreterFor']; })); - afterEach(() => { - videoHearingsServiceSpy.getParticipantRoles.calls.reset(); - }); + afterEach(() => {}); it('should initialize form controls', () => { component.initialiseForm(); @@ -1116,7 +918,6 @@ describe('AddParticipantComponent edit mode', () => { title: 'Mr', firstName: participant.first_name, lastName: participant.last_name, - party: 'Panel Member', role: 'Panel Member', email: participant.email, phone: participant.phone, @@ -1225,12 +1026,8 @@ describe('AddParticipantComponent edit mode', () => { fixture.detectChanges(); fixture.whenStable().then(() => { - const partyControl = component.form.controls['party']; - const partyElement = fixture.debugElement.query(By.css('#party')); expect(videoHearingsServiceSpy.getHearingRoles).toHaveBeenCalled(); - expect(partyControl.hasValidator(Validators.required)).toBeFalsy(); expect(component.hearingRoleList).toEqual(['Please select', 'Applicant', 'Litigant in person']); - expect(partyElement).toBeNull(); expect(component.displayNextButton).toBeTruthy(); expect(component.displayClearButton).toBeFalsy(); expect(component.displayAddButton).toBeFalsy(); @@ -1245,7 +1042,6 @@ describe('AddParticipantComponent edit mode', () => { component.searchEmail.email = 'mock@hmcts.net'; role.setValue('Representative'); - party.setValue('Applicant'); firstName.setValue('Sam'); lastName.setValue('Green'); email.setValue('Sam.Green@Representative.com'); @@ -1279,7 +1075,6 @@ describe('AddParticipantComponent edit mode', () => { fixture.detectChanges(); component.searchEmail.email = participant.email; component.form.setValue({ - party: 'Applicant', role: 'Representative', title: 'Ms', firstName: participant.first_name, @@ -1305,7 +1100,6 @@ describe('AddParticipantComponent edit mode', () => { fixture.detectChanges(); component.searchEmail.email = participant.email; component.form.setValue({ - party: Constants.PleaseSelect, role: '', title: Constants.PleaseSelect, firstName: participant.first_name, @@ -1395,7 +1189,6 @@ describe('AddParticipantComponent edit mode', () => { part1.is_judge = false; part1.email = 'firstname.lastname-interpretee@email.com'; part1.hearing_role_name = 'Litigant in Person'; - part1.case_role_name = 'Claimant'; part1.id = '100'; const part2 = new ParticipantModel(); @@ -1405,7 +1198,6 @@ describe('AddParticipantComponent edit mode', () => { part2.is_judge = false; part2.email = 'firstname.lastname-interpreter@email.com'; part2.hearing_role_name = 'Interpreter'; - part2.case_role_name = 'Claimant'; part2.interpreterFor = 'firstname.lastname-interpretee@email.com'; part2.id = '300'; component.hearing.participants.push(part1); @@ -1432,7 +1224,6 @@ describe('AddParticipantComponent edit mode', () => { spyOn(component.searchEmail, 'validateEmail').and.returnValue(true); component.searchEmail.email = 'test7@hmcts.net'; role.setValue('Interpreter'); - party.setValue('Applicant'); firstName.setValue('Test'); lastName.setValue('Participant8'); title.setValue('Mr'); @@ -1451,7 +1242,6 @@ describe('AddParticipantComponent edit mode no participants added', () => { beforeEach(waitForAsync(() => { const hearing = initExistHearingRequest(); videoHearingsServiceSpy = jasmine.createSpyObj<VideoHearingsService>([ - 'getParticipantRoles', 'getCurrentRequest', 'setBookingHasChanged', 'unsetBookingHasChanged', @@ -1462,10 +1252,8 @@ describe('AddParticipantComponent edit mode no participants added', () => { 'getHearingRoles' ]); launchDarklyServiceSpy = jasmine.createSpyObj<LaunchDarklyService>('LaunchDarklyService', ['getFlag']); - videoHearingsServiceSpy.getParticipantRoles.and.returnValue(Promise.resolve(roleList)); videoHearingsServiceSpy.getCurrentRequest.and.returnValue(hearing); videoHearingsServiceSpy.getHearingRoles.and.returnValue(Promise.resolve(flatRoleList)); - participantServiceSpy.mapParticipantsRoles.and.returnValue(partyList); participantServiceSpy.mapParticipantHearingRoles.and.returnValue(mappedHearingRoles); bookingServiceSpy = jasmine.createSpyObj<BookingService>(['getParticipantEmail', 'isEditMode', 'setEditMode', 'resetEditMode']); bookingServiceSpy.isEditMode.and.returnValue(true); @@ -1496,7 +1284,6 @@ describe('AddParticipantComponent edit mode no participants added', () => { component.ngOnInit(); role = component.form.controls['role']; - party = component.form.controls['party']; title = component.form.controls['title']; firstName = component.form.controls['firstName']; lastName = component.form.controls['lastName']; @@ -1517,9 +1304,9 @@ describe('AddParticipantComponent edit mode no participants added', () => { expect(bookingServiceSpy.getParticipantEmail).toHaveBeenCalled(); expect(component.selectedParticipantEmail).toBe(''); expect(component.showDetails).toBeFalsy(); - expect(component.displayNextButton).toBeTruthy(); - expect(component.displayClearButton).toBeFalsy(); - expect(component.displayAddButton).toBeFalsy(); + expect(component.displayNextButton).toBeFalsy(); + expect(component.displayClearButton).toBeTruthy(); + expect(component.displayAddButton).toBeTruthy(); expect(component.displayUpdateButton).toBeFalsy(); }); })); @@ -1568,7 +1355,6 @@ describe('AddParticipantComponent edit mode no participants added', () => { participant.hearing_role_name = HearingRoles.INTERPRETER; component.isRoleSelected = true; component.form.setValue({ - party: 'Applicant', role: 'Representative', title: 'Ms', firstName: participant.first_name, @@ -1618,7 +1404,7 @@ describe('AddParticipantComponent edit mode no participants added', () => { tick(1000); expect(component.showDetails).toBeFalsy(); - expect(component.displayAddButton).toBeFalsy(); + expect(component.displayAddButton).toBeTruthy(); })); it('should set existingParticipant to false', () => { participant.id = ''; @@ -1632,26 +1418,6 @@ describe('AddParticipantComponent edit mode no participants added', () => { component.getParticipant(participant); expect(component.existingParticipant).toBeTruthy(); }); - it('should reset hearing roles drop down if participant case role changed', () => { - spyOn(component, 'setupHearingRoles'); - participant.id = undefined; - participant.case_role_name = 'Applicant'; - component.participantDetails = participant; - - component.resetPartyAndRole(); - - expect(component.setupHearingRoles).toHaveBeenCalled(); - }); - it('should set case role value from the input field', () => { - participant.id = undefined; - participant.case_role_name = undefined; - component.isPartySelected = true; - component.participantDetails = participant; - - component.resetPartyAndRole(); - expect(component.participantDetails.case_role_name).toBeTruthy(); - expect(component.participantDetails.case_role_name).toEqual(Constants.PleaseSelect); - }); it('should set hearing role value from the input field', () => { participant.id = undefined; participant.hearing_role_name = undefined; @@ -1750,10 +1516,8 @@ describe('AddParticipantComponent edit mode no participants added', () => { describe('AddParticipantComponent set representer', () => { beforeEach(waitForAsync(() => { const hearing = initExistHearingRequest(); - videoHearingsServiceSpy.getParticipantRoles.and.returnValue(Promise.resolve(roleList)); videoHearingsServiceSpy.getCurrentRequest.and.returnValue(hearing); videoHearingsServiceSpy.getHearingRoles.and.returnValue(Promise.resolve(flatRoleList)); - participantServiceSpy.mapParticipantsRoles.and.returnValue(partyList); participantServiceSpy.mapParticipantHearingRoles.and.returnValue(mappedHearingRoles); bookingServiceSpy.isEditMode.and.returnValue(true); bookingServiceSpy.getParticipantEmail.and.returnValue(''); @@ -1775,7 +1539,6 @@ describe('AddParticipantComponent set representer', () => { component.ngOnInit(); role = component.form.controls['role']; - party = component.form.controls['party']; title = component.form.controls['title']; firstName = component.form.controls['firstName']; lastName = component.form.controls['lastName']; @@ -1790,8 +1553,6 @@ describe('AddParticipantComponent set representer', () => { })); it('should show company and name of representing person', () => { - component.caseAndHearingRoles = partyList; - component.form.get('party').setValue('Applicant'); component.form.get('role').setValue('Representative'); component.roleSelected(); diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.ts index e29db5286..877e92c96 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/add-participant/add-participant.component.ts @@ -7,7 +7,7 @@ import { SanitizeInputText } from '../../common/formatters/sanitize-input-text'; import { IDropDownModel } from '../../common/model/drop-down.model'; import { ParticipantModel } from '../../common/model/participant.model'; import { BookingService } from '../../services/booking.service'; -import { CaseAndHearingRolesResponse, HearingRoleResponse } from '../../services/clients/api-client'; +import { HearingRoleResponse } from '../../services/clients/api-client'; import { Logger } from '../../services/logger'; import { SearchService } from '../../services/search.service'; import { VideoHearingsService } from '../../services/video-hearings.service'; @@ -16,7 +16,6 @@ import { ParticipantService } from '../services/participant.service'; import { ParticipantListComponent } from '../participant'; import { HearingRoles } from '../../common/model/hearing-roles.model'; import { LinkedParticipantModel, LinkedParticipantType } from 'src/app/common/model/linked-participant.model'; -import { Validators } from '@angular/forms'; import { takeUntil } from 'rxjs/operators'; import { FeatureFlags, LaunchDarklyService } from 'src/app/services/launch-darkly.service'; import { InterpreterSelectedDto } from '../interpreter-form/interpreter-selected.model'; @@ -131,7 +130,6 @@ export class AddParticipantComponent extends AddParticipantBaseDirective impleme .getHearingRoles() .then((data: HearingRoleResponse[]) => { self.setupRolesWithoutCaseRole(data); - self.removePartyValidators(); self.handleRoleSetupForEditMode(self); }) .catch(error => this.logger.error(`${this.loggerPrefix} Error getting hearing roles.`, error)); @@ -184,7 +182,6 @@ export class AddParticipantComponent extends AddParticipantBaseDirective impleme initialiseForm() { super.initialiseForm(); - this.party.setValidators([Validators.required, Validators.pattern(this.constants.PleaseSelectPattern)]); const self = this; this.$subscriptions.push( @@ -196,7 +193,6 @@ export class AddParticipantComponent extends AddParticipantBaseDirective impleme if ( self.showDetails && self.role.value === self.constants.PleaseSelect && - self.party.value === self.constants.PleaseSelect && self.title.value === self.constants.PleaseSelect && self.firstName.value === '' && self.lastName.value === '' && @@ -204,11 +200,7 @@ export class AddParticipantComponent extends AddParticipantBaseDirective impleme self.displayName.value === '' ) { self.displayNext(); - } else if ( - !self.showDetails && - self.role.value === self.constants.PleaseSelect && - self.party.value === self.constants.PleaseSelect - ) { + } else if (!self.showDetails && self.role.value === self.constants.PleaseSelect) { self.displayNext(); } else if (self.showDetails && self.form.valid && self.searchEmail?.validateEmail()) { if (self.localEditMode) { @@ -224,11 +216,6 @@ export class AddParticipantComponent extends AddParticipantBaseDirective impleme ); } - private removePartyValidators() { - this.party.clearValidators(); - this.party.updateValueAndValidity(); - } - private repopulateParticipantToEdit() { const selectedParticipant = this.hearing.participants.find(s => s.email === this.selectedParticipantEmail); if (selectedParticipant) { @@ -255,15 +242,6 @@ export class AddParticipantComponent extends AddParticipantBaseDirective impleme } } - setupRoles(data: CaseAndHearingRolesResponse[]) { - this.caseAndHearingRoles = this.participantService.mapParticipantsRoles(data); - this.roleList = this.caseAndHearingRoles.filter(x => x.name !== 'Judge' && x.name !== 'Staff Member').map(x => x.name); - this.roleList.unshift(this.constants.PleaseSelect); - this.caseAndHearingRoles.forEach(x => { - this.setupHearingRoles(x.name); - }); - } - setupRolesWithoutCaseRole(data: HearingRoleResponse[]) { this.hearingRoles = this.participantService .mapParticipantHearingRoles(data) @@ -305,11 +283,6 @@ export class AddParticipantComponent extends AddParticipantBaseDirective impleme this.displayUpdateButton = false; } - partySelected() { - this.isPartySelected = this.party.value !== this.constants.PleaseSelect; - this.setupHearingRoles(this.party.value); - } - onRoleSelected($event) { $event.stopImmediatePropagation(); this.roleSelected(); @@ -479,8 +452,6 @@ export class AddParticipantComponent extends AddParticipantBaseDirective impleme newParticipant.last_name = this.lastName.value; newParticipant.phone = this.phone.value; newParticipant.title = this.title.value === this.constants.PleaseSelect ? null : this.title.value; - newParticipant.case_role_name = this.party.value; - newParticipant.case_role_name = null; newParticipant.hearing_role_name = this.role.value; newParticipant.hearing_role_code = this.hearingRoles.find(h => h.name === this.role.value)?.code; @@ -617,7 +588,6 @@ export class AddParticipantComponent extends AddParticipantBaseDirective impleme this.enableFields(); this.form.setValue({ role: this.constants.PleaseSelect, - party: this.constants.PleaseSelect, title: this.constants.PleaseSelect, firstName: '', lastName: '', diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/assign-judge/assign-judge.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/assign-judge/assign-judge.component.spec.ts index 9a6587039..9241b9819 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/assign-judge/assign-judge.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/assign-judge/assign-judge.component.spec.ts @@ -573,7 +573,6 @@ describe('AssignJudgeComponent', () => { expect(component.courtAccountJudgeEmail).toEqual(judge.username); expect(component.judgeDisplayNameFld.value).toEqual(judge.display_name); expect(updatedJudges[0]).toBe(judge); - expect(updatedJudges[0].case_role_name).toBeNull(); expect(updatedJudges[0].hearing_role_code).toBe(Constants.HearingRoleCodes.Judge); expect(component.canNavigate).toBe(true); diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/assign-judge/assign-judge.component.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/assign-judge/assign-judge.component.ts index c36afcb37..e23a1ff92 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/assign-judge/assign-judge.component.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/assign-judge/assign-judge.component.ts @@ -348,7 +348,6 @@ export class AssignJudgeComponent extends BookingBaseComponent implements OnInit if (!this.isExistingJudge(judge)) { if (this.hearingService.canAddJudge(judge.username)) { judge.is_judge = true; - judge.case_role_name = null; judge.hearing_role_code = Constants.HearingRoleCodes.Judge; judge.hearing_role_name = 'Judge'; this.hearing.participants = this.hearing.participants.filter(x => !x.is_judge); diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/create-hearing/create-hearing.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/create-hearing/create-hearing.component.spec.ts index 19c15b058..89baf4f80 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/create-hearing/create-hearing.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/create-hearing/create-hearing.component.spec.ts @@ -22,6 +22,7 @@ import { By } from '@angular/platform-browser'; import { createMultiDayHearing } from 'src/app/testing/helpers/hearing.helpers'; import { VideoSupplier } from 'src/app/services/clients/api-client'; import { ServiceIds } from '../models/supplier-override'; +import { ReferenceDataService } from 'src/app/services/reference-data.service'; function initHearingRequest(): HearingModel { const newHearing = new HearingModel(); @@ -39,6 +40,7 @@ function initExistingHearingRequest(): HearingModel { } let videoHearingsServiceSpy: jasmine.SpyObj<VideoHearingsService>; +let refDataServiceSpy: jasmine.SpyObj<ReferenceDataService>; let launchDarklyServiceSpy: jasmine.SpyObj<LaunchDarklyService>; let routerSpy: jasmine.SpyObj<Router>; const errorService: jasmine.SpyObj<ErrorService> = jasmine.createSpyObj('ErrorService', ['handleError']); @@ -65,23 +67,26 @@ describe('CreateHearingComponent with multiple Services', () => { .withArgs(FeatureFlags.supplierOverrides, defaultOverrideValue) .and.returnValue(of(defaultOverrideValue)); + refDataServiceSpy = jasmine.createSpyObj<ReferenceDataService>('ReferenceDataService', ['getHearingTypes']); + videoHearingsServiceSpy = jasmine.createSpyObj<VideoHearingsService>('VideoHearingsService', [ - 'getHearingTypes', 'getCurrentRequest', 'updateHearingRequest', 'setBookingHasChanged', 'unsetBookingHasChanged' ]); + routerSpy = jasmine.createSpyObj('Router', ['navigate']); videoHearingsServiceSpy.getCurrentRequest.and.returnValue(newHearing); - videoHearingsServiceSpy.getHearingTypes.and.returnValue(of(MockValues.HearingTypesList)); + refDataServiceSpy.getHearingTypes.and.returnValue(of(MockValues.HearingTypesList)); bookingServiceSpy = jasmine.createSpyObj('BookingSErvice', ['isEditMode', 'resetEditMode', 'removeEditMode']); TestBed.configureTestingModule({ imports: [SharedModule, RouterTestingModule], providers: [ { provide: VideoHearingsService, useValue: videoHearingsServiceSpy }, + { provide: ReferenceDataService, useValue: refDataServiceSpy }, { provide: Router, useValue: routerSpy }, { provide: ErrorService, useValue: errorService }, { provide: BookingService, useValue: bookingServiceSpy }, @@ -208,8 +213,8 @@ describe('CreateHearingComponent with single Service', () => { .withArgs(FeatureFlags.supplierOverrides, defaultOverrideValue) .and.returnValue(of(defaultOverrideValue)); + refDataServiceSpy.getHearingTypes.and.returnValue(of(MockValues.HearingTypesList)); videoHearingsServiceSpy = jasmine.createSpyObj<VideoHearingsService>('VideoHearingsService', [ - 'getHearingTypes', 'getCurrentRequest', 'updateHearingRequest', 'cancelRequest', @@ -219,12 +224,13 @@ describe('CreateHearingComponent with single Service', () => { routerSpy = jasmine.createSpyObj('Router', ['navigate']); bookingServiceSpy = jasmine.createSpyObj('BookingSErvice', ['isEditMode', 'resetEditMode', 'removeEditMode']); videoHearingsServiceSpy.getCurrentRequest.and.returnValue(newHearing); - videoHearingsServiceSpy.getHearingTypes.and.returnValue(of(MockValues.HearingTypesSingle)); + refDataServiceSpy.getHearingTypes.and.returnValue(of(MockValues.HearingTypesSingle)); TestBed.configureTestingModule({ imports: [HttpClientModule, ReactiveFormsModule, RouterTestingModule], providers: [ { provide: VideoHearingsService, useValue: videoHearingsServiceSpy }, + { provide: ReferenceDataService, useValue: refDataServiceSpy }, { provide: Router, useValue: routerSpy }, { provide: ErrorService, useValue: errorService }, { provide: BookingService, useValue: bookingServiceSpy }, @@ -242,7 +248,7 @@ describe('CreateHearingComponent with single Service', () => { }); it('should set Service when single item returned', fakeAsync(() => { - videoHearingsServiceSpy.getHearingTypes.and.returnValue(of(MockValues.HearingTypesSingle)); + refDataServiceSpy.getHearingTypes.and.returnValue(of(MockValues.HearingTypesSingle)); fixture.detectChanges(); tick(); fixture.detectChanges(); @@ -276,7 +282,6 @@ describe('CreateHearingComponent with existing request in session', () => { .and.returnValue(of(defaultOverrideValue)); videoHearingsServiceSpy = jasmine.createSpyObj<VideoHearingsService>('VideoHearingsService', [ - 'getHearingTypes', 'getCurrentRequest', 'updateHearingRequest', 'cancelRequest', @@ -287,12 +292,13 @@ describe('CreateHearingComponent with existing request in session', () => { bookingServiceSpy = jasmine.createSpyObj('BookingSErvice', ['isEditMode', 'resetEditMode', 'removeEditMode']); videoHearingsServiceSpy.getCurrentRequest.and.returnValue(existingRequest); - videoHearingsServiceSpy.getHearingTypes.and.returnValue(of(MockValues.HearingTypesList)); + refDataServiceSpy.getHearingTypes.and.returnValue(of(MockValues.HearingTypesList)); TestBed.configureTestingModule({ imports: [HttpClientModule, ReactiveFormsModule, RouterTestingModule], providers: [ { provide: VideoHearingsService, useValue: videoHearingsServiceSpy }, + { provide: ReferenceDataService, useValue: refDataServiceSpy }, { provide: Router, useValue: routerSpy }, { provide: ErrorService, useValue: errorService }, { provide: BookingService, useValue: bookingServiceSpy }, diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/create-hearing/create-hearing.component.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/create-hearing/create-hearing.component.ts index 205aace4b..3baa1ef42 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/create-hearing/create-hearing.component.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/create-hearing/create-hearing.component.ts @@ -16,6 +16,7 @@ import { FeatureFlags, LaunchDarklyService } from '../../services/launch-darkly. import { takeUntil } from 'rxjs/operators'; import { combineLatest, Subject } from 'rxjs'; import { ServiceIds } from '../models/supplier-override'; +import { ReferenceDataService } from 'src/app/services/reference-data.service'; @Component({ selector: 'app-create-hearing', @@ -30,7 +31,7 @@ export class CreateHearingComponent extends BookingBaseComponent implements OnIn availableHearingTypes: HearingTypeResponse[]; availableCaseTypes: string[]; selectedCaseType: string; - filteredHearingTypes: HearingTypeResponse[] = []; + selectedCaseTypeServiceId: string; hasSaved: boolean; isExistingHearing: boolean; destroyed$ = new Subject<void>(); @@ -49,7 +50,8 @@ export class CreateHearingComponent extends BookingBaseComponent implements OnIn protected bookingService: BookingService, protected logger: Logger, private readonly errorService: ErrorService, - private readonly launchDarklyService: LaunchDarklyService + private readonly launchDarklyService: LaunchDarklyService, + private readonly referenceDataService: ReferenceDataService ) { super(bookingService, router, hearingService, logger); this.attemptingCancellation = false; @@ -102,6 +104,7 @@ export class CreateHearingComponent extends BookingBaseComponent implements OnIn this.logger.debug(`${this.loggerPrefix} Checking for existing hearing.`); this.selectedCaseType = this.hearing.case_type; + this.selectedCaseTypeServiceId = this.hearing.case_type_service_id; if (this.hearing.case_type) { this.selectedCaseType = this.hearing.case_type; return; @@ -120,12 +123,6 @@ export class CreateHearingComponent extends BookingBaseComponent implements OnIn } } - private setHearingTypeForExistingHearing() { - if (this.hasSaved && this.filteredHearingTypes.length > 0) { - this.form.get('hearingType').setValue(this.hearing.hearing_type_id); - } - } - private initForm() { let firstCase = this.hearing.cases[0]; if (!firstCase) { @@ -137,12 +134,11 @@ export class CreateHearingComponent extends BookingBaseComponent implements OnIn firstCase.number, [Validators.required, Validators.pattern(Constants.TextInputPattern), Validators.maxLength(255)] ], - caseType: [this.selectedCaseType, [Validators.required, Validators.pattern('^((?!Please select).)*$')]], - hearingType: [this.hearing.hearing_type_id, []] + caseType: [this.selectedCaseType, [Validators.required, Validators.pattern('^((?!Please select).)*$')]] }); if (this.isExistingHearingOrParticipantsAdded()) { - ['caseType', 'hearingType'].forEach(k => { + ['caseType'].forEach(k => { this.form.get(k).disable(); }); } @@ -161,9 +157,6 @@ export class CreateHearingComponent extends BookingBaseComponent implements OnIn get caseType() { return this.form.get('caseType'); } - get hearingType() { - return this.form.get('hearingType'); - } get caseNameInvalid() { return this.caseName.invalid && (this.caseName.dirty || this.caseName.touched || this.failedSubmission); @@ -177,10 +170,6 @@ export class CreateHearingComponent extends BookingBaseComponent implements OnIn return this.caseType.invalid && (this.caseType.dirty || this.caseType.touched || this.failedSubmission); } - get hearingTypeInvalid() { - return this.hearingType.invalid && (this.hearingType.dirty || this.hearingType.touched || this.failedSubmission); - } - get canEditCaseName() { if (this.hearing.isMultiDayEdit) { return false; @@ -264,14 +253,7 @@ export class CreateHearingComponent extends BookingBaseComponent implements OnIn hearingCase.number = this.form.value.caseNumber; this.hearing.cases[0] = hearingCase; this.hearing.case_type_id = this.isExistingHearing ? this.hearing.case_type_id : this.form.getRawValue().caseType; - this.hearing.hearing_type_id = this.isExistingHearing ? this.hearing.hearing_type_id : this.form.getRawValue().hearingType; - const hearingType = this.availableHearingTypes.find(c => c.id === this.hearing.hearing_type_id); - // hearing type will be null if editing an expired hearing type - this.hearing.hearing_type_name = hearingType?.name ?? this.hearing.hearing_type_name; - this.hearing.hearing_type_code = hearingType?.code ?? this.hearing.hearing_type_code; - const hearingTypeGroup = this.availableHearingTypes.find(c => c.group === this.hearing.case_type); - // hearing type group will be null if editing an expired Service - this.hearing.case_type_service_id = hearingTypeGroup?.service_id ?? this.hearing.case_type_service_id; + this.hearing.case_type_service_id = this.selectedCaseTypeServiceId; this.hearing.supplier = this.form.getRawValue().supplier ?? this.retrieveDefaultSupplier(); this.hearingService.updateHearingRequest(this.hearing); this.logger.debug(`${this.loggerPrefix} Updated hearing request details`, { hearing: this.hearing }); @@ -279,11 +261,9 @@ export class CreateHearingComponent extends BookingBaseComponent implements OnIn private retrieveHearingTypes() { this.logger.debug(`${this.loggerPrefix} Retrieving hearing type`); - this.hearingService.getHearingTypes().subscribe({ + this.referenceDataService.getHearingTypes().subscribe({ next: (data: HearingTypeResponse[]) => { this.setupCaseTypeAndHearingTypes(data); - this.filterHearingTypes(); - this.setHearingTypeForExistingHearing(); }, error: error => this.errorService.handleError(error) }); @@ -299,11 +279,10 @@ export class CreateHearingComponent extends BookingBaseComponent implements OnIn this.logger.debug(`${this.loggerPrefix} Updating selected Service`, { caseType: this.selectedCaseType }); - const serviceId = hearingTypes.find(h => h.group === this.selectedCaseType)?.service_id; - if (this.supportedSupplierOverrides.serviceIds.includes(serviceId)) { + this.selectedCaseTypeServiceId = hearingTypes.find(h => h.group === this.selectedCaseType)?.service_id; + if (this.supportedSupplierOverrides.serviceIds.includes(this.selectedCaseTypeServiceId)) { this.displayOverrideSupplier = true; } - this.filterHearingTypes(); this.displaySupplierOverrideIfSupported(); }); @@ -337,22 +316,6 @@ export class CreateHearingComponent extends BookingBaseComponent implements OnIn } } - private filterHearingTypes() { - this.filteredHearingTypes = []; - if (this.selectedCaseType) { - this.filteredHearingTypes = this.availableHearingTypes.filter(h => h.group === this.selectedCaseType); - } - this.logger.debug(`${this.loggerPrefix} Filtering hearing types for Service`, { - caseType: this.selectedCaseType, - hearingTypes: this.filteredHearingTypes.length - }); - const pleaseSelect = new HearingTypeResponse(); - pleaseSelect.name = Constants.PleaseSelect; - pleaseSelect.id = null; - this.filteredHearingTypes.unshift(pleaseSelect); - this.hearingType.setValue(null); - } - private cancelBookingInCreateMode() { if (this.form.dirty || this.form.touched) { this.logger.debug(`${this.loggerPrefix} New booking. Changes found. Confirm if changes should be discarded.`); diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/endpoints/endpoints.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/endpoints/endpoints.component.spec.ts index 89a9c0e83..7d8fba464 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/endpoints/endpoints.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/endpoints/endpoints.component.spec.ts @@ -16,7 +16,6 @@ import { FeatureFlagDirective } from 'src/app/src/app/shared/feature-flag.direct function initHearingRequest(): HearingModel { const newHearing = new HearingModel(); - newHearing.hearing_type_id = -1; newHearing.hearing_venue_id = -1; newHearing.scheduled_duration = 0; newHearing.participants = [ diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/hearing-schedule/hearing-schedule.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/hearing-schedule/hearing-schedule.component.spec.ts index 7ba65548c..6d7936f3f 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/hearing-schedule/hearing-schedule.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/hearing-schedule/hearing-schedule.component.spec.ts @@ -525,10 +525,12 @@ describe('HearingScheduleComponent returning to page', () => { }); it('should set venue for existing hearing', () => { component.availableCourts = [ - new HearingVenueResponse({ id: 1, name: 'aa@hmcts.net' }), - new HearingVenueResponse({ id: 2, name: 'aa@hmcts.net1' }) + new HearingVenueResponse({ id: 1, name: 'aa@hmcts.net', code: '123' }), + new HearingVenueResponse({ id: 2, name: 'aa@hmcts.net1', code: '456' }) ]; component.hearing = new HearingModel(); + component.hearing.hearing_venue_id = 2; + component.hearing.court_code = '456'; component.hearing.court_name = 'aa@hmcts.net1'; component.isExistinHearing = true; component.setVenueForExistingHearing(); diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/hearing-schedule/hearing-schedule.component.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/hearing-schedule/hearing-schedule.component.ts index 3141ea5a5..51bdbf65b 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/hearing-schedule/hearing-schedule.component.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/hearing-schedule/hearing-schedule.component.ts @@ -86,8 +86,9 @@ export class HearingScheduleComponent extends BookingBaseComponent implements On }); this.failedSubmission = false; this.checkForExistingRequest(); - this.retrieveCourts(); this.initForm(); + this.retrieveCourts(); + super.ngOnInit(); } @@ -439,7 +440,7 @@ export class HearingScheduleComponent extends BookingBaseComponent implements On setVenueForExistingHearing() { if (this.isExistinHearing && this.availableCourts && this.availableCourts.length > 0) { - const selectedCourts = this.availableCourts.filter(x => x.name === this.hearing.court_name); + const selectedCourts = this.availableCourts.filter(x => x.code === this.hearing.court_code); if (selectedCourts && selectedCourts.length > 0) { this.selectedCourtName = selectedCourts[0].name; this.selectedCourtCode = selectedCourts[0].code; diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/participant/item/participant-item.component.html b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/participant/item/participant-item.component.html index 57b452051..78c305e14 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/participant/item/participant-item.component.html +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/participant/item/participant-item.component.html @@ -69,9 +69,6 @@ <div> <strong>{{ participant.representee }}</strong> </div> - <div *ngIf="displayCaseRole"> - {{ participant.case_role_name }} - </div> </ng-container> <ng-container *ngIf="isInterpreter"> @@ -81,9 +78,6 @@ <strong>{{ participant.interpretee_name }}</strong> </div> </ng-container> - <div *ngIf="displayCaseRole"> - {{ participant.case_role_name }} - </div> </ng-container> </div> @@ -95,17 +89,11 @@ <strong>{{ participant.interpretee_name }}</strong> </div> </ng-container> - <div *ngIf="displayCaseRole"> - {{ participant.case_role_name }} - </div> </div> <ng-template #otherIndividual> <div> {{ participant.hearing_role_name }} </div> - <div *ngIf="displayCaseRole"> - {{ participant.case_role_name }} - </div> </ng-template> </ng-template> diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/participant/item/participant-item.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/participant/item/participant-item.component.spec.ts index f6acee6dd..c3532de09 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/participant/item/participant-item.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/participant/item/participant-item.component.spec.ts @@ -165,18 +165,6 @@ describe('ParticipantItemComponent', () => { expect(component.isStaffMember).toBeFalsy(); }); - it('should return false if participant`s case role is None', () => { - component.participant = { - case_role_name: 'None', - is_judge: true, - is_exist_person: false, - isJudiciaryMember: false, - interpretation_language: undefined - }; - fixture.detectChanges(); - expect(component.hasCaseRole).toBeFalsy(); - }); - it('should return true if participant is an observer', () => { component.participant = { hearing_role_name: 'Observer', @@ -200,23 +188,9 @@ describe('ParticipantItemComponent', () => { fixture.detectChanges(); expect(component.isObserverOrPanelMember).toBeTruthy(); }); - - it('should return true if participant has a case role and is not a Panel Member', () => { - component.participant = { - hearing_role_name: 'Judge', - case_role_name: 'Judge', - is_judge: true, - is_exist_person: false, - isJudiciaryMember: false, - interpretation_language: undefined - }; - fixture.detectChanges(); - expect(component.displayCaseRole).toBeTruthy(); - }); it('should get judge email', () => { component.participant = { hearing_role_name: 'Judge', - case_role_name: 'Judge', is_judge: true, is_exist_person: false, isJudiciaryMember: false, @@ -228,7 +202,6 @@ describe('ParticipantItemComponent', () => { it('should get judge phone', () => { component.participant = { hearing_role_name: 'Judge', - case_role_name: 'Judge', is_judge: true, is_exist_person: false, isJudiciaryMember: false, diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/participant/item/participant-item.component.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/participant/item/participant-item.component.ts index 141a14b54..6d4dc0708 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/participant/item/participant-item.component.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/participant/item/participant-item.component.ts @@ -103,10 +103,6 @@ export class ParticipantItemComponent implements OnInit { return this.participant?.hearing_role_name === Constants.HearingRoles.StaffMember; } - get hasCaseRole() { - return this.participant?.case_role_name !== 'None'; - } - get isObserverOrPanelMember() { return ( ['Observer', 'Panel Member'].includes(this.participant?.hearing_role_name) || @@ -114,10 +110,6 @@ export class ParticipantItemComponent implements OnInit { ); } - get displayCaseRole() { - return this.hasCaseRole && !this.isObserverOrPanelMember; - } - get isInterpreter() { return this.participant.hearing_role_name === 'Interpreter' || this.participant.hearing_role_code === HearingRoleCodes.Interpreter; } diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/participant/list/participant-list.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/participant/list/participant-list.component.spec.ts index d7090aacd..001340667 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/participant/list/participant-list.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/participant/list/participant-list.component.spec.ts @@ -400,47 +400,41 @@ describe('ParticipantListComponent-SortParticipants', () => { it('should produce a sorted list with specific hierarchy and grouping', () => { const participantsArr = [ - { is_judge: true, case_role_name: null, hearing_role_name: 'Judge', first_name: 'L' }, - { is_judge: false, case_role_name: 'Winger', hearing_role_name: 'None', first_name: 'K' }, - { is_judge: false, case_role_name: 'None', hearing_role_name: 'Winger', first_name: 'J' }, - { is_judge: false, case_role_name: null, hearing_role_name: 'Staff Member', first_name: 'I' }, - { is_judge: false, case_role_name: 'None', hearing_role_name: 'Panel Member', first_name: 'H' }, - { is_judge: false, case_role_name: 'None', hearing_role_name: 'Observer', first_name: 'G' }, + { is_judge: true, hearing_role_name: 'Judge', first_name: 'L' }, + { is_judge: false, hearing_role_name: 'None', first_name: 'K' }, + { is_judge: false, hearing_role_name: 'Winger', first_name: 'J' }, + { is_judge: false, hearing_role_name: 'Staff Member', first_name: 'I' }, + { is_judge: false, hearing_role_name: 'Panel Member', first_name: 'H' }, + { is_judge: false, hearing_role_name: 'Observer', first_name: 'G' }, { is_judge: false, - case_role_name: 'Appellant', hearing_role_name: 'Litigant in Person', first_name: 'F' }, - { is_judge: false, case_role_name: 'None', hearing_role_name: 'Litigant in Person', first_name: 'E' }, + { is_judge: false, hearing_role_name: 'Litigant in Person', first_name: 'E' }, { is_judge: false, - case_role_name: 'Appellant', hearing_role_name: 'Litigant in Person', first_name: 'D' }, { is_judge: false, - case_role_name: 'Appellant', email: 'interpretees@email.co.uk', hearing_role_name: 'Litigant in Person', first_name: 'C' }, - { is_judge: false, case_role_name: 'None', hearing_role_name: 'Litigant in Person', first_name: 'B' }, + { is_judge: false, hearing_role_name: 'Litigant in Person', first_name: 'B' }, { is_judge: false, - case_role_name: 'Appellant', hearing_role_name: 'Litigant in Person', first_name: 'A' }, { is_judge: false, - case_role_name: 'None', hearing_role_name: 'Interpreter', first_name: 'A', interpreterFor: 'interpretees@email.co.uk' - }, - { is_judge: false, case_role_name: 'Observer', hearing_role_name: 'new observer type', first_name: 'M' } + } ]; if (!component.hearing.participants) { @@ -451,7 +445,6 @@ describe('ParticipantListComponent-SortParticipants', () => { is_judge: p.is_judge, hearing_role_name: p.hearing_role_name, first_name: p.first_name, - case_role_name: p.case_role_name, email: p.email, interpreterFor: p.interpreterFor, interpretation_language: undefined @@ -463,7 +456,6 @@ describe('ParticipantListComponent-SortParticipants', () => { const expectedResult: ParticipantModel[] = []; expectedResult.push({ is_judge: true, - case_role_name: null, email: undefined, hearing_role_name: 'Judge', first_name: 'L', @@ -472,7 +464,6 @@ describe('ParticipantListComponent-SortParticipants', () => { }); expectedResult.push({ is_judge: false, - case_role_name: 'None', email: undefined, hearing_role_name: 'Panel Member', first_name: 'H', @@ -481,43 +472,42 @@ describe('ParticipantListComponent-SortParticipants', () => { }); expectedResult.push({ is_judge: false, - case_role_name: 'None', email: undefined, hearing_role_name: 'Winger', first_name: 'J', interpreterFor: undefined, interpretation_language: undefined }); + expectedResult.push({ is_judge: false, - case_role_name: 'Winger', email: undefined, - hearing_role_name: 'None', - first_name: 'K', + hearing_role_name: 'Staff Member', + first_name: 'I', interpreterFor: undefined, interpretation_language: undefined }); + expectedResult.push({ is_judge: false, - case_role_name: null, email: undefined, - hearing_role_name: 'Staff Member', - first_name: 'I', + hearing_role_name: 'Litigant in Person', + first_name: 'A', interpreterFor: undefined, interpretation_language: undefined }); + expectedResult.push({ is_judge: false, - case_role_name: 'Appellant', email: undefined, hearing_role_name: 'Litigant in Person', - first_name: 'A', + first_name: 'B', interpreterFor: undefined, interpretation_language: undefined }); + expectedResult.push({ is_judge: false, - case_role_name: 'Appellant', email: 'interpretees@email.co.uk', hearing_role_name: 'Litigant in Person', first_name: 'C', @@ -527,7 +517,6 @@ describe('ParticipantListComponent-SortParticipants', () => { }); expectedResult.push({ is_judge: false, - case_role_name: 'None', email: undefined, hearing_role_name: 'Interpreter', first_name: 'A', @@ -535,60 +524,48 @@ describe('ParticipantListComponent-SortParticipants', () => { interpretee_name: undefined, interpretation_language: undefined }); + expectedResult.push({ is_judge: false, - case_role_name: 'Appellant', email: undefined, hearing_role_name: 'Litigant in Person', first_name: 'D', interpreterFor: undefined, interpretation_language: undefined }); + expectedResult.push({ is_judge: false, - case_role_name: 'Appellant', email: undefined, hearing_role_name: 'Litigant in Person', - first_name: 'F', + first_name: 'E', interpreterFor: undefined, interpretation_language: undefined }); expectedResult.push({ is_judge: false, - case_role_name: 'None', email: undefined, hearing_role_name: 'Litigant in Person', - first_name: 'B', + first_name: 'F', interpreterFor: undefined, interpretation_language: undefined }); expectedResult.push({ is_judge: false, - case_role_name: 'None', email: undefined, - hearing_role_name: 'Litigant in Person', - first_name: 'E', + hearing_role_name: 'None', + first_name: 'K', interpreterFor: undefined, interpretation_language: undefined }); expectedResult.push({ is_judge: false, - case_role_name: 'None', email: undefined, hearing_role_name: 'Observer', first_name: 'G', interpreterFor: undefined, interpretation_language: undefined }); - expectedResult.push({ - is_judge: false, - case_role_name: 'Observer', - email: undefined, - hearing_role_name: 'new observer type', - first_name: 'M', - interpreterFor: undefined, - interpretation_language: undefined - }); for (let i = 0; i < expectedResult.length; i++) { expect(component.sortedParticipants[i]).toEqual(expectedResult[i]); diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/participant/list/participant-list.component.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/participant/list/participant-list.component.ts index 25061581f..f573170b9 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/participant/list/participant-list.component.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/participant/list/participant-list.component.ts @@ -155,15 +155,15 @@ export class ParticipantListComponent implements OnInit, OnChanges, DoCheck, OnD }; } - private compareByPartyThenByFirstName() { + private compareByHearingRoleThenByFirstName() { return (a: ParticipantModel, b: ParticipantModel) => { const swapIndices = a > b ? 1 : 0; - const partyA = a.case_role_name === Constants.None ? a.hearing_role_name ?? a.hearing_role_code : a.case_role_name; - const partyB = b.case_role_name === Constants.None ? b.hearing_role_name ?? b.hearing_role_code : b.case_role_name; - if (partyA === partyB) { + const hearingRoleCodeA = a.hearing_role_code; + const hearingRoleCodeB = b.hearing_role_code; + if (hearingRoleCodeA === hearingRoleCodeB) { return a.first_name < b.first_name ? -1 : swapIndices; } - return partyA < partyB ? -1 : swapIndices; + return hearingRoleCodeA < hearingRoleCodeB ? -1 : swapIndices; }; } @@ -189,17 +189,13 @@ export class ParticipantListComponent implements OnInit, OnChanges, DoCheck, OnD (!participant.hearing_role_name || participant.hearing_role_name !== Constants.HearingRoles.Interpreter) && (!participant.hearing_role_code || participant.hearing_role_code !== HearingRoleCodes.Interpreter) ) - .sort(this.compareByPartyThenByFirstName()); + .sort(this.compareByHearingRoleThenByFirstName()); } private getObservers() { return this.hearing.participants - .filter( - participant => - Constants.HearingRoles.Observer === - (participant.case_role_name === Constants.None ? participant.hearing_role_name : participant.case_role_name) - ) - .sort(this.compareByPartyThenByFirstName()); + .filter(participant => Constants.HearingRoles.Observer === participant.hearing_role_name) + .sort(this.compareByHearingRoleThenByFirstName()); } private getJudicialPanelMembers(): ParticipantModel[] { @@ -213,22 +209,18 @@ export class ParticipantListComponent implements OnInit, OnChanges, DoCheck, OnD private getPanelMembers() { return this.hearing.participants - .filter(participant => - Constants.JudiciaryRoles.includes( - participant.case_role_name === Constants.None ? participant.hearing_role_name : participant.case_role_name - ) - ) - .sort(this.compareByPartyThenByFirstName()); + .filter(participant => Constants.JudiciaryRoles.includes(participant.hearing_role_name)) + .sort(this.compareByHearingRoleThenByFirstName()); } private getStaffMembers() { return this.hearing.participants .filter(participant => participant.hearing_role_name === Constants.HearingRoles.StaffMember) - .sort(this.compareByPartyThenByFirstName()); + .sort(this.compareByHearingRoleThenByFirstName()); } private getJudges() { - return this.hearing.participants.filter(participant => participant.is_judge).sort(this.compareByPartyThenByFirstName()); + return this.hearing.participants.filter(participant => participant.is_judge).sort(this.compareByHearingRoleThenByFirstName()); } private insertInterpreters(sortedList: ParticipantModel[]) { diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/search-email/search-email.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/search-email/search-email.component.spec.ts index 475c38366..ed98b60a8 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/search-email/search-email.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/search-email/search-email.component.spec.ts @@ -40,7 +40,6 @@ describe('SearchEmailComponent', () => { participantModel.first_name = 'Ann'; participantModel.last_name = 'Smith'; participantModel.title = 'Mrs'; - participantModel.case_role_name = 'Respondent'; participantModel.hearing_role_name = 'Litigant in person'; participantModel.phone = '12345678'; participantModel.display_name = 'Ann'; @@ -185,7 +184,6 @@ describe('SearchEmailComponent', () => { participant.first_name = 'citizen'; participant.last_name = 'one'; participantModel.title = 'Mr.'; - participantModel.case_role_name = 'Respondent'; participantModel.hearing_role_name = 'Litigant in person'; participantModel.phone = '12345678'; participantModel.display_name = 'Citizen One'; diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/search-email/search-email.component.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/search-email/search-email.component.ts index 74324a729..5b0ecdf76 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/search-email/search-email.component.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/search-email/search-email.component.ts @@ -37,8 +37,6 @@ export class SearchEmailComponent implements OnInit, OnDestroy { @Input() disabled = true; - @Input() caseRole = ''; - @Input() hearingRoleParticipant = ''; @Input() initialValue = ''; diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/services/participant.service.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/services/participant.service.spec.ts index 9dce15775..1d1ea6ae5 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/services/participant.service.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/services/participant.service.spec.ts @@ -1,7 +1,7 @@ import { TestBed, inject } from '@angular/core/testing'; import { ParticipantService } from './participant.service'; import { HttpClientModule } from '@angular/common/http'; -import { CaseAndHearingRolesResponse, HearingRole, HearingRoleResponse } from '../../services/clients/api-client'; +import { HearingRoleResponse } from '../../services/clients/api-client'; import { ParticipantModel } from '../../common/model/participant.model'; import { HearingModel } from '../../common/model/hearing.model'; import { Logger } from '../../services/logger'; @@ -20,26 +20,6 @@ describe('ParticipantService', () => { it('should be created', inject([ParticipantService], (service: ParticipantService) => { expect(service).toBeTruthy(); })); - it('should map roles to party model array', inject([ParticipantService], (service: ParticipantService) => { - const response = new CaseAndHearingRolesResponse(); - response.name = 'Respondent'; - response.hearing_roles = [new HearingRole({ name: 'Litigant in person', user_role: 'Individual' })]; - const responses: CaseAndHearingRolesResponse[] = []; - responses.push(response); - - const models = service.mapParticipantsRoles(responses); - expect(models).toBeTruthy(); - expect(models.length).toBe(1); - expect(models[0].name).toBe('Respondent'); - expect(models[0].hearingRoles.length).toBe(1); - expect(models[0].hearingRoles[0].name).toBe('Litigant in person'); - })); - it('should return empty party model array', inject([ParticipantService], (service: ParticipantService) => { - const responses: CaseAndHearingRolesResponse[] = []; - const models = service.mapParticipantsRoles(responses); - expect(models).toBeTruthy(); - expect(models.length).toBe(0); - })); it('should map roles to hearing role array', inject([ParticipantService], (service: ParticipantService) => { const responses: HearingRoleResponse[] = [ new HearingRoleResponse({ diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/services/participant.service.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/services/participant.service.ts index 4a20f31b3..13d8aa3da 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/services/participant.service.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/services/participant.service.ts @@ -1,8 +1,7 @@ import { Injectable } from '@angular/core'; import { HearingModel } from '../../common/model/hearing.model'; import { ParticipantModel } from '../../common/model/participant.model'; -import { PartyModel } from '../../common/model/party.model'; -import { CaseAndHearingRolesResponse, HearingRoleResponse } from '../../services/clients/api-client'; +import { HearingRoleResponse } from '../../services/clients/api-client'; import { Logger } from '../../services/logger'; import { HearingRoleModel } from '../../common/model/hearing-role.model'; @@ -13,18 +12,8 @@ export class ParticipantService { private readonly loggerPrefix = '[ParticipantService] -'; constructor(private readonly logger: Logger) {} - mapParticipantsRoles(caseRoles: CaseAndHearingRolesResponse[]) { - const participantRoles = caseRoles.map(s => { - const item = new PartyModel(s.name); - item.hearingRoles = s.hearing_roles.map(x => new HearingRoleModel(x.name, x.user_role)); - return item; - }); - return participantRoles; - } - mapParticipantHearingRoles(hearingRoles: HearingRoleResponse[]) { - const participantRoles = hearingRoles.map(x => new HearingRoleModel(x.name, x.user_role, x.code)); - return participantRoles; + return hearingRoles.map(x => new HearingRoleModel(x.name, x.user_role, x.code)); } public checkDuplication(email: string, participants: ParticipantModel[]): boolean { diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/summary/summary.component.html b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/summary/summary.component.html index ae713e7a0..6d332c80f 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/summary/summary.component.html +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/summary/summary.component.html @@ -32,7 +32,6 @@ <h2 class="govuk-heading-m" id="hearingSummary"> <div class="vh-text-break"><app-truncatable-text [id]="'caseNumber'" [text]="caseNumber" [maxLimit]="50"></app-truncatable-text></div> <div class="vh-text-break"><app-truncatable-text [id]="'caseName'" [text]="caseName" [maxLimit]="50"></app-truncatable-text></div> <div id="caseType">{{ caseType }}</div> - <div id="caseHearingType">{{ caseHearingType }}</div> </div> <app-booking-edit [title]="'Hearing schedule'" [editLink]="'hearing-schedule'" [elementId]="'hearing-schedule-id'"> </app-booking-edit> diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/summary/summary.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/summary/summary.component.spec.ts index 42c11eeda..9aab2589e 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/summary/summary.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/summary/summary.component.spec.ts @@ -38,6 +38,7 @@ import { ResponseTestData } from 'src/app/testing/data/response-test-data'; import { BookingStatusService } from 'src/app/services/booking-status-service'; import { FeatureFlags, LaunchDarklyService } from 'src/app/services/launch-darkly.service'; import { TruncatableTextComponent } from 'src/app/shared/truncatable-text/truncatable-text.component'; +import { ReferenceDataService } from 'src/app/services/reference-data.service'; function initExistingHearingRequest(): HearingModel { const pat1 = new ParticipantModel(); @@ -54,7 +55,6 @@ function initExistingHearingRequest(): HearingModel { newCaseRequest.number = 'TX/12345/2018'; const existingRequest = new HearingModel(); - existingRequest.hearing_type_id = 2; existingRequest.cases.push(newCaseRequest); existingRequest.hearing_venue_id = 2; existingRequest.scheduled_date_time = today; @@ -62,8 +62,6 @@ function initExistingHearingRequest(): HearingModel { existingRequest.other_information = '|OtherInformation|some notes'; existingRequest.audio_recording_required = true; existingRequest.court_room = '123W'; - const hearingTypeName = MockValues.HearingTypesList.find(c => c.id === existingRequest.hearing_type_id).name; - existingRequest.hearing_type_name = hearingTypeName; const courtString = MockValues.Courts.find(c => c.id === existingRequest.hearing_venue_id).name; existingRequest.court_name = courtString; existingRequest.isMultiDayEdit = false; @@ -89,7 +87,6 @@ function initBadHearingRequest(): HearingModel { newCaseRequest.number = 'TX/12345/2018'; const existingRequest = new HearingModel(); - existingRequest.hearing_type_id = 2; existingRequest.cases.push(newCaseRequest); existingRequest.hearing_venue_id = 2; existingRequest.scheduled_date_time = today; @@ -107,8 +104,8 @@ recordingGuardServiceSpy = jasmine.createSpyObj<RecordingGuardService>('Recordin 'mandatoryRecordingForHearingRole' ]); +const refDataServiceSpy = jasmine.createSpyObj<ReferenceDataService>('ReferenceDataService', ['getHearingTypes']); const videoHearingsServiceSpy: jasmine.SpyObj<VideoHearingsService> = jasmine.createSpyObj<VideoHearingsService>('VideoHearingsService', [ - 'getHearingTypes', 'getCurrentRequest', 'updateHearingRequest', 'saveHearing', @@ -143,7 +140,7 @@ describe('SummaryComponent with valid request', () => { const mockResp = new UpdateBookingStatusResponse(); mockResp.success = true; videoHearingsServiceSpy.getCurrentRequest.and.returnValue(existingRequest); - videoHearingsServiceSpy.getHearingTypes.and.returnValue(of(MockValues.HearingTypesList)); + refDataServiceSpy.getHearingTypes.and.returnValue(of(MockValues.HearingTypesList)); videoHearingsServiceSpy.saveHearing.and.returnValue(Promise.resolve(ResponseTestData.getHearingResponseTestData())); videoHearingsServiceSpy.cloneMultiHearings.and.callThrough(); videoHearingsServiceSpy.getStatus.and.returnValue(Promise.resolve(mockResp)); @@ -277,8 +274,6 @@ describe('SummaryComponent with valid request', () => { expect(component.otherInformation.OtherInformation).toEqual( stringifier.decode<OtherInformationModel>(existingRequest.other_information).OtherInformation ); - const hearingstring = MockValues.HearingTypesList.find(c => c.id === existingRequest.hearing_type_id).name; - expect(component.caseHearingType).toEqual(hearingstring); expect(component.hearingDate).toEqual(existingRequest.scheduled_date_time); const courtString = MockValues.Courts.find(c => c.id === existingRequest.hearing_venue_id); expect(component.courtRoomAddress).toEqual(`${courtString.name}, 123W`); @@ -378,7 +373,6 @@ describe('SummaryComponent with valid request', () => { participant.first_name = 'firstname'; participant.last_name = 'lastname'; participant.email = 'firstname.lastname@email.com'; - participant.case_role_name = 'Claimant'; participant.hearing_role_name = 'Litigant in person'; participants.push(participant); @@ -386,7 +380,6 @@ describe('SummaryComponent with valid request', () => { participant.first_name = 'firstname1'; participant.last_name = 'lastname1'; participant.email = 'firstname1.lastname1@email.com'; - participant.case_role_name = 'Claimant'; participant.hearing_role_name = 'Interpreter'; participant.interpreterFor = 'firstname.lastname@email.com'; participants.push(participant); @@ -414,7 +407,6 @@ describe('SummaryComponent with valid request', () => { participant.first_name = 'firstname'; participant.last_name = 'lastname'; participant.email = 'firstname.lastname@email.com'; - participant.case_role_name = 'Claimant'; participant.hearing_role_name = 'Litigant in person'; participants.push(participant); @@ -422,7 +414,6 @@ describe('SummaryComponent with valid request', () => { participant.first_name = 'firstname1'; participant.last_name = 'lastname1'; participant.email = 'firstname1.lastname1@email.com'; - participant.case_role_name = 'Claimant'; participant.hearing_role_name = 'Interpreter'; participant.interpreterFor = 'firstname.lastname@email.com'; participants.push(participant); @@ -643,7 +634,7 @@ describe('SummaryComponent with invalid request', () => { initExistingHearingRequest(); const existingRequest = initBadHearingRequest(); videoHearingsServiceSpy.getCurrentRequest.and.returnValue(existingRequest); - videoHearingsServiceSpy.getHearingTypes.and.returnValue(of(MockValues.HearingTypesList)); + refDataServiceSpy.getHearingTypes.and.returnValue(of(MockValues.HearingTypesList)); const validationProblem = new ValidationProblemDetails({ errors: { @@ -706,7 +697,7 @@ describe('SummaryComponent with existing request', () => { const existingRequest = initExistingHearingRequest(); existingRequest.hearing_id = '12345ty'; videoHearingsServiceSpy.getCurrentRequest.and.returnValue(existingRequest); - videoHearingsServiceSpy.getHearingTypes.and.returnValue(of(MockValues.HearingTypesList)); + refDataServiceSpy.getHearingTypes.and.returnValue(of(MockValues.HearingTypesList)); videoHearingsServiceSpy.updateHearing.and.returnValue(of(new HearingDetailsResponse())); videoHearingsServiceSpy.updateMultiDayHearing.and.returnValue(of(new HearingDetailsResponse())); @@ -758,7 +749,6 @@ describe('SummaryComponent with existing request', () => { fixture.detectChanges(); expect(component.caseNumber).toBe('TX/12345/2018'); expect(component.caseName).toBe('Mr. Test User vs HMRC'); - expect(component.caseHearingType).toBe('Automated Test'); expect(component.courtRoomAddress).toBeTruthy(); expect(component.hearingDuration).toBe('listed for 1 hour 20 minutes'); }); @@ -888,7 +878,6 @@ describe('SummaryComponent with existing request', () => { participant.first_name = 'firstname'; participant.last_name = 'lastname'; participant.email = 'firstname.lastname@email.com'; - participant.case_role_name = 'Claimant'; participant.hearing_role_name = 'Litigant in person'; participant.id = '100'; participant.linked_participants = linkedParticipants; @@ -903,7 +892,6 @@ describe('SummaryComponent with existing request', () => { participant.first_name = 'firstname1'; participant.last_name = 'lastname1'; participant.email = 'firstname1.lastname1@email.com'; - participant.case_role_name = 'Claimant'; participant.hearing_role_name = 'Interpreter'; participant.interpreterFor = ''; participant.id = '200'; @@ -939,7 +927,7 @@ describe('SummaryComponent with multi days request', () => { existingRequest.isMultiDayEdit = true; existingRequest.hearing_id = '12345ty'; videoHearingsServiceSpy.getCurrentRequest.and.returnValue(existingRequest); - videoHearingsServiceSpy.getHearingTypes.and.returnValue(of(MockValues.HearingTypesList)); + refDataServiceSpy.getHearingTypes.and.returnValue(of(MockValues.HearingTypesList)); videoHearingsServiceSpy.updateHearing.and.returnValue(of(new HearingDetailsResponse())); const participantServiceSpy = jasmine.createSpyObj<ParticipantService>('ParticipantService', ['removeParticipant']); @@ -986,7 +974,6 @@ describe('SummaryComponent with multi days request', () => { participant.first_name = 'firstname'; participant.last_name = 'lastname'; participant.email = 'firstname.lastname@email.com'; - participant.case_role_name = 'Claimant'; participant.hearing_role_name = 'Litigant in person'; participant.id = '100'; participant.linked_participants = linkedParticipants; @@ -1001,7 +988,6 @@ describe('SummaryComponent with multi days request', () => { participant.first_name = 'firstname1'; participant.last_name = 'lastname1'; participant.email = 'firstname1.lastname1@email.com'; - participant.case_role_name = 'Claimant'; participant.hearing_role_name = 'Interpreter'; participant.interpreterFor = ''; participant.id = '200'; diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/summary/summary.component.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/summary/summary.component.ts index b6ec257ca..08836d97b 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/summary/summary.component.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/booking/summary/summary.component.ts @@ -43,7 +43,6 @@ export class SummaryComponent implements OnInit, OnDestroy { bookingsSaving = false; caseNumber: string; caseName: string; - caseHearingType: string; hearingDate: Date; courtRoomAddress: string; hearingDuration: string; @@ -222,7 +221,6 @@ export class SummaryComponent implements OnInit, OnDestroy { private retrieveHearingSummary() { this.caseNumber = this.hearing.cases.length > 0 ? this.hearing.cases[0].number : ''; this.caseName = this.hearing.cases.length > 0 ? this.hearing.cases[0].name : ''; - this.caseHearingType = this.hearing.hearing_type_name; this.hearingDate = this.hearing.scheduled_date_time; this.hearingDuration = `listed for ${FormatShortDuration(this.hearing.scheduled_duration)}`; this.courtRoomAddress = this.formatCourtRoom(this.hearing.court_name, this.hearing.court_room); diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/booking-details/booking-details.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/booking-details/booking-details.component.spec.ts index dfbc80408..1abf05474 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/booking-details/booking-details.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/booking-details/booking-details.component.spec.ts @@ -41,7 +41,6 @@ export class BookingDetailsTestData { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', '', '33A', 'Coronation Street', @@ -73,7 +72,6 @@ export class BookingDetailsTestData { 'Judge', 'email.p1@hmcts.net', 'email1@hmcts.net', - 'Applicant', 'Representative', HearingRoleCodes.Representative, 'Alan Brake', @@ -94,7 +92,6 @@ export class BookingDetailsTestData { 'Citizen', 'email.p2@hmcts.net', 'email2@hmcts.net', - 'Applicant', 'Litigant in person', HearingRoleCodes.Applicant, 'Roy Bark', @@ -115,7 +112,6 @@ export class BookingDetailsTestData { 'Professional', 'email.p3@hmcts.net', 'email3@hmcts.net', - 'Respondent', 'Litigant in person', HearingRoleCodes.Respondent, 'Fill', diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/booking-participant-list/booking-participant-list.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/booking-participant-list/booking-participant-list.component.spec.ts index ee2936c89..90f99d688 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/booking-participant-list/booking-participant-list.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/booking-participant-list/booking-participant-list.component.spec.ts @@ -42,7 +42,6 @@ describe('BookingParticipantListComponent', () => { 'Citizen', 'email.p1@hmcts.net', 'email1@hmcts.net', - 'Respondent', 'Litigant in person', HearingRoleCodes.Respondent, 'Alan Brake', @@ -81,7 +80,6 @@ describe('BookingParticipantListComponent', () => { 'email.p1@hmcts.net', 'email1@hmcts.net', 'Judge', - 'Judge', null, 'Alan Brake', '', @@ -118,7 +116,6 @@ describe('BookingParticipantListComponent', () => { isJudge: p.isJudge ?? false, HearingRoleCode: p.HearingRoleCode, HearingRoleName: p.HearingRoleName, - CaseRoleName: p.CaseRoleName, LinkedParticipants: p.LinkedParticipants ?? null, ParticipantId: `${i + 1}`, Company: '', @@ -150,9 +147,6 @@ describe('BookingParticipantListComponent', () => { get isRepresenting(): boolean { return undefined; }, - showCaseRole(): boolean { - return false; - }, InterpretationLanguage: null, Screening: null }); @@ -172,48 +166,44 @@ describe('BookingParticipantListComponent', () => { const participantsInputArray = [ { - CaseRoleName: 'Appellant', HearingRoleName: 'Litigant in Person', FirstName: 'C', LinkedParticipants: linked_participantList1, Interpretee: 'interpretee' }, - { CaseRoleName: 'None', HearingRoleName: 'Interpreter', FirstName: 'A', LinkedParticipants: linked_participantList2 }, - { isJudge: true, CaseRoleName: null, HearingRoleName: 'Judge', FirstName: 'L' }, - { CaseRoleName: 'Winger', HearingRoleName: 'None', FirstName: 'K' }, - { CaseRoleName: 'None', HearingRoleName: 'Winger', FirstName: 'J' }, - { CaseRoleName: null, HearingRoleName: 'Staff Member', FirstName: 'I' }, - { CaseRoleName: 'None', HearingRoleName: 'Panel Member', FirstName: 'H' }, - { CaseRoleName: 'None', HearingRoleName: 'Observer', FirstName: 'G' }, - { CaseRoleName: 'Appellant', HearingRoleName: 'Litigant in Person', FirstName: 'F' }, - { CaseRoleName: 'None', HearingRoleName: 'Litigant in Person', FirstName: 'E' }, - { CaseRoleName: 'Appellant', HearingRoleName: 'Litigant in Person', FirstName: 'D' }, - { CaseRoleName: 'None', HearingRoleName: 'Litigant in Person', FirstName: 'B' }, - { CaseRoleName: 'Appellant', HearingRoleName: 'Litigant in Person', FirstName: 'A' }, - { CaseRoleName: 'Observer', HearingRoleName: 'new observer type', FirstName: 'M' } + { HearingRoleName: 'Interpreter', FirstName: 'A', LinkedParticipants: linked_participantList2 }, + { isJudge: true, HearingRoleName: 'Judge', FirstName: 'L' }, + { HearingRoleName: 'Winger', FirstName: 'J' }, + { HearingRoleName: 'Staff Member', FirstName: 'I' }, + { HearingRoleName: 'Panel Member', FirstName: 'H' }, + { HearingRoleName: 'Observer', FirstName: 'G' }, + { HearingRoleName: 'Litigant in Person', FirstName: 'F' }, + { HearingRoleName: 'Litigant in Person', FirstName: 'E' }, + { HearingRoleName: 'Litigant in Person', FirstName: 'D' }, + { HearingRoleName: 'Litigant in Person', FirstName: 'B' }, + { HearingRoleName: 'Litigant in Person', FirstName: 'A' }, + { HearingRoleName: 'Other role', FirstName: 'M' } ]; component.participants = parseTestInput(participantsInputArray); // expected output const expectedOutput = [ - { CaseRoleName: null, HearingRoleName: 'Judge', FirstName: 'L' }, - { CaseRoleName: 'None', HearingRoleName: 'Panel Member', FirstName: 'H' }, - { CaseRoleName: 'None', HearingRoleName: 'Winger', FirstName: 'J' }, - { CaseRoleName: 'Winger', HearingRoleName: 'None', FirstName: 'K' }, - { CaseRoleName: null, HearingRoleName: 'Staff Member', FirstName: 'I' }, - { CaseRoleName: 'Appellant', HearingRoleName: 'Litigant in Person', FirstName: 'A' }, - { CaseRoleName: 'Appellant', HearingRoleName: 'Litigant in Person', FirstName: 'C' }, - { CaseRoleName: 'None', HearingRoleName: 'Interpreter', FirstName: 'A' }, - { CaseRoleName: 'Appellant', HearingRoleName: 'Litigant in Person', FirstName: 'D' }, - { CaseRoleName: 'Appellant', HearingRoleName: 'Litigant in Person', FirstName: 'F' }, - { CaseRoleName: 'None', HearingRoleName: 'Litigant in Person', FirstName: 'B' }, - { CaseRoleName: 'None', HearingRoleName: 'Litigant in Person', FirstName: 'E' }, - { CaseRoleName: 'None', HearingRoleName: 'Observer', FirstName: 'G' }, - { CaseRoleName: 'Observer', HearingRoleName: 'new observer type', FirstName: 'M' } + { HearingRoleName: 'Judge', FirstName: 'L' }, + { HearingRoleName: 'Panel Member', FirstName: 'H' }, + { HearingRoleName: 'Winger', FirstName: 'J' }, + { HearingRoleName: 'Staff Member', FirstName: 'I' }, + { HearingRoleName: 'Litigant in Person', FirstName: 'A' }, + { HearingRoleName: 'Litigant in Person', FirstName: 'B' }, + { HearingRoleName: 'Litigant in Person', FirstName: 'C' }, + { HearingRoleName: 'Interpreter', FirstName: 'A' }, + { HearingRoleName: 'Litigant in Person', FirstName: 'D' }, + { HearingRoleName: 'Litigant in Person', FirstName: 'E' }, + { HearingRoleName: 'Litigant in Person', FirstName: 'F' }, + { HearingRoleName: 'Other role', FirstName: 'M' }, + { HearingRoleName: 'Observer', FirstName: 'G' } ]; for (let i = 0; i < expectedOutput.length; i++) { expect(component.sortedParticipants[i].FirstName).toEqual(expectedOutput[i].FirstName); - expect(component.sortedParticipants[i].CaseRoleName).toEqual(expectedOutput[i].CaseRoleName); expect(component.sortedParticipants[i].HearingRoleName).toEqual(expectedOutput[i].HearingRoleName); } done(); diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/booking-participant-list/booking-participant-list.component.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/booking-participant-list/booking-participant-list.component.ts index ea49de937..1c914eb93 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/booking-participant-list/booking-participant-list.component.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/booking-participant-list/booking-participant-list.component.ts @@ -3,7 +3,6 @@ import { ParticipantDetailsModel } from '../../common/model/participant-details. import { JudiciaryParticipantDetailsModel } from 'src/app/common/model/judiciary-participant-details.model'; import { BookingsDetailsModel } from '../../common/model/bookings-list.model'; import { Constants } from '../../common/constants'; -import {} from 'src/app/common/model/participant.model'; @Component({ selector: 'app-booking-participant-list', @@ -45,30 +44,22 @@ export class BookingParticipantListComponent { } private sortParticipants() { - const compareByPartyThenByFirstName = () => (a, b) => { + const compareByHearingRoleThenByFirstName = () => (a: ParticipantDetailsModel, b: ParticipantDetailsModel) => { const swapIndices = a > b ? 1 : 0; - const partyA = a.CaseRoleName === Constants.None ? a.HearingRoleName : a.CaseRoleName; - const partyB = b.CaseRoleName === Constants.None ? b.HearingRoleName : b.CaseRoleName; - if (partyA === partyB) { + const hearingRoleA = a.HearingRoleName; + const hearingRoleB = b.HearingRoleName; + if (hearingRoleA === hearingRoleB) { return a.FirstName < b.FirstName ? -1 : swapIndices; } - return partyA < partyB ? -1 : swapIndices; + return hearingRoleA < hearingRoleB ? -1 : swapIndices; }; const judges = this.participants.filter(participant => participant.HearingRoleName === Constants.Judge); const staffMember = this.participants.filter(participant => participant.HearingRoleName === Constants.HearingRoles.StaffMember); const panelMembersAndWingers = this.participants - .filter(participant => - Constants.JudiciaryRoles.includes( - participant.CaseRoleName === Constants.None ? participant.HearingRoleName : participant.CaseRoleName - ) - ) - .sort(compareByPartyThenByFirstName()); + .filter(participant => Constants.JudiciaryRoles.includes(participant.HearingRoleName)) + .sort(compareByHearingRoleThenByFirstName()); const interpreters = this.participants.filter(participant => participant.isInterpreter); - const observers = this.participants.filter( - participant => - Constants.HearingRoles.Observer === - (participant.CaseRoleName === Constants.None ? participant.HearingRoleName : participant.CaseRoleName) - ); + const observers = this.participants.filter(participant => Constants.HearingRoles.Observer === participant.HearingRoleName); const others = this.participants .filter( participant => @@ -78,7 +69,7 @@ export class BookingParticipantListComponent { !interpreters.includes(participant) && !observers.includes(participant) ) - .sort(compareByPartyThenByFirstName()); + .sort(compareByHearingRoleThenByFirstName()); const sorted = [...judges, ...panelMembersAndWingers, ...staffMember, ...others, ...observers]; this.insertInterpreters(interpreters, sorted); this.sortedParticipants = sorted; diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/bookings-list/bookings-list.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/bookings-list/bookings-list.component.spec.ts index 8670c90e0..e399f2932 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/bookings-list/bookings-list.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/bookings-list/bookings-list.component.spec.ts @@ -54,10 +54,9 @@ const videoHearingServiceSpy = jasmine.createSpyObj('VideoHearingService', [ 'cancelRequest', 'getHearingById', 'mapHearingDetailsResponseToHearingModel', - 'getHearingTypes', 'getUsers' ]); -const referenceDataServiceSpy = jasmine.createSpyObj('ReferenceDataService', ['getCourts']); +const referenceDataServiceSpy = jasmine.createSpyObj<ReferenceDataService>('ReferenceDataService', ['getCourts', 'getHearingTypes']); const launchDarklyServiceSpy = jasmine.createSpyObj<LaunchDarklyService>('LaunchDarklyService', ['getFlag']); let returnUrlService: ReturnUrlService; const featureFlagServiceSpy = jasmine.createSpyObj('FeatureFlagService', ['getFeatureFlagByName']); @@ -134,7 +133,6 @@ export class BookingslistTestData { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', 'JudgeGreen', '33A', 'Coronation Street', @@ -158,7 +156,6 @@ export class BookingslistTestData { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', 'JudgeGreen', '33A', 'Coronation Street', @@ -181,7 +178,7 @@ export class BookingslistTestData { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', + 'JudgeGreen', '33A', 'Coronation Street', @@ -217,7 +214,7 @@ export class BookingslistTestData { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', + 'JudgeGreen', '33A', 'Coronation Street', @@ -240,7 +237,7 @@ export class BookingslistTestData { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', + 'JudgeGreen', '33A', 'Coronation Street', @@ -263,7 +260,7 @@ export class BookingslistTestData { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', + 'JudgeGreen', '33A', 'Coronation Street', @@ -302,7 +299,7 @@ export class ArrayBookingslistModelTestData { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', + 'JudgeGreen', '33A', 'Coronation Street', @@ -325,7 +322,7 @@ export class ArrayBookingslistModelTestData { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', + 'JudgeGreen', '33A', 'Coronation Street', @@ -348,7 +345,7 @@ export class ArrayBookingslistModelTestData { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', + 'JudgeGreen', '33A', 'Coronation Street', @@ -380,7 +377,7 @@ export class ArrayBookingslistModelTestData { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', + 'JudgeGreen', '33A', 'Coronation Street', @@ -403,7 +400,7 @@ export class ArrayBookingslistModelTestData { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', + 'JudgeGreen', '33A', 'Coronation Street', @@ -426,7 +423,7 @@ export class ArrayBookingslistModelTestData { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', + 'JudgeGreen', '33A', 'Coronation Street', @@ -544,7 +541,7 @@ export class BookingPersistServiceSpy { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', + 'JudgeGreen', '33A', 'Coronation Street', @@ -587,7 +584,7 @@ describe('BookingsListComponent', () => { routerSpy = jasmine.createSpyObj('Router', ['navigate']); videoHearingServiceSpy.getHearingById.and.returnValue(of(new HearingDetailsResponse())); - videoHearingServiceSpy.getHearingTypes.and.returnValue(of(new Array<HearingTypeResponse>())); + referenceDataServiceSpy.getHearingTypes.and.returnValue(of(new Array<HearingTypeResponse>())); configServiceSpy.getConfig.and.returnValue({}); referenceDataServiceSpy.getCourts.and.returnValue(of(new Array<HearingVenueResponse>())); @@ -1079,7 +1076,7 @@ describe('BookingsListComponent', () => { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', + 'JudgeGreen', '33A', 'Coronation Street', @@ -1109,7 +1106,7 @@ describe('BookingsListComponent', () => { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', + 'JudgeGreen', '33A', 'Coronation Street', diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/hearing-details/hearing-details.component.html b/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/hearing-details/hearing-details.component.html index 78bca7062..f8444835e 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/hearing-details/hearing-details.component.html +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/hearing-details/hearing-details.component.html @@ -74,9 +74,6 @@ <h2 class="govuk-heading-s remove-header-padding">Hearing details</h2> <div class="govuk-grid-row"> <div class="govuk-body vh-sml" id="case-type">{{ hearing?.CaseType }}</div> </div> - <div class="govuk-grid-row"> - <div class="govuk-body vh-sml" id="hearing-type">{{ hearing?.HearingType }}</div> - </div> </div> <div *ngIf="hearing.isCreated"> diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/hearing-details/hearing-details.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/hearing-details/hearing-details.component.spec.ts index a3bae46a1..6a38e277e 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/hearing-details/hearing-details.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/hearing-details/hearing-details.component.spec.ts @@ -30,7 +30,6 @@ describe('HearingDetailsComponent', () => { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', 'JadgeGreen', '33A', 'Coronation Street', @@ -96,7 +95,6 @@ describe('HearingDetailsComponent', () => { 'user_role_name', 'username', 'contact_email', - 'case_role_name', 'hearing_role_name', 'hearing_role_code', 'display_name', @@ -124,7 +122,6 @@ describe('HearingDetailsComponent', () => { 'user_role_name', 'username', 'contact_email', - 'case_role_name', 'hearing_role_name', 'hearing_role_code', 'display_name', diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/participant-details/participant-details.component.html b/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/participant-details/participant-details.component.html index 1bd3290a8..7e5f77bf0 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/participant-details/participant-details.component.html +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/participant-details/participant-details.component.html @@ -51,10 +51,6 @@ </div> </ng-container> - <div id="participant-{{ participant?.ParticipantId }}-case-role-name" *ngIf="participant.showCaseRole()"> - {{ participant?.CaseRoleName }} - </div> - <ng-container *ngIf="participant?.InterpretationLanguage?.interpreterRequired"> <div class="participant-row__lang"> {{ @@ -102,9 +98,24 @@ </div> <div class="govuk-grid-row vh-mtop"> <div class="govuk-grid-column-one-quarter contact-label">Username</div> - <div id="participant-{{ participant?.ParticipantId }}-username" class="govuk-grid-column-three-quarters wrap"> + + <div + *ngIf="participant.Email !== participant.UserName; else usernamePending" + id="participant-{{ participant?.ParticipantId }}-username" + class="govuk-grid-column-three-quarters wrap" + > {{ participant?.UserName }} </div> + <ng-template #usernamePending> + <div + id="participant-{{ participant?.ParticipantId }}-username" + class="govuk-grid-column-three-quarters wrap" + appTooltip + [text]="'The account is being created. This may take a few moments. Please refresh shortly.'" + > + Pending + </div> + </ng-template> </div> <div class="govuk-grid-row vh-mtop"> <div class="govuk-grid-column-one-quarter contact-label">Telephone</div> diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/participant-details/participant-details.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/participant-details/participant-details.component.spec.ts index 3f07ae9ce..ba3bb8037 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/participant-details/participant-details.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/bookings-list/participant-details/participant-details.component.spec.ts @@ -27,7 +27,6 @@ describe('ParticipantDetailsComponent', () => { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', 'JadgeGreen', '33A', 'Coronation Street', @@ -59,7 +58,6 @@ describe('ParticipantDetailsComponent', () => { 'Citizen', 'email.p1@hmcts.net', 'email@hmcts.net', - 'Respondent', 'Respondent LIP', HearingRoleCodes.Respondent, 'Alan Brake', @@ -106,7 +104,6 @@ describe('ParticipantDetailsComponent', () => { 'Judge', 'judge@hmcts.net', 'email@hmcts.net', - 'Respondent', 'Judge', null, 'Judge', diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/booking-list.model.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/booking-list.model.spec.ts index ac9fbb71c..b04b58a02 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/booking-list.model.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/booking-list.model.spec.ts @@ -12,7 +12,6 @@ describe('BookingsDetailsModel', () => { '', '', '', - '', new Date(), '', new Date(), @@ -38,7 +37,6 @@ describe('BookingsDetailsModel', () => { '', '', '', - '', new Date(), '', new Date(), @@ -71,7 +69,6 @@ describe('BookingsDetailsModel', () => { '', '', '', - '', new Date(), '', new Date(), diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/bookings-list.model.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/bookings-list.model.ts index b288d3c2e..26311522a 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/bookings-list.model.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/bookings-list.model.ts @@ -18,7 +18,6 @@ export class BookingsDetailsModel { duration: number, hearingCaseNumber: string, hearingCaseName: string, - hearingType: string, judgeName: string, courtRoom: string, courtAddress: string, @@ -43,7 +42,6 @@ export class BookingsDetailsModel { this.Duration = duration; this.HearingCaseName = hearingCaseName; this.HearingCaseNumber = hearingCaseNumber; - this.HearingType = hearingType; this.JudgeName = judgeName; this.CourtRoom = courtRoom; this.CourtAddress = courtAddress; @@ -71,7 +69,6 @@ export class BookingsDetailsModel { Duration: number; HearingCaseNumber: string; HearingCaseName: string; - HearingType: string; JudgeName: string; CourtRoom: string; CourtAddress: string; diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/hearing.model.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/hearing.model.ts index 46a261ece..e8ab7439a 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/hearing.model.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/hearing.model.ts @@ -19,7 +19,6 @@ export class HearingModel { hearing_id?: string; scheduled_date_time?: Date; scheduled_duration?: number; - hearing_type_id?: number; cases?: CaseModel[]; participants?: ParticipantModel[]; judiciaryParticipants?: JudicialMemberDto[]; @@ -30,8 +29,6 @@ export class HearingModel { court_room?: string; hearing_venue_id?: number; case_type_id?: number; - hearing_type_name?: string; - hearing_type_code?: string; court_id?: number; court_name?: string; court_code?: string; diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/participant-details.model.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/participant-details.model.spec.ts index 6597a2656..3333e6d5f 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/participant-details.model.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/participant-details.model.spec.ts @@ -13,7 +13,7 @@ describe('participant details model', () => { 'user_role_name', 'username', 'contact_email', - 'case_role_name', + 'hearing_role_name', 'hearings_role_code', 'display_name', @@ -39,7 +39,7 @@ describe('participant details model', () => { 'user_role_name', 'username', 'contact_email', - 'case_role_name', + 'hearing_role_name', 'hearings_role_code', 'display_name', @@ -65,7 +65,7 @@ describe('participant details model', () => { 'user_role_name', 'username', 'contact_email', - 'case_role_name', + 'hearing_role_name', 'hearings_role_code', 'display_name', @@ -91,7 +91,7 @@ describe('participant details model', () => { 'user_role_name', 'username', 'contact_email', - 'case_role_name', + 'hearing_role_name', 'hearings_role_code', 'display_name', @@ -115,7 +115,7 @@ describe('participant details model', () => { 'user_role_name', 'username', 'Judiciaryemail', - 'case_role_name', + 'hearing_role_name', 'hearings_role_code', 'display_name', @@ -139,7 +139,7 @@ describe('participant details model', () => { 'Representative', 'username', 'contact_email', - 'case_role_name', + 'Representative', HearingRoleCodes.Representative, 'display_name', @@ -165,7 +165,7 @@ describe('participant details model', () => { 'user_role_name', 'username', 'contact_email', - 'case_role_name', + 'Individual', HearingRoleCodes.Applicant, 'display_name', @@ -180,102 +180,7 @@ describe('participant details model', () => { expect(model.isRepresenting).toBeFalsy(); }); - it('should return false when case role is none', () => { - const model = new ParticipantDetailsModel( - 'id', - 'externalRefId', - 'title', - 'first_name', - 'last_name', - 'user_role_name', - 'username', - 'contact_email', - 'none', - 'Individual', - HearingRoleCodes.Applicant, - 'display_name', - 'middle_names', - 'organisation', - 'representee', - '007867678678', - 'interpretee', - false, - null - ); - expect(model.showCaseRole()).toBeFalsy(); - }); - it('should return false when case role is staff member', () => { - const model = new ParticipantDetailsModel( - 'id', - 'externalRefId', - 'title', - 'first_name', - 'last_name', - 'user_role_name', - 'username', - 'contact_email', - 'Staff Member', - 'Individual', - HearingRoleCodes.StaffMember, - 'display_name', - 'middle_names', - 'organisation', - 'representee', - '007867678678', - 'staffmember', - false, - null - ); - expect(model.showCaseRole()).toBeFalsy(); - }); - it('should return false when case role is observer', () => { - const model = new ParticipantDetailsModel( - 'id', - 'externalRefId', - 'title', - 'first_name', - 'last_name', - 'user_role_name', - 'username', - 'contact_email', - 'observer', - 'Individual', - HearingRoleCodes.Observer, - 'display_name', - 'middle_names', - 'organisation', - 'representee', - '007867678678', - 'interpretee', - false, - null - ); - expect(model.showCaseRole()).toBeFalsy(); - }); - it('should return true when case role is representative', () => { - const model = new ParticipantDetailsModel( - 'id', - 'externalRefId', - 'title', - 'first_name', - 'last_name', - 'user_role_name', - 'username', - 'contact_email', - 'Representative', - 'Individual', - HearingRoleCodes.Representative, - 'display_name', - 'middle_names', - 'organisation', - 'representee', - '007867678678', - 'interpretee', - false, - null - ); - expect(model.showCaseRole()).toBeTruthy(); - }); + it('should return true when hearing role is interpreter', () => { const model = new ParticipantDetailsModel( 'id', @@ -286,7 +191,6 @@ describe('participant details model', () => { 'user_role_name', 'username', 'contact_email', - 'Citizen', 'Interpreter', HearingRoleCodes.Interpreter, 'display_name', @@ -310,7 +214,6 @@ describe('participant details model', () => { 'user_role_name', 'username', 'contact_email', - 'Citizen', 'Interpreter', HearingRoleCodes.Interpreter, 'display_name', @@ -324,28 +227,4 @@ describe('participant details model', () => { ); expect(model.isRepOrInterpreter).toBeTruthy(); }); - it('should not show case role when case role name is null', () => { - const model = new ParticipantDetailsModel( - 'id', - 'externalRefId', - 'title', - 'first_name', - 'last_name', - 'user_role_name', - 'username', - 'contact_email', - null, - 'Interpreter', - HearingRoleCodes.Interpreter, - 'display_name', - 'middle_names', - 'organisation', - 'representee', - '007867678678', - 'interpretee', - false, - null - ); - expect(model.showCaseRole()).toBeFalsy(); - }); }); diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/participant-details.model.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/participant-details.model.ts index 7f8cbb1df..56e4025b6 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/participant-details.model.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/participant-details.model.ts @@ -1,4 +1,3 @@ -import { CaseRoles } from './case-roles'; import { HearingRoleCodes, HearingRoles } from './hearing-roles.model'; import { LinkedParticipant } from '../../services/clients/api-client'; import { InterpreterSelectedDto } from 'src/app/booking/interpreter-form/interpreter-selected.model'; @@ -14,7 +13,6 @@ export class ParticipantDetailsModel { role: string, userName: string, email: string, - caseRoleName: string, hearingRoleName: string, hearingRoleCode: string, displayName: string, @@ -35,7 +33,6 @@ export class ParticipantDetailsModel { this.UserName = userName; this.Flag = false; this.Email = email; - this.CaseRoleName = caseRoleName; this.HearingRoleName = hearingRoleName; this.HearingRoleCode = hearingRoleCode; this.DisplayName = displayName; @@ -56,7 +53,6 @@ export class ParticipantDetailsModel { UserRoleName: string; UserName: string; Email: string; - CaseRoleName: string; HearingRoleName: string; HearingRoleCode: string; DisplayName: string; @@ -87,19 +83,6 @@ export class ParticipantDetailsModel { return this.UserRoleName && this.UserRoleName.indexOf('Representative') > -1 && !!this.Representee; } - showCaseRole(): boolean { - if (!this.CaseRoleName) { - return false; - } - - return !( - this.CaseRoleName.toLowerCase() === CaseRoles.NONE.toLowerCase() || - this.CaseRoleName.toLowerCase() === CaseRoles.OBSERVER.toLowerCase() || - this.CaseRoleName.toLowerCase() === CaseRoles.PANEL_MEMBER.toLowerCase() || - this.CaseRoleName.toLowerCase() === CaseRoles.STAFF_MEMBER.toLowerCase() - ); - } - get isInterpreter(): boolean { return ( (this.HearingRoleName && this.HearingRoleName.toLowerCase().trim() === HearingRoles.INTERPRETER) || diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/participant-model.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/participant-model.spec.ts index 24238437d..dd46987ad 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/participant-model.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/participant-model.spec.ts @@ -1,4 +1,4 @@ -import { JudgeAccountType, JudgeResponse, PersonResponse } from 'src/app/services/clients/api-client'; +import { JudgeAccountType, JudgeResponse, PersonResponseV2 } from 'src/app/services/clients/api-client'; import { ParticipantModel } from './participant.model'; describe('ParticipantModel', () => { @@ -12,8 +12,8 @@ describe('ParticipantModel', () => { expect(participant).toBeTruthy(); }); - it('should map PersonResponse to ParticipantModel', () => { - const person = new PersonResponse({ + it('should map PersonResponseV2 to ParticipantModel', () => { + const person = new PersonResponseV2({ contact_email: 'aa@hmcts.net', first_name: 'Sam', last_name: 'Green', @@ -35,7 +35,7 @@ describe('ParticipantModel', () => { expect(participant.username).toEqual(person.username); expect(participant.company).toEqual(person.organisation); }); - it('should mapping return empty ParticipantModel if PersonResponse is null', () => { + it('should mapping return empty ParticipantModel if PersonResponseV2 is null', () => { const person = null; participant = ParticipantModel.fromPersonResponse(person); expect(participant).toBeNull(); diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/participant.model.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/participant.model.ts index fa11189fe..61c41a940 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/participant.model.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/participant.model.ts @@ -1,4 +1,4 @@ -import { JudgeAccountType, JudgeResponse, PersonResponse } from 'src/app/services/clients/api-client'; +import { JudgeAccountType, JudgeResponse, PersonResponseV2 } from 'src/app/services/clients/api-client'; import { LinkedParticipantModel } from './linked-participant.model'; import { JudicialMemberDto } from 'src/app/booking/judicial-office-holders/models/add-judicial-member.model'; import { InterpreterSelectedDto } from 'src/app/booking/interpreter-form/interpreter-selected.model'; @@ -15,7 +15,6 @@ export class ParticipantModel { display_name?: string; username?: string; email?: string; - case_role_name?: string; hearing_role_name?: string; hearing_role_code?: string; phone?: string; @@ -43,7 +42,7 @@ export class ParticipantModel { } } - static fromPersonResponse(person: PersonResponse): ParticipantModel { + static fromPersonResponse(person: PersonResponseV2): ParticipantModel { return person ? { ...person, diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/party.model.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/party.model.ts deleted file mode 100644 index 4ed945455..000000000 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/common/model/party.model.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { HearingRoleModel } from './hearing-role.model'; - -// represents case role for a given hearing Service. -export class PartyModel { - constructor(name: string) { - this.name = name; - this.hearingRoles = []; - } - - name: string; - hearingRoles: Array<HearingRoleModel>; -} diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/booking-details.service.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/booking-details.service.spec.ts index 38ecfdd8a..a01f15716 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/booking-details.service.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/booking-details.service.spec.ts @@ -17,13 +17,9 @@ export class ResponseTestData { caseHearing.number = 'XX3456234565'; response.cases = []; response.cases.push(caseHearing); - response.hearing_type_name = 'Tax'; response.id = '1'; response.scheduled_date_time = new Date('2019-10-22 13:58:40.3730067'); response.scheduled_duration = 125; - response.hearing_venue_name = 'Coronation Street'; - response.case_type_name = 'Generic'; - response.hearing_type_name = 'Automated Test'; response.other_information = 'some note'; response.hearing_room_name = '777'; response.created_date = new Date('2019-10-22 13:58:40.3730067'); @@ -98,11 +94,9 @@ describe('booking details service', () => { expect(model).toBeTruthy(); expect(model.HearingId).toBe('1'); expect(model.Duration).toBe(125); - expect(model.CourtAddress).toBe('Coronation Street'); expect(model.CourtRoom).toBe('777'); expect(model.HearingCaseName).toBe('Smith vs Donner'); expect(model.HearingCaseNumber).toBe('XX3456234565'); - expect(model.HearingType).toBe('Automated Test'); expect(model.StartTime).toEqual(new Date('2019-10-22 13:58:40.3730067')); expect(model.CreatedBy).toBe('stub.response@hmcts.net'); expect(model.LastEditBy).toBe('stub.response@hmcts.net'); @@ -157,13 +151,9 @@ describe('booking details service', () => { caseHearing.number = 'XX3456234565'; response.cases = []; response.cases.push(caseHearing); - response.hearing_type_name = 'Tax'; response.id = '1'; response.scheduled_date_time = new Date('2019-10-22 13:58:40.3730067'); response.scheduled_duration = 125; - response.hearing_venue_name = 'Coronation Street'; - response.case_type_name = 'Civil Money Claims'; - response.hearing_type_name = 'Application to Set Judgment Aside'; response.other_information = 'some note'; response.hearing_room_name = '777'; response.created_date = new Date('2019-10-22 13:58:40.3730067'); diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/booking-details.service.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/booking-details.service.ts index 4e286967c..b819acac1 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/booking-details.service.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/booking-details.service.ts @@ -22,7 +22,6 @@ export class BookingDetailsService { hearingResponse.scheduled_duration, hearingResponse.cases && hearingResponse.cases.length > 0 ? hearingResponse.cases[0].number : '', hearingResponse.cases && hearingResponse.cases.length > 0 ? hearingResponse.cases[0].name : '', - hearingResponse.hearing_type_name, '', hearingResponse.hearing_room_name, hearingResponse.hearing_venue_name, @@ -81,7 +80,6 @@ export class BookingDetailsService { p.user_role_name, p.username, p.contact_email, - p.case_role_name, p.hearing_role_name, p.hearing_role_code, p.display_name, diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/bookings-list.service.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/bookings-list.service.spec.ts index 296276a3a..6be0b46c0 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/bookings-list.service.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/bookings-list.service.spec.ts @@ -17,7 +17,7 @@ export class ResponseTestData { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', + 'JadgeGreen', '33A', 'Coronation Street', @@ -40,7 +40,7 @@ export class ResponseTestData { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', + 'JadgeGreen', '33A', 'Coronation Street', @@ -63,7 +63,7 @@ export class ResponseTestData { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', + 'JadgeGreen', '33A', 'Coronation Street', @@ -100,7 +100,7 @@ export class ResponseTestData { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', + 'JadgeGreen', '33A', 'Coronation Street', @@ -123,7 +123,7 @@ export class ResponseTestData { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', + 'JadgeGreen', '33A', 'Coronation Street', @@ -146,7 +146,7 @@ export class ResponseTestData { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', + 'JadgeGreen', '33A', 'Coronation Street', @@ -177,7 +177,7 @@ export class ResponseTestData { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', + 'JadgeGreen', '33A', 'Coronation Street', @@ -200,7 +200,7 @@ export class ResponseTestData { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', + 'JadgeGreen', '33A', 'Coronation Street', @@ -223,7 +223,7 @@ export class ResponseTestData { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', + 'JadgeGreen', '33A', 'Coronation Street', @@ -271,7 +271,6 @@ export class ResponseTestData { bhr.court_room = '12A'; bhr.hearing_name = 'A vs B'; bhr.hearing_number = '123A'; - bhr.hearing_type_name = 'Tax'; bhr.judge_name = 'Judge'; bhr.scheduled_duration = 45; bhr.created_by = 'Roy'; @@ -288,7 +287,6 @@ export class ResponseTestData { bhr1.court_room = '12A'; bhr1.hearing_name = 'A vs B'; bhr1.hearing_number = '123A'; - bhr1.hearing_type_name = 'Tax'; bhr1.judge_name = 'Judge'; bhr1.scheduled_duration = 45; bhr1.created_by = 'Roy'; @@ -346,7 +344,6 @@ describe('bookings list service', () => { expect(model.Hearings[0].BookingsDetails[0].CourtAddress).toBe('court address'); expect(model.Hearings[0].BookingsDetails[0].HearingCaseName).toBe('A vs B'); expect(model.Hearings[0].BookingsDetails[0].HearingCaseNumber).toBe('123A'); - expect(model.Hearings[0].BookingsDetails[0].HearingType).toBe('Tax'); expect(model.Hearings[0].BookingsDetails[0].AudioRecordingRequired).toBe(true); expect(model.Hearings[0].BookingsDetails[0].GroupId).toBe('123'); }); @@ -402,7 +399,7 @@ describe('Booking list service functionality', () => { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', + 'JadgeGreen', '33A', 'Coronation Street', @@ -439,7 +436,7 @@ describe('Booking list service functionality', () => { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', + 'JadgeGreen', '33A', 'Coronation Street', diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/bookings-list.service.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/bookings-list.service.ts index 5d90f3df4..bd72187de 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/bookings-list.service.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/bookings-list.service.ts @@ -169,7 +169,6 @@ export class BookingsListService { hearing.scheduled_duration, hearing.hearing_number, hearing.hearing_name, - hearing.hearing_type_name, hearing.judge_name, hearing.court_room, hearing.court_address, diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/bookings-persist.service.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/bookings-persist.service.spec.ts index ab6c51c0b..53802d9e5 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/bookings-persist.service.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/bookings-persist.service.spec.ts @@ -20,7 +20,6 @@ function MockBookedHearing(): BookingsDetailsModel { 45, 'CaseNo', 'CaseName', - 'Financial Remedy', 'Judge Dredd', 'Manchester Room 1', 'Manchester Civil Court', diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/clients/api-client.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/clients/api-client.ts index bda2113d2..a560bddfb 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/clients/api-client.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/clients/api-client.ts @@ -2182,22 +2182,17 @@ export class BHClient extends ApiClientBase { } /** - * Find judges and court rooms accounts list by email search term. - * @param body (optional) The email address search term. + * Gets a list hearing types * @return OK */ - postJudgesBySearchTerm(body: string | undefined): Observable<JudgeResponse[]> { - let url_ = this.baseUrl + '/api/judiciary/judges'; + getHearingTypes(): Observable<HearingTypeResponse[]> { + let url_ = this.baseUrl + '/api/reference/types'; url_ = url_.replace(/[?&]$/, ''); - const content_ = JSON.stringify(body); - let options_: any = { - body: content_, observe: 'response', responseType: 'blob', headers: new HttpHeaders({ - 'Content-Type': 'application/json-patch+json', Accept: 'application/json' }) }; @@ -2205,28 +2200,28 @@ export class BHClient extends ApiClientBase { return _observableFrom(this.transformOptions(options_)) .pipe( _observableMergeMap(transformedOptions_ => { - return this.http.request('post', url_, transformedOptions_); + return this.http.request('get', url_, transformedOptions_); }) ) .pipe( _observableMergeMap((response_: any) => { - return this.processPostJudgesBySearchTerm(response_); + return this.processGetHearingTypes(response_); }) ) .pipe( _observableCatch((response_: any) => { if (response_ instanceof HttpResponseBase) { try { - return this.processPostJudgesBySearchTerm(response_ as any); + return this.processGetHearingTypes(response_ as any); } catch (e) { - return _observableThrow(e) as any as Observable<JudgeResponse[]>; + return _observableThrow(e) as any as Observable<HearingTypeResponse[]>; } - } else return _observableThrow(response_) as any as Observable<JudgeResponse[]>; + } else return _observableThrow(response_) as any as Observable<HearingTypeResponse[]>; }) ); } - protected processPostJudgesBySearchTerm(response: HttpResponseBase): Observable<JudgeResponse[]> { + protected processGetHearingTypes(response: HttpResponseBase): Observable<HearingTypeResponse[]> { const status = response.status; const responseBlob = response instanceof HttpResponse @@ -2257,20 +2252,20 @@ export class BHClient extends ApiClientBase { let resultData200 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); if (Array.isArray(resultData200)) { result200 = [] as any; - for (let item of resultData200) result200!.push(JudgeResponse.fromJS(item)); + for (let item of resultData200) result200!.push(HearingTypeResponse.fromJS(item)); } else { result200 = <any>null; } return _observableOf(result200); }) ); - } else if (status === 400) { + } else if (status === 404) { return blobToText(responseBlob).pipe( _observableMergeMap((_responseText: string) => { - let result400: any = null; - let resultData400 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); - result400 = ProblemDetails.fromJS(resultData400); - return throwException('Bad Request', status, _responseText, _headers, result400); + let result404: any = null; + let resultData404 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); + result404 = ProblemDetails.fromJS(resultData404); + return throwException('Not Found', status, _responseText, _headers, result404); }) ); } else if (status === 401) { @@ -2290,22 +2285,17 @@ export class BHClient extends ApiClientBase { } /** - * Find judiciary person list by email search term. - * @param body (optional) The email address search term. + * Get available courts * @return OK */ - searchForJudiciaryPerson(body: string | undefined): Observable<JudiciaryPerson[]> { - let url_ = this.baseUrl + '/api/judiciary/search'; + getCourts(): Observable<HearingVenueResponse[]> { + let url_ = this.baseUrl + '/api/reference/courts'; url_ = url_.replace(/[?&]$/, ''); - const content_ = JSON.stringify(body); - let options_: any = { - body: content_, observe: 'response', responseType: 'blob', headers: new HttpHeaders({ - 'Content-Type': 'application/json-patch+json', Accept: 'application/json' }) }; @@ -2313,28 +2303,28 @@ export class BHClient extends ApiClientBase { return _observableFrom(this.transformOptions(options_)) .pipe( _observableMergeMap(transformedOptions_ => { - return this.http.request('post', url_, transformedOptions_); + return this.http.request('get', url_, transformedOptions_); }) ) .pipe( _observableMergeMap((response_: any) => { - return this.processSearchForJudiciaryPerson(response_); + return this.processGetCourts(response_); }) ) .pipe( _observableCatch((response_: any) => { if (response_ instanceof HttpResponseBase) { try { - return this.processSearchForJudiciaryPerson(response_ as any); + return this.processGetCourts(response_ as any); } catch (e) { - return _observableThrow(e) as any as Observable<JudiciaryPerson[]>; + return _observableThrow(e) as any as Observable<HearingVenueResponse[]>; } - } else return _observableThrow(response_) as any as Observable<JudiciaryPerson[]>; + } else return _observableThrow(response_) as any as Observable<HearingVenueResponse[]>; }) ); } - protected processSearchForJudiciaryPerson(response: HttpResponseBase): Observable<JudiciaryPerson[]> { + protected processGetCourts(response: HttpResponseBase): Observable<HearingVenueResponse[]> { const status = response.status; const responseBlob = response instanceof HttpResponse @@ -2365,20 +2355,20 @@ export class BHClient extends ApiClientBase { let resultData200 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); if (Array.isArray(resultData200)) { result200 = [] as any; - for (let item of resultData200) result200!.push(JudiciaryPerson.fromJS(item)); + for (let item of resultData200) result200!.push(HearingVenueResponse.fromJS(item)); } else { result200 = <any>null; } return _observableOf(result200); }) ); - } else if (status === 400) { + } else if (status === 404) { return blobToText(responseBlob).pipe( _observableMergeMap((_responseText: string) => { - let result400: any = null; - let resultData400 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); - result400 = ProblemDetails.fromJS(resultData400); - return throwException('Bad Request', status, _responseText, _headers, result400); + let result404: any = null; + let resultData404 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); + result404 = ProblemDetails.fromJS(resultData404); + return throwException('Not Found', status, _responseText, _headers, result404); }) ); } else if (status === 401) { @@ -2398,22 +2388,17 @@ export class BHClient extends ApiClientBase { } /** - * Add a new justice user - * @param body (optional) - * @return Created + * Get available languages for interpreters + * @return OK */ - addNewJusticeUser(body: AddNewJusticeUserRequest | undefined): Observable<JusticeUserResponse> { - let url_ = this.baseUrl + '/api/justice-users'; + getAvailableLanguages(): Observable<AvailableLanguageResponse[]> { + let url_ = this.baseUrl + '/api/reference/available-languages'; url_ = url_.replace(/[?&]$/, ''); - const content_ = JSON.stringify(body); - let options_: any = { - body: content_, observe: 'response', responseType: 'blob', headers: new HttpHeaders({ - 'Content-Type': 'application/json', Accept: 'application/json' }) }; @@ -2421,28 +2406,28 @@ export class BHClient extends ApiClientBase { return _observableFrom(this.transformOptions(options_)) .pipe( _observableMergeMap(transformedOptions_ => { - return this.http.request('post', url_, transformedOptions_); + return this.http.request('get', url_, transformedOptions_); }) ) .pipe( _observableMergeMap((response_: any) => { - return this.processAddNewJusticeUser(response_); + return this.processGetAvailableLanguages(response_); }) ) .pipe( _observableCatch((response_: any) => { if (response_ instanceof HttpResponseBase) { try { - return this.processAddNewJusticeUser(response_ as any); + return this.processGetAvailableLanguages(response_ as any); } catch (e) { - return _observableThrow(e) as any as Observable<JusticeUserResponse>; + return _observableThrow(e) as any as Observable<AvailableLanguageResponse[]>; } - } else return _observableThrow(response_) as any as Observable<JusticeUserResponse>; + } else return _observableThrow(response_) as any as Observable<AvailableLanguageResponse[]>; }) ); } - protected processAddNewJusticeUser(response: HttpResponseBase): Observable<JusticeUserResponse> { + protected processGetAvailableLanguages(response: HttpResponseBase): Observable<AvailableLanguageResponse[]> { const status = response.status; const responseBlob = response instanceof HttpResponse @@ -2466,32 +2451,18 @@ export class BHClient extends ApiClientBase { return throwException('Internal Server Error', status, _responseText, _headers, result500); }) ); - } else if (status === 201) { - return blobToText(responseBlob).pipe( - _observableMergeMap((_responseText: string) => { - let result201: any = null; - let resultData201 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); - result201 = JusticeUserResponse.fromJS(resultData201); - return _observableOf(result201); - }) - ); - } else if (status === 400) { - return blobToText(responseBlob).pipe( - _observableMergeMap((_responseText: string) => { - let result400: any = null; - let resultData400 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); - result400 = ValidationProblemDetails.fromJS(resultData400); - return throwException('Bad Request', status, _responseText, _headers, result400); - }) - ); - } else if (status === 409) { + } else if (status === 200) { return blobToText(responseBlob).pipe( _observableMergeMap((_responseText: string) => { - let result409: any = null; - let resultData409 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); - result409 = resultData409 !== undefined ? resultData409 : <any>null; - - return throwException('Conflict', status, _responseText, _headers, result409); + let result200: any = null; + let resultData200 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); + if (Array.isArray(resultData200)) { + result200 = [] as any; + for (let item of resultData200) result200!.push(AvailableLanguageResponse.fromJS(item)); + } else { + result200 = <any>null; + } + return _observableOf(result200); }) ); } else if (status === 401) { @@ -2511,11 +2482,12 @@ export class BHClient extends ApiClientBase { } /** - * @param body (optional) + * Find judges and court rooms accounts list by email search term. + * @param body (optional) The email address search term. * @return OK */ - editJusticeUser(body: EditJusticeUserRequest | undefined): Observable<JusticeUserResponse> { - let url_ = this.baseUrl + '/api/justice-users'; + postJudgesBySearchTerm(body: string | undefined): Observable<JudgeResponse[]> { + let url_ = this.baseUrl + '/api/judiciary/judges'; url_ = url_.replace(/[?&]$/, ''); const content_ = JSON.stringify(body); @@ -2525,7 +2497,7 @@ export class BHClient extends ApiClientBase { observe: 'response', responseType: 'blob', headers: new HttpHeaders({ - 'Content-Type': 'application/json', + 'Content-Type': 'application/json-patch+json', Accept: 'application/json' }) }; @@ -2533,28 +2505,28 @@ export class BHClient extends ApiClientBase { return _observableFrom(this.transformOptions(options_)) .pipe( _observableMergeMap(transformedOptions_ => { - return this.http.request('patch', url_, transformedOptions_); + return this.http.request('post', url_, transformedOptions_); }) ) .pipe( _observableMergeMap((response_: any) => { - return this.processEditJusticeUser(response_); + return this.processPostJudgesBySearchTerm(response_); }) ) .pipe( _observableCatch((response_: any) => { if (response_ instanceof HttpResponseBase) { try { - return this.processEditJusticeUser(response_ as any); + return this.processPostJudgesBySearchTerm(response_ as any); } catch (e) { - return _observableThrow(e) as any as Observable<JusticeUserResponse>; + return _observableThrow(e) as any as Observable<JudgeResponse[]>; } - } else return _observableThrow(response_) as any as Observable<JusticeUserResponse>; + } else return _observableThrow(response_) as any as Observable<JudgeResponse[]>; }) ); } - protected processEditJusticeUser(response: HttpResponseBase): Observable<JusticeUserResponse> { + protected processPostJudgesBySearchTerm(response: HttpResponseBase): Observable<JudgeResponse[]> { const status = response.status; const responseBlob = response instanceof HttpResponse @@ -2583,7 +2555,12 @@ export class BHClient extends ApiClientBase { _observableMergeMap((_responseText: string) => { let result200: any = null; let resultData200 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); - result200 = JusticeUserResponse.fromJS(resultData200); + if (Array.isArray(resultData200)) { + result200 = [] as any; + for (let item of resultData200) result200!.push(JudgeResponse.fromJS(item)); + } else { + result200 = <any>null; + } return _observableOf(result200); }) ); @@ -2592,20 +2569,10 @@ export class BHClient extends ApiClientBase { _observableMergeMap((_responseText: string) => { let result400: any = null; let resultData400 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); - result400 = ValidationProblemDetails.fromJS(resultData400); + result400 = ProblemDetails.fromJS(resultData400); return throwException('Bad Request', status, _responseText, _headers, result400); }) ); - } else if (status === 404) { - return blobToText(responseBlob).pipe( - _observableMergeMap((_responseText: string) => { - let result404: any = null; - let resultData404 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); - result404 = resultData404 !== undefined ? resultData404 : <any>null; - - return throwException('Not Found', status, _responseText, _headers, result404); - }) - ); } else if (status === 401) { return blobToText(responseBlob).pipe( _observableMergeMap((_responseText: string) => { @@ -2623,20 +2590,22 @@ export class BHClient extends ApiClientBase { } /** - * Delete a justice user - * @param id The justice user id - * @return No Content + * Find judiciary person list by email search term. + * @param body (optional) The email address search term. + * @return OK */ - deleteJusticeUser(id: string): Observable<string> { - let url_ = this.baseUrl + '/api/justice-users/{id}'; - if (id === undefined || id === null) throw new Error("The parameter 'id' must be defined."); - url_ = url_.replace('{id}', encodeURIComponent('' + id)); + searchForJudiciaryPerson(body: string | undefined): Observable<JudiciaryPerson[]> { + let url_ = this.baseUrl + '/api/judiciary/search'; url_ = url_.replace(/[?&]$/, ''); + const content_ = JSON.stringify(body); + let options_: any = { + body: content_, observe: 'response', responseType: 'blob', headers: new HttpHeaders({ + 'Content-Type': 'application/json-patch+json', Accept: 'application/json' }) }; @@ -2644,28 +2613,28 @@ export class BHClient extends ApiClientBase { return _observableFrom(this.transformOptions(options_)) .pipe( _observableMergeMap(transformedOptions_ => { - return this.http.request('delete', url_, transformedOptions_); + return this.http.request('post', url_, transformedOptions_); }) ) .pipe( _observableMergeMap((response_: any) => { - return this.processDeleteJusticeUser(response_); + return this.processSearchForJudiciaryPerson(response_); }) ) .pipe( _observableCatch((response_: any) => { if (response_ instanceof HttpResponseBase) { try { - return this.processDeleteJusticeUser(response_ as any); + return this.processSearchForJudiciaryPerson(response_ as any); } catch (e) { - return _observableThrow(e) as any as Observable<string>; + return _observableThrow(e) as any as Observable<JudiciaryPerson[]>; } - } else return _observableThrow(response_) as any as Observable<string>; + } else return _observableThrow(response_) as any as Observable<JudiciaryPerson[]>; }) ); } - protected processDeleteJusticeUser(response: HttpResponseBase): Observable<string> { + protected processSearchForJudiciaryPerson(response: HttpResponseBase): Observable<JudiciaryPerson[]> { const status = response.status; const responseBlob = response instanceof HttpResponse @@ -2689,24 +2658,18 @@ export class BHClient extends ApiClientBase { return throwException('Internal Server Error', status, _responseText, _headers, result500); }) ); - } else if (status === 204) { - return blobToText(responseBlob).pipe( - _observableMergeMap((_responseText: string) => { - let result204: any = null; - let resultData204 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); - result204 = resultData204 !== undefined ? resultData204 : <any>null; - - return _observableOf(result204); - }) - ); - } else if (status === 404) { + } else if (status === 200) { return blobToText(responseBlob).pipe( _observableMergeMap((_responseText: string) => { - let result404: any = null; - let resultData404 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); - result404 = resultData404 !== undefined ? resultData404 : <any>null; - - return throwException('Not Found', status, _responseText, _headers, result404); + let result200: any = null; + let resultData200 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); + if (Array.isArray(resultData200)) { + result200 = [] as any; + for (let item of resultData200) result200!.push(JudiciaryPerson.fromJS(item)); + } else { + result200 = <any>null; + } + return _observableOf(result200); }) ); } else if (status === 400) { @@ -2714,7 +2677,7 @@ export class BHClient extends ApiClientBase { _observableMergeMap((_responseText: string) => { let result400: any = null; let resultData400 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); - result400 = ValidationProblemDetails.fromJS(resultData400); + result400 = ProblemDetails.fromJS(resultData400); return throwException('Bad Request', status, _responseText, _headers, result400); }) ); @@ -2735,11 +2698,12 @@ export class BHClient extends ApiClientBase { } /** + * Add a new justice user * @param body (optional) - * @return OK + * @return Created */ - restoreJusticeUser(body: RestoreJusticeUserRequest | undefined): Observable<JusticeUserResponse> { - let url_ = this.baseUrl + '/api/justice-users/restore'; + addNewJusticeUser(body: AddNewJusticeUserRequest | undefined): Observable<JusticeUserResponse> { + let url_ = this.baseUrl + '/api/justice-users'; url_ = url_.replace(/[?&]$/, ''); const content_ = JSON.stringify(body); @@ -2757,19 +2721,19 @@ export class BHClient extends ApiClientBase { return _observableFrom(this.transformOptions(options_)) .pipe( _observableMergeMap(transformedOptions_ => { - return this.http.request('patch', url_, transformedOptions_); + return this.http.request('post', url_, transformedOptions_); }) ) .pipe( _observableMergeMap((response_: any) => { - return this.processRestoreJusticeUser(response_); + return this.processAddNewJusticeUser(response_); }) ) .pipe( _observableCatch((response_: any) => { if (response_ instanceof HttpResponseBase) { try { - return this.processRestoreJusticeUser(response_ as any); + return this.processAddNewJusticeUser(response_ as any); } catch (e) { return _observableThrow(e) as any as Observable<JusticeUserResponse>; } @@ -2778,7 +2742,7 @@ export class BHClient extends ApiClientBase { ); } - protected processRestoreJusticeUser(response: HttpResponseBase): Observable<JusticeUserResponse> { + protected processAddNewJusticeUser(response: HttpResponseBase): Observable<JusticeUserResponse> { const status = response.status; const responseBlob = response instanceof HttpResponse @@ -2802,13 +2766,13 @@ export class BHClient extends ApiClientBase { return throwException('Internal Server Error', status, _responseText, _headers, result500); }) ); - } else if (status === 200) { + } else if (status === 201) { return blobToText(responseBlob).pipe( _observableMergeMap((_responseText: string) => { - let result200: any = null; - let resultData200 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); - result200 = JusticeUserResponse.fromJS(resultData200); - return _observableOf(result200); + let result201: any = null; + let resultData201 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); + result201 = JusticeUserResponse.fromJS(resultData201); + return _observableOf(result201); }) ); } else if (status === 400) { @@ -2820,14 +2784,14 @@ export class BHClient extends ApiClientBase { return throwException('Bad Request', status, _responseText, _headers, result400); }) ); - } else if (status === 404) { + } else if (status === 409) { return blobToText(responseBlob).pipe( _observableMergeMap((_responseText: string) => { - let result404: any = null; - let resultData404 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); - result404 = resultData404 !== undefined ? resultData404 : <any>null; + let result409: any = null; + let resultData409 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); + result409 = resultData409 !== undefined ? resultData409 : <any>null; - return throwException('Not Found', status, _responseText, _headers, result404); + return throwException('Conflict', status, _responseText, _headers, result409); }) ); } else if (status === 401) { @@ -2847,12 +2811,11 @@ export class BHClient extends ApiClientBase { } /** - * Find person list by email search term. - * @param body (optional) The email address search term. + * @param body (optional) * @return OK */ - postPersonBySearchTerm(body: string | undefined): Observable<PersonResponse[]> { - let url_ = this.baseUrl + '/api/persons'; + editJusticeUser(body: EditJusticeUserRequest | undefined): Observable<JusticeUserResponse> { + let url_ = this.baseUrl + '/api/justice-users'; url_ = url_.replace(/[?&]$/, ''); const content_ = JSON.stringify(body); @@ -2862,7 +2825,7 @@ export class BHClient extends ApiClientBase { observe: 'response', responseType: 'blob', headers: new HttpHeaders({ - 'Content-Type': 'application/json-patch+json', + 'Content-Type': 'application/json', Accept: 'application/json' }) }; @@ -2870,28 +2833,28 @@ export class BHClient extends ApiClientBase { return _observableFrom(this.transformOptions(options_)) .pipe( _observableMergeMap(transformedOptions_ => { - return this.http.request('post', url_, transformedOptions_); + return this.http.request('patch', url_, transformedOptions_); }) ) .pipe( _observableMergeMap((response_: any) => { - return this.processPostPersonBySearchTerm(response_); + return this.processEditJusticeUser(response_); }) ) .pipe( _observableCatch((response_: any) => { if (response_ instanceof HttpResponseBase) { try { - return this.processPostPersonBySearchTerm(response_ as any); + return this.processEditJusticeUser(response_ as any); } catch (e) { - return _observableThrow(e) as any as Observable<PersonResponse[]>; + return _observableThrow(e) as any as Observable<JusticeUserResponse>; } - } else return _observableThrow(response_) as any as Observable<PersonResponse[]>; + } else return _observableThrow(response_) as any as Observable<JusticeUserResponse>; }) ); } - protected processPostPersonBySearchTerm(response: HttpResponseBase): Observable<PersonResponse[]> { + protected processEditJusticeUser(response: HttpResponseBase): Observable<JusticeUserResponse> { const status = response.status; const responseBlob = response instanceof HttpResponse @@ -2920,12 +2883,7 @@ export class BHClient extends ApiClientBase { _observableMergeMap((_responseText: string) => { let result200: any = null; let resultData200 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); - if (Array.isArray(resultData200)) { - result200 = [] as any; - for (let item of resultData200) result200!.push(PersonResponse.fromJS(item)); - } else { - result200 = <any>null; - } + result200 = JusticeUserResponse.fromJS(resultData200); return _observableOf(result200); }) ); @@ -2934,10 +2892,20 @@ export class BHClient extends ApiClientBase { _observableMergeMap((_responseText: string) => { let result400: any = null; let resultData400 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); - result400 = ProblemDetails.fromJS(resultData400); + result400 = ValidationProblemDetails.fromJS(resultData400); return throwException('Bad Request', status, _responseText, _headers, result400); }) ); + } else if (status === 404) { + return blobToText(responseBlob).pipe( + _observableMergeMap((_responseText: string) => { + let result404: any = null; + let resultData404 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); + result404 = resultData404 !== undefined ? resultData404 : <any>null; + + return throwException('Not Found', status, _responseText, _headers, result404); + }) + ); } else if (status === 401) { return blobToText(responseBlob).pipe( _observableMergeMap((_responseText: string) => { @@ -2955,14 +2923,14 @@ export class BHClient extends ApiClientBase { } /** - * Search for non judge persons by contact email - * @param contactEmail (optional) - * @return OK + * Delete a justice user + * @param id The justice user id + * @return No Content */ - getPersonForUpdateByContactEmail(contactEmail: string | undefined): Observable<PersonResponse> { - let url_ = this.baseUrl + '/api/persons?'; - if (contactEmail === null) throw new Error("The parameter 'contactEmail' cannot be null."); - else if (contactEmail !== undefined) url_ += 'contactEmail=' + encodeURIComponent('' + contactEmail) + '&'; + deleteJusticeUser(id: string): Observable<string> { + let url_ = this.baseUrl + '/api/justice-users/{id}'; + if (id === undefined || id === null) throw new Error("The parameter 'id' must be defined."); + url_ = url_.replace('{id}', encodeURIComponent('' + id)); url_ = url_.replace(/[?&]$/, ''); let options_: any = { @@ -2976,28 +2944,28 @@ export class BHClient extends ApiClientBase { return _observableFrom(this.transformOptions(options_)) .pipe( _observableMergeMap(transformedOptions_ => { - return this.http.request('get', url_, transformedOptions_); + return this.http.request('delete', url_, transformedOptions_); }) ) .pipe( _observableMergeMap((response_: any) => { - return this.processGetPersonForUpdateByContactEmail(response_); + return this.processDeleteJusticeUser(response_); }) ) .pipe( _observableCatch((response_: any) => { if (response_ instanceof HttpResponseBase) { try { - return this.processGetPersonForUpdateByContactEmail(response_ as any); + return this.processDeleteJusticeUser(response_ as any); } catch (e) { - return _observableThrow(e) as any as Observable<PersonResponse>; + return _observableThrow(e) as any as Observable<string>; } - } else return _observableThrow(response_) as any as Observable<PersonResponse>; + } else return _observableThrow(response_) as any as Observable<string>; }) ); } - protected processGetPersonForUpdateByContactEmail(response: HttpResponseBase): Observable<PersonResponse> { + protected processDeleteJusticeUser(response: HttpResponseBase): Observable<string> { const status = response.status; const responseBlob = response instanceof HttpResponse @@ -3021,13 +2989,14 @@ export class BHClient extends ApiClientBase { return throwException('Internal Server Error', status, _responseText, _headers, result500); }) ); - } else if (status === 200) { + } else if (status === 204) { return blobToText(responseBlob).pipe( _observableMergeMap((_responseText: string) => { - let result200: any = null; - let resultData200 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); - result200 = PersonResponse.fromJS(resultData200); - return _observableOf(result200); + let result204: any = null; + let resultData204 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); + result204 = resultData204 !== undefined ? resultData204 : <any>null; + + return _observableOf(result204); }) ); } else if (status === 404) { @@ -3035,10 +3004,20 @@ export class BHClient extends ApiClientBase { _observableMergeMap((_responseText: string) => { let result404: any = null; let resultData404 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); - result404 = ProblemDetails.fromJS(resultData404); + result404 = resultData404 !== undefined ? resultData404 : <any>null; + return throwException('Not Found', status, _responseText, _headers, result404); }) ); + } else if (status === 400) { + return blobToText(responseBlob).pipe( + _observableMergeMap((_responseText: string) => { + let result400: any = null; + let resultData400 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); + result400 = ValidationProblemDetails.fromJS(resultData400); + return throwException('Bad Request', status, _responseText, _headers, result400); + }) + ); } else if (status === 401) { return blobToText(responseBlob).pipe( _observableMergeMap((_responseText: string) => { @@ -3056,20 +3035,21 @@ export class BHClient extends ApiClientBase { } /** - * Get all hearings for a person by username - * @param username (optional) + * @param body (optional) * @return OK */ - getHearingsByUsernameForDeletion(username: string | undefined): Observable<HearingsByUsernameForDeletionResponse[]> { - let url_ = this.baseUrl + '/api/persons/username/hearings?'; - if (username === null) throw new Error("The parameter 'username' cannot be null."); - else if (username !== undefined) url_ += 'username=' + encodeURIComponent('' + username) + '&'; + restoreJusticeUser(body: RestoreJusticeUserRequest | undefined): Observable<JusticeUserResponse> { + let url_ = this.baseUrl + '/api/justice-users/restore'; url_ = url_.replace(/[?&]$/, ''); + const content_ = JSON.stringify(body); + let options_: any = { + body: content_, observe: 'response', responseType: 'blob', headers: new HttpHeaders({ + 'Content-Type': 'application/json', Accept: 'application/json' }) }; @@ -3077,28 +3057,28 @@ export class BHClient extends ApiClientBase { return _observableFrom(this.transformOptions(options_)) .pipe( _observableMergeMap(transformedOptions_ => { - return this.http.request('get', url_, transformedOptions_); + return this.http.request('patch', url_, transformedOptions_); }) ) .pipe( _observableMergeMap((response_: any) => { - return this.processGetHearingsByUsernameForDeletion(response_); + return this.processRestoreJusticeUser(response_); }) ) .pipe( _observableCatch((response_: any) => { if (response_ instanceof HttpResponseBase) { try { - return this.processGetHearingsByUsernameForDeletion(response_ as any); + return this.processRestoreJusticeUser(response_ as any); } catch (e) { - return _observableThrow(e) as any as Observable<HearingsByUsernameForDeletionResponse[]>; + return _observableThrow(e) as any as Observable<JusticeUserResponse>; } - } else return _observableThrow(response_) as any as Observable<HearingsByUsernameForDeletionResponse[]>; + } else return _observableThrow(response_) as any as Observable<JusticeUserResponse>; }) ); } - protected processGetHearingsByUsernameForDeletion(response: HttpResponseBase): Observable<HearingsByUsernameForDeletionResponse[]> { + protected processRestoreJusticeUser(response: HttpResponseBase): Observable<JusticeUserResponse> { const status = response.status; const responseBlob = response instanceof HttpResponse @@ -3127,109 +3107,17 @@ export class BHClient extends ApiClientBase { _observableMergeMap((_responseText: string) => { let result200: any = null; let resultData200 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); - if (Array.isArray(resultData200)) { - result200 = [] as any; - for (let item of resultData200) result200!.push(HearingsByUsernameForDeletionResponse.fromJS(item)); - } else { - result200 = <any>null; - } + result200 = JusticeUserResponse.fromJS(resultData200); return _observableOf(result200); }) ); - } else if (status === 404) { - return blobToText(responseBlob).pipe( - _observableMergeMap((_responseText: string) => { - let result404: any = null; - let resultData404 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); - result404 = ProblemDetails.fromJS(resultData404); - return throwException('Not Found', status, _responseText, _headers, result404); - }) - ); - } else if (status === 401) { - return blobToText(responseBlob).pipe( - _observableMergeMap((_responseText: string) => { - return throwException('Unauthorized', status, _responseText, _headers); - }) - ); - } else if (status !== 200 && status !== 204) { - return blobToText(responseBlob).pipe( - _observableMergeMap((_responseText: string) => { - return throwException('An unexpected server error occurred.', status, _responseText, _headers); - }) - ); - } - return _observableOf(null as any); - } - - /** - * Delete a user account and anonymise a person in bookings - * @param username username of person - * @return No Content - */ - deletePersonWithUsername(username: string): Observable<void> { - let url_ = this.baseUrl + '/api/persons/username/{username}'; - if (username === undefined || username === null) throw new Error("The parameter 'username' must be defined."); - url_ = url_.replace('{username}', encodeURIComponent('' + username)); - url_ = url_.replace(/[?&]$/, ''); - - let options_: any = { - observe: 'response', - responseType: 'blob', - headers: new HttpHeaders({}) - }; - - return _observableFrom(this.transformOptions(options_)) - .pipe( - _observableMergeMap(transformedOptions_ => { - return this.http.request('delete', url_, transformedOptions_); - }) - ) - .pipe( - _observableMergeMap((response_: any) => { - return this.processDeletePersonWithUsername(response_); - }) - ) - .pipe( - _observableCatch((response_: any) => { - if (response_ instanceof HttpResponseBase) { - try { - return this.processDeletePersonWithUsername(response_ as any); - } catch (e) { - return _observableThrow(e) as any as Observable<void>; - } - } else return _observableThrow(response_) as any as Observable<void>; - }) - ); - } - - protected processDeletePersonWithUsername(response: HttpResponseBase): Observable<void> { - const status = response.status; - const responseBlob = - response instanceof HttpResponse - ? response.body - : (response as any).error instanceof Blob - ? (response as any).error - : undefined; - - let _headers: any = {}; - if (response.headers) { - for (let key of response.headers.keys()) { - _headers[key] = response.headers.get(key); - } - } - if (status === 500) { - return blobToText(responseBlob).pipe( - _observableMergeMap((_responseText: string) => { - let result500: any = null; - let resultData500 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); - result500 = UnexpectedErrorResponse.fromJS(resultData500); - return throwException('Internal Server Error', status, _responseText, _headers, result500); - }) - ); - } else if (status === 204) { + } else if (status === 400) { return blobToText(responseBlob).pipe( _observableMergeMap((_responseText: string) => { - return _observableOf(null as any); + let result400: any = null; + let resultData400 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); + result400 = ValidationProblemDetails.fromJS(resultData400); + return throwException('Bad Request', status, _responseText, _headers, result400); }) ); } else if (status === 404) { @@ -3237,7 +3125,8 @@ export class BHClient extends ApiClientBase { _observableMergeMap((_responseText: string) => { let result404: any = null; let resultData404 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); - result404 = ProblemDetails.fromJS(resultData404); + result404 = resultData404 !== undefined ? resultData404 : <any>null; + return throwException('Not Found', status, _responseText, _headers, result404); }) ); @@ -3258,15 +3147,12 @@ export class BHClient extends ApiClientBase { } /** - * Update the personal details - * @param personId The id of the person to update - * @param body (optional) Updated details of the person - * @return Accepted + * Find person list by email search term. + * @param body (optional) The email address search term. + * @return OK */ - updatePersonDetails(personId: string, body: UpdateAccountDetailsRequest | undefined): Observable<void> { - let url_ = this.baseUrl + '/api/persons/{personId}'; - if (personId === undefined || personId === null) throw new Error("The parameter 'personId' must be defined."); - url_ = url_.replace('{personId}', encodeURIComponent('' + personId)); + postPersonBySearchTerm(body: string | undefined): Observable<PersonResponseV2[]> { + let url_ = this.baseUrl + '/api/persons'; url_ = url_.replace(/[?&]$/, ''); const content_ = JSON.stringify(body); @@ -3276,35 +3162,36 @@ export class BHClient extends ApiClientBase { observe: 'response', responseType: 'blob', headers: new HttpHeaders({ - 'Content-Type': 'application/json-patch+json' + 'Content-Type': 'application/json-patch+json', + Accept: 'application/json' }) }; return _observableFrom(this.transformOptions(options_)) .pipe( _observableMergeMap(transformedOptions_ => { - return this.http.request('put', url_, transformedOptions_); + return this.http.request('post', url_, transformedOptions_); }) ) .pipe( _observableMergeMap((response_: any) => { - return this.processUpdatePersonDetails(response_); + return this.processPostPersonBySearchTerm(response_); }) ) .pipe( _observableCatch((response_: any) => { if (response_ instanceof HttpResponseBase) { try { - return this.processUpdatePersonDetails(response_ as any); + return this.processPostPersonBySearchTerm(response_ as any); } catch (e) { - return _observableThrow(e) as any as Observable<void>; + return _observableThrow(e) as any as Observable<PersonResponseV2[]>; } - } else return _observableThrow(response_) as any as Observable<void>; + } else return _observableThrow(response_) as any as Observable<PersonResponseV2[]>; }) ); } - protected processUpdatePersonDetails(response: HttpResponseBase): Observable<void> { + protected processPostPersonBySearchTerm(response: HttpResponseBase): Observable<PersonResponseV2[]> { const status = response.status; const responseBlob = response instanceof HttpResponse @@ -3328,19 +3215,18 @@ export class BHClient extends ApiClientBase { return throwException('Internal Server Error', status, _responseText, _headers, result500); }) ); - } else if (status === 202) { - return blobToText(responseBlob).pipe( - _observableMergeMap((_responseText: string) => { - return _observableOf(null as any); - }) - ); - } else if (status === 404) { + } else if (status === 200) { return blobToText(responseBlob).pipe( _observableMergeMap((_responseText: string) => { - let result404: any = null; - let resultData404 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); - result404 = ProblemDetails.fromJS(resultData404); - return throwException('Not Found', status, _responseText, _headers, result404); + let result200: any = null; + let resultData200 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); + if (Array.isArray(resultData200)) { + result200 = [] as any; + for (let item of resultData200) result200!.push(PersonResponseV2.fromJS(item)); + } else { + result200 = <any>null; + } + return _observableOf(result200); }) ); } else if (status === 400) { @@ -3369,14 +3255,14 @@ export class BHClient extends ApiClientBase { } /** - * Gets a list hearing types - * @param includeDeleted (optional) + * Search for non judge persons by contact email + * @param contactEmail (optional) * @return OK */ - getHearingTypes(includeDeleted: boolean | undefined): Observable<HearingTypeResponse[]> { - let url_ = this.baseUrl + '/api/reference/types?'; - if (includeDeleted === null) throw new Error("The parameter 'includeDeleted' cannot be null."); - else if (includeDeleted !== undefined) url_ += 'includeDeleted=' + encodeURIComponent('' + includeDeleted) + '&'; + getPersonForUpdateByContactEmail(contactEmail: string | undefined): Observable<PersonResponseV2> { + let url_ = this.baseUrl + '/api/persons?'; + if (contactEmail === null) throw new Error("The parameter 'contactEmail' cannot be null."); + else if (contactEmail !== undefined) url_ += 'contactEmail=' + encodeURIComponent('' + contactEmail) + '&'; url_ = url_.replace(/[?&]$/, ''); let options_: any = { @@ -3395,23 +3281,23 @@ export class BHClient extends ApiClientBase { ) .pipe( _observableMergeMap((response_: any) => { - return this.processGetHearingTypes(response_); + return this.processGetPersonForUpdateByContactEmail(response_); }) ) .pipe( _observableCatch((response_: any) => { if (response_ instanceof HttpResponseBase) { try { - return this.processGetHearingTypes(response_ as any); + return this.processGetPersonForUpdateByContactEmail(response_ as any); } catch (e) { - return _observableThrow(e) as any as Observable<HearingTypeResponse[]>; + return _observableThrow(e) as any as Observable<PersonResponseV2>; } - } else return _observableThrow(response_) as any as Observable<HearingTypeResponse[]>; + } else return _observableThrow(response_) as any as Observable<PersonResponseV2>; }) ); } - protected processGetHearingTypes(response: HttpResponseBase): Observable<HearingTypeResponse[]> { + protected processGetPersonForUpdateByContactEmail(response: HttpResponseBase): Observable<PersonResponseV2> { const status = response.status; const responseBlob = response instanceof HttpResponse @@ -3440,12 +3326,7 @@ export class BHClient extends ApiClientBase { _observableMergeMap((_responseText: string) => { let result200: any = null; let resultData200 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); - if (Array.isArray(resultData200)) { - result200 = [] as any; - for (let item of resultData200) result200!.push(HearingTypeResponse.fromJS(item)); - } else { - result200 = <any>null; - } + result200 = PersonResponseV2.fromJS(resultData200); return _observableOf(result200); }) ); @@ -3475,14 +3356,14 @@ export class BHClient extends ApiClientBase { } /** - * Get available participant roles - * @param caseTypeParameter (optional) + * Get all hearings for a person by username + * @param username (optional) * @return OK */ - getParticipantRoles(caseTypeParameter: string | undefined): Observable<CaseAndHearingRolesResponse[]> { - let url_ = this.baseUrl + '/api/reference/participantroles?'; - if (caseTypeParameter === null) throw new Error("The parameter 'caseTypeParameter' cannot be null."); - else if (caseTypeParameter !== undefined) url_ += 'caseTypeParameter=' + encodeURIComponent('' + caseTypeParameter) + '&'; + getHearingsByUsernameForDeletion(username: string | undefined): Observable<HearingsByUsernameForDeletionResponse[]> { + let url_ = this.baseUrl + '/api/persons/username/hearings?'; + if (username === null) throw new Error("The parameter 'username' cannot be null."); + else if (username !== undefined) url_ += 'username=' + encodeURIComponent('' + username) + '&'; url_ = url_.replace(/[?&]$/, ''); let options_: any = { @@ -3501,23 +3382,23 @@ export class BHClient extends ApiClientBase { ) .pipe( _observableMergeMap((response_: any) => { - return this.processGetParticipantRoles(response_); + return this.processGetHearingsByUsernameForDeletion(response_); }) ) .pipe( _observableCatch((response_: any) => { if (response_ instanceof HttpResponseBase) { try { - return this.processGetParticipantRoles(response_ as any); + return this.processGetHearingsByUsernameForDeletion(response_ as any); } catch (e) { - return _observableThrow(e) as any as Observable<CaseAndHearingRolesResponse[]>; + return _observableThrow(e) as any as Observable<HearingsByUsernameForDeletionResponse[]>; } - } else return _observableThrow(response_) as any as Observable<CaseAndHearingRolesResponse[]>; + } else return _observableThrow(response_) as any as Observable<HearingsByUsernameForDeletionResponse[]>; }) ); } - protected processGetParticipantRoles(response: HttpResponseBase): Observable<CaseAndHearingRolesResponse[]> { + protected processGetHearingsByUsernameForDeletion(response: HttpResponseBase): Observable<HearingsByUsernameForDeletionResponse[]> { const status = response.status; const responseBlob = response instanceof HttpResponse @@ -3548,7 +3429,7 @@ export class BHClient extends ApiClientBase { let resultData200 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); if (Array.isArray(resultData200)) { result200 = [] as any; - for (let item of resultData200) result200!.push(CaseAndHearingRolesResponse.fromJS(item)); + for (let item of resultData200) result200!.push(HearingsByUsernameForDeletionResponse.fromJS(item)); } else { result200 = <any>null; } @@ -3581,46 +3462,47 @@ export class BHClient extends ApiClientBase { } /** - * Get available courts - * @return OK + * Delete a user account and anonymise a person in bookings + * @param username username of person + * @return No Content */ - getCourts(): Observable<HearingVenueResponse[]> { - let url_ = this.baseUrl + '/api/reference/courts'; + deletePersonWithUsername(username: string): Observable<void> { + let url_ = this.baseUrl + '/api/persons/username/{username}'; + if (username === undefined || username === null) throw new Error("The parameter 'username' must be defined."); + url_ = url_.replace('{username}', encodeURIComponent('' + username)); url_ = url_.replace(/[?&]$/, ''); let options_: any = { observe: 'response', responseType: 'blob', - headers: new HttpHeaders({ - Accept: 'application/json' - }) + headers: new HttpHeaders({}) }; return _observableFrom(this.transformOptions(options_)) .pipe( _observableMergeMap(transformedOptions_ => { - return this.http.request('get', url_, transformedOptions_); + return this.http.request('delete', url_, transformedOptions_); }) ) .pipe( _observableMergeMap((response_: any) => { - return this.processGetCourts(response_); + return this.processDeletePersonWithUsername(response_); }) ) .pipe( _observableCatch((response_: any) => { if (response_ instanceof HttpResponseBase) { try { - return this.processGetCourts(response_ as any); + return this.processDeletePersonWithUsername(response_ as any); } catch (e) { - return _observableThrow(e) as any as Observable<HearingVenueResponse[]>; + return _observableThrow(e) as any as Observable<void>; } - } else return _observableThrow(response_) as any as Observable<HearingVenueResponse[]>; + } else return _observableThrow(response_) as any as Observable<void>; }) ); } - protected processGetCourts(response: HttpResponseBase): Observable<HearingVenueResponse[]> { + protected processDeletePersonWithUsername(response: HttpResponseBase): Observable<void> { const status = response.status; const responseBlob = response instanceof HttpResponse @@ -3644,18 +3526,10 @@ export class BHClient extends ApiClientBase { return throwException('Internal Server Error', status, _responseText, _headers, result500); }) ); - } else if (status === 200) { + } else if (status === 204) { return blobToText(responseBlob).pipe( _observableMergeMap((_responseText: string) => { - let result200: any = null; - let resultData200 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); - if (Array.isArray(resultData200)) { - result200 = [] as any; - for (let item of resultData200) result200!.push(HearingVenueResponse.fromJS(item)); - } else { - result200 = <any>null; - } - return _observableOf(result200); + return _observableOf(null as any); }) ); } else if (status === 404) { @@ -3684,46 +3558,53 @@ export class BHClient extends ApiClientBase { } /** - * Get available languages for interpreters - * @return OK + * Update the personal details + * @param personId The id of the person to update + * @param body (optional) Updated details of the person + * @return Accepted */ - getAvailableLanguages(): Observable<AvailableLanguageResponse[]> { - let url_ = this.baseUrl + '/api/reference/available-languages'; + updatePersonDetails(personId: string, body: UpdateAccountDetailsRequest | undefined): Observable<void> { + let url_ = this.baseUrl + '/api/persons/{personId}'; + if (personId === undefined || personId === null) throw new Error("The parameter 'personId' must be defined."); + url_ = url_.replace('{personId}', encodeURIComponent('' + personId)); url_ = url_.replace(/[?&]$/, ''); + const content_ = JSON.stringify(body); + let options_: any = { + body: content_, observe: 'response', responseType: 'blob', headers: new HttpHeaders({ - Accept: 'application/json' + 'Content-Type': 'application/json-patch+json' }) }; return _observableFrom(this.transformOptions(options_)) .pipe( _observableMergeMap(transformedOptions_ => { - return this.http.request('get', url_, transformedOptions_); + return this.http.request('put', url_, transformedOptions_); }) ) .pipe( _observableMergeMap((response_: any) => { - return this.processGetAvailableLanguages(response_); + return this.processUpdatePersonDetails(response_); }) ) .pipe( _observableCatch((response_: any) => { if (response_ instanceof HttpResponseBase) { try { - return this.processGetAvailableLanguages(response_ as any); + return this.processUpdatePersonDetails(response_ as any); } catch (e) { - return _observableThrow(e) as any as Observable<AvailableLanguageResponse[]>; + return _observableThrow(e) as any as Observable<void>; } - } else return _observableThrow(response_) as any as Observable<AvailableLanguageResponse[]>; + } else return _observableThrow(response_) as any as Observable<void>; }) ); } - protected processGetAvailableLanguages(response: HttpResponseBase): Observable<AvailableLanguageResponse[]> { + protected processUpdatePersonDetails(response: HttpResponseBase): Observable<void> { const status = response.status; const responseBlob = response instanceof HttpResponse @@ -3747,18 +3628,28 @@ export class BHClient extends ApiClientBase { return throwException('Internal Server Error', status, _responseText, _headers, result500); }) ); - } else if (status === 200) { + } else if (status === 202) { return blobToText(responseBlob).pipe( _observableMergeMap((_responseText: string) => { - let result200: any = null; - let resultData200 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); - if (Array.isArray(resultData200)) { - result200 = [] as any; - for (let item of resultData200) result200!.push(AvailableLanguageResponse.fromJS(item)); - } else { - result200 = <any>null; - } - return _observableOf(result200); + return _observableOf(null as any); + }) + ); + } else if (status === 404) { + return blobToText(responseBlob).pipe( + _observableMergeMap((_responseText: string) => { + let result404: any = null; + let resultData404 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); + result404 = ProblemDetails.fromJS(resultData404); + return throwException('Not Found', status, _responseText, _headers, result404); + }) + ); + } else if (status === 400) { + return blobToText(responseBlob).pipe( + _observableMergeMap((_responseText: string) => { + let result400: any = null; + let resultData400 = _responseText === '' ? null : JSON.parse(_responseText, this.jsonParseReviver); + result400 = ProblemDetails.fromJS(resultData400); + return throwException('Bad Request', status, _responseText, _headers, result400); }) ); } else if (status === 401) { @@ -5250,7 +5141,6 @@ export class BookingDetailsRequest implements IBookingDetailsRequest { scheduled_date_time?: Date; scheduled_duration?: number; hearing_venue_code?: string | undefined; - case_type_name?: string | undefined; case_type_service_id?: string | undefined; cases?: CaseRequest[] | undefined; participants?: ParticipantRequest[] | undefined; @@ -5280,7 +5170,6 @@ export class BookingDetailsRequest implements IBookingDetailsRequest { this.scheduled_date_time = _data['scheduled_date_time'] ? new Date(_data['scheduled_date_time'].toString()) : <any>undefined; this.scheduled_duration = _data['scheduled_duration']; this.hearing_venue_code = _data['hearing_venue_code']; - this.case_type_name = _data['case_type_name']; this.case_type_service_id = _data['case_type_service_id']; if (Array.isArray(_data['cases'])) { this.cases = [] as any; @@ -5324,7 +5213,6 @@ export class BookingDetailsRequest implements IBookingDetailsRequest { data['scheduled_date_time'] = this.scheduled_date_time ? this.scheduled_date_time.toISOString() : <any>undefined; data['scheduled_duration'] = this.scheduled_duration; data['hearing_venue_code'] = this.hearing_venue_code; - data['case_type_name'] = this.case_type_name; data['case_type_service_id'] = this.case_type_service_id; if (Array.isArray(this.cases)) { data['cases'] = []; @@ -5360,7 +5248,6 @@ export interface IBookingDetailsRequest { scheduled_date_time?: Date; scheduled_duration?: number; hearing_venue_code?: string | undefined; - case_type_name?: string | undefined; case_type_service_id?: string | undefined; cases?: CaseRequest[] | undefined; participants?: ParticipantRequest[] | undefined; @@ -5843,8 +5730,6 @@ export class ParticipantRequest implements IParticipantRequest { telephone_number?: string | undefined; username?: string | undefined; display_name?: string | undefined; - case_role_name?: string | undefined; - hearing_role_name?: string | undefined; hearing_role_code?: string | undefined; representee?: string | undefined; organisation_name?: string | undefined; @@ -5870,8 +5755,6 @@ export class ParticipantRequest implements IParticipantRequest { this.telephone_number = _data['telephone_number']; this.username = _data['username']; this.display_name = _data['display_name']; - this.case_role_name = _data['case_role_name']; - this.hearing_role_name = _data['hearing_role_name']; this.hearing_role_code = _data['hearing_role_code']; this.representee = _data['representee']; this.organisation_name = _data['organisation_name']; @@ -5900,8 +5783,6 @@ export class ParticipantRequest implements IParticipantRequest { data['telephone_number'] = this.telephone_number; data['username'] = this.username; data['display_name'] = this.display_name; - data['case_role_name'] = this.case_role_name; - data['hearing_role_name'] = this.hearing_role_name; data['hearing_role_code'] = this.hearing_role_code; data['representee'] = this.representee; data['organisation_name'] = this.organisation_name; @@ -5921,8 +5802,6 @@ export interface IParticipantRequest { telephone_number?: string | undefined; username?: string | undefined; display_name?: string | undefined; - case_role_name?: string | undefined; - hearing_role_name?: string | undefined; hearing_role_code?: string | undefined; representee?: string | undefined; organisation_name?: string | undefined; @@ -6349,7 +6228,6 @@ export class BookingsHearingResponse implements IBookingsHearingResponse { scheduled_date_time?: Date; scheduled_duration?: number; case_type_name?: string | undefined; - hearing_type_name?: string | undefined; court_room?: string | undefined; court_address?: string | undefined; judge_name?: string | undefined; @@ -6384,7 +6262,6 @@ export class BookingsHearingResponse implements IBookingsHearingResponse { this.scheduled_date_time = _data['scheduled_date_time'] ? new Date(_data['scheduled_date_time'].toString()) : <any>undefined; this.scheduled_duration = _data['scheduled_duration']; this.case_type_name = _data['case_type_name']; - this.hearing_type_name = _data['hearing_type_name']; this.court_room = _data['court_room']; this.court_address = _data['court_address']; this.judge_name = _data['judge_name']; @@ -6420,7 +6297,6 @@ export class BookingsHearingResponse implements IBookingsHearingResponse { data['scheduled_date_time'] = this.scheduled_date_time ? this.scheduled_date_time.toISOString() : <any>undefined; data['scheduled_duration'] = this.scheduled_duration; data['case_type_name'] = this.case_type_name; - data['hearing_type_name'] = this.hearing_type_name; data['court_room'] = this.court_room; data['court_address'] = this.court_address; data['judge_name'] = this.judge_name; @@ -6449,7 +6325,6 @@ export interface IBookingsHearingResponse { scheduled_date_time?: Date; scheduled_duration?: number; case_type_name?: string | undefined; - hearing_type_name?: string | undefined; court_room?: string | undefined; court_address?: string | undefined; judge_name?: string | undefined; @@ -6798,22 +6673,12 @@ export class HearingDetailsResponse implements IHearingDetailsResponse { id?: string; scheduled_date_time?: Date; scheduled_duration?: number; - /** V1 only */ - hearing_venue_name?: string | undefined; - /** V2 only */ hearing_venue_code?: string | undefined; - /** V1 only */ - case_type_name?: string | undefined; - /** V2 only */ + hearing_venue_name?: string | undefined; service_id?: string | undefined; - /** V1 only */ - hearing_type_name?: string | undefined; - /** V2 only */ - hearing_type_code?: string | undefined; + case_type_name?: string | undefined; cases?: CaseResponse[] | undefined; participants?: ParticipantResponse[] | undefined; - /** V1 only */ - telephone_participants?: TelephoneParticipantResponse[] | undefined; judiciary_participants?: JudiciaryParticipantResponse[] | undefined; hearing_room_name?: string | undefined; other_information?: string | undefined; @@ -6848,12 +6713,10 @@ export class HearingDetailsResponse implements IHearingDetailsResponse { this.id = _data['id']; this.scheduled_date_time = _data['scheduled_date_time'] ? new Date(_data['scheduled_date_time'].toString()) : <any>undefined; this.scheduled_duration = _data['scheduled_duration']; - this.hearing_venue_name = _data['hearing_venue_name']; this.hearing_venue_code = _data['hearing_venue_code']; - this.case_type_name = _data['case_type_name']; + this.hearing_venue_name = _data['hearing_venue_name']; this.service_id = _data['service_id']; - this.hearing_type_name = _data['hearing_type_name']; - this.hearing_type_code = _data['hearing_type_code']; + this.case_type_name = _data['case_type_name']; if (Array.isArray(_data['cases'])) { this.cases = [] as any; for (let item of _data['cases']) this.cases!.push(CaseResponse.fromJS(item)); @@ -6862,11 +6725,6 @@ export class HearingDetailsResponse implements IHearingDetailsResponse { this.participants = [] as any; for (let item of _data['participants']) this.participants!.push(ParticipantResponse.fromJS(item)); } - if (Array.isArray(_data['telephone_participants'])) { - this.telephone_participants = [] as any; - for (let item of _data['telephone_participants']) - this.telephone_participants!.push(TelephoneParticipantResponse.fromJS(item)); - } if (Array.isArray(_data['judiciary_participants'])) { this.judiciary_participants = [] as any; for (let item of _data['judiciary_participants']) @@ -6912,12 +6770,10 @@ export class HearingDetailsResponse implements IHearingDetailsResponse { data['id'] = this.id; data['scheduled_date_time'] = this.scheduled_date_time ? this.scheduled_date_time.toISOString() : <any>undefined; data['scheduled_duration'] = this.scheduled_duration; - data['hearing_venue_name'] = this.hearing_venue_name; data['hearing_venue_code'] = this.hearing_venue_code; - data['case_type_name'] = this.case_type_name; + data['hearing_venue_name'] = this.hearing_venue_name; data['service_id'] = this.service_id; - data['hearing_type_name'] = this.hearing_type_name; - data['hearing_type_code'] = this.hearing_type_code; + data['case_type_name'] = this.case_type_name; if (Array.isArray(this.cases)) { data['cases'] = []; for (let item of this.cases) data['cases'].push(item.toJSON()); @@ -6926,10 +6782,6 @@ export class HearingDetailsResponse implements IHearingDetailsResponse { data['participants'] = []; for (let item of this.participants) data['participants'].push(item.toJSON()); } - if (Array.isArray(this.telephone_participants)) { - data['telephone_participants'] = []; - for (let item of this.telephone_participants) data['telephone_participants'].push(item.toJSON()); - } if (Array.isArray(this.judiciary_participants)) { data['judiciary_participants'] = []; for (let item of this.judiciary_participants) data['judiciary_participants'].push(item.toJSON()); @@ -6967,22 +6819,12 @@ export interface IHearingDetailsResponse { id?: string; scheduled_date_time?: Date; scheduled_duration?: number; - /** V1 only */ - hearing_venue_name?: string | undefined; - /** V2 only */ hearing_venue_code?: string | undefined; - /** V1 only */ - case_type_name?: string | undefined; - /** V2 only */ + hearing_venue_name?: string | undefined; service_id?: string | undefined; - /** V1 only */ - hearing_type_name?: string | undefined; - /** V2 only */ - hearing_type_code?: string | undefined; + case_type_name?: string | undefined; cases?: CaseResponse[] | undefined; participants?: ParticipantResponse[] | undefined; - /** V1 only */ - telephone_participants?: TelephoneParticipantResponse[] | undefined; judiciary_participants?: JudiciaryParticipantResponse[] | undefined; hearing_room_name?: string | undefined; other_information?: string | undefined; @@ -7050,14 +6892,10 @@ export interface IHearingRoleResponse { /** Defines a type of hearing based on case */ export class HearingTypeResponse implements IHearingTypeResponse { - /** The short code for the type */ - code?: string | undefined; /** Which case type it belongs to */ group?: string | undefined; /** Unique identifier for this type of hearing */ id?: number | undefined; - /** Hearing type display name */ - name?: string | undefined; /** The service id for the type */ service_id?: string | undefined; @@ -7071,10 +6909,8 @@ export class HearingTypeResponse implements IHearingTypeResponse { init(_data?: any) { if (_data) { - this.code = _data['code']; this.group = _data['group']; this.id = _data['id']; - this.name = _data['name']; this.service_id = _data['service_id']; } } @@ -7088,10 +6924,8 @@ export class HearingTypeResponse implements IHearingTypeResponse { toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - data['code'] = this.code; data['group'] = this.group; data['id'] = this.id; - data['name'] = this.name; data['service_id'] = this.service_id; return data; } @@ -7099,14 +6933,10 @@ export class HearingTypeResponse implements IHearingTypeResponse { /** Defines a type of hearing based on case */ export interface IHearingTypeResponse { - /** The short code for the type */ - code?: string | undefined; /** Which case type it belongs to */ group?: string | undefined; /** Unique identifier for this type of hearing */ id?: number | undefined; - /** Hearing type display name */ - name?: string | undefined; /** The service id for the type */ service_id?: string | undefined; } @@ -7410,7 +7240,6 @@ export class ParticipantResponse implements IParticipantResponse { external_reference_id?: string | undefined; measures_external_id?: string | undefined; display_name?: string | undefined; - case_role_name?: string | undefined; hearing_role_name?: string | undefined; hearing_role_code?: string | undefined; user_role_name?: string | undefined; @@ -7441,7 +7270,6 @@ export class ParticipantResponse implements IParticipantResponse { this.external_reference_id = _data['external_reference_id']; this.measures_external_id = _data['measures_external_id']; this.display_name = _data['display_name']; - this.case_role_name = _data['case_role_name']; this.hearing_role_name = _data['hearing_role_name']; this.hearing_role_code = _data['hearing_role_code']; this.user_role_name = _data['user_role_name']; @@ -7480,7 +7308,6 @@ export class ParticipantResponse implements IParticipantResponse { data['external_reference_id'] = this.external_reference_id; data['measures_external_id'] = this.measures_external_id; data['display_name'] = this.display_name; - data['case_role_name'] = this.case_role_name; data['hearing_role_name'] = this.hearing_role_name; data['hearing_role_code'] = this.hearing_role_code; data['user_role_name'] = this.user_role_name; @@ -7508,7 +7335,6 @@ export interface IParticipantResponse { external_reference_id?: string | undefined; measures_external_id?: string | undefined; display_name?: string | undefined; - case_role_name?: string | undefined; hearing_role_name?: string | undefined; hearing_role_code?: string | undefined; user_role_name?: string | undefined; @@ -7527,65 +7353,11 @@ export interface IParticipantResponse { } export class ScreeningResponse implements IScreeningResponse { - type?: ScreeningType; - /** A list of participant/endpoint external ref ids to be protected from */ - protect_from?: string[] | undefined; - - constructor(data?: IScreeningResponse) { - if (data) { - for (var property in data) { - if (data.hasOwnProperty(property)) (<any>this)[property] = (<any>data)[property]; - } - } - } - - init(_data?: any) { - if (_data) { - this.type = _data['type']; - if (Array.isArray(_data['protect_from'])) { - this.protect_from = [] as any; - for (let item of _data['protect_from']) this.protect_from!.push(item); - } - } - } - - static fromJS(data: any): ScreeningResponse { - data = typeof data === 'object' ? data : {}; - let result = new ScreeningResponse(); - result.init(data); - return result; - } - - toJSON(data?: any) { - data = typeof data === 'object' ? data : {}; - data['type'] = this.type; - if (Array.isArray(this.protect_from)) { - data['protect_from'] = []; - for (let item of this.protect_from) data['protect_from'].push(item); - } - return data; - } -} - -export interface IScreeningResponse { - type?: ScreeningType; - /** A list of participant/endpoint external ref ids to be protected from */ - protect_from?: string[] | undefined; -} - -export class TelephoneParticipantResponse implements ITelephoneParticipantResponse { - id?: string; - case_role_name?: string | undefined; - hearing_role_name?: string | undefined; - first_name?: string | undefined; - last_name?: string | undefined; - contact_email?: string | undefined; - telephone_number?: string | undefined; - mobile_number?: string | undefined; - representee?: string | undefined; - linked_participants?: LinkedParticipantResponse[] | undefined; + type?: ScreeningType; + /** A list of participant/endpoint external ref ids to be protected from */ + protect_from?: string[] | undefined; - constructor(data?: ITelephoneParticipantResponse) { + constructor(data?: IScreeningResponse) { if (data) { for (var property in data) { if (data.hasOwnProperty(property)) (<any>this)[property] = (<any>data)[property]; @@ -7595,59 +7367,36 @@ export class TelephoneParticipantResponse implements ITelephoneParticipantRespon init(_data?: any) { if (_data) { - this.id = _data['id']; - this.case_role_name = _data['case_role_name']; - this.hearing_role_name = _data['hearing_role_name']; - this.first_name = _data['first_name']; - this.last_name = _data['last_name']; - this.contact_email = _data['contact_email']; - this.telephone_number = _data['telephone_number']; - this.mobile_number = _data['mobile_number']; - this.representee = _data['representee']; - if (Array.isArray(_data['linked_participants'])) { - this.linked_participants = [] as any; - for (let item of _data['linked_participants']) this.linked_participants!.push(LinkedParticipantResponse.fromJS(item)); + this.type = _data['type']; + if (Array.isArray(_data['protect_from'])) { + this.protect_from = [] as any; + for (let item of _data['protect_from']) this.protect_from!.push(item); } } } - static fromJS(data: any): TelephoneParticipantResponse { + static fromJS(data: any): ScreeningResponse { data = typeof data === 'object' ? data : {}; - let result = new TelephoneParticipantResponse(); + let result = new ScreeningResponse(); result.init(data); return result; } toJSON(data?: any) { data = typeof data === 'object' ? data : {}; - data['id'] = this.id; - data['case_role_name'] = this.case_role_name; - data['hearing_role_name'] = this.hearing_role_name; - data['first_name'] = this.first_name; - data['last_name'] = this.last_name; - data['contact_email'] = this.contact_email; - data['telephone_number'] = this.telephone_number; - data['mobile_number'] = this.mobile_number; - data['representee'] = this.representee; - if (Array.isArray(this.linked_participants)) { - data['linked_participants'] = []; - for (let item of this.linked_participants) data['linked_participants'].push(item.toJSON()); + data['type'] = this.type; + if (Array.isArray(this.protect_from)) { + data['protect_from'] = []; + for (let item of this.protect_from) data['protect_from'].push(item); } return data; } } -export interface ITelephoneParticipantResponse { - id?: string; - case_role_name?: string | undefined; - hearing_role_name?: string | undefined; - first_name?: string | undefined; - last_name?: string | undefined; - contact_email?: string | undefined; - telephone_number?: string | undefined; - mobile_number?: string | undefined; - representee?: string | undefined; - linked_participants?: LinkedParticipantResponse[] | undefined; +export interface IScreeningResponse { + type?: ScreeningType; + /** A list of participant/endpoint external ref ids to be protected from */ + protect_from?: string[] | undefined; } export class UnallocatedHearingsForVhoResponse implements IUnallocatedHearingsForVhoResponse { @@ -7775,51 +7524,6 @@ export interface IUserProfileResponse { is_case_administrator?: boolean; } -export class CaseAndHearingRolesResponse implements ICaseAndHearingRolesResponse { - name?: string | undefined; - hearing_roles?: HearingRole[] | undefined; - - constructor(data?: ICaseAndHearingRolesResponse) { - if (data) { - for (var property in data) { - if (data.hasOwnProperty(property)) (<any>this)[property] = (<any>data)[property]; - } - } - } - - init(_data?: any) { - if (_data) { - this.name = _data['name']; - if (Array.isArray(_data['hearing_roles'])) { - this.hearing_roles = [] as any; - for (let item of _data['hearing_roles']) this.hearing_roles!.push(HearingRole.fromJS(item)); - } - } - } - - static fromJS(data: any): CaseAndHearingRolesResponse { - data = typeof data === 'object' ? data : {}; - let result = new CaseAndHearingRolesResponse(); - result.init(data); - return result; - } - - toJSON(data?: any) { - data = typeof data === 'object' ? data : {}; - data['name'] = this.name; - if (Array.isArray(this.hearing_roles)) { - data['hearing_roles'] = []; - for (let item of this.hearing_roles) data['hearing_roles'].push(item.toJSON()); - } - return data; - } -} - -export interface ICaseAndHearingRolesResponse { - name?: string | undefined; - hearing_roles?: HearingRole[] | undefined; -} - export class CvpForAudioFileResponse implements ICvpForAudioFileResponse { file_name?: string | undefined; sas_token_uri?: string | undefined; @@ -7862,9 +7566,9 @@ export interface ICvpForAudioFileResponse { /** Case request */ export class EditCaseRequest implements IEditCaseRequest { /** The case number */ - number!: string; + number?: string | undefined; /** The case name */ - name!: string; + name?: string | undefined; constructor(data?: IEditCaseRequest) { if (data) { @@ -7899,9 +7603,9 @@ export class EditCaseRequest implements IEditCaseRequest { /** Case request */ export interface IEditCaseRequest { /** The case number */ - number: string; + number?: string | undefined; /** The case name */ - name: string; + name?: string | undefined; } export class EditEndpointRequest implements IEditEndpointRequest { @@ -7983,9 +7687,9 @@ export class EditHearingRequest implements IEditHearingRequest { hearing_venue_code?: string | undefined; /** The hearing room name at the hearing venue */ hearing_room_name?: string | undefined; - case!: EditCaseRequest; + case?: EditCaseRequest; /** List of participants in hearing */ - participants!: EditParticipantRequest[] | undefined; + participants?: EditParticipantRequest[] | undefined; /** List of judiciary participants in hearing */ judiciary_participants?: JudiciaryParticipantRequest[] | undefined; /** Any other information about the hearing */ @@ -8001,9 +7705,6 @@ export class EditHearingRequest implements IEditHearingRequest { if (data.hasOwnProperty(property)) (<any>this)[property] = (<any>data)[property]; } } - if (!data) { - this.case = new EditCaseRequest(); - } } init(_data?: any) { @@ -8013,7 +7714,7 @@ export class EditHearingRequest implements IEditHearingRequest { this.hearing_venue_name = _data['hearing_venue_name']; this.hearing_venue_code = _data['hearing_venue_code']; this.hearing_room_name = _data['hearing_room_name']; - this.case = _data['case'] ? EditCaseRequest.fromJS(_data['case']) : new EditCaseRequest(); + this.case = _data['case'] ? EditCaseRequest.fromJS(_data['case']) : <any>undefined; if (Array.isArray(_data['participants'])) { this.participants = [] as any; for (let item of _data['participants']) this.participants!.push(EditParticipantRequest.fromJS(item)); @@ -8077,9 +7778,9 @@ export interface IEditHearingRequest { hearing_venue_code?: string | undefined; /** The hearing room name at the hearing venue */ hearing_room_name?: string | undefined; - case: EditCaseRequest; + case?: EditCaseRequest; /** List of participants in hearing */ - participants: EditParticipantRequest[] | undefined; + participants?: EditParticipantRequest[] | undefined; /** List of judiciary participants in hearing */ judiciary_participants?: JudiciaryParticipantRequest[] | undefined; /** Any other information about the hearing */ @@ -8099,19 +7800,17 @@ export class EditParticipantRequest implements IEditParticipantRequest { /** Participant Title. */ title?: string | undefined; /** Participant first name. */ - first_name!: string; + first_name?: string | undefined; /** Participant middle name. */ middle_names?: string | undefined; /** Participant last name. */ - last_name!: string; + last_name?: string | undefined; /** Participant Contact Email */ - contact_email!: string; + contact_email?: string | undefined; /** Participant Telephone number */ telephone_number?: string | undefined; /** Participant Display Name */ - display_name!: string; - /** The name of the participant's case role */ - case_role_name?: string | undefined; + display_name?: string | undefined; /** The name of the participant's hearing role */ hearing_role_name?: string | undefined; /** The code of the participant's hearing role */ @@ -8145,7 +7844,6 @@ export class EditParticipantRequest implements IEditParticipantRequest { this.contact_email = _data['contact_email']; this.telephone_number = _data['telephone_number']; this.display_name = _data['display_name']; - this.case_role_name = _data['case_role_name']; this.hearing_role_name = _data['hearing_role_name']; this.hearing_role_code = _data['hearing_role_code']; this.representee = _data['representee']; @@ -8179,7 +7877,6 @@ export class EditParticipantRequest implements IEditParticipantRequest { data['contact_email'] = this.contact_email; data['telephone_number'] = this.telephone_number; data['display_name'] = this.display_name; - data['case_role_name'] = this.case_role_name; data['hearing_role_name'] = this.hearing_role_name; data['hearing_role_code'] = this.hearing_role_code; data['representee'] = this.representee; @@ -8203,19 +7900,17 @@ export interface IEditParticipantRequest { /** Participant Title. */ title?: string | undefined; /** Participant first name. */ - first_name: string; + first_name?: string | undefined; /** Participant middle name. */ middle_names?: string | undefined; /** Participant last name. */ - last_name: string; + last_name?: string | undefined; /** Participant Contact Email */ - contact_email: string; + contact_email?: string | undefined; /** Participant Telephone number */ telephone_number?: string | undefined; /** Participant Display Name */ - display_name: string; - /** The name of the participant's case role */ - case_role_name?: string | undefined; + display_name?: string | undefined; /** The name of the participant's hearing role */ hearing_role_name?: string | undefined; /** The code of the participant's hearing role */ @@ -8272,45 +7967,6 @@ export interface IHearingAudioRecordingResponse { audio_file_links?: string[] | undefined; } -export class HearingRole implements IHearingRole { - name?: string | undefined; - user_role?: string | undefined; - - constructor(data?: IHearingRole) { - if (data) { - for (var property in data) { - if (data.hasOwnProperty(property)) (<any>this)[property] = (<any>data)[property]; - } - } - } - - init(_data?: any) { - if (_data) { - this.name = _data['name']; - this.user_role = _data['user_role']; - } - } - - static fromJS(data: any): HearingRole { - data = typeof data === 'object' ? data : {}; - let result = new HearingRole(); - result.init(data); - return result; - } - - toJSON(data?: any) { - data = typeof data === 'object' ? data : {}; - data['name'] = this.name; - data['user_role'] = this.user_role; - return data; - } -} - -export interface IHearingRole { - name?: string | undefined; - user_role?: string | undefined; -} - export class HearingsForAudioFileSearchResponse implements IHearingsForAudioFileSearchResponse { /** Hearing Id */ id?: string; @@ -9006,6 +8662,8 @@ export class WorkingHours implements IWorkingHours { end_time_minutes?: number | undefined; start_time_hour?: number | undefined; start_time_minutes?: number | undefined; + readonly start_time?: string | undefined; + readonly end_time?: string | undefined; constructor(data?: IWorkingHours) { if (data) { @@ -9022,6 +8680,8 @@ export class WorkingHours implements IWorkingHours { this.end_time_minutes = _data['end_time_minutes']; this.start_time_hour = _data['start_time_hour']; this.start_time_minutes = _data['start_time_minutes']; + (<any>this).start_time = _data['start_time']; + (<any>this).end_time = _data['end_time']; } } @@ -9039,6 +8699,8 @@ export class WorkingHours implements IWorkingHours { data['end_time_minutes'] = this.end_time_minutes; data['start_time_hour'] = this.start_time_hour; data['start_time_minutes'] = this.start_time_minutes; + data['start_time'] = this.start_time; + data['end_time'] = this.end_time; return data; } } @@ -9049,6 +8711,8 @@ export interface IWorkingHours { end_time_minutes?: number | undefined; start_time_hour?: number | undefined; start_time_minutes?: number | undefined; + start_time?: string | undefined; + end_time?: string | undefined; } export class HearingVenueResponse implements IHearingVenueResponse { @@ -9226,73 +8890,6 @@ export interface IJusticeUserResponse { deleted?: boolean; } -export class PersonResponse implements IPersonResponse { - id?: string; - title?: string | undefined; - first_name?: string | undefined; - middle_names?: string | undefined; - last_name?: string | undefined; - contact_email?: string | undefined; - telephone_number?: string | undefined; - username?: string | undefined; - organisation?: string | undefined; - - constructor(data?: IPersonResponse) { - if (data) { - for (var property in data) { - if (data.hasOwnProperty(property)) (<any>this)[property] = (<any>data)[property]; - } - } - } - - init(_data?: any) { - if (_data) { - this.id = _data['id']; - this.title = _data['title']; - this.first_name = _data['first_name']; - this.middle_names = _data['middle_names']; - this.last_name = _data['last_name']; - this.contact_email = _data['contact_email']; - this.telephone_number = _data['telephone_number']; - this.username = _data['username']; - this.organisation = _data['organisation']; - } - } - - static fromJS(data: any): PersonResponse { - data = typeof data === 'object' ? data : {}; - let result = new PersonResponse(); - result.init(data); - return result; - } - - toJSON(data?: any) { - data = typeof data === 'object' ? data : {}; - data['id'] = this.id; - data['title'] = this.title; - data['first_name'] = this.first_name; - data['middle_names'] = this.middle_names; - data['last_name'] = this.last_name; - data['contact_email'] = this.contact_email; - data['telephone_number'] = this.telephone_number; - data['username'] = this.username; - data['organisation'] = this.organisation; - return data; - } -} - -export interface IPersonResponse { - id?: string; - title?: string | undefined; - first_name?: string | undefined; - middle_names?: string | undefined; - last_name?: string | undefined; - contact_email?: string | undefined; - telephone_number?: string | undefined; - username?: string | undefined; - organisation?: string | undefined; -} - export class VhoNonAvailabilityWorkHoursResponse implements IVhoNonAvailabilityWorkHoursResponse { id?: number; end_time?: Date; @@ -9383,6 +8980,73 @@ export interface IVhoWorkHoursResponse { end_time?: string | undefined; } +export class PersonResponseV2 implements IPersonResponseV2 { + id?: string; + title?: string | undefined; + first_name?: string | undefined; + middle_names?: string | undefined; + last_name?: string | undefined; + contact_email?: string | undefined; + telephone_number?: string | undefined; + username?: string | undefined; + organisation?: string | undefined; + + constructor(data?: IPersonResponseV2) { + if (data) { + for (var property in data) { + if (data.hasOwnProperty(property)) (<any>this)[property] = (<any>data)[property]; + } + } + } + + init(_data?: any) { + if (_data) { + this.id = _data['id']; + this.title = _data['title']; + this.first_name = _data['first_name']; + this.middle_names = _data['middle_names']; + this.last_name = _data['last_name']; + this.contact_email = _data['contact_email']; + this.telephone_number = _data['telephone_number']; + this.username = _data['username']; + this.organisation = _data['organisation']; + } + } + + static fromJS(data: any): PersonResponseV2 { + data = typeof data === 'object' ? data : {}; + let result = new PersonResponseV2(); + result.init(data); + return result; + } + + toJSON(data?: any) { + data = typeof data === 'object' ? data : {}; + data['id'] = this.id; + data['title'] = this.title; + data['first_name'] = this.first_name; + data['middle_names'] = this.middle_names; + data['last_name'] = this.last_name; + data['contact_email'] = this.contact_email; + data['telephone_number'] = this.telephone_number; + data['username'] = this.username; + data['organisation'] = this.organisation; + return data; + } +} + +export interface IPersonResponseV2 { + id?: string; + title?: string | undefined; + first_name?: string | undefined; + middle_names?: string | undefined; + last_name?: string | undefined; + contact_email?: string | undefined; + telephone_number?: string | undefined; + username?: string | undefined; + organisation?: string | undefined; +} + export class ProblemDetails implements IProblemDetails { type?: string | undefined; title?: string | undefined; diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/participant-edit-service.service.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/participant-edit-service.service.spec.ts index 290a871bb..2f09953d7 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/participant-edit-service.service.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/participant-edit-service.service.spec.ts @@ -1,6 +1,6 @@ import { of } from 'rxjs'; import { MockLogger } from '../shared/testing/mock-logger'; -import { BHClient, BookHearingException, PersonResponse } from './clients/api-client'; +import { BHClient, BookHearingException, PersonResponseV2 } from './clients/api-client'; import { ParticipantEditService } from './participant-edit-service.service'; describe('ParticipantDeleteServiceService', () => { @@ -33,7 +33,7 @@ describe('ParticipantDeleteServiceService', () => { }); it('should return person', async () => { - const existingPerson = new PersonResponse({ + const existingPerson = new PersonResponseV2({ id: 'id', first_name: 'John', last_name: 'Doe', diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/reference-data.service.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/reference-data.service.ts index 64314f2c9..65f435e2b 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/reference-data.service.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/reference-data.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core'; -import { AvailableLanguageResponse, BHClient, HearingVenueResponse } from './clients/api-client'; +import { AvailableLanguageResponse, BHClient, HearingTypeResponse, HearingVenueResponse } from './clients/api-client'; import { Observable, shareReplay } from 'rxjs'; @Injectable({ @@ -7,10 +7,16 @@ import { Observable, shareReplay } from 'rxjs'; }) export class ReferenceDataService { private interpreterLanguages$: Observable<AvailableLanguageResponse[]>; + private courts$: Observable<HearingVenueResponse[]>; + private hearingTypes$: Observable<HearingTypeResponse[]>; + constructor(private readonly bhClient: BHClient) {} getCourts(): Observable<HearingVenueResponse[]> { - return this.bhClient.getCourts(); + if (!this.courts$) { + this.courts$ = this.bhClient.getCourts().pipe(shareReplay(1)); + } + return this.courts$; } getAvailableInterpreterLanguages(): Observable<AvailableLanguageResponse[]> { @@ -19,4 +25,11 @@ export class ReferenceDataService { } return this.interpreterLanguages$; } + + getHearingTypes(): Observable<HearingTypeResponse[]> { + if (!this.hearingTypes$) { + this.hearingTypes$ = this.bhClient.getHearingTypes().pipe(shareReplay(1)); + } + return this.hearingTypes$; + } } diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/search.service.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/search.service.spec.ts index af90991d6..745f07e65 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/search.service.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/search.service.spec.ts @@ -2,7 +2,7 @@ import { SearchService } from './search.service'; import { TestBed } from '@angular/core/testing'; import { HttpClientModule } from '@angular/common/http'; import { of } from 'rxjs'; -import { BHClient, JudgeAccountType, JudgeResponse, PersonResponse } from './clients/api-client'; +import { BHClient, JudgeAccountType, JudgeResponse, PersonResponseV2 } from './clients/api-client'; import { ParticipantModel } from '../common/model/participant.model'; import { Constants } from '../common/constants'; import { LaunchDarklyService } from './launch-darkly.service'; @@ -15,7 +15,7 @@ const roleJudge = 'Judge'; const validSearchTerms = 'abc'; const invalidSearchTerms = 'ab'; -const personList: PersonResponse[] = JSON.parse( +const personList: PersonResponseV2[] = JSON.parse( ` [ { diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/search.service.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/search.service.ts index 610e4a84d..cf860d6a7 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/search.service.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/search.service.ts @@ -3,7 +3,7 @@ import { Observable, of } from 'rxjs'; import { map } from 'rxjs/operators'; import { IDropDownModel } from '../common/model/drop-down.model'; import { ParticipantModel } from '../common/model/participant.model'; -import { BHClient, JudgeResponse, PersonResponse } from '../services/clients/api-client'; +import { BHClient, JudgeResponse, PersonResponseV2 } from './clients/api-client'; import { Constants } from '../common/constants'; @Injectable({ @@ -76,7 +76,7 @@ export class SearchService { } } - searchEntries(term): Observable<Array<PersonResponse>> { + searchEntries(term): Observable<Array<PersonResponseV2>> { return this.bhClient.postPersonBySearchTerm(term); } diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/video-hearings.service.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/video-hearings.service.spec.ts index 4aad66272..4c6aaf2b0 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/video-hearings.service.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/video-hearings.service.spec.ts @@ -4,13 +4,11 @@ import { BHClient, BookingStatus, CancelMultiDayHearingRequest, - CaseAndHearingRolesResponse, CaseResponse, ClientSettingsResponse, EditMultiDayHearingRequest, EndpointResponse, HearingDetailsResponse, - HearingRole, JudiciaryParticipantResponse, LinkedParticipantResponse, MultiHearingRequest, @@ -27,17 +25,22 @@ import { LinkedParticipantModel, LinkedParticipantType } from '../common/model/l import { JudicialMemberDto } from '../booking/judicial-office-holders/models/add-judicial-member.model'; import { InterpreterSelectedDto } from '../booking/interpreter-form/interpreter-selected.model'; import { ScreeningDto } from '../booking/screening/screening.model'; +import { ReferenceDataService } from './reference-data.service'; +import { MockValues } from '../testing/data/test-objects'; describe('Video hearing service', () => { let service: VideoHearingsService; let clientApiSpy: jasmine.SpyObj<BHClient>; + let referenceDataServiceSpy: jasmine.SpyObj<ReferenceDataService>; const newRequestKey = 'bh-newRequest'; const conferencePhoneNumberKey = 'conferencePhoneNumberKey'; const conferencePhoneNumberWelshKey = 'conferencePhoneNumberWelshKey'; beforeEach(() => { + referenceDataServiceSpy = jasmine.createSpyObj<ReferenceDataService>('ReferenceDataService', ['getCourts', 'getHearingTypes']); + referenceDataServiceSpy.getCourts.and.returnValue(of(MockValues.Courts)); + referenceDataServiceSpy.getHearingTypes.and.returnValue(of(MockValues.HearingTypesList)); clientApiSpy = jasmine.createSpyObj<BHClient>([ 'getHearingTypes', - 'getParticipantRoles', 'bookNewHearing', 'cloneHearing', 'getTelephoneConferenceIdById', @@ -49,7 +52,7 @@ describe('Video hearing service', () => { 'cancelMultiDayHearing', 'getBookingQueueState' ]); - service = new VideoHearingsService(clientApiSpy); + service = new VideoHearingsService(clientApiSpy, referenceDataServiceSpy); }); afterEach(() => { @@ -89,10 +92,6 @@ describe('Video hearing service', () => { expect(service.hasUnsavedChanges()).toBe(true); }); - it('should get hearings types', () => { - service.getHearingTypes(); - expect(clientApiSpy.getHearingTypes).toHaveBeenCalled(); - }); it('should clone hearing', async () => { clientApiSpy.cloneHearing.and.returnValue(of(null)); @@ -112,26 +111,6 @@ describe('Video hearing service', () => { expect(service.getCurrentRequest().hearing_id).toBe('hearingId'); }); - it('should cache participant roles', async () => { - // given the api responds with - const serverResponse = new CaseAndHearingRolesResponse({ - name: 'Respondent', - hearing_roles: [ - new HearingRole({ name: 'Representative', user_role: 'Representative' }), - new HearingRole({ name: 'Litigant in person', user_role: 'Individual' }) - ] - }); - clientApiSpy.getParticipantRoles.and.returnValue(of([serverResponse])); - - // we get the response the first time - const response = await service.getParticipantRoles('Respondent'); - expect(response).toEqual([serverResponse]); - - // second time we get a cached value - await service.getParticipantRoles('Respondent'); - expect(clientApiSpy.getParticipantRoles).toHaveBeenCalledTimes(1); - }); - it('should remove currently cached hearing when cancelling', () => { const model = new HearingModel(); model.hearing_id = 'hearingId'; @@ -180,7 +159,6 @@ describe('Video hearing service', () => { model.supplier = VideoSupplier.Vodafone; const request = service.mapHearing(model); - expect(request.case_type_name).toBe('Tax'); expect(request.hearing_room_name).toBe('room 09'); expect(request.other_information).toBe('note'); expect(request.cases).toBeTruthy(); @@ -198,9 +176,7 @@ describe('Video hearing service', () => { const request = service.mapHearingDetailsResponseToHearingModel(model); expect(request.hearing_id).toEqual(model.id); - expect(request.case_type).toBe('Tax'); expect(request.court_room).toBe('room 09'); - expect(request.court_name).toBe('court address'); expect(request.other_information).toBe('note'); expect(request.cases).toBeTruthy(); expect(request.cases[0].name).toBe('case1'); @@ -243,11 +219,8 @@ describe('Video hearing service', () => { caseModel.number = 'Number 1'; const model = new HearingDetailsResponse(); model.id = '232423423jsn'; - model.case_type_name = 'Tax'; - model.hearing_type_name = 'hearing type'; model.scheduled_date_time = new Date(date); model.scheduled_duration = 30; - model.hearing_venue_name = 'court address'; model.hearing_room_name = 'room 09'; model.other_information = 'note'; model.cases = [caseModel]; @@ -268,7 +241,6 @@ describe('Video hearing service', () => { model.audio_recording_required = true; model.group_id = null; model.multi_day_hearing_last_day_scheduled_date_time = new Date(date); - return model; } }); @@ -284,7 +256,6 @@ describe('Video hearing service', () => { participant.display_name = 'Dan Smith'; participant.contact_email = 'dan@hmcts.net'; participant.telephone_number = '123123123'; - participant.case_role_name = 'Respondent'; participant.hearing_role_name = 'Litigant in person'; participant.user_role_name = 'Individual'; participant.interpreter_language = null; @@ -299,7 +270,6 @@ describe('Video hearing service', () => { judgeParticipant.display_name = 'Judge Test'; judgeParticipant.contact_email = 'judge@hmcts.net'; judgeParticipant.telephone_number = '123123123'; - judgeParticipant.case_role_name = null; judgeParticipant.hearing_role_name = null; judgeParticipant.user_role_name = 'Judge'; judgeParticipant.interpreter_language = null; @@ -315,7 +285,6 @@ describe('Video hearing service', () => { expect(model[0].display_name).toEqual(participant.display_name); expect(model[0].email).toEqual(participant.contact_email); expect(model[0].phone).toEqual(participant.telephone_number); - expect(model[0].case_role_name).toEqual(participant.case_role_name); expect(model[0].hearing_role_name).toEqual(participant.hearing_role_name); expect(model[0].is_judge).toBeFalse(); expect(model[0].interpretation_language).toBeNull(); @@ -328,7 +297,6 @@ describe('Video hearing service', () => { expect(model[1].display_name).toEqual(judgeParticipant.display_name); expect(model[1].email).toEqual(judgeParticipant.contact_email); expect(model[1].phone).toEqual(judgeParticipant.telephone_number); - expect(model[1].case_role_name).toEqual(judgeParticipant.case_role_name); expect(model[1].hearing_role_name).toEqual(judgeParticipant.hearing_role_name); expect(model[1].is_judge).toBeTrue(); expect(model[1].interpretation_language).toBeNull(); @@ -345,7 +313,6 @@ describe('Video hearing service', () => { participant.display_name = 'Dan Smith'; participant.email = 'dan@hmcts.net'; participant.phone = '123123123'; - participant.case_role_name = 'Respondent'; participant.hearing_role_name = 'Litigant in person'; participants.push(participant); @@ -359,8 +326,6 @@ describe('Video hearing service', () => { expect(model[0].display_name).toEqual(participant.display_name); expect(model[0].contact_email).toEqual(participant.email); expect(model[0].telephone_number).toEqual(participant.phone); - expect(model[0].case_role_name).toEqual(participant.case_role_name); - expect(model[0].hearing_role_name).toEqual(participant.hearing_role_name); }); it('should map Existing hearing', () => { @@ -374,7 +339,6 @@ describe('Video hearing service', () => { participant.display_name = 'Dan Smith'; participant.email = 'dan@hmcts.net'; participant.phone = '123123123'; - participant.case_role_name = 'Respondent'; participant.hearing_role_name = 'Litigant in person'; const interpretationLanguage: InterpreterSelectedDto = { signLanguageCode: null, @@ -430,7 +394,6 @@ describe('Video hearing service', () => { expect(actualParticipant.last_name).toEqual(expectedParticipant.last_name); expect(actualParticipant.middle_names).toEqual(expectedParticipant.middle_names); expect(actualParticipant.hearing_role_name).toEqual(expectedParticipant.hearing_role_name); - expect(actualParticipant.case_role_name).toEqual(expectedParticipant.case_role_name); expect(actualCase.name).toEqual(expectedCase.name); expect(actualCase.number).toEqual(expectedCase.number); expect(actualEndpoint).toEqual(expectedEndpoint); @@ -450,7 +413,6 @@ describe('Video hearing service', () => { participant.display_name = 'Dan Smith'; participant.email = 'dan@hmcts.net'; participant.phone = '123123123'; - participant.case_role_name = 'Respondent'; participant.hearing_role_name = 'Litigant in person'; const linkedParticipants: LinkedParticipantModel[] = []; const linkedParticipantModel = new LinkedParticipantModel(); @@ -491,7 +453,6 @@ describe('Video hearing service', () => { expect(editHearingRequest.participants[0].last_name).toEqual(hearingModel.participants[0].last_name); expect(editHearingRequest.participants[0].middle_names).toEqual(hearingModel.participants[0].middle_names); expect(editHearingRequest.participants[0].hearing_role_name).toEqual(hearingModel.participants[0].hearing_role_name); - expect(editHearingRequest.participants[0].case_role_name).toEqual(hearingModel.participants[0].case_role_name); expect(editHearingRequest.case.name).toEqual(hearingModel.cases[0].name); expect(editHearingRequest.case.number).toEqual(hearingModel.cases[0].number); expect(editHearingRequest.audio_recording_required).toEqual(hearingModel.audio_recording_required); @@ -982,7 +943,7 @@ describe('Video hearing service', () => { } sessionStorage.setItem(newRequestKey, JSON.stringify(hearing)); - service = new VideoHearingsService(clientApiSpy); + service = new VideoHearingsService(clientApiSpy, referenceDataServiceSpy); expect(service.isTotalHearingMoreThanThreshold()).toBe(false); }); @@ -999,7 +960,7 @@ describe('Video hearing service', () => { } sessionStorage.setItem(newRequestKey, JSON.stringify(hearing)); - service = new VideoHearingsService(clientApiSpy); + service = new VideoHearingsService(clientApiSpy, referenceDataServiceSpy); expect(service.isTotalHearingMoreThanThreshold()).toBe(true); }); diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/video-hearings.service.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/video-hearings.service.ts index 2b99361e9..9b9c6b950 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/services/video-hearings.service.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/services/video-hearings.service.ts @@ -1,12 +1,11 @@ import { Injectable } from '@angular/core'; -import { firstValueFrom, lastValueFrom, Observable } from 'rxjs'; +import { combineLatest, firstValueFrom, lastValueFrom, Observable } from 'rxjs'; import { BHClient, BookHearingRequest, BookingDetailsRequest, BookingStatus, CancelMultiDayHearingRequest, - CaseAndHearingRolesResponse, CaseRequest, CaseResponse, EditCaseRequest, @@ -19,6 +18,7 @@ import { HearingDetailsResponse, HearingRoleResponse, HearingTypeResponse, + HearingVenueResponse, JudiciaryParticipantRequest, LinkedParticipant, LinkedParticipantRequest, @@ -39,9 +39,10 @@ import { LinkedParticipantModel } from '../common/model/linked-participant.model import { Constants } from '../common/constants'; import * as moment from 'moment'; import { JudicialMemberDto } from '../booking/judicial-office-holders/models/add-judicial-member.model'; -import { map } from 'rxjs/operators'; +import { map, shareReplay } from 'rxjs/operators'; import { InterpreterSelectedDto } from '../booking/interpreter-form/interpreter-selected.model'; import { mapScreeningResponseToScreeningDto, ScreeningDto } from '../booking/screening/screening.model'; +import { ReferenceDataService } from './reference-data.service'; @Injectable({ providedIn: 'root' @@ -54,11 +55,13 @@ export class VideoHearingsService { private readonly vhoNonAvailabiltiesHaveChangesKey: string; private readonly totalHearingsCountThreshold: number = 40; + private readonly venues$: Observable<HearingVenueResponse[]>; + private readonly hearingTypes$: Observable<HearingTypeResponse[]>; + private modelHearing: HearingModel; - private readonly participantRoles = new Map<string, CaseAndHearingRolesResponse[]>(); private readonly judiciaryRoles = Constants.JudiciaryRoles; - constructor(private readonly bhClient: BHClient) { + constructor(private readonly bhClient: BHClient, private readonly referenceDataService: ReferenceDataService) { this.newRequestKey = 'bh-newRequest'; this.bookingHasChangesKey = 'bookingHasChangesKey'; this.conferencePhoneNumberKey = 'conferencePhoneNumberKey'; @@ -66,6 +69,8 @@ export class VideoHearingsService { this.vhoNonAvailabiltiesHaveChangesKey = 'vhoNonAvailabiltiesHaveChangesKey'; this.checkForExistingHearing(); + this.venues$ = this.referenceDataService.getCourts().pipe(shareReplay(1)); + this.hearingTypes$ = this.referenceDataService.getHearingTypes(); } private checkForExistingHearing() { @@ -116,10 +121,6 @@ export class VideoHearingsService { sessionStorage.removeItem(this.vhoNonAvailabiltiesHaveChangesKey); } - getHearingTypes(includeDeleted: boolean = false): Observable<HearingTypeResponse[]> { - return this.bhClient.getHearingTypes(includeDeleted); - } - getCurrentRequest(): HearingModel { return this.modelHearing; } @@ -141,15 +142,6 @@ export class VideoHearingsService { sessionStorage.setItem(this.newRequestKey, localRequest); } - async getParticipantRoles(caseTypeName: string): Promise<CaseAndHearingRolesResponse[]> { - if (this.participantRoles.has(caseTypeName)) { - return this.participantRoles.get(caseTypeName); - } - const roles = await firstValueFrom(this.bhClient.getParticipantRoles(caseTypeName)); - this.participantRoles.set(caseTypeName, roles); - return roles; - } - async getHearingRoles(): Promise<HearingRoleResponse[]> { const roles = await firstValueFrom(this.bhClient.getHearingRoles()); return roles; @@ -281,7 +273,6 @@ export class VideoHearingsService { const editParticipant = new EditParticipantRequest(); editParticipant.id = participant.id; editParticipant.external_reference_id = participant.externalReferenceId; - editParticipant.case_role_name = participant.case_role_name; editParticipant.contact_email = participant.email; editParticipant.display_name = participant.display_name; editParticipant.first_name = participant.first_name; @@ -330,7 +321,6 @@ export class VideoHearingsService { mapHearing(newRequest: HearingModel): BookingDetailsRequest { const newHearingRequest = new BookingDetailsRequest(); newHearingRequest.cases = this.mapCases(newRequest); - newHearingRequest.case_type_name = newRequest.case_type; newHearingRequest.case_type_service_id = newRequest.case_type_service_id; newHearingRequest.scheduled_date_time = new Date(newRequest.scheduled_date_time); newHearingRequest.scheduled_duration = newRequest.scheduled_duration; @@ -351,12 +341,13 @@ export class VideoHearingsService { const hearing = new HearingModel(); hearing.hearing_id = response.id; hearing.cases = this.mapCaseResponseToCaseModel(response.cases); - hearing.case_type = response.case_type_name; hearing.scheduled_date_time = new Date(response.scheduled_date_time); hearing.scheduled_duration = response.scheduled_duration; - hearing.court_name = response.hearing_venue_name; hearing.court_code = response.hearing_venue_code; + hearing.court_name = response.hearing_venue_name; hearing.court_room = response.hearing_room_name; + hearing.case_type = response.case_type_name; + hearing.case_type_service_id = response.service_id; hearing.participants = this.mapParticipantResponseToParticipantModel(response.participants); hearing.other_information = response.other_information; hearing.created_date = new Date(response.created_date); @@ -436,8 +427,6 @@ export class VideoHearingsService { participant.display_name = p.display_name; participant.contact_email = p.email; participant.telephone_number = p.phone; - participant.case_role_name = p.case_role_name; - participant.hearing_role_name = p.hearing_role_name; participant.hearing_role_code = p.hearing_role_code; participant.representee = p.representee; participant.organisation_name = p.company; @@ -494,7 +483,6 @@ export class VideoHearingsService { participant.display_name = p.display_name; participant.email = p.contact_email; participant.phone = p.telephone_number; - participant.case_role_name = p.case_role_name; participant.hearing_role_name = p.hearing_role_name; participant.hearing_role_code = p.hearing_role_code; participant.representee = p.representee; @@ -569,7 +557,20 @@ export class VideoHearingsService { } getHearingById(hearingId: string): Observable<HearingDetailsResponse> { - return this.bhClient.getHearingById(hearingId); + const hearingById$ = this.bhClient.getHearingById(hearingId); + return combineLatest([hearingById$, this.venues$, this.hearingTypes$]).pipe( + map(([hearing, venues, hearingTypes]) => { + const venue = venues.find(v => v.code === hearing.hearing_venue_code); + if (venue) { + hearing.hearing_venue_name = venue.name; + } + const hearingType = hearingTypes.find(ht => ht.service_id === hearing.service_id); + if (hearingType) { + hearing.case_type_name = hearingType.group; + } + return hearing; + }) + ); } cancelBooking(hearingId: string, reason: string): Observable<UpdateBookingStatusResponse> { diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/shared/menus/case-types-menu/case-types-menu.component.spec.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/shared/menus/case-types-menu/case-types-menu.component.spec.ts index 788887598..79bad5fe5 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/shared/menus/case-types-menu/case-types-menu.component.spec.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/shared/menus/case-types-menu/case-types-menu.component.spec.ts @@ -5,20 +5,20 @@ import { HttpClient, HttpHandler } from '@angular/common/http'; import { FormBuilder, ReactiveFormsModule } from '@angular/forms'; import { MockLogger } from '../../testing/mock-logger'; import { Logger } from '../../../services/logger'; -import { VideoHearingsService } from '../../../services/video-hearings.service'; import { of, throwError } from 'rxjs'; import { HearingTypeResponse } from '../../../services/clients/api-client'; import { NgSelectModule } from '@ng-select/ng-select'; +import { ReferenceDataService } from 'src/app/services/reference-data.service'; describe('CaseTypesMenuComponent', () => { let component: CaseTypesMenuComponent; let fixture: ComponentFixture<CaseTypesMenuComponent>; - let videoHearingServiceSpy: jasmine.SpyObj<VideoHearingsService>; + let refDataServiceSpy: jasmine.SpyObj<ReferenceDataService>; const caseType = 'caseType1'; beforeEach(async () => { - videoHearingServiceSpy = jasmine.createSpyObj('VideoHearingsService', ['getHearingTypes']); - videoHearingServiceSpy.getHearingTypes.and.returnValue(of([new HearingTypeResponse({ group: caseType })])); + refDataServiceSpy = jasmine.createSpyObj('ReferenceDataService', ['getHearingTypes']); + refDataServiceSpy.getHearingTypes.and.returnValue(of([new HearingTypeResponse({ group: caseType })])); await TestBed.configureTestingModule({ imports: [NgSelectModule, ReactiveFormsModule], declarations: [CaseTypesMenuComponent], @@ -27,7 +27,7 @@ describe('CaseTypesMenuComponent', () => { HttpHandler, FormBuilder, { provide: Logger, useValue: new MockLogger() }, - { provide: VideoHearingsService, useValue: videoHearingServiceSpy } + { provide: ReferenceDataService, useValue: refDataServiceSpy } ] }).compileComponents(); }); @@ -62,16 +62,16 @@ describe('CaseTypesMenuComponent', () => { describe('loadItems', () => { it('should call video hearing service', () => { component.loadItems(); - expect(videoHearingServiceSpy.getHearingTypes).toHaveBeenCalled(); + expect(refDataServiceSpy.getHearingTypes).toHaveBeenCalled(); expect(component.caseTypes).toContain('caseType1'); }); it('should call video hearing service, and catch thrown exception', () => { - videoHearingServiceSpy.getHearingTypes.and.returnValue(throwError({ status: 404 })); + refDataServiceSpy.getHearingTypes.and.returnValue(throwError({ status: 404 })); const handleListErrorSpy = spyOn(component, 'handleListError'); component.loadItems(); - expect(videoHearingServiceSpy.getHearingTypes).toHaveBeenCalled(); + expect(refDataServiceSpy.getHearingTypes).toHaveBeenCalled(); expect(handleListErrorSpy).toHaveBeenCalled(); }); }); diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/shared/menus/case-types-menu/case-types-menu.component.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/shared/menus/case-types-menu/case-types-menu.component.ts index f29569b9a..3862a1942 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/shared/menus/case-types-menu/case-types-menu.component.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/shared/menus/case-types-menu/case-types-menu.component.ts @@ -2,9 +2,9 @@ import { Component, EventEmitter, Output } from '@angular/core'; import { BookingPersistService } from '../../../services/bookings-persist.service'; import { FormBuilder } from '@angular/forms'; import { HearingTypeResponse } from '../../../services/clients/api-client'; -import { VideoHearingsService } from '../../../services/video-hearings.service'; import { Logger } from '../../../services/logger'; import { MenuBase } from '../menu-base'; +import { ReferenceDataService } from 'src/app/services/reference-data.service'; @Component({ selector: 'app-case-types-menu', @@ -22,7 +22,7 @@ export class CaseTypesMenuComponent extends MenuBase { constructor( private readonly bookingPersistService: BookingPersistService, - private readonly videoHearingService: VideoHearingsService, + private readonly referenceDataService: ReferenceDataService, formBuilder: FormBuilder, logger: Logger ) { @@ -34,7 +34,7 @@ export class CaseTypesMenuComponent extends MenuBase { loadItems(): void { const distinct = (value, index, array) => array.indexOf(value) === index; - this.videoHearingService.getHearingTypes(true).subscribe({ + this.referenceDataService.getHearingTypes().subscribe({ next: (data: HearingTypeResponse[]) => { this.caseTypes = this.items = [ ...Array.from( diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/testing/data/response-test-data.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/testing/data/response-test-data.ts index fd8ff7512..0e226487d 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/testing/data/response-test-data.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/testing/data/response-test-data.ts @@ -19,13 +19,9 @@ export class ResponseTestData { caseHearing.number = 'XX3456234565'; response.cases = []; response.cases.push(caseHearing); - response.hearing_type_name = 'Tax'; response.id = '1'; response.scheduled_date_time = new Date('2019-10-22 13:58:40.3730067'); response.scheduled_duration = 125; - response.hearing_venue_name = 'Coronation Street'; - response.case_type_name = 'Generic'; - response.hearing_type_name = 'Automated Test'; response.other_information = 'some note'; response.hearing_room_name = '777'; response.created_date = new Date('2019-10-22 13:58:40.3730067'); @@ -125,7 +121,6 @@ export class ResponseTestData { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', 'JadgeGreen', '33A', 'Coronation Street', @@ -148,7 +143,6 @@ export class ResponseTestData { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', 'JadgeGreen', '33A', 'Coronation Street', @@ -170,7 +164,6 @@ export class ResponseTestData { new Date('2019-12-22 13:58:40.3730067'), 120, 'XX3456234565', - 'Smith vs Donner', 'Tax', 'JadgeGreen', '33A', @@ -208,7 +201,6 @@ export class ResponseTestData { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', 'JadgeGreen', '33A', 'Coronation Street', @@ -231,7 +223,6 @@ export class ResponseTestData { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', 'JadgeGreen', '33A', 'Coronation Street', @@ -254,7 +245,6 @@ export class ResponseTestData { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', 'JadgeGreen', '33A', 'Coronation Street', @@ -285,7 +275,6 @@ export class ResponseTestData { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', 'JadgeGreen', '33A', 'Coronation Street', @@ -308,7 +297,6 @@ export class ResponseTestData { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', 'JadgeGreen', '33A', 'Coronation Street', @@ -331,7 +319,6 @@ export class ResponseTestData { 120, 'XX3456234565', 'Smith vs Donner', - 'Tax', 'JadgeGreen', '33A', 'Coronation Street', @@ -380,7 +367,6 @@ export class ResponseTestData { bhr.court_room = '12A'; bhr.hearing_name = 'A vs B'; bhr.hearing_number = '123A'; - bhr.hearing_type_name = 'Tax'; bhr.judge_name = 'Judge'; bhr.scheduled_duration = 45; bhr.created_by = 'Roy'; @@ -397,7 +383,6 @@ export class ResponseTestData { bhr1.court_room = '12A'; bhr1.hearing_name = 'A vs B'; bhr1.hearing_number = '123A'; - bhr1.hearing_type_name = 'Tax'; bhr1.judge_name = 'Judge'; bhr1.scheduled_duration = 45; bhr1.created_by = 'Roy'; diff --git a/AdminWebsite/AdminWebsite/ClientApp/src/app/testing/stubs/service-service-stub.ts b/AdminWebsite/AdminWebsite/ClientApp/src/app/testing/stubs/service-service-stub.ts index 0ad118112..b8a32214d 100644 --- a/AdminWebsite/AdminWebsite/ClientApp/src/app/testing/stubs/service-service-stub.ts +++ b/AdminWebsite/AdminWebsite/ClientApp/src/app/testing/stubs/service-service-stub.ts @@ -1,8 +1,8 @@ import { IDropDownModel } from 'src/app/common/model/drop-down.model'; import { Observable, of } from 'rxjs'; -import { PersonResponse } from '../../services/clients/api-client'; +import { PersonResponseV2 } from '../../services/clients/api-client'; -const participantList: PersonResponse[] = JSON.parse( +const participantList: PersonResponseV2[] = JSON.parse( ` [ { diff --git a/AdminWebsite/AdminWebsite/Contracts/Requests/BookingDetailsRequest.cs b/AdminWebsite/AdminWebsite/Contracts/Requests/BookingDetailsRequest.cs index 968ed8690..9af81192f 100644 --- a/AdminWebsite/AdminWebsite/Contracts/Requests/BookingDetailsRequest.cs +++ b/AdminWebsite/AdminWebsite/Contracts/Requests/BookingDetailsRequest.cs @@ -15,7 +15,6 @@ public class BookingDetailsRequest public int ScheduledDuration { get; set; } public string HearingVenueCode { get; set; } - public string CaseTypeName { get; set; } public string CaseTypeServiceId { get; set; } public List<CaseRequest> Cases { get; set; } public List<ParticipantRequest> Participants { get; set; } diff --git a/AdminWebsite/AdminWebsite/Contracts/Requests/ParticipantRequest.cs b/AdminWebsite/AdminWebsite/Contracts/Requests/ParticipantRequest.cs index a5accf69d..4451704c8 100644 --- a/AdminWebsite/AdminWebsite/Contracts/Requests/ParticipantRequest.cs +++ b/AdminWebsite/AdminWebsite/Contracts/Requests/ParticipantRequest.cs @@ -16,8 +16,6 @@ public class ParticipantRequest [StringLength(255, ErrorMessage = "Display name max length is 255 characters")] [RegularExpression(@"^[\p{L}\p{N}\s',._-]+$")] public string DisplayName { get; set; } - public string CaseRoleName { get; set; } - public string HearingRoleName { get; set; } public string HearingRoleCode { get; set; } public string Representee { get; set; } public string OrganisationName { get; set; } diff --git a/AdminWebsite/AdminWebsite/Contracts/Responses/BookingsHearingResponse.cs b/AdminWebsite/AdminWebsite/Contracts/Responses/BookingsHearingResponse.cs index a657f7d1c..8eda23789 100644 --- a/AdminWebsite/AdminWebsite/Contracts/Responses/BookingsHearingResponse.cs +++ b/AdminWebsite/AdminWebsite/Contracts/Responses/BookingsHearingResponse.cs @@ -12,7 +12,6 @@ public class BookingsHearingResponse public DateTime ScheduledDateTime { get; set; } public int ScheduledDuration { get; set; } public string CaseTypeName { get; set; } - public string HearingTypeName { get; set; } public string CourtRoom { get; set; } public string CourtAddress { get; set; } public string JudgeName { get; set; } diff --git a/AdminWebsite/AdminWebsite/Contracts/Responses/HearingDetailsResponse.cs b/AdminWebsite/AdminWebsite/Contracts/Responses/HearingDetailsResponse.cs index e0e5a5df9..bd2400009 100644 --- a/AdminWebsite/AdminWebsite/Contracts/Responses/HearingDetailsResponse.cs +++ b/AdminWebsite/AdminWebsite/Contracts/Responses/HearingDetailsResponse.cs @@ -9,39 +9,13 @@ public class HearingDetailsResponse public Guid Id { get; set; } public DateTime ScheduledDateTime { get; set; } public int ScheduledDuration { get; set; } - /// <summary> - /// V1 only - /// </summary> - public string HearingVenueName { get; set; } - /// <summary> - /// V2 only - /// </summary> public string HearingVenueCode { get; set; } - /// <summary> - /// V1 only - /// </summary> - public string CaseTypeName { get; set; } - /// <summary> - /// V2 only - /// </summary> + public string HearingVenueName { get; set; } public string ServiceId { get; set; } - /// <summary> - /// V1 only - /// </summary> - public string HearingTypeName { get; set; } - /// <summary> - /// V2 only - /// </summary> - public string HearingTypeCode { get; set; } + public string CaseTypeName { get; set; } public List<CaseResponse> Cases { get; set; } public List<ParticipantResponse> Participants { get; set; } - /// <summary> - /// V1 only - /// </summary> - public List<TelephoneParticipantResponse> TelephoneParticipants { get; set; } - public List<JudiciaryParticipantResponse> JudiciaryParticipants { get; set; } - public string HearingRoomName { get; set; } public string OtherInformation { get; set; } public DateTime CreatedDate { get; set; } diff --git a/AdminWebsite/AdminWebsite/Contracts/Responses/HearingTypeResponse.cs b/AdminWebsite/AdminWebsite/Contracts/Responses/HearingTypeResponse.cs index 2078684b4..b642b68eb 100644 --- a/AdminWebsite/AdminWebsite/Contracts/Responses/HearingTypeResponse.cs +++ b/AdminWebsite/AdminWebsite/Contracts/Responses/HearingTypeResponse.cs @@ -1,15 +1,10 @@ -namespace AdminWebsite.Contracts.Responses +namespace AdminWebsite.Contracts.Responses { /// <summary> /// Defines a type of hearing based on case /// </summary> public class HearingTypeResponse { - /// <summary> - /// The short code for the type - /// </summary> - public string Code { get; set; } - /// <summary> /// Which case type it belongs to /// </summary> @@ -20,11 +15,6 @@ public class HearingTypeResponse /// </summary> public int? Id { get; set; } - /// <summary> - /// Hearing type display name - /// </summary> - public string Name { get; set; } - /// <summary> /// The service id for the type /// </summary> diff --git a/AdminWebsite/AdminWebsite/Contracts/Responses/ParticipantResponse.cs b/AdminWebsite/AdminWebsite/Contracts/Responses/ParticipantResponse.cs index 578b7e565..e800a145d 100644 --- a/AdminWebsite/AdminWebsite/Contracts/Responses/ParticipantResponse.cs +++ b/AdminWebsite/AdminWebsite/Contracts/Responses/ParticipantResponse.cs @@ -9,7 +9,6 @@ public class ParticipantResponse public string ExternalReferenceId { get; set; } public string MeasuresExternalId { get; set; } public string DisplayName { get; set; } - public string CaseRoleName { get; set; } public string HearingRoleName { get; set; } public string HearingRoleCode { get; set; } public string UserRoleName { get; set; } diff --git a/AdminWebsite/AdminWebsite/Controllers/BookingListController.cs b/AdminWebsite/AdminWebsite/Controllers/BookingListController.cs index bfc33ed55..a2fca35c5 100644 --- a/AdminWebsite/AdminWebsite/Controllers/BookingListController.cs +++ b/AdminWebsite/AdminWebsite/Controllers/BookingListController.cs @@ -105,7 +105,7 @@ public async Task<ActionResult> GetBookingsList([FromBody]BookingSearchRequest r private async Task<List<int>> GetCaseTypesId(IEnumerable<string> caseTypes) { var typeIds = new List<int>(); - var types = await _bookingsApiClient.GetCaseTypesAsync(includeDeleted:true); + var types = await _bookingsApiClient.GetCaseTypesV2Async(includeDeleted:true); if (types != null && types.Count != 0) foreach (var item in caseTypes) { diff --git a/AdminWebsite/AdminWebsite/Controllers/HearingsController.cs b/AdminWebsite/AdminWebsite/Controllers/HearingsController.cs index 62c59ce88..9be83bd1d 100644 --- a/AdminWebsite/AdminWebsite/Controllers/HearingsController.cs +++ b/AdminWebsite/AdminWebsite/Controllers/HearingsController.cs @@ -6,7 +6,6 @@ using AdminWebsite.Attributes; using AdminWebsite.Contracts.Enums; using AdminWebsite.Contracts.Requests; -using AdminWebsite.Contracts.Responses; using AdminWebsite.Extensions; using AdminWebsite.Helper; using AdminWebsite.Mappers; @@ -18,10 +17,9 @@ using BookingsApi.Client; using BookingsApi.Contract.Interfaces.Requests; using BookingsApi.Contract.V1.Requests; -using BookingsApi.Contract.V1.Requests.Enums; +using BookingsApi.Contract.V2.Enums; using BookingsApi.Contract.V2.Requests; using BookingsApi.Contract.V2.Responses; -using FluentValidation; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Newtonsoft.Json; @@ -30,6 +28,7 @@ using VideoApi.Contract.Responses; using HearingDetailsResponse = AdminWebsite.Contracts.Responses.HearingDetailsResponse; using JudiciaryParticipantRequest = AdminWebsite.Contracts.Requests.JudiciaryParticipantRequest; +using JudiciaryParticipantResponse = AdminWebsite.Contracts.Responses.JudiciaryParticipantResponse; using LinkedParticipantRequest = AdminWebsite.Contracts.Requests.LinkedParticipantRequest; using ParticipantResponse = AdminWebsite.Contracts.Responses.ParticipantResponse; @@ -44,7 +43,6 @@ namespace AdminWebsite.Controllers public class HearingsController : ControllerBase { private readonly IBookingsApiClient _bookingsApiClient; - private readonly IValidator<EditHearingRequest> _editHearingRequestValidator; private readonly IHearingsService _hearingsService; private readonly IConferenceDetailsService _conferenceDetailsService; private readonly ILogger<HearingsController> _logger; @@ -56,14 +54,12 @@ public class HearingsController : ControllerBase #pragma warning disable S107 public HearingsController(IBookingsApiClient bookingsApiClient, IUserIdentity userIdentity, - IValidator<EditHearingRequest> editHearingRequestValidator, ILogger<HearingsController> logger, IHearingsService hearingsService, IConferenceDetailsService conferenceDetailsService) { _bookingsApiClient = bookingsApiClient; _userIdentity = userIdentity; - _editHearingRequestValidator = editHearingRequestValidator; _logger = logger; _hearingsService = hearingsService; _conferenceDetailsService = conferenceDetailsService; @@ -180,7 +176,7 @@ public async Task<IActionResult> CloneHearing(Guid hearingId, MultiHearingReques return BadRequest(); } - var cloneHearingRequest = new CloneHearingRequest + var cloneHearingRequest = new CloneHearingRequestV2() { Dates = hearingDates, ScheduledDuration = hearingRequest.ScheduledDuration @@ -192,7 +188,7 @@ public async Task<IActionResult> CloneHearing(Guid hearingId, MultiHearingReques await _bookingsApiClient.CloneHearingAsync(hearingId, cloneHearingRequest); _logger.LogDebug("Successfully cloned hearing {Hearing}", hearingId); - var groupedHearings = await _bookingsApiClient.GetHearingsByGroupIdAsync(hearingId); + var groupedHearings = await _bookingsApiClient.GetHearingsByGroupIdV2Async(hearingId); var conferenceStatusToGet = groupedHearings.Where(x => x.Participants? .Exists(gh => gh.HearingRoleName == RoleNames.Judge) ?? false); @@ -249,14 +245,6 @@ public async Task<ActionResult<HearingDetailsResponse>> EditHearing(Guid hearing } _logger.LogDebug("Attempting to edit hearing {Hearing}", hearingId); - var result = await _editHearingRequestValidator.ValidateAsync(request); - if (!result.IsValid) - { - _logger.LogWarning("Failed edit hearing validation"); - ModelState.AddFluentValidationErrors(result.Errors); - return ValidationProblem(ModelState); - } - HearingDetailsResponse originalHearing; try { @@ -437,8 +425,8 @@ private async Task UpdateMultiDayHearing(EditMultiDayHearingRequest request, Gui hearingsToUpdate = hearingsToUpdate .Where(h => - h.Status != BookingsApi.Contract.V2.Enums.BookingStatusV2.Cancelled && - h.Status != BookingsApi.Contract.V2.Enums.BookingStatusV2.Failed) + h.Status != BookingStatusV2.Cancelled && + h.Status != BookingStatusV2.Failed) .ToList(); await UpdateMultiDayHearingV2(hearingsToUpdate, hearingId, groupId, request); @@ -512,10 +500,10 @@ private async Task UpdateMultiDayHearingV2( private async Task CancelMultiDayHearing(CancelMultiDayHearingRequest request, Guid hearingId, Guid groupId) { - var hearingsInMultiDay = await _bookingsApiClient.GetHearingsByGroupIdAsync(groupId); + var hearingsInMultiDay = await _bookingsApiClient.GetHearingsByGroupIdV2Async(groupId); var thisHearing = hearingsInMultiDay.First(x => x.Id == hearingId); - var hearingsToCancel = new List<BookingsApi.Contract.V1.Responses.HearingDetailsResponse> + var hearingsToCancel = new List<HearingDetailsResponseV2> { thisHearing }; @@ -529,8 +517,8 @@ private async Task CancelMultiDayHearing(CancelMultiDayHearingRequest request, G // Hearings with these statuses will be rejected by bookings api, so filter them out hearingsToCancel = hearingsToCancel .Where(h => - h.Status != BookingsApi.Contract.V1.Enums.BookingStatus.Cancelled && - h.Status != BookingsApi.Contract.V1.Enums.BookingStatus.Failed) + h.Status != BookingStatusV2.Cancelled && + h.Status != BookingStatusV2.Failed) .ToList(); var cancelRequest = new CancelHearingsInGroupRequest @@ -628,7 +616,7 @@ private async Task UpdateJudiciaryParticipants(Guid hearingId, List<JudiciaryPar } var johsToAdd = request.NewJudiciaryParticipants - .Select(jp => new BookingsApi.Contract.V1.Requests.JudiciaryParticipantRequest() + .Select(jp => new BookingsApi.Contract.V2.Requests.JudiciaryParticipantRequest() { DisplayName = jp.DisplayName, PersonalCode = jp.PersonalCode, @@ -703,7 +691,7 @@ private static UpdateJudiciaryParticipantsRequest MapUpdateJudiciaryParticipants var newJohRequest = newJohs.Select(jp => { var roleCode = Enum.Parse<JudiciaryParticipantHearingRoleCode>(jp.Role); - return new BookingsApi.Contract.V1.Requests.JudiciaryParticipantRequest() + return new BookingsApi.Contract.V2.Requests.JudiciaryParticipantRequest() { DisplayName = jp.DisplayName, PersonalCode = jp.PersonalCode, @@ -720,7 +708,7 @@ private static UpdateJudiciaryParticipantsRequest MapUpdateJudiciaryParticipants if (johsToAdd.Count != 0) { var newParticipants = johsToAdd - .Select(x => new BookingsApi.Contract.V1.Requests.JudiciaryParticipantRequest + .Select(x => new BookingsApi.Contract.V2.Requests.JudiciaryParticipantRequest { ContactEmail = x.ContactEmail, DisplayName = x.DisplayName, diff --git a/AdminWebsite/AdminWebsite/Controllers/PersonsController.cs b/AdminWebsite/AdminWebsite/Controllers/PersonsController.cs index 2a47b3462..a21f317a9 100644 --- a/AdminWebsite/AdminWebsite/Controllers/PersonsController.cs +++ b/AdminWebsite/AdminWebsite/Controllers/PersonsController.cs @@ -11,8 +11,9 @@ using AdminWebsite.Contracts.Requests; using AdminWebsite.Services; using BookingsApi.Client; -using BookingsApi.Contract.V1.Requests; using BookingsApi.Contract.V1.Responses; +using BookingsApi.Contract.V2.Requests; +using BookingsApi.Contract.V2.Responses; using UserApi.Client; namespace AdminWebsite.Controllers @@ -49,16 +50,16 @@ public PersonsController(IBookingsApiClient bookingsApiClient, JavaScriptEncoder /// <returns> The list of person</returns> [HttpPost] [SwaggerOperation(OperationId = "PostPersonBySearchTerm")] - [ProducesResponseType(typeof(List<PersonResponse>), (int)HttpStatusCode.OK)] + [ProducesResponseType(typeof(List<PersonResponseV2>), (int)HttpStatusCode.OK)] [ProducesResponseType((int)HttpStatusCode.BadRequest)] - public async Task<ActionResult<IList<PersonResponse>>> PostPersonBySearchTerm([FromBody] string term) + public async Task<ActionResult<IList<PersonResponseV2>>> PostPersonBySearchTerm([FromBody] string term) { try { term = _encoder.Encode(term); - var searchTerm = new SearchTermRequest(term); + var searchTerm = new SearchTermRequestV2(term); - var personsResponse = await _bookingsApiClient.PostPersonBySearchTermAsync(searchTerm); + var personsResponse = await _bookingsApiClient.SearchForPersonV2Async(searchTerm); personsResponse = personsResponse?.Where(p => !p.ContactEmail.Contains(_testSettings.TestUsernameStem)).ToList(); @@ -128,14 +129,14 @@ public async Task<IActionResult> DeletePersonWithUsernameAsync(string username) /// <returns>A person</returns> [HttpGet(Name = "GetPersonForUpdateByContactEmail")] [SwaggerOperation(OperationId = "GetPersonForUpdateByContactEmail")] - [ProducesResponseType(typeof(PersonResponse), (int)HttpStatusCode.OK)] + [ProducesResponseType(typeof(PersonResponseV2), (int)HttpStatusCode.OK)] [ProducesResponseType((int)HttpStatusCode.NotFound)] - public async Task<ActionResult<PersonResponse>> GetPersonForUpdateByContactEmail( + public async Task<ActionResult<PersonResponseV2>> GetPersonForUpdateByContactEmail( [FromQuery] string contactEmail) { try { - var person = await _bookingsApiClient.SearchForNonJudgePersonsByContactEmailAsync(contactEmail); + var person = await _bookingsApiClient.SearchForNonJudgePersonsByContactEmailV2Async(contactEmail); return Ok(person); } catch (BookingsApiException e) @@ -144,7 +145,6 @@ public async Task<ActionResult<PersonResponse>> GetPersonForUpdateByContactEmail } } - /// <returns>A person</returns> /// <summary> /// Update the personal details /// </summary> @@ -156,10 +156,9 @@ public async Task<ActionResult<PersonResponse>> GetPersonForUpdateByContactEmail [ProducesResponseType((int)HttpStatusCode.Accepted)] [ProducesResponseType((int)HttpStatusCode.NotFound)] [ProducesResponseType((int)HttpStatusCode.BadRequest)] - public async Task<ActionResult<IList<PersonResponse>>> UpdatePersonDetails([FromRoute] Guid personId, + public async Task<ActionResult> UpdatePersonDetails([FromRoute] Guid personId, [FromBody] UpdateAccountDetailsRequest payload) { - try { var useridString = await _userAccountService.GetAdUserIdForUsername(payload.CurrentUsername); @@ -167,13 +166,13 @@ public async Task<ActionResult<IList<PersonResponse>>> UpdatePersonDetails([From var updatedPerson = await _userAccountService.UpdateUserAccountDetails(userId, payload.FirstName, payload.LastName); - var updateBookingPersonRequest = new UpdatePersonDetailsRequest + var updateBookingPersonRequest = new UpdatePersonDetailsRequestV2() { FirstName = updatedPerson.FirstName, LastName = updatedPerson.LastName, Username = updatedPerson.Email }; - await _bookingsApiClient.UpdatePersonDetailsAsync(personId, updateBookingPersonRequest); + await _bookingsApiClient.UpdatePersonDetailsV2Async(personId, updateBookingPersonRequest); return Accepted(); } catch (UserApiException e) diff --git a/AdminWebsite/AdminWebsite/Controllers/HearingRolesController.cs b/AdminWebsite/AdminWebsite/Controllers/ReferenceData/HearingRolesController.cs similarity index 96% rename from AdminWebsite/AdminWebsite/Controllers/HearingRolesController.cs rename to AdminWebsite/AdminWebsite/Controllers/ReferenceData/HearingRolesController.cs index 3358da8a4..06b796aff 100644 --- a/AdminWebsite/AdminWebsite/Controllers/HearingRolesController.cs +++ b/AdminWebsite/AdminWebsite/Controllers/ReferenceData/HearingRolesController.cs @@ -9,7 +9,7 @@ using Microsoft.AspNetCore.Mvc; using Swashbuckle.AspNetCore.Annotations; -namespace AdminWebsite.Controllers +namespace AdminWebsite.Controllers.ReferenceData { [Produces("application/json")] [Route("api/hearingroles")] diff --git a/AdminWebsite/AdminWebsite/Controllers/ReferenceData/HearingTypesController.cs b/AdminWebsite/AdminWebsite/Controllers/ReferenceData/HearingTypesController.cs index 10c45ef18..2181092c7 100644 --- a/AdminWebsite/AdminWebsite/Controllers/ReferenceData/HearingTypesController.cs +++ b/AdminWebsite/AdminWebsite/Controllers/ReferenceData/HearingTypesController.cs @@ -30,26 +30,15 @@ public HearingTypesController(IReferenceDataService referenceDataService) [HttpGet("types", Name = "GetHearingTypes")] [ProducesResponseType(typeof(IList<HearingTypeResponse>), (int)HttpStatusCode.OK)] [ProducesResponseType((int)HttpStatusCode.NotFound)] - public async Task<ActionResult<IList<HearingTypeResponse>>> GetHearingTypes( - [FromQuery] bool includeDeleted = false) + public async Task<ActionResult<IList<HearingTypeResponse>>> GetHearingTypes() { var caseTypes = await _referenceDataService.GetNonDeletedCaseTypesAsync(); - var result = caseTypes.SelectMany(caseType => caseType.HearingTypes - .Select(hearingType => new HearingTypeResponse - { - Group = caseType.Name, - Id = hearingType.Id, - Name = hearingType.Name, - ServiceId = caseType.ServiceId, - Code = hearingType.Code - })).ToList(); - - result.AddRange(caseTypes.Where(ct => ct.HearingTypes.Count == 0) - .Select(caseType => new HearingTypeResponse + var result = caseTypes.Select(caseType => new HearingTypeResponse { Group = caseType.Name, + Id = caseType.Id, ServiceId = caseType.ServiceId - })); + }).ToList(); return Ok(result); } diff --git a/AdminWebsite/AdminWebsite/Controllers/ReferenceData/ParticipantRolesController.cs b/AdminWebsite/AdminWebsite/Controllers/ReferenceData/ParticipantRolesController.cs deleted file mode 100644 index 45216a378..000000000 --- a/AdminWebsite/AdminWebsite/Controllers/ReferenceData/ParticipantRolesController.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Threading.Tasks; -using AdminWebsite.Models; -using BookingsApi.Client; -using BookingsApi.Contract.Interfaces.Response; -using Microsoft.AspNetCore.Mvc; - -namespace AdminWebsite.Controllers.ReferenceData; - -/// <summary> -/// Responsible for retrieving participant roles reference data when requesting a booking. -/// </summary> -public class ParticipantRolesController : ReferenceDataControllerBase -{ - private readonly IBookingsApiClient _bookingsApiClient; - - /// <summary> - /// Instantiate the controller - /// </summary> - public ParticipantRolesController(IBookingsApiClient bookingsApiClient) - { - _bookingsApiClient = bookingsApiClient; - } - - /// <summary> - /// Get available participant roles - /// </summary> - /// <returns>List of valid participant roles</returns> - [HttpGet("participantroles", Name = "GetParticipantRoles")] - [ProducesResponseType(typeof(IList<CaseAndHearingRolesResponse>), (int)HttpStatusCode.OK)] - [ProducesResponseType((int)HttpStatusCode.NotFound)] - public async Task<ActionResult<IList<CaseAndHearingRolesResponse>>> GetParticipantRoles(string caseTypeParameter) - { - var response = new List<CaseAndHearingRolesResponse>(); - List<ICaseRoleResponse> iCaseRoles; - var caseRoles2 = await _bookingsApiClient.GetCaseRolesForCaseServiceAsync(caseTypeParameter); - iCaseRoles = caseRoles2?.Select(e => (ICaseRoleResponse)e).ToList(); - - - if (iCaseRoles != null && iCaseRoles.Count != 0) - { - foreach (var caseRoleName in iCaseRoles.Select(cr => cr.Name)) - { - var caseRole = new CaseAndHearingRolesResponse { Name = caseRoleName }; - List<IHearingRoleResponse> iHearingRoles; - var hearingRoles1 = - await _bookingsApiClient.GetHearingRolesForCaseRoleV2Async(caseTypeParameter, caseRoleName); - iHearingRoles = hearingRoles1.Select(e => (IHearingRoleResponse)e).ToList(); - - caseRole.HearingRoles = iHearingRoles.ConvertAll(x => new HearingRole(x.Name, x.UserRole)); - - response.Add(caseRole); - } - } - - return Ok(response); - } -} \ No newline at end of file diff --git a/AdminWebsite/AdminWebsite/Controllers/WorkAllocationController.cs b/AdminWebsite/AdminWebsite/Controllers/WorkAllocationController.cs index 77060c49a..9b9bf4989 100644 --- a/AdminWebsite/AdminWebsite/Controllers/WorkAllocationController.cs +++ b/AdminWebsite/AdminWebsite/Controllers/WorkAllocationController.cs @@ -8,11 +8,10 @@ using AdminWebsite.Models; using BookingsApi.Client; using BookingsApi.Contract.V1.Requests; -using BookingsApi.Contract.V1.Responses; +using BookingsApi.Contract.V2.Responses; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Swashbuckle.AspNetCore.Annotations; -using HearingDetailsResponse = BookingsApi.Contract.V1.Responses.HearingDetailsResponse; namespace AdminWebsite.Controllers { @@ -37,10 +36,10 @@ public WorkAllocationController(IBookingsApiClient bookingsApiClient) [ProducesResponseType(typeof(UnallocatedHearingsForVhoResponse), (int)HttpStatusCode.OK)] public async Task<IActionResult> GetUnallocatedHearings() { - var unallocatedHearings = await _bookingsApiClient.GetUnallocatedHearingsAsync(); + var unallocatedHearings = await _bookingsApiClient.GetUnallocatedHearingsV2Async(); if (unallocatedHearings == null || unallocatedHearings.Count == 0) - return Ok(UnallocatedHearingsForVhoMapper.MapFrom(new List<HearingDetailsResponse>(), DateTime.Today)); + return Ok(UnallocatedHearingsForVhoMapper.MapFrom(new List<HearingDetailsResponseV2>(), DateTime.Today)); return Ok(UnallocatedHearingsForVhoMapper.MapFrom(unallocatedHearings.ToList(), DateTime.Today)); } diff --git a/AdminWebsite/AdminWebsite/Extensions/ConfigureServicesExtensions.cs b/AdminWebsite/AdminWebsite/Extensions/ConfigureServicesExtensions.cs index 5e00aece2..e25293eed 100644 --- a/AdminWebsite/AdminWebsite/Extensions/ConfigureServicesExtensions.cs +++ b/AdminWebsite/AdminWebsite/Extensions/ConfigureServicesExtensions.cs @@ -5,13 +5,10 @@ using AdminWebsite.Configuration; using AdminWebsite.Contracts.Responses; using AdminWebsite.Middleware; -using AdminWebsite.Models; using AdminWebsite.Security; using AdminWebsite.Services; using AdminWebsite.Swagger; -using AdminWebsite.Validators; using BookingsApi.Client; -using FluentValidation; using MicroElements.Swashbuckle.FluentValidation.AspNetCore; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; @@ -139,13 +136,11 @@ public static IServiceCollection AddCustomTypes(this IServiceCollection serviceC serviceCollection.AddHttpClient<IPublicHolidayRetriever, UkPublicHolidayRetriever>(); serviceCollection.AddTransient<IUserIdentity, UserIdentity>((ctx) => { - var userPrincipal = ctx.GetService<IHttpContextAccessor>().HttpContext.User; + var userPrincipal = ctx.GetService<IHttpContextAccessor>().HttpContext!.User; return new UserIdentity(userPrincipal); }); - serviceCollection.AddSingleton<IValidator<EditHearingRequest>, EditHearingRequestValidator>(); - return serviceCollection; } diff --git a/AdminWebsite/AdminWebsite/Extensions/HearingDetailsResponseExtensions.cs b/AdminWebsite/AdminWebsite/Extensions/HearingDetailsResponseExtensions.cs index c666885de..7c200fb83 100644 --- a/AdminWebsite/AdminWebsite/Extensions/HearingDetailsResponseExtensions.cs +++ b/AdminWebsite/AdminWebsite/Extensions/HearingDetailsResponseExtensions.cs @@ -1,207 +1,11 @@ -using System; -using System.Linq; -using AdminWebsite.Contracts.Enums; using AdminWebsite.Contracts.Responses; -using AdminWebsite.Models; -using Newtonsoft.Json; -namespace AdminWebsite.Extensions +namespace AdminWebsite.Extensions; + +public static class HearingDetailsResponseExtensions { - public static class HearingDetailsResponseExtensions + public static bool HasScheduleAmended(this HearingDetailsResponse hearing, HearingDetailsResponse anotherHearing) { - public static bool IsGenericHearing(this HearingDetailsResponse hearing) - { - return hearing.CaseTypeName.Equals("Generic", StringComparison.CurrentCultureIgnoreCase); - } - - public static bool HasScheduleAmended(this HearingDetailsResponse hearing, HearingDetailsResponse anotherHearing) - - { - return hearing.ScheduledDateTime.Ticks != anotherHearing.ScheduledDateTime.Ticks; - } - public static bool JudgeHasNotChangedForGenericHearing(this HearingDetailsResponse newHearingJudge, HearingDetailsResponse originalHearingJudge) - { - var judgeFromUpdatedHearing = newHearingJudge.GetJudgeById(); - var judgeFromOriginalHearing = originalHearingJudge.GetJudgeById(); - - if((judgeFromUpdatedHearing != judgeFromOriginalHearing) && newHearingJudge.IsGenericHearing()) return false; - return true; - } - private static Guid? GetJudgeById(this HearingDetailsResponse hearing) - { - var judgeId = hearing?.Participants.SingleOrDefault(x => - x.UserRoleName.Contains(RoleNames.Judge, StringComparison.CurrentCultureIgnoreCase))?.Id; - return judgeId; - } - - public static bool HasJudgeEmailChanged(this HearingDetailsResponse hearing, HearingDetailsResponse originalHearing) - { - var isNewJudgeEJud = IsJudgeEmailEJud(hearing); - var isOriginalJudgeEJud = IsJudgeEmailEJud(originalHearing); - var isNewJudgeVhJudge = hearing.GetJudgeEmail() != null; - var isOriginalJudgeVhJudge = originalHearing.GetJudgeEmail() != null; - - - if (isNewJudgeEJud && isOriginalJudgeEJud) - { - var judgeA = hearing.Participants.Find(x => - x.UserRoleName.Contains(RoleNames.Judge, StringComparison.CurrentCultureIgnoreCase)); - - - var judgeB = originalHearing.Participants.Find(x => - x.UserRoleName.Contains(RoleNames.Judge, StringComparison.CurrentCultureIgnoreCase)); - - return judgeA?.ContactEmail != judgeB?.ContactEmail; - } - - if (isNewJudgeVhJudge && isOriginalJudgeVhJudge) - { - return hearing.GetJudgeEmail() != originalHearing.GetJudgeEmail(); - } - - return isNewJudgeEJud || isOriginalJudgeEJud || isNewJudgeVhJudge || isOriginalJudgeVhJudge; - } - - public static bool DoesJudgeEmailExist(this HearingDetailsResponse hearing) - { - if (hearing.IsJudgeEmailEJud()) - { - return true; - } - - if (hearing.OtherInformation == null) return false; - var otherInformationDetails = GetOtherInformationObject(hearing.OtherInformation); - return !string.IsNullOrEmpty(otherInformationDetails.JudgeEmail); - } - - public static bool DoesJudgePhoneExist(this HearingDetailsResponse hearing) - { - if (hearing.OtherInformation == null) return false; - var otherInformationDetails = GetOtherInformationObject(hearing.OtherInformation); - return !string.IsNullOrWhiteSpace(otherInformationDetails.JudgePhone); - } - - public static string GetJudgeEmail(this HearingDetailsResponse hearing) - { - - var email = GetOtherInformationObject(hearing.OtherInformation)?.JudgeEmail; - if (string.IsNullOrEmpty(email)) - { - return null; - } - - return email; - } - - public static bool IsJudgeEmailEJud(this HearingDetailsResponse hearing) - { - var judge = hearing?.Participants.SingleOrDefault(x => - x.UserRoleName.Contains(RoleNames.Judge, StringComparison.CurrentCultureIgnoreCase)); - return IsEmailEjud(judge?.Username); - } - - public static bool IsParticipantAEJudJudicialOfficeHolder(this HearingDetailsResponse hearing, Guid participantId) - { - var joh = hearing?.Participants.SingleOrDefault(x => x.Id == participantId && - x.UserRoleName.Contains(RoleNames.JudicialOfficeHolder, StringComparison.CurrentCultureIgnoreCase)); - - return IsEmailEjud(joh?.Username); - } - - public static bool IsParticipantAJudicialOfficeHolderOrJudge(this HearingDetailsResponse hearing, - Guid participantId) - { - var joh = hearing?.Participants.SingleOrDefault(x => x.Id == participantId && - x.UserRoleName.Contains(RoleNames.JudicialOfficeHolder, - StringComparison.CurrentCultureIgnoreCase)); - var judge = hearing?.Participants.SingleOrDefault(x => x.Id == participantId && - x.UserRoleName.Contains(RoleNames.Judge, - StringComparison.CurrentCultureIgnoreCase)); - var result = joh != null || judge != null; - return result; - } - - private static bool IsEmailEjud(string email) - { - return !string.IsNullOrEmpty(email) && email.Contains("judiciary", StringComparison.CurrentCultureIgnoreCase); - } - - public static string GetJudgePhone(this HearingDetailsResponse hearing) - { - var phone = GetOtherInformationObject(hearing.OtherInformation).JudgePhone; - if (phone == string.Empty) - { - return null; - } - - return phone; - } - - public static string ToOtherInformationString(this OtherInformationDetails otherInformationDetailsObject) - { - return - otherInformationDetailsObject.ToJudgeOtherInformationString() + - $"|OtherInformation|{otherInformationDetailsObject.OtherInformation}"; - } - - public static HearingDetailsResponse Duplicate(this HearingDetailsResponse hearingDetailsResponse) - { - var json = JsonConvert.SerializeObject(hearingDetailsResponse); - return JsonConvert.DeserializeObject<HearingDetailsResponse>(json); - } - - public static BookingsApi.Contract.V1.Responses.HearingDetailsResponse Duplicate(this BookingsApi.Contract.V1.Responses.HearingDetailsResponse hearingDetailsResponse) - { - var json = JsonConvert.SerializeObject(hearingDetailsResponse); - return JsonConvert.DeserializeObject<BookingsApi.Contract.V1.Responses.HearingDetailsResponse>(json); - } - - public static string GetJudgeOtherInformationString(string otherInformation) - { - var otherInformationDetailsObject = GetOtherInformationObject(otherInformation); - return otherInformationDetailsObject.ToJudgeOtherInformationString(); - } - - private static string ToJudgeOtherInformationString(this OtherInformationDetails otherInformationDetailsObject) - { - return $"|JudgeEmail|{otherInformationDetailsObject.JudgeEmail}" + - $"|JudgePhone|{otherInformationDetailsObject.JudgePhone}"; - } - - private static OtherInformationDetails GetOtherInformationObject(string otherInformation) - { - try - { - var properties = otherInformation.Split("|"); - var otherInfo = new OtherInformationDetails - { - JudgeEmail = Array.IndexOf(properties, "JudgeEmail") > -1 - ? properties[Array.IndexOf(properties, "JudgeEmail") + 1] - : "", - JudgePhone = Array.IndexOf(properties, "JudgePhone") > -1 - ? properties[Array.IndexOf(properties, "JudgePhone") + 1] - : "", - OtherInformation = Array.IndexOf(properties, "OtherInformation") > -1 - ? properties[Array.IndexOf(properties, "OtherInformation") + 1] - : "" - }; - return otherInfo; - } - catch (Exception) - { - if (string.IsNullOrWhiteSpace(otherInformation)) - { - return new OtherInformationDetails { OtherInformation = otherInformation }; - } - - var properties = otherInformation.Split("|"); - if (properties.Length > 2) - { - return new OtherInformationDetails { OtherInformation = properties[2] }; - } - - return new OtherInformationDetails { OtherInformation = otherInformation }; - } - } + return hearing.ScheduledDateTime.Ticks != anotherHearing.ScheduledDateTime.Ticks; } } \ No newline at end of file diff --git a/AdminWebsite/AdminWebsite/Mappers/AvailableLanguageResponseMapper.cs b/AdminWebsite/AdminWebsite/Mappers/AvailableLanguageResponseMapper.cs index be34dafef..5ac1572e3 100644 --- a/AdminWebsite/AdminWebsite/Mappers/AvailableLanguageResponseMapper.cs +++ b/AdminWebsite/AdminWebsite/Mappers/AvailableLanguageResponseMapper.cs @@ -5,7 +5,7 @@ namespace AdminWebsite.Mappers; public static class AvailableLanguageResponseMapper { - public static AvailableLanguageResponse Map(this BookingsApi.Contract.V1.Responses.InterpreterLanguagesResponse languagesResponse) + public static AvailableLanguageResponse Map(this BookingsApi.Contract.V2.Responses.InterpreterLanguagesResponse languagesResponse) { return new AvailableLanguageResponse() { diff --git a/AdminWebsite/AdminWebsite/Mappers/BookingDetailsRequestMapper.cs b/AdminWebsite/AdminWebsite/Mappers/BookingDetailsRequestMapper.cs index f733c3568..0688ba579 100644 --- a/AdminWebsite/AdminWebsite/Mappers/BookingDetailsRequestMapper.cs +++ b/AdminWebsite/AdminWebsite/Mappers/BookingDetailsRequestMapper.cs @@ -25,7 +25,7 @@ public static V2.BookNewHearingRequestV2 MapToV2(this BookingDetailsRequest book Participants = bookingDetails.Participants? .Select(p => p.MapToV2()) .ToList(), - JudiciaryParticipants = bookingDetails.JudiciaryParticipants.Select(jp => jp.MapToV1()).ToList(), + JudicialOfficeHolders = bookingDetails.JudiciaryParticipants.Select(jp => jp.MapToV2()).ToList(), HearingRoomName = bookingDetails.HearingRoomName, OtherInformation = bookingDetails.OtherInformation, CreatedBy = bookingDetails.CreatedBy, diff --git a/AdminWebsite/AdminWebsite/Mappers/BookingsHearingResponseMapper.cs b/AdminWebsite/AdminWebsite/Mappers/BookingsHearingResponseMapper.cs index c0b1a2416..0ec688021 100644 --- a/AdminWebsite/AdminWebsite/Mappers/BookingsHearingResponseMapper.cs +++ b/AdminWebsite/AdminWebsite/Mappers/BookingsHearingResponseMapper.cs @@ -1,4 +1,3 @@ -using System; using BookingsHearingResponse = AdminWebsite.Contracts.Responses.BookingsHearingResponse; namespace AdminWebsite.Mappers; @@ -15,7 +14,6 @@ public static BookingsHearingResponse Map(this BookingsApi.Contract.V1.Responses ScheduledDateTime = hearingResponse.ScheduledDateTime, ScheduledDuration = hearingResponse.ScheduledDuration, CaseTypeName = hearingResponse.CaseTypeName, - HearingTypeName = hearingResponse.HearingTypeName, CourtRoom = hearingResponse.CourtRoom, CourtAddress = hearingResponse.CourtAddress, JudgeName = hearingResponse.JudgeName, diff --git a/AdminWebsite/AdminWebsite/Mappers/EditEndpointRequestMapper.cs b/AdminWebsite/AdminWebsite/Mappers/EditEndpointRequestMapper.cs index b4d3d6cbc..c6d1d68f4 100644 --- a/AdminWebsite/AdminWebsite/Mappers/EditEndpointRequestMapper.cs +++ b/AdminWebsite/AdminWebsite/Mappers/EditEndpointRequestMapper.cs @@ -1,6 +1,6 @@ using AdminWebsite.Contracts.Responses; using AdminWebsite.Models; -using V1 = BookingsApi.Contract.V1.Responses; +using V2 = BookingsApi.Contract.V2.Responses; namespace AdminWebsite.Mappers { @@ -17,7 +17,7 @@ public static EditEndpointRequest MapFrom(EndpointResponse response) }; } - public static EditEndpointRequest MapFrom(V1.EndpointResponse response) + public static EditEndpointRequest MapFrom(V2.EndpointResponseV2 response) { return new EditEndpointRequest { diff --git a/AdminWebsite/AdminWebsite/Mappers/EditMultiDayHearing/HearingChangesMapper.cs b/AdminWebsite/AdminWebsite/Mappers/EditMultiDayHearing/HearingChangesMapper.cs index 4609d27f3..e05158e1b 100644 --- a/AdminWebsite/AdminWebsite/Mappers/EditMultiDayHearing/HearingChangesMapper.cs +++ b/AdminWebsite/AdminWebsite/Mappers/EditMultiDayHearing/HearingChangesMapper.cs @@ -7,6 +7,7 @@ using AdminWebsite.Models; using AdminWebsite.Models.EditMultiDayHearing; using BookingsApi.Contract.V2.Responses; +using JudiciaryParticipantResponse = AdminWebsite.Contracts.Responses.JudiciaryParticipantResponse; using LinkedParticipant = AdminWebsite.Models.EditMultiDayHearing.LinkedParticipant; namespace AdminWebsite.Mappers.EditMultiDayHearing @@ -197,7 +198,7 @@ private static List<EndpointResponse> GetRemovedEndpoints(List<EditEndpointReque private static List<JudiciaryParticipantRequest> GetNewJudiciaryParticipants(HearingDetailsResponseV2 hearing, EditMultiDayHearingRequest request) { return request.JudiciaryParticipants - .Where(rjp => !hearing.JudiciaryParticipants.Exists(jp => jp.PersonalCode == rjp.PersonalCode)) + .Where(rjp => !hearing.JudicialOfficeHolders.Exists(jp => jp.PersonalCode == rjp.PersonalCode)) .ToList(); } diff --git a/AdminWebsite/AdminWebsite/Mappers/EditParticipantRequestMapper.cs b/AdminWebsite/AdminWebsite/Mappers/EditParticipantRequestMapper.cs index 46efbcdef..a9ce50eeb 100644 --- a/AdminWebsite/AdminWebsite/Mappers/EditParticipantRequestMapper.cs +++ b/AdminWebsite/AdminWebsite/Mappers/EditParticipantRequestMapper.cs @@ -1,6 +1,5 @@ using AdminWebsite.Contracts.Responses; using AdminWebsite.Models; -using V1 = BookingsApi.Contract.V1.Responses; using V2 = BookingsApi.Contract.V2.Responses; namespace AdminWebsite.Mappers { @@ -18,14 +17,13 @@ public static EditParticipantRequest MapFrom(ParticipantResponse response) ContactEmail = response.ContactEmail, TelephoneNumber = response.TelephoneNumber, DisplayName = response.DisplayName, - CaseRoleName = response.CaseRoleName, HearingRoleName = response.HearingRoleName, Representee = response.Representee, OrganisationName = response.Organisation, }; } - public static EditParticipantRequest MapFrom(V1.ParticipantResponse response) + public static EditParticipantRequest MapFrom(V2.ParticipantResponseV2 response) { return new EditParticipantRequest { @@ -37,7 +35,6 @@ public static EditParticipantRequest MapFrom(V1.ParticipantResponse response) ContactEmail = response.ContactEmail, TelephoneNumber = response.TelephoneNumber, DisplayName = response.DisplayName, - CaseRoleName = response.CaseRoleName, HearingRoleName = response.HearingRoleName, Representee = response.Representee, OrganisationName = response.Organisation, diff --git a/AdminWebsite/AdminWebsite/Mappers/HearingDetailsResponseMapper.cs b/AdminWebsite/AdminWebsite/Mappers/HearingDetailsResponseMapper.cs index f37225345..4d6d197aa 100644 --- a/AdminWebsite/AdminWebsite/Mappers/HearingDetailsResponseMapper.cs +++ b/AdminWebsite/AdminWebsite/Mappers/HearingDetailsResponseMapper.cs @@ -4,7 +4,6 @@ using AdminWebsite.Contracts.Enums; using AdminWebsite.Contracts.Responses; using BookingsApi.Contract.V2.Enums; -using V1 = BookingsApi.Contract.V1.Responses; using V2 = BookingsApi.Contract.V2.Responses; namespace AdminWebsite.Mappers; @@ -17,10 +16,8 @@ public static HearingDetailsResponse Map(this V2.HearingDetailsResponseV2 hearin Id = hearingDetails.Id, ScheduledDateTime = hearingDetails.ScheduledDateTime, ScheduledDuration = hearingDetails.ScheduledDuration, - HearingVenueName = hearingDetails.HearingVenueName, HearingVenueCode = hearingDetails.HearingVenueCode, ServiceId = hearingDetails.ServiceId, - CaseTypeName = hearingDetails.ServiceName, Cases = hearingDetails.Cases?.Select(e => new CaseResponse { IsLeadCase = e.IsLeadCase, @@ -40,7 +37,7 @@ public static HearingDetailsResponse Map(this V2.HearingDetailsResponseV2 hearin AudioRecordingRequired = hearingDetails.AudioRecordingRequired, CancelReason = hearingDetails.CancelReason, Endpoints = hearingDetails.Endpoints?.Select(e => e.Map(hearingDetails)).ToList(), - JudiciaryParticipants = hearingDetails.JudiciaryParticipants?.Select(j => j.Map()).ToList(), + JudiciaryParticipants = hearingDetails.JudicialOfficeHolders?.Select(j => j.Map()).ToList(), GroupId = hearingDetails.GroupId, ConferenceSupplier = Enum.TryParse<VideoSupplier>(hearingDetails.BookingSupplier.ToString(), out var supplier) ? supplier : VideoSupplier.Kinly, AllocatedToUsername = hearingDetails.AllocatedToUsername diff --git a/AdminWebsite/AdminWebsite/Mappers/JudgeResponseMapper.cs b/AdminWebsite/AdminWebsite/Mappers/JudgeResponseMapper.cs index b856354ef..da893a554 100644 --- a/AdminWebsite/AdminWebsite/Mappers/JudgeResponseMapper.cs +++ b/AdminWebsite/AdminWebsite/Mappers/JudgeResponseMapper.cs @@ -19,18 +19,6 @@ public static JudgeResponse MapTo(JudgeResponse personResponse) } - public static JudgeResponse MapTo(PersonResponse personResponse) - { - return new JudgeResponse - { - FirstName = personResponse.FirstName, - LastName = personResponse.LastName, - Email = personResponse.Username, - AccountType = JudgeAccountType.Judiciary, - ContactEmail = personResponse.ContactEmail - }; - } - public static JudgeResponse MapTo(JudiciaryPersonResponse personResponse) { return new JudgeResponse diff --git a/AdminWebsite/AdminWebsite/Mappers/JudiciaryParticipantRequestMapper.cs b/AdminWebsite/AdminWebsite/Mappers/JudiciaryParticipantRequestMapper.cs index 54416e6fe..68aac772a 100644 --- a/AdminWebsite/AdminWebsite/Mappers/JudiciaryParticipantRequestMapper.cs +++ b/AdminWebsite/AdminWebsite/Mappers/JudiciaryParticipantRequestMapper.cs @@ -1,13 +1,13 @@ using System; using AdminWebsite.Contracts.Requests; -using BookingsApi.Contract.V1.Requests.Enums; -using V1 = BookingsApi.Contract.V1.Requests; +using BookingsApi.Contract.V2.Enums; +using V2 = BookingsApi.Contract.V2.Requests; namespace AdminWebsite.Mappers { public static class JudiciaryParticipantRequestMapper { - public static V1.JudiciaryParticipantRequest MapToV1(this JudiciaryParticipantRequest request) => + public static V2.JudiciaryParticipantRequest MapToV2(this JudiciaryParticipantRequest request) => new() { DisplayName = request.DisplayName, diff --git a/AdminWebsite/AdminWebsite/Mappers/JudiciaryParticipantResponseMapper.cs b/AdminWebsite/AdminWebsite/Mappers/JudiciaryParticipantResponseMapper.cs index de84cd509..86a55d742 100644 --- a/AdminWebsite/AdminWebsite/Mappers/JudiciaryParticipantResponseMapper.cs +++ b/AdminWebsite/AdminWebsite/Mappers/JudiciaryParticipantResponseMapper.cs @@ -4,7 +4,7 @@ namespace AdminWebsite.Mappers { public static class JudiciaryParticipantResponseMapper { - public static JudiciaryParticipantResponse Map(this BookingsApi.Contract.V1.Responses.JudiciaryParticipantResponse judiciaryParticipantResponse) + public static JudiciaryParticipantResponse Map(this BookingsApi.Contract.V2.Responses.JudiciaryParticipantResponse judiciaryParticipantResponse) { return new JudiciaryParticipantResponse() { diff --git a/AdminWebsite/AdminWebsite/Mappers/JudiciaryPersonResponseMapper.cs b/AdminWebsite/AdminWebsite/Mappers/JudiciaryPersonResponseMapper.cs index df6d45dd5..2ea784ac9 100644 --- a/AdminWebsite/AdminWebsite/Mappers/JudiciaryPersonResponseMapper.cs +++ b/AdminWebsite/AdminWebsite/Mappers/JudiciaryPersonResponseMapper.cs @@ -1,5 +1,6 @@ using AdminWebsite.Contracts.Responses; using BookingsApi.Contract.V1.Responses; +using BookingsApi.Contract.V2.Responses; namespace AdminWebsite.Mappers { @@ -20,9 +21,9 @@ public static JudiciaryPerson MapToAdminWebResponse(this JudiciaryPersonResponse }; } - public static PersonResponse MapToPersonResponse(this JudiciaryPersonResponse judiciaryPersonResponse) + public static PersonResponseV2 MapToPersonResponse(this JudiciaryPersonResponse judiciaryPersonResponse) { - return new PersonResponse() + return new PersonResponseV2() { Title = judiciaryPersonResponse.Title, FirstName = judiciaryPersonResponse.FirstName, diff --git a/AdminWebsite/AdminWebsite/Mappers/LinkedParticipantResponseMapper.cs b/AdminWebsite/AdminWebsite/Mappers/LinkedParticipantResponseMapper.cs index 654a49545..8f1678008 100644 --- a/AdminWebsite/AdminWebsite/Mappers/LinkedParticipantResponseMapper.cs +++ b/AdminWebsite/AdminWebsite/Mappers/LinkedParticipantResponseMapper.cs @@ -5,15 +5,6 @@ namespace AdminWebsite.Mappers; public static class LinkedParticipantResponseMapper { - public static LinkedParticipantResponse Map(this BookingsApi.Contract.V1.Responses.LinkedParticipantResponse linkedParticipant) - { - return new LinkedParticipantResponse - { - LinkedId = linkedParticipant.LinkedId, - Type = (LinkedParticipantType)linkedParticipant.Type - }; - } - public static LinkedParticipantResponse Map(this BookingsApi.Contract.V2.Responses.LinkedParticipantResponseV2 linkedParticipant) { return new LinkedParticipantResponse diff --git a/AdminWebsite/AdminWebsite/Mappers/NewParticipantRequestMapper.cs b/AdminWebsite/AdminWebsite/Mappers/NewParticipantRequestMapper.cs index 0572f573c..2d44a7f5a 100644 --- a/AdminWebsite/AdminWebsite/Mappers/NewParticipantRequestMapper.cs +++ b/AdminWebsite/AdminWebsite/Mappers/NewParticipantRequestMapper.cs @@ -1,30 +1,10 @@ using AdminWebsite.Models; -using BookingsApi.Contract.V1.Requests; using BookingsApi.Contract.V2.Requests; namespace AdminWebsite.Mappers { public static class NewParticipantRequestMapper { - public static ParticipantRequest MapTo(EditParticipantRequest participant) - { - var newParticipant = new ParticipantRequest() - { - CaseRoleName = participant.CaseRoleName, - ContactEmail = participant.ContactEmail, - DisplayName = participant.DisplayName, - FirstName = participant.FirstName, - LastName = participant.LastName, - HearingRoleName = participant.HearingRoleName, - MiddleNames = participant.MiddleNames, - Representee = participant.Representee, - TelephoneNumber = participant.TelephoneNumber, - Title = participant.Title, - OrganisationName = participant.OrganisationName, - }; - return newParticipant; - } - public static ParticipantRequestV2 MapToV2(EditParticipantRequest participant) { var newParticipant = new ParticipantRequestV2 diff --git a/AdminWebsite/AdminWebsite/Mappers/ParticipantResponseMapper.cs b/AdminWebsite/AdminWebsite/Mappers/ParticipantResponseMapper.cs index 2d9d8af7a..cbc88d15f 100644 --- a/AdminWebsite/AdminWebsite/Mappers/ParticipantResponseMapper.cs +++ b/AdminWebsite/AdminWebsite/Mappers/ParticipantResponseMapper.cs @@ -1,36 +1,12 @@ using System.Collections.Generic; using System.Linq; using AdminWebsite.Contracts.Responses; -using V1 = BookingsApi.Contract.V1.Responses; using V2 = BookingsApi.Contract.V2.Responses; namespace AdminWebsite.Mappers; public static class ParticipantResponseMapper { - public static List<ParticipantResponse> Map(this List<V1.ParticipantResponse> participants) - { - return participants.Select(p => - new ParticipantResponse - { - Id = p.Id, - DisplayName = p.DisplayName, - CaseRoleName = p.CaseRoleName, - HearingRoleName = p.HearingRoleName, - UserRoleName = p.UserRoleName, - Title = p.Title, - FirstName = p.FirstName, - MiddleNames = p.MiddleNames, - LastName = p.LastName, - ContactEmail = p.ContactEmail, - TelephoneNumber = p.TelephoneNumber, - Username = p.Username, - Organisation = p.Organisation, - Representee = p.Representee, - LinkedParticipants = p.LinkedParticipants?.Select(lp => lp.Map()).ToList() - }).ToList(); - } - public static List<ParticipantResponse> Map(this List<V2.ParticipantResponseV2> participants, BookingsApi.Contract.V2.Responses.HearingDetailsResponseV2 hearingDetails) { return participants.Select(p => diff --git a/AdminWebsite/AdminWebsite/Mappers/TelephoneParticipantResponseMapper.cs b/AdminWebsite/AdminWebsite/Mappers/TelephoneParticipantResponseMapper.cs deleted file mode 100644 index e5484c96f..000000000 --- a/AdminWebsite/AdminWebsite/Mappers/TelephoneParticipantResponseMapper.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System.Linq; -using AdminWebsite.Contracts.Responses; -using V1 = BookingsApi.Contract.V1.Responses; - -namespace AdminWebsite.Mappers; - -public static class TelephoneParticipantResponseMapper -{ - public static TelephoneParticipantResponse Map(this V1.TelephoneParticipantResponse telephoneParticipant) - { - return new TelephoneParticipantResponse - { - Id = telephoneParticipant.Id, - CaseRoleName = telephoneParticipant.CaseRoleName, - HearingRoleName = telephoneParticipant.HearingRoleName, - FirstName = telephoneParticipant.FirstName, - LastName = telephoneParticipant.LastName, - ContactEmail = telephoneParticipant.ContactEmail, - TelephoneNumber = telephoneParticipant.TelephoneNumber, - MobileNumber = telephoneParticipant.MobileNumber, - Representee = telephoneParticipant.Representee, - LinkedParticipants = telephoneParticipant.LinkedParticipants?.Select(lp => lp.Map()).ToList() - }; - } -} \ No newline at end of file diff --git a/AdminWebsite/AdminWebsite/Mappers/UnallocatedHearingsForVHOMapper.cs b/AdminWebsite/AdminWebsite/Mappers/UnallocatedHearingsForVHOMapper.cs index 455cde3c9..11ef4d0c5 100644 --- a/AdminWebsite/AdminWebsite/Mappers/UnallocatedHearingsForVHOMapper.cs +++ b/AdminWebsite/AdminWebsite/Mappers/UnallocatedHearingsForVHOMapper.cs @@ -2,14 +2,13 @@ using System.Collections.Generic; using System.Linq; using AdminWebsite.Contracts.Responses; -using BookingsApi.Contract.V1.Responses; -using HearingDetailsResponse = BookingsApi.Contract.V1.Responses.HearingDetailsResponse; +using BookingsApi.Contract.V2.Responses; namespace AdminWebsite.Mappers; public static class UnallocatedHearingsForVhoMapper { - public static UnallocatedHearingsForVhoResponse MapFrom(List<HearingDetailsResponse> unallocatedHearings, DateTime today) + public static UnallocatedHearingsForVhoResponse MapFrom(List<HearingDetailsResponseV2> unallocatedHearings, DateTime today) { return new UnallocatedHearingsForVhoResponse { @@ -20,7 +19,7 @@ public static UnallocatedHearingsForVhoResponse MapFrom(List<HearingDetailsRespo }; } - private static DateForUnallocatedHearings MapToday(List<HearingDetailsResponse> unallocatedHearings, DateTime today) + private static DateForUnallocatedHearings MapToday(List<HearingDetailsResponseV2> unallocatedHearings, DateTime today) { return new DateForUnallocatedHearings { @@ -29,7 +28,7 @@ private static DateForUnallocatedHearings MapToday(List<HearingDetailsResponse> }; } - private static DateForUnallocatedHearings MapTomorrow(List<HearingDetailsResponse> unallocatedHearings, DateTime today) + private static DateForUnallocatedHearings MapTomorrow(List<HearingDetailsResponseV2> unallocatedHearings, DateTime today) { var tomorrow = today.AddDays(1); return new DateForUnallocatedHearings @@ -39,7 +38,7 @@ private static DateForUnallocatedHearings MapTomorrow(List<HearingDetailsRespons }; } - private static DateForUnallocatedHearings FindNext7Days(List<HearingDetailsResponse> unallocatedHearings, DateTime today) + private static DateForUnallocatedHearings FindNext7Days(List<HearingDetailsResponseV2> unallocatedHearings, DateTime today) { var dateStart = today.Date; var dateEnd = dateStart.AddDays(7); @@ -52,7 +51,7 @@ private static DateForUnallocatedHearings FindNext7Days(List<HearingDetailsRespo }; } - private static DateForUnallocatedHearings FindNext30Days(List<HearingDetailsResponse> unallocatedHearings, DateTime today) + private static DateForUnallocatedHearings FindNext30Days(List<HearingDetailsResponseV2> unallocatedHearings, DateTime today) { var dateStart = today.Date; var dateEnd = dateStart.AddDays(30); diff --git a/AdminWebsite/AdminWebsite/Mappers/UpdateParticipantRequestMapper.cs b/AdminWebsite/AdminWebsite/Mappers/UpdateParticipantRequestMapper.cs index 4fe1434cd..82ae9922f 100644 --- a/AdminWebsite/AdminWebsite/Mappers/UpdateParticipantRequestMapper.cs +++ b/AdminWebsite/AdminWebsite/Mappers/UpdateParticipantRequestMapper.cs @@ -1,6 +1,5 @@ using AdminWebsite.Models; using System; -using BookingsApi.Contract.V1.Requests; using BookingsApi.Contract.V2.Requests; using BookingsApi.Contract.V2.Responses; @@ -8,21 +7,6 @@ namespace AdminWebsite.Mappers { public static class UpdateParticipantRequestMapper { - public static UpdateParticipantRequest MapTo(EditParticipantRequest participant) - { - var updateParticipantRequest = new UpdateParticipantRequest - { - Title = participant.Title, - DisplayName = participant.DisplayName, - OrganisationName = participant.OrganisationName, - TelephoneNumber = participant.TelephoneNumber, - Representee = participant.Representee, - ParticipantId = participant.Id ?? Guid.Empty, - ContactEmail = participant.ContactEmail - }; - return updateParticipantRequest; - } - public static UpdateParticipantRequestV2 MapToV2(EditParticipantRequest participant) { var updateParticipantRequest = new UpdateParticipantRequestV2 diff --git a/AdminWebsite/AdminWebsite/Mappers/UserResponseMapper.cs b/AdminWebsite/AdminWebsite/Mappers/UserResponseMapper.cs index a77f697a0..c1ad1520b 100644 --- a/AdminWebsite/AdminWebsite/Mappers/UserResponseMapper.cs +++ b/AdminWebsite/AdminWebsite/Mappers/UserResponseMapper.cs @@ -1,14 +1,13 @@ - -using BookingsApi.Contract.V1.Responses; +using BookingsApi.Contract.V2.Responses; using UserApi.Contract.Responses; namespace AdminWebsite.Mappers { public static class UserResponseMapper { - public static PersonResponse MapFrom(UserResponse userResponse) + public static PersonResponseV2 MapFrom(UserResponse userResponse) { - return new PersonResponse + return new PersonResponseV2 { FirstName = userResponse.FirstName, LastName = userResponse.LastName, diff --git a/AdminWebsite/AdminWebsite/Models/CaseAndHearingRolesResponse.cs b/AdminWebsite/AdminWebsite/Models/CaseAndHearingRolesResponse.cs deleted file mode 100644 index 2212fbcba..000000000 --- a/AdminWebsite/AdminWebsite/Models/CaseAndHearingRolesResponse.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Collections.Generic; - -namespace AdminWebsite.Models -{ - public class CaseAndHearingRolesResponse - { - public string Name { get; set; } - public IEnumerable<HearingRole> HearingRoles { get; set; } - } -} diff --git a/AdminWebsite/AdminWebsite/Models/EditParticipantRequest.cs b/AdminWebsite/AdminWebsite/Models/EditParticipantRequest.cs index 543fb537d..07d0d4472 100644 --- a/AdminWebsite/AdminWebsite/Models/EditParticipantRequest.cs +++ b/AdminWebsite/AdminWebsite/Models/EditParticipantRequest.cs @@ -62,11 +62,6 @@ public EditParticipantRequest() [RegularExpression(@"^[\p{L}\p{N}\s',._-]+$")] public string DisplayName { get; set; } - /// <summary> - /// The name of the participant's case role - /// </summary> - public string CaseRoleName { get; set; } - /// <summary> /// The name of the participant's hearing role /// </summary> diff --git a/AdminWebsite/AdminWebsite/Services/HearingsService.cs b/AdminWebsite/AdminWebsite/Services/HearingsService.cs index fa053e5b9..df523d5a1 100644 --- a/AdminWebsite/AdminWebsite/Services/HearingsService.cs +++ b/AdminWebsite/AdminWebsite/Services/HearingsService.cs @@ -18,7 +18,6 @@ namespace AdminWebsite.Services public interface IHearingsService { void AssignEndpointDefenceAdvocates(List<Contracts.Requests.EndpointRequest> endpointsWithDa, IReadOnlyCollection<Contracts.Requests.ParticipantRequest> participants); - Task ProcessParticipants(Guid hearingId, List<UpdateParticipantRequest> existingParticipants, List<ParticipantRequest> newParticipants, List<Guid> removedParticipantIds, List<LinkedParticipantRequest> linkedParticipants); Task ProcessParticipantsV2(Guid hearingId, List<UpdateParticipantRequestV2> existingParticipants, List<ParticipantRequestV2> newParticipants, List<Guid> removedParticipantIds, List<LinkedParticipantRequestV2> linkedParticipants); Task<IParticipantRequest> ProcessNewParticipant(Guid hearingId, EditParticipantRequest participant, IParticipantRequest newParticipant, List<Guid> removedParticipantIds, HearingDetailsResponse hearing); Task ProcessEndpoints(Guid hearingId, List<EditEndpointRequest> endpoints, HearingDetailsResponse hearing, List<IParticipantRequest> newParticipantList); @@ -60,23 +59,6 @@ public static List<EditParticipantRequest> GetAddedParticipant(List<EditParticip .ToList() : new List<EditParticipantRequest>(); } - - public async Task ProcessParticipants(Guid hearingId, - List<UpdateParticipantRequest> existingParticipants, - List<ParticipantRequest> newParticipants, - List<Guid> removedParticipantIds, - List<LinkedParticipantRequest> linkedParticipants) - { - - var updateHearingParticipantsRequest = new UpdateHearingParticipantsRequest - { - ExistingParticipants = existingParticipants, - NewParticipants = newParticipants, - RemovedParticipantIds = removedParticipantIds, - LinkedParticipants = linkedParticipants - }; - await _bookingsApiClient.UpdateHearingParticipantsAsync(hearingId, updateHearingParticipantsRequest); - } public async Task ProcessParticipantsV2(Guid hearingId, List<UpdateParticipantRequestV2> existingParticipants, @@ -102,23 +84,6 @@ public Task<IParticipantRequest> ProcessNewParticipant( List<Guid> removedParticipantIds, HearingDetailsResponse hearing) { - // Add a new participant - // Map the request except the username - if (participant.CaseRoleName == RoleNames.Judge || (participant.HearingRoleName is RoleNames.PanelMember or RoleNames.Winger)) - { - if (hearing.Participants != null && - hearing.Participants.Exists(p => p.ContactEmail.Equals(participant.ContactEmail) && removedParticipantIds.TrueForAll(removedParticipantId => removedParticipantId != p.Id))) - { - //If the judge already exists in the database, there is no need to add again. - return Task.FromResult<IParticipantRequest>(null); - } - - if (newParticipant is ParticipantRequest v1Request) - { - v1Request.Username = participant.ContactEmail; - } - } - _logger.LogDebug("Adding participant {Participant} to hearing {Hearing}", newParticipant.DisplayName, hearingId); return Task.FromResult(newParticipant); diff --git a/AdminWebsite/AdminWebsite/Services/ReferenceDataService.cs b/AdminWebsite/AdminWebsite/Services/ReferenceDataService.cs index 066fc5ec7..48fa55556 100644 --- a/AdminWebsite/AdminWebsite/Services/ReferenceDataService.cs +++ b/AdminWebsite/AdminWebsite/Services/ReferenceDataService.cs @@ -7,19 +7,20 @@ using BookingsApi.Contract.V1.Responses; using BookingsApi.Contract.V2.Responses; using Microsoft.Extensions.Caching.Memory; +using Microsoft.Extensions.Logging; namespace AdminWebsite.Services; public interface IReferenceDataService { Task InitialiseCache(); - Task<List<CaseTypeResponse>> GetNonDeletedCaseTypesAsync(CancellationToken cancellationToken = default); + Task<List<CaseTypeResponseV2>> GetNonDeletedCaseTypesAsync(CancellationToken cancellationToken = default); Task<List<InterpreterLanguagesResponse>> GetInterpreterLanguagesAsync(CancellationToken cancellationToken = default); Task<List<HearingVenueResponse>> GetHearingVenuesAsync(CancellationToken cancellationToken = default); Task<List<HearingRoleResponseV2>> GetHearingRolesAsync(CancellationToken cancellationToken = default); } -public class ReferenceDataService(IBookingsApiClient bookingsApiClient, IMemoryCache memoryCache) : IReferenceDataService +public class ReferenceDataService(IBookingsApiClient bookingsApiClient, IMemoryCache memoryCache, ILogger<ReferenceDataService> logger) : IReferenceDataService { private const string InterpreterLanguagesKey = "RefData_InterpreterLanguages"; private const string HearingVenuesKey = "RefData_HearingVenues"; @@ -31,13 +32,15 @@ public async Task InitialiseCache() await GetHearingVenuesAsync(); await GetNonDeletedCaseTypesAsync(); await GetHearingRolesAsync(); + logger.LogInformation("Static ref data (languages, venues, case types and hearing roles) cached"); } - public async Task<List<CaseTypeResponse>> GetNonDeletedCaseTypesAsync(CancellationToken cancellationToken = default) + public async Task<List<CaseTypeResponseV2>> GetNonDeletedCaseTypesAsync( + CancellationToken cancellationToken = default) { return await GetOrCreateCacheAsync(CaseTypesKey, async token => { - var caseTypes = await bookingsApiClient.GetCaseTypesAsync(includeDeleted: false, token); + var caseTypes = await bookingsApiClient.GetCaseTypesV2Async(includeDeleted: false, token); return caseTypes.ToList(); }, cancellationToken); } diff --git a/AdminWebsite/AdminWebsite/Startup.cs b/AdminWebsite/AdminWebsite/Startup.cs index 1419167ca..77a582214 100644 --- a/AdminWebsite/AdminWebsite/Startup.cs +++ b/AdminWebsite/AdminWebsite/Startup.cs @@ -129,7 +129,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) // reference from https://github.com/dotnet/dotnet-docker/issues/2268#issuecomment-714613811 app.Use(async (context, next) => { - context.Response.Headers.Add("Strict-Transport-Security", "max-age=31536000"); + context.Response.Headers["Strict-Transport-Security"] = "max-age=31536000"; await next.Invoke(); }); app.UseXfo(options => options.SameOrigin()); diff --git a/AdminWebsite/AdminWebsite/Validators/CaseRequestValidation.cs b/AdminWebsite/AdminWebsite/Validators/CaseRequestValidation.cs deleted file mode 100644 index c9d964388..000000000 --- a/AdminWebsite/AdminWebsite/Validators/CaseRequestValidation.cs +++ /dev/null @@ -1,24 +0,0 @@ -using BookingsApi.Contract.V1.Requests; -using FluentValidation; - -namespace AdminWebsite.Validators -{ - public class CaseRequestValidation : AbstractValidator<CaseRequest> - { - private const string CaseNumber_MESSAGE = "Case number is required between 1 - 255 characters"; - private const string CaseName_MESSAGE = "Case name is required between 1 - 255 characters"; - - public CaseRequestValidation() - { - RuleFor(x => x.Number) - .NotEmpty() - .MaximumLength(255) - .WithMessage(CaseNumber_MESSAGE); - - RuleFor(x => x.Name) - .NotEmpty() - .MaximumLength(255) - .WithMessage(CaseName_MESSAGE); - } - } -} \ No newline at end of file diff --git a/AdminWebsite/AdminWebsite/Validators/EditHearingRequestValidator.cs b/AdminWebsite/AdminWebsite/Validators/EditHearingRequestValidator.cs deleted file mode 100644 index 27faf90fd..000000000 --- a/AdminWebsite/AdminWebsite/Validators/EditHearingRequestValidator.cs +++ /dev/null @@ -1,28 +0,0 @@ -using AdminWebsite.Models; -using FluentValidation; - -namespace AdminWebsite.Validators -{ - public class EditHearingRequestValidator : AbstractValidator<EditHearingRequest> - { - private const string ROOM_MSG = "Room name should be between 1 - 255 characters"; - private const string PARTICIPANT_MSG = "Please provide at least one participant"; - - public EditHearingRequestValidator() - { - RuleFor(x => x.HearingRoomName) - .MaximumLength(255) - .WithMessage(ROOM_MSG); - - RuleFor(x => x.Case).NotNull().SetValidator(new EditRequestValidation()); - - RuleFor(x => x.Participants) - .Must(x => x != null && x.Count > 0) - .When(x => x.JudiciaryParticipants == null || x.JudiciaryParticipants.Count == 0) - .WithMessage(PARTICIPANT_MSG); - - RuleForEach(x => x.Participants).NotNull().SetValidator(new EditParticipantRequestValidation()); - - } - } -} \ No newline at end of file diff --git a/AdminWebsite/AdminWebsite/Validators/EditParticipantRequestValidation.cs b/AdminWebsite/AdminWebsite/Validators/EditParticipantRequestValidation.cs deleted file mode 100644 index 993fe73f1..000000000 --- a/AdminWebsite/AdminWebsite/Validators/EditParticipantRequestValidation.cs +++ /dev/null @@ -1,37 +0,0 @@ -using AdminWebsite.Models; -using FluentValidation; - -namespace AdminWebsite.Validators -{ - public class EditParticipantRequestValidation : AbstractValidator<EditParticipantRequest> - { - private const string EMAIL_MSG = "Email is required in the correct format and between 1 - 255 characters"; - private const string DisplayName_MSG = "Display name is required and between 1 - 255 characters"; - private const string FirstName_MSG = "First name is required and between 1 - 255 characters"; - private const string LASTNAME_MSG = "Lastname is required and between 1 - 255 characters"; - - public EditParticipantRequestValidation() - { - RuleFor(x => x.ContactEmail) - .NotEmpty() - .EmailAddress() - .MaximumLength(255) - .WithMessage(EMAIL_MSG); - - RuleFor(x => x.DisplayName) - .NotEmpty() - .MaximumLength(255) - .WithMessage(DisplayName_MSG); - - RuleFor(x => x.FirstName) - .NotEmpty() - .MaximumLength(255) - .WithMessage(FirstName_MSG); - - RuleFor(x => x.LastName) - .NotEmpty() - .MaximumLength(255) - .WithMessage(LASTNAME_MSG); - } - } -} \ No newline at end of file diff --git a/AdminWebsite/AdminWebsite/Validators/EditRequestValidation.cs b/AdminWebsite/AdminWebsite/Validators/EditRequestValidation.cs deleted file mode 100644 index 2b51fc997..000000000 --- a/AdminWebsite/AdminWebsite/Validators/EditRequestValidation.cs +++ /dev/null @@ -1,24 +0,0 @@ -using AdminWebsite.Models; -using FluentValidation; - -namespace AdminWebsite.Validators -{ - public class EditRequestValidation : AbstractValidator<EditCaseRequest> - { - private const string CaseNumber_MSG = "Case number is required between 1 - 255 characters"; - private const string CaseName_MSG = "Case name is required between 1 - 255 characters"; - - public EditRequestValidation() - { - RuleFor(x => x.Number) - .NotEmpty() - .MaximumLength(255) - .WithMessage(CaseNumber_MSG); - - RuleFor(x => x.Name) - .NotEmpty() - .MaximumLength(255) - .WithMessage(CaseName_MSG); - } - } -} \ No newline at end of file diff --git a/AdminWebsite/AdminWebsite/Validators/ParticipantRequestValidation.cs b/AdminWebsite/AdminWebsite/Validators/ParticipantRequestValidation.cs deleted file mode 100644 index 26953b25f..000000000 --- a/AdminWebsite/AdminWebsite/Validators/ParticipantRequestValidation.cs +++ /dev/null @@ -1,37 +0,0 @@ -using BookingsApi.Contract.V1.Requests; -using FluentValidation; - -namespace AdminWebsite.Validators -{ - public class ParticipantRequestValidation : AbstractValidator<ParticipantRequest> - { - private const string EMAIL_MSG = "Email is required in the correct format and between 1 - 255 characters"; - private const string DisplayName_MSG = "Display name is required and between 1 - 255 characters"; - private const string FirstName_MSG = "First name is required and between 1 - 255 characters"; - private const string LASTNAME_MSG = "Lastname is required and between 1 - 255 characters"; - - public ParticipantRequestValidation() - { - RuleFor(x => x.ContactEmail) - .NotEmpty() - .EmailAddress() - .MaximumLength(255) - .WithMessage(EMAIL_MSG); - - RuleFor(x => x.DisplayName) - .NotEmpty() - .MaximumLength(255) - .WithMessage(DisplayName_MSG); - - RuleFor(x => x.FirstName) - .NotEmpty() - .MaximumLength(255) - .WithMessage(FirstName_MSG); - - RuleFor(x => x.LastName) - .NotEmpty() - .MaximumLength(255) - .WithMessage(LASTNAME_MSG); - } - } -} \ No newline at end of file diff --git a/AdminWebsite/AdminWebsite/packages.lock.json b/AdminWebsite/AdminWebsite/packages.lock.json index 949df7e42..62ac8a2db 100644 --- a/AdminWebsite/AdminWebsite/packages.lock.json +++ b/AdminWebsite/AdminWebsite/packages.lock.json @@ -14,11 +14,13 @@ }, "BookingsApi.Client": { "type": "Direct", - "requested": "[2.3.9, )", - "resolved": "2.3.9", - "contentHash": "Bzwufird9sw4QpyCuJBQpcNDuAZXmZWCjLMdoYyFUDdRlJm1xE9uMXaaOyYK2FFPE5WfLAftC/o0nYhhSgFeiQ==", + "requested": "[3.1.9, )", + "resolved": "3.1.9", + "contentHash": "szk1pTukvzHsprWASvwtdTvoHCbm5RC5Lnj1wYmSC+/I/s1uyoL7uLbauV2s84znk2xssLpol4N7Fyxl5wJGAw==", "dependencies": { - "Microsoft.AspNetCore.Mvc.Core": "2.2.5" + "BookingsApi.Common.DotNet6": "3.1.9", + "Microsoft.AspNetCore.Mvc.Core": "2.2.5", + "System.Text.Json": "8.0.5" } }, "FluentValidation.AspNetCore": { @@ -133,9 +135,9 @@ }, "Microsoft.Identity.Client": { "type": "Direct", - "requested": "[4.61.0, )", - "resolved": "4.61.0", - "contentHash": "3TDPEie+9t/NgBhoNifLFwM6nkypYUa8GUHfMnkYtovDDTQM8bsS2KEIP5tAh28BgfJZgof/KlCEKvGxz0H3Eg==", + "requested": "[4.61.3, )", + "resolved": "4.61.3", + "contentHash": "naJo/Qm35Caaoxp5utcw+R8eU8ZtLz2ALh8S+gkekOYQ1oazfCQMWVT4NJ/FnHzdIJlm8dMz0oMpMGCabx5odA==", "dependencies": { "Microsoft.IdentityModel.Abstractions": "6.35.0", "System.Diagnostics.DiagnosticSource": "6.0.1" @@ -155,9 +157,9 @@ }, "NotificationApi.Client": { "type": "Direct", - "requested": "[2.3.4, )", - "resolved": "2.3.4", - "contentHash": "BwxsCI+DORSasyvqktvdWt2jUJIrxwTgLDVx/3sOBDJkqMKJsn+glINBsQ7/kgyldaZningYYuasa3+JIFSVKA==", + "requested": "[3.0.5, )", + "resolved": "3.0.5", + "contentHash": "UErWgWJUm2TEb9yqEHxIzaGr7AFcqnjqRLu8legaYNOMFd1WVzuKYEBzEdMM1x8gHjTLofcIAIaRUqUx0LIFLg==", "dependencies": { "Microsoft.AspNetCore.Mvc.Core": "2.2.5", "Newtonsoft.Json": "13.0.3" @@ -244,12 +246,12 @@ }, "VideoApi.Client": { "type": "Direct", - "requested": "[2.2.26, )", - "resolved": "2.2.26", - "contentHash": "tkKsLUUKliw5iPA8It+R/Fv+oKsCwdeQfWFWHVhU+/mfNG2bT89L9SHDvjqLIXawTV35pigCRuidPaYt641sow==", + "requested": "[3.1.7, )", + "resolved": "3.1.7", + "contentHash": "l7/NvSybO0/k+rAg1jY78hjZrQ1v2P/qdmh75gJeK+tax3Ukwc0G6+QvKbvlbetzU1TjKf2GFrublKZ5h1OdMg==", "dependencies": { "Microsoft.AspNetCore.Mvc.Core": "2.2.5", - "Newtonsoft.Json": "13.0.3" + "System.Text.Json": "8.0.4" } }, "Azure.Core": { @@ -267,6 +269,14 @@ "System.Threading.Tasks.Extensions": "4.5.4" } }, + "BookingsApi.Common.DotNet6": { + "type": "Transitive", + "resolved": "3.1.9", + "contentHash": "3rSoSlmcZw4+uxPIj+KpBAI6WjIk2ntsEGc75oGDD7fQM+qpEDCuIn4xSid1fcO6sdQ2Dkd/8/3c0k2dyL+yeg==", + "dependencies": { + "System.Text.Json": "8.0.5" + } + }, "FluentValidation": { "type": "Transitive", "resolved": "11.5.1", @@ -1478,8 +1488,8 @@ }, "System.Text.Json": { "type": "Transitive", - "resolved": "4.7.2", - "contentHash": "TcMd95wcrubm9nHvJEQs70rC0H/8omiSGGpU4FQ/ZA1URIqD4pjmFJh2Mfv1yH1eHgJDWTi2hMDXwTET+zOOyg==" + "resolved": "8.0.5", + "contentHash": "0f1B50Ss7rqxXiaBJyzUu9bWFOO2/zSlifZ/UNMdiIpDYe4cY4LQQicP4nirK1OS31I43rn062UIJ1Q9bpmHpg==" }, "System.Threading": { "type": "Transitive", diff --git a/AdminWebsite/nuget.config b/AdminWebsite/nuget.config index c08c54db9..b9a3fec90 100644 --- a/AdminWebsite/nuget.config +++ b/AdminWebsite/nuget.config @@ -20,6 +20,7 @@ <packageSource key="vh-packages"> <package pattern="VH.*" /> <package pattern="BookingsApi.Client" /> + <package pattern="BookingsApi.Common.DotNet6" /> <package pattern="NotificationApi.Client" /> <package pattern="TestApi.Client" /> <package pattern="UserApi.Client" />