Skip to content

Commit

Permalink
feat(app&Service) : added processStepTypeId to provided endpoints (#297)
Browse files Browse the repository at this point in the history
add processStepTypeId to /api/Apps/provided/subscription-status
add processStepTypeId to /api/services/provided/subscription-status

------------

Refs: CPLP-3251
Reviewed-By: Phil Schneider <[email protected]>
  • Loading branch information
VPrasannaK94 authored Oct 13, 2023
1 parent 6c8976c commit 803d9f9
Show file tree
Hide file tree
Showing 12 changed files with 156 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ public async Task AddFavouriteAppForUserAsync(Guid appId)
item.OfferId,
item.ServiceName,
item.CompanySubscriptionStatuses,
item.Image == Guid.Empty ? null : item.Image)));
item.Image == Guid.Empty ? null : item.Image,
item.ProcessStepTypeId == default ? null : item.ProcessStepTypeId)));
}
return await Pagination.CreateResponseAsync(page, size, _settings.ApplicationsMaxPageSize, GetCompanyProvidedAppSubscriptionStatusData).ConfigureAwait(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
********************************************************************************/

using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;

namespace Org.Eclipse.TractusX.Portal.Backend.Offers.Library.Models;

Expand All @@ -34,5 +35,6 @@ public record OfferCompanySubscriptionStatusResponse(
Guid OfferId,
string? OfferName,
IEnumerable<CompanySubscriptionStatusData> CompanySubscriptionStatuses,
Guid? Image
Guid? Image,
ProcessStepTypeId? ProcessStepTypeId
);
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ public Task<OfferAutoSetupResponseData> AutoSetupServiceAsync(OfferAutoSetupData
item.OfferId,
item.ServiceName,
item.CompanySubscriptionStatuses,
item.Image == Guid.Empty ? null : item.Image)));
item.Image == Guid.Empty ? null : item.Image,
item.ProcessStepTypeId == default ? null : item.ProcessStepTypeId)));
}
return await Pagination.CreateResponseAsync(page, size, _settings.ApplicationsMaxPageSize, GetCompanyProvidedAppSubscriptionStatusData).ConfigureAwait(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;

namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;

/// <summary>
Expand Down Expand Up @@ -53,4 +55,10 @@ public OfferCompanySubscriptionStatusData()
/// </summary>
/// <value></value>
public Guid Image { get; set; }

/// <summary>
/// Id of the ProcessStep Type
/// </summary>
/// <value></value>
public ProcessStepTypeId ProcessStepTypeId { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public record AppProviderSubscriptionDetailData(
IEnumerable<string> Contact,
IEnumerable<SubscriptionTechnicalUserData> TechnicalUserData,
string? TenantUrl,
string AppInstanceId
string AppInstanceId,
ProcessStepTypeId? ProcessStepTypeId
);

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@ public OfferSubscription CreateOfferSubscription(Guid offerId, Guid companyId, O
Image = g.Documents
.Where(document => document.DocumentTypeId == DocumentTypeId.APP_LEADIMAGE && document.DocumentStatusId == DocumentStatusId.LOCKED)
.Select(document => document.Id)
.FirstOrDefault()
.FirstOrDefault(),
ProcessStepTypeId = g.OfferSubscriptions
.Where(os => os.ProcessId != null)
.Select(os => os.Process!.ProcessSteps
.OrderByDescending(ps => ps.DateCreated)
.Select(ps => ps.ProcessStepTypeId).FirstOrDefault()).FirstOrDefault()
})
.SingleOrDefaultAsync();

Expand Down Expand Up @@ -244,7 +249,9 @@ public OfferSubscription AttachAndModifyOfferSubscription(Guid offerSubscription
x.Company.Identities.Where(i => i.IdentityTypeId == IdentityTypeId.COMPANY_USER).Select(id => id.CompanyUser!).Where(cu => cu.Email != null && cu.Identity!.IdentityAssignedRoles.Select(ur => ur.UserRole!).Any(ur => userRoleIds.Contains(ur.Id))).Select(cu => cu.Email!),
x.Subscription.CompanyServiceAccounts.Select(sa => new SubscriptionTechnicalUserData(sa.Id, sa.Name, sa.Identity!.IdentityAssignedRoles.Select(ur => ur.UserRole!).Select(ur => ur.UserRoleText))),
x.Subscription.AppSubscriptionDetail!.AppSubscriptionUrl,
x.Subscription.AppSubscriptionDetail!.AppInstance!.IamClient!.ClientClientId)
x.Subscription.AppSubscriptionDetail!.AppInstance!.IamClient!.ClientClientId,
x.Subscription.Process!.ProcessSteps.Any() ?
x.Subscription.Process!.ProcessSteps.OrderByDescending(ps => ps.DateCreated).Select(ps => ps.ProcessStepTypeId).FirstOrDefault() : null)
: null))
.SingleOrDefaultAsync();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,11 @@ public async Task GetCompanyProvidedAppSubscriptionStatusesForUserAsync_ReturnsE
// Assert
result.Meta.NumberOfElements.Should().Be(5);
result.Content.Should().HaveCount(5).And.Satisfy(
x => x.OfferId == data[0].OfferId && x.OfferName == data[0].ServiceName && x.CompanySubscriptionStatuses.SequenceEqual(data[0].CompanySubscriptionStatuses) && x.Image == data[0].Image,
x => x.OfferId == data[1].OfferId && x.OfferName == data[1].ServiceName && x.CompanySubscriptionStatuses.SequenceEqual(data[1].CompanySubscriptionStatuses) && x.Image == data[1].Image,
x => x.OfferId == data[2].OfferId && x.OfferName == data[2].ServiceName && x.CompanySubscriptionStatuses.SequenceEqual(data[2].CompanySubscriptionStatuses) && x.Image == data[2].Image,
x => x.OfferId == data[3].OfferId && x.OfferName == data[3].ServiceName && x.CompanySubscriptionStatuses.SequenceEqual(data[3].CompanySubscriptionStatuses) && x.Image == data[3].Image,
x => x.OfferId == data[4].OfferId && x.OfferName == data[4].ServiceName && x.CompanySubscriptionStatuses.SequenceEqual(data[4].CompanySubscriptionStatuses) && x.Image == data[4].Image
x => x.OfferId == data[0].OfferId && x.OfferName == data[0].ServiceName && x.CompanySubscriptionStatuses.SequenceEqual(data[0].CompanySubscriptionStatuses) && x.Image == data[0].Image && x.ProcessStepTypeId == data[0].ProcessStepTypeId,
x => x.OfferId == data[1].OfferId && x.OfferName == data[1].ServiceName && x.CompanySubscriptionStatuses.SequenceEqual(data[1].CompanySubscriptionStatuses) && x.Image == data[1].Image && x.ProcessStepTypeId == data[1].ProcessStepTypeId,
x => x.OfferId == data[2].OfferId && x.OfferName == data[2].ServiceName && x.CompanySubscriptionStatuses.SequenceEqual(data[2].CompanySubscriptionStatuses) && x.Image == data[2].Image && x.ProcessStepTypeId == data[2].ProcessStepTypeId,
x => x.OfferId == data[3].OfferId && x.OfferName == data[3].ServiceName && x.CompanySubscriptionStatuses.SequenceEqual(data[3].CompanySubscriptionStatuses) && x.Image == data[3].Image && x.ProcessStepTypeId == data[3].ProcessStepTypeId,
x => x.OfferId == data[4].OfferId && x.OfferName == data[4].ServiceName && x.CompanySubscriptionStatuses.SequenceEqual(data[4].CompanySubscriptionStatuses) && x.Image == data[4].Image && x.ProcessStepTypeId == data[4].ProcessStepTypeId
);
A.CallTo(() => _offerSubscriptionRepository.GetOwnCompanyProvidedOfferSubscriptionStatusesUntrackedAsync(_identity.CompanyId, OfferTypeId.APP, default, A<IEnumerable<OfferSubscriptionStatusId>>.That.IsSameSequenceAs(new[] { OfferSubscriptionStatusId.PENDING, OfferSubscriptionStatusId.ACTIVE, OfferSubscriptionStatusId.INACTIVE }), offerId))
.MustHaveHappenedOnceExactly();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,11 @@ public async Task GetCompanyProvidedServiceSubscriptionStatusesForUserAsync_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].ServiceName && x.CompanySubscriptionStatuses.SequenceEqual(data[0].CompanySubscriptionStatuses) && x.Image == data[0].Image,
x => x.OfferId == data[1].OfferId && x.OfferName == data[1].ServiceName && x.CompanySubscriptionStatuses.SequenceEqual(data[1].CompanySubscriptionStatuses) && x.Image == data[1].Image,
x => x.OfferId == data[2].OfferId && x.OfferName == data[2].ServiceName && x.CompanySubscriptionStatuses.SequenceEqual(data[2].CompanySubscriptionStatuses) && x.Image == data[2].Image,
x => x.OfferId == data[3].OfferId && x.OfferName == data[3].ServiceName && x.CompanySubscriptionStatuses.SequenceEqual(data[3].CompanySubscriptionStatuses) && x.Image == data[3].Image,
x => x.OfferId == data[4].OfferId && x.OfferName == data[4].ServiceName && x.CompanySubscriptionStatuses.SequenceEqual(data[4].CompanySubscriptionStatuses) && x.Image == data[4].Image
x => x.OfferId == data[0].OfferId && x.OfferName == data[0].ServiceName && x.CompanySubscriptionStatuses.SequenceEqual(data[0].CompanySubscriptionStatuses) && x.Image == data[0].Image && x.ProcessStepTypeId == data[0].ProcessStepTypeId,
x => x.OfferId == data[1].OfferId && x.OfferName == data[1].ServiceName && x.CompanySubscriptionStatuses.SequenceEqual(data[1].CompanySubscriptionStatuses) && x.Image == data[1].Image && x.ProcessStepTypeId == data[1].ProcessStepTypeId,
x => x.OfferId == data[2].OfferId && x.OfferName == data[2].ServiceName && x.CompanySubscriptionStatuses.SequenceEqual(data[2].CompanySubscriptionStatuses) && x.Image == data[2].Image && x.ProcessStepTypeId == data[2].ProcessStepTypeId,
x => x.OfferId == data[3].OfferId && x.OfferName == data[3].ServiceName && x.CompanySubscriptionStatuses.SequenceEqual(data[3].CompanySubscriptionStatuses) && x.Image == data[3].Image && x.ProcessStepTypeId == data[3].ProcessStepTypeId,
x => x.OfferId == data[4].OfferId && x.OfferName == data[4].ServiceName && x.CompanySubscriptionStatuses.SequenceEqual(data[4].CompanySubscriptionStatuses) && x.Image == data[4].Image && x.ProcessStepTypeId == data[4].ProcessStepTypeId
);
A.CallTo(() => _offerSubscriptionsRepository.GetOwnCompanyProvidedOfferSubscriptionStatusesUntrackedAsync(_identity.CompanyId, OfferTypeId.SERVICE, null, A<IEnumerable<OfferSubscriptionStatusId>>.That.IsSameSequenceAs(new[] { OfferSubscriptionStatusId.PENDING, OfferSubscriptionStatusId.ACTIVE, OfferSubscriptionStatusId.INACTIVE }), offerId))
.MustHaveHappenedOnceExactly();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,19 +136,19 @@ public async Task GetAllBusinessAppDataForUserIdAsync_WithValidUser_ReturnsExpec
#region GetOwnCompanyProvidedOfferSubscriptionStatusesUntracked

