-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from DEFRA/feature/cdms-145-worst-case-scenari…
…o-outcome Feature/cdms 145 worst case scenario outcome
- Loading branch information
Showing
103 changed files
with
22,543 additions
and
388 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +0,0 @@ | ||
using Btms.Model; | ||
using FluentAssertions; | ||
using TestDataGenerator.Scenarios.SpecificFiles; | ||
using TestGenerator.IntegrationTesting.Backend; | ||
using TestGenerator.IntegrationTesting.Backend.Fixtures; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Btms.Backend.IntegrationTests.DecisionTests; | ||
|
||
[Trait("Category", "Integration")] | ||
public class BasicDecisionCodeTests | ||
{ | ||
public class SingleChedH01Tests(ITestOutputHelper output) | ||
: ScenarioGeneratorBaseTest<AllChedsH01DecisionGenerator>(output) | ||
{ | ||
[Fact] | ||
public void SingleChed_ShouldHaveH01DecisionCode() | ||
{ | ||
CheckDecisionCode("H01", Client); | ||
} | ||
} | ||
|
||
public class SingleChedH02Tests(ITestOutputHelper output) | ||
: ScenarioGeneratorBaseTest<AllChedsH02DecisionGenerator>(output) | ||
{ | ||
[Fact] | ||
public void SingleChed_ShouldHaveH02DecisionCode() | ||
{ | ||
CheckDecisionCode("H02", Client); | ||
} | ||
} | ||
|
||
[Trait("Category", "Integration")] | ||
public class SingleChedDecisionTests(ITestOutputHelper output) | ||
: ScenarioGeneratorBaseTest<AllChedsC03DecisionGenerator>(output) | ||
{ | ||
[Fact] | ||
public void SingleChed_ShouldHaveC03DecisionCode() | ||
{ | ||
CheckDecisionCode("C03", Client); | ||
} | ||
} | ||
|
||
[Trait("Category", "Integration")] | ||
public class MultiChedDecisionTest(ITestOutputHelper output) | ||
: ScenarioGeneratorBaseTest<MultiChedPMatchScenarioGenerator>(output) | ||
{ | ||
[Fact] | ||
public void MultiChed_ShouldHaveH02DecisionCode() | ||
{ | ||
string decisionCode = ""; | ||
var expectedDecision = "H02"; | ||
Client.AsJsonApiClient().Get("api/movements").GetResourceObjects<Movement>().Single().Decisions | ||
.OrderBy(x => x.ServiceHeader?.ServiceCalled).Last().Items! | ||
.All(i => | ||
{ | ||
decisionCode = i.Checks!.First().DecisionCode!; | ||
|
||
return decisionCode.Equals(expectedDecision); | ||
}).Should().BeTrue($"Expected {expectedDecision}. Actually {{0}}", decisionCode); | ||
} | ||
} | ||
|
||
private static void CheckDecisionCode(string expectedDecisionCode, BtmsClient client) | ||
{ | ||
string decisionCode; | ||
string mrn; | ||
|
||
var movements = client.AsJsonApiClient().Get("api/movements").GetResourceObjects<Movement>(); | ||
movements.Should().AllSatisfy(m => | ||
{ | ||
mrn = m.EntryReference; | ||
m.Decisions.OrderBy(x => x.ServiceHeader?.ServiceCalled).Last().Items.Should().AllSatisfy(i => | ||
{ | ||
i.Checks.Should().AllSatisfy(c => | ||
{ | ||
decisionCode = c.DecisionCode!; | ||
decisionCode.Should().Be(expectedDecisionCode, | ||
$"Expected {expectedDecisionCode}. Actually {{0}}. MRN: {{1}}", decisionCode, mrn); | ||
}); | ||
}); | ||
}); | ||
} | ||
} | ||
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
48 changes: 48 additions & 0 deletions
48
Btms.Backend.IntegrationTests/DecisionTests/MultiChedDecisionCodeTests.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,48 @@ | ||
using Btms.Model; | ||
using FluentAssertions; | ||
using TestDataGenerator.Scenarios.SpecificFiles; | ||
using TestGenerator.IntegrationTesting.Backend; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Btms.Backend.IntegrationTests.DecisionTests; | ||
|
||
[Trait("Category", "Integration")] | ||
public class MultiChedDecisionTest(ITestOutputHelper output) | ||
: MultipleScenarioGeneratorBaseTest(output) | ||
{ | ||
[Theory] | ||
[InlineData(typeof(MultiChedPMatchScenarioGenerator), "H02")] | ||
[InlineData(typeof(MultiChedAMatchScenarioGenerator), "C03")] | ||
[InlineData(typeof(MultiChedDMatchScenarioGenerator), "C03")] | ||
public void MultiChed_DecisionCode(Type generatorType, string expectedDecision) | ||
{ | ||
base.TestOutputHelper.WriteLine("Generator : {0}, Decision Code : {1}", generatorType!.FullName, expectedDecision); | ||
EnsureEnvironmentInitialised(generatorType); | ||
CheckDecisionCode(expectedDecision); | ||
} | ||
|
||
[Theory (Skip = "Need to update data")] | ||
[InlineData(typeof(MultiChedPWorstCaseMatchScenarioGenerator), "N07")] | ||
[InlineData(typeof(MultiChedAWorstCaseMatchScenarioGenerator), "H02")] | ||
[InlineData(typeof(MultiChedDWorstCaseMatchScenarioGenerator), "N02")] | ||
public void MultiChed_WorstCaseDecisionCode(Type generatorType, string expectedDecision) | ||
{ | ||
base.TestOutputHelper.WriteLine("Generator : {0}, Decision Code : {1}", generatorType!.FullName, expectedDecision); | ||
EnsureEnvironmentInitialised(generatorType); | ||
CheckDecisionCode(expectedDecision); | ||
} | ||
|
||
private void CheckDecisionCode(string expectedDecision) | ||
{ | ||
var decision = ""; | ||
Client.AsJsonApiClient().Get("api/movements").GetResourceObjects<Movement>().Single().Decisions | ||
.OrderBy(x => x.ServiceHeader?.ServiceCalled).Last().Items! | ||
.All(i => | ||
{ | ||
decision = i.Checks!.First().DecisionCode!; | ||
|
||
return decision.Equals(expectedDecision); | ||
}).Should().BeTrue($"Expected {expectedDecision}. Actually {{0}}", decision); | ||
} | ||
} |
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
80 changes: 79 additions & 1 deletion
80
...iChedWithDecision/ChedA/ALVS/24GBDFPIYGN8YKQAR3-c7de5aab-2679-47a2-8466-09dc52be2e25.json
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 |
---|---|---|
@@ -1 +1,79 @@ | ||
{"serviceHeader":{"sourceSystem":"CDS","destinationSystem":"ALVS","correlationId":"1315562","serviceCallTimestamp":1733315286000},"header":{"entryReference":"24GBDFPIYGN8YKQAR3","entryVersionNumber":1,"previousVersionNumber":null,"declarationUCR":"4GB279214189000-CL7238","declarationPartNumber":null,"declarationType":"S","arrivalDateTime":null,"submitterTURN":null,"declarantId":"GB279214189000","declarantName":"GB279214189000","dispatchCountryCode":"AE","goodsLocationCode":"LHRLHRLHR","masterUCR":"HARC17602480634"},"items":[{"itemNumber":1,"customsProcedureCode":"4000000","taricCommodityCode":"0106190000","goodsDescription":"11 LIVE CATS","consigneeId":"GB279214189000","consigneeName":"GB279214189000","itemNetMass":112,"itemSupplementaryUnits":0,"itemThirdQuantity":null,"itemOriginCountryCode":"AE","documents":[{"documentCode":"C640","documentReference":"GBCHD2024.5252413","documentStatus":"AE","documentControl":"P","documentQuantity":null}],"checks":[{"checkCode":"H221","departmentCode":"AHVLA"}]},{"itemNumber":2,"customsProcedureCode":"4000000","taricCommodityCode":"0106190000","goodsDescription":"11 LIVE CATS","consigneeId":"GB279214189000","consigneeName":"GB279214189000","itemNetMass":112,"itemSupplementaryUnits":0,"itemThirdQuantity":null,"itemOriginCountryCode":"AE","documents":[{"documentCode":"C640","documentReference":"GBCHD2024.5252370","documentStatus":"AE","documentControl":"P","documentQuantity":null}],"checks":[{"checkCode":"H221","departmentCode":"AHVLA"}]}]} | ||
{ | ||
"serviceHeader": { | ||
"sourceSystem": "CDS", | ||
"destinationSystem": "ALVS", | ||
"correlationId": "1315562", | ||
"serviceCallTimestamp": 1733315286000 | ||
}, | ||
"header": { | ||
"entryReference": "24GBDFPIYGN8YKQAR3", | ||
"entryVersionNumber": 1, | ||
"previousVersionNumber": null, | ||
"declarationUCR": "4GB279214189000-CL7238", | ||
"declarationPartNumber": null, | ||
"declarationType": "S", | ||
"arrivalDateTime": null, | ||
"submitterTURN": null, | ||
"declarantId": "GB279214189000", | ||
"declarantName": "GB279214189000", | ||
"dispatchCountryCode": "AE", | ||
"goodsLocationCode": "LHRLHRLHR", | ||
"masterUCR": "HARC17602480634" | ||
}, | ||
"items": [ | ||
{ | ||
"itemNumber": 1, | ||
"customsProcedureCode": "4000000", | ||
"taricCommodityCode": "0106190000", | ||
"goodsDescription": "11 LIVE CATS", | ||
"consigneeId": "GB279214189000", | ||
"consigneeName": "GB279214189000", | ||
"itemNetMass": 112, | ||
"itemSupplementaryUnits": 0, | ||
"itemThirdQuantity": null, | ||
"itemOriginCountryCode": "AE", | ||
"documents": [ | ||
{ | ||
"documentCode": "C640", | ||
"documentReference": "GBCHD2024.5252413", | ||
"documentStatus": "AE", | ||
"documentControl": "P", | ||
"documentQuantity": null | ||
} | ||
], | ||
"checks": [ | ||
{ | ||
"checkCode": "H221", | ||
"departmentCode": "AHVLA" | ||
} | ||
] | ||
}, | ||
{ | ||
"itemNumber": 2, | ||
"customsProcedureCode": "4000000", | ||
"taricCommodityCode": "0106190000", | ||
"goodsDescription": "11 LIVE CATS", | ||
"consigneeId": "GB279214189000", | ||
"consigneeName": "GB279214189000", | ||
"itemNetMass": 112, | ||
"itemSupplementaryUnits": 0, | ||
"itemThirdQuantity": null, | ||
"itemOriginCountryCode": "AE", | ||
"documents": [ | ||
{ | ||
"documentCode": "C640", | ||
"documentReference": "GBCHD2024.5252370", | ||
"documentStatus": "AE", | ||
"documentControl": "P", | ||
"documentQuantity": null | ||
} | ||
], | ||
"checks": [ | ||
{ | ||
"checkCode": "H221", | ||
"departmentCode": "AHVLA" | ||
} | ||
] | ||
} | ||
] | ||
} |
Oops, something went wrong.