public async Task LmiSocImportServiceImportReturnsSuccess()
        {
            // arrange
            var socJobProfileMapping = new SocJobProfileMappingModel
            {
                Soc         = 3231,
                JobProfiles = A.CollectionOfDummy <SocJobProfileItemModel>(2).ToList(),
            };
            var dummyLmiPredictedModel = A.Dummy <LmiPredictedModel>();

            dummyLmiPredictedModel.PredictedEmployment = A.CollectionOfDummy <LmiPredictedYearModel>(2).ToList();

            A.CallTo(() => fakeLmiApiConnector.ImportAsync <LmiSocDatasetModel>(A <Uri> .Ignored)).Returns(A.Dummy <LmiSocDatasetModel>());
            A.CallTo(() => fakeLmiApiConnector.ImportAsync <LmiPredictedModel>(A <Uri> .Ignored)).Returns(dummyLmiPredictedModel);
            A.CallTo(() => fakeLmiApiConnector.ImportAsync <LmiBreakdownModel>(A <Uri> .Ignored)).Returns(A.Dummy <LmiBreakdownModel>());

            // act
            var result = await lmiSocImportService.ImportAsync(socJobProfileMapping.Soc.Value, socJobProfileMapping.JobProfiles).ConfigureAwait(false);

            // assert
            A.CallTo(() => fakeLmiApiConnector.ImportAsync <LmiSocDatasetModel>(A <Uri> .Ignored)).MustHaveHappenedOnceExactly();
            A.CallTo(() => fakeLmiApiConnector.ImportAsync <LmiPredictedModel>(A <Uri> .Ignored)).MustHaveHappened(2, Times.Exactly);
            A.CallTo(() => fakeLmiApiConnector.ImportAsync <LmiBreakdownModel>(A <Uri> .Ignored)).MustHaveHappened(3, Times.Exactly);
            Assert.NotNull(result);
            Assert.NotNull(result !.JobProfiles);
            Assert.NotNull(result.JobGrowth);
            Assert.NotNull(result.QualificationLevel);
            Assert.NotNull(result.EmploymentByRegion);
            Assert.NotNull(result.TopIndustriesInJobGroup);
        }
Example #2
0
        public async Task LmiApiConnectorImportReturnsSuccess()
        {
            // arrange
            var expectedResult = new ApiTestModel
            {
                Id   = Guid.NewGuid(),
                Name = "a name",
            };

            A.CallTo(() => fakeApiDataConnector.GetAsync <ApiTestModel>(A <HttpClient> .Ignored, A <Uri> .Ignored)).Returns(expectedResult);

            // act
            var result = await lmiApiConnector.ImportAsync <ApiTestModel>(new Uri("https://somewhere.com", UriKind.Absolute)).ConfigureAwait(false);

            // assert
            A.CallTo(() => fakeApiDataConnector.GetAsync <ApiTestModel>(A <HttpClient> .Ignored, A <Uri> .Ignored)).MustHaveHappenedOnceExactly();
            Assert.NotNull(result);
            Assert.Equal(expectedResult.Id, result !.Id);
            Assert.Equal(expectedResult.Name, result.Name);
        }
Example #3
0
        public async Task <LmiSocDatasetModel?> ImportAsync(int soc, List <SocJobProfileItemModel>?jobProfiles)
        {
            logger.LogInformation($"Importing SOC '{soc}' with data from LMI API");

            var lmiSocUri                  = lmiApiClientOptions.BuildApiUri(soc, lmiApiClientOptions.MinYear, lmiApiClientOptions.MaxYear, LmiApiQuery.SocDetail);
            var jobGrowthStartUri          = lmiApiClientOptions.BuildApiUri(soc, lmiApiClientOptions.MinYear, lmiApiClientOptions.MinYear, LmiApiQuery.JobGrowth);
            var jobGrowthEndUri            = lmiApiClientOptions.BuildApiUri(soc, lmiApiClientOptions.MaxYear, lmiApiClientOptions.MaxYear, LmiApiQuery.JobGrowth);
            var qualificationLevelUri      = lmiApiClientOptions.BuildApiUri(soc, lmiApiClientOptions.MinYear, lmiApiClientOptions.MinYear, LmiApiQuery.QualificationLevel);
            var employmentByRegionUri      = lmiApiClientOptions.BuildApiUri(soc, lmiApiClientOptions.MinYear, lmiApiClientOptions.MinYear, LmiApiQuery.EmploymentByRegion);
            var topIndustriesInJobGroupUri = lmiApiClientOptions.BuildApiUri(soc, lmiApiClientOptions.MinYear, lmiApiClientOptions.MinYear, LmiApiQuery.TopIndustriesInJobGroup);

            var lmiSocDataset = await lmiApiConnector.ImportAsync <LmiSocDatasetModel>(lmiSocUri).ConfigureAwait(false);

            if (lmiSocDataset != null)
            {
                lmiSocDataset.JobProfiles = jobProfiles;
                lmiSocDataset.JobGrowth   = await lmiApiConnector.ImportAsync <LmiPredictedModel>(jobGrowthStartUri).ConfigureAwait(false);

                lmiSocDataset.QualificationLevel = await lmiApiConnector.ImportAsync <LmiBreakdownModel>(qualificationLevelUri).ConfigureAwait(false);

                lmiSocDataset.EmploymentByRegion = await lmiApiConnector.ImportAsync <LmiBreakdownModel>(employmentByRegionUri).ConfigureAwait(false);

                lmiSocDataset.TopIndustriesInJobGroup = await lmiApiConnector.ImportAsync <LmiBreakdownModel>(topIndustriesInJobGroupUri).ConfigureAwait(false);

                var jobGrowthEnd = await lmiApiConnector.ImportAsync <LmiPredictedModel>(jobGrowthEndUri).ConfigureAwait(false);

                if (lmiSocDataset.JobGrowth?.PredictedEmployment != null && jobGrowthEnd?.PredictedEmployment != null)
                {
                    lmiSocDataset.JobGrowth.PredictedEmployment.AddRange(jobGrowthEnd.PredictedEmployment);
                }

                logger.LogInformation($"Imported SOC '{soc}' with data from LMI API");

                return(lmiSocDataset);
            }

            logger.LogWarning($"no data for SOC '{soc}' available from LMI API");
            return(null);
        }