public void ConvertFromTest(bool socAssigned)
        {
            //Assign
            SetupSocCall(socAssigned);
            var jobprofileConverter = new JobProfileConverter(fakeRelatedClassificationsRepository, fakeDynamicContentExtensions, htbContentPropertyConverter, wywdPropertyConverter);

            var dummyRelatedItems = A.CollectionOfDummy <string>(1).AsEnumerable().AsQueryable();

            A.CallTo(() => fakeDynamicContentExtensions.GetRelatedContentUrl(A <DynamicContent> ._, A <string> ._)).Returns(dummyRelatedItems);

            //Act
            var jobProfile = jobprofileConverter.ConvertFrom(fakeDynamicContentItem);

            //Assert
            A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <Lstring>(A <DynamicContent> ._, A <string> ._))
            .MustHaveHappened();
            A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <bool>(A <DynamicContent> ._, A <string> ._))
            .MustHaveHappened();
            A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <decimal?>(A <DynamicContent> ._, A <string> ._))
            .MustHaveHappened();

            A.CallTo(() => fakeDynamicContentExtensions.GetFieldChoiceLabel(A <DynamicContent> ._, A <string> ._))
            .MustHaveHappened();

            A.CallTo(() => fakeRelatedClassificationsRepository.GetRelatedClassifications(A <DynamicContent> ._, A <string> ._, A <string> ._)).MustHaveHappened();
            A.CallTo(() => htbContentPropertyConverter.ConvertFrom(A <DynamicContent> ._)).MustHaveHappened();

            A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <decimal?>(A <DynamicContent> ._, nameof(JobProfile.SalaryStarter)))
            .MustHaveHappened();
            jobProfile.SalaryStarter.Should().Be(10);

            A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <decimal?>(A <DynamicContent> ._, nameof(JobProfile.SalaryExperienced)))
            .MustHaveHappened();
            jobProfile.SalaryExperienced.Should().Be(20);

            if (socAssigned)
            {
                A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <Lstring>(A <DynamicContent> ._, nameof(JobProfile.SOCCode)))
                .MustHaveHappened();
                jobProfile.SOCCode.Should().NotBeNullOrEmpty();
            }
            else
            {
                A.CallTo(() => fakeDynamicContentExtensions.GetFieldValue <Lstring>(A <DynamicContent> ._, nameof(JobProfile.SOCCode)))
                .MustNotHaveHappened();
                jobProfile.SOCCode.Should().BeNullOrEmpty();
            }
        }
