Exemplo n.º 1
0
        public void WhenCreatingFrameworkDocumentShouldTrimTitleWhiteSpaces()
        {
            var frameworkMetaData = new FrameworkMetaData
            {
                EffectiveFrom = DateTime.Parse("10-Feb-14"),
                EffectiveTo   = DateTime.MinValue,
                FworkCode     = 616,
                PwayCode      = 1,
                NasTitle      = " Accounting ",
                PathwayName   = "Accounting",
                ProgType      = 3
            };

            var mapper = new ElasticsearchMapper(_settings.Object, Mock.Of <IOrganisationTypeProcessor>());

            var framework = mapper.CreateFrameworkDocument(frameworkMetaData);

            framework.Title.Should().Be("Accounting: Accounting");
        }
Exemplo n.º 2
0
        public void WhenCreatingFrameworkDocumentAndPathwaySameAsTitleButWithTrailingSpace()
        {
            var frameworkMetaData = new FrameworkMetaData
            {
                EffectiveFrom = DateTime.Parse("10-Feb-14"),
                EffectiveTo   = DateTime.MinValue,
                FworkCode     = 616,
                PwayCode      = 1,
                NasTitle      = "Accounting",
                PathwayName   = "Accounting ",
                ProgType      = 3
            };

            var mapper = new ElasticsearchMapper(_settings.Object, Mock.Of <IOrganisationTypeProcessor>());

            var framework = mapper.CreateFrameworkDocument(frameworkMetaData);

            framework.Title.Should().Be("Accounting: Accounting");
            framework.Level.Should().Be(2);
            framework.FrameworkId.Should().Be(string.Format(_frameworkIdFormat, frameworkMetaData.FworkCode, frameworkMetaData.ProgType, frameworkMetaData.PwayCode));
        }
Exemplo n.º 3
0
        public ApprenticeshipDocument CreateFrameworkDocument(FrameworkMetaData frameworkMetaData)
        {
            // Trim off any whitespaces in the title or the Pathway Name
            frameworkMetaData.NasTitle    = frameworkMetaData.NasTitle?.Trim();
            frameworkMetaData.PathwayName = frameworkMetaData.PathwayName?.Trim();

            return(new ApprenticeshipDocument(ElasticsearchDocumentTypes.FRAMEWORK_DOCUMENT)
            {
                FrameworkId = string.Format(_settings.FrameworkIdFormat, frameworkMetaData.FworkCode, frameworkMetaData.ProgType, frameworkMetaData.PwayCode),
                Published = frameworkMetaData.Published,
                Title = CreateFrameworkTitle(frameworkMetaData.NasTitle, frameworkMetaData.PathwayName),
                FrameworkCode = frameworkMetaData.FworkCode,
                FrameworkName = frameworkMetaData.NasTitle,
                PathwayCode = frameworkMetaData.PwayCode,
                PathwayName = frameworkMetaData.PathwayName,
                ProgType = frameworkMetaData.ProgType,
                Level = MapToLevelFromProgType(frameworkMetaData.ProgType),
                JobRoleItems = frameworkMetaData.JobRoleItems?.Select(m => new JobRoleItem {
                    Title = m.Title, Description = m.Description
                }),
                Keywords = frameworkMetaData.Keywords,
                FundingPeriods = frameworkMetaData.FundingPeriods,
                FundingCap = frameworkMetaData.FundingCap,
                Duration = frameworkMetaData.Duration,
                TypicalLength = frameworkMetaData.TypicalLength,
                ExpiryDate = frameworkMetaData.EffectiveTo,
                SectorSubjectAreaTier1 = frameworkMetaData.SectorSubjectAreaTier1,
                SectorSubjectAreaTier2 = frameworkMetaData.SectorSubjectAreaTier2,
                CompletionQualifications = frameworkMetaData.CompletionQualifications,
                EntryRequirements = frameworkMetaData.EntryRequirements,
                ProfessionalRegistration = frameworkMetaData.ProfessionalRegistration,
                FrameworkOverview = frameworkMetaData.FrameworkOverview,
                CompetencyQualification = frameworkMetaData.CompetencyQualification,
                KnowledgeQualification = frameworkMetaData.KnowledgeQualification,
                CombinedQualification = frameworkMetaData.CombinedQualification,
                EffectiveFrom = frameworkMetaData.EffectiveFrom,
                EffectiveTo = frameworkMetaData.EffectiveTo
            });
        }
Exemplo n.º 4
0
        public void WhenCreatingFrameworkDocument()
        {
            var frameworkMetaData = new FrameworkMetaData
            {
                EffectiveFrom = DateTime.Parse("10-Feb-14"),
                EffectiveTo   = DateTime.MinValue,
                FworkCode     = 123,
                PwayCode      = 1,
                NasTitle      = "Sustainable Resource Operations and Management",
                PathwayName   = "Higher Apprenticeship in Sustainable Resource Operations and Management",
                ProgType      = 20,
                JobRoleItems  = new List <JobRoleItem>
                {
                    new JobRoleItem {
                        Title = "Title 1", Description = "Description 1"
                    }
                },
                Keywords      = new[] { "keyword1", "keyword2" },
                TypicalLength = new TypicalLength {
                    From = 12, To = 24, Unit = "m"
                },
                Duration = 12
            };

            var mapper = new ElasticsearchMapper(_settings.Object, Mock.Of <IOrganisationTypeProcessor>());

            var framework = mapper.CreateFrameworkDocument(frameworkMetaData);

            framework.Title.Should().Be("Sustainable Resource Operations and Management: Higher Apprenticeship in Sustainable Resource Operations and Management");
            framework.Level.Should().Be(4);
            framework.FrameworkId.Should().Be(string.Format(_frameworkIdFormat, frameworkMetaData.FworkCode, frameworkMetaData.ProgType, frameworkMetaData.PwayCode));
            framework.JobRoleItems.Count().Should().Be(1);
            framework.Keywords.Should().Contain(new[] { "keyword1", "keyword2" });
            framework.TypicalLength.From.ShouldBeEquivalentTo(12);
            framework.TypicalLength.To.ShouldBeEquivalentTo(24);
            framework.Duration.Should().Be(12);
        }
