public async Task Then_If_Has_Title_Training_Provider_ShortDescription_And_Descriptions_Then_Completed( string title, string programmeId, string description, string shortDescription, string trainingDescription, string outcomeDescription, string accountLegalEntityPublicHashedId, Vacancies.Client.Domain.Entities.TrainingProvider provider, ApprenticeshipProgramme programme, [Frozen] Mock <IRecruitVacancyClient> recruitVacancyClient, DisplayVacancyViewModelMapper mapper) { recruitVacancyClient.Setup(x => x.GetApprenticeshipProgrammeAsync(programmeId)).ReturnsAsync(programme); var vacancy = new Vacancy { Id = Guid.NewGuid(), Title = title, ProgrammeId = programmeId, Description = description, TrainingDescription = trainingDescription, ShortDescription = shortDescription, OutcomeDescription = outcomeDescription, TrainingProvider = provider, AccountLegalEntityPublicHashedId = accountLegalEntityPublicHashedId }; var model = new VacancyPreviewViewModel(); await mapper.MapFromVacancyAsync(model, vacancy); model.SetSectionStates(model, new ModelStateDictionary()); model.TaskListSectionOneState.Should().Be(VacancyTaskListSectionState.Completed); }
public async Task Then_The_Section_State_Is_Set_to_Not_Started( string title, string programmeId, string description, string shortDescription, string trainingDescription, string outcomeDescription, string accountLegalEntityPublicHashedId, Vacancies.Client.Domain.Entities.TrainingProvider provider, ApprenticeshipProgramme programme, [Frozen] Mock <IRecruitVacancyClient> recruitVacancyClient, DisplayVacancyViewModelMapper mapper) { var vacancy = CreateCompletedSectionOneAndSectionTwoVacancy(); vacancy.NumberOfPositions = null; var model = new VacancyPreviewViewModel(); await mapper.MapFromVacancyAsync(model, vacancy); model.SetSectionStates(model, new ModelStateDictionary()); model.TaskListSectionOneState.Should().Be(VacancyTaskListSectionState.Completed); model.TaskListSectionTwoState.Should().Be(VacancyTaskListSectionState.InProgress); model.TaskListSectionThreeState.Should().Be(VacancyTaskListSectionState.NotStarted); }
public VacancyManageOrchestrator(ILogger <VacancyManageOrchestrator> logger, DisplayVacancyViewModelMapper vacancyDisplayMapper, IRecruitVacancyClient client, IFeature featureToggle, ProviderRecruitSystemConfiguration systemConfig) : base(logger) { _vacancyDisplayMapper = vacancyDisplayMapper; _client = client; _featureToggle = featureToggle; _systemConfig = systemConfig; }
public async Task Then_If_Has_Title_Training_Provider_ShortDescription_Then_In_Progress( string title, string programmeId, string shortDescription, Vacancies.Client.Domain.Entities.TrainingProvider provider, ApprenticeshipProgramme programme, [Frozen] Mock <IRecruitVacancyClient> recruitVacancyClient, DisplayVacancyViewModelMapper mapper) { recruitVacancyClient.Setup(x => x.GetApprenticeshipProgrammeAsync(programmeId)).ReturnsAsync(programme); var vacancy = new Vacancy { Id = Guid.NewGuid(), Title = title, ProgrammeId = programmeId, ShortDescription = shortDescription, TrainingProvider = provider }; var model = new VacancyPreviewViewModel(); await mapper.MapFromVacancyAsync(model, vacancy); model.SetSectionStates(model, new ModelStateDictionary()); model.TaskListSectionOneState.Should().Be(VacancyTaskListSectionState.InProgress); }
public VacancyManageOrchestrator(ILogger <VacancyManageOrchestrator> logger, DisplayVacancyViewModelMapper vacancyDisplayMapper, IRecruitVacancyClient vacancyClient, EmployerRecruitSystemConfiguration systemConfig, IUtility utility) : base(logger) { _vacancyDisplayMapper = vacancyDisplayMapper; _client = vacancyClient; _systemConfig = systemConfig; _utility = utility; }
public async Task Then_If_There_Are_Skills_Qualifications_And_Other_Things_To_Consider_Added_Section_Set_To_Complete( string title, string programmeId, string description, string shortDescription, string trainingDescription, string outcomeDescription, List <string> skills, string otherThingsToConsider, List <Qualification> qualifications, Vacancies.Client.Domain.Entities.TrainingProvider provider, ApprenticeshipProgramme programme, [Frozen] Mock <IRecruitVacancyClient> recruitVacancyClient, DisplayVacancyViewModelMapper mapper) { var vacancy = CreateCompletedSectionOneAndSectionTwoVacancy(); vacancy.Skills = skills; vacancy.Qualifications = qualifications; vacancy.ThingsToConsider = otherThingsToConsider; var model = new VacancyPreviewViewModel(); await mapper.MapFromVacancyAsync(model, vacancy); model.SetSectionStates(model, new ModelStateDictionary()); model.TaskListSectionThreeState.Should().Be(VacancyTaskListSectionState.Completed); }
public VacancyTaskListOrchestrator(ILogger <VacancyTaskListOrchestrator> logger, IRecruitVacancyClient recruitVacancyClient, IUtility utility, IEmployerVacancyClient employerVacancyClient, DisplayVacancyViewModelMapper displayVacancyViewModelMapper) : base(logger) { _recruitVacancyClient = recruitVacancyClient; _utility = utility; _employerVacancyClient = employerVacancyClient; _displayVacancyViewModelMapper = displayVacancyViewModelMapper; }
public async Task RejectJobAdvertAsync_ShouldSendCommand() { //Arrange var user = new VacancyUser { Email = "*****@*****.**", Name = "advertname", UserId = "advertId" }; var vacancy = new Vacancy { EmployerAccountId = "ABCDEF", AccountLegalEntityPublicHashedId = "XVYABD", Id = Guid.Parse("84af954e-5baf-4942-897d-d00180a0839e"), Title = "has a value", NumberOfPositions = 1, EmployerLocation = new Address { Postcode = "has a value" }, ShortDescription = "has a value", ProgrammeId = "has a value", Wage = new Wage { Duration = 1, WageType = WageType.FixedWage }, LegalEntityName = "legal name", EmployerNameOption = EmployerNameOption.RegisteredName, StartDate = DateTime.Now, Status = VacancyStatus.Review, VacancyReference = 123456 }; var rejectJobAdvertViewModel = new RejectJobAdvertViewModel { RejectJobAdvert = true, VacancyId = vacancy.Id, EmployerAccountId = "ABCDEF" }; _mockRecruitVacancyClient.Setup(x => x.GetVacancyAsync(vacancy.Id)).ReturnsAsync(vacancy); _mockRecruitVacancyClient.Setup(x => x.GetEmployerDescriptionAsync(vacancy)).ReturnsAsync("employer description"); _mockRecruitVacancyClient.Setup(x => x.GetEmployerNameAsync(vacancy)).ReturnsAsync("employer name"); _mockRecruitVacancyClient.Setup(c => c.Validate(vacancy, It.IsAny <VacancyRuleSet>())).Returns(new EntityValidationResult()); var geocodeImageService = new Mock <IGeocodeImageService>(); var externalLinks = new Mock <IOptions <ExternalLinksConfiguration> >(); var mapper = new DisplayVacancyViewModelMapper(geocodeImageService.Object, externalLinks.Object, _mockRecruitVacancyClient.Object); var legalEntityAgreement = new Mock <ILegalEntityAgreementService>(); var utility = new Utility(_mockRecruitVacancyClient.Object, Mock.Of <IFeature>()); var sut = new VacancyPreviewOrchestrator(_mockRecruitVacancyClient.Object, Mock.Of <ILogger <VacancyPreviewOrchestrator> >(), mapper, _mockReviewSummaryService.Object, legalEntityAgreement.Object, _mockmessaging.Object, Mock.Of <IOptions <ExternalLinksConfiguration> >(), utility); //Act var response = await sut.RejectJobAdvertAsync(rejectJobAdvertViewModel, user); //Assert _mockmessaging.Verify(c => c.SendCommandAsync(It.IsAny <ICommand>()), Times.Once()); response.Data.IsRejected.Should().Be(true); }
public async Task Then_The_Vacancy_Is_Retrieved_And_Mapped( string findAnApprenticeshipUrl, VacancyRouteModel routeModel, ApprenticeshipProgramme programme, Vacancy vacancy, List <LegalEntity> legalEntities, [Frozen] Mock <IOptions <ExternalLinksConfiguration> > externalLinksConfiguration, [Frozen] Mock <IUtility> utility, [Frozen] Mock <IRecruitVacancyClient> recruitVacancyClient, [Frozen] Mock <IEmployerVacancyClient> employerVacancyClient, VacancyTaskListOrchestrator orchestrator) { vacancy.EmployerLocation = null; vacancy.EmployerNameOption = EmployerNameOption.RegisteredName; programme.Id = vacancy.ProgrammeId; programme.EducationLevelNumber = 3; programme.ApprenticeshipLevel = ApprenticeshipLevel.Higher; employerVacancyClient.Setup(x => x.GetEmployerLegalEntitiesAsync(routeModel.EmployerAccountId)) .ReturnsAsync(legalEntities); utility.Setup(x => x.GetAuthorisedVacancyForEditAsync(It.Is <VacancyRouteModel>( c => c.VacancyId.Equals(routeModel.VacancyId) && c.EmployerAccountId.Equals(routeModel.EmployerAccountId)), RouteNames.EmployerTaskListGet)) .ReturnsAsync(vacancy); recruitVacancyClient.Setup(x => x.GetActiveApprenticeshipProgrammesAsync()) .ReturnsAsync(new List <ApprenticeshipProgramme> { programme }); recruitVacancyClient.Setup(x => x.GetApprenticeshipProgrammeAsync(programme.Id)) .ReturnsAsync(programme); recruitVacancyClient.Setup(x => x.GetEmployerDescriptionAsync(vacancy)).ReturnsAsync(vacancy.EmployerDescription); recruitVacancyClient.Setup(x => x.GetEmployerNameAsync(vacancy)).ReturnsAsync(vacancy.EmployerName); externalLinksConfiguration.Object.Value.FindAnApprenticeshipUrl = findAnApprenticeshipUrl; var expectedViewModel = new VacancyPreviewViewModel(); var mapper = new DisplayVacancyViewModelMapper(Mock.Of <IGeocodeImageService>(), externalLinksConfiguration.Object, recruitVacancyClient.Object); var viewModel = await orchestrator.GetVacancyTaskListModel(routeModel); await mapper.MapFromVacancyAsync(expectedViewModel, vacancy); viewModel.Should().BeEquivalentTo(expectedViewModel, options => options .Excluding(c => c.SoftValidationErrors) .Excluding(c => c.RejectedReason) .Excluding(c => c.HasProgramme) .Excluding(c => c.HasWage) .Excluding(c => c.CanShowReference) .Excluding(c => c.CanShowDraftHeader) .Excluding(c => c.EducationLevelName) .Excluding(c => c.ApprenticeshipLevel) .Excluding(c => c.AccountLegalEntityCount) .Excluding(c => c.HasSelectedEmployerNameOption) ); viewModel.ApprenticeshipLevel.Should().Be(programme.ApprenticeshipLevel); viewModel.AccountLegalEntityCount.Should().Be(legalEntities.Count); viewModel.HasSelectedEmployerNameOption.Should().BeTrue(); }
public VacancyPreviewOrchestrator( IProviderVacancyClient client, IRecruitVacancyClient vacancyClient, ILogger <VacancyPreviewOrchestrator> logger, DisplayVacancyViewModelMapper vacancyDisplayMapper, IReviewSummaryService reviewSummaryService) : base(logger) { _client = client; _vacancyClient = vacancyClient; _vacancyDisplayMapper = vacancyDisplayMapper; _reviewSummaryService = reviewSummaryService; }
public async Task Then_The_Section_State_Is_Set( DisplayVacancyViewModelMapper mapper) { var vacancy = new Vacancy() { Id = Guid.NewGuid() }; var model = new VacancyPreviewViewModel(); await mapper.MapFromVacancyAsync(model, vacancy); model.SetSectionStates(model, new ModelStateDictionary()); model.TaskListSectionOneState.Should().Be(VacancyTaskListSectionState.NotStarted); }
public VacancyPreviewOrchestrator( IEmployerVacancyClient client, IRecruitVacancyClient vacancyClient, ILogger <VacancyPreviewOrchestrator> logger, DisplayVacancyViewModelMapper vacancyDisplayMapper, IReviewSummaryService reviewSummaryService, ILegalEntityAgreementService legalEntityAgreementService) : base(logger) { _client = client; _vacancyClient = vacancyClient; _vacancyDisplayMapper = vacancyDisplayMapper; _reviewSummaryService = reviewSummaryService; _legalEntityAgreementService = legalEntityAgreementService; }
public async Task Then_Section_State_Is_Set_To_Complete_With_Employer_Name_Description_And_ApplicationMethod_Set( Vacancy vacancy, [Frozen] Mock <IRecruitVacancyClient> recruitVacancyClient, DisplayVacancyViewModelMapper mapper) { vacancy.EmployerNameOption = EmployerNameOption.RegisteredName; var model = new VacancyPreviewViewModel(); await mapper.MapFromVacancyAsync(model, vacancy); model.SetSectionStates(model, new ModelStateDictionary()); model.TaskListSectionFourState.Should().Be(VacancyTaskListSectionState.Completed); }
public async Task And_Section_One_Not_Complete_Then_Not_Started( DisplayVacancyViewModelMapper mapper) { var vacancy = CreateCompletedSectionOneVacancy(); vacancy.OutcomeDescription = null; vacancy.Id = Guid.NewGuid(); var model = new VacancyPreviewViewModel(); await mapper.MapFromVacancyAsync(model, vacancy); model.SetSectionStates(model, new ModelStateDictionary()); model.TaskListSectionTwoState.Should().Be(VacancyTaskListSectionState.NotStarted); }
public async Task Then_Section_State_Is_Set_To_In_Progress_If_Employer_Name_And_Description_Set( Vacancy vacancy, [Frozen] Mock <IRecruitVacancyClient> recruitVacancyClient, DisplayVacancyViewModelMapper mapper) { vacancy.ApplicationMethod = null; var model = new VacancyPreviewViewModel(); await mapper.MapFromVacancyAsync(model, vacancy); model.SetSectionStates(model, new ModelStateDictionary()); model.TaskListSectionFourState.Should().Be(VacancyTaskListSectionState.InProgress); }
public async Task Then_If_Section_Started_Then_Set_To_In_Progress( string title, DisplayVacancyViewModelMapper mapper) { var vacancy = new Vacancy() { Id = Guid.NewGuid(), Title = title }; var model = new VacancyPreviewViewModel(); await mapper.MapFromVacancyAsync(model, vacancy); model.SetSectionStates(model, new ModelStateDictionary()); model.TaskListSectionOneState.Should().Be(VacancyTaskListSectionState.InProgress); }
public async Task And_Has_Important_Dates_Then_In_Progress( DateTime closingDate, DisplayVacancyViewModelMapper mapper) { var vacancy = CreateCompletedSectionOneVacancy(); vacancy.Id = Guid.NewGuid(); vacancy.ClosingDate = closingDate; vacancy.StartDate = closingDate.AddMonths(1); var model = new VacancyPreviewViewModel(); await mapper.MapFromVacancyAsync(model, vacancy); model.SetSectionStates(model, new ModelStateDictionary()); model.TaskListSectionTwoState.Should().Be(VacancyTaskListSectionState.InProgress); }
public VacancyPreviewOrchestrator( IRecruitVacancyClient vacancyClient, ILogger <VacancyPreviewOrchestrator> logger, DisplayVacancyViewModelMapper vacancyDisplayMapper, IReviewSummaryService reviewSummaryService, ILegalEntityAgreementService legalEntityAgreementService, IMessaging messaging, IOptions <ExternalLinksConfiguration> externalLinksOptions, IUtility utility) : base(logger) { _vacancyClient = vacancyClient; _vacancyDisplayMapper = vacancyDisplayMapper; _reviewSummaryService = reviewSummaryService; _legalEntityAgreementService = legalEntityAgreementService; _messaging = messaging; _utility = utility; _externalLinksConfiguration = externalLinksOptions.Value; }
public async Task Then_The_Section_State_Is_Set_To_Not_Started_If_Section_Three_Is_Complete_But_No_Name_On_Advert( Vacancy vacancy, [Frozen] Mock <IRecruitVacancyClient> recruitVacancyClient, DisplayVacancyViewModelMapper mapper) { recruitVacancyClient.Setup(x => x.GetEmployerNameAsync(vacancy)).ReturnsAsync(string.Empty); vacancy.EmployerDescription = null; vacancy.ApplicationMethod = null; vacancy.EmployerNameOption = null; var model = new VacancyPreviewViewModel(); await mapper.MapFromVacancyAsync(model, vacancy); model.SetSectionStates(model, new ModelStateDictionary()); model.TaskListSectionFourState.Should().Be(VacancyTaskListSectionState.NotStarted); }
public VacancyPreviewOrchestrator( IProviderVacancyClient client, IRecruitVacancyClient vacancyClient, ILogger <VacancyPreviewOrchestrator> logger, DisplayVacancyViewModelMapper vacancyDisplayMapper, IReviewSummaryService reviewSummaryService, ILegalEntityAgreementService legalEntityAgreementService, ITrainingProviderAgreementService trainingProviderAgreementService, IMessaging messaging) : base(logger) { _client = client; _vacancyClient = vacancyClient; _vacancyDisplayMapper = vacancyDisplayMapper; _reviewSummaryService = reviewSummaryService; _legalEntityAgreementService = legalEntityAgreementService; _trainingProviderAgreementService = trainingProviderAgreementService; _messaging = messaging; }
public async Task And_Has_All_Values_Then_Completed( Wage wage, DateTime closingDate, int numberOfPositions, Address employerLocation, DisplayVacancyViewModelMapper mapper) { var vacancy = CreateCompletedSectionOneVacancy(); vacancy.Id = Guid.NewGuid(); vacancy.Wage = wage; vacancy.ClosingDate = closingDate; vacancy.StartDate = closingDate.AddMonths(1); vacancy.NumberOfPositions = numberOfPositions; vacancy.EmployerLocation = employerLocation; var model = new VacancyPreviewViewModel(); await mapper.MapFromVacancyAsync(model, vacancy); model.SetSectionStates(model, new ModelStateDictionary()); model.TaskListSectionTwoState.Should().Be(VacancyTaskListSectionState.Completed); }
public async Task Then_If_There_Section_Two_Is_Completed_Then_Section_Three_Set_To_NotStarted( string title, string programmeId, string description, string shortDescription, string trainingDescription, string outcomeDescription, List <string> skills, Vacancies.Client.Domain.Entities.TrainingProvider provider, ApprenticeshipProgramme programme, [Frozen] Mock <IRecruitVacancyClient> recruitVacancyClient, DisplayVacancyViewModelMapper mapper) { var vacancy = CreateCompletedSectionOneAndSectionTwoVacancy(); var model = new VacancyPreviewViewModel(); await mapper.MapFromVacancyAsync(model, vacancy); model.SetSectionStates(model, new ModelStateDictionary()); model.TaskListSectionOneState.Should().Be(VacancyTaskListSectionState.Completed); model.TaskListSectionTwoState.Should().Be(VacancyTaskListSectionState.Completed); model.TaskListSectionThreeState.Should().Be(VacancyTaskListSectionState.NotStarted); }
public VacancyViewOrchestrator(DisplayVacancyViewModelMapper vacancyDisplayMapper, IEmployerVacancyClient client, IRecruitVacancyClient vacancyClient) { _vacancyDisplayMapper = vacancyDisplayMapper; _client = client; _vacancyClient = vacancyClient; }
public async Task SubmitVacancyAsync_ShouldNotSubmitWhenMissingAgreements(bool hasLegalEntityAgreement, bool hasProviderAgreement, bool shouldBeSubmitted) { var vacancyId = Guid.NewGuid(); const long ukprn = 12345678; const string employerAccountId = "ABCDEF"; const string accountLegalEntityPublicHashedId = "XVYABD"; var fixture = new Fixture(); var vacancy = fixture.Create <Vacancy>(); vacancy.Id = vacancyId; vacancy.TrainingProvider.Ukprn = ukprn; vacancy.Status = VacancyStatus.Draft; vacancy.IsDeleted = false; vacancy.EmployerAccountId = employerAccountId; vacancy.AccountLegalEntityPublicHashedId = accountLegalEntityPublicHashedId; vacancy.OwnerType = OwnerType.Provider; var client = new Mock <IProviderVacancyClient>(); var vacancyClient = new Mock <IRecruitVacancyClient>(); vacancyClient.Setup(c => c.GetVacancyAsync(vacancyId)) .ReturnsAsync(vacancy); vacancyClient.Setup(c => c.GetEmployerNameAsync(vacancy)) .ReturnsAsync("employer name from employer service"); vacancyClient.Setup(c => c.Validate(vacancy, It.IsAny <Recruit.Vacancies.Client.Application.Validation.VacancyRuleSet>())) .Returns(new EntityValidationResult()); var logger = new Mock <ILogger <VacancyPreviewOrchestrator> >(); var geocodeImageService = new Mock <IGeocodeImageService>(); var externalLinks = new Mock <IOptions <ExternalLinksConfiguration> >(); var mapper = new DisplayVacancyViewModelMapper(geocodeImageService.Object, externalLinks.Object, vacancyClient.Object, client.Object); var review = new Mock <IReviewSummaryService>(); var permission = new Mock <IProviderRelationshipsService>(); permission.Setup(p => p.HasProviderGotEmployersPermissionAsync(ukprn, employerAccountId, accountLegalEntityPublicHashedId, OperationType.RecruitmentRequiresReview)) .ReturnsAsync(false); var legalEntityAgreement = new Mock <ILegalEntityAgreementService>(); legalEntityAgreement.Setup(l => l.HasLegalEntityAgreementAsync(employerAccountId, accountLegalEntityPublicHashedId)) .ReturnsAsync(hasLegalEntityAgreement); var agreementServiceMock = new Mock <ITrainingProviderAgreementService>(); agreementServiceMock.Setup(t => t.HasAgreementAsync(ukprn)) .ReturnsAsync(hasProviderAgreement); var messagingMock = new Mock <IMessaging>(); var orch = new VacancyPreviewOrchestrator( client.Object, vacancyClient.Object, logger.Object, mapper, review.Object, permission.Object, legalEntityAgreement.Object, agreementServiceMock.Object, messagingMock.Object); var m = new SubmitEditModel { VacancyId = vacancyId, Ukprn = ukprn }; var user = new VacancyUser(); var actualResponse = await orch.SubmitVacancyAsync(m, user); var submittedTimes = shouldBeSubmitted ? Times.Once() : Times.Never(); messagingMock.Verify(c => c.SendCommandAsync(It.IsAny <ICommand>()), submittedTimes); actualResponse.Data.IsSubmitted.Should().Be(shouldBeSubmitted); actualResponse.Data.HasLegalEntityAgreement.Should().Be(hasLegalEntityAgreement); actualResponse.Data.HasProviderAgreement.Should().Be(hasProviderAgreement); }
public VacancyManageOrchestrator(ILogger <VacancyManageOrchestrator> logger, DisplayVacancyViewModelMapper vacancyDisplayMapper, IEmployerVacancyClient client, IRecruitVacancyClient vacancyClient) : base(logger) { _vacancyDisplayMapper = vacancyDisplayMapper; _client = client; _vacancyClient = vacancyClient; }
public VacancyViewOrchestrator(DisplayVacancyViewModelMapper vacancyDisplayMapper, IRecruitVacancyClient client, IUtility utility) { _vacancyDisplayMapper = vacancyDisplayMapper; _client = client; _utility = utility; }