Exemplo n.º 2
0
        public JobProfile ConvertFrom(DynamicContent content)
        {
            var jobProfile = new JobProfile
            {
                Title                              = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfile.Title)),
                AlternativeTitle                   = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfile.AlternativeTitle)),
                WidgetContentTitle                 = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfile.WidgetContentTitle)),
                Overview                           = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfile.Overview)),
                IsLMISalaryFeedOverriden           = dynamicContentExtensions.GetFieldValue <bool?>(content, nameof(JobProfile.IsLMISalaryFeedOverriden)),
                SalaryStarter                      = dynamicContentExtensions.GetFieldValue <decimal?>(content, nameof(JobProfile.SalaryStarter)),
                SalaryExperienced                  = dynamicContentExtensions.GetFieldValue <decimal?>(content, nameof(JobProfile.SalaryExperienced)),
                MinimumHours                       = dynamicContentExtensions.GetFieldValue <decimal?>(content, nameof(JobProfile.MinimumHours)),
                MaximumHours                       = dynamicContentExtensions.GetFieldValue <decimal?>(content, nameof(JobProfile.MaximumHours)),
                CareerPathAndProgression           = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfile.CareerPathAndProgression)),
                Skills                             = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfile.Skills)),
                HowToBecome                        = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfile.HowToBecome)),
                WhatYouWillDo                      = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfile.WhatYouWillDo)),
                WorkingHoursPatternsAndEnvironment = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfile.WorkingHoursPatternsAndEnvironment)),
                Salary                             = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfile.Salary)),
                CourseKeywords                     = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfile.CourseKeywords)),

                //Need to use a string to get the content cannot use JobProfile.JobProfileCategories as this is already used in the search
                //index and we will get a clash
                JobProfileCategoryIdCollection = dynamicContentExtensions.GetFieldValue <IList <Guid> >(content, RelatedJobProfileCategoriesField),
                UrlName              = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfile.UrlName)),
                DoesNotExistInBAU    = dynamicContentExtensions.GetFieldValue <bool>(content, nameof(JobProfile.DoesNotExistInBAU)),
                BAUSystemOverrideUrl = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfile.BAUSystemOverrideUrl)),
                IsImported           = dynamicContentExtensions.GetFieldValue <bool>(content, nameof(JobProfile.IsImported)),

                // How To Become section
                HowToBecomeData    = htbContentPropertyConverter.ConvertFrom(content),
                Restrictions       = GetRestrictions(content, RelatedRestrictionsField),
                OtherRequirements  = dynamicContentExtensions.GetFieldValue <Lstring>(content, OtherRequirementsField),
                DynamicTitlePrefix = dynamicContentExtensions.GetFieldChoiceLabel(content, nameof(JobProfile.DynamicTitlePrefix)),

                //What You will do section
                WhatYouWillDoData  = whatYouWillDoPropertyConverter.ConvertFrom(content),
                RelatedSkills      = dynamicContentExtensions.GetRelatedContentUrl(content, RelatedSkillsField)?.ToList(),
                DigitalSkillsLevel = dynamicContentExtensions.GetFieldChoiceLabel(content, nameof(JobProfile.DigitalSkillsLevel))
            };

            var socItem = dynamicContentExtensions.GetRelatedItems(content, Constants.SocField, 1).FirstOrDefault();

            if (socItem != null)
            {
                jobProfile.SOCCode = dynamicContentExtensions.GetFieldValue <Lstring>(socItem, nameof(JobProfile.SOCCode));
                jobProfile.ONetOccupationalCode =
                    dynamicContentExtensions.GetFieldValue <Lstring>(socItem, nameof(JobProfile.ONetOccupationalCode));
            }

            jobProfile.WorkingHoursDetails   = relatedClassificationsRepository.GetRelatedClassifications(content, nameof(JobProfile.WorkingHoursDetails), nameof(JobProfile.WorkingHoursDetails)).FirstOrDefault();
            jobProfile.WorkingPattern        = relatedClassificationsRepository.GetRelatedClassifications(content, nameof(JobProfile.WorkingPattern), nameof(JobProfile.WorkingPattern)).FirstOrDefault();
            jobProfile.WorkingPatternDetails = relatedClassificationsRepository.GetRelatedClassifications(content, nameof(JobProfile.WorkingPatternDetails), nameof(JobProfile.WorkingPatternDetails)).FirstOrDefault();

            //PSF
            jobProfile.RelatedInterests           = dynamicContentExtensions.GetRelatedContentUrl(content, RelatedInterestsField);
            jobProfile.RelatedEnablers            = dynamicContentExtensions.GetRelatedContentUrl(content, RelatedEnablersField);
            jobProfile.RelatedEntryQualifications = dynamicContentExtensions.GetRelatedContentUrl(content, RelatedEntryQualificationsField);
            jobProfile.RelatedTrainingRoutes      = dynamicContentExtensions.GetRelatedContentUrl(content, RelatedTrainingRoutesField);
            jobProfile.RelatedPreferredTaskTypes  = dynamicContentExtensions.GetRelatedContentUrl(content, RelatedPreferredTaskTypesField);
            jobProfile.RelatedJobAreas            = dynamicContentExtensions.GetRelatedContentUrl(content, RelatedJobAreasField);

            return(jobProfile);
        }
