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 Delete obsolete V1 operations and models #919

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion BookingsApi/BookingsApi.AcceptanceTests/Api/ApiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
using System.Threading.Tasks;
using BookingsApi.Client;
using BookingsApi.Common.Configuration;
using BookingsApi.Common.Security;
using BookingsApi.Contract.V1.Requests;
using BookingsApi.Contract.V1.Requests.Enums;
using BookingsApi.Contract.V1.Responses;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Options;
using NUnit.Framework;
using Testing.Common.Configuration;
using Testing.Common.Security;

namespace BookingsApi.AcceptanceTests.Api;

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
using System.Threading.Tasks;
using BookingsApi.Contract.V1.Requests;
using BookingsApi.Contract.V1.Responses;
using BookingsApi.Contract.V2.Requests;
using BookingsApi.Contract.V2.Responses;
using FluentAssertions;
using NUnit.Framework;
using Testing.Common.Builders.Api.V1.Request;
using Testing.Common.Builders.Api.V2;

namespace BookingsApi.AcceptanceTests.Api.V1.WorkAllocation;

public class WorkAllocationTests : ApiTest
{
private HearingDetailsResponse _hearing;
private HearingDetailsResponseV2 _hearing;
private JusticeUserResponse _cso;
private const string CaseName = "Bookings Api AC Automated";

Expand Down Expand Up @@ -40,7 +41,7 @@ public async Task should_assign_a_cso_to_a_hearing()
{
// arrange
var hearingSchedule = DateTime.Today.AddDays(1).AddHours(10).AddMinutes(20);
var bookNewHearingRequest = new SimpleBookNewHearingRequest(CaseName, hearingSchedule).Build();
var bookNewHearingRequest = new SimpleBookNewHearingRequestV2(CaseName, hearingSchedule, SimpleBookNewHearingRequestV2.JudgePersonalCode).Build();
// setup CSO to be working during hearing
var startTime = bookNewHearingRequest.ScheduledDateTime;
var endTime = bookNewHearingRequest.ScheduledDateTime.AddMinutes(bookNewHearingRequest.ScheduledDuration);
Expand All @@ -63,7 +64,7 @@ into dayOfWeek

await UpdateCsoWorkingHoursTo(workingHourRequests);
await ClearCsoExistingNonAvailabilities(startTime, endTime);
_hearing = await BookingsApiClient.BookNewHearingAsync(bookNewHearingRequest);
_hearing = await BookingsApiClient.BookNewHearingWithCodeAsync(bookNewHearingRequest);

// act
var updatedHearings = await BookingsApiClient.AllocateHearingsToCsoAsync(new UpdateHearingAllocationToCsoRequest
Expand All @@ -83,41 +84,15 @@ into dayOfWeek
var searchedHearing = searchResult.First(x => x.HearingId == _hearing.Id);
AssertHearingAllocationResponse(searchedHearing, bookNewHearingRequest);
}

[Test]
public async Task should_call_getAllocation_with_1000_ids_and_not_fail_and_return_the_valid_hearing()
{
// arrange
var hearingSchedule = DateTime.UtcNow.AddMinutes(5);

var bookNewHearingRequest = new SimpleBookNewHearingRequest(CaseName, hearingSchedule).Build();
_hearing = await BookingsApiClient.BookNewHearingAsync(bookNewHearingRequest);
await BookingsApiClient.AllocateHearingsToCsoAsync(new UpdateHearingAllocationToCsoRequest
{
Hearings = new List<Guid> {_hearing.Id},
CsoId = _cso.Id
});
var testParameters = new List<Guid>(){_hearing.Id};
for (int i = 0; i < 1000; i++)
testParameters.Add(Guid.NewGuid());

// act
var results = await BookingsApiClient.GetAllocationsForHearingsAsync(testParameters);

// assert
results.Count.Should().BeGreaterThan(0);
results.Should().Contain(e => e.HearingId == _hearing.Id);
}


[Test]
public async Task should_call_get_allocation_by_hearing_venue_and_return_valid_hearing()
{
// arrange
var hearingSchedule = DateTime.UtcNow.AddHours(1);

var bookNewHearingRequest = new SimpleBookNewHearingRequest(CaseName, hearingSchedule).Build();
_hearing = await BookingsApiClient.BookNewHearingAsync(bookNewHearingRequest);
var bookNewHearingRequest = new SimpleBookNewHearingRequestV2(CaseName, hearingSchedule, SimpleBookNewHearingRequestV2.JudgePersonalCode).Build();
_hearing = await BookingsApiClient.BookNewHearingWithCodeAsync(bookNewHearingRequest);
var allocations = await BookingsApiClient.AllocateHearingsToCsoAsync(new UpdateHearingAllocationToCsoRequest
{
Hearings = new List<Guid> {_hearing.Id},
Expand All @@ -129,19 +104,16 @@ public async Task should_call_get_allocation_by_hearing_venue_and_return_valid_h
var results = await BookingsApiClient.GetAllocationsForHearingsByVenueAsync(new[]{_hearing.HearingVenueName});

// assert
var result = results.FirstOrDefault(e => e.HearingId == allocation.HearingId);
result.Should().NotBeNull();
result.Cso?.Username.Should().Be(allocation.AllocatedCso);

var result = results.First(e => e.HearingId == allocation.HearingId);
result.Cso.Username.Should().Be(allocation.AllocatedCso);
}


private void AssertHearingAllocationResponse(HearingAllocationsResponse hearing, BookNewHearingRequest bookNewHearingRequest)
private void AssertHearingAllocationResponse(HearingAllocationsResponse hearing, BookNewHearingRequestV2 bookNewHearingRequest)
{
hearing.HearingId.Should().Be(_hearing.Id);
hearing.AllocatedCso.Should().Be(_cso.Username);
hearing.CaseNumber.Should().Be(bookNewHearingRequest.Cases[0].Number);
hearing.CaseType.Should().Be(bookNewHearingRequest.CaseTypeName);
hearing.ScheduledDateTime.Should().Be(_hearing.ScheduledDateTime);
hearing.Duration.Should().Be(_hearing.ScheduledDuration);
hearing.HasWorkHoursClash.Should().Be(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Threading.Tasks;
using FluentAssertions;

namespace BookingsApi.AcceptanceTests.Api.V2.CaseTypes;

public class CaseTypesTests : ApiTest
{
[Test]
public async Task should_get_all_case_types()
{
// arrange/ act
var allCaseTypes = await BookingsApiClient.GetCaseTypesV2Async(includeDeleted:false);

// assert
allCaseTypes.Should().NotBeNullOrEmpty();
allCaseTypes.Should().Contain(x => x.Name == "Generic");
allCaseTypes.Should().AllSatisfy(caseTypeResponse =>
{
caseTypeResponse.Id.Should().NotBe(0);
caseTypeResponse.Name.Should().NotBeNullOrWhiteSpace();
});

// consider adding an assertion for one service id of a known type?
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
using System;
using System.Threading.Tasks;
using BookingsApi.Contract.V1.Responses;
using BookingsApi.Contract.V2.Responses;
using FluentAssertions;
using NUnit.Framework;
using Testing.Common.Builders.Api.V1.Request;
using Testing.Common.Builders.Api.V2;

namespace BookingsApi.AcceptanceTests.Api.V1.Hearings;
namespace BookingsApi.AcceptanceTests.Api.V2.Hearings;

public class HearingTests : ApiTest
{

private HearingDetailsResponse _hearing;
private HearingDetailsResponseV2 _hearing;

[TearDown]
public async Task TearDown()
Expand All @@ -24,10 +22,10 @@ public async Task TearDown()
public async Task should_get_hearings_for_today()
{
var hearingSchedule = DateTime.UtcNow.AddMinutes(5);
var caseName = "Bookings Api AC Automated";
var request = new SimpleBookNewHearingRequest(caseName, hearingSchedule).Build();
_hearing = await BookingsApiClient.BookNewHearingAsync(request);
var results = await BookingsApiClient.GetHearingsForTodayAsync();
var caseName = "Bookings Api AC Automated - Get Today";
var request = new SimpleBookNewHearingRequestV2(caseName, hearingSchedule, SimpleBookNewHearingRequestV2.JudgePersonalCode).Build();
_hearing = await BookingsApiClient.BookNewHearingWithCodeAsync(request);
var results = await BookingsApiClient.GetHearingsForTodayV2Async();
results.Should().NotBeNullOrEmpty();
results.Should().Contain(e => e.Id == _hearing.Id);

Expand All @@ -37,10 +35,10 @@ public async Task should_get_hearings_for_today()
public async Task should_get_hearings_for_today_by_venue()
{
var hearingSchedule = DateTime.UtcNow.AddMinutes(5);
var caseName = "Bookings Api AC Automated";
var request = new SimpleBookNewHearingRequest(caseName, hearingSchedule).Build();
_hearing = await BookingsApiClient.BookNewHearingAsync(request);
var results = await BookingsApiClient.GetHearingsForTodayByVenueAsync(new []{ _hearing.HearingVenueName });
var caseName = "Bookings Api AC Automated - Get Today By Venue";
var request = new SimpleBookNewHearingRequestV2(caseName, hearingSchedule, SimpleBookNewHearingRequestV2.JudgePersonalCode).Build();
_hearing = await BookingsApiClient.BookNewHearingWithCodeAsync(request);
var results = await BookingsApiClient.GetHearingsForTodayByVenueV2Async([_hearing.HearingVenueName]);
results.Should().NotBeNullOrEmpty();
results.Should().Contain(e => e.Id == _hearing.Id);
foreach (var result in results)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Linq;
using System.Threading.Tasks;
using BookingsApi.Contract.V1.Enums;
using BookingsApi.Contract.V2.Enums;
using FluentAssertions;

namespace BookingsApi.AcceptanceTests.Api.V1.RefData;
namespace BookingsApi.AcceptanceTests.Api.V2.RefData;

public class InterpreterLanguageTests : ApiTest
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down Expand Up @@ -49,4 +49,8 @@
<Using Include="NUnit.Framework"/>
</ItemGroup>

<ItemGroup>
<Folder Include="Api\V2\" />
</ItemGroup>

</Project>
Loading