From 480e77010de213afc7b1c73e836b7c16d08d99b4 Mon Sep 17 00:00:00 2001 From: Amund Myrbostad Date: Tue, 10 Sep 2024 14:15:41 +0200 Subject: [PATCH] Updated DialogGenerator to match Rules set by validators Fixed CreateDialogCommandValidator check for TransmissionOpened --- .../Create/CreateDialogCommandValidator.cs | 20 +++++++++++++++---- .../DialogGenerator.cs | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogCommandValidator.cs b/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogCommandValidator.cs index 148a81778..91aba31d6 100644 --- a/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogCommandValidator.cs +++ b/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogCommandValidator.cs @@ -400,10 +400,22 @@ public CreateDialogDialogActivityDtoValidator( // .WithMessage($"{nameof(DialogActivityType.Values.DialogOpened)} is not allowed on a transmission.") .WithMessage($"A {nameof(DialogActivityType.Values.DialogOpened)} activity cannot reference a transmission.") // er det dette "rett" feilmelding? .When(x => x.Type == DialogActivityType.Values.DialogOpened); - RuleFor(x => x.TransmissionId) - .NotNull() - .WithMessage($"A {nameof(DialogActivityType.Values.TransmissionOpened)} needs to reference a transmission.") - .When(x => x.Type == DialogActivityType.Values.TransmissionOpened); + // Testene feilet av denne. var den for streng? + // Sier jeg her at når transmissionId != null MÅ Type == TransmissionOpened? + // Sier ikke den fra notification det samme? + // RuleFor(x => x.TransmissionId) + // .NotNull() + // .WithMessage($"A {nameof(DialogActivityType.Values.TransmissionOpened)} needs to reference a transmission.") + // .When(x => x.Type == DialogActivityType.Values.TransmissionOpened); + // ====================== REF FRA NOTIFI ========= + // RuleFor(x => x.TransmissionId) + // .NotNull() + // .NotEqual(default(Guid)) + // .When(x => x.ActivityType == DialogActivityType.Values.TransmissionOpened); + // ===================== END REF =================== + RuleFor(x => x.Type) + .Equal(DialogActivityType.Values.TransmissionOpened) + .When(x => x.TransmissionId != null); } } diff --git a/src/Digdir.Tool.Dialogporten.GenerateFakeData/DialogGenerator.cs b/src/Digdir.Tool.Dialogporten.GenerateFakeData/DialogGenerator.cs index 15ffde70e..dd5d997ec 100644 --- a/src/Digdir.Tool.Dialogporten.GenerateFakeData/DialogGenerator.cs +++ b/src/Digdir.Tool.Dialogporten.GenerateFakeData/DialogGenerator.cs @@ -247,12 +247,12 @@ public static List GenerateFakeDialogTransmis public static List GenerateFakeDialogActivities(int? count = null, DialogActivityType.Values? type = null) { return new Faker() - .RuleFor(o => o.Id, f => Uuid7.NewUuid7().ToGuid(true)) .RuleFor(o => o.CreatedAt, f => f.Date.Past()) .RuleFor(o => o.ExtendedType, f => new Uri(f.Internet.UrlWithPath())) .RuleFor(o => o.Type, f => type ?? f.PickRandom()) .RuleFor(o => o.PerformedBy, f => new CreateDialogDialogActivityPerformedByActorDto { ActorType = ActorType.Values.PartyRepresentative, ActorName = f.Name.FullName() }) .RuleFor(o => o.Description, (f, o) => o.Type == DialogActivityType.Values.Information ? GenerateFakeLocalizations(f.Random.Number(4, 8)) : null) + .RuleFor(o => o.Id, () => type == DialogActivityType.Values.DialogOpened ? null : Uuid7.NewUuid7().ToGuid(true)) .Generate(count ?? new Randomizer().Number(1, 4)); }