Esempio n. 1
0
        public void ShouldCreateValidStandardProviderDocument()
        {
            var mapper       = new ElasticsearchMapper(_settings.Object, Mock.Of <IOrganisationTypeProcessor>());
            var testProvider = GenerateTestProvider();

            var document = mapper.CreateStandardProviderDocument(testProvider, testProvider.Standards.First(), testProvider.Standards.First().DeliveryLocations.First());

            document.StandardCode.Should().Be(101);
            document.Ukprn.Should().Be(4556);
            document.ProviderName.Should().Be("Test Provider");
            document.TrainingLocations.First().LocationId.Should().Be(98);
            document.TrainingLocations.First().LocationName.Should().Be("Standard Test Location");
            document.ProviderMarketingInfo.Should().Be("Provider Marketing");
            document.ApprenticeshipMarketingInfo.Should().Be("Standard Apprenticeship Marketing");
            document.Phone.Should().Be("5555-5678");
            document.Email.Should().Be("*****@*****.**");
            document.ContactUsUrl.Should().Be("http://contact-us.com");
            document.ApprenticeshipInfoUrl.Should().Be("http://standard-info.com");
            document.LearnerSatisfaction.Should().Be(8.2);
            document.EmployerSatisfaction.Should().Be(9.2);
            document.DeliveryModes.Should().BeEquivalentTo("BlockRelease", "DayRelease");
            document.Website.Should().Be("http://location-site");
            document.TrainingLocations.First().Address.Address1.Should().Be("Standard Test Address1");
            document.TrainingLocations.First().Address.Address2.Should().Be("Standard Test Address2");
            document.TrainingLocations.First().Address.Town.Should().Be("Standard Test Town");
            document.TrainingLocations.First().Address.County.Should().Be("Standard Test County");
            document.TrainingLocations.First().Address.PostCode.Should().Be("TE4 5ES");

            document.TrainingLocations.FirstOrDefault()?.LocationPoint.Latitude.Should().Be(54.213);
            document.TrainingLocations.FirstOrDefault()?.LocationPoint.Longitude.Should().Be(-52.123);
            document.TrainingLocations.FirstOrDefault()?.Location.Coordinates.Latitude.Should().Be(54.213);
            document.TrainingLocations.FirstOrDefault()?.Location.Coordinates.Longitude.Should().Be(-52.123);
            document.TrainingLocations.FirstOrDefault()?.Location.Radius.Should().Be("30mi");
        }
        public void IndexFrameworks(string indexName, ICollection <Provider> indexEntries)
        {
            var frameworkProviderList = new List <ProviderDocument>();

            try
            {
                foreach (var provider in indexEntries)
                {
                    foreach (var framework in provider.Frameworks)
                    {
                        var deliveryLocationsOnly100 = framework.DeliveryLocations
                                                       .Where(_onlyAtEmployer)
                                                       .Where(x => x.DeliveryLocation.Address.GeoPoint != null)
                                                       .ToArray();

                        if (deliveryLocationsOnly100.Any())
                        {
                            var frameworkProvider = ElasticsearchMapper.CreateFrameworkProviderDocument(provider, framework, deliveryLocationsOnly100);
                            frameworkProviderList.Add(frameworkProvider);
                        }

                        frameworkProviderList.AddRange(from location in framework.DeliveryLocations.Where(_anyNotAtEmployer) where location.DeliveryLocation.Address.GeoPoint != null select ElasticsearchMapper.CreateFrameworkProviderDocument(provider, framework, location));
                    }
                }

                Client.BulkAllGeneric(frameworkProviderList, indexName);
            }
            catch (Exception ex)
            {
                _log.Error(ex, "Something failed indexing framework providers:" + ex.Message);
                throw;
            }
        }
Esempio n. 3
0
        public void ShouldCreateStandardProviderDocumentWithListLocationPoints()
        {
            var mapper       = new ElasticsearchMapper(_settings.Object, Mock.Of <IOrganisationTypeProcessor>());
            var testProvider = GenerateTestProvider();

            var document = mapper.CreateStandardProviderDocument(testProvider, testProvider.Standards.First(), testProvider.Frameworks.First().DeliveryLocations);

            document.LocationPoints.Count().Should().Be(1);
        }