Exemplo n.º 3
0
        public JobProfileMessage ConvertFrom(DynamicContent content)
        {
            DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager(Constants.DynamicProvider);
            var jobProfileMessage = new JobProfileMessage
            {
                JobProfileId             = dynamicContentExtensions.GetFieldValue <Guid>(content, content.GetContentItemIdKey()),
                Title                    = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfileMessage.Title)),
                WidgetContentTitle       = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfileMessage.WidgetContentTitle)),
                AlternativeTitle         = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfileMessage.AlternativeTitle)),
                Overview                 = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfileMessage.Overview)),
                SalaryStarter            = dynamicContentExtensions.GetFieldValue <decimal?>(content, nameof(JobProfileMessage.SalaryStarter)),
                SalaryExperienced        = dynamicContentExtensions.GetFieldValue <decimal?>(content, nameof(JobProfileMessage.SalaryExperienced)),
                MinimumHours             = dynamicContentExtensions.GetFieldValue <decimal?>(content, nameof(JobProfileMessage.MinimumHours)),
                MaximumHours             = dynamicContentExtensions.GetFieldValue <decimal?>(content, nameof(JobProfileMessage.MaximumHours)),
                CareerPathAndProgression = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfileMessage.CareerPathAndProgression)),
                CourseKeywords           = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfileMessage.CourseKeywords)),

                //Need to use a string to get the content cannot use JobProfileMessage.JobProfileCategories as this is already used in the search
                //index and we will get a clash
                UrlName    = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfileMessage.UrlName)),
                IsImported = dynamicContentExtensions.GetFieldValue <bool>(content, nameof(JobProfileMessage.IsImported)),

                // How To Become section
                HowToBecomeData    = htbContentPropertyConverter.ConvertFrom(content),
                RelatedCareersData = GetRelatedCareersData(content, Constants.RelatedCareerProfiles),
                Restrictions       = GetRestrictions(content, RelatedRestrictionsField),
                OtherRequirements  = dynamicContentExtensions.GetFieldValue <Lstring>(content, OtherRequirementsField),
                DynamicTitlePrefix = dynamicContentExtensions.GetFieldChoiceLabel(content, nameof(JobProfileMessage.DynamicTitlePrefix)),
                DigitalSkillsLevel = dynamicContentExtensions.GetFieldChoiceLabel(content, nameof(JobProfileMessage.DigitalSkillsLevel)),
            };

            jobProfileMessage.IncludeInSitemap = content.IncludeInSitemap;

            //What You will do section
            jobProfileMessage.WhatYouWillDoData = GetWYDRelatedDataForJobProfiles(content);

            //Related Skills Data
            jobProfileMessage.SocSkillsMatrixData = GetSocSkillMatrixItems(content, Constants.RelatedSkills);

            //Get SOC Code data
            var socItem = dynamicContentExtensions.GetRelatedItems(content, Constants.SocField, 1).FirstOrDefault();

            //SocCode Data
            jobProfileMessage.SocCodeData = GenerateSocData(content, socItem);

            //Working Pattern Details
            jobProfileMessage.WorkingPatternDetails = MapClassificationData(content.GetValue <TrackedList <Guid> >(Constants.WorkingPatternDetail));

            //Working Hours Details
            jobProfileMessage.WorkingHoursDetails = MapClassificationData(content.GetValue <TrackedList <Guid> >(Constants.WorkingHoursDetail));

            //Working Pattern
            jobProfileMessage.WorkingPattern = MapClassificationData(content.GetValue <TrackedList <Guid> >(Constants.WorkingPattern));

            //Hidden Alternative Title
            jobProfileMessage.HiddenAlternativeTitle = MapClassificationData(content.GetValue <TrackedList <Guid> >(Constants.HiddenAlternativeTitle));

            //Job Profile Specialism
            jobProfileMessage.JobProfileSpecialism = MapClassificationData(content.GetValue <TrackedList <Guid> >(Constants.JobProfileSpecialism));

            if (socItem != null)
            {
                jobProfileMessage.SocLevelTwo = dynamicContentExtensions.GetFieldValue <Lstring>(socItem, Constants.SOCCode).ToString().Substring(0, 2);
            }

            jobProfileMessage.LastModified         = dynamicContentExtensions.GetFieldValue <DateTime>(content, nameof(JobProfileMessage.LastModified));
            jobProfileMessage.CanonicalName        = dynamicContentExtensions.GetFieldValue <Lstring>(content, nameof(JobProfileMessage.UrlName)).ToLower();
            jobProfileMessage.JobProfileCategories = GetJobCategories(dynamicContentExtensions.GetFieldValue <IList <Guid> >(content, RelatedJobProfileCategoriesField));
            return(jobProfileMessage);
        }