-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CDMS-223 adds additional scenarios and tests for incorrect decisions
- Loading branch information
1 parent
1095b36
commit c8a6064
Showing
42 changed files
with
490 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
237 changes: 237 additions & 0 deletions
237
Btms.Backend.IntegrationTests/DecisionTests/Mrn24GBDDJER3ZFRMZAR9Tests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,237 @@ | ||
using System.Net; | ||
using Btms.Backend.IntegrationTests.Helpers; | ||
using Btms.Common.Extensions; | ||
using Btms.Model; | ||
using Btms.Model.Cds; | ||
using Btms.Types.Ipaffs; | ||
using FluentAssertions; | ||
using TestDataGenerator.Scenarios.ChedP; | ||
using TestDataGenerator.Scenarios.SpecificFiles; | ||
using TestGenerator.IntegrationTesting.Backend; | ||
using TestGenerator.IntegrationTesting.Backend.Extensions; | ||
using TestGenerator.IntegrationTesting.Backend.Fixtures; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
using ImportNotificationTypeEnum = Btms.Model.Ipaffs.ImportNotificationTypeEnum; | ||
|
||
namespace Btms.Backend.IntegrationTests.DecisionTests; | ||
|
||
[Trait("Category", "Integration")] | ||
public class Mrn24GBDDJER3ZFRMZAR9Tests(ITestOutputHelper output) | ||
: ScenarioGeneratorBaseTest<Mrn24GBDDJER3ZFRMZAR9ScenarioGenerator>(output) | ||
{ | ||
|
||
// [Fact] | ||
[Fact(Skip="Wrong decision being made")] | ||
public void ShouldHaveCorrectAlvsDecisionMatchedStatusOnDecison() | ||
{ | ||
Client | ||
.GetSingleMovement() | ||
.AlvsDecisionStatus.Decisions | ||
.First(d => d.Context.AlvsDecisionNumber == 2) | ||
.Context.DecisionComparison!.DecisionMatched | ||
.Should().BeTrue(); | ||
} | ||
|
||
// [Fact] | ||
[Fact(Skip="Wrong decision being made")] | ||
public void ShouldHaveCorrectAlvsDecisionStatusAtGlobalLevel() | ||
{ | ||
Client | ||
.GetSingleMovement() | ||
.AlvsDecisionStatus | ||
.Context.DecisionComparison!.DecisionStatus | ||
.Should().Be(DecisionStatusEnum.BtmsMadeSameDecisionAsAlvs); | ||
} | ||
|
||
// [Fact] | ||
[Fact(Skip="Wrong decision being made")] | ||
public void ShouldHaveCorrectAlvsDecisionMatchedStatusAtGlobalLevel() | ||
{ | ||
Client | ||
.GetSingleMovement() | ||
.AlvsDecisionStatus | ||
.Context.DecisionComparison!.DecisionMatched | ||
.Should().BeTrue(); | ||
} | ||
|
||
[Fact(Skip = "This should be making multiple decisions at the momennt given the complexity. Currently only making one")] | ||
public void ShouldHaveTbcBtmsDecisions() | ||
{ | ||
// | ||
Client | ||
.GetSingleMovement() | ||
.Decisions.Count | ||
.Should().Be(1); | ||
} | ||
|
||
[Fact] | ||
public void ShouldHaveCorrectDecisionAuditEntries() | ||
{ | ||
var notification = (ImportNotification)LoadedData | ||
.First(d => | ||
d is { Message: ImportNotification } | ||
) | ||
.Message; | ||
|
||
// Assert | ||
var movement = Client | ||
.GetSingleMovement(); | ||
|
||
var decisionWithLinkAndContext = movement.AuditEntries | ||
.Where(a => a is { CreatedBy: "Btms", Status: "Decision" }) | ||
.MaxBy(a => a.Version)!; | ||
|
||
decisionWithLinkAndContext.Context!.ImportNotifications | ||
.Should().NotBeNull(); | ||
|
||
decisionWithLinkAndContext.Context!.ImportNotifications! | ||
.Select(n => (n.Id, n.Version)) | ||
.Distinct() | ||
.Count() | ||
.Should() | ||
.Be(9); | ||
} | ||
|
||
[Fact] | ||
public void ShouldHave1AlvsDecisions() | ||
{ | ||
Client | ||
.GetSingleMovement() | ||
.AlvsDecisionStatus.Decisions.Count | ||
.Should() | ||
.Be(1); | ||
} | ||
|
||
|
||
[Fact] | ||
public void ShouldHave3AlvsDecisionChecks() | ||
{ | ||
Client | ||
.GetSingleMovement() | ||
.AlvsDecisionStatus.Context.DecisionComparison!.Checks.Count | ||
.Should() | ||
.Be(3); | ||
} | ||
|
||
[Fact] | ||
public void ShouldHaveCorrectAuditTrail() | ||
{ | ||
Client | ||
.GetSingleMovement() | ||
.AuditEntries | ||
.Select(a => (a.CreatedBy, a.Status, a.Version)) | ||
.Should() | ||
.Equal([ | ||
("Cds", "Created", 1), | ||
("Btms", "Linked", null), | ||
("Btms", "Linked", null), | ||
("Btms", "Linked", null), | ||
("Btms", "Linked", null), | ||
("Btms", "Linked", null), | ||
("Btms", "Linked", null), | ||
("Btms", "Linked", null), | ||
("Btms", "Linked", null), | ||
("Btms", "Linked", null), | ||
("Btms", "Decision", 1), | ||
("Cds", "Updated", 2), | ||
("Alvs", "Decision", 1) | ||
|
||
]); | ||
} | ||
|
||
[Fact(Skip="Wrong decision being made")] | ||
// [Fact] | ||
public void ShouldHaveDecisionMatched() | ||
{ | ||
var movement = Client | ||
.GetSingleMovement() | ||
.AlvsDecisionStatus.Context!.DecisionComparison!.DecisionMatched | ||
.Should().BeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void ShouldHaveChedPpDecisionStatus() | ||
{ | ||
Client | ||
.GetSingleMovement() | ||
.AlvsDecisionStatus.Context.DecisionComparison!.DecisionStatus | ||
.Should().Be(DecisionStatusEnum.HasChedppChecks); | ||
} | ||
|
||
[Fact] | ||
public void ShouldHaveChedType() | ||
{ | ||
Client | ||
.GetSingleMovement() | ||
.BtmsStatus.ChedTypes | ||
.Should().Equal(ImportNotificationTypeEnum.Chedpp); | ||
} | ||
|
||
[Fact] | ||
public void ShouldBeLinked() | ||
{ | ||
Client | ||
.GetSingleMovement() | ||
.BtmsStatus.LinkStatus | ||
.Should().Be("Linked"); | ||
} | ||
|
||
[Fact] | ||
public async Task ShouldNotHaveExceptions() | ||
{ | ||
// TestOutputHelper.WriteLine("Querying for aggregated data"); | ||
|
||
var result = await Client | ||
.GetExceptions(); | ||
|
||
TestOutputHelper.WriteLine($"{result.StatusCode} status"); | ||
result.IsSuccessStatusCode.Should().BeTrue(result.StatusCode.ToString()); | ||
|
||
(await result.GetString()) | ||
.Should() | ||
.Be("[]"); | ||
} | ||
|
||
[Fact(Skip="Wrong decision being made")] | ||
public void AlvsDecisionShouldHaveCorrectChecks() | ||
{ | ||
Client | ||
.GetSingleMovement() | ||
.AlvsDecisionStatus.Context.DecisionComparison!.Checks | ||
.Should().BeEquivalentTo([ | ||
new { | ||
ItemNumber = 1, | ||
CheckCode = "H219", | ||
AlvsDecisionCode = "C03", | ||
BtmsDecisionCode = "C03" | ||
}, | ||
new { | ||
ItemNumber = 2, | ||
CheckCode = "H219", | ||
AlvsDecisionCode = "C03", | ||
BtmsDecisionCode = "C03" | ||
}, | ||
new { | ||
ItemNumber = 3, | ||
CheckCode = "H219", | ||
AlvsDecisionCode = "C03", | ||
BtmsDecisionCode = "C03" | ||
} | ||
]); | ||
} | ||
|
||
[Fact] | ||
public async Task AlvsDecisionShouldReturnCorrectlyFromAnalytics() | ||
{ | ||
var result = await (await Client | ||
.GetAnalyticsDashboard(["decisionsByDecisionCode"])) | ||
.ToJsonDictionary(); | ||
|
||
// TODO would be nice to deserialise this into our dataset structures from analytics... | ||
result["decisionsByDecisionCode"]?["summary"]?["values"]?[ | ||
"Btms Made Same Decision As Alvs"]? | ||
.GetValue<int>() | ||
.Should().Be(2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.