Esempio n. 4
0
        public void WhenCreatingStandardOrganisationDocument()
        {
            const string epaOrganisationIdentifier = "OrgIdentifier";
            const string organisationType          = "Awarding Organisation";
            const string email           = "*****@*****.**";
            const string phone           = "555-5555";
            const string epaOrganisation = "EpaOrg";
            const string websiteLink     = "http://testemail.com";
            const string standardCode    = "standard_code";
            var          effectiveFrom   = DateTime.Today.AddDays(-7);
            var          effectiveTo     = DateTime.Today.AddDays(7);

            var address = new Indexer.Core.AssessmentOrgs.Models.Address
            {
                Primary   = "primary address",
                Secondary = "secondary address",
                Street    = "address street",
                Town      = "address town",
                Postcode  = "PO1 1OP"
            };

            var standardOrganisationsData = new StandardOrganisationsData
            {
                EpaOrganisationIdentifier = epaOrganisationIdentifier,
                OrganisationType          = organisationType,
                Email           = email,
                Phone           = phone,
                Address         = address,
                EpaOrganisation = epaOrganisation,
                WebsiteLink     = websiteLink,
                StandardCode    = standardCode,
                EffectiveFrom   = effectiveFrom,
                EffectiveTo     = effectiveTo
            };

            var mapper = new ElasticsearchMapper(_settings.Object, _organisationTypeProcessor.Object);

            var standardOrganisationDocument = mapper.CreateStandardOrganisationDocument(standardOrganisationsData);

            standardOrganisationDocument.EpaOrganisationIdentifier.Should().Be(epaOrganisationIdentifier);
            standardOrganisationDocument.OrganisationType.Should().Be(organisationType);
            standardOrganisationDocument.Email.Should().Be(email);
            standardOrganisationDocument.Phone.Should().Be(phone);
            standardOrganisationDocument.EpaOrganisation.Should().Be(epaOrganisation);
            standardOrganisationDocument.WebsiteLink.Should().Be(websiteLink);
            standardOrganisationDocument.Address.Primary.Should().Be(address.Primary);
            standardOrganisationDocument.Address.Secondary.Should().Be(address.Secondary);
            standardOrganisationDocument.Address.Street.Should().Be(address.Street);
            standardOrganisationDocument.Address.Town.Should().Be(address.Town);
            standardOrganisationDocument.Address.Postcode.Should().Be(address.Postcode);
            standardOrganisationDocument.StandardCode.Should().Be(standardCode);
            standardOrganisationDocument.EffectiveFrom.Should().Be(effectiveFrom);
            standardOrganisationDocument.EffectiveTo.Should().Be(effectiveTo);
        }
Esempio n. 5
0
        public void ShouldThrowMappingExceptionOnMappingErrorForStandardProviderMapping()
        {
            var mapper       = new ElasticsearchMapper(_settings.Object, Mock.Of <IOrganisationTypeProcessor>());
            var testProvider = GenerateTestProvider();

            // Remove Delivery modes
            testProvider.Standards.First().DeliveryLocations.First().DeliveryModes = null;

            Assert.Throws <MappingException>(() =>
                                             mapper.CreateStandardProviderDocument(
                                                 testProvider,
                                                 testProvider.Standards.First(),
                                                 testProvider.Standards.First().DeliveryLocations.First()));
        }
