diff --git a/src/portalbackend/PortalBackend.DBAccess/Models/CompanyApplicationWithStatus.cs b/src/portalbackend/PortalBackend.DBAccess/Models/CompanyApplicationWithStatus.cs index cc190de13f..4729635f7d 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Models/CompanyApplicationWithStatus.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Models/CompanyApplicationWithStatus.cs @@ -25,6 +25,8 @@ namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models public class CompanyApplicationWithStatus { public Guid ApplicationId; - public CompanyApplicationStatusId? ApplicationStatus; //FIXME - this should not be nullable! + public CompanyApplicationStatusId ApplicationStatus; + public IEnumerable? ApplicationChecklistDatas; } + public record ApplicationChecklistData(ApplicationChecklistEntryTypeId TypeId, ApplicationChecklistEntryStatusId StatusId); } diff --git a/src/portalbackend/PortalBackend.DBAccess/Repositories/UserRepository.cs b/src/portalbackend/PortalBackend.DBAccess/Repositories/UserRepository.cs index 9fcb030f03..71af86d61a 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Repositories/UserRepository.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Repositories/UserRepository.cs @@ -50,7 +50,9 @@ public IAsyncEnumerable GetApplicationsWithStatusU .Select(companyApplication => new CompanyApplicationWithStatus { ApplicationId = companyApplication.Id, - ApplicationStatus = companyApplication.ApplicationStatusId + ApplicationStatus = companyApplication.ApplicationStatusId, + ApplicationChecklistDatas = companyApplication.ApplicationChecklistEntries.Select(ace => + new ApplicationChecklistData(ace.ApplicationChecklistEntryTypeId, ace.ApplicationChecklistEntryStatusId)) }) .AsAsyncEnumerable(); diff --git a/src/registration/Registration.Service/BusinessLogic/RegistrationBusinessLogic.cs b/src/registration/Registration.Service/BusinessLogic/RegistrationBusinessLogic.cs index 9eea69092c..05a9f6704c 100644 --- a/src/registration/Registration.Service/BusinessLogic/RegistrationBusinessLogic.cs +++ b/src/registration/Registration.Service/BusinessLogic/RegistrationBusinessLogic.cs @@ -201,7 +201,9 @@ public async IAsyncEnumerable GetAllApplicationsForUserW yield return new CompanyApplicationData { ApplicationId = applicationWithStatus.ApplicationId, - ApplicationStatus = applicationWithStatus.ApplicationStatus + ApplicationStatus = applicationWithStatus.ApplicationStatus, + ApplicationChecklist = applicationWithStatus.ApplicationChecklistDatas!.Select(acd => + new ApplicationChecklistDetails(acd.TypeId, acd.StatusId)) }; } } diff --git a/src/registration/Registration.Service/Model/CompanyApplicationData.cs b/src/registration/Registration.Service/Model/CompanyApplicationData.cs index d683d1f74a..fc4dbbcd72 100644 --- a/src/registration/Registration.Service/Model/CompanyApplicationData.cs +++ b/src/registration/Registration.Service/Model/CompanyApplicationData.cs @@ -27,4 +27,8 @@ public class CompanyApplicationData public Guid ApplicationId { get; set; } public CompanyApplicationStatusId? ApplicationStatus { get; set; } + + public IEnumerable? ApplicationChecklist { get; set; } } + +public record ApplicationChecklistDetails(ApplicationChecklistEntryTypeId TypeId, ApplicationChecklistEntryStatusId StatusId); diff --git a/tests/portalbackend/PortalBackend.DBAccess.Tests/UserRepositoryTests.cs b/tests/portalbackend/PortalBackend.DBAccess.Tests/UserRepositoryTests.cs index f1eab5104f..5f2ae54ddd 100644 --- a/tests/portalbackend/PortalBackend.DBAccess.Tests/UserRepositoryTests.cs +++ b/tests/portalbackend/PortalBackend.DBAccess.Tests/UserRepositoryTests.cs @@ -356,6 +356,31 @@ public async Task GetAllFavouriteAppsForUserUntrackedAsync_ReturnsExpected() #endregion + #region GetApplicationsWithStatus + + [Fact] + public async Task GetApplicationsWithStatusUntrackedAsync_ReturnsExpected() + { + // Arrange + var sut = await CreateSut().ConfigureAwait(false); + + // Act + var result = await sut.GetApplicationsWithStatusUntrackedAsync(new("41fd2ab8-71cd-4546-9bef-a388d91b2542")).ToListAsync().ConfigureAwait(false); + + // Assert + result.Should().NotBeNull().And.Satisfy(x => x.ApplicationId == new Guid("6b2d1263-c073-4a48-bfaf-704dc154ca9e") + && x.ApplicationStatus == CompanyApplicationStatusId.SUBMITTED); + result.Single().ApplicationChecklistDatas.Should().Satisfy( + y => y.TypeId == ApplicationChecklistEntryTypeId.APPLICATION_ACTIVATION && y.StatusId == ApplicationChecklistEntryStatusId.TO_DO, + y => y.TypeId == ApplicationChecklistEntryTypeId.BUSINESS_PARTNER_NUMBER && y.StatusId == ApplicationChecklistEntryStatusId.DONE, + y => y.TypeId == ApplicationChecklistEntryTypeId.CLEARING_HOUSE && y.StatusId == ApplicationChecklistEntryStatusId.TO_DO, + y => y.TypeId == ApplicationChecklistEntryTypeId.IDENTITY_WALLET && y.StatusId == ApplicationChecklistEntryStatusId.TO_DO, + y => y.TypeId == ApplicationChecklistEntryTypeId.REGISTRATION_VERIFICATION && y.StatusId == ApplicationChecklistEntryStatusId.DONE, + y => y.TypeId == ApplicationChecklistEntryTypeId.SELF_DESCRIPTION_LP && y.StatusId == ApplicationChecklistEntryStatusId.TO_DO); + } + + #endregion + private async Task CreateSut() { var context = await _dbTestDbFixture.GetPortalDbContext().ConfigureAwait(false); diff --git a/tests/registration/Registration.Service.Tests/BusinessLogic/RegistrationBusinessLogicTest.cs b/tests/registration/Registration.Service.Tests/BusinessLogic/RegistrationBusinessLogicTest.cs index f642d2b773..25aa799f33 100644 --- a/tests/registration/Registration.Service.Tests/BusinessLogic/RegistrationBusinessLogicTest.cs +++ b/tests/registration/Registration.Service.Tests/BusinessLogic/RegistrationBusinessLogicTest.cs @@ -294,7 +294,15 @@ public async Task GetAllApplicationsForUserWithStatus_WithValidUser_GetsAllRoles new() { ApplicationId = _fixture.Create(), - ApplicationStatus = CompanyApplicationStatusId.VERIFY + ApplicationStatus = CompanyApplicationStatusId.VERIFY, + ApplicationChecklistDatas = new[]{ + new ApplicationChecklistData(ApplicationChecklistEntryTypeId.APPLICATION_ACTIVATION, ApplicationChecklistEntryStatusId.DONE), + new ApplicationChecklistData(ApplicationChecklistEntryTypeId.BUSINESS_PARTNER_NUMBER, ApplicationChecklistEntryStatusId.DONE), + new ApplicationChecklistData(ApplicationChecklistEntryTypeId.CLEARING_HOUSE, ApplicationChecklistEntryStatusId.DONE), + new ApplicationChecklistData(ApplicationChecklistEntryTypeId.IDENTITY_WALLET, ApplicationChecklistEntryStatusId.IN_PROGRESS), + new ApplicationChecklistData(ApplicationChecklistEntryTypeId.REGISTRATION_VERIFICATION, ApplicationChecklistEntryStatusId.FAILED), + new ApplicationChecklistData(ApplicationChecklistEntryTypeId.SELF_DESCRIPTION_LP, ApplicationChecklistEntryStatusId.TO_DO) + } } }; A.CallTo(() => _userRepository.GetApplicationsWithStatusUntrackedAsync(userCompanyId)) @@ -304,6 +312,14 @@ public async Task GetAllApplicationsForUserWithStatus_WithValidUser_GetsAllRoles var result = await sut.GetAllApplicationsForUserWithStatus(identity.CompanyId).ToListAsync().ConfigureAwait(false); result.Should().ContainSingle(); result.Single().ApplicationStatus.Should().Be(CompanyApplicationStatusId.VERIFY); + result.Single().ApplicationChecklist.Should().NotBeNull().And.HaveCount(6).And.Satisfy( + X => X.TypeId == ApplicationChecklistEntryTypeId.APPLICATION_ACTIVATION && X.StatusId == ApplicationChecklistEntryStatusId.DONE, + X => X.TypeId == ApplicationChecklistEntryTypeId.BUSINESS_PARTNER_NUMBER && X.StatusId == ApplicationChecklistEntryStatusId.DONE, + X => X.TypeId == ApplicationChecklistEntryTypeId.CLEARING_HOUSE && X.StatusId == ApplicationChecklistEntryStatusId.DONE, + X => X.TypeId == ApplicationChecklistEntryTypeId.IDENTITY_WALLET && X.StatusId == ApplicationChecklistEntryStatusId.IN_PROGRESS, + X => X.TypeId == ApplicationChecklistEntryTypeId.REGISTRATION_VERIFICATION && X.StatusId == ApplicationChecklistEntryStatusId.FAILED, + X => X.TypeId == ApplicationChecklistEntryTypeId.SELF_DESCRIPTION_LP && X.StatusId == ApplicationChecklistEntryStatusId.TO_DO + ); } #endregion