From 79fd86f084fbf9393bb9ed4f1047262e7e5af3fe Mon Sep 17 00:00:00 2001 From: Phil Schneider Date: Tue, 10 Oct 2023 22:51:13 +0200 Subject: [PATCH] fix(autoSetup): notification will be created directly after subscribing (#273) * fix(autoSetup): notification will be created directly after subscribing instead of creating the notification for an app subscription after triggering the provider, the notification will directly be created when subscribing to an offer Refs: CPLP-3288 --------- Reviewed-by: Norbert Truchsess --- .../OfferProviderBusinessLogic.cs | 69 +-------------- .../BusinessLogic/AppsBusinessLogic.cs | 2 +- .../Service/IOfferSubscriptionService.cs | 3 +- .../Service/OfferSubscriptionService.cs | 70 +++++++++++++-- .../BusinessLogic/ServiceBusinessLogic.cs | 2 +- .../Models/CompanyInformationData.cs | 3 +- .../Models/TriggerProviderInformation.cs | 1 - .../Repositories/CompanyRepository.cs | 13 +-- .../Repositories/ICompanyRepository.cs | 2 +- .../OfferSubscriptionsRepository.cs | 4 +- .../OfferProviderBusinessLogicTests.cs | 63 +++---------- .../BusinessLogic/AppBusinessLogicTests.cs | 3 +- .../Service/OfferSubscriptionServiceTests.cs | 88 +++++++++++-------- .../ServiceBusinessLogicTests.cs | 3 +- .../CompanyRepositoryTests.cs | 5 +- 15 files changed, 152 insertions(+), 179 deletions(-) diff --git a/src/externalsystems/OfferProvider.Library/BusinessLogic/OfferProviderBusinessLogic.cs b/src/externalsystems/OfferProvider.Library/BusinessLogic/OfferProviderBusinessLogic.cs index 8f8a365362..87d9f3ed28 100644 --- a/src/externalsystems/OfferProvider.Library/BusinessLogic/OfferProviderBusinessLogic.cs +++ b/src/externalsystems/OfferProvider.Library/BusinessLogic/OfferProviderBusinessLogic.cs @@ -18,15 +18,12 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -using Microsoft.Extensions.Options; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; -using Org.Eclipse.TractusX.Portal.Backend.OfferProvider.Library.DependencyInjection; using Org.Eclipse.TractusX.Portal.Backend.OfferProvider.Library.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library; -using System.Text.Json; namespace Org.Eclipse.TractusX.Portal.Backend.OfferProvider.Library.BusinessLogic; @@ -35,7 +32,6 @@ public class OfferProviderBusinessLogic : IOfferProviderBusinessLogic private readonly IPortalRepositories _portalRepositories; private readonly IOfferProviderService _offerProviderService; private readonly IProvisioningManager _provisioningManager; - private readonly OfferProviderSettings _settings; /// /// Constructor. @@ -47,13 +43,11 @@ public class OfferProviderBusinessLogic : IOfferProviderBusinessLogic public OfferProviderBusinessLogic( IPortalRepositories portalRepositories, IOfferProviderService offerProviderService, - IProvisioningManager provisioningManager, - IOptions options) + IProvisioningManager provisioningManager) { _portalRepositories = portalRepositories; _offerProviderService = offerProviderService; _provisioningManager = provisioningManager; - _settings = options.Value; } /// @@ -77,7 +71,7 @@ public OfferProviderBusinessLogic( new OfferThirdPartyAutoSetupCustomerData( data.CompanyInformationData.OrganizationName, data.CompanyInformationData.Country, - data.UserEmail), + data.CompanyInformationData.CompanyUserEmail), new OfferThirdPartyAutoSetupPropertyData( data.CompanyInformationData.BusinessPartnerNumber, offerSubscriptionId, @@ -88,15 +82,6 @@ await _offerProviderService .ConfigureAwait(false); } - var content = JsonSerializer.Serialize(new - { - AppName = data.OfferName, - data.OfferId, - RequestorCompanyName = data.CompanyInformationData.OrganizationName, - data.UserEmail, - AutoSetupExecuted = triggerProvider - }); - await SendNotifications(data.OfferId, data.OfferTypeId, data.SalesManagerId, data.CompanyUserId, content).ConfigureAwait(false); return ( new[] { data.IsSingleInstance ? @@ -107,56 +92,6 @@ await _offerProviderService null); } - private async Task SendNotifications( - Guid offerId, - OfferTypeId offerTypeId, - Guid? salesManagerId, - Guid companyUserId, - string notificationContent) - { - var serviceManagerRoles = _settings.ServiceManagerRoles; - var notificationRepository = _portalRepositories.GetInstance(); - - var notificationTypeId = offerTypeId == OfferTypeId.SERVICE ? NotificationTypeId.SERVICE_REQUEST : NotificationTypeId.APP_SUBSCRIPTION_REQUEST; - if (salesManagerId.HasValue) - { - notificationRepository.CreateNotification(salesManagerId.Value, notificationTypeId, false, - notification => - { - notification.CreatorUserId = companyUserId; - notification.Content = notificationContent; - }); - } - - var userRolesRepository = _portalRepositories.GetInstance(); - var roleData = await userRolesRepository - .GetUserRoleIdsUntrackedAsync(serviceManagerRoles) - .ToListAsync() - .ConfigureAwait(false); - if (roleData.Count < serviceManagerRoles.Sum(clientRoles => clientRoles.UserRoleNames.Count())) - { - throw new ConfigurationException($"invalid configuration, at least one of the configured roles does not exist in the database: {string.Join(", ", serviceManagerRoles.Select(clientRoles => $"client: {clientRoles.ClientId}, roles: [{string.Join(", ", clientRoles.UserRoleNames)}]"))}"); - } - - await foreach (var receiver in _portalRepositories.GetInstance().GetServiceProviderCompanyUserWithRoleIdAsync(offerId, roleData)) - { - if (salesManagerId.HasValue && receiver == salesManagerId.Value) - { - continue; - } - - notificationRepository.CreateNotification( - receiver, - notificationTypeId, - false, - notification => - { - notification.CreatorUserId = companyUserId; - notification.Content = notificationContent; - }); - } - } - /// public async Task<(IEnumerable? nextStepTypeIds, ProcessStepStatusId stepStatusId, bool modified, string? processMessage)> TriggerProviderCallback(Guid offerSubscriptionId, CancellationToken cancellationToken) { diff --git a/src/marketplace/Apps.Service/BusinessLogic/AppsBusinessLogic.cs b/src/marketplace/Apps.Service/BusinessLogic/AppsBusinessLogic.cs index 3f18eb5213..413bc7f8f5 100644 --- a/src/marketplace/Apps.Service/BusinessLogic/AppsBusinessLogic.cs +++ b/src/marketplace/Apps.Service/BusinessLogic/AppsBusinessLogic.cs @@ -177,7 +177,7 @@ public async Task AddFavouriteAppForUserAsync(Guid appId) /// public Task AddOwnCompanyAppSubscriptionAsync(Guid appId, IEnumerable offerAgreementConsentData) => - _offerSubscriptionService.AddOfferSubscriptionAsync(appId, offerAgreementConsentData, OfferTypeId.APP, _settings.BasePortalAddress, _settings.SubscriptionManagerRoles); + _offerSubscriptionService.AddOfferSubscriptionAsync(appId, offerAgreementConsentData, OfferTypeId.APP, _settings.BasePortalAddress, _settings.SubscriptionManagerRoles, _settings.ServiceManagerRoles); /// public Task TriggerActivateOfferSubscription(Guid subscriptionId) => diff --git a/src/marketplace/Offers.Library/Service/IOfferSubscriptionService.cs b/src/marketplace/Offers.Library/Service/IOfferSubscriptionService.cs index 9261f7214b..a9e6158f77 100644 --- a/src/marketplace/Offers.Library/Service/IOfferSubscriptionService.cs +++ b/src/marketplace/Offers.Library/Service/IOfferSubscriptionService.cs @@ -21,11 +21,10 @@ using Org.Eclipse.TractusX.Portal.Backend.Framework.Models.Configuration; using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; -using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; namespace Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Service; public interface IOfferSubscriptionService { - Task AddOfferSubscriptionAsync(Guid offerId, IEnumerable offerAgreementConsentData, OfferTypeId offerTypeId, string basePortalAddress, IEnumerable notificationRecipients); + Task AddOfferSubscriptionAsync(Guid offerId, IEnumerable offerAgreementConsentData, OfferTypeId offerTypeId, string basePortalAddress, IEnumerable notificationRecipients, IEnumerable serviceManagerRoles); } diff --git a/src/marketplace/Offers.Library/Service/OfferSubscriptionService.cs b/src/marketplace/Offers.Library/Service/OfferSubscriptionService.cs index 402f35b540..47a02c7f49 100644 --- a/src/marketplace/Offers.Library/Service/OfferSubscriptionService.cs +++ b/src/marketplace/Offers.Library/Service/OfferSubscriptionService.cs @@ -29,6 +29,7 @@ using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using System.Collections.Immutable; +using System.Text.Json; namespace Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Service; @@ -43,7 +44,7 @@ public class OfferSubscriptionService : IOfferSubscriptionService /// /// Factory to access the repositories /// Access to the identity of the user - /// Mail service. + /// Mail service. public OfferSubscriptionService( IPortalRepositories portalRepositories, IIdentityService identityService, @@ -55,10 +56,10 @@ public OfferSubscriptionService( } /// - public async Task AddOfferSubscriptionAsync(Guid offerId, IEnumerable offerAgreementConsentData, OfferTypeId offerTypeId, string basePortalAddress, IEnumerable notificationRecipients) + public async Task AddOfferSubscriptionAsync(Guid offerId, IEnumerable offerAgreementConsentData, OfferTypeId offerTypeId, string basePortalAddress, IEnumerable notificationRecipients, IEnumerable serviceManagerRoles) { var identity = _identityService.IdentityData; - var companyInformation = await ValidateCompanyInformationAsync(identity.CompanyId).ConfigureAwait(false); + var companyInformation = await ValidateCompanyInformationAsync(identity.CompanyId, identity.UserId).ConfigureAwait(false); var offerProviderDetails = await ValidateOfferProviderDetailDataAsync(offerId, offerTypeId).ConfigureAwait(false); if (offerProviderDetails.ProviderCompanyId == null) @@ -77,6 +78,15 @@ public async Task AddOfferSubscriptionAsync(Guid offerId, IEnumerable serviceManagerRoles) + { + var notificationRepository = _portalRepositories.GetInstance(); + + var notificationTypeId = offerTypeId == OfferTypeId.SERVICE ? NotificationTypeId.SERVICE_REQUEST : NotificationTypeId.APP_SUBSCRIPTION_REQUEST; + if (salesManagerId.HasValue) + { + notificationRepository.CreateNotification(salesManagerId.Value, notificationTypeId, false, + notification => + { + notification.CreatorUserId = companyUserId; + notification.Content = notificationContent; + }); + } + + var userRolesRepository = _portalRepositories.GetInstance(); + var roleData = await userRolesRepository + .GetUserRoleIdsUntrackedAsync(serviceManagerRoles) + .ToListAsync() + .ConfigureAwait(false); + if (roleData.Count < serviceManagerRoles.Sum(clientRoles => clientRoles.UserRoleNames.Count())) + { + throw new ConfigurationException($"invalid configuration, at least one of the configured roles does not exist in the database: {string.Join(", ", serviceManagerRoles.Select(clientRoles => $"client: {clientRoles.ClientId}, roles: [{string.Join(", ", clientRoles.UserRoleNames)}]"))}"); + } + + await foreach (var receiver in _portalRepositories.GetInstance().GetServiceProviderCompanyUserWithRoleIdAsync(offerId, roleData)) + { + if (salesManagerId.HasValue && receiver == salesManagerId.Value) + { + continue; + } + + notificationRepository.CreateNotification( + receiver, + notificationTypeId, + false, + notification => + { + notification.CreatorUserId = companyUserId; + notification.Content = notificationContent; + }); + } + } + private async Task ValidateOfferProviderDetailDataAsync(Guid offerId, OfferTypeId offerTypeId) { var offerProviderDetails = await _portalRepositories.GetInstance() @@ -133,10 +193,10 @@ private async Task ValidateConsent(IEnumerable offerA } } - private async Task ValidateCompanyInformationAsync(Guid companyId) + private async Task ValidateCompanyInformationAsync(Guid companyId, Guid companyUserId) { var companyInformation = await _portalRepositories.GetInstance() - .GetOwnCompanyInformationAsync(companyId).ConfigureAwait(false); + .GetOwnCompanyInformationAsync(companyId, companyUserId).ConfigureAwait(false); if (companyInformation == null) { throw new ControllerArgumentException($"Company {companyId} does not exist", nameof(companyId)); diff --git a/src/marketplace/Services.Service/BusinessLogic/ServiceBusinessLogic.cs b/src/marketplace/Services.Service/BusinessLogic/ServiceBusinessLogic.cs index f1fe6618a4..32b79a0cef 100644 --- a/src/marketplace/Services.Service/BusinessLogic/ServiceBusinessLogic.cs +++ b/src/marketplace/Services.Service/BusinessLogic/ServiceBusinessLogic.cs @@ -79,7 +79,7 @@ public ServiceBusinessLogic( /// public Task AddServiceSubscription(Guid serviceId, IEnumerable offerAgreementConsentData) => - _offerSubscriptionService.AddOfferSubscriptionAsync(serviceId, offerAgreementConsentData, OfferTypeId.SERVICE, _settings.BasePortalAddress, _settings.SubscriptionManagerRoles); + _offerSubscriptionService.AddOfferSubscriptionAsync(serviceId, offerAgreementConsentData, OfferTypeId.SERVICE, _settings.BasePortalAddress, _settings.SubscriptionManagerRoles, _settings.ServiceManagerRoles); /// public async Task GetServiceDetailsAsync(Guid serviceId, string lang) diff --git a/src/portalbackend/PortalBackend.DBAccess/Models/CompanyInformationData.cs b/src/portalbackend/PortalBackend.DBAccess/Models/CompanyInformationData.cs index 32dbca0a4a..3fcd394a13 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Models/CompanyInformationData.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Models/CompanyInformationData.cs @@ -24,4 +24,5 @@ public record CompanyInformationData( Guid CompanyId, string OrganizationName, string? Country, - string? BusinessPartnerNumber); + string? BusinessPartnerNumber, + string? CompanyUserEmail); diff --git a/src/portalbackend/PortalBackend.DBAccess/Models/TriggerProviderInformation.cs b/src/portalbackend/PortalBackend.DBAccess/Models/TriggerProviderInformation.cs index 1d46e0248c..96b1e35bc7 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Models/TriggerProviderInformation.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Models/TriggerProviderInformation.cs @@ -27,7 +27,6 @@ public record TriggerProviderInformation( string? OfferName, string? AutoSetupUrl, CompanyInformationData CompanyInformationData, - string? UserEmail, OfferTypeId OfferTypeId, Guid? SalesManagerId, Guid CompanyUserId, diff --git a/src/portalbackend/PortalBackend.DBAccess/Repositories/CompanyRepository.cs b/src/portalbackend/PortalBackend.DBAccess/Repositories/CompanyRepository.cs index 76da595d14..32a02c26c6 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Repositories/CompanyRepository.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Repositories/CompanyRepository.cs @@ -281,15 +281,16 @@ public IAsyncEnumerable GetCompanyRoleAndConsentAgreemen true )).SingleOrDefaultAsync(); - public Task GetOwnCompanyInformationAsync(Guid companyId) => + public Task GetOwnCompanyInformationAsync(Guid companyId, Guid companyUserId) => _context.Companies .AsNoTracking() .Where(c => c.Id == companyId) - .Select(user => new CompanyInformationData( - user.Id, - user.Name, - user.Address!.CountryAlpha2Code, - user.BusinessPartnerNumber + .Select(company => new CompanyInformationData( + company.Id, + company.Name, + company.Address!.CountryAlpha2Code, + company.BusinessPartnerNumber, + company.Identities.Where(x => x.Id == companyUserId && x.IdentityTypeId == IdentityTypeId.COMPANY_USER).Select(x => x.CompanyUser!.Email).SingleOrDefault() )) .SingleOrDefaultAsync(); diff --git a/src/portalbackend/PortalBackend.DBAccess/Repositories/ICompanyRepository.cs b/src/portalbackend/PortalBackend.DBAccess/Repositories/ICompanyRepository.cs index 53609f9668..5b9f9a6739 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Repositories/ICompanyRepository.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Repositories/ICompanyRepository.cs @@ -157,7 +157,7 @@ public interface ICompanyRepository /// Returns the CompanyStatus Data Task<(bool IsActive, bool IsValid)> GetCompanyStatusDataAsync(Guid companyId); - Task GetOwnCompanyInformationAsync(Guid companyId); + Task GetOwnCompanyInformationAsync(Guid companyId, Guid companyUserId); IAsyncEnumerable GetOwnCompanyRolesAsync(Guid companyId); /// diff --git a/src/portalbackend/PortalBackend.DBAccess/Repositories/OfferSubscriptionsRepository.cs b/src/portalbackend/PortalBackend.DBAccess/Repositories/OfferSubscriptionsRepository.cs index d8701023b4..bdc16659b8 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Repositories/OfferSubscriptionsRepository.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Repositories/OfferSubscriptionsRepository.cs @@ -362,9 +362,9 @@ public Task GetOfferSubscriptionDataForProcessIdAsync(Guid processId) => x.RequesterCompany!.Id, x.RequesterCompany.Name, x.RequesterCompany.Address!.CountryAlpha2Code, - x.RequesterCompany.BusinessPartnerNumber + x.RequesterCompany.BusinessPartnerNumber, + x.Email ), - x.Email, x.OfferTypeId, x.SalesManagerId, x.CompanyUserId, diff --git a/tests/externalsystems/OfferProvider.Library/BusinessLogic/OfferProviderBusinessLogicTests.cs b/tests/externalsystems/OfferProvider.Library/BusinessLogic/OfferProviderBusinessLogicTests.cs index db8cae93ef..54226de3ee 100644 --- a/tests/externalsystems/OfferProvider.Library/BusinessLogic/OfferProviderBusinessLogicTests.cs +++ b/tests/externalsystems/OfferProvider.Library/BusinessLogic/OfferProviderBusinessLogicTests.cs @@ -44,54 +44,38 @@ public class OfferProviderBusinessLogicTests private readonly Guid _salesManagerId = Guid.NewGuid(); private readonly Guid _receiverId = Guid.NewGuid(); - private readonly IFixture _fixture; - private readonly IPortalRepositories _portalRepositories; - private readonly INotificationRepository _notificationRepository; private readonly IOfferSubscriptionsRepository _offerSubscriptionRepository; private readonly IUserRolesRepository _userRolesRepository; private readonly IUserRepository _userRepository; private readonly IOfferProviderService _offerProviderService; private readonly IProvisioningManager _provisioningManager; - private readonly OfferProviderSettings _settings; private readonly OfferProviderBusinessLogic _sut; public OfferProviderBusinessLogicTests() { - _fixture = new Fixture().Customize(new AutoFakeItEasyCustomization { ConfigureMembers = true }); - _fixture.Behaviors.OfType().ToList() - .ForEach(b => _fixture.Behaviors.Remove(b)); - _fixture.Behaviors.Add(new OmitOnRecursionBehavior()); - _portalRepositories = A.Fake(); - _notificationRepository = A.Fake(); + var fixture = new Fixture().Customize(new AutoFakeItEasyCustomization { ConfigureMembers = true }); + fixture.Behaviors.OfType().ToList() + .ForEach(b => fixture.Behaviors.Remove(b)); + fixture.Behaviors.Add(new OmitOnRecursionBehavior()); + var portalRepositories = A.Fake(); _offerSubscriptionRepository = A.Fake(); _userRolesRepository = A.Fake(); _userRepository = A.Fake(); - A.CallTo(() => _portalRepositories.GetInstance()) + A.CallTo(() => portalRepositories.GetInstance()) .Returns(_offerSubscriptionRepository); - A.CallTo(() => _portalRepositories.GetInstance()) - .Returns(_notificationRepository); - A.CallTo(() => _portalRepositories.GetInstance()) + A.CallTo(() => portalRepositories.GetInstance()) .Returns(_userRolesRepository); - A.CallTo(() => _portalRepositories.GetInstance()) + A.CallTo(() => portalRepositories.GetInstance()) .Returns(_userRepository); _offerProviderService = A.Fake(); _provisioningManager = A.Fake(); - _settings = new OfferProviderSettings - { - Password = "test", - ClientId = "123", - ClientSecret = "test", - ServiceManagerRoles = Enumerable.Repeat(new UserRoleConfig("Portal", new[] { "Manager" }), 1) - }; - _sut = new OfferProviderBusinessLogic( - _portalRepositories, + portalRepositories, _offerProviderService, - _provisioningManager, - Options.Create(_settings)); + _provisioningManager); } #region TriggerProvider @@ -130,16 +114,6 @@ public async Task TriggerProvider_ValidMultiInstanceApp_ReturnsExpected(OfferTyp _offerProviderService.TriggerOfferProvider(A._, A._, A._)) .MustHaveHappenedOnceExactly(); - A.CallTo(() => _notificationRepository.CreateNotification(_salesManagerId, - offerTypeId == OfferTypeId.APP - ? NotificationTypeId.APP_SUBSCRIPTION_REQUEST - : NotificationTypeId.SERVICE_REQUEST, false, A>._)) - .MustHaveHappenedOnceExactly(); - A.CallTo(() => _notificationRepository.CreateNotification(_receiverId, - offerTypeId == OfferTypeId.APP - ? NotificationTypeId.APP_SUBSCRIPTION_REQUEST - : NotificationTypeId.SERVICE_REQUEST, false, A>._)) - .MustHaveHappenedOnceExactly(); } [Theory] @@ -161,16 +135,6 @@ public async Task TriggerProvider_ValidSingleInstanceApp_ReturnsExpected(OfferTy _offerProviderService.TriggerOfferProvider(A._, A._, A._)) .MustNotHaveHappened(); - A.CallTo(() => _notificationRepository.CreateNotification(_salesManagerId, - offerTypeId == OfferTypeId.APP - ? NotificationTypeId.APP_SUBSCRIPTION_REQUEST - : NotificationTypeId.SERVICE_REQUEST, false, A>._)) - .MustHaveHappenedOnceExactly(); - A.CallTo(() => _notificationRepository.CreateNotification(_receiverId, - offerTypeId == OfferTypeId.APP - ? NotificationTypeId.APP_SUBSCRIPTION_REQUEST - : NotificationTypeId.SERVICE_REQUEST, false, A>._)) - .MustHaveHappenedOnceExactly(); } #endregion @@ -319,8 +283,7 @@ private void SetupTriggerProvider(OfferTypeId offerTypeId = OfferTypeId.APP) _offerId, "Test App", "https://www.test.com", - new CompanyInformationData(Guid.NewGuid(), "Stark", "DE", "BPNL0000123TEST"), - "test@email.com", + new CompanyInformationData(Guid.NewGuid(), "Stark", "DE", "BPNL0000123TEST", "test@email.com"), offerTypeId, _salesManagerId, _companyUserId, @@ -332,8 +295,8 @@ private void SetupTriggerProvider(OfferTypeId offerTypeId = OfferTypeId.APP) _offerId, "Single Test App", "https://www.test.com", - new CompanyInformationData(Guid.NewGuid(), "Stark", "DE", "BPNL0000123TEST"), - "test@email.com", + new CompanyInformationData(Guid.NewGuid(), "Stark", "DE", "BPNL0000123TEST", + "test@email.com"), offerTypeId, _salesManagerId, _companyUserId, diff --git a/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppBusinessLogicTests.cs b/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppBusinessLogicTests.cs index e62c9636fd..f61f60454c 100644 --- a/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppBusinessLogicTests.cs +++ b/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppBusinessLogicTests.cs @@ -187,7 +187,7 @@ public async Task AddServiceSubscription_ReturnsCorrectId() var offerSubscriptionId = Guid.NewGuid(); var offerSubscriptionService = A.Fake(); var consentData = _fixture.CreateMany(2); - A.CallTo(() => offerSubscriptionService.AddOfferSubscriptionAsync(A._, A>._, A._, A._, A>._)) + A.CallTo(() => offerSubscriptionService.AddOfferSubscriptionAsync(A._, A>._, A._, A._, A>._, A>._)) .Returns(offerSubscriptionId); var sut = new AppsBusinessLogic(null!, offerSubscriptionService, null!, null!, Options.Create(new AppsSettings()), _identityService); @@ -201,6 +201,7 @@ public async Task AddServiceSubscription_ReturnsCorrectId() A>._, A.That.Matches(x => x == OfferTypeId.APP), A._, + A>._, A>._)) .MustHaveHappenedOnceExactly(); } diff --git a/tests/marketplace/Offers.Library.Tests/Service/OfferSubscriptionServiceTests.cs b/tests/marketplace/Offers.Library.Tests/Service/OfferSubscriptionServiceTests.cs index e49b9e320b..2bcfa2ca18 100644 --- a/tests/marketplace/Offers.Library.Tests/Service/OfferSubscriptionServiceTests.cs +++ b/tests/marketplace/Offers.Library.Tests/Service/OfferSubscriptionServiceTests.cs @@ -131,6 +131,7 @@ public async Task AddOfferSubscription_WithExistingId_CreatesServiceSubscription { new UserRoleConfig(ClientId, new[] { "Service Manager", "Sales Manager" }) }; + var serviceManagerRoles = new[] { new UserRoleConfig("portal", new[] { "Service Manager" }) }; A.CallTo(() => _offerSubscriptionsRepository.CheckPendingOrActiveSubscriptionExists(A._, A._, A._)) .Returns(false); var companyAssignedApps = new List(); @@ -153,7 +154,7 @@ public async Task AddOfferSubscription_WithExistingId_CreatesServiceSubscription }; // Act - await _sut.AddOfferSubscriptionAsync(_existingOfferId, _validConsentData, offerTypeId, BasePortalUrl, subscriptionManagerRoles).ConfigureAwait(false); + await _sut.AddOfferSubscriptionAsync(_existingOfferId, _validConsentData, offerTypeId, BasePortalUrl, subscriptionManagerRoles, serviceManagerRoles).ConfigureAwait(false); // Assert companyAssignedApps.Should().HaveCount(1); @@ -168,6 +169,11 @@ public async Task AddOfferSubscription_WithExistingId_CreatesServiceSubscription userParameter, A>.That.IsSameSequenceAs(template), _companyId)).MustHaveHappenedOnceExactly(); + A.CallTo(() => _notificationRepository.CreateNotification(_salesManagerId, + offerTypeId == OfferTypeId.APP + ? NotificationTypeId.APP_SUBSCRIPTION_REQUEST + : NotificationTypeId.SERVICE_REQUEST, false, A>._)) + .MustHaveHappenedOnceExactly(); } [Theory] @@ -185,7 +191,7 @@ public async Task AddOfferSubscription_WithSalesManagerEqualsReceiver_CreatesSer { new UserRoleConfig("portal", new[] { "Service Manager", "Sales Manager" }) }; - var offerProviderDetails = _fixture.Create(); + var serviceManagerRoles = new[] { new UserRoleConfig("portal", new[] { "Service Manager" }) }; A.CallTo(() => _offerSubscriptionsRepository.CheckPendingOrActiveSubscriptionExists(A._, A._, A._)) .Returns(false); var companyAssignedApps = new List(); @@ -207,7 +213,7 @@ public async Task AddOfferSubscription_WithSalesManagerEqualsReceiver_CreatesSer }; // Act - await _sut.AddOfferSubscriptionAsync(_existingOfferId, _validConsentData, offerTypeId, BasePortalUrl, subscriptionManagerRoles).ConfigureAwait(false); + await _sut.AddOfferSubscriptionAsync(_existingOfferId, _validConsentData, offerTypeId, BasePortalUrl, subscriptionManagerRoles, serviceManagerRoles).ConfigureAwait(false); // Assert companyAssignedApps.Should().HaveCount(1); @@ -228,6 +234,7 @@ public async Task AddOfferSubscription_WithExistingIdWithoutProviderEmail_Create var subscriptionManagerRoles = offerTypeId == OfferTypeId.APP ? new[]{ new UserRoleConfig("portal", new [] { "App Manager", "Sales Manager" })} : new[]{ new UserRoleConfig("Client1", new [] { "Service Manager", "Sales Manager" })}; + var serviceManagerRoles = new[] { new UserRoleConfig("portal", new[] { "Service Manager" }) }; A.CallTo(() => _offerSubscriptionsRepository.CheckPendingOrActiveSubscriptionExists(A._, A._, A._)) .Returns(false); var companyAssignedApps = new List(); @@ -239,7 +246,7 @@ public async Task AddOfferSubscription_WithExistingIdWithoutProviderEmail_Create }); // Act - await _sut.AddOfferSubscriptionAsync(_existingOfferIdWithoutProviderEmail, _validConsentData, offerTypeId, BasePortalUrl, subscriptionManagerRoles).ConfigureAwait(false); + await _sut.AddOfferSubscriptionAsync(_existingOfferIdWithoutProviderEmail, _validConsentData, offerTypeId, BasePortalUrl, subscriptionManagerRoles, serviceManagerRoles).ConfigureAwait(false); // Assert companyAssignedApps.Should().HaveCount(1); @@ -252,12 +259,13 @@ public async Task AddOfferSubscription_WithExistingAppSubscriptionAndProcessStep // Arrange var subscriptionManagerRoles = new[]{ new UserRoleConfig("portal", new [] { "App Manager", "Sales Manager" })}; + var serviceManagerRoles = new[] { new UserRoleConfig("portal", new[] { "Service Manager" }) }; var subscriptionId = Guid.NewGuid(); A.CallTo(() => _offerSubscriptionsRepository.CheckPendingOrActiveSubscriptionExists(A._, A._, A._)) .Returns(false); // Act - await _sut.AddOfferSubscriptionAsync(_existingOfferId, _validConsentData, OfferTypeId.APP, BasePortalUrl, subscriptionManagerRoles).ConfigureAwait(false); + await _sut.AddOfferSubscriptionAsync(_existingOfferId, _validConsentData, OfferTypeId.APP, BasePortalUrl, subscriptionManagerRoles, serviceManagerRoles).ConfigureAwait(false); // Assert A.CallTo(() => _offerSubscriptionsRepository.CheckPendingOrActiveSubscriptionExists(_existingOfferId, _companyId, OfferTypeId.APP)).MustHaveHappenedOnceExactly(); @@ -273,11 +281,12 @@ public async Task AddOfferSubscription_WithExistingActiveAppSubscription_Throws( // Arrange var subscriptionManagerRoles = new[]{ new UserRoleConfig("portal", new [] { "App Manager", "Sales Manager" })}; + var serviceManagerRoles = new[] { new UserRoleConfig("portal", new[] { "Service Manager" }) }; var subscriptionId = Guid.NewGuid(); A.CallTo(() => _offerSubscriptionsRepository.CheckPendingOrActiveSubscriptionExists(A._, A._, A._)) .Returns(true); - var Act = () => _sut.AddOfferSubscriptionAsync(_existingOfferId, _validConsentData, OfferTypeId.APP, BasePortalUrl, subscriptionManagerRoles); + var Act = () => _sut.AddOfferSubscriptionAsync(_existingOfferId, _validConsentData, OfferTypeId.APP, BasePortalUrl, subscriptionManagerRoles, serviceManagerRoles); // Act var result = await Assert.ThrowsAsync(Act).ConfigureAwait(false); @@ -300,18 +309,16 @@ public async Task AddOfferSubscription_NotAssignedCompany_ThrowsException(OfferT var subscriptionManagerRoles = offerTypeId == OfferTypeId.APP ? new[]{ new UserRoleConfig("portal", new [] { "App Manager", "Sales Manager" })} : new[]{ new UserRoleConfig("portal", new [] { "Service Manager", "Sales Manager" })}; - var identity = _fixture.Build() - .With(x => x.CompanyId, _notAssignedCompanyId) - .Create(); - A.CallTo(() => _identityService.IdentityData).Returns(identity); + var serviceManagerRoles = new[] { new UserRoleConfig("portal", new[] { "Service Manager" }) }; + A.CallTo(() => _identityService.IdentityData).Returns(_identity with { CompanyId = _notAssignedCompanyId }); // Act - async Task Action() => await _sut.AddOfferSubscriptionAsync(_existingOfferId, Enumerable.Empty(), offerTypeId, BasePortalUrl, subscriptionManagerRoles).ConfigureAwait(false); + async Task Action() => await _sut.AddOfferSubscriptionAsync(_existingOfferId, Enumerable.Empty(), offerTypeId, BasePortalUrl, subscriptionManagerRoles, serviceManagerRoles).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Action); ex.ParamName.Should().Be("companyId"); - ex.Message.Should().Be($"Company {identity.CompanyId} does not exist (Parameter 'companyId')"); + ex.Message.Should().Be($"Company {_notAssignedCompanyId} does not exist (Parameter 'companyId')"); } [Theory] @@ -323,10 +330,11 @@ public async Task AddOfferSubscription_WithNotExistingId_ThrowsException(OfferTy var subscriptionManagerRoles = offerTypeId == OfferTypeId.APP ? new[]{ new UserRoleConfig("portal", new [] { "App Manager", "Sales Manager" })} : new[]{ new UserRoleConfig("portal", new [] { "Service Manager", "Sales Manager" })}; + var serviceManagerRoles = new[] { new UserRoleConfig("portal", new[] { "Service Manager" }) }; var notExistingServiceId = Guid.NewGuid(); // Act - async Task Action() => await _sut.AddOfferSubscriptionAsync(notExistingServiceId, Enumerable.Empty(), offerTypeId, BasePortalUrl, subscriptionManagerRoles).ConfigureAwait(false); + async Task Action() => await _sut.AddOfferSubscriptionAsync(notExistingServiceId, Enumerable.Empty(), offerTypeId, BasePortalUrl, subscriptionManagerRoles, serviceManagerRoles).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Action); @@ -342,9 +350,10 @@ public async Task AddOfferSubscription_WithoutOfferProviderDetails_ThrowsExcepti var subscriptionManagerRoles = offerTypeId == OfferTypeId.APP ? new[]{ new UserRoleConfig("portal", new [] { "App Manager", "Sales Manager" })} : new[]{ new UserRoleConfig("portal", new [] { "Service Manager", "Sales Manager" })}; + var serviceManagerRoles = new[] { new UserRoleConfig("portal", new[] { "Service Manager" }) }; // Act - async Task Action() => await _sut.AddOfferSubscriptionAsync(_existingOfferWithoutDetailsFilled, Enumerable.Empty(), offerTypeId, BasePortalUrl, subscriptionManagerRoles).ConfigureAwait(false); + async Task Action() => await _sut.AddOfferSubscriptionAsync(_existingOfferWithoutDetailsFilled, Enumerable.Empty(), offerTypeId, BasePortalUrl, subscriptionManagerRoles, serviceManagerRoles).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Action); @@ -360,10 +369,11 @@ public async Task AddOfferSubscription_WithMissingConsentData_ThrowsControllerAr var subscriptionManagerRoles = offerTypeId == OfferTypeId.APP ? new[]{ new UserRoleConfig("portal", new [] { "App Manager", "Sales Manager" })} : new[]{ new UserRoleConfig("portal", new [] { "Service Manager", "Sales Manager" })}; + var serviceManagerRoles = new[] { new UserRoleConfig("portal", new[] { "Service Manager" }) }; var consentData = Enumerable.Empty(); // Act - async Task Action() => await _sut.AddOfferSubscriptionAsync(_existingOfferId, consentData, offerTypeId, BasePortalUrl, subscriptionManagerRoles).ConfigureAwait(false); + async Task Action() => await _sut.AddOfferSubscriptionAsync(_existingOfferId, consentData, offerTypeId, BasePortalUrl, subscriptionManagerRoles, serviceManagerRoles).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Action); @@ -381,11 +391,12 @@ public async Task AddOfferSubscription_WithAdditionalConsentData_ThrowsControlle var subscriptionManagerRoles = offerTypeId == OfferTypeId.APP ? new[]{ new UserRoleConfig("portal", new [] { "App Manager", "Sales Manager" })} : new[]{ new UserRoleConfig("portal", new [] { "Service Manager", "Sales Manager" })}; + var serviceManagerRoles = new[] { new UserRoleConfig("portal", new[] { "Service Manager" }) }; var additional = _fixture.CreateMany().ToImmutableArray(); var consentData = _validConsentData.Concat(additional).ToImmutableArray(); // Act - async Task Action() => await _sut.AddOfferSubscriptionAsync(_existingOfferId, consentData, offerTypeId, BasePortalUrl, subscriptionManagerRoles).ConfigureAwait(false); + async Task Action() => await _sut.AddOfferSubscriptionAsync(_existingOfferId, consentData, offerTypeId, BasePortalUrl, subscriptionManagerRoles, serviceManagerRoles).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Action); @@ -403,10 +414,11 @@ public async Task AddOfferSubscription_WithInactiveConsentData_ThrowsControllerA var subscriptionManagerRoles = offerTypeId == OfferTypeId.APP ? new[]{ new UserRoleConfig("portal", new [] { "App Manager", "Sales Manager" })} : new[]{ new UserRoleConfig("portal", new [] { "Service Manager", "Sales Manager" })}; + var serviceManagerRoles = new[] { new UserRoleConfig("portal", new[] { "Service Manager" }) }; var consentData = _offerAgreementIds.Select(id => new OfferAgreementConsentData(id, ConsentStatusId.INACTIVE)).ToImmutableArray(); // Act - async Task Action() => await _sut.AddOfferSubscriptionAsync(_existingOfferId, consentData, offerTypeId, BasePortalUrl, subscriptionManagerRoles).ConfigureAwait(false); + async Task Action() => await _sut.AddOfferSubscriptionAsync(_existingOfferId, consentData, offerTypeId, BasePortalUrl, subscriptionManagerRoles, serviceManagerRoles).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Action); @@ -424,11 +436,9 @@ public async Task AddOfferSubscription_WithoutBuisnessPartnerNumber_ThrowsConfli var subscriptionManagerRoles = offerTypeId == OfferTypeId.APP ? new[]{ new UserRoleConfig("portal", new [] { "App Manager", "Sales Manager" })} : new[]{ new UserRoleConfig("portal", new [] { "Service Manager", "Sales Manager" })}; - var identity = _fixture.Build() - .With(x => x.CompanyId, _noBpnSetCompanyId) - .Create(); - A.CallTo(() => _identityService.IdentityData).Returns(identity); - async Task Action() => await _sut.AddOfferSubscriptionAsync(_existingOfferId, Enumerable.Empty(), offerTypeId, BasePortalUrl, subscriptionManagerRoles).ConfigureAwait(false); + var serviceManagerRoles = new[] { new UserRoleConfig("portal", new[] { "Service Manager" }) }; + A.CallTo(() => _identityService.IdentityData).Returns(_identity with { CompanyId = _noBpnSetCompanyId }); + async Task Action() => await _sut.AddOfferSubscriptionAsync(_existingOfferId, Enumerable.Empty(), offerTypeId, BasePortalUrl, subscriptionManagerRoles, serviceManagerRoles).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Action); @@ -444,12 +454,13 @@ public async Task AddOfferSubscription_EmptyProviderCompanyId_ThrowsConflictExce var subscriptionManagerRoles = offerTypeId == OfferTypeId.APP ? new[]{ new UserRoleConfig(ClientId, new [] { "App Manager", "Sales Manager" })} : new[]{ new UserRoleConfig(ClientId, new [] { "Service Manager", "Sales Manager" })}; + var serviceManagerRoles = new[] { new UserRoleConfig("portal", new[] { "Service Manager" }) }; A.CallTo(() => _offerRepository.GetOfferProviderDetailsAsync(A.That.Matches(x => x == _existingOfferId), A._)) .Returns(new OfferProviderDetailsData("Test Offer", "Test Company", "provider@mail.de", _salesManagerId, "https://www.testurl.com", false, null)); // Act - async Task Action() => await _sut.AddOfferSubscriptionAsync(_existingOfferId, _validConsentData, offerTypeId, BasePortalUrl, subscriptionManagerRoles).ConfigureAwait(false); + async Task Action() => await _sut.AddOfferSubscriptionAsync(_existingOfferId, _validConsentData, offerTypeId, BasePortalUrl, subscriptionManagerRoles, serviceManagerRoles).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Action); @@ -466,15 +477,13 @@ public async Task AddOfferSubscription_WithExistingActiveSubscription_ThrowsConf // Arrange var subscriptionManagerRoles = new[]{ new UserRoleConfig("portal", new [] { "App Manager", "Sales Manager" })}; - var identity = _fixture.Build() - .With(x => x.CompanyId, _existingActiveSubscriptionCompanyId) - .Create(); - A.CallTo(() => _identityService.IdentityData).Returns(identity); - A.CallTo(() => _offerSubscriptionsRepository.CheckPendingOrActiveSubscriptionExists(_existingOfferId, identity.CompanyId, A._)) + var serviceManagerRoles = new[] { new UserRoleConfig("portal", new[] { "Service Manager" }) }; + A.CallTo(() => _identityService.IdentityData).Returns(_identity with { CompanyId = _existingActiveSubscriptionCompanyId }); + A.CallTo(() => _offerSubscriptionsRepository.CheckPendingOrActiveSubscriptionExists(_existingOfferId, _existingActiveSubscriptionCompanyId, A._)) .Returns(true); // Act - async Task Act() => await _sut.AddOfferSubscriptionAsync(_existingOfferId, _validConsentData, OfferTypeId.APP, BasePortalUrl, subscriptionManagerRoles).ConfigureAwait(false); + async Task Act() => await _sut.AddOfferSubscriptionAsync(_existingOfferId, _validConsentData, OfferTypeId.APP, BasePortalUrl, subscriptionManagerRoles, serviceManagerRoles).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Act); @@ -511,16 +520,16 @@ private void SetupRepositories() .With(x => x.Id, _existingOfferId) .Create(); - A.CallTo(() => _companyRepository.GetOwnCompanyInformationAsync(_identity.CompanyId)) - .Returns(new CompanyInformationData(_companyId, "The Company", "DE", "BPM00000001")); - A.CallTo(() => _companyRepository.GetOwnCompanyInformationAsync(_notAssignedCompanyId)) + A.CallTo(() => _companyRepository.GetOwnCompanyInformationAsync(_identity.CompanyId, _identity.UserId)) + .Returns(new CompanyInformationData(_companyId, "The Company", "DE", "BPM00000001", "test@mail.com")); + A.CallTo(() => _companyRepository.GetOwnCompanyInformationAsync(_notAssignedCompanyId, _identity.UserId)) .Returns((CompanyInformationData?)null); - A.CallTo(() => _companyRepository.GetOwnCompanyInformationAsync(_noBpnSetCompanyId)) - .Returns(new CompanyInformationData(_companyId, "The Company", "DE", null)); - A.CallTo(() => _companyRepository.GetOwnCompanyInformationAsync(_existingActiveSubscriptionCompanyId)) - .Returns(new CompanyInformationData(_existingActiveSubscriptionCompanyId, "The Company", "DE", "BPM00000001")); - A.CallTo(() => _companyRepository.GetOwnCompanyInformationAsync(_existingInactiveSubscriptionCompanyId)) - .Returns(new CompanyInformationData(_existingInactiveSubscriptionCompanyId, "The Company", "DE", "BPM00000001")); + A.CallTo(() => _companyRepository.GetOwnCompanyInformationAsync(_noBpnSetCompanyId, _identity.UserId)) + .Returns(new CompanyInformationData(_companyId, "The Company", "DE", null, "test@mail.com")); + A.CallTo(() => _companyRepository.GetOwnCompanyInformationAsync(_existingActiveSubscriptionCompanyId, _identity.UserId)) + .Returns(new CompanyInformationData(_existingActiveSubscriptionCompanyId, "The Company", "DE", "BPM00000001", "test@mail.com")); + A.CallTo(() => _companyRepository.GetOwnCompanyInformationAsync(_existingInactiveSubscriptionCompanyId, _identity.UserId)) + .Returns(new CompanyInformationData(_existingInactiveSubscriptionCompanyId, "The Company", "DE", "BPM00000001", "test@mail.com")); A.CallTo(() => _userRepository.GetServiceProviderCompanyUserWithRoleIdAsync(A.That.Matches(x => x == _existingOfferId), A>.That.IsSameSequenceAs(new[] { _userRoleId }))) .Returns(new[] { _companyUserId, _salesManagerId }.ToAsyncEnumerable()); A.CallTo(() => _userRolesRepository.GetUserRoleIdsUntrackedAsync(A>.That.Matches(x => x.First(y => y.ClientId == ClientId).ClientId == "Service Manager"))) @@ -580,6 +589,9 @@ private void SetupRepositories() A.CallTo(() => _agreementRepository.GetAgreementIdsForOfferAsync(A.That.Not.Matches(id => id == _existingOfferId || id == _existingOfferWithFailingAutoSetupId || id == _existingOfferWithoutDetailsFilled || id == _existingOfferIdWithoutProviderEmail))) .Returns(_fixture.CreateMany().ToAsyncEnumerable()); + A.CallTo(() => _userRolesRepository.GetUserRoleIdsUntrackedAsync(A>._)) + .Returns(new[] { Guid.NewGuid() }.ToAsyncEnumerable()); + A.CallTo(() => _portalRepositories.GetInstance()).Returns(_agreementRepository); A.CallTo(() => _portalRepositories.GetInstance()).Returns(_consentRepository); A.CallTo(() => _portalRepositories.GetInstance()).Returns(_companyRepository); diff --git a/tests/marketplace/Services.Service.Tests/BusinessLogic/ServiceBusinessLogicTests.cs b/tests/marketplace/Services.Service.Tests/BusinessLogic/ServiceBusinessLogicTests.cs index 502d47494e..39ad8bf732 100644 --- a/tests/marketplace/Services.Service.Tests/BusinessLogic/ServiceBusinessLogicTests.cs +++ b/tests/marketplace/Services.Service.Tests/BusinessLogic/ServiceBusinessLogicTests.cs @@ -156,7 +156,7 @@ public async Task AddServiceSubscription_ReturnsCorrectId() // Arrange var offerSubscriptionId = Guid.NewGuid(); var consentData = _fixture.CreateMany(2); - A.CallTo(() => _offerSubscriptionService.AddOfferSubscriptionAsync(A._, A>._, A._, A._, A>._)) + A.CallTo(() => _offerSubscriptionService.AddOfferSubscriptionAsync(A._, A>._, A._, A._, A>._, A>._)) .Returns(offerSubscriptionId); var serviceSettings = new ServiceSettings { @@ -178,6 +178,7 @@ public async Task AddServiceSubscription_ReturnsCorrectId() A>._, A.That.Matches(x => x == OfferTypeId.SERVICE), A._, + A>._, A>._)) .MustHaveHappenedOnceExactly(); } diff --git a/tests/portalbackend/PortalBackend.DBAccess.Tests/CompanyRepositoryTests.cs b/tests/portalbackend/PortalBackend.DBAccess.Tests/CompanyRepositoryTests.cs index 9178e87b66..942b99ec0e 100644 --- a/tests/portalbackend/PortalBackend.DBAccess.Tests/CompanyRepositoryTests.cs +++ b/tests/portalbackend/PortalBackend.DBAccess.Tests/CompanyRepositoryTests.cs @@ -684,11 +684,12 @@ public async Task GetOwnCompanAndCompanyUseryIdWithCompanyNameAndUserEmailAsync_ var (sut, _) = await CreateSut().ConfigureAwait(false); // Act - var result = await sut.GetOwnCompanyInformationAsync(new("2dc4249f-b5ca-4d42-bef1-7a7a950a4f87")).ConfigureAwait(false); + var result = await sut.GetOwnCompanyInformationAsync(new("2dc4249f-b5ca-4d42-bef1-7a7a950a4f87"), new Guid("cd436931-8399-4c1d-bd81-7dffb298c7ca")).ConfigureAwait(false); // Assert result.Should().NotBeNull(); result!.OrganizationName.Should().Be("Catena-X"); + result.CompanyUserEmail.Should().Be("inactive-user@mail.com"); } [Fact] @@ -698,7 +699,7 @@ public async Task GetOwnCompanAndCompanyUseryIdWithCompanyNameAndUserEmailAsync_ var (sut, _) = await CreateSut().ConfigureAwait(false); // Act - var result = await sut.GetOwnCompanyInformationAsync(Guid.NewGuid()).ConfigureAwait(false); + var result = await sut.GetOwnCompanyInformationAsync(Guid.NewGuid(), Guid.NewGuid()).ConfigureAwait(false); // Assert result.Should().BeNull();