[Theory]
[InlineData(SubscriptionStatusSorting.OfferIdAsc, null, OfferTypeId.SERVICE, new[] { OfferSubscriptionStatusId.ACTIVE }, 2, true)]
[InlineData(SubscriptionStatusSorting.OfferIdAsc, null, OfferTypeId.SERVICE, new OfferSubscriptionStatusId[] { }, 0, false)]
[InlineData(SubscriptionStatusSorting.OfferIdDesc, null, OfferTypeId.SERVICE, new[] { OfferSubscriptionStatusId.ACTIVE }, 2, false)]
[InlineData(SubscriptionStatusSorting.CompanyNameAsc, null, OfferTypeId.SERVICE, new[] { OfferSubscriptionStatusId.ACTIVE }, 2, true)]
[InlineData(SubscriptionStatusSorting.CompanyNameDesc, null, OfferTypeId.SERVICE, new[] { OfferSubscriptionStatusId.ACTIVE }, 2, true)]
[InlineData(SubscriptionStatusSorting.OfferIdAsc, "a16e73b9-5277-4b69-9f8d-3b227495dfea", OfferTypeId.SERVICE, new[] { OfferSubscriptionStatusId.ACTIVE }, 1, false)]
[InlineData(SubscriptionStatusSorting.OfferIdAsc, "a16e73b9-5277-4b69-9f8d-3b227495dfae", OfferTypeId.SERVICE, new[] { OfferSubscriptionStatusId.ACTIVE }, 1, true)]
[InlineData(SubscriptionStatusSorting.OfferIdAsc, "deadbeef-dead-beef-dead-beefdeadbeef", OfferTypeId.SERVICE, new[] { OfferSubscriptionStatusId.ACTIVE }, 0, false)]
[InlineData(SubscriptionStatusSorting.OfferIdAsc, null, OfferTypeId.APP, new[] { OfferSubscriptionStatusId.ACTIVE }, 1, false)]
[InlineData(SubscriptionStatusSorting.OfferIdAsc, null, OfferTypeId.APP, new[] { OfferSubscriptionStatusId.INACTIVE }, 1, false)]
[InlineData(SubscriptionStatusSorting.OfferIdAsc, null, OfferTypeId.APP, new[] { OfferSubscriptionStatusId.PENDING }, 1, false)]
[InlineData(SubscriptionStatusSorting.OfferIdAsc, null, OfferTypeId.APP, new[] { OfferSubscriptionStatusId.PENDING, OfferSubscriptionStatusId.ACTIVE }, 2, false)]
public async Task GetOwnCompanyProvidedOfferSubscriptionStatusesUntrackedAsync_ReturnsExpectedNotificationDetailData(SubscriptionStatusSorting sorting, string? offerIdTxt, OfferTypeId offerTypeId, IEnumerable<OfferSubscriptionStatusId> offerSubscriptionStatusIds, int count, bool technicalUser)
[InlineData(SubscriptionStatusSorting.OfferIdAsc, null, OfferTypeId.SERVICE, new[] { OfferSubscriptionStatusId.ACTIVE }, 2, true, ProcessStepTypeId.SINGLE_INSTANCE_SUBSCRIPTION_DETAILS_CREATION)]
[InlineData(SubscriptionStatusSorting.OfferIdAsc, null, OfferTypeId.SERVICE, new OfferSubscriptionStatusId[] { }, 0, false, null)]
[InlineData(SubscriptionStatusSorting.OfferIdDesc, null, OfferTypeId.SERVICE, new[] { OfferSubscriptionStatusId.ACTIVE }, 2, false, ProcessStepTypeId.ACTIVATE_SUBSCRIPTION)]
[InlineData(SubscriptionStatusSorting.CompanyNameAsc, null, OfferTypeId.SERVICE, new[] { OfferSubscriptionStatusId.ACTIVE }, 2, true, ProcessStepTypeId.SINGLE_INSTANCE_SUBSCRIPTION_DETAILS_CREATION)]
[InlineData(SubscriptionStatusSorting.CompanyNameDesc, null, OfferTypeId.SERVICE, new[] { OfferSubscriptionStatusId.ACTIVE }, 2, true, ProcessStepTypeId.SINGLE_INSTANCE_SUBSCRIPTION_DETAILS_CREATION)]
[InlineData(SubscriptionStatusSorting.OfferIdAsc, "a16e73b9-5277-4b69-9f8d-3b227495dfea", OfferTypeId.SERVICE, new[] { OfferSubscriptionStatusId.ACTIVE }, 1, false, ProcessStepTypeId.ACTIVATE_SUBSCRIPTION)]
[InlineData(SubscriptionStatusSorting.OfferIdAsc, "a16e73b9-5277-4b69-9f8d-3b227495dfae", OfferTypeId.SERVICE, new[] { OfferSubscriptionStatusId.ACTIVE }, 1, true, ProcessStepTypeId.SINGLE_INSTANCE_SUBSCRIPTION_DETAILS_CREATION)]
[InlineData(SubscriptionStatusSorting.OfferIdAsc, "deadbeef-dead-beef-dead-beefdeadbeef", OfferTypeId.SERVICE, new[] { OfferSubscriptionStatusId.ACTIVE }, 0, false, null)]
[InlineData(SubscriptionStatusSorting.OfferIdAsc, null, OfferTypeId.APP, new[] { OfferSubscriptionStatusId.ACTIVE }, 1, false, ProcessStepTypeId.RETRIGGER_PROVIDER)]
[InlineData(SubscriptionStatusSorting.OfferIdAsc, null, OfferTypeId.APP, new[] { OfferSubscriptionStatusId.INACTIVE }, 1, false, ProcessStepTypeId.START_AUTOSETUP)]
[InlineData(SubscriptionStatusSorting.OfferIdAsc, null, OfferTypeId.APP, new[] { OfferSubscriptionStatusId.PENDING }, 1, false, ProcessStepTypeId.TRIGGER_PROVIDER_CALLBACK)]
[InlineData(SubscriptionStatusSorting.OfferIdAsc, null, OfferTypeId.APP, new[] { OfferSubscriptionStatusId.PENDING, OfferSubscriptionStatusId.ACTIVE }, 2, false, ProcessStepTypeId.RETRIGGER_PROVIDER)]
public async Task GetOwnCompanyProvidedOfferSubscriptionStatusesUntrackedAsync_ReturnsExpectedNotificationDetailData(SubscriptionStatusSorting sorting, string? offerIdTxt, OfferTypeId offerTypeId, IEnumerable<OfferSubscriptionStatusId> offerSubscriptionStatusIds, int count, bool technicalUser, ProcessStepTypeId? processStepTypeId)
{
// Arrange
Guid? offerId = offerIdTxt == null ? null : new Guid(offerIdTxt);
Expand All @@ -165,6 +165,7 @@ public async Task GetOwnCompanyProvidedOfferSubscriptionStatusesUntrackedAsync_R
results.Data.Should().HaveCount(count);
results.Data.Should().AllBeOfType<OfferCompanySubscriptionStatusData>().Which.First().CompanySubscriptionStatuses.Should().HaveCount(1);
results.Data.Should().AllBeOfType<OfferCompanySubscriptionStatusData>().Which.First().CompanySubscriptionStatuses.Should().Match(x => x.Count() == 1 && x.First().TechnicalUser == technicalUser);
results.Data.Should().AllBeOfType<OfferCompanySubscriptionStatusData>().Which.First().ProcessStepTypeId.Should().Match(x => x == processStepTypeId);
}
else
{
Expand Down Expand Up @@ -297,7 +298,8 @@ public async Task GetAppSubscriptionDetailForProviderAsync_ReturnsExpected()
x.Contact.SequenceEqual(new[] { "[email protected]" }) &&
x.OfferSubscriptionStatus == OfferSubscriptionStatusId.ACTIVE &&
x.TenantUrl == "https://ec-qas.d13fe27.kyma.ondemand.com" &&
x.AppInstanceId == "https://catenax-int-dismantler-s66pftcc.authentication.eu10.hana.ondemand.com");
x.AppInstanceId == "https://catenax-int-dismantler-s66pftcc.authentication.eu10.hana.ondemand.com" &&
x.ProcessStepTypeId == ProcessStepTypeId.ACTIVATE_SUBSCRIPTION);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"id": "3DE6A31F-A5D1-4F60-AA3A-4B1A769BECBF",
"last_editor_id": null,
"display_name": null,
"description": null
"description": null,
"process_id": "0cc208c3-bdf6-456c-af81-6c3ebe14fe09"
},
{
"company_id": "2dc4249f-b5ca-4d42-bef1-7a7a950a4f87",
Expand All @@ -37,7 +38,8 @@
"id": "e80b5f5c-3a16-480b-b82e-1cc06a71fddc",
"last_editor_id": null,
"display_name": null,
"description": null
"description": null,
"process_id": "0cc208c3-bdf6-456c-af81-6c3ebe14fe10"
},
{
"company_id": "2dc4249f-b5ca-4d42-bef1-7a7a950a4f87",
Expand All @@ -58,7 +60,8 @@
"id": "81a8211d-6261-4969-8123-a420364ae997",
"last_editor_id": null,
"display_name": null,
"description": null
"description": null,
"process_id": "0cc208c3-bdf6-456c-af81-6c3ebe14fe11"
},
{
"company_id": "ac861325-bc54-4583-bcdc-9e9f2a38ff84",
Expand All @@ -68,7 +71,8 @@
"id": "783eb74f-0fe4-4652-a97e-913141539cf3",
"last_editor_id": null,
"display_name": null,
"description": null
"description": null,
"process_id": "0cc208c3-bdf6-456c-af81-6c3ebe14fe12"
},
{
"company_id": "ac861325-bc54-4583-bcdc-9e9f2a38ff84",
Expand All @@ -78,7 +82,8 @@
"id": "d395798b-07df-48b6-8e18-fb0f1f23c3ca",
"last_editor_id": null,
"display_name": null,
"description": null
"description": null,
"process_id": "0cc208c3-bdf6-456c-af81-6c3ebe14fe13"
},
{
"company_id": "41fd2ab8-71cd-4546-9bef-a388d91b2542",
Expand Down
Loading

0 comments on commit 803d9f9

Please sign in to comment.