From 44c72e7eb5ab1d3c0ac0557494de0663d2bcf5db Mon Sep 17 00:00:00 2001 From: Shaed Parkar Date: Fri, 22 Nov 2024 18:35:26 +0000 Subject: [PATCH] WIP refactor --- .../packages.lock.json | 25 +- .../HearingInputSanitizerAttributeTest.cs | 22 +- .../Controllers/BookingListControllerTest.cs | 65 ++--- .../HearingsController/BookNewHearingTests.cs | 1 + .../HearingsController/CancelHearingTests.cs | 11 +- .../CancelMultiDayHearingTests.cs | 19 +- .../HearingsController/EditHearingTests.cs | 46 ++-- .../EditMultiDayHearingTests.cs | 28 +-- .../HearingsController/FailHearingTests.cs | 9 +- .../HearingsController/GetHearingTests.cs | 40 +--- .../GetStatusHearingTests.cs | 36 +-- .../HearingsControllerTests.cs | 96 +------- .../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 | 7 +- .../HearingDetailsResponseExtensionsTests.cs | 225 +----------------- .../Helper/HearingResponseBuilder.cs | 43 ---- .../Helper/HearingResponseV2Builder.cs | 11 +- .../BookingsHearingResponseMapperTests.cs | 1 - ...HearingParticipantsRequestV2MapperTests.cs | 1 - .../EditParticipantRequestMapperTest.cs | 21 -- .../Mappers/EndpointResponseMapperTests.cs | 5 +- .../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 +-- .../Validators/CaseRequestValidationTest.cs | 53 ----- .../EditHearingRequestValidatorTest.cs | 73 ------ .../ParticipantRequestValidationTest.cs | 73 ------ .../AdminWebsite.UnitTests/packages.lock.json | 22 +- AdminWebsite/AdminWebsite/AdminWebsite.csproj | 2 +- .../HearingInputSanitizerAttribute.cs | 5 +- .../Responses/BookingsHearingResponse.cs | 1 - .../Responses/HearingTypeResponse.cs | 33 --- .../Responses/ParticipantResponse.cs | 1 - .../Controllers/BookingListController.cs | 2 +- .../Controllers/HearingsController.cs | 21 +- .../Controllers/PersonsController.cs | 25 +- .../HearingRolesController.cs | 2 +- .../ReferenceData/HearingTypesController.cs | 56 ----- .../ParticipantRolesController.cs | 60 ----- .../Controllers/WorkAllocationController.cs | 5 +- .../Extensions/ConfigureServicesExtensions.cs | 7 +- .../HearingDetailsResponseExtensions.cs | 207 +--------------- .../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 | 3 +- .../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 | 36 +-- .../Services/ReferenceDataService.cs | 7 +- 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 | 22 +- 85 files changed, 379 insertions(+), 1921 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/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/Contracts/Responses/HearingTypeResponse.cs rename AdminWebsite/AdminWebsite/Controllers/{ => ReferenceData}/HearingRolesController.cs (96%) delete mode 100644 AdminWebsite/AdminWebsite/Controllers/ReferenceData/HearingTypesController.cs 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..cac81aa60 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.2-pr-0919-0010", + "contentHash": "uTjHes/RCMLANtbDLm2sfQTdqSA/90fwUGb2KthKSsZWpjoYdZtJYDjLtTNFqeH7qAKQTV0herli/gAyAAP0hg==", "dependencies": { - "Microsoft.AspNetCore.Mvc.Core": "2.2.5" + "BookingsApi.Common.DotNet6": "3.1.2-pr-0919-0010", + "Microsoft.AspNetCore.Mvc.Core": "2.2.5", + "System.Text.Json": "8.0.5" + } + }, + "BookingsApi.Common.DotNet6": { + "type": "Transitive", + "resolved": "3.1.2-pr-0919-0010", + "contentHash": "JBKWH0dvKUOBh9AnUV0C6ExjeV0Wem3bfmk7Gkxrqnc+Iz5cUvz6zyMMnGVX1mFlsEgrxVeJXj/DoTV0YCyN0Q==", + "dependencies": { + "System.Text.Json": "8.0.5" } }, "Castle.Core": { @@ -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", @@ -2154,7 +2161,7 @@ "type": "Project", "dependencies": { "AspNetCore.HealthChecks.Uris": "[8.0.1, )", - "BookingsApi.Client": "[2.3.9, )", + "BookingsApi.Client": "[3.1.2-pr-0919-0010, )", "FluentValidation.AspNetCore": "[11.3.0, )", "LaunchDarkly.ServerSdk": "[8.5.0, )", "MicroElements.Swashbuckle.FluentValidation": "[6.0.0, )", 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() + .WhoseValue.As() .Should().NotBeNull() - .And.Subject.As(); + .And.Subject.As(); 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() + .WhoseValue.As() .Should().NotBeNull() - .And.Subject.As(); + .And.Subject.As(); request.HearingRoomName.Should().BeEquivalentTo(inputText); @@ -102,18 +101,17 @@ private static ActionExecutingContext CreateBookNewHearingRequestContext(string { var actionArguments = new Dictionary { - { requestKey, new BookNewHearingRequest + { requestKey, new BookNewHearingRequestV2 { HearingRoomName = text, - HearingVenueName = text, OtherInformation = text, - Cases = new List + Cases = new List { - new CaseRequest{Name = text, Number = text} + new(){Name = text, Number = text} }, - Participants = new List + Participants = new List { - 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 { "type1", "type2" }); - _bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(new List()); + _bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(new List()); 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 response = null; - _bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(response); + List 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(); - _bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(response); + var response = new List(); + _bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(response); var request = new BookingSearchRequest { @@ -156,19 +157,19 @@ public async Task { SetupTestCase(); - var response = new List + var response = new List { - new CaseTypeResponse + new CaseTypeResponseV2() { - HearingTypes = new List(), Id = 1, Name = "type3" + Id = 1, Name = "type3" }, - new CaseTypeResponse + new CaseTypeResponseV2 { - HearingTypes = new List(), 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 { "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()), 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 { "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()), 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)); + _bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(default(List)); 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)); + _bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(default(List)); 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)); + _bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(default(List)); 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)); + _bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(default(List)); 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)); + _bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(default(List)); 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)); + _bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(default(List)); 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)); + _bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(default(List)); 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)); + _bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(default(List)); 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)); + _bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(default(List)); 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 GetCaseTypesList() + private static List GetCaseTypesList() { - return new List + return new List { - new CaseTypeResponse + new() { - HearingTypes = new List(), Id = 1, Name = "type1" + Id = 1, Name = "type1" }, - new CaseTypeResponse + new() { - HearingTypes = new List(), Id = 2, Name = "type2" + Id = 2, Name = "type2" }, - new CaseTypeResponse + new() { - HearingTypes = new List(), 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..6043d542d 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 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().Setup(bs => bs.GetHearingDetailsByIdAsync(It.IsAny())) - .ReturnsAsync(new HearingDetailsResponse + _mocker.Mock().Setup(bs => bs.GetHearingDetailsByIdV2Async(It.IsAny())) + .ReturnsAsync(new HearingDetailsResponseV2() { - Participants = [new ParticipantResponse { HearingRoleName = "Judge" }] + Participants = [new ParticipantResponseV2 { HearingRoleName = HearingRoleName.Representative }] }); _controller = _mocker.Create(); } 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().Subject.Success.Should().BeTrue(); - var expectedUpdatedHearings = new List(); + var expectedUpdatedHearings = new List(); 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..db01b8242 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/EditHearingTests.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/EditHearingTests.cs @@ -6,9 +6,6 @@ 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; @@ -19,9 +16,7 @@ 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 { @@ -37,7 +32,7 @@ public class EditHearingTests private IHearingsService _hearingsService; private Mock> _participantGroupLogger; - private HearingDetailsResponse _updatedExistingParticipantHearingOriginal; + private HearingDetailsResponseV2 _updatedExistingParticipantHearingOriginal; private Mock _userIdentity; private HearingDetailsResponseV2 _v2HearingDetailsResponse; @@ -98,17 +93,17 @@ public void Setup() }, }; - var cases = new List + var cases = new List { - 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 +111,7 @@ public void Setup() Username = "old@domain.net" }], Cases = cases, - CaseTypeName = "Unit Test", + ServiceId = "ABC123", ScheduledDateTime = DateTime.UtcNow.AddHours(3), OtherInformation = "" }; @@ -139,10 +134,9 @@ public void Setup() }, Participants = new List() { - new EditParticipantRequest() { + new() { Id = participantId1, - CaseRoleName = "judge", - HearingRoleName = HearingRoleName.Judge, + HearingRoleName = HearingRoleName.Expert, FirstName = "FirstName", LastName = "LastName", ContactEmail = "judge@email.com", @@ -164,7 +158,7 @@ public void Setup() } }; - _bookingsApiClient.Setup(x => x.GetHearingDetailsByIdAsync(It.IsAny())) + _bookingsApiClient.Setup(x => x.GetHearingDetailsByIdV2Async(It.IsAny())) .ReturnsAsync(_updatedExistingParticipantHearingOriginal); _editHearingRequestValidator.Setup(x => x.ValidateAsync(It.IsAny(), It.IsAny())) @@ -215,7 +209,7 @@ public void Setup() Sip = "sip" } }, - JudiciaryParticipants = new List() + JudicialOfficeHolders = new List() { 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 +273,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 +315,7 @@ public async Task Should_return_updated_hearing2() _bookingsApiClient.Verify(x => x.AddJudiciaryParticipantsToHearingAsync( hearing.Id, - It.Is>(r => + It.Is>(r => r.Any(y => y.PersonalCode == panelMemberToAdd.PersonalCode))), Times.Once); } @@ -336,7 +330,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 +366,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())) .ReturnsAsync(updatedHearing) .ReturnsAsync(updatedHearing) @@ -418,7 +412,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 +446,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())) .ReturnsAsync(updatedHearing) .ReturnsAsync(updatedHearing) @@ -528,7 +522,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())) .ReturnsAsync(updatedHearing); @@ -570,9 +564,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 +627,7 @@ private void AssertJudiciaryJudgeReassigned( _bookingsApiClient.Verify(x => x.AddJudiciaryParticipantsToHearingAsync( It.IsAny(), - It.IsAny>()), + It.IsAny>()), 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().Setup(bs => bs.GetHearingDetailsByIdAsync(It.IsAny())) - .ReturnsAsync(new HearingDetailsResponse + _mocker.Mock().Setup(bs => bs.GetHearingDetailsByIdV2Async(It.IsAny())) + .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() + Cases = new List() { - 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() + Participants = new List() { 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().Setup(x => x.GetHearingDetailsByIdAsync(It.IsAny())) - .ReturnsAsync(_vhExistingHearingV1); + _mocker.Mock().Setup(x => x.GetHearingDetailsByIdV2Async(It.IsAny())) + .ReturnsAsync(_vhExistingHearingV2); } diff --git a/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/GetStatusHearingTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Controllers/HearingsController/GetStatusHearingTests.cs index b94898f96..463ec1292 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 _bookingsApiClientMock; private Mock _conferenceDetailsServiceMock; private Mock _hearingServiceMock; - private HearingDetailsResponse _vhExistingHearing; + private HearingDetailsResponseV2 _vhExistingHearing; private HearingDetailsResponseV2 _vhExistingHearingV2; private Guid _guid; @@ -47,42 +46,31 @@ public void Setup() public void Initialise() { _guid = Guid.NewGuid(); - _vhExistingHearing = new HearingDetailsResponse + _vhExistingHearing = new HearingDetailsResponseV2 { Cases = new List { 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 +79,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())) + _bookingsApiClientMock.Setup(x => x.GetHearingDetailsByIdV2Async(It.IsAny())) .ReturnsAsync(_vhExistingHearing); _bookingsApiClientMock.Setup(x => x.GetHearingDetailsByIdV2Async(It.IsAny())) - .ReturnsAsync(GetHearingDetailsResponseV2(BookingsApi.Contract.V2.Enums.BookingStatusV2.Created)); + .ReturnsAsync(GetHearingDetailsResponseV2(BookingStatusV2.Created)); } [Test] @@ -127,7 +115,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(), false)).Throws(new VideoApiException("Error", 400, null, null, null)); // Act var result = await _controller.GetHearingConferenceStatus(_guid); @@ -168,7 +156,7 @@ public async Task Should_return_ok_with_false_when_hearing_status_is_created_and // Arrange _conferenceDetailsServiceMock.Setup(x => x.GetConferenceDetailsByHearingId(It.IsAny(), 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..332e5ba93 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 { @@ -69,81 +64,6 @@ protected virtual void Setup() _conferencesServiceMock.Object); } - protected static List CreateListOfV1HearingsInMultiDayGroup( - Guid groupId, Guid initialHearingId) - { - var hearingDates = new List - { - 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 CreateListOfV1HearingsInMultiDayGroup( - Guid groupId, Guid initialHearingId, List scheduledDates) - { - var hearingsInMultiDay = new List(); - var i = 0; - foreach (var date in scheduledDates) - { - var hearing = Builder.CreateNew().Build(); - - hearing.Participants = new List - { - 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 CreateListOfV2HearingsInMultiDayGroup( Guid groupId, Guid initialHearingId) { @@ -157,16 +77,16 @@ protected static List CreateListOfV2HearingsInMultiDay return CreateListOfV2HearingsInMultiDayGroupAsV2(groupId, initialHearingId, hearingDates); } - protected static List CreateListOfV2HearingsInMultiDayGroup( + protected static List CreateListOfV2HearingsInMultiDayGroup( Guid groupId, Guid initialHearingId, List scheduledDates) { - var hearingsInMultiDay = new List(); + var hearingsInMultiDay = new List(); var i = 0; foreach (var date in scheduledDates) { - var hearing = Builder.CreateNew().Build(); + var hearing = Builder.CreateNew().Build(); - hearing.Participants = new List + hearing.Participants = new List { new() { @@ -180,7 +100,7 @@ protected static List CreateListOfV2HearingsInMultiDayGr } }; - hearing.JudiciaryParticipants = new List + hearing.JudicialOfficeHolders = new List { new() { @@ -193,7 +113,7 @@ protected static List CreateListOfV2HearingsInMultiDayGr } }; - hearing.Endpoints = new List + hearing.Endpoints = new List { new() { @@ -210,7 +130,7 @@ protected static List 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 +207,7 @@ protected static List CreateListOfV2HearingsInMultiDay } }; - hearing.JudiciaryParticipants = new List + hearing.JudicialOfficeHolders = new List { 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().Setup(bs => bs.GetHearingDetailsByIdAsync(It.IsAny())) - .ReturnsAsync(new V1.Responses.HearingDetailsResponse + _mocker.Mock().Setup(bs => bs.GetHearingDetailsByIdV2Async(It.IsAny())) + .ReturnsAsync(new HearingDetailsResponseV2() { - Participants = new List + Participants = new List { new () {HearingRoleName = "Judge"} }, - CaseTypeName = "Generic" + ServiceId = "Generic" }); _controller = _mocker.Create(); } @@ -98,22 +98,22 @@ public async Task Should_clone_hearing() { var request = GetMultiHearingRequest(); request.ScheduledDuration = 120; - var groupedHearings = new List + var groupedHearings = new List { new() { - Status = V1.Enums.BookingStatus.Booked, + Status = BookingStatusV2.Booked, GroupId = Guid.NewGuid(), Id = Guid.NewGuid(), } }; _mocker.Mock() - .Setup(x => x.GetHearingsByGroupIdAsync(It.IsAny())) + .Setup(x => x.GetHearingsByGroupIdV2Async(It.IsAny())) .ReturnsAsync(groupedHearings); _mocker.Mock() - .Setup(x => x.CloneHearingAsync(It.IsAny(), It.IsAny())) + .Setup(x => x.CloneHearingAsync(It.IsAny(), It.IsAny())) .Verifiable(); var response = await _controller.CloneHearing(Guid.NewGuid(), request); @@ -121,7 +121,7 @@ public async Task Should_clone_hearing() response.Should().BeOfType(); _mocker.Mock().Verify( - x => x.CloneHearingAsync(It.IsAny(), It.Is( + x => x.CloneHearingAsync(It.IsAny(), It.Is( 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(); + var groupedHearings = new List(); 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() - .Setup(x => x.GetHearingsByGroupIdAsync(It.IsAny())) + .Setup(x => x.GetHearingsByGroupIdV2Async(It.IsAny())) .ReturnsAsync(groupedHearings); _mocker.Mock() - .Setup(x => x.CloneHearingAsync(It.IsAny(), It.IsAny())) + .Setup(x => x.CloneHearingAsync(It.IsAny(), It.IsAny())) .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(); _mocker.Mock().Verify( - x => x.CloneHearingAsync(It.IsAny(), It.IsAny()), + x => x.CloneHearingAsync(It.IsAny(), It.IsAny()), Times.Exactly(1)); } @@ -178,7 +178,7 @@ public async Task Should_catch_BookingsApiException_by_clone_hearing() { var request = GetMultiHearingRequest(); _mocker.Mock() - .Setup(x => x.CloneHearingAsync(It.IsAny(), It.IsAny())) + .Setup(x => x.CloneHearingAsync(It.IsAny(), It.IsAny())) .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() - .Setup(x => x.CloneHearingAsync(It.IsAny(), It.IsAny())) + .Setup(x => x.CloneHearingAsync(It.IsAny(), It.IsAny())) .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 + var groupedHearings = new List { new() { - Status = V1.Enums.BookingStatus.Booked, + Status = BookingStatusV2.Booked, GroupId = Guid.NewGuid(), Id = Guid.NewGuid(), } }; _mocker.Mock() - .Setup(x => x.GetHearingsByGroupIdAsync(It.IsAny())) + .Setup(x => x.GetHearingsByGroupIdV2Async(It.IsAny())) .ReturnsAsync(groupedHearings); var expectedDates = new List(); @@ -232,7 +232,7 @@ public async Task Should_clone_hearings_on_weekends_when_start_or_end_date_are_o _mocker.Mock().Verify( x => x.CloneHearingAsync(It.IsAny(), - It.Is(r => r.Dates.All(d => expectedDates.Contains(d)))), + It.Is(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 + var groupedHearings = new List { new() { - Status = V1.Enums.BookingStatus.Booked, + Status = BookingStatusV2.Booked, GroupId = Guid.NewGuid(), Id = Guid.NewGuid(), } }; _mocker.Mock() - .Setup(x => x.GetHearingsByGroupIdAsync(It.IsAny())) + .Setup(x => x.GetHearingsByGroupIdV2Async(It.IsAny())) .ReturnsAsync(groupedHearings); var expectedDates = new List @@ -271,7 +271,7 @@ public async Task Should_not_clone_hearings_on_weekends_when_start_or_end_date_a _mocker.Mock().Verify( x => x.CloneHearingAsync(It.IsAny(), - It.Is(r => r.Dates.All(d => expectedDates.Contains(d)))), + It.Is(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 + var groupedHearings = new List { new() { - Status = V1.Enums.BookingStatus.Booked, + Status = BookingStatusV2.Booked, GroupId = Guid.NewGuid(), Id = Guid.NewGuid(), } }; _mocker.Mock() - .Setup(x => x.GetHearingsByGroupIdAsync(It.IsAny())) + .Setup(x => x.GetHearingsByGroupIdV2Async(It.IsAny())) .ReturnsAsync(groupedHearings); var expectedDates = new List @@ -312,7 +312,7 @@ public async Task Should_clone_hearings_using_hearing_dates() _mocker.Mock().Verify( x => x.CloneHearingAsync(It.IsAny(), - It.Is(r => r.Dates.All(d => expectedDates.Contains(d)))), + It.Is(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 + Cases = new List { - 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().Setup(x => x.GetHearingDetailsByIdAsync(It.IsAny())) + _mocker.Mock().Setup(x => x.GetHearingDetailsByIdV2Async(It.IsAny())) .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.CreateNew().Build(); + var person = Builder.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(); - var result = (AcceptedResult) actionResult.Result; + actionResult.Should().BeOfType(); + 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(); - var result = (ObjectResult) actionResult.Result; + actionResult.Should().BeOfType(); + 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())) + .Setup(x => x.UpdatePersonDetailsV2Async(_personId, It.IsAny())) .Throws(ClientException.ForBookingsAPI(HttpStatusCode.NotFound)); var actionResult = await _controller.UpdatePersonDetails(_personId, _payload); - actionResult.Result.Should().BeOfType(); - var result = (ObjectResult) actionResult.Result; + actionResult.Should().BeOfType(); + 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 _bookingsApiClient; private Mock _userAccountService; - private List _response; + private List _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 + _response = new List { - 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 + var expectedResponse = new List { _response[0], additionalParticipantToReturn }; - _bookingsApiClient.Setup(x => x.PostPersonBySearchTermAsync(It.Is(searchTermRequest => searchTermRequest.Term == searchTerm))) + _bookingsApiClient.Setup(x => x.SearchForPersonV2Async(It.Is(searchTermRequest => searchTermRequest.Term == searchTerm))) .ReturnsAsync(_response); @@ -86,7 +86,7 @@ public async Task Should_return_searched_participants() // Assert var okObjectResult = result.Result.Should().BeAssignableTo().Which; okObjectResult.Value.Should().BeEquivalentTo(expectedResponse); - _bookingsApiClient.Verify(x => x.PostPersonBySearchTermAsync(It.Is(request => request.Term == searchTerm)), Times.Once); + _bookingsApiClient.Verify(x => x.SearchForPersonV2Async(It.Is(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 + var expectedResponse = new List { _response[0] }; - _bookingsApiClient.Setup(x => x.PostPersonBySearchTermAsync(It.Is(searchTermRequest => searchTermRequest.Term == searchTerm))) + _bookingsApiClient.Setup(x => x.SearchForPersonV2Async(It.Is(searchTermRequest => searchTermRequest.Term == searchTerm))) .ReturnsAsync(_response); // Act @@ -125,7 +125,7 @@ public async Task Should_filter_TestUsernameStem() // Assert var okObjectResult = result.Result.Should().BeAssignableTo().Which; okObjectResult.Value.Should().BeEquivalentTo(expectedResponse); - _bookingsApiClient.Verify(x => x.PostPersonBySearchTermAsync(It.Is(request => request.Term == searchTerm)), Times.Once); + _bookingsApiClient.Verify(x => x.SearchForPersonV2Async(It.Is(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())) .ReturnsAsync(new List()); - _bookingsApiClient.Setup(x => x.PostPersonBySearchTermAsync(It.IsAny())) + _bookingsApiClient.Setup(x => x.SearchForPersonV2Async(It.IsAny())) .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())) .ReturnsAsync(new List()); - _bookingsApiClient.Setup(x => x.PostPersonBySearchTermAsync(It.IsAny())) + _bookingsApiClient.Setup(x => x.SearchForPersonV2Async(It.IsAny())) .ThrowsAsync(ClientException.ForBookingsAPI(HttpStatusCode.InternalServerError)); Assert.ThrowsAsync(() => _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 _referenceDataServiceMock; - private Mock _userIdentityMock; - private HearingTypesController _controller; - private AutoMock _mocker; - - [SetUp] - public void Setup() - { - _mocker = AutoMock.GetLoose(); - _userIdentityMock = _mocker.Mock(); - _referenceDataServiceMock = _mocker.Mock(); - _controller = _mocker.Create(); - } - - [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())) - .ReturnsAsync(GetCaseTypesList()); - - // Act - var result = await _controller.GetHearingTypes(includeDeleted); - - // Assert - var okObjectResult = result.Result.Should().BeAssignableTo().Which; - okObjectResult.Value.Should().BeEquivalentTo(GetHearingTypes()); - } - - private static List GetCaseTypesList() - { - return new List - { - new () - { - Id = 1, Name = "type1", ServiceId = "AA1", - HearingTypes = new List() - { - new () {Id = 10, Name = "HType10", Code = "Code10"}, - } - }, - new() - { - Id = 2, Name = "type2", ServiceId = "AA2", - HearingTypes = new List() - { - new () {Id = 20, Name = "HType20", Code = "Code20"}, - } - }, - new() - { - Id = 3, Name = "type3", ServiceId = "AA3", - HearingTypes = new List() - { - new () {Id = 25, Name = "HType25", Code = "Code25"}, - new () {Id = 29, Name = "HType29", Code = "Code29"}, - } - }, - new() - { - Id = 4, Name = "type4", ServiceId = "AA4", - HearingTypes = new List() - } - }; - } - - private static List GetHearingTypes() - { - var result = new List() - { - 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 _bookingsApiClientMock; - private Mock _userIdentityMock; - private ParticipantRolesController _controller; - private AutoMock _mocker; - - [SetUp] - public void Setup() - { - _mocker = AutoMock.GetLoose(); - _bookingsApiClientMock = _mocker.Mock(); - _userIdentityMock = _mocker.Mock(); - _controller = _mocker.Create(); - } - - [Test] - public async Task Should_return_participants_roles() - { - List listTypes; - listTypes = new List { new CaseRoleResponseV2 { Name = "type1" } }; - SetTestCase(listTypes); - - var response = await _controller.GetParticipantRoles("type1"); - response.Should().NotBeNull(); - var result = (OkObjectResult)response.Result; - var caseRoles = (List)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(); - SetTestCase(listTypes); - - var response = await _controller.GetParticipantRoles("type1"); - response.Should().NotBeNull(); - var result = (OkObjectResult)response.Result; - List caseRoles = (List)result.Value; - caseRoles.Count.Should().Be(0); - } - - [Test] - public async Task Should_return_empty_list_of_participants_roles_if_list_types_is_null() - { - List listTypes = null; - SetTestCase(listTypes); - - var response = await _controller.GetParticipantRoles("type1"); - response.Should().NotBeNull(); - var result = (OkObjectResult)response.Result; - List caseRoles = (List)result.Value; - caseRoles.Count.Should().Be(0); - } - - private void SetTestCase(List listTypes) - { - var listHearingRoles2 = new List { new HearingRoleResponseV2 { Name = "type1", UserRole = "role1"} }; - - _userIdentityMock.Setup(x => x.GetAdministratorCaseTypes()).Returns(new List { "type1", "type2" }); - - //v2 endpoints - var casetypeV2Response = listTypes?.Select(e => (CaseRoleResponseV2)e).ToList(); - _bookingsApiClientMock.Setup(x => x.GetCaseRolesForCaseServiceAsync(It.IsAny())).ReturnsAsync(casetypeV2Response); - _bookingsApiClientMock.Setup(x => x.GetHearingRolesForCaseRoleV2Async(It.IsAny(), It.IsAny())).ReturnsAsync(listHearingRoles2); - - } - } -} diff --git a/AdminWebsite/AdminWebsite.UnitTests/Controllers/WorkAllocationController/GetUnallocatedHearingsTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Controllers/WorkAllocationController/GetUnallocatedHearingsTests.cs index 7420ccc0e..9785f913d 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; @@ -26,7 +25,7 @@ public async Task Should_get_unallocated_hearings() { // Arrange _mocker.Mock().Setup(client => client.GetUnallocatedHearingsAsync()) - .ReturnsAsync(new List {new ()}); + .ReturnsAsync(new List {new ()}); // Act var response = await _controller.GetUnallocatedHearings(); @@ -42,7 +41,7 @@ public async Task Should_try_get_unallocated_hearings_and_return_empty_list() { // Arrange _mocker.Mock().Setup(client => client.GetUnallocatedHearingsAsync()) - .ReturnsAsync(new List()); + .ReturnsAsync(new List()); // Act var response = await _controller.GetUnallocatedHearings(); diff --git a/AdminWebsite/AdminWebsite.UnitTests/Extensions/HearingDetailsResponseExtensionsTests.cs b/AdminWebsite/AdminWebsite.UnitTests/Extensions/HearingDetailsResponseExtensionsTests.cs index eb2644421..b9e7cd5a2 100644 --- a/AdminWebsite/AdminWebsite.UnitTests/Extensions/HearingDetailsResponseExtensionsTests.cs +++ b/AdminWebsite/AdminWebsite.UnitTests/Extensions/HearingDetailsResponseExtensionsTests.cs @@ -19,229 +19,6 @@ public void Setup() Participants = new List() }; } - - [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() }).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() }; - 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() }; - 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() - { - _hearing.CaseTypeName = "Generic"; - var existingJudge = Builder.CreateNew() - .With(x => x.UserRoleName = UserRole.Judge.ToString()) - .With(x => x.Username = "old@judge.com") - .Build(); - _hearing.Participants.Add(existingJudge); - - var newJudge = Builder.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 - { - Id = _hearing.Id, - Participants = new List { newJudge } - }; - - _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.CreateNew() - .With(x => x.UserRoleName = UserRole.Judge.ToString()) - .With(x => x.Username = "old@judge.com") - .Build(); - _hearing.Participants.Add(existingJudge); - - var newJudge = Builder.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 - { - Id = _hearing.Id, - Participants = new List { newJudge } - }; - - _hearing.JudgeHasNotChangedForGenericHearing(updatedHearing).Should().BeTrue(); - } - [Test] - public void Should_Return_True_If_Judge_Has_Not_Changed_When_Comparing_Generic_Hearing_Judges() - { - _hearing.CaseTypeName = "Generic"; - var existingJudge = Builder.CreateNew() - .With(x => x.UserRoleName = UserRole.Judge.ToString()) - .With(x => x.Username = "old@judge.com") - .Build(); - _hearing.Participants.Add(existingJudge); - - var newJudge = Builder.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 - { - Id = _hearing.Id, - Participants = new List { newJudge } - }; - - _hearing.JudgeHasNotChangedForGenericHearing(updatedHearing).Should().BeTrue(); - } - - [Test] - public void Should_return_true_when_ejud_email_has_been_assigned_from_no_judge() - { - var judge = Builder.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 { judge } - }; - _hearing.HasJudgeEmailChanged(newHearing).Should().BeTrue(); - } - - [Test] - public void Should_return_true_when_ejud_email_has_changed_to_another_ejud() - { - var existingEJudJudge = Builder.CreateNew() - .With(x => x.UserRoleName = UserRole.Judge.ToString()) - .With(x => x.Username = "old@judiciaryejud.com") - .Build(); - _hearing.Participants.Add(existingEJudJudge); - - var newEJudJudge = Builder.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 { 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.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 { newEJudJudge } - }; - _hearing.HasJudgeEmailChanged(newHearing).Should().BeTrue(); - } - - [Test] - public void Should_return_true_when_vh_judge_has_changed_to_ejud_judge() - { - var existingEJudJudge = Builder.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 - { - Id = Guid.NewGuid(), - Participants = new List(), - OtherInformation = otherInfo.ToOtherInformationString() - }; - _hearing.HasJudgeEmailChanged(newHearing).Should().BeTrue(); - } + } } \ 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.CreateNew() - .With(x => x.Participants = new List()) - .With(x => x.Cases = new List { Builder.CreateNew().Build() }) - .Build(); - } - - public static HearingDetailsResponse WithEndPoints(this HearingDetailsResponse hearingDetailsResponse, int size) - { - var endPoints = Builder.CreateListOfSize(size).Build().ToList(); - - hearingDetailsResponse.Endpoints = endPoints; - - return hearingDetailsResponse; - } - - public static HearingDetailsResponse WithParticipant(this HearingDetailsResponse hearingDetailsResponse, string userRoleName, string userName =null) - { - var participant = Builder.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.CreateNew() .With(x => x.Participants = new List()) - .With(x => x.JudiciaryParticipants = new List()) + .With(x => x.JudicialOfficeHolders = new List()) .With(x => x.Cases = new List { Builder.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.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/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 }; + var expectedCases = new List { _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(); - 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(), - }; - 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 + var hearingDetailsResponse = new List { 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(); + var hearingDetailsResponse = new List(); 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() - .Setup(c => c.GetHearingsByGroupIdAsync(It.IsAny())) - .ReturnsAsync(new List { _hearing }); + .Setup(c => c.GetHearingsByGroupIdV2Async(It.IsAny())) + .ReturnsAsync(new List { _hearing }); _service = _mocker.Create(); _hearing = InitHearing(); @@ -96,54 +94,54 @@ public void Should_have_one_added_participant() [Test] public async Task Should_process_participants() { - var existingParticipants = new List(); - var newParticipants = new List(); + var existingParticipants = new List(); + var newParticipants = new List(); var removedParticipantIds = new List(); - var linkedParticipants = new List(); + var linkedParticipants = new List(); _mocker.Mock() - .Setup(x => x.GetHearingsByGroupIdAsync(_hearing.GroupId.Value)) - .ReturnsAsync(new List { _hearing }); + .Setup(x => x.GetHearingsByGroupIdV2Async(_hearing.GroupId.Value)) + .ReturnsAsync(new List { _hearing }); - await _service.ProcessParticipants(_hearing.Id, existingParticipants, newParticipants, removedParticipantIds, linkedParticipants); + await _service.ProcessParticipantsV2(_hearing.Id, existingParticipants, newParticipants, removedParticipantIds, linkedParticipants); _mocker.Mock() .Verify( - x => x.UpdateHearingParticipantsAsync(_hearing.Id, It.Is(x => - x.ExistingParticipants == existingParticipants - && x.NewParticipants == newParticipants - && x.RemovedParticipantIds == removedParticipantIds - && x.LinkedParticipants == linkedParticipants)), Times.Once); + x => x.UpdateHearingParticipantsV2Async(_hearing.Id, It.Is(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 { new CaseResponse { Name = "Test", Number = "123456" } }; - var rep = Builder.CreateNew() + var cases = new List { new() { Name = "Test", Number = "123456" } }; + var rep = Builder.CreateNew() .With(x => x.Id = Guid.NewGuid()) .With(x => x.UserRoleName = "Representative") .Build(); - var ind = Builder.CreateNew() + var ind = Builder.CreateNew() .With(x => x.Id = Guid.NewGuid()) .With(x => x.UserRoleName = "Individual") .Build(); - var joh = Builder.CreateNew() + var joh = Builder.CreateNew() .With(x => x.Id = Guid.NewGuid()) .With(x => x.UserRoleName = "Judicial Office Holder") .Build(); - var judge = Builder.CreateNew() + var judge = Builder.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.CreateNew() + var staffMember = Builder.CreateNew() .With(x => x.Id = Guid.NewGuid()) .With(x => x.UserRoleName = "Staff Member") .Build(); - return Builder.CreateNew() - .With(h => h.Participants = new List { rep, ind, joh, judge, staffMember }) + return Builder.CreateNew() + .With(h => h.Participants = new List { 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()); _mocker.Mock().Setup(x => x.GetHearingVenuesAsync(true, It.IsAny())) .ReturnsAsync(new List()); - _mocker.Mock().Setup(x => x.GetCaseTypesAsync(false, It.IsAny())) - .ReturnsAsync(new List()); + _mocker.Mock().Setup(x => x.GetCaseTypesV2Async(false, It.IsAny())) + .ReturnsAsync(new List()); _mocker.Mock().Setup(x => x.GetHearingRolesAsync(It.IsAny())) .ReturnsAsync(new List()); @@ -44,48 +44,34 @@ public async Task Should_initialise_cache() // assert _mocker.Mock().Verify(x => x.GetAvailableInterpreterLanguagesAsync(It.IsAny()), Times.Once); _mocker.Mock().Verify(x => x.GetHearingVenuesAsync(true, It.IsAny()), Times.Once); - _mocker.Mock().Verify(x => x.GetCaseTypesAsync(false, It.IsAny()), Times.Once); + _mocker.Mock().Verify(x => x.GetCaseTypesV2Async(false, It.IsAny()), Times.Once); _mocker.Mock().Verify(x => x.GetHearingRolesAsync(It.IsAny()), Times.Once); } [Test] public async Task should_return_non_deleted_case_types() { - var caseTypes = new List + var caseTypes = new List { 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() + Id = 4, Name = "type4", ServiceId = "AA4" } }; - _mocker.Mock().Setup(x => x.GetCaseTypesAsync(false, It.IsAny())) + _mocker.Mock().Setup(x => x.GetCaseTypesV2Async(false, It.IsAny())) .ReturnsAsync(caseTypes); // act 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() }; - 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 { 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 { 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..1d9255994 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.2-pr-0919-0010", + "contentHash": "uTjHes/RCMLANtbDLm2sfQTdqSA/90fwUGb2KthKSsZWpjoYdZtJYDjLtTNFqeH7qAKQTV0herli/gAyAAP0hg==", "dependencies": { - "Microsoft.AspNetCore.Mvc.Core": "2.2.5" + "BookingsApi.Common.DotNet6": "3.1.2-pr-0919-0010", + "Microsoft.AspNetCore.Mvc.Core": "2.2.5", + "System.Text.Json": "8.0.5" + } + }, + "BookingsApi.Common.DotNet6": { + "type": "Transitive", + "resolved": "3.1.2-pr-0919-0010", + "contentHash": "JBKWH0dvKUOBh9AnUV0C6ExjeV0Wem3bfmk7Gkxrqnc+Iz5cUvz6zyMMnGVX1mFlsEgrxVeJXj/DoTV0YCyN0Q==", + "dependencies": { + "System.Text.Json": "8.0.5" } }, "Castle.Core": { @@ -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", @@ -2221,7 +2231,7 @@ "type": "Project", "dependencies": { "AspNetCore.HealthChecks.Uris": "[8.0.1, )", - "BookingsApi.Client": "[2.3.9, )", + "BookingsApi.Client": "[3.1.2-pr-0919-0010, )", "FluentValidation.AspNetCore": "[11.3.0, )", "LaunchDarkly.ServerSdk": "[8.5.0, )", "MicroElements.Swashbuckle.FluentValidation": "[6.0.0, )", diff --git a/AdminWebsite/AdminWebsite/AdminWebsite.csproj b/AdminWebsite/AdminWebsite/AdminWebsite.csproj index 5d0b0a5b1..b0b6b30f4 100644 --- a/AdminWebsite/AdminWebsite/AdminWebsite.csproj +++ b/AdminWebsite/AdminWebsite/AdminWebsite.csproj @@ -30,7 +30,7 @@ - + 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/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/HearingTypeResponse.cs b/AdminWebsite/AdminWebsite/Contracts/Responses/HearingTypeResponse.cs deleted file mode 100644 index 2078684b4..000000000 --- a/AdminWebsite/AdminWebsite/Contracts/Responses/HearingTypeResponse.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace AdminWebsite.Contracts.Responses -{ - /// - /// Defines a type of hearing based on case - /// - public class HearingTypeResponse - { - /// - /// The short code for the type - /// - public string Code { get; set; } - - /// - /// Which case type it belongs to - /// - public string Group { get; set; } - - /// - /// Unique identifier for this type of hearing - /// - public int? Id { get; set; } - - /// - /// Hearing type display name - /// - public string Name { get; set; } - - /// - /// The service id for the type - /// - public string ServiceId { get; set; } - } -} 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 GetBookingsList([FromBody]BookingSearchRequest r private async Task> GetCaseTypesId(IEnumerable caseTypes) { var typeIds = new List(); - 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..6efa8a9e6 100644 --- a/AdminWebsite/AdminWebsite/Controllers/HearingsController.cs +++ b/AdminWebsite/AdminWebsite/Controllers/HearingsController.cs @@ -18,7 +18,7 @@ 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; @@ -30,6 +30,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; @@ -180,7 +181,7 @@ public async Task CloneHearing(Guid hearingId, MultiHearingReques return BadRequest(); } - var cloneHearingRequest = new CloneHearingRequest + var cloneHearingRequest = new CloneHearingRequestV2() { Dates = hearingDates, ScheduledDuration = hearingRequest.ScheduledDuration @@ -192,7 +193,7 @@ public async Task 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); @@ -512,10 +513,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 + var hearingsToCancel = new List { thisHearing }; @@ -529,8 +530,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 +629,7 @@ private async Task UpdateJudiciaryParticipants(Guid hearingId, List new BookingsApi.Contract.V1.Requests.JudiciaryParticipantRequest() + .Select(jp => new BookingsApi.Contract.V2.Requests.JudiciaryParticipantRequest() { DisplayName = jp.DisplayName, PersonalCode = jp.PersonalCode, @@ -703,7 +704,7 @@ private static UpdateJudiciaryParticipantsRequest MapUpdateJudiciaryParticipants var newJohRequest = newJohs.Select(jp => { var roleCode = Enum.Parse(jp.Role); - return new BookingsApi.Contract.V1.Requests.JudiciaryParticipantRequest() + return new BookingsApi.Contract.V2.Requests.JudiciaryParticipantRequest() { DisplayName = jp.DisplayName, PersonalCode = jp.PersonalCode, @@ -720,7 +721,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 /// The list of person [HttpPost] [SwaggerOperation(OperationId = "PostPersonBySearchTerm")] - [ProducesResponseType(typeof(List), (int)HttpStatusCode.OK)] + [ProducesResponseType(typeof(List), (int)HttpStatusCode.OK)] [ProducesResponseType((int)HttpStatusCode.BadRequest)] - public async Task>> PostPersonBySearchTerm([FromBody] string term) + public async Task>> 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 DeletePersonWithUsernameAsync(string username) /// A person [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> GetPersonForUpdateByContactEmail( + public async Task> 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> GetPersonForUpdateByContactEmail } } - /// A person /// /// Update the personal details /// @@ -156,10 +156,9 @@ public async Task> GetPersonForUpdateByContactEmail [ProducesResponseType((int)HttpStatusCode.Accepted)] [ProducesResponseType((int)HttpStatusCode.NotFound)] [ProducesResponseType((int)HttpStatusCode.BadRequest)] - public async Task>> UpdatePersonDetails([FromRoute] Guid personId, + public async Task UpdatePersonDetails([FromRoute] Guid personId, [FromBody] UpdateAccountDetailsRequest payload) { - try { var useridString = await _userAccountService.GetAdUserIdForUsername(payload.CurrentUsername); @@ -167,13 +166,13 @@ public async Task>> 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 deleted file mode 100644 index 10c45ef18..000000000 --- a/AdminWebsite/AdminWebsite/Controllers/ReferenceData/HearingTypesController.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Threading.Tasks; -using AdminWebsite.Contracts.Responses; -using AdminWebsite.Services; -using Microsoft.AspNetCore.Mvc; - -namespace AdminWebsite.Controllers.ReferenceData; - -/// -/// Responsible for retrieving hearing types reference data when requesting a booking. -/// -public class HearingTypesController : ReferenceDataControllerBase -{ - private readonly IReferenceDataService _referenceDataService; - - /// - /// Instantiate the controller - /// - public HearingTypesController(IReferenceDataService referenceDataService) - { - _referenceDataService = referenceDataService; - } - - /// - /// Gets a list hearing types - /// - /// List of hearing types - [HttpGet("types", Name = "GetHearingTypes")] - [ProducesResponseType(typeof(IList), (int)HttpStatusCode.OK)] - [ProducesResponseType((int)HttpStatusCode.NotFound)] - public async Task>> GetHearingTypes( - [FromQuery] bool includeDeleted = false) - { - 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 - { - Group = caseType.Name, - ServiceId = caseType.ServiceId - })); - - return Ok(result); - } -} \ No newline at end of file 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; - -/// -/// Responsible for retrieving participant roles reference data when requesting a booking. -/// -public class ParticipantRolesController : ReferenceDataControllerBase -{ - private readonly IBookingsApiClient _bookingsApiClient; - - /// - /// Instantiate the controller - /// - public ParticipantRolesController(IBookingsApiClient bookingsApiClient) - { - _bookingsApiClient = bookingsApiClient; - } - - /// - /// Get available participant roles - /// - /// List of valid participant roles - [HttpGet("participantroles", Name = "GetParticipantRoles")] - [ProducesResponseType(typeof(IList), (int)HttpStatusCode.OK)] - [ProducesResponseType((int)HttpStatusCode.NotFound)] - public async Task>> GetParticipantRoles(string caseTypeParameter) - { - var response = new List(); - List 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 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..a832079cf 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 { @@ -40,7 +39,7 @@ public async Task GetUnallocatedHearings() var unallocatedHearings = await _bookingsApiClient.GetUnallocatedHearingsAsync(); if (unallocatedHearings == null || unallocatedHearings.Count == 0) - return Ok(UnallocatedHearingsForVhoMapper.MapFrom(new List(), DateTime.Today)); + return Ok(UnallocatedHearingsForVhoMapper.MapFrom(new List(), 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(); serviceCollection.AddTransient((ctx) => { - var userPrincipal = ctx.GetService().HttpContext.User; + var userPrincipal = ctx.GetService().HttpContext!.User; return new UserIdentity(userPrincipal); }); - serviceCollection.AddSingleton, EditHearingRequestValidator>(); - return serviceCollection; } diff --git a/AdminWebsite/AdminWebsite/Extensions/HearingDetailsResponseExtensions.cs b/AdminWebsite/AdminWebsite/Extensions/HearingDetailsResponseExtensions.cs index c666885de..e7991bde4 100644 --- a/AdminWebsite/AdminWebsite/Extensions/HearingDetailsResponseExtensions.cs +++ b/AdminWebsite/AdminWebsite/Extensions/HearingDetailsResponseExtensions.cs @@ -1,207 +1,12 @@ -using System; -using System.Linq; -using AdminWebsite.Contracts.Enums; using AdminWebsite.Contracts.Responses; -using AdminWebsite.Models; -using Newtonsoft.Json; -namespace AdminWebsite.Extensions -{ - public static class HearingDetailsResponseExtensions - { - 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); - } +namespace AdminWebsite.Extensions; - 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(json); - } - - public static BookingsApi.Contract.V1.Responses.HearingDetailsResponse Duplicate(this BookingsApi.Contract.V1.Responses.HearingDetailsResponse hearingDetailsResponse) - { - var json = JsonConvert.SerializeObject(hearingDetailsResponse); - return JsonConvert.DeserializeObject(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] }; - } +public static class HearingDetailsResponseExtensions +{ + public static bool HasScheduleAmended(this HearingDetailsResponse hearing, HearingDetailsResponse anotherHearing) - 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 GetRemovedEndpoints(List 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..a2fbcd16c 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; @@ -40,7 +39,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(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 Map(this List 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 Map(this List 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 unallocatedHearings, DateTime today) + public static UnallocatedHearingsForVhoResponse MapFrom(List unallocatedHearings, DateTime today) { return new UnallocatedHearingsForVhoResponse { @@ -20,7 +19,7 @@ public static UnallocatedHearingsForVhoResponse MapFrom(List unallocatedHearings, DateTime today) + private static DateForUnallocatedHearings MapToday(List unallocatedHearings, DateTime today) { return new DateForUnallocatedHearings { @@ -29,7 +28,7 @@ private static DateForUnallocatedHearings MapToday(List }; } - private static DateForUnallocatedHearings MapTomorrow(List unallocatedHearings, DateTime today) + private static DateForUnallocatedHearings MapTomorrow(List unallocatedHearings, DateTime today) { var tomorrow = today.AddDays(1); return new DateForUnallocatedHearings @@ -39,7 +38,7 @@ private static DateForUnallocatedHearings MapTomorrow(List unallocatedHearings, DateTime today) + private static DateForUnallocatedHearings FindNext7Days(List unallocatedHearings, DateTime today) { var dateStart = today.Date; var dateEnd = dateStart.AddDays(7); @@ -52,7 +51,7 @@ private static DateForUnallocatedHearings FindNext7Days(List unallocatedHearings, DateTime today) + private static DateForUnallocatedHearings FindNext30Days(List 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 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; } - /// - /// The name of the participant's case role - /// - public string CaseRoleName { get; set; } - /// /// The name of the participant's hearing role /// diff --git a/AdminWebsite/AdminWebsite/Services/HearingsService.cs b/AdminWebsite/AdminWebsite/Services/HearingsService.cs index fa053e5b9..d1dce5e11 100644 --- a/AdminWebsite/AdminWebsite/Services/HearingsService.cs +++ b/AdminWebsite/AdminWebsite/Services/HearingsService.cs @@ -18,8 +18,8 @@ namespace AdminWebsite.Services public interface IHearingsService { void AssignEndpointDefenceAdvocates(List endpointsWithDa, IReadOnlyCollection participants); - Task ProcessParticipants(Guid hearingId, List existingParticipants, List newParticipants, List removedParticipantIds, List linkedParticipants); Task ProcessParticipantsV2(Guid hearingId, List existingParticipants, List newParticipants, List removedParticipantIds, List linkedParticipants); + [Obsolete("V2 models no longer require this method")] Task ProcessNewParticipant(Guid hearingId, EditParticipantRequest participant, IParticipantRequest newParticipant, List removedParticipantIds, HearingDetailsResponse hearing); Task ProcessEndpoints(Guid hearingId, List endpoints, HearingDetailsResponse hearing, List newParticipantList); UpdateHearingEndpointsRequestV2 MapUpdateHearingEndpointsRequestV2(Guid hearingId, List endpoints, HearingDetailsResponse hearing, List newParticipantList, HearingChanges hearingChanges = null); @@ -60,23 +60,6 @@ public static List GetAddedParticipant(List(); } - - public async Task ProcessParticipants(Guid hearingId, - List existingParticipants, - List newParticipants, - List removedParticipantIds, - List 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 existingParticipants, @@ -102,23 +85,6 @@ public Task ProcessNewParticipant( List 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(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..afcec23b5 100644 --- a/AdminWebsite/AdminWebsite/Services/ReferenceDataService.cs +++ b/AdminWebsite/AdminWebsite/Services/ReferenceDataService.cs @@ -13,7 +13,7 @@ namespace AdminWebsite.Services; public interface IReferenceDataService { Task InitialiseCache(); - Task> GetNonDeletedCaseTypesAsync(CancellationToken cancellationToken = default); + Task> GetNonDeletedCaseTypesAsync(CancellationToken cancellationToken = default); Task> GetInterpreterLanguagesAsync(CancellationToken cancellationToken = default); Task> GetHearingVenuesAsync(CancellationToken cancellationToken = default); Task> GetHearingRolesAsync(CancellationToken cancellationToken = default); @@ -33,11 +33,12 @@ public async Task InitialiseCache() await GetHearingRolesAsync(); } - public async Task> GetNonDeletedCaseTypesAsync(CancellationToken cancellationToken = default) + public async Task> 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 - { - 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 - { - 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 - { - 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 - { - 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 - { - 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..ae65e23a2 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.2-pr-0919-0010, )", + "resolved": "3.1.2-pr-0919-0010", + "contentHash": "uTjHes/RCMLANtbDLm2sfQTdqSA/90fwUGb2KthKSsZWpjoYdZtJYDjLtTNFqeH7qAKQTV0herli/gAyAAP0hg==", "dependencies": { - "Microsoft.AspNetCore.Mvc.Core": "2.2.5" + "BookingsApi.Common.DotNet6": "3.1.2-pr-0919-0010", + "Microsoft.AspNetCore.Mvc.Core": "2.2.5", + "System.Text.Json": "8.0.5" } }, "FluentValidation.AspNetCore": { @@ -267,6 +269,14 @@ "System.Threading.Tasks.Extensions": "4.5.4" } }, + "BookingsApi.Common.DotNet6": { + "type": "Transitive", + "resolved": "3.1.2-pr-0919-0010", + "contentHash": "JBKWH0dvKUOBh9AnUV0C6ExjeV0Wem3bfmk7Gkxrqnc+Iz5cUvz6zyMMnGVX1mFlsEgrxVeJXj/DoTV0YCyN0Q==", + "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",