Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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))));
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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;
        }
Ejemplo n.º 8
0
        private JobAd CreateFeaturedJobAd(IEmployer employer, int index)
        {
            var jobAd = employer.CreateTestJobAd(string.Format(JobTitleFormat, index));

            jobAd.CreatedTime = DateTime.Now.AddDays(-1);
            _jobAdsCommand.CreateJobAd(jobAd);
            _jobAdsCommand.OpenJobAd(jobAd);
            return(jobAd);
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
        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));
        }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        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);
        }
Ejemplo n.º 13
0
        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);
        }
Ejemplo n.º 14
0
        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);
        }
Ejemplo n.º 15
0
        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);
        }
Ejemplo n.º 16
0
        void IEmployerJobAdsCommand.OpenJobAd(IEmployer employer, JobAd jobAd, bool checkLimits)
        {
            if (!CanAccess(employer, jobAd))
            {
                throw new JobAdPermissionsException(employer, jobAd.Id);
            }

            // Check limits.

            if (checkLimits)
            {
                CheckLimits(employer.Id);
            }

            // Exercise a credit.

            _employerCreditsCommand.ExerciseJobAdCredit(jobAd);

            // Open the ad.

            _jobAdsCommand.OpenJobAd(jobAd);
        }
Ejemplo n.º 17
0
        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);
        }
Ejemplo n.º 18
0
        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);
                }
            }
        }
Ejemplo n.º 19
0
        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);
                }
            }
        }
Ejemplo n.º 20
0
        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);
        }