From 03455c982ffb7e76ae6853a9a4f210dec80e89a1 Mon Sep 17 00:00:00 2001 From: shaed-parkar <41630528+shaed-parkar@users.noreply.github.com> Date: Wed, 13 Sep 2023 09:24:32 +0100 Subject: [PATCH] VIH-10166 remove suitability answers & questionnaire (#715) --- .../Models/CreateHearingRequestBuilder.cs | 1 - .../Models/UpdateSuitabilityAnswersRequest.cs | 21 - .../Steps/ParticipantsSteps.cs | 9 - .../Steps/PersonsSteps.cs | 28 - .../BookingsApi.Client/BookingsApiClient.cs | 412 ----- .../V1/Requests/BookNewHearingRequest.cs | 3 +- .../V1/Requests/SuitabilityAnswersRequest.cs | 20 - .../V1/Requests/UpdateHearingRequest.cs | 3 + .../V1/Responses/BookingsHearingResponse.cs | 1 + .../V1/Responses/HearingDetailsResponse.cs | 1 + .../HearingSuitabilityAnswerResponse.cs | 35 - .../ParticipantSuitabilityAnswerResponse.cs | 53 - .../PersonSuitabilityAnswerResponse.cs | 15 - .../V1/Responses/SuitabilityAnswerResponse.cs | 23 - .../Responses/SuitabilityAnswersResponse.cs | 12 - .../Commands/CreateVideoHearingCommand.cs | 57 +- .../Commands/RemoveHearingCommand.cs | 3 +- .../Commands/UpdateHearingCommand.cs | 6 +- .../UpdateSuitabilityAnswersCommand.cs | 57 - .../Dtos/CreateVideoHearingDto.cs | 11 + .../Helper/CloneHearingToCommandMapper.cs | 16 +- .../BookingsApi.DAL/Mappings/HearingMap.cs | 2 +- ...ultQuestionnairRequiredToFalse.Designer.cs | 1385 +++++++++++++++++ ...5745_DefaultQuestionnairRequiredToFalse.cs | 52 + .../BookingsDbContextModelSnapshot.cs | 13 +- .../Queries/BaseQueries/VideoHearings.cs | 1 - .../Queries/GetHearingByIdQuery.cs | 1 - ...tParticipantWithSuitabilityAnswersQuery.cs | 83 - BookingsApi/BookingsApi.Domain/Hearing.cs | 10 +- .../Participants/Participant.cs | 1 - .../BookingsApi.Domain/Questionnaire.cs | 1 + .../BookingsApi.Domain/SuitabilityAnswer.cs | 1 + .../BookingsApi.Domain/VideoHearing.cs | 11 +- .../V1/Endpoints/AddEndPointToHearingTests.cs | 4 +- .../RemoveEndPointFromHearingTests.cs | 6 +- .../Api/V1/Endpoints/UpdateEndpointTests.cs | 4 +- .../V1/Hearings/GetHearingDetailsByIdTests.cs | 2 +- .../Api/V1/Hearings/UpdateHearingTests.cs | 4 +- .../AddParticipantsToHearingV2Tests.cs | 8 +- .../UpdateHearingParticipantsV2Tests.cs | 10 +- .../Hearings/GetHearingDetailsByIdV2Tests.cs | 2 +- .../Api/V2/Hearings/UpdateHearingV2Tests.cs | 6 +- .../BookingsApi.IntegrationTests.csproj | 6 - .../CreateVideoHearingCommandTests.cs | 17 +- .../Commands/RemoveHearingCommandTests.cs | 10 +- ...emoveParticipantFromHearingCommandTests.cs | 4 +- .../Commands/UpdateHearingCommandTests.cs | 16 +- .../GetBookingsByCaseTypesQueryHandlerTest.cs | 8 +- ...aringShellByIdQueryHandlerDatabaseTests.cs | 2 +- .../GetHearingsBySearchQueryHandlerTests.cs | 22 +- ...aringsForNotificationsQueryHandlerTests.cs | 20 +- .../Features/V1/Participants.feature | 25 - .../Features/V1/Persons.feature | 17 - .../Features/V1/SuitabilityAnswer.feature | 18 - .../Helper/TestDataManager.cs | 93 +- .../Steps/CommonSteps.cs | 2 +- .../Steps/EndPointSteps.cs | 14 +- .../Steps/HearingsSteps.cs | 33 +- .../Steps/ParticipantsSteps.cs | 64 - .../Steps/PersonsSteps.cs | 72 +- .../Steps/SuitabilityAnswersSteps.cs | 60 - .../UpdateSuitabilityAnswersTests.cs | 106 -- .../GetHearingsForNotificationTests.cs | 4 +- .../Helpers/RequestBuilderV1.cs | 1 - .../UpdateHearingDetailsTests.cs | 5 +- .../GetPersonSuitabilityAnswersTests.cs | 123 -- .../Persons/PersonsControllerTest.cs | 33 +- .../SuitabilityAnswersControllerTests.cs | 85 - .../GetUnallocatedHearingsTests.cs | 2 +- .../DAL/Queries/GetHearingShellQueryTest.cs | 3 +- .../Services/HearingAllocationServiceTests.cs | 3 +- .../GetAnonymisationDataQueryHandlerTests.cs | 26 +- .../Hearing/UpdateHearingDetailsTests.cs | 10 +- .../Domain/Hearing/ValidateArgumentsTests.cs | 2 +- ...AnonymiseCaseAndParticipantCommandTests.cs | 6 +- .../V1/CloneHearingToCommandMapperTests.cs | 2 - .../V1/HearingToDetailResponseMapperTests.cs | 3 +- .../SuitabilityAnswerToResonseMappingTest.cs | 64 - ...ideoHearingToBookingsResponseMapperTest.cs | 2 - .../V1/HearingParticipantsController.cs | 61 - .../Controllers/V1/HearingsController.cs | 3 +- .../Controllers/V1/PersonsController.cs | 53 - .../V1/SuitabilityAnswersController.cs | 62 - .../Controllers/V2/HearingsControllerV2.cs | 2 +- .../RequestBodyLoggingMiddleware.cs | 2 +- ...equestToCreateVideoHearingCommandMapper.cs | 15 +- .../V1/HearingToDetailsResponseMapper.cs | 1 - .../V1/SuitabilityAnswerToResponseMapper.cs | 22 - .../SuitabilityAnswersListToResponseMapper.cs | 35 - .../VideoHearingToBookingsResponseMapper.cs | 1 - ...uestV2ToCreateVideoHearingCommandMapper.cs | 17 +- .../Builders/Api/ApiUriFactory.cs | 9 - .../V1/Request/SimpleBookNewHearingRequest.cs | 1 - .../Builders/Domain/ParticipantBuilder.cs | 34 +- .../Builders/Domain/VideoHearingBuilder.cs | 3 +- .../Testing.Common/Configuration/TestData.cs | 1 - 96 files changed, 1657 insertions(+), 2042 deletions(-) delete mode 100644 BookingsApi/BookingsApi.AcceptanceTests/Models/UpdateSuitabilityAnswersRequest.cs delete mode 100644 BookingsApi/BookingsApi.Contract/V1/Requests/SuitabilityAnswersRequest.cs delete mode 100644 BookingsApi/BookingsApi.Contract/V1/Responses/HearingSuitabilityAnswerResponse.cs delete mode 100644 BookingsApi/BookingsApi.Contract/V1/Responses/ParticipantSuitabilityAnswerResponse.cs delete mode 100644 BookingsApi/BookingsApi.Contract/V1/Responses/PersonSuitabilityAnswerResponse.cs delete mode 100644 BookingsApi/BookingsApi.Contract/V1/Responses/SuitabilityAnswerResponse.cs delete mode 100644 BookingsApi/BookingsApi.Contract/V1/Responses/SuitabilityAnswersResponse.cs delete mode 100644 BookingsApi/BookingsApi.DAL/Commands/UpdateSuitabilityAnswersCommand.cs create mode 100644 BookingsApi/BookingsApi.DAL/Dtos/CreateVideoHearingDto.cs create mode 100644 BookingsApi/BookingsApi.DAL/Migrations/20230911145745_DefaultQuestionnairRequiredToFalse.Designer.cs create mode 100644 BookingsApi/BookingsApi.DAL/Migrations/20230911145745_DefaultQuestionnairRequiredToFalse.cs delete mode 100644 BookingsApi/BookingsApi.DAL/Queries/GetParticipantWithSuitabilityAnswersQuery.cs delete mode 100644 BookingsApi/BookingsApi.IntegrationTests/Features/V1/SuitabilityAnswer.feature delete mode 100644 BookingsApi/BookingsApi.IntegrationTests/Steps/SuitabilityAnswersSteps.cs delete mode 100644 BookingsApi/BookingsApi.UnitTests/Controllers/HearingParticipantsController/UpdateSuitabilityAnswersTests.cs delete mode 100644 BookingsApi/BookingsApi.UnitTests/Controllers/Persons/GetPersonSuitabilityAnswersTests.cs delete mode 100644 BookingsApi/BookingsApi.UnitTests/Controllers/SuitabilityAnswersControllerTests.cs delete mode 100644 BookingsApi/BookingsApi.UnitTests/Mappings/V1/SuitabilityAnswerToResonseMappingTest.cs delete mode 100644 BookingsApi/BookingsApi/Controllers/V1/SuitabilityAnswersController.cs delete mode 100644 BookingsApi/BookingsApi/Mappings/V1/SuitabilityAnswerToResponseMapper.cs delete mode 100644 BookingsApi/BookingsApi/Mappings/V1/SuitabilityAnswersListToResponseMapper.cs diff --git a/BookingsApi/BookingsApi.AcceptanceTests/Models/CreateHearingRequestBuilder.cs b/BookingsApi/BookingsApi.AcceptanceTests/Models/CreateHearingRequestBuilder.cs index 6c34340fb..d0acc0b52 100644 --- a/BookingsApi/BookingsApi.AcceptanceTests/Models/CreateHearingRequestBuilder.cs +++ b/BookingsApi/BookingsApi.AcceptanceTests/Models/CreateHearingRequestBuilder.cs @@ -93,7 +93,6 @@ public CreateHearingRequestBuilder(string caseName) .With(x => x.Endpoints = endpoints) .With(x => x.Cases = cases) .With(x => x.CreatedBy = createdBy) - .With(x => x.QuestionnaireNotRequired = false) .With(x => x.AudioRecordingRequired = true) .With(x => x.Endpoints = new List {new EndpointRequest{ DisplayName = "New Endpoint"}}) .Build(); diff --git a/BookingsApi/BookingsApi.AcceptanceTests/Models/UpdateSuitabilityAnswersRequest.cs b/BookingsApi/BookingsApi.AcceptanceTests/Models/UpdateSuitabilityAnswersRequest.cs deleted file mode 100644 index 30c6fee87..000000000 --- a/BookingsApi/BookingsApi.AcceptanceTests/Models/UpdateSuitabilityAnswersRequest.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using BookingsApi.Contract.V1.Requests; -using FizzWare.NBuilder; - -namespace BookingsApi.AcceptanceTests.Models -{ - internal static class UpdateSuitabilityAnswersRequest - { - public static List BuildRequest() - { - return Builder - .CreateListOfSize(2).All() - .With(x => x.Key = Faker.RandomNumber.Next().ToString()) - .With(x => x.Answer = Faker.Lorem.Sentence(10)) - .With(x => x.ExtendedAnswer = Faker.Lorem.Sentence(30)) - .Build() - .ToList(); - } - } -} \ No newline at end of file diff --git a/BookingsApi/BookingsApi.AcceptanceTests/Steps/ParticipantsSteps.cs b/BookingsApi/BookingsApi.AcceptanceTests/Steps/ParticipantsSteps.cs index 11b3271a4..7735bcbd0 100644 --- a/BookingsApi/BookingsApi.AcceptanceTests/Steps/ParticipantsSteps.cs +++ b/BookingsApi/BookingsApi.AcceptanceTests/Steps/ParticipantsSteps.cs @@ -163,14 +163,5 @@ public void ThenIndividualDetailsShouldBeUpdated(string participant) model.TelephoneNumber.Should().Be(updateParticipantRequest.TelephoneNumber); model.LinkedParticipants.Count.Should().Be(participant == "Individual" ? 1 : 0); } - - [Given(@"I have an update participant suitability answers with a valid user '(.*)'")] - public void GivenIHaveAnUpdateParticipantSuitabilityAnswersWithAValidUser(string role) - { - var participantId = _context.TestData.ParticipantsResponses.FirstOrDefault(x => x.UserRoleName.Equals(role)).Id; - var updateParticipantRequest = UpdateSuitabilityAnswersRequest.BuildRequest(); - _context.TestData.Answers = updateParticipantRequest; - _context.Request = _context.Put(UpdateSuitabilityAnswers(_context.TestData.Hearing.Id, participantId), updateParticipantRequest); - } } } \ No newline at end of file diff --git a/BookingsApi/BookingsApi.AcceptanceTests/Steps/PersonsSteps.cs b/BookingsApi/BookingsApi.AcceptanceTests/Steps/PersonsSteps.cs index f5a697946..c36661ad8 100644 --- a/BookingsApi/BookingsApi.AcceptanceTests/Steps/PersonsSteps.cs +++ b/BookingsApi/BookingsApi.AcceptanceTests/Steps/PersonsSteps.cs @@ -92,34 +92,6 @@ public void ThenPersonsDetailsShouldBeRetrieved() actual.Username.Should().Be(expected.Username); } - [Then(@"suitability answers for '(.*)' should be updated")] - public void ThenSuitabilityAnswersForShouldBeUpdated(string participant) - { - var username = _context.TestData.ParticipantsResponses - .FirstOrDefault(x => x.UserRoleName.Equals(participant)).Username; - var participantId = _context.TestData.ParticipantsResponses - .FirstOrDefault(x => x.UserRoleName.Equals(participant)).Id; - _context.Request = _context.Get(GetPersonSuitabilityAnswers(username)); - _context.Response = _context.Client().Execute(_context.Request); - _context.Response.StatusCode.Should().Be(HttpStatusCode.OK); - var model = - RequestHelper.Deserialise>( - _context.Response.Content); - var expectedResult = _context.TestData.Answers; - - expectedResult[0].Key.Should().Be(model[0].Answers[0].Key); - expectedResult[0].Answer.Should().Be(model[0].Answers[0].Answer); - expectedResult[0].ExtendedAnswer.Should().Be(model[0].Answers[0].ExtendedAnswer); - expectedResult[1].Key.Should().Be(model[0].Answers[1].Key); - expectedResult[1].Answer.Should().Be(model[0].Answers[1].Answer); - expectedResult[1].ExtendedAnswer.Should().Be(model[0].Answers[1].ExtendedAnswer); - - model[0].HearingId.Should().Be(_context.TestData.Hearing.Id); - model[0].ParticipantId.Should().Be(participantId); - model[0].UpdatedAt.Should().BeAfter(DateTime.UtcNow.AddMinutes(-2)); - model[0].QuestionnaireNotRequired.Should().BeFalse(); - } - [Then(@"a list of hearings for deletion is (.*)")] public void ThenAListOfHearingsForDeletionIs(int expectedNumOfHearings) { diff --git a/BookingsApi/BookingsApi.Client/BookingsApiClient.cs b/BookingsApi/BookingsApi.Client/BookingsApiClient.cs index 0434405ec..6b849f871 100644 --- a/BookingsApi/BookingsApi.Client/BookingsApiClient.cs +++ b/BookingsApi/BookingsApi.Client/BookingsApiClient.cs @@ -287,27 +287,6 @@ public partial interface IBookingsApiClient /// A server side error occurred. System.Threading.Tasks.Task UpdateHearingParticipantsAsync(System.Guid hearingId, UpdateHearingParticipantsRequest request, System.Threading.CancellationToken cancellationToken); - /// - /// Updates suitability answers for the participant - /// - /// Id of hearing - /// Id of participant - /// A list of suitability answers to update - /// Http status - /// A server side error occurred. - System.Threading.Tasks.Task UpdateSuitabilityAnswersAsync(System.Guid hearingId, System.Guid participantId, System.Collections.Generic.IEnumerable answers); - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Updates suitability answers for the participant - /// - /// Id of hearing - /// Id of participant - /// A list of suitability answers to update - /// Http status - /// A server side error occurred. - System.Threading.Tasks.Task UpdateSuitabilityAnswersAsync(System.Guid hearingId, System.Guid participantId, System.Collections.Generic.IEnumerable answers, System.Threading.CancellationToken cancellationToken); - /// /// Get all standard hearing roles /// @@ -983,25 +962,6 @@ public partial interface IBookingsApiClient /// A server side error occurred. System.Threading.Tasks.Task SearchForNonJudgePersonsByContactEmailAsync(string contactEmail, System.Threading.CancellationToken cancellationToken); - /// - /// Get a list of suitability answers for a given person - /// - /// The username of the person - /// A list of suitability answers - /// A server side error occurred. - [System.Obsolete] - System.Threading.Tasks.Task> GetPersonSuitabilityAnswersAsync(string username); - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Get a list of suitability answers for a given person - /// - /// The username of the person - /// A list of suitability answers - /// A server side error occurred. - [System.Obsolete] - System.Threading.Tasks.Task> GetPersonSuitabilityAnswersAsync(string username, System.Threading.CancellationToken cancellationToken); - /// /// Get list of person from the old hearings /// @@ -1107,25 +1067,6 @@ public partial interface IBookingsApiClient /// A server side error occurred. System.Threading.Tasks.Task> GetStaffMemberBySearchTermAsync(string term, System.Threading.CancellationToken cancellationToken); - /// - /// Get a cursor based list of suitability answers - /// - /// Cursor specifying from which entries to read next page, is defaulted if not specified - /// The max number hearings records to return. - /// The list of latest suitability answers for participants - /// A server side error occurred. - System.Threading.Tasks.Task GetSuitabilityAnswersAsync(string cursor, int? limit); - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Get a cursor based list of suitability answers - /// - /// Cursor specifying from which entries to read next page, is defaulted if not specified - /// The max number hearings records to return. - /// The list of latest suitability answers for participants - /// A server side error occurred. - System.Threading.Tasks.Task GetSuitabilityAnswersAsync(string cursor, int? limit, System.Threading.CancellationToken cancellationToken); - /// /// Automatically allocates a user to a hearing /// @@ -3155,131 +3096,6 @@ public virtual async System.Threading.Tasks.Task UpdateHearingParticipantsAsync( } } - /// - /// Updates suitability answers for the participant - /// - /// Id of hearing - /// Id of participant - /// A list of suitability answers to update - /// Http status - /// A server side error occurred. - public virtual System.Threading.Tasks.Task UpdateSuitabilityAnswersAsync(System.Guid hearingId, System.Guid participantId, System.Collections.Generic.IEnumerable answers) - { - return UpdateSuitabilityAnswersAsync(hearingId, participantId, answers, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Updates suitability answers for the participant - /// - /// Id of hearing - /// Id of participant - /// A list of suitability answers to update - /// Http status - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task UpdateSuitabilityAnswersAsync(System.Guid hearingId, System.Guid participantId, System.Collections.Generic.IEnumerable answers, System.Threading.CancellationToken cancellationToken) - { - if (hearingId == null) - throw new System.ArgumentNullException("hearingId"); - - if (participantId == null) - throw new System.ArgumentNullException("participantId"); - - if (answers == null) - throw new System.ArgumentNullException("answers"); - - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/hearings/{hearingId}/participants/{participantId}/suitability-answers"); - urlBuilder_.Replace("{hearingId}", System.Uri.EscapeDataString(ConvertToString(hearingId, System.Globalization.CultureInfo.InvariantCulture))); - urlBuilder_.Replace("{participantId}", System.Uri.EscapeDataString(ConvertToString(participantId, System.Globalization.CultureInfo.InvariantCulture))); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(answers, _settings.Value); - var content_ = new System.Net.Http.StringContent(json_); - content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); - request_.Content = content_; - request_.Method = new System.Net.Http.HttpMethod("PUT"); - - PrepareRequest(client_, request_, urlBuilder_); - - var url_ = urlBuilder_.ToString(); - request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); - - PrepareRequest(client_, request_, url_); - - var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); - var disposeResponse_ = true; - try - { - var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value); - if (response_.Content != null && response_.Content.Headers != null) - { - foreach (var item_ in response_.Content.Headers) - headers_[item_.Key] = item_.Value; - } - - ProcessResponse(client_, response_); - - var status_ = (int)response_.StatusCode; - if (status_ == 500) - { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); - if (objectResponse_.Object == null) - { - throw new BookingsApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); - } - throw new BookingsApiException("A server side error occurred.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); - } - else - if (status_ == 400) - { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); - if (objectResponse_.Object == null) - { - throw new BookingsApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); - } - throw new BookingsApiException("A server side error occurred.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); - } - else - if (status_ == 404) - { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); - if (objectResponse_.Object == null) - { - throw new BookingsApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); - } - throw new BookingsApiException("A server side error occurred.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); - } - else - if (status_ == 204) - { - return; - } - else - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new BookingsApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); - } - } - finally - { - if (disposeResponse_) - response_.Dispose(); - } - } - } - finally - { - if (disposeClient_) - client_.Dispose(); - } - } - /// /// Get all standard hearing roles /// @@ -8096,121 +7912,6 @@ public virtual async System.Threading.Tasks.Task SearchForNonJud } } - /// - /// Get a list of suitability answers for a given person - /// - /// The username of the person - /// A list of suitability answers - /// A server side error occurred. - [System.Obsolete] - public virtual System.Threading.Tasks.Task> GetPersonSuitabilityAnswersAsync(string username) - { - return GetPersonSuitabilityAnswersAsync(username, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Get a list of suitability answers for a given person - /// - /// The username of the person - /// A list of suitability answers - /// A server side error occurred. - [System.Obsolete] - public virtual async System.Threading.Tasks.Task> GetPersonSuitabilityAnswersAsync(string username, System.Threading.CancellationToken cancellationToken) - { - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/persons/username/{username}/suitability-answers"); - urlBuilder_.Replace("{username}", System.Uri.EscapeDataString(ConvertToString(username, System.Globalization.CultureInfo.InvariantCulture))); - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); - - PrepareRequest(client_, request_, urlBuilder_); - - var url_ = urlBuilder_.ToString(); - request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); - - PrepareRequest(client_, request_, url_); - - var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); - var disposeResponse_ = true; - try - { - var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value); - if (response_.Content != null && response_.Content.Headers != null) - { - foreach (var item_ in response_.Content.Headers) - headers_[item_.Key] = item_.Value; - } - - ProcessResponse(client_, response_); - - var status_ = (int)response_.StatusCode; - if (status_ == 500) - { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); - if (objectResponse_.Object == null) - { - throw new BookingsApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); - } - throw new BookingsApiException("A server side error occurred.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); - } - else - if (status_ == 200) - { - var objectResponse_ = await ReadObjectResponseAsync>(response_, headers_, cancellationToken).ConfigureAwait(false); - if (objectResponse_.Object == null) - { - throw new BookingsApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); - } - return objectResponse_.Object; - } - else - if (status_ == 400) - { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); - if (objectResponse_.Object == null) - { - throw new BookingsApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); - } - throw new BookingsApiException("A server side error occurred.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); - } - else - if (status_ == 404) - { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); - if (objectResponse_.Object == null) - { - throw new BookingsApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); - } - throw new BookingsApiException("A server side error occurred.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); - } - else - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new BookingsApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); - } - } - finally - { - if (disposeResponse_) - response_.Dispose(); - } - } - } - finally - { - if (disposeClient_) - client_.Dispose(); - } - } - /// /// Get list of person from the old hearings /// @@ -8924,119 +8625,6 @@ public virtual async System.Threading.Tasks.Task UpdatePersonUsernameAsync(strin } } - /// - /// Get a cursor based list of suitability answers - /// - /// Cursor specifying from which entries to read next page, is defaulted if not specified - /// The max number hearings records to return. - /// The list of latest suitability answers for participants - /// A server side error occurred. - public virtual System.Threading.Tasks.Task GetSuitabilityAnswersAsync(string cursor, int? limit) - { - return GetSuitabilityAnswersAsync(cursor, limit, System.Threading.CancellationToken.None); - } - - /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. - /// - /// Get a cursor based list of suitability answers - /// - /// Cursor specifying from which entries to read next page, is defaulted if not specified - /// The max number hearings records to return. - /// The list of latest suitability answers for participants - /// A server side error occurred. - public virtual async System.Threading.Tasks.Task GetSuitabilityAnswersAsync(string cursor, int? limit, System.Threading.CancellationToken cancellationToken) - { - var urlBuilder_ = new System.Text.StringBuilder(); - urlBuilder_.Append(BaseUrl != null ? BaseUrl.TrimEnd('/') : "").Append("/suitability-answers?"); - if (cursor != null) - { - urlBuilder_.Append(System.Uri.EscapeDataString("cursor") + "=").Append(System.Uri.EscapeDataString(ConvertToString(cursor, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); - } - if (limit != null) - { - urlBuilder_.Append(System.Uri.EscapeDataString("limit") + "=").Append(System.Uri.EscapeDataString(ConvertToString(limit, System.Globalization.CultureInfo.InvariantCulture))).Append("&"); - } - urlBuilder_.Length--; - - var client_ = _httpClient; - var disposeClient_ = false; - try - { - using (var request_ = new System.Net.Http.HttpRequestMessage()) - { - request_.Method = new System.Net.Http.HttpMethod("GET"); - request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); - - PrepareRequest(client_, request_, urlBuilder_); - - var url_ = urlBuilder_.ToString(); - request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); - - PrepareRequest(client_, request_, url_); - - var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); - var disposeResponse_ = true; - try - { - var headers_ = System.Linq.Enumerable.ToDictionary(response_.Headers, h_ => h_.Key, h_ => h_.Value); - if (response_.Content != null && response_.Content.Headers != null) - { - foreach (var item_ in response_.Content.Headers) - headers_[item_.Key] = item_.Value; - } - - ProcessResponse(client_, response_); - - var status_ = (int)response_.StatusCode; - if (status_ == 500) - { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); - if (objectResponse_.Object == null) - { - throw new BookingsApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); - } - throw new BookingsApiException("A server side error occurred.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); - } - else - if (status_ == 200) - { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); - if (objectResponse_.Object == null) - { - throw new BookingsApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); - } - return objectResponse_.Object; - } - else - if (status_ == 400) - { - var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); - if (objectResponse_.Object == null) - { - throw new BookingsApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); - } - throw new BookingsApiException("A server side error occurred.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); - } - else - { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new BookingsApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); - } - } - finally - { - if (disposeResponse_) - response_.Dispose(); - } - } - } - finally - { - if (disposeClient_) - client_.Dispose(); - } - } - /// /// Automatically allocates a user to a hearing /// diff --git a/BookingsApi/BookingsApi.Contract/V1/Requests/BookNewHearingRequest.cs b/BookingsApi/BookingsApi.Contract/V1/Requests/BookNewHearingRequest.cs index dd0d2163b..6f4aa1eb2 100644 --- a/BookingsApi/BookingsApi.Contract/V1/Requests/BookNewHearingRequest.cs +++ b/BookingsApi/BookingsApi.Contract/V1/Requests/BookNewHearingRequest.cs @@ -67,7 +67,8 @@ public BookNewHearingRequest() /// /// QuestionnaireNotRequired /// - public bool QuestionnaireNotRequired { get; set; } + [Obsolete("This property is no longer used.")] + public bool QuestionnaireNotRequired { get; set; } = false; /// /// Gets or sets the audio recording required flag, value true is indicated that recording is required, otherwise false diff --git a/BookingsApi/BookingsApi.Contract/V1/Requests/SuitabilityAnswersRequest.cs b/BookingsApi/BookingsApi.Contract/V1/Requests/SuitabilityAnswersRequest.cs deleted file mode 100644 index 56511761d..000000000 --- a/BookingsApi/BookingsApi.Contract/V1/Requests/SuitabilityAnswersRequest.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace BookingsApi.Contract.V1.Requests -{ - public class SuitabilityAnswersRequest - { - /// - /// Key used to identify the question - /// - public string Key { get; set; } - - /// - /// Answer the question - /// - public string Answer { get; set; } - - /// - /// Extended answer to the question - /// - public string ExtendedAnswer { get; set; } - } -} diff --git a/BookingsApi/BookingsApi.Contract/V1/Requests/UpdateHearingRequest.cs b/BookingsApi/BookingsApi.Contract/V1/Requests/UpdateHearingRequest.cs index 18743c88f..e3282d6bc 100644 --- a/BookingsApi/BookingsApi.Contract/V1/Requests/UpdateHearingRequest.cs +++ b/BookingsApi/BookingsApi.Contract/V1/Requests/UpdateHearingRequest.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; namespace BookingsApi.Contract.V1.Requests { @@ -43,6 +44,8 @@ public class UpdateHearingRequest /// /// QuestionnaireNotRequired /// + [Obsolete("This property is no longer used.")] + [DefaultValue(false)] public bool? QuestionnaireNotRequired { get; set; } /// diff --git a/BookingsApi/BookingsApi.Contract/V1/Responses/BookingsHearingResponse.cs b/BookingsApi/BookingsApi.Contract/V1/Responses/BookingsHearingResponse.cs index 21ac112ae..bf0bb3533 100644 --- a/BookingsApi/BookingsApi.Contract/V1/Responses/BookingsHearingResponse.cs +++ b/BookingsApi/BookingsApi.Contract/V1/Responses/BookingsHearingResponse.cs @@ -103,6 +103,7 @@ public DateTime HearingDate /// /// QuestionnaireNotRequired /// + [Obsolete("This property is no longer used.")] public bool QuestionnaireNotRequired { get; set; } /// diff --git a/BookingsApi/BookingsApi.Contract/V1/Responses/HearingDetailsResponse.cs b/BookingsApi/BookingsApi.Contract/V1/Responses/HearingDetailsResponse.cs index 026f391ca..5ee17cd93 100644 --- a/BookingsApi/BookingsApi.Contract/V1/Responses/HearingDetailsResponse.cs +++ b/BookingsApi/BookingsApi.Contract/V1/Responses/HearingDetailsResponse.cs @@ -101,6 +101,7 @@ public class HearingDetailsResponse /// /// QuestionnaireNotRequired /// + [Obsolete("This property is no longer used.")] public bool QuestionnaireNotRequired { get; set; } /// diff --git a/BookingsApi/BookingsApi.Contract/V1/Responses/HearingSuitabilityAnswerResponse.cs b/BookingsApi/BookingsApi.Contract/V1/Responses/HearingSuitabilityAnswerResponse.cs deleted file mode 100644 index a242dff1c..000000000 --- a/BookingsApi/BookingsApi.Contract/V1/Responses/HearingSuitabilityAnswerResponse.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace BookingsApi.Contract.V1.Responses -{ - public class HearingSuitabilityAnswerResponse - { - /// - /// Participant Id - /// - public Guid ParticipantId { get; set; } - - /// - /// Scheduled At - /// - public DateTime ScheduledAt { get; set; } - - /// - /// Updated At - /// - public DateTime UpdatedAt { get; set; } - - /// - /// Created At - /// - public DateTime CreatedAt { get; set; } - - /// - /// List of answers - /// - public IList Answers { get; set; } - - - } -} diff --git a/BookingsApi/BookingsApi.Contract/V1/Responses/ParticipantSuitabilityAnswerResponse.cs b/BookingsApi/BookingsApi.Contract/V1/Responses/ParticipantSuitabilityAnswerResponse.cs deleted file mode 100644 index 57b5f58b5..000000000 --- a/BookingsApi/BookingsApi.Contract/V1/Responses/ParticipantSuitabilityAnswerResponse.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace BookingsApi.Contract.V1.Responses -{ - public class ParticipantSuitabilityAnswerResponse - { - /// - /// Gets or sets the participant ID - /// - public Guid ParticipantId { get; set; } - - /// - /// Gets or sets the hearing case number - /// - public string CaseNumber { get; set; } - - /// - /// Gets or sets the participant hearing role - /// - public string HearingRole { get; set; } - - /// - /// Gets or sets the participant title - /// - public string Title { get; set; } - - /// - /// Gets or sets the participant first name - /// - public string FirstName { get; set; } - - /// - /// Gets or sets the participant last name - /// - public string LastName { get; set; } - - /// - /// Last updated date and time of the suitability answers - /// - public DateTime UpdatedAt { get; set; } - - /// - /// Gets or sets the name of represented person - /// - public string Representee { get; set; } - - /// - /// List of answers - /// - public IList Answers { get; set; } - } -} diff --git a/BookingsApi/BookingsApi.Contract/V1/Responses/PersonSuitabilityAnswerResponse.cs b/BookingsApi/BookingsApi.Contract/V1/Responses/PersonSuitabilityAnswerResponse.cs deleted file mode 100644 index 1b5b469f5..000000000 --- a/BookingsApi/BookingsApi.Contract/V1/Responses/PersonSuitabilityAnswerResponse.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace BookingsApi.Contract.V1.Responses -{ - public class PersonSuitabilityAnswerResponse - { - public Guid HearingId { get; set; } - public Guid ParticipantId { get; set; } - public DateTime ScheduledAt { get; set; } - public DateTime UpdatedAt { get; set; } - public bool QuestionnaireNotRequired { get; set; } - public IList Answers { get; set; } - } -} diff --git a/BookingsApi/BookingsApi.Contract/V1/Responses/SuitabilityAnswerResponse.cs b/BookingsApi/BookingsApi.Contract/V1/Responses/SuitabilityAnswerResponse.cs deleted file mode 100644 index c12cb29ec..000000000 --- a/BookingsApi/BookingsApi.Contract/V1/Responses/SuitabilityAnswerResponse.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace BookingsApi.Contract.V1.Responses -{ - /// - /// Suitability Answer Response Object - /// - public class SuitabilityAnswerResponse - { - /// - /// Key used to identify the question - /// - public string Key { get; set; } - - /// - /// Answer the question - /// - /// - public string Answer { get; set; } - /// - /// Extended answer to the question - /// - public string ExtendedAnswer { get; set; } - } -} diff --git a/BookingsApi/BookingsApi.Contract/V1/Responses/SuitabilityAnswersResponse.cs b/BookingsApi/BookingsApi.Contract/V1/Responses/SuitabilityAnswersResponse.cs deleted file mode 100644 index 359bf7dd1..000000000 --- a/BookingsApi/BookingsApi.Contract/V1/Responses/SuitabilityAnswersResponse.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Collections.Generic; - -namespace BookingsApi.Contract.V1.Responses -{ - public class SuitabilityAnswersResponse : PagedCursorBasedResponse - { - /// - /// Gets or sets a list of participants suitability answers. - /// - public List ParticipantSuitabilityAnswerResponse { get; set; } - } -} diff --git a/BookingsApi/BookingsApi.DAL/Commands/CreateVideoHearingCommand.cs b/BookingsApi/BookingsApi.DAL/Commands/CreateVideoHearingCommand.cs index 3b4904594..2399ebfb5 100644 --- a/BookingsApi/BookingsApi.DAL/Commands/CreateVideoHearingCommand.cs +++ b/BookingsApi/BookingsApi.DAL/Commands/CreateVideoHearingCommand.cs @@ -6,23 +6,30 @@ namespace BookingsApi.DAL.Commands { public class CreateVideoHearingCommand : ICommand { - public CreateVideoHearingCommand(CaseType caseType, HearingType hearingType, DateTime scheduledDateTime, - int scheduledDuration, HearingVenue venue, List participants, List cases, - bool questionnaireNotRequired, bool audioRecordingRequired, List endpoints, - List linkedParticipants, bool isMultiDayFirstHearing) + public CreateVideoHearingCommand(CreateVideoHearingRequiredDto requiredDto, + CreateVideoHearingOptionalDto optionalDto) { - CaseType = caseType; - HearingType = hearingType; - ScheduledDateTime = scheduledDateTime; - ScheduledDuration = scheduledDuration; - Venue = venue; - Participants = participants; - Cases = cases; - QuestionnaireNotRequired = questionnaireNotRequired; - AudioRecordingRequired = audioRecordingRequired; - Endpoints = endpoints; - LinkedParticipants = linkedParticipants; - IsMultiDayFirstHearing = isMultiDayFirstHearing; + CaseType = requiredDto.CaseType; + HearingType = requiredDto.HearingType; + ScheduledDateTime = requiredDto.ScheduledDateTime; + ScheduledDuration = requiredDto.ScheduledDuration; + Venue = requiredDto.Venue; + Cases = requiredDto.Cases; + + Participants = optionalDto.Participants ?? new List(); + HearingRoomName = optionalDto.HearingRoomName; + OtherInformation = optionalDto.OtherInformation; + CreatedBy = optionalDto.CreatedBy; + + AudioRecordingRequired = optionalDto.AudioRecordingRequired; + Endpoints = optionalDto.Endpoints; + CancelReason = optionalDto.CancelReason; + + LinkedParticipants = optionalDto.LinkedParticipants ?? new List(); + JudiciaryParticipants = optionalDto.JudiciaryParticipants ?? new List(); + IsMultiDayFirstHearing = optionalDto.IsMultiDayFirstHearing; + + SourceId = optionalDto.SourceId; } public Guid NewHearingId { get; set; } @@ -33,16 +40,15 @@ public CreateVideoHearingCommand(CaseType caseType, HearingType hearingType, Dat public HearingVenue Venue { get; } public List Participants { get; } public List Cases { get; } - public string HearingRoomName { get; set; } - public string OtherInformation { get; set; } - public string CreatedBy { get; set; } - public bool QuestionnaireNotRequired { get; set; } - public bool AudioRecordingRequired { get; set; } + public string HearingRoomName { get; } + public string OtherInformation { get; } + public string CreatedBy { get; } + public bool AudioRecordingRequired { get; } public List Endpoints { get; } - public string CancelReason { get; set; } - public Guid? SourceId { get; set; } + public string CancelReason { get; } + public Guid? SourceId { get; } public List LinkedParticipants { get; } - public List JudiciaryParticipants { get; set; } = new(); + public List JudiciaryParticipants { get; } public bool IsMultiDayFirstHearing { get; } } @@ -61,8 +67,7 @@ public async Task Handle(CreateVideoHearingCommand command) { var videoHearing = new VideoHearing(command.CaseType, command.HearingType, command.ScheduledDateTime, command.ScheduledDuration, command.Venue, command.HearingRoomName, - command.OtherInformation, command.CreatedBy, command.QuestionnaireNotRequired, - command.AudioRecordingRequired, command.CancelReason); + command.OtherInformation, command.CreatedBy, command.AudioRecordingRequired, command.CancelReason); // Ideally, the domain object would implement the clone method and so this change is a work around. videoHearing.IsFirstDayOfMultiDayHearing = command.IsMultiDayFirstHearing; diff --git a/BookingsApi/BookingsApi.DAL/Commands/RemoveHearingCommand.cs b/BookingsApi/BookingsApi.DAL/Commands/RemoveHearingCommand.cs index 38e483a78..6fc89ca9a 100644 --- a/BookingsApi/BookingsApi.DAL/Commands/RemoveHearingCommand.cs +++ b/BookingsApi/BookingsApi.DAL/Commands/RemoveHearingCommand.cs @@ -24,8 +24,7 @@ public async Task Handle(RemoveHearingCommand command) var hearingsIncCloned = await _context.VideoHearings .Include(x => x.HearingCases).ThenInclude(x => x.Case) .Include(x => x.Participants).ThenInclude(x => x.Person).ThenInclude(x => x.Organisation) - .Include(x => x.Participants).ThenInclude(x => x.LinkedParticipants)//.ThenInclude(x => x.Participant) - .Include(x => x.Participants).ThenInclude(x => x.Questionnaire).ThenInclude(x => x.SuitabilityAnswers) + .Include(x => x.Participants).ThenInclude(x => x.LinkedParticipants) .Include(x => x.Endpoints).ThenInclude(x => x.DefenceAdvocate) .Include(x=> x.JudiciaryParticipants).ThenInclude(x=> x.JudiciaryPerson) .Where(x => x.Id == command.HearingId || x.SourceId == command.HearingId).ToListAsync(); diff --git a/BookingsApi/BookingsApi.DAL/Commands/UpdateHearingCommand.cs b/BookingsApi/BookingsApi.DAL/Commands/UpdateHearingCommand.cs index e0fbbe056..d5d0e8cfa 100644 --- a/BookingsApi/BookingsApi.DAL/Commands/UpdateHearingCommand.cs +++ b/BookingsApi/BookingsApi.DAL/Commands/UpdateHearingCommand.cs @@ -12,12 +12,11 @@ public class UpdateHearingCommand : ICommand public string OtherInformation { get; set; } public string UpdatedBy { get; set; } public List Cases { get; set; } - public bool QuestionnaireNotRequired { get; set; } public bool AudioRecordingRequired { get; set; } public UpdateHearingCommand(Guid hearingId, DateTime scheduledDateTime, int scheduledDuration, HearingVenue hearingVenue, string hearingRoomName, string otherInformation, string updatedBy, - List cases, bool questionnaireNotRequired, bool audioRecordingRequired) + List cases, bool audioRecordingRequired) { HearingId = hearingId; ScheduledDateTime = scheduledDateTime; @@ -27,7 +26,6 @@ public UpdateHearingCommand(Guid hearingId, DateTime scheduledDateTime, int sche OtherInformation = otherInformation; UpdatedBy = updatedBy; Cases = cases; - QuestionnaireNotRequired = questionnaireNotRequired; AudioRecordingRequired = audioRecordingRequired; } } @@ -60,7 +58,7 @@ public async Task Handle(UpdateHearingCommand command) hearing.UpdateHearingDetails(command.HearingVenue, command.ScheduledDateTime, command.ScheduledDuration, command.HearingRoomName, command.OtherInformation, - command.UpdatedBy, command.Cases, command.QuestionnaireNotRequired, command.AudioRecordingRequired); + command.UpdatedBy, command.Cases, command.AudioRecordingRequired); if (command.ScheduledDateTime != oldScheduledDateTime) { diff --git a/BookingsApi/BookingsApi.DAL/Commands/UpdateSuitabilityAnswersCommand.cs b/BookingsApi/BookingsApi.DAL/Commands/UpdateSuitabilityAnswersCommand.cs deleted file mode 100644 index 83f7c0626..000000000 --- a/BookingsApi/BookingsApi.DAL/Commands/UpdateSuitabilityAnswersCommand.cs +++ /dev/null @@ -1,57 +0,0 @@ -namespace BookingsApi.DAL.Commands -{ - public class UpdateSuitabilityAnswersCommand : ICommand - { - public Guid ParticipantId { get; set; } - public Guid HearingId { get; set; } - public IList SuitabilityAnswers { get; set; } - public UpdateSuitabilityAnswersCommand(Guid hearingId, Guid participantId, IList suitabilityAnswers) - { - ParticipantId = participantId; - HearingId = hearingId; - SuitabilityAnswers = suitabilityAnswers; - } - } - - public class UpdateSuitabilityAnswersCommandHandler : ICommandHandler - { - private readonly BookingsDbContext _context; - - public UpdateSuitabilityAnswersCommandHandler(BookingsDbContext context) - { - _context = context; - } - - public async Task Handle(UpdateSuitabilityAnswersCommand command) - { - var hearing = await _context.VideoHearings - .Include("Participants.Person") - .Include("Participants.Questionnaire") - .Include("Participants.Questionnaire.SuitabilityAnswers") - .SingleOrDefaultAsync(x => x.Id == command.HearingId); - - if (hearing == null) - { - throw new HearingNotFoundException(command.HearingId); - } - - var participant = hearing.Participants.FirstOrDefault(p => p.Id == command.ParticipantId); - if (participant == null) - { - throw new ParticipantNotFoundException(command.ParticipantId); - } - - if (participant.Questionnaire == null) - { - participant.Questionnaire = new Questionnaire - { - Participant = participant, - ParticipantId = participant.Id - }; - } - - participant.Questionnaire.AddSuitabilityAnswers(command.SuitabilityAnswers); - await _context.SaveChangesAsync(); - } - } -} diff --git a/BookingsApi/BookingsApi.DAL/Dtos/CreateVideoHearingDto.cs b/BookingsApi/BookingsApi.DAL/Dtos/CreateVideoHearingDto.cs new file mode 100644 index 000000000..eed841ebb --- /dev/null +++ b/BookingsApi/BookingsApi.DAL/Dtos/CreateVideoHearingDto.cs @@ -0,0 +1,11 @@ +using BookingsApi.DAL.Commands; + +namespace BookingsApi.DAL.Dtos; + +public record CreateVideoHearingRequiredDto(CaseType CaseType, HearingType HearingType, DateTime ScheduledDateTime, + int ScheduledDuration, HearingVenue Venue, List Cases); + +public record CreateVideoHearingOptionalDto(List Participants, string HearingRoomName, + string OtherInformation, string CreatedBy, bool AudioRecordingRequired, List Endpoints, + string CancelReason, List LinkedParticipants, + List JudiciaryParticipants, bool IsMultiDayFirstHearing, Guid? SourceId); \ No newline at end of file diff --git a/BookingsApi/BookingsApi.DAL/Helper/CloneHearingToCommandMapper.cs b/BookingsApi/BookingsApi.DAL/Helper/CloneHearingToCommandMapper.cs index 9cfb30464..4b1b02c83 100644 --- a/BookingsApi/BookingsApi.DAL/Helper/CloneHearingToCommandMapper.cs +++ b/BookingsApi/BookingsApi.DAL/Helper/CloneHearingToCommandMapper.cs @@ -51,15 +51,11 @@ public static CreateVideoHearingCommand CloneToCommand(Hearing hearing, DateTime var linkedParticipantDtos = GetLinkedParticipantDtos(hearing); var duration = 480; - var command = new CreateVideoHearingCommand(hearing.CaseType, hearing.HearingType, newDate, - duration, hearing.HearingVenue, participants, cases, true, - hearing.AudioRecordingRequired, newEndpoints, linkedParticipantDtos, false) - { - HearingRoomName = hearing.HearingRoomName, - OtherInformation = hearing.OtherInformation, - CreatedBy = hearing.CreatedBy, - SourceId = hearing.Id - }; + var command = new CreateVideoHearingCommand(new CreateVideoHearingRequiredDto( + hearing.CaseType, hearing.HearingType, newDate, duration, hearing.HearingVenue, cases), + new CreateVideoHearingOptionalDto(participants, hearing.HearingRoomName, hearing.OtherInformation, + hearing.CreatedBy, hearing.AudioRecordingRequired, newEndpoints, null, linkedParticipantDtos, + new List(), false, hearing.Id)); return command; } @@ -73,7 +69,7 @@ private static List GetNewEndpointsDtos(Hearing hearing, IRandomGen do { sip = randomGenerator.GetWeakDeterministic(DateTime.UtcNow.Ticks, 1, 10); - } while (newEndpoints.Any(x => x.Sip.StartsWith(sip))); + } while (newEndpoints.Exists(x => x.Sip.StartsWith(sip))); var pin = randomGenerator.GetWeakDeterministic(DateTime.UtcNow.Ticks, 1, 4); var newEndpoint = new NewEndpoint { diff --git a/BookingsApi/BookingsApi.DAL/Mappings/HearingMap.cs b/BookingsApi/BookingsApi.DAL/Mappings/HearingMap.cs index a3eb85403..94f639f9e 100644 --- a/BookingsApi/BookingsApi.DAL/Mappings/HearingMap.cs +++ b/BookingsApi/BookingsApi.DAL/Mappings/HearingMap.cs @@ -22,7 +22,7 @@ public void Configure(EntityTypeBuilder builder) builder.Property(x => x.CreatedDate).HasConversion(v => v, v => DateTime.SpecifyKind(v, DateTimeKind.Utc)); builder.Property(x => x.UpdatedDate).HasConversion(v => v, v => DateTime.SpecifyKind(v, DateTimeKind.Utc)); builder.Property(x => x.Status).HasColumnName("HearingStatusId"); - builder.Property(x => x.QuestionnaireNotRequired); + builder.Property("QuestionnaireNotRequired").HasDefaultValue(false); builder.Property(x => x.CancelReason).HasMaxLength(255); builder.Property(x => x.SourceId); builder.Ignore(x => x.IsFirstDayOfMultiDayHearing); diff --git a/BookingsApi/BookingsApi.DAL/Migrations/20230911145745_DefaultQuestionnairRequiredToFalse.Designer.cs b/BookingsApi/BookingsApi.DAL/Migrations/20230911145745_DefaultQuestionnairRequiredToFalse.Designer.cs new file mode 100644 index 000000000..340b0933c --- /dev/null +++ b/BookingsApi/BookingsApi.DAL/Migrations/20230911145745_DefaultQuestionnairRequiredToFalse.Designer.cs @@ -0,0 +1,1385 @@ +// +using System; +using BookingsApi.DAL; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace BookingsApi.DAL.Migrations +{ + [DbContext(typeof(BookingsDbContext))] + [Migration("20230911145745_DefaultQuestionnairRequiredToFalse")] + partial class DefaultQuestionnairRequiredToFalse + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.9") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("BookingsApi.Domain.Allocation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("EffortSpent") + .HasColumnType("int"); + + b.Property("HearingId") + .HasColumnType("uniqueidentifier"); + + b.Property("JusticeUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdatedDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("HearingId"); + + b.HasIndex("JusticeUserId", "HearingId") + .IsUnique(); + + b.ToTable("Allocation", (string)null); + }); + + modelBuilder.Entity("BookingsApi.Domain.Case", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("IsLeadCase") + .HasColumnType("bit"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("Number") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("Case", (string)null); + }); + + modelBuilder.Entity("BookingsApi.Domain.DayOfWeek", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Day") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("Day") + .IsUnique() + .HasFilter("[Day] IS NOT NULL"); + + b.ToTable("DayOfWeek", (string)null); + }); + + modelBuilder.Entity("BookingsApi.Domain.Endpoint", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("DefenceAdvocateId") + .HasColumnType("uniqueidentifier"); + + b.Property("DisplayName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("HearingId") + .HasColumnType("uniqueidentifier"); + + b.Property("Pin") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Sip") + .HasColumnType("nvarchar(450)"); + + b.Property("UpdatedDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("DefenceAdvocateId"); + + b.HasIndex("HearingId"); + + b.HasIndex("Sip") + .IsUnique() + .HasFilter("[Sip] IS NOT NULL"); + + b.ToTable("Endpoint", (string)null); + }); + + modelBuilder.Entity("BookingsApi.Domain.Hearing", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("AudioRecordingRequired") + .HasColumnType("bit"); + + b.Property("CancelReason") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("CaseTypeId") + .HasColumnType("int"); + + b.Property("ConfirmedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("ConfirmedDate") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("HearingMediumType") + .HasColumnType("int") + .HasColumnName("HearingMediumId"); + + b.Property("HearingRoomName") + .HasColumnType("nvarchar(max)"); + + b.Property("HearingTypeId") + .HasColumnType("int"); + + b.Property("HearingVenueName") + .HasColumnType("nvarchar(450)"); + + b.Property("OtherInformation") + .HasColumnType("nvarchar(max)"); + + b.Property("QuestionnaireNotRequired") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); + + b.Property("ScheduledDateTime") + .HasColumnType("datetime2"); + + b.Property("ScheduledDuration") + .HasColumnType("int"); + + b.Property("SourceId") + .HasColumnType("uniqueidentifier"); + + b.Property("Status") + .HasColumnType("int") + .HasColumnName("HearingStatusId"); + + b.Property("UpdatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("CaseTypeId"); + + b.HasIndex("HearingTypeId"); + + b.HasIndex("HearingVenueName"); + + b.ToTable("Hearing", (string)null); + + b.HasDiscriminator("HearingMediumType"); + }); + + modelBuilder.Entity("BookingsApi.Domain.HearingCase", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CaseId") + .HasColumnType("bigint"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("HearingId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdatedDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("HearingId"); + + b.HasIndex("CaseId", "HearingId") + .IsUnique(); + + b.ToTable("HearingCase", (string)null); + }); + + modelBuilder.Entity("BookingsApi.Domain.HearingVenue", b => + { + b.Property("Name") + .HasColumnType("nvarchar(450)"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("ExpirationDate") + .HasColumnType("datetime2"); + + b.Property("Id") + .HasColumnType("int"); + + b.Property("IsScottish") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); + + b.Property("IsWorkAllocationEnabled") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("UpdatedDate") + .HasColumnType("datetime2"); + + b.Property("VenueCode") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Name"); + + b.HasIndex("VenueCode") + .IsUnique() + .HasFilter("[VenueCode] IS NOT NULL"); + + b.ToTable("HearingVenue", (string)null); + }); + + modelBuilder.Entity("BookingsApi.Domain.JobHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("IsSuccessful") + .HasColumnType("bit"); + + b.Property("JobName") + .HasColumnType("nvarchar(max)"); + + b.Property("LastRunDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("JobHistory", (string)null); + }); + + modelBuilder.Entity("BookingsApi.Domain.JudiciaryParticipant", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("DisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("HearingId") + .HasColumnType("uniqueidentifier"); + + b.Property("HearingRoleCode") + .HasColumnType("int"); + + b.Property("JudiciaryPersonId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdatedDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("HearingId"); + + b.HasIndex("JudiciaryPersonId"); + + b.ToTable("JudiciaryParticipant"); + }); + + modelBuilder.Entity("BookingsApi.Domain.JudiciaryPerson", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("ExternalRefId") + .HasColumnType("nvarchar(450)"); + + b.Property("Fullname") + .HasColumnType("nvarchar(max)"); + + b.Property("HasLeft") + .HasColumnType("bit"); + + b.Property("KnownAs") + .HasColumnType("nvarchar(max)"); + + b.Property("Leaver") + .HasColumnType("bit"); + + b.Property("LeftOn") + .HasColumnType("nvarchar(max)"); + + b.Property("PersonalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("PostNominals") + .HasColumnType("nvarchar(max)"); + + b.Property("Surname") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("ExternalRefId") + .IsUnique() + .HasFilter("[ExternalRefId] IS NOT NULL"); + + b.ToTable("JudiciaryPerson", (string)null); + }); + + modelBuilder.Entity("BookingsApi.Domain.JudiciaryPersonStaging", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("Email") + .HasColumnType("nvarchar(max)"); + + b.Property("ExternalRefId") + .HasColumnType("nvarchar(max)"); + + b.Property("Fullname") + .HasColumnType("nvarchar(max)"); + + b.Property("KnownAs") + .HasColumnType("nvarchar(max)"); + + b.Property("Leaver") + .HasColumnType("nvarchar(max)"); + + b.Property("LeftOn") + .HasColumnType("nvarchar(max)"); + + b.Property("PersonalCode") + .HasColumnType("nvarchar(max)"); + + b.Property("PostNominals") + .HasColumnType("nvarchar(max)"); + + b.Property("Surname") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("JudiciaryPersonsStaging"); + }); + + modelBuilder.Entity("BookingsApi.Domain.Jurisdiction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Code") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("IsLive") + .HasColumnType("bit"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("Jurisdiction"); + }); + + modelBuilder.Entity("BookingsApi.Domain.JusticeUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ContactEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("Deleted") + .HasColumnType("bit"); + + b.Property("FirstName") + .HasColumnType("nvarchar(max)"); + + b.Property("Lastname") + .HasColumnType("nvarchar(max)"); + + b.Property("Telephone") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedDate") + .HasColumnType("datetime2"); + + b.Property("UserRoleId") + .HasColumnType("int"); + + b.Property("Username") + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("Username") + .IsUnique() + .HasFilter("[Username] IS NOT NULL"); + + b.ToTable("JusticeUser", (string)null); + }); + + modelBuilder.Entity("BookingsApi.Domain.JusticeUserRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("JusticeUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdatedDate") + .HasColumnType("datetime2"); + + b.Property("UserRoleId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("JusticeUserId"); + + b.HasIndex("UserRoleId"); + + b.ToTable("JusticeUserRoles", (string)null); + }); + + modelBuilder.Entity("BookingsApi.Domain.LinkedParticipant", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("LinkedId") + .HasColumnType("uniqueidentifier"); + + b.Property("ParticipantId") + .HasColumnType("uniqueidentifier"); + + b.Property("Type") + .HasColumnType("int"); + + b.Property("UpdatedDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("LinkedId"); + + b.HasIndex("ParticipantId"); + + b.ToTable("LinkedParticipant", (string)null); + }); + + modelBuilder.Entity("BookingsApi.Domain.Organisation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("Organisation", (string)null); + }); + + modelBuilder.Entity("BookingsApi.Domain.Participants.Participant", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CaseRoleId") + .HasColumnType("int"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("Discriminator") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("HearingId") + .HasColumnType("uniqueidentifier"); + + b.Property("HearingRoleId") + .HasColumnType("int"); + + b.Property("PersonId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("CaseRoleId"); + + b.HasIndex("HearingId"); + + b.HasIndex("HearingRoleId"); + + b.HasIndex("PersonId", "HearingId") + .IsUnique(); + + b.ToTable("Participant", (string)null); + + b.HasDiscriminator("Discriminator").HasValue("Participant"); + }); + + modelBuilder.Entity("BookingsApi.Domain.Person", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("ContactEmail") + .HasColumnType("nvarchar(450)"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("FirstName") + .HasColumnType("nvarchar(max)"); + + b.Property("LastName") + .HasColumnType("nvarchar(max)"); + + b.Property("MiddleNames") + .HasColumnType("nvarchar(max)"); + + b.Property("OrganisationId") + .HasColumnType("bigint"); + + b.Property("TelephoneNumber") + .HasColumnType("nvarchar(max)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedDate") + .HasColumnType("datetime2"); + + b.Property("Username") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("ContactEmail") + .IsUnique() + .HasFilter("[ContactEmail] IS NOT NULL"); + + b.HasIndex("OrganisationId"); + + b.HasIndex("Username") + .IsUnique() + .HasFilter("[Username] IS NOT NULL"); + + b.ToTable("Person", (string)null); + }); + + modelBuilder.Entity("BookingsApi.Domain.Questionnaire", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ParticipantId") + .HasColumnType("uniqueidentifier"); + + b.Property("UpdatedDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("ParticipantId"); + + b.ToTable("Questionnaire", (string)null); + }); + + modelBuilder.Entity("BookingsApi.Domain.RefData.CaseRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CaseTypeId") + .HasColumnType("int"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("Group") + .HasColumnType("int"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("CaseTypeId"); + + b.ToTable("CaseRole", (string)null); + }); + + modelBuilder.Entity("BookingsApi.Domain.RefData.CaseType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("ExpirationDate") + .HasColumnType("datetime2"); + + b.Property("JurisdictionId") + .HasColumnType("int"); + + b.Property("Live") + .HasColumnType("bit"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("ServiceId") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("JurisdictionId"); + + b.ToTable("CaseType", (string)null); + }); + + modelBuilder.Entity("BookingsApi.Domain.RefData.HearingRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CaseRoleId") + .HasColumnType("int"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("Live") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedDate") + .HasColumnType("datetime2"); + + b.Property("UserRoleId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CaseRoleId"); + + b.HasIndex("UserRoleId"); + + b.ToTable("HearingRole", (string)null); + }); + + modelBuilder.Entity("BookingsApi.Domain.RefData.HearingType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CaseTypeId") + .HasColumnType("int"); + + b.Property("Code") + .HasColumnType("nvarchar(450)"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("ExpirationDate") + .HasColumnType("datetime2"); + + b.Property("Live") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedDate") + .HasColumnType("datetime2"); + + b.Property("WelshName") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CaseTypeId"); + + b.HasIndex("Code") + .IsUnique() + .HasFilter("[Code] IS NOT NULL"); + + b.ToTable("HearingType", (string)null); + }); + + modelBuilder.Entity("BookingsApi.Domain.RefData.UserRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("Name") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.ToTable("UserRole", (string)null); + }); + + modelBuilder.Entity("BookingsApi.Domain.SuitabilityAnswer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Data") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ExtendedData") + .HasColumnType("nvarchar(max)"); + + b.Property("Key") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("QuestionnaireId") + .HasColumnType("bigint"); + + b.Property("UpdatedDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("QuestionnaireId"); + + b.ToTable("SuitabilityAnswer", (string)null); + }); + + modelBuilder.Entity("BookingsApi.Domain.VhoNonAvailability", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("Deleted") + .HasColumnType("bit"); + + b.Property("EndTime") + .HasColumnType("datetime2"); + + b.Property("JusticeUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("StartTime") + .HasColumnType("datetime2"); + + b.Property("UpdatedDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("JusticeUserId"); + + b.ToTable("VhoNonAvailability", (string)null); + }); + + modelBuilder.Entity("BookingsApi.Domain.VhoWorkHours", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedDate") + .HasColumnType("datetime2"); + + b.Property("DayOfWeekId") + .HasColumnType("int"); + + b.Property("Deleted") + .HasColumnType("bit"); + + b.Property("EndTime") + .HasColumnType("time"); + + b.Property("JusticeUserId") + .HasColumnType("uniqueidentifier"); + + b.Property("StartTime") + .HasColumnType("time"); + + b.Property("UpdatedDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("DayOfWeekId"); + + b.HasIndex("JusticeUserId"); + + b.ToTable("VhoWorkHours", (string)null); + }); + + modelBuilder.Entity("BookingsApi.Domain.Participants.Individual", b => + { + b.HasBaseType("BookingsApi.Domain.Participants.Participant"); + + b.HasDiscriminator().HasValue("Individual"); + }); + + modelBuilder.Entity("BookingsApi.Domain.Participants.Judge", b => + { + b.HasBaseType("BookingsApi.Domain.Participants.Participant"); + + b.HasDiscriminator().HasValue("Judge"); + }); + + modelBuilder.Entity("BookingsApi.Domain.Participants.JudicialOfficeHolder", b => + { + b.HasBaseType("BookingsApi.Domain.Participants.Participant"); + + b.HasDiscriminator().HasValue("JudicialOfficeHolder"); + }); + + modelBuilder.Entity("BookingsApi.Domain.Participants.Representative", b => + { + b.HasBaseType("BookingsApi.Domain.Participants.Participant"); + + b.Property("Representee") + .HasColumnType("nvarchar(max)"); + + b.HasDiscriminator().HasValue("Representative"); + }); + + modelBuilder.Entity("BookingsApi.Domain.Participants.StaffMember", b => + { + b.HasBaseType("BookingsApi.Domain.Participants.Participant"); + + b.HasDiscriminator().HasValue("StaffMember"); + }); + + modelBuilder.Entity("BookingsApi.Domain.VideoHearing", b => + { + b.HasBaseType("BookingsApi.Domain.Hearing"); + + b.HasDiscriminator().HasValue(1); + }); + + modelBuilder.Entity("BookingsApi.Domain.Allocation", b => + { + b.HasOne("BookingsApi.Domain.Hearing", "Hearing") + .WithMany("Allocations") + .HasForeignKey("HearingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BookingsApi.Domain.JusticeUser", "JusticeUser") + .WithMany("Allocations") + .HasForeignKey("JusticeUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Hearing"); + + b.Navigation("JusticeUser"); + }); + + modelBuilder.Entity("BookingsApi.Domain.Endpoint", b => + { + b.HasOne("BookingsApi.Domain.Participants.Participant", "DefenceAdvocate") + .WithMany() + .HasForeignKey("DefenceAdvocateId"); + + b.HasOne("BookingsApi.Domain.Hearing", "Hearing") + .WithMany("Endpoints") + .HasForeignKey("HearingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DefenceAdvocate"); + + b.Navigation("Hearing"); + }); + + modelBuilder.Entity("BookingsApi.Domain.Hearing", b => + { + b.HasOne("BookingsApi.Domain.RefData.CaseType", "CaseType") + .WithMany() + .HasForeignKey("CaseTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BookingsApi.Domain.RefData.HearingType", "HearingType") + .WithMany() + .HasForeignKey("HearingTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BookingsApi.Domain.HearingVenue", "HearingVenue") + .WithMany() + .HasForeignKey("HearingVenueName"); + + b.Navigation("CaseType"); + + b.Navigation("HearingType"); + + b.Navigation("HearingVenue"); + }); + + modelBuilder.Entity("BookingsApi.Domain.HearingCase", b => + { + b.HasOne("BookingsApi.Domain.Case", "Case") + .WithMany("HearingCases") + .HasForeignKey("CaseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BookingsApi.Domain.Hearing", "Hearing") + .WithMany("HearingCases") + .HasForeignKey("HearingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Case"); + + b.Navigation("Hearing"); + }); + + modelBuilder.Entity("BookingsApi.Domain.JudiciaryParticipant", b => + { + b.HasOne("BookingsApi.Domain.Hearing", "Hearing") + .WithMany("JudiciaryParticipants") + .HasForeignKey("HearingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BookingsApi.Domain.JudiciaryPerson", "JudiciaryPerson") + .WithMany() + .HasForeignKey("JudiciaryPersonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Hearing"); + + b.Navigation("JudiciaryPerson"); + }); + + modelBuilder.Entity("BookingsApi.Domain.JusticeUserRole", b => + { + b.HasOne("BookingsApi.Domain.JusticeUser", "JusticeUser") + .WithMany("JusticeUserRoles") + .HasForeignKey("JusticeUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BookingsApi.Domain.RefData.UserRole", "UserRole") + .WithMany("JusticeUserRoles") + .HasForeignKey("UserRoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("JusticeUser"); + + b.Navigation("UserRole"); + }); + + modelBuilder.Entity("BookingsApi.Domain.LinkedParticipant", b => + { + b.HasOne("BookingsApi.Domain.Participants.Participant", "Linked") + .WithMany() + .HasForeignKey("LinkedId") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + + b.HasOne("BookingsApi.Domain.Participants.Participant", "Participant") + .WithMany("LinkedParticipants") + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.ClientCascade) + .IsRequired(); + + b.Navigation("Linked"); + + b.Navigation("Participant"); + }); + + modelBuilder.Entity("BookingsApi.Domain.Participants.Participant", b => + { + b.HasOne("BookingsApi.Domain.RefData.CaseRole", "CaseRole") + .WithMany() + .HasForeignKey("CaseRoleId"); + + b.HasOne("BookingsApi.Domain.Hearing", "Hearing") + .WithMany("Participants") + .HasForeignKey("HearingId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BookingsApi.Domain.RefData.HearingRole", "HearingRole") + .WithMany() + .HasForeignKey("HearingRoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BookingsApi.Domain.Person", "Person") + .WithMany() + .HasForeignKey("PersonId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CaseRole"); + + b.Navigation("Hearing"); + + b.Navigation("HearingRole"); + + b.Navigation("Person"); + }); + + modelBuilder.Entity("BookingsApi.Domain.Person", b => + { + b.HasOne("BookingsApi.Domain.Organisation", "Organisation") + .WithMany() + .HasForeignKey("OrganisationId"); + + b.Navigation("Organisation"); + }); + + modelBuilder.Entity("BookingsApi.Domain.Questionnaire", b => + { + b.HasOne("BookingsApi.Domain.Participants.Participant", "Participant") + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Participant"); + }); + + modelBuilder.Entity("BookingsApi.Domain.RefData.CaseRole", b => + { + b.HasOne("BookingsApi.Domain.RefData.CaseType", null) + .WithMany("CaseRoles") + .HasForeignKey("CaseTypeId"); + }); + + modelBuilder.Entity("BookingsApi.Domain.RefData.CaseType", b => + { + b.HasOne("BookingsApi.Domain.Jurisdiction", null) + .WithMany("CaseTypes") + .HasForeignKey("JurisdictionId"); + }); + + modelBuilder.Entity("BookingsApi.Domain.RefData.HearingRole", b => + { + b.HasOne("BookingsApi.Domain.RefData.CaseRole", null) + .WithMany("HearingRoles") + .HasForeignKey("CaseRoleId"); + + b.HasOne("BookingsApi.Domain.RefData.UserRole", "UserRole") + .WithMany() + .HasForeignKey("UserRoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("UserRole"); + }); + + modelBuilder.Entity("BookingsApi.Domain.RefData.HearingType", b => + { + b.HasOne("BookingsApi.Domain.RefData.CaseType", null) + .WithMany("HearingTypes") + .HasForeignKey("CaseTypeId"); + }); + + modelBuilder.Entity("BookingsApi.Domain.SuitabilityAnswer", b => + { + b.HasOne("BookingsApi.Domain.Questionnaire", "Questionnaire") + .WithMany("SuitabilityAnswers") + .HasForeignKey("QuestionnaireId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Questionnaire"); + }); + + modelBuilder.Entity("BookingsApi.Domain.VhoNonAvailability", b => + { + b.HasOne("BookingsApi.Domain.JusticeUser", "JusticeUser") + .WithMany("VhoNonAvailability") + .HasForeignKey("JusticeUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("JusticeUser"); + }); + + modelBuilder.Entity("BookingsApi.Domain.VhoWorkHours", b => + { + b.HasOne("BookingsApi.Domain.DayOfWeek", "DayOfWeek") + .WithMany() + .HasForeignKey("DayOfWeekId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("BookingsApi.Domain.JusticeUser", "JusticeUser") + .WithMany("VhoWorkHours") + .HasForeignKey("JusticeUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DayOfWeek"); + + b.Navigation("JusticeUser"); + }); + + modelBuilder.Entity("BookingsApi.Domain.Case", b => + { + b.Navigation("HearingCases"); + }); + + modelBuilder.Entity("BookingsApi.Domain.Hearing", b => + { + b.Navigation("Allocations"); + + b.Navigation("Endpoints"); + + b.Navigation("HearingCases"); + + b.Navigation("JudiciaryParticipants"); + + b.Navigation("Participants"); + }); + + modelBuilder.Entity("BookingsApi.Domain.Jurisdiction", b => + { + b.Navigation("CaseTypes"); + }); + + modelBuilder.Entity("BookingsApi.Domain.JusticeUser", b => + { + b.Navigation("Allocations"); + + b.Navigation("JusticeUserRoles"); + + b.Navigation("VhoNonAvailability"); + + b.Navigation("VhoWorkHours"); + }); + + modelBuilder.Entity("BookingsApi.Domain.Participants.Participant", b => + { + b.Navigation("LinkedParticipants"); + }); + + modelBuilder.Entity("BookingsApi.Domain.Questionnaire", b => + { + b.Navigation("SuitabilityAnswers"); + }); + + modelBuilder.Entity("BookingsApi.Domain.RefData.CaseRole", b => + { + b.Navigation("HearingRoles"); + }); + + modelBuilder.Entity("BookingsApi.Domain.RefData.CaseType", b => + { + b.Navigation("CaseRoles"); + + b.Navigation("HearingTypes"); + }); + + modelBuilder.Entity("BookingsApi.Domain.RefData.UserRole", b => + { + b.Navigation("JusticeUserRoles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/BookingsApi/BookingsApi.DAL/Migrations/20230911145745_DefaultQuestionnairRequiredToFalse.cs b/BookingsApi/BookingsApi.DAL/Migrations/20230911145745_DefaultQuestionnairRequiredToFalse.cs new file mode 100644 index 000000000..8e21835b7 --- /dev/null +++ b/BookingsApi/BookingsApi.DAL/Migrations/20230911145745_DefaultQuestionnairRequiredToFalse.cs @@ -0,0 +1,52 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace BookingsApi.DAL.Migrations +{ + public partial class DefaultQuestionnairRequiredToFalse : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_Questionnaire_ParticipantId", + table: "Questionnaire"); + + migrationBuilder.AlterColumn( + name: "QuestionnaireNotRequired", + table: "Hearing", + type: "bit", + nullable: false, + defaultValue: false, + oldClrType: typeof(bool), + oldType: "bit"); + + migrationBuilder.CreateIndex( + name: "IX_Questionnaire_ParticipantId", + table: "Questionnaire", + column: "ParticipantId"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_Questionnaire_ParticipantId", + table: "Questionnaire"); + + migrationBuilder.AlterColumn( + name: "QuestionnaireNotRequired", + table: "Hearing", + type: "bit", + nullable: false, + oldClrType: typeof(bool), + oldType: "bit", + oldDefaultValue: false); + + migrationBuilder.CreateIndex( + name: "IX_Questionnaire_ParticipantId", + table: "Questionnaire", + column: "ParticipantId", + unique: true); + } + } +} diff --git a/BookingsApi/BookingsApi.DAL/Migrations/BookingsDbContextModelSnapshot.cs b/BookingsApi/BookingsApi.DAL/Migrations/BookingsDbContextModelSnapshot.cs index 6d67a11d7..95211000a 100644 --- a/BookingsApi/BookingsApi.DAL/Migrations/BookingsDbContextModelSnapshot.cs +++ b/BookingsApi/BookingsApi.DAL/Migrations/BookingsDbContextModelSnapshot.cs @@ -192,7 +192,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("nvarchar(max)"); b.Property("QuestionnaireNotRequired") - .HasColumnType("bit"); + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); b.Property("ScheduledDateTime") .HasColumnType("datetime2"); @@ -719,8 +721,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); - b.HasIndex("ParticipantId") - .IsUnique(); + b.HasIndex("ParticipantId"); b.ToTable("Questionnaire", (string)null); }); @@ -1231,8 +1232,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("BookingsApi.Domain.Questionnaire", b => { b.HasOne("BookingsApi.Domain.Participants.Participant", "Participant") - .WithOne("Questionnaire") - .HasForeignKey("BookingsApi.Domain.Questionnaire", "ParticipantId") + .WithMany() + .HasForeignKey("ParticipantId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -1353,8 +1354,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("BookingsApi.Domain.Participants.Participant", b => { b.Navigation("LinkedParticipants"); - - b.Navigation("Questionnaire"); }); modelBuilder.Entity("BookingsApi.Domain.Questionnaire", b => diff --git a/BookingsApi/BookingsApi.DAL/Queries/BaseQueries/VideoHearings.cs b/BookingsApi/BookingsApi.DAL/Queries/BaseQueries/VideoHearings.cs index 35a892f55..b5c12de88 100644 --- a/BookingsApi/BookingsApi.DAL/Queries/BaseQueries/VideoHearings.cs +++ b/BookingsApi/BookingsApi.DAL/Queries/BaseQueries/VideoHearings.cs @@ -9,7 +9,6 @@ public static IQueryable Get(BookingsDbContext context) .Include(x => x.Participants).ThenInclude(x => x.CaseRole) .Include(x => x.Participants).ThenInclude(x => x.HearingRole).ThenInclude(x => x.UserRole) .Include(x => x.Participants).ThenInclude(x => x.LinkedParticipants) - .Include(x=>x.Participants).ThenInclude(x=>x.Questionnaire).ThenInclude(x=> x.SuitabilityAnswers) .Include("HearingCases.Case") .Include(x => x.CaseType) .ThenInclude(x => x.CaseRoles) diff --git a/BookingsApi/BookingsApi.DAL/Queries/GetHearingByIdQuery.cs b/BookingsApi/BookingsApi.DAL/Queries/GetHearingByIdQuery.cs index 00fd2f42b..717285690 100644 --- a/BookingsApi/BookingsApi.DAL/Queries/GetHearingByIdQuery.cs +++ b/BookingsApi/BookingsApi.DAL/Queries/GetHearingByIdQuery.cs @@ -27,7 +27,6 @@ public async Task Handle(GetHearingByIdQuery query) .Include(x => x.Participants).ThenInclude(x=> x.HearingRole).ThenInclude(x => x.UserRole) .Include(x => x.Participants).ThenInclude(x => x.LinkedParticipants) .Include("HearingCases.Case") - .Include(x=>x.Participants).ThenInclude(x=>x.Questionnaire).ThenInclude(x=> x.SuitabilityAnswers) .Include(x => x.CaseType) .ThenInclude(x => x.CaseRoles) .ThenInclude(x => x.HearingRoles) diff --git a/BookingsApi/BookingsApi.DAL/Queries/GetParticipantWithSuitabilityAnswersQuery.cs b/BookingsApi/BookingsApi.DAL/Queries/GetParticipantWithSuitabilityAnswersQuery.cs deleted file mode 100644 index 2427cfbc3..000000000 --- a/BookingsApi/BookingsApi.DAL/Queries/GetParticipantWithSuitabilityAnswersQuery.cs +++ /dev/null @@ -1,83 +0,0 @@ -using BookingsApi.Domain.Participants; - -namespace BookingsApi.DAL.Queries -{ - public class GetParticipantWithSuitabilityAnswersQuery : IQuery - { - private int _limit; - - public GetParticipantWithSuitabilityAnswersQuery() - { - Limit = 100; - } - - public string Cursor { get; set; } - - public int Limit - { - get => _limit; - set - { - if (value <= 0) throw new ArgumentException("Limit must be one or more", nameof(value)); - _limit = value; - } - } - } - - public class GetParticipantWithSuitabilityAnswersQueryHandler : IQueryHandler> - { - private readonly BookingsDbContext _context; - - public GetParticipantWithSuitabilityAnswersQueryHandler(BookingsDbContext context) - { - _context = context; - } - - public async Task> Handle(GetParticipantWithSuitabilityAnswersQuery query) - { - IQueryable participants = _context.Participants - .Include("Person") - .Include("HearingRole") - .Include("Hearing.HearingCases.Case") - .Include("Questionnaire") - .Include("Questionnaire.SuitabilityAnswers"); - - participants = participants.Where(x => x.Questionnaire != null && x.Questionnaire.SuitabilityAnswers.Any()).OrderByDescending(x => x.Questionnaire.UpdatedDate).ThenBy(x => x.Id.ToString()); - if (!string.IsNullOrEmpty(query.Cursor)) - { - TryParseCursor(query.Cursor, out var updatedDateTime, out var id); - participants = participants.Where(x => x.Questionnaire.UpdatedDate <= updatedDateTime - && x.Id != Guid.Parse(id)); - } - - - // Add one to the limit to know whether or not we have a next page - var result = await participants.Take(query.Limit + 1).ToListAsync(); - string nextCursor = null; - if (result.Count > query.Limit) - { - // The next cursor should be built based on the last item in the list - result = result.Take(query.Limit).ToList(); - var lastResult = result.Last(); - nextCursor = $"{lastResult.Questionnaire.UpdatedDate.Ticks}_{lastResult.Id}"; - } - - return new CursorPagedResult(result, nextCursor); - } - - private void TryParseCursor(string cursor, out DateTime updatedDateTime, out string id) - { - try - { - var parts = cursor.Split('_'); - updatedDateTime = new DateTime(long.Parse(parts[0])); - id = parts[1]; - } - catch (Exception e) - { - throw new FormatException($"Unexpected cursor format [{cursor}]", e); - } - } - } -} diff --git a/BookingsApi/BookingsApi.Domain/Hearing.cs b/BookingsApi/BookingsApi.Domain/Hearing.cs index ce1bdaafb..c6bcd5a59 100644 --- a/BookingsApi/BookingsApi.Domain/Hearing.cs +++ b/BookingsApi/BookingsApi.Domain/Hearing.cs @@ -31,8 +31,7 @@ protected Hearing() protected Hearing(CaseType caseType, HearingType hearingType, DateTime scheduledDateTime, int scheduledDuration, HearingVenue hearingVenue, string hearingRoomName, - string otherInformation, string createdBy, bool questionnaireNotRequired, - bool audioRecordingRequired, string cancelReason) + string otherInformation, string createdBy, bool audioRecordingRequired, string cancelReason) : this() { ValidateArguments(scheduledDateTime, scheduledDuration, hearingVenue, hearingType); @@ -47,7 +46,6 @@ protected Hearing(CaseType caseType, HearingType hearingType, DateTime scheduled HearingRoomName = hearingRoomName; OtherInformation = otherInformation; CreatedBy = createdBy; - QuestionnaireNotRequired = questionnaireNotRequired; AudioRecordingRequired = audioRecordingRequired; CancelReason = cancelReason; } @@ -75,9 +73,6 @@ protected Hearing(CaseType caseType, HearingType hearingType, DateTime scheduled public virtual IList JudiciaryParticipants { get; } public string HearingRoomName { get; set; } public string OtherInformation { get; set; } - - [Obsolete("This property is no longer used and will be removed in a future release.")] - public bool QuestionnaireNotRequired { get; set; } public bool AudioRecordingRequired { get; set; } public string CancelReason { get; set; } public Guid? SourceId { get; set; } @@ -414,7 +409,7 @@ public virtual void UpdateCase(Case @case) public void UpdateHearingDetails(HearingVenue hearingVenue, DateTime scheduledDateTime, int scheduledDuration, string hearingRoomName, string otherInformation, string updatedBy, - List cases, bool questionnaireNotRequired, bool audioRecordingRequired) + List cases, bool audioRecordingRequired) { ValidateScheduledDate(scheduledDateTime); @@ -451,7 +446,6 @@ public void UpdateHearingDetails(HearingVenue hearingVenue, DateTime scheduledDa OtherInformation = otherInformation; UpdatedBy = updatedBy; UpdatedDate = DateTime.UtcNow; - QuestionnaireNotRequired = questionnaireNotRequired; AudioRecordingRequired = audioRecordingRequired; } diff --git a/BookingsApi/BookingsApi.Domain/Participants/Participant.cs b/BookingsApi/BookingsApi.Domain/Participants/Participant.cs index aeaab507a..4b603e92f 100644 --- a/BookingsApi/BookingsApi.Domain/Participants/Participant.cs +++ b/BookingsApi/BookingsApi.Domain/Participants/Participant.cs @@ -39,7 +39,6 @@ protected Participant(Person person, HearingRole hearingRole, CaseRole caseRole) public string CreatedBy { get; set; } public string UpdatedBy { get; set; } public string Discriminator { get; set; } - public virtual Questionnaire Questionnaire { get; set; } public virtual IList LinkedParticipants { get; set; } diff --git a/BookingsApi/BookingsApi.Domain/Questionnaire.cs b/BookingsApi/BookingsApi.Domain/Questionnaire.cs index e97694d7a..8f174102c 100644 --- a/BookingsApi/BookingsApi.Domain/Questionnaire.cs +++ b/BookingsApi/BookingsApi.Domain/Questionnaire.cs @@ -6,6 +6,7 @@ namespace BookingsApi.Domain { + [Obsolete("This class is no longer used.")] public class Questionnaire : Entity { public Questionnaire() diff --git a/BookingsApi/BookingsApi.Domain/SuitabilityAnswer.cs b/BookingsApi/BookingsApi.Domain/SuitabilityAnswer.cs index d70af0998..8ed6da5be 100644 --- a/BookingsApi/BookingsApi.Domain/SuitabilityAnswer.cs +++ b/BookingsApi/BookingsApi.Domain/SuitabilityAnswer.cs @@ -3,6 +3,7 @@ namespace BookingsApi.Domain { + [Obsolete("This class is no longer used.")] public class SuitabilityAnswer : Entity { public SuitabilityAnswer(string key, string data, string extendedData) diff --git a/BookingsApi/BookingsApi.Domain/VideoHearing.cs b/BookingsApi/BookingsApi.Domain/VideoHearing.cs index a36c293ff..4b9f41f88 100644 --- a/BookingsApi/BookingsApi.Domain/VideoHearing.cs +++ b/BookingsApi/BookingsApi.Domain/VideoHearing.cs @@ -7,11 +7,12 @@ namespace BookingsApi.Domain public class VideoHearing : Hearing { protected VideoHearing() { } - public VideoHearing(CaseType caseType,HearingType hearingType, DateTime scheduledDateTime, int scheduledDuration, - HearingVenue hearingVenue, string hearingRoomName, string otherInformation, string createdBy, - bool questionnaireNotRequired, bool audioRecordingRequired, string cancelReason) : - base(caseType, hearingType, scheduledDateTime, scheduledDuration, hearingVenue, hearingRoomName, - otherInformation, createdBy, questionnaireNotRequired, audioRecordingRequired, cancelReason) + + public VideoHearing(CaseType caseType, HearingType hearingType, DateTime scheduledDateTime, + int scheduledDuration, HearingVenue hearingVenue, string hearingRoomName, string otherInformation, + string createdBy, bool audioRecordingRequired, string cancelReason) : base(caseType, hearingType, + scheduledDateTime, scheduledDuration, hearingVenue, hearingRoomName, otherInformation, createdBy, + audioRecordingRequired, cancelReason) { } diff --git a/BookingsApi/BookingsApi.IntegrationTests/Api/V1/Endpoints/AddEndPointToHearingTests.cs b/BookingsApi/BookingsApi.IntegrationTests/Api/V1/Endpoints/AddEndPointToHearingTests.cs index c46cf2d90..be8318b3b 100644 --- a/BookingsApi/BookingsApi.IntegrationTests/Api/V1/Endpoints/AddEndPointToHearingTests.cs +++ b/BookingsApi/BookingsApi.IntegrationTests/Api/V1/Endpoints/AddEndPointToHearingTests.cs @@ -78,7 +78,7 @@ public async Task should_return_not_found_when_adding_an_endpoint_to_a_hearing_t public async Task should_add_endpoint_with_a_defence_advocate_and_publish_message_when_hearing_is_created() { // arrange - var seededHearing = await Hooks.SeedVideoHearing(null, false, BookingStatus.Created); + var seededHearing = await Hooks.SeedVideoHearing(null, BookingStatus.Created); var rep = seededHearing.GetParticipants().First(x => x.HearingRole.UserRole.IsRepresentative); var hearingId = seededHearing.Id; var request = new AddEndpointRequest() @@ -119,7 +119,7 @@ public async Task should_add_endpoint_with_a_defence_advocate_and_publish_messag public async Task should_add_endpoint_with_a_defence_advocate_and_not_publish_message_when_hearing_is_not_created() { // arrange - var seededHearing = await Hooks.SeedVideoHearing(null, false, BookingStatus.Booked); + var seededHearing = await Hooks.SeedVideoHearing(status: BookingStatus.Booked); var rep = seededHearing.GetParticipants().First(x => x.HearingRole.UserRole.IsRepresentative); var hearingId = seededHearing.Id; var request = new AddEndpointRequest() diff --git a/BookingsApi/BookingsApi.IntegrationTests/Api/V1/Endpoints/RemoveEndPointFromHearingTests.cs b/BookingsApi/BookingsApi.IntegrationTests/Api/V1/Endpoints/RemoveEndPointFromHearingTests.cs index 17326e035..27604177f 100644 --- a/BookingsApi/BookingsApi.IntegrationTests/Api/V1/Endpoints/RemoveEndPointFromHearingTests.cs +++ b/BookingsApi/BookingsApi.IntegrationTests/Api/V1/Endpoints/RemoveEndPointFromHearingTests.cs @@ -35,7 +35,7 @@ [Test] public async Task should_return_bad_request_when_an_invalid_hearing_id_is public async Task should_remove_endpoint_from_and_publish_message_when_hearing_is_created_and_found() { // arrange - var seededHearing = await Hooks.SeedVideoHearing(null, false, BookingStatus.Created, 3); + var seededHearing = await Hooks.SeedVideoHearing(null, BookingStatus.Created, 3); using var client = Application.CreateClient(); var endpoint = seededHearing.GetEndpoints()[0]; var hearingId = seededHearing.Id; @@ -59,7 +59,7 @@ public async Task should_remove_endpoint_from_and_publish_message_when_hearing_i public async Task should_remove_endpoint_from_hearing_but_not_publish_when_hearing_is_not_created() { // arrange - var seededHearing = await Hooks.SeedVideoHearing(null, false, BookingStatus.Booked, 3); + var seededHearing = await Hooks.SeedVideoHearing(null, BookingStatus.Booked, 3); using var client = Application.CreateClient(); var endpoint = seededHearing.GetEndpoints()[0]; var hearingId = seededHearing.Id; @@ -101,7 +101,7 @@ public async Task should_return_not_found_when_removing_an_endpoint_for_a_hearin public async Task should_return_not_found_when_removing_an_endpoint_that_does_not_exist() { // arrange - var seededHearing = await Hooks.SeedVideoHearing(null, false, BookingStatus.Created, 3); + var seededHearing = await Hooks.SeedVideoHearing(null, BookingStatus.Created, 3); using var client = Application.CreateClient(); var hearingId = seededHearing.Id; var endpointId = Guid.NewGuid(); diff --git a/BookingsApi/BookingsApi.IntegrationTests/Api/V1/Endpoints/UpdateEndpointTests.cs b/BookingsApi/BookingsApi.IntegrationTests/Api/V1/Endpoints/UpdateEndpointTests.cs index 7ef4a885a..aefdef83e 100644 --- a/BookingsApi/BookingsApi.IntegrationTests/Api/V1/Endpoints/UpdateEndpointTests.cs +++ b/BookingsApi/BookingsApi.IntegrationTests/Api/V1/Endpoints/UpdateEndpointTests.cs @@ -77,7 +77,7 @@ public async Task should_return_not_found_when_updating_an_endpoint_to_a_hearing public async Task should_return_not_found_when_updating_an_endpoint_that_does_not_exist() { // arrange - var seededHearing = await Hooks.SeedVideoHearing(null, false, BookingStatus.Created); + var seededHearing = await Hooks.SeedVideoHearing(null, BookingStatus.Created); var hearingId = seededHearing.Id; var endpointId = Guid.NewGuid(); var request = new UpdateEndpointRequest() @@ -100,7 +100,7 @@ public async Task should_return_not_found_when_updating_an_endpoint_that_does_no public async Task should_return_no_content_when_endpoint_display_name_and_defence_advocate_is_updated() { // arrange - var seededHearing = await Hooks.SeedVideoHearing(null, false, BookingStatus.Created, 1); + var seededHearing = await Hooks.SeedVideoHearing(null, BookingStatus.Created, 1); var ep = seededHearing.Endpoints[0]; var rep = seededHearing.GetParticipants().First(x => x.HearingRole.UserRole.IsRepresentative); var hearingId = seededHearing.Id; diff --git a/BookingsApi/BookingsApi.IntegrationTests/Api/V1/Hearings/GetHearingDetailsByIdTests.cs b/BookingsApi/BookingsApi.IntegrationTests/Api/V1/Hearings/GetHearingDetailsByIdTests.cs index a14a1b2b8..587bf89e8 100644 --- a/BookingsApi/BookingsApi.IntegrationTests/Api/V1/Hearings/GetHearingDetailsByIdTests.cs +++ b/BookingsApi/BookingsApi.IntegrationTests/Api/V1/Hearings/GetHearingDetailsByIdTests.cs @@ -45,7 +45,7 @@ public async Task should_return_not_found_when_a_hearing_is_not_found_with_the_p public async Task should_return_a_hearing_when_matched_with_a_given_id() { // arrange - var hearing = await Hooks.SeedVideoHearing(null, false, BookingStatus.Booked, 1); + var hearing = await Hooks.SeedVideoHearing(null, BookingStatus.Booked, 1); var hearingId = hearing.Id; // act diff --git a/BookingsApi/BookingsApi.IntegrationTests/Api/V1/Hearings/UpdateHearingTests.cs b/BookingsApi/BookingsApi.IntegrationTests/Api/V1/Hearings/UpdateHearingTests.cs index a18f4d3cf..01dfdaca6 100644 --- a/BookingsApi/BookingsApi.IntegrationTests/Api/V1/Hearings/UpdateHearingTests.cs +++ b/BookingsApi/BookingsApi.IntegrationTests/Api/V1/Hearings/UpdateHearingTests.cs @@ -83,7 +83,7 @@ public async Task should_update_hearing_and_publish_when_hearing_status_is_creat var hearing = await Hooks.SeedVideoHearing(options => { options.Case = new Case("Case1 Num", "Case1 Name"); - }, false, BookingStatus.Created); + }, BookingStatus.Created); var hearingId = hearing.Id; var request = BuildRequest(); @@ -131,7 +131,7 @@ public async Task should_update_hearing_and_publish_when_hearing_status_is_creat public async Task should_update_hearing_and_not_publish_when_hearing_status_is_not_created() { // arrange - var hearing = await Hooks.SeedVideoHearing(null, false, BookingStatus.Booked); + var hearing = await Hooks.SeedVideoHearing(status: BookingStatus.Booked); var hearingId = hearing.Id; var request = BuildRequest(); diff --git a/BookingsApi/BookingsApi.IntegrationTests/Api/V2/HearingParticipants/AddParticipantsToHearingV2Tests.cs b/BookingsApi/BookingsApi.IntegrationTests/Api/V2/HearingParticipants/AddParticipantsToHearingV2Tests.cs index cddd53e15..22ca3d541 100644 --- a/BookingsApi/BookingsApi.IntegrationTests/Api/V2/HearingParticipants/AddParticipantsToHearingV2Tests.cs +++ b/BookingsApi/BookingsApi.IntegrationTests/Api/V2/HearingParticipants/AddParticipantsToHearingV2Tests.cs @@ -9,8 +9,8 @@ public class AddParticipantsToHearingV2Tests : ApiTest public async Task should_add_participant_to_hearing_and_return_200() { // arrange - var hearing = await Hooks.SeedVideoHearing(options => { options.Case = new Case("Case1 Num", "Case1 Name"); } - ,false, BookingStatus.Created); + var hearing = await Hooks.SeedVideoHearing(options => { options.Case = new Case("Case1 Num", "Case1 Name"); }, + BookingStatus.Created); var request = BuildRequestObject(); @@ -27,8 +27,8 @@ public async Task should_add_participant_to_hearing_and_return_200() public async Task should_add_participant_to_hearing_without_case_role_and_return_200() { // arrange - var hearing = await Hooks.SeedVideoHearing(options => { options.Case = new Case("Case1 Num", "Case1 Name"); } - ,false, BookingStatus.Created); + var hearing = await Hooks.SeedVideoHearing(options => { options.Case = new Case("Case1 Num", "Case1 Name"); }, + BookingStatus.Created); var request = BuildRequestObject(); request.Participants.ForEach(x => diff --git a/BookingsApi/BookingsApi.IntegrationTests/Api/V2/HearingParticipants/UpdateHearingParticipantsV2Tests.cs b/BookingsApi/BookingsApi.IntegrationTests/Api/V2/HearingParticipants/UpdateHearingParticipantsV2Tests.cs index 9a3197d21..1cb2649ef 100644 --- a/BookingsApi/BookingsApi.IntegrationTests/Api/V2/HearingParticipants/UpdateHearingParticipantsV2Tests.cs +++ b/BookingsApi/BookingsApi.IntegrationTests/Api/V2/HearingParticipants/UpdateHearingParticipantsV2Tests.cs @@ -54,7 +54,7 @@ public async Task should_return_not_found_when_video_hearing_is_not_found() { // arrange var hearing = await Hooks.SeedVideoHearing(options - => { options.Case = new Case("Case1 Num", "Case1 Name"); },false, BookingStatus.Created); + => { options.Case = new Case("Case1 Num", "Case1 Name"); }, BookingStatus.Created); var participantToUpdate = hearing.Participants.First(e => e.HearingRole.UserRole.IsIndividual); var request = new UpdateHearingParticipantsRequestV2 @@ -83,7 +83,7 @@ public async Task should_update_individual_participant_and_add_a_new_individual_ { // arrange var hearing = await Hooks.SeedVideoHearing(options - => { options.Case = new Case("Case1 Num", "Case1 Name"); },false, BookingStatus.Created); + => { options.Case = new Case("Case1 Num", "Case1 Name"); }, BookingStatus.Created); var participantToUpdate = hearing.Participants.First(e => e.HearingRole.UserRole.IsIndividual); var request = new UpdateHearingParticipantsRequestV2 @@ -165,7 +165,7 @@ public async Task should_return_validation_errors_when_case_role_not_found() // arrange var caseRoleName = "Invalid Role"; var hearing = await Hooks.SeedVideoHearing(options - => { options.Case = new Case("UpdateParticipantDataValidationFailure", "UpdateParticipantDataValidationFailure"); },false, BookingStatus.Created); + => { options.Case = new Case("UpdateParticipantDataValidationFailure", "UpdateParticipantDataValidationFailure"); }, BookingStatus.Created); var request = new UpdateHearingParticipantsRequestV2 { @@ -207,7 +207,7 @@ public async Task should_return_validation_errors_when_hearing_role_not_found_fr // arrange var hearingRoleName = "Invalid Role"; var hearing = await Hooks.SeedVideoHearing(options - => { options.Case = new Case("UpdateParticipantDataValidationFailure", "UpdateParticipantDataValidationFailure"); },false, BookingStatus.Created); + => { options.Case = new Case("UpdateParticipantDataValidationFailure", "UpdateParticipantDataValidationFailure"); }, BookingStatus.Created); var request = new UpdateHearingParticipantsRequestV2 { @@ -249,7 +249,7 @@ public async Task should_return_validation_errors_when_flat_structure_hearing_ro // arrange var hearingRoleName = "Invalid Role"; var hearing = await Hooks.SeedVideoHearing(options - => { options.Case = new Case("UpdateParticipantDataValidationFailure", "UpdateParticipantDataValidationFailure"); },false, BookingStatus.Created); + => { options.Case = new Case("UpdateParticipantDataValidationFailure", "UpdateParticipantDataValidationFailure"); }, BookingStatus.Created); var request = new UpdateHearingParticipantsRequestV2 { diff --git a/BookingsApi/BookingsApi.IntegrationTests/Api/V2/Hearings/GetHearingDetailsByIdV2Tests.cs b/BookingsApi/BookingsApi.IntegrationTests/Api/V2/Hearings/GetHearingDetailsByIdV2Tests.cs index 4d5671654..d8550b620 100644 --- a/BookingsApi/BookingsApi.IntegrationTests/Api/V2/Hearings/GetHearingDetailsByIdV2Tests.cs +++ b/BookingsApi/BookingsApi.IntegrationTests/Api/V2/Hearings/GetHearingDetailsByIdV2Tests.cs @@ -49,7 +49,7 @@ public async Task should_return_a_hearing_when_matched_with_a_given_id() var hearing = await Hooks.SeedVideoHearing(configureOptions: options => { options.AddJudiciaryPanelMember = true; - }, false, BookingStatus.Booked, 1, false); + }, BookingStatus.Booked, 1, false); var hearingId = hearing.Id; // act diff --git a/BookingsApi/BookingsApi.IntegrationTests/Api/V2/Hearings/UpdateHearingV2Tests.cs b/BookingsApi/BookingsApi.IntegrationTests/Api/V2/Hearings/UpdateHearingV2Tests.cs index bc1c59855..0a07e4ec5 100644 --- a/BookingsApi/BookingsApi.IntegrationTests/Api/V2/Hearings/UpdateHearingV2Tests.cs +++ b/BookingsApi/BookingsApi.IntegrationTests/Api/V2/Hearings/UpdateHearingV2Tests.cs @@ -83,7 +83,7 @@ public async Task should_update_hearing_and_publish_when_hearing_status_is_creat var hearing = await Hooks.SeedVideoHearing(options => { options.Case = new Case("Case1 Num", "Case1 Name"); - }, false, BookingStatus.Created); + }, BookingStatus.Created); var hearingId = hearing.Id; var request = BuildRequest(); @@ -131,7 +131,7 @@ public async Task should_update_hearing_and_publish_when_hearing_status_is_creat public async Task should_update_hearing_and_not_publish_when_hearing_status_is_not_created() { // arrange - var hearing = await Hooks.SeedVideoHearing(null); + var hearing = await Hooks.SeedVideoHearing(); var hearingId = hearing.Id; var request = BuildRequest(); @@ -148,7 +148,7 @@ public async Task should_update_hearing_and_not_publish_when_hearing_status_is_n message.Should().BeNull(); } - private UpdateHearingRequestV2 BuildRequest() + private static UpdateHearingRequestV2 BuildRequest() { var cases = Builder.CreateListOfSize(1).Build().ToList(); cases[0].IsLeadCase = false; diff --git a/BookingsApi/BookingsApi.IntegrationTests/BookingsApi.IntegrationTests.csproj b/BookingsApi/BookingsApi.IntegrationTests/BookingsApi.IntegrationTests.csproj index 9f5603ff3..75777777c 100644 --- a/BookingsApi/BookingsApi.IntegrationTests/BookingsApi.IntegrationTests.csproj +++ b/BookingsApi/BookingsApi.IntegrationTests/BookingsApi.IntegrationTests.csproj @@ -82,11 +82,5 @@ true true - - SuitabilityAnswer.feature - true - true - true - \ No newline at end of file diff --git a/BookingsApi/BookingsApi.IntegrationTests/Database/Commands/CreateVideoHearingCommandTests.cs b/BookingsApi/BookingsApi.IntegrationTests/Database/Commands/CreateVideoHearingCommandTests.cs index 65f737033..2ea64a5d8 100644 --- a/BookingsApi/BookingsApi.IntegrationTests/Database/Commands/CreateVideoHearingCommandTests.cs +++ b/BookingsApi/BookingsApi.IntegrationTests/Database/Commands/CreateVideoHearingCommandTests.cs @@ -33,7 +33,7 @@ public async Task Should_be_able_to_save_video_hearing_to_database() var hearingType = caseType.HearingTypes.First(x => x.Name == hearingTypeName); var scheduledDate = DateTime.Today.AddHours(10).AddMinutes(30); var duration = 45; - var venue = new RefDataBuilder().HearingVenues.First(); + var venue = new RefDataBuilder().HearingVenues[0]; var applicantCaseRole = caseType.CaseRoles.First(x => x.Name == "Applicant"); var applicantRepresentativeHearingRole = @@ -68,7 +68,6 @@ public async Task Should_be_able_to_save_video_hearing_to_database() var hearingRoomName = "Room01"; var otherInformation = "OtherInformation01"; var createdBy = "User01"; - const bool questionnaireNotRequired = false; const bool audioRecordingRequired = true; var endpoints = new List @@ -97,15 +96,11 @@ public async Task Should_be_able_to_save_video_hearing_to_database() LinkedParticipantType.Interpreter) }; - var command = - new CreateVideoHearingCommand(caseType, hearingType, scheduledDate, duration, venue, - participants, cases, questionnaireNotRequired, audioRecordingRequired, endpoints, - linkedParticipants, false) - { - HearingRoomName = hearingRoomName, - OtherInformation = otherInformation, - CreatedBy = createdBy - }; + var requiredDto = new CreateVideoHearingRequiredDto(caseType, hearingType, scheduledDate, duration, venue, cases); + var optionalDto = new CreateVideoHearingOptionalDto(participants, hearingRoomName, otherInformation, + createdBy, audioRecordingRequired, endpoints, null, linkedParticipants, + null, false, null); + var command = new CreateVideoHearingCommand(requiredDto, optionalDto); await _commandHandler.Handle(command); command.NewHearingId.Should().NotBeEmpty(); _newHearingId = command.NewHearingId; diff --git a/BookingsApi/BookingsApi.IntegrationTests/Database/Commands/RemoveHearingCommandTests.cs b/BookingsApi/BookingsApi.IntegrationTests/Database/Commands/RemoveHearingCommandTests.cs index 9c246b779..c8e52ff48 100644 --- a/BookingsApi/BookingsApi.IntegrationTests/Database/Commands/RemoveHearingCommandTests.cs +++ b/BookingsApi/BookingsApi.IntegrationTests/Database/Commands/RemoveHearingCommandTests.cs @@ -9,7 +9,6 @@ public class RemoveHearingCommandTests : DatabaseTestsBase { private RemoveHearingCommandHandler _commandHandler; private GetHearingByIdQueryHandler _getHearingByIdQueryHandler; - private Guid _newHearingId; [SetUp] public void Setup() @@ -17,7 +16,6 @@ public void Setup() var context = new BookingsDbContext(BookingsDbContextOptions); _commandHandler = new RemoveHearingCommandHandler(context); _getHearingByIdQueryHandler = new GetHearingByIdQueryHandler(context); - _newHearingId = Guid.Empty; } [Test] @@ -33,31 +31,25 @@ public async Task Should_remove_hearing() { var seededHearing = await Hooks.SeedVideoHearing(); TestContext.WriteLine($"New seeded video hearing id: {seededHearing.Id}"); - _newHearingId = seededHearing.Id; await _commandHandler.Handle(new RemoveHearingCommand(seededHearing.Id)); var returnedVideoHearing = await _getHearingByIdQueryHandler.Handle(new GetHearingByIdQuery(seededHearing.Id)); returnedVideoHearing.Should().BeNull(); - - _newHearingId = Guid.Empty; } [Test] public async Task Should_remove_hearing_containing_interpreter() { - var seededHearing = await Hooks.SeedVideoHearing(null, false,BookingStatus.Booked,0,false,true); + var seededHearing = await Hooks.SeedVideoHearing(null, BookingStatus.Booked, 0, false, true); TestContext.WriteLine($"New seeded video hearing id: {seededHearing.Id}"); - _newHearingId = seededHearing.Id; await _commandHandler.Handle(new RemoveHearingCommand(seededHearing.Id)); var returnedVideoHearing = await _getHearingByIdQueryHandler.Handle(new GetHearingByIdQuery(seededHearing.Id)); returnedVideoHearing.Should().BeNull(); - - _newHearingId = Guid.Empty; } } } \ No newline at end of file diff --git a/BookingsApi/BookingsApi.IntegrationTests/Database/Commands/RemoveParticipantFromHearingCommandTests.cs b/BookingsApi/BookingsApi.IntegrationTests/Database/Commands/RemoveParticipantFromHearingCommandTests.cs index 4bf504a15..bb74df0fb 100644 --- a/BookingsApi/BookingsApi.IntegrationTests/Database/Commands/RemoveParticipantFromHearingCommandTests.cs +++ b/BookingsApi/BookingsApi.IntegrationTests/Database/Commands/RemoveParticipantFromHearingCommandTests.cs @@ -54,7 +54,7 @@ public async Task Should_remove_participant_from_hearing() TestContext.WriteLine($"New seeded video hearing id: {seededHearing.Id}"); var beforeCount = seededHearing.GetParticipants().Count; - var participant = seededHearing.GetParticipants().First(); + var participant = seededHearing.GetParticipants()[0]; _personsToRemove.Add(participant.Person.ContactEmail); await _commandHandler.Handle(new RemoveParticipantFromHearingCommand(seededHearing.Id, participant)); @@ -87,7 +87,7 @@ await _commandHandler.Handle( [Test] public async Task Should_Remove_ParticipantLink_When_Participant_Is_Removed() { - var seededHearing = await Hooks.SeedVideoHearing(null, false, BookingStatus.Booked, 0, false, true); + var seededHearing = await Hooks.SeedVideoHearing(null, BookingStatus.Booked, 0, false, true); TestContext.WriteLine($"New seeded video hearing id: {seededHearing.Id}"); var participantWithALink = seededHearing.Participants.First(x => x.LinkedParticipants.Any()); diff --git a/BookingsApi/BookingsApi.IntegrationTests/Database/Commands/UpdateHearingCommandTests.cs b/BookingsApi/BookingsApi.IntegrationTests/Database/Commands/UpdateHearingCommandTests.cs index cf9bf4b15..509224dbd 100644 --- a/BookingsApi/BookingsApi.IntegrationTests/Database/Commands/UpdateHearingCommandTests.cs +++ b/BookingsApi/BookingsApi.IntegrationTests/Database/Commands/UpdateHearingCommandTests.cs @@ -51,12 +51,10 @@ public async Task Should_be_able_to_update_video_hearing() var caseName = "CaseName Update"; var caseNumber = "CaseNumber Update"; casesToUpdate.Add(new Case(caseNumber, caseName)); - const bool questionnaireNotRequired = false; const bool audioRecordingRequired = true; await _commandHandler.Handle(new UpdateHearingCommand(_newHearingId, newDateTime, newDuration, - newVenue, newHearingRoomName, newOtherInformation, updatedBy, casesToUpdate, - questionnaireNotRequired, audioRecordingRequired)); + newVenue, newHearingRoomName, newOtherInformation, updatedBy, casesToUpdate, audioRecordingRequired)); var returnedVideoHearing = await _getHearingByIdQueryHandler.Handle(new GetHearingByIdQuery(seededHearing.Id)); @@ -100,8 +98,7 @@ public async Task Should_deallocate_when_scheduled_datetime_changes_and_user_is_ var casesToUpdate = new List(); await _commandHandler.Handle(new UpdateHearingCommand(_newHearingId, newDateTime, seededHearing.ScheduledDuration, - newVenue, seededHearing.HearingRoomName, seededHearing.OtherInformation, updatedBy, casesToUpdate, - seededHearing.QuestionnaireNotRequired, seededHearing.AudioRecordingRequired)); + newVenue, seededHearing.HearingRoomName, seededHearing.OtherInformation, updatedBy, casesToUpdate, seededHearing.AudioRecordingRequired)); var returnedVideoHearing = await _getHearingByIdQueryHandler.Handle(new GetHearingByIdQuery(seededHearing.Id)); @@ -133,8 +130,7 @@ public async Task Should_deallocate_when_scheduled_datetime_changes_and_user_is_ var casesToUpdate = new List(); await _commandHandler.Handle(new UpdateHearingCommand(_newHearingId, newDateTime, seededHearing.ScheduledDuration, - newVenue, seededHearing.HearingRoomName, seededHearing.OtherInformation, updatedBy, casesToUpdate, - seededHearing.QuestionnaireNotRequired, seededHearing.AudioRecordingRequired)); + newVenue, seededHearing.HearingRoomName, seededHearing.OtherInformation, updatedBy, casesToUpdate, seededHearing.AudioRecordingRequired)); var returnedVideoHearing = await _getHearingByIdQueryHandler.Handle(new GetHearingByIdQuery(seededHearing.Id)); @@ -173,8 +169,7 @@ public async Task Should_not_deallocate_when_scheduled_datetime_changes_and_user var casesToUpdate = new List(); await _commandHandler.Handle(new UpdateHearingCommand(_newHearingId, newDateTime, seededHearing.ScheduledDuration, - newVenue, seededHearing.HearingRoomName, seededHearing.OtherInformation, updatedBy, casesToUpdate, - seededHearing.QuestionnaireNotRequired, seededHearing.AudioRecordingRequired)); + newVenue, seededHearing.HearingRoomName, seededHearing.OtherInformation, updatedBy, casesToUpdate, seededHearing.AudioRecordingRequired)); var returnedVideoHearing = await _getHearingByIdQueryHandler.Handle(new GetHearingByIdQuery(seededHearing.Id)); @@ -200,8 +195,7 @@ public async Task Should_not_deallocate_when_scheduled_datetime_has_not_changed( var casesToUpdate = new List(); await _commandHandler.Handle(new UpdateHearingCommand(_newHearingId, seededHearing.ScheduledDateTime, seededHearing.ScheduledDuration, - newVenue, seededHearing.HearingRoomName, seededHearing.OtherInformation, updatedBy, casesToUpdate, - seededHearing.QuestionnaireNotRequired, seededHearing.AudioRecordingRequired)); + newVenue, seededHearing.HearingRoomName, seededHearing.OtherInformation, updatedBy, casesToUpdate, seededHearing.AudioRecordingRequired)); var returnedVideoHearing = await _getHearingByIdQueryHandler.Handle(new GetHearingByIdQuery(seededHearing.Id)); diff --git a/BookingsApi/BookingsApi.IntegrationTests/Database/Queries/GetBookingsByCaseTypesQueryHandlerTest.cs b/BookingsApi/BookingsApi.IntegrationTests/Database/Queries/GetBookingsByCaseTypesQueryHandlerTest.cs index 3444ee5d0..e1aaf3d34 100644 --- a/BookingsApi/BookingsApi.IntegrationTests/Database/Queries/GetBookingsByCaseTypesQueryHandlerTest.cs +++ b/BookingsApi/BookingsApi.IntegrationTests/Database/Queries/GetBookingsByCaseTypesQueryHandlerTest.cs @@ -60,12 +60,12 @@ public async Task Should_return_video_hearings_filtered_by_case_number() var query = new GetBookingsByCaseTypesQuery(new List { videoHearing.CaseTypeId }) { - CaseNumber = Hooks.CaseNumber + CaseNumber = TestDataManager.CaseNumber }; var result = await _handler.Handle(query); - result.All(h => h.HearingCases.Any(hc => hc.Case.Number == Hooks.CaseNumber)).Should().BeTrue(); + result.All(h => h.HearingCases.Any(hc => hc.Case.Number == TestDataManager.CaseNumber)).Should().BeTrue(); } [Test(Description = "With AdminSearchToggle On")] @@ -172,13 +172,13 @@ await Hooks.SeedVideoHearing(opt => var query = new GetBookingsByCaseTypesQuery { - CaseNumber = Hooks.CaseNumber, + CaseNumber = TestDataManager.CaseNumber, VenueIds = venueIdsToFilterOn }; var result = await _handler.Handle(query); - result.All(h => h.HearingCases.Any(hc => hc.Case.Number == Hooks.CaseNumber)).Should().BeTrue(); + result.All(h => h.HearingCases.Any(hc => hc.Case.Number == TestDataManager.CaseNumber)).Should().BeTrue(); AssertHearingsAreFilteredByVenueIds(result, venueIdsToFilterOn); } diff --git a/BookingsApi/BookingsApi.IntegrationTests/Database/Queries/GetHearingShellByIdQueryHandlerDatabaseTests.cs b/BookingsApi/BookingsApi.IntegrationTests/Database/Queries/GetHearingShellByIdQueryHandlerDatabaseTests.cs index 1ff5792ec..bfd2b9202 100644 --- a/BookingsApi/BookingsApi.IntegrationTests/Database/Queries/GetHearingShellByIdQueryHandlerDatabaseTests.cs +++ b/BookingsApi/BookingsApi.IntegrationTests/Database/Queries/GetHearingShellByIdQueryHandlerDatabaseTests.cs @@ -17,7 +17,7 @@ public void Setup() [Test] public async Task Should_get_hearing_shell_by_id() { - var seededHearing = await Hooks.SeedVideoHearing(addSuitabilityAnswer: false, status: Domain.Enumerations.BookingStatus.Created, isMultiDayFirstHearing: false); + var seededHearing = await Hooks.SeedVideoHearing(status: Domain.Enumerations.BookingStatus.Created, isMultiDayFirstHearing: false); TestContext.WriteLine($"New seeded video hearing id: {seededHearing.Id}"); var hearing = await _handler.Handle(new GetHearingShellByIdQuery(seededHearing.Id)); diff --git a/BookingsApi/BookingsApi.IntegrationTests/Database/Queries/GetHearingsBySearchQueryHandlerTests.cs b/BookingsApi/BookingsApi.IntegrationTests/Database/Queries/GetHearingsBySearchQueryHandlerTests.cs index 6e280223a..0f8b158a0 100644 --- a/BookingsApi/BookingsApi.IntegrationTests/Database/Queries/GetHearingsBySearchQueryHandlerTests.cs +++ b/BookingsApi/BookingsApi.IntegrationTests/Database/Queries/GetHearingsBySearchQueryHandlerTests.cs @@ -17,11 +17,11 @@ public void Setup() [Test] public async Task Should_get_hearing_details_by_case_number() { - var seededHearing1 = await Hooks.SeedVideoHearing(addSuitabilityAnswer: false, status: BookingStatus.Created); + var seededHearing1 = await Hooks.SeedVideoHearing(status: BookingStatus.Created); TestContext.WriteLine($"New seeded video hearing id: { seededHearing1.Id }"); - var caseData = seededHearing1.HearingCases.First(); + var caseData = seededHearing1.HearingCases[0]; TestContext.WriteLine($"New seeded video caseNumber: { caseData.Case.Number }"); var hearing = await _handler.Handle(new GetHearingsBySearchQuery(caseData.Case.Number)); @@ -37,11 +37,11 @@ public async Task Should_get_hearing_details_by_case_number() [Test] public async Task Should_get_hearing_details_by_partial_case_number() { - var seededHearing1 = await Hooks.SeedVideoHearing(addSuitabilityAnswer: false, status: BookingStatus.Created); + var seededHearing1 = await Hooks.SeedVideoHearing(status: BookingStatus.Created); TestContext.WriteLine($"New seeded video hearing id: { seededHearing1.Id }"); - var caseData = seededHearing1.HearingCases.First(); + var caseData = seededHearing1.HearingCases[0]; TestContext.WriteLine($"New seeded video caseNumber: { caseData.Case.Number }"); var caseNumber = caseData.Case.Number.Substring(0, 3); @@ -59,11 +59,11 @@ public async Task Should_get_hearing_details_by_partial_case_number() [Test] public async Task Should_get_hearing_details_by_case_number_and_date() { - var seededHearing1 = await Hooks.SeedVideoHearing(addSuitabilityAnswer: false, status: BookingStatus.Created); + var seededHearing1 = await Hooks.SeedVideoHearing(status: BookingStatus.Created); TestContext.WriteLine($"New seeded video hearing id: { seededHearing1.Id }"); - var caseData = seededHearing1.HearingCases.First(); + var caseData = seededHearing1.HearingCases[0]; TestContext.WriteLine($"New seeded video caseNumber: { caseData.Case.Number }"); var caseNumber = caseData.Case.Number.Substring(0, 3); @@ -81,11 +81,11 @@ public async Task Should_get_hearing_details_by_case_number_and_date() [Test] public async Task Should_get_hearing_details_by_date() { - var seededHearing1 = await Hooks.SeedVideoHearing(addSuitabilityAnswer: false, status: BookingStatus.Created); + var seededHearing1 = await Hooks.SeedVideoHearing(status: BookingStatus.Created); TestContext.WriteLine($"New seeded video hearing id: { seededHearing1.Id }"); - var caseData = seededHearing1.HearingCases.First(); + var caseData = seededHearing1.HearingCases[0]; TestContext.WriteLine($"New seeded video caseNumber: { caseData.Case.Number }"); var hearings = await _handler.Handle(new GetHearingsBySearchQuery(null, seededHearing1.ScheduledDateTime)); @@ -101,11 +101,11 @@ public async Task Should_get_hearing_details_by_date() [Test] public async Task Should_not_get_hearing_details_by_case_number_and_wrong_date() { - var seededHearing1 = await Hooks.SeedVideoHearing(addSuitabilityAnswer: false, status: BookingStatus.Created); + var seededHearing1 = await Hooks.SeedVideoHearing(status: BookingStatus.Created); TestContext.WriteLine($"New seeded video hearing id: { seededHearing1.Id }"); - var caseData = seededHearing1.HearingCases.First(); + var caseData = seededHearing1.HearingCases[0]; TestContext.WriteLine($"New seeded video caseNumber: { caseData.Case.Number }"); var caseNumber = caseData.Case.Number.Substring(0, 3); @@ -113,7 +113,7 @@ public async Task Should_not_get_hearing_details_by_case_number_and_wrong_date() var hearings = await _handler.Handle(new GetHearingsBySearchQuery(caseNumber, date)); hearings.Should().NotBeNull(); - hearings.Any(x => x.Id == seededHearing1.Id).Should().BeFalse(); + hearings.Exists(x => x.Id == seededHearing1.Id).Should().BeFalse(); } } } \ No newline at end of file diff --git a/BookingsApi/BookingsApi.IntegrationTests/Database/Queries/GetHearingsForNotificationsQueryHandlerTests.cs b/BookingsApi/BookingsApi.IntegrationTests/Database/Queries/GetHearingsForNotificationsQueryHandlerTests.cs index 852093498..9cb08bb6f 100644 --- a/BookingsApi/BookingsApi.IntegrationTests/Database/Queries/GetHearingsForNotificationsQueryHandlerTests.cs +++ b/BookingsApi/BookingsApi.IntegrationTests/Database/Queries/GetHearingsForNotificationsQueryHandlerTests.cs @@ -21,16 +21,16 @@ public void Setup() [TestCase(BookingStatus.Booked)] public async Task Shoud_return_hearings_between_48_to_72_hrs_for_notifications(BookingStatus bookingStatus) { - var hearing1 = await Hooks.SeedPastVideoHearing(DateTime.Today.AddDays(2), null, false, BookingStatus.Created); - var hearing2 = await Hooks.SeedPastVideoHearing(DateTime.Today.AddDays(2), null, false, BookingStatus.Created); - var hearing3 = await Hooks.SeedPastVideoHearing(DateTime.Today.AddDays(3), null, false, BookingStatus.Created); + var hearing1 = await Hooks.SeedPastVideoHearing(DateTime.Today.AddDays(2), null, BookingStatus.Created); + var hearing2 = await Hooks.SeedPastVideoHearing(DateTime.Today.AddDays(2), null, BookingStatus.Created); + var hearing3 = await Hooks.SeedPastVideoHearing(DateTime.Today.AddDays(3), null, BookingStatus.Created); var query = new GetHearingsForNotificationsQuery(); var result = await _handler.Handle(query); - var resulthearing1 = result.FirstOrDefault(x => x.Id == hearing1.Id); - var resulthearing2 = result.FirstOrDefault(x => x.Id == hearing2.Id); - var resulthearing3 = result.FirstOrDefault(x => x.Id == hearing3.Id); + var resulthearing1 = result.Find(x => x.Id == hearing1.Id); + var resulthearing2 = result.Find(x => x.Id == hearing2.Id); + var resulthearing3 = result.Find(x => x.Id == hearing3.Id); resulthearing1.Should().NotBeNull(); resulthearing2.Should().NotBeNull(); @@ -44,7 +44,7 @@ public async Task Shoud_return_hearings_between_48_to_72_hrs_for_notifications(B [TestCase(BookingStatus.Booked)] public async Task Should_not_return_multiday_hearings_between_48_to_72_hrs_for_notifications(BookingStatus bookingStatus) { - var hearing1 = await Hooks.SeedPastVideoHearing(DateTime.Today.AddDays(2), null, false, bookingStatus, isMultiDayFirstHearing:true); + var hearing1 = await Hooks.SeedPastVideoHearing(DateTime.Today.AddDays(2), null, bookingStatus, isMultiDayFirstHearing:true); var groupId = hearing1.SourceId; @@ -61,9 +61,9 @@ public async Task Should_not_return_multiday_hearings_between_48_to_72_hrs_for_n var returnedHearing2 = groupResults[1]; var returnedHearing3 = groupResults[2]; - var resulthearing1 = result.FirstOrDefault(x => x.Id == returnedHearing1.Id); - var resulthearing2 = result.FirstOrDefault(x => x.Id == returnedHearing2.Id); - var resulthearing3 = result.FirstOrDefault(x => x.Id == returnedHearing3.Id); + var resulthearing1 = result.Find(x => x.Id == returnedHearing1.Id); + var resulthearing2 = result.Find(x => x.Id == returnedHearing2.Id); + var resulthearing3 = result.Find(x => x.Id == returnedHearing3.Id); resulthearing1.Should().NotBeNull(); resulthearing2.Should().NotBeNull(); diff --git a/BookingsApi/BookingsApi.IntegrationTests/Features/V1/Participants.feature b/BookingsApi/BookingsApi.IntegrationTests/Features/V1/Participants.feature index 7d86c930c..a377d3446 100644 --- a/BookingsApi/BookingsApi.IntegrationTests/Features/V1/Participants.feature +++ b/BookingsApi/BookingsApi.IntegrationTests/Features/V1/Participants.feature @@ -129,28 +129,3 @@ Scenario: Participant details updated successfully Given I have an update participant in a hearing request with a valid hearing id When I send the request to the endpoint Then the response should have the status OK and success status True - -Scenario: Participant submits suitability answers with invalid participant id - Given I have an update suitability answers request with an valid hearing id and invalid participant id - When I send the request to the endpoint - Then the response should have the status BadRequest and success status False - -Scenario: Participant submits suitability answers with invalid hearing id - Given I have an update suitability answers request with an invalid hearing id and valid participant id - When I send the request to the endpoint - Then the response should have the status BadRequest and success status False - -Scenario: Participant submits suitability answers with nonexisting hearing id - Given I have an update suitability answers request with an Nonexistent hearing id and valid participant id - When I send the request to the endpoint - Then the response should have the status NotFound and success status False - -Scenario: Participant submits suitability answers with nonexisting participant id - Given I have an update suitability answers request with an valid hearing id and Nonexistent participant id - When I send the request to the endpoint - Then the response should have the status NotFound and success status False - -Scenario: Participant submits suitability answers with valid data - Given I have an update suitability answers request with an valid hearing id and valid participant id - When I send the request to the endpoint - Then the response should have the status NoContent and success status True \ No newline at end of file diff --git a/BookingsApi/BookingsApi.IntegrationTests/Features/V1/Persons.feature b/BookingsApi/BookingsApi.IntegrationTests/Features/V1/Persons.feature index 734437cb3..dfe71dbcd 100644 --- a/BookingsApi/BookingsApi.IntegrationTests/Features/V1/Persons.feature +++ b/BookingsApi/BookingsApi.IntegrationTests/Features/V1/Persons.feature @@ -4,23 +4,6 @@ Feature: Persons As an api service I want to be able to retrieve persons stored in the system - Scenario: Get person suitability answers for invalid username - Given I have a get person suitability answers by username request with an invalid username - When I send the request to the endpoint - Then the response should have the status BadRequest and success status False - - Scenario: Get person suitability answers for valid username - Given I have a get person suitability answers by username request with an valid username - When I send the request to the endpoint - Then the response should have the status OK and success status True - And suitability answers retrieved should 'not be empty' - - Scenario: Get person without suitability answers for valid username - Given I have a get person without suitability answers by username request with an valid username - When I send the request to the endpoint - Then the response should have the status OK and success status True - And suitability answers retrieved should 'be empty' - Scenario: Get a list of usernames for hearings older than 3 months Given I have an hearing older than 3 months And I have a request to get the usernames for old hearings diff --git a/BookingsApi/BookingsApi.IntegrationTests/Features/V1/SuitabilityAnswer.feature b/BookingsApi/BookingsApi.IntegrationTests/Features/V1/SuitabilityAnswer.feature deleted file mode 100644 index d72ce5ad8..000000000 --- a/BookingsApi/BookingsApi.IntegrationTests/Features/V1/SuitabilityAnswer.feature +++ /dev/null @@ -1,18 +0,0 @@ -Feature: SuitabilityAnswer - In order to view all suitability answers - As an api service - I want to be able to retrieve suitability data - -@VIH-4460 -Scenario: Get all suitability answers sorted by latest one - Given I have the suitable answers for participants - When I send the request to the endpoint - Then the response should have the status OK and success status True - And suitable answers should be retrieved - -@VIH-4460-1 -Scenario: Get next set of suitable answers for participants continued from the next cursor - Given I have a request to the second set of suitable answers - When I send the request to the endpoint - Then the response should have the status OK and success status True - And suitable answers should be retrieved \ No newline at end of file diff --git a/BookingsApi/BookingsApi.IntegrationTests/Helper/TestDataManager.cs b/BookingsApi/BookingsApi.IntegrationTests/Helper/TestDataManager.cs index 02354286a..3f5713fdb 100644 --- a/BookingsApi/BookingsApi.IntegrationTests/Helper/TestDataManager.cs +++ b/BookingsApi/BookingsApi.IntegrationTests/Helper/TestDataManager.cs @@ -22,9 +22,7 @@ public class TestDataManager public List JudiciaryPersons { get; } = new(); private readonly List _seededJusticeUserIds = new(); private readonly List _seededAllocationIds = new(); - public string CaseNumber { get; } = "2222/3511"; - private Guid _individualId; - private List _participantRepresentativeIds; + public static string CaseNumber => "2222/3511"; private readonly string _defaultCaseName; public void AddHearingForCleanup(Guid id) @@ -158,7 +156,7 @@ public static async Task SeedJusticeUsersRole(BookingsDbContext context, Justice } public async Task SeedVideoHearing(Action configureOptions = null, - bool addSuitabilityAnswer = false, BookingStatus status = BookingStatus.Booked, int endPointsToAdd = 0, + BookingStatus status = BookingStatus.Booked, int endPointsToAdd = 0, bool addJoh = false, bool withLinkedParticipants = false, bool isMultiDayFirstHearing = false) { var options = new SeedVideoHearingOptions(); @@ -198,13 +196,11 @@ public async Task SeedVideoHearing(Action const string hearingRoomName = "Room02"; const string otherInformation = "OtherInformation02"; const string createdBy = "test@hmcts.net"; - const bool questionnaireNotRequired = false; const bool audioRecordingRequired = true; var cancelReason = "Online abandonment (incomplete registration)"; var videoHearing = new VideoHearing(caseType, hearingType, scheduledDate, duration, - venue, hearingRoomName, otherInformation, createdBy, questionnaireNotRequired, - audioRecordingRequired, cancelReason); + venue, hearingRoomName, otherInformation, createdBy, audioRecordingRequired, cancelReason); videoHearing.IsFirstDayOfMultiDayHearing = isMultiDayFirstHearing; videoHearing.AddIndividual(person1, applicantLipHearingRole, applicantCaseRole, $"{person1.FirstName} {person1.LastName}"); @@ -317,17 +313,7 @@ public async Task SeedVideoHearing(Action var hearing = await new GetHearingByIdQueryHandler(db).Handle( new GetHearingByIdQuery(videoHearing.Id)); - _individualId = hearing.Participants.First(x => x.HearingRole.UserRole.IsIndividual).Id; - _participantRepresentativeIds = hearing.Participants - .Where(x => x.HearingRole.UserRole.IsRepresentative).Select(x => x.Id).ToList(); - - if (addSuitabilityAnswer) - { - await AddQuestionnaire(); - } - - hearing = await new GetHearingByIdQueryHandler(db).Handle( - new GetHearingByIdQuery(videoHearing.Id)); + _seededHearings.Add(hearing.Id); return hearing; } @@ -362,13 +348,11 @@ public async Task SeedVideoHearingWithNoJudge( const string hearingRoomName = "Room02"; const string otherInformation = "OtherInformation02"; const string createdBy = "test@hmcts.net"; - const bool questionnaireNotRequired = false; const bool audioRecordingRequired = true; const string cancelReason = "Online abandonment (incomplete registration)"; var videoHearing = new VideoHearing(caseType, hearingType, scheduledDate, duration, - venue, hearingRoomName, otherInformation, createdBy, questionnaireNotRequired, - audioRecordingRequired, cancelReason); + venue, hearingRoomName, otherInformation, createdBy, audioRecordingRequired, cancelReason); videoHearing.AddIndividual(person1, applicantLipHearingRole, applicantCaseRole, $"{person1.FirstName} {person1.LastName}"); @@ -432,42 +416,6 @@ public async Task CloneVideoHearing(Guid hearingId, IList datesOfHeari } } - private async Task AddQuestionnaire() - { - await using var db = new BookingsDbContext(_dbContextOptions); - AddIndividualQuestionnaire(db); - AddRepresentativeQuestionnaire(db); - - await db.SaveChangesAsync(); - } - - private void AddIndividualQuestionnaire(BookingsDbContext db) - { - var participant = db.Participants - .Include(x => x.Questionnaire).First(x => x.Id == _individualId); - participant.Questionnaire = new Questionnaire {Participant = participant, ParticipantId = _individualId}; - participant.Questionnaire.AddSuitabilityAnswer("INTERPRETER", "No", ""); - participant.Questionnaire.AddSuitabilityAnswer("ROOM", "Yes", ""); - participant.UpdatedDate = DateTime.UtcNow; - db.Participants.Update(participant); - } - - private void AddRepresentativeQuestionnaire(BookingsDbContext db) - { - foreach (var item in _participantRepresentativeIds) - { - var participantRepresentative = db.Participants - .Include(x => x.Questionnaire).First(x => x.Id == item); - participantRepresentative.Questionnaire = new Questionnaire - {Participant = participantRepresentative, ParticipantId = item}; - - participantRepresentative.Questionnaire.AddSuitabilityAnswer("ABOUT_YOUR_CLIENT", "No", ""); - participantRepresentative.Questionnaire.AddSuitabilityAnswer("ROOM", "No", "Comments"); - participantRepresentative.UpdatedDate = DateTime.UtcNow; - db.Participants.Update(participantRepresentative); - } - } - private CaseType GetCaseTypeFromDb(string caseTypeName) { using var db = new BookingsDbContext(_dbContextOptions); @@ -637,8 +585,7 @@ public Task SeedPastHearings(DateTime scheduledDate) } public async Task SeedPastVideoHearing(DateTime pastScheduledDate, - Action configureOptions, - bool addSuitabilityAnswer = false, BookingStatus status = BookingStatus.Booked, + Action configureOptions, BookingStatus status = BookingStatus.Booked, bool isMultiDayFirstHearing = false) { var options = new SeedVideoHearingOptions(); @@ -674,13 +621,11 @@ public async Task SeedPastVideoHearing(DateTime pastScheduledDate, const string hearingRoomName = "Room02"; const string otherInformation = "OtherInformation02"; const string createdBy = "test@hmcts.net"; - const bool questionnaireNotRequired = false; const bool audioRecordingRequired = true; var cancelReason = "Online abandonment (incomplete registration)"; var videoHearing = new VideoHearing(caseType, hearingType, scheduledDate, duration, - venues[0], hearingRoomName, otherInformation, createdBy, questionnaireNotRequired, - audioRecordingRequired, cancelReason); + venues[0], hearingRoomName, otherInformation, createdBy, audioRecordingRequired, cancelReason); videoHearing.IsFirstDayOfMultiDayHearing = isMultiDayFirstHearing; videoHearing.AddIndividual(person1, applicantLipHearingRole, applicantCaseRole, $"{person1.FirstName} {person1.LastName}"); @@ -717,20 +662,6 @@ public async Task SeedPastVideoHearing(DateTime pastScheduledDate, var hearing = await new GetHearingByIdQueryHandler(new BookingsDbContext(_dbContextOptions)).Handle( new GetHearingByIdQuery(videoHearing.Id)); - _individualId = hearing.Participants.First(x => - x.HearingRole.Name.ToLower().IndexOf("judge", StringComparison.Ordinal) < 0 && - x.HearingRole.Name.ToLower().IndexOf("representative", StringComparison.Ordinal) < 0).Id; - _participantRepresentativeIds = hearing.Participants - .Where(x => x.HearingRole.Name.ToLower().Contains("representative", StringComparison.Ordinal)) - .Select(x => x.Id).ToList(); - - if (addSuitabilityAnswer) - { - await AddQuestionnaire(); - } - - hearing = await new GetHearingByIdQueryHandler(new BookingsDbContext(_dbContextOptions)).Handle( - new GetHearingByIdQuery(videoHearing.Id)); _seededHearings.Add(hearing.Id); return hearing; } @@ -763,13 +694,11 @@ public async Task SeedVideoHearingLinkedParticipants( const string hearingRoomName = "Room02"; const string otherInformation = "OtherInformation02"; const string createdBy = "test@hmcts.net"; - const bool questionnaireNotRequired = false; const bool audioRecordingRequired = true; var cancelReason = "Online abandonment (incomplete registration)"; var videoHearing = new VideoHearing(caseType, hearingType, scheduledDate, duration, - venues[0], hearingRoomName, otherInformation, createdBy, questionnaireNotRequired, - audioRecordingRequired, cancelReason); + venues[0], hearingRoomName, otherInformation, createdBy, audioRecordingRequired, cancelReason); videoHearing.AddIndividual(person1, applicantLipHearingRole, applicantCaseRole, $"{person1.FirstName} {person1.LastName}"); @@ -792,12 +721,6 @@ public async Task SeedVideoHearingLinkedParticipants( var hearing = await new GetHearingByIdQueryHandler(new BookingsDbContext(_dbContextOptions)).Handle( new GetHearingByIdQuery(videoHearing.Id)); - _individualId = hearing.Participants.First(x => x.HearingRole.UserRole.IsIndividual).Id; - _participantRepresentativeIds = hearing.Participants - .Where(x => x.HearingRole.UserRole.IsRepresentative).Select(x => x.Id).ToList(); - - hearing = await new GetHearingByIdQueryHandler(new BookingsDbContext(_dbContextOptions)).Handle( - new GetHearingByIdQuery(videoHearing.Id)); _seededHearings.Add(hearing.Id); return hearing; } diff --git a/BookingsApi/BookingsApi.IntegrationTests/Steps/CommonSteps.cs b/BookingsApi/BookingsApi.IntegrationTests/Steps/CommonSteps.cs index 92687622e..a16633d93 100644 --- a/BookingsApi/BookingsApi.IntegrationTests/Steps/CommonSteps.cs +++ b/BookingsApi/BookingsApi.IntegrationTests/Steps/CommonSteps.cs @@ -64,7 +64,7 @@ public async Task GivenIHaveAHearing() [Given(@"I have a confirmed hearing")] public async Task GivenIHaveAConfirmedHearing() { - var seededHearing = await Context.TestDataManager.SeedVideoHearing(addSuitabilityAnswer: false, status: BookingStatus.Created); + var seededHearing = await Context.TestDataManager.SeedVideoHearing(status: BookingStatus.Created); Context.TestData.NewHearingId = seededHearing.Id; Context.TestData.SeededHearing = seededHearing; NUnit.Framework.TestContext.WriteLine($"New seeded video hearing id: {seededHearing.Id}"); diff --git a/BookingsApi/BookingsApi.IntegrationTests/Steps/EndPointSteps.cs b/BookingsApi/BookingsApi.IntegrationTests/Steps/EndPointSteps.cs index 9c659dd56..17b1b88be 100644 --- a/BookingsApi/BookingsApi.IntegrationTests/Steps/EndPointSteps.cs +++ b/BookingsApi/BookingsApi.IntegrationTests/Steps/EndPointSteps.cs @@ -24,28 +24,28 @@ public EndPointSteps(Contexts.TestContext context) : base(context) [Given(@"I have a hearing with endpoints")] public async Task GivenIHaveAHearingWithEndpoints() { - var seededHearing = await Context.TestDataManager.SeedVideoHearing(null, false, BookingStatus.Booked, 3); + var seededHearing = await Context.TestDataManager.SeedVideoHearing(null, BookingStatus.Booked, 3); PersistTestHearingData(seededHearing); } [Given(@"I have a hearing with endpoints for cloning")] public async Task GivenIHaveAHearingWithEndpointsForCloning() { - var seededHearing = await Context.TestDataManager.SeedVideoHearing(null, false, BookingStatus.Booked, 3, isMultiDayFirstHearing: true); + var seededHearing = await Context.TestDataManager.SeedVideoHearing(null, BookingStatus.Booked, 3, isMultiDayFirstHearing: true); PersistTestHearingData(seededHearing); } [Given(@"I have a hearing with linked participants")] public async Task GivenIHaveAHearingWithLinkedParticipants() { - var seededHearing = await Context.TestDataManager.SeedVideoHearing(null, false, BookingStatus.Booked, 3, false, true); + var seededHearing = await Context.TestDataManager.SeedVideoHearing(null, BookingStatus.Booked, 3, false, true); PersistTestHearingData(seededHearing); } [Given(@"I have a hearing with linked participants for cloning")] public async Task GivenIHaveAHearingWithLinkedParticipantsForCloning() { - var seededHearing = await Context.TestDataManager.SeedVideoHearing(null, false, BookingStatus.Booked, 3, false, true, isMultiDayFirstHearing: true); + var seededHearing = await Context.TestDataManager.SeedVideoHearing(null, BookingStatus.Booked, 3, false, true, isMultiDayFirstHearing: true); PersistTestHearingData(seededHearing); } @@ -75,14 +75,14 @@ public void GivenIHaveRemoveEndpointFromAHearingRequest() { var hearing = GetHearingFromDb(); Context.HttpMethod = HttpMethod.Delete; - Context.Uri = RemoveEndPointFromHearing(_hearingId, hearing.Endpoints.First().Id); + Context.Uri = RemoveEndPointFromHearing(_hearingId, hearing.Endpoints[0].Id); } [Given(@"I have update display name of an endpoint request")] public void GivenIHaveUpdateDisplayNameOfAnEndpointRequest() { var hearing = GetHearingFromDb(); - var updatedEndPointId = hearing.Endpoints.First().Id; + var updatedEndPointId = hearing.Endpoints[0].Id; PrepareUpdateEndpointRequest(_hearingId, updatedEndPointId, new UpdateEndpointRequest() { DisplayName = "UpdatedDisplayName", @@ -95,7 +95,7 @@ public void GivenIHaveUpdateDisplayNameOfAnEndpointRequest() public void GivenIHaveUpdateEndpointWithDefenceAdvocateRequest() { var hearing = GetHearingFromDb(); - var updatedEndPointId = hearing.Endpoints.First().Id; + var updatedEndPointId = hearing.Endpoints[0].Id; var rep = hearing.GetParticipants().First(x => x.HearingRole.UserRole.IsRepresentative); PrepareUpdateEndpointRequest(_hearingId, updatedEndPointId, new UpdateEndpointRequest() { diff --git a/BookingsApi/BookingsApi.IntegrationTests/Steps/HearingsSteps.cs b/BookingsApi/BookingsApi.IntegrationTests/Steps/HearingsSteps.cs index a00549853..6b7dcb132 100644 --- a/BookingsApi/BookingsApi.IntegrationTests/Steps/HearingsSteps.cs +++ b/BookingsApi/BookingsApi.IntegrationTests/Steps/HearingsSteps.cs @@ -140,7 +140,6 @@ public async Task GivenIHaveAUpdateHearingRequest(Scenario scenario) Context.TestData.UpdateHearingRequest.HearingVenueName = string.Empty; Context.TestData.UpdateHearingRequest.ScheduledDuration = 0; Context.TestData.UpdateHearingRequest.ScheduledDateTime = DateTime.Now.AddDays(-5); - Context.TestData.UpdateHearingRequest.QuestionnaireNotRequired = false; Context.TestData.UpdateHearingRequest.AudioRecordingRequired = true; } @@ -198,7 +197,7 @@ public async Task GivenIHaveAGetHearingByUsernameRequest(Scenario scenario) _hearingId = seededHearing.Id; var username = scenario switch { - Scenario.Valid => seededHearing.GetParticipants().First().Person.Username, + Scenario.Valid => seededHearing.GetParticipants()[0].Person.Username, Scenario.Nonexistent => "madeupusername@hmcts.net", _ => throw new ArgumentOutOfRangeException(nameof(scenario), scenario, null) }; @@ -362,15 +361,13 @@ public async Task ThenHearingDetailsShouldBeUpdated() .Be(Context.TestData.UpdateHearingRequest.ScheduledDateTime.ToUniversalTime()); model.HearingRoomName.Should().Be(Context.TestData.UpdateHearingRequest.HearingRoomName); model.OtherInformation.Should().Be(Context.TestData.UpdateHearingRequest.OtherInformation); - model.QuestionnaireNotRequired.Should() - .Be(Context.TestData.UpdateHearingRequest.QuestionnaireNotRequired.GetValueOrDefault()); model.AudioRecordingRequired.Should() .Be(Context.TestData.UpdateHearingRequest.AudioRecordingRequired.GetValueOrDefault()); var updatedCases = model.Cases; var caseRequest = Context.TestData.UpdateHearingRequest.Cases.FirstOrDefault(); - updatedCases.First().Name.Should().Be(caseRequest?.Name); - updatedCases.First().Number.Should().Be(caseRequest?.Number); + updatedCases[0].Name.Should().Be(caseRequest?.Name); + updatedCases[0].Number.Should().Be(caseRequest?.Number); } [Then(@"the hearing should be removed")] @@ -388,7 +385,7 @@ public async Task ThenTheResponseShouldContainAListOfBookedHearings() var model = RequestHelper.Deserialise(json); model.Hearings.Count.Should().BeGreaterThan(0); - var aHearing = model.Hearings.First().Hearings.First(); + var aHearing = model.Hearings[0].Hearings[0]; aHearing.HearingNumber.Should().NotBeNullOrEmpty(); aHearing.HearingName.Should().NotBeNullOrEmpty(); } @@ -427,23 +424,6 @@ public async Task ThenTheResponseShouldBeAnEmptyList() json.Should().BeEquivalentTo("[]"); } - [Then(@"hearing suitability answers should be retrieved")] - public async Task ThenHearingSuitabilityAnswersShouldBeRetrieved() - { - var json = await Context.Response.Content.ReadAsStringAsync(); - var model = RequestHelper.Deserialise>(json); - model[0].Should().NotBeNull(); - model[0].ParticipantId.Should().NotBeEmpty(); - model[0].ScheduledAt.Should().BeAfter(DateTime.MinValue); - model[0].UpdatedAt.Should().BeAfter(DateTime.MinValue); - model[0].CreatedAt.Should().BeAfter(DateTime.MinValue); - model[0].Answers.Should().NotBeNull(); - var firstAnswer = model[0].Answers.First(); - firstAnswer.Key.Should().NotBeEmpty(); - firstAnswer.Answer.Should().NotBeEmpty(); - firstAnswer.ExtendedAnswer.Should().NotBeEmpty(); - } - [Then(@"the service bus should have been queued with a new bookings message")] public async Task ThenTheServiceBusShouldHaveBeenQueuedWithAMessage() { @@ -550,7 +530,6 @@ private void AssertHearingDetailsResponse(HearingDetailsResponse model) model.HearingRoomName.Should().NotBeNullOrEmpty(); model.OtherInformation.Should().NotBeNullOrEmpty(); model.CreatedBy.Should().NotBeNullOrEmpty(); - model.QuestionnaireNotRequired.Should().BeFalse(); model.AudioRecordingRequired.Should().BeTrue(); model.Endpoints.Should().NotBeNullOrEmpty(); foreach (var endpointResponse in model.Endpoints) @@ -621,7 +600,6 @@ private static BookNewHearingRequest BuildRequest(string caseName) .With(x => x.Cases = cases) .With(x => x.CreatedBy = createdBy) .With(x => x.AudioRecordingRequired = true) - .With(x => x.QuestionnaireNotRequired = false) .With(x => x.Endpoints = endpoints) .Build(); } @@ -642,7 +620,6 @@ private static UpdateHearingRequest BuildUpdateHearingRequestRequest(string case ScheduledDuration = 100, HearingVenueName = "Manchester County and Family Court", OtherInformation = "OtherInfo", - QuestionnaireNotRequired = false, AudioRecordingRequired = true, HearingRoomName = "20", UpdatedBy = $"admin{usernameStem}", @@ -697,7 +674,7 @@ private async Task SetHearingIdForGivenScenario(Scenario scenario) { case Scenario.Valid: { - var seededHearing = await Context.TestDataManager.SeedVideoHearing(addSuitabilityAnswer: true); + var seededHearing = await Context.TestDataManager.SeedVideoHearing(); TestContext.WriteLine($"New seeded video hearing id: {seededHearing.Id}"); _hearingId = seededHearing.Id; Context.TestData.NewHearingId = seededHearing.Id; diff --git a/BookingsApi/BookingsApi.IntegrationTests/Steps/ParticipantsSteps.cs b/BookingsApi/BookingsApi.IntegrationTests/Steps/ParticipantsSteps.cs index d4f150bf5..f741fa4a4 100644 --- a/BookingsApi/BookingsApi.IntegrationTests/Steps/ParticipantsSteps.cs +++ b/BookingsApi/BookingsApi.IntegrationTests/Steps/ParticipantsSteps.cs @@ -216,62 +216,6 @@ public async Task ThenAListOfHearingParticipantsShouldBeRetrieved() CheckParticipantData(model); } - [Given(@"I have an update suitability answers request with a (.*) hearing id and (.*) participant id")] - [Given(@"I have an update suitability answers request with an (.*) hearing id and (.*) participant id")] - public async Task GivenIHaveAnUpdateSuitabilityAnswersRequest(Scenario hearingScenario, Scenario participantScenario) - { - var seededHearing = await Context.TestDataManager.SeedVideoHearing(); - NUnit.Framework.TestContext.WriteLine($"New seeded video hearing id: {seededHearing.Id}"); - Context.TestData.NewHearingId = seededHearing.Id; - Guid participantId; - Guid hearingId; - - switch (hearingScenario) - { - case Scenario.Valid: - { - hearingId = Context.TestData.NewHearingId; - break; - } - case Scenario.Nonexistent: - { - hearingId = Guid.NewGuid(); - break; - } - case Scenario.Invalid: - { - hearingId = Guid.Empty; - break; - } - default: throw new ArgumentOutOfRangeException(nameof(hearingScenario), hearingScenario, null); - } - switch (participantScenario) - { - case Scenario.Valid: - { - participantId = seededHearing.GetParticipants().First().Id; - break; - } - case Scenario.Nonexistent: - { - participantId = Guid.NewGuid(); - break; - } - case Scenario.Invalid: - { - participantId = Guid.Empty; - break; - } - default: throw new ArgumentOutOfRangeException(nameof(participantScenario), participantScenario, null); - } - - Context.Uri = UpdateSuitabilityAnswers(hearingId, participantId); - Context.HttpMethod = HttpMethod.Put; - var request = UpdateSuitabilityAnswersRequest(); - var jsonBody = RequestHelper.Serialise(request); - Context.HttpContent = new StringContent(jsonBody, Encoding.UTF8, "application/json"); - } - private static void CheckParticipantData(IReadOnlyCollection model) { model.Should().NotBeNull(); @@ -384,14 +328,6 @@ private static AddParticipantsToHearingRequest BuildRequest() Participants = new List { newParticipant } }; } - private List UpdateSuitabilityAnswersRequest() - { - var answers = new List - { - new SuitabilityAnswersRequest {Key = "_Key", Answer = "_Answer", ExtendedAnswer = "_ExtendedAnswer"} - }; - return answers; - } [TearDown] public async Task TearDown() diff --git a/BookingsApi/BookingsApi.IntegrationTests/Steps/PersonsSteps.cs b/BookingsApi/BookingsApi.IntegrationTests/Steps/PersonsSteps.cs index fe71a6320..2e6e33247 100644 --- a/BookingsApi/BookingsApi.IntegrationTests/Steps/PersonsSteps.cs +++ b/BookingsApi/BookingsApi.IntegrationTests/Steps/PersonsSteps.cs @@ -44,7 +44,7 @@ public async Task GivenIHaveAGetPersonByContactEmailRequest(string personType, S } else { - _username = seededHearing.GetParticipants().First().Person.ContactEmail; + _username = seededHearing.GetParticipants()[0].Person.ContactEmail; } break; } @@ -67,7 +67,7 @@ public async Task GivenIHaveAGetPersonByContactEmailSearchTermRequest() var seededHearing = await Context.TestDataManager.SeedVideoHearing(); Context.TestData.NewHearingId = seededHearing.Id; NUnit.Framework.TestContext.WriteLine($"New seeded video hearing id: {seededHearing.Id}"); - var email = seededHearing.GetParticipants().First().Person.ContactEmail; + var email = seededHearing.GetParticipants()[0].Person.ContactEmail; var searchTerm = RequestHelper.Serialise( new SearchTermRequest(email.Substring(0, 3)) ); @@ -84,7 +84,7 @@ public async Task GivenIHaveAGetPersonByContactEmailSearchTermRequestThatCaseIns var seededHearing = await Context.TestDataManager.SeedVideoHearing(); Context.TestData.NewHearingId = seededHearing.Id; NUnit.Framework.TestContext.WriteLine($"New seeded video hearing id: {seededHearing.Id}"); - var email = seededHearing.GetParticipants().First().Person.ContactEmail; + var email = seededHearing.GetParticipants()[0].Person.ContactEmail; var searchTerm = RequestHelper.Serialise( new SearchTermRequest(email.Substring(0, 3).ToUpperInvariant()) ); @@ -93,22 +93,6 @@ public async Task GivenIHaveAGetPersonByContactEmailSearchTermRequestThatCaseIns Context.HttpContent = new StringContent(searchTerm, Encoding.UTF8, "application/json"); } - [Given(@"I have a get person suitability answers by username request with an (.*) username")] - public async Task GivenIHaveAGetPersonSuitabilityAnswersByUsernameRequest(Scenario scenario) - { - await SetUserNameForGivenScenario(scenario, true, true); - Context.Uri = GetPersonSuitabilityAnswers(_username); - Context.HttpMethod = HttpMethod.Get; - } - - [Given(@"I have a get person without suitability answers by username request with an (.*) username")] - public async Task GivenIHaveAGetPersonWithoutSuitabilityAnswersByUsernameRequest(Scenario scenario) - { - await SetUserNameForGivenScenario(scenario); - Context.Uri = GetPersonSuitabilityAnswers(_username); - Context.HttpMethod = HttpMethod.Get; - } - [Given(@"I have a request to get the usernames for old hearings")] public void GivenIHaveARequestToGetTheUsernamesForOldHearings() { @@ -169,7 +153,7 @@ public void GivenIHaveANonExistentUpdatePersonDetailsRequest() public void GivenIHaveAMalformedUpdatePersonDetailsRequest() { var hearing = Context.TestData.SeededHearing; - var person = hearing.GetPersons().First(); + var person = hearing.GetPersons()[0]; var request = new UpdatePersonDetailsRequest { Username = String.Empty, @@ -185,7 +169,7 @@ public void GivenIHaveAMalformedUpdatePersonDetailsRequest() public void GivenIHaveAValidUpdatePersonDetailsRequest() { var hearing = Context.TestData.SeededHearing; - var person = hearing.GetPersons().First(); + var person = hearing.GetPersons()[0]; var request = new UpdatePersonDetailsRequest { Username = "new.me@hmcts.net", @@ -262,53 +246,19 @@ public async Task ThenAListOfHearingUsernamesShouldBeRetrieved() model.Usernames.Count.Should().Be(4); // Individual, Representative & JOH participants } - - [Then(@"suitability answers retrieved should '(.*)'")] - public async Task ThenPersonsSuitabilityAnswersShouldBeRetrieved(string scenario) - { - var json = await Context.Response.Content.ReadAsStringAsync(); - var model = RequestHelper.Deserialise>(json); - - model[0].Should().NotBeNull(); - model[0].HearingId.Should().NotBeEmpty(); - model[0].HearingId.Should().Be(Context.TestData.NewHearingId); - model[0].ParticipantId.Should().NotBeEmpty(); - model[0].ParticipantId.Should().Be(Context.TestData.Participant.Id); - model[0].ScheduledAt.Should().BeAfter(DateTime.MinValue); - model[0].QuestionnaireNotRequired.Should().Be(false); - - if(scenario == "be empty") - { - model[0].Answers.Count.Should().Be(0); - model[0].UpdatedAt.Should().Be(DateTime.MinValue); - } - else - { - model[0].Answers.Should().NotBeNull(); - model[0].Answers.Count.Should().Be(2); - model[0].UpdatedAt.Should().BeAfter(DateTime.MinValue); - } - - } - - private async Task SetUserNameForGivenScenario(Scenario scenario, bool hasSuitability = false, bool addSuitabilityAnswer = false) + + private async Task SetUserNameForGivenScenario(Scenario scenario) { switch (scenario) { case Scenario.Valid: { - var seededHearing = await Context.TestDataManager.SeedVideoHearing(addSuitabilityAnswer: addSuitabilityAnswer); + var seededHearing = await Context.TestDataManager.SeedVideoHearing(); Context.TestData.NewHearingId = seededHearing.Id; NUnit.Framework.TestContext.WriteLine($"New seeded video hearing id: {seededHearing.Id}"); var participants = seededHearing.GetParticipants(); - if(hasSuitability) - { - _username = participants.First(p => p.Questionnaire != null && p.Questionnaire.SuitabilityAnswers.Any()).Person.Username; - } - else - { - _username = participants.First().Person.Username; - } + _username = participants[0].Person.Username; + Context.TestData.Participant = participants.First(p => p.Person.Username.Equals(_username)); break; } @@ -335,7 +285,7 @@ public async Task ThenAListOfHearingsForDeletionIs(int expectedNumOfHearings) { var result = response[0]; var hearing = Context.TestData.SeededHearing; - var leadCase = hearing.GetCases().FirstOrDefault(x => x.IsLeadCase) ?? hearing.GetCases().First(); + var leadCase = hearing.GetCases().FirstOrDefault(x => x.IsLeadCase) ?? hearing.GetCases()[0]; result.HearingId.Should().Be(hearing.Id); result.Venue.Should().Be(hearing.HearingVenueName); result.ScheduledDateTime.Should().Be(hearing.ScheduledDateTime); diff --git a/BookingsApi/BookingsApi.IntegrationTests/Steps/SuitabilityAnswersSteps.cs b/BookingsApi/BookingsApi.IntegrationTests/Steps/SuitabilityAnswersSteps.cs deleted file mode 100644 index 3f231cfa5..000000000 --- a/BookingsApi/BookingsApi.IntegrationTests/Steps/SuitabilityAnswersSteps.cs +++ /dev/null @@ -1,60 +0,0 @@ -using AcceptanceTests.Common.Api.Helpers; -using BookingsApi.Contract.V1.Responses; -using TechTalk.SpecFlow; -using static Testing.Common.Builders.Api.ApiUriFactory.SuitabilityAnswerEndpoints; - -namespace BookingsApi.IntegrationTests.Steps -{ - [Binding] - public sealed class SuitabilityAnswersBaseSteps : BaseSteps - { - public SuitabilityAnswersBaseSteps(Contexts.TestContext apiTestContext) : base(apiTestContext) - { - } - - [Given(@"I have the suitable answers for participants")] - public async Task GivenIHaveTheSuitableAnswersForParticipants() - { - var seededHearing = await Context.TestDataManager.SeedVideoHearing(addSuitabilityAnswer: true); - Context.TestData.NewHearingId = seededHearing.Id; - Context.Uri = GetSuitabilityAnswers(""); - Context.HttpMethod = HttpMethod.Get; - } - - [Then(@"suitable answers should be retrieved")] - public async Task ThenSuitableAnswersShouldBeRetrieved() - { - var json = await Context.Response.Content.ReadAsStringAsync(); - var model = RequestHelper.Deserialise(json); - model.Should().NotBeNull(); - model.PrevPageUrl.Should().NotBe(model.NextPageUrl); - model.ParticipantSuitabilityAnswerResponse.Should().NotBeNull(); - model.ParticipantSuitabilityAnswerResponse.Count.Should().BeGreaterThan(0); - var participantAnswer = model.ParticipantSuitabilityAnswerResponse[0]; - participantAnswer.FirstName.Should().NotBeEmpty(); - participantAnswer.LastName.Should().NotBeEmpty(); - participantAnswer.HearingRole.Should().NotBeEmpty(); - participantAnswer.Answers.Should().NotBeNull(); - participantAnswer.Answers.Count.Should().BeGreaterThan(0); - participantAnswer.UpdatedAt.Should().Be(model.ParticipantSuitabilityAnswerResponse.Max(s => s.UpdatedAt)); - } - - [Given(@"I have a request to the second set of suitable answers")] - public async Task GivenIHaveARequestToTheSecondSetOfSuitableAnswers() - { - var firstHearing = await Context.TestDataManager.SeedVideoHearing(addSuitabilityAnswer: true); - var secondHearing = await Context.TestDataManager.SeedVideoHearing(addSuitabilityAnswer: true); - - Context.TestData.OldHearingId = firstHearing.Id; - Context.TestData.NewHearingId = secondHearing.Id; - - Context.Uri = GetSuitabilityAnswerWithLimit("", 1); - Context.HttpMethod = HttpMethod.Get; - var response = await SendGetRequestAsync(Context); - var json = await response.Content.ReadAsStringAsync(); - var bookings = RequestHelper.Deserialise(json); - - Context.Uri = GetSuitabilityAnswerWithLimit(bookings.NextCursor, 1); - } - } -} diff --git a/BookingsApi/BookingsApi.UnitTests/Controllers/HearingParticipantsController/UpdateSuitabilityAnswersTests.cs b/BookingsApi/BookingsApi.UnitTests/Controllers/HearingParticipantsController/UpdateSuitabilityAnswersTests.cs deleted file mode 100644 index 4f4b4271a..000000000 --- a/BookingsApi/BookingsApi.UnitTests/Controllers/HearingParticipantsController/UpdateSuitabilityAnswersTests.cs +++ /dev/null @@ -1,106 +0,0 @@ -using System.Collections.Generic; -using System.Net; -using BookingsApi.Contract.V1.Requests; -using BookingsApi.Domain.Participants; -using BookingsApi.DAL.Commands; -using BookingsApi.DAL.Exceptions; -using BookingsApi.DAL.Queries; -using Microsoft.AspNetCore.Mvc; -using Testing.Common.Assertions; - -namespace BookingsApi.UnitTests.Controllers.HearingParticipantsController -{ - public class UpdateSuitabilityAnswersTests : HearingParticipantsControllerTest - { - private List answers; - - [SetUp] - public void TestInitialize() - { - answers = new List { - new SuitabilityAnswersRequest { Key = "Test", Answer = "TestA" }, - new SuitabilityAnswersRequest { Key = "Tester", Answer = "TestB" } - }; - } - - [Test] - public async Task Should_update_participant_in_hearing_for_given_hearing_and_participantid() - { - - var response = await Controller.UpdateSuitabilityAnswers(hearingId, participantId, answers); - - response.Should().NotBeNull(); - var objectResult = (NoContentResult)response; - objectResult.StatusCode.Should().Be((int)HttpStatusCode.NoContent); - CommandHandler.Verify(c => c.Handle(It.IsAny()), Times.Once); - } - - [Test] - public async Task Should_return_badrequest_for_given_invalid_hearingid() - { - hearingId = Guid.Empty; - - var result = await Controller.UpdateSuitabilityAnswers(hearingId, participantId, answers); - - result.Should().NotBeNull(); - var objectResult = (BadRequestObjectResult)result; - objectResult.StatusCode.Should().Be((int)HttpStatusCode.BadRequest); - ((SerializableError)objectResult.Value).ContainsKeyAndErrorMessage(nameof(hearingId), $"Please provide a valid {nameof(hearingId)}"); - QueryHandler.Verify(q => q.Handle>(It.IsAny()), Times.Never); - } - - [Test] - public async Task Should_return_notfound_with_HearingNotFoundException() - { - CommandHandler.Setup(c => c.Handle(It.IsAny())).ThrowsAsync(new HearingNotFoundException(Guid.NewGuid())); - - var result = await Controller.UpdateSuitabilityAnswers(hearingId, participantId, answers); - - result.Should().NotBeNull(); - var objectResult = (NotFoundObjectResult)result; - objectResult.StatusCode.Should().Be((int)HttpStatusCode.NotFound); - objectResult.Value.Should().Be("Hearing not found"); - } - - [Test] - public async Task Should_return_notfound_with_ParticipantNotFoundException() - { - CommandHandler.Setup(c => c.Handle(It.IsAny())).ThrowsAsync(new ParticipantNotFoundException(Guid.NewGuid())); - - var result = await Controller.UpdateSuitabilityAnswers(hearingId, participantId, answers); - - result.Should().NotBeNull(); - var objectResult = (NotFoundObjectResult)result; - objectResult.StatusCode.Should().Be((int)HttpStatusCode.NotFound); - objectResult.Value.Should().Be("Participant not found"); - } - - [Test] - public async Task Should_return_badrequest_for_given_invalid_participantid() - { - participantId = Guid.Empty; - - var result = await Controller.UpdateSuitabilityAnswers(hearingId, participantId, answers); - - result.Should().NotBeNull(); - var objectResult = (BadRequestObjectResult)result; - objectResult.StatusCode.Should().Be((int)HttpStatusCode.BadRequest); - ((SerializableError)objectResult.Value).ContainsKeyAndErrorMessage(nameof(participantId), $"Please provide a valid {nameof(participantId)}"); - QueryHandler.Verify(q => q.Handle>(It.IsAny()), Times.Never); - } - - [Test] - public async Task Should_return_badrequest_for_given_duplicated_answers() - { - answers.Add(new SuitabilityAnswersRequest { Key = "Test", Answer = "Testb" }); - - var result = await Controller.UpdateSuitabilityAnswers(hearingId, participantId, answers); - - result.Should().NotBeNull(); - var objectResult = (BadRequestObjectResult)result; - objectResult.StatusCode.Should().Be((int)HttpStatusCode.BadRequest); - ((SerializableError)objectResult.Value).ContainsKeyAndErrorMessage(nameof(participantId), $"Request '{nameof(answers)}' cannot contain duplicate keys."); - QueryHandler.Verify(q => q.Handle>(It.IsAny()), Times.Never); - } - } -} diff --git a/BookingsApi/BookingsApi.UnitTests/Controllers/HearingsController/GetHearingsForNotificationTests.cs b/BookingsApi/BookingsApi.UnitTests/Controllers/HearingsController/GetHearingsForNotificationTests.cs index 6ec131271..b6857ba3d 100644 --- a/BookingsApi/BookingsApi.UnitTests/Controllers/HearingsController/GetHearingsForNotificationTests.cs +++ b/BookingsApi/BookingsApi.UnitTests/Controllers/HearingsController/GetHearingsForNotificationTests.cs @@ -27,12 +27,12 @@ public async Task Should_Return_List_Of_Hearings_For_Notifcations() hearing2.UpdateStatus(BookingStatus.Created, "administrator", string.Empty); hearing2.UpdateHearingDetails(new HearingVenue(1, "venue1"), DateTime.Now.AddDays(2), - 15, "123", "note", "administrator", new List { new Case("123", "name") }, true, true); + 15, "123", "note", "administrator", new List { new Case("123", "name") }, true); var hearing3 = GetHearing("1232", caseNames); hearing3.UpdateStatus(BookingStatus.Created, "administrator", string.Empty); hearing2.UpdateHearingDetails(new HearingVenue(1, "venue1"), DateTime.Now.AddDays(2), - 15, "123", "note", "administrator", new List { new Case("123", "name") }, true, true); + 15, "123", "note", "administrator", new List { new Case("123", "name") }, true); var hearingList = new List { hearing1, hearing2, hearing3 }; diff --git a/BookingsApi/BookingsApi.UnitTests/Controllers/HearingsController/Helpers/RequestBuilderV1.cs b/BookingsApi/BookingsApi.UnitTests/Controllers/HearingsController/Helpers/RequestBuilderV1.cs index b6e7ee1c2..575f1073c 100644 --- a/BookingsApi/BookingsApi.UnitTests/Controllers/HearingsController/Helpers/RequestBuilderV1.cs +++ b/BookingsApi/BookingsApi.UnitTests/Controllers/HearingsController/Helpers/RequestBuilderV1.cs @@ -25,7 +25,6 @@ public static BookNewHearingRequest Build() .With(x => x.LinkedParticipants = linkedParticipants) .With(x => x.Cases = cases) .With(x => x.CreatedBy = createdBy) - .With(x => x.QuestionnaireNotRequired = false) .With(x => x.Endpoints = new List { new EndpointRequest { DisplayName = "Cool endpoint 1" } }) .Build(); diff --git a/BookingsApi/BookingsApi.UnitTests/Controllers/HearingsController/UpdateHearingDetailsTests.cs b/BookingsApi/BookingsApi.UnitTests/Controllers/HearingsController/UpdateHearingDetailsTests.cs index e6d2e7a33..69107cc2b 100644 --- a/BookingsApi/BookingsApi.UnitTests/Controllers/HearingsController/UpdateHearingDetailsTests.cs +++ b/BookingsApi/BookingsApi.UnitTests/Controllers/HearingsController/UpdateHearingDetailsTests.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using BookingsApi.Contract.V1.Requests; using BookingsApi.Contract.V1.Responses; -using BookingsApi.Mappings; using BookingsApi.Domain; using BookingsApi.Domain.Enumerations; using BookingsApi.DAL.Queries; @@ -26,7 +25,6 @@ public async Task should_send_message_to_bqs_with_updated_hearing() ScheduledDateTime = DateTime.Today.AddDays(2), HearingRoomName = "Updated room name", HearingVenueName = "Updated venue name", - QuestionnaireNotRequired = false, AudioRecordingRequired = true, Cases = null }; @@ -36,8 +34,7 @@ public async Task should_send_message_to_bqs_with_updated_hearing() updatedHearing.SetProtected(nameof(updatedHearing.Id), videoHearing.Id); updatedHearing.UpdateHearingDetails(newVenue, request.ScheduledDateTime, request.ScheduledDuration, request.HearingRoomName, request.OtherInformation, - request.UpdatedBy, new List(), request.QuestionnaireNotRequired.Value, - request.AudioRecordingRequired.Value); + request.UpdatedBy, new List(), request.AudioRecordingRequired.Value); updatedHearing.UpdateStatus(BookingStatus.Created, "initial", null); QueryHandlerMock diff --git a/BookingsApi/BookingsApi.UnitTests/Controllers/Persons/GetPersonSuitabilityAnswersTests.cs b/BookingsApi/BookingsApi.UnitTests/Controllers/Persons/GetPersonSuitabilityAnswersTests.cs deleted file mode 100644 index 9b8851b6b..000000000 --- a/BookingsApi/BookingsApi.UnitTests/Controllers/Persons/GetPersonSuitabilityAnswersTests.cs +++ /dev/null @@ -1,123 +0,0 @@ -using System.Collections.Generic; -using System.Net; -using BookingsApi.Contract.V1.Responses; -using BookingsApi.Domain; -using BookingsApi.Domain.Participants; -using BookingsApi.DAL.Queries; -using Microsoft.AspNetCore.Mvc; -using Testing.Common.Assertions; - -namespace BookingsApi.UnitTests.Controllers.Persons -{ - public class GetPersonSuitabilityAnswersTests : PersonsControllerTest - { - - [Test] - public async Task Should_return_empty_list_of_suitability_answers_if_no_hearings() - { - var userName = "userName@hmcts.net"; - QueryHandlerMock - .Setup(x => x.Handle>(It.IsAny())) - .ReturnsAsync(new List()); - - var result = await Controller.GetPersonSuitabilityAnswers(userName); - - result.Should().NotBeNull(); - var objectResult = result as ObjectResult; - var data = (List)(objectResult.Value); - data.Count.Should().Be(0); - objectResult.StatusCode.Should().Be((int)HttpStatusCode.OK); - } - - [Test] - public async Task Should_return_empty_list_of_suitability_answers_if_not_found_username() - { - var videoHearing = TestData(false); - QueryHandlerMock - .Setup(x => x.Handle>(It.IsAny())) - .ReturnsAsync(new List { videoHearing }); - var userName = videoHearing.Participants.First(p => p is Individual).Person.Username; - var result = await Controller.GetPersonSuitabilityAnswers(userName); - - result.Should().NotBeNull(); - - var objectResult = result as ObjectResult; - var data = (List)(objectResult.Value); - data.Count.Should().BeGreaterThan(0); - data[0].Answers.Count.Should().Be(0); - objectResult.StatusCode.Should().Be((int)HttpStatusCode.OK); - } - - [Test] - public async Task Should_return_list_of_suitability_answers() - { - var hearing = TestData(); - var userName = hearing.Participants[0].Person.Username; - QueryHandlerMock - .Setup(x => x.Handle>(It.IsAny())) - .ReturnsAsync(new List { hearing }); - - var result = await Controller.GetPersonSuitabilityAnswers(userName); - - result.Should().NotBeNull(); - - var objectResult = result as ObjectResult; - var data = (List)(objectResult.Value); - data.Count.Should().Be(1); - data[0].Answers.Count.Should().Be(1); - data[0].Answers[0].Key.Should().Be("AboutYou"); - data[0].UpdatedAt.Date.Should().Be(DateTime.Now.AddDays(-2).Date); - objectResult.StatusCode.Should().Be((int)HttpStatusCode.OK); - } - - [Test] - public async Task Should_return_badrequest_for_invalid_username() - { - var username = string.Empty; - - var result = await Controller.GetPersonSuitabilityAnswers(username); - - result.Should().NotBeNull(); - var objectResult = (BadRequestObjectResult)result; - objectResult.StatusCode.Should().Be((int)HttpStatusCode.BadRequest); - ((SerializableError)objectResult.Value).ContainsKeyAndErrorMessage(nameof(username), $"Please provide a valid {nameof(username)}"); - } - - [Test] - public async Task Should_return_empty_list_of_suitability_answers_if_no_matched_participant_with_username() - { - var hearing = TestData(); - var userName = "some@hmcts.net"; - - QueryHandlerMock - .Setup(x => x.Handle>(It.IsAny())) - .ReturnsAsync(new List { hearing }); - - var result = await Controller.GetPersonSuitabilityAnswers(userName); - - result.Should().NotBeNull(); - - var objectResult = result as ObjectResult; - var data = (List)(objectResult.Value); - data.Count.Should().Be(0); - objectResult.StatusCode.Should().Be((int)HttpStatusCode.OK); - } - - [Test] - public async Task Should_return_list_of_usernames_for_old_hearings() - { - var usernameList = new List { "testUser1@hmcts.net", "testUser2@hmcts.net", "testUser3@hmcts.net" }; - QueryHandlerMock - .Setup(x => x.Handle>(It.IsAny())) - .ReturnsAsync(usernameList); - - var result = await Controller.GetPersonByClosedHearings(); - result.Should().NotBeNull(); - var objectResult = result as ObjectResult; - var response = (UserWithClosedConferencesResponse)(objectResult.Value); - response.Usernames.Count.Should().Be(3); - QueryHandlerMock - .Verify(x => x.Handle>(It.IsAny()), Times.Once); - } - } -} diff --git a/BookingsApi/BookingsApi.UnitTests/Controllers/Persons/PersonsControllerTest.cs b/BookingsApi/BookingsApi.UnitTests/Controllers/Persons/PersonsControllerTest.cs index 9121ff226..0a4d20c5c 100644 --- a/BookingsApi/BookingsApi.UnitTests/Controllers/Persons/PersonsControllerTest.cs +++ b/BookingsApi/BookingsApi.UnitTests/Controllers/Persons/PersonsControllerTest.cs @@ -1,7 +1,4 @@ -using BookingsApi.Controllers; -using BookingsApi.Controllers.V1; -using BookingsApi.Domain; -using BookingsApi.Domain.Participants; +using BookingsApi.Controllers.V1; using BookingsApi.DAL.Commands.Core; using BookingsApi.DAL.Queries.Core; using BookingsApi.Infrastructure.Services.IntegrationEvents; @@ -27,33 +24,5 @@ public void Setup() Controller = new PersonsController(QueryHandlerMock.Object, CommandHandlerMock.Object, EventPublisherMock.Object, LoggerMock.Object); } - - protected VideoHearing TestData(bool addSuitability = true) - { - var builder = new VideoHearingBuilder(); - var hearing = builder.Build(); - if (addSuitability) - { - var participant = hearing.Participants.FirstOrDefault(p => p is Individual); - if (participant != null) - { - var answer = new SuitabilityAnswer("AboutYou", "Yes", "") - { - UpdatedDate = DateTime.Now.AddDays(-2) - }; - - participant.Questionnaire = new Questionnaire - { - Participant = participant, - ParticipantId = participant.Id - }; - - participant.Questionnaire.SuitabilityAnswers.Add(answer); - participant.Questionnaire.UpdatedDate = DateTime.Now.AddDays(-2); - } - - } - return hearing; - } } } diff --git a/BookingsApi/BookingsApi.UnitTests/Controllers/SuitabilityAnswersControllerTests.cs b/BookingsApi/BookingsApi.UnitTests/Controllers/SuitabilityAnswersControllerTests.cs deleted file mode 100644 index de2a28ac8..000000000 --- a/BookingsApi/BookingsApi.UnitTests/Controllers/SuitabilityAnswersControllerTests.cs +++ /dev/null @@ -1,85 +0,0 @@ -using BookingsApi.Controllers; -using BookingsApi.Domain; -using BookingsApi.Domain.Participants; -using Microsoft.AspNetCore.Mvc; -using System.Collections.Generic; -using System.Net; -using BookingsApi.Contract.V1.Responses; -using BookingsApi.Controllers.V1; -using BookingsApi.DAL.Queries; -using BookingsApi.DAL.Queries.Core; - -namespace BookingsApi.UnitTests.Controllers -{ - public class SuitabilityAnswersControllerTests - { - private Mock queryHandler; - private SuitabilityAnswersController suitabilityAnswersController; - - [SetUp] - public void TestInitialize() - { - var builder = new VideoHearingBuilder(); - var hearing = builder.Build(); - var participants = new List { Create(hearing, "Test", "Tester", 1), Create(hearing, "Tester", "Test", 2) }; - - queryHandler = new Mock(); - queryHandler.Setup(q => - q.Handle>(It.IsAny())) - .ReturnsAsync(new CursorPagedResult(participants, "next-cursor")); - - suitabilityAnswersController = new SuitabilityAnswersController(queryHandler.Object); - } - - private Participant Create(VideoHearing hearing,string fName, string lName,int addHour) - { - var participant = new Mock(); - participant.SetupGet(p => p.Hearing).Returns(hearing); - participant.SetupGet(p => p.Questionnaire).Returns(new Questionnaire { UpdatedDate = DateTime.Now.AddHours(addHour) }); - participant.SetupGet(p => p.Person).Returns(new Person("Mr", fName, lName, "me@me.com", $"{fName} {lName}")); - participant.SetupGet(p => p.HearingRole).Returns(new BookingsApi.Domain.RefData.HearingRole(1,"Test")); - - return participant.Object; - } - - [Test] - public async Task Should_return_SuitabilityAnswersResponse_without_cursor_for_given_query() - { - var result = await suitabilityAnswersController.GetSuitabilityAnswers("0",1); - - result.Should().NotBeNull(); - var objectResult = (ObjectResult)result.Result; - objectResult.Should().NotBeNull(); - objectResult.StatusCode.Should().Be((int)HttpStatusCode.OK); - var suitabilityAnswer = (SuitabilityAnswersResponse) objectResult.Value; - suitabilityAnswer.PrevPageUrl.Should().Be("suitability-answers/?cursor=0&limit=1"); - suitabilityAnswer.NextPageUrl.Should().Be("suitability-answers/?cursor=next-cursor&limit=1"); - suitabilityAnswer.NextCursor.Should().Be("next-cursor"); - suitabilityAnswer.ParticipantSuitabilityAnswerResponse[0].FirstName.Should().Be("Tester"); - suitabilityAnswer.ParticipantSuitabilityAnswerResponse[0].CaseNumber.Should().BeNullOrEmpty(); - suitabilityAnswer.ParticipantSuitabilityAnswerResponse[0].Representee.Should().BeNullOrEmpty(); - suitabilityAnswer.ParticipantSuitabilityAnswerResponse[1].FirstName.Should().Be("Test"); - queryHandler.Verify(q => - q.Handle>(It.Is(g => g.Cursor == null)), - Times.Once); - } - - [Test] - public async Task Should_return_SuitabilityAnswersResponse_with_cursor_for_given_query() - { - var result = await suitabilityAnswersController.GetSuitabilityAnswers("2", 1); - - result.Should().NotBeNull(); - var objectResult = (ObjectResult)result.Result; - objectResult.Should().NotBeNull(); - objectResult.StatusCode.Should().Be((int)HttpStatusCode.OK); - var suitabilityAnswer = (SuitabilityAnswersResponse)objectResult.Value; - suitabilityAnswer.PrevPageUrl.Should().Be("suitability-answers/?cursor=2&limit=1"); - suitabilityAnswer.NextPageUrl.Should().Be("suitability-answers/?cursor=next-cursor&limit=1"); - suitabilityAnswer.NextCursor.Should().Be("next-cursor"); - queryHandler.Verify(q => - q.Handle>(It.Is(g => g.Cursor == "2")), - Times.Once); - } - } -} diff --git a/BookingsApi/BookingsApi.UnitTests/Controllers/WorkAllocationsController/GetUnallocatedHearingsTests.cs b/BookingsApi/BookingsApi.UnitTests/Controllers/WorkAllocationsController/GetUnallocatedHearingsTests.cs index dbae04e6d..4c9e3e556 100644 --- a/BookingsApi/BookingsApi.UnitTests/Controllers/WorkAllocationsController/GetUnallocatedHearingsTests.cs +++ b/BookingsApi/BookingsApi.UnitTests/Controllers/WorkAllocationsController/GetUnallocatedHearingsTests.cs @@ -28,7 +28,7 @@ public async Task Should_Return_List_Of_Unallocated_Hearings() hearing2.UpdateStatus(BookingStatus.Created, "administrator", string.Empty); hearing2.UpdateHearingDetails(new HearingVenue(1, "venue1"), DateTime.Now.AddDays(2), - 15, "123", "note", "administrator", new List { new Case("123", "name") }, true, true); + 15, "123", "note", "administrator", new List { new Case("123", "name") }, true); var hearingList = new List { hearing1, hearing2 }; diff --git a/BookingsApi/BookingsApi.UnitTests/DAL/Queries/GetHearingShellQueryTest.cs b/BookingsApi/BookingsApi.UnitTests/DAL/Queries/GetHearingShellQueryTest.cs index f993fcf69..49e100771 100644 --- a/BookingsApi/BookingsApi.UnitTests/DAL/Queries/GetHearingShellQueryTest.cs +++ b/BookingsApi/BookingsApi.UnitTests/DAL/Queries/GetHearingShellQueryTest.cs @@ -31,11 +31,10 @@ public void InitialSetup() var hearingRoomName = "Roome03"; var otherInformation = "OtherInformation03"; var createdBy = "User03"; - const bool questionnaireNotRequired = false; const bool audioRecordingRequired = true; var cancelReason = "Online abandonment (incomplete registration)"; _hearing = new VideoHearing(caseType, hearingType, scheduledDateTime, duration, venue, hearingRoomName, - otherInformation, createdBy, questionnaireNotRequired, audioRecordingRequired, cancelReason); + otherInformation, createdBy, audioRecordingRequired, cancelReason); _context.VideoHearings.Add(_hearing); _context.SaveChangesAsync(); } diff --git a/BookingsApi/BookingsApi.UnitTests/DAL/Services/HearingAllocationServiceTests.cs b/BookingsApi/BookingsApi.UnitTests/DAL/Services/HearingAllocationServiceTests.cs index a5a1fe2c6..243b9cc5d 100644 --- a/BookingsApi/BookingsApi.UnitTests/DAL/Services/HearingAllocationServiceTests.cs +++ b/BookingsApi/BookingsApi.UnitTests/DAL/Services/HearingAllocationServiceTests.cs @@ -1397,13 +1397,12 @@ private VideoHearing CreateHearing(DateTime scheduledDateTime, int duration = 60 var hearingRoomName = "Room03"; var otherInformation = "OtherInformation03"; var createdBy = "User03"; - const bool questionnaireNotRequired = false; const bool audioRecordingRequired = true; var cancelReason = "Online abandonment (incomplete registration)"; var videoHearing = Builder.CreateNew().WithFactory(() => new VideoHearing(_caseType, _hearingType, scheduledDateTime, duration, _hearingVenue, hearingRoomName, - otherInformation, createdBy, questionnaireNotRequired, audioRecordingRequired, cancelReason)) + otherInformation, createdBy, audioRecordingRequired, cancelReason)) .Build(); // Set the navigation properties as well since these would've been set if we got the hearing from DB diff --git a/BookingsApi/BookingsApi.UnitTests/Domain/AnonymisationData/GetAnonymisationDataQueryHandlerTests.cs b/BookingsApi/BookingsApi.UnitTests/Domain/AnonymisationData/GetAnonymisationDataQueryHandlerTests.cs index da980d708..afbe27ad8 100644 --- a/BookingsApi/BookingsApi.UnitTests/Domain/AnonymisationData/GetAnonymisationDataQueryHandlerTests.cs +++ b/BookingsApi/BookingsApi.UnitTests/Domain/AnonymisationData/GetAnonymisationDataQueryHandlerTests.cs @@ -74,13 +74,13 @@ public async Task var hearing1 = new VideoHearing(_caseType1, hearingType, DateTime.Today, 40, new HearingVenue(1, "venue 1"), - Faker.Name.First(), Faker.Name.First(), null, true, false, null); + Faker.Name.First(), Faker.Name.First(), null, false, null); var hearing2 = new VideoHearing(_caseType1, hearingType, DateTime.Today, 40, new HearingVenue(1, "venue 1"), - Faker.Name.First(), Faker.Name.First(), null, true, false, null); + Faker.Name.First(), Faker.Name.First(), null, false, null); hearing1.AddJudge(_person1, _hearingRole1, _judgeCaseRole, "Judge 123"); hearing1.AddIndividual(_person2, _hearingRole2, _individualCaseRole, "Individual 123"); @@ -116,13 +116,13 @@ public async Task GetAnonymisationDataQuery_Filters_Out_Username_Included_In_Fut var hearing1 = new VideoHearing(_caseType1, hearingType, DateTime.Today, 40, new HearingVenue(1, "venue 1"), - Faker.Name.First(), Faker.Name.First(), null, true, false, null); + Faker.Name.First(), Faker.Name.First(), null, false, null); var hearing2 = new VideoHearing(_caseType1, hearingType, DateTime.Today, 40, new HearingVenue(1, "venue 1"), - Faker.Name.First(), Faker.Name.First(), null, true, false, null); + Faker.Name.First(), Faker.Name.First(), null, false, null); hearing1.AddJudge(_person1, _hearingRole1, _judgeCaseRole, "Judge 123"); hearing1.AddIndividual(_person2, _hearingRole2, _individualCaseRole, "Individual 123"); @@ -160,13 +160,13 @@ public async Task var hearing1 = new VideoHearing(_caseType1, hearingType, DateTime.Today, 40, new HearingVenue(1, "venue 1"), - Faker.Name.First(), Faker.Name.First(), null, true, false, null); + Faker.Name.First(), Faker.Name.First(), null, false, null); var hearing2 = new VideoHearing(_caseType1, hearingType, DateTime.Today, 40, new HearingVenue(1, "venue 1"), - Faker.Name.First(), Faker.Name.First(), null, true, false, null); + Faker.Name.First(), Faker.Name.First(), null, false, null); hearing1.AddJudge(_person1, _hearingRole1, _judgeCaseRole, "Judge 123"); hearing1.AddIndividual(_person2, _hearingRole2, _individualCaseRole, "Individual 123"); @@ -200,19 +200,19 @@ public async Task var hearing1 = new VideoHearing(_caseType1, hearingType, DateTime.Today, 40, new HearingVenue(1, "venue 1"), - Faker.Name.First(), Faker.Name.First(), null, true, false, null); + Faker.Name.First(), Faker.Name.First(), null, false, null); var hearing2 = new VideoHearing(_caseType1, hearingType, DateTime.Today, 40, new HearingVenue(1, "venue 1"), - Faker.Name.First(), Faker.Name.First(), null, true, false, null); + Faker.Name.First(), Faker.Name.First(), null, false, null); var hearing3 = new VideoHearing(_caseType1, hearingType, DateTime.Today, 40, new HearingVenue(1, "venue 1"), - Faker.Name.First(), Faker.Name.First(), null, true, false, null); + Faker.Name.First(), Faker.Name.First(), null, false, null); hearing1.AddJudge(_person1, _hearingRole1, _judgeCaseRole, "Judge 123"); hearing1.AddIndividual(_person2, _hearingRole2, _individualCaseRole, "Individual 123"); @@ -253,13 +253,13 @@ public async Task GetAnonymisationDataQuery_Filters_Out_Anonymised_Usernames() var hearing1 = new VideoHearing(_caseType1, hearingType, DateTime.Today, 40, new HearingVenue(1, "venue 1"), - Faker.Name.First(), Faker.Name.First(), null, true, false, null); + Faker.Name.First(), Faker.Name.First(), null, false, null); var hearing2 = new VideoHearing(_caseType1, hearingType, DateTime.Today, 40, new HearingVenue(1, "venue 1"), - Faker.Name.First(), Faker.Name.First(), null, true, false, null); + Faker.Name.First(), Faker.Name.First(), null, false, null); hearing1.AddJudge(_person1, _hearingRole1, _judgeCaseRole, "Judge 123"); hearing1.AddIndividual(_person2, _hearingRole2, _individualCaseRole, "Individual 123"); @@ -298,13 +298,13 @@ public async Task Filters_Out_Automation_Test_Account_Usernames(string username) var hearing1 = new VideoHearing(_caseType1, hearingType, DateTime.Today, 40, new HearingVenue(1, "venue 1"), - Faker.Name.First(), Faker.Name.First(), null, true, false, null); + Faker.Name.First(), Faker.Name.First(), null, false, null); var hearing2 = new VideoHearing(_caseType1, hearingType, DateTime.Today, 40, new HearingVenue(1, "venue 1"), - Faker.Name.First(), Faker.Name.First(), null, true, false, null); + Faker.Name.First(), Faker.Name.First(), null, false, null); var automationTestAccountPersonEntry = new Person(Faker.Name.Suffix(), Faker.Name.First(), Faker.Name.Last(), Faker.Internet.Email(), username); diff --git a/BookingsApi/BookingsApi.UnitTests/Domain/Hearing/UpdateHearingDetailsTests.cs b/BookingsApi/BookingsApi.UnitTests/Domain/Hearing/UpdateHearingDetailsTests.cs index efa592ca3..469e8c930 100644 --- a/BookingsApi/BookingsApi.UnitTests/Domain/Hearing/UpdateHearingDetailsTests.cs +++ b/BookingsApi/BookingsApi.UnitTests/Domain/Hearing/UpdateHearingDetailsTests.cs @@ -20,7 +20,6 @@ public void Should_update_hearing_details() var updatedBy = "testuser"; var caseName = "CaseName Update"; var caseNumber = "CaseNumber Update"; - const bool questionnaireNotRequired = false; const bool audioRecordingRequired = true; var casesToUpdate = new List @@ -29,12 +28,12 @@ public void Should_update_hearing_details() }; hearing.UpdateHearingDetails(newVenue, newDateTime, newDuration, - hearingRoomName, otherInformation, updatedBy, casesToUpdate, questionnaireNotRequired, audioRecordingRequired); + hearingRoomName, otherInformation, updatedBy, casesToUpdate, audioRecordingRequired); hearing.UpdatedDate.Should().BeAfter(beforeUpdatedDate); var updatedCases = hearing.GetCases(); - updatedCases.First().Name.Should().Be(caseName); - updatedCases.First().Number.Should().Be(caseNumber); + updatedCases[0].Name.Should().Be(caseName); + updatedCases[0].Number.Should().Be(caseNumber); } [Test] @@ -48,11 +47,10 @@ public void Should_throw_exception_when_validation_fails() var newDuration = -10; var updatedBy = "testuser"; var cases = new List(); - const bool questionnaireNotRequired = false; const bool audioRecordingRequired = true; Action action = () => hearing.UpdateHearingDetails(newVenue, newDateTime, newDuration, - string.Empty, string.Empty, updatedBy, cases, questionnaireNotRequired, audioRecordingRequired); + string.Empty, string.Empty, updatedBy, cases, audioRecordingRequired); action.Should().Throw() .And.ValidationFailures.Should() .Contain(x => x.Name == "ScheduledDuration") diff --git a/BookingsApi/BookingsApi.UnitTests/Domain/Hearing/ValidateArgumentsTests.cs b/BookingsApi/BookingsApi.UnitTests/Domain/Hearing/ValidateArgumentsTests.cs index c6e55a082..0dd41a55e 100644 --- a/BookingsApi/BookingsApi.UnitTests/Domain/Hearing/ValidateArgumentsTests.cs +++ b/BookingsApi/BookingsApi.UnitTests/Domain/Hearing/ValidateArgumentsTests.cs @@ -11,7 +11,7 @@ public void Should_throw_exception_when_validation_fails() // ReSharper disable once ObjectCreationAsStatement Action action = () => new VideoHearing(null, null, default(DateTime), 0, - null, null, null, null, false, true, null); + null, null, null, null, true, null); action.Should().Throw() .And.ValidationFailures.Should() diff --git a/BookingsApi/BookingsApi.UnitTests/Domain/Participants/AnonymiseCaseAndParticipantCommandTests.cs b/BookingsApi/BookingsApi.UnitTests/Domain/Participants/AnonymiseCaseAndParticipantCommandTests.cs index f67c92b26..bc7d9fd79 100644 --- a/BookingsApi/BookingsApi.UnitTests/Domain/Participants/AnonymiseCaseAndParticipantCommandTests.cs +++ b/BookingsApi/BookingsApi.UnitTests/Domain/Participants/AnonymiseCaseAndParticipantCommandTests.cs @@ -225,17 +225,17 @@ private async Task SeedHearings() _hearing1 = new VideoHearing(_caseType1, hearingType, DateTime.Today, 40, new HearingVenue(1, "venue 1"), - Faker.Name.First(), Faker.Name.First(), null, true, false, null); + Faker.Name.First(), Faker.Name.First(), null, false, null); _hearing2 = new VideoHearing(_caseType1, hearingType, DateTime.Today, 40, new HearingVenue(1, "venue 1"), - Faker.Name.First(), Faker.Name.First(), null, true, false, null); + Faker.Name.First(), Faker.Name.First(), null, false, null); _hearing3 = new VideoHearing(_caseType1, hearingType, DateTime.Today, 40, new HearingVenue(1, "venue 1"), - Faker.Name.First(), Faker.Name.First(), null, true, false, null); + Faker.Name.First(), Faker.Name.First(), null, false, null); _hearing1.AddJudge(_person1, _hearingRole1, _judgeCaseRole, "Judge 123"); _hearing1.AddIndividual(_person2, _hearingRole2, _individualCaseRole, "Individual 123"); diff --git a/BookingsApi/BookingsApi.UnitTests/Mappings/V1/CloneHearingToCommandMapperTests.cs b/BookingsApi/BookingsApi.UnitTests/Mappings/V1/CloneHearingToCommandMapperTests.cs index 649ff46d6..4d8d1ae18 100644 --- a/BookingsApi/BookingsApi.UnitTests/Mappings/V1/CloneHearingToCommandMapperTests.cs +++ b/BookingsApi/BookingsApi.UnitTests/Mappings/V1/CloneHearingToCommandMapperTests.cs @@ -81,8 +81,6 @@ public void should_map_hearing_to_command() x.DisplayName == ep.DisplayName && x.DefenceAdvocate?.Person?.ContactEmail == ep.ContactEmail).Should().NotBeNull(); } - - command.QuestionnaireNotRequired.Should().BeTrue(); command.AudioRecordingRequired.Should().Be(hearing.AudioRecordingRequired); } } diff --git a/BookingsApi/BookingsApi.UnitTests/Mappings/V1/HearingToDetailResponseMapperTests.cs b/BookingsApi/BookingsApi.UnitTests/Mappings/V1/HearingToDetailResponseMapperTests.cs index f86c68450..a750324cc 100644 --- a/BookingsApi/BookingsApi.UnitTests/Mappings/V1/HearingToDetailResponseMapperTests.cs +++ b/BookingsApi/BookingsApi.UnitTests/Mappings/V1/HearingToDetailResponseMapperTests.cs @@ -30,12 +30,11 @@ public void Should_map_all_properties() var hearingRoomName = "Roome03"; var otherInformation = "OtherInformation03"; var createdBy = "User03"; - const bool questionnaireNotRequired = false; const bool audioRecordingRequired = true; var cancelReason = "Online abandonment (incomplete registration)"; var hearing = new VideoHearing(caseType, hearingType, scheduledDateTime, duration, venue, hearingRoomName, - otherInformation, createdBy, questionnaireNotRequired, audioRecordingRequired, cancelReason); + otherInformation, createdBy, audioRecordingRequired, cancelReason); _videoHearing = Builder.CreateNew().WithFactory(() => hearing).Build(); diff --git a/BookingsApi/BookingsApi.UnitTests/Mappings/V1/SuitabilityAnswerToResonseMappingTest.cs b/BookingsApi/BookingsApi.UnitTests/Mappings/V1/SuitabilityAnswerToResonseMappingTest.cs deleted file mode 100644 index 66c0107a8..000000000 --- a/BookingsApi/BookingsApi.UnitTests/Mappings/V1/SuitabilityAnswerToResonseMappingTest.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System.Collections.Generic; -using BookingsApi.Domain; -using BookingsApi.Mappings.V1; -using BookingsApi.UnitTests.Utilities; - -namespace BookingsApi.UnitTests.Mappings.V1 -{ - public class SuitabilityAnswerToResonseMappingTest : TestBase - { - private IList suitabilityAnswers; - private SuitabilityAnswerToResponseMapper mapper; - - [SetUp] - public void SetUp() - { - mapper = new SuitabilityAnswerToResponseMapper(); - - var answer1 = new SuitabilityAnswer("AboutYou", "Yes",null); - var answer2 = new SuitabilityAnswer("AboutClient", "No", "note"); - var answer3 = new SuitabilityAnswer("AboutCpmputer", "Yes", ""); - - suitabilityAnswers = new List { answer1, answer2, answer3 }; - } - - [Test] - public void Should_map_suitability_answears_items_to_response_list() - { - var result = mapper.MapToResponses(suitabilityAnswers); - result.Should().NotBeNull(); - result.Count.Should().Be(3); - } - - [Test] - public void Should_map_suitability_answear_to_response_model() - { - var result = mapper.MapToResponses(suitabilityAnswers); - result[0].Key.Should().BeSameAs("AboutYou"); - result[0].Answer.Should().BeSameAs("Yes"); - result[0].ExtendedAnswer.Should().BeNull(); - - result[1].Key.Should().BeSameAs("AboutClient"); - result[1].Answer.Should().BeSameAs("No"); - result[1].ExtendedAnswer.Should().BeSameAs("note"); - } - - [Test] - public void Should_returns_empty_list_if_suitability_answears_is_empty_list() - { - suitabilityAnswers = new List(); - var result = mapper.MapToResponses(suitabilityAnswers); - result.Should().NotBeNull(); - result.Count.Should().Be(0); - } - - [Test] - public void Should_returns_empty_list_if_suitability_answears_is_null() - { - suitabilityAnswers = null; - var result = mapper.MapToResponses(suitabilityAnswers); - result.Should().NotBeNull(); - result.Count.Should().Be(0); - } - } -} diff --git a/BookingsApi/BookingsApi.UnitTests/Mappings/V1/VideoHearingToBookingsResponseMapperTest.cs b/BookingsApi/BookingsApi.UnitTests/Mappings/V1/VideoHearingToBookingsResponseMapperTest.cs index 81877218a..873b8f176 100644 --- a/BookingsApi/BookingsApi.UnitTests/Mappings/V1/VideoHearingToBookingsResponseMapperTest.cs +++ b/BookingsApi/BookingsApi.UnitTests/Mappings/V1/VideoHearingToBookingsResponseMapperTest.cs @@ -26,7 +26,6 @@ public void Should_return_mapped_hearings_grouped_by_date() var firstGroup = mappedHearings[0]; firstGroup.ScheduledDate.Should().Be(hearings[0].ScheduledDateTime.Date); firstGroup.Hearings.Count.Should().Be(1); - firstGroup.Hearings[0].QuestionnaireNotRequired.Should().BeFalse(); firstGroup.Hearings[0].AudioRecordingRequired.Should().BeTrue(); firstGroup.Hearings[0].CancelReason.Should().Be(hearings[0].CancelReason); firstGroup.Hearings[0].GroupId.Should().Be(hearings[0].Id); @@ -51,7 +50,6 @@ private static VideoHearing MockHearingAtDate(DateTime datetime, bool audioRecor mockedHearing.OtherInformation, "admin@hmcts.net", updatedCases, - false, audioRecordingRequired ); mockedHearing.IsFirstDayOfMultiDayHearing = isMultiDayFirstHearing; diff --git a/BookingsApi/BookingsApi/Controllers/V1/HearingParticipantsController.cs b/BookingsApi/BookingsApi/Controllers/V1/HearingParticipantsController.cs index 4797c42a2..f39ef27e5 100644 --- a/BookingsApi/BookingsApi/Controllers/V1/HearingParticipantsController.cs +++ b/BookingsApi/BookingsApi/Controllers/V1/HearingParticipantsController.cs @@ -456,67 +456,6 @@ public async Task UpdateParticipantDetails(Guid hearingId, Guid p return Ok(response); } - /// - /// Updates suitability answers for the participant - /// - /// Id of hearing - /// Id of participant - /// A list of suitability answers to update - /// Http status - [HttpPut("{hearingId}/participants/{participantId}/suitability-answers")] - [OpenApiOperation("UpdateSuitabilityAnswers")] - [ProducesResponseType(typeof(ValidationProblemDetails), (int)HttpStatusCode.BadRequest)] - [ProducesResponseType((int)HttpStatusCode.NotFound)] - [ProducesResponseType((int)HttpStatusCode.NoContent)] - [MapToApiVersion("1.0")] - public async Task UpdateSuitabilityAnswers(Guid hearingId, Guid participantId, [FromBody]List answers) - { - if (hearingId == Guid.Empty) - { - ModelState.AddModelError(nameof(hearingId), $"Please provide a valid {nameof(hearingId)}"); - return BadRequest(ModelState); - } - - if (participantId == Guid.Empty) - { - ModelState.AddModelError(nameof(participantId), $"Please provide a valid {nameof(participantId)}"); - return BadRequest(ModelState); - } - - // Reject any requests with duplicate keys - var duplicateKeyFound = answers.GroupBy(x => x.Key).Any(g => g.Count() > 1); - if (duplicateKeyFound) - { - ModelState.AddModelError(nameof(participantId), $"Request '{nameof(answers)}' cannot contain duplicate keys."); - return BadRequest(ModelState); - } - - var suitabilityAnswers = answers.Select(answer => new SuitabilityAnswer(answer.Key, answer.Answer, answer.ExtendedAnswer)) - .ToList(); - - var command = new UpdateSuitabilityAnswersCommand(hearingId, participantId, suitabilityAnswers); - - try - { - await _commandHandler.Handle(command); - } - catch (DomainRuleException e) - { - ModelState.AddDomainRuleErrors(e.ValidationFailures); - return BadRequest(ModelState); - } - catch (HearingNotFoundException) - { - return NotFound("Hearing not found"); - } - catch (ParticipantNotFoundException) - { - return NotFound("Participant not found"); - } - - return NoContent(); - } - private static List CreateParticipantResponseList(IEnumerable participants) { if (participants.Any()) diff --git a/BookingsApi/BookingsApi/Controllers/V1/HearingsController.cs b/BookingsApi/BookingsApi/Controllers/V1/HearingsController.cs index 8bb37a295..bc0b03376 100644 --- a/BookingsApi/BookingsApi/Controllers/V1/HearingsController.cs +++ b/BookingsApi/BookingsApi/Controllers/V1/HearingsController.cs @@ -437,13 +437,12 @@ public async Task UpdateHearingDetails(Guid hearingId, [FromBody] // use existing video hearing values here when request properties are null request.AudioRecordingRequired ??= videoHearing.AudioRecordingRequired; - request.QuestionnaireNotRequired = false; request.HearingRoomName ??= videoHearing.HearingRoomName; request.OtherInformation ??= videoHearing.OtherInformation; var command = new UpdateHearingCommand(hearingId, request.ScheduledDateTime, request.ScheduledDuration, venue, request.HearingRoomName, request.OtherInformation, - request.UpdatedBy, cases, request.QuestionnaireNotRequired.Value, request.AudioRecordingRequired.Value); + request.UpdatedBy, cases, request.AudioRecordingRequired.Value); var updatedHearing = await _bookingService.UpdateHearingAndPublish(command, videoHearing); var response = HearingToDetailsResponseMapper.Map(updatedHearing); diff --git a/BookingsApi/BookingsApi/Controllers/V1/PersonsController.cs b/BookingsApi/BookingsApi/Controllers/V1/PersonsController.cs index 3d6af9415..f330475f5 100644 --- a/BookingsApi/BookingsApi/Controllers/V1/PersonsController.cs +++ b/BookingsApi/BookingsApi/Controllers/V1/PersonsController.cs @@ -140,35 +140,6 @@ public async Task PostPersonBySearchTerm(SearchTermRequest term) return Ok(response); } - /// - /// Get a list of suitability answers for a given person - /// - /// The username of the person - /// A list of suitability answers - [HttpGet("username/{username}/suitability-answers")] - [OpenApiOperation("GetPersonSuitabilityAnswers")] - [ProducesResponseType(typeof(List), (int)HttpStatusCode.OK)] - [ProducesResponseType(typeof(ValidationProblemDetails), (int)HttpStatusCode.BadRequest)] - [ProducesResponseType((int)HttpStatusCode.NotFound)] - [Obsolete("This method is deprecated.")] - [ExcludeFromCodeCoverage] - [MapToApiVersion("1.0")] - public async Task GetPersonSuitabilityAnswers(string username) - { - if (!username.IsValidEmail()) - { - ModelState.AddModelError(nameof(username), $"Please provide a valid {nameof(username)}"); - return BadRequest(ModelState); - } - - var query = new GetHearingsByUsernameQuery(username); - var hearings = await _queryHandler.Handle>(query); - - var personSuitabilityAnswers = hearings.Select(hearing => BuildResponse(hearing, username)).Where(s => s != null).ToList(); - - return Ok(personSuitabilityAnswers); - } - /// /// Get list of person from the old hearings /// @@ -333,30 +304,6 @@ public async Task>> UpdatePersonDetails([From return Accepted(); } - - private static PersonSuitabilityAnswerResponse BuildResponse(Hearing hearing, string username) - { - PersonSuitabilityAnswerResponse personSuitabilityAnswer = null; - if (hearing.Participants != null) { - var participant = hearing.Participants.FirstOrDefault(p => p.Person.Username.ToLower() == username.Trim().ToLower()); - if (participant != null) - { - var answers = participant.Questionnaire != null ? participant.Questionnaire.SuitabilityAnswers : new List(); - var suitabilityAnswerToResponseMapper = new SuitabilityAnswerToResponseMapper(); - personSuitabilityAnswer = new PersonSuitabilityAnswerResponse - { - HearingId = hearing.Id, - ParticipantId = participant.Id, - UpdatedAt = participant.Questionnaire?.UpdatedDate ?? DateTime.MinValue, - ScheduledAt = hearing.ScheduledDateTime, - Answers = suitabilityAnswerToResponseMapper.MapToResponses(answers), - QuestionnaireNotRequired = hearing.QuestionnaireNotRequired - }; - } - } - - return personSuitabilityAnswer; - } /// /// Updates the person's user name diff --git a/BookingsApi/BookingsApi/Controllers/V1/SuitabilityAnswersController.cs b/BookingsApi/BookingsApi/Controllers/V1/SuitabilityAnswersController.cs deleted file mode 100644 index 550d5b67b..000000000 --- a/BookingsApi/BookingsApi/Controllers/V1/SuitabilityAnswersController.cs +++ /dev/null @@ -1,62 +0,0 @@ -using BookingsApi.Contract.V1.Responses; -using BookingsApi.Mappings.V1; - -namespace BookingsApi.Controllers.V1 -{ - [Produces("application/json")] - [Route("suitability-answers")] - [ApiVersion("1.0")] - [ApiController] - public class SuitabilityAnswersController : Controller - { - private const string DefaultCursor = "0"; - private const int DefaultLimit = 100; - - private readonly IQueryHandler _queryHandler; - - public SuitabilityAnswersController(IQueryHandler queryHandler) - { - _queryHandler = queryHandler; - } - - /// - /// Get a cursor based list of suitability answers - /// - /// Cursor specifying from which entries to read next page, is defaulted if not specified - /// The max number hearings records to return. - /// The list of latest suitability answers for participants - [HttpGet] - [OpenApiOperation("GetSuitabilityAnswers")] - [ProducesResponseType(typeof(SuitabilityAnswersResponse), (int)HttpStatusCode.OK)] - [ProducesResponseType(typeof(ValidationProblemDetails), (int)HttpStatusCode.BadRequest)] - public async Task> GetSuitabilityAnswers([FromQuery]string cursor = DefaultCursor, [FromQuery]int limit = DefaultLimit) - { - - var query = new GetParticipantWithSuitabilityAnswersQuery() - { - Cursor = cursor == DefaultCursor ? null : cursor, - Limit = limit - }; - var result = await _queryHandler.Handle>(query); - - var mapper = new SuitabilityAnswersListToResponseMapper(); - - var response = new SuitabilityAnswersResponse - { - PrevPageUrl = BuildCursorPageUrl(cursor, limit), - NextPageUrl = BuildCursorPageUrl(result.NextCursor, limit), - NextCursor = result.NextCursor, - Limit = limit, - ParticipantSuitabilityAnswerResponse = mapper.MapParticipantSuitabilityAnswerResponses(result) - }; - - return Ok(response); - } - - private string BuildCursorPageUrl(string cursor, int limit) - { - const string resourceUrl = "suitability-answers/"; - return $"{resourceUrl}?cursor={cursor}&limit={limit}"; - } - } -} diff --git a/BookingsApi/BookingsApi/Controllers/V2/HearingsControllerV2.cs b/BookingsApi/BookingsApi/Controllers/V2/HearingsControllerV2.cs index d93d2980d..fe1046ed2 100644 --- a/BookingsApi/BookingsApi/Controllers/V2/HearingsControllerV2.cs +++ b/BookingsApi/BookingsApi/Controllers/V2/HearingsControllerV2.cs @@ -154,7 +154,7 @@ public async Task UpdateHearingDetails(Guid hearingId, [FromBody] var command = new UpdateHearingCommand(hearingId, request.ScheduledDateTime, request.ScheduledDuration, venue, request.HearingRoomName, request.OtherInformation, - request.UpdatedBy, cases, false, request.AudioRecordingRequired.Value); + request.UpdatedBy, cases, request.AudioRecordingRequired.Value); var updatedHearing = await _bookingService.UpdateHearingAndPublish(command, videoHearing); var response = HearingToDetailsResponseV2Mapper.Map(updatedHearing); diff --git a/BookingsApi/BookingsApi/Extensions/RequestBodyLoggingMiddleware.cs b/BookingsApi/BookingsApi/Extensions/RequestBodyLoggingMiddleware.cs index bd36ce3b2..e559239dc 100644 --- a/BookingsApi/BookingsApi/Extensions/RequestBodyLoggingMiddleware.cs +++ b/BookingsApi/BookingsApi/Extensions/RequestBodyLoggingMiddleware.cs @@ -22,7 +22,7 @@ public async Task InvokeAsync(HttpContext context) context.Request.EnableBuffering(); // Only if we are dealing with POST or PUT, GET and others shouldn't have a body - if (context.Request.Body.CanRead && (method == HttpMethods.Post || method == HttpMethods.Put)) + if (context.Request.Body.CanRead && (method == HttpMethods.Post || method == HttpMethods.Put || method == HttpMethods.Patch)) { // Leave stream open so next middleware can read it using var reader = new StreamReader( diff --git a/BookingsApi/BookingsApi/Mappings/V1/BookNewHearingRequestToCreateVideoHearingCommandMapper.cs b/BookingsApi/BookingsApi/Mappings/V1/BookNewHearingRequestToCreateVideoHearingCommandMapper.cs index 293cb2e82..ca288ef3b 100644 --- a/BookingsApi/BookingsApi/Mappings/V1/BookNewHearingRequestToCreateVideoHearingCommandMapper.cs +++ b/BookingsApi/BookingsApi/Mappings/V1/BookNewHearingRequestToCreateVideoHearingCommandMapper.cs @@ -17,14 +17,13 @@ public static CreateVideoHearingCommand Map( var newEndpoints = MapEndpoints(request, randomGenerator, sipAddressStem); var linkedParticipants = MapLinkedParticipants(request); - return new CreateVideoHearingCommand(caseType, hearingType, - request.ScheduledDateTime, request.ScheduledDuration, venue, newParticipants, cases, - request.QuestionnaireNotRequired, request.AudioRecordingRequired, newEndpoints, linkedParticipants, request.IsMultiDayHearing) - { - HearingRoomName = request.HearingRoomName, - OtherInformation = request.OtherInformation, - CreatedBy = request.CreatedBy - }; + return new CreateVideoHearingCommand( + new CreateVideoHearingRequiredDto(caseType, hearingType, request.ScheduledDateTime, + request.ScheduledDuration, venue, cases), + new CreateVideoHearingOptionalDto(newParticipants, request.HearingRoomName, request.OtherInformation, request.CreatedBy, + request.AudioRecordingRequired, newEndpoints, null, linkedParticipants, + new List(), request.IsMultiDayHearing, null) + ); } private static List MapParticipants(BookNewHearingRequest request, CaseType caseType) diff --git a/BookingsApi/BookingsApi/Mappings/V1/HearingToDetailsResponseMapper.cs b/BookingsApi/BookingsApi/Mappings/V1/HearingToDetailsResponseMapper.cs index 8902e2f6a..63d693aef 100644 --- a/BookingsApi/BookingsApi/Mappings/V1/HearingToDetailsResponseMapper.cs +++ b/BookingsApi/BookingsApi/Mappings/V1/HearingToDetailsResponseMapper.cs @@ -41,7 +41,6 @@ public static HearingDetailsResponse Map(Hearing videoHearing) ConfirmedBy = videoHearing.ConfirmedBy, ConfirmedDate = videoHearing.ConfirmedDate, Status = videoHearing.Status.MapToContractEnum(), - QuestionnaireNotRequired = videoHearing.QuestionnaireNotRequired, AudioRecordingRequired = videoHearing.AudioRecordingRequired, CancelReason = videoHearing.CancelReason, GroupId = videoHearing.SourceId, diff --git a/BookingsApi/BookingsApi/Mappings/V1/SuitabilityAnswerToResponseMapper.cs b/BookingsApi/BookingsApi/Mappings/V1/SuitabilityAnswerToResponseMapper.cs deleted file mode 100644 index 1c147119c..000000000 --- a/BookingsApi/BookingsApi/Mappings/V1/SuitabilityAnswerToResponseMapper.cs +++ /dev/null @@ -1,22 +0,0 @@ -using BookingsApi.Contract.V1.Responses; - -namespace BookingsApi.Mappings.V1 -{ - public class SuitabilityAnswerToResponseMapper - { - public IList MapToResponses(IList answers) - { - return answers != null ? answers.Select(Map).ToList() : new List(); - } - - private static SuitabilityAnswerResponse Map(SuitabilityAnswer answer) - { - return new SuitabilityAnswerResponse - { - Key = answer.Key, - Answer = answer.Data, - ExtendedAnswer = answer.ExtendedData - }; - } - } -} diff --git a/BookingsApi/BookingsApi/Mappings/V1/SuitabilityAnswersListToResponseMapper.cs b/BookingsApi/BookingsApi/Mappings/V1/SuitabilityAnswersListToResponseMapper.cs deleted file mode 100644 index 50b7a97d6..000000000 --- a/BookingsApi/BookingsApi/Mappings/V1/SuitabilityAnswersListToResponseMapper.cs +++ /dev/null @@ -1,35 +0,0 @@ -using BookingsApi.Contract.V1.Responses; - -namespace BookingsApi.Mappings.V1 -{ - public class SuitabilityAnswersListToResponseMapper - { - public List MapParticipantSuitabilityAnswerResponses(IEnumerable participants) - { - var mapped = participants.Select(MapParticipantResponse); - return mapped.OrderByDescending(x => x.UpdatedAt).ToList(); - } - - public ParticipantSuitabilityAnswerResponse MapParticipantResponse(Participant participant) - { - var @case = participant.Hearing.GetCases().FirstOrDefault(); - var @representative = participant as Representative; - var answerMapper = new SuitabilityAnswerToResponseMapper(); - - var response = new ParticipantSuitabilityAnswerResponse - { - CaseNumber = @case != null ? @case.Number : string.Empty, - ParticipantId = participant.Id, - Title = participant.Person.Title, - FirstName = participant.Person.FirstName, - LastName = participant.Person.LastName, - HearingRole = participant.HearingRole.Name, - UpdatedAt = participant.Questionnaire.UpdatedDate, - Representee = @representative != null ? @representative.Representee : string.Empty, - Answers = answerMapper.MapToResponses(participant.Questionnaire.SuitabilityAnswers) - }; - - return response; - } - } -} diff --git a/BookingsApi/BookingsApi/Mappings/V1/VideoHearingToBookingsResponseMapper.cs b/BookingsApi/BookingsApi/Mappings/V1/VideoHearingToBookingsResponseMapper.cs index 5766b0edd..213b06593 100644 --- a/BookingsApi/BookingsApi/Mappings/V1/VideoHearingToBookingsResponseMapper.cs +++ b/BookingsApi/BookingsApi/Mappings/V1/VideoHearingToBookingsResponseMapper.cs @@ -53,7 +53,6 @@ public BookingsHearingResponse MapHearingResponse(VideoHearing videoHearing) ConfirmedDate = videoHearing.ConfirmedDate, JudgeName = judgeName, Status = videoHearing.Status.MapToContractEnum(), - QuestionnaireNotRequired = videoHearing.QuestionnaireNotRequired, AudioRecordingRequired = videoHearing.AudioRecordingRequired, CancelReason = videoHearing.CancelReason, GroupId = videoHearing.SourceId, diff --git a/BookingsApi/BookingsApi/Mappings/V2/BookNewHearingRequestV2ToCreateVideoHearingCommandMapper.cs b/BookingsApi/BookingsApi/Mappings/V2/BookNewHearingRequestV2ToCreateVideoHearingCommandMapper.cs index 9fbdd0341..5a5e63ce4 100644 --- a/BookingsApi/BookingsApi/Mappings/V2/BookNewHearingRequestV2ToCreateVideoHearingCommandMapper.cs +++ b/BookingsApi/BookingsApi/Mappings/V2/BookNewHearingRequestV2ToCreateVideoHearingCommandMapper.cs @@ -20,16 +20,13 @@ public static CreateVideoHearingCommand Map( var linkedParticipants = MapLinkedParticipants(requestV2); var judiciaryParticipants = MapJudiciaryParticipants(requestV2); - return new CreateVideoHearingCommand(caseType, hearingType, - requestV2.ScheduledDateTime, requestV2.ScheduledDuration, venue, newParticipants, cases, - false, requestV2.AudioRecordingRequired, newEndpoints, linkedParticipants, - requestV2.IsMultiDayHearing) - { - HearingRoomName = requestV2.HearingRoomName, - OtherInformation = requestV2.OtherInformation, - CreatedBy = requestV2.CreatedBy, - JudiciaryParticipants = judiciaryParticipants - }; + return new CreateVideoHearingCommand( + new CreateVideoHearingRequiredDto(caseType, hearingType, requestV2.ScheduledDateTime, + requestV2.ScheduledDuration, venue, cases), + new CreateVideoHearingOptionalDto(newParticipants, requestV2.HearingRoomName, requestV2.OtherInformation, + requestV2.CreatedBy, requestV2.AudioRecordingRequired, newEndpoints, null, linkedParticipants, + judiciaryParticipants, requestV2.IsMultiDayHearing, null) + ); } private static List MapJudiciaryParticipants(BookNewHearingRequestV2 requestV2) diff --git a/BookingsApi/Testing.Common/Builders/Api/ApiUriFactory.cs b/BookingsApi/Testing.Common/Builders/Api/ApiUriFactory.cs index 89f98838f..9a4e4a80d 100644 --- a/BookingsApi/Testing.Common/Builders/Api/ApiUriFactory.cs +++ b/BookingsApi/Testing.Common/Builders/Api/ApiUriFactory.cs @@ -83,7 +83,6 @@ public static class ParticipantsEndpoints public static string AddParticipantsToHearing(Guid hearingId) => $"{ApiRoot}/{hearingId}/participants"; public static string RemoveParticipantFromHearing(Guid hearingId, Guid participantId) => $"{ApiRoot}/{hearingId}/participants/{participantId}"; public static string UpdateParticipantDetails(Guid hearingId, Guid participantId) => $"{ApiRoot}/{hearingId}/participants/{participantId}"; - public static string UpdateSuitabilityAnswers(Guid hearingId, Guid participantId) => $"{ApiRoot}/{hearingId}/participants/{participantId}/suitability-answers"; } public static class PersonEndpoints @@ -92,7 +91,6 @@ public static class PersonEndpoints public static string GetPersonByUsername(string username) => $"{ApiRoot}/username/{username}"; public static string GetPersonByContactEmail(string contactEmail) => $"{ApiRoot}/contactEmail/{contactEmail}"; public static string PostPersonBySearchTerm => $"{ApiRoot}"; - public static string GetPersonSuitabilityAnswers(string username) => $"{ApiRoot}/username/{username}/suitability-answers"; public static string GetPersonByClosedHearings() => $"{ApiRoot}/userswithclosedhearings"; public static string GetHearingsByUsernameForDeletion(string username) => $"{ApiRoot}/username/hearings?username={username}"; public static string AnonymisePerson(string username) => $"{ApiRoot}/username/{username}/anonymise"; @@ -100,13 +98,6 @@ public static class PersonEndpoints public static string UpdatePersonDetails(Guid personId) => $"{ApiRoot}/{personId}"; public static string UpdatePersonUsername(string contactEmail, string username) => $"{ApiRoot}/user/{contactEmail}?username={username}"; } - - public static class SuitabilityAnswerEndpoints - { - private const string ApiRoot = "suitability-answers"; - public static string GetSuitabilityAnswers(string cursor) => $"{ApiRoot}/{cursor}"; - public static string GetSuitabilityAnswerWithLimit(string cursor = "", int limit = 100) => $"{ApiRoot}/?cursor={cursor}&limit={limit}"; - } public static class JVEndPointEndpoints { diff --git a/BookingsApi/Testing.Common/Builders/Api/V1/Request/SimpleBookNewHearingRequest.cs b/BookingsApi/Testing.Common/Builders/Api/V1/Request/SimpleBookNewHearingRequest.cs index 6d150a9f0..1f966feee 100644 --- a/BookingsApi/Testing.Common/Builders/Api/V1/Request/SimpleBookNewHearingRequest.cs +++ b/BookingsApi/Testing.Common/Builders/Api/V1/Request/SimpleBookNewHearingRequest.cs @@ -85,7 +85,6 @@ public SimpleBookNewHearingRequest(string caseName, DateTime scheduledDateTime) .With(x => x.Participants = participants) .With(x => x.Cases = cases) .With(x => x.CreatedBy = createdBy) - .With(x => x.QuestionnaireNotRequired = false) .With(x => x.AudioRecordingRequired = true) .Build(); } diff --git a/BookingsApi/Testing.Common/Builders/Domain/ParticipantBuilder.cs b/BookingsApi/Testing.Common/Builders/Domain/ParticipantBuilder.cs index c5d30e1b6..8d61cb56d 100644 --- a/BookingsApi/Testing.Common/Builders/Domain/ParticipantBuilder.cs +++ b/BookingsApi/Testing.Common/Builders/Domain/ParticipantBuilder.cs @@ -1,5 +1,4 @@ using BookingsApi.Domain.Participants; -using BookingsApi.Domain; using BookingsApi.Domain.RefData; using System.Collections.Generic; @@ -30,45 +29,18 @@ public ParticipantBuilder() _individualParticipant1 = new Individual(person1, applicantLipHearingRole, applicantCaseRole); _individualParticipant1.HearingRole = applicantLipHearingRole; - _individualParticipant1.Questionnaire = new Questionnaire - { - Participant = _individualParticipant1, - ParticipantId = _individualParticipant1.Id - }; - _individualParticipant1.Questionnaire.AddSuitabilityAnswers(ListOfSuitabilityAnswers()); - + _individualParticipant2 = new Individual(person2, respondentLipHearingRole, respondentCaseRole); _individualParticipant2.HearingRole = respondentLipHearingRole; - _individualParticipant2.Questionnaire = new Questionnaire - { - Participant = _individualParticipant2, - ParticipantId = _individualParticipant2.Id - }; - _individualParticipant2.Questionnaire.AddSuitabilityAnswers(ListOfSuitabilityAnswers()); - + _representativeParticipant = new Representative(person3, respondentRepresentativeHearingRole, respondentCaseRole); _representativeParticipant.HearingRole = respondentRepresentativeHearingRole; - _representativeParticipant.Questionnaire = new Questionnaire - { - Participant = _representativeParticipant, - ParticipantId = _representativeParticipant.Id - }; - _representativeParticipant.Questionnaire.AddSuitabilityAnswers(ListOfSuitabilityAnswers()); - + _participants.Add(_individualParticipant1); _participants.Add(_individualParticipant2); _participants.Add(_representativeParticipant); } - private List ListOfSuitabilityAnswers() - { - var answer1 = new SuitabilityAnswer("ABOUT_YOU", "No", ""); - var answer2 = new SuitabilityAnswer("ABOUT_YOUR_COMPUTER", "No", "Note"); - var answer3 = new SuitabilityAnswer("CONSENT", "YES", ""); - - return new List { answer1, answer2, answer3 }; - } - public Participant IndividualParticipantApplicant => _individualParticipant1; public Participant IndividualParticipantRespondent => _individualParticipant2; public Participant RepresentativeParticipantRespondent => _representativeParticipant; diff --git a/BookingsApi/Testing.Common/Builders/Domain/VideoHearingBuilder.cs b/BookingsApi/Testing.Common/Builders/Domain/VideoHearingBuilder.cs index e6147daf4..42922bcc2 100644 --- a/BookingsApi/Testing.Common/Builders/Domain/VideoHearingBuilder.cs +++ b/BookingsApi/Testing.Common/Builders/Domain/VideoHearingBuilder.cs @@ -29,13 +29,12 @@ public VideoHearingBuilder(DateTime? scheduledDateTime = null, bool addJudge = t var hearingRoomName = "Roome03"; var otherInformation = "OtherInformation03"; var createdBy = "User03"; - const bool questionnaireNotRequired = false; const bool audioRecordingRequired = true; var cancelReason = "Online abandonment (incomplete registration)"; _videoHearing = Builder.CreateNew().WithFactory(() => new VideoHearing(caseType, hearingType, scheduledDateTime.GetValueOrDefault(defaultDate), duration, venue, hearingRoomName, - otherInformation, createdBy, questionnaireNotRequired, audioRecordingRequired, cancelReason)) + otherInformation, createdBy, audioRecordingRequired, cancelReason)) .Build(); var applicantCaseRole = new CaseRole(1, "Applicant") { Group = CaseRoleGroup.Applicant }; diff --git a/BookingsApi/Testing.Common/Configuration/TestData.cs b/BookingsApi/Testing.Common/Configuration/TestData.cs index 97ad5ba53..fb29738c0 100644 --- a/BookingsApi/Testing.Common/Configuration/TestData.cs +++ b/BookingsApi/Testing.Common/Configuration/TestData.cs @@ -14,7 +14,6 @@ public TestData() TestContextData = new Dictionary(); } - public List Answers { get; set; } public string CaseName { get; set; } public BookNewHearingRequest CreateHearingRequest { get; set; } public HearingDetailsResponse Hearing { get; set; }