Skip to content

Commit

Permalink
CDMS-223 working through failing tests and using test attributes to c…
Browse files Browse the repository at this point in the history
…ontrol them
  • Loading branch information
craigedmunds committed Jan 14, 2025
1 parent 111223a commit 2af751e
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 87 deletions.
36 changes: 18 additions & 18 deletions Btms.Analytics/MovementExceptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ public class MovementExceptions(IMongoDbContext context, ILogger logger)
{
// TODO - we should think about pre-calculating this stuff and storing it on the movement...

Id = m.Id,
UpdatedSource = m.UpdatedSource,
Updated = m.Updated,
m.Id,
m.UpdatedSource,
m.Updated,
MaxDecisionNumber = m.Decisions.Max(d => d.Header!.DecisionNumber) ?? 0,
MaxEntryVersion = m.ClearanceRequests.Max(c => c.Header!.EntryVersionNumber) ?? 0,
LinkedCheds = m.Relationships.Notifications.Data.Count,
ItemCount = m.Items.Count,
ChedTypes = m.BtmsStatus.ChedTypes,
Status = m.BtmsStatus,
DecisionMatched = m.AlvsDecisionStatus.Context.DecisionComparison!.DecisionMatched,
m.BtmsStatus.ChedTypes,
m.BtmsStatus.LinkStatus,
m.AlvsDecisionStatus.Context.DecisionComparison!.DecisionMatched,
// DecisionMatched = !m.AlvsDecisionStatus.Decisions
// .OrderBy(d => d.Context.AlvsDecisionNumber)
// .Reverse()
Expand All @@ -46,19 +46,19 @@ public class MovementExceptions(IMongoDbContext context, ILogger logger)
.Select(m => new
{
Id = m.Id,
UpdatedSource = m.UpdatedSource,
Updated = m.Updated,
MaxDecisionNumber = m.MaxDecisionNumber,
MaxEntryVersion = m.MaxEntryVersion,
LinkedCheds = m.LinkedCheds,
ItemCount = m.ItemCount,
ChedTypes = m.ChedTypes,
Status = m.Status,
HasNotificationRelationships = m.HasNotificationRelationships,
m.UpdatedSource,
m.Updated,
m.MaxDecisionNumber,
m.MaxEntryVersion,
m.LinkedCheds,
m.ItemCount,
m.ChedTypes,
m.LinkStatus,
m.HasNotificationRelationships,
Total = m.MaxDecisionNumber + m.MaxEntryVersion + m.LinkedCheds + m.ItemCount,
// TODO - can we include CHED versions here too?
TotalDocumentVersions = m.MaxDecisionNumber + m.MaxEntryVersion + m.LinkedCheds,
DecisionMatched = m.DecisionMatched,
m.DecisionMatched,
ContiguousAlvsClearanceRequestVersionsFrom1 = m.ContiguousAlvsClearanceRequestVersionsFrom1.Count() == m.MaxEntryVersion
});

Expand Down Expand Up @@ -91,9 +91,9 @@ public class MovementExceptions(IMongoDbContext context, ILogger logger)
})
);
}

var movementsWhereAlvsLinksButNotBtmsQuery = simplifiedMovementView
.Where(r => r.Status.LinkStatus != LinkStatusEnum.Linked);
.Where(r => r.LinkStatus != LinkStatusEnum.Linked);

if (summary)
{
Expand Down
13 changes: 4 additions & 9 deletions Btms.Backend.IntegrationTests/DecisionTests/ChedPSimpleTests.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
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 TestGenerator.IntegrationTesting.Backend;
using TestGenerator.IntegrationTesting.Backend.Extensions;
using TestGenerator.IntegrationTesting.Backend.Fixtures;
using Xunit;
using Xunit.Abstractions;
using ImportNotificationTypeEnum = Btms.Model.Ipaffs.ImportNotificationTypeEnum;
Expand Down Expand Up @@ -40,7 +35,7 @@ public void ShouldHaveCorrectAlvsDecisionMatchedStatusAtGlobalLevel()
.Should().BeTrue();
}

