From f88b1ba01e01e4386b621c6ad0c25e7f29ca721c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20J=C3=B8rgen=20Skogstad?= Date: Tue, 24 Dec 2024 23:49:06 +0100 Subject: [PATCH] pffft --- docs/schema/V1/swagger.verified.json | 25 ++++-- .../IServiceResourceAuthorizer.cs | 2 +- .../Commands/Create/CreateDialogCommand.cs | 14 ++-- .../Create/CreateDialogCommandValidator.cs | 18 +++- .../Commands/Create/CreateDialogDto.cs | 2 +- .../Commands/Update/UpdateDialogCommand.cs | 7 ++ .../Dialogs/Create/CreateDialogEndpoint.cs | 15 +++- .../Dialogs/Update/UpdateDialogEndpoint.cs | 5 +- .../DialogGenerator.cs | 83 ++++++++++++++++--- .../V1/Common/Events/DomainEventsTests.cs | 50 +++++------ .../Dialogs/Queries/ActivityLogTests.cs | 6 +- .../Dialogs/Queries/DeletedDialogTests.cs | 2 +- .../EndUser/Dialogs/Queries/SeenLogTests.cs | 10 +-- .../Dialogs/Commands/CreateDialogTests.cs | 62 +++++++------- .../Dialogs/Commands/DeleteDialogTests.cs | 4 +- .../Dialogs/Commands/PurgeDialogTests.cs | 6 +- .../Dialogs/Commands/UpdateDialogTests.cs | 8 +- .../Dialogs/Queries/ActivityLogTests.cs | 6 +- .../Dialogs/Queries/GetDialogTests.cs | 11 +-- .../Dialogs/Queries/SeenLogTests.cs | 10 +-- .../NotificationConditionTests.cs | 12 +-- .../Commands/CreateTransmissionTests.cs | 16 ++-- .../Commands/UpdateTransmissionTests.cs | 12 +-- .../Dialogs/Commands/CreateDialogTests.cs | 12 +-- 24 files changed, 254 insertions(+), 144 deletions(-) diff --git a/docs/schema/V1/swagger.verified.json b/docs/schema/V1/swagger.verified.json index 51d6c547a..373fcb440 100644 --- a/docs/schema/V1/swagger.verified.json +++ b/docs/schema/V1/swagger.verified.json @@ -2243,7 +2243,7 @@ }, "type": "object" }, - "V1ServiceOwnerDialogsCommandsCreate_DialogCommand": { + "V1ServiceOwnerDialogsCommandsCreate_Dialog": { "additionalProperties": false, "properties": { "activities": { @@ -3221,6 +3221,18 @@ }, "type": "object" }, + "V1ServiceOwnerDialogsCreate_DialogRequest": { + "additionalProperties": false, + "properties": { + "dto": { + "$ref": "#/components/schemas/V1ServiceOwnerDialogsCommandsCreate_Dialog" + }, + "produceDialogEvents": { + "type": "boolean" + } + }, + "type": "object" + }, "V1ServiceOwnerDialogSeenLogsQueriesGet_SeenLog": { "additionalProperties": false, "properties": { @@ -4237,6 +4249,9 @@ "properties": { "dto": { "$ref": "#/components/schemas/V1ServiceOwnerDialogsCommandsUpdate_Dialog" + }, + "produceDialogEvents": { + "type": "boolean" } }, "type": "object" @@ -5832,14 +5847,12 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/V1ServiceOwnerDialogsCommandsCreate_DialogCommand" + "$ref": "#/components/schemas/V1ServiceOwnerDialogsCommandsCreate_Dialog" } } }, - "description": "", "required": true, - "x-name": "CreateDialogCommand", - "x-position": 1 + "x-name": "dto" }, "responses": { "201": { @@ -6970,4 +6983,4 @@ "url": "https://altinn-dev-api.azure-api.net/dialogporten" } ] -} \ No newline at end of file +} diff --git a/src/Digdir.Domain.Dialogporten.Application/Common/Authorization/IServiceResourceAuthorizer.cs b/src/Digdir.Domain.Dialogporten.Application/Common/Authorization/IServiceResourceAuthorizer.cs index 793b2e773..1120fb2a3 100644 --- a/src/Digdir.Domain.Dialogporten.Application/Common/Authorization/IServiceResourceAuthorizer.cs +++ b/src/Digdir.Domain.Dialogporten.Application/Common/Authorization/IServiceResourceAuthorizer.cs @@ -75,7 +75,7 @@ public async Task SetResourceType(DialogEntity dialog, Ca if (serviceResourceInformation is null) { var supportedResourceTypes = string.Join(", ", Constants.SupportedResourceTypes); - _domainContext.AddError(nameof(CreateDialogCommand.ServiceResource), + _domainContext.AddError(nameof(CreateDialogDto.ServiceResource), $"Service resource '{dialog.ServiceResource}' does not exist in the resource " + $"registry, or is not of the following supported resource types: " + $"[{supportedResourceTypes}]."); diff --git a/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogCommand.cs b/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogCommand.cs index 2fee13aa3..447f924fa 100644 --- a/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogCommand.cs +++ b/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogCommand.cs @@ -19,7 +19,11 @@ namespace Digdir.Domain.Dialogporten.Application.Features.V1.ServiceOwner.Dialogs.Commands.Create; -public sealed class CreateDialogCommand : CreateDialogDto, IRequest; +public sealed class CreateDialogCommand : IRequest +{ + public bool ProduceDialogEvents { get; init; } = true; + public CreateDialogDto Dto { get; set; } = null!; +} [GenerateOneOf] public sealed partial class CreateDialogResult : OneOfBase, DomainError, ValidationError, Forbidden>; @@ -54,7 +58,7 @@ public CreateDialogCommandHandler( public async Task Handle(CreateDialogCommand request, CancellationToken cancellationToken) { - var dialog = _mapper.Map(request); + var dialog = _mapper.Map(request.Dto); await _serviceResourceAuthorizer.SetResourceType(dialog, cancellationToken); var serviceResourceAuthorizationResult = await _serviceResourceAuthorizer.AuthorizeServiceResources(dialog, cancellationToken); @@ -86,7 +90,7 @@ public async Task Handle(CreateDialogCommand request, Cancel _domainContext.AddErrors(dialog.Transmissions.ValidateReferenceHierarchy( keySelector: x => x.Id, parentKeySelector: x => x.RelatedTransmissionId, - propertyName: nameof(CreateDialogCommand.Transmissions), + propertyName: nameof(CreateDialogDto.Transmissions), maxDepth: 100, maxWidth: 1)); @@ -101,7 +105,7 @@ public async Task Handle(CreateDialogCommand request, Cancel private void CreateDialogEndUserContext(CreateDialogCommand request, DialogEntity dialog) { dialog.DialogEndUserContext = new(); - if (!request.SystemLabel.HasValue) + if (!request.Dto.SystemLabel.HasValue) { return; } @@ -113,7 +117,7 @@ private void CreateDialogEndUserContext(CreateDialogCommand request, DialogEntit } dialog.DialogEndUserContext.UpdateLabel( - request.SystemLabel.Value, + request.Dto.SystemLabel.Value, $"{NorwegianOrganizationIdentifier.PrefixWithSeparator}{organizationNumber}", ActorType.Values.ServiceOwner); } 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 e35be4053..7ba383a87 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 @@ -17,7 +17,17 @@ namespace Digdir.Domain.Dialogporten.Application.Features.V1.ServiceOwner.Dialog internal sealed class CreateDialogCommandValidator : AbstractValidator { - public CreateDialogCommandValidator( + public CreateDialogCommandValidator(IValidator createDialogDtoValidator) + { + RuleFor(x => x.Dto) + .NotEmpty() + .SetValidator(createDialogDtoValidator); + } +} + +internal sealed class CreateDialogDtoValidator : AbstractValidator +{ + public CreateDialogDtoValidator( IValidator transmissionValidator, IValidator attachmentValidator, IValidator guiActionValidator, @@ -35,13 +45,13 @@ public CreateDialogCommandValidator( RuleFor(x => x.CreatedAt) .NotEmpty() - .WithMessage($"{{PropertyName}} must not be empty when '{nameof(CreateDialogCommand.UpdatedAt)} is set.") + .WithMessage($"{{PropertyName}} must not be empty when '{nameof(CreateDialogDto.UpdatedAt)} is set.") .When(x => x.UpdatedAt != default); RuleFor(x => x.UpdatedAt) .IsInPast() .GreaterThanOrEqualTo(x => x.CreatedAt) - .WithMessage($"'{{PropertyName}}' must be greater than or equal to '{nameof(CreateDialogCommand.CreatedAt)}'.") + .WithMessage($"'{{PropertyName}}' must be greater than or equal to '{nameof(CreateDialogDto.CreatedAt)}'.") .When(x => x.CreatedAt != default && x.UpdatedAt != default); RuleFor(x => x.ServiceResource) @@ -136,7 +146,7 @@ public CreateDialogCommandValidator( RuleFor(x => x.Process) .NotEmpty() - .WithMessage($"{{PropertyName}} must not be empty when {nameof(CreateDialogCommand.PrecedingProcess)} is set.") + .WithMessage($"{{PropertyName}} must not be empty when {nameof(CreateDialogDto.PrecedingProcess)} is set.") .When(x => x.PrecedingProcess is not null); RuleFor(x => x.PrecedingProcess) diff --git a/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogDto.cs b/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogDto.cs index 5b7791a71..4f98ce59f 100644 --- a/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogDto.cs +++ b/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogDto.cs @@ -11,7 +11,7 @@ namespace Digdir.Domain.Dialogporten.Application.Features.V1.ServiceOwner.Dialogs.Commands.Create; -public class CreateDialogDto +public sealed class CreateDialogDto { /// /// A self-defined UUIDv7 may be provided to support idempotent creation of dialogs. If not provided, a new UUIDv7 will be generated. diff --git a/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogCommand.cs b/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogCommand.cs index fb160b026..2c78dfd4d 100644 --- a/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogCommand.cs +++ b/src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogCommand.cs @@ -28,6 +28,7 @@ public sealed class UpdateDialogCommand : IRequest public Guid Id { get; set; } public Guid? IfMatchDialogRevision { get; set; } public UpdateDialogDto Dto { get; set; } = null!; + public bool ProduceDialogEvents { get; set; } = true; } [GenerateOneOf] @@ -162,6 +163,12 @@ public async Task Handle(UpdateDialogCommand request, Cancel } UpdateLabel(dialog); + + if (!request.ProduceDialogEvents) + { + _unitOfWork.WithoutAggregateSideEffects(); + } + var saveResult = await _unitOfWork .EnableConcurrencyCheck(dialog, request.IfMatchDialogRevision) .SaveChangesAsync(cancellationToken); diff --git a/src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/Dialogs/Create/CreateDialogEndpoint.cs b/src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/Dialogs/Create/CreateDialogEndpoint.cs index cbc9938e7..051854ad7 100644 --- a/src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/Dialogs/Create/CreateDialogEndpoint.cs +++ b/src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/Dialogs/Create/CreateDialogEndpoint.cs @@ -9,7 +9,7 @@ namespace Digdir.Domain.Dialogporten.WebApi.Endpoints.V1.ServiceOwner.Dialogs.Create; -public sealed class CreateDialogEndpoint : Endpoint +public sealed class CreateDialogEndpoint : Endpoint { private readonly ISender _sender; @@ -30,9 +30,10 @@ public override void Configure() StatusCodes.Status422UnprocessableEntity)); } - public override async Task HandleAsync(CreateDialogCommand req, CancellationToken ct) + public override async Task HandleAsync(CreateDialogRequest req, CancellationToken ct) { - var result = await _sender.Send(req, ct); + var command = new CreateDialogCommand { Dto = req.Dto, ProduceDialogEvents = req.ProduceDialogEvents }; + var result = await _sender.Send(command, ct); await result.Match( success => SendCreatedAtAsync(new GetDialogQuery { DialogId = success.Value }, success.Value, cancellation: ct), domainError => this.UnprocessableEntityAsync(domainError, ct), @@ -40,3 +41,11 @@ await result.Match( forbidden => this.ForbiddenAsync(forbidden, ct)); } } + +public sealed class CreateDialogRequest +{ + public bool ProduceDialogEvents { get; init; } = true; + + [FromBody] + public CreateDialogDto Dto { get; set; } = null!; +} diff --git a/src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/Dialogs/Update/UpdateDialogEndpoint.cs b/src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/Dialogs/Update/UpdateDialogEndpoint.cs index d75486f68..96845f77e 100644 --- a/src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/Dialogs/Update/UpdateDialogEndpoint.cs +++ b/src/Digdir.Domain.Dialogporten.WebApi/Endpoints/V1/ServiceOwner/Dialogs/Update/UpdateDialogEndpoint.cs @@ -38,7 +38,8 @@ public override async Task HandleAsync(UpdateDialogRequest req, CancellationToke { Id = req.DialogId, IfMatchDialogRevision = req.IfMatchDialogRevision, - Dto = req.Dto + Dto = req.Dto, + ProduceDialogEvents = req.ProduceDialogEvents }; var updateDialogResult = await _sender.Send(command, ct); @@ -61,4 +62,6 @@ public sealed class UpdateDialogRequest [FromHeader(headerName: Constants.IfMatch, isRequired: false, removeFromSchema: true)] public Guid? IfMatchDialogRevision { get; set; } + + public bool ProduceDialogEvents { get; init; } = true; } diff --git a/src/Digdir.Tool.Dialogporten.GenerateFakeData/DialogGenerator.cs b/src/Digdir.Tool.Dialogporten.GenerateFakeData/DialogGenerator.cs index 4cbd05a9d..449a9eacd 100644 --- a/src/Digdir.Tool.Dialogporten.GenerateFakeData/DialogGenerator.cs +++ b/src/Digdir.Tool.Dialogporten.GenerateFakeData/DialogGenerator.cs @@ -19,7 +19,61 @@ public static class DialogGenerator { private static readonly DateTime RefTime = new(2026, 1, 1); - public static CreateDialogCommand GenerateFakeDialog( + public static CreateDialogCommand GenerateSimpleFakeCreateDialogCommand(Guid? id = null) => new() + { + Dto = GenerateSimpleFakeDialog(id) + }; + + public static CreateDialogCommand GenerateFakeCreateDialogCommand( + int? seed = null, + Guid? id = null, + string? serviceResource = null, + string? party = null, + int? progress = null, + string? extendedStatus = null, + string? externalReference = null, + DateTimeOffset? createdAt = null, + DateTimeOffset? updatedAt = null, + DateTimeOffset? dueAt = null, + DateTimeOffset? expiresAt = null, + string? process = null, + DialogStatus.Values? status = null, + ContentDto? content = null, + List? searchTags = null, + List? attachments = null, + List? guiActions = null, + List? apiActions = null, + List? activities = null, + List? transmissions = null) => new() + { + Dto = GenerateFakeDialogs( + seed, + 1, + id, + serviceResource, + party, + null, + null, + progress, + extendedStatus, + externalReference, + createdAt, + updatedAt, + dueAt, + expiresAt, + process, + status, + content, + searchTags, + attachments, + guiActions, + apiActions, + activities, + transmissions + )[0] + }; + + public static CreateDialogDto GenerateFakeDialog( int? seed = null, Guid? id = null, string? serviceResource = null, @@ -68,7 +122,7 @@ public static CreateDialogCommand GenerateFakeDialog( )[0]; } - public static List GenerateFakeDialogs(int? seed = null, + public static List GenerateFakeDialogs(int? seed = null, int count = 1, Guid? id = null, string? serviceResource = null, @@ -93,7 +147,7 @@ public static List GenerateFakeDialogs(int? seed = null, List? transmissions = null) { Randomizer.Seed = seed.HasValue ? new Random(seed.Value) : new Random(); - return new Faker() + return new Faker() .RuleFor(o => o.Id, _ => id ?? IdentifiableExtensions.CreateVersion7()) .RuleFor(o => o.ServiceResource, _ => serviceResource ?? GenerateFakeResource(serviceResourceGenerator)) .RuleFor(o => o.Party, _ => party ?? GenerateRandomParty(partyGenerator)) @@ -118,7 +172,7 @@ public static List GenerateFakeDialogs(int? seed = null, private const string ResourcePrefix = "urn:altinn:resource:"; - public static CreateDialogCommand GenerateSimpleFakeDialog(Guid? id = null) + public static CreateDialogDto GenerateSimpleFakeDialog(Guid? id = null) { return GenerateFakeDialog( id: id, @@ -139,7 +193,8 @@ public static string GenerateFakeResource(Func? generator = null) // Apply a power function to skew the distribution towards higher numbers // The exponent controls the shape of the distribution curve const int numberOfDistinctResources = 1000; - const int exponent = 15; // Uses to adjust the distribution curve. Higher value = more skewed towards higher numbers + const int + exponent = 15; // Uses to adjust the distribution curve. Higher value = more skewed towards higher numbers var biasedRandom = Math.Pow(r.Double(), 1.0 / exponent); var result = 1 + (int)(biasedRandom * (numberOfDistinctResources - 1)); @@ -153,7 +208,9 @@ public static string GenerateRandomParty(Func? generator = null, bool f if (generatedValue != null) return generatedValue; var r = new Randomizer(); - return r.Bool() && !forcePerson ? $"urn:altinn:organization:identifier-no:{GenerateFakeOrgNo()}" : $"urn:altinn:person:identifier-no:{GenerateFakePid()}"; + return r.Bool() && !forcePerson + ? $"urn:altinn:organization:identifier-no:{GenerateFakeOrgNo()}" + : $"urn:altinn:person:identifier-no:{GenerateFakePid()}"; } private static readonly int[] SocialSecurityNumberWeights1 = [3, 7, 6, 1, 8, 9, 4, 5, 2]; @@ -162,7 +219,6 @@ public static string GenerateRandomParty(Func? generator = null, bool f public static string GenerateFakePid() { - int c1, c2; string pidWithoutControlDigits; do @@ -174,7 +230,6 @@ public static string GenerateFakePid() c1 = CalculateControlDigit(pidWithoutControlDigits, SocialSecurityNumberWeights1); c2 = CalculateControlDigit(pidWithoutControlDigits + c1, SocialSecurityNumberWeights2); - } while (c1 == -1 || c2 == -1); return pidWithoutControlDigits + c1 + c2; @@ -215,6 +270,7 @@ private static string GetRandomIndividualNumber(int year) private static readonly DateTime BirthDateRangeBegin = new(1965, 1, 1); private static readonly DateTime BirthDateRangeEnd = new(1970, 1, 1); private static readonly TimeSpan Range = BirthDateRangeEnd - BirthDateRangeBegin; + private static DateTime GenerateRandomDateOfBirth() { var r = new Randomizer(); @@ -254,7 +310,8 @@ public static List GenerateFakeDialogTransmissions(int? count = .Generate(count ?? new Randomizer().Number(1, 4)); } - public static List GenerateFakeDialogActivities(int? count = null, DialogActivityType.Values? type = null) + public static List GenerateFakeDialogActivities(int? count = null, + DialogActivityType.Values? type = null) { // Temporarily removing the ActivityType TransmissionOpened from the list of possible types for random picking. // Going to have a look at re-writing the generator https://github.com/digdir/dialogporten/issues/1123 @@ -266,8 +323,12 @@ public static List GenerateFakeDialogActivities(int? count = null, .RuleFor(o => o.CreatedAt, f => f.Date.Past()) .RuleFor(o => o.ExtendedType, f => new Uri(f.Internet.UrlWithPath(Uri.UriSchemeHttps))) .RuleFor(o => o.Type, f => type ?? f.PickRandom(activityTypes)) - .RuleFor(o => o.PerformedBy, f => new ActorDto { 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.PerformedBy, + f => new ActorDto { 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) .Generate(count ?? new Randomizer().Number(1, 4)); } diff --git a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/Common/Events/DomainEventsTests.cs b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/Common/Events/DomainEventsTests.cs index 306d3100a..8cb550cf4 100644 --- a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/Common/Events/DomainEventsTests.cs +++ b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/Common/Events/DomainEventsTests.cs @@ -46,26 +46,27 @@ public async Task Creates_CloudEvents_When_Dialog_Created() .Single(x => x.Type == DialogActivityType.Values.TransmissionOpened); var transmission = DialogGenerator.GenerateFakeDialogTransmissions(1).First(); transmissionOpenedActivity.TransmissionId = transmission.Id; - var createDialogCommand = DialogGenerator.GenerateFakeDialog( + var createDialogCommand = DialogGenerator.GenerateFakeCreateDialogCommand( activities: activities, attachments: DialogGenerator.GenerateFakeDialogAttachments(3)); - createDialogCommand.Transmissions.Add(transmission); + var dto = createDialogCommand.Dto; + dto.Transmissions.Add(transmission); // Act await Application.Send(createDialogCommand); await harness.Consumed - .SelectAsync(x => x.Context.Message.DialogId == createDialogCommand.Id) + .SelectAsync(x => x.Context.Message.DialogId == dto.Id) .FirstOrDefault(); await harness.Consumed - .SelectAsync(x => x.Context.Message.DialogId == createDialogCommand.Id) + .SelectAsync(x => x.Context.Message.DialogId == dto.Id) .Take(activities.Count) .ToListAsync(); var cloudEvents = Application.PopPublishedCloudEvents(); // Assert - cloudEvents.Should().OnlyContain(cloudEvent => cloudEvent.ResourceInstance == createDialogCommand.Id.ToString()); - cloudEvents.Should().OnlyContain(cloudEvent => cloudEvent.Resource == createDialogCommand.ServiceResource); - cloudEvents.Should().OnlyContain(cloudEvent => cloudEvent.Subject == createDialogCommand.Party); + cloudEvents.Should().OnlyContain(cloudEvent => cloudEvent.ResourceInstance == dto.Id.ToString()); + cloudEvents.Should().OnlyContain(cloudEvent => cloudEvent.Resource == dto.ServiceResource); + cloudEvents.Should().OnlyContain(cloudEvent => cloudEvent.Subject == dto.Party); cloudEvents.Should().ContainSingle(cloudEvent => cloudEvent.Type == CloudEventTypes.Get(nameof(DialogCreatedDomainEvent))); @@ -77,7 +78,7 @@ await harness.Consumed cloudEvents.Count .Should() // +1 for the dialog created event - .Be(createDialogCommand.Activities.Count + 1); + .Be(dto.Activities.Count + 1); } [Fact] @@ -85,14 +86,15 @@ public async Task Creates_CloudEvent_When_Dialog_Updates() { // Arrange var harness = await Application.ConfigureServicesWithMassTransitTestHarness(); - var createDialogCommand = DialogGenerator.GenerateFakeDialog( + var createDialogCommand = DialogGenerator.GenerateFakeCreateDialogCommand( activities: [], progress: 0, attachments: []); await Application.Send(createDialogCommand); + var dto = createDialogCommand.Dto; - var getDialogResult = await Application.Send(new GetDialogQuery { DialogId = createDialogCommand.Id!.Value }); + var getDialogResult = await Application.Send(new GetDialogQuery { DialogId = dto.Id!.Value }); getDialogResult.TryPickT0(out var getDialogDto, out _); var updateDialogDto = Mapper.Map(getDialogDto); @@ -102,20 +104,20 @@ public async Task Creates_CloudEvent_When_Dialog_Updates() var updateDialogCommand = new UpdateDialogCommand { - Id = createDialogCommand.Id!.Value, + Id = dto.Id!.Value, Dto = updateDialogDto }; await Application.Send(updateDialogCommand); await harness.Consumed - .SelectAsync(x => x.Context.Message.DialogId == createDialogCommand.Id) + .SelectAsync(x => x.Context.Message.DialogId == dto.Id) .FirstOrDefault(); var cloudEvents = Application.PopPublishedCloudEvents(); // Assert - cloudEvents.Should().OnlyContain(cloudEvent => cloudEvent.ResourceInstance == createDialogCommand.Id!.Value.ToString()); - cloudEvents.Should().OnlyContain(cloudEvent => cloudEvent.Resource == createDialogCommand.ServiceResource); - cloudEvents.Should().OnlyContain(cloudEvent => cloudEvent.Subject == createDialogCommand.Party); + cloudEvents.Should().OnlyContain(cloudEvent => cloudEvent.ResourceInstance == dto.Id!.Value.ToString()); + cloudEvents.Should().OnlyContain(cloudEvent => cloudEvent.Resource == dto.ServiceResource); + cloudEvents.Should().OnlyContain(cloudEvent => cloudEvent.Subject == dto.Party); cloudEvents.Should().ContainSingle(cloudEvent => cloudEvent.Type == CloudEventTypes.Get(nameof(DialogUpdatedDomainEvent))); @@ -127,7 +129,7 @@ public async Task Creates_CloudEvent_When_Attachments_Updates() // Arrange var harness = await Application.ConfigureServicesWithMassTransitTestHarness(); var dialogId = IdentifiableExtensions.CreateVersion7(); - var createDialogCommand = DialogGenerator.GenerateFakeDialog( + var createDialogCommand = DialogGenerator.GenerateFakeCreateDialogCommand( id: dialogId, attachments: []); @@ -163,8 +165,8 @@ await harness.Consumed // Assert cloudEvents.Should().OnlyContain(cloudEvent => cloudEvent.ResourceInstance == dialogId.ToString()); - cloudEvents.Should().OnlyContain(cloudEvent => cloudEvent.Resource == createDialogCommand.ServiceResource); - cloudEvents.Should().OnlyContain(cloudEvent => cloudEvent.Subject == createDialogCommand.Party); + cloudEvents.Should().OnlyContain(cloudEvent => cloudEvent.Resource == createDialogCommand.Dto.ServiceResource); + cloudEvents.Should().OnlyContain(cloudEvent => cloudEvent.Subject == createDialogCommand.Dto.Party); cloudEvents.Should().ContainSingle(cloudEvent => cloudEvent.Type == CloudEventTypes.Get(nameof(DialogUpdatedDomainEvent))); @@ -175,7 +177,7 @@ public async Task Creates_CloudEvents_When_Dialog_Deleted() // Arrange var harness = await Application.ConfigureServicesWithMassTransitTestHarness(); var dialogId = IdentifiableExtensions.CreateVersion7(); - var createDialogCommand = DialogGenerator.GenerateFakeDialog(id: dialogId, attachments: [], activities: []); + var createDialogCommand = DialogGenerator.GenerateFakeCreateDialogCommand(id: dialogId, attachments: [], activities: []); await Application.Send(createDialogCommand); @@ -192,8 +194,8 @@ await harness.Consumed // Assert cloudEvents.Should().OnlyContain(cloudEvent => cloudEvent.ResourceInstance == dialogId.ToString()); - cloudEvents.Should().OnlyContain(cloudEvent => cloudEvent.Resource == createDialogCommand.ServiceResource); - cloudEvents.Should().OnlyContain(cloudEvent => cloudEvent.Subject == createDialogCommand.Party); + cloudEvents.Should().OnlyContain(cloudEvent => cloudEvent.Resource == createDialogCommand.Dto.ServiceResource); + cloudEvents.Should().OnlyContain(cloudEvent => cloudEvent.Subject == createDialogCommand.Dto.Party); cloudEvents.Should().ContainSingle(cloudEvent => cloudEvent.Type == CloudEventTypes.Get(nameof(DialogDeletedDomainEvent))); @@ -205,7 +207,7 @@ public async Task Creates_DialogDeletedEvent_When_Dialog_Purged() // Arrange var harness = await Application.ConfigureServicesWithMassTransitTestHarness(); var dialogId = IdentifiableExtensions.CreateVersion7(); - var createDialogCommand = DialogGenerator.GenerateFakeDialog(id: dialogId, attachments: [], activities: []); + var createDialogCommand = DialogGenerator.GenerateFakeCreateDialogCommand(id: dialogId, attachments: [], activities: []); await Application.Send(createDialogCommand); @@ -223,8 +225,8 @@ await harness.Consumed // Assert cloudEvents.Should().OnlyContain(cloudEvent => cloudEvent.ResourceInstance == dialogId.ToString()); - cloudEvents.Should().OnlyContain(cloudEvent => cloudEvent.Resource == createDialogCommand.ServiceResource); - cloudEvents.Should().OnlyContain(cloudEvent => cloudEvent.Subject == createDialogCommand.Party); + cloudEvents.Should().OnlyContain(cloudEvent => cloudEvent.Resource == createDialogCommand.Dto.ServiceResource); + cloudEvents.Should().OnlyContain(cloudEvent => cloudEvent.Subject == createDialogCommand.Dto.Party); cloudEvents.Should().ContainSingle(cloudEvent => cloudEvent.Type == CloudEventTypes.Get(nameof(DialogDeletedDomainEvent))); diff --git a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/EndUser/Dialogs/Queries/ActivityLogTests.cs b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/EndUser/Dialogs/Queries/ActivityLogTests.cs index d5495680e..c1bf2a376 100644 --- a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/EndUser/Dialogs/Queries/ActivityLogTests.cs +++ b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/EndUser/Dialogs/Queries/ActivityLogTests.cs @@ -42,7 +42,7 @@ public async Task Search_Dialog_LatestActivity_Should_Not_Return_User_Ids_Unhash // Act var response = await Application.Send(new SearchDialogQuery { - ServiceResource = [createDialogCommand.ServiceResource] + ServiceResource = [createDialogCommand.Dto.ServiceResource] }); // Assert @@ -84,11 +84,11 @@ public async Task Get_ActivityLog_Should_Not_Return_User_Ids_Unhashed() private async Task<(CreateDialogCommand, CreateDialogResult)> GenerateDialogWithActivity() { - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(); + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(); var activity = DialogGenerator.GenerateFakeDialogActivity(type: DialogActivityType.Values.Information); activity.PerformedBy.ActorId = DialogGenerator.GenerateRandomParty(forcePerson: true); activity.PerformedBy.ActorName = null; - createDialogCommand.Activities.Add(activity); + createDialogCommand.Dto.Activities.Add(activity); var createCommandResponse = await Application.Send(createDialogCommand); return (createDialogCommand, createCommandResponse); } diff --git a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/EndUser/Dialogs/Queries/DeletedDialogTests.cs b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/EndUser/Dialogs/Queries/DeletedDialogTests.cs index 30e3613cc..1bae1aaef 100644 --- a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/EndUser/Dialogs/Queries/DeletedDialogTests.cs +++ b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/EndUser/Dialogs/Queries/DeletedDialogTests.cs @@ -13,7 +13,7 @@ public class DeletedDialogTests(DialogApplication application) : ApplicationColl public async Task Fetching_Deleted_Dialog_Should_Return_Gone() { // Arrange - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(); + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(); var createDialogResponse = await Application.Send(createDialogCommand); var dialogId = createDialogResponse.AsT0.Value; diff --git a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/EndUser/Dialogs/Queries/SeenLogTests.cs b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/EndUser/Dialogs/Queries/SeenLogTests.cs index ab9cb0bfe..e1ec696f8 100644 --- a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/EndUser/Dialogs/Queries/SeenLogTests.cs +++ b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/EndUser/Dialogs/Queries/SeenLogTests.cs @@ -16,7 +16,7 @@ public class SeenLogTests(DialogApplication application) : ApplicationCollection public async Task Get_Dialog_SeenLog_Should_Not_Return_User_Ids_Unhashed() { - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(); + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(); var createCommandResponse = await Application.Send(createDialogCommand); // Act @@ -38,7 +38,7 @@ public async Task Get_Dialog_SeenLog_Should_Not_Return_User_Ids_Unhashed() public async Task Search_Dialog_SeenLog_Should_Not_Return_User_Ids_Unhashed() { // Arrange - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(); + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(); var createCommandResponse = await Application.Send(createDialogCommand); // Trigger SeenLog @@ -47,7 +47,7 @@ public async Task Search_Dialog_SeenLog_Should_Not_Return_User_Ids_Unhashed() // Act var response = await Application.Send(new SearchDialogQuery { - ServiceResource = [createDialogCommand.ServiceResource] + ServiceResource = [createDialogCommand.Dto.ServiceResource] }); // Assert @@ -67,7 +67,7 @@ public async Task Search_Dialog_SeenLog_Should_Not_Return_User_Ids_Unhashed() public async Task Get_SeenLog_Should_Not_Return_User_Ids_Unhashed() { // Arrange - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(); + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(); var createCommandResponse = await Application.Send(createDialogCommand); var triggerSeenLogResponse = await Application.Send(new GetDialogQuery { DialogId = createCommandResponse.AsT0.Value }); @@ -93,7 +93,7 @@ public async Task Get_SeenLog_Should_Not_Return_User_Ids_Unhashed() public async Task Search_SeenLog_Should_Not_Return_User_Ids_Unhashed() { // Arrange - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(); + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(); var createCommandResponse = await Application.Send(createDialogCommand); // Trigger SeenLog diff --git a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Commands/CreateDialogTests.cs b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Commands/CreateDialogTests.cs index ef91ba303..287074970 100644 --- a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Commands/CreateDialogTests.cs +++ b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Commands/CreateDialogTests.cs @@ -24,7 +24,7 @@ public async Task Cant_Create_Dialog_With_UUIDv4_format() // Arrange var invalidDialogId = Guid.NewGuid(); - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(id: invalidDialogId); + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(id: invalidDialogId); // Act var response = await Application.Send(createDialogCommand); @@ -41,7 +41,7 @@ public async Task Cant_Create_Dialog_With_UUIDv7_In_Little_Endian_Format() // Guid created with Medo, Uuid7.NewUuid7().ToGuid(bigEndian: true) var invalidDialogId = Guid.Parse("b2ca9301-c371-ab74-a87b-4ee1416b9655"); - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(id: invalidDialogId); + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(id: invalidDialogId); // Act var response = await Application.Send(createDialogCommand); @@ -58,7 +58,7 @@ public async Task Cant_Create_Dialog_With_ID_With_Timestamp_In_The_Future() var timestamp = DateTimeOffset.UtcNow.AddSeconds(1); var invalidDialogId = IdentifiableExtensions.CreateVersion7(timestamp); - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(id: invalidDialogId); + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(id: invalidDialogId); // Act var response = await Application.Send(createDialogCommand); @@ -75,7 +75,7 @@ public async Task Create_Dialog_With_ID_With_Timestamp_In_The_Past() var timestamp = DateTimeOffset.UtcNow.AddSeconds(-1); var validDialogId = IdentifiableExtensions.CreateVersion7(timestamp); - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(id: validDialogId); + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(id: validDialogId); // Act var response = await Application.Send(createDialogCommand); @@ -91,7 +91,7 @@ public async Task Create_CreatesDialog_WhenDialogIsSimple() { // Arrange var expectedDialogId = IdentifiableExtensions.CreateVersion7(); - var createCommand = DialogGenerator.GenerateSimpleFakeDialog(id: expectedDialogId); + var createCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(id: expectedDialogId); // Act var response = await Application.Send(createCommand); @@ -106,7 +106,7 @@ public async Task Create_CreateDialog_WhenDialogIsComplex() { // Arrange var expectedDialogId = IdentifiableExtensions.CreateVersion7(); - var createDialogCommand = DialogGenerator.GenerateFakeDialog(id: expectedDialogId); + var createDialogCommand = DialogGenerator.GenerateFakeCreateDialogCommand(id: expectedDialogId); // Act var result = await Application.Send(createDialogCommand); @@ -123,7 +123,7 @@ public async Task Can_Create_Dialog_With_UpdatedAt_Supplied() var dialogId = IdentifiableExtensions.CreateVersion7(); var createdAt = DateTimeOffset.UtcNow.AddYears(-20); var updatedAt = DateTimeOffset.UtcNow.AddYears(-15); - var createDialogCommand = DialogGenerator.GenerateFakeDialog(id: dialogId, updatedAt: updatedAt, createdAt: createdAt); + var createDialogCommand = DialogGenerator.GenerateFakeCreateDialogCommand(id: dialogId, updatedAt: updatedAt, createdAt: createdAt); // Act var createDialogResult = await Application.Send(createDialogCommand); @@ -150,7 +150,7 @@ public async Task Cant_Create_Dialog_With_UpdatedAt_Supplied_Without_CreatedAt_S { // Arrange var updatedAt = DateTimeOffset.UtcNow.AddYears(-15); - var createDialogCommand = DialogGenerator.GenerateFakeDialog(updatedAt: updatedAt); + var createDialogCommand = DialogGenerator.GenerateFakeCreateDialogCommand(updatedAt: updatedAt); // Act var response = await Application.Send(createDialogCommand); @@ -158,7 +158,7 @@ public async Task Cant_Create_Dialog_With_UpdatedAt_Supplied_Without_CreatedAt_S // Assert response.TryPickT2(out var validationError, out _).Should().BeTrue(); validationError.Should().NotBeNull(); - validationError.Errors.Should().Contain(e => e.ErrorMessage.Contains(nameof(createDialogCommand.UpdatedAt))); + validationError.Errors.Should().Contain(e => e.ErrorMessage.Contains(nameof(createDialogCommand.Dto.UpdatedAt))); } [Fact] @@ -167,7 +167,7 @@ public async Task Cant_Create_Dialog_With_UpdatedAt_Date_Earlier_Than_CreatedAt_ // Arrange var createdAt = DateTimeOffset.UtcNow.AddYears(-10); var updatedAt = DateTimeOffset.UtcNow.AddYears(-15); - var createDialogCommand = DialogGenerator.GenerateFakeDialog(updatedAt: updatedAt, createdAt: createdAt); + var createDialogCommand = DialogGenerator.GenerateFakeCreateDialogCommand(updatedAt: updatedAt, createdAt: createdAt); // Act var response = await Application.Send(createDialogCommand); @@ -175,7 +175,7 @@ public async Task Cant_Create_Dialog_With_UpdatedAt_Date_Earlier_Than_CreatedAt_ // Assert response.TryPickT2(out var validationError, out _).Should().BeTrue(); validationError.Should().NotBeNull(); - validationError.Errors.Should().Contain(e => e.ErrorMessage.Contains(nameof(createDialogCommand.CreatedAt))); + validationError.Errors.Should().Contain(e => e.ErrorMessage.Contains(nameof(createDialogCommand.Dto.CreatedAt))); } [Fact] @@ -184,7 +184,7 @@ public async Task Cant_Create_Dialog_With_UpdatedAt_Or_CreatedAt_In_The_Future() // Arrange var aYearFromNow = DateTimeOffset.UtcNow.AddYears(1); var createDialogCommand = DialogGenerator - .GenerateFakeDialog(updatedAt: aYearFromNow, createdAt: aYearFromNow); + .GenerateFakeCreateDialogCommand(updatedAt: aYearFromNow, createdAt: aYearFromNow); // Act var response = await Application.Send(createDialogCommand); @@ -201,7 +201,7 @@ public async Task Can_Create_Dialog_With_UpdatedAt_And_CreatedAt_Being_Equal() // Arrange var aYearAgo = DateTimeOffset.UtcNow.AddYears(-1); var createDialogCommand = DialogGenerator - .GenerateFakeDialog(updatedAt: aYearAgo, createdAt: aYearAgo); + .GenerateFakeCreateDialogCommand(updatedAt: aYearAgo, createdAt: aYearAgo); // Act var response = await Application.Send(createDialogCommand); @@ -218,8 +218,8 @@ public async Task Cannot_Create_Transmission_Without_Content() var transmission = DialogGenerator.GenerateFakeDialogTransmissions(1)[0]; transmission.Content = null!; - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(); - createDialogCommand.Transmissions = [transmission]; + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(); + createDialogCommand.Dto.Transmissions = [transmission]; // Act var response = await Application.Send(createDialogCommand); @@ -240,8 +240,8 @@ public async Task Cannot_Create_Transmission_Without_Content_Value() transmission.Content.Summary.Value = []; transmission.Content.Title.Value = []; - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(); - createDialogCommand.Transmissions = [transmission]; + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(); + createDialogCommand.Dto.Transmissions = [transmission]; // Act var response = await Application.Send(createDialogCommand); @@ -250,7 +250,7 @@ public async Task Cannot_Create_Transmission_Without_Content_Value() response.TryPickT2(out var validationError, out _).Should().BeTrue(); validationError.Should().NotBeNull(); validationError.Errors - .Count(e => e.PropertyName.Contains(nameof(createDialogCommand.Content))) + .Count(e => e.PropertyName.Contains(nameof(createDialogCommand.Dto.Content))) .Should() .Be(2); } @@ -263,8 +263,8 @@ public async Task Cannot_Create_Transmission_With_Empty_Content_Localization_Val transmission.Content.Summary.Value = [new LocalizationDto { LanguageCode = "nb", Value = "" }]; transmission.Content.Title.Value = [new LocalizationDto { LanguageCode = "nb", Value = "" }]; - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(); - createDialogCommand.Transmissions = [transmission]; + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(); + createDialogCommand.Dto.Transmissions = [transmission]; // Act var response = await Application.Send(createDialogCommand); @@ -273,7 +273,7 @@ public async Task Cannot_Create_Transmission_With_Empty_Content_Localization_Val response.TryPickT2(out var validationError, out _).Should().BeTrue(); validationError.Should().NotBeNull(); validationError.Errors - .Count(e => e.PropertyName.Contains(nameof(createDialogCommand.Content))) + .Count(e => e.PropertyName.Contains(nameof(createDialogCommand.Dto.Content))) .Should() .Be(2); } @@ -290,8 +290,8 @@ public async Task Cannot_Create_Transmission_With_Empty_Content_Localization_Val public async Task Cannot_Create_AdditionalInfo_Content_With_Html_MediaType_Without_Correct_Scope() { // Arrange - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(); - createDialogCommand.Content.AdditionalInfo = CreateHtmlContentValueDto(); + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(); + createDialogCommand.Dto.Content.AdditionalInfo = CreateHtmlContentValueDto(); // Act var response = await Application.Send(createDialogCommand); @@ -309,8 +309,8 @@ public async Task Cannot_Create_AdditionalInfo_Content_With_Html_MediaType_Witho public async Task Can_Create_AdditionalInfo_Content_With_Html_MediaType_With_Correct_Scope() { // Arrange - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(); - createDialogCommand.Content.AdditionalInfo = CreateHtmlContentValueDto(); + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(); + createDialogCommand.Dto.Content.AdditionalInfo = CreateHtmlContentValueDto(); var userWithLegacyScope = new IntegrationTestUser([new("scope", Constants.LegacyHtmlScope)]); Application.ConfigureServices(services => @@ -331,8 +331,8 @@ public async Task Can_Create_AdditionalInfo_Content_With_Html_MediaType_With_Cor public async Task Cannot_Create_Title_Content_With_Html_MediaType_With_Correct_Scope() { // Arrange - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(); - createDialogCommand.Content.Title = CreateHtmlContentValueDto(); + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(); + createDialogCommand.Dto.Content.Title = CreateHtmlContentValueDto(); var userWithLegacyScope = new IntegrationTestUser([new("scope", Constants.LegacyHtmlScope)]); Application.ConfigureServices(services => @@ -357,8 +357,8 @@ public async Task Cannot_Create_Title_Content_With_Html_MediaType_With_Correct_S public async Task Cannot_Create_Title_Content_With_Embeddable_Html_MediaType_With_Correct_Scope() { // Arrange - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(); - createDialogCommand.Content.Title = new ContentValueDto + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(); + createDialogCommand.Dto.Content.Title = new ContentValueDto { MediaType = MediaTypes.LegacyEmbeddableHtml, Value = [new LocalizationDto { LanguageCode = "en", Value = "https://external.html" }] @@ -388,8 +388,8 @@ public async Task Can_Create_MainContentRef_Content_With_Embeddable_Html_MediaTy { // Arrange var expectedDialogId = IdentifiableExtensions.CreateVersion7(); - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(id: expectedDialogId); - createDialogCommand.Content.MainContentReference = new ContentValueDto + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(id: expectedDialogId); + createDialogCommand.Dto.Content.MainContentReference = new ContentValueDto { MediaType = MediaTypes.LegacyEmbeddableHtml, Value = [new LocalizationDto { LanguageCode = "en", Value = "https://external.html" }] diff --git a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Commands/DeleteDialogTests.cs b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Commands/DeleteDialogTests.cs index a225fc9a3..703861922 100644 --- a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Commands/DeleteDialogTests.cs +++ b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Commands/DeleteDialogTests.cs @@ -14,7 +14,7 @@ public class DeleteDialogTests(DialogApplication application) : ApplicationColle public async Task Deleting_Dialog_Should_Set_DeletedAt() { // Arrange - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(); + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(); var createDialogResponse = await Application.Send(createDialogCommand); // Act @@ -35,7 +35,7 @@ public async Task Deleting_Dialog_Should_Set_DeletedAt() public async Task Updating_Deleted_Dialog_Should_Return_EntityDeleted() { // Arrange - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(); + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(); var createDialogResponse = await Application.Send(createDialogCommand); var dialogId = createDialogResponse.AsT0.Value; diff --git a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Commands/PurgeDialogTests.cs b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Commands/PurgeDialogTests.cs index 22adc5938..494595e9e 100644 --- a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Commands/PurgeDialogTests.cs +++ b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Commands/PurgeDialogTests.cs @@ -16,7 +16,7 @@ public async Task Purge_RemovesDialog_FromDatabase() { // Arrange var expectedDialogId = IdentifiableExtensions.CreateVersion7(); - var createCommand = DialogGenerator.GenerateFakeDialog(id: expectedDialogId); + var createCommand = DialogGenerator.GenerateFakeCreateDialogCommand(id: expectedDialogId); var createResponse = await Application.Send(createCommand); createResponse.TryPickT0(out _, out _).Should().BeTrue(); @@ -42,7 +42,7 @@ public async Task Purge_ReturnsConcurrencyError_OnIfMatchDialogRevisionMismatch( { // Arrange var expectedDialogId = IdentifiableExtensions.CreateVersion7(); - var createCommand = DialogGenerator.GenerateFakeDialog(id: expectedDialogId); + var createCommand = DialogGenerator.GenerateFakeCreateDialogCommand(id: expectedDialogId); var createResponse = await Application.Send(createCommand); createResponse.TryPickT0(out _, out _).Should().BeTrue(); @@ -59,7 +59,7 @@ public async Task Purge_ReturnsNotFound_OnNonExistingDialog() { // Arrange var expectedDialogId = IdentifiableExtensions.CreateVersion7(); - var createCommand = DialogGenerator.GenerateFakeDialog(id: expectedDialogId); + var createCommand = DialogGenerator.GenerateFakeCreateDialogCommand(id: expectedDialogId); await Application.Send(createCommand); var purgeCommand = new PurgeDialogCommand { DialogId = expectedDialogId }; await Application.Send(purgeCommand); diff --git a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Commands/UpdateDialogTests.cs b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Commands/UpdateDialogTests.cs index d8e752f60..f70211d64 100644 --- a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Commands/UpdateDialogTests.cs +++ b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Commands/UpdateDialogTests.cs @@ -51,9 +51,9 @@ public async Task Cannot_Include_Old_Activities_To_UpdateCommand() public async Task Cannot_Include_Old_Transmissions_In_UpdateCommand() { // Arrange - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(); + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(); var existingTransmission = DialogGenerator.GenerateFakeDialogTransmissions(count: 1).First(); - createDialogCommand.Transmissions.Add(existingTransmission); + createDialogCommand.Dto.Transmissions.Add(existingTransmission); var createCommandResponse = await Application.Send(createDialogCommand); var getDialogQuery = new GetDialogQuery { DialogId = createCommandResponse.AsT0.Value }; @@ -86,11 +86,11 @@ public async Task Cannot_Include_Old_Transmissions_In_UpdateCommand() private async Task<(CreateDialogCommand, CreateDialogResult)> GenerateDialogWithActivity() { - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(); + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(); var activity = DialogGenerator.GenerateFakeDialogActivity(type: DialogActivityType.Values.Information); activity.PerformedBy.ActorId = DialogGenerator.GenerateRandomParty(forcePerson: true); activity.PerformedBy.ActorName = null; - createDialogCommand.Activities.Add(activity); + createDialogCommand.Dto.Activities.Add(activity); var createCommandResponse = await Application.Send(createDialogCommand); return (createDialogCommand, createCommandResponse); } diff --git a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Queries/ActivityLogTests.cs b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Queries/ActivityLogTests.cs index 6b899cff3..6b6b4fb4b 100644 --- a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Queries/ActivityLogTests.cs +++ b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Queries/ActivityLogTests.cs @@ -43,7 +43,7 @@ public async Task Search_Dialog_LatestActivity_Should_Return_User_Ids_Unhashed() // Act var response = await Application.Send(new SearchDialogQuery { - ServiceResource = [createDialogCommand.ServiceResource] + ServiceResource = [createDialogCommand.Dto.ServiceResource] }); // Assert @@ -85,11 +85,11 @@ public async Task Get_ActivityLog_Should_Return_User_Ids_Unhashed() private async Task<(CreateDialogCommand, CreateDialogResult)> GenerateDialogWithActivity() { - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(); + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(); var activity = DialogGenerator.GenerateFakeDialogActivity(type: DialogActivityType.Values.Information); activity.PerformedBy.ActorId = DialogGenerator.GenerateRandomParty(forcePerson: true); activity.PerformedBy.ActorName = null; - createDialogCommand.Activities.Add(activity); + createDialogCommand.Dto.Activities.Add(activity); var createCommandResponse = await Application.Send(createDialogCommand); return (createDialogCommand, createCommandResponse); } diff --git a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Queries/GetDialogTests.cs b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Queries/GetDialogTests.cs index cadeb8a92..cc45fba13 100644 --- a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Queries/GetDialogTests.cs +++ b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Queries/GetDialogTests.cs @@ -16,9 +16,9 @@ public async Task Get_ReturnsSimpleDialog_WhenDialogExists() { // Arrange var expectedDialogId = IdentifiableExtensions.CreateVersion7(); - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(id: expectedDialogId); - + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(id: expectedDialogId); var createCommandResponse = await Application.Send(createDialogCommand); + var dto = createDialogCommand.Dto; // Act var response = await Application.Send(new GetDialogQuery { DialogId = createCommandResponse.AsT0.Value }); @@ -26,7 +26,7 @@ public async Task Get_ReturnsSimpleDialog_WhenDialogExists() // Assert response.TryPickT0(out var result, out _).Should().BeTrue(); result.Should().NotBeNull(); - result.Should().BeEquivalentTo(createDialogCommand, options => options + result.Should().BeEquivalentTo(createDialogCommand.Dto, options => options .Excluding(x => x.UpdatedAt) .Excluding(x => x.CreatedAt) .Excluding(x => x.SystemLabel)); @@ -37,8 +37,9 @@ public async Task Get_ReturnsDialog_WhenDialogExists() { // Arrange var expectedDialogId = IdentifiableExtensions.CreateVersion7(); - var createCommand = DialogGenerator.GenerateFakeDialog(id: expectedDialogId); + var createCommand = DialogGenerator.GenerateFakeCreateDialogCommand(id: expectedDialogId); var createCommandResponse = await Application.Send(createCommand); + var dto = createCommand.Dto; // Act var response = await Application.Send(new GetDialogQuery { DialogId = createCommandResponse.AsT0.Value }); @@ -46,7 +47,7 @@ public async Task Get_ReturnsDialog_WhenDialogExists() // Assert response.TryPickT0(out var result, out _).Should().BeTrue(); result.Should().NotBeNull(); - result.Should().BeEquivalentTo(createCommand, options => options + result.Should().BeEquivalentTo(createCommand.Dto, options => options .Excluding(x => x.UpdatedAt) .Excluding(x => x.CreatedAt) .Excluding(x => x.SystemLabel)); diff --git a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Queries/SeenLogTests.cs b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Queries/SeenLogTests.cs index 49502e2a0..544b491de 100644 --- a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Queries/SeenLogTests.cs +++ b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Queries/SeenLogTests.cs @@ -17,7 +17,7 @@ public class SeenLogTests(DialogApplication application) : ApplicationCollection public async Task Get_Dialog_SeenLog_Should_Return_User_Ids_Unhashed() { // Arrange - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(); + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(); var createCommandResponse = await Application.Send(createDialogCommand); // Call EndUser API to trigger SeenLog @@ -41,7 +41,7 @@ public async Task Get_Dialog_SeenLog_Should_Return_User_Ids_Unhashed() public async Task Search_Dialog_SeenLog_Should_Return_User_Ids_Unhashed() { // Arrange - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(); + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(); var createCommandResponse = await Application.Send(createDialogCommand); // Trigger SeenLog @@ -50,7 +50,7 @@ public async Task Search_Dialog_SeenLog_Should_Return_User_Ids_Unhashed() // Act var response = await Application.Send(new SearchDialogQuery { - ServiceResource = [createDialogCommand.ServiceResource] + ServiceResource = [createDialogCommand.Dto.ServiceResource] }); // Assert @@ -70,7 +70,7 @@ public async Task Search_Dialog_SeenLog_Should_Return_User_Ids_Unhashed() public async Task Get_SeenLog_Should_Return_User_Ids_Unhashed() { // Arrange - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(); + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(); var createCommandResponse = await Application.Send(createDialogCommand); var triggerSeenLogResponse = await Application.Send(new GetDialogQueryEndUser { DialogId = createCommandResponse.AsT0.Value }); @@ -96,7 +96,7 @@ public async Task Get_SeenLog_Should_Return_User_Ids_Unhashed() public async Task Search_SeenLog_Should_Return_User_Ids_Unhashed() { // Arrange - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(); + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(); var createCommandResponse = await Application.Send(createDialogCommand); // Trigger SeenLog diff --git a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/NotificationCondition/NotificationConditionTests.cs b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/NotificationCondition/NotificationConditionTests.cs index 9c13b255c..23e5539df 100644 --- a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/NotificationCondition/NotificationConditionTests.cs +++ b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/NotificationCondition/NotificationConditionTests.cs @@ -28,7 +28,7 @@ public async Task SendNotification_Should_Be_True_When_Conditions_Are_Met( bool expectedSendNotificationValue) { // Arrange - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(); + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(); switch (conditionType) { case NotificationConditionType.Exists when expectedSendNotificationValue: @@ -44,7 +44,7 @@ public async Task SendNotification_Should_Be_True_When_Conditions_Are_Met( if (activityType is DialogActivityType.Values.TransmissionOpened) { - var transmissionId = createDialogCommand.Transmissions.FirstOrDefault()?.Id ?? Guid.NewGuid(); + var transmissionId = createDialogCommand.Dto.Transmissions.FirstOrDefault()?.Id ?? Guid.NewGuid(); notificationConditionQuery.TransmissionId = transmissionId; } @@ -62,13 +62,13 @@ private static void AddActivityRequirements( DialogActivityType.Values activityType) { var activity = DialogGenerator.GenerateFakeDialogActivity(type: activityType); - createDialogCommand.Activities.Add(activity); + createDialogCommand.Dto.Activities.Add(activity); if (activityType is not DialogActivityType.Values.TransmissionOpened) return; var transmission = DialogGenerator.GenerateFakeDialogTransmissions(type: DialogTransmissionType.Values.Information)[0]; - createDialogCommand.Transmissions.Add(transmission); - createDialogCommand.Activities[0].TransmissionId = createDialogCommand.Transmissions[0].Id; + createDialogCommand.Dto.Transmissions.Add(transmission); + createDialogCommand.Dto.Activities[0].TransmissionId = createDialogCommand.Dto.Transmissions[0].Id; } [Fact] @@ -90,7 +90,7 @@ public async Task NotFound_Should_Be_Returned_When_Dialog_Does_Not_Exist() public async Task Gone_Should_Be_Returned_When_Dialog_Is_Deleted() { // Arrange - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(); + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(); var response = await Application.Send(createDialogCommand); response.TryPickT0(out var dialogId, out _); diff --git a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Transmissions/Commands/CreateTransmissionTests.cs b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Transmissions/Commands/CreateTransmissionTests.cs index e0cd3e275..2dd538b32 100644 --- a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Transmissions/Commands/CreateTransmissionTests.cs +++ b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Transmissions/Commands/CreateTransmissionTests.cs @@ -20,10 +20,10 @@ public async Task Can_Create_Simple_Transmission() { // Arrange var dialogId = IdentifiableExtensions.CreateVersion7(); - var createCommand = DialogGenerator.GenerateSimpleFakeDialog(id: dialogId); + var createCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(id: dialogId); var transmission = DialogGenerator.GenerateFakeDialogTransmissions(1)[0]; - createCommand.Transmissions = [transmission]; + createCommand.Dto.Transmissions = [transmission]; // Act var response = await Application.Send(createCommand); @@ -42,7 +42,7 @@ public async Task Can_Create_Transmission_With_Embeddable_Content() { // Arrange var dialogId = IdentifiableExtensions.CreateVersion7(); - var createCommand = DialogGenerator.GenerateSimpleFakeDialog(id: dialogId); + var createCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(id: dialogId); var transmissionId = IdentifiableExtensions.CreateVersion7(); var transmission = DialogGenerator.GenerateFakeDialogTransmissions(1)[0]; @@ -55,7 +55,7 @@ public async Task Can_Create_Transmission_With_Embeddable_Content() Value = [new LocalizationDto { LanguageCode = "nb", Value = contentUrl }] }; - createCommand.Transmissions = [transmission]; + createCommand.Dto.Transmissions = [transmission]; // Act var response = await Application.Send(createCommand); @@ -79,7 +79,7 @@ public async Task Can_Create_Transmission_With_Embeddable_Content() public async Task Cannot_Create_Transmission_Embeddable_Content_With_Http_Url() { // Arrange - var createCommand = DialogGenerator.GenerateSimpleFakeDialog(); + var createCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(); var transmission = DialogGenerator.GenerateFakeDialogTransmissions(1)[0]; @@ -89,7 +89,7 @@ public async Task Cannot_Create_Transmission_Embeddable_Content_With_Http_Url() Value = [new LocalizationDto { LanguageCode = "nb", Value = "http://example.com/transmission" }] }; - createCommand.Transmissions = [transmission]; + createCommand.Dto.Transmissions = [transmission]; // Act var response = await Application.Send(createCommand); @@ -105,7 +105,7 @@ public async Task Cannot_Create_Transmission_Embeddable_Content_With_Http_Url() public async Task Can_Create_Related_Transmission_With_Null_Id() { // Arrange - var createCommand = DialogGenerator.GenerateSimpleFakeDialog(); + var createCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(); var transmissions = DialogGenerator.GenerateFakeDialogTransmissions(2); transmissions[0].RelatedTransmissionId = transmissions[1].Id; @@ -114,7 +114,7 @@ public async Task Can_Create_Related_Transmission_With_Null_Id() // on all transmissions before validating the hierarchy. transmissions[0].Id = null; - createCommand.Transmissions = transmissions; + createCommand.Dto.Transmissions = transmissions; // Act var response = await Application.Send(createCommand); diff --git a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Transmissions/Commands/UpdateTransmissionTests.cs b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Transmissions/Commands/UpdateTransmissionTests.cs index a7e57c4d9..f3eae124e 100644 --- a/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Transmissions/Commands/UpdateTransmissionTests.cs +++ b/tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Transmissions/Commands/UpdateTransmissionTests.cs @@ -18,10 +18,10 @@ public UpdateTransmissionTests(DialogApplication application) : base(application public async Task Can_Create_Simple_Transmission_In_Update() { // Arrange - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(); + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(); var existingTransmission = DialogGenerator.GenerateFakeDialogTransmissions(1).First(); - createDialogCommand.Transmissions.Add(existingTransmission); + createDialogCommand.Dto.Transmissions.Add(existingTransmission); var createCommandResponse = await Application.Send(createDialogCommand); var getDialogQuery = new GetDialogQuery { DialogId = createCommandResponse.AsT0.Value }; @@ -53,9 +53,9 @@ public async Task Can_Create_Simple_Transmission_In_Update() public async Task Can_Update_Related_Transmission_With_Null_Id() { // Arrange - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(); + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(); var existingTransmission = DialogGenerator.GenerateFakeDialogTransmissions(1).First(); - createDialogCommand.Transmissions.Add(existingTransmission); + createDialogCommand.Dto.Transmissions.Add(existingTransmission); var createCommandResponse = await Application.Send(createDialogCommand); var getDialogQuery = new GetDialogQuery { DialogId = createCommandResponse.AsT0.Value }; @@ -92,9 +92,9 @@ public async Task Can_Update_Related_Transmission_With_Null_Id() public async Task Cannot_Include_Old_Transmissions_In_UpdateCommand() { // Arrange - var createDialogCommand = DialogGenerator.GenerateSimpleFakeDialog(); + var createDialogCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(); var existingTransmission = DialogGenerator.GenerateFakeDialogTransmissions(count: 1).First(); - createDialogCommand.Transmissions.Add(existingTransmission); + createDialogCommand.Dto.Transmissions.Add(existingTransmission); var createCommandResponse = await Application.Send(createDialogCommand); var getDialogQuery = new GetDialogQuery { DialogId = createCommandResponse.AsT0.Value }; diff --git a/tests/Digdir.Domain.Dialogporten.Application.Unit.Tests/Features/V1/ServiceOwner/Dialogs/Commands/CreateDialogTests.cs b/tests/Digdir.Domain.Dialogporten.Application.Unit.Tests/Features/V1/ServiceOwner/Dialogs/Commands/CreateDialogTests.cs index 3d7b11590..d025573db 100644 --- a/tests/Digdir.Domain.Dialogporten.Application.Unit.Tests/Features/V1/ServiceOwner/Dialogs/Commands/CreateDialogTests.cs +++ b/tests/Digdir.Domain.Dialogporten.Application.Unit.Tests/Features/V1/ServiceOwner/Dialogs/Commands/CreateDialogTests.cs @@ -30,15 +30,15 @@ public async Task CreateDialogCommand_Should_Return_Forbidden_When_Scope_Is_Miss var serviceAuthorizationSub = Substitute.For(); var userSub = Substitute.For(); - var createCommand = DialogGenerator.GenerateSimpleFakeDialog(); + var createCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(); serviceAuthorizationSub .AuthorizeServiceResources(Arg.Any(), Arg.Any()) .Returns(new Forbidden()); resourceRegistrySub - .GetResourceInformation(createCommand.ServiceResource, Arg.Any()) - .Returns(new ServiceResourceInformation(createCommand.ServiceResource, "foo", "912345678", "ttd")); + .GetResourceInformation(createCommand.Dto.ServiceResource, Arg.Any()) + .Returns(new ServiceResourceInformation(createCommand.Dto.ServiceResource, "foo", "912345678", "ttd")); var commandHandler = new CreateDialogCommandHandler(userSub, dialogDbContextSub, mapper, unitOfWorkSub, domainContextSub, @@ -67,15 +67,15 @@ public async Task CreateDialogCommand_Should_Return_Forbidden_When_User_Is_Not_O var resourceRegistrySub = Substitute.For(); var serviceAuthorizationSub = Substitute.For(); var userSub = Substitute.For(); - var createCommand = DialogGenerator.GenerateSimpleFakeDialog(); + var createCommand = DialogGenerator.GenerateSimpleFakeCreateDialogCommand(); serviceAuthorizationSub .AuthorizeServiceResources(Arg.Any(), Arg.Any()) .Returns(new Forbidden()); resourceRegistrySub - .GetResourceInformation(createCommand.ServiceResource, Arg.Any()) - .Returns(new ServiceResourceInformation(createCommand.ServiceResource, "foo", "912345678", "ttd")); + .GetResourceInformation(createCommand.Dto.ServiceResource, Arg.Any()) + .Returns(new ServiceResourceInformation(createCommand.Dto.ServiceResource, "foo", "912345678", "ttd")); var commandHandler = new CreateDialogCommandHandler(userSub, dialogDbContextSub, mapper, unitOfWorkSub, domainContextSub,