Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VIH-10899 upgrade bookings api client #1449

Merged
merged 18 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 26 additions & 19 deletions AdminWebsite/AdminWebsite.IntegrationTests/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,20 @@
},
"BookingsApi.Client": {
"type": "Transitive",
"resolved": "2.3.9",
"contentHash": "Bzwufird9sw4QpyCuJBQpcNDuAZXmZWCjLMdoYyFUDdRlJm1xE9uMXaaOyYK2FFPE5WfLAftC/o0nYhhSgFeiQ==",
"resolved": "3.1.9",
"contentHash": "szk1pTukvzHsprWASvwtdTvoHCbm5RC5Lnj1wYmSC+/I/s1uyoL7uLbauV2s84znk2xssLpol4N7Fyxl5wJGAw==",
"dependencies": {
"Microsoft.AspNetCore.Mvc.Core": "2.2.5"
"BookingsApi.Common.DotNet6": "3.1.9",
"Microsoft.AspNetCore.Mvc.Core": "2.2.5",
"System.Text.Json": "8.0.5"
}
},
"BookingsApi.Common.DotNet6": {
"type": "Transitive",
"resolved": "3.1.9",
"contentHash": "3rSoSlmcZw4+uxPIj+KpBAI6WjIk2ntsEGc75oGDD7fQM+qpEDCuIn4xSid1fcO6sdQ2Dkd/8/3c0k2dyL+yeg==",
"dependencies": {
"System.Text.Json": "8.0.5"
}
},
"Castle.Core": {
Expand Down Expand Up @@ -933,8 +943,8 @@
},
"Microsoft.Identity.Client": {
"type": "Transitive",
"resolved": "4.61.0",
"contentHash": "3TDPEie+9t/NgBhoNifLFwM6nkypYUa8GUHfMnkYtovDDTQM8bsS2KEIP5tAh28BgfJZgof/KlCEKvGxz0H3Eg==",
"resolved": "4.61.3",
"contentHash": "naJo/Qm35Caaoxp5utcw+R8eU8ZtLz2ALh8S+gkekOYQ1oazfCQMWVT4NJ/FnHzdIJlm8dMz0oMpMGCabx5odA==",
"dependencies": {
"Microsoft.IdentityModel.Abstractions": "6.35.0",
"System.Diagnostics.DiagnosticSource": "6.0.1"
Expand Down Expand Up @@ -1170,8 +1180,8 @@
},
"NotificationApi.Client": {
"type": "Transitive",
"resolved": "2.3.4",
"contentHash": "BwxsCI+DORSasyvqktvdWt2jUJIrxwTgLDVx/3sOBDJkqMKJsn+glINBsQ7/kgyldaZningYYuasa3+JIFSVKA==",
"resolved": "3.0.5",
"contentHash": "UErWgWJUm2TEb9yqEHxIzaGr7AFcqnjqRLu8legaYNOMFd1WVzuKYEBzEdMM1x8gHjTLofcIAIaRUqUx0LIFLg==",
"dependencies": {
"Microsoft.AspNetCore.Mvc.Core": "2.2.5",
"Newtonsoft.Json": "13.0.3"
Expand Down Expand Up @@ -2026,11 +2036,8 @@
},
"System.Text.Json": {
"type": "Transitive",
"resolved": "8.0.0",
"contentHash": "OdrZO2WjkiEG6ajEFRABTRCi/wuXQPxeV6g8xvUJqdxMvvuCCEk86zPla8UiIQJz3durtUEbNyY/3lIhS0yZvQ==",
"dependencies": {
"System.Text.Encodings.Web": "8.0.0"
}
"resolved": "8.0.5",
"contentHash": "0f1B50Ss7rqxXiaBJyzUu9bWFOO2/zSlifZ/UNMdiIpDYe4cY4LQQicP4nirK1OS31I43rn062UIJ1Q9bpmHpg=="
},
"System.Text.RegularExpressions": {
"type": "Transitive",
Expand Down Expand Up @@ -2143,18 +2150,18 @@
},
"VideoApi.Client": {
"type": "Transitive",
"resolved": "2.2.26",
"contentHash": "tkKsLUUKliw5iPA8It+R/Fv+oKsCwdeQfWFWHVhU+/mfNG2bT89L9SHDvjqLIXawTV35pigCRuidPaYt641sow==",
"resolved": "3.1.7",
"contentHash": "l7/NvSybO0/k+rAg1jY78hjZrQ1v2P/qdmh75gJeK+tax3Ukwc0G6+QvKbvlbetzU1TjKf2GFrublKZ5h1OdMg==",
"dependencies": {
"Microsoft.AspNetCore.Mvc.Core": "2.2.5",
"Newtonsoft.Json": "13.0.3"
"System.Text.Json": "8.0.4"
}
},
"adminwebsite": {
"type": "Project",
"dependencies": {
"AspNetCore.HealthChecks.Uris": "[8.0.1, )",
"BookingsApi.Client": "[2.3.9, )",
"BookingsApi.Client": "[3.1.9, )",
"FluentValidation.AspNetCore": "[11.3.0, )",
"LaunchDarkly.ServerSdk": "[8.5.0, )",
"MicroElements.Swashbuckle.FluentValidation": "[6.0.0, )",
Expand All @@ -2165,19 +2172,19 @@
"Microsoft.AspNetCore.SpaServices": "[3.1.32, )",
"Microsoft.AspNetCore.SpaServices.Extensions": "[8.0.4, )",
"Microsoft.Graph": "[5.52.0, )",
"Microsoft.Identity.Client": "[4.61.0, )",
"Microsoft.Identity.Client": "[4.61.3, )",
"Microsoft.OpenApi": "[1.6.14, )",
"Microsoft.VisualStudio.Azure.Containers.Tools.Targets": "[1.20.1, )",
"NWebsec.AspNetCore.Middleware": "[3.0.0, )",
"NotificationApi.Client": "[2.3.4, )",
"NotificationApi.Client": "[3.0.5, )",
"Polly": "[8.4.0, )",
"Swashbuckle.AspNetCore": "[6.6.1, )",
"Swashbuckle.AspNetCore.Annotations": "[6.6.1, )",
"Swashbuckle.AspNetCore.Newtonsoft": "[6.6.1, )",
"Swashbuckle.AspNetCore.Swagger": "[6.6.1, )",
"TimeZoneConverter": "[6.1.0, )",
"UserApi.Client": "[2.1.1, )",
"VideoApi.Client": "[2.2.26, )"
"VideoApi.Client": "[3.1.7, )"
}
},
"adminwebsite.testing.common": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Microsoft.AspNetCore.Routing;
using AdminWebsite.Models;
using AdminWebsite.UnitTests.Controllers;
using BookingsApi.Contract.V1.Requests;
using BookingsApi.Contract.V2.Requests;

namespace AdminWebsite.UnitTests.Attributes
{
Expand All @@ -29,12 +29,11 @@ public void OnActionExecuting_Strips_Out_Invalid_Characters_BookNewHearingReques
var request = context.ActionArguments
.Should().NotBeNull()
.And.ContainKey("request")
.WhoseValue.As<BookNewHearingRequest>()
.WhoseValue.As<BookNewHearingRequestV2>()
.Should().NotBeNull()
.And.Subject.As<BookNewHearingRequest>();
.And.Subject.As<BookNewHearingRequestV2>();

request.HearingRoomName.Should().BeEquivalentTo(expectedText);
request.HearingVenueName.Should().BeEquivalentTo(expectedText);
request.OtherInformation.Should().BeEquivalentTo(expectedText);
request.Cases.Should().OnlyContain(x => x.Name == expectedText && x.Number == expectedText);
request.Participants.Should().OnlyContain
Expand Down Expand Up @@ -90,9 +89,9 @@ public void OnActionExecuting_invalid_request_will_not_sanitizer(string inputTex
var request = context.ActionArguments
.Should().NotBeNull()
.And.ContainKey("nothing")
.WhoseValue.As<BookNewHearingRequest>()
.WhoseValue.As<BookNewHearingRequestV2>()
.Should().NotBeNull()
.And.Subject.As<BookNewHearingRequest>();
.And.Subject.As<BookNewHearingRequestV2>();

request.HearingRoomName.Should().BeEquivalentTo(inputText);

Expand All @@ -102,18 +101,17 @@ private static ActionExecutingContext CreateBookNewHearingRequestContext(string
{
var actionArguments = new Dictionary<string, object>
{
{ requestKey, new BookNewHearingRequest
{ requestKey, new BookNewHearingRequestV2
{
HearingRoomName = text,
HearingVenueName = text,
OtherInformation = text,
Cases = new List<CaseRequest>
Cases = new List<CaseRequestV2>
{
new CaseRequest{Name = text, Number = text}
new(){Name = text, Number = text}
},
Participants = new List<BookingsApi.Contract.V1.Requests.ParticipantRequest>
Participants = new List<ParticipantRequestV2>
{
new BookingsApi.Contract.V1.Requests.ParticipantRequest
new()
{
Title = text,
FirstName = text,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.AspNetCore.Mvc;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
using BookingsApi.Contract.V2.Responses;

namespace AdminWebsite.UnitTests.Controllers
{
Expand Down Expand Up @@ -56,7 +57,7 @@ public async Task Should_return_booking_list_if_cursor_is_not_null()
.ReturnsAsync(new BookingsResponse());
_userIdentity.Setup(x => x.GetGroupDisplayNames()).Returns(new List<string> { "type1", "type2" });

_bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(new List<CaseTypeResponse>());
_bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(new List<CaseTypeResponseV2>());

var request = new BookingSearchRequest
{
Expand Down Expand Up @@ -115,8 +116,8 @@ public async Task Should_throw_exception_for_booking_list_and_returns_bad_result
public async Task Should_return_ok_for_booking_list_with_null_types_in_database()
{
SetupTestCase();
List<CaseTypeResponse> response = null;
_bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(response);
List<CaseTypeResponseV2> response = null;
_bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(response);

var request = new BookingSearchRequest
{
Expand All @@ -135,8 +136,8 @@ public async Task Should_return_ok_for_booking_list_with_empty_list_of_types()
{
SetupTestCase();

var response = new List<CaseTypeResponse>();
_bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(response);
var response = new List<CaseTypeResponseV2>();
_bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(response);

var request = new BookingSearchRequest
{
Expand All @@ -156,19 +157,19 @@ public async Task
{
SetupTestCase();

var response = new List<CaseTypeResponse>
var response = new List<CaseTypeResponseV2>
{
new CaseTypeResponse
new CaseTypeResponseV2()
{
HearingTypes = new List<HearingTypeResponse>(), Id = 1, Name = "type3"
Id = 1, Name = "type3"
},
new CaseTypeResponse
new CaseTypeResponseV2
{
HearingTypes = new List<HearingTypeResponse>(), Id = 2, Name = "type4"
Id = 2, Name = "type4"
}
};

_bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(response);
_bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(response);

var request = new BookingSearchRequest
{
Expand All @@ -194,7 +195,7 @@ public async Task Should_return_ok_for_booking_list_with_defined_types_list()

_userIdentity.Setup(x => x.GetGroupDisplayNames()).Returns(new List<string> { "type1", "type2" });

_bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(() => GetCaseTypesList());
_bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(() => GetCaseTypesList());

var request = new BookingSearchRequest
{
Expand All @@ -207,7 +208,7 @@ public async Task Should_return_ok_for_booking_list_with_defined_types_list()
okResult.StatusCode.Should().Be(200);

_userIdentity.Verify(x => x.IsATeamLead(), Times.Once);
_bookingsApiClient.Verify(s => s.GetCaseTypesAsync(true), Times.Once);
_bookingsApiClient.Verify(s => s.GetCaseTypesV2Async(true), Times.Once);
_bookingsApiClient.Verify(x => x.GetHearingsByTypesAsync(It.IsAny<GetHearingRequest>()), Times.Once);
}

Expand All @@ -224,7 +225,7 @@ public async Task Should_return_ok_for_booking_list_and_exclude_repeated_types()

_userIdentity.Setup(x => x.GetGroupDisplayNames()).Returns(new List<string> { "type1", "type2", "type2" });

_bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(() => GetCaseTypesList());
_bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(() => GetCaseTypesList());

var request = new BookingSearchRequest
{
Expand All @@ -238,7 +239,7 @@ public async Task Should_return_ok_for_booking_list_and_exclude_repeated_types()
okResult.StatusCode.Should().Be(200);

_userIdentity.Verify(x => x.IsATeamLead(), Times.Once);
_bookingsApiClient.Verify(s => s.GetCaseTypesAsync(true), Times.Once);
_bookingsApiClient.Verify(s => s.GetCaseTypesV2Async(true), Times.Once);
_bookingsApiClient.Verify(x => x.GetHearingsByTypesAsync(It.IsAny<GetHearingRequest>()), Times.Once);
}

Expand All @@ -247,7 +248,7 @@ public async Task Should_return_booking_list_when_admin_search_by_case_number()
{
SetupTestCase();

_bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(default(List<CaseTypeResponse>));
_bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(default(List<CaseTypeResponseV2>));

var request = new BookingSearchRequest
{
Expand All @@ -268,7 +269,7 @@ public async Task Should_return_booking_list_when_admin_search_by_venue_ids()
{
SetupTestCase();

_bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(default(List<CaseTypeResponse>));
_bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(default(List<CaseTypeResponseV2>));

var request = new BookingSearchRequest
{
Expand All @@ -288,7 +289,7 @@ public async Task Should_return_booking_list_when_admin_search_by_last_name()
{
SetupTestCase();

_bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(default(List<CaseTypeResponse>));
_bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(default(List<CaseTypeResponseV2>));

var request = new BookingSearchRequest
{
Expand All @@ -311,7 +312,7 @@ public async Task Should_return_booking_list_when_admin_search_by_case_types()
{
SetupTestCase();

_bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(default(List<CaseTypeResponse>));
_bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(default(List<CaseTypeResponseV2>));

var request = new BookingSearchRequest
{
Expand All @@ -334,7 +335,7 @@ public async Task Should_return_bookings_list_when_admin_search_by_start_date()

var startDate = new DateTime(2022, 3, 25, 0, 0, 0, DateTimeKind.Utc);

_bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(default(List<CaseTypeResponse>));
_bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(default(List<CaseTypeResponseV2>));

var request = new BookingSearchRequest
{
Expand All @@ -359,7 +360,7 @@ public async Task Should_return_bookings_list_when_admin_search_by_end_date()

var endDate = new DateTime(2022, 3, 25, 0, 0, 0, DateTimeKind.Utc);

_bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(default(List<CaseTypeResponse>));
_bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(default(List<CaseTypeResponseV2>));

var request = new BookingSearchRequest
{
Expand All @@ -384,7 +385,7 @@ public async Task Should_return_bookings_list_when_admin_search_by_start_and_end
var startDate = new DateTime(2022, 3, 24, 0, 0, 0, DateTimeKind.Utc);
var endDate = new DateTime(2022, 3, 25, 0, 0, 0, DateTimeKind.Utc);

_bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(default(List<CaseTypeResponse>));
_bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(default(List<CaseTypeResponseV2>));

var request = new BookingSearchRequest
{
Expand All @@ -411,7 +412,7 @@ public async Task Should_return_bad_request_when_admin_search_with_start_date_af
var startDate = new DateTime(2022, 3, 25, 0, 0, 0, DateTimeKind.Utc);
var endDate = new DateTime(2022, 3, 24, 0, 0, 0, DateTimeKind.Utc);

_bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(default(List<CaseTypeResponse>));
_bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(default(List<CaseTypeResponseV2>));

var request = new BookingSearchRequest
{
Expand All @@ -433,7 +434,7 @@ public async Task Should_return_booking_list_when_admin_search_by_multiple_crite
{
SetupTestCase();

_bookingsApiClient.Setup(s => s.GetCaseTypesAsync(true)).ReturnsAsync(default(List<CaseTypeResponse>));
_bookingsApiClient.Setup(s => s.GetCaseTypesV2Async(true)).ReturnsAsync(default(List<CaseTypeResponseV2>));

var request = new BookingSearchRequest
{
Expand All @@ -452,21 +453,21 @@ public async Task Should_return_booking_list_when_admin_search_by_multiple_crite
okResult.StatusCode.Should().Be(200);
}

private static List<CaseTypeResponse> GetCaseTypesList()
private static List<CaseTypeResponseV2> GetCaseTypesList()
{
return new List<CaseTypeResponse>
return new List<CaseTypeResponseV2>
{
new CaseTypeResponse
new()
{
HearingTypes = new List<HearingTypeResponse>(), Id = 1, Name = "type1"
Id = 1, Name = "type1"
},
new CaseTypeResponse
new()
{
HearingTypes = new List<HearingTypeResponse>(), Id = 2, Name = "type2"
Id = 2, Name = "type2"
},
new CaseTypeResponse
new()
{
HearingTypes = new List<HearingTypeResponse>(), Id = 3, Name = "type3"
Id = 3, Name = "type3"
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using BookingsApi.Contract.V2.Requests;
using Microsoft.AspNetCore.Mvc;
using VideoApi.Contract.Responses;
using JudiciaryParticipantRequest = AdminWebsite.Contracts.Requests.JudiciaryParticipantRequest;
using LinkedParticipantType = AdminWebsite.Contracts.Enums.LinkedParticipantType;

namespace AdminWebsite.UnitTests.Controllers.HearingsController
Expand Down Expand Up @@ -76,7 +77,8 @@ public async Task Should_book_hearing()
result.Result.Should().BeOfType<CreatedResult>();
var createdObjectResult = (CreatedResult) result.Result;
createdObjectResult.StatusCode.Should().Be(201);
createdObjectResult.Value.Should().BeEquivalentTo(hearingDetailsResponse, options => options.ExcludingMissingMembers());
createdObjectResult.Value.Should().BeEquivalentTo(hearingDetailsResponse,
options => options.ExcludingMissingMembers().Excluding(x => x.HearingVenueName));

bookingDetails.Participants.Exists(x => string.IsNullOrWhiteSpace(x.Username)).Should().BeFalse();

Expand Down
Loading
Loading