[FailingFact(jiraTicket:"CDMS-234")]
[FailingFact(jiraTicket:"CDMS-234"), Trait("JiraTicket", "CDMS-234")]
public void ShouldHave2BtmsDecisions()
{
Client
Expand All @@ -49,7 +44,7 @@ public void ShouldHave2BtmsDecisions()
.Should().Be(2);
}

[FailingFact(jiraTicket:"CDMS-234")]
[FailingFact(jiraTicket:"CDMS-234"), Trait("JiraTicket", "CDMS-234")]
public void ShouldHaveCorrectDecisionAuditEntries()
{
var chedPNotification = (ImportNotification)LoadedData
Expand Down Expand Up @@ -89,7 +84,7 @@ public void ShouldHave1AlvsDecision()
.Be(1);
}

[FailingFact(jiraTicket:"CDMS-234")]
[FailingFact(jiraTicket:"CDMS-234"), Trait("JiraTicket", "CDMS-234")]
public void ShouldHaveCorrectAuditTrail()
{
Client
Expand Down Expand Up @@ -170,7 +165,7 @@ public async Task ShouldNotHaveExceptions()
.Be("[]");
}

[FailingFact(jiraTicket:"CDMS-234")]
[FailingFact(jiraTicket:"CDMS-234"), Trait("JiraTicket", "CDMS-234")]
public void AlvsDecisionShouldBePaired()
{
Client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public ChedPUpdatedNotificationTests(ITestOutputHelper output): base(output)

// This scenario has an update adding a commodity that gets
// processed but doesn't cause a new decision
[FailingFact(jiraTicket:"CDMS-234")]
// [FailingFact(jiraTicket:"CDMS-234"), Trait("JiraTicket", "CDMS-234")]
[Fact]
public void ShouldHaveCorrectAuditEntries()
{
var movement = Client
Expand All @@ -47,12 +48,13 @@ public void ShouldHaveCorrectAuditEntries()
("Btms", "Decision", 1, null),
("Btms", "Linked", null, null), //TODO : can we get context in here including the notification info
("Btms", "Decision", 2, 1),
("Btms", "Decision", 3, 2),
("Alvs", "Decision", 1, null), //TODO : we should be able to use the IBM provided file to get some context
("Btms", "Decision", 3, 2)

]);
}

[FailingFact(jiraTicket:"CDMS-234")]
[FailingFact(jiraTicket:"CDMS-234"), Trait("JiraTicket", "CDMS-234")]
// [Fact]
public void ShouldHave3BtmsDecisions()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class Mrn24GBDDJER3ZFRMZAR9Tests(ITestOutputHelper output)
: ScenarioGeneratorBaseTest<Mrn24GBDDJER3ZFRMZAR9ScenarioGenerator>(output)
{

[FailingFact(jiraTicket:"CDMS-235")]
[FailingFact(jiraTicket:"CDMS-235"), Trait("JiraTicket", "CDMS-235")]
public void ShouldHaveCorrectAlvsDecisionMatchedStatusOnDecison()
{
Client
Expand All @@ -32,7 +32,7 @@ public void ShouldHaveCorrectAlvsDecisionMatchedStatusOnDecison()
.Should().BeTrue();
}

[FailingFact(jiraTicket:"CDMS-235")]
[FailingFact(jiraTicket:"CDMS-235"), Trait("JiraTicket", "CDMS-235")]
public void ShouldHaveCorrectAlvsDecisionStatusAtGlobalLevel()
{
Client
Expand All @@ -42,7 +42,7 @@ public void ShouldHaveCorrectAlvsDecisionStatusAtGlobalLevel()
.Should().Be(DecisionStatusEnum.BtmsMadeSameDecisionAsAlvs);
}

[FailingFact(jiraTicket:"CDMS-235")]
[FailingFact(jiraTicket:"CDMS-235"), Trait("JiraTicket", "CDMS-235")]
public void ShouldHaveCorrectAlvsDecisionMatchedStatusAtGlobalLevel()
{
Client
Expand All @@ -53,7 +53,7 @@ public void ShouldHaveCorrectAlvsDecisionMatchedStatusAtGlobalLevel()
}

// [IncorrectDecisionFact(Skip = "This should be making multiple decisions at the momennt given the complexity. Currently only making one")]
[FailingFact(jiraTicket:"CDMS-234")]
[FailingFact(jiraTicket:"CDMS-234"), Trait("JiraTicket", "CDMS-234")]
public void ShouldHaveTbcBtmsDecisions()
{
//
Expand All @@ -63,7 +63,8 @@ public void ShouldHaveTbcBtmsDecisions()
.Should().Be(1);
}

[FailingFact(jiraTicket:"CDMS-235")]
// [FailingFact(jiraTicket:"CDMS-235"), Trait("JiraTicket", "CDMS-235")]
[Fact]
public void ShouldHaveCorrectDecisionAuditEntries()
{
var notification = (ImportNotification)LoadedData
Expand Down Expand Up @@ -111,7 +112,8 @@ public void ShouldHave3AlvsDecisionChecks()
.Be(3);
}

[FailingFact(jiraTicket:"CDMS-235")]
// [FailingFact(jiraTicket:"CDMS-235"), Trait("JiraTicket", "CDMS-235")]
[Fact]
public void ShouldHaveCorrectAuditTrail()
{
Client
Expand All @@ -137,7 +139,7 @@ public void ShouldHaveCorrectAuditTrail()
]);
}