Esempio n. 6
0
        public void WhenCreatingOrganisationDocument()
        {
            const string epaOrganisationIdentifier = "OrgIdentifier";
            const string organisationType          = "Awarding Organisation";
            const string email           = "*****@*****.**";
            const string phone           = "555-5555";
            const string epaOrganisation = "EpaOrg";
            const string websiteLink     = "http://testemail.com";
            var          address         = new Indexer.Core.AssessmentOrgs.Models.Address
            {
                Primary   = "primary address",
                Secondary = "secondary address",
                Street    = "address street",
                Town      = "address town",
                Postcode  = "PO1 1OP"
            };

            var organisation = new Organisation
            {
                EpaOrganisationIdentifier = epaOrganisationIdentifier,
                OrganisationType          = organisationType,
                Email           = email,
                Phone           = phone,
                Address         = address,
                EpaOrganisation = epaOrganisation,
                WebsiteLink     = websiteLink
            };

            var mapper = new ElasticsearchMapper(_settings.Object, _organisationTypeProcessor.Object);

            var organisationDocument = mapper.CreateOrganisationDocument(organisation);

            organisationDocument.EpaOrganisationIdentifier.Should().Be(epaOrganisationIdentifier);
            organisationDocument.OrganisationType.Should().Be(organisationType);
            organisationDocument.Email.Should().Be(email);
            organisationDocument.Phone.Should().Be(phone);
            organisationDocument.EpaOrganisation.Should().Be(epaOrganisation);
            organisationDocument.WebsiteLink.Should().Be(websiteLink);
            organisationDocument.Address.Primary.Should().Be(address.Primary);
            organisationDocument.Address.Secondary.Should().Be(address.Secondary);
            organisationDocument.Address.Street.Should().Be(address.Street);
            organisationDocument.Address.Town.Should().Be(address.Town);
            organisationDocument.Address.Postcode.Should().Be(address.Postcode);
        }
Esempio n. 7
0
        public void WhenCreatingFrameworkDocumentShouldTrimPathwayWhiteSpaces()
        {
            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.PathwayName.Should().Be("Accounting");
        }
Esempio n. 8
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));
        }
Esempio n. 9
0
        public void ShouldCreateValidFrameworkProviderDocument()
        {
            var mapper       = new ElasticsearchMapper(_settings.Object, Mock.Of <IOrganisationTypeProcessor>());
            var testProvider = GenerateTestProvider();

            var document = mapper.CreateFrameworkProviderDocument(testProvider, testProvider.Frameworks.First(), testProvider.Frameworks.First().DeliveryLocations.First());

            document.FrameworkCode.Should().Be(99);
            document.PathwayCode.Should().Be(1122);
            document.FrameworkId.Should().Be(string.Format(_frameworkIdFormat, 99, 20, 1122));
            document.Level.Should().Be(4);

            document.Ukprn.Should().Be(4556);
            document.ProviderName.Should().Be("Test Provider");
            document.TrainingLocations.First().LocationId.Should().Be(77);
            document.TrainingLocations.First().LocationName.Should().Be("Framework Test Location");
            document.ProviderMarketingInfo.Should().Be("Provider Marketing");
            document.ApprenticeshipMarketingInfo.Should().Be("Framework Apprenticeship Marketing");
            document.Phone.Should().Be("12324-5678");
            document.Email.Should().Be("*****@*****.**");
            document.ContactUsUrl.Should().Be("http://contact-us.com");
            document.ApprenticeshipInfoUrl.Should().Be("http://standard-info.com");
            document.LearnerSatisfaction.Should().Be(8.2);
            document.EmployerSatisfaction.Should().Be(9.2);
            document.DeliveryModes.Should().BeEquivalentTo("BlockRelease", "DayRelease");
            document.Website.Should().Be("http://location-site");
            document.TrainingLocations.First().Address.Address1.Should().Be("Framework Test Address1");
            document.TrainingLocations.First().Address.Address2.Should().Be("Framework Test Address2");
            document.TrainingLocations.First().Address.Town.Should().Be("Framework Test Town");
            document.TrainingLocations.First().Address.County.Should().Be("Framework Test County");
            document.TrainingLocations.First().Address.PostCode.Should().Be("TE3 5ES");

            document.TrainingLocations.FirstOrDefault()?.LocationPoint.Latitude.Should().Be(53.213);
            document.TrainingLocations.FirstOrDefault()?.LocationPoint.Longitude.Should().Be(-50.123);
            document.TrainingLocations.FirstOrDefault()?.Location.Coordinates.Latitude.Should().Be(53.213);
            document.TrainingLocations.FirstOrDefault()?.Location.Coordinates.Longitude.Should().Be(-50.123);
            document.TrainingLocations.FirstOrDefault()?.Location.Radius.Should().Be("25mi");
        }
Esempio n. 10
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);
        }
        public void IndexApiProviders(string indexName, ICollection <Provider> entries)
        {
            var apiProviderList = entries.Select(provider => ElasticsearchMapper.CreateProviderApiDocument(provider)).ToList();

            Client.BulkAllGeneric(apiProviderList, indexName);
        }