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 17 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
31 changes: 19 additions & 12 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.2-pr-0919-0015",
"contentHash": "IRm5VlvedpTmAAutyPlMJ1409prJwlCoH/UqUiMZgQFTw90vcOPV3rjfJY2LDkW5ald+cAXsnt9xdx2sRZSUoQ==",
"dependencies": {
"Microsoft.AspNetCore.Mvc.Core": "2.2.5"
"BookingsApi.Common.DotNet6": "3.1.2-pr-0919-0015",
"Microsoft.AspNetCore.Mvc.Core": "2.2.5",
"System.Text.Json": "8.0.5"
}
},
"BookingsApi.Common.DotNet6": {
"type": "Transitive",
"resolved": "3.1.2-pr-0919-0015",
"contentHash": "XRGaOrPoDqYVDDH5I/8u/iLX12A4Az8DN5TL7soqqlT0AodhvuB/5oNr49LCkQ3jugPzK1iyW60zE5Qzi55zoA==",
"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 @@ -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 @@ -2154,7 +2161,7 @@
"type": "Project",
"dependencies": {
"AspNetCore.HealthChecks.Uris": "[8.0.1, )",
"BookingsApi.Client": "[2.3.9, )",
"BookingsApi.Client": "[3.1.2-pr-0919-0015, )",
"FluentValidation.AspNetCore": "[11.3.0, )",
"LaunchDarkly.ServerSdk": "[8.5.0, )",
"MicroElements.Swashbuckle.FluentValidation": "[6.0.0, )",
Expand All @@ -2165,7 +2172,7 @@
"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, )",
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using BookingsApi.Client;
using BookingsApi.Contract.V1.Requests.Enums;
using Autofac.Extras.Moq;
using BookingsApi.Contract.V1.Requests;
using BookingsApi.Contract.V1.Responses;
using BookingsApi.Contract.V2.Responses;
using VideoApi.Contract.Consts;
using VideoApi.Contract.Responses;
using ParticipantResponse = BookingsApi.Contract.V1.Responses.ParticipantResponse;

namespace AdminWebsite.UnitTests.Controllers.HearingsController
{
Expand All @@ -36,10 +35,10 @@ public void Setup()
TelephoneConferenceId = "expected_conference_phone_id"
}
});
_mocker.Mock<IBookingsApiClient>().Setup(bs => bs.GetHearingDetailsByIdAsync(It.IsAny<Guid>()))
.ReturnsAsync(new HearingDetailsResponse
_mocker.Mock<IBookingsApiClient>().Setup(bs => bs.GetHearingDetailsByIdV2Async(It.IsAny<Guid>()))
.ReturnsAsync(new HearingDetailsResponseV2()
{
Participants = [new ParticipantResponse { HearingRoleName = "Judge" }]
Participants = [new ParticipantResponseV2 { HearingRoleName = HearingRoleName.Representative }]
});
_controller = _mocker.Create<AdminWebsite.Controllers.HearingsController>();
}
Expand Down
Loading
Loading