Skip to content

Commit

Permalink
Merge pull request #936 from SkillsFundingAgency/CON-2685_Fix-vacancy…
Browse files Browse the repository at this point in the history
…-transfer

CON-2685 Since removing the LegalEntityId from the code, we didn't re…
  • Loading branch information
Najamuddin-Muhammad authored Nov 19, 2020
2 parents 54af62e + b4e8c2e commit 7cdc16a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Esfa.Recruit.Vacancies.Client.Application.Commands;
using Esfa.Recruit.Vacancies.Client.Application.Queues;
using Esfa.Recruit.Vacancies.Client.Application.Queues.Messages;
using Esfa.Recruit.Vacancies.Client.Domain.Entities;
using Esfa.Recruit.Vacancies.Client.Domain.Messaging;
using Esfa.Recruit.Vacancies.Client.Infrastructure.Services.EmployerAccount;
using Esfa.Recruit.Vacancies.Jobs.Configuration;
Expand Down Expand Up @@ -143,5 +144,39 @@ public async Task GivenMatchingExistingLegalEntityId_ThenVerifyTransferProcessIs
_mockRecruitQueueService.Verify(x => x.AddMessageAsync(It.IsAny<TransferVacanciesFromProviderQueueMessage>()), Times.Once);
_mockMessaging.Verify(x => x.SendCommandAsync(It.Is<SetupProviderCommand>(c => c.Ukprn == Ukprn)), Times.Once);
}

[Fact]
public async Task GivenMatchingExistingLegalEntityId_ThenQueuedMessageIsMappedCorrectly()
{
var matchingLegalEntityViewModel = _autoFixture.Build<LegalEntityViewModel>()
.With(l => l.DasAccountId, EmployerAccountIdEncoded)
.With(l => l.AccountLegalEntityId, AccountLegalEntityId)
.With(l => l.LegalEntityId, RecruitLegalEntityId)
.Create();

var grantedOperations = new HashSet<Operation> { Operation.CreateCohort };
_mockEncoder.Setup(x => x.Encode(EmployerAccountId, EncodingType.AccountId)).Returns(EmployerAccountIdEncoded);
_mockEmployerAccountProvider.Setup(x => x.GetLegalEntitiesConnectedToAccountAsync(EmployerAccountIdEncoded))
.ReturnsAsync(_dummyLegalEntities.Append(matchingLegalEntityViewModel));

var userRef = Guid.NewGuid();

TransferVacanciesFromProviderQueueMessage queuedMessage = null;
_mockRecruitQueueService.Setup(mock => mock.AddMessageAsync(It.IsAny<TransferVacanciesFromProviderQueueMessage>())).Callback((TransferVacanciesFromProviderQueueMessage message) =>
{
queuedMessage = message;
});

await _sut.Handle(new UpdatedPermissionsEvent(EmployerAccountId, AccountLegalEntityId, AccountProviderId, AccountProviderLegalEntityId, Ukprn, userRef, UserEmailAddress, UserFirstName, UserLastName, grantedOperations, DateTime.UtcNow), null);

Assert.NotNull(queuedMessage);
Assert.Equal(Ukprn, queuedMessage.Ukprn);
Assert.Equal(EmployerAccountIdEncoded, queuedMessage.EmployerAccountId);
Assert.Equal(matchingLegalEntityViewModel.AccountLegalEntityPublicHashedId, queuedMessage.AccountLegalEntityPublicHashedId);
Assert.Equal(userRef, queuedMessage.UserRef);
Assert.Equal(UserEmailAddress, queuedMessage.UserEmailAddress);
Assert.Equal($"{UserFirstName} {UserLastName}", queuedMessage.UserName);
Assert.Equal(TransferReason.EmployerRevokedPermission, queuedMessage.TransferReason);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ await _recruitQueueService.AddMessageAsync(new TransferVacanciesFromProviderQueu
{
Ukprn = message.Ukprn,
EmployerAccountId = employerAccountId,
AccountLegalEntityPublicHashedId = legalEntity.AccountLegalEntityPublicHashedId,
UserRef = message.UserRef.Value,
UserEmailAddress = message.UserEmailAddress,
UserName = $"{message.UserFirstName} {message.UserLastName}",
Expand Down

0 comments on commit 7cdc16a

Please sign in to comment.