diff --git a/src/Jobs/Recruit.Vacancies.Jobs.UnitTests/DomainEvents/Handlers/VacancyRejectedHandlerTests.cs b/src/Jobs/Recruit.Vacancies.Jobs.UnitTests/DomainEvents/Handlers/VacancyRejectedHandlerTests.cs index e5138ce526..3a1bb1787c 100644 --- a/src/Jobs/Recruit.Vacancies.Jobs.UnitTests/DomainEvents/Handlers/VacancyRejectedHandlerTests.cs +++ b/src/Jobs/Recruit.Vacancies.Jobs.UnitTests/DomainEvents/Handlers/VacancyRejectedHandlerTests.cs @@ -92,7 +92,7 @@ public async Task GivenVacancyRejectedEvent_ProviderResolver_ShouldBeSet() await _sut.HandleAsync(@event); //Assert - _sentCommRequest.ParticipantsResolverName.Should().Be(CommunicationConstants.ParticipantResolverNames.ProviderParticipantsResolverName); + _sentCommRequest.ParticipantsResolverName.Should().Be(CommunicationConstants.ParticipantResolverNames.VacancyParticipantsResolverName); } [Fact] diff --git a/src/Jobs/Recruit.Vacancies.Jobs/DomainEvents/Handlers/Vacancy/VacancyRejectedHandler.cs b/src/Jobs/Recruit.Vacancies.Jobs/DomainEvents/Handlers/Vacancy/VacancyRejectedHandler.cs index 85cb31e8f2..f89b7d96f4 100644 --- a/src/Jobs/Recruit.Vacancies.Jobs/DomainEvents/Handlers/Vacancy/VacancyRejectedHandler.cs +++ b/src/Jobs/Recruit.Vacancies.Jobs/DomainEvents/Handlers/Vacancy/VacancyRejectedHandler.cs @@ -43,7 +43,7 @@ private CommunicationRequest GetRejectedVacancyCommunicationRequest(long vacancy { var communicationRequest = new CommunicationRequest( CommunicationConstants.RequestType.VacancyRejectedByEmployer, - CommunicationConstants.ParticipantResolverNames.ProviderParticipantsResolverName, + CommunicationConstants.ParticipantResolverNames.VacancyParticipantsResolverName, CommunicationConstants.ServiceName); communicationRequest.AddEntity(CommunicationConstants.EntityTypes.Vacancy, vacancyReference); communicationRequest.AddEntity(CommunicationConstants.EntityTypes.ApprenticeshipServiceUrl, vacancyReference); diff --git a/src/Shared/Recruit.Vacancies.Client/Application/Communications/ParticipantResolverPlugins/VacancyParticipantsResolverPlugin.cs b/src/Shared/Recruit.Vacancies.Client/Application/Communications/ParticipantResolverPlugins/VacancyParticipantsResolverPlugin.cs index 82361ef41c..8d3b4c33e9 100644 --- a/src/Shared/Recruit.Vacancies.Client/Application/Communications/ParticipantResolverPlugins/VacancyParticipantsResolverPlugin.cs +++ b/src/Shared/Recruit.Vacancies.Client/Application/Communications/ParticipantResolverPlugins/VacancyParticipantsResolverPlugin.cs @@ -51,7 +51,8 @@ public async Task> GetParticipantsAsync(Communica { users = await _userRepository.GetProviderUsersAsync(vacancy.TrainingProvider.Ukprn.GetValueOrDefault()); } - return ParticipantResolverPluginHelper.ConvertToCommunicationUsers(users, vacancy.SubmittedByUser.UserId); + + return ParticipantResolverPluginHelper.ConvertToCommunicationUsers(users, vacancy.SubmittedByUser?.UserId ?? vacancy.ReviewByUser?.UserId); } public async Task> ValidateParticipantAsync(IEnumerable messages) diff --git a/src/Shared/UnitTests/Vacancies.Client/Application/Communications/ParticipantResolvers/VacancyParticipantResolverPluginTests.cs b/src/Shared/UnitTests/Vacancies.Client/Application/Communications/ParticipantResolvers/VacancyParticipantResolverPluginTests.cs index dbdada969d..ecc8c6a783 100644 --- a/src/Shared/UnitTests/Vacancies.Client/Application/Communications/ParticipantResolvers/VacancyParticipantResolverPluginTests.cs +++ b/src/Shared/UnitTests/Vacancies.Client/Application/Communications/ParticipantResolvers/VacancyParticipantResolverPluginTests.cs @@ -101,6 +101,31 @@ public async Task ShouldReturnVacancyOwnerAsPrimaryUser() participants.Single(p => p.UserId != PrimaryUserId).Participation.Should().Be(UserParticipation.SecondaryUser); } + [Fact] + public async Task ShouldProviderReviewSenderAsPrimaryUser() + { + var user = _fixture.Build().With(v => v.UserId, PrimaryUserId).Create(); + var vacancy = _fixture + .Build() + .With(v => v.OwnerType, OwnerType.Provider) + .Without(v => v.SubmittedByUser) + .With(v => v.ReviewByUser, user) + .Create(); + + _mockVacancyRepository.Setup(v => v.GetVacancyAsync(It.IsAny())).ReturnsAsync(vacancy); + + var sut = GetSut(); + + var request = new CommunicationRequest(_fixture.Create(), _fixture.Create(), _fixture.Create()); + request.AddEntity(CommunicationConstants.EntityTypes.Vacancy, _fixture.Create()); + + var participants = await sut.GetParticipantsAsync(request); + + participants.Count().Should().Be(2); + participants.Single(p => p.UserId == PrimaryUserId).Participation.Should().Be(UserParticipation.PrimaryUser); + participants.Single(p => p.UserId != PrimaryUserId).Participation.Should().Be(UserParticipation.SecondaryUser); + } + private VacancyParticipantsResolverPlugin GetSut() { return new VacancyParticipantsResolverPlugin(