Skip to content

Commit

Permalink
fix(agreement): adjust GET: companyRoleAgreementConsents endpoint (#410)
Browse files Browse the repository at this point in the history
only return agreements with assigned companyRoles for endpoint /api/registration/application/{applicationId}/companyRoleAgreementConsents

Refs: CPLP-3677
  • Loading branch information
Phil91 authored Jan 15, 2024
1 parent 586a595 commit 22bfffb
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ public void RemoveCompanyAssignedRoles(Guid companyId, IEnumerable<CompanyRoleId
company.CompanyApplications.Any(application => application.Id == applicationId))
.Select(company => new CompanyRoleAgreementConsents(
company.CompanyAssignedRoles.Select(companyAssignedRole => companyAssignedRole.CompanyRoleId),
company.Consents.Where(consent => consent.ConsentStatusId == ConsentStatusId.ACTIVE && consent.Agreement!.AgreementStatusId == AgreementStatusId.ACTIVE).Select(consent => new AgreementConsentStatus(
consent.AgreementId,
consent.ConsentStatusId
)))).SingleOrDefaultAsync();
company.Consents
.Where(consent => consent.ConsentStatusId == ConsentStatusId.ACTIVE && consent.Agreement!.AgreementStatusId == AgreementStatusId.ACTIVE && consent.Agreement.AgreementAssignedCompanyRoles.Any())
.Select(consent => new AgreementConsentStatus(
consent.AgreementId,
consent.ConsentStatusId
)))).SingleOrDefaultAsync();

public async IAsyncEnumerable<CompanyRoleData> GetCompanyRoleAgreementsUntrackedAsync()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public async Task GetActiveServices_ReturnsExpectedAppCount()

// Assert
results.Should().NotBeNullOrEmpty();
results.Should().HaveCount(6);
results.Should().HaveCount(7);
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public async Task AgreementView_GetAll_ReturnsExpected()

// Act
var result = await sut.AgreementView.ToListAsync().ConfigureAwait(false);
result.Should().HaveCount(7);
result.Should().HaveCount(8);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,9 @@ public async Task GetCompanyRoleAndConsentAgreementDetailsAsync_ReturnsExpected(
.And.Satisfy(
x => x.CompanyRoleId == CompanyRoleId.ACTIVE_PARTICIPANT && x.RoleDescription == activeDescription && x.CompanyRolesActive == false && x.Agreements.Count() == 2 && x.Agreements.All(agreement => agreement.ConsentStatus == 0),
x => x.CompanyRoleId == CompanyRoleId.APP_PROVIDER && x.RoleDescription == appDescription && x.CompanyRolesActive == false && x.Agreements.Count() == 1 && x.Agreements.All(agreement => agreement.ConsentStatus == 0),
x => x.CompanyRoleId == CompanyRoleId.SERVICE_PROVIDER && x.RoleDescription == serviceDscription && x.CompanyRolesActive == true && x.Agreements.Count() == 2
&& x.Agreements.Any(agr => agr.AgreementId == new Guid("aa0a0000-7fbc-1f2f-817f-bce0502c1094") && agr.DocumentId == null && agr.AgreementName == "Terms & Conditions - Consultant" && agr.ConsentStatus == ConsentStatusId.ACTIVE)
x => x.CompanyRoleId == CompanyRoleId.SERVICE_PROVIDER && x.RoleDescription == serviceDscription && x.CompanyRolesActive == true && x.Agreements.Count() == 3
&& x.Agreements.Any(agr => agr.AgreementId == new Guid("aa0a0000-7fbc-1f2f-817f-bce0502c1094") && agr.DocumentId == null && agr.AgreementName == "Terms & Conditions - Consultant" && agr.ConsentStatus == ConsentStatusId.ACTIVE)
&& x.Agreements.Any(agr => agr.AgreementId == new Guid("aa0a0000-7fbc-1f2f-817f-bce0502c1018") && agr.DocumentId == null && agr.AgreementName == "Data Sharing Approval - allow CX to submit company data (company name, requester) to process the subscription" && agr.ConsentStatus == 0)
&& x.Agreements.Any(agr => agr.AgreementId == new Guid("aa0a0000-7fbc-1f2f-817f-bce0502c1017") && agr.DocumentId == new Guid("00000000-0000-0000-0000-000000000004") && agr.AgreementName == "Terms & Conditions Service Provider" && agr.ConsentStatus == 0),
x => x.CompanyRoleId == CompanyRoleId.ONBOARDING_SERVICE_PROVIDER && x.RoleDescription == onboardingServiceProviderDescription && x.CompanyRolesActive == false && x.Agreements.Count() == 1 && x.Agreements.All(agreement => agreement.ConsentStatus == 0));
}
Expand Down Expand Up @@ -630,7 +631,7 @@ public async Task GetAgreementAssignedRolesDataAsync_ReturnsExpectedOrder()

