From 53a4369ad1e25dd2d313353c7f95f2b9ffb399be Mon Sep 17 00:00:00 2001 From: Norbert Truchsess Date: Wed, 24 Jul 2024 18:10:46 +0200 Subject: [PATCH] chore(code-quality): fix imports (#869) --- .../BusinessLogic/AppsBusinessLogic.cs | 10 +- .../CompanySubscriptionStatusExtensions.cs | 7 +- .../Extensions/ProcessStepExtensions.cs | 24 +++-- .../Offers.Library/Service/OfferService.cs | 9 +- .../BusinessLogic/ServiceBusinessLogic.cs | 10 +- .../BusinessLogic/AppBusinessLogicTests.cs | 50 ++++----- .../OfferDocumentServiceTests.cs | 43 ++++---- .../Service/ExtensionsTest.cs | 100 ++++++++++++++++++ .../Service/OfferServiceTests.cs | 6 +- .../ServiceBusinessLogicTests.cs | 30 +++--- 10 files changed, 186 insertions(+), 103 deletions(-) create mode 100644 tests/marketplace/Offers.Library.Tests/Service/ExtensionsTest.cs diff --git a/src/marketplace/Apps.Service/BusinessLogic/AppsBusinessLogic.cs b/src/marketplace/Apps.Service/BusinessLogic/AppsBusinessLogic.cs index 3927fd2028..a29edfcc7e 100644 --- a/src/marketplace/Apps.Service/BusinessLogic/AppsBusinessLogic.cs +++ b/src/marketplace/Apps.Service/BusinessLogic/AppsBusinessLogic.cs @@ -18,10 +18,10 @@ ********************************************************************************/ using Microsoft.Extensions.Options; -using Offers.Library.Extensions; using Org.Eclipse.TractusX.Portal.Backend.Apps.Service.ViewModels; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; +using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Extensions; using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Models; using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Service; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess; @@ -46,7 +46,6 @@ public class AppsBusinessLogic : IAppsBusinessLogic private readonly IOfferService _offerService; private readonly IOfferSetupService _offerSetupService; private readonly IIdentityData _identityData; - private readonly ILogger _logger; /// /// Constructor. @@ -57,22 +56,19 @@ public class AppsBusinessLogic : IAppsBusinessLogic /// Offer Setup Service /// Settings /// Identity - /// The logger public AppsBusinessLogic( IPortalRepositories portalRepositories, IOfferSubscriptionService offerSubscriptionService, IOfferService offerService, IOfferSetupService offerSetupService, IOptions settings, - IIdentityService identityService, - ILogger logger) + IIdentityService identityService) { _portalRepositories = portalRepositories; _offerSubscriptionService = offerSubscriptionService; _offerService = offerService; _offerSetupService = offerSetupService; _identityData = identityService.IdentityData; - _logger = logger; _settings = settings.Value; } @@ -180,7 +176,7 @@ public async Task AddFavouriteAppForUserAsync(Guid appId) new OfferCompanySubscriptionStatusResponse( item.OfferId, item.ServiceName, - item.CompanySubscriptionStatuses.Select(x => x.GetCompanySubscriptionStatus(item.OfferId, _logger)), + item.CompanySubscriptionStatuses.Select(x => x.GetCompanySubscriptionStatus(item.OfferId)), item.Image == Guid.Empty ? null : item.Image))); } return await Pagination.CreateResponseAsync(page, size, _settings.ApplicationsMaxPageSize, GetCompanyProvidedAppSubscriptionStatusData).ConfigureAwait(ConfigureAwaitOptions.None); diff --git a/src/marketplace/Offers.Library/Extensions/CompanySubscriptionStatusExtensions.cs b/src/marketplace/Offers.Library/Extensions/CompanySubscriptionStatusExtensions.cs index cb7ee326d4..ffd3b96831 100644 --- a/src/marketplace/Offers.Library/Extensions/CompanySubscriptionStatusExtensions.cs +++ b/src/marketplace/Offers.Library/Extensions/CompanySubscriptionStatusExtensions.cs @@ -17,14 +17,13 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -using Microsoft.Extensions.Logging; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; -namespace Offers.Library.Extensions; +namespace Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Extensions; public static class CompanySubscriptionStatusExtensions { - public static CompanySubscriptionStatus GetCompanySubscriptionStatus(this CompanySubscriptionStatusData data, Guid offerId, ILogger logger) => + public static CompanySubscriptionStatus GetCompanySubscriptionStatus(this CompanySubscriptionStatusData data, Guid offerId) => new( data.CompanyId, data.CompanyName, @@ -34,5 +33,5 @@ public static CompanySubscriptionStatus GetCompanySubscriptionStatus(this Compan data.BpnNumber, data.Email, data.TechnicalUser, - data.ProcessSteps.GetProcessStepTypeId(offerId, logger)); + data.ProcessSteps.GetProcessStepTypeId(offerId)); } diff --git a/src/marketplace/Offers.Library/Extensions/ProcessStepExtensions.cs b/src/marketplace/Offers.Library/Extensions/ProcessStepExtensions.cs index 69c7f9e94b..cfad02d7b4 100644 --- a/src/marketplace/Offers.Library/Extensions/ProcessStepExtensions.cs +++ b/src/marketplace/Offers.Library/Extensions/ProcessStepExtensions.cs @@ -17,22 +17,28 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -using Microsoft.Extensions.Logging; +using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; -namespace Offers.Library.Extensions; +namespace Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Extensions; public static class ProcessStepExtensions { - public static ProcessStepTypeId? GetProcessStepTypeId(this IEnumerable<(ProcessStepTypeId ProcessStepTypeId, ProcessStepStatusId ProcessStepStatusId)> processSteps, Guid offerId, ILogger logger) + public static ProcessStepTypeId? GetProcessStepTypeId(this IEnumerable<(ProcessStepTypeId ProcessStepTypeId, ProcessStepStatusId ProcessStepStatusId)> processSteps, Guid offerId) { - if (processSteps.Count(p => p.ProcessStepStatusId == ProcessStepStatusId.TODO) > 1) + try { - logger.Log(LogLevel.Error, "Offers: {OfferIds} contain more than one process step in todo", string.Join(",", offerId)); - } + var processStep = processSteps.Where(p => p.ProcessStepStatusId == ProcessStepStatusId.TODO) + .DistinctBy(p => p.ProcessStepTypeId) + .SingleOrDefault(); - return processSteps.Any(p => p.ProcessStepStatusId == ProcessStepStatusId.TODO) - ? processSteps.Single(p => p.ProcessStepStatusId == ProcessStepStatusId.TODO).ProcessStepTypeId - : null; + return processStep == default + ? null + : processStep.ProcessStepTypeId; + } + catch (InvalidOperationException) + { + throw new ConflictException($"Offers: {offerId} contains more than one process step in todo"); + } } } diff --git a/src/marketplace/Offers.Library/Service/OfferService.cs b/src/marketplace/Offers.Library/Service/OfferService.cs index 892630e5ce..cb2671b85a 100644 --- a/src/marketplace/Offers.Library/Service/OfferService.cs +++ b/src/marketplace/Offers.Library/Service/OfferService.cs @@ -18,13 +18,13 @@ ********************************************************************************/ using Microsoft.Extensions.Logging; -using Offers.Library.Extensions; using Org.Eclipse.TractusX.Portal.Backend.Framework.Async; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.Framework.Linq; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models.Configuration; using Org.Eclipse.TractusX.Portal.Backend.Notifications.Library; +using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Extensions; using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Extensions; @@ -45,7 +45,6 @@ public class OfferService : IOfferService private readonly IMailingProcessCreation _mailingProcessCreation; private readonly IIdentityData _identityData; private readonly IOfferSetupService _offerSetupService; - private readonly ILogger _logger; /// /// Constructor. @@ -60,15 +59,13 @@ public OfferService(IPortalRepositories portalRepositories, INotificationService notificationService, IMailingProcessCreation mailingProcessCreation, IIdentityService identityService, - IOfferSetupService offerSetupService, - ILogger logger) + IOfferSetupService offerSetupService) { _portalRepositories = portalRepositories; _notificationService = notificationService; _mailingProcessCreation = mailingProcessCreation; _identityData = identityService.IdentityData; _offerSetupService = offerSetupService; - _logger = logger; } /// @@ -828,7 +825,7 @@ public async Task GetAppSubscriptionDetailsFo { var data = await GetOfferSubscriptionDetailsInternal(offerId, subscriptionId, offerTypeId, contactUserRoles, OfferCompanyRole.Provider, _portalRepositories.GetInstance().GetAppSubscriptionDetailsForProviderAsync) .ConfigureAwait(ConfigureAwaitOptions.None); - return new AppProviderSubscriptionDetailData(data.Id, data.OfferSubscriptionStatus, data.Name, data.Customer, data.Bpn, data.Contact, data.TechnicalUserData, data.TenantUrl, data.AppInstanceId, data.ProcessSteps.GetProcessStepTypeId(data.Id, _logger)); + return new AppProviderSubscriptionDetailData(data.Id, data.OfferSubscriptionStatus, data.Name, data.Customer, data.Bpn, data.Contact, data.TechnicalUserData, data.TenantUrl, data.AppInstanceId, data.ProcessSteps.GetProcessStepTypeId(data.Id)); } /// diff --git a/src/marketplace/Services.Service/BusinessLogic/ServiceBusinessLogic.cs b/src/marketplace/Services.Service/BusinessLogic/ServiceBusinessLogic.cs index 83b2f84fe6..ca229885e1 100644 --- a/src/marketplace/Services.Service/BusinessLogic/ServiceBusinessLogic.cs +++ b/src/marketplace/Services.Service/BusinessLogic/ServiceBusinessLogic.cs @@ -18,9 +18,9 @@ ********************************************************************************/ using Microsoft.Extensions.Options; -using Offers.Library.Extensions; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; +using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Extensions; using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Models; using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Service; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess; @@ -45,7 +45,6 @@ public class ServiceBusinessLogic : IServiceBusinessLogic private readonly IOfferSetupService _offerSetupService; private readonly ServiceSettings _settings; private readonly IIdentityData _identityData; - private readonly ILogger _logger; /// /// Constructor. @@ -56,22 +55,19 @@ public class ServiceBusinessLogic : IServiceBusinessLogic /// Offer Setup Service /// Access the identity of the user /// Access to the settings - /// Access to the logger public ServiceBusinessLogic( IPortalRepositories portalRepositories, IOfferService offerService, IOfferSubscriptionService offerSubscriptionService, IOfferSetupService offerSetupService, IIdentityService identityService, - IOptions settings, - ILogger logger) + IOptions settings) { _portalRepositories = portalRepositories; _offerService = offerService; _offerSubscriptionService = offerSubscriptionService; _offerSetupService = offerSetupService; _identityData = identityService.IdentityData; - _logger = logger; _settings = settings.Value; } @@ -156,7 +152,7 @@ public Task AutoSetupServiceAsync(OfferAutoSetupData new OfferCompanySubscriptionStatusResponse( item.OfferId, item.ServiceName, - item.CompanySubscriptionStatuses.Select(x => x.GetCompanySubscriptionStatus(item.OfferId, _logger)), + item.CompanySubscriptionStatuses.Select(x => x.GetCompanySubscriptionStatus(item.OfferId)), item.Image == Guid.Empty ? null : item.Image))); } return await Pagination.CreateResponseAsync(page, size, _settings.ApplicationsMaxPageSize, GetCompanyProvidedAppSubscriptionStatusData).ConfigureAwait(ConfigureAwaitOptions.None); diff --git a/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppBusinessLogicTests.cs b/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppBusinessLogicTests.cs index c38266a3d4..4d4da1588f 100644 --- a/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppBusinessLogicTests.cs +++ b/tests/marketplace/Apps.Service.Tests/BusinessLogic/AppBusinessLogicTests.cs @@ -21,7 +21,6 @@ using AutoFixture.AutoFakeItEasy; using FakeItEasy; using FluentAssertions; -using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Org.Eclipse.TractusX.Portal.Backend.Apps.Service.ViewModels; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; @@ -52,7 +51,6 @@ public class AppBusinessLogicTests private readonly IOfferSetupService _offerSetupService; private readonly IIdentityService _identityService; private readonly IOfferService _offerService; - private readonly ILogger _logger; public AppBusinessLogicTests() { @@ -68,7 +66,6 @@ public AppBusinessLogicTests() _identity = A.Fake(); _identityService = A.Fake(); _offerSetupService = A.Fake(); - _logger = A.Fake>(); A.CallTo(() => _identity.IdentityId).Returns(CompanyUserId); A.CallTo(() => _identity.IdentityTypeId).Returns(IdentityTypeId.COMPANY_USER); A.CallTo(() => _identity.CompanyId).Returns(CompanyId); @@ -78,7 +75,6 @@ public AppBusinessLogicTests() A.CallTo(() => _portalRepositories.GetInstance()).Returns(_offerSubscriptionRepository); _fixture.Inject(_portalRepositories); - _fixture.Inject(_logger); } [Fact] @@ -86,7 +82,7 @@ public async Task AddFavouriteAppForUser_ExecutesSuccessfully() { // Arrange var appId = _fixture.Create(); - var sut = new AppsBusinessLogic(_portalRepositories, null!, null!, null!, Options.Create(new AppsSettings()), _identityService, _logger); + var sut = new AppsBusinessLogic(_portalRepositories, null!, null!, null!, Options.Create(new AppsSettings()), _identityService); // Act await sut.AddFavouriteAppForUserAsync(appId); @@ -102,7 +98,7 @@ public async Task RemoveFavouriteAppForUser_ExecutesSuccessfully() // Arrange var appId = _fixture.Create(); - var sut = new AppsBusinessLogic(_portalRepositories, null!, null!, null!, Options.Create(new AppsSettings()), _identityService, _logger); + var sut = new AppsBusinessLogic(_portalRepositories, null!, null!, null!, Options.Create(new AppsSettings()), _identityService); // Act await sut.RemoveFavouriteAppForUserAsync(appId); @@ -121,7 +117,7 @@ public async Task GetAllActiveAppsAsync_ExecutesSuccessfully() var results = _fixture.CreateMany(5); A.CallTo(() => _offerRepository.GetAllActiveAppsAsync(A._, A._)).Returns(results.ToAsyncEnumerable()); - var sut = new AppsBusinessLogic(_portalRepositories, null!, null!, null!, Options.Create(new AppsSettings()), _identityService, _logger); + var sut = new AppsBusinessLogic(_portalRepositories, null!, null!, null!, Options.Create(new AppsSettings()), _identityService); // Act var result = await sut.GetAllActiveAppsAsync(null).ToListAsync(); @@ -140,7 +136,7 @@ public async Task GetAllUserUserBusinessAppsAsync_WithValidData_ReturnsExpectedD // Arrange var appData = _fixture.CreateMany<(Guid, Guid, string?, string, Guid, string)>(5); A.CallTo(() => _offerSubscriptionRepository.GetAllBusinessAppDataForUserIdAsync(A._)).Returns(appData.ToAsyncEnumerable()); - var sut = new AppsBusinessLogic(_portalRepositories, null!, null!, null!, Options.Create(new AppsSettings()), _identityService, _logger); + var sut = new AppsBusinessLogic(_portalRepositories, null!, null!, null!, Options.Create(new AppsSettings()), _identityService); // Act var result = await sut.GetAllUserUserBusinessAppsAsync().ToListAsync(); @@ -163,7 +159,7 @@ public async Task GetAppAgreement_WithUserId_ReturnsAgreementData() var data = _fixture.CreateMany(1); A.CallTo(() => offerService.GetOfferAgreementsAsync(A.That.Matches(x => x == appId), A._)) .Returns(data.ToAsyncEnumerable()); - var sut = new AppsBusinessLogic(null!, null!, offerService, null!, Options.Create(new AppsSettings()), _identityService, _logger); + var sut = new AppsBusinessLogic(null!, null!, offerService, null!, Options.Create(new AppsSettings()), _identityService); // Act var result = await sut.GetAppAgreement(appId).ToListAsync(); @@ -185,7 +181,7 @@ public async Task AddServiceSubscription_ReturnsCorrectId() var consentData = _fixture.CreateMany(2); 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, _logger); + var sut = new AppsBusinessLogic(null!, offerSubscriptionService, null!, null!, Options.Create(new AppsSettings()), _identityService); // Act var result = await sut.AddOwnCompanyAppSubscriptionAsync(Guid.NewGuid(), consentData); @@ -216,7 +212,7 @@ public async Task AutoSetupService_ReturnsExcepted() .Returns(offerAutoSetupResponseData); var data = new OfferAutoSetupData(Guid.NewGuid(), "https://www.offer.com"); - var sut = new AppsBusinessLogic(null!, null!, null!, offerSetupService, _fixture.Create>(), _identityService, _logger); + var sut = new AppsBusinessLogic(null!, null!, null!, offerSetupService, _fixture.Create>(), _identityService); // Act var result = await sut.AutoSetupAppAsync(data); @@ -236,7 +232,7 @@ public async Task StartAutoSetupService_ReturnsExcepted() var offerSetupService = A.Fake(); var data = new OfferAutoSetupData(Guid.NewGuid(), "https://www.offer.com"); - var sut = new AppsBusinessLogic(null!, null!, null!, offerSetupService, _fixture.Create>(), _identityService, _logger); + var sut = new AppsBusinessLogic(null!, null!, null!, offerSetupService, _fixture.Create>(), _identityService); // Act await sut.StartAutoSetupAsync(data); @@ -256,7 +252,7 @@ public async Task ActivateSingleInstance_ReturnsExcepted() var offerSetupService = A.Fake(); var offerSubscriptionId = Guid.NewGuid(); - var sut = new AppsBusinessLogic(null!, null!, null!, offerSetupService, _fixture.Create>(), _identityService, _logger); + var sut = new AppsBusinessLogic(null!, null!, null!, offerSetupService, _fixture.Create>(), _identityService); // Act await sut.ActivateSingleInstance(offerSubscriptionId); @@ -285,7 +281,7 @@ public async Task GetCompanyProvidedAppSubscriptionStatusesForUserAsync_ReturnsE ApplicationsMaxPageSize = 15 }; - var sut = new AppsBusinessLogic(_portalRepositories, null!, null!, null!, Options.Create(appsSettings), _identityService, _logger); + var sut = new AppsBusinessLogic(_portalRepositories, null!, null!, null!, Options.Create(appsSettings), _identityService); // Act var result = await sut.GetCompanyProvidedAppSubscriptionStatusesForUserAsync(0, 10, null, null, offerId, null); @@ -320,7 +316,7 @@ public async Task GetCompanyProvidedAppSubscriptionStatusesForUserAsync_EmptyIma ApplicationsMaxPageSize = 15 }; - var sut = new AppsBusinessLogic(_portalRepositories, null!, null!, null!, Options.Create(appsSettings), _identityService, _logger); + var sut = new AppsBusinessLogic(_portalRepositories, null!, null!, null!, Options.Create(appsSettings), _identityService); // Act var result = await sut.GetCompanyProvidedAppSubscriptionStatusesForUserAsync(0, 10, null, null, offerId, null); @@ -348,7 +344,7 @@ public async Task GetCompanyProvidedAppSubscriptionStatusesForUserAsync_QueryNul ApplicationsMaxPageSize = 15 }; - var sut = new AppsBusinessLogic(_portalRepositories, null!, null!, null!, Options.Create(appsSettings), _identityService, _logger); + var sut = new AppsBusinessLogic(_portalRepositories, null!, null!, null!, Options.Create(appsSettings), _identityService); // Act var result = await sut.GetCompanyProvidedAppSubscriptionStatusesForUserAsync(0, 10, null, null, offerId, null); @@ -373,7 +369,7 @@ public async Task ActivateOfferSubscription_CallsExpected() { ITAdminRoles = new List(), ServiceManagerRoles = new List() - }), _identityService, _logger); + }), _identityService); // Act await sut.TriggerActivateOfferSubscription(offerSubscriptionId); @@ -391,7 +387,7 @@ public async Task ActivateOfferSubscription_CallsExpected() public async Task UnsubscribeOwnCompanyAppSubscriptionAsync_ExpectedCall() { // Arrange - var sut = new AppsBusinessLogic(_portalRepositories, null!, _offerService, null!, Options.Create(new AppsSettings()), _identityService, _logger); + var sut = new AppsBusinessLogic(_portalRepositories, null!, _offerService, null!, Options.Create(new AppsSettings()), _identityService); // Act await sut.UnsubscribeOwnCompanyAppSubscriptionAsync(_fixture.Create()); @@ -419,7 +415,7 @@ public async Task GetAppDocumentContentAsync_ReturnsExpectedResult() A.CallTo(() => _offerService.GetOfferDocumentContentAsync(appId, documentId, settings.AppImageDocumentTypeIds, OfferTypeId.APP, A._)) .Returns(data); - var sut = new AppsBusinessLogic(_portalRepositories, null!, _offerService, null!, Options.Create(settings), _identityService, _logger); + var sut = new AppsBusinessLogic(_portalRepositories, null!, _offerService, null!, Options.Create(settings), _identityService); // Act var result = await sut.GetAppDocumentContentAsync(appId, documentId, CancellationToken.None); @@ -453,7 +449,7 @@ public async Task GetCompanyProvidedAppsDataForUserAsync_ReturnsExpectedCount(Ap A.CallTo(() => _offerRepository.GetProvidedOffersData(A>._, A._, A._, A._, A._))! .Returns(paginationResult); - var sut = new AppsBusinessLogic(_portalRepositories, null!, null!, null!, _fixture.Create>(), _identityService, _logger); + var sut = new AppsBusinessLogic(_portalRepositories, null!, null!, null!, _fixture.Create>(), _identityService); //Act var result = await sut.GetCompanyProvidedAppsDataForUserAsync(2, 3, sorting, name, serviceStatusIdFilter); @@ -478,7 +474,7 @@ public async Task GetCompanySubscribedAppSubscriptionStatusesForUserAsync_Return A.CallTo(() => _offerService.GetCompanySubscribedOfferSubscriptionStatusesForUserAsync(A._, A._, A._, A._)) .Returns(pagination); - var sut = new AppsBusinessLogic(_portalRepositories, null!, _offerService, null!, _fixture.Create>(), _identityService, _logger); + var sut = new AppsBusinessLogic(_portalRepositories, null!, _offerService, null!, _fixture.Create>(), _identityService); // Act var result = await sut.GetCompanySubscribedAppSubscriptionStatusesForUserAsync(0, 10); @@ -509,7 +505,7 @@ public async Task GetSubscriptionDetailForProvider_ReturnsExpected() }; A.CallTo(() => _offerService.GetAppSubscriptionDetailsForProviderAsync(A._, A._, A._, A>._)) .Returns(data); - var sut = new AppsBusinessLogic(null!, null!, _offerService, null!, Options.Create(settings), _identityService, _logger); + var sut = new AppsBusinessLogic(null!, null!, _offerService, null!, Options.Create(settings), _identityService); // Act var result = await sut.GetSubscriptionDetailForProvider(appId, subscriptionId); @@ -543,7 +539,7 @@ public async Task GetSubscriptionDetailForSubscriber_ReturnsExpected() A.CallTo(() => _offerService.GetSubscriptionDetailsForSubscriberAsync(A._, A._, A._, A>._)) .Returns(data); - var sut = new AppsBusinessLogic(null!, null!, _offerService, null!, Options.Create(settings), _identityService, _logger); + var sut = new AppsBusinessLogic(null!, null!, _offerService, null!, Options.Create(settings), _identityService); // Act var result = await sut.GetSubscriptionDetailForSubscriber(appId, subscriptionId); @@ -584,7 +580,7 @@ public async Task GetAppDetailsByIdAsync_ReturnsExpected() A.CallTo(() => _offerRepository.GetOfferDetailsByIdAsync(A._, A._, A._, A._!, A._)) .Returns(data); - var sut = new AppsBusinessLogic(_portalRepositories, null!, _offerService, null!, Options.Create(new AppsSettings()), _identityService, _logger); + var sut = new AppsBusinessLogic(_portalRepositories, null!, _offerService, null!, Options.Create(new AppsSettings()), _identityService); // Act var result = await sut.GetAppDetailsByIdAsync(appId, language); @@ -642,7 +638,7 @@ public async Task GetAppDetailsByIdAsync_WithNullProperties_ReturnsExpected() A.CallTo(() => _offerRepository.GetOfferDetailsByIdAsync(A._, A._, A._, A._, A._)) .Returns(data); - var sut = new AppsBusinessLogic(_portalRepositories, null!, _offerService, null!, Options.Create(new AppsSettings()), _identityService, _logger); + var sut = new AppsBusinessLogic(_portalRepositories, null!, _offerService, null!, Options.Create(new AppsSettings()), _identityService); // Act var result = await sut.GetAppDetailsByIdAsync(appId, null); @@ -670,7 +666,7 @@ public async Task GetOwnCompanyActiveSubscribedAppSubscriptionStatusesForUserAsy A.CallTo(() => _offerSubscriptionRepository.GetOwnCompanyActiveSubscribedOfferSubscriptionStatusesUntrackedAsync(A._, A._, A._)) .Returns(data); - var sut = new AppsBusinessLogic(_portalRepositories, null!, _offerService, null!, _fixture.Create>(), _identityService, _logger); + var sut = new AppsBusinessLogic(_portalRepositories, null!, _offerService, null!, _fixture.Create>(), _identityService); // Act var result = await sut.GetOwnCompanyActiveSubscribedAppSubscriptionStatusesForUserAsync().ToListAsync(); @@ -692,7 +688,7 @@ public async Task GetOwnCompanySubscribedAppOfferSubscriptionDataForUserAsync_Re A.CallTo(() => _offerSubscriptionRepository.GetOwnCompanySubscribedOfferSubscriptionUntrackedAsync(A._, A._)) .Returns(data); - var sut = new AppsBusinessLogic(_portalRepositories, null!, _offerService, null!, _fixture.Create>(), _identityService, _logger); + var sut = new AppsBusinessLogic(_portalRepositories, null!, _offerService, null!, _fixture.Create>(), _identityService); // Act var result = await sut.GetOwnCompanySubscribedAppOfferSubscriptionDataForUserAsync().ToListAsync(); diff --git a/tests/marketplace/Offer.Library.Web.Tests/OfferDocumentServiceTests.cs b/tests/marketplace/Offer.Library.Web.Tests/OfferDocumentServiceTests.cs index fbb3096432..f7ee1dfe16 100644 --- a/tests/marketplace/Offer.Library.Web.Tests/OfferDocumentServiceTests.cs +++ b/tests/marketplace/Offer.Library.Web.Tests/OfferDocumentServiceTests.cs @@ -19,7 +19,6 @@ using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Models; -using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Web; 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.Entities; @@ -28,7 +27,7 @@ using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared.Extensions; -namespace Offer.Library.Web.Tests; +namespace Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Web.Tests; public class OfferDocumentServiceTests { @@ -73,8 +72,8 @@ public async Task UploadDocumentAsync_WithValidData_CallsExpected(OfferTypeId of { // Arrange var uploadDocumentTypeIdSettings = offerTypeId == OfferTypeId.APP - ? new UploadDocumentConfig[] { new(DocumentTypeId.APP_CONTRACT, new[] { MediaTypeId.PDF }) } - : new UploadDocumentConfig[] { new(DocumentTypeId.ADDITIONAL_DETAILS, new[] { MediaTypeId.PDF }) }; + ? [new UploadDocumentConfig(DocumentTypeId.APP_CONTRACT, [MediaTypeId.PDF])] + : new UploadDocumentConfig[] { new(DocumentTypeId.ADDITIONAL_DETAILS, [MediaTypeId.PDF]) }; var documentId = _fixture.Create(); var file = FormFileHelper.GetFormFile("this is just a test", "superFile.pdf", "application/pdf"); var documents = new List(); @@ -92,10 +91,10 @@ public async Task UploadDocumentAsync_WithValidData_CallsExpected(OfferTypeId of var offerAssignedDocument = new OfferAssignedDocument(offerId, docId); offerAssignedDocuments.Add(offerAssignedDocument); }); - var existingOffer = _fixture.Create(); + var existingOffer = _fixture.Create(); existingOffer.DateLastChanged = DateTimeOffset.UtcNow; - A.CallTo(() => _offerRepository.AttachAndModifyOffer(_validAppId, A>._, A?>._)) - .Invokes((Guid _, Action setOptionalParameters, Action? initializeParemeters) => + A.CallTo(() => _offerRepository.AttachAndModifyOffer(_validAppId, A>._, A?>._)) + .Invokes((Guid _, Action setOptionalParameters, Action? initializeParemeters) => { initializeParemeters?.Invoke(existingOffer); setOptionalParameters(existingOffer); @@ -104,7 +103,7 @@ public async Task UploadDocumentAsync_WithValidData_CallsExpected(OfferTypeId of await _sut.UploadDocumentAsync(_validAppId, documentTypeId, file, offerTypeId, uploadDocumentTypeIdSettings, offerStatusId, CancellationToken.None); // Assert - A.CallTo(() => _offerRepository.AttachAndModifyOffer(_validAppId, A>._, A?>._)).MustHaveHappenedOnceExactly(); + A.CallTo(() => _offerRepository.AttachAndModifyOffer(_validAppId, A>._, A?>._)).MustHaveHappenedOnceExactly(); A.CallTo(() => _portalRepositories.SaveAsync()).MustHaveHappenedOnceExactly(); documents.Should().HaveCount(1); offerAssignedDocuments.Should().HaveCount(1); @@ -118,8 +117,8 @@ public async Task UploadDocumentAsync_InValidData_ThrowsNotFoundException(OfferT // Arrange var id = _fixture.Create(); var uploadDocumentTypeIdSettings = offerTypeId == OfferTypeId.APP - ? new UploadDocumentConfig[] { new(DocumentTypeId.APP_CONTRACT, new[] { MediaTypeId.PDF }) } - : new UploadDocumentConfig[] { new(DocumentTypeId.ADDITIONAL_DETAILS, new[] { MediaTypeId.PDF }) }; + ? [new(DocumentTypeId.APP_CONTRACT, [MediaTypeId.PDF])] + : new UploadDocumentConfig[] { new(DocumentTypeId.ADDITIONAL_DETAILS, [MediaTypeId.PDF]) }; var file = FormFileHelper.GetFormFile("this is just a test", "superFile.pdf", "application/pdf"); A.CallTo(() => _offerRepository.GetProviderCompanyUserIdForOfferUntrackedAsync(id, _identity.CompanyId, OfferStatusId.CREATED, offerTypeId)) .Returns<(bool, bool, bool)>(default); @@ -139,8 +138,8 @@ public async Task UploadDocumentAsync_EmptyId_ThrowsControllerArgumentException( { // Arrange var uploadDocumentTypeIdSettings = offerTypeId == OfferTypeId.APP - ? new UploadDocumentConfig[] { new(DocumentTypeId.APP_CONTRACT, new[] { MediaTypeId.PDF }) } - : new UploadDocumentConfig[] { new(DocumentTypeId.ADDITIONAL_DETAILS, new[] { MediaTypeId.PDF }) }; + ? new UploadDocumentConfig[] { new(DocumentTypeId.APP_CONTRACT, [MediaTypeId.PDF]) } + : [new(DocumentTypeId.ADDITIONAL_DETAILS, [MediaTypeId.PDF])]; var file = FormFileHelper.GetFormFile("this is just a test", "superFile.pdf", "application/pdf"); // Act @@ -159,8 +158,8 @@ public async Task UploadDocumentAsync_EmptyFileName_ThrowsControllerArgumentExce // Arrange var id = _fixture.Create(); var uploadDocumentTypeIdSettings = offerTypeId == OfferTypeId.APP - ? new UploadDocumentConfig[] { new(DocumentTypeId.APP_CONTRACT, new[] { MediaTypeId.PDF }) } - : new UploadDocumentConfig[] { new(DocumentTypeId.ADDITIONAL_DETAILS, new[] { MediaTypeId.PDF }) }; + ? new UploadDocumentConfig[] { new(DocumentTypeId.APP_CONTRACT, [MediaTypeId.PDF]) } + : [new(DocumentTypeId.ADDITIONAL_DETAILS, [MediaTypeId.PDF])]; var file = FormFileHelper.GetFormFile("this is just a test", "", "application/pdf"); // Act @@ -179,8 +178,8 @@ public async Task UploadDocumentAsync_contentType_ThrowsUnsupportedMediaTypeExce // Arrange var id = _fixture.Create(); var uploadDocumentTypeIdSettings = offerTypeId == OfferTypeId.APP - ? new UploadDocumentConfig[] { new(DocumentTypeId.APP_CONTRACT, new[] { MediaTypeId.PDF }) } - : new UploadDocumentConfig[] { new(DocumentTypeId.ADDITIONAL_DETAILS, new[] { MediaTypeId.PDF }) }; + ? new UploadDocumentConfig[] { new(DocumentTypeId.APP_CONTRACT, [MediaTypeId.PDF]) } + : [new(DocumentTypeId.ADDITIONAL_DETAILS, [MediaTypeId.PDF])]; var file = FormFileHelper.GetFormFile("this is just a test", "TestFile.txt", "image/svg+xml"); // Act @@ -199,8 +198,8 @@ public async Task UploadDocumentAsync_contentType_ThrowsUnsupportedMediaTypeExce // Arrange var id = _fixture.Create(); var uploadDocumentTypeIdSettings = offerTypeId == OfferTypeId.APP - ? new UploadDocumentConfig[] { new(DocumentTypeId.APP_CONTRACT, new[] { MediaTypeId.PDF }) } - : new UploadDocumentConfig[] { new(DocumentTypeId.ADDITIONAL_DETAILS, new[] { MediaTypeId.PDF }) }; + ? new UploadDocumentConfig[] { new(DocumentTypeId.APP_CONTRACT, [MediaTypeId.PDF]) } + : [new(DocumentTypeId.ADDITIONAL_DETAILS, [MediaTypeId.PDF])]; var file = FormFileHelper.GetFormFile("this is just a test", "TestFile.txt", "foo/bar"); // Act @@ -219,8 +218,8 @@ public async Task UploadDocumentAsync_documentType_ThrowsControllerArgumentExcep // Arrange var id = _fixture.Create(); var uploadDocumentTypeIdSettings = offerTypeId == OfferTypeId.APP - ? new UploadDocumentConfig[] { new(DocumentTypeId.APP_CONTRACT, new[] { MediaTypeId.PDF }) } - : new UploadDocumentConfig[] { new(DocumentTypeId.ADDITIONAL_DETAILS, new[] { MediaTypeId.PDF }) }; + ? new UploadDocumentConfig[] { new(DocumentTypeId.APP_CONTRACT, [MediaTypeId.PDF]) } + : [new(DocumentTypeId.ADDITIONAL_DETAILS, [MediaTypeId.PDF])]; var file = FormFileHelper.GetFormFile("this is just a test", "superFile.pdf", "application/pdf"); // Act @@ -242,8 +241,8 @@ public async Task UploadDocumentAsync_isStatusCreated_ThrowsConflictException(Of A.CallTo(() => _identity.IdentityId).Returns(Guid.NewGuid()); A.CallTo(() => _identity.CompanyId).Returns(companyId); var uploadDocumentTypeIdSettings = offerTypeId == OfferTypeId.APP - ? new UploadDocumentConfig[] { new(DocumentTypeId.APP_CONTRACT, new[] { MediaTypeId.PDF }) } - : new UploadDocumentConfig[] { new(DocumentTypeId.ADDITIONAL_DETAILS, new[] { MediaTypeId.PDF }) }; + ? new UploadDocumentConfig[] { new(DocumentTypeId.APP_CONTRACT, [MediaTypeId.PDF]) } + : [new(DocumentTypeId.ADDITIONAL_DETAILS, [MediaTypeId.PDF])]; var file = FormFileHelper.GetFormFile("this is just a test", "superFile.pdf", "application/pdf"); A.CallTo(() => _offerRepository.GetProviderCompanyUserIdForOfferUntrackedAsync(id, companyId, offerStatusId, offerTypeId)) .Returns((true, false, true)); diff --git a/tests/marketplace/Offers.Library.Tests/Service/ExtensionsTest.cs b/tests/marketplace/Offers.Library.Tests/Service/ExtensionsTest.cs new file mode 100644 index 0000000000..0c649e318e --- /dev/null +++ b/tests/marketplace/Offers.Library.Tests/Service/ExtensionsTest.cs @@ -0,0 +1,100 @@ +/******************************************************************************** + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; +using Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Extensions; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; + +namespace Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Tests; + +public class ExtensionsTest +{ + private readonly IFixture _fixture; + public ExtensionsTest() + { + _fixture = new Fixture().Customize(new AutoFakeItEasyCustomization { ConfigureMembers = true }); + _fixture.Behaviors.OfType().ToList() + .ForEach(b => _fixture.Behaviors.Remove(b)); + _fixture.Behaviors.Add(new OmitOnRecursionBehavior()); + } + + #region ProcessStepExtensions + + [Fact] + public void NoStep_ReturnsExpected() + { + var processSteps = Enumerable.Empty<(ProcessStepTypeId, ProcessStepStatusId)>(); + var offerId = Guid.NewGuid(); + + var result = processSteps.GetProcessStepTypeId(offerId); + + result.Should().BeNull(); + } + + [Fact] + public void NoToDoStep_ReturnsExpected() + { + var processStepTypeIds = _fixture.CreateMany(4); + var processStepStatusIds = new[] { ProcessStepStatusId.DONE, ProcessStepStatusId.DUPLICATE, ProcessStepStatusId.FAILED, ProcessStepStatusId.SKIPPED }; + var processSteps = processStepTypeIds.Zip(processStepStatusIds); + var offerId = Guid.NewGuid(); + + var result = processSteps.GetProcessStepTypeId(offerId); + + result.Should().BeNull(); + } + + [Fact] + public void SingleToDoStep_ReturnsExpected() + { + var processStepTypeId = _fixture.Create(); + var processSteps = new[] { (processStepTypeId, ProcessStepStatusId.TODO) }; + var offerId = Guid.NewGuid(); + + var result = processSteps.GetProcessStepTypeId(offerId); + + result.Should().Be(processStepTypeId); + } + + [Fact] + public void MultipleToDoSteps_SameType_ReturnsExpected() + { + var processStepTypeId = _fixture.Create(); + var processSteps = new[] { (processStepTypeId, ProcessStepStatusId.TODO), (processStepTypeId, ProcessStepStatusId.TODO) }; + var offerId = Guid.NewGuid(); + + var result = processSteps.GetProcessStepTypeId(offerId); + + result.Should().Be(processStepTypeId); + } + + [Fact] + public void MultipleToDoSteps_DifferentType_Throws() + { + var processStepTypeIds = _fixture.CreateMany(); + var processSteps = processStepTypeIds.Select(processStepTypeId => (processStepTypeId, ProcessStepStatusId.TODO)); + var offerId = Guid.NewGuid(); + + var result = Assert.Throws(() => processSteps.GetProcessStepTypeId(offerId)); + + result.Message.Should().Be($"Offers: {offerId} contains more than one process step in todo"); + } + + #endregion +} diff --git a/tests/marketplace/Offers.Library.Tests/Service/OfferServiceTests.cs b/tests/marketplace/Offers.Library.Tests/Service/OfferServiceTests.cs index 6a71983f01..7caecd9920 100644 --- a/tests/marketplace/Offers.Library.Tests/Service/OfferServiceTests.cs +++ b/tests/marketplace/Offers.Library.Tests/Service/OfferServiceTests.cs @@ -70,7 +70,6 @@ public class OfferServiceTests private readonly ITechnicalUserProfileRepository _technicalUserProfileRepository; private readonly IConnectorsRepository _connectorsRepository; private readonly IIdentityService _identityService; - private readonly ILogger _logger; public OfferServiceTests() { @@ -100,13 +99,12 @@ public OfferServiceTests() _connectorsRepository = A.Fake(); _identity = A.Fake(); _identityService = A.Fake(); - _logger = A.Fake>(); A.CallTo(() => _identity.IdentityId).Returns(_companyUserId); A.CallTo(() => _identity.IdentityTypeId).Returns(IdentityTypeId.COMPANY_USER); A.CallTo(() => _identity.CompanyId).Returns(_companyId); A.CallTo(() => _identityService.IdentityData).Returns(_identity); - _sut = new OfferService(_portalRepositories, _notificationService, _mailingProcessCreation, _identityService, _offerSetupService, _logger); + _sut = new OfferService(_portalRepositories, _notificationService, _mailingProcessCreation, _identityService, _offerSetupService); SetupRepositories(); _createNotificationsEnumerator = SetupServices(); @@ -766,7 +764,7 @@ public async Task SubmitOffer_WithInvalidPrivacyPolicies_ThrowsConflictException .Create(); A.CallTo(() => _offerRepository.GetOfferReleaseDataByIdAsync(A._, A._)).Returns(data); - var sut = new OfferService(_portalRepositories, null!, null!, _identityService, _offerSetupService, _logger); + var sut = new OfferService(_portalRepositories, null!, null!, _identityService, _offerSetupService); // Act async Task Act() => await sut.SubmitOfferAsync(Guid.NewGuid(), _fixture.Create(), _fixture.CreateMany(1), _fixture.CreateMany(), new[] { DocumentTypeId.CONFORMITY_APPROVAL_BUSINESS_APPS }); diff --git a/tests/marketplace/Services.Service.Tests/BusinessLogic/ServiceBusinessLogicTests.cs b/tests/marketplace/Services.Service.Tests/BusinessLogic/ServiceBusinessLogicTests.cs index 783e979371..8bb139cd82 100644 --- a/tests/marketplace/Services.Service.Tests/BusinessLogic/ServiceBusinessLogicTests.cs +++ b/tests/marketplace/Services.Service.Tests/BusinessLogic/ServiceBusinessLogicTests.cs @@ -21,7 +21,6 @@ using AutoFixture.AutoFakeItEasy; using FakeItEasy; using FluentAssertions; -using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; @@ -64,7 +63,6 @@ public class ServiceBusinessLogicTests private readonly IOfferSubscriptionService _offerSubscriptionService; private readonly IOfferService _offerService; private readonly IIdentityService _identityService; - private readonly ILogger _logger; public ServiceBusinessLogicTests() { @@ -92,7 +90,6 @@ public ServiceBusinessLogicTests() _offerService = A.Fake(); _identity = A.Fake(); _identityService = A.Fake(); - _logger = A.Fake>(); A.CallTo(() => _identity.IdentityId).Returns(Guid.NewGuid()); A.CallTo(() => _identity.IdentityTypeId).Returns(IdentityTypeId.COMPANY_USER); A.CallTo(() => _identity.CompanyId).Returns(Guid.NewGuid()); @@ -115,7 +112,6 @@ public ServiceBusinessLogicTests() }; var options = Options.Create(serviceSettings); _fixture.Inject(options); - _fixture.Inject(_logger); } #region Get Active Services @@ -169,7 +165,7 @@ public async Task AddServiceSubscription_ReturnsCorrectId() }, BasePortalAddress = "https://base-portal-address-test.de" }; - var sut = new ServiceBusinessLogic(null!, null!, _offerSubscriptionService, null!, _identityService, Options.Create(serviceSettings), _logger); + var sut = new ServiceBusinessLogic(null!, null!, _offerSubscriptionService, null!, _identityService, Options.Create(serviceSettings)); // Act var result = await sut.AddServiceSubscription(_existingServiceId, consentData); @@ -205,7 +201,7 @@ public async Task GetCompanyProvidedServiceSubscriptionStatusesForUserAsync_Retu { ApplicationsMaxPageSize = 15 }; - var sut = new ServiceBusinessLogic(_portalRepositories, null!, null!, null!, _identityService, Options.Create(serviceSettings), _logger); + var sut = new ServiceBusinessLogic(_portalRepositories, null!, null!, null!, _identityService, Options.Create(serviceSettings)); // Act var result = await sut.GetCompanyProvidedServiceSubscriptionStatusesForUserAsync(0, 10, null, null, offerId, null); @@ -239,7 +235,7 @@ public async Task GetCompanyProvidedServiceSubscriptionStatusesForUserAsync_Empt { ApplicationsMaxPageSize = 15 }; - var sut = new ServiceBusinessLogic(_portalRepositories, null!, null!, null!, _identityService, Options.Create(serviceSettings), _logger); + var sut = new ServiceBusinessLogic(_portalRepositories, null!, null!, null!, _identityService, Options.Create(serviceSettings)); // Act var result = await sut.GetCompanyProvidedServiceSubscriptionStatusesForUserAsync(0, 10, null, null, offerId, null); @@ -266,7 +262,7 @@ public async Task GetCompanyProvidedServiceSubscriptionStatusesForUserAsync_Quer { ApplicationsMaxPageSize = 15 }; - var sut = new ServiceBusinessLogic(_portalRepositories, null!, null!, null!, _identityService, Options.Create(serviceSettings), _logger); + var sut = new ServiceBusinessLogic(_portalRepositories, null!, null!, null!, _identityService, Options.Create(serviceSettings)); // Act var result = await sut.GetCompanyProvidedServiceSubscriptionStatusesForUserAsync(0, 10, null, null, offerId, null); @@ -327,7 +323,7 @@ public async Task GetServiceAgreement_WithUserId_ReturnsServiceDetailData() var data = _fixture.CreateMany(1); A.CallTo(() => offerService.GetOfferAgreementsAsync(_existingServiceId, A._)) .Returns(data.ToAsyncEnumerable()); - var sut = new ServiceBusinessLogic(null!, offerService, null!, null!, _identityService, Options.Create(new ServiceSettings()), _logger); + var sut = new ServiceBusinessLogic(null!, offerService, null!, null!, _identityService, Options.Create(new ServiceSettings())); // Act var result = await sut.GetServiceAgreement(_existingServiceId).ToListAsync(); @@ -380,7 +376,7 @@ public async Task GetServiceConsentDetailData_WithValidId_ReturnsServiceConsentD var offerService = A.Fake(); A.CallTo(() => offerService.GetConsentDetailDataAsync(_validConsentId, A._)) .Returns(data); - var sut = new ServiceBusinessLogic(null!, offerService, null!, null!, _identityService, Options.Create(new ServiceSettings()), _logger); + var sut = new ServiceBusinessLogic(null!, offerService, null!, null!, _identityService, Options.Create(new ServiceSettings())); // Act var result = await sut.GetServiceConsentDetailDataAsync(_validConsentId); @@ -398,7 +394,7 @@ public async Task GetServiceConsentDetailData_WithInValidId_ReturnsServiceConsen var invalidConsentId = Guid.NewGuid(); A.CallTo(() => offerService.GetConsentDetailDataAsync(A.That.Not.Matches(x => x == _validConsentId), A._)) .Throws(() => new NotFoundException("Test")); - var sut = new ServiceBusinessLogic(null!, offerService, null!, null!, _identityService, Options.Create(new ServiceSettings()), _logger); + var sut = new ServiceBusinessLogic(null!, offerService, null!, null!, _identityService, Options.Create(new ServiceSettings())); // Act async Task Action() => await sut.GetServiceConsentDetailDataAsync(invalidConsentId); @@ -426,7 +422,7 @@ public async Task AutoSetupService_ReturnsExcepted() .Returns(responseData); var data = new OfferAutoSetupData(Guid.NewGuid(), "https://www.offer.com"); var settings = _fixture.Create(); - var sut = new ServiceBusinessLogic(null!, null!, null!, offerSetupService, _identityService, Options.Create(settings), _logger); + var sut = new ServiceBusinessLogic(null!, null!, null!, offerSetupService, _identityService, Options.Create(settings)); // Act var result = await sut.AutoSetupServiceAsync(data); @@ -475,7 +471,7 @@ public async Task GetServiceDocumentContentAsync_ReturnsExpectedCalls() DocumentTypeId.SERVICE_LEADIMAGE } }; - var sut = new ServiceBusinessLogic(_portalRepositories, _offerService, null!, null!, _identityService, Options.Create(settings), _logger); + var sut = new ServiceBusinessLogic(_portalRepositories, _offerService, null!, null!, _identityService, Options.Create(settings)); // Act await sut.GetServiceDocumentContentAsync(serviceId, documentId, CancellationToken.None); @@ -537,7 +533,7 @@ public async Task GetSubscriptionDetailForProvider_WithNotMatchingUserRoles_Thro }; A.CallTo(() => _offerService.GetSubscriptionDetailsForProviderAsync(offerId, subscriptionId, OfferTypeId.SERVICE, A>._)) .Returns(data); - var sut = new ServiceBusinessLogic(null!, _offerService, null!, null!, _identityService, Options.Create(settings), _logger); + var sut = new ServiceBusinessLogic(null!, _offerService, null!, null!, _identityService, Options.Create(settings)); // Act var result = await sut.GetSubscriptionDetailForProvider(offerId, subscriptionId); @@ -567,7 +563,7 @@ public async Task GetSubscriptionDetailForSubscriber_WithNotMatchingUserRoles_Th A.CallTo(() => _offerService.GetSubscriptionDetailsForSubscriberAsync(A._, A._, OfferTypeId.SERVICE, A>._)) .Returns(data); - var sut = new ServiceBusinessLogic(null!, _offerService, null!, null!, _identityService, Options.Create(settings), _logger); + var sut = new ServiceBusinessLogic(null!, _offerService, null!, null!, _identityService, Options.Create(settings)); // Act var result = await sut.GetSubscriptionDetailForSubscriber(offerId, subscriptionId); @@ -591,7 +587,7 @@ public async Task GetCompanySubscribedServiceSubscriptionStatusesForUserAsync_Re A.CallTo(() => _offerService.GetCompanySubscribedOfferSubscriptionStatusesForUserAsync(A._, A._, A._, A._)) .Returns(paginationResponse); - var sut = new ServiceBusinessLogic(null!, _offerService, null!, null!, _identityService, Options.Create(new ServiceSettings()), _logger); + var sut = new ServiceBusinessLogic(null!, _offerService, null!, null!, _identityService, Options.Create(new ServiceSettings())); // Act var result = await sut.GetCompanySubscribedServiceSubscriptionStatusesForUserAsync(0, 10); @@ -611,7 +607,7 @@ public async Task GetCompanySubscribedServiceSubscriptionStatusesForUserAsync_Re public async Task UnsubscribeOwnCompanyAppSubscriptionAsync_ExpectedCall() { // Arrange - var sut = new ServiceBusinessLogic(null!, _offerService, null!, null!, _identityService, Options.Create(new ServiceSettings()), _logger); + var sut = new ServiceBusinessLogic(null!, _offerService, null!, null!, _identityService, Options.Create(new ServiceSettings())); // Act await sut.UnsubscribeOwnCompanyServiceSubscriptionAsync(_fixture.Create());