From eb7eb649c236dd6998d02d7c5131caaf06b1b085 Mon Sep 17 00:00:00 2001 From: VPrasannaK94 <117351802+VPrasannaK94@users.noreply.github.com> Date: Fri, 25 Aug 2023 12:34:21 +0530 Subject: [PATCH] feat(app& service): extend subscriptionStatus endpoint (#234) add subscription id to subscriptionStatus endpoint --------- Refs: CPLP3178 Reviewed-By: Phil Schneider --- .../Models/OfferSubscriptionStatusDetailData.cs | 1 + src/marketplace/Offers.Library/Service/OfferService.cs | 1 + .../Models/OfferSubscriptionStatusData.cs | 1 + .../Repositories/OfferSubscriptionsRepository.cs | 1 + .../Offers.Library.Tests/Service/OfferServiceTests.cs | 10 +++++----- .../OfferSubscriptionRepositoryTest.cs | 4 ++++ 6 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/marketplace/Offers.Library/Models/OfferSubscriptionStatusDetailData.cs b/src/marketplace/Offers.Library/Models/OfferSubscriptionStatusDetailData.cs index 911a3a1fd3..f34a25dba2 100644 --- a/src/marketplace/Offers.Library/Models/OfferSubscriptionStatusDetailData.cs +++ b/src/marketplace/Offers.Library/Models/OfferSubscriptionStatusDetailData.cs @@ -28,4 +28,5 @@ public record OfferSubscriptionStatusDetailData( [property: JsonPropertyName("name")] string? OfferName, [property: JsonPropertyName("provider")] string Provider, [property: JsonPropertyName("status")] OfferSubscriptionStatusId OfferSubscriptionStatusId, + [property: JsonPropertyName("subscriptionId")] Guid OfferSubscriptionId, [property: JsonPropertyName("image")] Guid? DocumentId); diff --git a/src/marketplace/Offers.Library/Service/OfferService.cs b/src/marketplace/Offers.Library/Service/OfferService.cs index 928481659a..e5c791067b 100644 --- a/src/marketplace/Offers.Library/Service/OfferService.cs +++ b/src/marketplace/Offers.Library/Service/OfferService.cs @@ -869,6 +869,7 @@ private async Task> ValidateRoleData(IEnumerable document.DocumentTypeId == documentTypeId && diff --git a/tests/marketplace/Offers.Library.Tests/Service/OfferServiceTests.cs b/tests/marketplace/Offers.Library.Tests/Service/OfferServiceTests.cs index 4185341bbd..979e6121b2 100644 --- a/tests/marketplace/Offers.Library.Tests/Service/OfferServiceTests.cs +++ b/tests/marketplace/Offers.Library.Tests/Service/OfferServiceTests.cs @@ -2415,11 +2415,11 @@ public async Task GetCompanySubscribedOfferSubscriptionStatusesForUserAsync_Retu // Assert result.Meta.NumberOfElements.Should().Be(5); result.Content.Should().HaveCount(5).And.Satisfy( - x => x.OfferId == data[0].OfferId && x.OfferName == data[0].OfferName && x.Provider == data[0].Provider && x.OfferSubscriptionStatusId == data[0].OfferSubscriptionStatusId && x.DocumentId == data[0].DocumentId, - x => x.OfferId == data[1].OfferId && x.OfferName == data[1].OfferName && x.Provider == data[1].Provider && x.OfferSubscriptionStatusId == data[1].OfferSubscriptionStatusId && x.DocumentId == data[1].DocumentId, - x => x.OfferId == data[2].OfferId && x.OfferName == data[2].OfferName && x.Provider == data[2].Provider && x.OfferSubscriptionStatusId == data[2].OfferSubscriptionStatusId && x.DocumentId == data[2].DocumentId, - x => x.OfferId == data[3].OfferId && x.OfferName == data[3].OfferName && x.Provider == data[3].Provider && x.OfferSubscriptionStatusId == data[3].OfferSubscriptionStatusId && x.DocumentId == data[3].DocumentId, - x => x.OfferId == data[4].OfferId && x.OfferName == data[4].OfferName && x.Provider == data[4].Provider && x.OfferSubscriptionStatusId == data[4].OfferSubscriptionStatusId && x.DocumentId == data[4].DocumentId + x => x.OfferId == data[0].OfferId && x.OfferName == data[0].OfferName && x.Provider == data[0].Provider && x.OfferSubscriptionStatusId == data[0].OfferSubscriptionStatusId && x.OfferSubscriptionId == data[0].OfferSubscriptionId && x.DocumentId == data[0].DocumentId, + x => x.OfferId == data[1].OfferId && x.OfferName == data[1].OfferName && x.Provider == data[1].Provider && x.OfferSubscriptionStatusId == data[1].OfferSubscriptionStatusId && x.OfferSubscriptionId == data[1].OfferSubscriptionId && x.DocumentId == data[1].DocumentId, + x => x.OfferId == data[2].OfferId && x.OfferName == data[2].OfferName && x.Provider == data[2].Provider && x.OfferSubscriptionStatusId == data[2].OfferSubscriptionStatusId && x.OfferSubscriptionId == data[2].OfferSubscriptionId && x.DocumentId == data[2].DocumentId, + x => x.OfferId == data[3].OfferId && x.OfferName == data[3].OfferName && x.Provider == data[3].Provider && x.OfferSubscriptionStatusId == data[3].OfferSubscriptionStatusId && x.OfferSubscriptionId == data[3].OfferSubscriptionId && x.DocumentId == data[3].DocumentId, + x => x.OfferId == data[4].OfferId && x.OfferName == data[4].OfferName && x.Provider == data[4].Provider && x.OfferSubscriptionStatusId == data[4].OfferSubscriptionStatusId && x.OfferSubscriptionId == data[4].OfferSubscriptionId && x.DocumentId == data[4].DocumentId ); A.CallTo(() => _offerSubscriptionsRepository.GetOwnCompanySubscribedOfferSubscriptionStatusesUntrackedAsync(_identity.CompanyId, offerTypeId, documentTypeId)) .MustHaveHappenedOnceExactly(); diff --git a/tests/portalbackend/PortalBackend.DBAccess.Tests/OfferSubscriptionRepositoryTest.cs b/tests/portalbackend/PortalBackend.DBAccess.Tests/OfferSubscriptionRepositoryTest.cs index 901ce426d6..98a3bcce7c 100644 --- a/tests/portalbackend/PortalBackend.DBAccess.Tests/OfferSubscriptionRepositoryTest.cs +++ b/tests/portalbackend/PortalBackend.DBAccess.Tests/OfferSubscriptionRepositoryTest.cs @@ -812,11 +812,13 @@ public async Task GetOwnCompanySubscribedOfferSubscriptionStatusesUntrackedAsync x.OfferSubscriptionStatusId == OfferSubscriptionStatusId.ACTIVE && x.OfferName == "Trace-X" && x.Provider == "Catena-X" && + x.OfferSubscriptionId == new Guid("ed4de48d-fd4b-4384-a72f-ecae3c6cc5ba") && x.DocumentId == new Guid("e020787d-1e04-4c0b-9c06-bd1cd44724b1"), x => x.OfferId == new Guid("ac1cf001-7fbc-1f2f-817f-bce0572c0007") && x.OfferSubscriptionStatusId == OfferSubscriptionStatusId.PENDING && x.OfferName == "Trace-X" && x.Provider == "Catena-X" && + x.OfferSubscriptionId == new Guid("e8886159-9258-44a5-88d8-f5735a197a09") && x.DocumentId == new Guid("e020787d-1e04-4c0b-9c06-bd1cd44724b1") ); break; @@ -828,11 +830,13 @@ public async Task GetOwnCompanySubscribedOfferSubscriptionStatusesUntrackedAsync x.OfferSubscriptionStatusId == OfferSubscriptionStatusId.ACTIVE && x.OfferName == "SDE with EDC" && x.Provider == "Service Provider" && + x.OfferSubscriptionId == new Guid("3de6a31f-a5d1-4f60-aa3a-4b1a769becbf") && x.DocumentId == Guid.Empty, x => x.OfferId == new Guid("a16e73b9-5277-4b69-9f8d-3b227495dfae") && x.OfferSubscriptionStatusId == OfferSubscriptionStatusId.ACTIVE && x.OfferName == "Service Test 123" && x.Provider == "Service Provider" && + x.OfferSubscriptionId == new Guid("e80b5f5c-3a16-480b-b82e-1cc06a71fddc") && x.DocumentId == Guid.Empty ); break;