// Assert
result.Should().NotBeNull()
.And.HaveCount(6)
.And.HaveCount(7)
.And.Satisfy(
x => x.agreementStatusData.AgreementId == new Guid("aa0a0000-7fbc-1f2f-817f-bce0502c1090")
&& x.agreementStatusData.AgreementStatusId == AgreementStatusId.INACTIVE
Expand All @@ -641,15 +642,18 @@ public async Task GetAgreementAssignedRolesDataAsync_ReturnsExpectedOrder()
x => x.agreementStatusData.AgreementId == new Guid("aa0a0000-7fbc-1f2f-817f-bce0502c1013")
&& x.agreementStatusData.AgreementStatusId == AgreementStatusId.ACTIVE
&& x.CompanyRoleId == CompanyRoleId.ACTIVE_PARTICIPANT,
x => x.agreementStatusData.AgreementId == new Guid("aa0a0000-7fbc-1f2f-817f-bce0502c1094")
&& x.agreementStatusData.AgreementStatusId == AgreementStatusId.ACTIVE
&& x.CompanyRoleId == CompanyRoleId.SERVICE_PROVIDER,
x => x.agreementStatusData.AgreementId == new Guid("aa0a0000-7fbc-1f2f-817f-bce0502c1011")
&& x.agreementStatusData.AgreementStatusId == AgreementStatusId.ACTIVE
&& x.CompanyRoleId == CompanyRoleId.APP_PROVIDER,
x => x.agreementStatusData.AgreementId == new Guid("aa0a0000-7fbc-1f2f-817f-bce0502c1018")
&& x.agreementStatusData.AgreementStatusId == AgreementStatusId.ACTIVE
&& x.CompanyRoleId == CompanyRoleId.SERVICE_PROVIDER,
x => x.agreementStatusData.AgreementId == new Guid("aa0a0000-7fbc-1f2f-817f-bce0502c1017")
&& x.agreementStatusData.AgreementStatusId == AgreementStatusId.ACTIVE
&& x.CompanyRoleId == CompanyRoleId.SERVICE_PROVIDER,
x => x.agreementStatusData.AgreementId == new Guid("aa0a0000-7fbc-1f2f-817f-bce0502c1011")
&& x.agreementStatusData.AgreementStatusId == AgreementStatusId.ACTIVE
&& x.CompanyRoleId == CompanyRoleId.APP_PROVIDER
x => x.agreementStatusData.AgreementId == new Guid("aa0a0000-7fbc-1f2f-817f-bce0502c1094")
&& x.agreementStatusData.AgreementStatusId == AgreementStatusId.ACTIVE
&& x.CompanyRoleId == CompanyRoleId.SERVICE_PROVIDER
);
result.Select(x => x.CompanyRoleId).Should().BeInAscendingOrder();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public async Task GetCompanyRoleAgreementsUntrackedAsync_ReturnsExpected()
// Arrange
var activeAgreementIds = new[] { new Guid("aa0a0000-7fbc-1f2f-817f-bce0502c1010"), new Guid("aa0a0000-7fbc-1f2f-817f-bce0502c1013") };
var appAgreementIds = new[] { new Guid("aa0a0000-7fbc-1f2f-817f-bce0502c1011") };
var serviceAgreementIds = new[] { new Guid("aa0a0000-7fbc-1f2f-817f-bce0502c1017"), new Guid("aa0a0000-7fbc-1f2f-817f-bce0502c1094") };
var serviceAgreementIds = new[] { new Guid("aa0a0000-7fbc-1f2f-817f-bce0502c1017"), new Guid("aa0a0000-7fbc-1f2f-817f-bce0502c1018"), new Guid("aa0a0000-7fbc-1f2f-817f-bce0502c1094") };
var onboardingAgreementIds = new[] { new Guid("311aac58-932b-4622-be8b-34337e48d70d") };
var (sut, _) = await CreateSut().ConfigureAwait(false);

Expand All @@ -116,7 +116,7 @@ public async Task GetCompanyRoleAgreementsUntrackedAsync_ReturnsExpected()
x.AgreementIds.SequenceEqual(activeAgreementIds),
x => x.CompanyRoleId == CompanyRoleId.APP_PROVIDER && x.AgreementIds.Count() == 1 &&
x.AgreementIds.SequenceEqual(appAgreementIds),
x => x.CompanyRoleId == CompanyRoleId.SERVICE_PROVIDER && x.AgreementIds.Count() == 2 &&
x => x.CompanyRoleId == CompanyRoleId.SERVICE_PROVIDER && x.AgreementIds.Count() == 3 &&
x.AgreementIds.SequenceEqual(serviceAgreementIds),
x => x.CompanyRoleId == CompanyRoleId.ONBOARDING_SERVICE_PROVIDER && x.AgreementIds.Count() == 1 &&
x.AgreementIds.SequenceEqual(onboardingAgreementIds)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public async Task GetSubmitData_WithoutNetworkRegistration_ReturnsExpected()
// Assert
result.Exists.Should().BeTrue();
result.CompanyApplications.Should().BeEmpty();
result.CompanyRoleAgreementIds.Should().Satisfy(x => x.CompanyRoleId == CompanyRoleId.SERVICE_PROVIDER && x.AgreementIds.Count() == 2);
result.CompanyRoleAgreementIds.Should().Satisfy(x => x.CompanyRoleId == CompanyRoleId.SERVICE_PROVIDER && x.AgreementIds.Count() == 3);
result.ProcessId.Should().BeNull();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
{
"agreement_id": "aa0a0000-7fbc-1f2f-817f-bce0502c1094",
"company_role_id": 3
},
{
"agreement_id": "aa0a0000-7fbc-1f2f-817f-bce0502c1018",
"company_role_id": 3
}
]

0 comments on commit 22bfffb

Please sign in to comment.