Skip to content

Commit

Permalink
Consumer API: Use StatusChanged instead of RelationshipCreated Domain…
Browse files Browse the repository at this point in the history
…Event when establishing a new Relationship (#615)

* refactor: remove relationship created event

* refactor: remove tests

* refactor: remove using directives

* refactor: remove relationship created form Quotas module

* refactor: remove external event type, RelationshipCreated

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
NikolaDmitrasinovic and mergify[bot] authored Apr 24, 2024
1 parent 08e4d8c commit 42b6d89
Show file tree
Hide file tree
Showing 12 changed files with 8 additions and 207 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Backbone.Modules.Quotas.Application.DomainEvents.Incoming.IdentityCreated;
using Backbone.Modules.Quotas.Application.DomainEvents.Incoming.MessageCreated;
using Backbone.Modules.Quotas.Application.DomainEvents.Incoming.QuotaCreatedForTier;
using Backbone.Modules.Quotas.Application.DomainEvents.Incoming.RelationshipCreated;
using Backbone.Modules.Quotas.Application.DomainEvents.Incoming.RelationshipStatusChanged;
using Backbone.Modules.Quotas.Application.DomainEvents.Incoming.RelationshipTemplateCreated;
using Backbone.Modules.Quotas.Application.DomainEvents.Incoming.TierCreated;
Expand All @@ -14,7 +13,6 @@
using Backbone.Modules.Quotas.Domain.DomainEvents.Incoming.FileUploaded;
using Backbone.Modules.Quotas.Domain.DomainEvents.Incoming.IdentityCreated;
using Backbone.Modules.Quotas.Domain.DomainEvents.Incoming.MessageCreated;
using Backbone.Modules.Quotas.Domain.DomainEvents.Incoming.RelationshipCreated;
using Backbone.Modules.Quotas.Domain.DomainEvents.Incoming.RelationshipStatusChanged;
using Backbone.Modules.Quotas.Domain.DomainEvents.Incoming.RelationshipTemplateCreated;
using Backbone.Modules.Quotas.Domain.DomainEvents.Incoming.TierCreated;
Expand All @@ -41,7 +39,6 @@ private static void SubscribeToSynchronizationEvents(IEventBus eventBus)
eventBus.Subscribe<MessageCreatedDomainEvent, MessageCreatedDomainEventHandler>();
eventBus.Subscribe<TierQuotaDefinitionDeletedDomainEvent, TierQuotaDefinitionDeletedDomainEventHandler>();
eventBus.Subscribe<FileUploadedDomainEvent, FileUploadedDomainEventHandler>();
eventBus.Subscribe<RelationshipCreatedDomainEvent, RelationshipCreatedDomainEventHandler>();
eventBus.Subscribe<RelationshipStatusChangedDomainEvent, RelationshipStatusChangedDomainEventHandler>();
eventBus.Subscribe<RelationshipTemplateCreatedDomainEvent, RelationshipTemplateCreatedDomainEventHandler>();
eventBus.Subscribe<TokenCreatedDomainEvent, TokenCreatedDomainEventHandler>();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
using Backbone.BuildingBlocks.Application.Abstractions.Infrastructure.EventBus;
using Backbone.BuildingBlocks.Application.Abstractions.Infrastructure.UserContext;
using Backbone.DevelopmentKit.Identity.ValueObjects;
using Backbone.Modules.Relationships.Application.DomainEvents.Outgoing;
using Backbone.Modules.Relationships.Application.Infrastructure.Persistence.Repository;
using Backbone.Modules.Relationships.Domain.Aggregates.Relationships;
using Backbone.Modules.Relationships.Domain.Aggregates.RelationshipTemplates;
using Backbone.Modules.Relationships.Domain.DomainEvents.Outgoing;
using MediatR;

namespace Backbone.Modules.Relationships.Application.Relationships.Commands.CreateRelationship;
Expand Down Expand Up @@ -78,6 +78,6 @@ private async Task CreateAndSaveRelationship()

private void PublishDomainEvent()
{
_eventBus.Publish(new RelationshipCreatedDomainEvent(_relationship));
_eventBus.Publish(new RelationshipStatusChangedDomainEvent(_relationship));
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
using Backbone.BuildingBlocks.Application.Abstractions.Infrastructure.EventBus;
using Backbone.BuildingBlocks.Application.Abstractions.Infrastructure.UserContext;
using Backbone.DevelopmentKit.Identity.ValueObjects;
using Backbone.Modules.Relationships.Application.DomainEvents.Outgoing;
using Backbone.Modules.Relationships.Application.Infrastructure.Persistence.Repository;
using Backbone.Modules.Relationships.Application.Relationships.Commands.CreateRelationship;
using Backbone.Modules.Relationships.Domain.Aggregates.Relationships;
using Backbone.Modules.Relationships.Domain.Aggregates.RelationshipTemplates;
using Backbone.Modules.Relationships.Domain.DomainEvents.Outgoing;
using Backbone.Tooling;
using Backbone.UnitTestTools.Data;
using Backbone.UnitTestTools.Extensions;
Expand Down Expand Up @@ -120,7 +120,7 @@ public void Throws_when_no_template_with_given_id_exists()
}

[Fact]
public async Task Publishes_RelationshipCreatedDomainEvent()
public async Task Publishes_RelationshipStatusChangedDomainEvent()
{
// Arrange
SystemTime.Set("2020-01-01");
Expand Down Expand Up @@ -153,7 +153,7 @@ await handler.Handle(new CreateRelationshipCommand
}, CancellationToken.None);

// Assert
A.CallTo(() => mockEventBus.Publish(A<RelationshipCreatedDomainEvent>.That.Matches(e => e.From == activeIdentity, relationshipTemplate.CreatedBy))).MustHaveHappenedOnceExactly();
A.CallTo(() => mockEventBus.Publish(A<RelationshipStatusChangedDomainEvent>.That.Matches(e => e.Initiator == activeIdentity, relationshipTemplate.CreatedBy))).MustHaveHappenedOnceExactly();
}