Exemplo n.º 5
0
        public void Init()
        {
            _mockAngleSharpService  = new Mock <IAngleSharpService>();
            _mockAppServiceSettings = new Mock <IAppServiceSettings>();
            _mockCsvService         = new Mock <IReadMetaDataFromCsv>();
            _mockFileExtractor      = new Mock <IUnzipStream>();
            _mockHttpGetFile        = new Mock <IHttpGetFile>();
            _mockLogger             = new Mock <ILog>();

            _linkEndPoints = new List <string> {
                "endpoint"
            };
            _framework = new FrameworkMetaData
            {
                FworkCode     = 500,
                PwayCode      = 1,
                ProgType      = 2,
                EffectiveFrom = DateTime.Now.AddDays(-4),
                EffectiveTo   = DateTime.Now.AddDays(4)
            };

            _apprenticeshipComponentType = new ApprenticeshipComponentTypeMetaData
            {
                ApprenticeshipComponentType = 1,
            };

            _frameworkAim = new FrameworkAimMetaData
            {
                FworkCode = _framework.FworkCode,
                PwayCode  = _framework.PwayCode,
                ProgType  = _framework.ProgType,
                ApprenticeshipComponentType = _apprenticeshipComponentType.ApprenticeshipComponentType,
                LearnAimRef = "5001738X"
            };

            _learningDelivery = new LearningDeliveryMetaData
            {
                LearnAimRef      = _frameworkAim.LearnAimRef,
                LearnAimRefTitle = "Test Learning Delivery"
            };

            _fundingMetaData = new FundingMetaData
            {
                LearnAimRef     = _frameworkAim.LearnAimRef,
                EffectiveFrom   = DateTime.Now.AddYears(-2),
                EffectiveTo     = DateTime.Now.AddDays(20),
                FundingCategory = "APP_ACT_COST", // This category is used to determine an apprenticeship funded qualification
                RateWeighted    = 150
            };

            _appFundingMetaData = new ApprenticeshipFundingMetaData
            {
                ApprenticeshipType = "FWK",
                ApprenticeshipCode = _framework.FworkCode,
                PwayCode           = _framework.PwayCode,
                ProgType           = _framework.ProgType,
                ReservedValue1     = 18,
                MaxEmployerLevyCap = 9000
            };

            _frameworkList = new List <FrameworkMetaData> {
                _framework
            };
            _frameworkAimList = new List <FrameworkAimMetaData> {
                _frameworkAim
            };
            _apprenticeshipComponentTypeList = new List <ApprenticeshipComponentTypeMetaData> {
                _apprenticeshipComponentType
            };
            _learningDeliveryList = new List <LearningDeliveryMetaData> {
                _learningDelivery
            };
            _fundingList = new List <FundingMetaData> {
                _fundingMetaData
            };
            _fundingApprenticeshipsList = new List <ApprenticeshipFundingMetaData> {
                _appFundingMetaData
            };

            _mockHttpGetFile.Setup(m => m.GetFile(It.IsAny <string>())).Returns(new MemoryStream());
            _mockCsvService.Setup(x => x.ReadFromString <FrameworkMetaData>(It.IsAny <string>())).Returns(_frameworkList);
            _mockCsvService.Setup(x => x.ReadFromString <FrameworkAimMetaData>(It.IsAny <string>())).Returns(_frameworkAimList);
            _mockCsvService.Setup(x => x.ReadFromString <ApprenticeshipComponentTypeMetaData>(It.IsAny <string>())).Returns(_apprenticeshipComponentTypeList);
            _mockCsvService.Setup(x => x.ReadFromString <LearningDeliveryMetaData>(It.IsAny <string>())).Returns(_learningDeliveryList);
            _mockCsvService.Setup(x => x.ReadFromString <FundingMetaData>(It.IsAny <string>())).Returns(_fundingList);
            _mockCsvService.Setup(x => x.ReadFromString <ApprenticeshipFundingMetaData>(It.IsAny <string>())).Returns(_fundingApprenticeshipsList);

            _mockAngleSharpService.Setup(x => x.GetLinks(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Returns(_linkEndPoints);

            _mockAppServiceSettings.Setup(a => a.FrameworksExpiredRequired).Returns(new List <string>());

            _sut = new LarsDataService(
                _mockAppServiceSettings.Object,
                _mockCsvService.Object,
                _mockHttpGetFile.Object,
                _mockFileExtractor.Object,
                _mockAngleSharpService.Object,
                _mockLogger.Object);
        }