public void TestJobAds() { // Refresh whatever may be in the cache. var administrator = _administratorAccountsCommand.CreateTestAdministrator(0); _featuredCommand.UpdateFeaturedStatistics(GetFeaturedStatistics()); ClearCache(administrator); // No job ads. Get(HomeUrl); Assert.AreEqual(0, GetJobAds()); // Post a job ad yesterday. var employer = _employerAccountsCommand.CreateTestEmployer(0, _organisationsCommand.CreateTestOrganisation(0)); var jobAd = employer.CreateTestJobAd(); jobAd.CreatedTime = DateTime.Now.AddDays(-1); _jobAdsCommand.CreateJobAd(jobAd); // Should not show up until cache is refreshed. Get(HomeUrl); Assert.AreEqual(0, GetJobAds()); _featuredCommand.UpdateFeaturedStatistics(GetFeaturedStatistics()); ClearCache(administrator); Get(HomeUrl); Assert.AreEqual(1, GetJobAds()); // Post another job ad. jobAd = employer.CreateTestJobAd(); jobAd.CreatedTime = DateTime.Now.AddDays(-4); _jobAdsCommand.CreateJobAd(jobAd); Get(HomeUrl); Assert.AreEqual(1, GetJobAds()); _featuredCommand.UpdateFeaturedStatistics(GetFeaturedStatistics()); ClearCache(administrator); Get(HomeUrl); Assert.AreEqual(2, GetJobAds()); // Post another outside the 7 day timeframe. jobAd = employer.CreateTestJobAd(); jobAd.CreatedTime = DateTime.Now.AddDays(-14); _jobAdsCommand.CreateJobAd(jobAd); Get(HomeUrl); Assert.AreEqual(2, GetJobAds()); _featuredCommand.UpdateFeaturedStatistics(GetFeaturedStatistics()); ClearCache(administrator); Get(HomeUrl); Assert.AreEqual(2, GetJobAds()); }
public void TestInitialize() { _australia = _locationQuery.GetCountry("Australia"); Resolve <IDbConnectionFactory>().DeleteAllTestData(); JobAdSearchHost.ClearIndex(); var employer = _employerAccountsCommand.CreateTestEmployer("jobposter", _organisationsCommand.CreateTestOrganisation("The Job Advertiser")); _one = employer.CreateTestJobAd("Title one", "The content for the first ad"); _one.CreatedTime = DateTime.Now.AddDays(-1); // Just to make sure it's before "two"; we only index days. _one.Description.Salary = new Salary { LowerBound = 50000, UpperBound = 60000, Rate = SalaryRate.Year, Currency = Currency.AUD }; _jobAdsCommand.CreateJobAd(_one); _jobAdsCommand.OpenJobAd(_one); _two = employer.CreateTestJobAd("Title two", "Different content for the second ad"); _locationQuery.ResolvePostalSuburb(_two.Description.Location, _australia, "2000"); _two.Description.CompanyName = "Really Bad Employers"; _two.Description.JobTypes = JobTypes.Contract; _two.Description.Industries = new List <Industry> { _industriesQuery.GetIndustry("Other") }; _jobAdsCommand.CreateJobAd(_two); _jobAdsCommand.OpenJobAd(_two); }
public void TestSimpleSort() { _australia = _locationQuery.GetCountry("Australia"); var employer = _employerAccountsCommand.CreateTestEmployer(0, _organisationsCommand.CreateTestOrganisation(0)); var one = employer.CreateTestJobAd("Title one", "The content for the first ad"); one.CreatedTime = DateTime.Now.AddDays(-1); // Just to make sure it's before "two"; we only index days. one.Description.Salary = new Salary { LowerBound = 50000, UpperBound = 60000, Rate = SalaryRate.Year, Currency = Currency.AUD }; _jobAdsCommand.CreateJobAd(one); _jobAdsCommand.OpenJobAd(one); var two = employer.CreateTestJobAd("Title two", "Different content for the second ad"); _locationQuery.ResolvePostalSuburb(two.Description.Location, _australia, "2000"); two.Description.CompanyName = "Really Bad Employers"; two.Description.JobTypes = JobTypes.Contract; two.Description.Industries = new List <Industry> { _industriesQuery.GetIndustry("Other") }; _jobAdsCommand.CreateJobAd(two); _jobAdsCommand.OpenJobAd(two); var member = new Member { Id = Guid.NewGuid() }; var flagList = _jobAdFlagListsQuery.GetFlagList(member); _memberJobAdListsCommand.AddJobAdToFlagList(member, flagList, one.Id); _memberJobAdListsCommand.AddJobAdToFlagList(member, flagList, two.Id); // Title only var criteria = new JobAdSearchSortCriteria { SortOrder = JobAdSortOrder.JobType }; TestSort(member, criteria, one, two); // Title and content criteria = new JobAdSearchSortCriteria { SortOrder = JobAdSortOrder.CreatedTime }; TestSort(member, criteria, two, one); // No results //criteria = new JobAdSortCriteria { AdTitle = "one", Keywords = "second" }; //TestSort(criteria); }
public void TestExternalJobAd() { var employer = CreateEmployer(); var jobAd = employer.CreateTestJobAd(); jobAd.Integration.IntegratorUserId = _careerOneQuery.GetIntegratorUser().Id; _jobAdsCommand.CreateJobAd(jobAd); _jobAdsCommand.OpenJobAd(jobAd); AssertJsonSuccess(Deserialize <JsonResponseModel>(Post(GetExternallyAppliedUrl(jobAd.Id)))); }
private JobAd CreateJobAd(int index) { var jobAd = new JobAd { Id = Guid.NewGuid(), Status = JobAdStatus.Open, Title = string.Format("Job Ad {0}", index), CreatedTime = DateTime.Now.AddDays(-100), JobDescription = new JobDescription { BulletPoints = new[] { "good verbal communication", "self management and independency", "bullet point 3" }, Content = "Mutley, you snickering, floppy eared hound. When courage is needed, you're never around.", JobTypes = JobTypes.FullTime, Industries = new List <Industry> { _industriesQuery.GetIndustry("Engineering") }, Location = new LocationReference(_locationQuery.GetCountrySubdivision(_australia, "QLD")), } }; _jobAdsCommand.CreateJobAd(jobAd); return(jobAd); }
private static JobAd PostTestJobAd(this IJobAdsCommand jobAdsCommand, JobAd jobAd, JobAdStatus jobStatus) { jobAdsCommand.CreateJobAd(jobAd); switch (jobStatus) { case JobAdStatus.Open: jobAdsCommand.OpenJobAd(jobAd); break; case JobAdStatus.Closed: jobAdsCommand.OpenJobAd(jobAd); jobAdsCommand.CloseJobAd(jobAd); break; case JobAdStatus.Deleted: jobAdsCommand.DeleteJobAd(jobAd); break; default: //do nothing - job is created in draft state break; } return(jobAd); }
public static void PostJobAd(this IJobAdsCommand jobAdsCommand, JobAd jobAd) { // Creating the job ad puts it into the Draft state so open it as well. jobAdsCommand.CreateJobAd(jobAd); jobAdsCommand.OpenJobAd(jobAd); }
private JobAd CreateJobAd(IHasId <Guid> employer, JobAdStatus status) { var jobAd = new JobAd { Id = Guid.NewGuid(), Status = status, Title = "Best Job in the World", CreatedTime = DateTime.Now, PosterId = employer.Id, Description = { BulletPoints = new[] { "good verbal communication", "self management and independency", "bullet point 3" }, Content = "Mutley, you snickering, floppy eared hound. When courage is needed, you're never around.", JobTypes = JobTypes.FullTime, Industries = new List <Industry> { _industriesQuery.GetIndustry("Engineering") }, }, }; _jobAdsCommand.CreateJobAd(jobAd); _jobAdsCommand.OpenJobAd(jobAd); if (status == JobAdStatus.Closed) { _jobAdsCommand.CloseJobAd(jobAd); } return(jobAd); }
private void CreateNewJobAd(string adContent, JobAdStatus adStatus, IHasId <Guid> adPoster, bool adHideContactDetails, ContactDetails adContactDetails, string summary, string bulletpoint1, string bulletpoint2, string bulletpoint3, FileReference logoImg, string adTitle, string positionTitle, JobTypes jobtypes, bool isResidenacyRequired, string externalRef, decimal?maxsalary, decimal?minsalary, string package, IList <Industry> reqIndustries, string companyname, LocationReference jobLocation, DateTime expiryDate) { var bulletPoints = new[] { bulletpoint1, bulletpoint2, bulletpoint3 }; var newJobAd = new JobAd { Status = adStatus, PosterId = adPoster.Id, Visibility = { HideContactDetails = adHideContactDetails, HideCompany = false, }, ContactDetails = adContactDetails, Title = adTitle, Integration = { ExternalReferenceId = externalRef }, LogoId = logoImg == null ? (Guid?)null : logoImg.Id, ExpiryTime = expiryDate, Description = { CompanyName = companyname, Content = adContent, PositionTitle = positionTitle, ResidencyRequired = isResidenacyRequired, JobTypes = jobtypes, Industries = reqIndustries, Summary = summary, Salary = (minsalary.HasValue || maxsalary.HasValue ? new Salary { Currency = Currency.AUD, LowerBound = minsalary, UpperBound = maxsalary, Rate = SalaryRate.Year, } : null), Package = package, BulletPoints = bulletPoints, Location = jobLocation, } }; _jobAdsCommand.CreateJobAd(newJobAd); if (adStatus == JobAdStatus.Open) { _jobAdsCommand.OpenJobAd(newJobAd); } else if (adStatus == JobAdStatus.Closed) { _jobAdsCommand.CloseJobAd(newJobAd); } return; }
private Guid CreateJobAd(IntegratorUser integratorUser, Guid employerId, JobAdElement jobAdElement) { var jobAd = jobAdElement.Map(_industriesQuery, _locationQuery); jobAd.PosterId = employerId; jobAd.Integration.IntegratorUserId = integratorUser.Id; _jobAdsCommand.CreateJobAd(jobAd); _jobAdsCommand.OpenJobAd(jobAd); return(jobAd.Id); }
public void TestAnonymous() { var employer = CreateEmployer(); var jobAd = employer.CreateTestJobAd(); _jobAdsCommand.CreateJobAd(jobAd); _jobAdsCommand.OpenJobAd(jobAd); Get(HomeUrl); var anonymousId = GetAnonymousId(); Assert.IsTrue(_jobAdViewsQuery.GetViewedJobAdIds(anonymousId, new[] { jobAd.Id }).CollectionEqual(new Guid[0])); Assert.AreEqual(0, _jobAdViewsQuery.GetViewedCount(jobAd.Id)); // View. AssertJsonSuccess(Deserialize <JsonResponseModel>(Post(GetViewedUrl(jobAd.Id)))); Assert.IsTrue(_jobAdViewsQuery.GetViewedJobAdIds(anonymousId, new[] { jobAd.Id }).CollectionEqual(new[] { jobAd.Id })); Assert.IsTrue(_jobAdViewsQuery.HasViewedJobAd(anonymousId, jobAd.Id)); }
protected JobAd CreateJobAd(IEmployer employer, Action <JobAd> prepareCreate) { var jobAd = employer.CreateTestJobAd(); if (prepareCreate != null) { prepareCreate(jobAd); } _jobAdsCommand.CreateJobAd(jobAd); _jobAdsCommand.OpenJobAd(jobAd); return(jobAd); }
private JobAd PostJobAd(IEmployer employer, DateTime time) { var jobAd = employer.CreateTestJobAd(); jobAd.CreatedTime = time; _jobAdsCommand.CreateJobAd(jobAd); // To get the timing right go directly to the repository. _jobAdsRepository.ChangeStatus(jobAd.Id, JobAdStatus.Open, null, time); jobAd.Status = JobAdStatus.Open; return(jobAd); }
void IAnonymousJobAdsCommand.CreateJobAd(AnonymousUser user, JobAd jobAd) { var poster = _jobPostersCommand.GetJobPoster(user.Id); if (poster == null) { poster = new JobPoster { Id = user.Id }; _jobPostersCommand.CreateJobPoster(poster); } jobAd.PosterId = poster.Id; _jobAdsCommand.CreateJobAd(jobAd); }
private JobAd CreateNewJobAd(string adContent, JobAdStatus adStatus, IHasId <Guid> adPoster, bool adHideContactDetails, ContactDetails adContactDetails, string summary, string bulletpoint1, string bulletpoint2, string bulletpoint3, FileReference logoImg, string adTitle, string positionTitle, JobTypes jobtypes, bool isResidenacyRequired, string externalRef, string maxsalary, string minsalary, string package, IList <Industry> reqIndustries, string companyname, LocationReference jobLocation, DateTime expiryDate) { var salary = SalaryExtensions.Parse(minsalary, maxsalary, SalaryRate.Year, true); var bulletPoints = new[] { bulletpoint1, bulletpoint2, bulletpoint3 }; var newJobAd = new JobAd { Status = adStatus, PosterId = adPoster.Id, Visibility = { HideContactDetails = adHideContactDetails, HideCompany = false, }, ContactDetails = adContactDetails, Title = adTitle, Integration = { ExternalReferenceId = externalRef }, LogoId = logoImg == null ? (Guid?)null : logoImg.Id, ExpiryTime = expiryDate, Description = { CompanyName = companyname, Content = adContent, PositionTitle = positionTitle, ResidencyRequired = isResidenacyRequired, JobTypes = jobtypes, Industries = reqIndustries, Summary = summary, Salary = salary, Package = package, BulletPoints = bulletPoints, Location = jobLocation, } }; _jobAdsCommand.CreateJobAd(newJobAd); _jobAdsCommand.OpenJobAd(newJobAd); return(newJobAd); }
protected JobAd CreateJobAd(JobPoster jobPoster, int index, Action <JobAd> initialiseJobAd) { var jobAd = new JobAd { PosterId = jobPoster.Id, Title = string.Format(TitleFormat, index), Description = new JobAdDescription { Content = string.Format(ContentFormat, index), }, }; initialiseJobAd(jobAd); _jobAdsCommand.CreateJobAd(jobAd); _jobAdsCommand.OpenJobAd(jobAd); _jobAdSortService.UpdateJobAd(jobAd.Id); return(jobAd); }
private static JobAd PostTestJobAd(this IJobAdsCommand jobAdsCommand, JobAd jobAd, JobAdStatus jobStatus) { jobAdsCommand.CreateJobAd(jobAd); switch (jobStatus) { case JobAdStatus.Open: jobAdsCommand.OpenJobAd(jobAd); break; case JobAdStatus.Closed: jobAdsCommand.OpenJobAd(jobAd); jobAdsCommand.CloseJobAd(jobAd); break; case JobAdStatus.Deleted: jobAdsCommand.DeleteJobAd(jobAd); break; } return(jobAd); }
protected JobAd CreateJobAd(int index, JobPoster jobPoster, Action <JobAd> prepare) { var jobAd = new JobAd { Id = Guid.NewGuid(), PosterId = jobPoster.Id, Title = string.Format(TitleFormat, index), Description = { Content = string.Format(ContentFormat, index), }, }; if (prepare != null) { prepare(jobAd); } _jobAdsCommand.CreateJobAd(jobAd); return(jobAd); }
protected JobAd PostJobAd(IEmployer employer, Action <JobAd> action) { var jobAd = new JobAd { PosterId = employer.Id, Title = Title, Description = { Content = Content, } }; if (action != null) { action(jobAd); } _jobAdsCommand.CreateJobAd(jobAd); _jobAdsCommand.OpenJobAd(jobAd); return(jobAd); }
private JobAd CreateJobAd(int index, IEmployer employer, decimal?salaryLowerBound, decimal?salaryUpperBound, string title, string positionTitle, string contactEmailAddress) { // Create a job ad that doesn't have any candidate matches on the salary - no email should be sent. var jobAd = employer.CreateTestJobAd(); jobAd.CreatedTime = DateTime.Now.AddDays(-1).AddMinutes(-1 * index); jobAd.Description.Salary = salaryLowerBound == null && salaryUpperBound == null ? null : new Salary { LowerBound = salaryLowerBound, UpperBound = salaryUpperBound, Rate = SalaryRate.Year, Currency = Currency.AUD }; jobAd.Title = title; jobAd.Description.PositionTitle = positionTitle; if (!string.IsNullOrEmpty(contactEmailAddress)) { jobAd.ContactDetails.EmailAddress = contactEmailAddress; } _jobAdsCommand.CreateJobAd(jobAd); _jobAdsCommand.OpenJobAd(jobAd); return(jobAd); }
private void MapProductionFeed(string file, bool saveParsedData) { if (saveParsedData) { JobAdSearchHost.Start(); JobAdSortHost.Start(); } const string postId = "123456"; var jobPosterId = CreateEmployer(0).Id; var integrationUserId = _jxtQuery.GetIntegratorUser().Id; var posts = GetJobFeed(file); IJobFeedMapper <Job> mapper = new JobAdMapper(_locationQuery, _industriesQuery, null); foreach (var post in posts) { var jobAd = new JobAd { PosterId = jobPosterId, Integration = { IntegratorReferenceId = postId, ExternalApplyUrl = post.ApplicationMethod.Value, IntegratorUserId = integrationUserId, }, }; mapper.ApplyPostData(post, jobAd); if (saveParsedData) { _jobAdsCommand.CreateJobAd(jobAd); _jobAdsCommand.OpenJobAd(jobAd); } } }
private void MapProductionFeed(string file, bool saveParsedData) { if (saveParsedData) { JobAdSearchHost.Start(); JobAdSortHost.Start(); } const string postId = "123456"; var jobPosterId = new Guid("D12C0E2E-E464-491C-96D2-15D79F98E506"); var integrationUserId = _careerOneQuery.GetIntegratorUser().Id; var posts = GetJobFeed(file); IJobFeedMapper <Job> mapper = new JobAdMapper(_locationQuery, _industriesQuery, null); foreach (var post in posts) { var jobAd = new JobAd { PosterId = jobPosterId, Integration = { IntegratorReferenceId = postId, ExternalApplyUrl = string.Format("http://jobview.careerone.com.au/GetJob.aspx?JobID={0}", postId), IntegratorUserId = integrationUserId, }, }; mapper.ApplyPostData(post, jobAd); if (saveParsedData) { _jobAdsCommand.CreateJobAd(jobAd); _jobAdsCommand.OpenJobAd(jobAd); } } }
public PostAdvertResponseMessage PostAdvert(PostAdvertRequestMessage request) { const string method = "PostAdvert"; EventSource.Raise(Event.Information, method, Event.Arg("request", request)); IntegratorUser integratorUser; IEmployer jobPoster; CheckUser(request.UserCredentials, out integratorUser, out jobPoster); var errors = new List <string>(); var report = new PostAdvertReport(); foreach (var postAd in request.PostAdvert.Adverts.PostAdvert) { report.JobAds++; try { if (_jobAdIntegrationQuery.GetOpenJobAdIds(integratorUser.Id, postAd.JobReference).Count != 0) { // Already exists as a JobG8 ad var message = string.Format("Job ad to be posted, '{0}', already exists.", postAd.JobReference); EventSource.Raise(Event.Error, method, message, Event.Arg("postAd", postAd)); errors.Add(message); report.Duplicates++; } else { var jobAd = MapJobAd(postAd); jobAd.PosterId = jobPoster.Id; jobAd.Features = _jobAdIntegrationQuery.GetDefaultFeatures(); jobAd.FeatureBoost = _jobAdIntegrationQuery.GetDefaultFeatureBoost(); jobAd.Integration.IntegratorUserId = integratorUser.Id; if (_externalJobAdsCommand.CanCreateJobAd(jobAd)) { _jobAdsCommand.CreateJobAd(jobAd); // The application form, for now, needs to be directly saved into the database. _jobAdsCommand.CreateApplicationRequirements(jobAd.Id, postAd.ApplicationFormXML); _jobAdsCommand.OpenJobAd(jobAd); report.Posted++; } else { var message = string.Format("Job ad to be posted, '{0}' ([{1}] '{2}')," + " was already posted by another integrator.", postAd.JobReference, postAd.ClientReference, postAd.Position); EventSource.Raise(Event.Error, method, message, Event.Arg("postAd", postAd)); errors.Add(message); } } } catch (ServiceEndUserException e) { EventSource.Raise(Event.Error, method, e, null, Event.Arg("postAd", postAd)); errors.Add(string.Format("JobReference='{0}': {1}", postAd.JobReference, e.Message)); report.Failed++; } catch (Exception e) { EventSource.Raise(Event.Error, method, e, null, Event.Arg("postAd", postAd)); errors.Add(string.Format("JobReference='{0}': Unexpected error.", postAd.JobReference)); report.Failed++; } } // Record it. _jobAdIntegrationReportsCommand.CreateJobAdIntegrationEvent(new JobAdImportPostEvent { Success = true, IntegratorUserId = integratorUser.Id, PosterId = jobPoster.Id, JobAds = report.JobAds, Failed = report.Failed, Posted = report.Posted, Duplicates = report.Duplicates }); var response = new PostAdvertResponseMessage { PostAdvertResponse = new Response { Success = string.Join("\r\n", errors.ToArray()) } }; EventSource.Raise(Event.Information, method, string.Format("{0} ads processed; {1} new ads, {2} duplicate ads, {3} errors.", report.JobAds, report.Posted, report.Duplicates, report.Failed), Event.Arg("response", response)); return(response); }
void IEmployerJobAdsCommand.CreateJobAd(IEmployer employer, JobAd jobAd) { jobAd.PosterId = employer.Id; _jobAdsCommand.CreateJobAd(jobAd); }