Skip to content

Commit

Permalink
feat(registration) : added applicationChecklist
Browse files Browse the repository at this point in the history
typeId and StatusId

Ref: CPLP-3028
  • Loading branch information
VPrasannaK94 committed Aug 2, 2023
1 parent f2546d9 commit 3957eaf
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ApplicationChecklistData>? ApplicationChecklistDatas;
}
public record ApplicationChecklistData(ApplicationChecklistEntryTypeId TypeId, ApplicationChecklistEntryStatusId StatusId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ public IAsyncEnumerable<CompanyApplicationWithStatus> 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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ public async IAsyncEnumerable<CompanyApplicationData> 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))
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ public class CompanyApplicationData
public Guid ApplicationId { get; set; }

public CompanyApplicationStatusId? ApplicationStatus { get; set; }

public IEnumerable<ApplicationChecklistDetails>? ApplicationChecklist { get; set; }
}

public record ApplicationChecklistDetails(ApplicationChecklistEntryTypeId TypeId, ApplicationChecklistEntryStatusId StatusId);
Original file line number Diff line number Diff line change
Expand Up @@ -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<UserRepository> CreateSut()
{
var context = await _dbTestDbFixture.GetPortalDbContext().ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,15 @@ public async Task GetAllApplicationsForUserWithStatus_WithValidUser_GetsAllRoles
new()
{
ApplicationId = _fixture.Create<Guid>(),
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))
Expand All @@ -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
Expand Down

0 comments on commit 3957eaf

Please sign in to comment.