feat(notification-outbox): additive NotificationId query filter for ?correlationId= deep links
Claude-Session: https://claude.ai/code/session_01NcMG6xXdsJbmD2wYAgkK29
This commit is contained in:
+28
@@ -1,6 +1,7 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Entities.Notifications;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Types.Enums;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Types.Notifications;
|
||||
using ZB.MOM.WW.ScadaBridge.ConfigurationDatabase;
|
||||
using ZB.MOM.WW.ScadaBridge.ConfigurationDatabase.Repositories;
|
||||
using ZB.MOM.WW.ScadaBridge.ConfigurationDatabase.Tests.Migrations;
|
||||
@@ -101,6 +102,33 @@ public class NotificationOutboxRepositoryIntegrationTests : IClassFixture<MsSqlM
|
||||
Assert.Equal(1, count);
|
||||
}
|
||||
|
||||
[SkippableFact]
|
||||
public async Task QueryAsync_NotificationIdFilter_ReturnsExactlyThatRow()
|
||||
{
|
||||
Skip.IfNot(_fixture.Available, _fixture.SkipReason);
|
||||
|
||||
// Flow Debugger / Audit Log ?correlationId= deep link: an exact match on one
|
||||
// NotificationId must return that single row and count it alone.
|
||||
var wantedId = Guid.NewGuid().ToString();
|
||||
var otherId = Guid.NewGuid().ToString();
|
||||
await using (var context = CreateContext())
|
||||
{
|
||||
var repo = new NotificationOutboxRepository(context);
|
||||
await repo.InsertIfNotExistsAsync(MakeNotification(wantedId, subject: "Wanted"));
|
||||
await repo.InsertIfNotExistsAsync(MakeNotification(otherId, subject: "Other"));
|
||||
}
|
||||
|
||||
await using var queryContext = CreateContext();
|
||||
var queryRepo = new NotificationOutboxRepository(queryContext);
|
||||
var (rows, totalCount) = await queryRepo.QueryAsync(
|
||||
new NotificationOutboxFilter(NotificationId: wantedId), pageNumber: 1, pageSize: 50);
|
||||
|
||||
Assert.Equal(1, totalCount);
|
||||
var row = Assert.Single(rows);
|
||||
Assert.Equal(wantedId, row.NotificationId);
|
||||
Assert.Equal("Wanted", row.Subject);
|
||||
}
|
||||
|
||||
// --- helpers ------------------------------------------------------------
|
||||
|
||||
private ScadaBridgeDbContext CreateContext()
|
||||
|
||||
+34
@@ -115,6 +115,40 @@ public class NotificationOutboxActorQueryTests : TestKit
|
||||
Assert.Equal("site-1", staleSummary.SourceSiteId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Query_WithNotificationIdFilter_PassesExactMatchToRepositoryFilter()
|
||||
{
|
||||
_repository.QueryAsync(
|
||||
Arg.Any<NotificationOutboxFilter>(), Arg.Any<int>(), Arg.Any<int>(), Arg.Any<CancellationToken>())
|
||||
.Returns(((IReadOnlyList<Notification>)Array.Empty<Notification>(), 0));
|
||||
var actor = CreateActor();
|
||||
|
||||
actor.Tell(
|
||||
new NotificationOutboxQueryRequest(
|
||||
CorrelationId: "corr-nid",
|
||||
StatusFilter: null,
|
||||
TypeFilter: null,
|
||||
SourceSiteFilter: null,
|
||||
ListNameFilter: null,
|
||||
StuckOnly: false,
|
||||
SubjectKeyword: null,
|
||||
From: null,
|
||||
To: null,
|
||||
PageNumber: 1,
|
||||
PageSize: 50,
|
||||
NotificationIdFilter: "abc"),
|
||||
TestActor);
|
||||
|
||||
var response = ExpectMsg<NotificationOutboxQueryResponse>();
|
||||
Assert.True(response.Success);
|
||||
|
||||
// The ?correlationId= deep link from the Flow Debugger / Audit Log rides through
|
||||
// to the repository as an exact-match NotificationId constraint.
|
||||
_repository.Received(1).QueryAsync(
|
||||
Arg.Is<NotificationOutboxFilter>(f => f.NotificationId == "abc"),
|
||||
1, 50, Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Query_WithStatusFilterString_ParsesToEnumOnFilter()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user