-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #922 from SkillsFundingAgency/CON-1187-remove-lega…
…lentityid CON-1187-Remove LegalEntityId
- Loading branch information
Showing
38 changed files
with
106 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
using Moq; | ||
using Xunit; | ||
|
||
namespace Esfa.Recruit.Vacancies.Jobs.UnitTests.Jobs | ||
namespace Recruit.Vacancies.Jobs.UnitTests.Jobs | ||
{ | ||
public class TransferVacanciesFromProviderJobTests | ||
{ | ||
|
@@ -35,28 +35,34 @@ public TransferVacanciesFromProviderJobTests() | |
public async Task GivenRequest_WhenNoMatchingVacanciesToTransfer_AndProviderHasManyLegalEntityPermissions_ThenShouldNotQueueAnyTransfers() | ||
{ | ||
const long Ukprn = 1; | ||
const long LegalEntityId = 2; | ||
const string AccountLegalEntityPublicHashedId = "2"; | ||
const string EmployerAccountId = "employer-account-id"; | ||
|
||
_mockVacancyQuery.Setup(x => x.GetProviderOwnedVacanciesForLegalEntityAsync(Ukprn, LegalEntityId)) | ||
_mockVacancyQuery.Setup(x => x.GetProviderOwnedVacanciesForLegalEntityAsync(Ukprn, AccountLegalEntityPublicHashedId)) | ||
.ReturnsAsync(Enumerable.Empty<Vacancy>()); | ||
|
||
var employerInfo = new EmployerInfo | ||
{ | ||
LegalEntities = new List<LegalEntity> | ||
{ | ||
new LegalEntity{LegalEntityId = LegalEntityId}, | ||
new LegalEntity{LegalEntityId = 12345} | ||
new LegalEntity | ||
{ | ||
AccountLegalEntityPublicHashedId = "2" | ||
}, | ||
new LegalEntity | ||
{ | ||
AccountLegalEntityPublicHashedId = "12345" | ||
} | ||
} | ||
}; | ||
|
||
_mockQueryStoreReader.Setup(q => q.GetProviderEmployerVacancyDataAsync(Ukprn, EmployerAccountId)) | ||
.ReturnsAsync(employerInfo); | ||
|
||
await _sut.Run(Ukprn, EmployerAccountId, LegalEntityId, Guid.NewGuid(), string.Empty, string.Empty, TransferReason.EmployerRevokedPermission); | ||
await _sut.Run(Ukprn, EmployerAccountId, AccountLegalEntityPublicHashedId, Guid.NewGuid(), string.Empty, string.Empty, TransferReason.EmployerRevokedPermission); | ||
|
||
_mockRecruitQueueService.Verify(x => x.AddMessageAsync(It.IsAny<TransferVacancyToLegalEntityQueueMessage>()), Times.Never); | ||
_mockVacancyQuery.Verify(x => x.GetProviderOwnedVacanciesForEmployerWithoutLegalEntityAsync(It.IsAny<long>(), It.IsAny<string>()), Times.Never); | ||
_mockVacancyQuery.Verify(x => x.GetProviderOwnedVacanciesForEmployerWithoutAccountLegalEntityPublicHashedIdAsync(It.IsAny<long>(), It.IsAny<string>()), Times.Never); | ||
} | ||
|
||
[Fact] | ||
|
@@ -68,27 +74,30 @@ public async Task GivenRequest_WhenMatchingVacanciesToTransfer_AndProviderHasSin | |
const string UserEmail = "[email protected]"; | ||
const string UserName = "John Smith"; | ||
const long Ukprn = 1; | ||
const long LegalEntityId = 2; | ||
const string AccountLegalEntityPublicHashedId = "2"; | ||
const string EmployerAccountId = "employer-account-id"; | ||
|
||
_mockVacancyQuery.Setup(x => x.GetProviderOwnedVacanciesForLegalEntityAsync(Ukprn, LegalEntityId)) | ||
_mockVacancyQuery.Setup(x => x.GetProviderOwnedVacanciesForLegalEntityAsync(Ukprn, AccountLegalEntityPublicHashedId)) | ||
.ReturnsAsync(new Fixture().CreateMany<Vacancy>(NoOfMatchingVacancies)); | ||
|
||
var employerInfo = new EmployerInfo | ||
{ | ||
LegalEntities = new List<LegalEntity> | ||
{ | ||
new LegalEntity{LegalEntityId = LegalEntityId} | ||
new LegalEntity | ||
{ | ||
AccountLegalEntityPublicHashedId = AccountLegalEntityPublicHashedId | ||
} | ||
} | ||
}; | ||
|
||
_mockQueryStoreReader.Setup(q => q.GetProviderEmployerVacancyDataAsync(Ukprn, EmployerAccountId)) | ||
.ReturnsAsync(employerInfo); | ||
|
||
_mockVacancyQuery.Setup(x => x.GetProviderOwnedVacanciesForEmployerWithoutLegalEntityAsync(Ukprn, EmployerAccountId)) | ||
_mockVacancyQuery.Setup(x => x.GetProviderOwnedVacanciesForEmployerWithoutAccountLegalEntityPublicHashedIdAsync(Ukprn, EmployerAccountId)) | ||
.ReturnsAsync(new Fixture().CreateMany<Vacancy>(NoOfVacanciesWithoutLegalEntity)); | ||
|
||
await _sut.Run(Ukprn, EmployerAccountId, LegalEntityId, userRef, UserEmail, UserName, TransferReason.EmployerRevokedPermission); | ||
await _sut.Run(Ukprn, EmployerAccountId, AccountLegalEntityPublicHashedId, userRef, UserEmail, UserName, TransferReason.EmployerRevokedPermission); | ||
|
||
var expectedCallCount = NoOfMatchingVacancies + NoOfVacanciesWithoutLegalEntity; | ||
_mockRecruitQueueService.Verify(x => x.AddMessageAsync(It.IsAny<TransferVacancyToLegalEntityQueueMessage>()), Times.Exactly(expectedCallCount)); | ||
|
@@ -102,27 +111,33 @@ public async Task GivenRequest_WhenMatchingVacanciesToTransfer_AndProviderHasMan | |
const string UserEmail = "[email protected]"; | ||
const string UserName = "John Smith"; | ||
const long Ukprn = 1; | ||
const long LegalEntityId = 2; | ||
const string AccountLegalEntityPublicHashedId = "2"; | ||
const string EmployerAccountId = "employer-account-id"; | ||
|
||
_mockVacancyQuery.Setup(x => x.GetProviderOwnedVacanciesForLegalEntityAsync(Ukprn, LegalEntityId)) | ||
_mockVacancyQuery.Setup(x => x.GetProviderOwnedVacanciesForLegalEntityAsync(Ukprn, AccountLegalEntityPublicHashedId)) | ||
.ReturnsAsync(new Fixture().CreateMany<Vacancy>(NoOfMatchingVacancies)); | ||
|
||
var employerInfo = new EmployerInfo | ||
{ | ||
LegalEntities = new List<LegalEntity> | ||
{ | ||
new LegalEntity{LegalEntityId = LegalEntityId}, | ||
new LegalEntity{LegalEntityId = 1234} | ||
new LegalEntity | ||
{ | ||
AccountLegalEntityPublicHashedId = AccountLegalEntityPublicHashedId | ||
}, | ||
new LegalEntity | ||
{ | ||
AccountLegalEntityPublicHashedId = "1234" | ||
} | ||
} | ||
}; | ||
|
||
_mockQueryStoreReader.Setup(q => q.GetProviderEmployerVacancyDataAsync(Ukprn, EmployerAccountId)) | ||
.ReturnsAsync(employerInfo); | ||
|
||
await _sut.Run(Ukprn, EmployerAccountId, LegalEntityId, userRef, UserEmail, UserName, TransferReason.EmployerRevokedPermission); | ||
await _sut.Run(Ukprn, EmployerAccountId, AccountLegalEntityPublicHashedId, userRef, UserEmail, UserName, TransferReason.EmployerRevokedPermission); | ||
|
||
_mockVacancyQuery.Verify(x => x.GetProviderOwnedVacanciesForEmployerWithoutLegalEntityAsync(It.IsAny<long>(), It.IsAny<string>()), Times.Never); | ||
_mockVacancyQuery.Verify(x => x.GetProviderOwnedVacanciesForEmployerWithoutAccountLegalEntityPublicHashedIdAsync(It.IsAny<long>(), It.IsAny<string>()), Times.Never); | ||
_mockRecruitQueueService.Verify(x => x.AddMessageAsync(It.IsAny<TransferVacancyToLegalEntityQueueMessage>()), Times.Exactly(NoOfMatchingVacancies)); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 3 additions & 9 deletions
12
...ies.Jobs/DomainEvents/Handlers/Provider/ProviderBlockedOnLegalEntityDomainEventHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,30 @@ | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Esfa.Recruit.Vacancies.Client.Domain.Events; | ||
using Esfa.Recruit.Vacancies.Client.Infrastructure.Services.EmployerAccount; | ||
using Esfa.Recruit.Vacancies.Client.Infrastructure.Services.ProviderRelationship; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Esfa.Recruit.Vacancies.Jobs.DomainEvents.Handlers.Provider | ||
{ | ||
public class ProviderBlockedOnLegalEntityDomainEventHandler : DomainEventHandler, IDomainEventHandler<ProviderBlockedOnLegalEntityEvent> | ||
{ | ||
private readonly IEmployerAccountProvider _employerAccountProvider; | ||
private readonly IProviderRelationshipsService _providerRelationshipsService; | ||
private readonly ILogger<ProviderBlockedOnLegalEntityDomainEventHandler> _logger; | ||
public ProviderBlockedOnLegalEntityDomainEventHandler( | ||
IEmployerAccountProvider employerAccountProvider, | ||
IProviderRelationshipsService providerRelationshipsService, | ||
public ProviderBlockedOnLegalEntityDomainEventHandler(IProviderRelationshipsService providerRelationshipsService, | ||
ILogger<ProviderBlockedOnLegalEntityDomainEventHandler> logger) : base(logger) | ||
{ | ||
_logger = logger; | ||
_employerAccountProvider = employerAccountProvider; | ||
_providerRelationshipsService = providerRelationshipsService; | ||
} | ||
|
||
public async Task HandleAsync(string eventPayload) | ||
{ | ||
var eventData = DeserializeEvent<ProviderBlockedOnLegalEntityEvent>(eventPayload); | ||
|
||
_logger.LogInformation($"Attempting to revoke provider {eventData.Ukprn} permission on account {eventData.EmployerAccountId} with public hash {eventData.AccountLegalEntityPublicHashedId} for legal entity {eventData.LegalEntityId}."); | ||
_logger.LogInformation($"Attempting to revoke provider {eventData.Ukprn} permission on account {eventData.EmployerAccountId} with public hash {eventData.AccountLegalEntityPublicHashedId} for legal entity {eventData.AccountLegalEntityPublicHashedId}."); | ||
|
||
await _providerRelationshipsService.RevokeProviderPermissionToRecruitAsync(eventData.Ukprn, eventData.AccountLegalEntityPublicHashedId); | ||
|
||
_logger.LogInformation($"Successfully revoked provider {eventData.Ukprn} permission on account {eventData.EmployerAccountId} for legal entity {eventData.LegalEntityId}."); | ||
_logger.LogInformation($"Successfully revoked provider {eventData.Ukprn} permission on account {eventData.EmployerAccountId} for legal entity {eventData.AccountLegalEntityPublicHashedId}."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.