public void GivenAnEmployerHasNoApplications() { var applications = new List <ApprenticeApplicationModel>(); var getApplications = new GetApplicationsModel { ApprenticeApplications = applications, BankDetailsStatus = BankDetailsStatus.NotSupplied }; _testData = new TestData.Account.WithInitialApplicationForASingleEntity(); _testContext.TestDataStore.Add("HashedAccountId", _testData.HashedAccountId); _testContext.TestDataStore.Add("HashedAccountLegalEntityId", _testData.HashedAccountLegalEntityId); _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, _testData.HashedAccountId); _testContext.EmployerIncentivesApi.MockServer .Given( Request .Create() .WithPath( $"/accounts/{_testData.AccountId}/legalentity/{_testData.AccountLegalEntityId}/applications") .UsingGet() ) .RespondWith( Response.Create() .WithStatusCode(HttpStatusCode.OK) .WithBody(JsonConvert.SerializeObject(getApplications))); }
public void GivenAnEmployerAccountHasMultipleLegalEntities() { _testData = new TestData.Account.WithInitialApplicationForASingleEntity(); var legalEntities = new List <LegalEntityModel> { new LegalEntityModel { AccountId = _testData.AccountId.ToString(), AccountLegalEntityId = _testData.AccountLegalEntityId.ToString() }, new LegalEntityModel { AccountId = _testData.AccountId.ToString(), AccountLegalEntityId = _fixture.Create <string>() } }; _testContext.EmployerIncentivesApi.MockServer .Given( Request .Create() .WithPath($"/accounts/{_testData.AccountId}/legalentities") .UsingGet() ) .RespondWith( Response.Create() .WithStatusCode(HttpStatusCode.OK) .WithBody(JsonConvert.SerializeObject(legalEntities))); }
public void GivenTheEmployerHasPreviouslySuppliedTheirBankDetails() { var applications = new List <ApprenticeApplicationModel> { _fixture.Create <ApprenticeApplicationModel>() }; var getApplications = new GetApplicationsModel { ApprenticeApplications = applications, BankDetailsStatus = BankDetailsStatus.Completed, FirstSubmittedApplicationId = _applicationId }; var testData = new TestData.Account.WithInitialApplicationForASingleEntity(); _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, testData.HashedAccountId); _testContext.EmployerIncentivesApi.MockServer .Given( Request .Create() .WithPath($"/accounts/{testData.AccountId}/legalentity/{testData.AccountLegalEntityId}/applications") .UsingGet() ) .RespondWith( Response.Create() .WithStatusCode(HttpStatusCode.OK) .WithBody(JsonConvert.SerializeObject(getApplications))); }
private void AnEmployerHasASingleSubmittedApplication(Guid applicationId, BankDetailsStatus bankDetailsStatus = BankDetailsStatus.Completed) { _testData = new TestData.Account.WithInitialApplicationForASingleEntity(); _testContext.TestDataStore.Add("HashedAccountId", _testData.HashedAccountId); _testContext.TestDataStore.Add("HashedAccountLegalEntityId", _testData.HashedAccountLegalEntityId); _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, _testData.HashedAccountId); var applications = new List <ApprenticeApplicationModel> { _fixture.Build <ApprenticeApplicationModel>() .With(p => p.AccountId, _testData.AccountId) .Create() }; applications[0].Status = "Submitted"; var getApplications = new GetApplicationsModel { ApprenticeApplications = applications, BankDetailsStatus = bankDetailsStatus, FirstSubmittedApplicationId = applicationId }; _testContext.EmployerIncentivesApi.MockServer .Given( Request .Create() .WithPath($"/accounts/{_testData.AccountId}/legalentity/{_testData.AccountLegalEntityId}/applications") .UsingGet() ) .RespondWith( Response.Create() .WithStatusCode(HttpStatusCode.OK) .WithBody(JsonConvert.SerializeObject(getApplications))); }
public ApprenticeConfirmationSteps(TestContext testContext) : base(testContext) { _testContext = testContext; _testData = new TestData.Account.WithInitialApplicationForASingleEntity(); _testContext.TestDataStore.Add("HashedAccountId", _testData.HashedAccountId); _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, _testData.HashedAccountId); }
public AmendApprenticeSelectionSteps(TestContext testContext) : base(testContext) { _testContext = testContext; _hashingService = _testContext.HashingService; _data = new TestData.Account.WithInitialApplicationForASingleEntity(); _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, _data.HashedAccountId); }
public EmploymentStartDatesSteps(TestContext testContext) : base(testContext) { _testContext = testContext; _hashingService = _testContext.HashingService; _data = new TestData.Account.WithInitialApplicationForASingleEntity(); _legalEntity = _data.LegalEntities.First(); _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, _data.HashedAccountId); }
public void GivenAnEmployerApplyingForAGrantHasAlreadySelectedEligibleApprentices(int p0) { _testData = new TestData.Account.WithInitialApplicationForASingleEntity(); _testContext.TestDataStore.Add("HashedAccountId", _testData.HashedAccountId); _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, _testData.HashedAccountId); SetupServiceMocks(_testData.ApplicationResponse); }
public EmployerIncentivesApiBuilder WithInitialApplication() { var data = new TestData.Account.WithInitialApplicationForASingleEntity(); _server .Given( Request .Create() .WithPath($"/accounts/{data.AccountId}/applications") .UsingPost() ) .RespondWith( Response.Create() .WithStatusCode(HttpStatusCode.Created)); _server .Given( Request .Create() .WithPath(x => x.Contains($"/accounts/{data.AccountId}/applications/") && !x.Contains("accountlegalentity")) .UsingGet() ) .RespondWith( Response.Create() .WithStatusCode(HttpStatusCode.OK) .WithHeader("Content-Type", "application/json") .WithBody(JsonConvert.SerializeObject(data.ApplicationResponse, TestHelper.DefaultSerialiserSettings)) ); _server .Given( Request .Create() .WithPath(x => x.Contains($"/accounts/{data.AccountId}/applications") && x.Contains("accountlegalentity")) .UsingGet() ) .RespondWith( Response.Create() .WithStatusCode(HttpStatusCode.OK) .WithHeader("Content-Type", "application/json") .WithBody(data.AccountLegalEntityId.ToString()) ); _server .Given( Request .Create() .WithPath($"/accounts/{data.AccountId}/applications") .UsingPut() ) .RespondWith( Response.Create() .WithStatusCode(HttpStatusCode.OK)); AddClaim(EmployerClaimTypes.Account, data.HashedAccountId); return(this); }
public void GivenAnEmployerHasSelectedAnApprenticeWithinTheExtensionWindowAndHasSignedTheAgreement() { _testData = new TestData.Account.WithInitialApplicationForASingleEntity(); _testData.ApplicationResponse.Application.NewAgreementRequired = false; _testContext.TestDataStore.Add("HashedAccountId", _testData.HashedAccountId); _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, _testData.HashedAccountId); SetupServiceMocks(_testData.GetApplicationResponseWithFirstTwoApprenticesSelected); }
private void AnEmployerHasAnApplicationWithAnAgreementVersionThatNeedsSigning(Guid applicationId) { _testData = new TestData.Account.WithInitialApplicationForASingleEntity(); _testContext.TestDataStore.Add("HashedAccountId", _testData.HashedAccountId); _testContext.TestDataStore.Add("HashedAccountLegalEntityId", _testData.HashedAccountLegalEntityId); _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, _testData.HashedAccountId); ClawbackStatusModel clawbackStatus = null; var applications = new List <ApprenticeApplicationModel> { _fixture.Build <ApprenticeApplicationModel>() .With(p => p.AccountId, _testData.AccountId) .With(p => p.FirstPaymentStatus, _fixture.Build <PaymentStatusModel>() .With(p => p.RequiresNewEmployerAgreement, true) .With(p => p.PaymentIsStopped, false) .With(p => p.WithdrawnByCompliance, false) .With(p => p.WithdrawnByEmployer, false) .With(p => p.EmploymentCheckPassed, true) .Without(p => p.IsClawedBack) .Create() ) .With(p => p.FirstClawbackStatus, clawbackStatus) .With(p => p.SecondClawbackStatus, clawbackStatus) .Create() }; var getApplications = new GetApplicationsModel { ApprenticeApplications = applications, FirstSubmittedApplicationId = applicationId }; _testContext.EmployerIncentivesApi.MockServer .Given( Request .Create() .WithPath( $"/accounts/{_testData.AccountId}/legalentity/{_testData.AccountLegalEntityId}/applications") .UsingGet() ) .RespondWith( Response.Create() .WithStatusCode(HttpStatusCode.OK) .WithBody(JsonConvert.SerializeObject(getApplications))); }
private void AnApplicationWithAFailedEmploymentCheck(Guid applicationId) { _testData = new TestData.Account.WithInitialApplicationForASingleEntity(); _testContext.TestDataStore.Add("HashedAccountId", _testData.HashedAccountId); _testContext.TestDataStore.Add("HashedAccountLegalEntityId", _testData.HashedAccountLegalEntityId); _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, _testData.HashedAccountId); var applications = new List <ApprenticeApplicationModel> { _fixture.Build <ApprenticeApplicationModel>() .With(p => p.AccountId, _testData.AccountId) .With(p => p.FirstPaymentStatus, _fixture.Build <PaymentStatusModel>() .With(p => p.EmploymentCheckPassed, false) .Create() ) .With(p => p.SecondPaymentStatus, _fixture.Build <PaymentStatusModel>() .With(p => p.EmploymentCheckPassed, false) .Create() ) .Without(p => p.FirstClawbackStatus) .Without(p => p.SecondClawbackStatus) .Create() }; var getApplications = new GetApplicationsModel { ApprenticeApplications = applications, FirstSubmittedApplicationId = applicationId }; _testContext.EmployerIncentivesApi.MockServer .Given( Request .Create() .WithPath( $"/accounts/{_testData.AccountId}/legalentity/{_testData.AccountLegalEntityId}/applications") .UsingGet() ) .RespondWith( Response.Create() .WithStatusCode(HttpStatusCode.OK) .WithBody(JsonConvert.SerializeObject(getApplications))); }
public EmployerIncentivesApiBuilder WithApplicationConfirmation() { var data = new TestData.Account.WithInitialApplicationForASingleEntity(); _server .Given( Request .Create() .WithPath($"/accounts/{data.AccountId}/applications") .UsingPatch() ) .RespondWith( Response.Create() .WithStatusCode(HttpStatusCode.OK)); AddClaim(EmployerClaimTypes.Account, data.HashedAccountId); return(this); }
public async Task WhenTheEmployerSubmitsAnApplicationForTheApprenticeshipPayment() { var testdata = new TestData.Account.WithInitialApplicationForASingleEntity(); _testDataStore.Add("HashedAccountId", testdata.HashedAccountId); _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, testdata.HashedAccountId); _testDataStore.Add("HashedAccountLegalEntityId", testdata.HashedAccountLegalEntityId); var url = $"{testdata.HashedAccountId}/apply/declaration/{testdata.ApplicationId}"; var request = new HttpRequestMessage(HttpMethod.Post, url); var response = await _testContext.WebsiteClient.SendAsync(request); response.EnsureSuccessStatusCode(); _testContext.TestDataStore.GetOrCreate("Response", onCreate: () => { return(response); }); }
private void AnApplicationWithAnUnsentClawedBackPayment(Guid applicationId) { _testData = new TestData.Account.WithInitialApplicationForASingleEntity(); _testContext.TestDataStore.Add("HashedAccountId", _testData.HashedAccountId); _testContext.TestDataStore.Add("HashedAccountLegalEntityId", _testData.HashedAccountLegalEntityId); _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, _testData.HashedAccountId); var clawbackStatus = new ClawbackStatusModel { ClawbackDate = _fixture.Create <DateTime>(), // unset still has a clawback date ClawbackAmount = _fixture.Create <decimal>(), OriginalPaymentDate = _fixture.Create <DateTime>() }; var applications = new List <ApprenticeApplicationModel> { _fixture.Build <ApprenticeApplicationModel>() .With(p => p.AccountId, _testData.AccountId) .With(p => p.FirstClawbackStatus, clawbackStatus) .Without(p => p.SecondClawbackStatus) .Create() }; var getApplications = new GetApplicationsModel { ApprenticeApplications = applications, FirstSubmittedApplicationId = applicationId }; _testContext.EmployerIncentivesApi.MockServer .Given( Request .Create() .WithPath( $"/accounts/{_testData.AccountId}/legalentity/{_testData.AccountLegalEntityId}/applications") .UsingGet() ) .RespondWith( Response.Create() .WithStatusCode(HttpStatusCode.OK) .WithBody(JsonConvert.SerializeObject(getApplications))); }
public void GivenAnEmployerApplyingForAGrantHasApprenticesMatchingTheEligibilityRequirement() { var data = new TestData.Account.WithInitialApplicationForASingleEntity(); _apprenticeshipData = data.Apprentices; _legalEntity = data.LegalEntities.First(); var accountId = _testData.GetOrCreate("AccountId", onCreate: () => data.AccountId); _testData.Add("HashedAccountId", _hashingService.HashValue(accountId)); _testContext.AddOrReplaceClaim(EmployerClaimTypes.Account, _hashingService.HashValue(accountId)); var accountLegalEntityId = _testData.GetOrCreate("AccountLegalEntityId", onCreate: () => data.AccountLegalEntityId); _testData.Add("HashedAccountLegalEntityId", _hashingService.HashValue(accountLegalEntityId)); _testContext.EmployerIncentivesApi.MockServer .Given( Request .Create() .WithPath($"/apprenticeships") .WithParam("accountid", accountId.ToString()) .WithParam("accountlegalentityid", accountLegalEntityId.ToString()) .UsingGet() ) .RespondWith( Response.Create() .WithBody(JsonConvert.SerializeObject(_apprenticeshipData, TestHelper.DefaultSerialiserSettings)) .WithStatusCode(HttpStatusCode.OK)); _testContext.EmployerIncentivesApi.MockServer .Given( Request .Create() .WithPath($"/accounts/{accountId}/applications") .UsingPost() ) .RespondWith( Response.Create() .WithStatusCode(HttpStatusCode.Created)); _testContext.EmployerIncentivesApi.MockServer .Given( Request .Create() .WithPath(x => x.Contains($"/accounts/{data.AccountId}/applications/") && !x.Contains("accountlegalentity")) .UsingGet() ) .RespondWith( Response.Create() .WithStatusCode(HttpStatusCode.OK) .WithHeader("Content-Type", "application/json") .WithBody(JsonConvert.SerializeObject(data.ApplicationResponse, TestHelper.DefaultSerialiserSettings))); _testContext.EmployerIncentivesApi.MockServer .Given( Request .Create() .WithPath($"/accounts/{accountId}/applications") .UsingPost() ) .RespondWith( Response.Create() .WithStatusCode(HttpStatusCode.Created) .WithHeader("Content-Type", "application/json") .WithBody(string.Empty)); _testContext.EmployerIncentivesApi.MockServer .Given( Request .Create() .WithPath(x => x.Contains($"accounts/{data.AccountId}/applications") && x.Contains("accountlegalentity")) // applicationid is generated in application service so will vary per request .UsingGet() ) .RespondWith( Response.Create() .WithStatusCode(HttpStatusCode.OK) .WithHeader("Content-Type", "application/json") .WithBody(data.AccountLegalEntityId.ToString())); _testContext.EmployerIncentivesApi.MockServer .Given( Request .Create() .WithPath($"/accounts/{data.AccountId}/legalentities/{_legalEntity.AccountLegalEntityId}") .UsingGet() ) .RespondWith( Response.Create() .WithBody(JsonConvert.SerializeObject(_legalEntity)) .WithStatusCode(HttpStatusCode.OK)); }