[FailingFact(jiraTicket:"CDMS-235")]
[FailingFact(jiraTicket:"CDMS-235"), Trait("JiraTicket", "CDMS-235")]
public void ShouldHaveDecisionMatched()
{
var movement = Client
Expand Down Expand Up @@ -189,7 +191,7 @@ public async Task ShouldNotHaveExceptions()
.Be("[]");
}

[FailingFact(jiraTicket:"CDMS-235")]
[FailingFact(jiraTicket:"CDMS-235"), Trait("JiraTicket", "CDMS-235")]
// [Fact]
public void AlvsDecisionShouldHaveCorrectChecks()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class Mrn24GBDEEA43OY1CQAR7Tests(ITestOutputHelper output)
: ScenarioGeneratorBaseTest<Mrn24GBDEEA43OY1CQAR7ScenarioGenerator>(output)
{

[FailingFact(reason: "Has Ched PP Checks")]
[FailingFact(jiraTicket:"CDMS-205", "Has Ched PP Checks"), Trait("JiraTicket", "CDMS-205")]
public void ShouldHaveCorrectAlvsDecisionMatchedStatusOnDecison()
{
Client
Expand All @@ -43,7 +43,7 @@ public void ShouldHaveCorrectAlvsDecisionMatchedStatusOnPreviousDecison()
.Should().BeNull();
}

[FailingFact(reason: "Has Ched PP Checks")]
[FailingFact(jiraTicket:"CDMS-205", "Has Ched PP Checks"), Trait("JiraTicket", "CDMS-205")]
public void ShouldHaveCorrectAlvsDecisionMatchedStatusAtGlobalLevel()
{
Client
Expand All @@ -53,7 +53,8 @@ public void ShouldHaveCorrectAlvsDecisionMatchedStatusAtGlobalLevel()
.Should().BeTrue();
}

[FailingFact(jiraTicket:"CDMS-234")]
// [FailingFact(jiraTicket:"CDMS-234"), Trait("JiraTicket", "CDMS-234")]
[Fact]
public void ShouldHave1BtmsDecision()
{
Client
Expand Down Expand Up @@ -100,7 +101,8 @@ public void ShouldHave2AlvsDecisions()
.Be(2);
}

[FailingFact(reason: "Has Ched PP Checks")]
[Fact]
// [FailingFact(jiraTicket:"CDMS-205", "Has Ched PP Checks"), Trait("JiraTicket", "CDMS-205")]
public void ShouldHaveCorrectAuditTrail()
{
Client
Expand All @@ -118,7 +120,7 @@ public void ShouldHaveCorrectAuditTrail()
]);
}

[FailingFact(reason: "Has Ched PP Checks")]
[FailingFact(jiraTicket:"CDMS-205", "Has Ched PP Checks"), Trait("JiraTicket", "CDMS-205")]
public void ShouldHaveDecisionMatched()
{
var movement = Client
Expand Down Expand Up @@ -170,7 +172,7 @@ public async Task ShouldNotHaveExceptions()
.Be("[]");
}

