From c6c19d2ad75c5755e5e7e1e42c7817db9c0e52f4 Mon Sep 17 00:00:00 2001 From: Anders Balling Petersen Date: Fri, 15 Nov 2024 10:15:04 +0100 Subject: [PATCH] refac: 0. Refactor MasterData module to clean architecture (#1344) * Refactored MasterData module to clean architecture * Create wrapper interface for MasterDataContext --------- Co-authored-by: Ebbe Knudsen --- source/B2BApi/B2BApi.csproj | 2 +- source/B2BApi/HostFactory.cs | 2 +- source/B2CWebApi/B2CWebApi.csproj | 34 +++++++-------- source/B2CWebApi/Program.cs | 2 +- source/Edi.Repository.sln | 42 +++++++++---------- source/Edi.UnitTests/Edi.UnitTests.csproj | 2 +- source/Edi.UnitTests/EdiTestBase.cs | 6 +-- .../IncomingMessages.IntegrationTests.csproj | 4 +- .../IncomingMessagesTestBase.cs | 4 +- .../Fixture/IntegrationEventsTestBase.cs | 5 +-- .../IntegrationEvents.IntegrationTests.csproj | 2 +- .../Behaviours/BehavioursTestBase.cs | 2 +- .../IntegrationTests/IntegrationTests.csproj | 2 +- source/IntegrationTests/TestBase.cs | 2 +- .../IMasterDataContext.cs | 27 ++++++++++++ .../MasterData.Application.csproj | 8 ++-- .../MasterDataClient.cs | 7 ++-- .../ActorCertificates/ActorCertificate.cs | 1 - .../IActorCertificateRepository.cs | 2 - .../Actors/IActorRepository.cs | 2 - .../IProcessDelegationRepository.cs | 3 -- .../ProcessDelegations/ProcessDelegation.cs | 1 - .../ActorCertificateEntityConfiguration.cs | 3 +- .../Actors/ActorEntityConfiguration.cs | 1 - .../Actors/ActorRepository.cs | 2 - .../DataAccess/MasterDataContext.cs | 7 ++-- .../MasterDataExtensions.cs | 9 +++- .../GridAreaOwnerEntityConfiguration.cs | 1 - .../MasterData.Infrastructure.csproj | 5 ++- .../ProcessDelegationEntityConfiguration.cs | 3 +- .../Fixture/MasterDataTestBase.cs | 4 +- .../MasterData.IntegrationTests.csproj | 2 +- .../OutgoingMessages.IntegrationTests.csproj | 26 ++++++------ .../OutgoingMessagesTestBase.cs | 5 +-- 34 files changed, 120 insertions(+), 110 deletions(-) create mode 100644 source/MasterData.Application/IMasterDataContext.cs rename source/{MasterData.Application => MasterData.Infrastructure}/Extensions/DependencyInjection/MasterDataExtensions.cs (87%) diff --git a/source/B2BApi/B2BApi.csproj b/source/B2BApi/B2BApi.csproj index 5acd4c74f1..e90d5f697c 100644 --- a/source/B2BApi/B2BApi.csproj +++ b/source/B2BApi/B2BApi.csproj @@ -60,7 +60,7 @@ limitations under the License. - + diff --git a/source/B2BApi/HostFactory.cs b/source/B2BApi/HostFactory.cs index a4389816aa..8c37e96a32 100644 --- a/source/B2BApi/HostFactory.cs +++ b/source/B2BApi/HostFactory.cs @@ -25,7 +25,7 @@ using Energinet.DataHub.EDI.DataAccess.UnitOfWork.Extensions.DependencyInjection; using Energinet.DataHub.EDI.IncomingMessages.Application.Extensions.DependencyInjection; using Energinet.DataHub.EDI.IntegrationEvents.Application.Extensions.DependencyInjection; -using Energinet.DataHub.EDI.MasterData.Application.Extensions.DependencyInjection; +using Energinet.DataHub.EDI.MasterData.Infrastructure.Extensions.DependencyInjection; using Energinet.DataHub.EDI.Outbox.Infrastructure; using Energinet.DataHub.EDI.OutgoingMessages.Application.Extensions.DependencyInjection; using Energinet.DataHub.EDI.Process.Application.Extensions.DependencyInjection; diff --git a/source/B2CWebApi/B2CWebApi.csproj b/source/B2CWebApi/B2CWebApi.csproj index a7cc846ee4..4db79b396b 100644 --- a/source/B2CWebApi/B2CWebApi.csproj +++ b/source/B2CWebApi/B2CWebApi.csproj @@ -8,33 +8,33 @@ - + - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - - - - - - - - + + + + + + + + - + - - + + diff --git a/source/B2CWebApi/Program.cs b/source/B2CWebApi/Program.cs index da00b0d93a..5fb79ee946 100644 --- a/source/B2CWebApi/Program.cs +++ b/source/B2CWebApi/Program.cs @@ -24,7 +24,7 @@ using Energinet.DataHub.EDI.B2CWebApi.Security; using Energinet.DataHub.EDI.DataAccess.UnitOfWork.Extensions.DependencyInjection; using Energinet.DataHub.EDI.IncomingMessages.Application.Extensions.DependencyInjection; -using Energinet.DataHub.EDI.MasterData.Application.Extensions.DependencyInjection; +using Energinet.DataHub.EDI.MasterData.Infrastructure.Extensions.DependencyInjection; using Energinet.DataHub.EDI.Outbox.Infrastructure; var builder = WebApplication.CreateBuilder(args); diff --git a/source/Edi.Repository.sln b/source/Edi.Repository.sln index 81b88ac8d5..dedcaae76b 100644 --- a/source/Edi.Repository.sln +++ b/source/Edi.Repository.sln @@ -122,12 +122,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{1DEA9C4F EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MasterData.IntegrationTests", "MasterData.IntegrationTests\MasterData.IntegrationTests.csproj", "{0EA98CF7-1E71-4FFE-9825-A9EA22701E6D}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MasterData.Application", "MasterData.Application\MasterData.Application.csproj", "{104BEB59-8E92-4517-8141-620073B89887}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MasterData.Domain", "MasterData.Domain\MasterData.Domain.csproj", "{CDB51D9E-3D69-4E37-A9D4-B12E04722078}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MasterData.Infrastructure", "MasterData.Infrastructure\MasterData.Infrastructure.csproj", "{17E5D9E6-C482-47C5-BABA-56ACFA13BD43}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MasterData.Interfaces", "MasterData.Interfaces\MasterData.Interfaces.csproj", "{03330B59-67CF-426E-AB61-1F87137E10F4}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Outbox", "Outbox", "{C31C36C8-7661-4782-9915-E8278CD4DFEA}" @@ -206,6 +200,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProcessManager.Core.Tests", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProcessManager.Orchestrations.Tests", "ProcessManager.Orchestrations.Tests\ProcessManager.Orchestrations.Tests.csproj", "{6E524405-2B66-4563-B043-492DB8734060}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MasterData.Infrastructure", "MasterData.Infrastructure\MasterData.Infrastructure.csproj", "{61571A46-1145-4FF9-9C91-47C33520B53A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MasterData.Application", "MasterData.Application\MasterData.Application.csproj", "{0E787394-5AD2-4920-900F-E802EDB726B6}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MasterData.Domain", "MasterData.Domain\MasterData.Domain.csproj", "{4A238A51-ED28-4039-8046-ED7B1336C614}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -328,18 +328,6 @@ Global {0EA98CF7-1E71-4FFE-9825-A9EA22701E6D}.Debug|Any CPU.Build.0 = Debug|Any CPU {0EA98CF7-1E71-4FFE-9825-A9EA22701E6D}.Release|Any CPU.ActiveCfg = Release|Any CPU {0EA98CF7-1E71-4FFE-9825-A9EA22701E6D}.Release|Any CPU.Build.0 = Release|Any CPU - {104BEB59-8E92-4517-8141-620073B89887}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {104BEB59-8E92-4517-8141-620073B89887}.Debug|Any CPU.Build.0 = Debug|Any CPU - {104BEB59-8E92-4517-8141-620073B89887}.Release|Any CPU.ActiveCfg = Release|Any CPU - {104BEB59-8E92-4517-8141-620073B89887}.Release|Any CPU.Build.0 = Release|Any CPU - {CDB51D9E-3D69-4E37-A9D4-B12E04722078}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CDB51D9E-3D69-4E37-A9D4-B12E04722078}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CDB51D9E-3D69-4E37-A9D4-B12E04722078}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CDB51D9E-3D69-4E37-A9D4-B12E04722078}.Release|Any CPU.Build.0 = Release|Any CPU - {17E5D9E6-C482-47C5-BABA-56ACFA13BD43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {17E5D9E6-C482-47C5-BABA-56ACFA13BD43}.Debug|Any CPU.Build.0 = Debug|Any CPU - {17E5D9E6-C482-47C5-BABA-56ACFA13BD43}.Release|Any CPU.ActiveCfg = Release|Any CPU - {17E5D9E6-C482-47C5-BABA-56ACFA13BD43}.Release|Any CPU.Build.0 = Release|Any CPU {03330B59-67CF-426E-AB61-1F87137E10F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {03330B59-67CF-426E-AB61-1F87137E10F4}.Debug|Any CPU.Build.0 = Debug|Any CPU {03330B59-67CF-426E-AB61-1F87137E10F4}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -452,6 +440,18 @@ Global {6E524405-2B66-4563-B043-492DB8734060}.Debug|Any CPU.Build.0 = Debug|Any CPU {6E524405-2B66-4563-B043-492DB8734060}.Release|Any CPU.ActiveCfg = Release|Any CPU {6E524405-2B66-4563-B043-492DB8734060}.Release|Any CPU.Build.0 = Release|Any CPU + {61571A46-1145-4FF9-9C91-47C33520B53A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {61571A46-1145-4FF9-9C91-47C33520B53A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {61571A46-1145-4FF9-9C91-47C33520B53A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {61571A46-1145-4FF9-9C91-47C33520B53A}.Release|Any CPU.Build.0 = Release|Any CPU + {0E787394-5AD2-4920-900F-E802EDB726B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0E787394-5AD2-4920-900F-E802EDB726B6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0E787394-5AD2-4920-900F-E802EDB726B6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0E787394-5AD2-4920-900F-E802EDB726B6}.Release|Any CPU.Build.0 = Release|Any CPU + {4A238A51-ED28-4039-8046-ED7B1336C614}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4A238A51-ED28-4039-8046-ED7B1336C614}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4A238A51-ED28-4039-8046-ED7B1336C614}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4A238A51-ED28-4039-8046-ED7B1336C614}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -509,9 +509,6 @@ Global {ED4BC8EC-5C20-4250-B2DD-9FEAEF726D8E} = {5E56C03C-09BD-4F47-917E-4D5B03E4EE0E} {1DEA9C4F-02C5-4D91-A6B4-F87421FDE638} = {ED4BC8EC-5C20-4250-B2DD-9FEAEF726D8E} {0EA98CF7-1E71-4FFE-9825-A9EA22701E6D} = {1DEA9C4F-02C5-4D91-A6B4-F87421FDE638} - {104BEB59-8E92-4517-8141-620073B89887} = {ED4BC8EC-5C20-4250-B2DD-9FEAEF726D8E} - {CDB51D9E-3D69-4E37-A9D4-B12E04722078} = {ED4BC8EC-5C20-4250-B2DD-9FEAEF726D8E} - {17E5D9E6-C482-47C5-BABA-56ACFA13BD43} = {ED4BC8EC-5C20-4250-B2DD-9FEAEF726D8E} {03330B59-67CF-426E-AB61-1F87137E10F4} = {ED4BC8EC-5C20-4250-B2DD-9FEAEF726D8E} {C31C36C8-7661-4782-9915-E8278CD4DFEA} = {5E56C03C-09BD-4F47-917E-4D5B03E4EE0E} {7F858416-5101-4CAE-A7CE-7C7DE65C7465} = {C31C36C8-7661-4782-9915-E8278CD4DFEA} @@ -548,6 +545,9 @@ Global {866DFC4D-9E52-4DC9-B745-E47A2B12822F} = {A1D87C36-B279-40DB-8C75-B74453458A02} {8E6CCEC1-0CD6-464B-A101-24E166715BD7} = {9CB2AEDE-FAB7-405B-913F-3E7E673F962D} {6E524405-2B66-4563-B043-492DB8734060} = {BF4FFF69-2FAA-4C40-A781-ABC5EABEA258} + {61571A46-1145-4FF9-9C91-47C33520B53A} = {ED4BC8EC-5C20-4250-B2DD-9FEAEF726D8E} + {0E787394-5AD2-4920-900F-E802EDB726B6} = {ED4BC8EC-5C20-4250-B2DD-9FEAEF726D8E} + {4A238A51-ED28-4039-8046-ED7B1336C614} = {ED4BC8EC-5C20-4250-B2DD-9FEAEF726D8E} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {8C390B97-896A-4AAD-8609-3C20E80966D2} diff --git a/source/Edi.UnitTests/Edi.UnitTests.csproj b/source/Edi.UnitTests/Edi.UnitTests.csproj index 78bd5db121..5d84e9e907 100644 --- a/source/Edi.UnitTests/Edi.UnitTests.csproj +++ b/source/Edi.UnitTests/Edi.UnitTests.csproj @@ -37,6 +37,6 @@ - + diff --git a/source/Edi.UnitTests/EdiTestBase.cs b/source/Edi.UnitTests/EdiTestBase.cs index 60f231ca9c..27d1e55353 100644 --- a/source/Edi.UnitTests/EdiTestBase.cs +++ b/source/Edi.UnitTests/EdiTestBase.cs @@ -13,20 +13,16 @@ // limitations under the License. using BuildingBlocks.Application.Extensions.DependencyInjection; -using Energinet.DataHub.BuildingBlocks.Tests; using Energinet.DataHub.BuildingBlocks.Tests.Logging; using Energinet.DataHub.Core.App.Common.Extensions.DependencyInjection; using Energinet.DataHub.Core.Messaging.Communication.Extensions.Options; using Energinet.DataHub.EDI.DataAccess.Extensions.DependencyInjection; using Energinet.DataHub.EDI.DataAccess.UnitOfWork.Extensions.DependencyInjection; -using Energinet.DataHub.EDI.MasterData.Application.Extensions.DependencyInjection; +using Energinet.DataHub.EDI.MasterData.Infrastructure.Extensions.DependencyInjection; using Energinet.DataHub.Wholesale.Edi.Extensions.DependencyInjection; -using Energinet.DataHub.Wholesale.Edi.Validation; using Energinet.DataHub.Wholesale.Edi.Validation.Helpers; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; -using Microsoft.Extensions.Logging; using Xunit.Abstractions; namespace Energinet.DataHub.Wholesale.Edi.UnitTests; diff --git a/source/IncomingMessages.IntegrationTests/IncomingMessages.IntegrationTests.csproj b/source/IncomingMessages.IntegrationTests/IncomingMessages.IntegrationTests.csproj index dbbede664b..3ebf62fb72 100644 --- a/source/IncomingMessages.IntegrationTests/IncomingMessages.IntegrationTests.csproj +++ b/source/IncomingMessages.IntegrationTests/IncomingMessages.IntegrationTests.csproj @@ -1,4 +1,4 @@ -