private ApplicationModel MapFromGetApplicationResponse(IncentiveApplicationDto application, string accountId, Guid applicationId) { return(new ApplicationModel(applicationId, accountId, _hashingService.HashValue(application.AccountLegalEntityId), application.Apprenticeships.OrderBy(x => x.LastName).Select(MapFromApplicationApprenticeDto), application.BankDetailsRequired, application.NewAgreementRequired)); }
public async Task Then_The_Apprenticeship_Course_Is_Returned( GetApplicationQuery query, IncentiveApplicationDto applicationResponse, GetApprenticeshipResponse apprenticeshipResponse, [Frozen] Mock <ICommitmentsApiClient <CommitmentsConfiguration> > commitmentsClient, [Frozen] Mock <IApplicationService> applicationService, GetApplicationHandler handler ) { apprenticeshipResponse.Id = applicationResponse.Apprenticeships.First().ApprenticeshipId; commitmentsClient .Setup(client => client.Get <GetApprenticeshipResponse>(It.IsAny <GetApprenticeshipRequest>())) .ReturnsAsync(new GetApprenticeshipResponse()); commitmentsClient .Setup(client => client.Get <GetApprenticeshipResponse>( It.Is <GetApprenticeshipRequest>(c => c.GetUrl.EndsWith($"/{applicationResponse.Apprenticeships.First().ApprenticeshipId}")))) .ReturnsAsync(apprenticeshipResponse); applicationService .Setup(x => x.Get(query.AccountId, query.ApplicationId)) .ReturnsAsync(applicationResponse); var actual = await handler.Handle(query, CancellationToken.None); actual.Application.Apprenticeships.First().CourseName.Should().Be(apprenticeshipResponse.CourseName); }
public async Task WhenTheyRetrieveTheApplication() { var url = $"/accounts/{_request.AccountId}/applications/{_request.IncentiveApplicationId}"; var(_, data) = await EmployerIncentiveApi.Client.GetValueAsync <IncentiveApplicationDto>(url); _returnedApplication = data; }
private IncentiveApplication MapApplication(IncentiveApplicationDto applicationDto) { return(new IncentiveApplication { AccountLegalEntityId = applicationDto.AccountLegalEntityId, BankDetailsRequired = applicationDto.BankDetailsRequired, Apprenticeships = new List <IncentiveApplicationApprenticeship>(), LegalEntityId = applicationDto.LegalEntityId, SubmittedByEmail = applicationDto.SubmittedByEmail, SubmittedByName = applicationDto.SubmittedByName, NewAgreementRequired = applicationDto.NewAgreementRequired }); }
public async Task Then_The_Signed_Agreements_Are_Returned( GetBankingDataQuery query, IncentiveApplicationDto applicationResponse, LegalEntity legalEntityResponse, [Frozen] Mock <IApplicationService> applicationService, [Frozen] Mock <IAccountsService> accountsService, GetBankingDataHandler handler ) { applicationService.Setup(x => x.Get(query.AccountId, query.ApplicationId)).ReturnsAsync(applicationResponse); accountsService.Setup(x => x.GetLegalEntity(query.HashedAccountId, applicationResponse.LegalEntityId)).ReturnsAsync(legalEntityResponse); var actual = await handler.Handle(query, CancellationToken.None); actual.Data.SignedAgreements.Should().BeEquivalentTo(legalEntityResponse.Agreements.Where(x => x.Status == EmployerAgreementStatus.Signed || x.Status == EmployerAgreementStatus.Expired || x.Status == EmployerAgreementStatus.Superseded), opts => opts.ExcludingMissingMembers()); }
public async Task Then_The_Application_Is_Returned( GetApplicationQuery query, IncentiveApplicationDto applicationResponse, [Frozen] Mock <ICommitmentsApiClient <CommitmentsConfiguration> > commitmentsClient, [Frozen] Mock <IApplicationService> applicationService, GetApplicationHandler handler ) { commitmentsClient.Setup(client => client.Get <GetApprenticeshipResponse>(It.IsAny <GetApprenticeshipRequest>())) .ReturnsAsync(new GetApprenticeshipResponse()); applicationService.Setup(x => x.Get(query.AccountId, query.ApplicationId)).ReturnsAsync(applicationResponse); var actual = await handler.Handle(query, CancellationToken.None); actual.Application.Should().BeEquivalentTo(applicationResponse, opts => opts.ExcludingMissingMembers()); }
public async Task Then_The_Api_Is_Called_Returning_The_Application( long accountId, Guid applicationId, IncentiveApplicationDto apiResponse, [Frozen] Mock <IEmployerIncentivesApiClient <EmployerIncentivesConfiguration> > client, ApplicationService service ) { client.Setup(x => x.Get <IncentiveApplicationDto>( It.Is <GetApplicationRequest>(c => c.GetUrl.Contains(accountId.ToString()) && c.GetUrl.Contains(applicationId.ToString())))) .ReturnsAsync(apiResponse); var actual = await service.Get(accountId, applicationId); actual.Should().BeEquivalentTo(apiResponse); }
public async Task Then_The_Apprenticeships_Are_Not_Returned_If_Opted_Out( GetApplicationQuery query, IncentiveApplicationDto applicationResponse, GetApprenticeshipResponse apprenticeshipResponse, [Frozen] Mock <ICommitmentsApiClient <CommitmentsConfiguration> > commitmentsClient, [Frozen] Mock <IApplicationService> applicationService, GetApplicationHandler handler ) { query.IncludeApprenticeships = false; applicationService.Setup(x => x.Get(query.AccountId, query.ApplicationId)).ReturnsAsync(applicationResponse); var actual = await handler.Handle(query, CancellationToken.None); actual.Application.Apprenticeships.Count().Should().Be(0); commitmentsClient.Verify(client => client.Get <GetApprenticeshipResponse>(It.IsAny <GetApprenticeshipRequest>()), Times.Never); }
public async Task Then_The_Application_Data_Is_Returned( GetBankingDataQuery query, IncentiveApplicationDto applicationResponse, [Frozen] Mock <IApplicationService> applicationService, GetBankingDataHandler handler ) { applicationService.Setup(x => x.Get(query.AccountId, query.ApplicationId)).ReturnsAsync(applicationResponse); var actual = await handler.Handle(query, CancellationToken.None); actual.Data.SubmittedByEmail.Should().Be(applicationResponse.SubmittedByEmail); actual.Data.SubmittedByName.Should().Be(applicationResponse.SubmittedByName); actual.Data.LegalEntityId.Should().Be(applicationResponse.LegalEntityId); actual.Data.ApplicationValue.Should().Be(applicationResponse.Apprenticeships.Sum(x => x.TotalIncentiveAmount)); actual.Data.VendorCode.Should().Be("00000000"); actual.Data.NumberOfApprenticeships.Should().Be(applicationResponse.Apprenticeships.Count()); }
public async Task Then_Agreements_Without_a_Signed_Date_Are_Not_Returned( GetBankingDataQuery query, IncentiveApplicationDto applicationResponse, LegalEntity legalEntityResponse, [Frozen] Mock <IApplicationService> applicationService, [Frozen] Mock <IAccountsService> accountsService, GetBankingDataHandler handler ) { var agreementWithoutDate = legalEntityResponse.Agreements.First(x => x.Status == EmployerAgreementStatus.Signed || x.Status == EmployerAgreementStatus.Expired || x.Status == EmployerAgreementStatus.Superseded); agreementWithoutDate.SignedDate = null; applicationService.Setup(x => x.Get(query.AccountId, query.ApplicationId)).ReturnsAsync(applicationResponse); accountsService.Setup(x => x.GetLegalEntity(query.HashedAccountId, applicationResponse.LegalEntityId)).ReturnsAsync(legalEntityResponse); var actual = await handler.Handle(query, CancellationToken.None); actual.Data.SignedAgreements.Count().Should().Be(legalEntityResponse.Agreements.Count(x => x.Status == EmployerAgreementStatus.Signed || x.Status == EmployerAgreementStatus.Expired || x.Status == EmployerAgreementStatus.Superseded) - 1); }
public void WhenTheEmployerHasAlreadyProvidedBankDetails() { _application = _fixture.Build <IncentiveApplicationDto>().With(p => p.BankDetailsRequired, false).Create(); var response = new ApplicationResponse { Application = _application }; _testContext.EmployerIncentivesApi.MockServer.ResetMappings(); _testContext.EmployerIncentivesApi.MockServer .Given( Request .Create() .WithPath($"/accounts/{_data.AccountId}/applications/{_data.ApplicationId}") .WithParam("includeApprenticeships", new ExactMatcher("False")) .UsingGet() ) .RespondWith( Response.Create() .WithStatusCode(HttpStatusCode.OK) .WithHeader("Content-Type", "application/json") .WithBody(JsonConvert.SerializeObject(response))); }
public GetApplicationResponse(IncentiveApplicationDto application) { Application = application; }