[FailingFact(reason: "Has Ched PP Checks")]
[FailingFact(jiraTicket:"CDMS-205", "Has Ched PP Checks"), Trait("JiraTicket", "CDMS-205")]
public void AlvsDecisionShouldHaveCorrectChecks()
{
Client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@
namespace Btms.Backend.IntegrationTests.DecisionTests;

[Trait("Category", "Integration")]
// [Trait("Category", "Testing12")]
// [Category("Testing12")]
public class Mrn24GBDEHMFC4WGXVAR7Tests(ITestOutputHelper output)
: ScenarioGeneratorBaseTest<Mrn24GBDEHMFC4WGXVAR7ScenarioGenerator>(output)
{

[FailingFact(jiraTicket:"CDMS-232")]
[FailingFact(jiraTicket:"CDMS-232"), Trait("JiraTicket", "CDMS-232")]
public void ShouldHaveCorrectAlvsDecisionMatchedStatusOnDecison()
{
Client
Expand Down Expand Up @@ -49,7 +46,7 @@ public void ShouldHaveCorrectAlvsDecisionStatusAtGlobalLevel()
.Should().Be(DecisionStatusEnum.AlvsClearanceRequestVersion1NotPresent);
}

[FailingFact(jiraTicket:"CDMS-232")]
[FailingFact(jiraTicket:"CDMS-232"), Trait("JiraTicket", "CDMS-232")]
public void ShouldHaveCorrectAlvsDecisionMatchedStatusAtGlobalLevel()
{
Client
Expand All @@ -59,7 +56,8 @@ public void ShouldHaveCorrectAlvsDecisionMatchedStatusAtGlobalLevel()
.Should().BeTrue();
}

[FailingFact(jiraTicket:"CDMS-234")]
// [FailingFact(jiraTicket:"CDMS-234"), Trait("JiraTicket", "CDMS-234")]
[Fact]
public void ShouldHave2BtmsDecisions()
{
Client
Expand Down Expand Up @@ -106,11 +104,7 @@ public void ShouldHave3AlvsDecisions()
.Be(3);
}

// [FailingFact(jiraTicket:"CDMS-234"), Trait("JiraTicket", "CDMS-234")]
[Fact, Category("Testing12")]
// [FailingFactTraitAttribute(name:"Category", value:"Testing12")]
// [FailingFact(jiraTicket:"CDMS-234", name="Category", value:"Testing12")]
// [Trait("Category", "CDMS-234")]
[FailingFact(jiraTicket:"CDMS-234"), Trait("JiraTicket", "CDMS-234")]
public void ShouldHaveCorrectAuditTrail()
{
//NB : Unsure why there's a BTMS decision 2 after alvs decision 1, but not
Expand All @@ -120,7 +114,7 @@ public void ShouldHaveCorrectAuditTrail()
.AuditEntries
.Select(a => (a.CreatedBy, a.Status, a.Version))
.Should()
.Equal([
.BeEquivalentTo<(string, string, int?)>([
("Cds", "Created", 1),
("Btms", "Linked", null),
("Btms", "Decision", 1),
Expand Down Expand Up @@ -175,7 +169,7 @@ public async Task ShouldNotHaveExceptions()
.Be("[]");
}

[FailingFact(jiraTicket:"CDMS-232")]
[FailingFact(jiraTicket:"CDMS-232"), Trait("JiraTicket", "CDMS-232")]
public void AlvsDecisionShouldHaveCorrectChecks()
{
Client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void ShouldHaveCorrectAlvsDecisionMatchedStatusAtGlobalLevel()
.Should().BeTrue();
}

[FailingFact(jiraTicket:"CDMS-234")]
[FailingFact(jiraTicket:"CDMS-234"), Trait("JiraTicket", "CDMS-234")]
public void ShouldHave1BtmsDecision()
{
Client
Expand Down Expand Up @@ -102,7 +102,7 @@ public void ShouldHave2AlvsDecisions()
.Be(2);
}

[FailingFact(jiraTicket:"CDMS-234")]
[FailingFact(jiraTicket:"CDMS-234"), Trait("JiraTicket", "CDMS-234")]
public void ShouldHaveCorrectAuditTrail()
{
Client
Expand Down
Loading

0 comments on commit 2af751e

Please sign in to comment.