public async Task <IList <DeltaReportSummaryItemModel>?> GetSummaryAsync() { var url = new Uri($"{deltaReportApiClientOptions.BaseAddress}", UriKind.Absolute); logger.LogInformation($"Retrieving summaries from LMI delta report API: {url}"); return(await apiDataConnector.GetAsync <List <DeltaReportSummaryItemModel> >(httpClient, url).ConfigureAwait(false)); }
public async Task DeltaReportApiConnectorTestsGetSummaryReturnsSuccess() { // arrange var expectedResults = new List <DeltaReportSummaryItemModel> { new DeltaReportSummaryItemModel { Id = Guid.NewGuid(), SocImportedCount = 11, SocUnchangedCount = 5, SocAdditionCount = 2, SocUpdateCount = 1, SocDeletionCount = 3, }, }; A.CallTo(() => fakeApiDataConnector.GetAsync <List <DeltaReportSummaryItemModel> >(A <HttpClient> .Ignored, A <Uri> .Ignored)).Returns(expectedResults); // act var results = await deltaReportApiConnector.GetSummaryAsync().ConfigureAwait(false); // assert A.CallTo(() => fakeApiDataConnector.GetAsync <List <DeltaReportSummaryItemModel> >(A <HttpClient> .Ignored, A <Uri> .Ignored)).MustHaveHappenedOnceExactly(); Assert.NotNull(results); Assert.Equal(expectedResults.Count, results !.Count); Assert.Equal(expectedResults.First().Id, results.First().Id); }
public async Task JobGroupApiConnectorTestsGetSummaryReturnsSuccess() { // arrange var expectedResults = new List <JobGroupSummaryItemModel> { new JobGroupSummaryItemModel { Id = Guid.NewGuid(), Soc = 3543, Title = "A title", }, }; A.CallTo(() => fakeApiDataConnector.GetAsync <IList <JobGroupSummaryItemModel> >(A <HttpClient> .Ignored, A <Uri> .Ignored)).Returns(expectedResults); // act var results = await jobGroupApiConnector.GetSummaryAsync(new Uri("https://somewhere.com", UriKind.Absolute)).ConfigureAwait(false); // assert A.CallTo(() => fakeApiDataConnector.GetAsync <IList <JobGroupSummaryItemModel> >(A <HttpClient> .Ignored, A <Uri> .Ignored)).MustHaveHappenedOnceExactly(); Assert.NotNull(results); Assert.Equal(expectedResults.Count, results !.Count); Assert.Equal(expectedResults.First().Soc, results.First().Soc); Assert.Equal(expectedResults.First().Title, results.First().Title); }
public async Task <IList <JobGroupSummaryItemModel>?> GetSummaryAsync() { var url = new Uri($"{jobGroupClientOptions.BaseAddress}{jobGroupClientOptions.SummaryEndpoint}"); logger.LogInformation($"Retrieving summaries from job-groups app: {url}"); return(await apiDataConnector.GetAsync <List <JobGroupSummaryItemModel> >(httpClient, url).ConfigureAwait(false)); }
public async Task <IList <SocDatasetSummaryItemModel>?> GetSummaryAsync(Uri uri) { logger.LogInformation($"Retrieving summaries from LMI Import API: {uri}"); var socDatasetSummaries = await apiDataConnector.GetAsync <IList <SocDatasetSummaryItemModel> >(httpClient, uri).ConfigureAwait(false); return(socDatasetSummaries); }
public async Task <IList <JobProfileSummaryModel>?> GetSummaryAsync() { var jobProfileSummaries = await apiDataConnector.GetAsync <IList <JobProfileSummaryModel> >(httpClient, jobProfileApiClientOptions.BaseAddress !).ConfigureAwait(false); if (jobProfileApiClientOptions.DeveloperModeMaxJobProfiles > 0) { jobProfileSummaries = jobProfileSummaries.Take(jobProfileApiClientOptions.DeveloperModeMaxJobProfiles).ToList(); } return(jobProfileSummaries); }
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); }
public async Task ApiDataConnectorGetReturnsSuccess() { // arrange var expectedResult = new ApiTestModel { Id = Guid.NewGuid(), Name = "a name", }; var jsonResponse = JsonConvert.SerializeObject(expectedResult); A.CallTo(() => fakeApiConnector.GetAsync(A <HttpClient> .Ignored, A <Uri> .Ignored, A <string> .Ignored)).Returns(jsonResponse); // act var result = await apiDataConnector.GetAsync <ApiTestModel>(A.Fake <HttpClient>(), dummyUrl).ConfigureAwait(false); // assert A.CallTo(() => fakeApiConnector.GetAsync(A <HttpClient> .Ignored, A <Uri> .Ignored, A <string> .Ignored)).MustHaveHappenedOnceExactly(); Assert.NotNull(result); Assert.Equal(expectedResult.Id, result !.Id); Assert.Equal(expectedResult.Name, result.Name); }
public async Task JobProfileApiConnectorGetSummaryReturnsSuccess() { // arrange var expectedResults = new List <JobProfileSummaryModel> { new JobProfileSummaryModel { Title = "A title", Url = new Uri("https://somewhere.com/", UriKind.Absolute), }, }; A.CallTo(() => fakeApiDataConnector.GetAsync <IList <JobProfileSummaryModel> >(A <HttpClient> .Ignored, A <Uri> .Ignored)).Returns(expectedResults); // act var results = await jobProfileApiConnector.GetSummaryAsync().ConfigureAwait(false); // assert A.CallTo(() => fakeApiDataConnector.GetAsync <IList <JobProfileSummaryModel> >(A <HttpClient> .Ignored, A <Uri> .Ignored)).MustHaveHappenedOnceExactly(); Assert.NotNull(results); Assert.Equal(expectedResults.Count, results !.Count); Assert.Equal(expectedResults.First().Title, results.First().Title); Assert.Equal(expectedResults.First().Url, results.First().Url); }
public async Task <TModel?> ImportAsync <TModel>(Uri uri) where TModel : class { logger.LogInformation($"Getting LMI data from: {uri}"); var apiData = await apiDataConnector.GetAsync <TModel>(httpClient, uri).ConfigureAwait(false); if (apiData != null) { logger.LogInformation($"Get LMI data from: {uri} was successful"); return(apiData); } return(default);
public async Task <IList <JobGroupSummaryItemModel>?> GetSummaryAsync(Uri url) { logger.LogInformation($"Retrieving summaries from job groups API: {url}"); return(await apiDataConnector.GetAsync <IList <JobGroupSummaryItemModel> >(httpClient, url).ConfigureAwait(false)); }