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

Updated tests which look at the relationships on the API response rat… #115

Merged
merged 2 commits into from
Feb 5, 2025
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
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Btms.Model;
using FluentAssertions;
using TestDataGenerator.Scenarios.SpecificFiles;
using TestGenerator.IntegrationTesting.Backend;
Expand Down Expand Up @@ -25,9 +26,11 @@ public void DecisionShouldHaveCorrectDecisionCodeForSingleNotification(Type gene
base.TestOutputHelper.WriteLine("Generator : {0}, Decision Code : {1}", generatorType!.FullName, decisionCode);
EnsureEnvironmentInitialised(generatorType);

var movement = Client
var apiResponse = Client
.GetMovementByMrn(mrn);

var movement = apiResponse.GetResourceObject<Movement>();

var lastDecision = movement.Decisions.OrderByDescending(x => x.ServiceHeader?.ServiceCalled).First();


Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Btms.Model;
using Btms.Model.Auditing;
using Btms.Model.Cds;
using Btms.Types.Ipaffs;
Expand Down Expand Up @@ -26,9 +27,11 @@ public void DecisionShouldHaveCorrectDecisionCodeForSingleNotification(Type gene
base.TestOutputHelper.WriteLine("Generator : {0}, Decision Code : {1}", generatorType!.FullName, decisionCode);
EnsureEnvironmentInitialised(generatorType);

var movement = Client
var apiResponse = Client
.GetMovementByMrn(mrn);

var movement = apiResponse.GetResourceObject<Movement>();

var lastDecision = movement.Decisions.OrderByDescending(x => x.ServiceHeader?.ServiceCalled).First();


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ public class IpaffsCancelledTests(ITestOutputHelper output)
public void NotificationShouldBeDeleted_AndRelationshipsRemoved_AndHaveAuditEntries()
{
// Assert
var notification = Client
var resource = Client
.GetNotificationById("CHEDD.GB.2024.5246106");

var notification = resource.GetResourceObject<ImportNotification>();

resource.Data.Relationships!.First().Value!.Data.ManyValue!.Count.Should().Be(1);

notification.Status.Should().Be(ImportNotificationStatusEnum.Cancelled);
notification.Relationships.Should().BeEquivalentTo(new NotificationTdmRelationships());
notification.AuditEntries.Count(x => x.Status == "Unlinked").Should().Be(0);
notification.AuditEntries.Count(x => x.Status == "Cancelled").Should().Be(1);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Btms.Model;
using Btms.Model.Auditing;
using Btms.Model.Ipaffs;
using Btms.Model.Relationships;
Expand All @@ -18,11 +19,14 @@ public class IpaffsDeletedTests(ITestOutputHelper output)
public void NotificationShouldBeDeleted_AndRelationshipsRemoved_AndHaveAuditEntries()
{
// Assert
var notification = Client
.GetFirstImportNotification();
var resource = Client
.GetNotificationById("CHEDD.GB.2024.5256764");

var notification = resource.GetResourceObject<ImportNotification>();

resource.Data.Relationships!.First().Value!.Data.ManyValue!.Count.Should().Be(0);

notification.Status.Should().Be(ImportNotificationStatusEnum.Deleted);
notification.Relationships.Should().BeEquivalentTo(new NotificationTdmRelationships());
notification.AuditEntries.Count(x => x.Status == "Unlinked").Should().Be(1);
notification.AuditEntries.Count(x => x.Status == "Deleted").Should().Be(1);
}
Expand All @@ -34,10 +38,10 @@ public void MovementShouldHaveRelationshipsRemoved_AndHaveAuditEntries()
var movement1 = Client.GetMovementByMrn("24GBDHDJXQ5TCDBAR1");
var movement2 = Client.GetMovementByMrn("24GBDPN9J48XRW5AR0");

movement1.Relationships.Should().BeEquivalentTo(new MovementTdmRelationships());
movement1.AuditEntries.Count(x => x.Status == "Unlinked").Should().Be(1);
movement1.Data.Relationships!.First().Value!.Data.ManyValue!.Count.Should().Be(0);
movement1.GetResourceObject<Movement>().AuditEntries.Count(x => x.Status == "Unlinked").Should().Be(1);

movement2.Relationships.Should().BeEquivalentTo(new MovementTdmRelationships());
movement2.AuditEntries.Count(x => x.Status == "Unlinked").Should().Be(1);
movement2.Data.Relationships!.First().Value!.Data.ManyValue!.Count.Should().Be(0);
movement2.GetResourceObject<Movement>().AuditEntries.Count(x => x.Status == "Unlinked").Should().Be(1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Btms.Model.Ipaffs;
// using Btms.Types.Ipaffs;
using TestGenerator.IntegrationTesting.Backend.Fixtures;
using TestGenerator.IntegrationTesting.Backend.JsonApiClient;

namespace TestGenerator.IntegrationTesting.Backend.Extensions;

Expand All @@ -15,12 +16,10 @@ public static Movement GetSingleMovement(this BtmsClient client)
.Single();
}

public static Movement GetMovementByMrn(this BtmsClient client, string mrn)
public static SingleItemJsonApiDocument GetMovementByMrn(this BtmsClient client, string mrn)
{
return client.AsJsonApiClient()
.Get("api/movements")
.GetResourceObjects<Movement>()
.Single(x => x.EntryReference == mrn);
.GetById(mrn, "api/movements");
}

public static ImportNotification GetFirstImportNotification(this BtmsClient client)
Expand All @@ -32,13 +31,10 @@ public static ImportNotification GetFirstImportNotification(this BtmsClient clie
return results.First();
}

public static ImportNotification GetNotificationById(this BtmsClient client, string id)
public static SingleItemJsonApiDocument GetNotificationById(this BtmsClient client, string id)
{
var results = client.AsJsonApiClient()
.Get("api/import-notifications")
.GetResourceObjects<ImportNotification>();

return results.First(x => x.Id == id);
return client.AsJsonApiClient()
.GetById(id, "api/import-notifications");
}

public static ImportNotification GetSingleImportNotification(this BtmsClient client)
Expand Down
Loading