private static Handler CreateHandler(IRelationshipTemplatesRepository relationshipTemplatesRepository)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
using Backbone.Modules.Synchronization.Application.DomainEvents.Incoming.IdentityDeletionProcessStarted;
using Backbone.Modules.Synchronization.Application.DomainEvents.Incoming.IdentityDeletionProcessStatusChanged;
using Backbone.Modules.Synchronization.Application.DomainEvents.Incoming.MessageCreated;
using Backbone.Modules.Synchronization.Application.DomainEvents.Incoming.RelationshipCreated;
using Backbone.Modules.Synchronization.Application.DomainEvents.Incoming.RelationshipStatusChanged;
using Backbone.Modules.Synchronization.Domain.DomainEvents.Incoming.IdentityDeletionProcessStarted;
using Backbone.Modules.Synchronization.Domain.DomainEvents.Incoming.IdentityDeletionProcessStatusChanged;
using Backbone.Modules.Synchronization.Domain.DomainEvents.Incoming.MessageCreated;
using Backbone.Modules.Synchronization.Domain.DomainEvents.Incoming.RelationshipCreated;
using Backbone.Modules.Synchronization.Domain.DomainEvents.Incoming.RelationshipStatusChanged;

namespace Backbone.Modules.Synchronization.Application.Extensions;
Expand All @@ -32,7 +30,6 @@ private static void SubscribeToMessagesEvents(IEventBus eventBus)

private static void SubscribeToRelationshipsEvents(IEventBus eventBus)
{
eventBus.Subscribe<RelationshipCreatedDomainEvent, RelationshipCreatedDomainEventHandler>();
eventBus.Subscribe<RelationshipStatusChangedDomainEvent, RelationshipStatusChangedDomainEventHandler>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public void CreateMappings(Profile configuration)
{
ExternalEventType.MessageDelivered => "MessageDelivered",
ExternalEventType.MessageReceived => "MessageReceived",
ExternalEventType.RelationshipCreated => "RelationshipCreated",
ExternalEventType.RelationshipStatusChanged => "RelationshipStatusChanged",
_ => throw new ArgumentOutOfRangeException(nameof(externalEventType), externalEventType, null)
});
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ public enum ExternalEventType
{
MessageReceived = 0,
MessageDelivered = 1,
RelationshipCreated = 2,
RelationshipStatusChanged = 3,
IdentityDeletionProcessStarted = 4,
IdentityDeletionProcessStatusChanged = 5
RelationshipStatusChanged = 2,
IdentityDeletionProcessStarted = 3,
IdentityDeletionProcessStatusChanged = 4
}

This file was deleted.

0 comments on commit 42b6d89

Please sign in to comment.