From 955c002d3555ca62ad01183e3be59d316c2edb1b Mon Sep 17 00:00:00 2001 From: Joshua Hawxwell Date: Fri, 2 Aug 2024 07:52:16 +0100 Subject: [PATCH] Rename donordata Provided and Tasks (#1395) * Rename donordata Provided and Tasks * Move tasks from using actor * Move uses of actor.ShareCodeData to sharecode.Data --- cmd/event-received/factory.go | 4 +- cmd/event-received/handlers.go | 6 +- cmd/event-received/handlers_test.go | 8 +- .../lpastore_event_handler_test.go | 10 +- .../makeregister_event_handler_test.go | 4 +- .../mock_lpaStoreClient_test.go | 10 +- .../mock_shareCodeSender_test.go | 10 +- cmd/event-received/sirius_event_handler.go | 2 +- .../sirius_event_handler_test.go | 51 +++-- internal/actor/share_code_data.go | 7 - internal/actor/task_state.go | 33 --- internal/app/dashboard_store.go | 10 +- internal/app/dashboard_store_test.go | 29 +-- internal/app/document_store.go | 4 +- internal/app/document_store_test.go | 16 +- internal/app/evidence_received_store_test.go | 2 +- .../app/mock_LpaStoreResolvingService_test.go | 14 +- internal/app/organisation_store.go | 4 +- internal/app/organisation_store_test.go | 2 +- internal/app/share_code_store.go | 19 +- internal/app/share_code_store_test.go | 27 +-- internal/app/uid_store.go | 2 +- internal/app/uid_store_test.go | 4 +- internal/attorney/attorneydata/store.go | 2 +- internal/attorney/attorneydata/store_test.go | 8 +- ...ont_want_to_be_attorney_logged_out_test.go | 7 +- .../attorneypage/confirm_your_details.go | 4 +- .../attorneypage/confirm_your_details_test.go | 4 +- .../enter_reference_number_opt_out_test.go | 9 +- .../enter_reference_number_test.go | 21 +- .../attorney/attorneypage/mobile_number.go | 6 +- .../attorneypage/mobile_number_test.go | 12 +- .../attorneypage/mock_AttorneyStore_test.go | 16 +- .../attorneypage/mock_DonorStore_test.go | 14 +- .../attorneypage/mock_ShareCodeStore_test.go | 38 ++-- .../attorney/attorneypage/read_the_lpa.go | 4 +- .../attorneypage/read_the_lpa_test.go | 4 +- internal/attorney/attorneypage/register.go | 9 +- internal/attorney/attorneypage/sign.go | 8 +- internal/attorney/attorneypage/sign_test.go | 22 +- internal/attorney/attorneypage/task_list.go | 4 +- .../attorney/attorneypage/task_list_test.go | 50 ++--- .../certificateproviderdata/store.go | 3 +- .../certificateproviderdata/store_test.go | 8 +- ...rm_dont_want_to_be_certificate_provider.go | 6 +- ...t_to_be_certificate_provider_logged_out.go | 5 +- ...be_certificate_provider_logged_out_test.go | 26 +-- ...nt_want_to_be_certificate_provider_test.go | 22 +- .../confirm_your_details.go | 4 +- .../confirm_your_details_test.go | 4 +- .../enter_date_of_birth.go | 4 +- .../enter_date_of_birth_test.go | 12 +- .../enter_reference_number_opt_out_test.go | 9 +- .../enter_reference_number_test.go | 11 +- .../mock_CertificateProviderStore_test.go | 16 +- .../mock_DonorStore_test.go | 24 +-- .../mock_ShareCodeStore_test.go | 38 ++-- .../one_login_identity_details.go | 4 +- .../one_login_identity_details_test.go | 4 +- .../provide_certificate.go | 4 +- .../provide_certificate_test.go | 6 +- .../certificateproviderpage/read_the_lpa.go | 4 +- .../read_the_lpa_test.go | 4 +- .../certificateproviderpage/register.go | 13 +- .../certificateproviderpage/task_list.go | 4 +- .../certificateproviderpage/task_list_test.go | 34 +-- .../unable_to_confirm_identity.go | 4 +- .../unable_to_confirm_identity_test.go | 4 +- .../donor/donordata/donor_provided_test.go | 46 ++-- internal/donor/donordata/provided.go | 46 ++-- internal/donor/donordata/store.go | 32 +-- internal/donor/donordata/store_test.go | 86 ++++---- internal/donor/donordata/voucher.go | 2 +- internal/donor/donordata/voucher_test.go | 6 +- internal/donor/donorpage/add_correspondent.go | 10 +- .../donor/donorpage/add_correspondent_test.go | 44 ++-- ..._applying_for_fee_discount_or_exemption.go | 2 +- ...ying_for_fee_discount_or_exemption_test.go | 22 +- .../donor/donorpage/can_you_sign_your_lpa.go | 2 +- .../donorpage/can_you_sign_your_lpa_test.go | 12 +- .../donorpage/certificate_provider_address.go | 6 +- .../certificate_provider_address_test.go | 56 ++--- .../donorpage/certificate_provider_details.go | 7 +- .../certificate_provider_details_test.go | 41 ++-- .../donor/donorpage/change_mobile_number.go | 4 +- .../donorpage/change_mobile_number_test.go | 32 +-- .../donor/donorpage/check_you_can_sign.go | 2 +- .../donorpage/check_you_can_sign_test.go | 10 +- .../donor/donorpage/check_your_details.go | 4 +- .../donorpage/check_your_details_test.go | 12 +- internal/donor/donorpage/check_your_lpa.go | 14 +- .../donor/donorpage/check_your_lpa_test.go | 68 +++--- .../choose_a_new_certificate_provider.go | 4 +- .../choose_a_new_certificate_provider_test.go | 16 +- internal/donor/donorpage/choose_attorneys.go | 6 +- .../donorpage/choose_attorneys_address.go | 2 +- .../choose_attorneys_address_test.go | 52 ++--- .../donorpage/choose_attorneys_guidance.go | 4 +- .../choose_attorneys_guidance_test.go | 8 +- .../donorpage/choose_attorneys_summary.go | 4 +- .../choose_attorneys_summary_test.go | 8 +- .../donor/donorpage/choose_attorneys_test.go | 39 ++-- .../donorpage/choose_people_to_notify.go | 7 +- .../choose_people_to_notify_address.go | 6 +- .../choose_people_to_notify_address_test.go | 56 ++--- .../choose_people_to_notify_summary.go | 4 +- .../choose_people_to_notify_summary_test.go | 42 ++-- .../donorpage/choose_people_to_notify_test.go | 29 +-- .../donorpage/choose_replacement_attorneys.go | 6 +- .../choose_replacement_attorneys_address.go | 2 +- ...oose_replacement_attorneys_address_test.go | 50 ++--- .../choose_replacement_attorneys_summary.go | 4 +- ...oose_replacement_attorneys_summary_test.go | 20 +- .../choose_replacement_attorneys_test.go | 39 ++-- .../confirm_person_allowed_to_vouch.go | 2 +- .../confirm_person_allowed_to_vouch_test.go | 16 +- ...our_certificate_provider_is_not_related.go | 10 +- ...ertificate_provider_is_not_related_test.go | 82 ++++---- internal/donor/donorpage/delete_lpa.go | 4 +- internal/donor/donorpage/delete_lpa_test.go | 10 +- .../donorpage/do_you_want_to_notify_people.go | 10 +- .../do_you_want_to_notify_people_test.go | 64 +++--- .../donor/donorpage/enter_access_code_test.go | 9 +- .../donorpage/enter_correspondent_address.go | 6 +- .../enter_correspondent_address_test.go | 56 ++--- .../donorpage/enter_correspondent_details.go | 7 +- .../enter_correspondent_details_test.go | 24 +-- .../enter_replacement_trust_corporation.go | 2 +- ...r_replacement_trust_corporation_address.go | 2 +- ...lacement_trust_corporation_address_test.go | 50 ++--- ...nter_replacement_trust_corporation_test.go | 18 +- .../donorpage/enter_trust_corporation.go | 2 +- .../enter_trust_corporation_address.go | 2 +- .../enter_trust_corporation_address_test.go | 50 ++--- .../donorpage/enter_trust_corporation_test.go | 16 +- internal/donor/donorpage/enter_voucher.go | 2 +- .../donor/donorpage/enter_voucher_test.go | 16 +- internal/donor/donorpage/fee_denied.go | 4 +- internal/donor/donorpage/fee_denied_test.go | 6 +- internal/donor/donorpage/guidance.go | 4 +- internal/donor/donorpage/guidance_test.go | 6 +- ...w_do_you_know_your_certificate_provider.go | 6 +- ...you_know_your_certificate_provider_test.go | 50 ++--- ...ong_have_you_known_certificate_provider.go | 2 +- ...ave_you_known_certificate_provider_test.go | 22 +- .../how_should_attorneys_make_decisions.go | 4 +- ...ow_should_attorneys_make_decisions_test.go | 28 +-- ...ld_replacement_attorneys_make_decisions.go | 4 +- ...placement_attorneys_make_decisions_test.go | 36 ++-- ...ow_should_replacement_attorneys_step_in.go | 2 +- ...ould_replacement_attorneys_step_in_test.go | 36 ++-- ...provider_prefer_to_carry_out_their_role.go | 2 +- ...der_prefer_to_carry_out_their_role_test.go | 18 +- .../how_would_you_like_to_send_evidence.go | 2 +- ...ow_would_you_like_to_send_evidence_test.go | 14 +- .../donorpage/identity_with_one_login.go | 2 +- .../identity_with_one_login_callback.go | 8 +- .../identity_with_one_login_callback_test.go | 26 +-- .../donorpage/identity_with_one_login_test.go | 6 +- .../donorpage/life_sustaining_treatment.go | 6 +- .../life_sustaining_treatment_test.go | 22 +- internal/donor/donorpage/lpa_details_saved.go | 4 +- .../donor/donorpage/lpa_details_saved_test.go | 6 +- internal/donor/donorpage/lpa_progress.go | 4 +- internal/donor/donorpage/lpa_progress_test.go | 14 +- internal/donor/donorpage/lpa_type.go | 6 +- internal/donor/donorpage/lpa_type_test.go | 26 +-- .../donorpage/mock_DocumentStore_test.go | 24 +-- .../donor/donorpage/mock_DonorStore_test.go | 50 ++--- .../donorpage/mock_GetDonorStore_test.go | 14 +- internal/donor/donorpage/mock_Handler_test.go | 10 +- .../donorpage/mock_LpaStoreClient_test.go | 20 +- .../donorpage/mock_ShareCodeSender_test.go | 10 +- .../donorpage/mock_ShareCodeStore_test.go | 14 +- .../donorpage/mock_WitnessCodeSender_test.go | 20 +- .../donorpage/one_login_identity_details.go | 4 +- .../one_login_identity_details_test.go | 20 +- internal/donor/donorpage/pay.go | 2 +- internal/donor/donorpage/pay_test.go | 36 ++-- .../donor/donorpage/payment_confirmation.go | 2 +- .../donorpage/payment_confirmation_test.go | 69 +++--- .../donorpage/previous_application_number.go | 2 +- .../previous_application_number_test.go | 16 +- internal/donor/donorpage/previous_fee.go | 2 +- internal/donor/donorpage/previous_fee_test.go | 20 +- internal/donor/donorpage/register.go | 29 +-- internal/donor/donorpage/register_test.go | 37 ++-- .../register_with_court_of_protection.go | 2 +- .../register_with_court_of_protection_test.go | 12 +- internal/donor/donorpage/remove_attorney.go | 2 +- .../donor/donorpage/remove_attorney_test.go | 32 +-- .../donorpage/remove_person_to_notify.go | 6 +- .../donorpage/remove_person_to_notify_test.go | 26 +-- .../donorpage/remove_replacement_attorney.go | 2 +- .../remove_replacement_attorney_test.go | 32 +-- .../donorpage/remove_trust_corporation.go | 6 +- .../remove_trust_corporation_test.go | 50 ++--- .../donor/donorpage/resend_witness_code.go | 2 +- .../donorpage/resend_witness_code_test.go | 14 +- internal/donor/donorpage/restrictions.go | 8 +- internal/donor/donorpage/restrictions_test.go | 30 +-- .../send_us_your_evidence_by_post.go | 2 +- .../send_us_your_evidence_by_post_test.go | 10 +- internal/donor/donorpage/sign_your_lpa.go | 4 +- .../donor/donorpage/sign_your_lpa_test.go | 16 +- internal/donor/donorpage/task_list.go | 17 +- internal/donor/donorpage/task_list_test.go | 147 +++++++------ internal/donor/donorpage/upload_evidence.go | 2 +- .../donor/donorpage/upload_evidence_sse.go | 2 +- .../donorpage/upload_evidence_sse_test.go | 6 +- .../donor/donorpage/upload_evidence_test.go | 68 +++--- .../donorpage/want_replacement_attorneys.go | 4 +- .../want_replacement_attorneys_test.go | 32 +-- internal/donor/donorpage/what_is_vouching.go | 2 +- .../donor/donorpage/what_is_vouching_test.go | 10 +- .../donor/donorpage/what_you_can_do_now.go | 2 +- .../donorpage/what_you_can_do_now_test.go | 20 +- .../donorpage/when_can_the_lpa_be_used.go | 8 +- .../when_can_the_lpa_be_used_test.go | 26 +-- .../which_fee_type_are_you_applying_for.go | 2 +- ...hich_fee_type_are_you_applying_for_test.go | 16 +- internal/donor/donorpage/withdraw_lpa.go | 4 +- internal/donor/donorpage/withdraw_lpa_test.go | 12 +- .../witnessing_as_certificate_provider.go | 10 +- ...witnessing_as_certificate_provider_test.go | 77 ++++--- .../witnessing_as_independent_witness.go | 4 +- .../witnessing_as_independent_witness_test.go | 50 ++--- .../donorpage/witnessing_your_signature.go | 4 +- .../witnessing_your_signature_test.go | 14 +- .../donorpage/you_cannot_sign_your_lpa_yet.go | 2 +- .../you_cannot_sign_your_lpa_yet_test.go | 6 +- internal/donor/donorpage/your_address.go | 2 +- internal/donor/donorpage/your_address_test.go | 38 ++-- .../donorpage/your_authorised_signatory.go | 7 +- .../your_authorised_signatory_test.go | 29 +-- .../donor/donorpage/your_date_of_birth.go | 2 +- .../donorpage/your_date_of_birth_test.go | 18 +- internal/donor/donorpage/your_email.go | 2 +- internal/donor/donorpage/your_email_test.go | 12 +- .../donorpage/your_independent_witness.go | 7 +- .../your_independent_witness_address.go | 6 +- .../your_independent_witness_address_test.go | 52 ++--- .../your_independent_witness_mobile.go | 2 +- .../your_independent_witness_mobile_test.go | 18 +- .../your_independent_witness_test.go | 29 +-- internal/donor/donorpage/your_lpa_language.go | 2 +- .../donor/donorpage/your_lpa_language_test.go | 14 +- internal/donor/donorpage/your_name.go | 4 +- internal/donor/donorpage/your_name_test.go | 24 +-- .../donorpage/your_preferred_language.go | 2 +- .../donorpage/your_preferred_language_test.go | 12 +- internal/lpastore/client_test.go | 4 +- internal/lpastore/lpa.go | 4 +- internal/lpastore/lpa_test.go | 14 +- internal/lpastore/mock_DonorStore_test.go | 14 +- internal/lpastore/resolving_service.go | 6 +- internal/lpastore/resolving_service_test.go | 35 ++-- internal/lpastore/update.go | 2 +- internal/lpastore/update_test.go | 2 +- internal/page/common.go | 9 +- internal/page/dashboard_test.go | 4 +- internal/page/data.go | 30 +-- internal/page/data_test.go | 93 ++++----- internal/page/fixtures/attorney.go | 33 +-- .../page/fixtures/certificate_provider.go | 14 +- internal/page/fixtures/donor.go | 45 ++-- internal/page/fixtures/fixtures.go | 5 +- internal/page/fixtures/supporter.go | 16 +- internal/page/lpa_progress_tracker.go | 56 ++--- internal/page/lpa_progress_tracker_test.go | 196 +++++++++--------- internal/page/mock_DonorStore_test.go | 24 +-- internal/page/mock_ShareCodeStore_test.go | 26 +-- internal/page/mock_shareCodeSender_test.go | 8 +- internal/page/paths.go | 8 +- internal/page/paths_test.go | 165 ++++++++------- internal/page/share_code.go | 5 +- internal/page/share_code_test.go | 57 ++--- .../confirm_donor_can_interact_online_test.go | 4 +- internal/page/supporter/dashboard.go | 2 +- internal/page/supporter/dashboard_test.go | 2 +- internal/page/supporter/donor_access.go | 7 +- internal/page/supporter/donor_access_test.go | 55 ++--- .../page/supporter/mock_DonorStore_test.go | 50 ++--- .../supporter/mock_OrganisationStore_test.go | 14 +- .../supporter/mock_ShareCodeStore_test.go | 38 ++-- internal/page/supporter/register.go | 17 +- internal/page/supporter/view_lpa_test.go | 5 +- internal/page/witness_code.go | 4 +- internal/page/witness_code_test.go | 20 +- internal/sharecode/data.go | 2 +- internal/templatefn/fn.go | 2 +- internal/templatefn/fn_test.go | 2 +- 292 files changed, 2591 insertions(+), 2601 deletions(-) delete mode 100644 internal/actor/share_code_data.go delete mode 100644 internal/actor/task_state.go diff --git a/cmd/event-received/factory.go b/cmd/event-received/factory.go index 43b8afee41..34c89437cd 100644 --- a/cmd/event-received/factory.go +++ b/cmd/event-received/factory.go @@ -28,7 +28,7 @@ type LambdaClient interface { } type LpaStoreClient interface { - SendLpa(ctx context.Context, donor *donordata.DonorProvidedDetails) error + SendLpa(ctx context.Context, donor *donordata.Provided) error Lpa(ctx context.Context, uid string) (*lpastore.Lpa, error) } @@ -38,7 +38,7 @@ type SecretsClient interface { type ShareCodeSender interface { SendCertificateProviderInvite(context.Context, page.AppData, page.CertificateProviderInvite) error - SendCertificateProviderPrompt(context.Context, page.AppData, *donordata.DonorProvidedDetails) error + SendCertificateProviderPrompt(context.Context, page.AppData, *donordata.Provided) error SendAttorneys(context.Context, page.AppData, *lpastore.Lpa) error } diff --git a/cmd/event-received/handlers.go b/cmd/event-received/handlers.go index fa0b94be52..18fa8c3c80 100644 --- a/cmd/event-received/handlers.go +++ b/cmd/event-received/handlers.go @@ -52,7 +52,7 @@ func handleObjectTagsAdded(ctx context.Context, dynamodbClient dynamodbClient, e return nil } -func putDonor(ctx context.Context, donor *donordata.DonorProvidedDetails, now func() time.Time, client dynamodbClient) error { +func putDonor(ctx context.Context, donor *donordata.Provided, now func() time.Time, client dynamodbClient) error { donor.UpdatedAt = now() if err := donor.UpdateHash(); err != nil { return err @@ -61,7 +61,7 @@ func putDonor(ctx context.Context, donor *donordata.DonorProvidedDetails, now fu return client.Put(ctx, donor) } -func getDonorByLpaUID(ctx context.Context, client dynamodbClient, uid string) (*donordata.DonorProvidedDetails, error) { +func getDonorByLpaUID(ctx context.Context, client dynamodbClient, uid string) (*donordata.Provided, error) { var key dynamo.Keys if err := client.OneByUID(ctx, uid, &key); err != nil { return nil, fmt.Errorf("failed to resolve uid: %w", err) @@ -71,7 +71,7 @@ func getDonorByLpaUID(ctx context.Context, client dynamodbClient, uid string) (* return nil, fmt.Errorf("PK missing from LPA in response") } - var donor donordata.DonorProvidedDetails + var donor donordata.Provided if err := client.One(ctx, key.PK, key.SK, &donor); err != nil { return nil, fmt.Errorf("failed to get LPA: %w", err) } diff --git a/cmd/event-received/handlers_test.go b/cmd/event-received/handlers_test.go index df05073d69..3d575eb1f2 100644 --- a/cmd/event-received/handlers_test.go +++ b/cmd/event-received/handlers_test.go @@ -49,7 +49,7 @@ func TestHandleObjectTagsAdded(t *testing.T) { dynamoClient. On("One", ctx, dynamo.LpaKey("123"), dynamo.DonorKey("456"), mock.Anything). Return(func(ctx context.Context, pk dynamo.PK, sk dynamo.SK, v interface{}) error { - b, _ := json.Marshal(donordata.DonorProvidedDetails{LpaID: "123", Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}}) + b, _ := json.Marshal(donordata.Provided{LpaID: "123", Tasks: donordata.Tasks{PayForLpa: task.PaymentStatePending}}) json.Unmarshal(b, v) return nil }) @@ -135,7 +135,7 @@ func TestHandleObjectTagsAddedWhenDynamoClientOneByUIDError(t *testing.T) { dynamoClient. On("One", ctx, dynamo.LpaKey("123"), dynamo.DonorKey("456"), mock.Anything). Return(func(ctx context.Context, pk dynamo.PK, sk dynamo.SK, v interface{}) error { - b, _ := json.Marshal(donordata.DonorProvidedDetails{LpaID: "123", Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}}) + b, _ := json.Marshal(donordata.Provided{LpaID: "123", Tasks: donordata.Tasks{PayForLpa: task.PaymentStatePending}}) json.Unmarshal(b, v) return expectedError }) @@ -169,7 +169,7 @@ func TestHandleObjectTagsAddedWhenDocumentStoreUpdateScanResultsError(t *testing dynamoClient. On("One", ctx, dynamo.LpaKey("123"), dynamo.DonorKey("456"), mock.Anything). Return(func(ctx context.Context, pk dynamo.PK, sk dynamo.SK, v interface{}) error { - b, _ := json.Marshal(donordata.DonorProvidedDetails{LpaID: "123", Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}}) + b, _ := json.Marshal(donordata.Provided{LpaID: "123", Tasks: donordata.Tasks{PayForLpa: task.PaymentStatePending}}) json.Unmarshal(b, v) return nil }) @@ -184,7 +184,7 @@ func TestHandleObjectTagsAddedWhenDocumentStoreUpdateScanResultsError(t *testing } func TestGetLpaByUID(t *testing.T) { - expectedDonor := &donordata.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456"))} + expectedDonor := &donordata.Provided{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456"))} client := newMockDynamodbClient(t) client. diff --git a/cmd/event-received/lpastore_event_handler_test.go b/cmd/event-received/lpastore_event_handler_test.go index 4a89aa7af1..c562fa2c56 100644 --- a/cmd/event-received/lpastore_event_handler_test.go +++ b/cmd/event-received/lpastore_event_handler_test.go @@ -26,7 +26,7 @@ func TestLpaStoreEventHandlerHandleLpaUpdated(t *testing.T) { Detail: json.RawMessage(`{"uid":"M-1111-2222-3333","changeType":"PERFECT"}`), } - updated := &donordata.DonorProvidedDetails{ + updated := &donordata.Provided{ PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), PerfectAt: testNow, @@ -45,7 +45,7 @@ func TestLpaStoreEventHandlerHandleLpaUpdated(t *testing.T) { client. On("One", ctx, dynamo.LpaKey("123"), dynamo.DonorKey("456"), mock.Anything). Return(func(ctx context.Context, pk dynamo.PK, sk dynamo.SK, v interface{}) error { - b, _ := json.Marshal(donordata.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456"))}) + b, _ := json.Marshal(donordata.Provided{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456"))}) json.Unmarshal(b, v) return nil }) @@ -85,7 +85,7 @@ func TestLpaStoreEventHandlerHandleLpaUpdatedWhenDynamoGetErrors(t *testing.T) { Detail: json.RawMessage(`{"uid":"M-1111-2222-3333","changeType":"PERFECT"}`), } - updated := &donordata.DonorProvidedDetails{ + updated := &donordata.Provided{ PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), PerfectAt: testNow, @@ -114,7 +114,7 @@ func TestLpaStoreEventHandlerHandleLpaUpdatedWhenDynamoPutErrors(t *testing.T) { Detail: json.RawMessage(`{"uid":"M-1111-2222-3333","changeType":"PERFECT"}`), } - updated := &donordata.DonorProvidedDetails{ + updated := &donordata.Provided{ PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), PerfectAt: testNow, @@ -133,7 +133,7 @@ func TestLpaStoreEventHandlerHandleLpaUpdatedWhenDynamoPutErrors(t *testing.T) { client. On("One", ctx, dynamo.LpaKey("123"), dynamo.DonorKey("456"), mock.Anything). Return(func(ctx context.Context, pk dynamo.PK, sk dynamo.SK, v interface{}) error { - b, _ := json.Marshal(donordata.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456"))}) + b, _ := json.Marshal(donordata.Provided{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456"))}) json.Unmarshal(b, v) return nil }) diff --git a/cmd/event-received/makeregister_event_handler_test.go b/cmd/event-received/makeregister_event_handler_test.go index 1e8c53ab98..75c2b6940d 100644 --- a/cmd/event-received/makeregister_event_handler_test.go +++ b/cmd/event-received/makeregister_event_handler_test.go @@ -61,7 +61,7 @@ func TestHandleUidRequested(t *testing.T) { dynamoClient. On("One", ctx, dynamo.LpaKey("123"), dynamo.DonorKey("456"), mock.Anything). Return(func(ctx context.Context, pk dynamo.PK, sk dynamo.SK, v interface{}) error { - b, _ := attributevalue.Marshal(&donordata.DonorProvidedDetails{ + b, _ := attributevalue.Marshal(&donordata.Provided{ Donor: donordata.Donor{FirstNames: "a", LastName: "b", Address: place.Address{Line1: "a"}, DateOfBirth: dob}, Type: donordata.LpaTypePersonalWelfare, CreatedAt: testNow, @@ -170,7 +170,7 @@ func TestHandleUidRequestedWhenEventClientErrors(t *testing.T) { dynamoClient. On("One", ctx, dynamo.LpaKey("123"), dynamo.DonorKey("456"), mock.Anything). Return(func(ctx context.Context, pk dynamo.PK, sk dynamo.SK, v interface{}) error { - b, _ := attributevalue.Marshal(&donordata.DonorProvidedDetails{}) + b, _ := attributevalue.Marshal(&donordata.Provided{}) attributevalue.Unmarshal(b, v) return nil }) diff --git a/cmd/event-received/mock_lpaStoreClient_test.go b/cmd/event-received/mock_lpaStoreClient_test.go index d914407d56..167fe1154b 100644 --- a/cmd/event-received/mock_lpaStoreClient_test.go +++ b/cmd/event-received/mock_lpaStoreClient_test.go @@ -84,7 +84,7 @@ func (_c *mockLpaStoreClient_Lpa_Call) RunAndReturn(run func(context.Context, st } // SendLpa provides a mock function with given fields: ctx, donor -func (_m *mockLpaStoreClient) SendLpa(ctx context.Context, donor *donordata.DonorProvidedDetails) error { +func (_m *mockLpaStoreClient) SendLpa(ctx context.Context, donor *donordata.Provided) error { ret := _m.Called(ctx, donor) if len(ret) == 0 { @@ -92,7 +92,7 @@ func (_m *mockLpaStoreClient) SendLpa(ctx context.Context, donor *donordata.Dono } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *donordata.DonorProvidedDetails) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, *donordata.Provided) error); ok { r0 = rf(ctx, donor) } else { r0 = ret.Error(0) @@ -113,9 +113,9 @@ func (_e *mockLpaStoreClient_Expecter) SendLpa(ctx interface{}, donor interface{ return &mockLpaStoreClient_SendLpa_Call{Call: _e.mock.On("SendLpa", ctx, donor)} } -func (_c *mockLpaStoreClient_SendLpa_Call) Run(run func(ctx context.Context, donor *donordata.DonorProvidedDetails)) *mockLpaStoreClient_SendLpa_Call { +func (_c *mockLpaStoreClient_SendLpa_Call) Run(run func(ctx context.Context, donor *donordata.Provided)) *mockLpaStoreClient_SendLpa_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*donordata.DonorProvidedDetails)) + run(args[0].(context.Context), args[1].(*donordata.Provided)) }) return _c } @@ -125,7 +125,7 @@ func (_c *mockLpaStoreClient_SendLpa_Call) Return(_a0 error) *mockLpaStoreClient return _c } -func (_c *mockLpaStoreClient_SendLpa_Call) RunAndReturn(run func(context.Context, *donordata.DonorProvidedDetails) error) *mockLpaStoreClient_SendLpa_Call { +func (_c *mockLpaStoreClient_SendLpa_Call) RunAndReturn(run func(context.Context, *donordata.Provided) error) *mockLpaStoreClient_SendLpa_Call { _c.Call.Return(run) return _c } diff --git a/cmd/event-received/mock_shareCodeSender_test.go b/cmd/event-received/mock_shareCodeSender_test.go index 176280bfcc..40a37b96c6 100644 --- a/cmd/event-received/mock_shareCodeSender_test.go +++ b/cmd/event-received/mock_shareCodeSender_test.go @@ -123,7 +123,7 @@ func (_c *mockShareCodeSender_SendCertificateProviderInvite_Call) RunAndReturn(r } // SendCertificateProviderPrompt provides a mock function with given fields: _a0, _a1, _a2 -func (_m *mockShareCodeSender) SendCertificateProviderPrompt(_a0 context.Context, _a1 page.AppData, _a2 *donordata.DonorProvidedDetails) error { +func (_m *mockShareCodeSender) SendCertificateProviderPrompt(_a0 context.Context, _a1 page.AppData, _a2 *donordata.Provided) error { ret := _m.Called(_a0, _a1, _a2) if len(ret) == 0 { @@ -131,7 +131,7 @@ func (_m *mockShareCodeSender) SendCertificateProviderPrompt(_a0 context.Context } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, page.AppData, *donordata.DonorProvidedDetails) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, page.AppData, *donordata.Provided) error); ok { r0 = rf(_a0, _a1, _a2) } else { r0 = ret.Error(0) @@ -153,9 +153,9 @@ func (_e *mockShareCodeSender_Expecter) SendCertificateProviderPrompt(_a0 interf return &mockShareCodeSender_SendCertificateProviderPrompt_Call{Call: _e.mock.On("SendCertificateProviderPrompt", _a0, _a1, _a2)} } -func (_c *mockShareCodeSender_SendCertificateProviderPrompt_Call) Run(run func(_a0 context.Context, _a1 page.AppData, _a2 *donordata.DonorProvidedDetails)) *mockShareCodeSender_SendCertificateProviderPrompt_Call { +func (_c *mockShareCodeSender_SendCertificateProviderPrompt_Call) Run(run func(_a0 context.Context, _a1 page.AppData, _a2 *donordata.Provided)) *mockShareCodeSender_SendCertificateProviderPrompt_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(page.AppData), args[2].(*donordata.DonorProvidedDetails)) + run(args[0].(context.Context), args[1].(page.AppData), args[2].(*donordata.Provided)) }) return _c } @@ -165,7 +165,7 @@ func (_c *mockShareCodeSender_SendCertificateProviderPrompt_Call) Return(_a0 err return _c } -func (_c *mockShareCodeSender_SendCertificateProviderPrompt_Call) RunAndReturn(run func(context.Context, page.AppData, *donordata.DonorProvidedDetails) error) *mockShareCodeSender_SendCertificateProviderPrompt_Call { +func (_c *mockShareCodeSender_SendCertificateProviderPrompt_Call) RunAndReturn(run func(context.Context, page.AppData, *donordata.Provided) error) *mockShareCodeSender_SendCertificateProviderPrompt_Call { _c.Call.Return(run) return _c } diff --git a/cmd/event-received/sirius_event_handler.go b/cmd/event-received/sirius_event_handler.go index a27d7618b9..6f5f6f6c96 100644 --- a/cmd/event-received/sirius_event_handler.go +++ b/cmd/event-received/sirius_event_handler.go @@ -194,7 +194,7 @@ func handleDonorSubmissionCompleted(ctx context.Context, client dynamodbClient, lpaID := uuidString() - if err := client.Put(ctx, &donordata.DonorProvidedDetails{ + if err := client.Put(ctx, &donordata.Provided{ PK: dynamo.LpaKey(lpaID), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("PAPER")), LpaID: lpaID, diff --git a/cmd/event-received/sirius_event_handler_test.go b/cmd/event-received/sirius_event_handler_test.go index 75e0ca2e9f..f4cfba5390 100644 --- a/cmd/event-received/sirius_event_handler_test.go +++ b/cmd/event-received/sirius_event_handler_test.go @@ -10,7 +10,6 @@ import ( "github.com/aws/aws-lambda-go/events" "github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" donordata "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" @@ -126,11 +125,11 @@ func TestHandleFeeApproved(t *testing.T) { Detail: json.RawMessage(`{"uid":"M-1111-2222-3333"}`), } - donorProvided := donordata.DonorProvidedDetails{ + donorProvided := donordata.Provided{ PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), FeeType: pay.NoFee, - Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending, ConfirmYourIdentityAndSign: actor.IdentityTaskCompleted}, + Tasks: donordata.Tasks{PayForLpa: task.PaymentStatePending, ConfirmYourIdentityAndSign: task.IdentityStateCompleted}, } completedDonorProvided := donorProvided @@ -204,11 +203,11 @@ func TestHandleFeeApprovedWhenNotPaid(t *testing.T) { Detail: json.RawMessage(`{"uid":"M-1111-2222-3333"}`), } - donorProvided := donordata.DonorProvidedDetails{ + donorProvided := donordata.Provided{ PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), FeeType: pay.HalfFee, - Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending, ConfirmYourIdentityAndSign: actor.IdentityTaskCompleted}, + Tasks: donordata.Tasks{PayForLpa: task.PaymentStatePending, ConfirmYourIdentityAndSign: task.IdentityStateCompleted}, } completedDonorProvided := donorProvided @@ -272,11 +271,11 @@ func TestHandleFeeApprovedWhenNotSigned(t *testing.T) { Detail: json.RawMessage(`{"uid":"M-1111-2222-3333"}`), } - donorProvided := donordata.DonorProvidedDetails{ + donorProvided := donordata.Provided{ PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), FeeType: pay.NoFee, - Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}, + Tasks: donordata.Tasks{PayForLpa: task.PaymentStatePending}, } client := newMockDynamodbClient(t) @@ -334,11 +333,11 @@ func TestHandleFeeApprovedWhenAlreadyPaidOrApproved(t *testing.T) { client. On("One", ctx, dynamo.LpaKey("123"), dynamo.DonorKey("456"), mock.Anything). Return(func(ctx context.Context, pk dynamo.PK, sk dynamo.SK, v interface{}) error { - b, _ := attributevalue.Marshal(&donordata.DonorProvidedDetails{ + b, _ := attributevalue.Marshal(&donordata.Provided{ PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), FeeType: pay.NoFee, - Tasks: donordata.DonorTasks{PayForLpa: taskState}, + Tasks: donordata.Tasks{PayForLpa: taskState}, }) attributevalue.Unmarshal(b, v) return nil @@ -362,14 +361,14 @@ func TestHandleFeeApprovedWhenDynamoClientPutError(t *testing.T) { client. On("OneByUID", ctx, "M-1111-2222-3333", mock.Anything). Return(func(ctx context.Context, uid string, v interface{}) error { - b, _ := attributevalue.Marshal(donordata.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456"))}) + b, _ := attributevalue.Marshal(donordata.Provided{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456"))}) attributevalue.Unmarshal(b, v) return nil }) client. On("One", ctx, dynamo.LpaKey("123"), dynamo.DonorKey("456"), mock.Anything). Return(func(ctx context.Context, pk dynamo.PK, sk dynamo.SK, v interface{}) error { - b, _ := attributevalue.Marshal(donordata.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}}) + b, _ := attributevalue.Marshal(donordata.Provided{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: donordata.Tasks{PayForLpa: task.PaymentStatePending}}) attributevalue.Unmarshal(b, v) return nil }) @@ -400,11 +399,11 @@ func TestHandleFeeApprovedWhenShareCodeSenderError(t *testing.T) { client. On("One", ctx, dynamo.LpaKey("123"), dynamo.DonorKey("456"), mock.Anything). Return(func(ctx context.Context, pk dynamo.PK, sk dynamo.SK, v interface{}) error { - b, _ := attributevalue.Marshal(donordata.DonorProvidedDetails{ + b, _ := attributevalue.Marshal(donordata.Provided{ PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), FeeType: pay.NoFee, - Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending, ConfirmYourIdentityAndSign: actor.IdentityTaskCompleted}, + Tasks: donordata.Tasks{PayForLpa: task.PaymentStatePending, ConfirmYourIdentityAndSign: task.IdentityStateCompleted}, }) attributevalue.Unmarshal(b, v) return nil @@ -443,11 +442,11 @@ func TestHandleFeeApprovedWhenLpaStoreError(t *testing.T) { client. On("One", ctx, dynamo.LpaKey("123"), dynamo.DonorKey("456"), mock.Anything). Return(func(ctx context.Context, pk dynamo.PK, sk dynamo.SK, v interface{}) error { - b, _ := attributevalue.Marshal(donordata.DonorProvidedDetails{ + b, _ := attributevalue.Marshal(donordata.Provided{ PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), FeeType: pay.NoFee, - Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending, ConfirmYourIdentityAndSign: actor.IdentityTaskCompleted}, + Tasks: donordata.Tasks{PayForLpa: task.PaymentStatePending, ConfirmYourIdentityAndSign: task.IdentityStateCompleted}, }) attributevalue.Unmarshal(b, v) return nil @@ -469,7 +468,7 @@ func TestHandleFurtherInfoRequested(t *testing.T) { } now := time.Now() - updated := &donordata.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateMoreEvidenceRequired}, UpdatedAt: now} + updated := &donordata.Provided{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: donordata.Tasks{PayForLpa: task.PaymentStateMoreEvidenceRequired}, UpdatedAt: now} updated.UpdateHash() client := newMockDynamodbClient(t) @@ -483,7 +482,7 @@ func TestHandleFurtherInfoRequested(t *testing.T) { client. On("One", ctx, dynamo.LpaKey("123"), dynamo.DonorKey("456"), mock.Anything). Return(func(ctx context.Context, pk dynamo.PK, sk dynamo.SK, v interface{}) error { - b, _ := attributevalue.Marshal(donordata.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}}) + b, _ := attributevalue.Marshal(donordata.Provided{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: donordata.Tasks{PayForLpa: task.PaymentStatePending}}) attributevalue.Unmarshal(b, v) return nil }) @@ -524,10 +523,10 @@ func TestHandleFurtherInfoRequestedWhenPaymentTaskIsAlreadyMoreEvidenceRequired( client. On("One", ctx, dynamo.LpaKey("123"), dynamo.DonorKey("456"), mock.Anything). Return(func(ctx context.Context, pk dynamo.PK, sk dynamo.SK, v interface{}) error { - b, _ := attributevalue.Marshal(&donordata.DonorProvidedDetails{ + b, _ := attributevalue.Marshal(&donordata.Provided{ PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), - Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateMoreEvidenceRequired}, + Tasks: donordata.Tasks{PayForLpa: task.PaymentStateMoreEvidenceRequired}, }) attributevalue.Unmarshal(b, v) @@ -546,7 +545,7 @@ func TestHandleFurtherInfoRequestedWhenPutError(t *testing.T) { } now := time.Now() - updated := &donordata.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateMoreEvidenceRequired}, UpdatedAt: now} + updated := &donordata.Provided{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: donordata.Tasks{PayForLpa: task.PaymentStateMoreEvidenceRequired}, UpdatedAt: now} updated.UpdateHash() client := newMockDynamodbClient(t) @@ -560,7 +559,7 @@ func TestHandleFurtherInfoRequestedWhenPutError(t *testing.T) { client. On("One", ctx, dynamo.LpaKey("123"), dynamo.DonorKey("456"), mock.Anything). Return(func(ctx context.Context, pk dynamo.PK, sk dynamo.SK, v interface{}) error { - b, _ := attributevalue.Marshal(donordata.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}}) + b, _ := attributevalue.Marshal(donordata.Provided{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: donordata.Tasks{PayForLpa: task.PaymentStatePending}}) attributevalue.Unmarshal(b, v) return nil }) @@ -579,7 +578,7 @@ func TestHandleFeeDenied(t *testing.T) { } now := time.Now() - updated := &donordata.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateDenied}, FeeType: pay.FullFee, UpdatedAt: now} + updated := &donordata.Provided{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: donordata.Tasks{PayForLpa: task.PaymentStateDenied}, FeeType: pay.FullFee, UpdatedAt: now} updated.UpdateHash() client := newMockDynamodbClient(t) @@ -593,7 +592,7 @@ func TestHandleFeeDenied(t *testing.T) { client. On("One", ctx, dynamo.LpaKey("123"), dynamo.DonorKey("456"), mock.Anything). Return(func(ctx context.Context, pk dynamo.PK, sk dynamo.SK, v interface{}) error { - b, _ := attributevalue.Marshal(donordata.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}}) + b, _ := attributevalue.Marshal(donordata.Provided{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: donordata.Tasks{PayForLpa: task.PaymentStatePending}}) attributevalue.Unmarshal(b, v) return nil }) @@ -634,7 +633,7 @@ func TestHandleFeeDeniedWhenTaskAlreadyDenied(t *testing.T) { client. On("One", ctx, dynamo.LpaKey("123"), dynamo.DonorKey("456"), mock.Anything). Return(func(ctx context.Context, pk dynamo.PK, sk dynamo.SK, v interface{}) error { - b, _ := attributevalue.Marshal(donordata.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateDenied}}) + b, _ := attributevalue.Marshal(donordata.Provided{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: donordata.Tasks{PayForLpa: task.PaymentStateDenied}}) attributevalue.Unmarshal(b, v) return nil }) @@ -662,7 +661,7 @@ func TestHandleFeeDeniedWhenPutError(t *testing.T) { client. On("One", ctx, dynamo.LpaKey("123"), dynamo.DonorKey("456"), mock.Anything). Return(func(ctx context.Context, pk dynamo.PK, sk dynamo.SK, v interface{}) error { - b, _ := attributevalue.Marshal(donordata.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}}) + b, _ := attributevalue.Marshal(donordata.Provided{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: donordata.Tasks{PayForLpa: task.PaymentStatePending}}) attributevalue.Unmarshal(b, v) return nil }) @@ -699,7 +698,7 @@ func TestHandleDonorSubmissionCompleted(t *testing.T) { OneByUID(ctx, "M-1111-2222-3333", mock.Anything). Return(dynamo.NotFoundError{}) client.EXPECT(). - Put(ctx, &donordata.DonorProvidedDetails{ + Put(ctx, &donordata.Provided{ PK: dynamo.LpaKey(testUuidString), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("PAPER")), LpaID: testUuidString, diff --git a/internal/actor/share_code_data.go b/internal/actor/share_code_data.go deleted file mode 100644 index 96f0a56347..0000000000 --- a/internal/actor/share_code_data.go +++ /dev/null @@ -1,7 +0,0 @@ -package actor - -import ( - "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" -) - -type ShareCodeData = sharecode.ShareCodeData diff --git a/internal/actor/task_state.go b/internal/actor/task_state.go deleted file mode 100644 index d11cf7bcdb..0000000000 --- a/internal/actor/task_state.go +++ /dev/null @@ -1,33 +0,0 @@ -package actor - -import "github.com/ministryofjustice/opg-modernising-lpa/internal/task" - -type TaskState = task.State - -const ( - TaskNotStarted = task.StateNotStarted - TaskInProgress = task.StateInProgress - TaskCompleted = task.StateCompleted -) - -type PaymentTask = task.PaymentState - -const ( - PaymentTaskNotStarted = task.PaymentStateNotStarted - PaymentTaskInProgress = task.PaymentStateInProgress - PaymentTaskPending = task.PaymentStatePending - PaymentTaskApproved = task.PaymentStateApproved - PaymentTaskDenied = task.PaymentStateDenied - PaymentTaskMoreEvidenceRequired = task.PaymentStateMoreEvidenceRequired - PaymentTaskCompleted = task.PaymentStateCompleted -) - -type IdentityTask = task.IdentityState - -const ( - IdentityTaskNotStarted = task.IdentityStateNotStarted - IdentityTaskInProgress = task.IdentityStateInProgress - IdentityTaskPending = task.IdentityStatePending - IdentityTaskProblem = task.IdentityStateProblem - IdentityTaskCompleted = task.IdentityStateCompleted -) diff --git a/internal/app/dashboard_store.go b/internal/app/dashboard_store.go index 869c57dd53..3a04fcbe7e 100644 --- a/internal/app/dashboard_store.go +++ b/internal/app/dashboard_store.go @@ -19,7 +19,7 @@ import ( ) type LpaStoreResolvingService interface { - ResolveList(ctx context.Context, donors []*donordata.DonorProvidedDetails) ([]*lpastore.Lpa, error) + ResolveList(ctx context.Context, donors []*donordata.Provided) ([]*lpastore.Lpa, error) } // An lpaLink is used to join an actor to an LPA. @@ -105,7 +105,7 @@ func (s *dashboardStore) GetAll(ctx context.Context) (donor, attorney, certifica var ( referencedKeys []dynamo.Keys - donorsDetails []*donordata.DonorProvidedDetails + donorsDetails []*donordata.Provided ) for _, item := range lpasOrProvidedDetails { var ks dynamo.Keys @@ -115,7 +115,7 @@ func (s *dashboardStore) GetAll(ctx context.Context) (donor, attorney, certifica if isLpaKey(ks) { var donorDetails struct { - donordata.DonorProvidedDetails + donordata.Provided ReferencedSK dynamo.OrganisationKeyType } if err := attributevalue.UnmarshalMap(item, &donorDetails); err != nil { @@ -125,7 +125,7 @@ func (s *dashboardStore) GetAll(ctx context.Context) (donor, attorney, certifica if donorDetails.ReferencedSK != "" { referencedKeys = append(referencedKeys, dynamo.Keys{PK: ks.PK, SK: donorDetails.ReferencedSK}) } else if donorDetails.LpaUID != "" { - donorsDetails = append(donorsDetails, &donorDetails.DonorProvidedDetails) + donorsDetails = append(donorsDetails, &donorDetails.Provided) } } } @@ -137,7 +137,7 @@ func (s *dashboardStore) GetAll(ctx context.Context) (donor, attorney, certifica } for _, item := range referencedLpas { - donorDetails := &donordata.DonorProvidedDetails{} + donorDetails := &donordata.Provided{} if err := attributevalue.UnmarshalMap(item, donorDetails); err != nil { return nil, nil, nil, err } diff --git a/internal/app/dashboard_store_test.go b/internal/app/dashboard_store_test.go index d188572d42..874ee5ea15 100644 --- a/internal/app/dashboard_store_test.go +++ b/internal/app/dashboard_store_test.go @@ -15,6 +15,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" mock "github.com/stretchr/testify/mock" ) @@ -24,7 +25,7 @@ func TestDashboardStoreGetAll(t *testing.T) { aTime := time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC) lpa0 := &lpastore.Lpa{LpaID: "0", LpaUID: "M", UpdatedAt: aTime} - lpa0Donor := &donordata.DonorProvidedDetails{ + lpa0Donor := &donordata.Provided{ PK: dynamo.LpaKey("0"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey(sessionID)), LpaID: "0", @@ -32,7 +33,7 @@ func TestDashboardStoreGetAll(t *testing.T) { UpdatedAt: aTime, } lpa123 := &lpastore.Lpa{LpaID: "123", LpaUID: "M", UpdatedAt: aTime} - lpa123Donor := &donordata.DonorProvidedDetails{ + lpa123Donor := &donordata.Provided{ PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey(sessionID)), LpaID: "123", @@ -40,7 +41,7 @@ func TestDashboardStoreGetAll(t *testing.T) { UpdatedAt: aTime, } lpa456 := &lpastore.Lpa{LpaID: "456", LpaUID: "M"} - lpa456Donor := &donordata.DonorProvidedDetails{ + lpa456Donor := &donordata.Provided{ PK: dynamo.LpaKey("456"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("another-id")), LpaID: "456", @@ -50,10 +51,10 @@ func TestDashboardStoreGetAll(t *testing.T) { PK: dynamo.LpaKey("456"), SK: dynamo.CertificateProviderKey(sessionID), LpaID: "456", - Tasks: certificateproviderdata.Tasks{ConfirmYourDetails: actor.TaskCompleted}, + Tasks: certificateproviderdata.Tasks{ConfirmYourDetails: task.StateCompleted}, } lpa789 := &lpastore.Lpa{LpaID: "789", LpaUID: "M"} - lpa789Donor := &donordata.DonorProvidedDetails{ + lpa789Donor := &donordata.Provided{ PK: dynamo.LpaKey("789"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("different-id")), LpaID: "789", @@ -63,16 +64,16 @@ func TestDashboardStoreGetAll(t *testing.T) { PK: dynamo.LpaKey("789"), SK: dynamo.AttorneyKey(sessionID), LpaID: "789", - Tasks: attorneydata.Tasks{ConfirmYourDetails: actor.TaskInProgress}, + Tasks: attorneydata.Tasks{ConfirmYourDetails: task.StateInProgress}, } - lpaNoUIDDonor := &donordata.DonorProvidedDetails{ + lpaNoUIDDonor := &donordata.Provided{ PK: dynamo.LpaKey("0"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey(sessionID)), LpaID: "999", UpdatedAt: aTime, } lpaCertified := &lpastore.Lpa{LpaID: "signed-by-cp", LpaUID: "M"} - lpaCertifiedDonor := &donordata.DonorProvidedDetails{ + lpaCertifiedDonor := &donordata.Provided{ PK: dynamo.LpaKey("signed-by-cp"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("another-id")), LpaID: "signed-by-cp", @@ -90,7 +91,7 @@ func TestDashboardStoreGetAll(t *testing.T) { "SK": dynamo.DonorKey(sessionID), "ReferencedSK": dynamo.OrganisationKey("org-id"), } - lpaReferencedDonor := &donordata.DonorProvidedDetails{ + lpaReferencedDonor := &donordata.Provided{ PK: dynamo.LpaKey("referenced"), SK: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), LpaID: "referenced", @@ -158,7 +159,7 @@ func TestDashboardStoreGetAll(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). - ResolveList(ctx, []*donordata.DonorProvidedDetails{lpa123Donor, lpa456Donor, lpa789Donor, lpa0Donor, lpaCertifiedDonor, lpaReferencedDonor}). + ResolveList(ctx, []*donordata.Provided{lpa123Donor, lpa456Donor, lpa789Donor, lpa0Donor, lpaCertifiedDonor, lpaReferencedDonor}). Return([]*lpastore.Lpa{lpa123, lpa456, lpa789, lpa0, lpaCertified, lpaReferenced}, nil) dashboardStore := &dashboardStore{dynamoClient: dynamoClient, lpaStoreResolvingService: lpaStoreResolvingService} @@ -178,7 +179,7 @@ func TestDashboardStoreGetAllSubmittedForAttorneys(t *testing.T) { aTime := time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC) lpaSubmitted := &lpastore.Lpa{LpaID: "submitted", LpaUID: "M", Submitted: true} - lpaSubmittedDonor := &donordata.DonorProvidedDetails{ + lpaSubmittedDonor := &donordata.Provided{ PK: dynamo.LpaKey("submitted"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("another-id")), LpaID: "submitted", @@ -191,7 +192,7 @@ func TestDashboardStoreGetAllSubmittedForAttorneys(t *testing.T) { LpaID: "submitted", } lpaSubmittedReplacement := &lpastore.Lpa{LpaID: "submitted-replacement", LpaUID: "M", Submitted: true} - lpaSubmittedReplacementDonor := &donordata.DonorProvidedDetails{ + lpaSubmittedReplacementDonor := &donordata.Provided{ PK: dynamo.LpaKey("submitted-replacement"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("another-id")), LpaID: "submitted-replacement", @@ -227,7 +228,7 @@ func TestDashboardStoreGetAllSubmittedForAttorneys(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). - ResolveList(ctx, []*donordata.DonorProvidedDetails{lpaSubmittedDonor, lpaSubmittedReplacementDonor}). + ResolveList(ctx, []*donordata.Provided{lpaSubmittedDonor, lpaSubmittedReplacementDonor}). Return([]*lpastore.Lpa{lpaSubmitted, lpaSubmittedReplacement}, nil) dashboardStore := &dashboardStore{dynamoClient: dynamoClient, lpaStoreResolvingService: lpaStoreResolvingService} @@ -249,7 +250,7 @@ func TestDashboardStoreGetAllWhenResolveErrors(t *testing.T) { sessionID := "an-id" aTime := time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC) - donor := &donordata.DonorProvidedDetails{LpaID: "0", LpaUID: "M", UpdatedAt: aTime, SK: dynamo.LpaOwnerKey(dynamo.DonorKey(sessionID)), PK: dynamo.LpaKey("0")} + donor := &donordata.Provided{LpaID: "0", LpaUID: "M", UpdatedAt: aTime, SK: dynamo.LpaOwnerKey(dynamo.DonorKey(sessionID)), PK: dynamo.LpaKey("0")} ctx := page.ContextWithSessionData(context.Background(), &appcontext.SessionData{SessionID: sessionID}) diff --git a/internal/app/document_store.go b/internal/app/document_store.go index 0e72a69c0c..e611cc70c9 100644 --- a/internal/app/document_store.go +++ b/internal/app/document_store.go @@ -38,7 +38,7 @@ func NewDocumentStore(dynamoClient DynamoClient, s3Client S3Client, eventClient } } -func (s *documentStore) Create(ctx context.Context, donor *donordata.DonorProvidedDetails, filename string, data []byte) (page.Document, error) { +func (s *documentStore) Create(ctx context.Context, donor *donordata.Provided, filename string, data []byte) (page.Document, error) { key := donor.LpaUID + "/evidence/" + s.randomUUID() document := page.Document{ @@ -117,7 +117,7 @@ func (s *documentStore) Delete(ctx context.Context, document page.Document) erro return s.dynamoClient.DeleteOne(ctx, document.PK, document.SK) } -func (s *documentStore) Submit(ctx context.Context, donor *donordata.DonorProvidedDetails, documents page.Documents) error { +func (s *documentStore) Submit(ctx context.Context, donor *donordata.Provided, documents page.Documents) error { var unsentDocuments []any var unsentEvidence []event.Evidence diff --git a/internal/app/document_store_test.go b/internal/app/document_store_test.go index 19431da4fa..9d90f87b51 100644 --- a/internal/app/document_store_test.go +++ b/internal/app/document_store_test.go @@ -286,7 +286,7 @@ func TestDocumentStoreSubmit(t *testing.T) { ctx := context.Background() now := time.Now() - donor := &donordata.DonorProvidedDetails{LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload} + donor := &donordata.Provided{LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload} documents := page.Documents{ {PK: "a-pk", SK: "a-sk", Key: "a-key", Filename: "a-filename.pdf"}, {PK: "b-pk", SK: "b-sk", Key: "b-key", Filename: "b-filename.png"}, @@ -335,7 +335,7 @@ func TestDocumentStoreSubmit(t *testing.T) { func TestDocumentStoreSubmitWhenNoUnsentDocuments(t *testing.T) { ctx := context.Background() - donor := &donordata.DonorProvidedDetails{LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload} + donor := &donordata.Provided{LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload} documents := page.Documents{{PK: "a-pk", SK: "a-sk", Key: "a-key", Sent: time.Now()}} documentStore := &documentStore{} @@ -348,7 +348,7 @@ func TestDocumentStoreSubmitWhenS3ClientErrors(t *testing.T) { ctx := context.Background() now := time.Now() - donor := &donordata.DonorProvidedDetails{LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload} + donor := &donordata.Provided{LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload} documents := page.Documents{{PK: "a-pk", SK: "a-sk", Key: "a-key"}} s3Client := newMockS3Client(t) @@ -369,7 +369,7 @@ func TestDocumentStoreSubmitWhenEventClientErrors(t *testing.T) { ctx := context.Background() now := time.Now() - donor := &donordata.DonorProvidedDetails{LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload} + donor := &donordata.Provided{LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload} documents := page.Documents{{PK: "a-pk", SK: "a-sk", Key: "a-key"}} s3Client := newMockS3Client(t) @@ -396,7 +396,7 @@ func TestDocumentStoreSubmitWhenDynamoClientErrors(t *testing.T) { ctx := context.Background() now := time.Now() - donor := &donordata.DonorProvidedDetails{LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload} + donor := &donordata.Provided{LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload} documents := page.Documents{{PK: "a-pk", SK: "a-sk", Key: "a-key"}} s3Client := newMockS3Client(t) @@ -429,7 +429,7 @@ func TestDocumentCreate(t *testing.T) { ctx := context.Background() now := time.Now() - donor := &donordata.DonorProvidedDetails{LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload, LpaID: "lpa-id"} + donor := &donordata.Provided{LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload, LpaID: "lpa-id"} data := []byte("some-data") @@ -468,7 +468,7 @@ func TestDocumentCreateWhenS3Error(t *testing.T) { ctx := context.Background() now := time.Now() - donor := &donordata.DonorProvidedDetails{LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload, LpaID: "lpa-id"} + donor := &donordata.Provided{LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload, LpaID: "lpa-id"} s3Client := newMockS3Client(t) s3Client.EXPECT(). @@ -490,7 +490,7 @@ func TestDocumentCreateWhenDynamoError(t *testing.T) { ctx := context.Background() now := time.Now() - donor := &donordata.DonorProvidedDetails{LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload, LpaID: "lpa-id"} + donor := &donordata.Provided{LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload, LpaID: "lpa-id"} data := []byte("some-data") diff --git a/internal/app/evidence_received_store_test.go b/internal/app/evidence_received_store_test.go index 4a32724c4a..dbfb86a435 100644 --- a/internal/app/evidence_received_store_test.go +++ b/internal/app/evidence_received_store_test.go @@ -50,7 +50,7 @@ func TestEvidenceReceivedStoreGetWhenDataStoreError(t *testing.T) { ctx := page.ContextWithSessionData(context.Background(), &appcontext.SessionData{LpaID: "an-id", SessionID: "456"}) dynamoClient := newMockDynamoClient(t) - dynamoClient.ExpectOne(ctx, dynamo.LpaKey("an-id"), dynamo.EvidenceReceivedKey(), &donordata.DonorProvidedDetails{LpaID: "an-id"}, expectedError) + dynamoClient.ExpectOne(ctx, dynamo.LpaKey("an-id"), dynamo.EvidenceReceivedKey(), &donordata.Provided{LpaID: "an-id"}, expectedError) evidenceReceivedStore := &evidenceReceivedStore{dynamoClient: dynamoClient} diff --git a/internal/app/mock_LpaStoreResolvingService_test.go b/internal/app/mock_LpaStoreResolvingService_test.go index 9c7cdc28a0..980a0b9cb9 100644 --- a/internal/app/mock_LpaStoreResolvingService_test.go +++ b/internal/app/mock_LpaStoreResolvingService_test.go @@ -25,7 +25,7 @@ func (_m *mockLpaStoreResolvingService) EXPECT() *mockLpaStoreResolvingService_E } // ResolveList provides a mock function with given fields: ctx, donors -func (_m *mockLpaStoreResolvingService) ResolveList(ctx context.Context, donors []*donordata.DonorProvidedDetails) ([]*lpastore.Lpa, error) { +func (_m *mockLpaStoreResolvingService) ResolveList(ctx context.Context, donors []*donordata.Provided) ([]*lpastore.Lpa, error) { ret := _m.Called(ctx, donors) if len(ret) == 0 { @@ -34,10 +34,10 @@ func (_m *mockLpaStoreResolvingService) ResolveList(ctx context.Context, donors var r0 []*lpastore.Lpa var r1 error - if rf, ok := ret.Get(0).(func(context.Context, []*donordata.DonorProvidedDetails) ([]*lpastore.Lpa, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, []*donordata.Provided) ([]*lpastore.Lpa, error)); ok { return rf(ctx, donors) } - if rf, ok := ret.Get(0).(func(context.Context, []*donordata.DonorProvidedDetails) []*lpastore.Lpa); ok { + if rf, ok := ret.Get(0).(func(context.Context, []*donordata.Provided) []*lpastore.Lpa); ok { r0 = rf(ctx, donors) } else { if ret.Get(0) != nil { @@ -45,7 +45,7 @@ func (_m *mockLpaStoreResolvingService) ResolveList(ctx context.Context, donors } } - if rf, ok := ret.Get(1).(func(context.Context, []*donordata.DonorProvidedDetails) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, []*donordata.Provided) error); ok { r1 = rf(ctx, donors) } else { r1 = ret.Error(1) @@ -66,9 +66,9 @@ func (_e *mockLpaStoreResolvingService_Expecter) ResolveList(ctx interface{}, do return &mockLpaStoreResolvingService_ResolveList_Call{Call: _e.mock.On("ResolveList", ctx, donors)} } -func (_c *mockLpaStoreResolvingService_ResolveList_Call) Run(run func(ctx context.Context, donors []*donordata.DonorProvidedDetails)) *mockLpaStoreResolvingService_ResolveList_Call { +func (_c *mockLpaStoreResolvingService_ResolveList_Call) Run(run func(ctx context.Context, donors []*donordata.Provided)) *mockLpaStoreResolvingService_ResolveList_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].([]*donordata.DonorProvidedDetails)) + run(args[0].(context.Context), args[1].([]*donordata.Provided)) }) return _c } @@ -78,7 +78,7 @@ func (_c *mockLpaStoreResolvingService_ResolveList_Call) Return(_a0 []*lpastore. return _c } -func (_c *mockLpaStoreResolvingService_ResolveList_Call) RunAndReturn(run func(context.Context, []*donordata.DonorProvidedDetails) ([]*lpastore.Lpa, error)) *mockLpaStoreResolvingService_ResolveList_Call { +func (_c *mockLpaStoreResolvingService_ResolveList_Call) RunAndReturn(run func(context.Context, []*donordata.Provided) ([]*lpastore.Lpa, error)) *mockLpaStoreResolvingService_ResolveList_Call { _c.Call.Return(run) return _c } diff --git a/internal/app/organisation_store.go b/internal/app/organisation_store.go index 72399c1502..5d82ed505e 100644 --- a/internal/app/organisation_store.go +++ b/internal/app/organisation_store.go @@ -87,7 +87,7 @@ func (s *organisationStore) Put(ctx context.Context, organisation *actor.Organis return s.dynamoClient.Put(ctx, organisation) } -func (s *organisationStore) CreateLPA(ctx context.Context) (*donordata.DonorProvidedDetails, error) { +func (s *organisationStore) CreateLPA(ctx context.Context) (*donordata.Provided, error) { data, err := appcontext.SessionDataFromContext(ctx) if err != nil { return nil, err @@ -100,7 +100,7 @@ func (s *organisationStore) CreateLPA(ctx context.Context) (*donordata.DonorProv lpaID := s.uuidString() donorUID := s.newUID() - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ PK: dynamo.LpaKey(lpaID), SK: dynamo.LpaOwnerKey(dynamo.OrganisationKey(data.OrganisationID)), LpaID: lpaID, diff --git a/internal/app/organisation_store_test.go b/internal/app/organisation_store_test.go index 45df097c90..aea6e65640 100644 --- a/internal/app/organisation_store_test.go +++ b/internal/app/organisation_store_test.go @@ -179,7 +179,7 @@ func TestOrganisationStorePut(t *testing.T) { func TestOrganisationStoreCreateLPA(t *testing.T) { ctx := page.ContextWithSessionData(context.Background(), &appcontext.SessionData{OrganisationID: "an-id"}) - expectedDonor := &donordata.DonorProvidedDetails{ + expectedDonor := &donordata.Provided{ PK: dynamo.LpaKey("a-uuid"), SK: dynamo.LpaOwnerKey(dynamo.OrganisationKey("an-id")), LpaID: "a-uuid", diff --git a/internal/app/share_code_store.go b/internal/app/share_code_store.go index 26d5c55aab..695c131b83 100644 --- a/internal/app/share_code_store.go +++ b/internal/app/share_code_store.go @@ -9,6 +9,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" ) type ShareCodeStoreDynamoClient interface { @@ -28,8 +29,8 @@ func NewShareCodeStore(dynamoClient ShareCodeStoreDynamoClient) *shareCodeStore return &shareCodeStore{dynamoClient: dynamoClient, now: time.Now} } -func (s *shareCodeStore) Get(ctx context.Context, actorType actor.Type, shareCode string) (actor.ShareCodeData, error) { - var data actor.ShareCodeData +func (s *shareCodeStore) Get(ctx context.Context, actorType actor.Type, shareCode string) (sharecode.Data, error) { + var data sharecode.Data pk, err := shareCodeKey(actorType, shareCode) if err != nil { @@ -37,17 +38,17 @@ func (s *shareCodeStore) Get(ctx context.Context, actorType actor.Type, shareCod } if err := s.dynamoClient.OneByPK(ctx, pk, &data); err != nil { - return actor.ShareCodeData{}, err + return sharecode.Data{}, err } if !data.LpaLinkedAt.IsZero() { - return actor.ShareCodeData{}, dynamo.NotFoundError{} + return sharecode.Data{}, dynamo.NotFoundError{} } return data, err } -func (s *shareCodeStore) Put(ctx context.Context, actorType actor.Type, shareCode string, data actor.ShareCodeData) error { +func (s *shareCodeStore) Put(ctx context.Context, actorType actor.Type, shareCode string, data sharecode.Data) error { pk, err := shareCodeKey(actorType, shareCode) if err != nil { return err @@ -59,7 +60,7 @@ func (s *shareCodeStore) Put(ctx context.Context, actorType actor.Type, shareCod return s.dynamoClient.Put(ctx, data) } -func (s *shareCodeStore) PutDonor(ctx context.Context, shareCode string, data actor.ShareCodeData) error { +func (s *shareCodeStore) PutDonor(ctx context.Context, shareCode string, data sharecode.Data) error { organisationKey, ok := data.LpaOwnerKey.Organisation() if !ok { return errors.New("shareCodeStore.PutDonor can only be used by organisations") @@ -72,8 +73,8 @@ func (s *shareCodeStore) PutDonor(ctx context.Context, shareCode string, data ac return s.dynamoClient.Put(ctx, data) } -func (s *shareCodeStore) GetDonor(ctx context.Context) (actor.ShareCodeData, error) { - var data actor.ShareCodeData +func (s *shareCodeStore) GetDonor(ctx context.Context) (sharecode.Data, error) { + var data sharecode.Data sessionData, err := appcontext.SessionDataFromContext(ctx) if err != nil { @@ -86,7 +87,7 @@ func (s *shareCodeStore) GetDonor(ctx context.Context) (actor.ShareCodeData, err return data, err } -func (s *shareCodeStore) Delete(ctx context.Context, shareCode actor.ShareCodeData) error { +func (s *shareCodeStore) Delete(ctx context.Context, shareCode sharecode.Data) error { return s.dynamoClient.DeleteOne(ctx, shareCode.PK, shareCode.SK) } diff --git a/internal/app/share_code_store_test.go b/internal/app/share_code_store_test.go index 7ffedbacc7..1b4b4c0cca 100644 --- a/internal/app/share_code_store_test.go +++ b/internal/app/share_code_store_test.go @@ -9,6 +9,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -35,7 +36,7 @@ func TestShareCodeStoreGet(t *testing.T) { for name, tc := range testcases { t.Run(name, func(t *testing.T) { ctx := context.Background() - data := actor.ShareCodeData{LpaKey: "lpa-id"} + data := sharecode.Data{LpaKey: "lpa-id"} dynamoClient := newMockDynamoClient(t) dynamoClient. @@ -57,13 +58,13 @@ func TestShareCodeStoreGetWhenLinked(t *testing.T) { dynamoClient := newMockDynamoClient(t) dynamoClient. ExpectOneByPK(ctx, dynamo.ShareKey(dynamo.DonorShareKey("123")), - actor.ShareCodeData{LpaLinkedAt: time.Now()}, nil) + sharecode.Data{LpaLinkedAt: time.Now()}, nil) shareCodeStore := &shareCodeStore{dynamoClient: dynamoClient} result, err := shareCodeStore.Get(ctx, actor.TypeDonor, "123") assert.Equal(t, dynamo.NotFoundError{}, err) - assert.Equal(t, actor.ShareCodeData{}, result) + assert.Equal(t, sharecode.Data{}, result) } func TestShareCodeStoreGetForBadActorType(t *testing.T) { @@ -76,7 +77,7 @@ func TestShareCodeStoreGetForBadActorType(t *testing.T) { func TestShareCodeStoreGetOnError(t *testing.T) { ctx := context.Background() - data := actor.ShareCodeData{LpaKey: "lpa-id"} + data := sharecode.Data{LpaKey: "lpa-id"} dynamoClient := newMockDynamoClient(t) dynamoClient. @@ -111,7 +112,7 @@ func TestShareCodeStorePut(t *testing.T) { for name, tc := range testcases { t.Run(name, func(t *testing.T) { ctx := context.Background() - data := actor.ShareCodeData{PK: tc.pk, SK: dynamo.ShareSortKey(dynamo.MetadataKey("123")), LpaKey: "lpa-id"} + data := sharecode.Data{PK: tc.pk, SK: dynamo.ShareSortKey(dynamo.MetadataKey("123")), LpaKey: "lpa-id"} dynamoClient := newMockDynamoClient(t) dynamoClient.EXPECT(). @@ -130,7 +131,7 @@ func TestShareCodeStorePutForBadActorType(t *testing.T) { ctx := context.Background() shareCodeStore := &shareCodeStore{} - err := shareCodeStore.Put(ctx, actor.TypePersonToNotify, "123", actor.ShareCodeData{}) + err := shareCodeStore.Put(ctx, actor.TypePersonToNotify, "123", sharecode.Data{}) assert.NotNil(t, err) } @@ -144,7 +145,7 @@ func TestShareCodeStorePutOnError(t *testing.T) { shareCodeStore := &shareCodeStore{dynamoClient: dynamoClient} - err := shareCodeStore.Put(ctx, actor.TypeAttorney, "123", actor.ShareCodeData{LpaKey: "123"}) + err := shareCodeStore.Put(ctx, actor.TypeAttorney, "123", sharecode.Data{LpaKey: "123"}) assert.Equal(t, expectedError, err) } @@ -161,7 +162,7 @@ func TestShareCodeStoreGetDonor(t *testing.T) { OrganisationID: "org-id", LpaID: "lpa-id", }) - data := actor.ShareCodeData{LpaKey: dynamo.LpaKey("lpa-id")} + data := sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id")} dynamoClient := newMockDynamoClient(t) dynamoClient. @@ -188,7 +189,7 @@ func TestShareCodeStorePutDonor(t *testing.T) { dynamoClient := newMockDynamoClient(t) dynamoClient.EXPECT(). - Put(ctx, actor.ShareCodeData{ + Put(ctx, sharecode.Data{ PK: dynamo.ShareKey(dynamo.DonorShareKey("123")), SK: dynamo.ShareSortKey(dynamo.DonorInviteKey(dynamo.OrganisationKey("org-id"), dynamo.LpaKey("lpa-id"))), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), @@ -199,7 +200,7 @@ func TestShareCodeStorePutDonor(t *testing.T) { shareCodeStore := &shareCodeStore{dynamoClient: dynamoClient, now: testNowFn} - err := shareCodeStore.PutDonor(ctx, "123", actor.ShareCodeData{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), LpaKey: dynamo.LpaKey("lpa-id")}) + err := shareCodeStore.PutDonor(ctx, "123", sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), LpaKey: dynamo.LpaKey("lpa-id")}) assert.Nil(t, err) } @@ -208,7 +209,7 @@ func TestShareCodeStorePutDonorWhenDonor(t *testing.T) { shareCodeStore := &shareCodeStore{} - err := shareCodeStore.PutDonor(ctx, "123", actor.ShareCodeData{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("org-id")), LpaKey: dynamo.LpaKey("lpa-id")}) + err := shareCodeStore.PutDonor(ctx, "123", sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("org-id")), LpaKey: dynamo.LpaKey("lpa-id")}) assert.Error(t, err) } @@ -224,7 +225,7 @@ func TestShareCodeStoreDelete(t *testing.T) { shareCodeStore := &shareCodeStore{dynamoClient: dynamoClient} - err := shareCodeStore.Delete(ctx, actor.ShareCodeData{LpaKey: "123", PK: pk, SK: sk}) + err := shareCodeStore.Delete(ctx, sharecode.Data{LpaKey: "123", PK: pk, SK: sk}) assert.Nil(t, err) } @@ -238,7 +239,7 @@ func TestShareCodeStoreDeleteOnError(t *testing.T) { shareCodeStore := &shareCodeStore{dynamoClient: dynamoClient} - err := shareCodeStore.Delete(ctx, actor.ShareCodeData{}) + err := shareCodeStore.Delete(ctx, sharecode.Data{}) assert.Equal(t, expectedError, err) } diff --git a/internal/app/uid_store.go b/internal/app/uid_store.go index 3fb804b06e..7611c3ab17 100644 --- a/internal/app/uid_store.go +++ b/internal/app/uid_store.go @@ -50,7 +50,7 @@ func (s *uidStore) Set(ctx context.Context, lpaID, sessionID, organisationID, ui return fmt.Errorf("uidStore update failed: %w", err) } - var donor *donordata.DonorProvidedDetails + var donor *donordata.Provided if err := attributevalue.UnmarshalMap(newAttrs, &donor); err != nil { return fmt.Errorf("uidStore unmarshal failed: %w", err) } diff --git a/internal/app/uid_store_test.go b/internal/app/uid_store_test.go index d8d76672c4..c27c34b1b1 100644 --- a/internal/app/uid_store_test.go +++ b/internal/app/uid_store_test.go @@ -32,7 +32,7 @@ func TestUidStoreSet(t *testing.T) { ":now": testNow, }) - returnValues, _ := attributevalue.MarshalMap(donordata.DonorProvidedDetails{ + returnValues, _ := attributevalue.MarshalMap(donordata.Provided{ Donor: donordata.Donor{ FirstNames: "x", LastName: "y", @@ -79,7 +79,7 @@ func TestUidStoreSetWhenDynamoClientError(t *testing.T) { } func TestUidStoreSetWhenSearchIndexErrors(t *testing.T) { - returnValues, _ := attributevalue.MarshalMap(donordata.DonorProvidedDetails{ + returnValues, _ := attributevalue.MarshalMap(donordata.Provided{ Donor: donordata.Donor{ FirstNames: "x", LastName: "y", diff --git a/internal/attorney/attorneydata/store.go b/internal/attorney/attorneydata/store.go index d9d23b4be0..3263c7b8fa 100644 --- a/internal/attorney/attorneydata/store.go +++ b/internal/attorney/attorneydata/store.go @@ -42,7 +42,7 @@ func NewStore(dynamoClient DynamoClient, now func() time.Time) *Store { return &Store{dynamoClient: dynamoClient, now: now} } -func (s *Store) Create(ctx context.Context, shareCode sharecode.ShareCodeData, email string) (*Provided, error) { +func (s *Store) Create(ctx context.Context, shareCode sharecode.Data, email string) (*Provided, error) { data, err := appcontext.SessionDataFromContext(ctx) if err != nil { return nil, err diff --git a/internal/attorney/attorneydata/store_test.go b/internal/attorney/attorneydata/store_test.go index 3a5f3770e9..c4f9744aa0 100644 --- a/internal/attorney/attorneydata/store_test.go +++ b/internal/attorney/attorneydata/store_test.go @@ -43,7 +43,7 @@ func TestAttorneyStoreCreate(t *testing.T) { Email: "a@example.com", } - shareCode := sharecode.ShareCodeData{ + shareCode := sharecode.Data{ PK: dynamo.ShareKey(dynamo.AttorneyShareKey("123")), SK: dynamo.ShareSortKey(dynamo.MetadataKey("123")), ActorUID: uid, @@ -91,7 +91,7 @@ func TestAttorneyStoreCreateWhenSessionMissing(t *testing.T) { attorneyStore := &Store{dynamoClient: nil, now: nil} - _, err := attorneyStore.Create(ctx, sharecode.ShareCodeData{}, "") + _, err := attorneyStore.Create(ctx, sharecode.Data{}, "") assert.Equal(t, appcontext.SessionMissingError{}, err) } @@ -107,7 +107,7 @@ func TestAttorneyStoreCreateWhenSessionDataMissing(t *testing.T) { attorneyStore := &Store{} - _, err := attorneyStore.Create(ctx, sharecode.ShareCodeData{}, "") + _, err := attorneyStore.Create(ctx, sharecode.Data{}, "") assert.NotNil(t, err) }) } @@ -124,7 +124,7 @@ func TestAttorneyStoreCreateWhenWriteTransactionError(t *testing.T) { attorneyStore := &Store{dynamoClient: dynamoClient, now: func() time.Time { return now }} - _, err := attorneyStore.Create(ctx, sharecode.ShareCodeData{ + _, err := attorneyStore.Create(ctx, sharecode.Data{ PK: dynamo.ShareKey(dynamo.AttorneyShareKey("123")), SK: dynamo.ShareSortKey(dynamo.MetadataKey("123")), }, "") diff --git a/internal/attorney/attorneypage/confirm_dont_want_to_be_attorney_logged_out_test.go b/internal/attorney/attorneypage/confirm_dont_want_to_be_attorney_logged_out_test.go index 1825ed7426..c382a809c3 100644 --- a/internal/attorney/attorneypage/confirm_dont_want_to_be_attorney_logged_out_test.go +++ b/internal/attorney/attorneypage/confirm_dont_want_to_be_attorney_logged_out_test.go @@ -15,6 +15,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" + sharecode "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -152,7 +153,7 @@ func TestPostConfirmDontWantToBeAttorneyLoggedOut(t *testing.T) { LpaData(r). Return(&sesh.LpaDataSession{LpaID: "lpa-id"}, nil) - shareCodeData := actor.ShareCodeData{ + shareCodeData := sharecode.Data{ LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), ActorUID: tc.uid, @@ -229,7 +230,7 @@ func TestPostConfirmDontWantToBeAttorneyLoggedOutWhenAttorneyNotFound(t *testing LpaData(r). Return(&sesh.LpaDataSession{LpaID: "lpa-id"}, nil) - shareCodeData := actor.ShareCodeData{ + shareCodeData := sharecode.Data{ LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), ActorUID: actoruid.New(), @@ -260,7 +261,7 @@ func TestPostConfirmDontWantToBeAttorneyLoggedOutErrors(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/?referenceNumber=123", nil) ctx := page.ContextWithSessionData(r.Context(), &appcontext.SessionData{LpaID: "lpa-id"}) - shareCodeData := actor.ShareCodeData{ + shareCodeData := sharecode.Data{ LpaKey: dynamo.LpaKey("lpa-id"), } diff --git a/internal/attorney/attorneypage/confirm_your_details.go b/internal/attorney/attorneypage/confirm_your_details.go index f0f7111f14..6126761bfb 100644 --- a/internal/attorney/attorneypage/confirm_your_details.go +++ b/internal/attorney/attorneypage/confirm_your_details.go @@ -4,10 +4,10 @@ import ( "net/http" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -23,7 +23,7 @@ type confirmYourDetailsData struct { func ConfirmYourDetails(tmpl template.Template, attorneyStore AttorneyStore, lpaStoreResolvingService LpaStoreResolvingService) Handler { return func(appData page.AppData, w http.ResponseWriter, r *http.Request, attorneyProvidedDetails *attorneydata.Provided) error { if r.Method == http.MethodPost { - attorneyProvidedDetails.Tasks.ConfirmYourDetails = actor.TaskCompleted + attorneyProvidedDetails.Tasks.ConfirmYourDetails = task.StateCompleted if err := attorneyStore.Put(r.Context(), attorneyProvidedDetails); err != nil { return err diff --git a/internal/attorney/attorneypage/confirm_your_details_test.go b/internal/attorney/attorneypage/confirm_your_details_test.go index e37c2eb01b..9026466b70 100644 --- a/internal/attorney/attorneypage/confirm_your_details_test.go +++ b/internal/attorney/attorneypage/confirm_your_details_test.go @@ -5,11 +5,11 @@ import ( "net/http/httptest" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -122,7 +122,7 @@ func TestPostConfirmYourDetails(t *testing.T) { Put(r.Context(), &attorneydata.Provided{ UID: uid, LpaID: "lpa-id", - Tasks: attorneydata.Tasks{ConfirmYourDetails: actor.TaskCompleted}, + Tasks: attorneydata.Tasks{ConfirmYourDetails: task.StateCompleted}, }). Return(nil) diff --git a/internal/attorney/attorneypage/enter_reference_number_opt_out_test.go b/internal/attorney/attorneypage/enter_reference_number_opt_out_test.go index 12d1842096..b209eed2c5 100644 --- a/internal/attorney/attorneypage/enter_reference_number_opt_out_test.go +++ b/internal/attorney/attorneypage/enter_reference_number_opt_out_test.go @@ -12,6 +12,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" + sharecode "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -74,7 +75,7 @@ func TestPostEnterReferenceNumberOptOut(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), actor.TypeAttorney, "abcdef123456"). - Return(actor.ShareCodeData{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id")), ActorUID: uid}, nil) + Return(sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id")), ActorUID: uid}, nil) sessionStore := newMockSessionStore(t) sessionStore.EXPECT(). @@ -107,7 +108,7 @@ func TestPostEnterReferenceNumberOptOutErrors(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(mock.Anything, mock.Anything, mock.Anything). - Return(actor.ShareCodeData{}, expectedError) + Return(sharecode.Data{}, expectedError) return shareCodeStore }, @@ -118,7 +119,7 @@ func TestPostEnterReferenceNumberOptOutErrors(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(mock.Anything, mock.Anything, mock.Anything). - Return(actor.ShareCodeData{LpaKey: dynamo.LpaKey("lpa-id")}, nil) + Return(sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id")}, nil) return shareCodeStore }, @@ -168,7 +169,7 @@ func TestPostEnterReferenceNumberOptOutOnShareCodeStoreNotFoundError(t *testing. shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), actor.TypeAttorney, "abcdef123456"). - Return(actor.ShareCodeData{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id"))}, dynamo.NotFoundError{}) + Return(sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id"))}, dynamo.NotFoundError{}) err := EnterReferenceNumberOptOut(template.Execute, shareCodeStore, nil)(testAppData, w, r) diff --git a/internal/attorney/attorneypage/enter_reference_number_test.go b/internal/attorney/attorneypage/enter_reference_number_test.go index b2ff86c88b..744dd9ed98 100644 --- a/internal/attorney/attorneypage/enter_reference_number_test.go +++ b/internal/attorney/attorneypage/enter_reference_number_test.go @@ -14,6 +14,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" + sharecode "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -71,27 +72,27 @@ func TestGetEnterReferenceNumberOnTemplateError(t *testing.T) { func TestPostEnterReferenceNumber(t *testing.T) { testcases := map[string]struct { - shareCode actor.ShareCodeData + shareCode sharecode.Data session *sesh.LoginSession isReplacement bool isTrustCorporation bool }{ "attorney": { - shareCode: actor.ShareCodeData{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID}, + shareCode: sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID}, session: &sesh.LoginSession{Sub: "hey", Email: "a@example.com"}, }, "replacement": { - shareCode: actor.ShareCodeData{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID, IsReplacementAttorney: true}, + shareCode: sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID, IsReplacementAttorney: true}, session: &sesh.LoginSession{Sub: "hey", Email: "a@example.com"}, isReplacement: true, }, "trust corporation": { - shareCode: actor.ShareCodeData{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID, IsTrustCorporation: true}, + shareCode: sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID, IsTrustCorporation: true}, session: &sesh.LoginSession{Sub: "hey", Email: "a@example.com"}, isTrustCorporation: true, }, "replacement trust corporation": { - shareCode: actor.ShareCodeData{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID, IsReplacementAttorney: true, IsTrustCorporation: true}, + shareCode: sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID, IsReplacementAttorney: true, IsTrustCorporation: true}, session: &sesh.LoginSession{Sub: "hey", Email: "a@example.com"}, isReplacement: true, isTrustCorporation: true, @@ -139,7 +140,7 @@ func TestPostEnterReferenceNumber(t *testing.T) { } func TestPostEnterReferenceNumberWhenConditionalCheckFailed(t *testing.T) { - shareCode := actor.ShareCodeData{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID} + shareCode := sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID} form := url.Values{ "reference-number": {"abcdef123456"}, @@ -185,7 +186,7 @@ func TestPostEnterReferenceNumberOnDonorStoreError(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), actor.TypeAttorney, "abcdef123456"). - Return(actor.ShareCodeData{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, expectedError) + Return(sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, expectedError) err := EnterReferenceNumber(nil, shareCodeStore, nil, nil)(testAppData, w, r) @@ -218,7 +219,7 @@ func TestPostEnterReferenceNumberOnShareCodeStoreNotFoundError(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), actor.TypeAttorney, "abcdef123456"). - Return(actor.ShareCodeData{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, dynamo.NotFoundError{}) + Return(sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, dynamo.NotFoundError{}) err := EnterReferenceNumber(template.Execute, shareCodeStore, nil, nil)(testAppData, w, r) @@ -240,7 +241,7 @@ func TestPostEnterReferenceNumberOnSessionGetError(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), actor.TypeAttorney, "abcdef123456"). - Return(actor.ShareCodeData{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, nil) + Return(sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, nil) sessionStore := newMockSessionStore(t) sessionStore.EXPECT(). @@ -264,7 +265,7 @@ func TestPostEnterReferenceNumberOnAttorneyStoreError(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), actor.TypeAttorney, "abcdef123456"). - Return(actor.ShareCodeData{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, nil) + Return(sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, nil) attorneyStore := newMockAttorneyStore(t) attorneyStore.EXPECT(). diff --git a/internal/attorney/attorneypage/mobile_number.go b/internal/attorney/attorneypage/mobile_number.go index d15ddddf24..448b2a29d7 100644 --- a/internal/attorney/attorneypage/mobile_number.go +++ b/internal/attorney/attorneypage/mobile_number.go @@ -4,10 +4,10 @@ import ( "net/http" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -37,8 +37,8 @@ func MobileNumber(tmpl template.Template, attorneyStore AttorneyStore) Handler { if data.Errors.None() { attorneyProvidedDetails.Mobile = data.Form.Mobile - if attorneyProvidedDetails.Tasks.ConfirmYourDetails == actor.TaskNotStarted { - attorneyProvidedDetails.Tasks.ConfirmYourDetails = actor.TaskInProgress + if attorneyProvidedDetails.Tasks.ConfirmYourDetails == task.StateNotStarted { + attorneyProvidedDetails.Tasks.ConfirmYourDetails = task.StateInProgress } if err := attorneyStore.Put(r.Context(), attorneyProvidedDetails); err != nil { diff --git a/internal/attorney/attorneypage/mobile_number_test.go b/internal/attorney/attorneypage/mobile_number_test.go index 12b3c40999..bbf0b247cc 100644 --- a/internal/attorney/attorneypage/mobile_number_test.go +++ b/internal/attorney/attorneypage/mobile_number_test.go @@ -7,9 +7,9 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -118,7 +118,7 @@ func TestPostMobileNumber(t *testing.T) { LpaID: "lpa-id", Mobile: "07535111222", Tasks: attorneydata.Tasks{ - ConfirmYourDetails: actor.TaskInProgress, + ConfirmYourDetails: task.StateInProgress, }, }, appData: testAppData, @@ -128,13 +128,13 @@ func TestPostMobileNumber(t *testing.T) { attorney: &attorneydata.Provided{ LpaID: "lpa-id", Tasks: attorneydata.Tasks{ - ConfirmYourDetails: actor.TaskCompleted, + ConfirmYourDetails: task.StateCompleted, }, }, updatedAttorney: &attorneydata.Provided{ LpaID: "lpa-id", Tasks: attorneydata.Tasks{ - ConfirmYourDetails: actor.TaskCompleted, + ConfirmYourDetails: task.StateCompleted, }, }, }, @@ -147,7 +147,7 @@ func TestPostMobileNumber(t *testing.T) { LpaID: "lpa-id", Mobile: "07535111222", Tasks: attorneydata.Tasks{ - ConfirmYourDetails: actor.TaskInProgress, + ConfirmYourDetails: task.StateInProgress, }, }, appData: testReplacementAppData, @@ -158,7 +158,7 @@ func TestPostMobileNumber(t *testing.T) { updatedAttorney: &attorneydata.Provided{ LpaID: "lpa-id", Tasks: attorneydata.Tasks{ - ConfirmYourDetails: actor.TaskInProgress, + ConfirmYourDetails: task.StateInProgress, }, }, }, diff --git a/internal/attorney/attorneypage/mock_AttorneyStore_test.go b/internal/attorney/attorneypage/mock_AttorneyStore_test.go index 681effdd41..4e7a4ce383 100644 --- a/internal/attorney/attorneypage/mock_AttorneyStore_test.go +++ b/internal/attorney/attorneypage/mock_AttorneyStore_test.go @@ -26,7 +26,7 @@ func (_m *mockAttorneyStore) EXPECT() *mockAttorneyStore_Expecter { } // Create provides a mock function with given fields: ctx, shareCode, email -func (_m *mockAttorneyStore) Create(ctx context.Context, shareCode sharecode.ShareCodeData, email string) (*attorneydata.Provided, error) { +func (_m *mockAttorneyStore) Create(ctx context.Context, shareCode sharecode.Data, email string) (*attorneydata.Provided, error) { ret := _m.Called(ctx, shareCode, email) if len(ret) == 0 { @@ -35,10 +35,10 @@ func (_m *mockAttorneyStore) Create(ctx context.Context, shareCode sharecode.Sha var r0 *attorneydata.Provided var r1 error - if rf, ok := ret.Get(0).(func(context.Context, sharecode.ShareCodeData, string) (*attorneydata.Provided, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, sharecode.Data, string) (*attorneydata.Provided, error)); ok { return rf(ctx, shareCode, email) } - if rf, ok := ret.Get(0).(func(context.Context, sharecode.ShareCodeData, string) *attorneydata.Provided); ok { + if rf, ok := ret.Get(0).(func(context.Context, sharecode.Data, string) *attorneydata.Provided); ok { r0 = rf(ctx, shareCode, email) } else { if ret.Get(0) != nil { @@ -46,7 +46,7 @@ func (_m *mockAttorneyStore) Create(ctx context.Context, shareCode sharecode.Sha } } - if rf, ok := ret.Get(1).(func(context.Context, sharecode.ShareCodeData, string) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, sharecode.Data, string) error); ok { r1 = rf(ctx, shareCode, email) } else { r1 = ret.Error(1) @@ -62,15 +62,15 @@ type mockAttorneyStore_Create_Call struct { // Create is a helper method to define mock.On call // - ctx context.Context -// - shareCode sharecode.ShareCodeData +// - shareCode sharecode.Data // - email string func (_e *mockAttorneyStore_Expecter) Create(ctx interface{}, shareCode interface{}, email interface{}) *mockAttorneyStore_Create_Call { return &mockAttorneyStore_Create_Call{Call: _e.mock.On("Create", ctx, shareCode, email)} } -func (_c *mockAttorneyStore_Create_Call) Run(run func(ctx context.Context, shareCode sharecode.ShareCodeData, email string)) *mockAttorneyStore_Create_Call { +func (_c *mockAttorneyStore_Create_Call) Run(run func(ctx context.Context, shareCode sharecode.Data, email string)) *mockAttorneyStore_Create_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(sharecode.ShareCodeData), args[2].(string)) + run(args[0].(context.Context), args[1].(sharecode.Data), args[2].(string)) }) return _c } @@ -80,7 +80,7 @@ func (_c *mockAttorneyStore_Create_Call) Return(_a0 *attorneydata.Provided, _a1 return _c } -func (_c *mockAttorneyStore_Create_Call) RunAndReturn(run func(context.Context, sharecode.ShareCodeData, string) (*attorneydata.Provided, error)) *mockAttorneyStore_Create_Call { +func (_c *mockAttorneyStore_Create_Call) RunAndReturn(run func(context.Context, sharecode.Data, string) (*attorneydata.Provided, error)) *mockAttorneyStore_Create_Call { _c.Call.Return(run) return _c } diff --git a/internal/attorney/attorneypage/mock_DonorStore_test.go b/internal/attorney/attorneypage/mock_DonorStore_test.go index ff6bca7e5f..4f851ea54a 100644 --- a/internal/attorney/attorneypage/mock_DonorStore_test.go +++ b/internal/attorney/attorneypage/mock_DonorStore_test.go @@ -23,23 +23,23 @@ func (_m *mockDonorStore) EXPECT() *mockDonorStore_Expecter { } // GetAny provides a mock function with given fields: _a0 -func (_m *mockDonorStore) GetAny(_a0 context.Context) (*donordata.DonorProvidedDetails, error) { +func (_m *mockDonorStore) GetAny(_a0 context.Context) (*donordata.Provided, error) { ret := _m.Called(_a0) if len(ret) == 0 { panic("no return value specified for GetAny") } - var r0 *donordata.DonorProvidedDetails + var r0 *donordata.Provided var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (*donordata.DonorProvidedDetails, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context) (*donordata.Provided, error)); ok { return rf(_a0) } - if rf, ok := ret.Get(0).(func(context.Context) *donordata.DonorProvidedDetails); ok { + if rf, ok := ret.Get(0).(func(context.Context) *donordata.Provided); ok { r0 = rf(_a0) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*donordata.DonorProvidedDetails) + r0 = ret.Get(0).(*donordata.Provided) } } @@ -70,12 +70,12 @@ func (_c *mockDonorStore_GetAny_Call) Run(run func(_a0 context.Context)) *mockDo return _c } -func (_c *mockDonorStore_GetAny_Call) Return(_a0 *donordata.DonorProvidedDetails, _a1 error) *mockDonorStore_GetAny_Call { +func (_c *mockDonorStore_GetAny_Call) Return(_a0 *donordata.Provided, _a1 error) *mockDonorStore_GetAny_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockDonorStore_GetAny_Call) RunAndReturn(run func(context.Context) (*donordata.DonorProvidedDetails, error)) *mockDonorStore_GetAny_Call { +func (_c *mockDonorStore_GetAny_Call) RunAndReturn(run func(context.Context) (*donordata.Provided, error)) *mockDonorStore_GetAny_Call { _c.Call.Return(run) return _c } diff --git a/internal/attorney/attorneypage/mock_ShareCodeStore_test.go b/internal/attorney/attorneypage/mock_ShareCodeStore_test.go index debe9ef662..93f17a10fa 100644 --- a/internal/attorney/attorneypage/mock_ShareCodeStore_test.go +++ b/internal/attorney/attorneypage/mock_ShareCodeStore_test.go @@ -25,7 +25,7 @@ func (_m *mockShareCodeStore) EXPECT() *mockShareCodeStore_Expecter { } // Delete provides a mock function with given fields: ctx, shareCode -func (_m *mockShareCodeStore) Delete(ctx context.Context, shareCode sharecode.ShareCodeData) error { +func (_m *mockShareCodeStore) Delete(ctx context.Context, shareCode sharecode.Data) error { ret := _m.Called(ctx, shareCode) if len(ret) == 0 { @@ -33,7 +33,7 @@ func (_m *mockShareCodeStore) Delete(ctx context.Context, shareCode sharecode.Sh } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, sharecode.ShareCodeData) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, sharecode.Data) error); ok { r0 = rf(ctx, shareCode) } else { r0 = ret.Error(0) @@ -49,14 +49,14 @@ type mockShareCodeStore_Delete_Call struct { // Delete is a helper method to define mock.On call // - ctx context.Context -// - shareCode sharecode.ShareCodeData +// - shareCode sharecode.Data func (_e *mockShareCodeStore_Expecter) Delete(ctx interface{}, shareCode interface{}) *mockShareCodeStore_Delete_Call { return &mockShareCodeStore_Delete_Call{Call: _e.mock.On("Delete", ctx, shareCode)} } -func (_c *mockShareCodeStore_Delete_Call) Run(run func(ctx context.Context, shareCode sharecode.ShareCodeData)) *mockShareCodeStore_Delete_Call { +func (_c *mockShareCodeStore_Delete_Call) Run(run func(ctx context.Context, shareCode sharecode.Data)) *mockShareCodeStore_Delete_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(sharecode.ShareCodeData)) + run(args[0].(context.Context), args[1].(sharecode.Data)) }) return _c } @@ -66,28 +66,28 @@ func (_c *mockShareCodeStore_Delete_Call) Return(_a0 error) *mockShareCodeStore_ return _c } -func (_c *mockShareCodeStore_Delete_Call) RunAndReturn(run func(context.Context, sharecode.ShareCodeData) error) *mockShareCodeStore_Delete_Call { +func (_c *mockShareCodeStore_Delete_Call) RunAndReturn(run func(context.Context, sharecode.Data) error) *mockShareCodeStore_Delete_Call { _c.Call.Return(run) return _c } // Get provides a mock function with given fields: ctx, actorType, shareCode -func (_m *mockShareCodeStore) Get(ctx context.Context, actorType temporary.ActorType, shareCode string) (sharecode.ShareCodeData, error) { +func (_m *mockShareCodeStore) Get(ctx context.Context, actorType temporary.ActorType, shareCode string) (sharecode.Data, error) { ret := _m.Called(ctx, actorType, shareCode) if len(ret) == 0 { panic("no return value specified for Get") } - var r0 sharecode.ShareCodeData + var r0 sharecode.Data var r1 error - if rf, ok := ret.Get(0).(func(context.Context, temporary.ActorType, string) (sharecode.ShareCodeData, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, temporary.ActorType, string) (sharecode.Data, error)); ok { return rf(ctx, actorType, shareCode) } - if rf, ok := ret.Get(0).(func(context.Context, temporary.ActorType, string) sharecode.ShareCodeData); ok { + if rf, ok := ret.Get(0).(func(context.Context, temporary.ActorType, string) sharecode.Data); ok { r0 = rf(ctx, actorType, shareCode) } else { - r0 = ret.Get(0).(sharecode.ShareCodeData) + r0 = ret.Get(0).(sharecode.Data) } if rf, ok := ret.Get(1).(func(context.Context, temporary.ActorType, string) error); ok { @@ -119,18 +119,18 @@ func (_c *mockShareCodeStore_Get_Call) Run(run func(ctx context.Context, actorTy return _c } -func (_c *mockShareCodeStore_Get_Call) Return(_a0 sharecode.ShareCodeData, _a1 error) *mockShareCodeStore_Get_Call { +func (_c *mockShareCodeStore_Get_Call) Return(_a0 sharecode.Data, _a1 error) *mockShareCodeStore_Get_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockShareCodeStore_Get_Call) RunAndReturn(run func(context.Context, temporary.ActorType, string) (sharecode.ShareCodeData, error)) *mockShareCodeStore_Get_Call { +func (_c *mockShareCodeStore_Get_Call) RunAndReturn(run func(context.Context, temporary.ActorType, string) (sharecode.Data, error)) *mockShareCodeStore_Get_Call { _c.Call.Return(run) return _c } // Put provides a mock function with given fields: ctx, actorType, shareCode, data -func (_m *mockShareCodeStore) Put(ctx context.Context, actorType temporary.ActorType, shareCode string, data sharecode.ShareCodeData) error { +func (_m *mockShareCodeStore) Put(ctx context.Context, actorType temporary.ActorType, shareCode string, data sharecode.Data) error { ret := _m.Called(ctx, actorType, shareCode, data) if len(ret) == 0 { @@ -138,7 +138,7 @@ func (_m *mockShareCodeStore) Put(ctx context.Context, actorType temporary.Actor } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, temporary.ActorType, string, sharecode.ShareCodeData) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, temporary.ActorType, string, sharecode.Data) error); ok { r0 = rf(ctx, actorType, shareCode, data) } else { r0 = ret.Error(0) @@ -156,14 +156,14 @@ type mockShareCodeStore_Put_Call struct { // - ctx context.Context // - actorType temporary.ActorType // - shareCode string -// - data sharecode.ShareCodeData +// - data sharecode.Data func (_e *mockShareCodeStore_Expecter) Put(ctx interface{}, actorType interface{}, shareCode interface{}, data interface{}) *mockShareCodeStore_Put_Call { return &mockShareCodeStore_Put_Call{Call: _e.mock.On("Put", ctx, actorType, shareCode, data)} } -func (_c *mockShareCodeStore_Put_Call) Run(run func(ctx context.Context, actorType temporary.ActorType, shareCode string, data sharecode.ShareCodeData)) *mockShareCodeStore_Put_Call { +func (_c *mockShareCodeStore_Put_Call) Run(run func(ctx context.Context, actorType temporary.ActorType, shareCode string, data sharecode.Data)) *mockShareCodeStore_Put_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(temporary.ActorType), args[2].(string), args[3].(sharecode.ShareCodeData)) + run(args[0].(context.Context), args[1].(temporary.ActorType), args[2].(string), args[3].(sharecode.Data)) }) return _c } @@ -173,7 +173,7 @@ func (_c *mockShareCodeStore_Put_Call) Return(_a0 error) *mockShareCodeStore_Put return _c } -func (_c *mockShareCodeStore_Put_Call) RunAndReturn(run func(context.Context, temporary.ActorType, string, sharecode.ShareCodeData) error) *mockShareCodeStore_Put_Call { +func (_c *mockShareCodeStore_Put_Call) RunAndReturn(run func(context.Context, temporary.ActorType, string, sharecode.Data) error) *mockShareCodeStore_Put_Call { _c.Call.Return(run) return _c } diff --git a/internal/attorney/attorneypage/read_the_lpa.go b/internal/attorney/attorneypage/read_the_lpa.go index 3933bd015c..deed0c82f5 100644 --- a/internal/attorney/attorneypage/read_the_lpa.go +++ b/internal/attorney/attorneypage/read_the_lpa.go @@ -4,10 +4,10 @@ import ( "net/http" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -20,7 +20,7 @@ type readTheLpaData struct { func ReadTheLpa(tmpl template.Template, lpaStoreResolvingService LpaStoreResolvingService, attorneyStore AttorneyStore) Handler { return func(appData page.AppData, w http.ResponseWriter, r *http.Request, attorneyProvidedDetails *attorneydata.Provided) error { if r.Method == http.MethodPost { - attorneyProvidedDetails.Tasks.ReadTheLpa = actor.TaskCompleted + attorneyProvidedDetails.Tasks.ReadTheLpa = task.StateCompleted if err := attorneyStore.Put(r.Context(), attorneyProvidedDetails); err != nil { return err diff --git a/internal/attorney/attorneypage/read_the_lpa_test.go b/internal/attorney/attorneypage/read_the_lpa_test.go index 9c2a6517e5..9eb2e96e54 100644 --- a/internal/attorney/attorneypage/read_the_lpa_test.go +++ b/internal/attorney/attorneypage/read_the_lpa_test.go @@ -5,11 +5,11 @@ import ( "net/http/httptest" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" attorneydata "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" ) @@ -114,7 +114,7 @@ func TestPostReadTheLpa(t *testing.T) { Put(r.Context(), &attorneydata.Provided{ LpaID: "lpa-id", Tasks: attorneydata.Tasks{ - ReadTheLpa: actor.TaskCompleted, + ReadTheLpa: task.StateCompleted, }, }). Return(nil) diff --git a/internal/attorney/attorneypage/register.go b/internal/attorney/attorneypage/register.go index 534dc06a81..f8a23bedf3 100644 --- a/internal/attorney/attorneypage/register.go +++ b/internal/attorney/attorneypage/register.go @@ -17,6 +17,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/place" "github.com/ministryofjustice/opg-modernising-lpa/internal/random" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" ) type Localizer interface { @@ -53,13 +54,13 @@ type OneLoginClient interface { } type ShareCodeStore interface { - Get(ctx context.Context, actorType actor.Type, shareCode string) (actor.ShareCodeData, error) - Put(ctx context.Context, actorType actor.Type, shareCode string, data actor.ShareCodeData) error - Delete(ctx context.Context, shareCode actor.ShareCodeData) error + Get(ctx context.Context, actorType actor.Type, shareCode string) (sharecode.Data, error) + Put(ctx context.Context, actorType actor.Type, shareCode string, data sharecode.Data) error + Delete(ctx context.Context, shareCode sharecode.Data) error } type AttorneyStore interface { - Create(ctx context.Context, shareCode actor.ShareCodeData, email string) (*attorneydata.Provided, error) + Create(ctx context.Context, shareCode sharecode.Data, email string) (*attorneydata.Provided, error) Get(ctx context.Context) (*attorneydata.Provided, error) Put(ctx context.Context, attorney *attorneydata.Provided) error Delete(ctx context.Context) error diff --git a/internal/attorney/attorneypage/sign.go b/internal/attorney/attorneypage/sign.go index c5aeb0934a..898f4ace42 100644 --- a/internal/attorney/attorneypage/sign.go +++ b/internal/attorney/attorneypage/sign.go @@ -5,10 +5,10 @@ import ( "time" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -57,7 +57,7 @@ func Sign( data.Errors = data.Form.Validate(appData.IsTrustCorporation(), appData.IsReplacementAttorney()) if data.Errors.None() { - attorneyProvidedDetails.Tasks.SignTheLpa = actor.TaskCompleted + attorneyProvidedDetails.Tasks.SignTheLpa = task.StateCompleted attorneyProvidedDetails.SignedAt = now() if attorney.SignedAt.IsZero() { @@ -112,9 +112,9 @@ func Sign( if data.Errors.None() { if signatoryIndex == 1 { - attorneyProvidedDetails.Tasks.SignTheLpaSecond = actor.TaskCompleted + attorneyProvidedDetails.Tasks.SignTheLpaSecond = task.StateCompleted } else { - attorneyProvidedDetails.Tasks.SignTheLpa = actor.TaskCompleted + attorneyProvidedDetails.Tasks.SignTheLpa = task.StateCompleted } attorneyProvidedDetails.AuthorisedSignatories[signatoryIndex] = attorneydata.TrustCorporationSignatory{ diff --git a/internal/attorney/attorneypage/sign_test.go b/internal/attorney/attorneypage/sign_test.go index 3abde96b58..f3b8c00da7 100644 --- a/internal/attorney/attorneypage/sign_test.go +++ b/internal/attorney/attorneypage/sign_test.go @@ -8,13 +8,13 @@ import ( "testing" "time" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -352,7 +352,7 @@ func TestPostSign(t *testing.T) { updatedAttorney: &attorneydata.Provided{ LpaID: "lpa-id", SignedAt: now, - Tasks: attorneydata.Tasks{SignTheLpa: actor.TaskCompleted}, + Tasks: attorneydata.Tasks{SignTheLpa: task.StateCompleted}, }, }, "replacement attorney": { @@ -366,7 +366,7 @@ func TestPostSign(t *testing.T) { updatedAttorney: &attorneydata.Provided{ LpaID: "lpa-id", SignedAt: now, - Tasks: attorneydata.Tasks{SignTheLpa: actor.TaskCompleted}, + Tasks: attorneydata.Tasks{SignTheLpa: task.StateCompleted}, }, }, "second trust corporation": { @@ -391,7 +391,7 @@ func TestPostSign(t *testing.T) { ProfessionalTitle: "c", SignedAt: now, }}, - Tasks: attorneydata.Tasks{SignTheLpaSecond: actor.TaskCompleted}, + Tasks: attorneydata.Tasks{SignTheLpaSecond: task.StateCompleted}, }, }, "second replacment trust corporation": { @@ -416,7 +416,7 @@ func TestPostSign(t *testing.T) { ProfessionalTitle: "c", SignedAt: now, }}, - Tasks: attorneydata.Tasks{SignTheLpaSecond: actor.TaskCompleted}, + Tasks: attorneydata.Tasks{SignTheLpaSecond: task.StateCompleted}, }, }, } @@ -476,7 +476,7 @@ func TestPostSignWhenSignedInLpaStore(t *testing.T) { updatedAttorney: &attorneydata.Provided{ LpaID: "lpa-id", SignedAt: attorneySignedAt, - Tasks: attorneydata.Tasks{SignTheLpa: actor.TaskCompleted}, + Tasks: attorneydata.Tasks{SignTheLpa: task.StateCompleted}, }, }, "replacement attorney": { @@ -490,7 +490,7 @@ func TestPostSignWhenSignedInLpaStore(t *testing.T) { updatedAttorney: &attorneydata.Provided{ LpaID: "lpa-id", SignedAt: attorneySignedAt, - Tasks: attorneydata.Tasks{SignTheLpa: actor.TaskCompleted}, + Tasks: attorneydata.Tasks{SignTheLpa: task.StateCompleted}, }, }, "second trust corporation": { @@ -515,7 +515,7 @@ func TestPostSignWhenSignedInLpaStore(t *testing.T) { ProfessionalTitle: "c", SignedAt: attorneySignedAt, }}, - Tasks: attorneydata.Tasks{SignTheLpaSecond: actor.TaskCompleted}, + Tasks: attorneydata.Tasks{SignTheLpaSecond: task.StateCompleted}, }, }, "second replacment trust corporation": { @@ -540,7 +540,7 @@ func TestPostSignWhenSignedInLpaStore(t *testing.T) { ProfessionalTitle: "c", SignedAt: attorneySignedAt, }}, - Tasks: attorneydata.Tasks{SignTheLpaSecond: actor.TaskCompleted}, + Tasks: attorneydata.Tasks{SignTheLpaSecond: task.StateCompleted}, }, }, } @@ -604,7 +604,7 @@ func TestPostSignWhenWantSecondSignatory(t *testing.T) { ProfessionalTitle: "c", SignedAt: now, }}, - Tasks: attorneydata.Tasks{SignTheLpa: actor.TaskCompleted}, + Tasks: attorneydata.Tasks{SignTheLpa: task.StateCompleted}, }, }, "replacement trust corporation": { @@ -628,7 +628,7 @@ func TestPostSignWhenWantSecondSignatory(t *testing.T) { ProfessionalTitle: "c", SignedAt: now, }}, - Tasks: attorneydata.Tasks{SignTheLpa: actor.TaskCompleted}, + Tasks: attorneydata.Tasks{SignTheLpa: task.StateCompleted}, }, }, } diff --git a/internal/attorney/attorneypage/task_list.go b/internal/attorney/attorneypage/task_list.go index a910bb4df2..2dec72b6a8 100644 --- a/internal/attorney/attorneypage/task_list.go +++ b/internal/attorney/attorneypage/task_list.go @@ -4,10 +4,10 @@ import ( "net/http" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -21,7 +21,7 @@ type taskListData struct { type taskListItem struct { Name string Path string - State actor.TaskState + State task.State Count int } diff --git a/internal/attorney/attorneypage/task_list_test.go b/internal/attorney/attorneypage/task_list_test.go index 62d520e287..fc06e18891 100644 --- a/internal/attorney/attorneypage/task_list_test.go +++ b/internal/attorney/attorneypage/task_list_test.go @@ -6,11 +6,11 @@ import ( "testing" "time" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -49,15 +49,15 @@ func TestGetTaskList(t *testing.T) { attorney: &attorneydata.Provided{ WouldLikeSecondSignatory: form.Yes, Tasks: attorneydata.Tasks{ - ConfirmYourDetails: actor.TaskCompleted, - ReadTheLpa: actor.TaskCompleted, + ConfirmYourDetails: task.StateCompleted, + ReadTheLpa: task.StateCompleted, }, }, appData: testTrustCorporationAppData, expected: func(items []taskListItem) []taskListItem { - items[0].State = actor.TaskCompleted + items[0].State = task.StateCompleted items[0].Path = page.Paths.Attorney.MobileNumber.Format("lpa-id") - items[1].State = actor.TaskCompleted + items[1].State = task.StateCompleted items[2].Name = "signTheLpaSignatory1" items[2].Path = page.Paths.Attorney.RightsAndResponsibilities.Format("lpa-id") @@ -74,14 +74,14 @@ func TestGetTaskList(t *testing.T) { }, attorney: &attorneydata.Provided{ Tasks: attorneydata.Tasks{ - ConfirmYourDetails: actor.TaskCompleted, - ReadTheLpa: actor.TaskCompleted, + ConfirmYourDetails: task.StateCompleted, + ReadTheLpa: task.StateCompleted, }, }, appData: testAppData, expected: func(items []taskListItem) []taskListItem { - items[0].State = actor.TaskCompleted - items[1].State = actor.TaskCompleted + items[0].State = task.StateCompleted + items[1].State = task.StateCompleted return items }, @@ -94,14 +94,14 @@ func TestGetTaskList(t *testing.T) { }, attorney: &attorneydata.Provided{ Tasks: attorneydata.Tasks{ - ConfirmYourDetails: actor.TaskCompleted, - ReadTheLpa: actor.TaskCompleted, + ConfirmYourDetails: task.StateCompleted, + ReadTheLpa: task.StateCompleted, }, }, appData: testAppData, expected: func(items []taskListItem) []taskListItem { - items[0].State = actor.TaskCompleted - items[1].State = actor.TaskCompleted + items[0].State = task.StateCompleted + items[1].State = task.StateCompleted items[2].Path = page.Paths.Attorney.RightsAndResponsibilities.Format("lpa-id") return items @@ -115,16 +115,16 @@ func TestGetTaskList(t *testing.T) { }, attorney: &attorneydata.Provided{ Tasks: attorneydata.Tasks{ - ConfirmYourDetails: actor.TaskCompleted, - ReadTheLpa: actor.TaskCompleted, - SignTheLpa: actor.TaskCompleted, + ConfirmYourDetails: task.StateCompleted, + ReadTheLpa: task.StateCompleted, + SignTheLpa: task.StateCompleted, }, }, appData: testAppData, expected: func(items []taskListItem) []taskListItem { - items[0].State = actor.TaskCompleted - items[1].State = actor.TaskCompleted - items[2].State = actor.TaskCompleted + items[0].State = task.StateCompleted + items[1].State = task.StateCompleted + items[2].State = task.StateCompleted items[2].Path = page.Paths.Attorney.RightsAndResponsibilities.Format("lpa-id") return items @@ -138,16 +138,16 @@ func TestGetTaskList(t *testing.T) { }, attorney: &attorneydata.Provided{ Tasks: attorneydata.Tasks{ - ConfirmYourDetails: actor.TaskCompleted, - ReadTheLpa: actor.TaskCompleted, - SignTheLpa: actor.TaskCompleted, + ConfirmYourDetails: task.StateCompleted, + ReadTheLpa: task.StateCompleted, + SignTheLpa: task.StateCompleted, }, }, appData: testReplacementAppData, expected: func(items []taskListItem) []taskListItem { - items[0].State = actor.TaskCompleted - items[1].State = actor.TaskCompleted - items[2].State = actor.TaskCompleted + items[0].State = task.StateCompleted + items[1].State = task.StateCompleted + items[2].State = task.StateCompleted items[2].Path = page.Paths.Attorney.RightsAndResponsibilities.Format("lpa-id") return items diff --git a/internal/certificateprovider/certificateproviderdata/store.go b/internal/certificateprovider/certificateproviderdata/store.go index 02e3193663..0b354ea1e1 100644 --- a/internal/certificateprovider/certificateproviderdata/store.go +++ b/internal/certificateprovider/certificateproviderdata/store.go @@ -10,6 +10,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" "github.com/ministryofjustice/opg-modernising-lpa/internal/temporary" ) @@ -42,7 +43,7 @@ type Store struct { now func() time.Time } -func (s *Store) Create(ctx context.Context, shareCode actor.ShareCodeData, email string) (*Provided, error) { +func (s *Store) Create(ctx context.Context, shareCode sharecode.Data, email string) (*Provided, error) { data, err := appcontext.SessionDataFromContext(ctx) if err != nil { return nil, err diff --git a/internal/certificateprovider/certificateproviderdata/store_test.go b/internal/certificateprovider/certificateproviderdata/store_test.go index 02999bc62d..10ca4771be 100644 --- a/internal/certificateprovider/certificateproviderdata/store_test.go +++ b/internal/certificateprovider/certificateproviderdata/store_test.go @@ -20,7 +20,7 @@ func TestCertificateProviderStoreCreate(t *testing.T) { uid := actoruid.New() details := &Provided{PK: dynamo.LpaKey("lpa-id"), SK: dynamo.CertificateProviderKey("session-id"), LpaID: "lpa-id", UpdatedAt: testNow, UID: uid, Email: "a@b.com"} - shareCode := sharecode.ShareCodeData{ + shareCode := sharecode.Data{ PK: dynamo.ShareKey(dynamo.CertificateProviderShareKey("share-key")), SK: dynamo.ShareSortKey(dynamo.MetadataKey("share-key")), ActorUID: uid, @@ -57,7 +57,7 @@ func TestCertificateProviderStoreCreate(t *testing.T) { func TestCertificateProviderStoreCreateWhenSessionMissing(t *testing.T) { certificateProviderStore := &Store{dynamoClient: nil, now: nil} - _, err := certificateProviderStore.Create(ctx, sharecode.ShareCodeData{}, "") + _, err := certificateProviderStore.Create(ctx, sharecode.Data{}, "") assert.Equal(t, appcontext.SessionMissingError{}, err) } @@ -73,7 +73,7 @@ func TestCertificateProviderStoreCreateWhenSessionDataMissing(t *testing.T) { certificateProviderStore := &Store{} - _, err := certificateProviderStore.Create(ctx, sharecode.ShareCodeData{}, "") + _, err := certificateProviderStore.Create(ctx, sharecode.Data{}, "") assert.NotNil(t, err) }) } @@ -89,7 +89,7 @@ func TestCertificateProviderStoreCreateWhenWriteTransactionError(t *testing.T) { certificateProviderStore := &Store{dynamoClient: dynamoClient, now: testNowFn} - _, err := certificateProviderStore.Create(ctx, sharecode.ShareCodeData{ + _, err := certificateProviderStore.Create(ctx, sharecode.Data{ PK: dynamo.ShareKey(dynamo.CertificateProviderShareKey("123")), SK: dynamo.ShareSortKey(dynamo.MetadataKey("123")), }, "") diff --git a/internal/certificateprovider/certificateproviderpage/confirm_dont_want_to_be_certificate_provider.go b/internal/certificateprovider/certificateproviderpage/confirm_dont_want_to_be_certificate_provider.go index efc3e40d09..5c2b7b82ab 100644 --- a/internal/certificateprovider/certificateproviderpage/confirm_dont_want_to_be_certificate_provider.go +++ b/internal/certificateprovider/certificateproviderpage/confirm_dont_want_to_be_certificate_provider.go @@ -5,12 +5,12 @@ import ( "net/url" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -65,8 +65,8 @@ func ConfirmDontWantToBeCertificateProvider(tmpl template.Template, lpaStoreReso } donor.CertificateProvider = donordata.CertificateProvider{} - donor.Tasks.CertificateProvider = actor.TaskNotStarted - donor.Tasks.CheckYourLpa = actor.TaskNotStarted + donor.Tasks.CertificateProvider = task.StateNotStarted + donor.Tasks.CheckYourLpa = task.StateNotStarted if err = donorStore.Put(r.Context(), donor); err != nil { return err diff --git a/internal/certificateprovider/certificateproviderpage/confirm_dont_want_to_be_certificate_provider_logged_out.go b/internal/certificateprovider/certificateproviderpage/confirm_dont_want_to_be_certificate_provider_logged_out.go index 659cbed121..5fb580d751 100644 --- a/internal/certificateprovider/certificateproviderpage/confirm_dont_want_to_be_certificate_provider_logged_out.go +++ b/internal/certificateprovider/certificateproviderpage/confirm_dont_want_to_be_certificate_provider_logged_out.go @@ -12,6 +12,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -78,8 +79,8 @@ func ConfirmDontWantToBeCertificateProviderLoggedOut(tmpl template.Template, sha } donor.CertificateProvider = donordata.CertificateProvider{} - donor.Tasks.CertificateProvider = actor.TaskNotStarted - donor.Tasks.CheckYourLpa = actor.TaskNotStarted + donor.Tasks.CertificateProvider = task.StateNotStarted + donor.Tasks.CheckYourLpa = task.StateNotStarted if err = donorStore.Put(ctx, donor); err != nil { return err diff --git a/internal/certificateprovider/certificateproviderpage/confirm_dont_want_to_be_certificate_provider_logged_out_test.go b/internal/certificateprovider/certificateproviderpage/confirm_dont_want_to_be_certificate_provider_logged_out_test.go index eddc1fccbd..808fd1a4e1 100644 --- a/internal/certificateprovider/certificateproviderpage/confirm_dont_want_to_be_certificate_provider_logged_out_test.go +++ b/internal/certificateprovider/certificateproviderpage/confirm_dont_want_to_be_certificate_provider_logged_out_test.go @@ -15,6 +15,8 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" + sharecode "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -204,14 +206,14 @@ func TestPostConfirmDontWantToBeCertificateProviderLoggedOut(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). GetAny(ctx). - Return(&donordata.DonorProvidedDetails{ + Return(&donordata.Provided{ LpaUID: "lpa-uid", Donor: donordata.Donor{ FirstNames: "a b", LastName: "c", }, - Tasks: donordata.DonorTasks{ - CertificateProvider: actor.TaskCompleted, - CheckYourLpa: actor.TaskCompleted, + Tasks: donordata.Tasks{ + CertificateProvider: task.StateCompleted, + CheckYourLpa: task.StateCompleted, }, CertificateProvider: donordata.CertificateProvider{ UID: actoruid.New(), @@ -220,14 +222,14 @@ func TestPostConfirmDontWantToBeCertificateProviderLoggedOut(t *testing.T) { Type: donordata.LpaTypePersonalWelfare, }, nil) donorStore.EXPECT(). - Put(ctx, &donordata.DonorProvidedDetails{ + Put(ctx, &donordata.Provided{ LpaUID: "lpa-uid", Donor: donordata.Donor{ FirstNames: "a b", LastName: "c", }, - Tasks: donordata.DonorTasks{ - CertificateProvider: actor.TaskNotStarted, - CheckYourLpa: actor.TaskNotStarted, + Tasks: donordata.Tasks{ + CertificateProvider: task.StateNotStarted, + CheckYourLpa: task.StateNotStarted, }, CertificateProvider: donordata.CertificateProvider{}, Type: donordata.LpaTypePersonalWelfare, @@ -253,7 +255,7 @@ func TestPostConfirmDontWantToBeCertificateProviderLoggedOut(t *testing.T) { LpaData(r). Return(&sesh.LpaDataSession{LpaID: "lpa-id"}, nil) - shareCodeData := actor.ShareCodeData{ + shareCodeData := sharecode.Data{ LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), } @@ -298,7 +300,7 @@ func TestPostConfirmDontWantToBeCertificateProviderLoggedOutErrors(t *testing.T) r, _ := http.NewRequest(http.MethodPost, "/?referenceNumber=123", nil) ctx := page.ContextWithSessionData(r.Context(), &appcontext.SessionData{LpaID: "lpa-id"}) - shareCodeData := actor.ShareCodeData{ + shareCodeData := sharecode.Data{ LpaKey: dynamo.LpaKey("lpa-id"), } @@ -385,7 +387,7 @@ func TestPostConfirmDontWantToBeCertificateProviderLoggedOutErrors(t *testing.T) donorStore := newMockDonorStore(t) donorStore.EXPECT(). GetAny(ctx). - Return(&donordata.DonorProvidedDetails{}, expectedError) + Return(&donordata.Provided{}, expectedError) return donorStore }, @@ -422,7 +424,7 @@ func TestPostConfirmDontWantToBeCertificateProviderLoggedOutErrors(t *testing.T) donorStore := newMockDonorStore(t) donorStore.EXPECT(). GetAny(ctx). - Return(&donordata.DonorProvidedDetails{}, nil) + Return(&donordata.Provided{}, nil) donorStore.EXPECT(). Put(ctx, mock.Anything). Return(expectedError) diff --git a/internal/certificateprovider/certificateproviderpage/confirm_dont_want_to_be_certificate_provider_test.go b/internal/certificateprovider/certificateproviderpage/confirm_dont_want_to_be_certificate_provider_test.go index 5fc30685b7..69dbb48150 100644 --- a/internal/certificateprovider/certificateproviderpage/confirm_dont_want_to_be_certificate_provider_test.go +++ b/internal/certificateprovider/certificateproviderpage/confirm_dont_want_to_be_certificate_provider_test.go @@ -7,7 +7,6 @@ import ( "testing" "time" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" @@ -15,6 +14,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -170,14 +170,14 @@ func TestPostConfirmDontWantToBeCertificateProvider(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). GetAny(r.Context()). - Return(&donordata.DonorProvidedDetails{ + Return(&donordata.Provided{ LpaUID: "lpa-uid", Donor: donordata.Donor{ FirstNames: "a b", LastName: "c", }, - Tasks: donordata.DonorTasks{ - CertificateProvider: actor.TaskCompleted, - CheckYourLpa: actor.TaskCompleted, + Tasks: donordata.Tasks{ + CertificateProvider: task.StateCompleted, + CheckYourLpa: task.StateCompleted, }, CertificateProvider: donordata.CertificateProvider{ UID: uid, @@ -186,14 +186,14 @@ func TestPostConfirmDontWantToBeCertificateProvider(t *testing.T) { Type: donordata.LpaTypePersonalWelfare, }, nil) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaUID: "lpa-uid", Donor: donordata.Donor{ FirstNames: "a b", LastName: "c", }, - Tasks: donordata.DonorTasks{ - CertificateProvider: actor.TaskNotStarted, - CheckYourLpa: actor.TaskNotStarted, + Tasks: donordata.Tasks{ + CertificateProvider: task.StateNotStarted, + CheckYourLpa: task.StateNotStarted, }, CertificateProvider: donordata.CertificateProvider{}, Type: donordata.LpaTypePersonalWelfare, @@ -319,7 +319,7 @@ func TestPostConfirmDontWantToBeCertificateProviderErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). GetAny(r.Context()). - Return(&donordata.DonorProvidedDetails{}, expectedError) + Return(&donordata.Provided{}, expectedError) return donorStore }, @@ -349,7 +349,7 @@ func TestPostConfirmDontWantToBeCertificateProviderErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). GetAny(r.Context()). - Return(&donordata.DonorProvidedDetails{}, nil) + Return(&donordata.Provided{}, nil) donorStore.EXPECT(). Put(r.Context(), mock.Anything). Return(expectedError) diff --git a/internal/certificateprovider/certificateproviderpage/confirm_your_details.go b/internal/certificateprovider/certificateproviderpage/confirm_your_details.go index 4d1c9a3cbd..43c96e0544 100644 --- a/internal/certificateprovider/certificateproviderpage/confirm_your_details.go +++ b/internal/certificateprovider/certificateproviderpage/confirm_your_details.go @@ -4,10 +4,10 @@ import ( "net/http" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -29,7 +29,7 @@ func ConfirmYourDetails(tmpl template.Template, lpaStoreResolvingService LpaStor } if r.Method == http.MethodPost { - certificateProvider.Tasks.ConfirmYourDetails = actor.TaskCompleted + certificateProvider.Tasks.ConfirmYourDetails = task.StateCompleted if err := certificateProviderStore.Put(r.Context(), certificateProvider); err != nil { return err diff --git a/internal/certificateprovider/certificateproviderpage/confirm_your_details_test.go b/internal/certificateprovider/certificateproviderpage/confirm_your_details_test.go index df7aa0b976..d12c803bfb 100644 --- a/internal/certificateprovider/certificateproviderpage/confirm_your_details_test.go +++ b/internal/certificateprovider/certificateproviderpage/confirm_your_details_test.go @@ -6,11 +6,11 @@ import ( "testing" "time" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -143,7 +143,7 @@ func TestPostConfirmYourDetails(t *testing.T) { Put(r.Context(), &certificateproviderdata.Provided{ LpaID: "lpa-id", Tasks: certificateproviderdata.Tasks{ - ConfirmYourDetails: actor.TaskCompleted, + ConfirmYourDetails: task.StateCompleted, }, }). Return(nil) diff --git a/internal/certificateprovider/certificateproviderpage/enter_date_of_birth.go b/internal/certificateprovider/certificateproviderpage/enter_date_of_birth.go index 82d99eccc9..716b5ec5ad 100644 --- a/internal/certificateprovider/certificateproviderpage/enter_date_of_birth.go +++ b/internal/certificateprovider/certificateproviderpage/enter_date_of_birth.go @@ -4,11 +4,11 @@ import ( "net/http" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/date" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -52,7 +52,7 @@ func EnterDateOfBirth(tmpl template.Template, lpaStoreResolvingService LpaStoreR if data.Errors.None() && data.DobWarning == "" { certificateProvider.DateOfBirth = data.Form.Dob if !certificateProvider.Tasks.ConfirmYourDetails.Completed() { - certificateProvider.Tasks.ConfirmYourDetails = actor.TaskInProgress + certificateProvider.Tasks.ConfirmYourDetails = task.StateInProgress } if err := certificateProviderStore.Put(r.Context(), certificateProvider); err != nil { diff --git a/internal/certificateprovider/certificateproviderpage/enter_date_of_birth_test.go b/internal/certificateprovider/certificateproviderpage/enter_date_of_birth_test.go index 071062f627..97b93ac303 100644 --- a/internal/certificateprovider/certificateproviderpage/enter_date_of_birth_test.go +++ b/internal/certificateprovider/certificateproviderpage/enter_date_of_birth_test.go @@ -9,12 +9,12 @@ import ( "testing" "time" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/date" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -140,7 +140,7 @@ func TestPostEnterDateOfBirth(t *testing.T) { LpaID: "lpa-id", DateOfBirth: date.New(validBirthYear, "1", "2"), Tasks: certificateproviderdata.Tasks{ - ConfirmYourDetails: actor.TaskInProgress, + ConfirmYourDetails: task.StateInProgress, }, }, }, @@ -153,14 +153,14 @@ func TestPostEnterDateOfBirth(t *testing.T) { retrieved: &certificateproviderdata.Provided{ LpaID: "lpa-id", Tasks: certificateproviderdata.Tasks{ - ConfirmYourDetails: actor.TaskCompleted, + ConfirmYourDetails: task.StateCompleted, }, }, updated: &certificateproviderdata.Provided{ LpaID: "lpa-id", DateOfBirth: date.New(validBirthYear, "1", "2"), Tasks: certificateproviderdata.Tasks{ - ConfirmYourDetails: actor.TaskCompleted, + ConfirmYourDetails: task.StateCompleted, }, }, }, @@ -176,7 +176,7 @@ func TestPostEnterDateOfBirth(t *testing.T) { LpaID: "lpa-id", DateOfBirth: date.New("1900", "1", "2"), Tasks: certificateproviderdata.Tasks{ - ConfirmYourDetails: actor.TaskInProgress, + ConfirmYourDetails: task.StateInProgress, }, }, }, @@ -232,7 +232,7 @@ func TestPostEnterDateOfBirthWhenProfessionalCertificateProvider(t *testing.T) { LpaID: "lpa-id", DateOfBirth: date.New("1980", "1", "2"), Tasks: certificateproviderdata.Tasks{ - ConfirmYourDetails: actor.TaskInProgress, + ConfirmYourDetails: task.StateInProgress, }, }). Return(nil) diff --git a/internal/certificateprovider/certificateproviderpage/enter_reference_number_opt_out_test.go b/internal/certificateprovider/certificateproviderpage/enter_reference_number_opt_out_test.go index 9fa1d2fd1e..16fedad22b 100644 --- a/internal/certificateprovider/certificateproviderpage/enter_reference_number_opt_out_test.go +++ b/internal/certificateprovider/certificateproviderpage/enter_reference_number_opt_out_test.go @@ -12,6 +12,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" + sharecode "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -74,7 +75,7 @@ func TestPostEnterReferenceNumberOptOut(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), actor.TypeCertificateProvider, "abcdef123456"). - Return(actor.ShareCodeData{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id")), ActorUID: uid}, nil) + Return(sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id")), ActorUID: uid}, nil) sessionStore := newMockSessionStore(t) sessionStore.EXPECT(). @@ -107,7 +108,7 @@ func TestPostEnterReferenceNumberOptOutErrors(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(mock.Anything, mock.Anything, mock.Anything). - Return(actor.ShareCodeData{}, expectedError) + Return(sharecode.Data{}, expectedError) return shareCodeStore }, @@ -118,7 +119,7 @@ func TestPostEnterReferenceNumberOptOutErrors(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(mock.Anything, mock.Anything, mock.Anything). - Return(actor.ShareCodeData{LpaKey: dynamo.LpaKey("lpa-id")}, nil) + Return(sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id")}, nil) return shareCodeStore }, @@ -168,7 +169,7 @@ func TestPostEnterReferenceNumberOptOutOnShareCodeStoreNotFoundError(t *testing. shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), actor.TypeCertificateProvider, "abcdef123456"). - Return(actor.ShareCodeData{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id"))}, dynamo.NotFoundError{}) + Return(sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id"))}, dynamo.NotFoundError{}) err := EnterReferenceNumberOptOut(template.Execute, shareCodeStore, nil)(testAppData, w, r) diff --git a/internal/certificateprovider/certificateproviderpage/enter_reference_number_test.go b/internal/certificateprovider/certificateproviderpage/enter_reference_number_test.go index 6a79f8893c..75ec22de2b 100644 --- a/internal/certificateprovider/certificateproviderpage/enter_reference_number_test.go +++ b/internal/certificateprovider/certificateproviderpage/enter_reference_number_test.go @@ -15,6 +15,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" + sharecode "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -74,7 +75,7 @@ func TestPostEnterReferenceNumber(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - shareCodeData := actor.ShareCodeData{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id")), ActorUID: uid} + shareCodeData := sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id")), ActorUID: uid} shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), actor.TypeCertificateProvider, "abcdef123456"). @@ -113,7 +114,7 @@ func TestPostEnterReferenceNumberWhenConditionalCheckFailed(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - shareCodeData := actor.ShareCodeData{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id")), ActorUID: uid} + shareCodeData := sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id")), ActorUID: uid} shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), mock.Anything, mock.Anything). @@ -150,7 +151,7 @@ func TestPostEnterReferenceNumberOnShareCodeStoreError(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), actor.TypeCertificateProvider, "abcdef123456"). - Return(actor.ShareCodeData{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id"))}, expectedError) + Return(sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id"))}, expectedError) err := EnterReferenceNumber(nil, shareCodeStore, nil, nil)(testAppData, w, r) @@ -183,7 +184,7 @@ func TestPostEnterReferenceNumberOnShareCodeStoreNotFoundError(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), actor.TypeCertificateProvider, "abcdef123456"). - Return(actor.ShareCodeData{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id"))}, dynamo.NotFoundError{}) + Return(sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id"))}, dynamo.NotFoundError{}) err := EnterReferenceNumber(template.Execute, shareCodeStore, nil, nil)(testAppData, w, r) @@ -206,7 +207,7 @@ func TestPostEnterReferenceNumberWhenCreateError(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), actor.TypeCertificateProvider, "abcdef123456"). - Return(actor.ShareCodeData{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id")), ActorUID: uid}, nil) + Return(sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("session-id")), ActorUID: uid}, nil) sessionStore := newMockSessionStore(t) sessionStore.EXPECT(). diff --git a/internal/certificateprovider/certificateproviderpage/mock_CertificateProviderStore_test.go b/internal/certificateprovider/certificateproviderpage/mock_CertificateProviderStore_test.go index 54d1d78426..e980158d02 100644 --- a/internal/certificateprovider/certificateproviderpage/mock_CertificateProviderStore_test.go +++ b/internal/certificateprovider/certificateproviderpage/mock_CertificateProviderStore_test.go @@ -26,7 +26,7 @@ func (_m *mockCertificateProviderStore) EXPECT() *mockCertificateProviderStore_E } // Create provides a mock function with given fields: ctx, shareCode, email -func (_m *mockCertificateProviderStore) Create(ctx context.Context, shareCode sharecode.ShareCodeData, email string) (*certificateproviderdata.Provided, error) { +func (_m *mockCertificateProviderStore) Create(ctx context.Context, shareCode sharecode.Data, email string) (*certificateproviderdata.Provided, error) { ret := _m.Called(ctx, shareCode, email) if len(ret) == 0 { @@ -35,10 +35,10 @@ func (_m *mockCertificateProviderStore) Create(ctx context.Context, shareCode sh var r0 *certificateproviderdata.Provided var r1 error - if rf, ok := ret.Get(0).(func(context.Context, sharecode.ShareCodeData, string) (*certificateproviderdata.Provided, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, sharecode.Data, string) (*certificateproviderdata.Provided, error)); ok { return rf(ctx, shareCode, email) } - if rf, ok := ret.Get(0).(func(context.Context, sharecode.ShareCodeData, string) *certificateproviderdata.Provided); ok { + if rf, ok := ret.Get(0).(func(context.Context, sharecode.Data, string) *certificateproviderdata.Provided); ok { r0 = rf(ctx, shareCode, email) } else { if ret.Get(0) != nil { @@ -46,7 +46,7 @@ func (_m *mockCertificateProviderStore) Create(ctx context.Context, shareCode sh } } - if rf, ok := ret.Get(1).(func(context.Context, sharecode.ShareCodeData, string) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, sharecode.Data, string) error); ok { r1 = rf(ctx, shareCode, email) } else { r1 = ret.Error(1) @@ -62,15 +62,15 @@ type mockCertificateProviderStore_Create_Call struct { // Create is a helper method to define mock.On call // - ctx context.Context -// - shareCode sharecode.ShareCodeData +// - shareCode sharecode.Data // - email string func (_e *mockCertificateProviderStore_Expecter) Create(ctx interface{}, shareCode interface{}, email interface{}) *mockCertificateProviderStore_Create_Call { return &mockCertificateProviderStore_Create_Call{Call: _e.mock.On("Create", ctx, shareCode, email)} } -func (_c *mockCertificateProviderStore_Create_Call) Run(run func(ctx context.Context, shareCode sharecode.ShareCodeData, email string)) *mockCertificateProviderStore_Create_Call { +func (_c *mockCertificateProviderStore_Create_Call) Run(run func(ctx context.Context, shareCode sharecode.Data, email string)) *mockCertificateProviderStore_Create_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(sharecode.ShareCodeData), args[2].(string)) + run(args[0].(context.Context), args[1].(sharecode.Data), args[2].(string)) }) return _c } @@ -80,7 +80,7 @@ func (_c *mockCertificateProviderStore_Create_Call) Return(_a0 *certificateprovi return _c } -func (_c *mockCertificateProviderStore_Create_Call) RunAndReturn(run func(context.Context, sharecode.ShareCodeData, string) (*certificateproviderdata.Provided, error)) *mockCertificateProviderStore_Create_Call { +func (_c *mockCertificateProviderStore_Create_Call) RunAndReturn(run func(context.Context, sharecode.Data, string) (*certificateproviderdata.Provided, error)) *mockCertificateProviderStore_Create_Call { _c.Call.Return(run) return _c } diff --git a/internal/certificateprovider/certificateproviderpage/mock_DonorStore_test.go b/internal/certificateprovider/certificateproviderpage/mock_DonorStore_test.go index a85b6e6ea7..3950a93c78 100644 --- a/internal/certificateprovider/certificateproviderpage/mock_DonorStore_test.go +++ b/internal/certificateprovider/certificateproviderpage/mock_DonorStore_test.go @@ -23,23 +23,23 @@ func (_m *mockDonorStore) EXPECT() *mockDonorStore_Expecter { } // GetAny provides a mock function with given fields: ctx -func (_m *mockDonorStore) GetAny(ctx context.Context) (*donordata.DonorProvidedDetails, error) { +func (_m *mockDonorStore) GetAny(ctx context.Context) (*donordata.Provided, error) { ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for GetAny") } - var r0 *donordata.DonorProvidedDetails + var r0 *donordata.Provided var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (*donordata.DonorProvidedDetails, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context) (*donordata.Provided, error)); ok { return rf(ctx) } - if rf, ok := ret.Get(0).(func(context.Context) *donordata.DonorProvidedDetails); ok { + if rf, ok := ret.Get(0).(func(context.Context) *donordata.Provided); ok { r0 = rf(ctx) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*donordata.DonorProvidedDetails) + r0 = ret.Get(0).(*donordata.Provided) } } @@ -70,18 +70,18 @@ func (_c *mockDonorStore_GetAny_Call) Run(run func(ctx context.Context)) *mockDo return _c } -func (_c *mockDonorStore_GetAny_Call) Return(_a0 *donordata.DonorProvidedDetails, _a1 error) *mockDonorStore_GetAny_Call { +func (_c *mockDonorStore_GetAny_Call) Return(_a0 *donordata.Provided, _a1 error) *mockDonorStore_GetAny_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockDonorStore_GetAny_Call) RunAndReturn(run func(context.Context) (*donordata.DonorProvidedDetails, error)) *mockDonorStore_GetAny_Call { +func (_c *mockDonorStore_GetAny_Call) RunAndReturn(run func(context.Context) (*donordata.Provided, error)) *mockDonorStore_GetAny_Call { _c.Call.Return(run) return _c } // Put provides a mock function with given fields: ctx, donor -func (_m *mockDonorStore) Put(ctx context.Context, donor *donordata.DonorProvidedDetails) error { +func (_m *mockDonorStore) Put(ctx context.Context, donor *donordata.Provided) error { ret := _m.Called(ctx, donor) if len(ret) == 0 { @@ -89,7 +89,7 @@ func (_m *mockDonorStore) Put(ctx context.Context, donor *donordata.DonorProvide } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *donordata.DonorProvidedDetails) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, *donordata.Provided) error); ok { r0 = rf(ctx, donor) } else { r0 = ret.Error(0) @@ -110,9 +110,9 @@ func (_e *mockDonorStore_Expecter) Put(ctx interface{}, donor interface{}) *mock return &mockDonorStore_Put_Call{Call: _e.mock.On("Put", ctx, donor)} } -func (_c *mockDonorStore_Put_Call) Run(run func(ctx context.Context, donor *donordata.DonorProvidedDetails)) *mockDonorStore_Put_Call { +func (_c *mockDonorStore_Put_Call) Run(run func(ctx context.Context, donor *donordata.Provided)) *mockDonorStore_Put_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*donordata.DonorProvidedDetails)) + run(args[0].(context.Context), args[1].(*donordata.Provided)) }) return _c } @@ -122,7 +122,7 @@ func (_c *mockDonorStore_Put_Call) Return(_a0 error) *mockDonorStore_Put_Call { return _c } -func (_c *mockDonorStore_Put_Call) RunAndReturn(run func(context.Context, *donordata.DonorProvidedDetails) error) *mockDonorStore_Put_Call { +func (_c *mockDonorStore_Put_Call) RunAndReturn(run func(context.Context, *donordata.Provided) error) *mockDonorStore_Put_Call { _c.Call.Return(run) return _c } diff --git a/internal/certificateprovider/certificateproviderpage/mock_ShareCodeStore_test.go b/internal/certificateprovider/certificateproviderpage/mock_ShareCodeStore_test.go index c45ca68521..1c2adf2c49 100644 --- a/internal/certificateprovider/certificateproviderpage/mock_ShareCodeStore_test.go +++ b/internal/certificateprovider/certificateproviderpage/mock_ShareCodeStore_test.go @@ -25,7 +25,7 @@ func (_m *mockShareCodeStore) EXPECT() *mockShareCodeStore_Expecter { } // Delete provides a mock function with given fields: ctx, shareCode -func (_m *mockShareCodeStore) Delete(ctx context.Context, shareCode sharecode.ShareCodeData) error { +func (_m *mockShareCodeStore) Delete(ctx context.Context, shareCode sharecode.Data) error { ret := _m.Called(ctx, shareCode) if len(ret) == 0 { @@ -33,7 +33,7 @@ func (_m *mockShareCodeStore) Delete(ctx context.Context, shareCode sharecode.Sh } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, sharecode.ShareCodeData) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, sharecode.Data) error); ok { r0 = rf(ctx, shareCode) } else { r0 = ret.Error(0) @@ -49,14 +49,14 @@ type mockShareCodeStore_Delete_Call struct { // Delete is a helper method to define mock.On call // - ctx context.Context -// - shareCode sharecode.ShareCodeData +// - shareCode sharecode.Data func (_e *mockShareCodeStore_Expecter) Delete(ctx interface{}, shareCode interface{}) *mockShareCodeStore_Delete_Call { return &mockShareCodeStore_Delete_Call{Call: _e.mock.On("Delete", ctx, shareCode)} } -func (_c *mockShareCodeStore_Delete_Call) Run(run func(ctx context.Context, shareCode sharecode.ShareCodeData)) *mockShareCodeStore_Delete_Call { +func (_c *mockShareCodeStore_Delete_Call) Run(run func(ctx context.Context, shareCode sharecode.Data)) *mockShareCodeStore_Delete_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(sharecode.ShareCodeData)) + run(args[0].(context.Context), args[1].(sharecode.Data)) }) return _c } @@ -66,28 +66,28 @@ func (_c *mockShareCodeStore_Delete_Call) Return(_a0 error) *mockShareCodeStore_ return _c } -func (_c *mockShareCodeStore_Delete_Call) RunAndReturn(run func(context.Context, sharecode.ShareCodeData) error) *mockShareCodeStore_Delete_Call { +func (_c *mockShareCodeStore_Delete_Call) RunAndReturn(run func(context.Context, sharecode.Data) error) *mockShareCodeStore_Delete_Call { _c.Call.Return(run) return _c } // Get provides a mock function with given fields: ctx, actorType, shareCode -func (_m *mockShareCodeStore) Get(ctx context.Context, actorType temporary.ActorType, shareCode string) (sharecode.ShareCodeData, error) { +func (_m *mockShareCodeStore) Get(ctx context.Context, actorType temporary.ActorType, shareCode string) (sharecode.Data, error) { ret := _m.Called(ctx, actorType, shareCode) if len(ret) == 0 { panic("no return value specified for Get") } - var r0 sharecode.ShareCodeData + var r0 sharecode.Data var r1 error - if rf, ok := ret.Get(0).(func(context.Context, temporary.ActorType, string) (sharecode.ShareCodeData, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, temporary.ActorType, string) (sharecode.Data, error)); ok { return rf(ctx, actorType, shareCode) } - if rf, ok := ret.Get(0).(func(context.Context, temporary.ActorType, string) sharecode.ShareCodeData); ok { + if rf, ok := ret.Get(0).(func(context.Context, temporary.ActorType, string) sharecode.Data); ok { r0 = rf(ctx, actorType, shareCode) } else { - r0 = ret.Get(0).(sharecode.ShareCodeData) + r0 = ret.Get(0).(sharecode.Data) } if rf, ok := ret.Get(1).(func(context.Context, temporary.ActorType, string) error); ok { @@ -119,18 +119,18 @@ func (_c *mockShareCodeStore_Get_Call) Run(run func(ctx context.Context, actorTy return _c } -func (_c *mockShareCodeStore_Get_Call) Return(_a0 sharecode.ShareCodeData, _a1 error) *mockShareCodeStore_Get_Call { +func (_c *mockShareCodeStore_Get_Call) Return(_a0 sharecode.Data, _a1 error) *mockShareCodeStore_Get_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockShareCodeStore_Get_Call) RunAndReturn(run func(context.Context, temporary.ActorType, string) (sharecode.ShareCodeData, error)) *mockShareCodeStore_Get_Call { +func (_c *mockShareCodeStore_Get_Call) RunAndReturn(run func(context.Context, temporary.ActorType, string) (sharecode.Data, error)) *mockShareCodeStore_Get_Call { _c.Call.Return(run) return _c } // Put provides a mock function with given fields: ctx, actorType, shareCode, shareCodeData -func (_m *mockShareCodeStore) Put(ctx context.Context, actorType temporary.ActorType, shareCode string, shareCodeData sharecode.ShareCodeData) error { +func (_m *mockShareCodeStore) Put(ctx context.Context, actorType temporary.ActorType, shareCode string, shareCodeData sharecode.Data) error { ret := _m.Called(ctx, actorType, shareCode, shareCodeData) if len(ret) == 0 { @@ -138,7 +138,7 @@ func (_m *mockShareCodeStore) Put(ctx context.Context, actorType temporary.Actor } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, temporary.ActorType, string, sharecode.ShareCodeData) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, temporary.ActorType, string, sharecode.Data) error); ok { r0 = rf(ctx, actorType, shareCode, shareCodeData) } else { r0 = ret.Error(0) @@ -156,14 +156,14 @@ type mockShareCodeStore_Put_Call struct { // - ctx context.Context // - actorType temporary.ActorType // - shareCode string -// - shareCodeData sharecode.ShareCodeData +// - shareCodeData sharecode.Data func (_e *mockShareCodeStore_Expecter) Put(ctx interface{}, actorType interface{}, shareCode interface{}, shareCodeData interface{}) *mockShareCodeStore_Put_Call { return &mockShareCodeStore_Put_Call{Call: _e.mock.On("Put", ctx, actorType, shareCode, shareCodeData)} } -func (_c *mockShareCodeStore_Put_Call) Run(run func(ctx context.Context, actorType temporary.ActorType, shareCode string, shareCodeData sharecode.ShareCodeData)) *mockShareCodeStore_Put_Call { +func (_c *mockShareCodeStore_Put_Call) Run(run func(ctx context.Context, actorType temporary.ActorType, shareCode string, shareCodeData sharecode.Data)) *mockShareCodeStore_Put_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(temporary.ActorType), args[2].(string), args[3].(sharecode.ShareCodeData)) + run(args[0].(context.Context), args[1].(temporary.ActorType), args[2].(string), args[3].(sharecode.Data)) }) return _c } @@ -173,7 +173,7 @@ func (_c *mockShareCodeStore_Put_Call) Return(_a0 error) *mockShareCodeStore_Put return _c } -func (_c *mockShareCodeStore_Put_Call) RunAndReturn(run func(context.Context, temporary.ActorType, string, sharecode.ShareCodeData) error) *mockShareCodeStore_Put_Call { +func (_c *mockShareCodeStore_Put_Call) RunAndReturn(run func(context.Context, temporary.ActorType, string, sharecode.Data) error) *mockShareCodeStore_Put_Call { _c.Call.Return(run) return _c } diff --git a/internal/certificateprovider/certificateproviderpage/one_login_identity_details.go b/internal/certificateprovider/certificateproviderpage/one_login_identity_details.go index 1ce53308e0..35406a3fa2 100644 --- a/internal/certificateprovider/certificateproviderpage/one_login_identity_details.go +++ b/internal/certificateprovider/certificateproviderpage/one_login_identity_details.go @@ -4,9 +4,9 @@ import ( "net/http" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -33,7 +33,7 @@ func OneLoginIdentityDetails(tmpl template.Template, certificateProviderStore Ce lpa.CertificateProvider.FirstNames, lpa.CertificateProvider.LastName, ) { - certificateProvider.Tasks.ConfirmYourIdentity = actor.TaskCompleted + certificateProvider.Tasks.ConfirmYourIdentity = task.StateCompleted if err = certificateProviderStore.Put(r.Context(), certificateProvider); err != nil { return err diff --git a/internal/certificateprovider/certificateproviderpage/one_login_identity_details_test.go b/internal/certificateprovider/certificateproviderpage/one_login_identity_details_test.go index 0340c45b7c..b9604c506d 100644 --- a/internal/certificateprovider/certificateproviderpage/one_login_identity_details_test.go +++ b/internal/certificateprovider/certificateproviderpage/one_login_identity_details_test.go @@ -5,12 +5,12 @@ import ( "net/http/httptest" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/date" "github.com/ministryofjustice/opg-modernising-lpa/internal/identity" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -63,7 +63,7 @@ func TestPostOneLoginIdentityDetails(t *testing.T) { IdentityUserData: identity.UserData{Status: identity.StatusConfirmed, FirstNames: "a", LastName: "b", DateOfBirth: date.New("2000", "1", "1")}, LpaID: "lpa-id", DateOfBirth: date.New("2000", "1", "1"), - Tasks: certificateproviderdata.Tasks{ConfirmYourIdentity: actor.TaskCompleted}, + Tasks: certificateproviderdata.Tasks{ConfirmYourIdentity: task.StateCompleted}, } certificateProviderStore := newMockCertificateProviderStore(t) diff --git a/internal/certificateprovider/certificateproviderpage/provide_certificate.go b/internal/certificateprovider/certificateproviderpage/provide_certificate.go index 0cb5a626fa..0549e3491c 100644 --- a/internal/certificateprovider/certificateproviderpage/provide_certificate.go +++ b/internal/certificateprovider/certificateproviderpage/provide_certificate.go @@ -6,12 +6,12 @@ import ( "time" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -65,7 +65,7 @@ func ProvideCertificate( } certificateProvider.SignedAt = now() - certificateProvider.Tasks.ProvideTheCertificate = actor.TaskCompleted + certificateProvider.Tasks.ProvideTheCertificate = task.StateCompleted if lpa.CertificateProvider.SignedAt.IsZero() { if err := lpaStoreClient.SendCertificateProvider(r.Context(), certificateProvider, lpa); err != nil { diff --git a/internal/certificateprovider/certificateproviderpage/provide_certificate_test.go b/internal/certificateprovider/certificateproviderpage/provide_certificate_test.go index 7cfeaae964..3be4add05d 100644 --- a/internal/certificateprovider/certificateproviderpage/provide_certificate_test.go +++ b/internal/certificateprovider/certificateproviderpage/provide_certificate_test.go @@ -9,12 +9,12 @@ import ( "testing" "time" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -130,7 +130,7 @@ func TestPostProvideCertificate(t *testing.T) { LpaID: "lpa-id", SignedAt: now, Tasks: certificateproviderdata.Tasks{ - ProvideTheCertificate: actor.TaskCompleted, + ProvideTheCertificate: task.StateCompleted, }, Email: "a@example.com", } @@ -220,7 +220,7 @@ func TestPostProvideCertificateWhenSignedInLpaStore(t *testing.T) { LpaID: "lpa-id", SignedAt: signedAt, Tasks: certificateproviderdata.Tasks{ - ProvideTheCertificate: actor.TaskCompleted, + ProvideTheCertificate: task.StateCompleted, }, Email: "a@example.com", } diff --git a/internal/certificateprovider/certificateproviderpage/read_the_lpa.go b/internal/certificateprovider/certificateproviderpage/read_the_lpa.go index 68038b3e2c..2b228324a1 100644 --- a/internal/certificateprovider/certificateproviderpage/read_the_lpa.go +++ b/internal/certificateprovider/certificateproviderpage/read_the_lpa.go @@ -4,10 +4,10 @@ import ( "net/http" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -29,7 +29,7 @@ func ReadTheLpa(tmpl template.Template, lpaStoreResolvingService LpaStoreResolvi return page.Paths.CertificateProvider.TaskList.Redirect(w, r, appData, lpa.LpaID) } - certificateProvider.Tasks.ReadTheLpa = actor.TaskCompleted + certificateProvider.Tasks.ReadTheLpa = task.StateCompleted if err := certificateProviderStore.Put(r.Context(), certificateProvider); err != nil { return err } diff --git a/internal/certificateprovider/certificateproviderpage/read_the_lpa_test.go b/internal/certificateprovider/certificateproviderpage/read_the_lpa_test.go index 5f90e33efa..c189d0ad85 100644 --- a/internal/certificateprovider/certificateproviderpage/read_the_lpa_test.go +++ b/internal/certificateprovider/certificateproviderpage/read_the_lpa_test.go @@ -6,10 +6,10 @@ import ( "testing" "time" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -89,7 +89,7 @@ func TestPostReadTheLpa(t *testing.T) { certificateProviderStore.EXPECT(). Put(r.Context(), &certificateproviderdata.Provided{ Tasks: certificateproviderdata.Tasks{ - ReadTheLpa: actor.TaskCompleted, + ReadTheLpa: task.StateCompleted, }, }). Return(nil) diff --git a/internal/certificateprovider/certificateproviderpage/register.go b/internal/certificateprovider/certificateproviderpage/register.go index 0ee460ff6b..c3b9fb2cda 100644 --- a/internal/certificateprovider/certificateproviderpage/register.go +++ b/internal/certificateprovider/certificateproviderpage/register.go @@ -20,6 +20,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/place" "github.com/ministryofjustice/opg-modernising-lpa/internal/random" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" ) type Handler func(data page.AppData, w http.ResponseWriter, r *http.Request, details *certificateproviderdata.Provided) error @@ -35,7 +36,7 @@ type Logger interface { } type CertificateProviderStore interface { - Create(ctx context.Context, shareCode actor.ShareCodeData, email string) (*certificateproviderdata.Provided, error) + Create(ctx context.Context, shareCode sharecode.Data, email string) (*certificateproviderdata.Provided, error) Delete(ctx context.Context) error Get(ctx context.Context) (*certificateproviderdata.Provided, error) Put(ctx context.Context, certificateProvider *certificateproviderdata.Provided) error @@ -49,9 +50,9 @@ type OneLoginClient interface { } type ShareCodeStore interface { - Get(ctx context.Context, actorType actor.Type, shareCode string) (actor.ShareCodeData, error) - Put(ctx context.Context, actorType actor.Type, shareCode string, shareCodeData actor.ShareCodeData) error - Delete(ctx context.Context, shareCode actor.ShareCodeData) error + Get(ctx context.Context, actorType actor.Type, shareCode string) (sharecode.Data, error) + Put(ctx context.Context, actorType actor.Type, shareCode string, shareCodeData sharecode.Data) error + Delete(ctx context.Context, shareCode sharecode.Data) error } type Template func(io.Writer, interface{}) error @@ -96,8 +97,8 @@ type LpaStoreClient interface { type ErrorHandler func(http.ResponseWriter, *http.Request, error) type DonorStore interface { - GetAny(ctx context.Context) (*donordata.DonorProvidedDetails, error) - Put(ctx context.Context, donor *donordata.DonorProvidedDetails) error + GetAny(ctx context.Context) (*donordata.Provided, error) + Put(ctx context.Context, donor *donordata.Provided) error } func Register( diff --git a/internal/certificateprovider/certificateproviderpage/task_list.go b/internal/certificateprovider/certificateproviderpage/task_list.go index 549697ad98..014d168a2e 100644 --- a/internal/certificateprovider/certificateproviderpage/task_list.go +++ b/internal/certificateprovider/certificateproviderpage/task_list.go @@ -4,10 +4,10 @@ import ( "net/http" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -21,7 +21,7 @@ type taskListData struct { type taskListItem struct { Name string Path string - State actor.TaskState + State task.State Disabled bool } diff --git a/internal/certificateprovider/certificateproviderpage/task_list_test.go b/internal/certificateprovider/certificateproviderpage/task_list_test.go index 19b7fe9dcb..b794c36a7a 100644 --- a/internal/certificateprovider/certificateproviderpage/task_list_test.go +++ b/internal/certificateprovider/certificateproviderpage/task_list_test.go @@ -6,11 +6,11 @@ import ( "testing" "time" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/identity" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -40,12 +40,12 @@ func TestGetTaskList(t *testing.T) { }, certificateProvider: &certificateproviderdata.Provided{ Tasks: certificateproviderdata.Tasks{ - ConfirmYourDetails: actor.TaskCompleted, + ConfirmYourDetails: task.StateCompleted, }, }, appData: testAppData, expected: func(items []taskListItem) []taskListItem { - items[0].State = actor.TaskCompleted + items[0].State = task.StateCompleted items[1].Disabled = true items[2].Disabled = true @@ -59,12 +59,12 @@ func TestGetTaskList(t *testing.T) { }, certificateProvider: &certificateproviderdata.Provided{ Tasks: certificateproviderdata.Tasks{ - ConfirmYourDetails: actor.TaskCompleted, + ConfirmYourDetails: task.StateCompleted, }, }, appData: testAppData, expected: func(items []taskListItem) []taskListItem { - items[0].State = actor.TaskCompleted + items[0].State = task.StateCompleted items[1].Disabled = true items[2].Disabled = true @@ -80,17 +80,17 @@ func TestGetTaskList(t *testing.T) { certificateProvider: &certificateproviderdata.Provided{ IdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, Tasks: certificateproviderdata.Tasks{ - ConfirmYourDetails: actor.TaskCompleted, - ConfirmYourIdentity: actor.TaskCompleted, - ProvideTheCertificate: actor.TaskCompleted, + ConfirmYourDetails: task.StateCompleted, + ConfirmYourIdentity: task.StateCompleted, + ProvideTheCertificate: task.StateCompleted, }, }, appData: testAppData, expected: func(items []taskListItem) []taskListItem { - items[0].State = actor.TaskCompleted - items[1].State = actor.TaskCompleted + items[0].State = task.StateCompleted + items[1].State = task.StateCompleted items[1].Path = page.Paths.CertificateProvider.ReadTheLpa.Format("lpa-id") - items[2].State = actor.TaskCompleted + items[2].State = task.StateCompleted return items }, @@ -103,17 +103,17 @@ func TestGetTaskList(t *testing.T) { }, certificateProvider: &certificateproviderdata.Provided{ Tasks: certificateproviderdata.Tasks{ - ConfirmYourDetails: actor.TaskCompleted, - ConfirmYourIdentity: actor.TaskCompleted, - ProvideTheCertificate: actor.TaskCompleted, + ConfirmYourDetails: task.StateCompleted, + ConfirmYourIdentity: task.StateCompleted, + ProvideTheCertificate: task.StateCompleted, }, }, appData: testAppData, expected: func(items []taskListItem) []taskListItem { - items[0].State = actor.TaskCompleted - items[1].State = actor.TaskCompleted + items[0].State = task.StateCompleted + items[1].State = task.StateCompleted items[1].Path = page.Paths.CertificateProvider.ReadTheLpa.Format("lpa-id") - items[2].State = actor.TaskCompleted + items[2].State = task.StateCompleted return items }, diff --git a/internal/certificateprovider/certificateproviderpage/unable_to_confirm_identity.go b/internal/certificateprovider/certificateproviderpage/unable_to_confirm_identity.go index e68b4a3ce2..3204fd444c 100644 --- a/internal/certificateprovider/certificateproviderpage/unable_to_confirm_identity.go +++ b/internal/certificateprovider/certificateproviderpage/unable_to_confirm_identity.go @@ -4,10 +4,10 @@ import ( "net/http" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -20,7 +20,7 @@ type unableToConfirmIdentityData struct { func UnableToConfirmIdentity(tmpl template.Template, certificateProviderStore CertificateProviderStore, lpaStoreResolvingService LpaStoreResolvingService) Handler { return func(appData page.AppData, w http.ResponseWriter, r *http.Request, certificateProvider *certificateproviderdata.Provided) error { if r.Method == http.MethodPost { - certificateProvider.Tasks.ConfirmYourIdentity = actor.TaskCompleted + certificateProvider.Tasks.ConfirmYourIdentity = task.StateCompleted if err := certificateProviderStore.Put(r.Context(), certificateProvider); err != nil { return err diff --git a/internal/certificateprovider/certificateproviderpage/unable_to_confirm_identity_test.go b/internal/certificateprovider/certificateproviderpage/unable_to_confirm_identity_test.go index 6eda61706b..332e46a12f 100644 --- a/internal/certificateprovider/certificateproviderpage/unable_to_confirm_identity_test.go +++ b/internal/certificateprovider/certificateproviderpage/unable_to_confirm_identity_test.go @@ -5,10 +5,10 @@ import ( "net/http/httptest" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -92,7 +92,7 @@ func TestPostUnableToConfirmIdentity(t *testing.T) { certificateProviderStore.EXPECT(). Put(r.Context(), &certificateproviderdata.Provided{ LpaID: "lpa-id", - Tasks: certificateproviderdata.Tasks{ConfirmYourIdentity: actor.TaskCompleted}, + Tasks: certificateproviderdata.Tasks{ConfirmYourIdentity: task.StateCompleted}, }). Return(nil) diff --git a/internal/donor/donordata/donor_provided_test.go b/internal/donor/donordata/donor_provided_test.go index 1dfc5da27f..7857dd5650 100644 --- a/internal/donor/donordata/donor_provided_test.go +++ b/internal/donor/donordata/donor_provided_test.go @@ -22,8 +22,8 @@ var address = place.Address{ } func TestGenerateHash(t *testing.T) { - makeDonor := func(version uint8, hash uint64) *DonorProvidedDetails { - return &DonorProvidedDetails{ + makeDonor := func(version uint8, hash uint64) *Provided { + return &Provided{ HashVersion: version, Hash: hash, Attorneys: Attorneys{ @@ -35,14 +35,14 @@ func TestGenerateHash(t *testing.T) { } // DO change this value to match the updates - const modified uint64 = 0x1cefa62ee4bb85e5 + const modified uint64 = 0xfe1ed2aef88cbd75 // DO NOT change these initial hash values. If a field has been added/removed // you will need to handle the version gracefully by modifying // (*DonorProvidedDetails).HashInclude and adding another testcase for the new // version. testcases := map[uint8]uint64{ - 0: 0x7dce1f9e651e6c8f, + 0: 0x72bdc7895854e6c9, } for version, initial := range testcases { @@ -65,7 +65,7 @@ func TestGenerateHash(t *testing.T) { } func TestGenerateHashVersionTooHigh(t *testing.T) { - donor := &DonorProvidedDetails{ + donor := &Provided{ HashVersion: currentHashVersion + 1, Attorneys: Attorneys{ Attorneys: []Attorney{ @@ -79,8 +79,8 @@ func TestGenerateHashVersionTooHigh(t *testing.T) { } func TestGenerateCheckedHash(t *testing.T) { - makeDonor := func(version uint8, hash uint64) *DonorProvidedDetails { - return &DonorProvidedDetails{ + makeDonor := func(version uint8, hash uint64) *Provided { + return &Provided{ CheckedHashVersion: version, CheckedHash: hash, Attorneys: Attorneys{ @@ -121,7 +121,7 @@ func TestGenerateCheckedHash(t *testing.T) { } func TestGenerateCheckedHashVersionTooHigh(t *testing.T) { - donor := &DonorProvidedDetails{ + donor := &Provided{ CheckedHashVersion: currentCheckedHashVersion + 1, Attorneys: Attorneys{ Attorneys: []Attorney{ @@ -136,11 +136,11 @@ func TestGenerateCheckedHashVersionTooHigh(t *testing.T) { func TestIdentityConfirmed(t *testing.T) { testCases := map[string]struct { - lpa *DonorProvidedDetails + lpa *Provided expected bool }{ "confirmed": { - lpa: &DonorProvidedDetails{ + lpa: &Provided{ DonorIdentityUserData: identity.UserData{FirstNames: "a", LastName: "b", Status: identity.StatusConfirmed, DateOfBirth: date.New("2000", "1", "1")}, Donor: Donor{ FirstNames: "a", @@ -151,7 +151,7 @@ func TestIdentityConfirmed(t *testing.T) { expected: true, }, "failed": { - lpa: &DonorProvidedDetails{ + lpa: &Provided{ DonorIdentityUserData: identity.UserData{FirstNames: "a", LastName: "b", Status: identity.StatusFailed, DateOfBirth: date.New("2000", "1", "1")}, Donor: Donor{ FirstNames: "a", @@ -162,7 +162,7 @@ func TestIdentityConfirmed(t *testing.T) { expected: false, }, "name does not match": { - lpa: &DonorProvidedDetails{ + lpa: &Provided{ DonorIdentityUserData: identity.UserData{FirstNames: "a", LastName: "b", Status: identity.StatusConfirmed, DateOfBirth: date.New("2000", "1", "1")}, Donor: Donor{ FirstNames: "a", @@ -173,7 +173,7 @@ func TestIdentityConfirmed(t *testing.T) { expected: false, }, "dob does not match": { - lpa: &DonorProvidedDetails{ + lpa: &Provided{ DonorIdentityUserData: identity.UserData{FirstNames: "a", LastName: "b", Status: identity.StatusConfirmed, DateOfBirth: date.New("2000", "1", "1")}, Donor: Donor{ FirstNames: "a", @@ -184,7 +184,7 @@ func TestIdentityConfirmed(t *testing.T) { expected: false, }, "insufficient evidence": { - lpa: &DonorProvidedDetails{ + lpa: &Provided{ DonorIdentityUserData: identity.UserData{FirstNames: "a", LastName: "b", Status: identity.StatusInsufficientEvidence, DateOfBirth: date.New("2000", "1", "1")}, Donor: Donor{ FirstNames: "a", @@ -195,7 +195,7 @@ func TestIdentityConfirmed(t *testing.T) { expected: false, }, "none": { - lpa: &DonorProvidedDetails{}, + lpa: &Provided{}, expected: false, }, } @@ -208,7 +208,7 @@ func TestIdentityConfirmed(t *testing.T) { } func TestAttorneysSigningDeadline(t *testing.T) { - donor := DonorProvidedDetails{ + donor := Provided{ SignedAt: time.Date(2020, time.January, 2, 3, 4, 5, 6, time.UTC), } @@ -224,7 +224,7 @@ func TestUnder18ActorDetails(t *testing.T) { uid3 := actoruid.New() uid4 := actoruid.New() - donor := DonorProvidedDetails{ + donor := Provided{ LpaID: "lpa-id", Attorneys: Attorneys{Attorneys: []Attorney{ {FirstNames: "a", LastName: "b", DateOfBirth: under18, UID: uid1}, @@ -245,7 +245,7 @@ func TestUnder18ActorDetails(t *testing.T) { } func TestActorAddresses(t *testing.T) { - donor := &DonorProvidedDetails{ + donor := &Provided{ Donor: Donor{Address: place.Address{Line1: "1"}}, Attorneys: Attorneys{Attorneys: []Attorney{ {Address: place.Address{Line1: "2"}}, @@ -271,7 +271,7 @@ func TestActorAddresses(t *testing.T) { } func TestActorAddressesActorWithNoAddressIgnored(t *testing.T) { - donor := &DonorProvidedDetails{ + donor := &Provided{ Donor: Donor{FirstNames: "Donor", LastName: "Actor", Address: address}, Attorneys: Attorneys{Attorneys: []Attorney{ {FirstNames: "Attorney One", LastName: "Actor", Address: address}, @@ -290,7 +290,7 @@ func TestActorAddressesActorWithNoAddressIgnored(t *testing.T) { } func TestAllLayAttorneysFirstNames(t *testing.T) { - donor := &DonorProvidedDetails{ + donor := &Provided{ Attorneys: Attorneys{ Attorneys: []Attorney{ {FirstNames: "John", LastName: "Smith"}, @@ -309,7 +309,7 @@ func TestAllLayAttorneysFirstNames(t *testing.T) { } func TestAllLayAttorneysFullNames(t *testing.T) { - donor := &DonorProvidedDetails{ + donor := &Provided{ Attorneys: Attorneys{ Attorneys: []Attorney{ {FirstNames: "John", LastName: "Smith"}, @@ -328,7 +328,7 @@ func TestAllLayAttorneysFullNames(t *testing.T) { } func TestTrustCorporationOriginal(t *testing.T) { - donor := &DonorProvidedDetails{ + donor := &Provided{ Attorneys: Attorneys{TrustCorporation: TrustCorporation{Name: "Corp"}}, ReplacementAttorneys: Attorneys{TrustCorporation: TrustCorporation{Name: "Trust"}}, } @@ -343,7 +343,7 @@ func TestNamesChanged(t *testing.T) { "OtherNames": {FirstNames: "a", LastName: "b", OtherNames: "d"}, } - donor := &DonorProvidedDetails{Donor: Donor{FirstNames: "a", LastName: "b", OtherNames: "c"}} + donor := &Provided{Donor: Donor{FirstNames: "a", LastName: "b", OtherNames: "c"}} for name, updatedDonor := range testCases { t.Run(name, func(t *testing.T) { diff --git a/internal/donor/donordata/provided.go b/internal/donor/donordata/provided.go index f9e03fae77..f07427e1c2 100644 --- a/internal/donor/donordata/provided.go +++ b/internal/donor/donordata/provided.go @@ -23,7 +23,7 @@ const ( currentCheckedHashVersion uint8 = 0 ) -type DonorTasks struct { +type Tasks struct { YourDetails task.State ChooseAttorneys task.State ChooseReplacementAttorneys task.State @@ -39,8 +39,8 @@ type DonorTasks struct { ConfirmYourIdentityAndSign task.IdentityState } -// DonorProvidedDetails contains all the data related to the LPA application -type DonorProvidedDetails struct { +// Provided contains all the data related to the LPA application +type Provided struct { PK dynamo.LpaKeyType `hash:"-"` SK dynamo.LpaOwnerKeyType `hash:"-"` // Hash is used to determine whether the Lpa has been changed since last read @@ -74,7 +74,7 @@ type DonorProvidedDetails struct { // Restrictions on attorneys actions Restrictions string // Used to show the task list - Tasks DonorTasks + Tasks Tasks // PaymentDetails are records of payments made for the LPA via GOV.UK Pay PaymentDetails []Payment // Information returned by the identity service related to the applicant @@ -156,7 +156,7 @@ type DonorProvidedDetails struct { HasSentApplicationUpdatedEvent bool `hash:"-"` } -func (d *DonorProvidedDetails) HashInclude(field string, _ any) (bool, error) { +func (d *Provided) HashInclude(field string, _ any) (bool, error) { if d.HashVersion > currentHashVersion { return false, errors.New("HashVersion too high") } @@ -167,7 +167,7 @@ func (d *DonorProvidedDetails) HashInclude(field string, _ any) (bool, error) { // toCheck filters the fields used for hashing further, for the use of // determining whether the LPA data has changed since it was checked by the // donor. -type toCheck DonorProvidedDetails +type toCheck Provided func (c toCheck) HashInclude(field string, _ any) (bool, error) { if c.CheckedHashVersion > currentCheckedHashVersion { @@ -206,49 +206,49 @@ func (c toCheck) HashInclude(field string, _ any) (bool, error) { return true, nil } -func (l *DonorProvidedDetails) NamesChanged(firstNames, lastName, otherNames string) bool { +func (l *Provided) NamesChanged(firstNames, lastName, otherNames string) bool { return l.Donor.FirstNames != firstNames || l.Donor.LastName != lastName || l.Donor.OtherNames != otherNames } -func (l *DonorProvidedDetails) HashChanged() bool { +func (l *Provided) HashChanged() bool { hash, _ := l.generateHash() return hash != l.Hash } -func (l *DonorProvidedDetails) UpdateHash() (err error) { +func (l *Provided) UpdateHash() (err error) { l.HashVersion = currentHashVersion l.Hash, err = l.generateHash() return err } -func (l *DonorProvidedDetails) generateHash() (uint64, error) { +func (l *Provided) generateHash() (uint64, error) { return hashstructure.Hash(l, hashstructure.FormatV2, nil) } -func (l *DonorProvidedDetails) CheckedHashChanged() bool { +func (l *Provided) CheckedHashChanged() bool { hash, _ := l.generateCheckedHash() return hash != l.CheckedHash } -func (l *DonorProvidedDetails) UpdateCheckedHash() (err error) { +func (l *Provided) UpdateCheckedHash() (err error) { l.CheckedHashVersion = currentCheckedHashVersion l.CheckedHash, err = l.generateCheckedHash() return err } -func (l *DonorProvidedDetails) generateCheckedHash() (uint64, error) { +func (l *Provided) generateCheckedHash() (uint64, error) { return hashstructure.Hash(toCheck(*l), hashstructure.FormatV2, nil) } -func (l *DonorProvidedDetails) DonorIdentityConfirmed() bool { +func (l *Provided) DonorIdentityConfirmed() bool { return l.DonorIdentityUserData.Status.IsConfirmed() && l.DonorIdentityUserData.MatchName(l.Donor.FirstNames, l.Donor.LastName) && l.DonorIdentityUserData.DateOfBirth.Equals(l.Donor.DateOfBirth) } -func (l *DonorProvidedDetails) AttorneysAndCpSigningDeadline() time.Time { +func (l *Provided) AttorneysAndCpSigningDeadline() time.Time { return l.SignedAt.Add((24 * time.Hour) * 28) } @@ -259,7 +259,7 @@ type Under18ActorDetails struct { Type temporary.ActorType } -func (l *DonorProvidedDetails) Under18ActorDetails() []Under18ActorDetails { +func (l *Provided) Under18ActorDetails() []Under18ActorDetails { var data []Under18ActorDetails eighteenYearsAgo := date.Today().AddDate(-18, 0, 0) @@ -288,7 +288,7 @@ func (l *DonorProvidedDetails) Under18ActorDetails() []Under18ActorDetails { return data } -func (l *DonorProvidedDetails) ActorAddresses() []place.Address { +func (l *Provided) ActorAddresses() []place.Address { var addresses []place.Address if l.Donor.Address.String() != "" { @@ -314,7 +314,7 @@ func (l *DonorProvidedDetails) ActorAddresses() []place.Address { return addresses } -func (l *DonorProvidedDetails) AllLayAttorneysFirstNames() []string { +func (l *Provided) AllLayAttorneysFirstNames() []string { var names []string for _, a := range l.Attorneys.Attorneys { @@ -328,7 +328,7 @@ func (l *DonorProvidedDetails) AllLayAttorneysFirstNames() []string { return names } -func (l *DonorProvidedDetails) AllLayAttorneysFullNames() []string { +func (l *Provided) AllLayAttorneysFullNames() []string { var names []string for _, a := range l.Attorneys.Attorneys { @@ -342,7 +342,7 @@ func (l *DonorProvidedDetails) AllLayAttorneysFullNames() []string { return names } -func (l *DonorProvidedDetails) TrustCorporationsNames() []string { +func (l *Provided) TrustCorporationsNames() []string { var names []string if l.Attorneys.TrustCorporation.Name != "" { @@ -356,7 +356,7 @@ func (l *DonorProvidedDetails) TrustCorporationsNames() []string { return names } -func (l *DonorProvidedDetails) Cost() int { +func (l *Provided) Cost() int { if l.Tasks.PayForLpa.IsDenied() { return 8200 } @@ -364,7 +364,7 @@ func (l *DonorProvidedDetails) Cost() int { return pay.Cost(l.FeeType, l.PreviousFee) } -func (l *DonorProvidedDetails) FeeAmount() pay.AmountPence { +func (l *Provided) FeeAmount() pay.AmountPence { paid := 0 for _, payment := range l.PaymentDetails { @@ -378,7 +378,7 @@ func (l *DonorProvidedDetails) FeeAmount() pay.AmountPence { // of the certificate provider matches that of the donor or one of the // attorneys. For a match of the last name we break on '-' to account for // double-barrelled names. -func (l *DonorProvidedDetails) CertificateProviderSharesDetails() bool { +func (l *Provided) CertificateProviderSharesDetails() bool { certificateProviderParts := strings.Split(l.CertificateProvider.LastName, "-") donorParts := strings.Split(l.Donor.LastName, "-") diff --git a/internal/donor/donordata/store.go b/internal/donor/donordata/store.go index dc0f886112..73697d85c6 100644 --- a/internal/donor/donordata/store.go +++ b/internal/donor/donordata/store.go @@ -83,7 +83,7 @@ func NewStore(dynamoClient DynamoClient, eventClient EventClient, logger Logger, } } -func (s *donorStore) Create(ctx context.Context) (*DonorProvidedDetails, error) { +func (s *donorStore) Create(ctx context.Context) (*Provided, error) { data, err := appcontext.SessionDataFromContext(ctx) if err != nil { return nil, err @@ -96,7 +96,7 @@ func (s *donorStore) Create(ctx context.Context) (*DonorProvidedDetails, error) lpaID := s.uuidString() donorUID := s.newUID() - donor := &DonorProvidedDetails{ + donor := &Provided{ PK: dynamo.LpaKey(lpaID), SK: dynamo.LpaOwnerKey(dynamo.DonorKey(data.SessionID)), LpaID: lpaID, @@ -158,7 +158,7 @@ type lpaReference struct { // for the organisation ID that holds the Lpa data; // 2. an lpaLink which allows // the Lpa to be shown on the donor's dashboard. -func (s *donorStore) Link(ctx context.Context, shareCode sharecode.ShareCodeData, donorEmail string) error { +func (s *donorStore) Link(ctx context.Context, shareCode sharecode.Data, donorEmail string) error { organisationKey, ok := shareCode.LpaOwnerKey.Organisation() if !ok { return errors.New("donorStore.Link can only be used with organisations") @@ -201,7 +201,7 @@ func (s *donorStore) Link(ctx context.Context, shareCode sharecode.ShareCodeData return s.dynamoClient.WriteTransaction(ctx, transaction) } -func (s *donorStore) GetAny(ctx context.Context) (*DonorProvidedDetails, error) { +func (s *donorStore) GetAny(ctx context.Context) (*Provided, error) { data, err := appcontext.SessionDataFromContext(ctx) if err != nil { return nil, err @@ -217,7 +217,7 @@ func (s *donorStore) GetAny(ctx context.Context) (*DonorProvidedDetails, error) } var donor struct { - DonorProvidedDetails + Provided ReferencedSK dynamo.OrganisationKeyType } if err := s.dynamoClient.OneByPartialSK(ctx, dynamo.LpaKey(data.LpaID), sk, &donor); err != nil { @@ -228,10 +228,10 @@ func (s *donorStore) GetAny(ctx context.Context) (*DonorProvidedDetails, error) err = s.dynamoClient.One(ctx, dynamo.LpaKey(data.LpaID), donor.ReferencedSK, &donor) } - return &donor.DonorProvidedDetails, err + return &donor.Provided, err } -func (s *donorStore) Get(ctx context.Context) (*DonorProvidedDetails, error) { +func (s *donorStore) Get(ctx context.Context) (*Provided, error) { data, err := appcontext.SessionDataFromContext(ctx) if err != nil { return nil, err @@ -247,7 +247,7 @@ func (s *donorStore) Get(ctx context.Context) (*DonorProvidedDetails, error) { } var donor struct { - DonorProvidedDetails + Provided ReferencedSK dynamo.OrganisationKeyType } if err := s.dynamoClient.One(ctx, dynamo.LpaKey(data.LpaID), sk, &donor); err != nil { @@ -258,10 +258,10 @@ func (s *donorStore) Get(ctx context.Context) (*DonorProvidedDetails, error) { err = s.dynamoClient.One(ctx, dynamo.LpaKey(data.LpaID), donor.ReferencedSK, &donor) } - return &donor.DonorProvidedDetails, err + return &donor.Provided, err } -func (s *donorStore) Latest(ctx context.Context) (*DonorProvidedDetails, error) { +func (s *donorStore) Latest(ctx context.Context) (*Provided, error) { data, err := appcontext.SessionDataFromContext(ctx) if err != nil { return nil, err @@ -271,7 +271,7 @@ func (s *donorStore) Latest(ctx context.Context) (*DonorProvidedDetails, error) return nil, errors.New("donorStore.Latest requires SessionID") } - var donor *DonorProvidedDetails + var donor *Provided if err := s.dynamoClient.LatestForActor(ctx, dynamo.DonorKey(data.SessionID), &donor); err != nil { return nil, err } @@ -279,7 +279,7 @@ func (s *donorStore) Latest(ctx context.Context) (*DonorProvidedDetails, error) return donor, nil } -func (s *donorStore) GetByKeys(ctx context.Context, keys []dynamo.Keys) ([]DonorProvidedDetails, error) { +func (s *donorStore) GetByKeys(ctx context.Context, keys []dynamo.Keys) ([]Provided, error) { if len(keys) == 0 { return nil, nil } @@ -289,10 +289,10 @@ func (s *donorStore) GetByKeys(ctx context.Context, keys []dynamo.Keys) ([]Donor return nil, err } - var donors []DonorProvidedDetails + var donors []Provided err = attributevalue.UnmarshalListOfMaps(items, &donors) - mappedDonors := map[string]DonorProvidedDetails{} + mappedDonors := map[string]Provided{} for _, donor := range donors { mappedDonors[donor.PK.PK()+"|"+donor.SK.SK()] = donor } @@ -305,7 +305,7 @@ func (s *donorStore) GetByKeys(ctx context.Context, keys []dynamo.Keys) ([]Donor return donors, err } -func (s *donorStore) Put(ctx context.Context, donor *DonorProvidedDetails) error { +func (s *donorStore) Put(ctx context.Context, donor *Provided) error { if !donor.HashChanged() { return nil } @@ -387,7 +387,7 @@ func (s *donorStore) Delete(ctx context.Context) error { return s.dynamoClient.DeleteKeys(ctx, keys) } -func (s *donorStore) DeleteDonorAccess(ctx context.Context, shareCodeData sharecode.ShareCodeData) error { +func (s *donorStore) DeleteDonorAccess(ctx context.Context, shareCodeData sharecode.Data) error { organisationKey, ok := shareCodeData.LpaOwnerKey.Organisation() if !ok { return errors.New("donorStore.DeleteDonorAccess can only be used with organisations") diff --git a/internal/donor/donordata/store_test.go b/internal/donor/donordata/store_test.go index 038ebddfeb..660f82da9d 100644 --- a/internal/donor/donordata/store_test.go +++ b/internal/donor/donordata/store_test.go @@ -27,26 +27,26 @@ func TestDonorStoreGetAny(t *testing.T) { ctx := appcontext.ContextWithSessionData(context.Background(), &appcontext.SessionData{LpaID: "an-id"}) dynamoClient := newMockDynamoClient(t) - dynamoClient.ExpectOneByPartialSK(ctx, dynamo.LpaKey("an-id"), dynamo.DonorKey(""), &DonorProvidedDetails{LpaID: "an-id"}, nil) + dynamoClient.ExpectOneByPartialSK(ctx, dynamo.LpaKey("an-id"), dynamo.DonorKey(""), &Provided{LpaID: "an-id"}, nil) donorStore := &donorStore{dynamoClient: dynamoClient, uuidString: func() string { return "10100000" }} lpa, err := donorStore.GetAny(ctx) assert.Nil(t, err) - assert.Equal(t, &DonorProvidedDetails{LpaID: "an-id"}, lpa) + assert.Equal(t, &Provided{LpaID: "an-id"}, lpa) } func TestDonorStoreGetAnyWhenOrganisation(t *testing.T) { ctx := appcontext.ContextWithSessionData(context.Background(), &appcontext.SessionData{LpaID: "an-id", OrganisationID: "x"}) dynamoClient := newMockDynamoClient(t) - dynamoClient.ExpectOneByPartialSK(ctx, dynamo.LpaKey("an-id"), dynamo.OrganisationKey(""), &DonorProvidedDetails{LpaID: "an-id"}, nil) + dynamoClient.ExpectOneByPartialSK(ctx, dynamo.LpaKey("an-id"), dynamo.OrganisationKey(""), &Provided{LpaID: "an-id"}, nil) donorStore := &donorStore{dynamoClient: dynamoClient, uuidString: func() string { return "10100000" }} lpa, err := donorStore.GetAny(ctx) assert.Nil(t, err) - assert.Equal(t, &DonorProvidedDetails{LpaID: "an-id"}, lpa) + assert.Equal(t, &Provided{LpaID: "an-id"}, lpa) } func TestDonorStoreGetAnyWhenReference(t *testing.T) { @@ -60,13 +60,13 @@ func TestDonorStoreGetAnyWhenReference(t *testing.T) { ReferencedSK: dynamo.OrganisationKey("org"), }, nil) dynamoClient.ExpectOne(ctx, dynamo.LpaKey("an-id"), dynamo.OrganisationKey("org"), - &DonorProvidedDetails{LpaID: "an-id"}, nil) + &Provided{LpaID: "an-id"}, nil) donorStore := &donorStore{dynamoClient: dynamoClient, uuidString: func() string { return "10100000" }} lpa, err := donorStore.GetAny(ctx) assert.Nil(t, err) - assert.Equal(t, &DonorProvidedDetails{SK: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaID: "an-id"}, lpa) + assert.Equal(t, &Provided{SK: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaID: "an-id"}, lpa) } func TestDonorStoreGetAnyWithSessionMissing(t *testing.T) { @@ -80,7 +80,7 @@ func TestDonorStoreGetAnyWhenDataStoreError(t *testing.T) { ctx := appcontext.ContextWithSessionData(context.Background(), &appcontext.SessionData{LpaID: "an-id"}) dynamoClient := newMockDynamoClient(t) - dynamoClient.ExpectOneByPartialSK(ctx, dynamo.LpaKey("an-id"), dynamo.DonorKey(""), &DonorProvidedDetails{LpaID: "an-id"}, expectedError) + dynamoClient.ExpectOneByPartialSK(ctx, dynamo.LpaKey("an-id"), dynamo.DonorKey(""), &Provided{LpaID: "an-id"}, expectedError) donorStore := &donorStore{dynamoClient: dynamoClient, uuidString: func() string { return "10100000" }} @@ -127,13 +127,13 @@ func TestDonorStoreGet(t *testing.T) { ctx := appcontext.ContextWithSessionData(context.Background(), tc.sessionData) dynamoClient := newMockDynamoClient(t) - dynamoClient.ExpectOne(ctx, dynamo.LpaKey("an-id"), tc.expectedSK, &DonorProvidedDetails{LpaID: "an-id"}, nil) + dynamoClient.ExpectOne(ctx, dynamo.LpaKey("an-id"), tc.expectedSK, &Provided{LpaID: "an-id"}, nil) donorStore := &donorStore{dynamoClient: dynamoClient, uuidString: func() string { return "10100000" }} lpa, err := donorStore.Get(ctx) assert.Nil(t, err) - assert.Equal(t, &DonorProvidedDetails{LpaID: "an-id"}, lpa) + assert.Equal(t, &Provided{LpaID: "an-id"}, lpa) }) } } @@ -143,13 +143,13 @@ func TestDonorStoreGetWhenReferenced(t *testing.T) { dynamoClient := newMockDynamoClient(t) dynamoClient.ExpectOne(ctx, dynamo.LpaKey("an-id"), dynamo.DonorKey("456"), lpaReference{ReferencedSK: dynamo.OrganisationKey("789")}, nil) - dynamoClient.ExpectOne(ctx, dynamo.LpaKey("an-id"), dynamo.OrganisationKey("789"), &DonorProvidedDetails{LpaID: "an-id"}, expectedError) + dynamoClient.ExpectOne(ctx, dynamo.LpaKey("an-id"), dynamo.OrganisationKey("789"), &Provided{LpaID: "an-id"}, expectedError) donorStore := &donorStore{dynamoClient: dynamoClient, uuidString: func() string { return "10100000" }} lpa, err := donorStore.Get(ctx) assert.Equal(t, expectedError, err) - assert.Equal(t, &DonorProvidedDetails{LpaID: "an-id"}, lpa) + assert.Equal(t, &Provided{LpaID: "an-id"}, lpa) } func TestDonorStoreGetWithSessionMissing(t *testing.T) { @@ -175,13 +175,13 @@ func TestDonorStoreLatest(t *testing.T) { ctx := appcontext.ContextWithSessionData(context.Background(), &appcontext.SessionData{LpaID: "an-id", SessionID: "456"}) dynamoClient := newMockDynamoClient(t) - dynamoClient.ExpectLatestForActor(ctx, dynamo.DonorKey("456"), &DonorProvidedDetails{LpaID: "an-id"}, nil) + dynamoClient.ExpectLatestForActor(ctx, dynamo.DonorKey("456"), &Provided{LpaID: "an-id"}, nil) donorStore := &donorStore{dynamoClient: dynamoClient, uuidString: func() string { return "10100000" }} lpa, err := donorStore.Latest(ctx) assert.Nil(t, err) - assert.Equal(t, &DonorProvidedDetails{LpaID: "an-id"}, lpa) + assert.Equal(t, &Provided{LpaID: "an-id"}, lpa) } func TestDonorStoreLatestWithSessionMissing(t *testing.T) { @@ -195,7 +195,7 @@ func TestDonorStoreLatestWhenDataStoreError(t *testing.T) { ctx := appcontext.ContextWithSessionData(context.Background(), &appcontext.SessionData{LpaID: "an-id", SessionID: "456"}) dynamoClient := newMockDynamoClient(t) - dynamoClient.ExpectLatestForActor(ctx, dynamo.DonorKey("456"), &DonorProvidedDetails{LpaID: "an-id"}, expectedError) + dynamoClient.ExpectLatestForActor(ctx, dynamo.DonorKey("456"), &Provided{LpaID: "an-id"}, expectedError) donorStore := &donorStore{dynamoClient: dynamoClient, uuidString: func() string { return "10100000" }} @@ -209,7 +209,7 @@ func TestDonorStoreGetByKeys(t *testing.T) { {PK: dynamo.LpaKey("2"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("b"))}, {PK: dynamo.LpaKey("3"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("c"))}, } - donors := []DonorProvidedDetails{ + donors := []Provided{ {PK: dynamo.LpaKey("1"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("a")), LpaID: "1"}, {PK: dynamo.LpaKey("2"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("b")), LpaID: "2"}, {PK: dynamo.LpaKey("3"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("c")), LpaID: "3"}, @@ -253,7 +253,7 @@ func TestDonorStoreGetByKeysWhenDynamoErrors(t *testing.T) { } func TestDonorStorePut(t *testing.T) { - saved := &DonorProvidedDetails{PK: dynamo.LpaKey("5"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("an-id")), LpaID: "5", HasSentApplicationUpdatedEvent: true, Donor: Donor{FirstNames: "x", LastName: "y"}} + saved := &Provided{PK: dynamo.LpaKey("5"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("an-id")), LpaID: "5", HasSentApplicationUpdatedEvent: true, Donor: Donor{FirstNames: "x", LastName: "y"}} saved.UpdateHash() dynamoClient := newMockDynamoClient(t) @@ -263,12 +263,12 @@ func TestDonorStorePut(t *testing.T) { donorStore := &donorStore{dynamoClient: dynamoClient, now: testNowFn} - err := donorStore.Put(ctx, &DonorProvidedDetails{PK: dynamo.LpaKey("5"), Hash: 5, SK: dynamo.LpaOwnerKey(dynamo.DonorKey("an-id")), LpaID: "5", HasSentApplicationUpdatedEvent: true, Donor: Donor{FirstNames: "x", LastName: "y"}}) + err := donorStore.Put(ctx, &Provided{PK: dynamo.LpaKey("5"), Hash: 5, SK: dynamo.LpaOwnerKey(dynamo.DonorKey("an-id")), LpaID: "5", HasSentApplicationUpdatedEvent: true, Donor: Donor{FirstNames: "x", LastName: "y"}}) assert.Nil(t, err) } func TestDonorStorePutWhenUIDSet(t *testing.T) { - saved := &DonorProvidedDetails{PK: dynamo.LpaKey("5"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("an-id")), LpaID: "5", HasSentApplicationUpdatedEvent: true, LpaUID: "M", UpdatedAt: testNow, Donor: Donor{FirstNames: "x", LastName: "y"}} + saved := &Provided{PK: dynamo.LpaKey("5"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("an-id")), LpaID: "5", HasSentApplicationUpdatedEvent: true, LpaUID: "M", UpdatedAt: testNow, Donor: Donor{FirstNames: "x", LastName: "y"}} saved.UpdateHash() dynamoClient := newMockDynamoClient(t) @@ -283,7 +283,7 @@ func TestDonorStorePutWhenUIDSet(t *testing.T) { donorStore := &donorStore{dynamoClient: dynamoClient, searchClient: searchClient, now: testNowFn} - err := donorStore.Put(ctx, &DonorProvidedDetails{PK: dynamo.LpaKey("5"), Hash: 5, SK: dynamo.LpaOwnerKey(dynamo.DonorKey("an-id")), LpaID: "5", HasSentApplicationUpdatedEvent: true, LpaUID: "M", Donor: Donor{FirstNames: "x", LastName: "y"}}) + err := donorStore.Put(ctx, &Provided{PK: dynamo.LpaKey("5"), Hash: 5, SK: dynamo.LpaOwnerKey(dynamo.DonorKey("an-id")), LpaID: "5", HasSentApplicationUpdatedEvent: true, LpaUID: "M", Donor: Donor{FirstNames: "x", LastName: "y"}}) assert.Nil(t, err) } @@ -304,14 +304,14 @@ func TestDonorStorePutWhenUIDSetIndexErrors(t *testing.T) { donorStore := &donorStore{dynamoClient: dynamoClient, searchClient: searchClient, logger: logger, now: testNowFn} - err := donorStore.Put(ctx, &DonorProvidedDetails{PK: dynamo.LpaKey("5"), Hash: 5, SK: dynamo.LpaOwnerKey(dynamo.DonorKey("an-id")), LpaID: "5", HasSentApplicationUpdatedEvent: true, LpaUID: "M", Donor: Donor{FirstNames: "x", LastName: "y"}}) + err := donorStore.Put(ctx, &Provided{PK: dynamo.LpaKey("5"), Hash: 5, SK: dynamo.LpaOwnerKey(dynamo.DonorKey("an-id")), LpaID: "5", HasSentApplicationUpdatedEvent: true, LpaUID: "M", Donor: Donor{FirstNames: "x", LastName: "y"}}) assert.Nil(t, err) } func TestDonorStorePutWhenNoChange(t *testing.T) { donorStore := &donorStore{} - donor := &DonorProvidedDetails{LpaID: "an-id"} + donor := &Provided{LpaID: "an-id"} donor.Hash, _ = hashstructure.Hash(donor, hashstructure.FormatV2, nil) err := donorStore.Put(ctx, donor) @@ -319,7 +319,7 @@ func TestDonorStorePutWhenNoChange(t *testing.T) { } func TestDonorStorePutWhenCheckChangeAndCheckCompleted(t *testing.T) { - saved := &DonorProvidedDetails{PK: dynamo.LpaKey("5"), Hash: 5, CheckedHash: 5, SK: dynamo.LpaOwnerKey(dynamo.DonorKey("an-id")), LpaID: "5", HasSentApplicationUpdatedEvent: true, Donor: Donor{FirstNames: "a", LastName: "b"}, Tasks: DonorTasks{CheckYourLpa: task.StateInProgress}} + saved := &Provided{PK: dynamo.LpaKey("5"), Hash: 5, CheckedHash: 5, SK: dynamo.LpaOwnerKey(dynamo.DonorKey("an-id")), LpaID: "5", HasSentApplicationUpdatedEvent: true, Donor: Donor{FirstNames: "a", LastName: "b"}, Tasks: Tasks{CheckYourLpa: task.StateInProgress}} _ = saved.UpdateHash() dynamoClient := newMockDynamoClient(t) @@ -329,7 +329,7 @@ func TestDonorStorePutWhenCheckChangeAndCheckCompleted(t *testing.T) { donorStore := &donorStore{dynamoClient: dynamoClient, now: testNowFn} - err := donorStore.Put(ctx, &DonorProvidedDetails{PK: dynamo.LpaKey("5"), Hash: 5, CheckedHash: 5, SK: dynamo.LpaOwnerKey(dynamo.DonorKey("an-id")), LpaID: "5", HasSentApplicationUpdatedEvent: true, Donor: Donor{FirstNames: "a", LastName: "b"}, Tasks: DonorTasks{CheckYourLpa: task.StateCompleted}}) + err := donorStore.Put(ctx, &Provided{PK: dynamo.LpaKey("5"), Hash: 5, CheckedHash: 5, SK: dynamo.LpaOwnerKey(dynamo.DonorKey("an-id")), LpaID: "5", HasSentApplicationUpdatedEvent: true, Donor: Donor{FirstNames: "a", LastName: "b"}, Tasks: Tasks{CheckYourLpa: task.StateCompleted}}) assert.Nil(t, err) } @@ -339,7 +339,7 @@ func TestDonorStorePutWhenError(t *testing.T) { donorStore := &donorStore{dynamoClient: dynamoClient, now: time.Now} - err := donorStore.Put(ctx, &DonorProvidedDetails{PK: dynamo.LpaKey("5"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("an-id")), LpaID: "5"}) + err := donorStore.Put(ctx, &Provided{PK: dynamo.LpaKey("5"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("an-id")), LpaID: "5"}) assert.Equal(t, expectedError, err) } @@ -356,7 +356,7 @@ func TestDonorStorePutWhenApplicationUpdatedWhenError(t *testing.T) { donorStore := &donorStore{eventClient: eventClient, searchClient: searchClient, now: testNowFn} - err := donorStore.Put(ctx, &DonorProvidedDetails{ + err := donorStore.Put(ctx, &Provided{ PK: dynamo.LpaKey("5"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("an-id")), LpaID: "5", @@ -376,7 +376,7 @@ func TestDonorStorePutWhenApplicationUpdatedWhenError(t *testing.T) { } func TestDonorStoreCreate(t *testing.T) { - testCases := map[string]DonorProvidedDetails{ + testCases := map[string]Provided{ "with previous details": { Donor: Donor{ UID: actoruid.New(), @@ -393,7 +393,7 @@ func TestDonorStoreCreate(t *testing.T) { for name, previousDetails := range testCases { t.Run(name, func(t *testing.T) { ctx := appcontext.ContextWithSessionData(context.Background(), &appcontext.SessionData{SessionID: "an-id"}) - donor := &DonorProvidedDetails{ + donor := &Provided{ PK: dynamo.LpaKey("10100000"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("an-id")), LpaID: "10100000", @@ -444,14 +444,14 @@ func TestDonorStoreCreateWhenError(t *testing.T) { "latest": func(t *testing.T) *mockDynamoClient { dynamoClient := newMockDynamoClient(t) dynamoClient. - ExpectLatestForActor(ctx, dynamo.DonorKey("an-id"), DonorProvidedDetails{}, expectedError) + ExpectLatestForActor(ctx, dynamo.DonorKey("an-id"), Provided{}, expectedError) return dynamoClient }, "donor record": func(t *testing.T) *mockDynamoClient { dynamoClient := newMockDynamoClient(t) dynamoClient. - ExpectLatestForActor(ctx, dynamo.DonorKey("an-id"), DonorProvidedDetails{}, nil) + ExpectLatestForActor(ctx, dynamo.DonorKey("an-id"), Provided{}, nil) dynamoClient.EXPECT(). Create(ctx, mock.Anything). Return(expectedError) @@ -461,7 +461,7 @@ func TestDonorStoreCreateWhenError(t *testing.T) { "link record": func(t *testing.T) *mockDynamoClient { dynamoClient := newMockDynamoClient(t) dynamoClient. - ExpectLatestForActor(ctx, dynamo.DonorKey("an-id"), DonorProvidedDetails{}, nil) + ExpectLatestForActor(ctx, dynamo.DonorKey("an-id"), Provided{}, nil) dynamoClient.EXPECT(). Create(ctx, mock.Anything). Return(nil). @@ -511,7 +511,7 @@ func TestDonorStoreLink(t *testing.T) { for name, tc := range testcases { t.Run(name, func(t *testing.T) { ctx := appcontext.ContextWithSessionData(context.Background(), &appcontext.SessionData{SessionID: "session-id"}) - shareCode := sharecode.ShareCodeData{ + shareCode := sharecode.Data{ LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), } @@ -532,7 +532,7 @@ func TestDonorStoreLink(t *testing.T) { }, }, Puts: []any{ - sharecode.ShareCodeData{ + sharecode.Data{ LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), LpaLinkedTo: "a@example.com", @@ -559,14 +559,14 @@ func TestDonorStoreLink(t *testing.T) { func TestDonorStoreLinkWithDonor(t *testing.T) { donorStore := &donorStore{} - err := donorStore.Link(ctx, sharecode.ShareCodeData{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor"))}, "a@example.com") + err := donorStore.Link(ctx, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor"))}, "a@example.com") assert.Error(t, err) } func TestDonorStoreLinkWithSessionMissing(t *testing.T) { donorStore := &donorStore{} - err := donorStore.Link(ctx, sharecode.ShareCodeData{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org"))}, "a@example.com") + err := donorStore.Link(ctx, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org"))}, "a@example.com") assert.Equal(t, appcontext.SessionMissingError{}, err) } @@ -574,7 +574,7 @@ func TestDonorStoreLinkWithSessionIDMissing(t *testing.T) { ctx := appcontext.ContextWithSessionData(context.Background(), &appcontext.SessionData{}) donorStore := &donorStore{} - err := donorStore.Link(ctx, sharecode.ShareCodeData{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org"))}, "a@example.com") + err := donorStore.Link(ctx, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org"))}, "a@example.com") assert.Error(t, err) } @@ -589,7 +589,7 @@ func TestDonorStoreLinkWhenDonorLinkAlreadyExists(t *testing.T) { err := donorStore.Link( ctx, - sharecode.ShareCodeData{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org"))}, + sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org"))}, "a@example.com", ) @@ -614,7 +614,7 @@ func TestDonorStoreLinkWhenError(t *testing.T) { for name, setupDynamoClient := range testcases { t.Run(name, func(t *testing.T) { ctx := appcontext.ContextWithSessionData(context.Background(), &appcontext.SessionData{SessionID: "an-id"}) - shareCode := sharecode.ShareCodeData{ + shareCode := sharecode.Data{ LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), } @@ -725,7 +725,7 @@ func TestDonorStoreDeleteDonorAccess(t *testing.T) { ctx := appcontext.ContextWithSessionData(context.Background(), &appcontext.SessionData{SessionID: "an-id", OrganisationID: "org-id"}) link := temporary.LpaLink{PK: dynamo.LpaKey("lpa-id"), SK: dynamo.SubKey("donor-sub")} - shareCodeData := sharecode.ShareCodeData{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), LpaKey: dynamo.LpaKey("lpa-id")} + shareCodeData := sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), LpaKey: dynamo.LpaKey("lpa-id")} dynamoClient := newMockDynamoClient(t) dynamoClient.ExpectOneByPartialSK(ctx, dynamo.LpaKey("lpa-id"), dynamo.SubKey(""), link, nil) @@ -748,7 +748,7 @@ func TestDonorStoreDeleteDonorAccess(t *testing.T) { func TestDonorStoreDeleteDonorAccessWhenDonor(t *testing.T) { donorStore := &donorStore{} - err := donorStore.DeleteDonorAccess(ctx, sharecode.ShareCodeData{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor"))}) + err := donorStore.DeleteDonorAccess(ctx, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor"))}) assert.Error(t, err) } @@ -762,7 +762,7 @@ func TestDonorStoreDeleteDonorAccessWhenSessionMissing(t *testing.T) { t.Run(name, func(t *testing.T) { donorStore := &donorStore{} - err := donorStore.DeleteDonorAccess(ctx, sharecode.ShareCodeData{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org"))}) + err := donorStore.DeleteDonorAccess(ctx, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org"))}) assert.Error(t, err) }) } @@ -773,7 +773,7 @@ func TestDonorStoreDeleteDonorAccessWhenDeleterInDifferentOrganisation(t *testin donorStore := &donorStore{} - err := donorStore.DeleteDonorAccess(ctx, sharecode.ShareCodeData{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), LpaKey: dynamo.LpaKey("lpa-id")}) + err := donorStore.DeleteDonorAccess(ctx, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), LpaKey: dynamo.LpaKey("lpa-id")}) assert.Error(t, err) } @@ -785,7 +785,7 @@ func TestDonorStoreDeleteDonorAccessWhenOneByPartialSKError(t *testing.T) { donorStore := &donorStore{dynamoClient: dynamoClient} - err := donorStore.DeleteDonorAccess(ctx, sharecode.ShareCodeData{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), LpaKey: dynamo.LpaKey("lpa-id")}) + err := donorStore.DeleteDonorAccess(ctx, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), LpaKey: dynamo.LpaKey("lpa-id")}) assert.Error(t, err) } @@ -800,6 +800,6 @@ func TestDonorStoreDeleteDonorAccessWhenWriteTransactionError(t *testing.T) { donorStore := &donorStore{dynamoClient: dynamoClient} - err := donorStore.DeleteDonorAccess(ctx, sharecode.ShareCodeData{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), LpaKey: dynamo.LpaKey("lpa-id")}) + err := donorStore.DeleteDonorAccess(ctx, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), LpaKey: dynamo.LpaKey("lpa-id")}) assert.Error(t, err) } diff --git a/internal/donor/donordata/voucher.go b/internal/donor/donordata/voucher.go index 9e1f11f1ff..d280abe763 100644 --- a/internal/donor/donordata/voucher.go +++ b/internal/donor/donordata/voucher.go @@ -17,7 +17,7 @@ func (v Voucher) FullName() string { return v.FirstNames + " " + v.LastName } -func (v Voucher) Matches(donor *DonorProvidedDetails) (match []temporary.ActorType) { +func (v Voucher) Matches(donor *Provided) (match []temporary.ActorType) { if v.FirstNames == "" && v.LastName == "" { return nil } diff --git a/internal/donor/donordata/voucher_test.go b/internal/donor/donordata/voucher_test.go index aabe413fe9..a64eb67c14 100644 --- a/internal/donor/donordata/voucher_test.go +++ b/internal/donor/donordata/voucher_test.go @@ -12,7 +12,7 @@ func TestVoucherFullName(t *testing.T) { } func TestVoucherMatches(t *testing.T) { - donor := &DonorProvidedDetails{ + donor := &Provided{ Donor: Donor{FirstNames: "a", LastName: "b"}, Attorneys: Attorneys{Attorneys: []Attorney{ {FirstNames: "c", LastName: "d"}, @@ -45,7 +45,7 @@ func TestVoucherMatches(t *testing.T) { } func TestVoucherMatchesMultiple(t *testing.T) { - donor := &DonorProvidedDetails{ + donor := &Provided{ Donor: Donor{FirstNames: "a", LastName: "b"}, Attorneys: Attorneys{Attorneys: []Attorney{ {FirstNames: "a", LastName: "b"}, @@ -70,7 +70,7 @@ func TestVoucherMatchesMultiple(t *testing.T) { } func TestVoucherMatchesEmptyNamesIgnored(t *testing.T) { - donor := &DonorProvidedDetails{ + donor := &Provided{ Donor: Donor{FirstNames: "", LastName: ""}, Attorneys: Attorneys{Attorneys: []Attorney{ {FirstNames: "", LastName: ""}, diff --git a/internal/donor/donorpage/add_correspondent.go b/internal/donor/donorpage/add_correspondent.go index 2c89dfe68b..ab55e19458 100644 --- a/internal/donor/donorpage/add_correspondent.go +++ b/internal/donor/donorpage/add_correspondent.go @@ -4,10 +4,10 @@ import ( "net/http" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -15,11 +15,11 @@ type addCorrespondentData struct { App page.AppData Errors validation.List Form *form.YesNoForm - Donor *donordata.DonorProvidedDetails + Donor *donordata.Provided } func AddCorrespondent(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &addCorrespondentData{ App: appData, Donor: donor, @@ -36,11 +36,11 @@ func AddCorrespondent(tmpl template.Template, donorStore DonorStore) Handler { var redirectUrl page.LpaPath if donor.AddCorrespondent.IsNo() { donor.Correspondent = donordata.Correspondent{} - donor.Tasks.AddCorrespondent = actor.TaskCompleted + donor.Tasks.AddCorrespondent = task.StateCompleted redirectUrl = page.Paths.TaskList } else { if donor.Correspondent.FirstNames == "" { - donor.Tasks.AddCorrespondent = actor.TaskInProgress + donor.Tasks.AddCorrespondent = task.StateInProgress } redirectUrl = page.Paths.EnterCorrespondentDetails } diff --git a/internal/donor/donorpage/add_correspondent_test.go b/internal/donor/donorpage/add_correspondent_test.go index 40724782ce..1d24229cdf 100644 --- a/internal/donor/donorpage/add_correspondent_test.go +++ b/internal/donor/donorpage/add_correspondent_test.go @@ -7,10 +7,10 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -24,12 +24,12 @@ func TestGetAddCorrespondent(t *testing.T) { template.EXPECT(). Execute(w, &addCorrespondentData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{}, + Donor: &donordata.Provided{}, Form: form.NewYesNoForm(form.YesNoUnknown), }). Return(nil) - err := AddCorrespondent(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := AddCorrespondent(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -44,12 +44,12 @@ func TestGetAddCorrespondentFromStore(t *testing.T) { template.EXPECT(). Execute(w, &addCorrespondentData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{AddCorrespondent: form.Yes}, + Donor: &donordata.Provided{AddCorrespondent: form.Yes}, Form: form.NewYesNoForm(form.Yes), }). Return(nil) - err := AddCorrespondent(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{AddCorrespondent: form.Yes}) + err := AddCorrespondent(template.Execute, nil)(testAppData, w, r, &donordata.Provided{AddCorrespondent: form.Yes}) resp := w.Result() assert.Nil(t, err) @@ -65,7 +65,7 @@ func TestGetAddCorrespondentWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := AddCorrespondent(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := AddCorrespondent(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -76,40 +76,40 @@ func TestPostAddCorrespondent(t *testing.T) { testCases := map[string]struct { yesNo form.YesNo existingCorrespondent donordata.Correspondent - existingTaskState actor.TaskState + existingTaskState task.State expectedCorrespondent donordata.Correspondent - expectedTaskState actor.TaskState + expectedTaskState task.State redirect page.LpaPath }{ "yes was yes": { yesNo: form.Yes, existingCorrespondent: donordata.Correspondent{FirstNames: "John"}, - existingTaskState: actor.TaskCompleted, + existingTaskState: task.StateCompleted, expectedCorrespondent: donordata.Correspondent{FirstNames: "John"}, - expectedTaskState: actor.TaskCompleted, + expectedTaskState: task.StateCompleted, redirect: page.Paths.EnterCorrespondentDetails, }, "yes was no": { yesNo: form.Yes, - existingTaskState: actor.TaskCompleted, - expectedTaskState: actor.TaskInProgress, + existingTaskState: task.StateCompleted, + expectedTaskState: task.StateInProgress, redirect: page.Paths.EnterCorrespondentDetails, }, "yes": { yesNo: form.Yes, - expectedTaskState: actor.TaskInProgress, + expectedTaskState: task.StateInProgress, redirect: page.Paths.EnterCorrespondentDetails, }, "no was yes": { yesNo: form.No, existingCorrespondent: donordata.Correspondent{FirstNames: "John"}, - existingTaskState: actor.TaskCompleted, - expectedTaskState: actor.TaskCompleted, + existingTaskState: task.StateCompleted, + expectedTaskState: task.StateCompleted, redirect: page.Paths.TaskList, }, "no": { yesNo: form.No, - expectedTaskState: actor.TaskCompleted, + expectedTaskState: task.StateCompleted, redirect: page.Paths.TaskList, }, } @@ -126,18 +126,18 @@ func TestPostAddCorrespondent(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", AddCorrespondent: tc.yesNo, Correspondent: tc.expectedCorrespondent, - Tasks: donordata.DonorTasks{AddCorrespondent: tc.expectedTaskState}, + Tasks: donordata.Tasks{AddCorrespondent: tc.expectedTaskState}, }). Return(nil) - err := AddCorrespondent(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := AddCorrespondent(nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Correspondent: tc.existingCorrespondent, - Tasks: donordata.DonorTasks{AddCorrespondent: tc.existingTaskState}, + Tasks: donordata.Tasks{AddCorrespondent: tc.existingTaskState}, }) resp := w.Result() @@ -162,7 +162,7 @@ func TestPostAddCorrespondentWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := AddCorrespondent(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := AddCorrespondent(nil, donorStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -179,7 +179,7 @@ func TestPostAddCorrespondentWhenValidationErrors(t *testing.T) { })). Return(nil) - err := AddCorrespondent(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := AddCorrespondent(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/are_you_applying_for_fee_discount_or_exemption.go b/internal/donor/donorpage/are_you_applying_for_fee_discount_or_exemption.go index 010d6c8723..11fdcc5c60 100644 --- a/internal/donor/donorpage/are_you_applying_for_fee_discount_or_exemption.go +++ b/internal/donor/donorpage/are_you_applying_for_fee_discount_or_exemption.go @@ -19,7 +19,7 @@ type areYouApplyingForFeeDiscountOrExemptionData struct { } func AreYouApplyingForFeeDiscountOrExemption(tmpl template.Template, payer Handler, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &areYouApplyingForFeeDiscountOrExemptionData{ App: appData, CertificateProvider: donor.CertificateProvider, diff --git a/internal/donor/donorpage/are_you_applying_for_fee_discount_or_exemption_test.go b/internal/donor/donorpage/are_you_applying_for_fee_discount_or_exemption_test.go index 0767aa55d8..f4ac5c574f 100644 --- a/internal/donor/donorpage/are_you_applying_for_fee_discount_or_exemption_test.go +++ b/internal/donor/donorpage/are_you_applying_for_fee_discount_or_exemption_test.go @@ -28,7 +28,7 @@ func TestGetAreYouApplyingForFeeDiscountOrExemption(t *testing.T) { }). Return(nil) - err := AreYouApplyingForFeeDiscountOrExemption(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := AreYouApplyingForFeeDiscountOrExemption(template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -47,7 +47,7 @@ func TestGetAreYouApplyingForFeeDiscountOrExemptionWhenTemplateErrors(t *testing }). Return(expectedError) - err := AreYouApplyingForFeeDiscountOrExemption(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := AreYouApplyingForFeeDiscountOrExemption(template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -63,7 +63,7 @@ func TestPostAreYouApplyingForFeeDiscountOrExemption(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - donor := &donordata.DonorProvidedDetails{LpaID: "lpa-id", Donor: donordata.Donor{Email: "a@b.com"}} + donor := &donordata.Provided{LpaID: "lpa-id", Donor: donordata.Donor{Email: "a@b.com"}} payer := newMockHandler(t) payer.EXPECT(). @@ -72,10 +72,10 @@ func TestPostAreYouApplyingForFeeDiscountOrExemption(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{Email: "a@b.com"}, - Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateInProgress}, + Tasks: donordata.Tasks{PayForLpa: task.PaymentStateInProgress}, }). Return(nil) @@ -97,7 +97,7 @@ func TestPostAreYouApplyingForFeeDiscountOrExemptionWhenDonorStoreErrors(t *test Put(r.Context(), mock.Anything). Return(expectedError) - err := AreYouApplyingForFeeDiscountOrExemption(nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := AreYouApplyingForFeeDiscountOrExemption(nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -120,7 +120,7 @@ func TestPostAreYouApplyingForFeeDiscountOrExemptionWhenPayerErrors(t *testing.T Put(r.Context(), mock.Anything). Return(nil) - err := AreYouApplyingForFeeDiscountOrExemption(nil, payer.Execute, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := AreYouApplyingForFeeDiscountOrExemption(nil, payer.Execute, donorStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -135,14 +135,14 @@ func TestPostAreYouApplyingForFeeDiscountOrExemptionWhenYes(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{Email: "a@b.com"}, - Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateInProgress}, + Tasks: donordata.Tasks{PayForLpa: task.PaymentStateInProgress}, }). Return(nil) - err := AreYouApplyingForFeeDiscountOrExemption(nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", Donor: donordata.Donor{Email: "a@b.com"}}) + err := AreYouApplyingForFeeDiscountOrExemption(nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", Donor: donordata.Donor{Email: "a@b.com"}}) resp := w.Result() assert.Nil(t, err) @@ -168,7 +168,7 @@ func TestPostAreYouApplyingForFeeDiscountOrExemptionWhenValidationError(t *testi })). Return(nil) - err := AreYouApplyingForFeeDiscountOrExemption(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", Donor: donordata.Donor{Email: "a@b.com"}}) + err := AreYouApplyingForFeeDiscountOrExemption(template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", Donor: donordata.Donor{Email: "a@b.com"}}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/can_you_sign_your_lpa.go b/internal/donor/donorpage/can_you_sign_your_lpa.go index 2fde767a14..24b2876590 100644 --- a/internal/donor/donorpage/can_you_sign_your_lpa.go +++ b/internal/donor/donorpage/can_you_sign_your_lpa.go @@ -19,7 +19,7 @@ type canYouSignYourLpaData struct { } func CanYouSignYourLpa(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &canYouSignYourLpaData{ App: appData, Form: &canYouSignYourLpaForm{ diff --git a/internal/donor/donorpage/can_you_sign_your_lpa_test.go b/internal/donor/donorpage/can_you_sign_your_lpa_test.go index 715e14d2aa..8bc8b21e17 100644 --- a/internal/donor/donorpage/can_you_sign_your_lpa_test.go +++ b/internal/donor/donorpage/can_you_sign_your_lpa_test.go @@ -28,7 +28,7 @@ func TestGetCanYouSignYourLpa(t *testing.T) { }). Return(nil) - err := CanYouSignYourLpa(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := CanYouSignYourLpa(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -44,7 +44,7 @@ func TestGetCanYouSignYourLpaWhenTemplateErrors(t *testing.T) { On("Execute", w, mock.Anything). Return(expectedError) - err := CanYouSignYourLpa(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := CanYouSignYourLpa(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -96,13 +96,13 @@ func TestPostCanYouSignYourLpa(t *testing.T) { donorStore := newMockDonorStore(t) donorStore. - On("Put", r.Context(), &donordata.DonorProvidedDetails{ + On("Put", r.Context(), &donordata.Provided{ LpaID: "lpa-id", Donor: tc.person, }). Return(nil) - err := CanYouSignYourLpa(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := CanYouSignYourLpa(nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", }) resp := w.Result() @@ -130,7 +130,7 @@ func TestPostCanYouSignYourLpaWhenValidationError(t *testing.T) { })). Return(nil) - err := CanYouSignYourLpa(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := CanYouSignYourLpa(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -151,7 +151,7 @@ func TestPostCanYouSignYourLpaWhenStoreErrors(t *testing.T) { On("Put", r.Context(), mock.Anything). Return(expectedError) - err := CanYouSignYourLpa(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := CanYouSignYourLpa(nil, donorStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } diff --git a/internal/donor/donorpage/certificate_provider_address.go b/internal/donor/donorpage/certificate_provider_address.go index 9bb31c6664..e176383606 100644 --- a/internal/donor/donorpage/certificate_provider_address.go +++ b/internal/donor/donorpage/certificate_provider_address.go @@ -4,15 +4,15 @@ import ( "net/http" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" ) func CertificateProviderAddress(logger Logger, tmpl template.Template, addressClient AddressClient, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := newChooseAddressData( appData, "certificateProvider", @@ -44,7 +44,7 @@ func CertificateProviderAddress(logger Logger, tmpl template.Template, addressCl setAddress := func(address place.Address) error { donor.CertificateProvider.Address = *data.Form.Address - donor.Tasks.CertificateProvider = actor.TaskCompleted + donor.Tasks.CertificateProvider = task.StateCompleted if err := donorStore.Put(r.Context(), donor); err != nil { return err diff --git a/internal/donor/donorpage/certificate_provider_address_test.go b/internal/donor/donorpage/certificate_provider_address_test.go index 9019dafb30..b456d9ae80 100644 --- a/internal/donor/donorpage/certificate_provider_address_test.go +++ b/internal/donor/donorpage/certificate_provider_address_test.go @@ -8,11 +8,11 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -39,7 +39,7 @@ func TestGetCertificateProviderAddress(t *testing.T) { }). Return(nil) - err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{CertificateProvider: certificateProvider}) + err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{CertificateProvider: certificateProvider}) resp := w.Result() assert.Nil(t, err) @@ -74,7 +74,7 @@ func TestGetCertificateProviderAddressWhenProfessionalCertificateProvider(t *tes }). Return(nil) - err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{CertificateProvider: certificateProvider}) + err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{CertificateProvider: certificateProvider}) resp := w.Result() assert.Nil(t, err) @@ -104,7 +104,7 @@ func TestGetCertificateProviderAddressFromStore(t *testing.T) { }). Return(nil) - err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{CertificateProvider: certificateProvider}) + err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{CertificateProvider: certificateProvider}) resp := w.Result() assert.Nil(t, err) @@ -134,7 +134,7 @@ func TestGetCertificateProviderAddressManual(t *testing.T) { }). Return(nil) - err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{CertificateProvider: certificateProvider}) + err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{CertificateProvider: certificateProvider}) resp := w.Result() assert.Nil(t, err) @@ -156,7 +156,7 @@ func TestGetCertificateProviderAddressWhenTemplateErrors(t *testing.T) { }). Return(expectedError) - err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -179,14 +179,14 @@ func TestPostCertificateProviderAddressManual(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", CertificateProvider: donordata.CertificateProvider{Address: testAddress}, - Tasks: donordata.DonorTasks{CertificateProvider: actor.TaskCompleted}, + Tasks: donordata.Tasks{CertificateProvider: task.StateCompleted}, }). Return(nil) - err := CertificateProviderAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) + err := CertificateProviderAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id"}) resp := w.Result() assert.Nil(t, err) @@ -210,13 +210,13 @@ func TestPostCertificateProviderAddressManualWhenStoreErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ CertificateProvider: donordata.CertificateProvider{Address: testAddress}, - Tasks: donordata.DonorTasks{CertificateProvider: actor.TaskCompleted}, + Tasks: donordata.Tasks{CertificateProvider: task.StateCompleted}, }). Return(expectedError) - err := CertificateProviderAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := CertificateProviderAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -237,17 +237,17 @@ func TestPostCertificateProviderAddressManualFromStore(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", CertificateProvider: donordata.CertificateProvider{ FirstNames: "John", Address: testAddress, }, - Tasks: donordata.DonorTasks{CertificateProvider: actor.TaskCompleted}, + Tasks: donordata.Tasks{CertificateProvider: task.StateCompleted}, }). Return(nil) - err := CertificateProviderAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := CertificateProviderAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", CertificateProvider: donordata.CertificateProvider{ FirstNames: "John", @@ -296,7 +296,7 @@ func TestPostCertificateProviderAddressManualWhenValidationError(t *testing.T) { }). Return(nil) - err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -330,7 +330,7 @@ func TestPostCertificateProviderPostcodeSelect(t *testing.T) { }). Return(nil) - err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -373,7 +373,7 @@ func TestPostCertificateProviderPostcodeSelectWhenValidationError(t *testing.T) }). Return(nil) - err := CertificateProviderAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := CertificateProviderAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -415,7 +415,7 @@ func TestPostCertificateProviderPostcodeLookup(t *testing.T) { }). Return(nil) - err := CertificateProviderAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := CertificateProviderAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -458,7 +458,7 @@ func TestPostCertificateProviderPostcodeLookupError(t *testing.T) { }). Return(nil) - err := CertificateProviderAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := CertificateProviderAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -506,7 +506,7 @@ func TestPostCertificateProviderPostcodeLookupInvalidPostcodeError(t *testing.T) }). Return(nil) - err := CertificateProviderAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := CertificateProviderAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -548,7 +548,7 @@ func TestPostCertificateProviderPostcodeLookupValidPostcodeNoAddresses(t *testin }). Return(nil) - err := CertificateProviderAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := CertificateProviderAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -579,7 +579,7 @@ func TestPostCertificateProviderPostcodeLookupWhenValidationError(t *testing.T) }). Return(nil) - err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -609,7 +609,7 @@ func TestPostCertificateProviderAddressReuse(t *testing.T) { }). Return(nil) - err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{Address: place.Address{Line1: "donor lane"}}, }) resp := w.Result() @@ -630,7 +630,7 @@ func TestPostCertificateProviderAddressReuseSelect(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", CertificateProvider: donordata.CertificateProvider{ Address: place.Address{ @@ -642,11 +642,11 @@ func TestPostCertificateProviderAddressReuseSelect(t *testing.T) { Country: "GB", }, }, - Tasks: donordata.DonorTasks{CertificateProvider: actor.TaskCompleted}, + Tasks: donordata.Tasks{CertificateProvider: task.StateCompleted}, }). Return(nil) - err := CertificateProviderAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) + err := CertificateProviderAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id"}) resp := w.Result() assert.Nil(t, err) @@ -679,7 +679,7 @@ func TestPostCertificateProviderAddressReuseSelectWhenValidationError(t *testing }). Return(nil) - err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{Address: place.Address{Line1: "donor lane"}}, }) resp := w.Result() diff --git a/internal/donor/donorpage/certificate_provider_details.go b/internal/donor/donorpage/certificate_provider_details.go index ffdb1ee6dc..db7dfbc357 100644 --- a/internal/donor/donorpage/certificate_provider_details.go +++ b/internal/donor/donorpage/certificate_provider_details.go @@ -9,6 +9,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -20,7 +21,7 @@ type certificateProviderDetailsData struct { } func CertificateProviderDetails(tmpl template.Template, donorStore DonorStore, newUID func() actoruid.UID) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &certificateProviderDetailsData{ App: appData, Form: &certificateProviderDetailsForm{ @@ -67,7 +68,7 @@ func CertificateProviderDetails(tmpl template.Template, donorStore DonorStore, n } if !donor.Tasks.CertificateProvider.Completed() { - donor.Tasks.CertificateProvider = actor.TaskInProgress + donor.Tasks.CertificateProvider = task.StateInProgress } if err := donorStore.Put(r.Context(), donor); err != nil { @@ -126,7 +127,7 @@ func (d *certificateProviderDetailsForm) Validate() validation.List { return errors } -func certificateProviderMatches(donor *donordata.DonorProvidedDetails, firstNames, lastName string) actor.Type { +func certificateProviderMatches(donor *donordata.Provided, firstNames, lastName string) actor.Type { if firstNames == "" && lastName == "" { return actor.TypeNone } diff --git a/internal/donor/donorpage/certificate_provider_details_test.go b/internal/donor/donorpage/certificate_provider_details_test.go index 7775cca2f9..81f73896a8 100644 --- a/internal/donor/donorpage/certificate_provider_details_test.go +++ b/internal/donor/donorpage/certificate_provider_details_test.go @@ -10,6 +10,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -27,7 +28,7 @@ func TestGetCertificateProviderDetails(t *testing.T) { }). Return(nil) - err := CertificateProviderDetails(template.Execute, nil, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := CertificateProviderDetails(template.Execute, nil, testUIDFn)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -36,11 +37,11 @@ func TestGetCertificateProviderDetails(t *testing.T) { func TestGetCertificateProviderDetailsFromStore(t *testing.T) { testcases := map[string]struct { - donor *donordata.DonorProvidedDetails + donor *donordata.Provided form *certificateProviderDetailsForm }{ "uk mobile": { - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ CertificateProvider: donordata.CertificateProvider{ FirstNames: "John", Mobile: "07777", @@ -52,7 +53,7 @@ func TestGetCertificateProviderDetailsFromStore(t *testing.T) { }, }, "non-uk mobile": { - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ CertificateProvider: donordata.CertificateProvider{ FirstNames: "John", Mobile: "07777", @@ -101,7 +102,7 @@ func TestGetCertificateProviderDetailsWhenTemplateErrors(t *testing.T) { }). Return(expectedError) - err := CertificateProviderDetails(template.Execute, nil, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := CertificateProviderDetails(template.Execute, nil, testUIDFn)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -179,18 +180,18 @@ func TestPostCertificateProviderDetails(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{ FirstNames: "Jane", LastName: "Doe", }, CertificateProvider: tc.certificateProviderDetails, - Tasks: donordata.DonorTasks{CertificateProvider: actor.TaskInProgress}, + Tasks: donordata.Tasks{CertificateProvider: task.StateInProgress}, }). Return(nil) - err := CertificateProviderDetails(nil, donorStore, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := CertificateProviderDetails(nil, donorStore, testUIDFn)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{ FirstNames: "Jane", @@ -219,7 +220,7 @@ func TestPostCertificateProviderDetailsWhenAmendingDetailsAfterStateComplete(t * donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{ FirstNames: "Jane", @@ -231,17 +232,17 @@ func TestPostCertificateProviderDetailsWhenAmendingDetailsAfterStateComplete(t * LastName: "Rey", Mobile: "07535111111", }, - Tasks: donordata.DonorTasks{CertificateProvider: actor.TaskCompleted}, + Tasks: donordata.Tasks{CertificateProvider: task.StateCompleted}, }). Return(nil) - err := CertificateProviderDetails(nil, donorStore, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := CertificateProviderDetails(nil, donorStore, testUIDFn)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{ FirstNames: "Jane", LastName: "Doe", }, - Tasks: donordata.DonorTasks{CertificateProvider: actor.TaskCompleted}, + Tasks: donordata.Tasks{CertificateProvider: task.StateCompleted}, }) resp := w.Result() @@ -253,7 +254,7 @@ func TestPostCertificateProviderDetailsWhenAmendingDetailsAfterStateComplete(t * func TestPostCertificateProviderDetailsWhenInputRequired(t *testing.T) { testCases := map[string]struct { form url.Values - existingDonor *donordata.DonorProvidedDetails + existingDonor *donordata.Provided dataMatcher func(t *testing.T, data *certificateProviderDetailsData) bool }{ "validation error": { @@ -261,7 +262,7 @@ func TestPostCertificateProviderDetailsWhenInputRequired(t *testing.T) { "last-name": {"Doe"}, "mobile": {"07535111111"}, }, - existingDonor: &donordata.DonorProvidedDetails{}, + existingDonor: &donordata.Provided{}, dataMatcher: func(t *testing.T, data *certificateProviderDetailsData) bool { return assert.Equal(t, validation.With("first-names", validation.EnterError{Label: "firstNames"}), data.Errors) }, @@ -272,7 +273,7 @@ func TestPostCertificateProviderDetailsWhenInputRequired(t *testing.T) { "last-name": {"Doe"}, "mobile": {"07535111111"}, }, - existingDonor: &donordata.DonorProvidedDetails{ + existingDonor: &donordata.Provided{ Donor: donordata.Donor{ FirstNames: "John", LastName: "Doe", @@ -288,7 +289,7 @@ func TestPostCertificateProviderDetailsWhenInputRequired(t *testing.T) { "last-name": {"Doe"}, "ignore-name-warning": {"errorDonorMatchesActor|theCertificateProvider|John|Doe"}, }, - existingDonor: &donordata.DonorProvidedDetails{ + existingDonor: &donordata.Provided{ Donor: donordata.Donor{ FirstNames: "John", LastName: "Doe", @@ -305,7 +306,7 @@ func TestPostCertificateProviderDetailsWhenInputRequired(t *testing.T) { "mobile": {"07535111111"}, "ignore-name-warning": {"errorAttorneyMatchesActor|theCertificateProvider|John|Doe"}, }, - existingDonor: &donordata.DonorProvidedDetails{ + existingDonor: &donordata.Provided{ Donor: donordata.Donor{ FirstNames: "John", LastName: "Doe", @@ -355,7 +356,7 @@ func TestPostCertificateProviderDetailsWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := CertificateProviderDetails(nil, donorStore, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := CertificateProviderDetails(nil, donorStore, testUIDFn)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -436,7 +437,7 @@ func TestCertificateProviderDetailsFormValidate(t *testing.T) { } func TestCertificateProviderMatches(t *testing.T) { - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "c", LastName: "d"}, @@ -469,7 +470,7 @@ func TestCertificateProviderMatches(t *testing.T) { } func TestCertificateProviderMatchesEmptyNamesIgnored(t *testing.T) { - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ Donor: donordata.Donor{FirstNames: "", LastName: ""}, Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "", LastName: ""}, diff --git a/internal/donor/donorpage/change_mobile_number.go b/internal/donor/donorpage/change_mobile_number.go index 1af88fa2f7..9cce2526a6 100644 --- a/internal/donor/donorpage/change_mobile_number.go +++ b/internal/donor/donorpage/change_mobile_number.go @@ -21,7 +21,7 @@ type changeMobileNumberData struct { } func ChangeMobileNumber(tmpl template.Template, witnessCodeSender WitnessCodeSender, actorType actor.Type) Handler { - var send func(context.Context, *donordata.DonorProvidedDetails, page.Localizer) error + var send func(context.Context, *donordata.Provided, page.Localizer) error var redirect page.LpaPath switch actorType { case actor.TypeIndependentWitness: @@ -34,7 +34,7 @@ func ChangeMobileNumber(tmpl template.Template, witnessCodeSender WitnessCodeSen panic("ChangeMobileNumber only supports IndependentWitness or CertificateProvider actors") } - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &changeMobileNumberData{ App: appData, Form: &changeMobileNumberForm{}, diff --git a/internal/donor/donorpage/change_mobile_number_test.go b/internal/donor/donorpage/change_mobile_number_test.go index b18cd03279..b0862f265c 100644 --- a/internal/donor/donorpage/change_mobile_number_test.go +++ b/internal/donor/donorpage/change_mobile_number_test.go @@ -35,7 +35,7 @@ func TestGetChangeMobileNumber(t *testing.T) { }). Return(nil) - err := ChangeMobileNumber(template.Execute, newMockWitnessCodeSender(t), actorType)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChangeMobileNumber(template.Execute, newMockWitnessCodeSender(t), actorType)(testAppData, w, r, &donordata.Provided{ CertificateProvider: donordata.CertificateProvider{FirstNames: "Certificate", LastName: "Provided"}, IndependentWitness: donordata.IndependentWitness{FirstNames: "Independent", LastName: "Witness"}, }) @@ -49,11 +49,11 @@ func TestGetChangeMobileNumber(t *testing.T) { func TestGetChangeMobileNumberFromStore(t *testing.T) { testcases := map[string]struct { - donor *donordata.DonorProvidedDetails + donor *donordata.Provided actorType actor.Type }{ "certificate provider uk mobile": { - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ CertificateProvider: donordata.CertificateProvider{ Mobile: "07777", }, @@ -61,7 +61,7 @@ func TestGetChangeMobileNumberFromStore(t *testing.T) { actorType: actor.TypeCertificateProvider, }, "certificate provider non-uk mobile": { - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ CertificateProvider: donordata.CertificateProvider{ Mobile: "07777", HasNonUKMobile: true, @@ -70,7 +70,7 @@ func TestGetChangeMobileNumberFromStore(t *testing.T) { actorType: actor.TypeCertificateProvider, }, "independent witness uk mobile": { - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ IndependentWitness: donordata.IndependentWitness{ Mobile: "07777", }, @@ -78,7 +78,7 @@ func TestGetChangeMobileNumberFromStore(t *testing.T) { actorType: actor.TypeIndependentWitness, }, "independent witness non-uk mobile": { - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ IndependentWitness: donordata.IndependentWitness{ Mobile: "07777", HasNonUKMobile: true, @@ -120,7 +120,7 @@ func TestGetChangeMobileNumberWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := ChangeMobileNumber(template.Execute, newMockWitnessCodeSender(t), actor.TypeCertificateProvider)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := ChangeMobileNumber(template.Execute, newMockWitnessCodeSender(t), actor.TypeCertificateProvider)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -131,7 +131,7 @@ func TestPostChangeMobileNumber(t *testing.T) { testCases := map[string]struct { form url.Values actorType actor.Type - donor *donordata.DonorProvidedDetails + donor *donordata.Provided send string redirect page.LpaPath }{ @@ -140,7 +140,7 @@ func TestPostChangeMobileNumber(t *testing.T) { "mobile": {"07535111111"}, }, actorType: actor.TypeCertificateProvider, - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ LpaID: "lpa-id", CertificateProvider: donordata.CertificateProvider{ Mobile: "07535111111", @@ -156,7 +156,7 @@ func TestPostChangeMobileNumber(t *testing.T) { "non-uk-mobile": {"+337575757"}, }, actorType: actor.TypeCertificateProvider, - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ LpaID: "lpa-id", CertificateProvider: donordata.CertificateProvider{ Mobile: "+337575757", @@ -172,7 +172,7 @@ func TestPostChangeMobileNumber(t *testing.T) { "mobile": {"07535111111"}, }, actorType: actor.TypeIndependentWitness, - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ LpaID: "lpa-id", IndependentWitness: donordata.IndependentWitness{ Mobile: "07535111111", @@ -188,7 +188,7 @@ func TestPostChangeMobileNumber(t *testing.T) { "non-uk-mobile": {"+337575757"}, }, actorType: actor.TypeIndependentWitness, - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ LpaID: "lpa-id", IndependentWitness: donordata.IndependentWitness{ Mobile: "+337575757", @@ -212,7 +212,7 @@ func TestPostChangeMobileNumber(t *testing.T) { On(tc.send, r.Context(), tc.donor, testAppData.Localizer). Return(nil) - err := ChangeMobileNumber(nil, witnessCodeSender, tc.actorType)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChangeMobileNumber(nil, witnessCodeSender, tc.actorType)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, }) @@ -239,7 +239,7 @@ func TestPostChangeMobileNumberWhenSendErrors(t *testing.T) { SendToCertificateProvider(mock.Anything, mock.Anything, mock.Anything). Return(expectedError) - err := ChangeMobileNumber(nil, witnessCodeSender, actor.TypeCertificateProvider)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) + err := ChangeMobileNumber(nil, witnessCodeSender, actor.TypeCertificateProvider)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id"}) assert.Equal(t, expectedError, err) } @@ -264,7 +264,7 @@ func TestPostChangeMobileNumberWhenSendErrorsWithTooManyRequests(t *testing.T) { })). Return(nil) - err := ChangeMobileNumber(template.Execute, witnessCodeSender, actor.TypeCertificateProvider)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) + err := ChangeMobileNumber(template.Execute, witnessCodeSender, actor.TypeCertificateProvider)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id"}) resp := w.Result() assert.Nil(t, err) @@ -287,7 +287,7 @@ func TestPostChangeMobileNumberWhenValidationError(t *testing.T) { })). Return(nil) - err := ChangeMobileNumber(template.Execute, newMockWitnessCodeSender(t), actor.TypeCertificateProvider)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := ChangeMobileNumber(template.Execute, newMockWitnessCodeSender(t), actor.TypeCertificateProvider)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/check_you_can_sign.go b/internal/donor/donorpage/check_you_can_sign.go index 911b541e5a..5c28b3832e 100644 --- a/internal/donor/donorpage/check_you_can_sign.go +++ b/internal/donor/donorpage/check_you_can_sign.go @@ -17,7 +17,7 @@ type checkYouCanSignData struct { } func CheckYouCanSign(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &checkYouCanSignData{ App: appData, Form: form.NewYesNoForm(donor.Donor.CanSign), diff --git a/internal/donor/donorpage/check_you_can_sign_test.go b/internal/donor/donorpage/check_you_can_sign_test.go index 94df922a00..2fe56545f6 100644 --- a/internal/donor/donorpage/check_you_can_sign_test.go +++ b/internal/donor/donorpage/check_you_can_sign_test.go @@ -28,7 +28,7 @@ func TestGetCheckYouCanSign(t *testing.T) { }). Return(nil) - err := CheckYouCanSign(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := CheckYouCanSign(template.Execute, nil)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{CanSign: form.No}, }) @@ -57,10 +57,10 @@ func TestPostCheckYouCanSign(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{LpaID: "lpa-id", Donor: donordata.Donor{CanSign: yesNo}}). + Put(r.Context(), &donordata.Provided{LpaID: "lpa-id", Donor: donordata.Donor{CanSign: yesNo}}). Return(nil) - err := CheckYouCanSign(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) + err := CheckYouCanSign(nil, donorStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id"}) resp := w.Result() @@ -85,7 +85,7 @@ func TestPostCheckYouCanSignErrorOnPutStore(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := CheckYouCanSign(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := CheckYouCanSign(nil, donorStore)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() @@ -111,7 +111,7 @@ func TestCheckYouCanSignFormValidation(t *testing.T) { })). Return(nil) - err := CheckYouCanSign(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := CheckYouCanSign(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/check_your_details.go b/internal/donor/donorpage/check_your_details.go index f69427bd04..cdb2449f85 100644 --- a/internal/donor/donorpage/check_your_details.go +++ b/internal/donor/donorpage/check_your_details.go @@ -12,11 +12,11 @@ import ( type checkYourDetailsData struct { App page.AppData Errors validation.List - Donor *donordata.DonorProvidedDetails + Donor *donordata.Provided } func CheckYourDetails(tmpl template.Template) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { if r.Method == http.MethodPost { if !donor.Tasks.PayForLpa.IsCompleted() { return page.Paths.WeHaveReceivedVoucherDetails.Redirect(w, r, appData, donor) diff --git a/internal/donor/donorpage/check_your_details_test.go b/internal/donor/donorpage/check_your_details_test.go index ba0cc1c6ca..38c96f266f 100644 --- a/internal/donor/donorpage/check_your_details_test.go +++ b/internal/donor/donorpage/check_your_details_test.go @@ -15,7 +15,7 @@ func TestGetCheckYourDetails(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &donordata.DonorProvidedDetails{} + donor := &donordata.Provided{} template := newMockTemplate(t) template.EXPECT(). @@ -35,10 +35,10 @@ func TestGetCheckYourDetailsWhenTemplateErrors(t *testing.T) { template := newMockTemplate(t) template.EXPECT(). - Execute(w, &checkYourDetailsData{App: testAppData, Donor: &donordata.DonorProvidedDetails{}}). + Execute(w, &checkYourDetailsData{App: testAppData, Donor: &donordata.Provided{}}). Return(expectedError) - err := CheckYourDetails(template.Execute)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := CheckYourDetails(template.Execute)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -47,9 +47,9 @@ func TestPostCheckYourDetails(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodPost, "/", nil) - err := CheckYourDetails(nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := CheckYourDetails(nil)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", - Tasks: donordata.DonorTasks{ + Tasks: donordata.Tasks{ PayForLpa: task.PaymentStateCompleted, }, }) @@ -64,7 +64,7 @@ func TestPostCheckYourDetailsWhenUnpaid(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodPost, "/", nil) - err := CheckYourDetails(nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) + err := CheckYourDetails(nil)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id"}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/check_your_lpa.go b/internal/donor/donorpage/check_your_lpa.go index 0ce75f51e5..1e4b3d8ea5 100644 --- a/internal/donor/donorpage/check_your_lpa.go +++ b/internal/donor/donorpage/check_your_lpa.go @@ -8,19 +8,19 @@ import ( "time" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) type checkYourLpaData struct { App page.AppData Errors validation.List - Donor *donordata.DonorProvidedDetails + Donor *donordata.Provided Form *checkYourLpaForm CertificateProviderContacted bool CanContinue bool @@ -33,7 +33,7 @@ type checkYourLpaNotifier struct { appPublicURL string } -func (n *checkYourLpaNotifier) Notify(ctx context.Context, appData page.AppData, donor *donordata.DonorProvidedDetails, wasCompleted bool) error { +func (n *checkYourLpaNotifier) Notify(ctx context.Context, appData page.AppData, donor *donordata.Provided, wasCompleted bool) error { if donor.CertificateProvider.CarryOutBy.IsPaper() { return n.sendPaperNotification(ctx, appData, donor, wasCompleted) } @@ -41,7 +41,7 @@ func (n *checkYourLpaNotifier) Notify(ctx context.Context, appData page.AppData, return n.sendOnlineNotification(ctx, appData, donor, wasCompleted) } -func (n *checkYourLpaNotifier) sendPaperNotification(ctx context.Context, appData page.AppData, donor *donordata.DonorProvidedDetails, wasCompleted bool) error { +func (n *checkYourLpaNotifier) sendPaperNotification(ctx context.Context, appData page.AppData, donor *donordata.Provided, wasCompleted bool) error { var sms notify.SMS if wasCompleted { sms = notify.CertificateProviderActingOnPaperDetailsChangedSMS{ @@ -61,7 +61,7 @@ func (n *checkYourLpaNotifier) sendPaperNotification(ctx context.Context, appDat return n.notifyClient.SendActorSMS(ctx, donor.CertificateProvider.Mobile, donor.LpaUID, sms) } -func (n *checkYourLpaNotifier) sendOnlineNotification(ctx context.Context, appData page.AppData, donor *donordata.DonorProvidedDetails, wasCompleted bool) error { +func (n *checkYourLpaNotifier) sendOnlineNotification(ctx context.Context, appData page.AppData, donor *donordata.Provided, wasCompleted bool) error { if !wasCompleted { return n.shareCodeSender.SendCertificateProviderInvite(ctx, appData, page.CertificateProviderInvite{ LpaKey: donor.PK, @@ -107,7 +107,7 @@ func CheckYourLpa(tmpl template.Template, donorStore DonorStore, shareCodeSender appPublicURL: appPublicURL, } - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &checkYourLpaData{ App: appData, Donor: donor, @@ -123,7 +123,7 @@ func CheckYourLpa(tmpl template.Template, donorStore DonorStore, shareCodeSender data.Errors = data.Form.Validate() if data.Errors.None() { - donor.Tasks.CheckYourLpa = actor.TaskCompleted + donor.Tasks.CheckYourLpa = task.StateCompleted donor.CheckedAt = now() if err := donor.UpdateCheckedHash(); err != nil { return err diff --git a/internal/donor/donorpage/check_your_lpa_test.go b/internal/donor/donorpage/check_your_lpa_test.go index 00e7920028..80f75c8206 100644 --- a/internal/donor/donorpage/check_your_lpa_test.go +++ b/internal/donor/donorpage/check_your_lpa_test.go @@ -7,12 +7,12 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -27,12 +27,12 @@ func TestGetCheckYourLpa(t *testing.T) { Execute(w, &checkYourLpaData{ App: testAppData, Form: &checkYourLpaForm{}, - Donor: &donordata.DonorProvidedDetails{}, + Donor: &donordata.Provided{}, CanContinue: true, }). Return(nil) - err := CheckYourLpa(template.Execute, nil, nil, nil, nil, testNowFn, "http://example.org")(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := CheckYourLpa(template.Execute, nil, nil, nil, nil, testNowFn, "http://example.org")(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -43,7 +43,7 @@ func TestGetCheckYourLpaFromStore(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ CheckedAt: testNow, } donor.UpdateCheckedHash() @@ -76,10 +76,10 @@ func TestPostCheckYourLpaWhenNotChanged(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ LpaID: "lpa-id", CheckedAt: testNow, - Tasks: donordata.DonorTasks{CheckYourLpa: actor.TaskCompleted}, + Tasks: donordata.Tasks{CheckYourLpa: task.StateCompleted}, CertificateProvider: donordata.CertificateProvider{CarryOutBy: donordata.ChannelOnline}, } donor.UpdateCheckedHash() @@ -104,9 +104,9 @@ func TestPostCheckYourLpaWhenNotChanged(t *testing.T) { } func TestPostCheckYourLpaDigitalCertificateProviderOnFirstCheck(t *testing.T) { - testCases := []actor.TaskState{ - actor.TaskNotStarted, - actor.TaskInProgress, + testCases := []task.State{ + task.StateNotStarted, + task.StateInProgress, } for _, existingTaskState := range testCases { @@ -120,18 +120,18 @@ func TestPostCheckYourLpaDigitalCertificateProviderOnFirstCheck(t *testing.T) { r.Header.Add("Content-Type", page.FormUrlEncoded) uid := actoruid.New() - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ LpaID: "lpa-id", Hash: 5, - Tasks: donordata.DonorTasks{CheckYourLpa: existingTaskState}, + Tasks: donordata.Tasks{CheckYourLpa: existingTaskState}, CertificateProvider: donordata.CertificateProvider{UID: uid, FirstNames: "John", LastName: "Smith", Email: "john@example.com", CarryOutBy: donordata.ChannelOnline}, } - updatedDonor := &donordata.DonorProvidedDetails{ + updatedDonor := &donordata.Provided{ LpaID: "lpa-id", Hash: 5, CheckedAt: testNow, - Tasks: donordata.DonorTasks{CheckYourLpa: actor.TaskCompleted}, + Tasks: donordata.Tasks{CheckYourLpa: task.StateCompleted}, CertificateProvider: donordata.CertificateProvider{UID: uid, FirstNames: "John", LastName: "Smith", Email: "john@example.com", CarryOutBy: donordata.ChannelOnline}, } updatedDonor.UpdateCheckedHash() @@ -162,18 +162,18 @@ func TestPostCheckYourLpaDigitalCertificateProviderOnFirstCheck(t *testing.T) { func TestPostCheckYourLpaDigitalCertificateProviderOnSubsequentChecks(t *testing.T) { testCases := map[string]struct { - certificateProviderDetailsTaskState actor.TaskState + certificateProviderDetailsTaskState task.State expectedSms notify.SMS }{ "cp not started": { - certificateProviderDetailsTaskState: actor.TaskNotStarted, + certificateProviderDetailsTaskState: task.StateNotStarted, expectedSms: notify.CertificateProviderActingDigitallyHasNotConfirmedPersonalDetailsLPADetailsChangedPromptSMS{ DonorFullName: "Teneil Throssell", LpaType: "property and affairs", }, }, "cp in progress": { - certificateProviderDetailsTaskState: actor.TaskInProgress, + certificateProviderDetailsTaskState: task.StateInProgress, expectedSms: notify.CertificateProviderActingDigitallyHasConfirmedPersonalDetailsLPADetailsChangedPromptSMS{ DonorFullNamePossessive: "Teneil Throssell’s", LpaType: "property and affairs", @@ -181,7 +181,7 @@ func TestPostCheckYourLpaDigitalCertificateProviderOnSubsequentChecks(t *testing }, }, "cp completed": { - certificateProviderDetailsTaskState: actor.TaskCompleted, + certificateProviderDetailsTaskState: task.StateCompleted, expectedSms: notify.CertificateProviderActingDigitallyHasConfirmedPersonalDetailsLPADetailsChangedPromptSMS{ DonorFullNamePossessive: "Teneil Throssell’s", LpaType: "property and affairs", @@ -211,14 +211,14 @@ func TestPostCheckYourLpaDigitalCertificateProviderOnSubsequentChecks(t *testing testAppData.Localizer = localizer - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ LpaID: "lpa-id", LpaUID: "lpa-uid", Hash: 5, Type: donordata.LpaTypePropertyAndAffairs, Donor: donordata.Donor{FirstNames: "Teneil", LastName: "Throssell"}, CheckedAt: testNow, - Tasks: donordata.DonorTasks{CheckYourLpa: actor.TaskCompleted}, + Tasks: donordata.Tasks{CheckYourLpa: task.StateCompleted}, CertificateProvider: donordata.CertificateProvider{CarryOutBy: donordata.ChannelOnline, Mobile: "07700900000"}, } @@ -263,20 +263,20 @@ func TestPostCheckYourLpaDigitalCertificateProviderOnSubsequentChecksCertificate GetAny(r.Context()). Return(nil, expectedError) - err := CheckYourLpa(nil, nil, nil, nil, certificateProviderStore, testNowFn, "http://example.org")(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := CheckYourLpa(nil, nil, nil, nil, certificateProviderStore, testNowFn, "http://example.org")(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Hash: 5, Type: donordata.LpaTypePropertyAndAffairs, Donor: donordata.Donor{FirstNames: "Teneil", LastName: "Throssell"}, CheckedAt: testNow, - Tasks: donordata.DonorTasks{CheckYourLpa: actor.TaskCompleted}, + Tasks: donordata.Tasks{CheckYourLpa: task.StateCompleted}, CertificateProvider: donordata.CertificateProvider{CarryOutBy: donordata.ChannelOnline, Mobile: "07700900000"}, }) assert.Equal(t, expectedError, err) } func TestPostCheckYourLpaPaperCertificateProviderOnFirstCheck(t *testing.T) { - for _, existingTaskState := range []actor.TaskState{actor.TaskNotStarted, actor.TaskInProgress} { + for _, existingTaskState := range []task.State{task.StateNotStarted, task.StateInProgress} { t.Run(existingTaskState.String(), func(t *testing.T) { form := url.Values{ "checked-and-happy": {"1"}, @@ -293,23 +293,23 @@ func TestPostCheckYourLpaPaperCertificateProviderOnFirstCheck(t *testing.T) { testAppData.Localizer = localizer - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ LpaID: "lpa-id", LpaUID: "lpa-uid", Hash: 5, Donor: donordata.Donor{FirstNames: "Teneil", LastName: "Throssell"}, - Tasks: donordata.DonorTasks{CheckYourLpa: existingTaskState}, + Tasks: donordata.Tasks{CheckYourLpa: existingTaskState}, CertificateProvider: donordata.CertificateProvider{CarryOutBy: donordata.ChannelPaper, Mobile: "07700900000"}, Type: donordata.LpaTypePropertyAndAffairs, } - updatedDonor := &donordata.DonorProvidedDetails{ + updatedDonor := &donordata.Provided{ LpaID: "lpa-id", LpaUID: "lpa-uid", Hash: 5, Donor: donordata.Donor{FirstNames: "Teneil", LastName: "Throssell"}, CheckedAt: testNow, - Tasks: donordata.DonorTasks{CheckYourLpa: actor.TaskCompleted}, + Tasks: donordata.Tasks{CheckYourLpa: task.StateCompleted}, CertificateProvider: donordata.CertificateProvider{CarryOutBy: donordata.ChannelPaper, Mobile: "07700900000"}, Type: donordata.LpaTypePropertyAndAffairs, } @@ -349,13 +349,13 @@ func TestPostCheckYourLpaPaperCertificateProviderOnSubsequentCheck(t *testing.T) r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ LpaID: "lpa-id", LpaUID: "lpa-uid", Hash: 5, Donor: donordata.Donor{FirstNames: "Teneil", LastName: "Throssell"}, CheckedAt: testNow, - Tasks: donordata.DonorTasks{CheckYourLpa: actor.TaskCompleted}, + Tasks: donordata.Tasks{CheckYourLpa: task.StateCompleted}, CertificateProvider: donordata.CertificateProvider{CarryOutBy: donordata.ChannelPaper, Mobile: "07700900000"}, Type: donordata.LpaTypePropertyAndAffairs, } @@ -391,13 +391,13 @@ func TestPostCheckYourLpaWhenStoreErrors(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ LpaID: "lpa-id", LpaUID: "lpa-uid", Hash: 5, Donor: donordata.Donor{FirstNames: "Teneil", LastName: "Throssell"}, CheckedAt: testNow, - Tasks: donordata.DonorTasks{CheckYourLpa: actor.TaskCompleted}, + Tasks: donordata.Tasks{CheckYourLpa: task.StateCompleted}, CertificateProvider: donordata.CertificateProvider{CarryOutBy: donordata.ChannelPaper, Mobile: "07700900000"}, Type: donordata.LpaTypePropertyAndAffairs, } @@ -428,10 +428,10 @@ func TestPostCheckYourLpaWhenShareCodeSenderErrors(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ LpaID: "lpa-id", Hash: 5, - Tasks: donordata.DonorTasks{CheckYourLpa: actor.TaskInProgress}, + Tasks: donordata.Tasks{CheckYourLpa: task.StateInProgress}, } shareCodeSender := newMockShareCodeSender(t) @@ -467,7 +467,7 @@ func TestPostCheckYourLpaWhenNotifyClientErrors(t *testing.T) { SendActorSMS(mock.Anything, mock.Anything, mock.Anything, mock.Anything). Return(expectedError) - err := CheckYourLpa(nil, nil, nil, notifyClient, nil, testNowFn, "http://example.org")(testAppData, w, r, &donordata.DonorProvidedDetails{Hash: 5, CertificateProvider: donordata.CertificateProvider{CarryOutBy: donordata.ChannelPaper}}) + err := CheckYourLpa(nil, nil, nil, notifyClient, nil, testNowFn, "http://example.org")(testAppData, w, r, &donordata.Provided{Hash: 5, CertificateProvider: donordata.CertificateProvider{CarryOutBy: donordata.ChannelPaper}}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -490,7 +490,7 @@ func TestPostCheckYourLpaWhenValidationErrors(t *testing.T) { })). Return(nil) - err := CheckYourLpa(template.Execute, nil, nil, nil, nil, nil, "http://example.org")(testAppData, w, r, &donordata.DonorProvidedDetails{Hash: 5}) + err := CheckYourLpa(template.Execute, nil, nil, nil, nil, nil, "http://example.org")(testAppData, w, r, &donordata.Provided{Hash: 5}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/choose_a_new_certificate_provider.go b/internal/donor/donorpage/choose_a_new_certificate_provider.go index 39e3fae11a..8cf3e87e94 100644 --- a/internal/donor/donorpage/choose_a_new_certificate_provider.go +++ b/internal/donor/donorpage/choose_a_new_certificate_provider.go @@ -10,13 +10,13 @@ import ( ) type chooseNewCertificateProviderData struct { - Donor *donordata.DonorProvidedDetails + Donor *donordata.Provided Errors validation.List App page.AppData } func ChooseNewCertificateProvider(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &chooseNewCertificateProviderData{Donor: donor, App: appData} if r.Method == http.MethodPost { diff --git a/internal/donor/donorpage/choose_a_new_certificate_provider_test.go b/internal/donor/donorpage/choose_a_new_certificate_provider_test.go index b600e7bafc..c6077a891c 100644 --- a/internal/donor/donorpage/choose_a_new_certificate_provider_test.go +++ b/internal/donor/donorpage/choose_a_new_certificate_provider_test.go @@ -15,10 +15,10 @@ func TestGetChooseNewCertificateProvider(t *testing.T) { template := newMockTemplate(t) template.EXPECT(). - Execute(w, &chooseNewCertificateProviderData{Donor: &donordata.DonorProvidedDetails{}, App: testAppData}). + Execute(w, &chooseNewCertificateProviderData{Donor: &donordata.Provided{}, App: testAppData}). Return(nil) - err := ChooseNewCertificateProvider(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := ChooseNewCertificateProvider(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -31,10 +31,10 @@ func TestGetChooseNewCertificateProviderWhenTemplateError(t *testing.T) { template := newMockTemplate(t) template.EXPECT(). - Execute(w, &chooseNewCertificateProviderData{Donor: &donordata.DonorProvidedDetails{}, App: testAppData}). + Execute(w, &chooseNewCertificateProviderData{Donor: &donordata.Provided{}, App: testAppData}). Return(expectedError) - err := ChooseNewCertificateProvider(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := ChooseNewCertificateProvider(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -47,10 +47,10 @@ func TestPostChooseNewCertificateProvider(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{CertificateProvider: donordata.CertificateProvider{}}). + Put(r.Context(), &donordata.Provided{CertificateProvider: donordata.CertificateProvider{}}). Return(nil) - err := ChooseNewCertificateProvider(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{CertificateProvider: donordata.CertificateProvider{FirstNames: "first-names"}}) + err := ChooseNewCertificateProvider(nil, donorStore)(testAppData, w, r, &donordata.Provided{CertificateProvider: donordata.CertificateProvider{FirstNames: "first-names"}}) resp := w.Result() @@ -64,10 +64,10 @@ func TestPostChooseNewCertificateProviderWhenStoreError(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{CertificateProvider: donordata.CertificateProvider{}}). + Put(r.Context(), &donordata.Provided{CertificateProvider: donordata.CertificateProvider{}}). Return(expectedError) - err := ChooseNewCertificateProvider(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{CertificateProvider: donordata.CertificateProvider{FirstNames: "first-names"}}) + err := ChooseNewCertificateProvider(nil, donorStore)(testAppData, w, r, &donordata.Provided{CertificateProvider: donordata.CertificateProvider{FirstNames: "first-names"}}) resp := w.Result() diff --git a/internal/donor/donorpage/choose_attorneys.go b/internal/donor/donorpage/choose_attorneys.go index 54ba6145d3..a901225835 100644 --- a/internal/donor/donorpage/choose_attorneys.go +++ b/internal/donor/donorpage/choose_attorneys.go @@ -17,7 +17,7 @@ import ( type chooseAttorneysData struct { App page.AppData Errors validation.List - Donor *donordata.DonorProvidedDetails + Donor *donordata.Provided Form *chooseAttorneysForm ShowDetails bool DobWarning string @@ -26,7 +26,7 @@ type chooseAttorneysData struct { } func ChooseAttorneys(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { uid := actoruid.FromRequest(r) if uid.IsZero() { @@ -166,7 +166,7 @@ func (f *chooseAttorneysForm) DobWarning() string { return "" } -func attorneyMatches(donor *donordata.DonorProvidedDetails, uid actoruid.UID, firstNames, lastName string) actor.Type { +func attorneyMatches(donor *donordata.Provided, uid actoruid.UID, firstNames, lastName string) actor.Type { if firstNames == "" && lastName == "" { return actor.TypeNone } diff --git a/internal/donor/donorpage/choose_attorneys_address.go b/internal/donor/donorpage/choose_attorneys_address.go index a4f1a8d6ea..e094720c6c 100644 --- a/internal/donor/donorpage/choose_attorneys_address.go +++ b/internal/donor/donorpage/choose_attorneys_address.go @@ -12,7 +12,7 @@ import ( ) func ChooseAttorneysAddress(logger Logger, tmpl template.Template, addressClient AddressClient, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { attorney, found := donor.Attorneys.Get(actoruid.FromRequest(r)) if found == false { diff --git a/internal/donor/donorpage/choose_attorneys_address_test.go b/internal/donor/donorpage/choose_attorneys_address_test.go index 6d66b47acd..a85d0b5a03 100644 --- a/internal/donor/donorpage/choose_attorneys_address_test.go +++ b/internal/donor/donorpage/choose_attorneys_address_test.go @@ -8,12 +8,12 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -36,7 +36,7 @@ func TestGetChooseAttorneysAddress(t *testing.T) { }). Return(nil) - err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ UID: uid, FirstNames: "John", @@ -76,7 +76,7 @@ func TestGetChooseAttorneysAddressFromStore(t *testing.T) { }). Return(nil) - err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney}}, }) resp := w.Result() @@ -106,7 +106,7 @@ func TestGetChooseAttorneysAddressManual(t *testing.T) { }). Return(nil) - err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) resp := w.Result() @@ -132,7 +132,7 @@ func TestGetChooseAttorneysAddressWhenTemplateErrors(t *testing.T) { }). Return(expectedError) - err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) resp := w.Result() @@ -158,9 +158,9 @@ func TestPostChooseAttorneysAddressManual(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", - Tasks: donordata.DonorTasks{ChooseAttorneys: actor.TaskCompleted}, + Tasks: donordata.Tasks{ChooseAttorneys: task.StateCompleted}, Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ UID: uid, FirstNames: "a", @@ -169,7 +169,7 @@ func TestPostChooseAttorneysAddressManual(t *testing.T) { }). Return(nil) - err := ChooseAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ UID: uid, @@ -204,7 +204,7 @@ func TestPostChooseAttorneysAddressManualWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := ChooseAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{ Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ UID: uid, Address: place.Address{}, @@ -231,9 +231,9 @@ func TestPostChooseAttorneysAddressManualFromStore(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", - Tasks: donordata.DonorTasks{ChooseAttorneys: actor.TaskCompleted}, + Tasks: donordata.Tasks{ChooseAttorneys: task.StateCompleted}, Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ UID: uid, FirstNames: "John", @@ -242,7 +242,7 @@ func TestPostChooseAttorneysAddressManualFromStore(t *testing.T) { }). Return(nil) - err := ChooseAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ UID: uid, @@ -299,7 +299,7 @@ func TestPostChooseAttorneysAddressManualWhenValidationError(t *testing.T) { }). Return(nil) - err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney}}, }) resp := w.Result() @@ -337,7 +337,7 @@ func TestPostChooseAttorneysAddressPostcodeSelect(t *testing.T) { }). Return(nil) - err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) resp := w.Result() @@ -384,7 +384,7 @@ func TestPostChooseAttorneysAddressPostcodeSelectWhenValidationError(t *testing. }). Return(nil) - err := ChooseAttorneysAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseAttorneysAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{ Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) resp := w.Result() @@ -430,7 +430,7 @@ func TestPostChooseAttorneysPostcodeLookup(t *testing.T) { }). Return(nil) - err := ChooseAttorneysAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseAttorneysAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{ Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) resp := w.Result() @@ -477,7 +477,7 @@ func TestPostChooseAttorneysPostcodeLookupError(t *testing.T) { }). Return(nil) - err := ChooseAttorneysAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseAttorneysAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{ Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) resp := w.Result() @@ -529,7 +529,7 @@ func TestPostChooseAttorneysPostcodeLookupInvalidPostcodeError(t *testing.T) { }). Return(nil) - err := ChooseAttorneysAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseAttorneysAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{ Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) resp := w.Result() @@ -573,7 +573,7 @@ func TestPostChooseAttorneysPostcodeLookupValidPostcodeNoAddresses(t *testing.T) }). Return(nil) - err := ChooseAttorneysAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseAttorneysAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{ Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) resp := w.Result() @@ -608,7 +608,7 @@ func TestPostChooseAttorneysPostcodeLookupWhenValidationError(t *testing.T) { }). Return(nil) - err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) resp := w.Result() @@ -643,7 +643,7 @@ func TestPostChooseAttorneysAddressReuse(t *testing.T) { }). Return(nil) - err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{Address: place.Address{Line1: "donor lane"}}, Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) @@ -678,14 +678,14 @@ func TestPostChooseAttorneysAddressReuseSelect(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{updatedAttorney}}, - Tasks: donordata.DonorTasks{ChooseAttorneys: actor.TaskInProgress}, + Tasks: donordata.Tasks{ChooseAttorneys: task.StateInProgress}, }). Return(nil) - err := ChooseAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) @@ -723,7 +723,7 @@ func TestPostChooseAttorneysAddressReuseSelectWhenValidationError(t *testing.T) }). Return(nil) - err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{Address: place.Address{Line1: "donor lane"}}, Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) @@ -767,7 +767,7 @@ func TestPostChooseAttorneysManuallyFromAnotherPage(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, tc.requestUrl, strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ { diff --git a/internal/donor/donorpage/choose_attorneys_guidance.go b/internal/donor/donorpage/choose_attorneys_guidance.go index 4bfd224c5a..94ba602c8d 100644 --- a/internal/donor/donorpage/choose_attorneys_guidance.go +++ b/internal/donor/donorpage/choose_attorneys_guidance.go @@ -14,11 +14,11 @@ import ( type chooseAttorneysGuidanceData struct { App page.AppData Errors validation.List - Donor *donordata.DonorProvidedDetails + Donor *donordata.Provided } func ChooseAttorneysGuidance(tmpl template.Template, newUID func() actoruid.UID) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &chooseAttorneysGuidanceData{ App: appData, Donor: donor, diff --git a/internal/donor/donorpage/choose_attorneys_guidance_test.go b/internal/donor/donorpage/choose_attorneys_guidance_test.go index cd149f3d7f..dd72572a5e 100644 --- a/internal/donor/donorpage/choose_attorneys_guidance_test.go +++ b/internal/donor/donorpage/choose_attorneys_guidance_test.go @@ -19,11 +19,11 @@ func TestGetChooseAttorneysGuidance(t *testing.T) { template.EXPECT(). Execute(w, &chooseAttorneysGuidanceData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{}, + Donor: &donordata.Provided{}, }). Return(nil) - err := ChooseAttorneysGuidance(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := ChooseAttorneysGuidance(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -39,7 +39,7 @@ func TestGetChooseAttorneysGuidanceWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := ChooseAttorneysGuidance(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := ChooseAttorneysGuidance(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -51,7 +51,7 @@ func TestPostChooseAttorneysGuidance(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", nil) r.Header.Add("Content-Type", page.FormUrlEncoded) - err := ChooseAttorneysGuidance(nil, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) + err := ChooseAttorneysGuidance(nil, testUIDFn)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id"}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/choose_attorneys_summary.go b/internal/donor/donorpage/choose_attorneys_summary.go index 0e87668af9..b0dbe5fd99 100644 --- a/internal/donor/donorpage/choose_attorneys_summary.go +++ b/internal/donor/donorpage/choose_attorneys_summary.go @@ -16,11 +16,11 @@ type chooseAttorneysSummaryData struct { App page.AppData Errors validation.List Form *form.YesNoForm - Donor *donordata.DonorProvidedDetails + Donor *donordata.Provided } func ChooseAttorneysSummary(tmpl template.Template, newUID func() actoruid.UID) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { if donor.Attorneys.Len() == 0 { return page.Paths.ChooseAttorneys.RedirectQuery(w, r, appData, donor, url.Values{"id": {newUID().String()}}) } diff --git a/internal/donor/donorpage/choose_attorneys_summary_test.go b/internal/donor/donorpage/choose_attorneys_summary_test.go index 2bce8a2262..86af9dc860 100644 --- a/internal/donor/donorpage/choose_attorneys_summary_test.go +++ b/internal/donor/donorpage/choose_attorneys_summary_test.go @@ -17,7 +17,7 @@ import ( ) func TestGetChooseAttorneysSummary(t *testing.T) { - testcases := map[string]*donordata.DonorProvidedDetails{ + testcases := map[string]*donordata.Provided{ "attorney": { Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{}}}, }, @@ -53,7 +53,7 @@ func TestGetChooseAttorneysSummaryWhenNoAttorneysOrTrustCorporation(t *testing.T w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - err := ChooseAttorneysSummary(nil, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) + err := ChooseAttorneysSummary(nil, testUIDFn)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id"}) resp := w.Result() assert.Nil(t, err) @@ -99,7 +99,7 @@ func TestPostChooseAttorneysSummaryAddAttorney(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - err := ChooseAttorneysSummary(nil, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", Attorneys: tc.Attorneys}) + err := ChooseAttorneysSummary(nil, testUIDFn)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", Attorneys: tc.Attorneys}) resp := w.Result() assert.Nil(t, err) @@ -127,7 +127,7 @@ func TestPostChooseAttorneysSummaryFormValidation(t *testing.T) { })). Return(nil) - err := ChooseAttorneysSummary(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{}}}}) + err := ChooseAttorneysSummary(template.Execute, nil)(testAppData, w, r, &donordata.Provided{Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{}}}}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/choose_attorneys_test.go b/internal/donor/donorpage/choose_attorneys_test.go index 46aa79c1b5..e0eee05499 100644 --- a/internal/donor/donorpage/choose_attorneys_test.go +++ b/internal/donor/donorpage/choose_attorneys_test.go @@ -15,6 +15,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -65,7 +66,7 @@ func TestGetChooseAttorneys(t *testing.T) { template.EXPECT(). Execute(w, &chooseAttorneysData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{ + Donor: &donordata.Provided{ Type: tc.lpaType, ReplacementAttorneys: tc.replacementAttorneys, }, @@ -75,7 +76,7 @@ func TestGetChooseAttorneys(t *testing.T) { }). Return(nil) - err := ChooseAttorneys(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseAttorneys(template.Execute, nil)(testAppData, w, r, &donordata.Provided{ Type: tc.lpaType, ReplacementAttorneys: tc.replacementAttorneys, }) @@ -91,7 +92,7 @@ func TestGetChooseAttorneysWhenNoID(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - err := ChooseAttorneys(nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseAttorneys(nil, nil)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "John", UID: testUID}, @@ -112,7 +113,7 @@ func TestGetChooseAttorneysDobWarningIsAlwaysShown(t *testing.T) { template.EXPECT(). Execute(w, &chooseAttorneysData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{ + Donor: &donordata.Provided{ Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {UID: testUID, DateOfBirth: date.New("1900", "1", "2")}, }}, @@ -125,7 +126,7 @@ func TestGetChooseAttorneysDobWarningIsAlwaysShown(t *testing.T) { }). Return(nil) - err := ChooseAttorneys(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseAttorneys(template.Execute, nil)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{}, Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {UID: testUID, DateOfBirth: date.New("1900", "1", "2")}, @@ -146,7 +147,7 @@ func TestGetChooseAttorneysWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := ChooseAttorneys(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := ChooseAttorneys(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -223,18 +224,18 @@ func TestPostChooseAttorneysAttorneyDoesNotExist(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{ FirstNames: "Jane", LastName: "Doe", }, Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{tc.attorney}}, - Tasks: donordata.DonorTasks{ChooseAttorneys: actor.TaskInProgress}, + Tasks: donordata.Tasks{ChooseAttorneys: task.StateInProgress}, }). Return(nil) - err := ChooseAttorneys(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseAttorneys(nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{ FirstNames: "Jane", @@ -324,15 +325,15 @@ func TestPostChooseAttorneysAttorneyExists(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{tc.attorney}}, - Tasks: donordata.DonorTasks{ChooseAttorneys: actor.TaskCompleted}, + Tasks: donordata.Tasks{ChooseAttorneys: task.StateCompleted}, }). Return(nil) - err := ChooseAttorneys(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseAttorneys(nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ @@ -368,7 +369,7 @@ func TestPostChooseAttorneysNameWarningOnlyShownWhenAttorneyAndFormNamesAreDiffe donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ @@ -380,11 +381,11 @@ func TestPostChooseAttorneysNameWarningOnlyShownWhenAttorneyAndFormNamesAreDiffe DateOfBirth: date.New("2000", "1", "2"), }, }}, - Tasks: donordata.DonorTasks{ChooseAttorneys: actor.TaskCompleted}, + Tasks: donordata.Tasks{ChooseAttorneys: task.StateCompleted}, }). Return(nil) - err := ChooseAttorneys(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseAttorneys(nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ @@ -523,7 +524,7 @@ func TestPostChooseAttorneysWhenInputRequired(t *testing.T) { })). Return(nil) - err := ChooseAttorneys(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseAttorneys(template.Execute, nil)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, }) resp := w.Result() @@ -553,7 +554,7 @@ func TestPostChooseAttorneysWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := ChooseAttorneys(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := ChooseAttorneys(nil, donorStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -714,7 +715,7 @@ func TestChooseAttorneysFormDobWarning(t *testing.T) { func TestAttorneyMatches(t *testing.T) { uid := actoruid.New() - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "c", LastName: "d"}, @@ -749,7 +750,7 @@ func TestAttorneyMatches(t *testing.T) { func TestAttorneyMatchesEmptyNamesIgnored(t *testing.T) { uid := actoruid.New() - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ Donor: donordata.Donor{FirstNames: "", LastName: ""}, Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {UID: uid, FirstNames: "", LastName: ""}, diff --git a/internal/donor/donorpage/choose_people_to_notify.go b/internal/donor/donorpage/choose_people_to_notify.go index 444a4fe691..b75e37b826 100644 --- a/internal/donor/donorpage/choose_people_to_notify.go +++ b/internal/donor/donorpage/choose_people_to_notify.go @@ -10,6 +10,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -21,7 +22,7 @@ type choosePeopleToNotifyData struct { } func ChoosePeopleToNotify(tmpl template.Template, donorStore DonorStore, newUID func() actoruid.UID) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { if len(donor.PeopleToNotify) > 4 { return page.Paths.ChoosePeopleToNotifySummary.Redirect(w, r, appData, donor) } @@ -73,7 +74,7 @@ func ChoosePeopleToNotify(tmpl template.Template, donorStore DonorStore, newUID } if !donor.Tasks.PeopleToNotify.Completed() { - donor.Tasks.PeopleToNotify = actor.TaskInProgress + donor.Tasks.PeopleToNotify = task.StateInProgress } if err := donorStore.Put(r.Context(), donor); err != nil { @@ -116,7 +117,7 @@ func (f *choosePeopleToNotifyForm) Validate() validation.List { return errors } -func personToNotifyMatches(donor *donordata.DonorProvidedDetails, uid actoruid.UID, firstNames, lastName string) actor.Type { +func personToNotifyMatches(donor *donordata.Provided, uid actoruid.UID, firstNames, lastName string) actor.Type { if firstNames == "" && lastName == "" { return actor.TypeNone } diff --git a/internal/donor/donorpage/choose_people_to_notify_address.go b/internal/donor/donorpage/choose_people_to_notify_address.go index 587c1884f5..8f2ca52018 100644 --- a/internal/donor/donorpage/choose_people_to_notify_address.go +++ b/internal/donor/donorpage/choose_people_to_notify_address.go @@ -4,16 +4,16 @@ import ( "net/http" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" ) func ChoosePeopleToNotifyAddress(logger Logger, tmpl template.Template, addressClient AddressClient, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { personToNotify, found := donor.PeopleToNotify.Get(actoruid.FromRequest(r)) if found == false { @@ -39,7 +39,7 @@ func ChoosePeopleToNotifyAddress(logger Logger, tmpl template.Template, addressC setAddress := func(address place.Address) error { personToNotify.Address = *data.Form.Address donor.PeopleToNotify.Put(personToNotify) - donor.Tasks.PeopleToNotify = actor.TaskCompleted + donor.Tasks.PeopleToNotify = task.StateCompleted if err := donorStore.Put(r.Context(), donor); err != nil { return err diff --git a/internal/donor/donorpage/choose_people_to_notify_address_test.go b/internal/donor/donorpage/choose_people_to_notify_address_test.go index 806d1bbb23..3d3b7a8f5d 100644 --- a/internal/donor/donorpage/choose_people_to_notify_address_test.go +++ b/internal/donor/donorpage/choose_people_to_notify_address_test.go @@ -8,12 +8,12 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -43,7 +43,7 @@ func TestGetChoosePeopleToNotifyAddress(t *testing.T) { }). Return(nil) - err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{PeopleToNotify: donordata.PeopleToNotify{personToNotify}}) + err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{PeopleToNotify: donordata.PeopleToNotify{personToNotify}}) resp := w.Result() assert.Nil(t, err) @@ -71,7 +71,7 @@ func TestGetChoosePeopleToNotifyAddressFromStore(t *testing.T) { }). Return(nil) - err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ PeopleToNotify: donordata.PeopleToNotify{{UID: uid, Address: testAddress}}, }) resp := w.Result() @@ -101,7 +101,7 @@ func TestGetChoosePeopleToNotifyAddressManual(t *testing.T) { }). Return(nil) - err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{PeopleToNotify: donordata.PeopleToNotify{{UID: uid, Address: testAddress}}}) + err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{PeopleToNotify: donordata.PeopleToNotify{{UID: uid, Address: testAddress}}}) resp := w.Result() assert.Nil(t, err) @@ -130,7 +130,7 @@ func TestGetChoosePeopleToNotifyAddressWhenTemplateErrors(t *testing.T) { }). Return(expectedError) - err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{PeopleToNotify: donordata.PeopleToNotify{personToNotify}}) + err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{PeopleToNotify: donordata.PeopleToNotify{personToNotify}}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -154,17 +154,17 @@ func TestPostChoosePeopleToNotifyAddressManual(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", PeopleToNotify: donordata.PeopleToNotify{{UID: uid, Address: testAddress}}, - Tasks: donordata.DonorTasks{PeopleToNotify: actor.TaskCompleted}, + Tasks: donordata.Tasks{PeopleToNotify: task.StateCompleted}, }). Return(nil) - err := ChoosePeopleToNotifyAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChoosePeopleToNotifyAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", PeopleToNotify: donordata.PeopleToNotify{{UID: uid}}, - Tasks: donordata.DonorTasks{PeopleToNotify: actor.TaskInProgress}, + Tasks: donordata.Tasks{PeopleToNotify: task.StateInProgress}, }) resp := w.Result() @@ -190,13 +190,13 @@ func TestPostChoosePeopleToNotifyAddressManualWhenStoreErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ PeopleToNotify: donordata.PeopleToNotify{{UID: uid, Address: testAddress}}, - Tasks: donordata.DonorTasks{PeopleToNotify: actor.TaskCompleted}, + Tasks: donordata.Tasks{PeopleToNotify: task.StateCompleted}, }). Return(expectedError) - err := ChoosePeopleToNotifyAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{PeopleToNotify: donordata.PeopleToNotify{{UID: uid}}}) + err := ChoosePeopleToNotifyAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{PeopleToNotify: donordata.PeopleToNotify{{UID: uid}}}) assert.Equal(t, expectedError, err) } @@ -219,25 +219,25 @@ func TestPostChoosePeopleToNotifyAddressManualFromStore(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", PeopleToNotify: donordata.PeopleToNotify{donordata.PersonToNotify{ UID: uid, FirstNames: "John", Address: testAddress, }}, - Tasks: donordata.DonorTasks{PeopleToNotify: actor.TaskCompleted}, + Tasks: donordata.Tasks{PeopleToNotify: task.StateCompleted}, }). Return(nil) - err := ChoosePeopleToNotifyAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChoosePeopleToNotifyAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", PeopleToNotify: donordata.PeopleToNotify{donordata.PersonToNotify{ UID: uid, FirstNames: "John", Address: place.Address{Line1: "line1"}, }}, - Tasks: donordata.DonorTasks{PeopleToNotify: actor.TaskInProgress}, + Tasks: donordata.Tasks{PeopleToNotify: task.StateInProgress}, }) resp := w.Result() @@ -276,7 +276,7 @@ func TestPostChoosePeopleToNotifyPostcodeSelect(t *testing.T) { }). Return(nil) - err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ PeopleToNotify: donordata.PeopleToNotify{{ UID: uid, FirstNames: "John", @@ -327,7 +327,7 @@ func TestPostChoosePeopleToNotifyPostcodeSelectWhenValidationError(t *testing.T) }). Return(nil) - err := ChoosePeopleToNotifyAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{PeopleToNotify: donordata.PeopleToNotify{{UID: uid}}}) + err := ChoosePeopleToNotifyAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{PeopleToNotify: donordata.PeopleToNotify{{UID: uid}}}) resp := w.Result() assert.Nil(t, err) @@ -371,7 +371,7 @@ func TestPostChoosePeopleToNotifyPostcodeLookup(t *testing.T) { }). Return(nil) - err := ChoosePeopleToNotifyAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{PeopleToNotify: donordata.PeopleToNotify{{UID: uid, FirstNames: "John"}}}) + err := ChoosePeopleToNotifyAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{PeopleToNotify: donordata.PeopleToNotify{{UID: uid, FirstNames: "John"}}}) resp := w.Result() assert.Nil(t, err) @@ -416,7 +416,7 @@ func TestPostChoosePeopleToNotifyPostcodeLookupError(t *testing.T) { }). Return(nil) - err := ChoosePeopleToNotifyAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{PeopleToNotify: donordata.PeopleToNotify{{UID: uid}}}) + err := ChoosePeopleToNotifyAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{PeopleToNotify: donordata.PeopleToNotify{{UID: uid}}}) resp := w.Result() assert.Nil(t, err) @@ -466,7 +466,7 @@ func TestPostChoosePeopleToNotifyPostcodeLookupInvalidPostcodeError(t *testing.T }). Return(nil) - err := ChoosePeopleToNotifyAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{PeopleToNotify: donordata.PeopleToNotify{{UID: uid}}}) + err := ChoosePeopleToNotifyAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{PeopleToNotify: donordata.PeopleToNotify{{UID: uid}}}) resp := w.Result() assert.Nil(t, err) @@ -510,7 +510,7 @@ func TestPostChoosePeopleToNotifyPostcodeLookupValidPostcodeNoAddresses(t *testi }). Return(nil) - err := ChoosePeopleToNotifyAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{PeopleToNotify: donordata.PeopleToNotify{{UID: uid}}}) + err := ChoosePeopleToNotifyAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{PeopleToNotify: donordata.PeopleToNotify{{UID: uid}}}) resp := w.Result() assert.Nil(t, err) @@ -548,7 +548,7 @@ func TestPostChoosePeopleToNotifyPostcodeLookupWhenValidationError(t *testing.T) }). Return(nil) - err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{PeopleToNotify: donordata.PeopleToNotify{personToNotify}}) + err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{PeopleToNotify: donordata.PeopleToNotify{personToNotify}}) resp := w.Result() assert.Nil(t, err) @@ -581,7 +581,7 @@ func TestPostChoosePeopleToNotifyAddressReuse(t *testing.T) { }). Return(nil) - err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{Address: place.Address{Line1: "donor lane"}}, PeopleToNotify: donordata.PeopleToNotify{{UID: uid}}, }) @@ -604,7 +604,7 @@ func TestPostChoosePeopleToNotifyAddressReuseSelect(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", PeopleToNotify: donordata.PeopleToNotify{{ UID: uid, @@ -617,11 +617,11 @@ func TestPostChoosePeopleToNotifyAddressReuseSelect(t *testing.T) { Country: "GB", }, }}, - Tasks: donordata.DonorTasks{PeopleToNotify: actor.TaskCompleted}, + Tasks: donordata.Tasks{PeopleToNotify: task.StateCompleted}, }). Return(nil) - err := ChoosePeopleToNotifyAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", PeopleToNotify: donordata.PeopleToNotify{{UID: uid}}}) + err := ChoosePeopleToNotifyAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", PeopleToNotify: donordata.PeopleToNotify{{UID: uid}}}) resp := w.Result() assert.Nil(t, err) @@ -656,7 +656,7 @@ func TestPostChoosePeopleToNotifyAddressReuseSelectWhenValidationError(t *testin }). Return(nil) - err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{Address: place.Address{Line1: "donor lane"}}, PeopleToNotify: donordata.PeopleToNotify{{UID: uid}}, }) diff --git a/internal/donor/donorpage/choose_people_to_notify_summary.go b/internal/donor/donorpage/choose_people_to_notify_summary.go index 8dd14e23cf..84440ebe8b 100644 --- a/internal/donor/donorpage/choose_people_to_notify_summary.go +++ b/internal/donor/donorpage/choose_people_to_notify_summary.go @@ -15,11 +15,11 @@ type choosePeopleToNotifySummaryData struct { App page.AppData Errors validation.List Form *form.YesNoForm - Donor *donordata.DonorProvidedDetails + Donor *donordata.Provided } func ChoosePeopleToNotifySummary(tmpl template.Template) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { if len(donor.PeopleToNotify) == 0 { return page.Paths.DoYouWantToNotifyPeople.Redirect(w, r, appData, donor) } diff --git a/internal/donor/donorpage/choose_people_to_notify_summary_test.go b/internal/donor/donorpage/choose_people_to_notify_summary_test.go index 3e5ba46890..2bb8647da4 100644 --- a/internal/donor/donorpage/choose_people_to_notify_summary_test.go +++ b/internal/donor/donorpage/choose_people_to_notify_summary_test.go @@ -7,11 +7,11 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -21,7 +21,7 @@ func TestGetChoosePeopleToNotifySummary(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &donordata.DonorProvidedDetails{PeopleToNotify: donordata.PeopleToNotify{{}}} + donor := &donordata.Provided{PeopleToNotify: donordata.PeopleToNotify{{}}} template := newMockTemplate(t) template.EXPECT(). @@ -43,15 +43,15 @@ func TestGetChoosePeopleToNotifySummaryWhenNoPeopleToNotify(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - err := ChoosePeopleToNotifySummary(nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChoosePeopleToNotifySummary(nil)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", - Tasks: donordata.DonorTasks{ - YourDetails: actor.TaskCompleted, - ChooseAttorneys: actor.TaskCompleted, - ChooseReplacementAttorneys: actor.TaskCompleted, - WhenCanTheLpaBeUsed: actor.TaskCompleted, - Restrictions: actor.TaskCompleted, - CertificateProvider: actor.TaskCompleted, + Tasks: donordata.Tasks{ + YourDetails: task.StateCompleted, + ChooseAttorneys: task.StateCompleted, + ChooseReplacementAttorneys: task.StateCompleted, + WhenCanTheLpaBeUsed: task.StateCompleted, + Restrictions: task.StateCompleted, + CertificateProvider: task.StateCompleted, }, }) @@ -71,7 +71,7 @@ func TestPostChoosePeopleToNotifySummaryAddPersonToNotify(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - err := ChoosePeopleToNotifySummary(nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", PeopleToNotify: donordata.PeopleToNotify{{UID: actoruid.New()}}}) + err := ChoosePeopleToNotifySummary(nil)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", PeopleToNotify: donordata.PeopleToNotify{{UID: actoruid.New()}}}) resp := w.Result() assert.Nil(t, err) @@ -88,17 +88,17 @@ func TestPostChoosePeopleToNotifySummaryNoFurtherPeopleToNotify(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - err := ChoosePeopleToNotifySummary(nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChoosePeopleToNotifySummary(nil)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", PeopleToNotify: donordata.PeopleToNotify{{UID: actoruid.New()}}, - Tasks: donordata.DonorTasks{ - YourDetails: actor.TaskCompleted, - ChooseAttorneys: actor.TaskCompleted, - ChooseReplacementAttorneys: actor.TaskCompleted, - WhenCanTheLpaBeUsed: actor.TaskCompleted, - Restrictions: actor.TaskCompleted, - CertificateProvider: actor.TaskCompleted, - PeopleToNotify: actor.TaskCompleted, + Tasks: donordata.Tasks{ + YourDetails: task.StateCompleted, + ChooseAttorneys: task.StateCompleted, + ChooseReplacementAttorneys: task.StateCompleted, + WhenCanTheLpaBeUsed: task.StateCompleted, + Restrictions: task.StateCompleted, + CertificateProvider: task.StateCompleted, + PeopleToNotify: task.StateCompleted, }, }) resp := w.Result() @@ -126,7 +126,7 @@ func TestPostChoosePeopleToNotifySummaryFormValidation(t *testing.T) { })). Return(nil) - err := ChoosePeopleToNotifySummary(template.Execute)(testAppData, w, r, &donordata.DonorProvidedDetails{PeopleToNotify: donordata.PeopleToNotify{{}}}) + err := ChoosePeopleToNotifySummary(template.Execute)(testAppData, w, r, &donordata.Provided{PeopleToNotify: donordata.PeopleToNotify{{}}}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/choose_people_to_notify_test.go b/internal/donor/donorpage/choose_people_to_notify_test.go index c82a6a41af..5afb12b9ef 100644 --- a/internal/donor/donorpage/choose_people_to_notify_test.go +++ b/internal/donor/donorpage/choose_people_to_notify_test.go @@ -11,6 +11,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -28,7 +29,7 @@ func TestGetChoosePeopleToNotify(t *testing.T) { }). Return(nil) - err := ChoosePeopleToNotify(template.Execute, nil, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := ChoosePeopleToNotify(template.Execute, nil, testUIDFn)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -41,7 +42,7 @@ func TestGetChoosePeopleToNotifyFromStore(t *testing.T) { template := newMockTemplate(t) - err := ChoosePeopleToNotify(template.Execute, nil, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChoosePeopleToNotify(template.Execute, nil, testUIDFn)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", PeopleToNotify: donordata.PeopleToNotify{ { @@ -71,7 +72,7 @@ func TestGetChoosePeopleToNotifyWhenTemplateErrors(t *testing.T) { }). Return(expectedError) - err := ChoosePeopleToNotify(template.Execute, nil, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := ChoosePeopleToNotify(template.Execute, nil, testUIDFn)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -117,7 +118,7 @@ func TestGetChoosePeopleToNotifyPeopleLimitReached(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - err := ChoosePeopleToNotify(nil, nil, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChoosePeopleToNotify(nil, nil, testUIDFn)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", PeopleToNotify: tc.addedPeople, }) @@ -168,15 +169,15 @@ func TestPostChoosePeopleToNotifyPersonDoesNotExists(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, PeopleToNotify: donordata.PeopleToNotify{tc.personToNotify}, - Tasks: donordata.DonorTasks{PeopleToNotify: actor.TaskInProgress}, + Tasks: donordata.Tasks{PeopleToNotify: task.StateInProgress}, }). Return(nil) - err := ChoosePeopleToNotify(nil, donorStore, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChoosePeopleToNotify(nil, donorStore, testUIDFn)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, }) @@ -202,18 +203,18 @@ func TestPostChoosePeopleToNotifyPersonExists(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", PeopleToNotify: donordata.PeopleToNotify{{ FirstNames: "Johnny", LastName: "Dear", UID: uid, }}, - Tasks: donordata.DonorTasks{PeopleToNotify: actor.TaskInProgress}, + Tasks: donordata.Tasks{PeopleToNotify: task.StateInProgress}, }). Return(nil) - err := ChoosePeopleToNotify(nil, donorStore, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChoosePeopleToNotify(nil, donorStore, testUIDFn)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", PeopleToNotify: donordata.PeopleToNotify{{ FirstNames: "John", @@ -278,7 +279,7 @@ func TestPostChoosePeopleToNotifyWhenInputRequired(t *testing.T) { })). Return(nil) - err := ChoosePeopleToNotify(template.Execute, nil, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChoosePeopleToNotify(template.Execute, nil, testUIDFn)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, }) resp := w.Result() @@ -304,7 +305,7 @@ func TestPostChoosePeopleToNotifyWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := ChoosePeopleToNotify(nil, donorStore, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := ChoosePeopleToNotify(nil, donorStore, testUIDFn)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -369,7 +370,7 @@ func TestChoosePeopleToNotifyFormValidate(t *testing.T) { func TestPersonToNotifyMatches(t *testing.T) { uid := actoruid.New() - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "c", LastName: "d"}, @@ -399,7 +400,7 @@ func TestPersonToNotifyMatches(t *testing.T) { func TestPersonToNotifyMatchesEmptyNamesIgnored(t *testing.T) { uid := actoruid.New() - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ Donor: donordata.Donor{FirstNames: "", LastName: ""}, Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "", LastName: ""}, diff --git a/internal/donor/donorpage/choose_replacement_attorneys.go b/internal/donor/donorpage/choose_replacement_attorneys.go index 445724cf74..929d6667dc 100644 --- a/internal/donor/donorpage/choose_replacement_attorneys.go +++ b/internal/donor/donorpage/choose_replacement_attorneys.go @@ -16,7 +16,7 @@ import ( type chooseReplacementAttorneysData struct { App page.AppData Errors validation.List - Donor *donordata.DonorProvidedDetails + Donor *donordata.Provided Form *chooseAttorneysForm DobWarning string NameWarning *actor.SameNameWarning @@ -24,7 +24,7 @@ type chooseReplacementAttorneysData struct { } func ChooseReplacementAttorneys(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { uid := actoruid.FromRequest(r) if uid.IsZero() { @@ -95,7 +95,7 @@ func ChooseReplacementAttorneys(tmpl template.Template, donorStore DonorStore) H } } -func replacementAttorneyMatches(donor *donordata.DonorProvidedDetails, uid actoruid.UID, firstNames, lastName string) actor.Type { +func replacementAttorneyMatches(donor *donordata.Provided, uid actoruid.UID, firstNames, lastName string) actor.Type { if firstNames == "" && lastName == "" { return actor.TypeNone } diff --git a/internal/donor/donorpage/choose_replacement_attorneys_address.go b/internal/donor/donorpage/choose_replacement_attorneys_address.go index d1b05781d1..93c934acb7 100644 --- a/internal/donor/donorpage/choose_replacement_attorneys_address.go +++ b/internal/donor/donorpage/choose_replacement_attorneys_address.go @@ -12,7 +12,7 @@ import ( ) func ChooseReplacementAttorneysAddress(logger Logger, tmpl template.Template, addressClient AddressClient, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { attorney, _ := donor.ReplacementAttorneys.Get(actoruid.FromRequest(r)) data := newChooseAddressData( diff --git a/internal/donor/donorpage/choose_replacement_attorneys_address_test.go b/internal/donor/donorpage/choose_replacement_attorneys_address_test.go index 6965cba93e..6152cf289b 100644 --- a/internal/donor/donorpage/choose_replacement_attorneys_address_test.go +++ b/internal/donor/donorpage/choose_replacement_attorneys_address_test.go @@ -8,12 +8,12 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -43,7 +43,7 @@ func TestGetChooseReplacementAttorneysAddress(t *testing.T) { }). Return(nil) - err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ra}}}) + err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ra}}}) resp := w.Result() assert.Nil(t, err) @@ -76,7 +76,7 @@ func TestGetChooseReplacementAttorneysAddressFromStore(t *testing.T) { }). Return(nil) - err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ra}}}) + err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ra}}}) resp := w.Result() assert.Nil(t, err) @@ -109,7 +109,7 @@ func TestGetChooseReplacementAttorneysAddressManual(t *testing.T) { }). Return(nil) - err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ra}}}) + err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ra}}}) resp := w.Result() assert.Nil(t, err) @@ -138,7 +138,7 @@ func TestGetChooseReplacementAttorneysAddressWhenTemplateErrors(t *testing.T) { }). Return(expectedError) - err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ra}}}) + err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ra}}}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -162,18 +162,18 @@ func TestPostChooseReplacementAttorneysAddressManual(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ UID: uid, FirstNames: "a", Address: testAddress, }}}, - Tasks: donordata.DonorTasks{ChooseReplacementAttorneys: actor.TaskCompleted}, + Tasks: donordata.Tasks{ChooseReplacementAttorneys: task.StateCompleted}, }). Return(nil) - err := ChooseReplacementAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseReplacementAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid, FirstNames: "a"}}}, }) @@ -204,7 +204,7 @@ func TestPostChooseReplacementAttorneysAddressManualWhenStoreErrors(t *testing.T Put(r.Context(), mock.Anything). Return(expectedError) - err := ChooseReplacementAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}}) + err := ChooseReplacementAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}}) assert.Equal(t, expectedError, err) } @@ -226,18 +226,18 @@ func TestPostChooseReplacementAttorneysAddressManualFromStore(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ UID: uid, FirstNames: "John", Address: testAddress, }}}, - Tasks: donordata.DonorTasks{ChooseReplacementAttorneys: actor.TaskCompleted}, + Tasks: donordata.Tasks{ChooseReplacementAttorneys: task.StateCompleted}, }). Return(nil) - err := ChooseReplacementAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseReplacementAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ UID: uid, @@ -289,7 +289,7 @@ func TestPostChooseReplacementAttorneysAddressManualWhenValidationError(t *testi }). Return(nil) - err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}}) + err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}}) resp := w.Result() assert.Nil(t, err) @@ -325,7 +325,7 @@ func TestPostChooseReplacementAttorneysPostcodeSelect(t *testing.T) { }). Return(nil) - err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}}) + err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}}) resp := w.Result() assert.Nil(t, err) @@ -370,7 +370,7 @@ func TestPostChooseReplacementAttorneysPostcodeSelectWhenValidationError(t *test }). Return(nil) - err := ChooseReplacementAttorneysAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}}) + err := ChooseReplacementAttorneysAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}}) resp := w.Result() assert.Nil(t, err) @@ -414,7 +414,7 @@ func TestPostChooseReplacementAttorneysPostcodeLookup(t *testing.T) { }). Return(nil) - err := ChooseReplacementAttorneysAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}}) + err := ChooseReplacementAttorneysAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}}) resp := w.Result() assert.Nil(t, err) @@ -459,7 +459,7 @@ func TestPostChooseReplacementAttorneysPostcodeLookupError(t *testing.T) { }). Return(nil) - err := ChooseReplacementAttorneysAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}}) + err := ChooseReplacementAttorneysAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}}) resp := w.Result() assert.Nil(t, err) @@ -509,7 +509,7 @@ func TestPostChooseReplacementAttorneysPostcodeLookupInvalidPostcodeError(t *tes }). Return(nil) - err := ChooseReplacementAttorneysAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseReplacementAttorneysAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{ ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) resp := w.Result() @@ -555,7 +555,7 @@ func TestPostChooseReplacementAttorneysPostcodeLookupValidPostcodeNoAddresses(t }). Return(nil) - err := ChooseReplacementAttorneysAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseReplacementAttorneysAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{ ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) resp := w.Result() @@ -590,7 +590,7 @@ func TestPostChooseReplacementAttorneysPostcodeLookupWhenValidationError(t *test }). Return(nil) - err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}}) + err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}}) resp := w.Result() assert.Nil(t, err) @@ -623,7 +623,7 @@ func TestPostChooseReplacementAttorneysAddressReuse(t *testing.T) { }). Return(nil) - err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{Address: place.Address{Line1: "donor lane"}}, ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) @@ -658,14 +658,14 @@ func TestPostChooseReplacementAttorneysAddressReuseSelect(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{updatedAttorney}}, - Tasks: donordata.DonorTasks{ChooseReplacementAttorneys: actor.TaskInProgress}, + Tasks: donordata.Tasks{ChooseReplacementAttorneys: task.StateInProgress}, }). Return(nil) - err := ChooseReplacementAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseReplacementAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) @@ -703,7 +703,7 @@ func TestPostChooseReplacementAttorneysAddressReuseSelectWhenValidationError(t * }). Return(nil) - err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{Address: place.Address{Line1: "donor lane"}}, ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) diff --git a/internal/donor/donorpage/choose_replacement_attorneys_summary.go b/internal/donor/donorpage/choose_replacement_attorneys_summary.go index e1342fafdd..d4420a372c 100644 --- a/internal/donor/donorpage/choose_replacement_attorneys_summary.go +++ b/internal/donor/donorpage/choose_replacement_attorneys_summary.go @@ -16,11 +16,11 @@ type chooseReplacementAttorneysSummaryData struct { App page.AppData Errors validation.List Form *form.YesNoForm - Donor *donordata.DonorProvidedDetails + Donor *donordata.Provided } func ChooseReplacementAttorneysSummary(tmpl template.Template, newUID func() actoruid.UID) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { if donor.ReplacementAttorneys.Len() == 0 { return page.Paths.DoYouWantReplacementAttorneys.Redirect(w, r, appData, donor) } diff --git a/internal/donor/donorpage/choose_replacement_attorneys_summary_test.go b/internal/donor/donorpage/choose_replacement_attorneys_summary_test.go index b3afd1fb82..01868f2a33 100644 --- a/internal/donor/donorpage/choose_replacement_attorneys_summary_test.go +++ b/internal/donor/donorpage/choose_replacement_attorneys_summary_test.go @@ -7,12 +7,12 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/date" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -29,7 +29,7 @@ func TestGetChooseReplacementAttorneysSummary(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &donordata.DonorProvidedDetails{ReplacementAttorneys: attorneys} + donor := &donordata.Provided{ReplacementAttorneys: attorneys} template := newMockTemplate(t) template.EXPECT(). @@ -53,9 +53,9 @@ func TestGetChooseReplacementAttorneysSummaryWhenNoReplacementAttorneys(t *testi w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - err := ChooseReplacementAttorneysSummary(nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseReplacementAttorneysSummary(nil, nil)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", - Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted}, + Tasks: donordata.Tasks{YourDetails: task.StateCompleted, ChooseAttorneys: task.StateCompleted}, }) resp := w.Result() @@ -73,7 +73,7 @@ func TestPostChooseReplacementAttorneysSummaryAddAttorney(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - err := ChooseReplacementAttorneysSummary(nil, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{}}}}) + err := ChooseReplacementAttorneysSummary(nil, testUIDFn)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{}}}}) resp := w.Result() assert.Nil(t, err) @@ -142,7 +142,7 @@ func TestPostChooseReplacementAttorneysSummaryDoNotAddAttorney(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - err := ChooseReplacementAttorneysSummary(nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseReplacementAttorneysSummary(nil, nil)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", ReplacementAttorneys: tc.replacementAttorneys, AttorneyDecisions: donordata.AttorneyDecisions{ @@ -150,9 +150,9 @@ func TestPostChooseReplacementAttorneysSummaryDoNotAddAttorney(t *testing.T) { Details: tc.decisionDetails, }, Attorneys: tc.attorneys, - Tasks: donordata.DonorTasks{ - YourDetails: actor.TaskCompleted, - ChooseAttorneys: actor.TaskCompleted, + Tasks: donordata.Tasks{ + YourDetails: task.StateCompleted, + ChooseAttorneys: task.StateCompleted, }, }) resp := w.Result() @@ -182,7 +182,7 @@ func TestPostChooseReplacementAttorneySummaryFormValidation(t *testing.T) { })). Return(nil) - err := ChooseReplacementAttorneysSummary(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{}}}}) + err := ChooseReplacementAttorneysSummary(template.Execute, nil)(testAppData, w, r, &donordata.Provided{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{}}}}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/choose_replacement_attorneys_test.go b/internal/donor/donorpage/choose_replacement_attorneys_test.go index 22415c4de6..058c7a50c6 100644 --- a/internal/donor/donorpage/choose_replacement_attorneys_test.go +++ b/internal/donor/donorpage/choose_replacement_attorneys_test.go @@ -15,6 +15,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -65,7 +66,7 @@ func TestGetChooseReplacementAttorneys(t *testing.T) { template.EXPECT(). Execute(w, &chooseReplacementAttorneysData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{ + Donor: &donordata.Provided{ Type: tc.lpaType, Attorneys: tc.attorneys, }, @@ -74,7 +75,7 @@ func TestGetChooseReplacementAttorneys(t *testing.T) { }). Return(nil) - err := ChooseReplacementAttorneys(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseReplacementAttorneys(template.Execute, nil)(testAppData, w, r, &donordata.Provided{ Type: tc.lpaType, Attorneys: tc.attorneys, }) @@ -90,7 +91,7 @@ func TestGetChooseReplacementAttorneysWhenNoID(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - err := ChooseReplacementAttorneys(nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{FirstNames: "John", UID: actoruid.New()}}}}) + err := ChooseReplacementAttorneys(nil, nil)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{FirstNames: "John", UID: actoruid.New()}}}}) resp := w.Result() assert.Nil(t, err) @@ -106,7 +107,7 @@ func TestGetChooseReplacementAttorneysDobWarningIsAlwaysShown(t *testing.T) { template.EXPECT(). Execute(w, &chooseReplacementAttorneysData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{ + Donor: &donordata.Provided{ ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {UID: testUID, DateOfBirth: date.New("1900", "1", "2")}, }}, @@ -118,7 +119,7 @@ func TestGetChooseReplacementAttorneysDobWarningIsAlwaysShown(t *testing.T) { }). Return(nil) - err := ChooseReplacementAttorneys(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseReplacementAttorneys(template.Execute, nil)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{}, ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {UID: testUID, DateOfBirth: date.New("1900", "1", "2")}, @@ -139,7 +140,7 @@ func TestGetChooseReplacementAttorneysWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := ChooseReplacementAttorneys(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := ChooseReplacementAttorneys(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -216,15 +217,15 @@ func TestPostChooseReplacementAttorneysAttorneyDoesNotExists(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{tc.attorney}}, - Tasks: donordata.DonorTasks{ChooseReplacementAttorneys: actor.TaskInProgress}, + Tasks: donordata.Tasks{ChooseReplacementAttorneys: task.StateInProgress}, }). Return(nil) - err := ChooseReplacementAttorneys(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}}) + err := ChooseReplacementAttorneys(nil, donorStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}}) resp := w.Result() assert.Nil(t, err) @@ -308,15 +309,15 @@ func TestPostChooseReplacementAttorneysAttorneyExists(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{tc.attorney}}, - Tasks: donordata.DonorTasks{ChooseReplacementAttorneys: actor.TaskCompleted}, + Tasks: donordata.Tasks{ChooseReplacementAttorneys: task.StateCompleted}, }). Return(nil) - err := ChooseReplacementAttorneys(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseReplacementAttorneys(nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ @@ -351,7 +352,7 @@ func TestPostChooseReplacementAttorneysNameWarningOnlyShownWhenAttorneyAndFormNa donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ @@ -363,11 +364,11 @@ func TestPostChooseReplacementAttorneysNameWarningOnlyShownWhenAttorneyAndFormNa DateOfBirth: date.New("2000", "1", "2"), }, }}, - Tasks: donordata.DonorTasks{ChooseReplacementAttorneys: actor.TaskCompleted}, + Tasks: donordata.Tasks{ChooseReplacementAttorneys: task.StateCompleted}, }). Return(nil) - err := ChooseReplacementAttorneys(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ChooseReplacementAttorneys(nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ @@ -500,7 +501,7 @@ func TestPostChooseReplacementAttorneysWhenInputRequired(t *testing.T) { })). Return(nil) - err := ChooseReplacementAttorneys(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}}) + err := ChooseReplacementAttorneys(template.Execute, nil)(testAppData, w, r, &donordata.Provided{Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}}) resp := w.Result() assert.Nil(t, err) @@ -528,14 +529,14 @@ func TestPostChooseReplacementAttorneysWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := ChooseReplacementAttorneys(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := ChooseReplacementAttorneys(nil, donorStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } func TestReplacementAttorneyMatches(t *testing.T) { uid := actoruid.New() - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "c", LastName: "d"}, @@ -569,7 +570,7 @@ func TestReplacementAttorneyMatches(t *testing.T) { func TestReplacementAttorneyMatchesEmptyNamesIgnored(t *testing.T) { uid := actoruid.New() - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ Donor: donordata.Donor{FirstNames: "", LastName: ""}, Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "", LastName: ""}, diff --git a/internal/donor/donorpage/confirm_person_allowed_to_vouch.go b/internal/donor/donorpage/confirm_person_allowed_to_vouch.go index 1d14eea3ed..71342f348b 100644 --- a/internal/donor/donorpage/confirm_person_allowed_to_vouch.go +++ b/internal/donor/donorpage/confirm_person_allowed_to_vouch.go @@ -32,7 +32,7 @@ func (d confirmPersonAllowedToVouchData) MultipleMatches() bool { } func ConfirmPersonAllowedToVouch(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { matches := donor.Voucher.Matches(donor) data := &confirmPersonAllowedToVouchData{ diff --git a/internal/donor/donorpage/confirm_person_allowed_to_vouch_test.go b/internal/donor/donorpage/confirm_person_allowed_to_vouch_test.go index c970acfd09..54c21e34bf 100644 --- a/internal/donor/donorpage/confirm_person_allowed_to_vouch_test.go +++ b/internal/donor/donorpage/confirm_person_allowed_to_vouch_test.go @@ -32,12 +32,12 @@ func TestConfirmPersonAllowedToVouchDataMultipleMatches(t *testing.T) { func TestGetConfirmPersonAllowedToVouch(t *testing.T) { testcases := map[string]struct { - donor *donordata.DonorProvidedDetails + donor *donordata.Provided matches []actor.Type matchSurname bool }{ "matches donor": { - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ Donor: donordata.Donor{FirstNames: "John", LastName: "Smith"}, CertificateProvider: donordata.CertificateProvider{FirstNames: "John", LastName: "Smith"}, Voucher: donordata.Voucher{FirstNames: "John", LastName: "Smith"}, @@ -45,7 +45,7 @@ func TestGetConfirmPersonAllowedToVouch(t *testing.T) { matches: []actor.Type{actor.TypeDonor, actor.TypeCertificateProvider}, }, "matches donor last name": { - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ Donor: donordata.Donor{FirstNames: "Dave", LastName: "Smith"}, CertificateProvider: donordata.CertificateProvider{FirstNames: "John", LastName: "Smith"}, Voucher: donordata.Voucher{FirstNames: "John", LastName: "Smith"}, @@ -89,7 +89,7 @@ func TestGetConfirmPersonAllowedToVouchWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := ConfirmPersonAllowedToVouch(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := ConfirmPersonAllowedToVouch(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -125,13 +125,13 @@ func TestPostConfirmPersonAllowedToVouch(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Voucher: tc.voucher, }). Return(nil) - err := ConfirmPersonAllowedToVouch(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ConfirmPersonAllowedToVouch(nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Voucher: donordata.Voucher{FirstNames: "John"}, }) @@ -158,7 +158,7 @@ func TestPostConfirmPersonAllowedToVouchWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := ConfirmPersonAllowedToVouch(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := ConfirmPersonAllowedToVouch(nil, donorStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -175,7 +175,7 @@ func TestPostConfirmPersonAllowedToVouchWhenValidationErrors(t *testing.T) { })). Return(nil) - err := ConfirmPersonAllowedToVouch(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := ConfirmPersonAllowedToVouch(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/confirm_your_certificate_provider_is_not_related.go b/internal/donor/donorpage/confirm_your_certificate_provider_is_not_related.go index 40f906fbfe..e7ccf6d4f5 100644 --- a/internal/donor/donorpage/confirm_your_certificate_provider_is_not_related.go +++ b/internal/donor/donorpage/confirm_your_certificate_provider_is_not_related.go @@ -5,10 +5,10 @@ import ( "time" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -16,11 +16,11 @@ type confirmYourCertificateProviderIsNotRelatedData struct { App page.AppData Errors validation.List Form *form.YesNoForm - Donor *donordata.DonorProvidedDetails + Donor *donordata.Provided } func ConfirmYourCertificateProviderIsNotRelated(tmpl template.Template, donorStore DonorStore, now func() time.Time) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &confirmYourCertificateProviderIsNotRelatedData{ App: appData, Form: form.NewYesNoForm(form.YesNoUnknown), @@ -36,7 +36,7 @@ func ConfirmYourCertificateProviderIsNotRelated(tmpl template.Template, donorSto if r.Method == http.MethodPost { if r.PostFormValue("action") == "choose-new" { donor.CertificateProvider = donordata.CertificateProvider{} - donor.Tasks.CertificateProvider = actor.TaskNotStarted + donor.Tasks.CertificateProvider = task.StateNotStarted if err := donorStore.Put(r.Context(), donor); err != nil { return err } @@ -49,7 +49,7 @@ func ConfirmYourCertificateProviderIsNotRelated(tmpl template.Template, donorSto if data.Errors.None() && data.Form.YesNo.IsYes() { donor.CertificateProviderNotRelatedConfirmedAt = now() - donor.Tasks.CheckYourLpa = actor.TaskInProgress + donor.Tasks.CheckYourLpa = task.StateInProgress if err := donorStore.Put(r.Context(), donor); err != nil { return err diff --git a/internal/donor/donorpage/confirm_your_certificate_provider_is_not_related_test.go b/internal/donor/donorpage/confirm_your_certificate_provider_is_not_related_test.go index 3f6a494596..961b4f2dcf 100644 --- a/internal/donor/donorpage/confirm_your_certificate_provider_is_not_related_test.go +++ b/internal/donor/donorpage/confirm_your_certificate_provider_is_not_related_test.go @@ -7,10 +7,10 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -20,9 +20,9 @@ func TestGetConfirmYourCertificateProviderIsNotRelated(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &donordata.DonorProvidedDetails{ - Tasks: donordata.DonorTasks{ - CertificateProvider: actor.TaskCompleted, + donor := &donordata.Provided{ + Tasks: donordata.Tasks{ + CertificateProvider: task.StateCompleted, }, } @@ -46,7 +46,7 @@ func TestGetConfirmYourCertificateProviderIsNotRelatedWhenNoCertificateProvider( w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - err := ConfirmYourCertificateProviderIsNotRelated(nil, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ConfirmYourCertificateProviderIsNotRelated(nil, nil, nil)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", }) resp := w.Result() @@ -65,9 +65,9 @@ func TestGetConfirmYourCertificateProviderIsNotRelatedWhenTemplateErrors(t *test Execute(w, mock.Anything). Return(expectedError) - err := ConfirmYourCertificateProviderIsNotRelated(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ - Tasks: donordata.DonorTasks{ - CertificateProvider: actor.TaskCompleted, + err := ConfirmYourCertificateProviderIsNotRelated(template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ + Tasks: donordata.Tasks{ + CertificateProvider: task.StateCompleted, }, }) resp := w.Result() @@ -87,38 +87,38 @@ func TestPostConfirmYourCertificateProviderIsNotRelated(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{CanSign: form.Yes}, HasSentApplicationUpdatedEvent: true, - Tasks: donordata.DonorTasks{ - YourDetails: actor.TaskCompleted, - ChooseAttorneys: actor.TaskCompleted, - ChooseReplacementAttorneys: actor.TaskCompleted, - WhenCanTheLpaBeUsed: actor.TaskCompleted, - Restrictions: actor.TaskCompleted, - CertificateProvider: actor.TaskCompleted, - PeopleToNotify: actor.TaskCompleted, - AddCorrespondent: actor.TaskCompleted, - CheckYourLpa: actor.TaskInProgress, + Tasks: donordata.Tasks{ + YourDetails: task.StateCompleted, + ChooseAttorneys: task.StateCompleted, + ChooseReplacementAttorneys: task.StateCompleted, + WhenCanTheLpaBeUsed: task.StateCompleted, + Restrictions: task.StateCompleted, + CertificateProvider: task.StateCompleted, + PeopleToNotify: task.StateCompleted, + AddCorrespondent: task.StateCompleted, + CheckYourLpa: task.StateInProgress, }, CertificateProviderNotRelatedConfirmedAt: testNow, }). Return(nil) - err := ConfirmYourCertificateProviderIsNotRelated(nil, donorStore, testNowFn)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ConfirmYourCertificateProviderIsNotRelated(nil, donorStore, testNowFn)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{CanSign: form.Yes}, HasSentApplicationUpdatedEvent: true, - Tasks: donordata.DonorTasks{ - YourDetails: actor.TaskCompleted, - ChooseAttorneys: actor.TaskCompleted, - ChooseReplacementAttorneys: actor.TaskCompleted, - WhenCanTheLpaBeUsed: actor.TaskCompleted, - Restrictions: actor.TaskCompleted, - CertificateProvider: actor.TaskCompleted, - PeopleToNotify: actor.TaskCompleted, - AddCorrespondent: actor.TaskCompleted, + Tasks: donordata.Tasks{ + YourDetails: task.StateCompleted, + ChooseAttorneys: task.StateCompleted, + ChooseReplacementAttorneys: task.StateCompleted, + WhenCanTheLpaBeUsed: task.StateCompleted, + Restrictions: task.StateCompleted, + CertificateProvider: task.StateCompleted, + PeopleToNotify: task.StateCompleted, + AddCorrespondent: task.StateCompleted, }, }) resp := w.Result() @@ -139,21 +139,21 @@ func TestPostConfirmYourCertificateProviderIsNotRelatedChooseNew(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", - Tasks: donordata.DonorTasks{ - CertificateProvider: actor.TaskNotStarted, + Tasks: donordata.Tasks{ + CertificateProvider: task.StateNotStarted, }, }). Return(nil) - err := ConfirmYourCertificateProviderIsNotRelated(nil, donorStore, testNowFn)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := ConfirmYourCertificateProviderIsNotRelated(nil, donorStore, testNowFn)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", CertificateProvider: donordata.CertificateProvider{ FirstNames: "John", }, - Tasks: donordata.DonorTasks{ - CertificateProvider: actor.TaskCompleted, + Tasks: donordata.Tasks{ + CertificateProvider: task.StateCompleted, }, }) resp := w.Result() @@ -184,9 +184,9 @@ func TestPostConfirmYourCertificateProviderIsNotRelatedWhenStoreErrors(t *testin Put(r.Context(), mock.Anything). Return(expectedError) - err := ConfirmYourCertificateProviderIsNotRelated(nil, donorStore, testNowFn)(testAppData, w, r, &donordata.DonorProvidedDetails{ - Tasks: donordata.DonorTasks{ - CertificateProvider: actor.TaskCompleted, + err := ConfirmYourCertificateProviderIsNotRelated(nil, donorStore, testNowFn)(testAppData, w, r, &donordata.Provided{ + Tasks: donordata.Tasks{ + CertificateProvider: task.StateCompleted, }, }) @@ -207,9 +207,9 @@ func TestPostConfirmYourCertificateProviderIsNotRelatedWhenValidationErrors(t *t })). Return(nil) - err := ConfirmYourCertificateProviderIsNotRelated(template.Execute, nil, testNowFn)(testAppData, w, r, &donordata.DonorProvidedDetails{ - Tasks: donordata.DonorTasks{ - CertificateProvider: actor.TaskCompleted, + err := ConfirmYourCertificateProviderIsNotRelated(template.Execute, nil, testNowFn)(testAppData, w, r, &donordata.Provided{ + Tasks: donordata.Tasks{ + CertificateProvider: task.StateCompleted, }, }) resp := w.Result() diff --git a/internal/donor/donorpage/delete_lpa.go b/internal/donor/donorpage/delete_lpa.go index bfe3826b54..943f2a04bb 100644 --- a/internal/donor/donorpage/delete_lpa.go +++ b/internal/donor/donorpage/delete_lpa.go @@ -13,12 +13,12 @@ import ( type deleteLpaData struct { App page.AppData Errors validation.List - Donor *donordata.DonorProvidedDetails + Donor *donordata.Provided } func DeleteLpa(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { if r.Method == http.MethodPost { if err := donorStore.Delete(r.Context()); err != nil { return err diff --git a/internal/donor/donorpage/delete_lpa_test.go b/internal/donor/donorpage/delete_lpa_test.go index 5523aacc0b..57cf67f766 100644 --- a/internal/donor/donorpage/delete_lpa_test.go +++ b/internal/donor/donorpage/delete_lpa_test.go @@ -20,11 +20,11 @@ func TestGetDeleteLpa(t *testing.T) { template.EXPECT(). Execute(w, &deleteLpaData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{}, + Donor: &donordata.Provided{}, }). Return(nil) - err := DeleteLpa(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := DeleteLpa(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -40,7 +40,7 @@ func TestGetDeleteLpaWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := DeleteLpa(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := DeleteLpa(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -57,7 +57,7 @@ func TestPostDeleteLpa(t *testing.T) { Delete(r.Context()). Return(nil) - err := DeleteLpa(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaUID: "lpa-uid"}) + err := DeleteLpa(nil, donorStore)(testAppData, w, r, &donordata.Provided{LpaUID: "lpa-uid"}) resp := w.Result() assert.Nil(t, err) @@ -75,7 +75,7 @@ func TestPostDeleteLpaWhenStoreErrors(t *testing.T) { Delete(r.Context()). Return(expectedError) - err := DeleteLpa(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := DeleteLpa(nil, donorStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } diff --git a/internal/donor/donorpage/do_you_want_to_notify_people.go b/internal/donor/donorpage/do_you_want_to_notify_people.go index 476469a967..05674cb1d0 100644 --- a/internal/donor/donorpage/do_you_want_to_notify_people.go +++ b/internal/donor/donorpage/do_you_want_to_notify_people.go @@ -4,10 +4,10 @@ import ( "net/http" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -15,12 +15,12 @@ type doYouWantToNotifyPeopleData struct { App page.AppData Errors validation.List Form *form.YesNoForm - Donor *donordata.DonorProvidedDetails + Donor *donordata.Provided HowWorkTogether string } func DoYouWantToNotifyPeople(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { if len(donor.PeopleToNotify) > 0 { return page.Paths.ChoosePeopleToNotifySummary.Redirect(w, r, appData, donor) } @@ -46,13 +46,13 @@ func DoYouWantToNotifyPeople(tmpl template.Template, donorStore DonorStore) Hand if data.Errors.None() { donor.DoYouWantToNotifyPeople = data.Form.YesNo - donor.Tasks.PeopleToNotify = actor.TaskInProgress + donor.Tasks.PeopleToNotify = task.StateInProgress redirectPath := page.Paths.ChoosePeopleToNotify if donor.DoYouWantToNotifyPeople == form.No { redirectPath = page.Paths.TaskList - donor.Tasks.PeopleToNotify = actor.TaskCompleted + donor.Tasks.PeopleToNotify = task.StateCompleted } if err := donorStore.Put(r.Context(), donor); err != nil { diff --git a/internal/donor/donorpage/do_you_want_to_notify_people_test.go b/internal/donor/donorpage/do_you_want_to_notify_people_test.go index 60b44a239d..98006b198e 100644 --- a/internal/donor/donorpage/do_you_want_to_notify_people_test.go +++ b/internal/donor/donorpage/do_you_want_to_notify_people_test.go @@ -7,11 +7,11 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -25,12 +25,12 @@ func TestGetDoYouWantToNotifyPeople(t *testing.T) { template.EXPECT(). Execute(w, &doYouWantToNotifyPeopleData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{}, + Donor: &donordata.Provided{}, Form: form.NewYesNoForm(form.YesNoUnknown), }). Return(nil) - err := DoYouWantToNotifyPeople(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := DoYouWantToNotifyPeople(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -45,14 +45,14 @@ func TestGetDoYouWantToNotifyPeopleFromStore(t *testing.T) { template.EXPECT(). Execute(w, &doYouWantToNotifyPeopleData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{ + Donor: &donordata.Provided{ DoYouWantToNotifyPeople: form.Yes, }, Form: form.NewYesNoForm(form.Yes), }). Return(nil) - err := DoYouWantToNotifyPeople(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := DoYouWantToNotifyPeople(template.Execute, nil)(testAppData, w, r, &donordata.Provided{ DoYouWantToNotifyPeople: form.Yes, }) resp := w.Result() @@ -89,7 +89,7 @@ func TestGetDoYouWantToNotifyPeopleHowAttorneysWorkTogether(t *testing.T) { template.EXPECT(). Execute(w, &doYouWantToNotifyPeopleData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{ + Donor: &donordata.Provided{ DoYouWantToNotifyPeople: form.Yes, AttorneyDecisions: donordata.AttorneyDecisions{How: tc.howWorkTogether}, }, @@ -98,7 +98,7 @@ func TestGetDoYouWantToNotifyPeopleHowAttorneysWorkTogether(t *testing.T) { }). Return(nil) - err := DoYouWantToNotifyPeople(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := DoYouWantToNotifyPeople(template.Execute, nil)(testAppData, w, r, &donordata.Provided{ DoYouWantToNotifyPeople: form.Yes, AttorneyDecisions: donordata.AttorneyDecisions{How: tc.howWorkTogether}, }) @@ -116,7 +116,7 @@ func TestGetDoYouWantToNotifyPeopleFromStoreWithPeople(t *testing.T) { template := newMockTemplate(t) - err := DoYouWantToNotifyPeople(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := DoYouWantToNotifyPeople(template.Execute, nil)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", PeopleToNotify: donordata.PeopleToNotify{ {UID: actoruid.New()}, @@ -138,7 +138,7 @@ func TestGetDoYouWantToNotifyPeopleWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := DoYouWantToNotifyPeople(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := DoYouWantToNotifyPeople(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -150,19 +150,19 @@ func TestPostDoYouWantToNotifyPeople(t *testing.T) { YesNo form.YesNo ExistingAnswer form.YesNo ExpectedRedirect page.LpaPath - ExpectedStatus actor.TaskState + ExpectedStatus task.State }{ { YesNo: form.Yes, ExistingAnswer: form.No, ExpectedRedirect: page.Paths.ChoosePeopleToNotify, - ExpectedStatus: actor.TaskInProgress, + ExpectedStatus: task.StateInProgress, }, { YesNo: form.No, ExistingAnswer: form.Yes, ExpectedRedirect: page.Paths.TaskList, - ExpectedStatus: actor.TaskCompleted, + ExpectedStatus: task.StateCompleted, }, } @@ -178,31 +178,31 @@ func TestPostDoYouWantToNotifyPeople(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", DoYouWantToNotifyPeople: tc.YesNo, - Tasks: donordata.DonorTasks{ - YourDetails: actor.TaskCompleted, - ChooseAttorneys: actor.TaskCompleted, - ChooseReplacementAttorneys: actor.TaskCompleted, - WhenCanTheLpaBeUsed: actor.TaskCompleted, - Restrictions: actor.TaskCompleted, - CertificateProvider: actor.TaskCompleted, + Tasks: donordata.Tasks{ + YourDetails: task.StateCompleted, + ChooseAttorneys: task.StateCompleted, + ChooseReplacementAttorneys: task.StateCompleted, + WhenCanTheLpaBeUsed: task.StateCompleted, + Restrictions: task.StateCompleted, + CertificateProvider: task.StateCompleted, PeopleToNotify: tc.ExpectedStatus, }, }). Return(nil) - err := DoYouWantToNotifyPeople(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := DoYouWantToNotifyPeople(nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", DoYouWantToNotifyPeople: tc.ExistingAnswer, - Tasks: donordata.DonorTasks{ - YourDetails: actor.TaskCompleted, - ChooseAttorneys: actor.TaskCompleted, - ChooseReplacementAttorneys: actor.TaskCompleted, - WhenCanTheLpaBeUsed: actor.TaskCompleted, - Restrictions: actor.TaskCompleted, - CertificateProvider: actor.TaskCompleted, + Tasks: donordata.Tasks{ + YourDetails: task.StateCompleted, + ChooseAttorneys: task.StateCompleted, + ChooseReplacementAttorneys: task.StateCompleted, + WhenCanTheLpaBeUsed: task.StateCompleted, + Restrictions: task.StateCompleted, + CertificateProvider: task.StateCompleted, }, }) resp := w.Result() @@ -225,13 +225,13 @@ func TestPostDoYouWantToNotifyPeopleWhenStoreErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ DoYouWantToNotifyPeople: form.Yes, - Tasks: donordata.DonorTasks{PeopleToNotify: actor.TaskInProgress}, + Tasks: donordata.Tasks{PeopleToNotify: task.StateInProgress}, }). Return(expectedError) - err := DoYouWantToNotifyPeople(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := DoYouWantToNotifyPeople(nil, donorStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -248,7 +248,7 @@ func TestPostDoYouWantToNotifyPeopleWhenValidationErrors(t *testing.T) { })). Return(nil) - err := DoYouWantToNotifyPeople(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := DoYouWantToNotifyPeople(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/enter_access_code_test.go b/internal/donor/donorpage/enter_access_code_test.go index 8241e1feb8..890e369497 100644 --- a/internal/donor/donorpage/enter_access_code_test.go +++ b/internal/donor/donorpage/enter_access_code_test.go @@ -11,6 +11,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + sharecode "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -67,7 +68,7 @@ func TestPostEnterAccessCode(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - shareCode := actor.ShareCodeData{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID} + shareCode := sharecode.Data{LpaKey: dynamo.LpaKey("lpa-id"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("")), ActorUID: testUID} shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). @@ -103,7 +104,7 @@ func TestPostEnterAccessCodeOnShareCodeStoreError(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), actor.TypeDonor, "abcdef123456"). - Return(actor.ShareCodeData{LpaKey: "lpa-id", LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, expectedError) + Return(sharecode.Data{LpaKey: "lpa-id", LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, expectedError) err := EnterAccessCode(nil, nil, shareCodeStore, nil)(testAppData, w, r) resp := w.Result() @@ -135,7 +136,7 @@ func TestPostEnterAccessCodeOnShareCodeStoreNotFoundError(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), actor.TypeDonor, "abcdef123456"). - Return(actor.ShareCodeData{LpaKey: "lpa-id", LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, dynamo.NotFoundError{}) + Return(sharecode.Data{LpaKey: "lpa-id", LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, dynamo.NotFoundError{}) err := EnterAccessCode(nil, template.Execute, shareCodeStore, nil)(testAppData, w, r) resp := w.Result() @@ -156,7 +157,7 @@ func TestPostEnterAccessCodeOnDonorStoreError(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). Get(r.Context(), actor.TypeDonor, "abcdef123456"). - Return(actor.ShareCodeData{LpaKey: "lpa-id", LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, nil) + Return(sharecode.Data{LpaKey: "lpa-id", LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey(""))}, nil) donorStore := newMockDonorStore(t) donorStore.EXPECT(). diff --git a/internal/donor/donorpage/enter_correspondent_address.go b/internal/donor/donorpage/enter_correspondent_address.go index e6082388e0..a531eed9ef 100644 --- a/internal/donor/donorpage/enter_correspondent_address.go +++ b/internal/donor/donorpage/enter_correspondent_address.go @@ -4,16 +4,16 @@ import ( "net/http" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" ) func EnterCorrespondentAddress(logger Logger, tmpl template.Template, addressClient AddressClient, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := newChooseAddressData( appData, "correspondent", @@ -31,7 +31,7 @@ func EnterCorrespondentAddress(logger Logger, tmpl template.Template, addressCli data.Errors = data.Form.Validate(false) setAddress := func(address place.Address) error { - donor.Tasks.AddCorrespondent = actor.TaskCompleted + donor.Tasks.AddCorrespondent = task.StateCompleted donor.Correspondent.Address = *data.Form.Address if err := donorStore.Put(r.Context(), donor); err != nil { diff --git a/internal/donor/donorpage/enter_correspondent_address_test.go b/internal/donor/donorpage/enter_correspondent_address_test.go index 4dd5738351..9168a9e414 100644 --- a/internal/donor/donorpage/enter_correspondent_address_test.go +++ b/internal/donor/donorpage/enter_correspondent_address_test.go @@ -8,11 +8,11 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -33,7 +33,7 @@ func TestGetEnterCorrespondentAddress(t *testing.T) { }). Return(nil) - err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Correspondent: donordata.Correspondent{ FirstNames: "John", LastName: "Smith", @@ -66,7 +66,7 @@ func TestGetEnterCorrespondentAddressFromStore(t *testing.T) { }). Return(nil) - err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Correspondent: donordata.Correspondent{ Address: address, }, @@ -96,7 +96,7 @@ func TestGetEnterCorrespondentAddressManual(t *testing.T) { }). Return(nil) - err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -118,7 +118,7 @@ func TestGetEnterCorrespondentAddressWhenTemplateErrors(t *testing.T) { }). Return(expectedError) - err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -141,18 +141,18 @@ func TestPostEnterCorrespondentAddressManual(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Correspondent: donordata.Correspondent{ Address: testAddress, }, - Tasks: donordata.DonorTasks{ - AddCorrespondent: actor.TaskCompleted, + Tasks: donordata.Tasks{ + AddCorrespondent: task.StateCompleted, }, }). Return(nil) - err := EnterCorrespondentAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterCorrespondentAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", }) resp := w.Result() @@ -181,7 +181,7 @@ func TestPostEnterCorrespondentAddressManualWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := EnterCorrespondentAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := EnterCorrespondentAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -202,19 +202,19 @@ func TestPostEnterCorrespondentAddressManualFromStore(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Correspondent: donordata.Correspondent{ FirstNames: "John", Address: testAddress, }, - Tasks: donordata.DonorTasks{ - AddCorrespondent: actor.TaskCompleted, + Tasks: donordata.Tasks{ + AddCorrespondent: task.StateCompleted, }, }). Return(nil) - err := EnterCorrespondentAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterCorrespondentAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Correspondent: donordata.Correspondent{ FirstNames: "John", @@ -261,7 +261,7 @@ func TestPostEnterCorrespondentAddressManualWhenValidationError(t *testing.T) { }). Return(nil) - err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -302,7 +302,7 @@ func TestPostEnterCorrespondentAddressSelect(t *testing.T) { }). Return(nil) - err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -345,7 +345,7 @@ func TestPostEnterCorrespondentAddressSelectWhenValidationError(t *testing.T) { }). Return(nil) - err := EnterCorrespondentAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := EnterCorrespondentAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -387,7 +387,7 @@ func TestPostEnterCorrespondentAddressLookup(t *testing.T) { }). Return(nil) - err := EnterCorrespondentAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := EnterCorrespondentAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -430,7 +430,7 @@ func TestPostEnterCorrespondentAddressLookupError(t *testing.T) { }). Return(nil) - err := EnterCorrespondentAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := EnterCorrespondentAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -478,7 +478,7 @@ func TestPostEnterCorrespondentAddressInvalidPostcodeError(t *testing.T) { }). Return(nil) - err := EnterCorrespondentAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := EnterCorrespondentAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -520,7 +520,7 @@ func TestPostEnterCorrespondentAddressValidPostcodeNoAddresses(t *testing.T) { }). Return(nil) - err := EnterCorrespondentAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := EnterCorrespondentAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -551,7 +551,7 @@ func TestPostEnterCorrespondentAddressLookupWhenValidationError(t *testing.T) { }). Return(nil) - err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -582,7 +582,7 @@ func TestPostEnterCorrespondentAddressReuse(t *testing.T) { }). Return(nil) - err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{Address: place.Address{Line1: "donor lane"}}, }) resp := w.Result() @@ -614,14 +614,14 @@ func TestPostEnterCorrespondentAddressReuseSelect(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Correspondent: updatedCorrespondent, - Tasks: donordata.DonorTasks{AddCorrespondent: actor.TaskCompleted}, + Tasks: donordata.Tasks{AddCorrespondent: task.StateCompleted}, }). Return(nil) - err := EnterCorrespondentAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterCorrespondentAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", }) resp := w.Result() @@ -646,7 +646,7 @@ func TestPostEnterCorrespondentAddressReuseSelectWhenError(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := EnterCorrespondentAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterCorrespondentAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", }) @@ -678,7 +678,7 @@ func TestPostEnterCorrespondentAddressReuseSelectWhenValidationError(t *testing. }). Return(nil) - err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{Address: place.Address{Line1: "donor lane"}}, }) resp := w.Result() diff --git a/internal/donor/donorpage/enter_correspondent_details.go b/internal/donor/donorpage/enter_correspondent_details.go index 9da2bd88d1..06838c66b8 100644 --- a/internal/donor/donorpage/enter_correspondent_details.go +++ b/internal/donor/donorpage/enter_correspondent_details.go @@ -9,6 +9,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -20,7 +21,7 @@ type enterCorrespondentDetailsData struct { } func EnterCorrespondentDetails(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &enterCorrespondentDetailsData{ App: appData, Form: &enterCorrespondentDetailsForm{ @@ -48,11 +49,11 @@ func EnterCorrespondentDetails(tmpl template.Template, donorStore DonorStore) Ha var redirect page.LpaPath if donor.Correspondent.WantAddress.IsNo() { donor.Correspondent.Address = place.Address{} - donor.Tasks.AddCorrespondent = actor.TaskCompleted + donor.Tasks.AddCorrespondent = task.StateCompleted redirect = page.Paths.TaskList } else { if !donor.Tasks.AddCorrespondent.Completed() && donor.Correspondent.Address.Line1 == "" { - donor.Tasks.AddCorrespondent = actor.TaskInProgress + donor.Tasks.AddCorrespondent = task.StateInProgress } redirect = page.Paths.EnterCorrespondentAddress } diff --git a/internal/donor/donorpage/enter_correspondent_details_test.go b/internal/donor/donorpage/enter_correspondent_details_test.go index 1748d4932a..ab30e101a3 100644 --- a/internal/donor/donorpage/enter_correspondent_details_test.go +++ b/internal/donor/donorpage/enter_correspondent_details_test.go @@ -7,11 +7,11 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -29,7 +29,7 @@ func TestGetEnterCorrespondentDetails(t *testing.T) { }). Return(nil) - err := EnterCorrespondentDetails(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := EnterCorrespondentDetails(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -51,7 +51,7 @@ func TestGetEnterCorrespondentDetailsFromStore(t *testing.T) { }). Return(nil) - err := EnterCorrespondentDetails(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterCorrespondentDetails(template.Execute, nil)(testAppData, w, r, &donordata.Provided{ Correspondent: donordata.Correspondent{ FirstNames: "John", }, @@ -71,7 +71,7 @@ func TestGetEnterCorrespondentDetailsWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := EnterCorrespondentDetails(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := EnterCorrespondentDetails(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -92,7 +92,7 @@ func TestPostEnterCorrespondentDetails(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "John", LastName: "Smith"}, Correspondent: donordata.Correspondent{ @@ -101,11 +101,11 @@ func TestPostEnterCorrespondentDetails(t *testing.T) { Email: "email@example.com", WantAddress: form.No, }, - Tasks: donordata.DonorTasks{AddCorrespondent: actor.TaskCompleted}, + Tasks: donordata.Tasks{AddCorrespondent: task.StateCompleted}, }). Return(nil) - err := EnterCorrespondentDetails(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterCorrespondentDetails(nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "John", LastName: "Smith"}, }) @@ -130,7 +130,7 @@ func TestPostEnterCorrespondentDetailsWhenWantsAddress(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "John", LastName: "Smith"}, Correspondent: donordata.Correspondent{ @@ -139,11 +139,11 @@ func TestPostEnterCorrespondentDetailsWhenWantsAddress(t *testing.T) { Email: "email@example.com", WantAddress: form.Yes, }, - Tasks: donordata.DonorTasks{AddCorrespondent: actor.TaskInProgress}, + Tasks: donordata.Tasks{AddCorrespondent: task.StateInProgress}, }). Return(nil) - err := EnterCorrespondentDetails(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterCorrespondentDetails(nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "John", LastName: "Smith"}, }) @@ -172,7 +172,7 @@ func TestPostEnterCorrespondentDetailsWhenValidationError(t *testing.T) { })). Return(nil) - err := EnterCorrespondentDetails(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterCorrespondentDetails(template.Execute, nil)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{ FirstNames: "John", LastName: "Doe", @@ -201,7 +201,7 @@ func TestPostEnterCorrespondentDetailsWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := EnterCorrespondentDetails(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterCorrespondentDetails(nil, donorStore)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{ FirstNames: "John", Address: place.Address{Line1: "abc"}, diff --git a/internal/donor/donorpage/enter_replacement_trust_corporation.go b/internal/donor/donorpage/enter_replacement_trust_corporation.go index 8b0fa6db40..9783258363 100644 --- a/internal/donor/donorpage/enter_replacement_trust_corporation.go +++ b/internal/donor/donorpage/enter_replacement_trust_corporation.go @@ -17,7 +17,7 @@ type enterReplacementTrustCorporationData struct { } func EnterReplacementTrustCorporation(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { trustCorporation := donor.ReplacementAttorneys.TrustCorporation data := &enterReplacementTrustCorporationData{ diff --git a/internal/donor/donorpage/enter_replacement_trust_corporation_address.go b/internal/donor/donorpage/enter_replacement_trust_corporation_address.go index 1503fbc7fa..754b2c1269 100644 --- a/internal/donor/donorpage/enter_replacement_trust_corporation_address.go +++ b/internal/donor/donorpage/enter_replacement_trust_corporation_address.go @@ -11,7 +11,7 @@ import ( ) func EnterReplacementTrustCorporationAddress(logger Logger, tmpl template.Template, addressClient AddressClient, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { trustCorporation := donor.ReplacementAttorneys.TrustCorporation data := newChooseAddressData( diff --git a/internal/donor/donorpage/enter_replacement_trust_corporation_address_test.go b/internal/donor/donorpage/enter_replacement_trust_corporation_address_test.go index 8a920eeebb..65d1f0dac2 100644 --- a/internal/donor/donorpage/enter_replacement_trust_corporation_address_test.go +++ b/internal/donor/donorpage/enter_replacement_trust_corporation_address_test.go @@ -8,11 +8,11 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -32,7 +32,7 @@ func TestGetEnterReplacementTrustCorporationAddress(t *testing.T) { }). Return(nil) - err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{Name: "a"}}, }) resp := w.Result() @@ -59,7 +59,7 @@ func TestGetEnterReplacementTrustCorporationAddressManual(t *testing.T) { }). Return(nil) - err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -82,7 +82,7 @@ func TestGetEnterReplacementTrustCorporationAddressWhenTemplateErrors(t *testing }). Return(expectedError) - err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -107,9 +107,9 @@ func TestPostEnterReplacementTrustCorporationAddressManual(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", - Tasks: donordata.DonorTasks{ChooseReplacementAttorneys: actor.TaskCompleted}, + Tasks: donordata.Tasks{ChooseReplacementAttorneys: task.StateCompleted}, ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{ Name: "a", Address: testAddress, @@ -117,7 +117,7 @@ func TestPostEnterReplacementTrustCorporationAddressManual(t *testing.T) { }). Return(nil) - err := EnterReplacementTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterReplacementTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{ Name: "a", @@ -150,7 +150,7 @@ func TestPostEnterReplacementTrustCorporationAddressManualWhenStoreErrors(t *tes Put(r.Context(), mock.Anything). Return(expectedError) - err := EnterReplacementTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterReplacementTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{ ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) @@ -173,9 +173,9 @@ func TestPostEnterReplacementTrustCorporationAddressManualFromStore(t *testing.T donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", - Tasks: donordata.DonorTasks{ChooseReplacementAttorneys: actor.TaskCompleted}, + Tasks: donordata.Tasks{ChooseReplacementAttorneys: task.StateCompleted}, ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{ Name: "John", Address: testAddress, @@ -183,7 +183,7 @@ func TestPostEnterReplacementTrustCorporationAddressManualFromStore(t *testing.T }). Return(nil) - err := EnterReplacementTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterReplacementTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{ Name: "John", @@ -231,7 +231,7 @@ func TestPostEnterReplacementTrustCorporationAddressManualWhenValidationError(t }). Return(nil) - err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -266,7 +266,7 @@ func TestPostEnterReplacementTrustCorporationAddressPostcodeSelect(t *testing.T) }). Return(nil) - err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -310,7 +310,7 @@ func TestPostEnterReplacementTrustCorporationAddressPostcodeSelectWhenValidation }). Return(nil) - err := EnterReplacementTrustCorporationAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterReplacementTrustCorporationAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{ ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -353,7 +353,7 @@ func TestPostEnterReplacementTrustCorporationPostcodeLookup(t *testing.T) { }). Return(nil) - err := EnterReplacementTrustCorporationAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterReplacementTrustCorporationAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{ ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -397,7 +397,7 @@ func TestPostEnterReplacementTrustCorporationPostcodeLookupError(t *testing.T) { }). Return(nil) - err := EnterReplacementTrustCorporationAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterReplacementTrustCorporationAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{ ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -446,7 +446,7 @@ func TestPostEnterReplacementTrustCorporationAddressPostcodeLookupInvalidPostcod }). Return(nil) - err := EnterReplacementTrustCorporationAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterReplacementTrustCorporationAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{ ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -487,7 +487,7 @@ func TestPostEnterReplacementTrustCorporationAddressPostcodeLookupValidPostcodeN }). Return(nil) - err := EnterReplacementTrustCorporationAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterReplacementTrustCorporationAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{ ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -519,7 +519,7 @@ func TestPostEnterReplacementTrustCorporationAddressPostcodeLookupWhenValidation }). Return(nil) - err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -551,7 +551,7 @@ func TestPostEnterReplacementTrustCorporationAddressReuse(t *testing.T) { }). Return(nil) - err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{Address: place.Address{Line1: "donor lane"}}, ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) @@ -585,14 +585,14 @@ func TestPostEnterReplacementTrustCorporationAddressReuseSelect(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{TrustCorporation: updatedTrustCorporation}, - Tasks: donordata.DonorTasks{ChooseReplacementAttorneys: actor.TaskCompleted}, + Tasks: donordata.Tasks{ChooseReplacementAttorneys: task.StateCompleted}, }). Return(nil) - err := EnterReplacementTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterReplacementTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{ Name: "a", @@ -629,7 +629,7 @@ func TestPostEnterReplacementTrustCorporationAddressReuseSelectWhenValidationErr }). Return(nil) - err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{Address: place.Address{Line1: "donor lane"}}, ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) @@ -671,7 +671,7 @@ func TestPostEnterReplacementTrustCorporationAddressManuallyFromAnotherPage(t *t r, _ := http.NewRequest(http.MethodPost, tc.requestUrl, strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{ Address: place.Address{ diff --git a/internal/donor/donorpage/enter_replacement_trust_corporation_test.go b/internal/donor/donorpage/enter_replacement_trust_corporation_test.go index 4ad4118f32..ab03883faa 100644 --- a/internal/donor/donorpage/enter_replacement_trust_corporation_test.go +++ b/internal/donor/donorpage/enter_replacement_trust_corporation_test.go @@ -7,9 +7,9 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -27,7 +27,7 @@ func TestGetEnterReplacementTrustCorporation(t *testing.T) { }). Return(nil) - err := EnterReplacementTrustCorporation(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := EnterReplacementTrustCorporation(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -46,7 +46,7 @@ func TestGetEnterReplacementTrustCorporationWhenTemplateErrors(t *testing.T) { }). Return(expectedError) - err := EnterReplacementTrustCorporation(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := EnterReplacementTrustCorporation(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -66,7 +66,7 @@ func TestPostEnterReplacementTrustCorporation(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{ TrustCorporation: donordata.TrustCorporation{ @@ -75,13 +75,13 @@ func TestPostEnterReplacementTrustCorporation(t *testing.T) { Email: "name@example.com", }, }, - Tasks: donordata.DonorTasks{ - ChooseReplacementAttorneys: actor.TaskInProgress, + Tasks: donordata.Tasks{ + ChooseReplacementAttorneys: task.StateInProgress, }, }). Return(nil) - err := EnterReplacementTrustCorporation(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterReplacementTrustCorporation(nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", }) resp := w.Result() @@ -108,7 +108,7 @@ func TestPostEnterReplacementTrustCorporationWhenValidationError(t *testing.T) { })). Return(nil) - err := EnterReplacementTrustCorporation(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterReplacementTrustCorporation(template.Execute, nil)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, }) resp := w.Result() @@ -133,7 +133,7 @@ func TestPostEnterReplacementTrustCorporationWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := EnterReplacementTrustCorporation(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := EnterReplacementTrustCorporation(nil, donorStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } diff --git a/internal/donor/donorpage/enter_trust_corporation.go b/internal/donor/donorpage/enter_trust_corporation.go index 936c58d10b..44e0f6f04a 100644 --- a/internal/donor/donorpage/enter_trust_corporation.go +++ b/internal/donor/donorpage/enter_trust_corporation.go @@ -17,7 +17,7 @@ type enterTrustCorporationData struct { } func EnterTrustCorporation(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { trustCorporation := donor.Attorneys.TrustCorporation data := &enterTrustCorporationData{ diff --git a/internal/donor/donorpage/enter_trust_corporation_address.go b/internal/donor/donorpage/enter_trust_corporation_address.go index 7b3b40cd7f..946eb195b7 100644 --- a/internal/donor/donorpage/enter_trust_corporation_address.go +++ b/internal/donor/donorpage/enter_trust_corporation_address.go @@ -11,7 +11,7 @@ import ( ) func EnterTrustCorporationAddress(logger Logger, tmpl template.Template, addressClient AddressClient, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { trustCorporation := donor.Attorneys.TrustCorporation data := newChooseAddressData( diff --git a/internal/donor/donorpage/enter_trust_corporation_address_test.go b/internal/donor/donorpage/enter_trust_corporation_address_test.go index 3d129d1400..6232d2b189 100644 --- a/internal/donor/donorpage/enter_trust_corporation_address_test.go +++ b/internal/donor/donorpage/enter_trust_corporation_address_test.go @@ -8,11 +8,11 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -32,7 +32,7 @@ func TestGetEnterTrustCorporationAddress(t *testing.T) { }). Return(nil) - err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{Name: "a"}}, }) resp := w.Result() @@ -59,7 +59,7 @@ func TestGetEnterTrustCorporationAddressManual(t *testing.T) { }). Return(nil) - err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -82,7 +82,7 @@ func TestGetEnterTrustCorporationAddressWhenTemplateErrors(t *testing.T) { }). Return(expectedError) - err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -107,9 +107,9 @@ func TestPostEnterTrustCorporationAddressManual(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", - Tasks: donordata.DonorTasks{ChooseAttorneys: actor.TaskCompleted}, + Tasks: donordata.Tasks{ChooseAttorneys: task.StateCompleted}, Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{ Name: "a", Address: testAddress, @@ -117,7 +117,7 @@ func TestPostEnterTrustCorporationAddressManual(t *testing.T) { }). Return(nil) - err := EnterTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{ Name: "a", @@ -150,7 +150,7 @@ func TestPostEnterTrustCorporationAddressManualWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := EnterTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{ Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) @@ -173,9 +173,9 @@ func TestPostEnterTrustCorporationAddressManualFromStore(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", - Tasks: donordata.DonorTasks{ChooseAttorneys: actor.TaskCompleted}, + Tasks: donordata.Tasks{ChooseAttorneys: task.StateCompleted}, Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{ Name: "John", Address: testAddress, @@ -183,7 +183,7 @@ func TestPostEnterTrustCorporationAddressManualFromStore(t *testing.T) { }). Return(nil) - err := EnterTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{ Name: "John", @@ -231,7 +231,7 @@ func TestPostEnterTrustCorporationAddressManualWhenValidationError(t *testing.T) }). Return(nil) - err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -266,7 +266,7 @@ func TestPostEnterTrustCorporationAddressPostcodeSelect(t *testing.T) { }). Return(nil) - err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -310,7 +310,7 @@ func TestPostEnterTrustCorporationAddressPostcodeSelectWhenValidationError(t *te }). Return(nil) - err := EnterTrustCorporationAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterTrustCorporationAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{ Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -353,7 +353,7 @@ func TestPostEnterTrustCorporationPostcodeLookup(t *testing.T) { }). Return(nil) - err := EnterTrustCorporationAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterTrustCorporationAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{ Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -397,7 +397,7 @@ func TestPostEnterTrustCorporationPostcodeLookupError(t *testing.T) { }). Return(nil) - err := EnterTrustCorporationAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterTrustCorporationAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{ Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -446,7 +446,7 @@ func TestPostEnterTrustCorporationAddressPostcodeLookupInvalidPostcodeError(t *t }). Return(nil) - err := EnterTrustCorporationAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterTrustCorporationAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{ Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -487,7 +487,7 @@ func TestPostEnterTrustCorporationAddressPostcodeLookupValidPostcodeNoAddresses( }). Return(nil) - err := EnterTrustCorporationAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterTrustCorporationAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{ Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -519,7 +519,7 @@ func TestPostEnterTrustCorporationAddressPostcodeLookupWhenValidationError(t *te }). Return(nil) - err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -551,7 +551,7 @@ func TestPostEnterTrustCorporationAddressReuse(t *testing.T) { }). Return(nil) - err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{Address: place.Address{Line1: "donor lane"}}, Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) @@ -585,14 +585,14 @@ func TestPostEnterTrustCorporationAddressReuseSelect(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Attorneys: donordata.Attorneys{TrustCorporation: updatedTrustCorporation}, - Tasks: donordata.DonorTasks{ChooseAttorneys: actor.TaskCompleted}, + Tasks: donordata.Tasks{ChooseAttorneys: task.StateCompleted}, }). Return(nil) - err := EnterTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{ Name: "a", @@ -629,7 +629,7 @@ func TestPostEnterTrustCorporationAddressReuseSelectWhenValidationError(t *testi }). Return(nil) - err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{Address: place.Address{Line1: "donor lane"}}, Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) @@ -671,7 +671,7 @@ func TestPostEnterTrustCorporationAddressManuallyFromAnotherPage(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, tc.requestUrl, strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ LpaID: "lpa-id", Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{ Address: place.Address{ diff --git a/internal/donor/donorpage/enter_trust_corporation_test.go b/internal/donor/donorpage/enter_trust_corporation_test.go index ca0d1320d2..8d8626e9d5 100644 --- a/internal/donor/donorpage/enter_trust_corporation_test.go +++ b/internal/donor/donorpage/enter_trust_corporation_test.go @@ -7,9 +7,9 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -27,7 +27,7 @@ func TestGetEnterTrustCorporation(t *testing.T) { }). Return(nil) - err := EnterTrustCorporation(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := EnterTrustCorporation(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -46,7 +46,7 @@ func TestGetEnterTrustCorporationWhenTemplateErrors(t *testing.T) { }). Return(expectedError) - err := EnterTrustCorporation(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := EnterTrustCorporation(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -66,18 +66,18 @@ func TestPostEnterTrustCorporation(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{ Name: "Co co.", CompanyNumber: "453345", Email: "name@example.com", }}, - Tasks: donordata.DonorTasks{ChooseAttorneys: actor.TaskInProgress}, + Tasks: donordata.Tasks{ChooseAttorneys: task.StateInProgress}, }). Return(nil) - err := EnterTrustCorporation(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterTrustCorporation(nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", }) resp := w.Result() @@ -104,7 +104,7 @@ func TestPostEnterTrustCorporationWhenValidationError(t *testing.T) { })). Return(nil) - err := EnterTrustCorporation(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterTrustCorporation(template.Execute, nil)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, }) resp := w.Result() @@ -129,7 +129,7 @@ func TestPostEnterTrustCorporationWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := EnterTrustCorporation(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := EnterTrustCorporation(nil, donorStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } diff --git a/internal/donor/donorpage/enter_voucher.go b/internal/donor/donorpage/enter_voucher.go index 43e40481f6..5689c7197b 100644 --- a/internal/donor/donorpage/enter_voucher.go +++ b/internal/donor/donorpage/enter_voucher.go @@ -17,7 +17,7 @@ type enterVoucherData struct { } func EnterVoucher(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &enterVoucherData{ App: appData, Form: &enterVoucherForm{ diff --git a/internal/donor/donorpage/enter_voucher_test.go b/internal/donor/donorpage/enter_voucher_test.go index 598ad8db5f..9beb1e04ce 100644 --- a/internal/donor/donorpage/enter_voucher_test.go +++ b/internal/donor/donorpage/enter_voucher_test.go @@ -26,7 +26,7 @@ func TestGetEnterVoucher(t *testing.T) { }). Return(nil) - err := EnterVoucher(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := EnterVoucher(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -42,7 +42,7 @@ func TestGetEnterVoucherWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := EnterVoucher(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := EnterVoucher(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -59,7 +59,7 @@ func TestPostEnterVoucher(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, CertificateProvider: donordata.CertificateProvider{FirstNames: "Barry", LastName: "Bloggs"}, @@ -72,7 +72,7 @@ func TestPostEnterVoucher(t *testing.T) { }). Return(nil) - err := EnterVoucher(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterVoucher(nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, CertificateProvider: donordata.CertificateProvider{FirstNames: "Barry", LastName: "Bloggs"}, @@ -105,7 +105,7 @@ func TestPostEnterVoucherWhenMatches(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, CertificateProvider: donordata.CertificateProvider{FirstNames: "Barry", LastName: "Bloggs"}, @@ -117,7 +117,7 @@ func TestPostEnterVoucherWhenMatches(t *testing.T) { }). Return(nil) - err := EnterVoucher(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterVoucher(nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, CertificateProvider: donordata.CertificateProvider{FirstNames: "Barry", LastName: "Bloggs"}, @@ -148,7 +148,7 @@ func TestPostEnterVoucherWhenValidationErrors(t *testing.T) { })). Return(nil) - err := EnterVoucher(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := EnterVoucher(template.Execute, nil)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, }) resp := w.Result() @@ -173,7 +173,7 @@ func TestPostEnterVoucherWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := EnterVoucher(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := EnterVoucher(nil, donorStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } diff --git a/internal/donor/donorpage/fee_denied.go b/internal/donor/donorpage/fee_denied.go index 843ea688e4..ed7a774ca7 100644 --- a/internal/donor/donorpage/fee_denied.go +++ b/internal/donor/donorpage/fee_denied.go @@ -10,13 +10,13 @@ import ( ) type feeDeniedData struct { - Donor *donordata.DonorProvidedDetails + Donor *donordata.Provided Errors validation.List App page.AppData } func FeeDenied(tmpl template.Template, payer Handler) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { if r.Method == http.MethodPost { return payer(appData, w, r, donor) } diff --git a/internal/donor/donorpage/fee_denied_test.go b/internal/donor/donorpage/fee_denied_test.go index ca7a42a8d3..2cc763d019 100644 --- a/internal/donor/donorpage/fee_denied_test.go +++ b/internal/donor/donorpage/fee_denied_test.go @@ -14,7 +14,7 @@ func TestGetFeeDenied(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &donordata.DonorProvidedDetails{Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateDenied}} + donor := &donordata.Provided{Tasks: donordata.Tasks{PayForLpa: task.PaymentStateDenied}} template := newMockTemplate(t) template.EXPECT(). @@ -32,7 +32,7 @@ func TestPostFeeDenied(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodPost, "/", nil) - donor := &donordata.DonorProvidedDetails{Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateDenied}} + donor := &donordata.Provided{Tasks: donordata.Tasks{PayForLpa: task.PaymentStateDenied}} payer := newMockHandler(t) payer.EXPECT(). @@ -50,7 +50,7 @@ func TestPostFeeDeniedWhenPayerError(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodPost, "/", nil) - donor := &donordata.DonorProvidedDetails{Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateDenied}} + donor := &donordata.Provided{Tasks: donordata.Tasks{PayForLpa: task.PaymentStateDenied}} payer := newMockHandler(t) payer.EXPECT(). diff --git a/internal/donor/donorpage/guidance.go b/internal/donor/donorpage/guidance.go index f84a10d037..1e0fea6ae6 100644 --- a/internal/donor/donorpage/guidance.go +++ b/internal/donor/donorpage/guidance.go @@ -12,11 +12,11 @@ import ( type guidanceData struct { App page.AppData Errors validation.List - Donor *donordata.DonorProvidedDetails + Donor *donordata.Provided } func Guidance(tmpl template.Template) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &guidanceData{ App: appData, Donor: donor, diff --git a/internal/donor/donorpage/guidance_test.go b/internal/donor/donorpage/guidance_test.go index 7e4a48e314..da30fc1eec 100644 --- a/internal/donor/donorpage/guidance_test.go +++ b/internal/donor/donorpage/guidance_test.go @@ -14,7 +14,7 @@ func TestGuidance(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &donordata.DonorProvidedDetails{} + donor := &donordata.Provided{} template := newMockTemplate(t) template.EXPECT(). @@ -34,10 +34,10 @@ func TestGuidanceWhenTemplateErrors(t *testing.T) { template := newMockTemplate(t) template.EXPECT(). - Execute(w, &guidanceData{App: testAppData, Donor: &donordata.DonorProvidedDetails{}}). + Execute(w, &guidanceData{App: testAppData, Donor: &donordata.Provided{}}). Return(expectedError) - err := Guidance(template.Execute)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := Guidance(template.Execute)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } diff --git a/internal/donor/donorpage/how_do_you_know_your_certificate_provider.go b/internal/donor/donorpage/how_do_you_know_your_certificate_provider.go index 4017c219df..6121a5f0bc 100644 --- a/internal/donor/donorpage/how_do_you_know_your_certificate_provider.go +++ b/internal/donor/donorpage/how_do_you_know_your_certificate_provider.go @@ -4,10 +4,10 @@ import ( "net/http" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -20,7 +20,7 @@ type howDoYouKnowYourCertificateProviderData struct { } func HowDoYouKnowYourCertificateProvider(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &howDoYouKnowYourCertificateProviderData{ App: appData, CertificateProvider: donor.CertificateProvider, @@ -40,7 +40,7 @@ func HowDoYouKnowYourCertificateProvider(tmpl template.Template, donorStore Dono } if !donor.CertificateProvider.Relationship.Empty() && data.Form.How != donor.CertificateProvider.Relationship { - donor.Tasks.CertificateProvider = actor.TaskInProgress + donor.Tasks.CertificateProvider = task.StateInProgress donor.CertificateProvider.Address = place.Address{} } diff --git a/internal/donor/donorpage/how_do_you_know_your_certificate_provider_test.go b/internal/donor/donorpage/how_do_you_know_your_certificate_provider_test.go index d8c2a3dec9..df9e7c4fa7 100644 --- a/internal/donor/donorpage/how_do_you_know_your_certificate_provider_test.go +++ b/internal/donor/donorpage/how_do_you_know_your_certificate_provider_test.go @@ -7,10 +7,10 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -29,7 +29,7 @@ func TestGetHowDoYouKnowYourCertificateProvider(t *testing.T) { }). Return(nil) - err := HowDoYouKnowYourCertificateProvider(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := HowDoYouKnowYourCertificateProvider(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -54,7 +54,7 @@ func TestGetHowDoYouKnowYourCertificateProviderFromStore(t *testing.T) { }). Return(nil) - err := HowDoYouKnowYourCertificateProvider(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := HowDoYouKnowYourCertificateProvider(template.Execute, nil)(testAppData, w, r, &donordata.Provided{ CertificateProvider: certificateProvider, }) resp := w.Result() @@ -72,7 +72,7 @@ func TestGetHowDoYouKnowYourCertificateProviderWhenTemplateErrors(t *testing.T) Execute(w, mock.Anything). Return(expectedError) - err := HowDoYouKnowYourCertificateProvider(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := HowDoYouKnowYourCertificateProvider(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -111,22 +111,22 @@ func TestPostHowDoYouKnowYourCertificateProvider(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", CertificateProvider: tc.certificateProviderDetails, - Tasks: donordata.DonorTasks{ - YourDetails: actor.TaskCompleted, - ChooseAttorneys: actor.TaskCompleted, + Tasks: donordata.Tasks{ + YourDetails: task.StateCompleted, + ChooseAttorneys: task.StateCompleted, }, }). Return(nil) - err := HowDoYouKnowYourCertificateProvider(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := HowDoYouKnowYourCertificateProvider(nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", CertificateProvider: donordata.CertificateProvider{FirstNames: "John"}, - Tasks: donordata.DonorTasks{ - YourDetails: actor.TaskCompleted, - ChooseAttorneys: actor.TaskCompleted, + Tasks: donordata.Tasks{ + YourDetails: task.StateCompleted, + ChooseAttorneys: task.StateCompleted, }, }) resp := w.Result() @@ -144,7 +144,7 @@ func TestPostHowDoYouKnowYourCertificateProviderWhenSwitchingRelationship(t *tes existingCertificateProviderDetails donordata.CertificateProvider updatedCertificateProviderDetails donordata.CertificateProvider redirect page.LpaPath - taskState actor.TaskState + taskState task.State }{ "personally to professionally": { form: url.Values{"how": {donordata.Professionally.String()}}, @@ -181,24 +181,24 @@ func TestPostHowDoYouKnowYourCertificateProviderWhenSwitchingRelationship(t *tes donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", CertificateProvider: tc.updatedCertificateProviderDetails, - Tasks: donordata.DonorTasks{ - YourDetails: actor.TaskCompleted, - ChooseAttorneys: actor.TaskCompleted, - CertificateProvider: actor.TaskInProgress, + Tasks: donordata.Tasks{ + YourDetails: task.StateCompleted, + ChooseAttorneys: task.StateCompleted, + CertificateProvider: task.StateInProgress, }, }). Return(nil) - err := HowDoYouKnowYourCertificateProvider(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := HowDoYouKnowYourCertificateProvider(nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", CertificateProvider: tc.existingCertificateProviderDetails, - Tasks: donordata.DonorTasks{ - YourDetails: actor.TaskCompleted, - ChooseAttorneys: actor.TaskCompleted, - CertificateProvider: actor.TaskCompleted, + Tasks: donordata.Tasks{ + YourDetails: task.StateCompleted, + ChooseAttorneys: task.StateCompleted, + CertificateProvider: task.StateCompleted, }, }) resp := w.Result() @@ -224,7 +224,7 @@ func TestPostHowDoYouKnowYourCertificateProviderWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := HowDoYouKnowYourCertificateProvider(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := HowDoYouKnowYourCertificateProvider(nil, donorStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -241,7 +241,7 @@ func TestPostHowDoYouKnowYourCertificateProviderWhenValidationErrors(t *testing. })). Return(nil) - err := HowDoYouKnowYourCertificateProvider(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := HowDoYouKnowYourCertificateProvider(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/how_long_have_you_known_certificate_provider.go b/internal/donor/donorpage/how_long_have_you_known_certificate_provider.go index 06b10dd5d0..234c4ce1d6 100644 --- a/internal/donor/donorpage/how_long_have_you_known_certificate_provider.go +++ b/internal/donor/donorpage/how_long_have_you_known_certificate_provider.go @@ -18,7 +18,7 @@ type howLongHaveYouKnownCertificateProviderData struct { } func HowLongHaveYouKnownCertificateProvider(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &howLongHaveYouKnownCertificateProviderData{ App: appData, CertificateProvider: donor.CertificateProvider, diff --git a/internal/donor/donorpage/how_long_have_you_known_certificate_provider_test.go b/internal/donor/donorpage/how_long_have_you_known_certificate_provider_test.go index 2003951c6e..4c430cf798 100644 --- a/internal/donor/donorpage/how_long_have_you_known_certificate_provider_test.go +++ b/internal/donor/donorpage/how_long_have_you_known_certificate_provider_test.go @@ -7,11 +7,11 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/date" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -29,7 +29,7 @@ func TestGetHowLongHaveYouKnownCertificateProvider(t *testing.T) { }). Return(nil) - err := HowLongHaveYouKnownCertificateProvider(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := HowLongHaveYouKnownCertificateProvider(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -52,7 +52,7 @@ func TestGetHowLongHaveYouKnownCertificateProviderFromStore(t *testing.T) { }). Return(nil) - err := HowLongHaveYouKnownCertificateProvider(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{CertificateProvider: certificateProvider}) + err := HowLongHaveYouKnownCertificateProvider(template.Execute, nil)(testAppData, w, r, &donordata.Provided{CertificateProvider: certificateProvider}) resp := w.Result() assert.Nil(t, err) @@ -71,7 +71,7 @@ func TestGetHowLongHaveYouKnownCertificateProviderWhenTemplateErrors(t *testing. }). Return(expectedError) - err := HowLongHaveYouKnownCertificateProvider(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := HowLongHaveYouKnownCertificateProvider(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -89,20 +89,20 @@ func TestPostHowLongHaveYouKnownCertificateProviderMoreThan2Years(t *testing.T) donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{FirstNames: "a", LastName: "b", Address: place.Address{Line1: "c"}, DateOfBirth: date.New("1990", "1", "1")}}}, AttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, CertificateProvider: donordata.CertificateProvider{RelationshipLength: donordata.GreaterThanEqualToTwoYears}, - Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted}, + Tasks: donordata.Tasks{YourDetails: task.StateCompleted, ChooseAttorneys: task.StateCompleted}, }). Return(nil) - err := HowLongHaveYouKnownCertificateProvider(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := HowLongHaveYouKnownCertificateProvider(nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{FirstNames: "a", LastName: "b", Address: place.Address{Line1: "c"}, DateOfBirth: date.New("1990", "1", "1")}}}, AttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, - Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted}, + Tasks: donordata.Tasks{YourDetails: task.StateCompleted, ChooseAttorneys: task.StateCompleted}, }) resp := w.Result() @@ -120,7 +120,7 @@ func TestPostHowLongHaveYouKnownCertificateProviderLessThan2Years(t *testing.T) r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - err := HowLongHaveYouKnownCertificateProvider(nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) + err := HowLongHaveYouKnownCertificateProvider(nil, nil)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id"}) resp := w.Result() assert.Nil(t, err) @@ -142,7 +142,7 @@ func TestPostHowLongHaveYouKnownCertificateProviderWhenStoreErrors(t *testing.T) Put(r.Context(), mock.Anything). Return(expectedError) - err := HowLongHaveYouKnownCertificateProvider(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := HowLongHaveYouKnownCertificateProvider(nil, donorStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -161,7 +161,7 @@ func TestPostHowLongHaveYouKnownCertificateProviderWhenValidationErrors(t *testi }). Return(nil) - err := HowLongHaveYouKnownCertificateProvider(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := HowLongHaveYouKnownCertificateProvider(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/how_should_attorneys_make_decisions.go b/internal/donor/donorpage/how_should_attorneys_make_decisions.go index 9a0817ad25..bb6ef75e68 100644 --- a/internal/donor/donorpage/how_should_attorneys_make_decisions.go +++ b/internal/donor/donorpage/how_should_attorneys_make_decisions.go @@ -13,12 +13,12 @@ type howShouldAttorneysMakeDecisionsData struct { App page.AppData Errors validation.List Form *howShouldAttorneysMakeDecisionsForm - Donor *donordata.DonorProvidedDetails + Donor *donordata.Provided Options donordata.AttorneysActOptions } func HowShouldAttorneysMakeDecisions(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &howShouldAttorneysMakeDecisionsData{ App: appData, Form: &howShouldAttorneysMakeDecisionsForm{ diff --git a/internal/donor/donorpage/how_should_attorneys_make_decisions_test.go b/internal/donor/donorpage/how_should_attorneys_make_decisions_test.go index 051937bacc..c5822a4f03 100644 --- a/internal/donor/donorpage/how_should_attorneys_make_decisions_test.go +++ b/internal/donor/donorpage/how_should_attorneys_make_decisions_test.go @@ -7,9 +7,9 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -24,12 +24,12 @@ func TestGetHowShouldAttorneysMakeDecisions(t *testing.T) { Execute(w, &howShouldAttorneysMakeDecisionsData{ App: testAppData, Form: &howShouldAttorneysMakeDecisionsForm{}, - Donor: &donordata.DonorProvidedDetails{}, + Donor: &donordata.Provided{}, Options: donordata.AttorneysActValues, }). Return(nil) - err := HowShouldAttorneysMakeDecisions(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := HowShouldAttorneysMakeDecisions(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -48,12 +48,12 @@ func TestGetHowShouldAttorneysMakeDecisionsFromStore(t *testing.T) { DecisionsType: donordata.Jointly, DecisionsDetails: "some decisions", }, - Donor: &donordata.DonorProvidedDetails{AttorneyDecisions: donordata.AttorneyDecisions{Details: "some decisions", How: donordata.Jointly}}, + Donor: &donordata.Provided{AttorneyDecisions: donordata.AttorneyDecisions{Details: "some decisions", How: donordata.Jointly}}, Options: donordata.AttorneysActValues, }). Return(nil) - err := HowShouldAttorneysMakeDecisions(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{AttorneyDecisions: donordata.AttorneyDecisions{Details: "some decisions", How: donordata.Jointly}}) + err := HowShouldAttorneysMakeDecisions(template.Execute, nil)(testAppData, w, r, &donordata.Provided{AttorneyDecisions: donordata.AttorneyDecisions{Details: "some decisions", How: donordata.Jointly}}) resp := w.Result() assert.Nil(t, err) @@ -69,7 +69,7 @@ func TestGetHowShouldAttorneysMakeDecisionsWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := HowShouldAttorneysMakeDecisions(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := HowShouldAttorneysMakeDecisions(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -90,17 +90,17 @@ func TestPostHowShouldAttorneysMakeDecisions(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Attorneys: attorneys, AttorneyDecisions: donordata.AttorneyDecisions{How: donordata.JointlyAndSeverally}, - Tasks: donordata.DonorTasks{ChooseAttorneys: actor.TaskCompleted}, + Tasks: donordata.Tasks{ChooseAttorneys: task.StateCompleted}, }). Return(nil) template := newMockTemplate(t) - err := HowShouldAttorneysMakeDecisions(template.Execute, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", Attorneys: attorneys}) + err := HowShouldAttorneysMakeDecisions(template.Execute, donorStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", Attorneys: attorneys}) resp := w.Result() assert.Nil(t, err) @@ -151,17 +151,17 @@ func TestPostHowShouldAttorneysMakeDecisionsFromStore(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{FirstNames: "a", Address: testAddress}, {FirstNames: "b", Address: testAddress}}}, AttorneyDecisions: donordata.AttorneyDecisions{Details: tc.updatedDetails, How: tc.updatedType}, - Tasks: donordata.DonorTasks{ChooseAttorneys: actor.TaskCompleted}, + Tasks: donordata.Tasks{ChooseAttorneys: task.StateCompleted}, }). Return(nil) template := newMockTemplate(t) - err := HowShouldAttorneysMakeDecisions(template.Execute, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := HowShouldAttorneysMakeDecisions(template.Execute, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{FirstNames: "a", Address: testAddress}, {FirstNames: "b", Address: testAddress}}}, AttorneyDecisions: donordata.AttorneyDecisions{Details: tc.existingDetails, How: tc.existingType}, @@ -191,7 +191,7 @@ func TestPostHowShouldAttorneysMakeDecisionsWhenValidationErrors(t *testing.T) { })). Return(nil) - err := HowShouldAttorneysMakeDecisions(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := HowShouldAttorneysMakeDecisions(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -215,7 +215,7 @@ func TestPostHowShouldAttorneysMakeDecisionsErrorOnPutStore(t *testing.T) { template := newMockTemplate(t) - err := HowShouldAttorneysMakeDecisions(template.Execute, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := HowShouldAttorneysMakeDecisions(template.Execute, donorStore)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) diff --git a/internal/donor/donorpage/how_should_replacement_attorneys_make_decisions.go b/internal/donor/donorpage/how_should_replacement_attorneys_make_decisions.go index 4d6b7c5e9e..4b308066e2 100644 --- a/internal/donor/donorpage/how_should_replacement_attorneys_make_decisions.go +++ b/internal/donor/donorpage/how_should_replacement_attorneys_make_decisions.go @@ -14,11 +14,11 @@ type howShouldReplacementAttorneysMakeDecisionsData struct { Errors validation.List Form *howShouldAttorneysMakeDecisionsForm Options donordata.AttorneysActOptions - Donor *donordata.DonorProvidedDetails + Donor *donordata.Provided } func HowShouldReplacementAttorneysMakeDecisions(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &howShouldReplacementAttorneysMakeDecisionsData{ App: appData, Form: &howShouldAttorneysMakeDecisionsForm{ diff --git a/internal/donor/donorpage/how_should_replacement_attorneys_make_decisions_test.go b/internal/donor/donorpage/how_should_replacement_attorneys_make_decisions_test.go index 63f51fa790..741b6b30d8 100644 --- a/internal/donor/donorpage/how_should_replacement_attorneys_make_decisions_test.go +++ b/internal/donor/donorpage/how_should_replacement_attorneys_make_decisions_test.go @@ -7,9 +7,9 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -25,11 +25,11 @@ func TestGetHowShouldReplacementAttorneysMakeDecisions(t *testing.T) { App: testAppData, Form: &howShouldAttorneysMakeDecisionsForm{}, Options: donordata.AttorneysActValues, - Donor: &donordata.DonorProvidedDetails{}, + Donor: &donordata.Provided{}, }). Return(nil) - err := HowShouldReplacementAttorneysMakeDecisions(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := HowShouldReplacementAttorneysMakeDecisions(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -49,11 +49,11 @@ func TestGetHowShouldReplacementAttorneysMakeDecisionsFromStore(t *testing.T) { DecisionsDetails: "some decisions", }, Options: donordata.AttorneysActValues, - Donor: &donordata.DonorProvidedDetails{ReplacementAttorneyDecisions: donordata.AttorneyDecisions{Details: "some decisions", How: donordata.Jointly}}, + Donor: &donordata.Provided{ReplacementAttorneyDecisions: donordata.AttorneyDecisions{Details: "some decisions", How: donordata.Jointly}}, }). Return(nil) - err := HowShouldReplacementAttorneysMakeDecisions(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ReplacementAttorneyDecisions: donordata.AttorneyDecisions{Details: "some decisions", How: donordata.Jointly}}) + err := HowShouldReplacementAttorneysMakeDecisions(template.Execute, nil)(testAppData, w, r, &donordata.Provided{ReplacementAttorneyDecisions: donordata.AttorneyDecisions{Details: "some decisions", How: donordata.Jointly}}) resp := w.Result() assert.Nil(t, err) @@ -69,7 +69,7 @@ func TestGetHowShouldReplacementAttorneysMakeDecisionsWhenTemplateErrors(t *test Execute(w, mock.Anything). Return(expectedError) - err := HowShouldReplacementAttorneysMakeDecisions(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := HowShouldReplacementAttorneysMakeDecisions(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -88,12 +88,12 @@ func TestPostHowShouldReplacementAttorneysMakeDecisions(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{LpaID: "lpa-id", ReplacementAttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}}). + Put(r.Context(), &donordata.Provided{LpaID: "lpa-id", ReplacementAttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}}). Return(nil) template := newMockTemplate(t) - err := HowShouldReplacementAttorneysMakeDecisions(template.Execute, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) + err := HowShouldReplacementAttorneysMakeDecisions(template.Execute, donorStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id"}) resp := w.Result() assert.Nil(t, err) @@ -107,7 +107,7 @@ func TestPostHowShouldReplacementAttorneysMakeDecisionsFromStore(t *testing.T) { existing donordata.AttorneyDecisions attorneys donordata.Attorneys updated donordata.AttorneyDecisions - taskState actor.TaskState + taskState task.State redirect page.LpaPath }{ "existing details not set": { @@ -118,7 +118,7 @@ func TestPostHowShouldReplacementAttorneysMakeDecisionsFromStore(t *testing.T) { existing: donordata.AttorneyDecisions{How: donordata.JointlyAndSeverally}, attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{FirstNames: "a", Address: testAddress, Email: "a"}}}, updated: donordata.AttorneyDecisions{How: donordata.JointlyForSomeSeverallyForOthers, Details: "some details"}, - taskState: actor.TaskCompleted, + taskState: task.StateCompleted, redirect: page.Paths.TaskList, }, "existing details set": { @@ -129,7 +129,7 @@ func TestPostHowShouldReplacementAttorneysMakeDecisionsFromStore(t *testing.T) { existing: donordata.AttorneyDecisions{How: donordata.JointlyForSomeSeverallyForOthers, Details: "some details"}, attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{FirstNames: "a", Address: testAddress, Email: "a"}}}, updated: donordata.AttorneyDecisions{How: donordata.Jointly}, - taskState: actor.TaskCompleted, + taskState: task.StateCompleted, redirect: page.Paths.TaskList, }, } @@ -142,17 +142,17 @@ func TestPostHowShouldReplacementAttorneysMakeDecisionsFromStore(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", ReplacementAttorneys: tc.attorneys, ReplacementAttorneyDecisions: tc.updated, - Tasks: donordata.DonorTasks{ChooseReplacementAttorneys: tc.taskState}, + Tasks: donordata.Tasks{ChooseReplacementAttorneys: tc.taskState}, }). Return(nil) template := newMockTemplate(t) - err := HowShouldReplacementAttorneysMakeDecisions(template.Execute, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := HowShouldReplacementAttorneysMakeDecisions(template.Execute, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", ReplacementAttorneys: tc.attorneys, ReplacementAttorneyDecisions: tc.existing, @@ -181,7 +181,7 @@ func TestPostHowShouldReplacementAttorneysMakeDecisionsWhenStoreErrors(t *testin Put(r.Context(), mock.Anything). Return(expectedError) - err := HowShouldReplacementAttorneysMakeDecisions(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := HowShouldReplacementAttorneysMakeDecisions(nil, donorStore)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -204,7 +204,7 @@ func TestPostHowShouldReplacementAttorneysMakeDecisionsWhenValidationErrors(t *t })). Return(nil) - err := HowShouldReplacementAttorneysMakeDecisions(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := HowShouldReplacementAttorneysMakeDecisions(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -223,12 +223,12 @@ func TestPostHowShouldReplacementAttorneysMakeDecisionsErrorOnPutStore(t *testin donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ReplacementAttorneyDecisions: donordata.AttorneyDecisions{Details: "", How: donordata.Jointly}}). + Put(r.Context(), &donordata.Provided{ReplacementAttorneyDecisions: donordata.AttorneyDecisions{Details: "", How: donordata.Jointly}}). Return(expectedError) template := newMockTemplate(t) - err := HowShouldReplacementAttorneysMakeDecisions(template.Execute, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := HowShouldReplacementAttorneysMakeDecisions(template.Execute, donorStore)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) diff --git a/internal/donor/donorpage/how_should_replacement_attorneys_step_in.go b/internal/donor/donorpage/how_should_replacement_attorneys_step_in.go index 4942fa9c03..2d589cf2b7 100644 --- a/internal/donor/donorpage/how_should_replacement_attorneys_step_in.go +++ b/internal/donor/donorpage/how_should_replacement_attorneys_step_in.go @@ -17,7 +17,7 @@ type howShouldReplacementAttorneysStepInData struct { } func HowShouldReplacementAttorneysStepIn(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &howShouldReplacementAttorneysStepInData{ App: appData, Form: &howShouldReplacementAttorneysStepInForm{ diff --git a/internal/donor/donorpage/how_should_replacement_attorneys_step_in_test.go b/internal/donor/donorpage/how_should_replacement_attorneys_step_in_test.go index d1f0646e09..9a24cfa055 100644 --- a/internal/donor/donorpage/how_should_replacement_attorneys_step_in_test.go +++ b/internal/donor/donorpage/how_should_replacement_attorneys_step_in_test.go @@ -7,10 +7,10 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -29,7 +29,7 @@ func TestGetHowShouldReplacementAttorneysStepIn(t *testing.T) { }). Return(nil) - err := HowShouldReplacementAttorneysStepIn(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := HowShouldReplacementAttorneysStepIn(template.Execute, nil)(testAppData, w, r, &donordata.Provided{ ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{}}}, }) resp := w.Result() @@ -54,7 +54,7 @@ func TestGetHowShouldReplacementAttorneysStepInFromStore(t *testing.T) { }). Return(nil) - err := HowShouldReplacementAttorneysStepIn(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := HowShouldReplacementAttorneysStepIn(template.Execute, nil)(testAppData, w, r, &donordata.Provided{ HowShouldReplacementAttorneysStepIn: donordata.ReplacementAttorneysStepInAnotherWay, HowShouldReplacementAttorneysStepInDetails: "some details", }) @@ -76,7 +76,7 @@ func TestPostHowShouldReplacementAttorneysStepIn(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", HowShouldReplacementAttorneysStepIn: donordata.ReplacementAttorneysStepInAnotherWay, HowShouldReplacementAttorneysStepInDetails: "some details"}). @@ -84,7 +84,7 @@ func TestPostHowShouldReplacementAttorneysStepIn(t *testing.T) { template := newMockTemplate(t) - err := HowShouldReplacementAttorneysStepIn(template.Execute, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) + err := HowShouldReplacementAttorneysStepIn(template.Execute, donorStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id"}) resp := w.Result() assert.Nil(t, err) @@ -100,7 +100,7 @@ func TestPostHowShouldReplacementAttorneysStepInRedirects(t *testing.T) { HowReplacementAttorneysMakeDecisions donordata.AttorneysAct HowShouldReplacementAttorneysStepIn donordata.ReplacementAttorneysStepIn ExpectedRedirectUrl page.LpaPath - TaskState actor.TaskState + TaskState task.State }{ "multiple attorneys acting jointly and severally replacements step in when none left": { Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ @@ -114,7 +114,7 @@ func TestPostHowShouldReplacementAttorneysStepInRedirects(t *testing.T) { HowAttorneysMakeDecisions: donordata.JointlyAndSeverally, HowShouldReplacementAttorneysStepIn: donordata.ReplacementAttorneysStepInWhenAllCanNoLongerAct, ExpectedRedirectUrl: page.Paths.HowShouldReplacementAttorneysMakeDecisions, - TaskState: actor.TaskInProgress, + TaskState: task.StateInProgress, }, "multiple attorneys acting jointly": { ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ @@ -125,7 +125,7 @@ func TestPostHowShouldReplacementAttorneysStepInRedirects(t *testing.T) { HowShouldReplacementAttorneysStepIn: donordata.ReplacementAttorneysStepInWhenOneCanNoLongerAct, HowReplacementAttorneysMakeDecisions: donordata.Jointly, ExpectedRedirectUrl: page.Paths.TaskList, - TaskState: actor.TaskInProgress, + TaskState: task.StateInProgress, }, "multiple attorneys acting jointly and severally replacements step in when one loses capacity": { Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ @@ -135,7 +135,7 @@ func TestPostHowShouldReplacementAttorneysStepInRedirects(t *testing.T) { HowAttorneysMakeDecisions: donordata.JointlyAndSeverally, HowShouldReplacementAttorneysStepIn: donordata.ReplacementAttorneysStepInWhenOneCanNoLongerAct, ExpectedRedirectUrl: page.Paths.TaskList, - TaskState: actor.TaskNotStarted, + TaskState: task.StateNotStarted, }, "multiple attorneys acting jointly and severally": { Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ @@ -149,7 +149,7 @@ func TestPostHowShouldReplacementAttorneysStepInRedirects(t *testing.T) { HowAttorneysMakeDecisions: donordata.JointlyAndSeverally, HowShouldReplacementAttorneysStepIn: donordata.ReplacementAttorneysStepInWhenOneCanNoLongerAct, ExpectedRedirectUrl: page.Paths.TaskList, - TaskState: actor.TaskInProgress, + TaskState: task.StateInProgress, }, } @@ -165,20 +165,20 @@ func TestPostHowShouldReplacementAttorneysStepInRedirects(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Attorneys: tc.Attorneys, AttorneyDecisions: donordata.AttorneyDecisions{How: tc.HowAttorneysMakeDecisions}, ReplacementAttorneys: tc.ReplacementAttorneys, ReplacementAttorneyDecisions: donordata.AttorneyDecisions{How: tc.HowReplacementAttorneysMakeDecisions}, HowShouldReplacementAttorneysStepIn: tc.HowShouldReplacementAttorneysStepIn, - Tasks: donordata.DonorTasks{ChooseReplacementAttorneys: tc.TaskState}, + Tasks: donordata.Tasks{ChooseReplacementAttorneys: tc.TaskState}, }). Return(nil) template := newMockTemplate(t) - err := HowShouldReplacementAttorneysStepIn(template.Execute, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := HowShouldReplacementAttorneysStepIn(template.Execute, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Attorneys: tc.Attorneys, AttorneyDecisions: donordata.AttorneyDecisions{How: tc.HowAttorneysMakeDecisions}, @@ -230,7 +230,7 @@ func TestPostHowShouldReplacementAttorneysStepInFromStore(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", HowShouldReplacementAttorneysStepIn: tc.updatedWhenStepIn, HowShouldReplacementAttorneysStepInDetails: tc.updatedOtherDetails}). @@ -238,7 +238,7 @@ func TestPostHowShouldReplacementAttorneysStepInFromStore(t *testing.T) { template := newMockTemplate(t) - err := HowShouldReplacementAttorneysStepIn(template.Execute, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := HowShouldReplacementAttorneysStepIn(template.Execute, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", HowShouldReplacementAttorneysStepIn: tc.existingWhenStepIn, HowShouldReplacementAttorneysStepInDetails: tc.existingOtherDetails, @@ -269,7 +269,7 @@ func TestPostHowShouldReplacementAttorneysStepInFormValidation(t *testing.T) { })). Return(nil) - err := HowShouldReplacementAttorneysStepIn(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := HowShouldReplacementAttorneysStepIn(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -288,14 +288,14 @@ func TestPostHowShouldReplacementAttorneysStepInWhenPutStoreError(t *testing.T) donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ HowShouldReplacementAttorneysStepIn: donordata.ReplacementAttorneysStepInAnotherWay, HowShouldReplacementAttorneysStepInDetails: "some details"}). Return(expectedError) template := newMockTemplate(t) - err := HowShouldReplacementAttorneysStepIn(template.Execute, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := HowShouldReplacementAttorneysStepIn(template.Execute, donorStore)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) diff --git a/internal/donor/donorpage/how_would_certificate_provider_prefer_to_carry_out_their_role.go b/internal/donor/donorpage/how_would_certificate_provider_prefer_to_carry_out_their_role.go index 2046e7441b..5522252d32 100644 --- a/internal/donor/donorpage/how_would_certificate_provider_prefer_to_carry_out_their_role.go +++ b/internal/donor/donorpage/how_would_certificate_provider_prefer_to_carry_out_their_role.go @@ -18,7 +18,7 @@ type howWouldCertificateProviderPreferToCarryOutTheirRoleData struct { } func HowWouldCertificateProviderPreferToCarryOutTheirRole(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &howWouldCertificateProviderPreferToCarryOutTheirRoleData{ App: appData, CertificateProvider: donor.CertificateProvider, diff --git a/internal/donor/donorpage/how_would_certificate_provider_prefer_to_carry_out_their_role_test.go b/internal/donor/donorpage/how_would_certificate_provider_prefer_to_carry_out_their_role_test.go index 2a9f41f7c9..43e9965920 100644 --- a/internal/donor/donorpage/how_would_certificate_provider_prefer_to_carry_out_their_role_test.go +++ b/internal/donor/donorpage/how_would_certificate_provider_prefer_to_carry_out_their_role_test.go @@ -27,7 +27,7 @@ func TestGetHowWouldCertificateProviderPreferToCarryOutTheirRole(t *testing.T) { }). Return(nil) - err := HowWouldCertificateProviderPreferToCarryOutTheirRole(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := HowWouldCertificateProviderPreferToCarryOutTheirRole(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -48,7 +48,7 @@ func TestGetHowWouldCertificateProviderPreferToCarryOutTheirRoleFromStore(t *tes }). Return(nil) - err := HowWouldCertificateProviderPreferToCarryOutTheirRole(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := HowWouldCertificateProviderPreferToCarryOutTheirRole(template.Execute, nil)(testAppData, w, r, &donordata.Provided{ CertificateProvider: donordata.CertificateProvider{CarryOutBy: donordata.ChannelPaper}, }) resp := w.Result() @@ -70,7 +70,7 @@ func TestGetHowWouldCertificateProviderPreferToCarryOutTheirRoleWhenTemplateErro }). Return(expectedError) - err := HowWouldCertificateProviderPreferToCarryOutTheirRole(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := HowWouldCertificateProviderPreferToCarryOutTheirRole(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -104,13 +104,13 @@ func TestPostHowWouldCertificateProviderPreferToCarryOutTheirRole(t *testing.T) donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", CertificateProvider: donordata.CertificateProvider{CarryOutBy: tc.carryOutBy, Email: tc.email}, }). Return(nil) - err := HowWouldCertificateProviderPreferToCarryOutTheirRole(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) + err := HowWouldCertificateProviderPreferToCarryOutTheirRole(nil, donorStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id"}) resp := w.Result() assert.Nil(t, err) @@ -132,13 +132,13 @@ func TestPostHowWouldCertificateProviderPreferToCarryOutTheirRoleChangingFromOnl donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", CertificateProvider: donordata.CertificateProvider{CarryOutBy: donordata.ChannelPaper, Email: ""}, }). Return(nil) - err := HowWouldCertificateProviderPreferToCarryOutTheirRole(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := HowWouldCertificateProviderPreferToCarryOutTheirRole(nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", CertificateProvider: donordata.CertificateProvider{CarryOutBy: donordata.ChannelOnline, Email: "a@b.com"}, }) @@ -163,7 +163,7 @@ func TestPostHowWouldCertificateProviderPreferToCarryOutTheirRoleWhenStoreErrors Put(r.Context(), mock.Anything). Return(expectedError) - err := HowWouldCertificateProviderPreferToCarryOutTheirRole(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := HowWouldCertificateProviderPreferToCarryOutTheirRole(nil, donorStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -180,7 +180,7 @@ func TestPostHowWouldCertificateProviderPreferToCarryOutTheirRoleWhenValidationE })). Return(nil) - err := HowWouldCertificateProviderPreferToCarryOutTheirRole(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := HowWouldCertificateProviderPreferToCarryOutTheirRole(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/how_would_you_like_to_send_evidence.go b/internal/donor/donorpage/how_would_you_like_to_send_evidence.go index 4f17a4c95d..068fe40cff 100644 --- a/internal/donor/donorpage/how_would_you_like_to_send_evidence.go +++ b/internal/donor/donorpage/how_would_you_like_to_send_evidence.go @@ -18,7 +18,7 @@ type howWouldYouLikeToSendEvidenceData struct { } func HowWouldYouLikeToSendEvidence(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &howWouldYouLikeToSendEvidenceData{ App: appData, Options: pay.EvidenceDeliveryValues, diff --git a/internal/donor/donorpage/how_would_you_like_to_send_evidence_test.go b/internal/donor/donorpage/how_would_you_like_to_send_evidence_test.go index 229eaa9fc9..8f1d0b7445 100644 --- a/internal/donor/donorpage/how_would_you_like_to_send_evidence_test.go +++ b/internal/donor/donorpage/how_would_you_like_to_send_evidence_test.go @@ -27,7 +27,7 @@ func TestGetHowWouldYouLikeToSendEvidence(t *testing.T) { }). Return(nil) - err := HowWouldYouLikeToSendEvidence(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := HowWouldYouLikeToSendEvidence(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -46,7 +46,7 @@ func TestGetHowWouldYouLikeToSendEvidenceFromStore(t *testing.T) { }). Return(nil) - err := HowWouldYouLikeToSendEvidence(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := HowWouldYouLikeToSendEvidence(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -62,7 +62,7 @@ func TestGetHowWouldYouLikeToSendEvidenceWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := HowWouldYouLikeToSendEvidence(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := HowWouldYouLikeToSendEvidence(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -87,10 +87,10 @@ func TestPostHowWouldYouLikeToSendEvidence(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{LpaID: "lpa-id", EvidenceDelivery: evidenceDelivery}). + Put(r.Context(), &donordata.Provided{LpaID: "lpa-id", EvidenceDelivery: evidenceDelivery}). Return(nil) - err := HowWouldYouLikeToSendEvidence(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) + err := HowWouldYouLikeToSendEvidence(nil, donorStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id"}) resp := w.Result() assert.Nil(t, err) @@ -114,7 +114,7 @@ func TestPostHowWouldYouLikeToSendEvidenceWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := HowWouldYouLikeToSendEvidence(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) + err := HowWouldYouLikeToSendEvidence(nil, donorStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id"}) assert.Equal(t, expectedError, err) } @@ -130,7 +130,7 @@ func TestPostHowWouldYouLikeToSendEvidenceWhenValidationErrors(t *testing.T) { })). Return(nil) - err := HowWouldYouLikeToSendEvidence(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := HowWouldYouLikeToSendEvidence(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/identity_with_one_login.go b/internal/donor/donorpage/identity_with_one_login.go index 2ce4e75f15..8679cd5d9a 100644 --- a/internal/donor/donorpage/identity_with_one_login.go +++ b/internal/donor/donorpage/identity_with_one_login.go @@ -10,7 +10,7 @@ import ( ) func IdentityWithOneLogin(oneLoginClient OneLoginClient, sessionStore SessionStore, randomString func(int) string) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { locale := "" if appData.Lang == localize.Cy { locale = "cy" diff --git a/internal/donor/donorpage/identity_with_one_login_callback.go b/internal/donor/donorpage/identity_with_one_login_callback.go index 6f52a6fb8a..b44ec24dda 100644 --- a/internal/donor/donorpage/identity_with_one_login_callback.go +++ b/internal/donor/donorpage/identity_with_one_login_callback.go @@ -4,14 +4,14 @@ import ( "errors" "net/http" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/identity" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" ) func IdentityWithOneLoginCallback(oneLoginClient OneLoginClient, sessionStore SessionStore, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { if donor.DonorIdentityConfirmed() { return page.Paths.OneLoginIdentityDetails.Redirect(w, r, appData, donor) } @@ -43,9 +43,9 @@ func IdentityWithOneLoginCallback(oneLoginClient OneLoginClient, sessionStore Se donor.DonorIdentityUserData = userData if userData.Status.IsFailed() { - donor.Tasks.ConfirmYourIdentityAndSign = actor.IdentityTaskProblem + donor.Tasks.ConfirmYourIdentityAndSign = task.IdentityStateProblem } else { - donor.Tasks.ConfirmYourIdentityAndSign = actor.IdentityTaskInProgress + donor.Tasks.ConfirmYourIdentityAndSign = task.IdentityStateInProgress } if err := donorStore.Put(r.Context(), donor); err != nil { diff --git a/internal/donor/donorpage/identity_with_one_login_callback_test.go b/internal/donor/donorpage/identity_with_one_login_callback_test.go index f73551657f..433984bf55 100644 --- a/internal/donor/donorpage/identity_with_one_login_callback_test.go +++ b/internal/donor/donorpage/identity_with_one_login_callback_test.go @@ -7,12 +7,12 @@ import ( "testing" "time" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/identity" "github.com/ministryofjustice/opg-modernising-lpa/internal/onelogin" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -24,11 +24,11 @@ func TestGetIdentityWithOneLoginCallback(t *testing.T) { userInfo := onelogin.UserInfo{CoreIdentityJWT: "an-identity-jwt"} userData := identity.UserData{Status: identity.StatusConfirmed, FirstNames: "John", LastName: "Doe", RetrievedAt: now} - updatedDonor := &donordata.DonorProvidedDetails{ + updatedDonor := &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "John", LastName: "Doe"}, DonorIdentityUserData: userData, - Tasks: donordata.DonorTasks{ConfirmYourIdentityAndSign: actor.IdentityTaskInProgress}, + Tasks: donordata.Tasks{ConfirmYourIdentityAndSign: task.IdentityStateInProgress}, } donorStore := newMockDonorStore(t) @@ -52,7 +52,7 @@ func TestGetIdentityWithOneLoginCallback(t *testing.T) { ParseIdentityClaim(r.Context(), userInfo). Return(userData, nil) - err := IdentityWithOneLoginCallback(oneLoginClient, sessionStore, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := IdentityWithOneLoginCallback(oneLoginClient, sessionStore, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "John", LastName: "Doe"}, }) @@ -182,7 +182,7 @@ func TestGetIdentityWithOneLoginCallbackWhenIdentityNotConfirmed(t *testing.T) { sessionStore := tc.sessionStore(t) oneLoginClient := tc.oneLoginClient(t) - err := IdentityWithOneLoginCallback(oneLoginClient, sessionStore, tc.donorStore(t))(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := IdentityWithOneLoginCallback(oneLoginClient, sessionStore, tc.donorStore(t))(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, tc.error, err) @@ -198,11 +198,11 @@ func TestGetIdentityWithOneLoginCallbackWhenInsufficientEvidenceReturnCodeClaimP donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ Donor: donordata.Donor{FirstNames: "John", LastName: "Doe"}, LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusInsufficientEvidence}, - Tasks: donordata.DonorTasks{ConfirmYourIdentityAndSign: actor.IdentityTaskInProgress}, + Tasks: donordata.Tasks{ConfirmYourIdentityAndSign: task.IdentityStateInProgress}, }). Return(nil) @@ -222,7 +222,7 @@ func TestGetIdentityWithOneLoginCallbackWhenInsufficientEvidenceReturnCodeClaimP ParseIdentityClaim(mock.Anything, mock.Anything). Return(identity.UserData{Status: identity.StatusInsufficientEvidence}, nil) - err := IdentityWithOneLoginCallback(oneLoginClient, sessionStore, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := IdentityWithOneLoginCallback(oneLoginClient, sessionStore, donorStore)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{FirstNames: "John", LastName: "Doe"}, LpaID: "lpa-id", }) @@ -240,11 +240,11 @@ func TestGetIdentityWithOneLoginCallbackWhenAnyOtherReturnCodeClaimPresent(t *te donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ Donor: donordata.Donor{FirstNames: "John", LastName: "Doe"}, LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusFailed}, - Tasks: donordata.DonorTasks{ConfirmYourIdentityAndSign: actor.IdentityTaskProblem}, + Tasks: donordata.Tasks{ConfirmYourIdentityAndSign: task.IdentityStateProblem}, }). Return(nil) @@ -264,7 +264,7 @@ func TestGetIdentityWithOneLoginCallbackWhenAnyOtherReturnCodeClaimPresent(t *te ParseIdentityClaim(mock.Anything, mock.Anything). Return(identity.UserData{Status: identity.StatusFailed}, nil) - err := IdentityWithOneLoginCallback(oneLoginClient, sessionStore, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := IdentityWithOneLoginCallback(oneLoginClient, sessionStore, donorStore)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{FirstNames: "John", LastName: "Doe"}, LpaID: "lpa-id", }) @@ -301,7 +301,7 @@ func TestGetIdentityWithOneLoginCallbackWhenPutDonorStoreError(t *testing.T) { ParseIdentityClaim(mock.Anything, mock.Anything). Return(identity.UserData{Status: identity.StatusConfirmed}, nil) - err := IdentityWithOneLoginCallback(oneLoginClient, sessionStore, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := IdentityWithOneLoginCallback(oneLoginClient, sessionStore, donorStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -312,7 +312,7 @@ func TestGetIdentityWithOneLoginCallbackWhenReturning(t *testing.T) { now := time.Date(2012, time.January, 1, 2, 3, 4, 5, time.UTC) userData := identity.UserData{Status: identity.StatusConfirmed, FirstNames: "first-name", LastName: "last-name", RetrievedAt: now} - err := IdentityWithOneLoginCallback(nil, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := IdentityWithOneLoginCallback(nil, nil, nil)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "first-name", LastName: "last-name"}, DonorIdentityUserData: userData, diff --git a/internal/donor/donorpage/identity_with_one_login_test.go b/internal/donor/donorpage/identity_with_one_login_test.go index 72ea8c2f30..8570118656 100644 --- a/internal/donor/donorpage/identity_with_one_login_test.go +++ b/internal/donor/donorpage/identity_with_one_login_test.go @@ -27,7 +27,7 @@ func TestIdentityWithOneLogin(t *testing.T) { SetOneLogin(r, w, &sesh.OneLoginSession{State: "i am random", Nonce: "i am random", Locale: "cy", Redirect: page.Paths.IdentityWithOneLoginCallback.Format("lpa-id"), LpaID: "lpa-id"}). Return(nil) - err := IdentityWithOneLogin(client, sessionStore, func(int) string { return "i am random" })(page.AppData{Lang: localize.Cy}, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) + err := IdentityWithOneLogin(client, sessionStore, func(int) string { return "i am random" })(page.AppData{Lang: localize.Cy}, w, r, &donordata.Provided{LpaID: "lpa-id"}) resp := w.Result() assert.Nil(t, err) @@ -44,7 +44,7 @@ func TestIdentityWithOneLoginWhenAuthCodeURLError(t *testing.T) { AuthCodeURL("i am random", "i am random", "", true). Return("http://auth?locale=en", expectedError) - err := IdentityWithOneLogin(client, nil, func(int) string { return "i am random" })(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := IdentityWithOneLogin(client, nil, func(int) string { return "i am random" })(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -65,7 +65,7 @@ func TestIdentityWithOneLoginWhenStoreSaveError(t *testing.T) { SetOneLogin(r, w, mock.Anything). Return(expectedError) - err := IdentityWithOneLogin(client, sessionStore, func(int) string { return "i am random" })(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := IdentityWithOneLogin(client, sessionStore, func(int) string { return "i am random" })(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) diff --git a/internal/donor/donorpage/life_sustaining_treatment.go b/internal/donor/donorpage/life_sustaining_treatment.go index 29122d88ee..874d4ad84a 100644 --- a/internal/donor/donorpage/life_sustaining_treatment.go +++ b/internal/donor/donorpage/life_sustaining_treatment.go @@ -4,9 +4,9 @@ import ( "net/http" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -18,7 +18,7 @@ type lifeSustainingTreatmentData struct { } func LifeSustainingTreatment(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &lifeSustainingTreatmentData{ App: appData, Form: &lifeSustainingTreatmentForm{ @@ -33,7 +33,7 @@ func LifeSustainingTreatment(tmpl template.Template, donorStore DonorStore) Hand if data.Errors.None() { donor.LifeSustainingTreatmentOption = data.Form.Option - donor.Tasks.LifeSustainingTreatment = actor.TaskCompleted + donor.Tasks.LifeSustainingTreatment = task.StateCompleted if err := donorStore.Put(r.Context(), donor); err != nil { return err } diff --git a/internal/donor/donorpage/life_sustaining_treatment_test.go b/internal/donor/donorpage/life_sustaining_treatment_test.go index 0513a95b94..b255356fff 100644 --- a/internal/donor/donorpage/life_sustaining_treatment_test.go +++ b/internal/donor/donorpage/life_sustaining_treatment_test.go @@ -7,9 +7,9 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -28,7 +28,7 @@ func TestGetLifeSustainingTreatment(t *testing.T) { }). Return(nil) - err := LifeSustainingTreatment(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := LifeSustainingTreatment(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -50,7 +50,7 @@ func TestGetLifeSustainingTreatmentFromStore(t *testing.T) { }). Return(nil) - err := LifeSustainingTreatment(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LifeSustainingTreatmentOption: donordata.LifeSustainingTreatmentOptionA}) + err := LifeSustainingTreatment(template.Execute, nil)(testAppData, w, r, &donordata.Provided{LifeSustainingTreatmentOption: donordata.LifeSustainingTreatmentOptionA}) resp := w.Result() assert.Nil(t, err) @@ -66,7 +66,7 @@ func TestGetLifeSustainingTreatmentWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := LifeSustainingTreatment(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := LifeSustainingTreatment(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -84,16 +84,16 @@ func TestPostLifeSustainingTreatment(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", LifeSustainingTreatmentOption: donordata.LifeSustainingTreatmentOptionA, - Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, LifeSustainingTreatment: actor.TaskCompleted}, + Tasks: donordata.Tasks{YourDetails: task.StateCompleted, ChooseAttorneys: task.StateCompleted, LifeSustainingTreatment: task.StateCompleted}, }). Return(nil) - err := LifeSustainingTreatment(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := LifeSustainingTreatment(nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", - Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted}, + Tasks: donordata.Tasks{YourDetails: task.StateCompleted, ChooseAttorneys: task.StateCompleted}, }) resp := w.Result() @@ -113,10 +113,10 @@ func TestPostLifeSustainingTreatmentWhenStoreErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{LifeSustainingTreatmentOption: donordata.LifeSustainingTreatmentOptionA, Tasks: donordata.DonorTasks{LifeSustainingTreatment: actor.TaskCompleted}}). + Put(r.Context(), &donordata.Provided{LifeSustainingTreatmentOption: donordata.LifeSustainingTreatmentOptionA, Tasks: donordata.Tasks{LifeSustainingTreatment: task.StateCompleted}}). Return(expectedError) - err := LifeSustainingTreatment(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := LifeSustainingTreatment(nil, donorStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -133,7 +133,7 @@ func TestPostLifeSustainingTreatmentWhenValidationErrors(t *testing.T) { })). Return(nil) - err := LifeSustainingTreatment(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := LifeSustainingTreatment(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/lpa_details_saved.go b/internal/donor/donorpage/lpa_details_saved.go index 6199810b2a..a75c127fbe 100644 --- a/internal/donor/donorpage/lpa_details_saved.go +++ b/internal/donor/donorpage/lpa_details_saved.go @@ -11,13 +11,13 @@ import ( type LpaDetailsSavedData struct { App page.AppData - Donor *donordata.DonorProvidedDetails + Donor *donordata.Provided IsFirstCheck bool Errors validation.List } func LpaDetailsSaved(tmpl template.Template) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { return tmpl(w, LpaDetailsSavedData{ App: appData, IsFirstCheck: r.URL.Query().Has("firstCheck"), diff --git a/internal/donor/donorpage/lpa_details_saved_test.go b/internal/donor/donorpage/lpa_details_saved_test.go index ac30f4cef4..b03ff3b382 100644 --- a/internal/donor/donorpage/lpa_details_saved_test.go +++ b/internal/donor/donorpage/lpa_details_saved_test.go @@ -26,11 +26,11 @@ func TestGetLpaDetailsSaved(t *testing.T) { Execute(w, LpaDetailsSavedData{ App: testAppData, IsFirstCheck: expectedIsFirstCheck, - Donor: &donordata.DonorProvidedDetails{}, + Donor: &donordata.Provided{}, }). Return(nil) - err := LpaDetailsSaved(template.Execute)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := LpaDetailsSaved(template.Execute)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -48,7 +48,7 @@ func TestGetLpaDetailsSavedOnTemplateError(t *testing.T) { Execute(mock.Anything, mock.Anything). Return(expectedError) - err := LpaDetailsSaved(template.Execute)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := LpaDetailsSaved(template.Execute)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) diff --git a/internal/donor/donorpage/lpa_progress.go b/internal/donor/donorpage/lpa_progress.go index 4675706193..7e4ef73b21 100644 --- a/internal/donor/donorpage/lpa_progress.go +++ b/internal/donor/donorpage/lpa_progress.go @@ -11,13 +11,13 @@ import ( type lpaProgressData struct { App page.AppData - Donor *donordata.DonorProvidedDetails + Donor *donordata.Provided Progress page.Progress Errors validation.List } func LpaProgress(tmpl template.Template, lpaStoreResolvingService LpaStoreResolvingService, progressTracker ProgressTracker) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { lpa, err := lpaStoreResolvingService.Get(r.Context()) if err != nil { return err diff --git a/internal/donor/donorpage/lpa_progress_test.go b/internal/donor/donorpage/lpa_progress_test.go index e6e2ffa11f..c864d52fd0 100644 --- a/internal/donor/donorpage/lpa_progress_test.go +++ b/internal/donor/donorpage/lpa_progress_test.go @@ -5,10 +5,10 @@ import ( "net/http/httptest" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" lpastore "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -27,18 +27,18 @@ func TestGetLpaProgress(t *testing.T) { progressTracker := newMockProgressTracker(t) progressTracker.EXPECT(). Progress(lpa). - Return(page.Progress{DonorSigned: page.ProgressTask{State: actor.TaskInProgress}}) + Return(page.Progress{DonorSigned: page.ProgressTask{State: task.StateInProgress}}) template := newMockTemplate(t) template.EXPECT(). Execute(w, &lpaProgressData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{LpaUID: "lpa-uid"}, - Progress: page.Progress{DonorSigned: page.ProgressTask{State: actor.TaskInProgress}}, + Donor: &donordata.Provided{LpaUID: "lpa-uid"}, + Progress: page.Progress{DonorSigned: page.ProgressTask{State: task.StateInProgress}}, }). Return(nil) - err := LpaProgress(template.Execute, lpaStoreResolvingService, progressTracker)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaUID: "lpa-uid"}) + err := LpaProgress(template.Execute, lpaStoreResolvingService, progressTracker)(testAppData, w, r, &donordata.Provided{LpaUID: "lpa-uid"}) resp := w.Result() assert.Nil(t, err) @@ -54,7 +54,7 @@ func TestGetLpaProgressWhenLpaStoreClientErrors(t *testing.T) { Get(r.Context()). Return(nil, expectedError) - err := LpaProgress(nil, lpaStoreResolvingService, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaUID: "lpa-uid"}) + err := LpaProgress(nil, lpaStoreResolvingService, nil)(testAppData, w, r, &donordata.Provided{LpaUID: "lpa-uid"}) assert.Equal(t, expectedError, err) } @@ -77,6 +77,6 @@ func TestGetLpaProgressOnTemplateError(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := LpaProgress(template.Execute, lpaStoreResolvingService, progressTracker)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaUID: "lpa-uid"}) + err := LpaProgress(template.Execute, lpaStoreResolvingService, progressTracker)(testAppData, w, r, &donordata.Provided{LpaUID: "lpa-uid"}) assert.Equal(t, expectedError, err) } diff --git a/internal/donor/donorpage/lpa_type.go b/internal/donor/donorpage/lpa_type.go index 3836238a19..96f879360f 100644 --- a/internal/donor/donorpage/lpa_type.go +++ b/internal/donor/donorpage/lpa_type.go @@ -4,11 +4,11 @@ import ( "net/http" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/event" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/uid" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -22,7 +22,7 @@ type lpaTypeData struct { } func LpaType(tmpl template.Template, donorStore DonorStore, eventClient EventClient) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &lpaTypeData{ App: appData, Form: &lpaTypeForm{ @@ -46,7 +46,7 @@ func LpaType(tmpl template.Template, donorStore DonorStore, eventClient EventCli if donor.Type.IsPersonalWelfare() { donor.WhenCanTheLpaBeUsed = donordata.CanBeUsedWhenCapacityLost } - donor.Tasks.YourDetails = actor.TaskCompleted + donor.Tasks.YourDetails = task.StateCompleted donor.HasSentApplicationUpdatedEvent = false if err := donorStore.Put(r.Context(), donor); err != nil { diff --git a/internal/donor/donorpage/lpa_type_test.go b/internal/donor/donorpage/lpa_type_test.go index ff49788aaa..5084bc0f53 100644 --- a/internal/donor/donorpage/lpa_type_test.go +++ b/internal/donor/donorpage/lpa_type_test.go @@ -8,13 +8,13 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/date" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/event" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/uid" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" @@ -34,7 +34,7 @@ func TestGetLpaType(t *testing.T) { }). Return(nil) - err := LpaType(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := LpaType(template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -57,7 +57,7 @@ func TestGetLpaTypeFromStore(t *testing.T) { }). Return(nil) - err := LpaType(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{Type: donordata.LpaTypePropertyAndAffairs}) + err := LpaType(template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{Type: donordata.LpaTypePropertyAndAffairs}) resp := w.Result() assert.Nil(t, err) @@ -73,7 +73,7 @@ func TestGetLpaTypeWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := LpaType(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := LpaType(template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -81,7 +81,7 @@ func TestGetLpaTypeWhenTemplateErrors(t *testing.T) { } func TestPostLpaType(t *testing.T) { - testcases := map[donordata.LpaType]*donordata.DonorProvidedDetails{ + testcases := map[donordata.LpaType]*donordata.Provided{ donordata.LpaTypePropertyAndAffairs: { LpaID: "lpa-id", Donor: donordata.Donor{ @@ -91,7 +91,7 @@ func TestPostLpaType(t *testing.T) { Address: place.Address{Postcode: "F1 1FF"}, }, Type: donordata.LpaTypePropertyAndAffairs, - Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted}, + Tasks: donordata.Tasks{YourDetails: task.StateCompleted}, }, donordata.LpaTypePersonalWelfare: { LpaID: "lpa-id", @@ -103,7 +103,7 @@ func TestPostLpaType(t *testing.T) { }, Type: donordata.LpaTypePersonalWelfare, WhenCanTheLpaBeUsed: donordata.CanBeUsedWhenCapacityLost, - Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted}, + Tasks: donordata.Tasks{YourDetails: task.StateCompleted}, }, } @@ -138,7 +138,7 @@ func TestPostLpaType(t *testing.T) { }). Return(nil) - err := LpaType(nil, donorStore, eventClient)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := LpaType(nil, donorStore, eventClient)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{ FirstNames: "John", @@ -175,7 +175,7 @@ func TestPostLpaTypeWhenTrustCorporation(t *testing.T) { })). Return(nil) - err := LpaType(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := LpaType(template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{ FirstNames: "John", @@ -201,7 +201,7 @@ func TestPostLpaTypeWhenSessionErrors(t *testing.T) { r, _ := http.NewRequestWithContext(context.Background(), http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - err := LpaType(nil, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := LpaType(nil, nil, nil)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", }) @@ -229,7 +229,7 @@ func TestPostLpaTypeWhenEventErrors(t *testing.T) { SendUidRequested(r.Context(), mock.Anything). Return(expectedError) - err := LpaType(nil, donorStore, eventClient)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := LpaType(nil, donorStore, eventClient)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", }) @@ -252,7 +252,7 @@ func TestPostLpaTypeWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := LpaType(nil, donorStore, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := LpaType(nil, donorStore, nil)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -269,7 +269,7 @@ func TestPostLpaTypeWhenValidationErrors(t *testing.T) { })). Return(nil) - err := LpaType(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := LpaType(template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/mock_DocumentStore_test.go b/internal/donor/donorpage/mock_DocumentStore_test.go index b4ab4ca0ee..a06487fc8c 100644 --- a/internal/donor/donorpage/mock_DocumentStore_test.go +++ b/internal/donor/donorpage/mock_DocumentStore_test.go @@ -25,7 +25,7 @@ func (_m *mockDocumentStore) EXPECT() *mockDocumentStore_Expecter { } // Create provides a mock function with given fields: _a0, _a1, _a2, _a3 -func (_m *mockDocumentStore) Create(_a0 context.Context, _a1 *donordata.DonorProvidedDetails, _a2 string, _a3 []byte) (page.Document, error) { +func (_m *mockDocumentStore) Create(_a0 context.Context, _a1 *donordata.Provided, _a2 string, _a3 []byte) (page.Document, error) { ret := _m.Called(_a0, _a1, _a2, _a3) if len(ret) == 0 { @@ -34,16 +34,16 @@ func (_m *mockDocumentStore) Create(_a0 context.Context, _a1 *donordata.DonorPro var r0 page.Document var r1 error - if rf, ok := ret.Get(0).(func(context.Context, *donordata.DonorProvidedDetails, string, []byte) (page.Document, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, *donordata.Provided, string, []byte) (page.Document, error)); ok { return rf(_a0, _a1, _a2, _a3) } - if rf, ok := ret.Get(0).(func(context.Context, *donordata.DonorProvidedDetails, string, []byte) page.Document); ok { + if rf, ok := ret.Get(0).(func(context.Context, *donordata.Provided, string, []byte) page.Document); ok { r0 = rf(_a0, _a1, _a2, _a3) } else { r0 = ret.Get(0).(page.Document) } - if rf, ok := ret.Get(1).(func(context.Context, *donordata.DonorProvidedDetails, string, []byte) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, *donordata.Provided, string, []byte) error); ok { r1 = rf(_a0, _a1, _a2, _a3) } else { r1 = ret.Error(1) @@ -66,9 +66,9 @@ func (_e *mockDocumentStore_Expecter) Create(_a0 interface{}, _a1 interface{}, _ return &mockDocumentStore_Create_Call{Call: _e.mock.On("Create", _a0, _a1, _a2, _a3)} } -func (_c *mockDocumentStore_Create_Call) Run(run func(_a0 context.Context, _a1 *donordata.DonorProvidedDetails, _a2 string, _a3 []byte)) *mockDocumentStore_Create_Call { +func (_c *mockDocumentStore_Create_Call) Run(run func(_a0 context.Context, _a1 *donordata.Provided, _a2 string, _a3 []byte)) *mockDocumentStore_Create_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*donordata.DonorProvidedDetails), args[2].(string), args[3].([]byte)) + run(args[0].(context.Context), args[1].(*donordata.Provided), args[2].(string), args[3].([]byte)) }) return _c } @@ -78,7 +78,7 @@ func (_c *mockDocumentStore_Create_Call) Return(_a0 page.Document, _a1 error) *m return _c } -func (_c *mockDocumentStore_Create_Call) RunAndReturn(run func(context.Context, *donordata.DonorProvidedDetails, string, []byte) (page.Document, error)) *mockDocumentStore_Create_Call { +func (_c *mockDocumentStore_Create_Call) RunAndReturn(run func(context.Context, *donordata.Provided, string, []byte) (page.Document, error)) *mockDocumentStore_Create_Call { _c.Call.Return(run) return _c } @@ -283,7 +283,7 @@ func (_c *mockDocumentStore_Put_Call) RunAndReturn(run func(context.Context, pag } // Submit provides a mock function with given fields: _a0, _a1, _a2 -func (_m *mockDocumentStore) Submit(_a0 context.Context, _a1 *donordata.DonorProvidedDetails, _a2 page.Documents) error { +func (_m *mockDocumentStore) Submit(_a0 context.Context, _a1 *donordata.Provided, _a2 page.Documents) error { ret := _m.Called(_a0, _a1, _a2) if len(ret) == 0 { @@ -291,7 +291,7 @@ func (_m *mockDocumentStore) Submit(_a0 context.Context, _a1 *donordata.DonorPro } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *donordata.DonorProvidedDetails, page.Documents) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, *donordata.Provided, page.Documents) error); ok { r0 = rf(_a0, _a1, _a2) } else { r0 = ret.Error(0) @@ -313,9 +313,9 @@ func (_e *mockDocumentStore_Expecter) Submit(_a0 interface{}, _a1 interface{}, _ return &mockDocumentStore_Submit_Call{Call: _e.mock.On("Submit", _a0, _a1, _a2)} } -func (_c *mockDocumentStore_Submit_Call) Run(run func(_a0 context.Context, _a1 *donordata.DonorProvidedDetails, _a2 page.Documents)) *mockDocumentStore_Submit_Call { +func (_c *mockDocumentStore_Submit_Call) Run(run func(_a0 context.Context, _a1 *donordata.Provided, _a2 page.Documents)) *mockDocumentStore_Submit_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*donordata.DonorProvidedDetails), args[2].(page.Documents)) + run(args[0].(context.Context), args[1].(*donordata.Provided), args[2].(page.Documents)) }) return _c } @@ -325,7 +325,7 @@ func (_c *mockDocumentStore_Submit_Call) Return(_a0 error) *mockDocumentStore_Su return _c } -func (_c *mockDocumentStore_Submit_Call) RunAndReturn(run func(context.Context, *donordata.DonorProvidedDetails, page.Documents) error) *mockDocumentStore_Submit_Call { +func (_c *mockDocumentStore_Submit_Call) RunAndReturn(run func(context.Context, *donordata.Provided, page.Documents) error) *mockDocumentStore_Submit_Call { _c.Call.Return(run) return _c } diff --git a/internal/donor/donorpage/mock_DonorStore_test.go b/internal/donor/donorpage/mock_DonorStore_test.go index d5f47b8481..a165b2ba9d 100644 --- a/internal/donor/donorpage/mock_DonorStore_test.go +++ b/internal/donor/donorpage/mock_DonorStore_test.go @@ -71,23 +71,23 @@ func (_c *mockDonorStore_Delete_Call) RunAndReturn(run func(context.Context) err } // Get provides a mock function with given fields: ctx -func (_m *mockDonorStore) Get(ctx context.Context) (*donordata.DonorProvidedDetails, error) { +func (_m *mockDonorStore) Get(ctx context.Context) (*donordata.Provided, error) { ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for Get") } - var r0 *donordata.DonorProvidedDetails + var r0 *donordata.Provided var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (*donordata.DonorProvidedDetails, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context) (*donordata.Provided, error)); ok { return rf(ctx) } - if rf, ok := ret.Get(0).(func(context.Context) *donordata.DonorProvidedDetails); ok { + if rf, ok := ret.Get(0).(func(context.Context) *donordata.Provided); ok { r0 = rf(ctx) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*donordata.DonorProvidedDetails) + r0 = ret.Get(0).(*donordata.Provided) } } @@ -118,34 +118,34 @@ func (_c *mockDonorStore_Get_Call) Run(run func(ctx context.Context)) *mockDonor return _c } -func (_c *mockDonorStore_Get_Call) Return(_a0 *donordata.DonorProvidedDetails, _a1 error) *mockDonorStore_Get_Call { +func (_c *mockDonorStore_Get_Call) Return(_a0 *donordata.Provided, _a1 error) *mockDonorStore_Get_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockDonorStore_Get_Call) RunAndReturn(run func(context.Context) (*donordata.DonorProvidedDetails, error)) *mockDonorStore_Get_Call { +func (_c *mockDonorStore_Get_Call) RunAndReturn(run func(context.Context) (*donordata.Provided, error)) *mockDonorStore_Get_Call { _c.Call.Return(run) return _c } // Latest provides a mock function with given fields: ctx -func (_m *mockDonorStore) Latest(ctx context.Context) (*donordata.DonorProvidedDetails, error) { +func (_m *mockDonorStore) Latest(ctx context.Context) (*donordata.Provided, error) { ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for Latest") } - var r0 *donordata.DonorProvidedDetails + var r0 *donordata.Provided var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (*donordata.DonorProvidedDetails, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context) (*donordata.Provided, error)); ok { return rf(ctx) } - if rf, ok := ret.Get(0).(func(context.Context) *donordata.DonorProvidedDetails); ok { + if rf, ok := ret.Get(0).(func(context.Context) *donordata.Provided); ok { r0 = rf(ctx) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*donordata.DonorProvidedDetails) + r0 = ret.Get(0).(*donordata.Provided) } } @@ -176,18 +176,18 @@ func (_c *mockDonorStore_Latest_Call) Run(run func(ctx context.Context)) *mockDo return _c } -func (_c *mockDonorStore_Latest_Call) Return(_a0 *donordata.DonorProvidedDetails, _a1 error) *mockDonorStore_Latest_Call { +func (_c *mockDonorStore_Latest_Call) Return(_a0 *donordata.Provided, _a1 error) *mockDonorStore_Latest_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockDonorStore_Latest_Call) RunAndReturn(run func(context.Context) (*donordata.DonorProvidedDetails, error)) *mockDonorStore_Latest_Call { +func (_c *mockDonorStore_Latest_Call) RunAndReturn(run func(context.Context) (*donordata.Provided, error)) *mockDonorStore_Latest_Call { _c.Call.Return(run) return _c } // Link provides a mock function with given fields: ctx, data, donorEmail -func (_m *mockDonorStore) Link(ctx context.Context, data sharecode.ShareCodeData, donorEmail string) error { +func (_m *mockDonorStore) Link(ctx context.Context, data sharecode.Data, donorEmail string) error { ret := _m.Called(ctx, data, donorEmail) if len(ret) == 0 { @@ -195,7 +195,7 @@ func (_m *mockDonorStore) Link(ctx context.Context, data sharecode.ShareCodeData } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, sharecode.ShareCodeData, string) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, sharecode.Data, string) error); ok { r0 = rf(ctx, data, donorEmail) } else { r0 = ret.Error(0) @@ -211,15 +211,15 @@ type mockDonorStore_Link_Call struct { // Link is a helper method to define mock.On call // - ctx context.Context -// - data sharecode.ShareCodeData +// - data sharecode.Data // - donorEmail string func (_e *mockDonorStore_Expecter) Link(ctx interface{}, data interface{}, donorEmail interface{}) *mockDonorStore_Link_Call { return &mockDonorStore_Link_Call{Call: _e.mock.On("Link", ctx, data, donorEmail)} } -func (_c *mockDonorStore_Link_Call) Run(run func(ctx context.Context, data sharecode.ShareCodeData, donorEmail string)) *mockDonorStore_Link_Call { +func (_c *mockDonorStore_Link_Call) Run(run func(ctx context.Context, data sharecode.Data, donorEmail string)) *mockDonorStore_Link_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(sharecode.ShareCodeData), args[2].(string)) + run(args[0].(context.Context), args[1].(sharecode.Data), args[2].(string)) }) return _c } @@ -229,13 +229,13 @@ func (_c *mockDonorStore_Link_Call) Return(_a0 error) *mockDonorStore_Link_Call return _c } -func (_c *mockDonorStore_Link_Call) RunAndReturn(run func(context.Context, sharecode.ShareCodeData, string) error) *mockDonorStore_Link_Call { +func (_c *mockDonorStore_Link_Call) RunAndReturn(run func(context.Context, sharecode.Data, string) error) *mockDonorStore_Link_Call { _c.Call.Return(run) return _c } // Put provides a mock function with given fields: ctx, donor -func (_m *mockDonorStore) Put(ctx context.Context, donor *donordata.DonorProvidedDetails) error { +func (_m *mockDonorStore) Put(ctx context.Context, donor *donordata.Provided) error { ret := _m.Called(ctx, donor) if len(ret) == 0 { @@ -243,7 +243,7 @@ func (_m *mockDonorStore) Put(ctx context.Context, donor *donordata.DonorProvide } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *donordata.DonorProvidedDetails) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, *donordata.Provided) error); ok { r0 = rf(ctx, donor) } else { r0 = ret.Error(0) @@ -264,9 +264,9 @@ func (_e *mockDonorStore_Expecter) Put(ctx interface{}, donor interface{}) *mock return &mockDonorStore_Put_Call{Call: _e.mock.On("Put", ctx, donor)} } -func (_c *mockDonorStore_Put_Call) Run(run func(ctx context.Context, donor *donordata.DonorProvidedDetails)) *mockDonorStore_Put_Call { +func (_c *mockDonorStore_Put_Call) Run(run func(ctx context.Context, donor *donordata.Provided)) *mockDonorStore_Put_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*donordata.DonorProvidedDetails)) + run(args[0].(context.Context), args[1].(*donordata.Provided)) }) return _c } @@ -276,7 +276,7 @@ func (_c *mockDonorStore_Put_Call) Return(_a0 error) *mockDonorStore_Put_Call { return _c } -func (_c *mockDonorStore_Put_Call) RunAndReturn(run func(context.Context, *donordata.DonorProvidedDetails) error) *mockDonorStore_Put_Call { +func (_c *mockDonorStore_Put_Call) RunAndReturn(run func(context.Context, *donordata.Provided) error) *mockDonorStore_Put_Call { _c.Call.Return(run) return _c } diff --git a/internal/donor/donorpage/mock_GetDonorStore_test.go b/internal/donor/donorpage/mock_GetDonorStore_test.go index 153225bd55..966ca0c195 100644 --- a/internal/donor/donorpage/mock_GetDonorStore_test.go +++ b/internal/donor/donorpage/mock_GetDonorStore_test.go @@ -23,23 +23,23 @@ func (_m *mockGetDonorStore) EXPECT() *mockGetDonorStore_Expecter { } // Get provides a mock function with given fields: _a0 -func (_m *mockGetDonorStore) Get(_a0 context.Context) (*donordata.DonorProvidedDetails, error) { +func (_m *mockGetDonorStore) Get(_a0 context.Context) (*donordata.Provided, error) { ret := _m.Called(_a0) if len(ret) == 0 { panic("no return value specified for Get") } - var r0 *donordata.DonorProvidedDetails + var r0 *donordata.Provided var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (*donordata.DonorProvidedDetails, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context) (*donordata.Provided, error)); ok { return rf(_a0) } - if rf, ok := ret.Get(0).(func(context.Context) *donordata.DonorProvidedDetails); ok { + if rf, ok := ret.Get(0).(func(context.Context) *donordata.Provided); ok { r0 = rf(_a0) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*donordata.DonorProvidedDetails) + r0 = ret.Get(0).(*donordata.Provided) } } @@ -70,12 +70,12 @@ func (_c *mockGetDonorStore_Get_Call) Run(run func(_a0 context.Context)) *mockGe return _c } -func (_c *mockGetDonorStore_Get_Call) Return(_a0 *donordata.DonorProvidedDetails, _a1 error) *mockGetDonorStore_Get_Call { +func (_c *mockGetDonorStore_Get_Call) Return(_a0 *donordata.Provided, _a1 error) *mockGetDonorStore_Get_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockGetDonorStore_Get_Call) RunAndReturn(run func(context.Context) (*donordata.DonorProvidedDetails, error)) *mockGetDonorStore_Get_Call { +func (_c *mockGetDonorStore_Get_Call) RunAndReturn(run func(context.Context) (*donordata.Provided, error)) *mockGetDonorStore_Get_Call { _c.Call.Return(run) return _c } diff --git a/internal/donor/donorpage/mock_Handler_test.go b/internal/donor/donorpage/mock_Handler_test.go index 0b6f2da8c1..e7830fa1eb 100644 --- a/internal/donor/donorpage/mock_Handler_test.go +++ b/internal/donor/donorpage/mock_Handler_test.go @@ -26,7 +26,7 @@ func (_m *mockHandler) EXPECT() *mockHandler_Expecter { } // Execute provides a mock function with given fields: data, w, r, donor -func (_m *mockHandler) Execute(data page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { +func (_m *mockHandler) Execute(data page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { ret := _m.Called(data, w, r, donor) if len(ret) == 0 { @@ -34,7 +34,7 @@ func (_m *mockHandler) Execute(data page.AppData, w http.ResponseWriter, r *http } var r0 error - if rf, ok := ret.Get(0).(func(page.AppData, http.ResponseWriter, *http.Request, *donordata.DonorProvidedDetails) error); ok { + if rf, ok := ret.Get(0).(func(page.AppData, http.ResponseWriter, *http.Request, *donordata.Provided) error); ok { r0 = rf(data, w, r, donor) } else { r0 = ret.Error(0) @@ -57,9 +57,9 @@ func (_e *mockHandler_Expecter) Execute(data interface{}, w interface{}, r inter return &mockHandler_Execute_Call{Call: _e.mock.On("Execute", data, w, r, donor)} } -func (_c *mockHandler_Execute_Call) Run(run func(data page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails)) *mockHandler_Execute_Call { +func (_c *mockHandler_Execute_Call) Run(run func(data page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided)) *mockHandler_Execute_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(page.AppData), args[1].(http.ResponseWriter), args[2].(*http.Request), args[3].(*donordata.DonorProvidedDetails)) + run(args[0].(page.AppData), args[1].(http.ResponseWriter), args[2].(*http.Request), args[3].(*donordata.Provided)) }) return _c } @@ -69,7 +69,7 @@ func (_c *mockHandler_Execute_Call) Return(_a0 error) *mockHandler_Execute_Call return _c } -func (_c *mockHandler_Execute_Call) RunAndReturn(run func(page.AppData, http.ResponseWriter, *http.Request, *donordata.DonorProvidedDetails) error) *mockHandler_Execute_Call { +func (_c *mockHandler_Execute_Call) RunAndReturn(run func(page.AppData, http.ResponseWriter, *http.Request, *donordata.Provided) error) *mockHandler_Execute_Call { _c.Call.Return(run) return _c } diff --git a/internal/donor/donorpage/mock_LpaStoreClient_test.go b/internal/donor/donorpage/mock_LpaStoreClient_test.go index 8892594ddc..8088b5af60 100644 --- a/internal/donor/donorpage/mock_LpaStoreClient_test.go +++ b/internal/donor/donorpage/mock_LpaStoreClient_test.go @@ -84,7 +84,7 @@ func (_c *mockLpaStoreClient_Lpa_Call) RunAndReturn(run func(context.Context, st } // SendDonorConfirmIdentity provides a mock function with given fields: ctx, donor -func (_m *mockLpaStoreClient) SendDonorConfirmIdentity(ctx context.Context, donor *donordata.DonorProvidedDetails) error { +func (_m *mockLpaStoreClient) SendDonorConfirmIdentity(ctx context.Context, donor *donordata.Provided) error { ret := _m.Called(ctx, donor) if len(ret) == 0 { @@ -92,7 +92,7 @@ func (_m *mockLpaStoreClient) SendDonorConfirmIdentity(ctx context.Context, dono } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *donordata.DonorProvidedDetails) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, *donordata.Provided) error); ok { r0 = rf(ctx, donor) } else { r0 = ret.Error(0) @@ -113,9 +113,9 @@ func (_e *mockLpaStoreClient_Expecter) SendDonorConfirmIdentity(ctx interface{}, return &mockLpaStoreClient_SendDonorConfirmIdentity_Call{Call: _e.mock.On("SendDonorConfirmIdentity", ctx, donor)} } -func (_c *mockLpaStoreClient_SendDonorConfirmIdentity_Call) Run(run func(ctx context.Context, donor *donordata.DonorProvidedDetails)) *mockLpaStoreClient_SendDonorConfirmIdentity_Call { +func (_c *mockLpaStoreClient_SendDonorConfirmIdentity_Call) Run(run func(ctx context.Context, donor *donordata.Provided)) *mockLpaStoreClient_SendDonorConfirmIdentity_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*donordata.DonorProvidedDetails)) + run(args[0].(context.Context), args[1].(*donordata.Provided)) }) return _c } @@ -125,13 +125,13 @@ func (_c *mockLpaStoreClient_SendDonorConfirmIdentity_Call) Return(_a0 error) *m return _c } -func (_c *mockLpaStoreClient_SendDonorConfirmIdentity_Call) RunAndReturn(run func(context.Context, *donordata.DonorProvidedDetails) error) *mockLpaStoreClient_SendDonorConfirmIdentity_Call { +func (_c *mockLpaStoreClient_SendDonorConfirmIdentity_Call) RunAndReturn(run func(context.Context, *donordata.Provided) error) *mockLpaStoreClient_SendDonorConfirmIdentity_Call { _c.Call.Return(run) return _c } // SendLpa provides a mock function with given fields: ctx, details -func (_m *mockLpaStoreClient) SendLpa(ctx context.Context, details *donordata.DonorProvidedDetails) error { +func (_m *mockLpaStoreClient) SendLpa(ctx context.Context, details *donordata.Provided) error { ret := _m.Called(ctx, details) if len(ret) == 0 { @@ -139,7 +139,7 @@ func (_m *mockLpaStoreClient) SendLpa(ctx context.Context, details *donordata.Do } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *donordata.DonorProvidedDetails) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, *donordata.Provided) error); ok { r0 = rf(ctx, details) } else { r0 = ret.Error(0) @@ -160,9 +160,9 @@ func (_e *mockLpaStoreClient_Expecter) SendLpa(ctx interface{}, details interfac return &mockLpaStoreClient_SendLpa_Call{Call: _e.mock.On("SendLpa", ctx, details)} } -func (_c *mockLpaStoreClient_SendLpa_Call) Run(run func(ctx context.Context, details *donordata.DonorProvidedDetails)) *mockLpaStoreClient_SendLpa_Call { +func (_c *mockLpaStoreClient_SendLpa_Call) Run(run func(ctx context.Context, details *donordata.Provided)) *mockLpaStoreClient_SendLpa_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*donordata.DonorProvidedDetails)) + run(args[0].(context.Context), args[1].(*donordata.Provided)) }) return _c } @@ -172,7 +172,7 @@ func (_c *mockLpaStoreClient_SendLpa_Call) Return(_a0 error) *mockLpaStoreClient return _c } -func (_c *mockLpaStoreClient_SendLpa_Call) RunAndReturn(run func(context.Context, *donordata.DonorProvidedDetails) error) *mockLpaStoreClient_SendLpa_Call { +func (_c *mockLpaStoreClient_SendLpa_Call) RunAndReturn(run func(context.Context, *donordata.Provided) error) *mockLpaStoreClient_SendLpa_Call { _c.Call.Return(run) return _c } diff --git a/internal/donor/donorpage/mock_ShareCodeSender_test.go b/internal/donor/donorpage/mock_ShareCodeSender_test.go index 71dfcfa59e..34f9829ae4 100644 --- a/internal/donor/donorpage/mock_ShareCodeSender_test.go +++ b/internal/donor/donorpage/mock_ShareCodeSender_test.go @@ -73,7 +73,7 @@ func (_c *mockShareCodeSender_SendCertificateProviderInvite_Call) RunAndReturn(r } // SendCertificateProviderPrompt provides a mock function with given fields: _a0, _a1, _a2 -func (_m *mockShareCodeSender) SendCertificateProviderPrompt(_a0 context.Context, _a1 page.AppData, _a2 *donordata.DonorProvidedDetails) error { +func (_m *mockShareCodeSender) SendCertificateProviderPrompt(_a0 context.Context, _a1 page.AppData, _a2 *donordata.Provided) error { ret := _m.Called(_a0, _a1, _a2) if len(ret) == 0 { @@ -81,7 +81,7 @@ func (_m *mockShareCodeSender) SendCertificateProviderPrompt(_a0 context.Context } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, page.AppData, *donordata.DonorProvidedDetails) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, page.AppData, *donordata.Provided) error); ok { r0 = rf(_a0, _a1, _a2) } else { r0 = ret.Error(0) @@ -103,9 +103,9 @@ func (_e *mockShareCodeSender_Expecter) SendCertificateProviderPrompt(_a0 interf return &mockShareCodeSender_SendCertificateProviderPrompt_Call{Call: _e.mock.On("SendCertificateProviderPrompt", _a0, _a1, _a2)} } -func (_c *mockShareCodeSender_SendCertificateProviderPrompt_Call) Run(run func(_a0 context.Context, _a1 page.AppData, _a2 *donordata.DonorProvidedDetails)) *mockShareCodeSender_SendCertificateProviderPrompt_Call { +func (_c *mockShareCodeSender_SendCertificateProviderPrompt_Call) Run(run func(_a0 context.Context, _a1 page.AppData, _a2 *donordata.Provided)) *mockShareCodeSender_SendCertificateProviderPrompt_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(page.AppData), args[2].(*donordata.DonorProvidedDetails)) + run(args[0].(context.Context), args[1].(page.AppData), args[2].(*donordata.Provided)) }) return _c } @@ -115,7 +115,7 @@ func (_c *mockShareCodeSender_SendCertificateProviderPrompt_Call) Return(_a0 err return _c } -func (_c *mockShareCodeSender_SendCertificateProviderPrompt_Call) RunAndReturn(run func(context.Context, page.AppData, *donordata.DonorProvidedDetails) error) *mockShareCodeSender_SendCertificateProviderPrompt_Call { +func (_c *mockShareCodeSender_SendCertificateProviderPrompt_Call) RunAndReturn(run func(context.Context, page.AppData, *donordata.Provided) error) *mockShareCodeSender_SendCertificateProviderPrompt_Call { _c.Call.Return(run) return _c } diff --git a/internal/donor/donorpage/mock_ShareCodeStore_test.go b/internal/donor/donorpage/mock_ShareCodeStore_test.go index 8fac118379..42326c72fc 100644 --- a/internal/donor/donorpage/mock_ShareCodeStore_test.go +++ b/internal/donor/donorpage/mock_ShareCodeStore_test.go @@ -25,22 +25,22 @@ func (_m *mockShareCodeStore) EXPECT() *mockShareCodeStore_Expecter { } // Get provides a mock function with given fields: ctx, actorType, code -func (_m *mockShareCodeStore) Get(ctx context.Context, actorType temporary.ActorType, code string) (sharecode.ShareCodeData, error) { +func (_m *mockShareCodeStore) Get(ctx context.Context, actorType temporary.ActorType, code string) (sharecode.Data, error) { ret := _m.Called(ctx, actorType, code) if len(ret) == 0 { panic("no return value specified for Get") } - var r0 sharecode.ShareCodeData + var r0 sharecode.Data var r1 error - if rf, ok := ret.Get(0).(func(context.Context, temporary.ActorType, string) (sharecode.ShareCodeData, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, temporary.ActorType, string) (sharecode.Data, error)); ok { return rf(ctx, actorType, code) } - if rf, ok := ret.Get(0).(func(context.Context, temporary.ActorType, string) sharecode.ShareCodeData); ok { + if rf, ok := ret.Get(0).(func(context.Context, temporary.ActorType, string) sharecode.Data); ok { r0 = rf(ctx, actorType, code) } else { - r0 = ret.Get(0).(sharecode.ShareCodeData) + r0 = ret.Get(0).(sharecode.Data) } if rf, ok := ret.Get(1).(func(context.Context, temporary.ActorType, string) error); ok { @@ -72,12 +72,12 @@ func (_c *mockShareCodeStore_Get_Call) Run(run func(ctx context.Context, actorTy return _c } -func (_c *mockShareCodeStore_Get_Call) Return(_a0 sharecode.ShareCodeData, _a1 error) *mockShareCodeStore_Get_Call { +func (_c *mockShareCodeStore_Get_Call) Return(_a0 sharecode.Data, _a1 error) *mockShareCodeStore_Get_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockShareCodeStore_Get_Call) RunAndReturn(run func(context.Context, temporary.ActorType, string) (sharecode.ShareCodeData, error)) *mockShareCodeStore_Get_Call { +func (_c *mockShareCodeStore_Get_Call) RunAndReturn(run func(context.Context, temporary.ActorType, string) (sharecode.Data, error)) *mockShareCodeStore_Get_Call { _c.Call.Return(run) return _c } diff --git a/internal/donor/donorpage/mock_WitnessCodeSender_test.go b/internal/donor/donorpage/mock_WitnessCodeSender_test.go index fd553c86c8..0942cea102 100644 --- a/internal/donor/donorpage/mock_WitnessCodeSender_test.go +++ b/internal/donor/donorpage/mock_WitnessCodeSender_test.go @@ -25,7 +25,7 @@ func (_m *mockWitnessCodeSender) EXPECT() *mockWitnessCodeSender_Expecter { } // SendToCertificateProvider provides a mock function with given fields: _a0, _a1, _a2 -func (_m *mockWitnessCodeSender) SendToCertificateProvider(_a0 context.Context, _a1 *donordata.DonorProvidedDetails, _a2 page.Localizer) error { +func (_m *mockWitnessCodeSender) SendToCertificateProvider(_a0 context.Context, _a1 *donordata.Provided, _a2 page.Localizer) error { ret := _m.Called(_a0, _a1, _a2) if len(ret) == 0 { @@ -33,7 +33,7 @@ func (_m *mockWitnessCodeSender) SendToCertificateProvider(_a0 context.Context, } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *donordata.DonorProvidedDetails, page.Localizer) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, *donordata.Provided, page.Localizer) error); ok { r0 = rf(_a0, _a1, _a2) } else { r0 = ret.Error(0) @@ -55,9 +55,9 @@ func (_e *mockWitnessCodeSender_Expecter) SendToCertificateProvider(_a0 interfac return &mockWitnessCodeSender_SendToCertificateProvider_Call{Call: _e.mock.On("SendToCertificateProvider", _a0, _a1, _a2)} } -func (_c *mockWitnessCodeSender_SendToCertificateProvider_Call) Run(run func(_a0 context.Context, _a1 *donordata.DonorProvidedDetails, _a2 page.Localizer)) *mockWitnessCodeSender_SendToCertificateProvider_Call { +func (_c *mockWitnessCodeSender_SendToCertificateProvider_Call) Run(run func(_a0 context.Context, _a1 *donordata.Provided, _a2 page.Localizer)) *mockWitnessCodeSender_SendToCertificateProvider_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*donordata.DonorProvidedDetails), args[2].(page.Localizer)) + run(args[0].(context.Context), args[1].(*donordata.Provided), args[2].(page.Localizer)) }) return _c } @@ -67,13 +67,13 @@ func (_c *mockWitnessCodeSender_SendToCertificateProvider_Call) Return(_a0 error return _c } -func (_c *mockWitnessCodeSender_SendToCertificateProvider_Call) RunAndReturn(run func(context.Context, *donordata.DonorProvidedDetails, page.Localizer) error) *mockWitnessCodeSender_SendToCertificateProvider_Call { +func (_c *mockWitnessCodeSender_SendToCertificateProvider_Call) RunAndReturn(run func(context.Context, *donordata.Provided, page.Localizer) error) *mockWitnessCodeSender_SendToCertificateProvider_Call { _c.Call.Return(run) return _c } // SendToIndependentWitness provides a mock function with given fields: _a0, _a1, _a2 -func (_m *mockWitnessCodeSender) SendToIndependentWitness(_a0 context.Context, _a1 *donordata.DonorProvidedDetails, _a2 page.Localizer) error { +func (_m *mockWitnessCodeSender) SendToIndependentWitness(_a0 context.Context, _a1 *donordata.Provided, _a2 page.Localizer) error { ret := _m.Called(_a0, _a1, _a2) if len(ret) == 0 { @@ -81,7 +81,7 @@ func (_m *mockWitnessCodeSender) SendToIndependentWitness(_a0 context.Context, _ } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *donordata.DonorProvidedDetails, page.Localizer) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, *donordata.Provided, page.Localizer) error); ok { r0 = rf(_a0, _a1, _a2) } else { r0 = ret.Error(0) @@ -103,9 +103,9 @@ func (_e *mockWitnessCodeSender_Expecter) SendToIndependentWitness(_a0 interface return &mockWitnessCodeSender_SendToIndependentWitness_Call{Call: _e.mock.On("SendToIndependentWitness", _a0, _a1, _a2)} } -func (_c *mockWitnessCodeSender_SendToIndependentWitness_Call) Run(run func(_a0 context.Context, _a1 *donordata.DonorProvidedDetails, _a2 page.Localizer)) *mockWitnessCodeSender_SendToIndependentWitness_Call { +func (_c *mockWitnessCodeSender_SendToIndependentWitness_Call) Run(run func(_a0 context.Context, _a1 *donordata.Provided, _a2 page.Localizer)) *mockWitnessCodeSender_SendToIndependentWitness_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*donordata.DonorProvidedDetails), args[2].(page.Localizer)) + run(args[0].(context.Context), args[1].(*donordata.Provided), args[2].(page.Localizer)) }) return _c } @@ -115,7 +115,7 @@ func (_c *mockWitnessCodeSender_SendToIndependentWitness_Call) Return(_a0 error) return _c } -func (_c *mockWitnessCodeSender_SendToIndependentWitness_Call) RunAndReturn(run func(context.Context, *donordata.DonorProvidedDetails, page.Localizer) error) *mockWitnessCodeSender_SendToIndependentWitness_Call { +func (_c *mockWitnessCodeSender_SendToIndependentWitness_Call) RunAndReturn(run func(context.Context, *donordata.Provided, page.Localizer) error) *mockWitnessCodeSender_SendToIndependentWitness_Call { _c.Call.Return(run) return _c } diff --git a/internal/donor/donorpage/one_login_identity_details.go b/internal/donor/donorpage/one_login_identity_details.go index 5bb3400611..f51f8cfc98 100644 --- a/internal/donor/donorpage/one_login_identity_details.go +++ b/internal/donor/donorpage/one_login_identity_details.go @@ -14,14 +14,14 @@ import ( type oneLoginIdentityDetailsData struct { App page.AppData Errors validation.List - DonorProvided *donordata.DonorProvidedDetails + DonorProvided *donordata.Provided DetailsMatch bool DetailsUpdated bool Form *form.YesNoForm } func OneLoginIdentityDetails(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &oneLoginIdentityDetailsData{ App: appData, Form: form.NewYesNoForm(form.YesNoUnknown), diff --git a/internal/donor/donorpage/one_login_identity_details_test.go b/internal/donor/donorpage/one_login_identity_details_test.go index 14c396fa34..c3432e9e16 100644 --- a/internal/donor/donorpage/one_login_identity_details_test.go +++ b/internal/donor/donorpage/one_login_identity_details_test.go @@ -22,13 +22,13 @@ func TestGetOneLoginIdentityDetails(t *testing.T) { dob := date.New("1", "2", "3") testcases := map[string]struct { - donorProvided *donordata.DonorProvidedDetails + donorProvided *donordata.Provided expectedDetailsMatch bool expectedDetailsUpdated bool url string }{ "details match": { - donorProvided: &donordata.DonorProvidedDetails{ + donorProvided: &donordata.Provided{ Donor: donordata.Donor{FirstNames: "a", LastName: "b", DateOfBirth: dob, Address: testAddress}, DonorIdentityUserData: identity.UserData{FirstNames: "a", LastName: "b", DateOfBirth: dob, CurrentAddress: testAddress}, }, @@ -36,14 +36,14 @@ func TestGetOneLoginIdentityDetails(t *testing.T) { url: "/", }, "details do not match": { - donorProvided: &donordata.DonorProvidedDetails{ + donorProvided: &donordata.Provided{ Donor: donordata.Donor{FirstNames: "a"}, DonorIdentityUserData: identity.UserData{FirstNames: "b"}, }, url: "/", }, "details updated": { - donorProvided: &donordata.DonorProvidedDetails{ + donorProvided: &donordata.Provided{ Donor: donordata.Donor{FirstNames: "a"}, DonorIdentityUserData: identity.UserData{FirstNames: "b"}, }, @@ -87,7 +87,7 @@ func TestPostOneLoginIdentityDetailsWhenYes(t *testing.T) { existingDob := date.New("1", "2", "3") identityDob := date.New("4", "5", "6") - updated := &donordata.DonorProvidedDetails{ + updated := &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "b", LastName: "b", DateOfBirth: identityDob, Address: place.Address{Line1: "a"}}, DonorIdentityUserData: identity.UserData{FirstNames: "b", LastName: "b", DateOfBirth: identityDob, CurrentAddress: place.Address{Line1: "a"}}, @@ -99,7 +99,7 @@ func TestPostOneLoginIdentityDetailsWhenYes(t *testing.T) { Put(r.Context(), updated). Return(nil) - err := OneLoginIdentityDetails(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := OneLoginIdentityDetails(nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "a", LastName: "a", DateOfBirth: existingDob, Address: testAddress}, DonorIdentityUserData: identity.UserData{FirstNames: "b", LastName: "b", DateOfBirth: identityDob, CurrentAddress: place.Address{Line1: "a"}}, @@ -118,7 +118,7 @@ func TestPostOneLoginIdentityDetailsWhenNo(t *testing.T) { r := httptest.NewRequest(http.MethodPost, "/", strings.NewReader(f.Encode())) r.Header.Set("Content-Type", "application/x-www-form-urlencoded") - err := OneLoginIdentityDetails(nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) + err := OneLoginIdentityDetails(nil, nil)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id"}) resp := w.Result() assert.Nil(t, err) @@ -131,7 +131,7 @@ func TestPostOneLoginIdentityDetailsWhenIdentityAndLPADetailsAlreadyMatch(t *tes r := httptest.NewRequest(http.MethodPost, "/", nil) r.Header.Set("Content-Type", "application/x-www-form-urlencoded") - err := OneLoginIdentityDetails(nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}}) + err := OneLoginIdentityDetails(nil, nil)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}}) resp := w.Result() assert.Nil(t, err) @@ -151,7 +151,7 @@ func TestPostOneLoginIdentityDetailsWhenDonorStoreError(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := OneLoginIdentityDetails(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := OneLoginIdentityDetails(nil, donorStore)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -174,7 +174,7 @@ func TestPostOneLoginIdentityDetailsWhenValidationError(t *testing.T) { })). Return(nil) - err := OneLoginIdentityDetails(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{Donor: donordata.Donor{FirstNames: "a"}}) + err := OneLoginIdentityDetails(template.Execute, nil)(testAppData, w, r, &donordata.Provided{Donor: donordata.Donor{FirstNames: "a"}}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/pay.go b/internal/donor/donorpage/pay.go index cfca3b4311..55d533b591 100644 --- a/internal/donor/donorpage/pay.go +++ b/internal/donor/donorpage/pay.go @@ -20,7 +20,7 @@ func Pay( randomString func(int) string, appPublicURL string, ) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { if donor.FeeType.IsNoFee() || donor.FeeType.IsHardshipFee() || donor.Tasks.PayForLpa.IsMoreEvidenceRequired() { donor.Tasks.PayForLpa = task.PaymentStatePending if err := donorStore.Put(r.Context(), donor); err != nil { diff --git a/internal/donor/donorpage/pay_test.go b/internal/donor/donorpage/pay_test.go index d821a9d0cc..b1c81ac1a1 100644 --- a/internal/donor/donorpage/pay_test.go +++ b/internal/donor/donorpage/pay_test.go @@ -70,7 +70,7 @@ func TestPay(t *testing.T) { InfoContext(r.Context(), "skipping payment", slog.String("next_url", tc.nextURL)) } - err := Pay(logger, sessionStore, nil, payClient, func(int) string { return "123456789012" }, "http://example.org")(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", Donor: donordata.Donor{Email: "a@b.com"}, FeeType: pay.FullFee}) + err := Pay(logger, sessionStore, nil, payClient, func(int) string { return "123456789012" }, "http://example.org")(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", LpaUID: "lpa-uid", Donor: donordata.Donor{Email: "a@b.com"}, FeeType: pay.FullFee}) resp := w.Result() assert.Nil(t, err) @@ -93,15 +93,15 @@ func TestPayWhenPaymentNotRequired(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", FeeType: feeType, - Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}, + Tasks: donordata.Tasks{PayForLpa: task.PaymentStatePending}, EvidenceDelivery: pay.Upload, }). Return(nil) - err := Pay(nil, nil, donorStore, nil, nil, "")(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := Pay(nil, nil, donorStore, nil, nil, "")(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", FeeType: feeType, EvidenceDelivery: pay.Upload, @@ -128,15 +128,15 @@ func TestPayWhenPostingEvidence(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", FeeType: feeType, - Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}, + Tasks: donordata.Tasks{PayForLpa: task.PaymentStatePending}, EvidenceDelivery: pay.Post, }). Return(nil) - err := Pay(nil, nil, donorStore, nil, nil, "")(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := Pay(nil, nil, donorStore, nil, nil, "")(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", FeeType: feeType, EvidenceDelivery: pay.Post, @@ -156,18 +156,18 @@ func TestPayWhenMoreEvidenceProvided(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", FeeType: pay.HalfFee, - Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}, + Tasks: donordata.Tasks{PayForLpa: task.PaymentStatePending}, EvidenceDelivery: pay.Upload, }). Return(nil) - err := Pay(nil, nil, donorStore, nil, nil, "")(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := Pay(nil, nil, donorStore, nil, nil, "")(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", FeeType: pay.HalfFee, - Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateMoreEvidenceRequired}, + Tasks: donordata.Tasks{PayForLpa: task.PaymentStateMoreEvidenceRequired}, EvidenceDelivery: pay.Upload, }) resp := w.Result() @@ -183,14 +183,14 @@ func TestPayWhenPaymentNotRequiredWhenDonorStorePutError(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", FeeType: pay.NoFee, - Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}, + Tasks: donordata.Tasks{PayForLpa: task.PaymentStatePending}, }). Return(expectedError) - err := Pay(nil, nil, donorStore, nil, nil, "")(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := Pay(nil, nil, donorStore, nil, nil, "")(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", FeeType: pay.NoFee, }) @@ -235,12 +235,12 @@ func TestPayWhenFeeDenied(t *testing.T) { logger.EXPECT(). InfoContext(r.Context(), mock.Anything, mock.Anything) - err := Pay(logger, sessionStore, nil, payClient, func(int) string { return "123456789012" }, "http://example.org")(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := Pay(logger, sessionStore, nil, payClient, func(int) string { return "123456789012" }, "http://example.org")(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", LpaUID: "lpa-uid", Donor: donordata.Donor{Email: "a@b.com"}, FeeType: pay.HalfFee, - Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateDenied}, + Tasks: donordata.Tasks{PayForLpa: task.PaymentStateDenied}, PaymentDetails: []donordata.Payment{{Amount: 4100}}, }) resp := w.Result() @@ -259,7 +259,7 @@ func TestPayWhenCreatePaymentErrors(t *testing.T) { CreatePayment(mock.Anything, mock.Anything, mock.Anything). Return(nil, expectedError) - err := Pay(nil, nil, nil, payClient, func(int) string { return "123456789012" }, "")(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := Pay(nil, nil, nil, payClient, func(int) string { return "123456789012" }, "")(testAppData, w, r, &donordata.Provided{}) assert.ErrorIs(t, err, expectedError) } @@ -285,7 +285,7 @@ func TestPayWhenSessionErrors(t *testing.T) { }, }, nil) - err := Pay(nil, sessionStore, nil, payClient, func(int) string { return "123456789012" }, "")(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := Pay(nil, sessionStore, nil, payClient, func(int) string { return "123456789012" }, "")(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } diff --git a/internal/donor/donorpage/payment_confirmation.go b/internal/donor/donorpage/payment_confirmation.go index c247af9ea2..9fb63f9c2c 100644 --- a/internal/donor/donorpage/payment_confirmation.go +++ b/internal/donor/donorpage/payment_confirmation.go @@ -28,7 +28,7 @@ type paymentConfirmationData struct { } func PaymentConfirmation(logger Logger, tmpl template.Template, payClient PayClient, donorStore DonorStore, sessionStore SessionStore, shareCodeSender ShareCodeSender, lpaStoreClient LpaStoreClient, eventClient EventClient, notifyClient NotifyClient) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { paymentSession, err := sessionStore.Payment(r) if err != nil { return err diff --git a/internal/donor/donorpage/payment_confirmation_test.go b/internal/donor/donorpage/payment_confirmation_test.go index 72c366df08..e997385a74 100644 --- a/internal/donor/donorpage/payment_confirmation_test.go +++ b/internal/donor/donorpage/payment_confirmation_test.go @@ -8,7 +8,6 @@ import ( "testing" "time" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/date" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/event" @@ -68,7 +67,7 @@ func TestGetPaymentConfirmationFullFee(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ Type: donordata.LpaTypePersonalWelfare, Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, LpaUID: "lpa-uid", @@ -82,7 +81,7 @@ func TestGetPaymentConfirmationFullFee(t *testing.T) { PaymentReference: "123456789012", Amount: 8200, }}, - Tasks: donordata.DonorTasks{ + Tasks: donordata.Tasks{ PayForLpa: task.PaymentStateCompleted, }, }). @@ -100,14 +99,14 @@ func TestGetPaymentConfirmationFullFee(t *testing.T) { notifyClient := newMockNotifyClient(t). withEmailPersonalizations(r.Context(), "£82") - err := PaymentConfirmation(newMockLogger(t), template.Execute, payClient, donorStore, sessionStore, nil, nil, eventClient, notifyClient)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := PaymentConfirmation(newMockLogger(t), template.Execute, payClient, donorStore, sessionStore, nil, nil, eventClient, notifyClient)(testAppData, w, r, &donordata.Provided{ LpaUID: "lpa-uid", FeeType: pay.FullFee, EvidenceDelivery: tc.evidenceDelivery, CertificateProvider: donordata.CertificateProvider{ Email: "certificateprovider@example.com", }, - Tasks: donordata.DonorTasks{ + Tasks: donordata.Tasks{ PayForLpa: task.PaymentStateInProgress, }, Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, @@ -149,7 +148,7 @@ func TestGetPaymentConfirmationHalfFee(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ Type: donordata.LpaTypePersonalWelfare, Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, LpaUID: "lpa-uid", @@ -162,7 +161,7 @@ func TestGetPaymentConfirmationHalfFee(t *testing.T) { PaymentReference: "123456789012", Amount: 4100, }}, - Tasks: donordata.DonorTasks{ + Tasks: donordata.Tasks{ PayForLpa: task.PaymentStatePending, }, }). @@ -180,7 +179,7 @@ func TestGetPaymentConfirmationHalfFee(t *testing.T) { notifyClient := newMockNotifyClient(t). withEmailPersonalizations(r.Context(), "£41") - err := PaymentConfirmation(newMockLogger(t), template.Execute, payClient, donorStore, sessionStore, nil, nil, eventClient, notifyClient)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := PaymentConfirmation(newMockLogger(t), template.Execute, payClient, donorStore, sessionStore, nil, nil, eventClient, notifyClient)(testAppData, w, r, &donordata.Provided{ Type: donordata.LpaTypePersonalWelfare, Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, LpaUID: "lpa-uid", @@ -188,7 +187,7 @@ func TestGetPaymentConfirmationHalfFee(t *testing.T) { CertificateProvider: donordata.CertificateProvider{ Email: "certificateprovider@example.com", }, - Tasks: donordata.DonorTasks{ + Tasks: donordata.Tasks{ PayForLpa: task.PaymentStateInProgress, }, }) @@ -228,7 +227,7 @@ func TestGetPaymentConfirmationApprovedOrDenied(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ Type: donordata.LpaTypePersonalWelfare, Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, LpaUID: "lpa-uid", @@ -241,7 +240,7 @@ func TestGetPaymentConfirmationApprovedOrDenied(t *testing.T) { PaymentReference: "123456789012", Amount: 8200, }}, - Tasks: donordata.DonorTasks{ + Tasks: donordata.Tasks{ PayForLpa: task.PaymentStateCompleted, }, }). @@ -259,7 +258,7 @@ func TestGetPaymentConfirmationApprovedOrDenied(t *testing.T) { notifyClient := newMockNotifyClient(t). withEmailPersonalizations(r.Context(), "£82") - err := PaymentConfirmation(newMockLogger(t), template.Execute, payClient, donorStore, sessionStore, nil, nil, eventClient, notifyClient)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := PaymentConfirmation(newMockLogger(t), template.Execute, payClient, donorStore, sessionStore, nil, nil, eventClient, notifyClient)(testAppData, w, r, &donordata.Provided{ Type: donordata.LpaTypePersonalWelfare, Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, LpaUID: "lpa-uid", @@ -267,7 +266,7 @@ func TestGetPaymentConfirmationApprovedOrDenied(t *testing.T) { CertificateProvider: donordata.CertificateProvider{ Email: "certificateprovider@example.com", }, - Tasks: donordata.DonorTasks{ + Tasks: donordata.Tasks{ PayForLpa: taskState, }, }) @@ -285,7 +284,7 @@ func TestGetPaymentConfirmationApprovedOrDeniedWhenSigned(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/payment-confirmation", nil) - updatedDonor := &donordata.DonorProvidedDetails{ + updatedDonor := &donordata.Provided{ Type: donordata.LpaTypePersonalWelfare, Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, LpaUID: "lpa-uid", @@ -298,9 +297,9 @@ func TestGetPaymentConfirmationApprovedOrDeniedWhenSigned(t *testing.T) { PaymentReference: "123456789012", Amount: 8200, }}, - Tasks: donordata.DonorTasks{ + Tasks: donordata.Tasks{ PayForLpa: task.PaymentStateCompleted, - ConfirmYourIdentityAndSign: actor.IdentityTaskCompleted, + ConfirmYourIdentityAndSign: task.IdentityStateCompleted, }, } @@ -353,7 +352,7 @@ func TestGetPaymentConfirmationApprovedOrDeniedWhenSigned(t *testing.T) { notifyClient := newMockNotifyClient(t). withEmailPersonalizations(r.Context(), "£82") - err := PaymentConfirmation(newMockLogger(t), template.Execute, payClient, donorStore, sessionStore, shareCodeSender, lpaStoreClient, eventClient, notifyClient)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := PaymentConfirmation(newMockLogger(t), template.Execute, payClient, donorStore, sessionStore, shareCodeSender, lpaStoreClient, eventClient, notifyClient)(testAppData, w, r, &donordata.Provided{ Type: donordata.LpaTypePersonalWelfare, Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, LpaUID: "lpa-uid", @@ -361,9 +360,9 @@ func TestGetPaymentConfirmationApprovedOrDeniedWhenSigned(t *testing.T) { CertificateProvider: donordata.CertificateProvider{ Email: "certificateprovider@example.com", }, - Tasks: donordata.DonorTasks{ + Tasks: donordata.Tasks{ PayForLpa: taskState, - ConfirmYourIdentityAndSign: actor.IdentityTaskCompleted, + ConfirmYourIdentityAndSign: task.IdentityStateCompleted, }, }) resp := w.Result() @@ -415,7 +414,7 @@ func TestGetPaymentConfirmationApprovedOrDeniedWhenVoucherAllowed(t *testing.T) notifyClient := newMockNotifyClient(t). withEmailPersonalizations(r.Context(), "£82") - err := PaymentConfirmation(newMockLogger(t), template.Execute, payClient, donorStore, sessionStore, nil, nil, eventClient, notifyClient)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := PaymentConfirmation(newMockLogger(t), template.Execute, payClient, donorStore, sessionStore, nil, nil, eventClient, notifyClient)(testAppData, w, r, &donordata.Provided{ Type: donordata.LpaTypePersonalWelfare, Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, LpaUID: "lpa-uid", @@ -424,7 +423,7 @@ func TestGetPaymentConfirmationApprovedOrDeniedWhenVoucherAllowed(t *testing.T) Email: "certificateprovider@example.com", }, Voucher: donordata.Voucher{Allowed: true}, - Tasks: donordata.DonorTasks{ + Tasks: donordata.Tasks{ PayForLpa: task, }, }) @@ -453,12 +452,12 @@ func TestGetPaymentConfirmationWhenNotSuccess(t *testing.T) { }, }, nil) - err := PaymentConfirmation(newMockLogger(t), nil, payClient, nil, sessionStore, nil, nil, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := PaymentConfirmation(newMockLogger(t), nil, payClient, nil, sessionStore, nil, nil, nil, nil)(testAppData, w, r, &donordata.Provided{ LpaUID: "lpa-uid", CertificateProvider: donordata.CertificateProvider{ Email: "certificateprovider@example.com", }, - Tasks: donordata.DonorTasks{ + Tasks: donordata.Tasks{ PayForLpa: task.PaymentStateInProgress, }, }) @@ -477,7 +476,7 @@ func TestGetPaymentConfirmationWhenErrorGettingSession(t *testing.T) { Payment(r). Return(nil, expectedError) - err := PaymentConfirmation(nil, template.Execute, newMockPayClient(t), nil, sessionStore, nil, nil, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := PaymentConfirmation(nil, template.Execute, newMockPayClient(t), nil, sessionStore, nil, nil, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -498,7 +497,7 @@ func TestGetPaymentConfirmationWhenErrorGettingPayment(t *testing.T) { template := newMockTemplate(t) - err := PaymentConfirmation(nil, template.Execute, payClient, nil, sessionStore, nil, nil, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := PaymentConfirmation(nil, template.Execute, payClient, nil, sessionStore, nil, nil, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.ErrorIs(t, err, expectedError) @@ -545,7 +544,7 @@ func TestGetPaymentConfirmationWhenErrorExpiringSession(t *testing.T) { notifyClient := newMockNotifyClient(t). withEmailPersonalizations(r.Context(), "£82") - err := PaymentConfirmation(logger, template.Execute, payClient, donorStore, sessionStore, nil, nil, eventClient, notifyClient)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := PaymentConfirmation(logger, template.Execute, payClient, donorStore, sessionStore, nil, nil, eventClient, notifyClient)(testAppData, w, r, &donordata.Provided{ CertificateProvider: donordata.CertificateProvider{ Email: "certificateprovider@example.com", }, @@ -573,7 +572,7 @@ func TestGetPaymentConfirmationWhenEventClientError(t *testing.T) { SendPaymentReceived(r.Context(), mock.Anything). Return(expectedError) - err := PaymentConfirmation(nil, nil, payClient, nil, sessionStore, nil, nil, eventClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := PaymentConfirmation(nil, nil, payClient, nil, sessionStore, nil, nil, eventClient, nil)(testAppData, w, r, &donordata.Provided{ FeeType: pay.HalfFee, CertificateProvider: donordata.CertificateProvider{ Email: "certificateprovider@example.com", @@ -610,7 +609,7 @@ func TestGetPaymentConfirmationWhenNotifyClientError(t *testing.T) { testAppData.Localizer = localizer - err := PaymentConfirmation(nil, nil, payClient, nil, sessionStore, nil, nil, eventClient, notifyClient)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := PaymentConfirmation(nil, nil, payClient, nil, sessionStore, nil, nil, eventClient, notifyClient)(testAppData, w, r, &donordata.Provided{ Type: donordata.LpaTypePersonalWelfare, Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, FeeType: pay.HalfFee, @@ -652,7 +651,7 @@ func TestGetPaymentConfirmationHalfFeeWhenDonorStorePutError(t *testing.T) { notifyClient := newMockNotifyClient(t). withEmailPersonalizations(r.Context(), "£41") - err := PaymentConfirmation(nil, nil, payClient, donorStore, sessionStore, nil, nil, eventClient, notifyClient)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := PaymentConfirmation(nil, nil, payClient, donorStore, sessionStore, nil, nil, eventClient, notifyClient)(testAppData, w, r, &donordata.Provided{ LpaUID: "lpa-uid", Type: donordata.LpaTypePersonalWelfare, Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, @@ -700,7 +699,7 @@ func TestGetPaymentConfirmationWhenLpaStoreClientErrors(t *testing.T) { notifyClient := newMockNotifyClient(t). withEmailPersonalizations(r.Context(), "£82") - err := PaymentConfirmation(newMockLogger(t), nil, payClient, nil, sessionStore, shareCodeSender, lpaStoreClient, eventClient, notifyClient)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := PaymentConfirmation(newMockLogger(t), nil, payClient, nil, sessionStore, shareCodeSender, lpaStoreClient, eventClient, notifyClient)(testAppData, w, r, &donordata.Provided{ LpaUID: "lpa-uid", Type: donordata.LpaTypePersonalWelfare, Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, @@ -708,9 +707,9 @@ func TestGetPaymentConfirmationWhenLpaStoreClientErrors(t *testing.T) { CertificateProvider: donordata.CertificateProvider{ Email: "certificateprovider@example.com", }, - Tasks: donordata.DonorTasks{ + Tasks: donordata.Tasks{ PayForLpa: task.PaymentStateApproved, - ConfirmYourIdentityAndSign: actor.IdentityTaskCompleted, + ConfirmYourIdentityAndSign: task.IdentityStateCompleted, }, }) @@ -745,7 +744,7 @@ func TestGetPaymentConfirmationWhenShareCodeSenderErrors(t *testing.T) { notifyClient := newMockNotifyClient(t). withEmailPersonalizations(r.Context(), "£82") - err := PaymentConfirmation(newMockLogger(t), nil, payClient, nil, sessionStore, shareCodeSender, nil, eventClient, notifyClient)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := PaymentConfirmation(newMockLogger(t), nil, payClient, nil, sessionStore, shareCodeSender, nil, eventClient, notifyClient)(testAppData, w, r, &donordata.Provided{ LpaUID: "lpa-uid", Type: donordata.LpaTypePersonalWelfare, Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, @@ -753,9 +752,9 @@ func TestGetPaymentConfirmationWhenShareCodeSenderErrors(t *testing.T) { CertificateProvider: donordata.CertificateProvider{ Email: "certificateprovider@example.com", }, - Tasks: donordata.DonorTasks{ + Tasks: donordata.Tasks{ PayForLpa: task.PaymentStateApproved, - ConfirmYourIdentityAndSign: actor.IdentityTaskCompleted, + ConfirmYourIdentityAndSign: task.IdentityStateCompleted, }, }) diff --git a/internal/donor/donorpage/previous_application_number.go b/internal/donor/donorpage/previous_application_number.go index 19a458eef9..4df2428d35 100644 --- a/internal/donor/donorpage/previous_application_number.go +++ b/internal/donor/donorpage/previous_application_number.go @@ -17,7 +17,7 @@ type previousApplicationNumberData struct { } func PreviousApplicationNumber(tmpl template.Template, donorStore DonorStore, eventClient EventClient) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &previousApplicationNumberData{ App: appData, Form: &previousApplicationNumberForm{ diff --git a/internal/donor/donorpage/previous_application_number_test.go b/internal/donor/donorpage/previous_application_number_test.go index 73d8ef0324..4356277b95 100644 --- a/internal/donor/donorpage/previous_application_number_test.go +++ b/internal/donor/donorpage/previous_application_number_test.go @@ -27,7 +27,7 @@ func TestGetPreviousApplicationNumber(t *testing.T) { }). Return(nil) - err := PreviousApplicationNumber(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := PreviousApplicationNumber(template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -48,7 +48,7 @@ func TestGetPreviousApplicationNumberFromStore(t *testing.T) { }). Return(nil) - err := PreviousApplicationNumber(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{PreviousApplicationNumber: "ABC"}) + err := PreviousApplicationNumber(template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{PreviousApplicationNumber: "ABC"}) resp := w.Result() assert.Nil(t, err) @@ -64,7 +64,7 @@ func TestGetPreviousApplicationNumberWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := PreviousApplicationNumber(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := PreviousApplicationNumber(template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -89,7 +89,7 @@ func TestPostPreviousApplicationNumber(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", LpaUID: "lpa-uid", PreviousApplicationNumber: start, @@ -104,7 +104,7 @@ func TestPostPreviousApplicationNumber(t *testing.T) { }). Return(nil) - err := PreviousApplicationNumber(nil, donorStore, eventClient)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := PreviousApplicationNumber(nil, donorStore, eventClient)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", LpaUID: "lpa-uid", }) @@ -136,7 +136,7 @@ func TestPostPreviousApplicationNumberWhenEventErrors(t *testing.T) { SendPreviousApplicationLinked(r.Context(), mock.Anything). Return(expectedError) - err := PreviousApplicationNumber(nil, donorStore, eventClient)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := PreviousApplicationNumber(nil, donorStore, eventClient)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", LpaUID: "lpa-uid", }) @@ -158,7 +158,7 @@ func TestPostPreviousApplicationNumberWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := PreviousApplicationNumber(nil, donorStore, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := PreviousApplicationNumber(nil, donorStore, nil)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -174,7 +174,7 @@ func TestPostPreviousApplicationNumberWhenValidationErrors(t *testing.T) { })). Return(nil) - err := PreviousApplicationNumber(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := PreviousApplicationNumber(template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/previous_fee.go b/internal/donor/donorpage/previous_fee.go index f245584630..62df36c303 100644 --- a/internal/donor/donorpage/previous_fee.go +++ b/internal/donor/donorpage/previous_fee.go @@ -18,7 +18,7 @@ type previousFeeData struct { } func PreviousFee(tmpl template.Template, payer Handler, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &previousFeeData{ App: appData, Form: &previousFeeForm{ diff --git a/internal/donor/donorpage/previous_fee_test.go b/internal/donor/donorpage/previous_fee_test.go index 9b2a478143..cfc6497cb1 100644 --- a/internal/donor/donorpage/previous_fee_test.go +++ b/internal/donor/donorpage/previous_fee_test.go @@ -28,7 +28,7 @@ func TestGetPreviousFee(t *testing.T) { }). Return(nil) - err := PreviousFee(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := PreviousFee(template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -50,7 +50,7 @@ func TestGetPreviousFeeFromStore(t *testing.T) { }). Return(nil) - err := PreviousFee(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{PreviousFee: pay.PreviousFeeHalf}) + err := PreviousFee(template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{PreviousFee: pay.PreviousFeeHalf}) resp := w.Result() assert.Nil(t, err) @@ -66,7 +66,7 @@ func TestGetPreviousFeeWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := PreviousFee(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := PreviousFee(template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -82,7 +82,7 @@ func TestPostPreviousFeeWhenFullFee(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ LpaID: "lpa-id", PreviousFee: pay.PreviousFeeFull, } @@ -97,7 +97,7 @@ func TestPostPreviousFeeWhenFullFee(t *testing.T) { Execute(testAppData, w, r, donor). Return(nil) - err := PreviousFee(nil, payer.Execute, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) + err := PreviousFee(nil, payer.Execute, donorStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id"}) assert.Nil(t, err) } @@ -112,13 +112,13 @@ func TestPostPreviousFeeWhenOtherFee(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", PreviousFee: pay.PreviousFeeHalf, }). Return(nil) - err := PreviousFee(nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) + err := PreviousFee(nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id"}) resp := w.Result() assert.Nil(t, err) @@ -135,7 +135,7 @@ func TestPostPreviousFeeWhenNotChanged(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - err := PreviousFee(nil, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := PreviousFee(nil, nil, nil)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", PreviousFee: pay.PreviousFeeHalf, }) @@ -160,7 +160,7 @@ func TestPostPreviousFeeWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := PreviousFee(nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := PreviousFee(nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -177,7 +177,7 @@ func TestPostPreviousFeeWhenValidationErrors(t *testing.T) { })). Return(nil) - err := PreviousFee(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := PreviousFee(template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/register.go b/internal/donor/donorpage/register.go index a2b93d7a08..15b42411b4 100644 --- a/internal/donor/donorpage/register.go +++ b/internal/donor/donorpage/register.go @@ -22,6 +22,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/place" "github.com/ministryofjustice/opg-modernising-lpa/internal/random" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" "github.com/ministryofjustice/opg-modernising-lpa/internal/uid" ) @@ -29,7 +30,7 @@ type LpaStoreResolvingService interface { Get(ctx context.Context) (*lpastore.Lpa, error) } -type Handler func(data page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error +type Handler func(data page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error type Template func(io.Writer, interface{}) error @@ -40,15 +41,15 @@ type Logger interface { } type DonorStore interface { - Get(ctx context.Context) (*donordata.DonorProvidedDetails, error) - Latest(ctx context.Context) (*donordata.DonorProvidedDetails, error) - Put(ctx context.Context, donor *donordata.DonorProvidedDetails) error + Get(ctx context.Context) (*donordata.Provided, error) + Latest(ctx context.Context) (*donordata.Provided, error) + Put(ctx context.Context, donor *donordata.Provided) error Delete(ctx context.Context) error - Link(ctx context.Context, data actor.ShareCodeData, donorEmail string) error + Link(ctx context.Context, data sharecode.Data, donorEmail string) error } type GetDonorStore interface { - Get(context.Context) (*donordata.DonorProvidedDetails, error) + Get(context.Context) (*donordata.Provided, error) } type CertificateProviderStore interface { @@ -76,7 +77,7 @@ type AddressClient interface { type ShareCodeSender interface { SendCertificateProviderInvite(context.Context, page.AppData, page.CertificateProviderInvite) error - SendCertificateProviderPrompt(context.Context, page.AppData, *donordata.DonorProvidedDetails) error + SendCertificateProviderPrompt(context.Context, page.AppData, *donordata.Provided) error } type OneLoginClient interface { @@ -102,8 +103,8 @@ type SessionStore interface { } type WitnessCodeSender interface { - SendToCertificateProvider(context.Context, *donordata.DonorProvidedDetails, page.Localizer) error - SendToIndependentWitness(context.Context, *donordata.DonorProvidedDetails, page.Localizer) error + SendToCertificateProvider(context.Context, *donordata.Provided, page.Localizer) error + SendToIndependentWitness(context.Context, *donordata.Provided, page.Localizer) error } type UidClient interface { @@ -123,8 +124,8 @@ type DocumentStore interface { Put(context.Context, page.Document) error Delete(context.Context, page.Document) error DeleteInfectedDocuments(context.Context, page.Documents) error - Create(context.Context, *donordata.DonorProvidedDetails, string, []byte) (page.Document, error) - Submit(context.Context, *donordata.DonorProvidedDetails, page.Documents) error + Create(context.Context, *donordata.Provided, string, []byte) (page.Document, error) + Submit(context.Context, *donordata.Provided, page.Documents) error } type EventClient interface { @@ -141,12 +142,12 @@ type DashboardStore interface { type LpaStoreClient interface { Lpa(ctx context.Context, lpaUID string) (*lpastore.Lpa, error) - SendDonorConfirmIdentity(ctx context.Context, donor *donordata.DonorProvidedDetails) error - SendLpa(ctx context.Context, details *donordata.DonorProvidedDetails) error + SendDonorConfirmIdentity(ctx context.Context, donor *donordata.Provided) error + SendLpa(ctx context.Context, details *donordata.Provided) error } type ShareCodeStore interface { - Get(ctx context.Context, actorType actor.Type, code string) (actor.ShareCodeData, error) + Get(ctx context.Context, actorType actor.Type, code string) (sharecode.Data, error) } type ErrorHandler func(http.ResponseWriter, *http.Request, error) diff --git a/internal/donor/donorpage/register_test.go b/internal/donor/donorpage/register_test.go index 52a757a663..8af93a5ad5 100644 --- a/internal/donor/donorpage/register_test.go +++ b/internal/donor/donorpage/register_test.go @@ -18,6 +18,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/pay" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -168,7 +169,7 @@ func TestMakeLpaHandleWhenDetailsProvidedAndUIDExists(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(mock.Anything). - Return(&donordata.DonorProvidedDetails{Donor: donordata.Donor{ + Return(&donordata.Provided{Donor: donordata.Donor{ FirstNames: "Jane", LastName: "Smith", DateOfBirth: date.New("2000", "1", "2"), @@ -176,12 +177,12 @@ func TestMakeLpaHandleWhenDetailsProvidedAndUIDExists(t *testing.T) { Email: "a@example.com", }, Type: donordata.LpaTypePropertyAndAffairs, - Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted}, + Tasks: donordata.Tasks{YourDetails: task.StateCompleted}, LpaUID: "a-uid", }, nil) handle := makeLpaHandle(mux, sessionStore, nil, donorStore) - handle("/path", page.None, func(appData page.AppData, hw http.ResponseWriter, hr *http.Request, _ *donordata.DonorProvidedDetails) error { + handle("/path", page.None, func(appData page.AppData, hw http.ResponseWriter, hr *http.Request, _ *donordata.Provided) error { assert.Equal(t, tc.expectedAppData, appData) assert.Equal(t, w, hw) @@ -215,18 +216,18 @@ func TestMakeHandleLpaWhenDonorEmailNotSet(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(mock.Anything). - Return(&donordata.DonorProvidedDetails{Donor: donordata.Donor{ + Return(&donordata.Provided{Donor: donordata.Donor{ FirstNames: "Jane", LastName: "Smith", DateOfBirth: date.New("2000", "1", "2"), Address: place.Address{Postcode: "ABC123"}, }, Type: donordata.LpaTypePropertyAndAffairs, - Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted}, + Tasks: donordata.Tasks{YourDetails: task.StateCompleted}, LpaUID: "a-uid", }, nil) donorStore.EXPECT(). - Put(mock.Anything, &donordata.DonorProvidedDetails{Donor: donordata.Donor{ + Put(mock.Anything, &donordata.Provided{Donor: donordata.Donor{ FirstNames: "Jane", LastName: "Smith", DateOfBirth: date.New("2000", "1", "2"), @@ -234,13 +235,13 @@ func TestMakeHandleLpaWhenDonorEmailNotSet(t *testing.T) { Email: "a@example.com", }, Type: donordata.LpaTypePropertyAndAffairs, - Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted}, + Tasks: donordata.Tasks{YourDetails: task.StateCompleted}, LpaUID: "a-uid", }). Return(nil) handle := makeLpaHandle(mux, sessionStore, nil, donorStore) - handle("/path", page.None, func(appData page.AppData, hw http.ResponseWriter, hr *http.Request, _ *donordata.DonorProvidedDetails) error { + handle("/path", page.None, func(appData page.AppData, hw http.ResponseWriter, hr *http.Request, _ *donordata.Provided) error { hw.WriteHeader(http.StatusTeapot) return nil }) @@ -263,7 +264,7 @@ func TestMakeLpaHandleWhenSessionStoreError(t *testing.T) { Return(nil, expectedError) handle := makeLpaHandle(mux, sessionStore, nil, nil) - handle("/path", page.None, func(_ page.AppData, _ http.ResponseWriter, _ *http.Request, _ *donordata.DonorProvidedDetails) error { + handle("/path", page.None, func(_ page.AppData, _ http.ResponseWriter, _ *http.Request, _ *donordata.Provided) error { return expectedError }) @@ -280,14 +281,14 @@ func TestMakeLpaHandleWhenDonorStoreError(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(mock.Anything). - Return(&donordata.DonorProvidedDetails{}, expectedError) + Return(&donordata.Provided{}, expectedError) return donorStore }, "put": func() *mockDonorStore { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(mock.Anything). - Return(&donordata.DonorProvidedDetails{}, nil) + Return(&donordata.Provided{}, nil) donorStore.EXPECT(). Put(mock.Anything, mock.Anything). Return(expectedError) @@ -312,7 +313,7 @@ func TestMakeLpaHandleWhenDonorStoreError(t *testing.T) { Execute(w, r, expectedError) handle := makeLpaHandle(mux, sessionStore, errorHandler.Execute, donorStore()) - handle("/path", page.None, func(_ page.AppData, _ http.ResponseWriter, _ *http.Request, _ *donordata.DonorProvidedDetails) error { + handle("/path", page.None, func(_ page.AppData, _ http.ResponseWriter, _ *http.Request, _ *donordata.Provided) error { return expectedError }) @@ -340,10 +341,10 @@ func TestMakeLpaHandleWhenCannotGoToURL(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(mock.Anything). - Return(&donordata.DonorProvidedDetails{LpaID: "123", Donor: donordata.Donor{Email: "a@example.com"}}, nil) + Return(&donordata.Provided{LpaID: "123", Donor: donordata.Donor{Email: "a@example.com"}}, nil) handle := makeLpaHandle(mux, sessionStore, nil, donorStore) - handle(path, page.None, func(_ page.AppData, _ http.ResponseWriter, _ *http.Request, _ *donordata.DonorProvidedDetails) error { + handle(path, page.None, func(_ page.AppData, _ http.ResponseWriter, _ *http.Request, _ *donordata.Provided) error { return nil }) @@ -367,11 +368,11 @@ func TestMakeLpaHandleSessionExistingSessionData(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(mock.Anything). - Return(&donordata.DonorProvidedDetails{Donor: donordata.Donor{Email: "a@example.com"}}, nil) + Return(&donordata.Provided{Donor: donordata.Donor{Email: "a@example.com"}}, nil) mux := http.NewServeMux() handle := makeLpaHandle(mux, sessionStore, nil, donorStore) - handle("/path", page.RequireSession|page.CanGoBack, func(appData page.AppData, hw http.ResponseWriter, hr *http.Request, _ *donordata.DonorProvidedDetails) error { + handle("/path", page.RequireSession|page.CanGoBack, func(appData page.AppData, hw http.ResponseWriter, hr *http.Request, _ *donordata.Provided) error { assert.Equal(t, page.AppData{ Page: "/lpa/123/path", SessionID: "cmFuZG9t", @@ -410,11 +411,11 @@ func TestMakeLpaHandleErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(mock.Anything). - Return(&donordata.DonorProvidedDetails{Donor: donordata.Donor{Email: "a@example.com"}}, nil) + Return(&donordata.Provided{Donor: donordata.Donor{Email: "a@example.com"}}, nil) mux := http.NewServeMux() handle := makeLpaHandle(mux, sessionStore, errorHandler.Execute, donorStore) - handle("/path", page.RequireSession, func(_ page.AppData, _ http.ResponseWriter, _ *http.Request, _ *donordata.DonorProvidedDetails) error { + handle("/path", page.RequireSession, func(_ page.AppData, _ http.ResponseWriter, _ *http.Request, _ *donordata.Provided) error { return expectedError }) diff --git a/internal/donor/donorpage/register_with_court_of_protection.go b/internal/donor/donorpage/register_with_court_of_protection.go index 90fc36e142..fb54b8f05c 100644 --- a/internal/donor/donorpage/register_with_court_of_protection.go +++ b/internal/donor/donorpage/register_with_court_of_protection.go @@ -18,7 +18,7 @@ type registerWithCourtOfProtectionData struct { } func RegisterWithCourtOfProtection(tmpl template.Template, donorStore DonorStore, now func() time.Time) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := ®isterWithCourtOfProtectionData{ App: appData, Form: form.NewYesNoForm(form.YesNoUnknown), diff --git a/internal/donor/donorpage/register_with_court_of_protection_test.go b/internal/donor/donorpage/register_with_court_of_protection_test.go index 0742236aae..ba35cc1404 100644 --- a/internal/donor/donorpage/register_with_court_of_protection_test.go +++ b/internal/donor/donorpage/register_with_court_of_protection_test.go @@ -28,7 +28,7 @@ func TestGetRegisterWithCourtOfProtection(t *testing.T) { }). Return(nil) - err := RegisterWithCourtOfProtection(template.Execute, nil, testNowFn)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := RegisterWithCourtOfProtection(template.Execute, nil, testNowFn)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -44,7 +44,7 @@ func TestGetRegisterWithCourtOfProtectionWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := RegisterWithCourtOfProtection(template.Execute, nil, testNowFn)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := RegisterWithCourtOfProtection(template.Execute, nil, testNowFn)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -67,7 +67,7 @@ func TestPostRegisterWithCourtOfProtection(t *testing.T) { donorStore: func() *mockDonorStore { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(context.Background(), &donordata.DonorProvidedDetails{LpaID: "lpa-id", RegisteringWithCourtOfProtection: true}). + Put(context.Background(), &donordata.Provided{LpaID: "lpa-id", RegisteringWithCourtOfProtection: true}). Return(nil) return donorStore }, @@ -85,7 +85,7 @@ func TestPostRegisterWithCourtOfProtection(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - err := RegisterWithCourtOfProtection(nil, tc.donorStore(), testNowFn)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) + err := RegisterWithCourtOfProtection(nil, tc.donorStore(), testNowFn)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id"}) resp := w.Result() assert.Nil(t, err) @@ -109,7 +109,7 @@ func TestPostRegisterWithCourtOfProtectionWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := RegisterWithCourtOfProtection(nil, donorStore, testNowFn)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := RegisterWithCourtOfProtection(nil, donorStore, testNowFn)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -126,7 +126,7 @@ func TestPostRegisterWithCourtOfProtectionWhenValidationErrors(t *testing.T) { })). Return(nil) - err := RegisterWithCourtOfProtection(template.Execute, nil, testNowFn)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := RegisterWithCourtOfProtection(template.Execute, nil, testNowFn)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/remove_attorney.go b/internal/donor/donorpage/remove_attorney.go index 8a09bcb04f..850d4dff76 100644 --- a/internal/donor/donorpage/remove_attorney.go +++ b/internal/donor/donorpage/remove_attorney.go @@ -21,7 +21,7 @@ type removeAttorneyData struct { } func RemoveAttorney(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { attorney, found := donor.Attorneys.Get(actoruid.FromRequest(r)) if found == false { diff --git a/internal/donor/donorpage/remove_attorney_test.go b/internal/donor/donorpage/remove_attorney_test.go index 41e0de5f33..fe936e0e9c 100644 --- a/internal/donor/donorpage/remove_attorney_test.go +++ b/internal/donor/donorpage/remove_attorney_test.go @@ -7,12 +7,12 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -42,7 +42,7 @@ func TestGetRemoveAttorney(t *testing.T) { }). Return(nil) - err := RemoveAttorney(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney}}}) + err := RemoveAttorney(template.Execute, nil)(testAppData, w, r, &donordata.Provided{Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney}}}) resp := w.Result() @@ -63,7 +63,7 @@ func TestGetRemoveAttorneyAttorneyDoesNotExist(t *testing.T) { }, } - err := RemoveAttorney(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney}}}) + err := RemoveAttorney(template.Execute, nil)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney}}}) resp := w.Result() @@ -78,40 +78,40 @@ func TestPostRemoveAttorney(t *testing.T) { attorneyWithoutAddress := donordata.Attorney{UID: actoruid.New()} testcases := map[string]struct { - donor *donordata.DonorProvidedDetails - updatedDonor *donordata.DonorProvidedDetails + donor *donordata.Provided + updatedDonor *donordata.Provided redirect page.LpaPath }{ "many left": { - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithEmail, attorneyWithAddress, attorneyWithoutAddress}}, AttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, }, - updatedDonor: &donordata.DonorProvidedDetails{ + updatedDonor: &donordata.Provided{ LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithEmail, attorneyWithAddress}}, AttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, - Tasks: donordata.DonorTasks{ChooseAttorneys: actor.TaskInProgress}, + Tasks: donordata.Tasks{ChooseAttorneys: task.StateInProgress}, }, redirect: page.Paths.ChooseAttorneysSummary, }, "one left": { - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithAddress, attorneyWithoutAddress}}, AttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, }, - updatedDonor: &donordata.DonorProvidedDetails{ + updatedDonor: &donordata.Provided{ LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithAddress}}, - Tasks: donordata.DonorTasks{ChooseAttorneys: actor.TaskInProgress}, + Tasks: donordata.Tasks{ChooseAttorneys: task.StateInProgress}, }, redirect: page.Paths.ChooseAttorneysSummary, }, "none left": { - donor: &donordata.DonorProvidedDetails{LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithoutAddress}}}, - updatedDonor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithoutAddress}}}, + updatedDonor: &donordata.Provided{ LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{}}, }, @@ -165,7 +165,7 @@ func TestPostRemoveAttorneyWithFormValueNo(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/?id="+attorneyWithoutAddress.UID.String(), strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - err := RemoveAttorney(nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithoutAddress, attorneyWithAddress}}}) + err := RemoveAttorney(nil, nil)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithoutAddress, attorneyWithAddress}}}) resp := w.Result() assert.Nil(t, err) @@ -201,7 +201,7 @@ func TestPostRemoveAttorneyErrorOnPutStore(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := RemoveAttorney(template.Execute, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithoutAddress, attorneyWithAddress}}}) + err := RemoveAttorney(template.Execute, donorStore)(testAppData, w, r, &donordata.Provided{Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithoutAddress, attorneyWithAddress}}}) resp := w.Result() assert.ErrorIs(t, err, expectedError) @@ -227,7 +227,7 @@ func TestRemoveAttorneyFormValidation(t *testing.T) { })). Return(nil) - err := RemoveAttorney(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := RemoveAttorney(template.Execute, nil)(testAppData, w, r, &donordata.Provided{ Attorneys: donordata.Attorneys{ Attorneys: []donordata.Attorney{{ UID: uid, diff --git a/internal/donor/donorpage/remove_person_to_notify.go b/internal/donor/donorpage/remove_person_to_notify.go index e55eb6931a..4e3735e50f 100644 --- a/internal/donor/donorpage/remove_person_to_notify.go +++ b/internal/donor/donorpage/remove_person_to_notify.go @@ -5,11 +5,11 @@ import ( "net/http" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -21,7 +21,7 @@ type removePersonToNotifyData struct { } func RemovePersonToNotify(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { person, found := donor.PeopleToNotify.Get(actoruid.FromRequest(r)) if found == false { @@ -42,7 +42,7 @@ func RemovePersonToNotify(tmpl template.Template, donorStore DonorStore) Handler if data.Form.YesNo == form.Yes { donor.PeopleToNotify.Delete(person) if len(donor.PeopleToNotify) == 0 { - donor.Tasks.PeopleToNotify = actor.TaskNotStarted + donor.Tasks.PeopleToNotify = task.StateNotStarted } if err := donorStore.Put(r.Context(), donor); err != nil { diff --git a/internal/donor/donorpage/remove_person_to_notify_test.go b/internal/donor/donorpage/remove_person_to_notify_test.go index 64a4e9f431..4a30866e6d 100644 --- a/internal/donor/donorpage/remove_person_to_notify_test.go +++ b/internal/donor/donorpage/remove_person_to_notify_test.go @@ -7,12 +7,12 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -40,7 +40,7 @@ func TestGetRemovePersonToNotify(t *testing.T) { }). Return(nil) - err := RemovePersonToNotify(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{PeopleToNotify: donordata.PeopleToNotify{personToNotify}}) + err := RemovePersonToNotify(template.Execute, nil)(testAppData, w, r, &donordata.Provided{PeopleToNotify: donordata.PeopleToNotify{personToNotify}}) resp := w.Result() @@ -59,7 +59,7 @@ func TestGetRemovePersonToNotifyAttorneyDoesNotExist(t *testing.T) { }, } - err := RemovePersonToNotify(nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", PeopleToNotify: donordata.PeopleToNotify{personToNotify}}) + err := RemovePersonToNotify(nil, nil)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", PeopleToNotify: donordata.PeopleToNotify{personToNotify}}) resp := w.Result() assert.Nil(t, err) @@ -91,10 +91,10 @@ func TestPostRemovePersonToNotify(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{LpaID: "lpa-id", PeopleToNotify: donordata.PeopleToNotify{personToNotifyWithAddress}}). + Put(r.Context(), &donordata.Provided{LpaID: "lpa-id", PeopleToNotify: donordata.PeopleToNotify{personToNotifyWithAddress}}). Return(nil) - err := RemovePersonToNotify(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", PeopleToNotify: donordata.PeopleToNotify{personToNotifyWithoutAddress, personToNotifyWithAddress}}) + err := RemovePersonToNotify(nil, donorStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", PeopleToNotify: donordata.PeopleToNotify{personToNotifyWithoutAddress, personToNotifyWithAddress}}) resp := w.Result() assert.Nil(t, err) @@ -124,7 +124,7 @@ func TestPostRemovePersonToNotifyWithFormValueNo(t *testing.T) { Address: place.Address{}, } - err := RemovePersonToNotify(nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", PeopleToNotify: donordata.PeopleToNotify{personToNotifyWithoutAddress, personToNotifyWithAddress}}) + err := RemovePersonToNotify(nil, nil)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", PeopleToNotify: donordata.PeopleToNotify{personToNotifyWithoutAddress, personToNotifyWithAddress}}) resp := w.Result() assert.Nil(t, err) @@ -156,10 +156,10 @@ func TestPostRemovePersonToNotifyErrorOnPutStore(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{PeopleToNotify: donordata.PeopleToNotify{personToNotifyWithAddress}}). + Put(r.Context(), &donordata.Provided{PeopleToNotify: donordata.PeopleToNotify{personToNotifyWithAddress}}). Return(expectedError) - err := RemovePersonToNotify(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{PeopleToNotify: donordata.PeopleToNotify{personToNotifyWithoutAddress, personToNotifyWithAddress}}) + err := RemovePersonToNotify(nil, donorStore)(testAppData, w, r, &donordata.Provided{PeopleToNotify: donordata.PeopleToNotify{personToNotifyWithoutAddress, personToNotifyWithAddress}}) resp := w.Result() assert.ErrorIs(t, err, expectedError) @@ -190,7 +190,7 @@ func TestRemovePersonToNotifyFormValidation(t *testing.T) { })). Return(nil) - err := RemovePersonToNotify(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{PeopleToNotify: donordata.PeopleToNotify{personToNotifyWithoutAddress}}) + err := RemovePersonToNotify(template.Execute, nil)(testAppData, w, r, &donordata.Provided{PeopleToNotify: donordata.PeopleToNotify{personToNotifyWithoutAddress}}) resp := w.Result() assert.Nil(t, err) @@ -214,17 +214,17 @@ func TestRemovePersonToNotifyRemoveLastPerson(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", PeopleToNotify: donordata.PeopleToNotify{}, - Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, PeopleToNotify: actor.TaskNotStarted}, + Tasks: donordata.Tasks{YourDetails: task.StateCompleted, ChooseAttorneys: task.StateCompleted, PeopleToNotify: task.StateNotStarted}, }). Return(nil) - err := RemovePersonToNotify(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := RemovePersonToNotify(nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", PeopleToNotify: donordata.PeopleToNotify{personToNotifyWithoutAddress}, - Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, PeopleToNotify: actor.TaskCompleted}, + Tasks: donordata.Tasks{YourDetails: task.StateCompleted, ChooseAttorneys: task.StateCompleted, PeopleToNotify: task.StateCompleted}, }) resp := w.Result() diff --git a/internal/donor/donorpage/remove_replacement_attorney.go b/internal/donor/donorpage/remove_replacement_attorney.go index 77ab804615..b66c94e51f 100644 --- a/internal/donor/donorpage/remove_replacement_attorney.go +++ b/internal/donor/donorpage/remove_replacement_attorney.go @@ -12,7 +12,7 @@ import ( ) func RemoveReplacementAttorney(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { attorney, found := donor.ReplacementAttorneys.Get(actoruid.FromRequest(r)) if found == false { diff --git a/internal/donor/donorpage/remove_replacement_attorney_test.go b/internal/donor/donorpage/remove_replacement_attorney_test.go index 42ef8f6ec7..28dc0b13b2 100644 --- a/internal/donor/donorpage/remove_replacement_attorney_test.go +++ b/internal/donor/donorpage/remove_replacement_attorney_test.go @@ -7,12 +7,12 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -42,7 +42,7 @@ func TestGetRemoveReplacementAttorney(t *testing.T) { }). Return(nil) - err := RemoveReplacementAttorney(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney}}}) + err := RemoveReplacementAttorney(template.Execute, nil)(testAppData, w, r, &donordata.Provided{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney}}}) resp := w.Result() @@ -61,7 +61,7 @@ func TestGetRemoveReplacementAttorneyAttorneyDoesNotExist(t *testing.T) { }, } - err := RemoveReplacementAttorney(nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney}}}) + err := RemoveReplacementAttorney(nil, nil)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney}}}) resp := w.Result() assert.Nil(t, err) @@ -75,40 +75,40 @@ func TestPostRemoveReplacementAttorney(t *testing.T) { attorneyWithoutAddress := donordata.Attorney{UID: actoruid.New()} testcases := map[string]struct { - donor *donordata.DonorProvidedDetails - updatedDonor *donordata.DonorProvidedDetails + donor *donordata.Provided + updatedDonor *donordata.Provided redirect page.LpaPath }{ "many left": { - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithEmail, attorneyWithAddress, attorneyWithoutAddress}}, ReplacementAttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, }, - updatedDonor: &donordata.DonorProvidedDetails{ + updatedDonor: &donordata.Provided{ LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithEmail, attorneyWithAddress}}, ReplacementAttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, - Tasks: donordata.DonorTasks{ChooseReplacementAttorneys: actor.TaskInProgress}, + Tasks: donordata.Tasks{ChooseReplacementAttorneys: task.StateInProgress}, }, redirect: page.Paths.ChooseReplacementAttorneysSummary, }, "one left": { - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithAddress, attorneyWithoutAddress}}, ReplacementAttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, }, - updatedDonor: &donordata.DonorProvidedDetails{ + updatedDonor: &donordata.Provided{ LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithAddress}}, - Tasks: donordata.DonorTasks{ChooseReplacementAttorneys: actor.TaskInProgress}, + Tasks: donordata.Tasks{ChooseReplacementAttorneys: task.StateInProgress}, }, redirect: page.Paths.ChooseReplacementAttorneysSummary, }, "none left": { - donor: &donordata.DonorProvidedDetails{LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithoutAddress}}}, - updatedDonor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithoutAddress}}}, + updatedDonor: &donordata.Provided{ LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{}}, }, @@ -164,7 +164,7 @@ func TestPostRemoveReplacementAttorneyWithFormValueNo(t *testing.T) { Address: place.Address{}, } - err := RemoveReplacementAttorney(nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithoutAddress, attorneyWithAddress}}}) + err := RemoveReplacementAttorney(nil, nil)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithoutAddress, attorneyWithAddress}}}) resp := w.Result() assert.Nil(t, err) @@ -199,7 +199,7 @@ func TestPostRemoveReplacementAttorneyErrorOnPutStore(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := RemoveReplacementAttorney(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := RemoveReplacementAttorney(nil, donorStore)(testAppData, w, r, &donordata.Provided{ WantReplacementAttorneys: form.Yes, ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithoutAddress, attorneyWithAddress}}, }) @@ -234,7 +234,7 @@ func TestRemoveReplacementAttorneyFormValidation(t *testing.T) { })). Return(nil) - err := RemoveReplacementAttorney(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithoutAddress}}}) + err := RemoveReplacementAttorney(template.Execute, nil)(testAppData, w, r, &donordata.Provided{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithoutAddress}}}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/remove_trust_corporation.go b/internal/donor/donorpage/remove_trust_corporation.go index c429bc6c98..503fb0e2a8 100644 --- a/internal/donor/donorpage/remove_trust_corporation.go +++ b/internal/donor/donorpage/remove_trust_corporation.go @@ -17,7 +17,7 @@ func RemoveTrustCorporation(tmpl template.Template, donorStore DonorStore, isRep titleLabel = "removeReplacementTrustCorporation" } - updateDonor := func(donor *donordata.DonorProvidedDetails) { + updateDonor := func(donor *donordata.Provided) { donor.Attorneys.TrustCorporation = donordata.TrustCorporation{} if donor.Attorneys.Len() == 1 { donor.AttorneyDecisions = donordata.AttorneyDecisions{} @@ -25,7 +25,7 @@ func RemoveTrustCorporation(tmpl template.Template, donorStore DonorStore, isRep } if isReplacement { - updateDonor = func(donor *donordata.DonorProvidedDetails) { + updateDonor = func(donor *donordata.Provided) { donor.ReplacementAttorneys.TrustCorporation = donordata.TrustCorporation{} if donor.ReplacementAttorneys.Len() == 1 { donor.ReplacementAttorneyDecisions = donordata.AttorneyDecisions{} @@ -33,7 +33,7 @@ func RemoveTrustCorporation(tmpl template.Template, donorStore DonorStore, isRep } } - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { name := donor.Attorneys.TrustCorporation.Name if isReplacement { name = donor.ReplacementAttorneys.TrustCorporation.Name diff --git a/internal/donor/donorpage/remove_trust_corporation_test.go b/internal/donor/donorpage/remove_trust_corporation_test.go index 9c717907a3..94d3d36fbe 100644 --- a/internal/donor/donorpage/remove_trust_corporation_test.go +++ b/internal/donor/donorpage/remove_trust_corporation_test.go @@ -7,12 +7,12 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -24,16 +24,16 @@ func TestGetRemoveTrustCorporation(t *testing.T) { testcases := map[string]struct { isReplacement bool titleLabel string - donor *donordata.DonorProvidedDetails + donor *donordata.Provided }{ "attorney": { titleLabel: "removeTrustCorporation", - donor: &donordata.DonorProvidedDetails{Attorneys: donordata.Attorneys{TrustCorporation: trustCorporation}}, + donor: &donordata.Provided{Attorneys: donordata.Attorneys{TrustCorporation: trustCorporation}}, }, "replacement": { isReplacement: true, titleLabel: "removeReplacementTrustCorporation", - donor: &donordata.DonorProvidedDetails{ReplacementAttorneys: donordata.Attorneys{TrustCorporation: trustCorporation}}, + donor: &donordata.Provided{ReplacementAttorneys: donordata.Attorneys{TrustCorporation: trustCorporation}}, }, } @@ -68,69 +68,69 @@ func TestPostRemoveTrustCorporation(t *testing.T) { testcases := map[string]struct { isReplacement bool - donor *donordata.DonorProvidedDetails - updatedDonor *donordata.DonorProvidedDetails + donor *donordata.Provided + updatedDonor *donordata.Provided redirect page.LpaPath }{ "many left": { - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ LpaID: "lpa-id", Attorneys: donordata.Attorneys{TrustCorporation: trustCorporation, Attorneys: []donordata.Attorney{attorney, attorney}}, AttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, }, - updatedDonor: &donordata.DonorProvidedDetails{ + updatedDonor: &donordata.Provided{ LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney, attorney}}, AttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, - Tasks: donordata.DonorTasks{ChooseAttorneys: actor.TaskInProgress}, + Tasks: donordata.Tasks{ChooseAttorneys: task.StateInProgress}, }, redirect: page.Paths.ChooseAttorneysSummary, }, "replacement many left": { isReplacement: true, - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{TrustCorporation: trustCorporation, Attorneys: []donordata.Attorney{attorney, attorney}}, ReplacementAttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, }, - updatedDonor: &donordata.DonorProvidedDetails{ + updatedDonor: &donordata.Provided{ LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney, attorney}}, ReplacementAttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, - Tasks: donordata.DonorTasks{ChooseReplacementAttorneys: actor.TaskInProgress}, + Tasks: donordata.Tasks{ChooseReplacementAttorneys: task.StateInProgress}, }, redirect: page.Paths.ChooseReplacementAttorneysSummary, }, "one left": { - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ LpaID: "lpa-id", Attorneys: donordata.Attorneys{TrustCorporation: trustCorporation, Attorneys: []donordata.Attorney{attorney}}, AttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, }, - updatedDonor: &donordata.DonorProvidedDetails{ + updatedDonor: &donordata.Provided{ LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney}}, - Tasks: donordata.DonorTasks{ChooseAttorneys: actor.TaskInProgress}, + Tasks: donordata.Tasks{ChooseAttorneys: task.StateInProgress}, }, redirect: page.Paths.ChooseAttorneysSummary, }, "replacement one left": { isReplacement: true, - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{TrustCorporation: trustCorporation, Attorneys: []donordata.Attorney{attorney}}, ReplacementAttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, }, - updatedDonor: &donordata.DonorProvidedDetails{ + updatedDonor: &donordata.Provided{ LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney}}, - Tasks: donordata.DonorTasks{ChooseReplacementAttorneys: actor.TaskInProgress}, + Tasks: donordata.Tasks{ChooseReplacementAttorneys: task.StateInProgress}, }, redirect: page.Paths.ChooseReplacementAttorneysSummary, }, "none left": { - donor: &donordata.DonorProvidedDetails{LpaID: "lpa-id", Attorneys: donordata.Attorneys{TrustCorporation: trustCorporation}}, - updatedDonor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{LpaID: "lpa-id", Attorneys: donordata.Attorneys{TrustCorporation: trustCorporation}}, + updatedDonor: &donordata.Provided{ LpaID: "lpa-id", Attorneys: donordata.Attorneys{}, }, @@ -138,8 +138,8 @@ func TestPostRemoveTrustCorporation(t *testing.T) { }, "replacement none left": { isReplacement: true, - donor: &donordata.DonorProvidedDetails{LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{TrustCorporation: trustCorporation}}, - updatedDonor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{TrustCorporation: trustCorporation}}, + updatedDonor: &donordata.Provided{ LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{}, }, @@ -199,7 +199,7 @@ func TestPostRemoveTrustCorporationWithFormValueNo(t *testing.T) { Address: place.Address{}, } - err := RemoveTrustCorporation(template.Execute, nil, false)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithoutAddress, attorneyWithAddress}}}) + err := RemoveTrustCorporation(template.Execute, nil, false)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithoutAddress, attorneyWithAddress}}}) resp := w.Result() @@ -237,7 +237,7 @@ func TestPostRemoveTrustCorporationErrorOnPutStore(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := RemoveTrustCorporation(template.Execute, donorStore, false)(testAppData, w, r, &donordata.DonorProvidedDetails{Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithoutAddress, attorneyWithAddress}}}) + err := RemoveTrustCorporation(template.Execute, donorStore, false)(testAppData, w, r, &donordata.Provided{Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithoutAddress, attorneyWithAddress}}}) resp := w.Result() @@ -269,7 +269,7 @@ func TestRemoveTrustCorporationFormValidation(t *testing.T) { })). Return(nil) - err := RemoveTrustCorporation(template.Execute, nil, false)(testAppData, w, r, &donordata.DonorProvidedDetails{Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithoutAddress}}}) + err := RemoveTrustCorporation(template.Execute, nil, false)(testAppData, w, r, &donordata.Provided{Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithoutAddress}}}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/resend_witness_code.go b/internal/donor/donorpage/resend_witness_code.go index b90d892a05..dd478cfdb6 100644 --- a/internal/donor/donorpage/resend_witness_code.go +++ b/internal/donor/donorpage/resend_witness_code.go @@ -25,7 +25,7 @@ func ResendWitnessCode(tmpl template.Template, witnessCodeSender WitnessCodeSend redirect = page.Paths.WitnessingAsIndependentWitness } - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &resendWitnessCodeData{ App: appData, } diff --git a/internal/donor/donorpage/resend_witness_code_test.go b/internal/donor/donorpage/resend_witness_code_test.go index f264910e97..94ebb8a5b1 100644 --- a/internal/donor/donorpage/resend_witness_code_test.go +++ b/internal/donor/donorpage/resend_witness_code_test.go @@ -29,7 +29,7 @@ func TestGetResendWitnessCode(t *testing.T) { }). Return(nil) - err := ResendWitnessCode(template.Execute, &mockWitnessCodeSender{}, actorType)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := ResendWitnessCode(template.Execute, &mockWitnessCodeSender{}, actorType)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -47,7 +47,7 @@ func TestGetResendWitnessCodeWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := ResendWitnessCode(template.Execute, &mockWitnessCodeSender{}, actor.TypeCertificateProvider)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := ResendWitnessCode(template.Execute, &mockWitnessCodeSender{}, actor.TypeCertificateProvider)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -75,7 +75,7 @@ func TestPostResendWitnessCode(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader("")) r.Header.Add("Content-Type", page.FormUrlEncoded) - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, } @@ -100,7 +100,7 @@ func TestPostResendWitnessCodeWhenSendErrors(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader("")) r.Header.Add("Content-Type", page.FormUrlEncoded) - donor := &donordata.DonorProvidedDetails{Donor: donordata.Donor{FirstNames: "john"}} + donor := &donordata.Provided{Donor: donordata.Donor{FirstNames: "john"}} witnessCodeSender := newMockWitnessCodeSender(t) witnessCodeSender.EXPECT(). @@ -114,18 +114,18 @@ func TestPostResendWitnessCodeWhenSendErrors(t *testing.T) { func TestPostResendWitnessCodeWhenTooRecentlySent(t *testing.T) { testcases := map[actor.Type]struct { - donor *donordata.DonorProvidedDetails + donor *donordata.Provided send string }{ actor.TypeIndependentWitness: { - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ Donor: donordata.Donor{FirstNames: "john"}, IndependentWitnessCodes: donordata.WitnessCodes{{Created: time.Now()}}, }, send: "SendToIndependentWitness", }, actor.TypeCertificateProvider: { - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ Donor: donordata.Donor{FirstNames: "john"}, CertificateProviderCodes: donordata.WitnessCodes{{Created: time.Now()}}, }, diff --git a/internal/donor/donorpage/restrictions.go b/internal/donor/donorpage/restrictions.go index 59dfc7356f..4f6bdd0f72 100644 --- a/internal/donor/donorpage/restrictions.go +++ b/internal/donor/donorpage/restrictions.go @@ -4,20 +4,20 @@ import ( "net/http" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) type restrictionsData struct { App page.AppData Errors validation.List - Donor *donordata.DonorProvidedDetails + Donor *donordata.Provided } func Restrictions(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &restrictionsData{ App: appData, Donor: donor, @@ -28,7 +28,7 @@ func Restrictions(tmpl template.Template, donorStore DonorStore) Handler { data.Errors = form.Validate() if data.Errors.None() { - donor.Tasks.Restrictions = actor.TaskCompleted + donor.Tasks.Restrictions = task.StateCompleted donor.Restrictions = form.Restrictions if err := donorStore.Put(r.Context(), donor); err != nil { diff --git a/internal/donor/donorpage/restrictions_test.go b/internal/donor/donorpage/restrictions_test.go index 6bf18c045a..e088d3dc96 100644 --- a/internal/donor/donorpage/restrictions_test.go +++ b/internal/donor/donorpage/restrictions_test.go @@ -7,10 +7,10 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/random" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" ) @@ -23,11 +23,11 @@ func TestGetRestrictions(t *testing.T) { template.EXPECT(). Execute(w, &restrictionsData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{}, + Donor: &donordata.Provided{}, }). Return(nil) - err := Restrictions(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := Restrictions(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -42,11 +42,11 @@ func TestGetRestrictionsFromStore(t *testing.T) { template.EXPECT(). Execute(w, &restrictionsData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{Restrictions: "blah"}, + Donor: &donordata.Provided{Restrictions: "blah"}, }). Return(nil) - err := Restrictions(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{Restrictions: "blah"}) + err := Restrictions(template.Execute, nil)(testAppData, w, r, &donordata.Provided{Restrictions: "blah"}) resp := w.Result() assert.Nil(t, err) @@ -61,11 +61,11 @@ func TestGetRestrictionsWhenTemplateErrors(t *testing.T) { template.EXPECT(). Execute(w, &restrictionsData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{}, + Donor: &donordata.Provided{}, }). Return(expectedError) - err := Restrictions(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := Restrictions(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -83,16 +83,16 @@ func TestPostRestrictions(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Restrictions: "blah", - Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, Restrictions: actor.TaskCompleted}, + Tasks: donordata.Tasks{YourDetails: task.StateCompleted, ChooseAttorneys: task.StateCompleted, Restrictions: task.StateCompleted}, }). Return(nil) - err := Restrictions(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := Restrictions(nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", - Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted}, + Tasks: donordata.Tasks{YourDetails: task.StateCompleted, ChooseAttorneys: task.StateCompleted}, }) resp := w.Result() @@ -112,10 +112,10 @@ func TestPostRestrictionsWhenStoreErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{Restrictions: "blah", Tasks: donordata.DonorTasks{Restrictions: actor.TaskCompleted}}). + Put(r.Context(), &donordata.Provided{Restrictions: "blah", Tasks: donordata.Tasks{Restrictions: task.StateCompleted}}). Return(expectedError) - err := Restrictions(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := Restrictions(nil, donorStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -134,11 +134,11 @@ func TestPostRestrictionsWhenValidationErrors(t *testing.T) { Execute(w, &restrictionsData{ App: testAppData, Errors: validation.With("restrictions", validation.StringTooLongError{Label: "restrictions", Length: 10000}), - Donor: &donordata.DonorProvidedDetails{}, + Donor: &donordata.Provided{}, }). Return(nil) - err := Restrictions(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := Restrictions(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/send_us_your_evidence_by_post.go b/internal/donor/donorpage/send_us_your_evidence_by_post.go index 23b4f2b448..e7de1c2bf0 100644 --- a/internal/donor/donorpage/send_us_your_evidence_by_post.go +++ b/internal/donor/donorpage/send_us_your_evidence_by_post.go @@ -18,7 +18,7 @@ type sendUsYourEvidenceByPostData struct { } func SendUsYourEvidenceByPost(tmpl template.Template, payer Handler, eventClient EventClient) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &sendUsYourEvidenceByPostData{ App: appData, FeeType: donor.FeeType, diff --git a/internal/donor/donorpage/send_us_your_evidence_by_post_test.go b/internal/donor/donorpage/send_us_your_evidence_by_post_test.go index ad884ba1ab..6cce48cd1e 100644 --- a/internal/donor/donorpage/send_us_your_evidence_by_post_test.go +++ b/internal/donor/donorpage/send_us_your_evidence_by_post_test.go @@ -21,7 +21,7 @@ func TestGetSendUsYourEvidenceByPost(t *testing.T) { Execute(w, &sendUsYourEvidenceByPostData{App: testAppData}). Return(nil) - err := SendUsYourEvidenceByPost(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := SendUsYourEvidenceByPost(template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -37,7 +37,7 @@ func TestGetSendUsYourEvidenceByPostWhenTemplateErrors(t *testing.T) { Execute(w, &sendUsYourEvidenceByPostData{App: testAppData}). Return(expectedError) - err := SendUsYourEvidenceByPost(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := SendUsYourEvidenceByPost(template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -48,7 +48,7 @@ func TestPostSendUsYourEvidenceByPost(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodPost, "/about-payment", nil) - donor := &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Post} + donor := &donordata.Provided{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Post} eventClient := newMockEventClient(t) eventClient.EXPECT(). @@ -77,7 +77,7 @@ func TestPostSendUsYourEvidenceByPostWhenEventClientErrors(t *testing.T) { SendReducedFeeRequested(r.Context(), mock.Anything). Return(expectedError) - err := SendUsYourEvidenceByPost(nil, nil, eventClient)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := SendUsYourEvidenceByPost(nil, nil, eventClient)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -95,6 +95,6 @@ func TestPostSendUsYourEvidenceByPostWhenPayerErrors(t *testing.T) { Execute(testAppData, w, r, mock.Anything). Return(expectedError) - err := SendUsYourEvidenceByPost(nil, payer.Execute, eventClient)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := SendUsYourEvidenceByPost(nil, payer.Execute, eventClient)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } diff --git a/internal/donor/donorpage/sign_your_lpa.go b/internal/donor/donorpage/sign_your_lpa.go index bf52b0566e..aa45b9d71c 100644 --- a/internal/donor/donorpage/sign_your_lpa.go +++ b/internal/donor/donorpage/sign_your_lpa.go @@ -13,7 +13,7 @@ import ( type signYourLpaData struct { App page.AppData Errors validation.List - Donor *donordata.DonorProvidedDetails + Donor *donordata.Provided Form *signYourLpaForm WantToSignFormValue string WantToApplyFormValue string @@ -25,7 +25,7 @@ const ( ) func SignYourLpa(tmpl template.Template, donorStore DonorStore, now func() time.Time) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { if !donor.SignedAt.IsZero() { return page.Paths.WitnessingYourSignature.Redirect(w, r, appData, donor) } diff --git a/internal/donor/donorpage/sign_your_lpa_test.go b/internal/donor/donorpage/sign_your_lpa_test.go index 89acd5cce3..e5249de71c 100644 --- a/internal/donor/donorpage/sign_your_lpa_test.go +++ b/internal/donor/donorpage/sign_your_lpa_test.go @@ -25,13 +25,13 @@ func TestGetSignYourLpa(t *testing.T) { Execute(w, &signYourLpaData{ App: testAppData, Form: &signYourLpaForm{}, - Donor: &donordata.DonorProvidedDetails{}, + Donor: &donordata.Provided{}, WantToSignFormValue: WantToSignLpa, WantToApplyFormValue: WantToApplyForLpa, }). Return(nil) - err := SignYourLpa(template.Execute, nil, testNowFn)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := SignYourLpa(template.Execute, nil, testNowFn)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -42,7 +42,7 @@ func TestGetSignYourLpaWhenSigned(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - err := SignYourLpa(nil, nil, testNowFn)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := SignYourLpa(nil, nil, testNowFn)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, SignedAt: time.Now(), @@ -58,7 +58,7 @@ func TestGetSignYourLpaFromStore(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ WantToSignLpa: true, WantToApplyForLpa: false, } @@ -95,7 +95,7 @@ func TestPostSignYourLpa(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, WantToSignLpa: true, @@ -104,7 +104,7 @@ func TestPostSignYourLpa(t *testing.T) { }). Return(nil) - err := SignYourLpa(nil, donorStore, testNowFn)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}}) + err := SignYourLpa(nil, donorStore, testNowFn)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}}) resp := w.Result() assert.Nil(t, err) @@ -126,7 +126,7 @@ func TestPostSignYourLpaWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := SignYourLpa(nil, donorStore, testNowFn)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := SignYourLpa(nil, donorStore, testNowFn)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -147,7 +147,7 @@ func TestPostSignYourLpaWhenValidationErrors(t *testing.T) { })). Return(nil) - err := SignYourLpa(template.Execute, nil, testNowFn)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := SignYourLpa(template.Execute, nil, testNowFn)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/task_list.go b/internal/donor/donorpage/task_list.go index 6283022ca3..f3618be7d8 100644 --- a/internal/donor/donorpage/task_list.go +++ b/internal/donor/donorpage/task_list.go @@ -4,7 +4,6 @@ import ( "net/http" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/identity" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" @@ -15,7 +14,7 @@ import ( type taskListData struct { App page.AppData Errors validation.List - Donor *donordata.DonorProvidedDetails + Donor *donordata.Provided Sections []taskListSection EvidenceReceived bool } @@ -23,9 +22,9 @@ type taskListData struct { type taskListItem struct { Name string Path string - State actor.TaskState + State task.State PaymentState task.PaymentState - IdentityState actor.IdentityTask + IdentityState task.IdentityState Count int Hidden bool } @@ -36,7 +35,7 @@ type taskListSection struct { } func TaskList(tmpl template.Template, evidenceReceivedStore EvidenceReceivedStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { evidenceReceived, err := evidenceReceivedStore.Get(r.Context()) if err != nil { return err @@ -124,7 +123,7 @@ func TaskList(tmpl template.Template, evidenceReceivedStore EvidenceReceivedStor } } -func taskListTypeSpecificStep(donor *donordata.DonorProvidedDetails) taskListItem { +func taskListTypeSpecificStep(donor *donordata.Provided) taskListItem { if donor.Type == donordata.LpaTypePersonalWelfare { return taskListItem{ Name: "lifeSustainingTreatment", @@ -140,7 +139,7 @@ func taskListTypeSpecificStep(donor *donordata.DonorProvidedDetails) taskListIte } } -func taskListCheckLpaPath(donor *donordata.DonorProvidedDetails) page.LpaPath { +func taskListCheckLpaPath(donor *donordata.Provided) page.LpaPath { if len(donor.Under18ActorDetails()) > 0 { return page.Paths.YouCannotSignYourLpaYet } else if donor.CertificateProviderSharesDetails() { @@ -150,7 +149,7 @@ func taskListCheckLpaPath(donor *donordata.DonorProvidedDetails) page.LpaPath { } } -func taskListPaymentSection(donor *donordata.DonorProvidedDetails) taskListSection { +func taskListPaymentSection(donor *donordata.Provided) taskListSection { var paymentPath string switch donor.Tasks.PayForLpa { case task.PaymentStateApproved: @@ -175,7 +174,7 @@ func taskListPaymentSection(donor *donordata.DonorProvidedDetails) taskListSecti } } -func taskListSignSection(donor *donordata.DonorProvidedDetails) taskListSection { +func taskListSignSection(donor *donordata.Provided) taskListSection { var signPath page.LpaPath switch donor.DonorIdentityUserData.Status { diff --git a/internal/donor/donorpage/task_list_test.go b/internal/donor/donorpage/task_list_test.go index 4d18a75074..998364ad23 100644 --- a/internal/donor/donorpage/task_list_test.go +++ b/internal/donor/donorpage/task_list_test.go @@ -6,7 +6,6 @@ import ( "testing" "time" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/date" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" @@ -22,20 +21,20 @@ import ( func TestGetTaskList(t *testing.T) { testCases := map[string]struct { appData page.AppData - donor *donordata.DonorProvidedDetails + donor *donordata.Provided evidenceReceived bool expected func([]taskListSection) []taskListSection }{ "empty": { appData: testAppData, - donor: &donordata.DonorProvidedDetails{LpaID: "lpa-id", Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}}, + donor: &donordata.Provided{LpaID: "lpa-id", Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}}, expected: func(sections []taskListSection) []taskListSection { return sections }, }, "cannot sign": { appData: testAppData, - donor: &donordata.DonorProvidedDetails{LpaID: "lpa-id", Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}, CanSign: form.No}}, + donor: &donordata.Provided{LpaID: "lpa-id", Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}, CanSign: form.No}}, expected: func(sections []taskListSection) []taskListSection { sections[0].Items[8].Hidden = false @@ -44,7 +43,7 @@ func TestGetTaskList(t *testing.T) { }, "evidence received": { appData: testAppData, - donor: &donordata.DonorProvidedDetails{LpaID: "lpa-id", Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}}, + donor: &donordata.Provided{LpaID: "lpa-id", Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}}, evidenceReceived: true, expected: func(sections []taskListSection) []taskListSection { return sections @@ -52,7 +51,7 @@ func TestGetTaskList(t *testing.T) { }, "more evidence required": { appData: testAppData, - donor: &donordata.DonorProvidedDetails{LpaID: "lpa-id", Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateMoreEvidenceRequired}}, + donor: &donordata.Provided{LpaID: "lpa-id", Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, Tasks: donordata.Tasks{PayForLpa: task.PaymentStateMoreEvidenceRequired}}, evidenceReceived: true, expected: func(sections []taskListSection) []taskListSection { sections[1].Items = []taskListItem{ @@ -64,7 +63,7 @@ func TestGetTaskList(t *testing.T) { }, "fee denied": { appData: testAppData, - donor: &donordata.DonorProvidedDetails{LpaID: "lpa-id", Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateDenied}}, + donor: &donordata.Provided{LpaID: "lpa-id", Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, Tasks: donordata.Tasks{PayForLpa: task.PaymentStateDenied}}, evidenceReceived: true, expected: func(sections []taskListSection) []taskListSection { sections[1].Items = []taskListItem{ @@ -76,7 +75,7 @@ func TestGetTaskList(t *testing.T) { }, "fee approved": { appData: testAppData, - donor: &donordata.DonorProvidedDetails{LpaID: "lpa-id", Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateApproved}}, + donor: &donordata.Provided{LpaID: "lpa-id", Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, Tasks: donordata.Tasks{PayForLpa: task.PaymentStateApproved}}, evidenceReceived: true, expected: func(sections []taskListSection) []taskListSection { sections[1].Items = []taskListItem{ @@ -88,7 +87,7 @@ func TestGetTaskList(t *testing.T) { }, "personal welfare": { appData: testAppData, - donor: &donordata.DonorProvidedDetails{LpaID: "lpa-id", Type: donordata.LpaTypePersonalWelfare, Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}}, + donor: &donordata.Provided{LpaID: "lpa-id", Type: donordata.LpaTypePersonalWelfare, Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}}, expected: func(sections []taskListSection) []taskListSection { sections[0].Items[3] = taskListItem{ Name: "lifeSustainingTreatment", @@ -100,7 +99,7 @@ func TestGetTaskList(t *testing.T) { }, "confirmed identity": { appData: testAppData, - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed, LastName: "a"}, @@ -115,7 +114,7 @@ func TestGetTaskList(t *testing.T) { }, "confirmed identity does not match LPA": { appData: testAppData, - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{LastName: "b", Address: place.Address{Line1: "x"}}, DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed, LastName: "a"}, @@ -130,7 +129,7 @@ func TestGetTaskList(t *testing.T) { }, "failed identity": { appData: testAppData, - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, DonorIdentityUserData: identity.UserData{Status: identity.StatusFailed, LastName: "a"}, @@ -145,7 +144,7 @@ func TestGetTaskList(t *testing.T) { }, "insufficient evidence for identity": { appData: testAppData, - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, DonorIdentityUserData: identity.UserData{Status: identity.StatusInsufficientEvidence, LastName: "a"}, @@ -160,7 +159,7 @@ func TestGetTaskList(t *testing.T) { }, "insufficient evidence for identity with voucher details": { appData: testAppData, - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, DonorIdentityUserData: identity.UserData{Status: identity.StatusInsufficientEvidence, LastName: "a"}, @@ -176,7 +175,7 @@ func TestGetTaskList(t *testing.T) { }, "does not want a voucher": { appData: testAppData, - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, DonorIdentityUserData: identity.UserData{Status: identity.StatusInsufficientEvidence, LastName: "a"}, @@ -192,7 +191,7 @@ func TestGetTaskList(t *testing.T) { }, "wants a voucher": { appData: testAppData, - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, DonorIdentityUserData: identity.UserData{Status: identity.StatusInsufficientEvidence, LastName: "a"}, @@ -208,7 +207,7 @@ func TestGetTaskList(t *testing.T) { }, "is applying to court of protection": { appData: testAppData, - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, DonorIdentityUserData: identity.UserData{Status: identity.StatusInsufficientEvidence, LastName: "a"}, @@ -225,7 +224,7 @@ func TestGetTaskList(t *testing.T) { }, "is applying to court of protection and has signed": { appData: testAppData, - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, DonorIdentityUserData: identity.UserData{Status: identity.StatusInsufficientEvidence, LastName: "a"}, @@ -243,7 +242,7 @@ func TestGetTaskList(t *testing.T) { }, "attorneys under 18": { appData: testAppData, - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "xx"}}, Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ @@ -254,7 +253,7 @@ func TestGetTaskList(t *testing.T) { sections[0].Items[1] = taskListItem{ Name: "chooseYourAttorneys", Path: page.Paths.ChooseAttorneysSummary.Format("lpa-id"), - State: actor.TaskNotStarted, + State: task.StateNotStarted, Count: 1, } @@ -265,7 +264,7 @@ func TestGetTaskList(t *testing.T) { }, "certificate provider has similar name": { appData: testAppData, - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, CertificateProvider: donordata.CertificateProvider{LastName: "a"}, @@ -278,7 +277,7 @@ func TestGetTaskList(t *testing.T) { }, "mixed": { appData: testAppData, - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "this"}, CertificateProvider: donordata.CertificateProvider{LastName: "a", Address: place.Address{Line1: "x"}}, @@ -289,29 +288,29 @@ func TestGetTaskList(t *testing.T) { ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {DateOfBirth: date.Today().AddDate(-20, 0, 0)}, }}, - Tasks: donordata.DonorTasks{ - YourDetails: actor.TaskCompleted, - ChooseAttorneys: actor.TaskCompleted, - ChooseReplacementAttorneys: actor.TaskInProgress, - WhenCanTheLpaBeUsed: actor.TaskInProgress, - Restrictions: actor.TaskCompleted, - CertificateProvider: actor.TaskInProgress, - CheckYourLpa: actor.TaskCompleted, + Tasks: donordata.Tasks{ + YourDetails: task.StateCompleted, + ChooseAttorneys: task.StateCompleted, + ChooseReplacementAttorneys: task.StateInProgress, + WhenCanTheLpaBeUsed: task.StateInProgress, + Restrictions: task.StateCompleted, + CertificateProvider: task.StateInProgress, + CheckYourLpa: task.StateCompleted, PayForLpa: task.PaymentStateInProgress, }, }, expected: func(sections []taskListSection) []taskListSection { sections[0].Items = []taskListItem{ - {Name: "provideYourDetails", Path: page.Paths.YourDetails.Format("lpa-id"), State: actor.TaskCompleted}, - {Name: "chooseYourAttorneys", Path: page.Paths.ChooseAttorneysSummary.Format("lpa-id"), State: actor.TaskCompleted, Count: 2}, - {Name: "chooseYourReplacementAttorneys", Path: page.Paths.ChooseReplacementAttorneysSummary.Format("lpa-id"), State: actor.TaskInProgress, Count: 1}, - {Name: "chooseWhenTheLpaCanBeUsed", Path: page.Paths.WhenCanTheLpaBeUsed.Format("lpa-id"), State: actor.TaskInProgress}, - {Name: "addRestrictionsToTheLpa", Path: page.Paths.Restrictions.Format("lpa-id"), State: actor.TaskCompleted}, - {Name: "chooseYourCertificateProvider", Path: page.Paths.WhatACertificateProviderDoes.Format("lpa-id"), State: actor.TaskInProgress}, + {Name: "provideYourDetails", Path: page.Paths.YourDetails.Format("lpa-id"), State: task.StateCompleted}, + {Name: "chooseYourAttorneys", Path: page.Paths.ChooseAttorneysSummary.Format("lpa-id"), State: task.StateCompleted, Count: 2}, + {Name: "chooseYourReplacementAttorneys", Path: page.Paths.ChooseReplacementAttorneysSummary.Format("lpa-id"), State: task.StateInProgress, Count: 1}, + {Name: "chooseWhenTheLpaCanBeUsed", Path: page.Paths.WhenCanTheLpaBeUsed.Format("lpa-id"), State: task.StateInProgress}, + {Name: "addRestrictionsToTheLpa", Path: page.Paths.Restrictions.Format("lpa-id"), State: task.StateCompleted}, + {Name: "chooseYourCertificateProvider", Path: page.Paths.WhatACertificateProviderDoes.Format("lpa-id"), State: task.StateInProgress}, {Name: "peopleToNotifyAboutYourLpa", Path: page.Paths.DoYouWantToNotifyPeople.Format("lpa-id")}, {Name: "addCorrespondent", Path: page.Paths.AddCorrespondent.Format("lpa-id")}, {Name: "chooseYourSignatoryAndIndependentWitness", Path: page.Paths.GettingHelpSigning.Format("lpa-id"), Hidden: true}, - {Name: "checkAndSendToYourCertificateProvider", Path: page.Paths.CheckYourLpa.Format("lpa-id"), State: actor.TaskCompleted}, + {Name: "checkAndSendToYourCertificateProvider", Path: page.Paths.CheckYourLpa.Format("lpa-id"), State: task.StateCompleted}, } sections[1].Items = []taskListItem{ @@ -323,7 +322,7 @@ func TestGetTaskList(t *testing.T) { }, "signed": { appData: testAppData, - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ LpaID: "lpa-id", SignedAt: time.Now(), Donor: donordata.Donor{FirstNames: "this"}, @@ -336,31 +335,31 @@ func TestGetTaskList(t *testing.T) { {DateOfBirth: date.Today().AddDate(-20, 0, 0)}, }}, DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed, LastName: "a"}, - Tasks: donordata.DonorTasks{ - YourDetails: actor.TaskCompleted, - ChooseAttorneys: actor.TaskCompleted, - ChooseReplacementAttorneys: actor.TaskCompleted, - WhenCanTheLpaBeUsed: actor.TaskCompleted, - Restrictions: actor.TaskCompleted, - CertificateProvider: actor.TaskCompleted, - CheckYourLpa: actor.TaskCompleted, - AddCorrespondent: actor.TaskCompleted, + Tasks: donordata.Tasks{ + YourDetails: task.StateCompleted, + ChooseAttorneys: task.StateCompleted, + ChooseReplacementAttorneys: task.StateCompleted, + WhenCanTheLpaBeUsed: task.StateCompleted, + Restrictions: task.StateCompleted, + CertificateProvider: task.StateCompleted, + CheckYourLpa: task.StateCompleted, + AddCorrespondent: task.StateCompleted, PayForLpa: task.PaymentStateCompleted, - ConfirmYourIdentityAndSign: actor.IdentityTaskCompleted, + ConfirmYourIdentityAndSign: task.IdentityStateCompleted, }, }, expected: func(sections []taskListSection) []taskListSection { sections[0].Items = []taskListItem{ - {Name: "provideYourDetails", Path: page.Paths.YourDetails.Format("lpa-id"), State: actor.TaskCompleted}, - {Name: "chooseYourAttorneys", Path: page.Paths.ChooseAttorneysSummary.Format("lpa-id"), State: actor.TaskCompleted, Count: 2}, - {Name: "chooseYourReplacementAttorneys", Path: page.Paths.ChooseReplacementAttorneysSummary.Format("lpa-id"), State: actor.TaskCompleted, Count: 1}, - {Name: "chooseWhenTheLpaCanBeUsed", Path: page.Paths.WhenCanTheLpaBeUsed.Format("lpa-id"), State: actor.TaskCompleted}, - {Name: "addRestrictionsToTheLpa", Path: page.Paths.Restrictions.Format("lpa-id"), State: actor.TaskCompleted}, - {Name: "chooseYourCertificateProvider", Path: page.Paths.WhatACertificateProviderDoes.Format("lpa-id"), State: actor.TaskCompleted}, + {Name: "provideYourDetails", Path: page.Paths.YourDetails.Format("lpa-id"), State: task.StateCompleted}, + {Name: "chooseYourAttorneys", Path: page.Paths.ChooseAttorneysSummary.Format("lpa-id"), State: task.StateCompleted, Count: 2}, + {Name: "chooseYourReplacementAttorneys", Path: page.Paths.ChooseReplacementAttorneysSummary.Format("lpa-id"), State: task.StateCompleted, Count: 1}, + {Name: "chooseWhenTheLpaCanBeUsed", Path: page.Paths.WhenCanTheLpaBeUsed.Format("lpa-id"), State: task.StateCompleted}, + {Name: "addRestrictionsToTheLpa", Path: page.Paths.Restrictions.Format("lpa-id"), State: task.StateCompleted}, + {Name: "chooseYourCertificateProvider", Path: page.Paths.WhatACertificateProviderDoes.Format("lpa-id"), State: task.StateCompleted}, {Name: "peopleToNotifyAboutYourLpa", Path: page.Paths.DoYouWantToNotifyPeople.Format("lpa-id")}, - {Name: "addCorrespondent", Path: page.Paths.AddCorrespondent.Format("lpa-id"), State: actor.TaskCompleted}, + {Name: "addCorrespondent", Path: page.Paths.AddCorrespondent.Format("lpa-id"), State: task.StateCompleted}, {Name: "chooseYourSignatoryAndIndependentWitness", Path: page.Paths.GettingHelpSigning.Format("lpa-id"), Hidden: true}, - {Name: "checkAndSendToYourCertificateProvider", Path: page.Paths.CheckYourLpa.Format("lpa-id"), State: actor.TaskCompleted}, + {Name: "checkAndSendToYourCertificateProvider", Path: page.Paths.CheckYourLpa.Format("lpa-id"), State: task.StateCompleted}, } sections[1].Items = []taskListItem{ @@ -368,7 +367,7 @@ func TestGetTaskList(t *testing.T) { } sections[2].Items = []taskListItem{ - {Name: "confirmYourIdentityAndSign", Path: page.Paths.YouHaveSubmittedYourLpa.Format("lpa-id"), IdentityState: actor.IdentityTaskCompleted}, + {Name: "confirmYourIdentityAndSign", Path: page.Paths.YouHaveSubmittedYourLpa.Format("lpa-id"), IdentityState: task.IdentityStateCompleted}, } return sections @@ -381,7 +380,7 @@ func TestGetTaskList(t *testing.T) { Lang: localize.En, SupporterData: &page.SupporterData{}, }, - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "this"}, CertificateProvider: donordata.CertificateProvider{LastName: "a", Address: place.Address{Line1: "x"}}, @@ -392,25 +391,25 @@ func TestGetTaskList(t *testing.T) { ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {DateOfBirth: date.Today().AddDate(-20, 0, 0)}, }}, - Tasks: donordata.DonorTasks{ - YourDetails: actor.TaskCompleted, - ChooseAttorneys: actor.TaskCompleted, - ChooseReplacementAttorneys: actor.TaskInProgress, - WhenCanTheLpaBeUsed: actor.TaskInProgress, - Restrictions: actor.TaskCompleted, - CertificateProvider: actor.TaskInProgress, + Tasks: donordata.Tasks{ + YourDetails: task.StateCompleted, + ChooseAttorneys: task.StateCompleted, + ChooseReplacementAttorneys: task.StateInProgress, + WhenCanTheLpaBeUsed: task.StateInProgress, + Restrictions: task.StateCompleted, + CertificateProvider: task.StateInProgress, }, }, expected: func(sections []taskListSection) []taskListSection { sections[0].Items = []taskListItem{ - {Name: "provideYourDetails", Path: page.Paths.YourDetails.Format("lpa-id"), State: actor.TaskCompleted}, - {Name: "chooseYourAttorneys", Path: page.Paths.ChooseAttorneysSummary.Format("lpa-id"), State: actor.TaskCompleted, Count: 2}, - {Name: "chooseYourReplacementAttorneys", Path: page.Paths.ChooseReplacementAttorneysSummary.Format("lpa-id"), State: actor.TaskInProgress, Count: 1}, - {Name: "chooseWhenTheLpaCanBeUsed", Path: page.Paths.WhenCanTheLpaBeUsed.Format("lpa-id"), State: actor.TaskInProgress}, - {Name: "addRestrictionsToTheLpa", Path: page.Paths.Restrictions.Format("lpa-id"), State: actor.TaskCompleted}, - {Name: "chooseYourCertificateProvider", Path: page.Paths.WhatACertificateProviderDoes.Format("lpa-id"), State: actor.TaskInProgress}, + {Name: "provideYourDetails", Path: page.Paths.YourDetails.Format("lpa-id"), State: task.StateCompleted}, + {Name: "chooseYourAttorneys", Path: page.Paths.ChooseAttorneysSummary.Format("lpa-id"), State: task.StateCompleted, Count: 2}, + {Name: "chooseYourReplacementAttorneys", Path: page.Paths.ChooseReplacementAttorneysSummary.Format("lpa-id"), State: task.StateInProgress, Count: 1}, + {Name: "chooseWhenTheLpaCanBeUsed", Path: page.Paths.WhenCanTheLpaBeUsed.Format("lpa-id"), State: task.StateInProgress}, + {Name: "addRestrictionsToTheLpa", Path: page.Paths.Restrictions.Format("lpa-id"), State: task.StateCompleted}, + {Name: "chooseYourCertificateProvider", Path: page.Paths.WhatACertificateProviderDoes.Format("lpa-id"), State: task.StateInProgress}, {Name: "peopleToNotifyAboutYourLpa", Path: page.Paths.DoYouWantToNotifyPeople.Format("lpa-id")}, - {Name: "addCorrespondent", Path: page.Paths.AddCorrespondent.Format("lpa-id"), State: actor.TaskNotStarted}, + {Name: "addCorrespondent", Path: page.Paths.AddCorrespondent.Format("lpa-id"), State: task.StateNotStarted}, {Name: "chooseYourSignatoryAndIndependentWitness", Path: page.Paths.GettingHelpSigning.Format("lpa-id"), Hidden: true}, } @@ -485,7 +484,7 @@ func TestGetTaskListWhenEvidenceReceivedStoreErrors(t *testing.T) { Get(r.Context()). Return(false, expectedError) - err := TaskList(nil, evidenceReceivedStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := TaskList(nil, evidenceReceivedStore)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -506,7 +505,7 @@ func TestGetTaskListWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := TaskList(template.Execute, evidenceReceivedStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := TaskList(template.Execute, evidenceReceivedStore)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) diff --git a/internal/donor/donorpage/upload_evidence.go b/internal/donor/donorpage/upload_evidence.go index eeaf7cf152..77ee9d9fec 100644 --- a/internal/donor/donorpage/upload_evidence.go +++ b/internal/donor/donorpage/upload_evidence.go @@ -61,7 +61,7 @@ type uploadEvidenceData struct { } func UploadEvidence(tmpl template.Template, logger Logger, payer Handler, documentStore DocumentStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { if donor.Tasks.PayForLpa.IsPending() { return page.Paths.TaskList.Redirect(w, r, appData, donor) } diff --git a/internal/donor/donorpage/upload_evidence_sse.go b/internal/donor/donorpage/upload_evidence_sse.go index 45d704eee2..3fab58ad7e 100644 --- a/internal/donor/donorpage/upload_evidence_sse.go +++ b/internal/donor/donorpage/upload_evidence_sse.go @@ -11,7 +11,7 @@ import ( ) func UploadEvidenceSSE(documentStore DocumentStore, ttl time.Duration, flushFrequency time.Duration, now func() time.Time) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { w.Header().Set("Cache-Control", "no-cache") w.Header().Set("Connection", "keep-alive") w.Header().Set("Content-Type", "text/event-stream") diff --git a/internal/donor/donorpage/upload_evidence_sse_test.go b/internal/donor/donorpage/upload_evidence_sse_test.go index 260dd01a01..223fbbc3a4 100644 --- a/internal/donor/donorpage/upload_evidence_sse_test.go +++ b/internal/donor/donorpage/upload_evidence_sse_test.go @@ -38,7 +38,7 @@ func TestUploadEvidenceSSE(t *testing.T) { now := time.Now() - err := UploadEvidenceSSE(documentStore, 4*time.Millisecond, 2*time.Millisecond, func() time.Time { return now })(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := UploadEvidenceSSE(documentStore, 4*time.Millisecond, 2*time.Millisecond, func() time.Time { return now })(testAppData, w, r, &donordata.Provided{}) resp := w.Result() bodyBytes, _ := io.ReadAll(resp.Body) @@ -60,7 +60,7 @@ func TestUploadEvidenceSSEOnDonorStoreError(t *testing.T) { {Scanned: true}, }, expectedError) - err := UploadEvidenceSSE(documentStore, 4*time.Millisecond, 2*time.Millisecond, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := UploadEvidenceSSE(documentStore, 4*time.Millisecond, 2*time.Millisecond, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() bodyBytes, _ := io.ReadAll(resp.Body) @@ -93,7 +93,7 @@ func TestUploadEvidenceSSEOnDonorStoreErrorWhenRefreshingDocuments(t *testing.T) now := time.Now() - err := UploadEvidenceSSE(documentStore, 4*time.Millisecond, 2*time.Millisecond, func() time.Time { return now })(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := UploadEvidenceSSE(documentStore, 4*time.Millisecond, 2*time.Millisecond, func() time.Time { return now })(testAppData, w, r, &donordata.Provided{}) resp := w.Result() bodyBytes, _ := io.ReadAll(resp.Body) diff --git a/internal/donor/donorpage/upload_evidence_test.go b/internal/donor/donorpage/upload_evidence_test.go index f55ff110fc..eb5563175a 100644 --- a/internal/donor/donorpage/upload_evidence_test.go +++ b/internal/donor/donorpage/upload_evidence_test.go @@ -42,7 +42,7 @@ func TestGetUploadEvidence(t *testing.T) { }). Return(nil) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{FeeType: pay.FullFee}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.Provided{FeeType: pay.FullFee}) resp := w.Result() assert.Nil(t, err) @@ -53,7 +53,7 @@ func TestGetUploadEvidenceWhenTaskPending(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - err := UploadEvidence(nil, nil, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", FeeType: pay.FullFee, Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}}) + err := UploadEvidence(nil, nil, nil, nil)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", FeeType: pay.FullFee, Tasks: donordata.Tasks{PayForLpa: task.PaymentStatePending}}) resp := w.Result() assert.Nil(t, err) @@ -75,7 +75,7 @@ func TestGetUploadEvidenceWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -106,7 +106,7 @@ func TestPostUploadEvidenceWithUploadActionAcceptedFileTypes(t *testing.T) { GetAll(r.Context()). Return(page.Documents{}, nil) documentStore.EXPECT(). - Create(r.Context(), &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}, filename, mock.Anything). + Create(r.Context(), &donordata.Provided{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}, filename, mock.Anything). Return(page.Document{ PK: dynamo.LpaKey("lpa-id"), SK: dynamo.DocumentKey("lpa-uid/evidence/a-uid"), @@ -131,7 +131,7 @@ func TestPostUploadEvidenceWithUploadActionAcceptedFileTypes(t *testing.T) { }). Return(nil) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) assert.Nil(t, err) }) } @@ -141,7 +141,7 @@ func TestPostUploadEvidenceWhenTaskPending(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodPost, "/", nil) - err := UploadEvidence(nil, nil, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", FeeType: pay.FullFee, Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}}) + err := UploadEvidence(nil, nil, nil, nil)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", FeeType: pay.FullFee, Tasks: donordata.Tasks{PayForLpa: task.PaymentStatePending}}) resp := w.Result() assert.Nil(t, err) @@ -161,7 +161,7 @@ func TestPostUploadEvidenceWithUploadActionMultipleFiles(t *testing.T) { GetAll(r.Context()). Return(page.Documents{}, nil) documentStore.EXPECT(). - Create(r.Context(), &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}, "dummy.pdf", mock.Anything). + Create(r.Context(), &donordata.Provided{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}, "dummy.pdf", mock.Anything). Return(page.Document{ PK: dynamo.LpaKey("lpa-id"), SK: dynamo.DocumentKey("lpa-uid/evidence/a-uid"), @@ -170,7 +170,7 @@ func TestPostUploadEvidenceWithUploadActionMultipleFiles(t *testing.T) { }, nil). Once() documentStore.EXPECT(). - Create(r.Context(), &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}, "dummy.png", mock.Anything). + Create(r.Context(), &donordata.Provided{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}, "dummy.png", mock.Anything). Return(page.Document{ PK: dynamo.LpaKey("lpa-id"), SK: dynamo.DocumentKey("lpa-uid/evidence/a-uid"), @@ -204,7 +204,7 @@ func TestPostUploadEvidenceWithUploadActionMultipleFiles(t *testing.T) { }). Return(nil) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) assert.Nil(t, err) } @@ -234,7 +234,7 @@ func TestPostUploadEvidenceWithUploadActionFilenameSpecialCharactersAreEscaped(t GetAll(r.Context()). Return(page.Documents{}, nil) documentStore.EXPECT(). - Create(r.Context(), &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}, "<img src=1 onerror=alert(document.domain)>’ brute.heic", mock.Anything). + Create(r.Context(), &donordata.Provided{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}, "<img src=1 onerror=alert(document.domain)>’ brute.heic", mock.Anything). Return(page.Document{ PK: dynamo.LpaKey("lpa-id"), SK: dynamo.DocumentKey("lpa-uid/evidence/a-uid"), @@ -261,7 +261,7 @@ func TestPostUploadEvidenceWithUploadActionFilenameSpecialCharactersAreEscaped(t }). Return(nil) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) assert.Nil(t, err) } @@ -272,7 +272,7 @@ func TestPostUploadEvidenceWithPayAction(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", &buf) r.Header.Set("Content-Type", contentType) - donor := &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload} + donor := &donordata.Provided{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload} documents := page.Documents{{ PK: dynamo.LpaKey("lpa-id"), @@ -324,10 +324,10 @@ func TestPostUploadEvidenceWithPayActionWhenPayerError(t *testing.T) { payer := newMockHandler(t) payer.EXPECT(). - Execute(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}). + Execute(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}). Return(expectedError) - err := UploadEvidence(nil, nil, payer.Execute, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) + err := UploadEvidence(nil, nil, payer.Execute, documentStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) assert.Equal(t, expectedError, err) } @@ -339,7 +339,7 @@ func TestPostUploadEvidenceWithPayActionWhenDocumentStoreSubmitErrors(t *testing r, _ := http.NewRequest(http.MethodPost, "/", &buf) r.Header.Set("Content-Type", contentType) - donor := &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload} + donor := &donordata.Provided{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload} documentStore := newMockDocumentStore(t) documentStore.EXPECT(). @@ -366,7 +366,7 @@ func TestPostUploadEvidenceWithPayActionWhenUnscannedDocument(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", &buf) r.Header.Set("Content-Type", contentType) - donor := &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload} + donor := &donordata.Provided{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload} documentStore := newMockDocumentStore(t) documentStore.EXPECT(). @@ -440,7 +440,7 @@ func TestPostUploadEvidenceWithScanResultsActionWithInfectedFiles(t *testing.T) }). Return(nil) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) assert.Nil(t, err) } @@ -469,7 +469,7 @@ func TestPostUploadEvidenceWithScanResultsActionWithoutInfectedFiles(t *testing. }). Return(nil) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) assert.Nil(t, err) } @@ -490,7 +490,7 @@ func TestPostUploadEvidenceWithPayActionWithInfectedFilesWhenDocumentStoreGetAll {Filename: "d", VirusDetected: true}, }, expectedError) - err := UploadEvidence(nil, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) + err := UploadEvidence(nil, nil, nil, documentStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) assert.Equal(t, expectedError, err) } @@ -519,7 +519,7 @@ func TestPostUploadEvidenceWithScanResultsActionWithInfectedFilesWhenDocumentSto }). Return(expectedError) - err := UploadEvidence(nil, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) + err := UploadEvidence(nil, nil, nil, documentStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) assert.Equal(t, expectedError, err) } @@ -555,7 +555,7 @@ func TestPostUploadEvidenceWithScanResultsActionWithInfectedFilesWhenDocumentSto }, expectedError). Once() - err := UploadEvidence(nil, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) + err := UploadEvidence(nil, nil, nil, documentStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) assert.Equal(t, expectedError, err) } @@ -603,7 +603,7 @@ func TestPostUploadEvidenceWithScanResultsActionWithInfectedFilesWhenTemplateErr }). Return(expectedError) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) assert.Equal(t, expectedError, err) } @@ -638,7 +638,7 @@ func TestPostUploadEvidenceWhenBadCsrfField(t *testing.T) { }). Return(nil) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", FeeType: pay.FullFee}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", FeeType: pay.FullFee}) resp := w.Result() assert.Nil(t, err) @@ -678,7 +678,7 @@ func TestPostUploadEvidenceWhenBadActionField(t *testing.T) { }). Return(nil) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", FeeType: pay.FullFee}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", FeeType: pay.FullFee}) resp := w.Result() assert.Nil(t, err) @@ -726,7 +726,7 @@ func TestPostUploadEvidenceNumberOfFilesLimitPassed(t *testing.T) { }). Return(nil) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaUID: "lpa-uid", FeeType: pay.FullFee}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.Provided{LpaUID: "lpa-uid", FeeType: pay.FullFee}) assert.Nil(t, err) } @@ -811,7 +811,7 @@ func TestPostUploadEvidenceWhenBadUpload(t *testing.T) { }). Return(nil) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", FeeType: pay.FullFee}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", FeeType: pay.FullFee}) resp := w.Result() assert.Nil(t, err) @@ -864,7 +864,7 @@ func TestGetUploadEvidenceDeleteEvidence(t *testing.T) { }). Return(nil) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.Provided{}) assert.Nil(t, err) } @@ -909,7 +909,7 @@ func TestGetUploadEvidenceDeleteEvidenceWhenUnexpectedFieldName(t *testing.T) { }). Return(nil) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.Provided{}) assert.Nil(t, err) } @@ -944,7 +944,7 @@ func TestGetUploadEvidenceDeleteEvidenceWhenDocumentStoreDeleteError(t *testing. Delete(r.Context(), page.Document{Key: "lpa-uid/evidence/a-uid", Filename: "dummy.pdf"}). Return(expectedError) - err := UploadEvidence(nil, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := UploadEvidence(nil, nil, nil, documentStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -992,7 +992,7 @@ func TestGetUploadEvidenceDeleteEvidenceWhenTemplateError(t *testing.T) { }). Return(expectedError) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -1037,7 +1037,7 @@ func TestPostUploadEvidenceWithCloseConnectionAction(t *testing.T) { }). Return(nil) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaUID: "lpa-uid", FeeType: pay.HalfFee}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.Provided{LpaUID: "lpa-uid", FeeType: pay.HalfFee}) resp := w.Result() @@ -1072,7 +1072,7 @@ func TestPostUploadEvidenceWithCloseConnectionActionWhenDocumentStoreDeleteError Delete(r.Context(), page.Document{Key: "lpa-uid/evidence/another-uid", Filename: "dummy.png", Scanned: false}). Return(expectedError) - err := UploadEvidence(nil, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaUID: "lpa-uid", FeeType: pay.HalfFee}) + err := UploadEvidence(nil, nil, nil, documentStore)(testAppData, w, r, &donordata.Provided{LpaUID: "lpa-uid", FeeType: pay.HalfFee}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -1120,7 +1120,7 @@ func TestPostUploadEvidenceWithCloseConnectionActionWhenTemplateError(t *testing }). Return(expectedError) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaUID: "lpa-uid", FeeType: pay.HalfFee}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.Provided{LpaUID: "lpa-uid", FeeType: pay.HalfFee}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -1167,7 +1167,7 @@ func TestPostUploadEvidenceWithCancelUploadAction(t *testing.T) { }). Return(nil) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaUID: "lpa-uid", FeeType: pay.HalfFee}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.Provided{LpaUID: "lpa-uid", FeeType: pay.HalfFee}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/want_replacement_attorneys.go b/internal/donor/donorpage/want_replacement_attorneys.go index 51ed91b92e..67d980549f 100644 --- a/internal/donor/donorpage/want_replacement_attorneys.go +++ b/internal/donor/donorpage/want_replacement_attorneys.go @@ -16,11 +16,11 @@ type wantReplacementAttorneysData struct { App page.AppData Errors validation.List Form *form.YesNoForm - Donor *donordata.DonorProvidedDetails + Donor *donordata.Provided } func WantReplacementAttorneys(tmpl template.Template, donorStore DonorStore, newUID func() actoruid.UID) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &wantReplacementAttorneysData{ App: appData, Donor: donor, diff --git a/internal/donor/donorpage/want_replacement_attorneys_test.go b/internal/donor/donorpage/want_replacement_attorneys_test.go index 54fb3f541c..e008632780 100644 --- a/internal/donor/donorpage/want_replacement_attorneys_test.go +++ b/internal/donor/donorpage/want_replacement_attorneys_test.go @@ -7,11 +7,11 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -25,12 +25,12 @@ func TestGetWantReplacementAttorneys(t *testing.T) { template.EXPECT(). Execute(w, &wantReplacementAttorneysData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{}, + Donor: &donordata.Provided{}, Form: form.NewYesNoForm(form.YesNoUnknown), }). Return(nil) - err := WantReplacementAttorneys(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := WantReplacementAttorneys(template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -43,7 +43,7 @@ func TestGetWantReplacementAttorneysWithExistingReplacementAttorneys(t *testing. template := newMockTemplate(t) - err := WantReplacementAttorneys(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{FirstNames: "this"}}}}) + err := WantReplacementAttorneys(template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{FirstNames: "this"}}}}) resp := w.Result() assert.Nil(t, err) @@ -59,12 +59,12 @@ func TestGetWantReplacementAttorneysFromStore(t *testing.T) { template.EXPECT(). Execute(w, &wantReplacementAttorneysData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{WantReplacementAttorneys: form.Yes}, + Donor: &donordata.Provided{WantReplacementAttorneys: form.Yes}, Form: form.NewYesNoForm(form.Yes), }). Return(nil) - err := WantReplacementAttorneys(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{WantReplacementAttorneys: form.Yes}) + err := WantReplacementAttorneys(template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{WantReplacementAttorneys: form.Yes}) resp := w.Result() assert.Nil(t, err) @@ -80,7 +80,7 @@ func TestGetWantReplacementAttorneysWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := WantReplacementAttorneys(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := WantReplacementAttorneys(template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -94,14 +94,14 @@ func TestPostWantReplacementAttorneys(t *testing.T) { yesNo form.YesNo existingReplacementAttorneys donordata.Attorneys expectedReplacementAttorneys donordata.Attorneys - taskState actor.TaskState + taskState task.State redirect string }{ "yes": { yesNo: form.Yes, existingReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, expectedReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, - taskState: actor.TaskInProgress, + taskState: task.StateInProgress, redirect: page.Paths.ChooseReplacementAttorneys.Format("lpa-id") + "?id=" + testUID.String(), }, "no": { @@ -111,7 +111,7 @@ func TestPostWantReplacementAttorneys(t *testing.T) { {UID: actoruid.New()}, }}, expectedReplacementAttorneys: donordata.Attorneys{}, - taskState: actor.TaskCompleted, + taskState: task.StateCompleted, redirect: page.Paths.TaskList.Format("lpa-id"), }, } @@ -128,18 +128,18 @@ func TestPostWantReplacementAttorneys(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", WantReplacementAttorneys: tc.yesNo, ReplacementAttorneys: tc.expectedReplacementAttorneys, - Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, ChooseReplacementAttorneys: tc.taskState}, + Tasks: donordata.Tasks{YourDetails: task.StateCompleted, ChooseAttorneys: task.StateCompleted, ChooseReplacementAttorneys: tc.taskState}, }). Return(nil) - err := WantReplacementAttorneys(nil, donorStore, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := WantReplacementAttorneys(nil, donorStore, testUIDFn)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", ReplacementAttorneys: tc.existingReplacementAttorneys, - Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted}, + Tasks: donordata.Tasks{YourDetails: task.StateCompleted, ChooseAttorneys: task.StateCompleted}, }) resp := w.Result() @@ -164,7 +164,7 @@ func TestPostWantReplacementAttorneysWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := WantReplacementAttorneys(nil, donorStore, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := WantReplacementAttorneys(nil, donorStore, nil)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -181,7 +181,7 @@ func TestPostWantReplacementAttorneysWhenValidationErrors(t *testing.T) { })). Return(nil) - err := WantReplacementAttorneys(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := WantReplacementAttorneys(template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/what_is_vouching.go b/internal/donor/donorpage/what_is_vouching.go index 2e9b6f4124..259dfc47d7 100644 --- a/internal/donor/donorpage/what_is_vouching.go +++ b/internal/donor/donorpage/what_is_vouching.go @@ -17,7 +17,7 @@ type whatIsVouchingData struct { } func WhatIsVouching(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &whatIsVouchingData{ App: appData, Form: form.NewYesNoForm(donor.WantVoucher), diff --git a/internal/donor/donorpage/what_is_vouching_test.go b/internal/donor/donorpage/what_is_vouching_test.go index 43897f2d54..cb6c4b114f 100644 --- a/internal/donor/donorpage/what_is_vouching_test.go +++ b/internal/donor/donorpage/what_is_vouching_test.go @@ -30,7 +30,7 @@ func TestGetWhatIsVouching(t *testing.T) { }). Return(nil) - err := WhatIsVouching(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{WantVoucher: form.Yes}) + err := WhatIsVouching(template.Execute, nil)(testAppData, w, r, &donordata.Provided{WantVoucher: form.Yes}) assert.Nil(t, err) } @@ -44,7 +44,7 @@ func TestGetWhatIsVouchingWhenTemplateError(t *testing.T) { Execute(mock.Anything, mock.Anything). Return(expectedError) - err := WhatIsVouching(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := WhatIsVouching(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) assert.Error(t, err) } @@ -67,13 +67,13 @@ func TestPostWhatIsVouching(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", WantVoucher: yesNo, }). Return(nil) - err := WhatIsVouching(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) + err := WhatIsVouching(nil, donorStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id"}) resp := w.Result() assert.Nil(t, err) @@ -97,7 +97,7 @@ func TestPostWhatIsVouchingWhenDonorStoreError(t *testing.T) { Put(mock.Anything, mock.Anything). Return(expectedError) - err := WhatIsVouching(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) + err := WhatIsVouching(nil, donorStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id"}) resp := w.Result() assert.Error(t, err) diff --git a/internal/donor/donorpage/what_you_can_do_now.go b/internal/donor/donorpage/what_you_can_do_now.go index 5988c3e447..400578fe4f 100644 --- a/internal/donor/donorpage/what_you_can_do_now.go +++ b/internal/donor/donorpage/what_you_can_do_now.go @@ -19,7 +19,7 @@ type whatYouCanDoNowData struct { } func WhatYouCanDoNow(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &whatYouCanDoNowData{ App: appData, Form: &whatYouCanDoNowForm{ diff --git a/internal/donor/donorpage/what_you_can_do_now_test.go b/internal/donor/donorpage/what_you_can_do_now_test.go index cae748ac69..1a620a70c7 100644 --- a/internal/donor/donorpage/what_you_can_do_now_test.go +++ b/internal/donor/donorpage/what_you_can_do_now_test.go @@ -31,7 +31,7 @@ func TestGetWhatYouCanDoNow(t *testing.T) { }). Return(nil) - err := WhatYouCanDoNow(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := WhatYouCanDoNow(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) assert.Nil(t, err) } @@ -45,7 +45,7 @@ func TestGetWhatYouCanDoNowWhenTemplateError(t *testing.T) { Execute(mock.Anything, mock.Anything). Return(expectedError) - err := WhatYouCanDoNow(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := WhatYouCanDoNow(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) assert.Error(t, err) } @@ -53,18 +53,18 @@ func TestGetWhatYouCanDoNowWhenTemplateError(t *testing.T) { func TestPostWhatYouCanDoNow(t *testing.T) { testcases := map[actor.NoVoucherDecision]struct { expectedPath string - expectedDonor *donordata.DonorProvidedDetails + expectedDonor *donordata.Provided }{ actor.ProveOwnID: { expectedPath: page.Paths.TaskList.Format("lpa-id"), - expectedDonor: &donordata.DonorProvidedDetails{ + expectedDonor: &donordata.Provided{ LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{}, }, }, actor.SelectNewVoucher: { expectedPath: page.Paths.EnterVoucher.Format("lpa-id"), - expectedDonor: &donordata.DonorProvidedDetails{ + expectedDonor: &donordata.Provided{ LpaID: "lpa-id", WantVoucher: form.Yes, DonorIdentityUserData: identity.UserData{Status: identity.StatusInsufficientEvidence}, @@ -72,14 +72,14 @@ func TestPostWhatYouCanDoNow(t *testing.T) { }, actor.WithdrawLPA: { expectedPath: page.Paths.WithdrawThisLpa.Format("lpa-id"), - expectedDonor: &donordata.DonorProvidedDetails{ + expectedDonor: &donordata.Provided{ LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusInsufficientEvidence}, }, }, actor.ApplyToCOP: { expectedPath: page.Paths.WhatHappensNextRegisteringWithCourtOfProtection.Format("lpa-id"), - expectedDonor: &donordata.DonorProvidedDetails{ + expectedDonor: &donordata.Provided{ LpaID: "lpa-id", RegisteringWithCourtOfProtection: true, DonorIdentityUserData: identity.UserData{Status: identity.StatusInsufficientEvidence}, @@ -102,7 +102,7 @@ func TestPostWhatYouCanDoNow(t *testing.T) { Put(r.Context(), tc.expectedDonor). Return(nil) - err := WhatYouCanDoNow(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusInsufficientEvidence}}) + err := WhatYouCanDoNow(nil, donorStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusInsufficientEvidence}}) resp := w.Result() assert.Nil(t, err) @@ -126,7 +126,7 @@ func TestPostWhatYouCanDoNowWhenDonorStoreError(t *testing.T) { Put(mock.Anything, mock.Anything). Return(expectedError) - err := WhatYouCanDoNow(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) + err := WhatYouCanDoNow(nil, donorStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id"}) resp := w.Result() assert.Error(t, err) @@ -149,7 +149,7 @@ func TestPostWhatYouCanDoNowWhenValidationErrors(t *testing.T) { })). Return(nil) - err := WhatYouCanDoNow(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) + err := WhatYouCanDoNow(template.Execute, nil)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id"}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/when_can_the_lpa_be_used.go b/internal/donor/donorpage/when_can_the_lpa_be_used.go index b6598888a8..b48213e7dc 100644 --- a/internal/donor/donorpage/when_can_the_lpa_be_used.go +++ b/internal/donor/donorpage/when_can_the_lpa_be_used.go @@ -4,22 +4,22 @@ import ( "net/http" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) type whenCanTheLpaBeUsedData struct { App page.AppData Errors validation.List - Donor *donordata.DonorProvidedDetails + Donor *donordata.Provided Form *whenCanTheLpaBeUsedForm Options donordata.CanBeUsedWhenOptions } func WhenCanTheLpaBeUsed(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &whenCanTheLpaBeUsedData{ App: appData, Donor: donor, @@ -35,7 +35,7 @@ func WhenCanTheLpaBeUsed(tmpl template.Template, donorStore DonorStore) Handler if data.Errors.None() { donor.WhenCanTheLpaBeUsed = data.Form.When - donor.Tasks.WhenCanTheLpaBeUsed = actor.TaskCompleted + donor.Tasks.WhenCanTheLpaBeUsed = task.StateCompleted if err := donorStore.Put(r.Context(), donor); err != nil { return err } diff --git a/internal/donor/donorpage/when_can_the_lpa_be_used_test.go b/internal/donor/donorpage/when_can_the_lpa_be_used_test.go index b88d0b2b2d..2034735139 100644 --- a/internal/donor/donorpage/when_can_the_lpa_be_used_test.go +++ b/internal/donor/donorpage/when_can_the_lpa_be_used_test.go @@ -7,9 +7,9 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -23,13 +23,13 @@ func TestGetWhenCanTheLpaBeUsed(t *testing.T) { template.EXPECT(). Execute(w, &whenCanTheLpaBeUsedData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{}, + Donor: &donordata.Provided{}, Form: &whenCanTheLpaBeUsedForm{}, Options: donordata.CanBeUsedWhenValues, }). Return(nil) - err := WhenCanTheLpaBeUsed(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := WhenCanTheLpaBeUsed(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -44,7 +44,7 @@ func TestGetWhenCanTheLpaBeUsedFromStore(t *testing.T) { template.EXPECT(). Execute(w, &whenCanTheLpaBeUsedData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{WhenCanTheLpaBeUsed: donordata.CanBeUsedWhenHasCapacity}, + Donor: &donordata.Provided{WhenCanTheLpaBeUsed: donordata.CanBeUsedWhenHasCapacity}, Form: &whenCanTheLpaBeUsedForm{ When: donordata.CanBeUsedWhenHasCapacity, }, @@ -52,7 +52,7 @@ func TestGetWhenCanTheLpaBeUsedFromStore(t *testing.T) { }). Return(nil) - err := WhenCanTheLpaBeUsed(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{WhenCanTheLpaBeUsed: donordata.CanBeUsedWhenHasCapacity}) + err := WhenCanTheLpaBeUsed(template.Execute, nil)(testAppData, w, r, &donordata.Provided{WhenCanTheLpaBeUsed: donordata.CanBeUsedWhenHasCapacity}) resp := w.Result() assert.Nil(t, err) @@ -68,7 +68,7 @@ func TestGetWhenCanTheLpaBeUsedWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := WhenCanTheLpaBeUsed(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := WhenCanTheLpaBeUsed(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -86,16 +86,16 @@ func TestPostWhenCanTheLpaBeUsed(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", WhenCanTheLpaBeUsed: donordata.CanBeUsedWhenHasCapacity, - Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, WhenCanTheLpaBeUsed: actor.TaskCompleted}, + Tasks: donordata.Tasks{YourDetails: task.StateCompleted, ChooseAttorneys: task.StateCompleted, WhenCanTheLpaBeUsed: task.StateCompleted}, }). Return(nil) - err := WhenCanTheLpaBeUsed(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := WhenCanTheLpaBeUsed(nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", - Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted}, + Tasks: donordata.Tasks{YourDetails: task.StateCompleted, ChooseAttorneys: task.StateCompleted}, }) resp := w.Result() @@ -115,10 +115,10 @@ func TestPostWhenCanTheLpaBeUsedWhenStoreErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{WhenCanTheLpaBeUsed: donordata.CanBeUsedWhenHasCapacity, Tasks: donordata.DonorTasks{WhenCanTheLpaBeUsed: actor.TaskCompleted}}). + Put(r.Context(), &donordata.Provided{WhenCanTheLpaBeUsed: donordata.CanBeUsedWhenHasCapacity, Tasks: donordata.Tasks{WhenCanTheLpaBeUsed: task.StateCompleted}}). Return(expectedError) - err := WhenCanTheLpaBeUsed(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := WhenCanTheLpaBeUsed(nil, donorStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -135,7 +135,7 @@ func TestPostWhenCanTheLpaBeUsedWhenValidationErrors(t *testing.T) { })). Return(nil) - err := WhenCanTheLpaBeUsed(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := WhenCanTheLpaBeUsed(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/which_fee_type_are_you_applying_for.go b/internal/donor/donorpage/which_fee_type_are_you_applying_for.go index 3555662c6a..6b71ea1c97 100644 --- a/internal/donor/donorpage/which_fee_type_are_you_applying_for.go +++ b/internal/donor/donorpage/which_fee_type_are_you_applying_for.go @@ -18,7 +18,7 @@ type whichFeeTypeAreYouApplyingForData struct { } func WhichFeeTypeAreYouApplyingFor(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &whichFeeTypeAreYouApplyingForData{ App: appData, Form: &whichFeeTypeAreYouApplyingForForm{ diff --git a/internal/donor/donorpage/which_fee_type_are_you_applying_for_test.go b/internal/donor/donorpage/which_fee_type_are_you_applying_for_test.go index 42b3997c36..93b8300b35 100644 --- a/internal/donor/donorpage/which_fee_type_are_you_applying_for_test.go +++ b/internal/donor/donorpage/which_fee_type_are_you_applying_for_test.go @@ -28,7 +28,7 @@ func TestGetWhichFeeTypeAreYouApplyingFor(t *testing.T) { }). Return(nil) - err := WhichFeeTypeAreYouApplyingFor(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := WhichFeeTypeAreYouApplyingFor(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -48,7 +48,7 @@ func TestGetWhichFeeTypeAreYouApplyingForWithLpaData(t *testing.T) { }). Return(nil) - err := WhichFeeTypeAreYouApplyingFor(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{FeeType: pay.HalfFee}) + err := WhichFeeTypeAreYouApplyingFor(template.Execute, nil)(testAppData, w, r, &donordata.Provided{FeeType: pay.HalfFee}) resp := w.Result() assert.Nil(t, err) @@ -68,7 +68,7 @@ func TestGetWhichFeeTypeAreYouApplyingForOnTemplateError(t *testing.T) { }). Return(expectedError) - err := WhichFeeTypeAreYouApplyingFor(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := WhichFeeTypeAreYouApplyingFor(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -95,10 +95,10 @@ func TestPostWhichFeeTypeAreYouApplyingFor(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{LpaID: "lpa-id", FeeType: feeType}). + Put(r.Context(), &donordata.Provided{LpaID: "lpa-id", FeeType: feeType}). Return(nil) - err := WhichFeeTypeAreYouApplyingFor(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) + err := WhichFeeTypeAreYouApplyingFor(nil, donorStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id"}) resp := w.Result() assert.Nil(t, err) @@ -119,10 +119,10 @@ func TestPostWhichFeeTypeAreYouApplyingForOnStoreError(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{LpaID: "lpa-id", FeeType: pay.HalfFee}). + Put(r.Context(), &donordata.Provided{LpaID: "lpa-id", FeeType: pay.HalfFee}). Return(expectedError) - err := WhichFeeTypeAreYouApplyingFor(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) + err := WhichFeeTypeAreYouApplyingFor(nil, donorStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id"}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -147,7 +147,7 @@ func TestPostWhichFeeTypeAreYouApplyingForOnInvalidForm(t *testing.T) { })). Return(nil) - err := WhichFeeTypeAreYouApplyingFor(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) + err := WhichFeeTypeAreYouApplyingFor(template.Execute, nil)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id"}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/withdraw_lpa.go b/internal/donor/donorpage/withdraw_lpa.go index 875b43f682..d45708fcfc 100644 --- a/internal/donor/donorpage/withdraw_lpa.go +++ b/internal/donor/donorpage/withdraw_lpa.go @@ -14,11 +14,11 @@ import ( type withdrawLpaData struct { App page.AppData Errors validation.List - Donor *donordata.DonorProvidedDetails + Donor *donordata.Provided } func WithdrawLpa(tmpl template.Template, donorStore DonorStore, now func() time.Time) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { if r.Method == http.MethodPost { donor.WithdrawnAt = now() if err := donorStore.Put(r.Context(), donor); err != nil { diff --git a/internal/donor/donorpage/withdraw_lpa_test.go b/internal/donor/donorpage/withdraw_lpa_test.go index 7e4328754b..62acdbe4a4 100644 --- a/internal/donor/donorpage/withdraw_lpa_test.go +++ b/internal/donor/donorpage/withdraw_lpa_test.go @@ -21,11 +21,11 @@ func TestGetWithdrawLpa(t *testing.T) { template.EXPECT(). Execute(w, &withdrawLpaData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{}, + Donor: &donordata.Provided{}, }). Return(nil) - err := WithdrawLpa(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := WithdrawLpa(template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -41,7 +41,7 @@ func TestGetWithdrawLpaWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := WithdrawLpa(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := WithdrawLpa(template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -57,13 +57,13 @@ func TestPostWithdrawLpa(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaUID: "lpa-uid", WithdrawnAt: now, }). Return(nil) - err := WithdrawLpa(nil, donorStore, func() time.Time { return now })(testAppData, w, r, &donordata.DonorProvidedDetails{LpaUID: "lpa-uid"}) + err := WithdrawLpa(nil, donorStore, func() time.Time { return now })(testAppData, w, r, &donordata.Provided{LpaUID: "lpa-uid"}) resp := w.Result() assert.Nil(t, err) @@ -81,6 +81,6 @@ func TestPostWithdrawLpaWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := WithdrawLpa(nil, donorStore, time.Now)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaUID: "lpa-uid"}) + err := WithdrawLpa(nil, donorStore, time.Now)(testAppData, w, r, &donordata.Provided{LpaUID: "lpa-uid"}) assert.Equal(t, expectedError, err) } diff --git a/internal/donor/donorpage/witnessing_as_certificate_provider.go b/internal/donor/donorpage/witnessing_as_certificate_provider.go index 657c54fb06..00009364f3 100644 --- a/internal/donor/donorpage/witnessing_as_certificate_provider.go +++ b/internal/donor/donorpage/witnessing_as_certificate_provider.go @@ -5,9 +5,9 @@ import ( "time" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -15,7 +15,7 @@ type witnessingAsCertificateProviderData struct { App page.AppData Errors validation.List Form *witnessingAsCertificateProviderForm - Donor *donordata.DonorProvidedDetails + Donor *donordata.Provided } func WitnessingAsCertificateProvider( @@ -25,7 +25,7 @@ func WitnessingAsCertificateProvider( lpaStoreClient LpaStoreClient, now func() time.Time, ) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &witnessingAsCertificateProviderData{ App: appData, Donor: donor, @@ -52,9 +52,9 @@ func WitnessingAsCertificateProvider( } if data.Errors.None() { - donor.Tasks.ConfirmYourIdentityAndSign = actor.IdentityTaskCompleted + donor.Tasks.ConfirmYourIdentityAndSign = task.IdentityStateCompleted if donor.RegisteringWithCourtOfProtection { - donor.Tasks.ConfirmYourIdentityAndSign = actor.IdentityTaskPending + donor.Tasks.ConfirmYourIdentityAndSign = task.IdentityStatePending } donor.WitnessCodeLimiter = nil diff --git a/internal/donor/donorpage/witnessing_as_certificate_provider_test.go b/internal/donor/donorpage/witnessing_as_certificate_provider_test.go index e7340b38e4..4226bee49a 100644 --- a/internal/donor/donorpage/witnessing_as_certificate_provider_test.go +++ b/internal/donor/donorpage/witnessing_as_certificate_provider_test.go @@ -8,7 +8,6 @@ import ( "testing" "time" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/identity" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" @@ -26,12 +25,12 @@ func TestGetWitnessingAsCertificateProvider(t *testing.T) { template.EXPECT(). Execute(w, &witnessingAsCertificateProviderData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{}, + Donor: &donordata.Provided{}, Form: &witnessingAsCertificateProviderForm{}, }). Return(nil) - err := WitnessingAsCertificateProvider(template.Execute, nil, nil, nil, time.Now)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := WitnessingAsCertificateProvider(template.Execute, nil, nil, nil, time.Now)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -46,14 +45,14 @@ func TestGetWitnessingAsCertificateProviderFromStore(t *testing.T) { template.EXPECT(). Execute(w, &witnessingAsCertificateProviderData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{ + Donor: &donordata.Provided{ CertificateProvider: donordata.CertificateProvider{FirstNames: "Joan"}, }, Form: &witnessingAsCertificateProviderForm{}, }). Return(nil) - err := WitnessingAsCertificateProvider(template.Execute, nil, nil, nil, time.Now)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := WitnessingAsCertificateProvider(template.Execute, nil, nil, nil, time.Now)(testAppData, w, r, &donordata.Provided{ CertificateProvider: donordata.CertificateProvider{FirstNames: "Joan"}, }) resp := w.Result() @@ -70,12 +69,12 @@ func TestGetWitnessingAsCertificateProviderWhenTemplateErrors(t *testing.T) { template.EXPECT(). Execute(w, &witnessingAsCertificateProviderData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{}, + Donor: &donordata.Provided{}, Form: &witnessingAsCertificateProviderForm{}, }). Return(expectedError) - err := WitnessingAsCertificateProvider(template.Execute, nil, nil, nil, time.Now)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := WitnessingAsCertificateProvider(template.Execute, nil, nil, nil, time.Now)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -85,14 +84,14 @@ func TestGetWitnessingAsCertificateProviderWhenTemplateErrors(t *testing.T) { func TestPostWitnessingAsCertificateProvider(t *testing.T) { testcases := map[string]struct { registeringWithCOP bool - expectedIdentityAndSignTaskStatus actor.IdentityTask + expectedIdentityAndSignTaskStatus task.IdentityState }{ "registering with COP": { registeringWithCOP: true, - expectedIdentityAndSignTaskStatus: actor.IdentityTaskPending, + expectedIdentityAndSignTaskStatus: task.IdentityStatePending, }, "proved ID": { - expectedIdentityAndSignTaskStatus: actor.IdentityTaskCompleted, + expectedIdentityAndSignTaskStatus: task.IdentityStateCompleted, }, } @@ -107,13 +106,13 @@ func TestPostWitnessingAsCertificateProvider(t *testing.T) { r.Header.Add("Content-Type", page.FormUrlEncoded) now := time.Now() - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, CertificateProvider: donordata.CertificateProvider{FirstNames: "Fred"}, WitnessedByCertificateProviderAt: now, - Tasks: donordata.DonorTasks{ + Tasks: donordata.Tasks{ ConfirmYourIdentityAndSign: tc.expectedIdentityAndSignTaskStatus, PayForLpa: task.PaymentStateCompleted, }, @@ -135,12 +134,12 @@ func TestPostWitnessingAsCertificateProvider(t *testing.T) { SendLpa(r.Context(), donor). Return(nil) - err := WitnessingAsCertificateProvider(nil, donorStore, shareCodeSender, lpaStoreClient, func() time.Time { return now })(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := WitnessingAsCertificateProvider(nil, donorStore, shareCodeSender, lpaStoreClient, func() time.Time { return now })(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, CertificateProvider: donordata.CertificateProvider{FirstNames: "Fred"}, - Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateCompleted}, + Tasks: donordata.Tasks{PayForLpa: task.PaymentStateCompleted}, RegisteringWithCourtOfProtection: tc.registeringWithCOP, }) resp := w.Result() @@ -163,15 +162,15 @@ func TestPostWitnessingAsCertificateProviderWhenPaymentPending(t *testing.T) { r.Header.Add("Content-Type", page.FormUrlEncoded) now := time.Now() - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, CertificateProvider: donordata.CertificateProvider{Email: "name@example.com"}, CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, WitnessedByCertificateProviderAt: now, - Tasks: donordata.DonorTasks{ + Tasks: donordata.Tasks{ PayForLpa: task.PaymentStatePending, - ConfirmYourIdentityAndSign: actor.IdentityTaskCompleted, + ConfirmYourIdentityAndSign: task.IdentityStateCompleted, }, } donorStore := newMockDonorStore(t) @@ -179,12 +178,12 @@ func TestPostWitnessingAsCertificateProviderWhenPaymentPending(t *testing.T) { Put(r.Context(), donor). Return(nil) - err := WitnessingAsCertificateProvider(nil, donorStore, nil, nil, func() time.Time { return now })(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := WitnessingAsCertificateProvider(nil, donorStore, nil, nil, func() time.Time { return now })(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, CertificateProvider: donordata.CertificateProvider{Email: "name@example.com"}, CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, - Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}, + Tasks: donordata.Tasks{PayForLpa: task.PaymentStatePending}, }) resp := w.Result() @@ -218,12 +217,12 @@ func TestPostWitnessingAsCertificateProviderWhenSendLpaErrors(t *testing.T) { SendLpa(r.Context(), mock.Anything). Return(expectedError) - err := WitnessingAsCertificateProvider(nil, donorStore, shareCodeSender, lpaStoreClient, func() time.Time { return now })(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := WitnessingAsCertificateProvider(nil, donorStore, shareCodeSender, lpaStoreClient, func() time.Time { return now })(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, CertificateProvider: donordata.CertificateProvider{FirstNames: "Fred"}, - Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateCompleted}, + Tasks: donordata.Tasks{PayForLpa: task.PaymentStateCompleted}, }) assert.Equal(t, expectedError, err) } @@ -248,10 +247,10 @@ func TestPostWitnessingAsCertificateProviderWhenShareCodeSendToCertificateProvid SendCertificateProviderPrompt(r.Context(), testAppData, mock.Anything). Return(expectedError) - err := WitnessingAsCertificateProvider(nil, donorStore, shareCodeSender, nil, func() time.Time { return now })(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := WitnessingAsCertificateProvider(nil, donorStore, shareCodeSender, nil, func() time.Time { return now })(testAppData, w, r, &donordata.Provided{ CertificateProvider: donordata.CertificateProvider{Email: "name@example.com"}, CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, - Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateCompleted}, + Tasks: donordata.Tasks{PayForLpa: task.PaymentStateCompleted}, }) assert.Equal(t, expectedError, err) @@ -271,9 +270,9 @@ func TestPostWitnessingAsCertificateProviderCodeTooOld(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), mock.MatchedBy(func(donor *donordata.DonorProvidedDetails) bool { + Put(r.Context(), mock.MatchedBy(func(donor *donordata.Provided) bool { donor.WitnessCodeLimiter = nil - return assert.Equal(t, donor, &donordata.DonorProvidedDetails{ + return assert.Equal(t, donor, &donordata.Provided{ CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: invalidCreated}}, }) })). @@ -283,7 +282,7 @@ func TestPostWitnessingAsCertificateProviderCodeTooOld(t *testing.T) { template.EXPECT(). Execute(w, &witnessingAsCertificateProviderData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{ + Donor: &donordata.Provided{ CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: invalidCreated}}, }, Errors: validation.With("witness-code", validation.CustomError{Label: "witnessCodeExpired"}), @@ -291,7 +290,7 @@ func TestPostWitnessingAsCertificateProviderCodeTooOld(t *testing.T) { }). Return(nil) - err := WitnessingAsCertificateProvider(template.Execute, donorStore, nil, nil, time.Now)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := WitnessingAsCertificateProvider(template.Execute, donorStore, nil, nil, time.Now)(testAppData, w, r, &donordata.Provided{ CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: invalidCreated}}, }) resp := w.Result() @@ -313,9 +312,9 @@ func TestPostWitnessingAsCertificateProviderCodeDoesNotMatch(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), mock.MatchedBy(func(donor *donordata.DonorProvidedDetails) bool { + Put(r.Context(), mock.MatchedBy(func(donor *donordata.Provided) bool { donor.WitnessCodeLimiter = nil - return assert.Equal(t, donor, &donordata.DonorProvidedDetails{ + return assert.Equal(t, donor, &donordata.Provided{ CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, }) })). @@ -325,7 +324,7 @@ func TestPostWitnessingAsCertificateProviderCodeDoesNotMatch(t *testing.T) { template.EXPECT(). Execute(w, &witnessingAsCertificateProviderData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{ + Donor: &donordata.Provided{ CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, }, Errors: validation.With("witness-code", validation.CustomError{Label: "witnessCodeDoesNotMatch"}), @@ -333,7 +332,7 @@ func TestPostWitnessingAsCertificateProviderCodeDoesNotMatch(t *testing.T) { }). Return(nil) - err := WitnessingAsCertificateProvider(template.Execute, donorStore, nil, nil, time.Now)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := WitnessingAsCertificateProvider(template.Execute, donorStore, nil, nil, time.Now)(testAppData, w, r, &donordata.Provided{ CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, }) resp := w.Result() @@ -356,9 +355,9 @@ func TestPostWitnessingAsCertificateProviderWhenCodeExpired(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), mock.MatchedBy(func(donor *donordata.DonorProvidedDetails) bool { + Put(r.Context(), mock.MatchedBy(func(donor *donordata.Provided) bool { donor.WitnessCodeLimiter = nil - return assert.Equal(t, donor, &donordata.DonorProvidedDetails{ + return assert.Equal(t, donor, &donordata.Provided{ CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: invalidCreated}}, }) })). @@ -368,7 +367,7 @@ func TestPostWitnessingAsCertificateProviderWhenCodeExpired(t *testing.T) { template.EXPECT(). Execute(w, &witnessingAsCertificateProviderData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{ + Donor: &donordata.Provided{ CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: invalidCreated}}, }, Errors: validation.With("witness-code", validation.CustomError{Label: "witnessCodeExpired"}), @@ -376,7 +375,7 @@ func TestPostWitnessingAsCertificateProviderWhenCodeExpired(t *testing.T) { }). Return(nil) - err := WitnessingAsCertificateProvider(template.Execute, donorStore, nil, nil, time.Now)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := WitnessingAsCertificateProvider(template.Execute, donorStore, nil, nil, time.Now)(testAppData, w, r, &donordata.Provided{ CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: invalidCreated}}, }) resp := w.Result() @@ -398,9 +397,9 @@ func TestPostWitnessingAsCertificateProviderCodeLimitBreached(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), mock.MatchedBy(func(donor *donordata.DonorProvidedDetails) bool { + Put(r.Context(), mock.MatchedBy(func(donor *donordata.Provided) bool { donor.WitnessCodeLimiter = nil - return assert.Equal(t, donor, &donordata.DonorProvidedDetails{ + return assert.Equal(t, donor, &donordata.Provided{ CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, }) })). @@ -410,7 +409,7 @@ func TestPostWitnessingAsCertificateProviderCodeLimitBreached(t *testing.T) { template.EXPECT(). Execute(w, &witnessingAsCertificateProviderData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{ + Donor: &donordata.Provided{ CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, }, Errors: validation.With("witness-code", validation.CustomError{Label: "tooManyWitnessCodeAttempts"}), @@ -418,7 +417,7 @@ func TestPostWitnessingAsCertificateProviderCodeLimitBreached(t *testing.T) { }). Return(nil) - err := WitnessingAsCertificateProvider(template.Execute, donorStore, nil, nil, time.Now)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := WitnessingAsCertificateProvider(template.Execute, donorStore, nil, nil, time.Now)(testAppData, w, r, &donordata.Provided{ WitnessCodeLimiter: donordata.NewLimiter(time.Minute, 0, 10), CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, }) diff --git a/internal/donor/donorpage/witnessing_as_independent_witness.go b/internal/donor/donorpage/witnessing_as_independent_witness.go index 8e3bcf7a8b..9145f6508e 100644 --- a/internal/donor/donorpage/witnessing_as_independent_witness.go +++ b/internal/donor/donorpage/witnessing_as_independent_witness.go @@ -14,11 +14,11 @@ type witnessingAsIndependentWitnessData struct { App page.AppData Errors validation.List Form *witnessingAsIndependentWitnessForm - Donor *donordata.DonorProvidedDetails + Donor *donordata.Provided } func WitnessingAsIndependentWitness(tmpl template.Template, donorStore DonorStore, now func() time.Time) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &witnessingAsIndependentWitnessData{ App: appData, Donor: donor, diff --git a/internal/donor/donorpage/witnessing_as_independent_witness_test.go b/internal/donor/donorpage/witnessing_as_independent_witness_test.go index be77a95b14..8b329cd71e 100644 --- a/internal/donor/donorpage/witnessing_as_independent_witness_test.go +++ b/internal/donor/donorpage/witnessing_as_independent_witness_test.go @@ -24,12 +24,12 @@ func TestGetWitnessingAsIndependentWitness(t *testing.T) { template.EXPECT(). Execute(w, &witnessingAsIndependentWitnessData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{}, + Donor: &donordata.Provided{}, Form: &witnessingAsIndependentWitnessForm{}, }). Return(nil) - err := WitnessingAsIndependentWitness(template.Execute, nil, time.Now)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := WitnessingAsIndependentWitness(template.Execute, nil, time.Now)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -44,14 +44,14 @@ func TestGetWitnessingAsIndependentWitnessFromStore(t *testing.T) { template.EXPECT(). Execute(w, &witnessingAsIndependentWitnessData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{ + Donor: &donordata.Provided{ IndependentWitness: donordata.IndependentWitness{FirstNames: "Joan"}, }, Form: &witnessingAsIndependentWitnessForm{}, }). Return(nil) - err := WitnessingAsIndependentWitness(template.Execute, nil, time.Now)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := WitnessingAsIndependentWitness(template.Execute, nil, time.Now)(testAppData, w, r, &donordata.Provided{ IndependentWitness: donordata.IndependentWitness{FirstNames: "Joan"}, }) resp := w.Result() @@ -68,12 +68,12 @@ func TestGetWitnessingAsIndependentWitnessWhenTemplateErrors(t *testing.T) { template.EXPECT(). Execute(w, &witnessingAsIndependentWitnessData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{}, + Donor: &donordata.Provided{}, Form: &witnessingAsIndependentWitnessForm{}, }). Return(expectedError) - err := WitnessingAsIndependentWitness(template.Execute, nil, time.Now)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := WitnessingAsIndependentWitness(template.Execute, nil, time.Now)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -92,7 +92,7 @@ func TestPostWitnessingAsIndependentWitness(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, IndependentWitnessCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, @@ -100,7 +100,7 @@ func TestPostWitnessingAsIndependentWitness(t *testing.T) { }). Return(nil) - err := WitnessingAsIndependentWitness(nil, donorStore, func() time.Time { return now })(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := WitnessingAsIndependentWitness(nil, donorStore, func() time.Time { return now })(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, IndependentWitnessCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, @@ -127,7 +127,7 @@ func TestPostWitnessingAsIndependentWitnessWhenDonorStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := WitnessingAsIndependentWitness(nil, donorStore, func() time.Time { return now })(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := WitnessingAsIndependentWitness(nil, donorStore, func() time.Time { return now })(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, IndependentWitnessCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, @@ -149,9 +149,9 @@ func TestPostWitnessingAsIndependentWitnessCodeTooOld(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), mock.MatchedBy(func(donor *donordata.DonorProvidedDetails) bool { + Put(r.Context(), mock.MatchedBy(func(donor *donordata.Provided) bool { donor.WitnessCodeLimiter = nil - return assert.Equal(t, donor, &donordata.DonorProvidedDetails{ + return assert.Equal(t, donor, &donordata.Provided{ IndependentWitnessCodes: donordata.WitnessCodes{{Code: "1234", Created: invalidCreated}}, }) })). @@ -161,7 +161,7 @@ func TestPostWitnessingAsIndependentWitnessCodeTooOld(t *testing.T) { template.EXPECT(). Execute(w, &witnessingAsIndependentWitnessData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{ + Donor: &donordata.Provided{ IndependentWitnessCodes: donordata.WitnessCodes{{Code: "1234", Created: invalidCreated}}, }, Errors: validation.With("witness-code", validation.CustomError{Label: "witnessCodeExpired"}), @@ -169,7 +169,7 @@ func TestPostWitnessingAsIndependentWitnessCodeTooOld(t *testing.T) { }). Return(nil) - err := WitnessingAsIndependentWitness(template.Execute, donorStore, time.Now)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := WitnessingAsIndependentWitness(template.Execute, donorStore, time.Now)(testAppData, w, r, &donordata.Provided{ IndependentWitnessCodes: donordata.WitnessCodes{{Code: "1234", Created: invalidCreated}}, }) resp := w.Result() @@ -191,9 +191,9 @@ func TestPostWitnessingAsIndependentWitnessCodeDoesNotMatch(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), mock.MatchedBy(func(donor *donordata.DonorProvidedDetails) bool { + Put(r.Context(), mock.MatchedBy(func(donor *donordata.Provided) bool { donor.WitnessCodeLimiter = nil - return assert.Equal(t, donor, &donordata.DonorProvidedDetails{ + return assert.Equal(t, donor, &donordata.Provided{ IndependentWitnessCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, }) })). @@ -203,7 +203,7 @@ func TestPostWitnessingAsIndependentWitnessCodeDoesNotMatch(t *testing.T) { template.EXPECT(). Execute(w, &witnessingAsIndependentWitnessData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{ + Donor: &donordata.Provided{ IndependentWitnessCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, }, Errors: validation.With("witness-code", validation.CustomError{Label: "witnessCodeDoesNotMatch"}), @@ -211,7 +211,7 @@ func TestPostWitnessingAsIndependentWitnessCodeDoesNotMatch(t *testing.T) { }). Return(nil) - err := WitnessingAsIndependentWitness(template.Execute, donorStore, time.Now)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := WitnessingAsIndependentWitness(template.Execute, donorStore, time.Now)(testAppData, w, r, &donordata.Provided{ IndependentWitnessCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, }) resp := w.Result() @@ -234,9 +234,9 @@ func TestPostWitnessingAsIndependentWitnessWhenCodeExpired(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), mock.MatchedBy(func(donor *donordata.DonorProvidedDetails) bool { + Put(r.Context(), mock.MatchedBy(func(donor *donordata.Provided) bool { donor.WitnessCodeLimiter = nil - return assert.Equal(t, donor, &donordata.DonorProvidedDetails{ + return assert.Equal(t, donor, &donordata.Provided{ IndependentWitnessCodes: donordata.WitnessCodes{{Code: "1234", Created: invalidCreated}}, }) })). @@ -246,7 +246,7 @@ func TestPostWitnessingAsIndependentWitnessWhenCodeExpired(t *testing.T) { template.EXPECT(). Execute(w, &witnessingAsIndependentWitnessData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{ + Donor: &donordata.Provided{ IndependentWitnessCodes: donordata.WitnessCodes{{Code: "1234", Created: invalidCreated}}, }, Errors: validation.With("witness-code", validation.CustomError{Label: "witnessCodeExpired"}), @@ -254,7 +254,7 @@ func TestPostWitnessingAsIndependentWitnessWhenCodeExpired(t *testing.T) { }). Return(nil) - err := WitnessingAsIndependentWitness(template.Execute, donorStore, time.Now)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := WitnessingAsIndependentWitness(template.Execute, donorStore, time.Now)(testAppData, w, r, &donordata.Provided{ IndependentWitnessCodes: donordata.WitnessCodes{{Code: "1234", Created: invalidCreated}}, }) resp := w.Result() @@ -276,9 +276,9 @@ func TestPostWitnessingAsIndependentWitnessCodeLimitBreached(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), mock.MatchedBy(func(donor *donordata.DonorProvidedDetails) bool { + Put(r.Context(), mock.MatchedBy(func(donor *donordata.Provided) bool { donor.WitnessCodeLimiter = nil - return assert.Equal(t, donor, &donordata.DonorProvidedDetails{ + return assert.Equal(t, donor, &donordata.Provided{ IndependentWitnessCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, }) })). @@ -288,7 +288,7 @@ func TestPostWitnessingAsIndependentWitnessCodeLimitBreached(t *testing.T) { template.EXPECT(). Execute(w, &witnessingAsIndependentWitnessData{ App: testAppData, - Donor: &donordata.DonorProvidedDetails{ + Donor: &donordata.Provided{ IndependentWitnessCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, }, Errors: validation.With("witness-code", validation.CustomError{Label: "tooManyWitnessCodeAttempts"}), @@ -296,7 +296,7 @@ func TestPostWitnessingAsIndependentWitnessCodeLimitBreached(t *testing.T) { }). Return(nil) - err := WitnessingAsIndependentWitness(template.Execute, donorStore, time.Now)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := WitnessingAsIndependentWitness(template.Execute, donorStore, time.Now)(testAppData, w, r, &donordata.Provided{ WitnessCodeLimiter: donordata.NewLimiter(time.Minute, 0, 10), IndependentWitnessCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, }) diff --git a/internal/donor/donorpage/witnessing_your_signature.go b/internal/donor/donorpage/witnessing_your_signature.go index a9f11b6c7d..75fbcd53af 100644 --- a/internal/donor/donorpage/witnessing_your_signature.go +++ b/internal/donor/donorpage/witnessing_your_signature.go @@ -12,11 +12,11 @@ import ( type witnessingYourSignatureData struct { App page.AppData Errors validation.List - Donor *donordata.DonorProvidedDetails + Donor *donordata.Provided } func WitnessingYourSignature(tmpl template.Template, witnessCodeSender WitnessCodeSender, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { if r.Method == http.MethodPost { if err := witnessCodeSender.SendToCertificateProvider(r.Context(), donor, appData.Localizer); err != nil { return err diff --git a/internal/donor/donorpage/witnessing_your_signature_test.go b/internal/donor/donorpage/witnessing_your_signature_test.go index df0d015833..4f5826c42c 100644 --- a/internal/donor/donorpage/witnessing_your_signature_test.go +++ b/internal/donor/donorpage/witnessing_your_signature_test.go @@ -20,7 +20,7 @@ func TestGetWitnessingYourSignature(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &donordata.DonorProvidedDetails{CertificateProvider: donordata.CertificateProvider{Mobile: "07535111111"}} + donor := &donordata.Provided{CertificateProvider: donordata.CertificateProvider{Mobile: "07535111111"}} template := newMockTemplate(t) template.EXPECT(). @@ -38,7 +38,7 @@ func TestGetWitnessingYourSignatureWhenTemplateErrors(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &donordata.DonorProvidedDetails{CertificateProvider: donordata.CertificateProvider{Mobile: "07535111111"}} + donor := &donordata.Provided{CertificateProvider: donordata.CertificateProvider{Mobile: "07535111111"}} template := newMockTemplate(t) template.EXPECT(). @@ -54,7 +54,7 @@ func TestPostWitnessingYourSignature(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodPost, "/", nil) - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{CanSign: form.Yes}, DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, @@ -78,7 +78,7 @@ func TestPostWitnessingYourSignatureCannotSign(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodPost, "/", nil) - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{CanSign: form.No}, DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, @@ -90,7 +90,7 @@ func TestPostWitnessingYourSignatureCannotSign(t *testing.T) { SendToCertificateProvider(r.Context(), donor, mock.Anything). Return(nil) witnessCodeSender.EXPECT(). - SendToIndependentWitness(r.Context(), &donordata.DonorProvidedDetails{ + SendToIndependentWitness(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{CanSign: form.No}, DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, @@ -101,7 +101,7 @@ func TestPostWitnessingYourSignatureCannotSign(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(r.Context()). - Return(&donordata.DonorProvidedDetails{ + Return(&donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{CanSign: form.No}, DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, @@ -117,7 +117,7 @@ func TestPostWitnessingYourSignatureCannotSign(t *testing.T) { } func TestPostWitnessingYourSignatureWhenWitnessCodeSenderErrors(t *testing.T) { - donor := &donordata.DonorProvidedDetails{Donor: donordata.Donor{CanSign: form.No}, CertificateProvider: donordata.CertificateProvider{Mobile: "07535111111"}} + donor := &donordata.Provided{Donor: donordata.Donor{CanSign: form.No}, CertificateProvider: donordata.CertificateProvider{Mobile: "07535111111"}} testcases := map[string]struct { setupWitnessCodeSender func(witnessCodeSender *mockWitnessCodeSender) diff --git a/internal/donor/donorpage/you_cannot_sign_your_lpa_yet.go b/internal/donor/donorpage/you_cannot_sign_your_lpa_yet.go index 518b7cd900..d6a13876ba 100644 --- a/internal/donor/donorpage/you_cannot_sign_your_lpa_yet.go +++ b/internal/donor/donorpage/you_cannot_sign_your_lpa_yet.go @@ -9,7 +9,7 @@ import ( ) func YouCannotSignYourLpaYet(tmpl template.Template) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { if len(donor.Under18ActorDetails()) == 0 { return appData.Redirect(w, r, page.Paths.TaskList.Format(donor.LpaID)) } diff --git a/internal/donor/donorpage/you_cannot_sign_your_lpa_yet_test.go b/internal/donor/donorpage/you_cannot_sign_your_lpa_yet_test.go index c474e35790..dba6f3b958 100644 --- a/internal/donor/donorpage/you_cannot_sign_your_lpa_yet_test.go +++ b/internal/donor/donorpage/you_cannot_sign_your_lpa_yet_test.go @@ -15,7 +15,7 @@ func TestGetYouCannotSignYourLpaYetWithUnder18Actors(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {DateOfBirth: date.New(date.Today().YearString(), "1", "2")}, @@ -38,7 +38,7 @@ func TestGetYouCannotSignYourLpaYetWithUnder18ActorsWhenTemplateError(t *testing w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {DateOfBirth: date.New(date.Today().YearString(), "1", "2")}, @@ -61,7 +61,7 @@ func TestGetYouCannotSignYourLpaYetWithoutUnder18Actors(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - err := YouCannotSignYourLpaYet(nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YouCannotSignYourLpaYet(nil)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {DateOfBirth: date.New("2000", "1", "2")}, diff --git a/internal/donor/donorpage/your_address.go b/internal/donor/donorpage/your_address.go index 5d768a80fb..bdf1391eff 100644 --- a/internal/donor/donorpage/your_address.go +++ b/internal/donor/donorpage/your_address.go @@ -12,7 +12,7 @@ import ( ) func YourAddress(logger Logger, tmpl template.Template, addressClient AddressClient, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := newChooseAddressData( appData, "", diff --git a/internal/donor/donorpage/your_address_test.go b/internal/donor/donorpage/your_address_test.go index e1e2118e4e..a372ef541b 100644 --- a/internal/donor/donorpage/your_address_test.go +++ b/internal/donor/donorpage/your_address_test.go @@ -50,7 +50,7 @@ func TestGetYourAddress(t *testing.T) { Execute(w, tc.expectedData). Return(nil) - err := YourAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -78,7 +78,7 @@ func TestGetYourAddressFromStore(t *testing.T) { }). Return(nil) - err := YourAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YourAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{ Address: address, }, @@ -106,7 +106,7 @@ func TestGetYourAddressManual(t *testing.T) { }). Return(nil) - err := YourAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -126,7 +126,7 @@ func TestGetYourAddressWhenTemplateErrors(t *testing.T) { }). Return(expectedError) - err := YourAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -173,7 +173,7 @@ func TestPostYourAddressManual(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{ Address: testAddress, @@ -182,7 +182,7 @@ func TestPostYourAddressManual(t *testing.T) { }). Return(nil) - err := YourAddress(nil, nil, nil, donorStore)(tc.appData, w, r, &donordata.DonorProvidedDetails{ + err := YourAddress(nil, nil, nil, donorStore)(tc.appData, w, r, &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{ Address: place.Address{Line1: "a", Line2: "b", Line3: "c", TownOrCity: "d"}, @@ -228,7 +228,7 @@ func TestPostYourAddressManualWhenAddressNotChanged(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, tc.url, strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - err := YourAddress(nil, nil, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YourAddress(nil, nil, nil, nil)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{ Address: place.Address{ @@ -266,14 +266,14 @@ func TestPostYourAddressManualWhenStoreErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ Donor: donordata.Donor{ Address: testAddress, }, }). Return(expectedError) - err := YourAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -294,7 +294,7 @@ func TestPostYourAddressManualFromStore(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{ FirstNames: "John", @@ -303,7 +303,7 @@ func TestPostYourAddressManualFromStore(t *testing.T) { }). Return(nil) - err := YourAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YourAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{ FirstNames: "John", @@ -348,7 +348,7 @@ func TestPostYourAddressManualWhenValidationError(t *testing.T) { }). Return(nil) - err := YourAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -387,7 +387,7 @@ func TestPostYourAddressSelect(t *testing.T) { }). Return(nil) - err := YourAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -428,7 +428,7 @@ func TestPostYourAddressSelectWhenValidationError(t *testing.T) { }). Return(nil) - err := YourAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -468,7 +468,7 @@ func TestPostYourAddressLookup(t *testing.T) { }). Return(nil) - err := YourAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -509,7 +509,7 @@ func TestPostYourAddressLookupError(t *testing.T) { }). Return(nil) - err := YourAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -555,7 +555,7 @@ func TestPostYourAddressInvalidPostcodeError(t *testing.T) { }). Return(nil) - err := YourAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -595,7 +595,7 @@ func TestPostYourAddressValidPostcodeNoAddresses(t *testing.T) { }). Return(nil) - err := YourAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -624,7 +624,7 @@ func TestPostYourAddressLookupWhenValidationError(t *testing.T) { }). Return(nil) - err := YourAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/your_authorised_signatory.go b/internal/donor/donorpage/your_authorised_signatory.go index 747043d7cf..7e025ca63a 100644 --- a/internal/donor/donorpage/your_authorised_signatory.go +++ b/internal/donor/donorpage/your_authorised_signatory.go @@ -8,6 +8,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -19,7 +20,7 @@ type yourAuthorisedSignatoryData struct { } func YourAuthorisedSignatory(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &yourAuthorisedSignatoryData{ App: appData, Form: &yourAuthorisedSignatoryForm{ @@ -48,7 +49,7 @@ func YourAuthorisedSignatory(tmpl template.Template, donorStore DonorStore) Hand donor.AuthorisedSignatory.LastName = data.Form.LastName if !donor.Tasks.ChooseYourSignatory.Completed() { - donor.Tasks.ChooseYourSignatory = actor.TaskInProgress + donor.Tasks.ChooseYourSignatory = task.StateInProgress } if err := donorStore.Put(r.Context(), donor); err != nil { @@ -91,7 +92,7 @@ func (f *yourAuthorisedSignatoryForm) Validate() validation.List { return errors } -func signatoryMatches(donor *donordata.DonorProvidedDetails, firstNames, lastName string) actor.Type { +func signatoryMatches(donor *donordata.Provided, firstNames, lastName string) actor.Type { if firstNames == "" && lastName == "" { return actor.TypeNone } diff --git a/internal/donor/donorpage/your_authorised_signatory_test.go b/internal/donor/donorpage/your_authorised_signatory_test.go index 455d873a43..d808b598d2 100644 --- a/internal/donor/donorpage/your_authorised_signatory_test.go +++ b/internal/donor/donorpage/your_authorised_signatory_test.go @@ -11,6 +11,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -28,7 +29,7 @@ func TestGetYourAuthorisedSignatory(t *testing.T) { }). Return(nil) - err := YourAuthorisedSignatory(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourAuthorisedSignatory(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -49,7 +50,7 @@ func TestGetYourAuthorisedSignatoryFromStore(t *testing.T) { }). Return(nil) - err := YourAuthorisedSignatory(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YourAuthorisedSignatory(template.Execute, nil)(testAppData, w, r, &donordata.Provided{ AuthorisedSignatory: donordata.AuthorisedSignatory{ FirstNames: "John", }, @@ -69,7 +70,7 @@ func TestGetYourAuthorisedSignatoryWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := YourAuthorisedSignatory(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourAuthorisedSignatory(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -113,15 +114,15 @@ func TestPostYourAuthorisedSignatory(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "John", LastName: "Smith"}, AuthorisedSignatory: tc.person, - Tasks: donordata.DonorTasks{ChooseYourSignatory: actor.TaskInProgress}, + Tasks: donordata.Tasks{ChooseYourSignatory: task.StateInProgress}, }). Return(nil) - err := YourAuthorisedSignatory(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YourAuthorisedSignatory(nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "John", LastName: "Smith"}, }) @@ -147,22 +148,22 @@ func TestPostYourAuthorisedSignatoryWhenTaskCompleted(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", AuthorisedSignatory: donordata.AuthorisedSignatory{ FirstNames: "John", LastName: "Doe", }, - Tasks: donordata.DonorTasks{ChooseYourSignatory: actor.TaskCompleted}, + Tasks: donordata.Tasks{ChooseYourSignatory: task.StateCompleted}, }). Return(nil) - err := YourAuthorisedSignatory(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YourAuthorisedSignatory(nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", AuthorisedSignatory: donordata.AuthorisedSignatory{ FirstNames: "John", }, - Tasks: donordata.DonorTasks{ChooseYourSignatory: actor.TaskCompleted}, + Tasks: donordata.Tasks{ChooseYourSignatory: task.StateCompleted}, }) resp := w.Result() @@ -227,7 +228,7 @@ func TestPostYourAuthorisedSignatoryWhenInputRequired(t *testing.T) { })). Return(nil) - err := YourAuthorisedSignatory(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YourAuthorisedSignatory(template.Execute, nil)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{ FirstNames: "John", LastName: "Doe", @@ -256,7 +257,7 @@ func TestPostYourAuthorisedSignatoryWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := YourAuthorisedSignatory(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YourAuthorisedSignatory(nil, donorStore)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{ FirstNames: "John", Address: place.Address{Line1: "abc"}, @@ -327,7 +328,7 @@ func TestYourAuthorisedSignatoryFormValidate(t *testing.T) { } func TestSignatoryMatches(t *testing.T) { - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "c", LastName: "d"}, @@ -360,7 +361,7 @@ func TestSignatoryMatches(t *testing.T) { } func TestSignatoryMatchesEmptyNamesIgnored(t *testing.T) { - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{}}}, ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{}}}, PeopleToNotify: donordata.PeopleToNotify{{}}, diff --git a/internal/donor/donorpage/your_date_of_birth.go b/internal/donor/donorpage/your_date_of_birth.go index 37eb0e54cd..482c52c84f 100644 --- a/internal/donor/donorpage/your_date_of_birth.go +++ b/internal/donor/donorpage/your_date_of_birth.go @@ -21,7 +21,7 @@ type yourDateOfBirthData struct { } func YourDateOfBirth(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &yourDateOfBirthData{ App: appData, Form: &yourDateOfBirthForm{ diff --git a/internal/donor/donorpage/your_date_of_birth_test.go b/internal/donor/donorpage/your_date_of_birth_test.go index 902f8eb5f8..a091aa033f 100644 --- a/internal/donor/donorpage/your_date_of_birth_test.go +++ b/internal/donor/donorpage/your_date_of_birth_test.go @@ -29,7 +29,7 @@ func TestGetYourDateOfBirth(t *testing.T) { }). Return(nil) - err := YourDateOfBirth(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourDateOfBirth(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -50,7 +50,7 @@ func TestGetYourDateOfBirthFromStore(t *testing.T) { }). Return(nil) - err := YourDateOfBirth(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YourDateOfBirth(template.Execute, nil)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{ DateOfBirth: date.New("2000", "1", "2"), }, @@ -76,7 +76,7 @@ func TestGetYourDateOfBirthDobWarningIsAlwaysShown(t *testing.T) { }). Return(nil) - err := YourDateOfBirth(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YourDateOfBirth(template.Execute, nil)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{ DateOfBirth: date.New("1900", "01", "02"), }, @@ -96,7 +96,7 @@ func TestGetYourDateOfBirthWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := YourDateOfBirth(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{Donor: donordata.Donor{FirstNames: "John", DateOfBirth: date.New("2000", "1", "2")}}) + err := YourDateOfBirth(template.Execute, nil)(testAppData, w, r, &donordata.Provided{Donor: donordata.Donor{FirstNames: "John", DateOfBirth: date.New("2000", "1", "2")}}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -160,13 +160,13 @@ func TestPostYourDateOfBirth(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Donor: tc.person, }). Return(nil) - err := YourDateOfBirth(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YourDateOfBirth(nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{ DateOfBirth: date.New("2000", "1", "2"), @@ -212,7 +212,7 @@ func TestPostYourDateOfBirthWhenDetailsNotChanged(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, tc.url, strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - err := YourDateOfBirth(nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YourDateOfBirth(nil, nil)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{ DateOfBirth: date.New(validBirthYear, "1", "2"), @@ -279,7 +279,7 @@ func TestPostYourDateOfBirthWhenInputRequired(t *testing.T) { })). Return(nil) - err := YourDateOfBirth(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{Donor: donordata.Donor{DateOfBirth: date.New("2000", "1", "2")}}) + err := YourDateOfBirth(template.Execute, nil)(testAppData, w, r, &donordata.Provided{Donor: donordata.Donor{DateOfBirth: date.New("2000", "1", "2")}}) resp := w.Result() assert.Nil(t, err) @@ -304,7 +304,7 @@ func TestPostYourDateOfBirthWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := YourDateOfBirth(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YourDateOfBirth(nil, donorStore)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{ DateOfBirth: date.New("2000", "1", "2"), }, diff --git a/internal/donor/donorpage/your_email.go b/internal/donor/donorpage/your_email.go index 667440e79b..3aeb90a875 100644 --- a/internal/donor/donorpage/your_email.go +++ b/internal/donor/donorpage/your_email.go @@ -17,7 +17,7 @@ type yourEmailData struct { } func YourEmail(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &yourEmailData{ App: appData, Form: &yourEmailForm{ diff --git a/internal/donor/donorpage/your_email_test.go b/internal/donor/donorpage/your_email_test.go index 9cbe6f1e00..27b6217938 100644 --- a/internal/donor/donorpage/your_email_test.go +++ b/internal/donor/donorpage/your_email_test.go @@ -26,7 +26,7 @@ func TestGetYourEmail(t *testing.T) { }). Return(nil) - err := YourEmail(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourEmail(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -42,7 +42,7 @@ func TestGetYourEmailWhenTemplateErrors(t *testing.T) { On("Execute", w, mock.Anything). Return(expectedError) - err := YourEmail(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourEmail(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -61,7 +61,7 @@ func TestPostYourEmail(t *testing.T) { donorStore := newMockDonorStore(t) donorStore. - On("Put", r.Context(), &donordata.DonorProvidedDetails{ + On("Put", r.Context(), &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{ FirstNames: "John", @@ -70,7 +70,7 @@ func TestPostYourEmail(t *testing.T) { }). Return(nil) - err := YourEmail(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YourEmail(nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{ FirstNames: "John", @@ -99,7 +99,7 @@ func TestPostYourEmailWhenValidationError(t *testing.T) { })). Return(nil) - err := YourEmail(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourEmail(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -120,7 +120,7 @@ func TestPostYourEmailWhenStoreErrors(t *testing.T) { On("Put", r.Context(), mock.Anything). Return(expectedError) - err := YourEmail(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourEmail(nil, donorStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } diff --git a/internal/donor/donorpage/your_independent_witness.go b/internal/donor/donorpage/your_independent_witness.go index 497dec051c..645648c2d9 100644 --- a/internal/donor/donorpage/your_independent_witness.go +++ b/internal/donor/donorpage/your_independent_witness.go @@ -8,6 +8,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -19,7 +20,7 @@ type yourIndependentWitnessData struct { } func YourIndependentWitness(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &yourIndependentWitnessData{ App: appData, Form: &yourIndependentWitnessForm{ @@ -48,7 +49,7 @@ func YourIndependentWitness(tmpl template.Template, donorStore DonorStore) Handl donor.IndependentWitness.LastName = data.Form.LastName if !donor.Tasks.ChooseYourSignatory.Completed() { - donor.Tasks.ChooseYourSignatory = actor.TaskInProgress + donor.Tasks.ChooseYourSignatory = task.StateInProgress } if err := donorStore.Put(r.Context(), donor); err != nil { @@ -91,7 +92,7 @@ func (f *yourIndependentWitnessForm) Validate() validation.List { return errors } -func independentWitnessMatches(donor *donordata.DonorProvidedDetails, firstNames, lastName string) actor.Type { +func independentWitnessMatches(donor *donordata.Provided, firstNames, lastName string) actor.Type { if firstNames == "" && lastName == "" { return actor.TypeNone } diff --git a/internal/donor/donorpage/your_independent_witness_address.go b/internal/donor/donorpage/your_independent_witness_address.go index 355f211033..8623108bd4 100644 --- a/internal/donor/donorpage/your_independent_witness_address.go +++ b/internal/donor/donorpage/your_independent_witness_address.go @@ -4,16 +4,16 @@ import ( "net/http" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" ) func YourIndependentWitnessAddress(logger Logger, tmpl template.Template, addressClient AddressClient, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := newChooseAddressData( appData, "independentWitness", @@ -31,7 +31,7 @@ func YourIndependentWitnessAddress(logger Logger, tmpl template.Template, addres data.Errors = data.Form.Validate(false) setAddress := func(address place.Address) error { - donor.Tasks.ChooseYourSignatory = actor.TaskCompleted + donor.Tasks.ChooseYourSignatory = task.StateCompleted donor.IndependentWitness.Address = *data.Form.Address if err := donorStore.Put(r.Context(), donor); err != nil { diff --git a/internal/donor/donorpage/your_independent_witness_address_test.go b/internal/donor/donorpage/your_independent_witness_address_test.go index c30b29cbba..f0ab21040c 100644 --- a/internal/donor/donorpage/your_independent_witness_address_test.go +++ b/internal/donor/donorpage/your_independent_witness_address_test.go @@ -8,12 +8,12 @@ import ( "strings" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -34,7 +34,7 @@ func TestGetYourIndependentWitnessAddress(t *testing.T) { }). Return(nil) - err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ IndependentWitness: donordata.IndependentWitness{ FirstNames: "John", LastName: "Smith", @@ -67,7 +67,7 @@ func TestGetYourIndependentWitnessAddressFromStore(t *testing.T) { }). Return(nil) - err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ IndependentWitness: donordata.IndependentWitness{ Address: address, }, @@ -97,7 +97,7 @@ func TestGetYourIndependentWitnessAddressManual(t *testing.T) { }). Return(nil) - err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -119,7 +119,7 @@ func TestGetYourIndependentWitnessAddressWhenTemplateErrors(t *testing.T) { }). Return(expectedError) - err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -142,18 +142,18 @@ func TestPostYourIndependentWitnessAddressManual(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", IndependentWitness: donordata.IndependentWitness{ Address: testAddress, }, - Tasks: donordata.DonorTasks{ - ChooseYourSignatory: actor.TaskCompleted, + Tasks: donordata.Tasks{ + ChooseYourSignatory: task.StateCompleted, }, }). Return(nil) - err := YourIndependentWitnessAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YourIndependentWitnessAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", }) resp := w.Result() @@ -182,7 +182,7 @@ func TestPostYourIndependentWitnessAddressManualWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := YourIndependentWitnessAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourIndependentWitnessAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -203,19 +203,19 @@ func TestPostYourIndependentWitnessAddressManualFromStore(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", IndependentWitness: donordata.IndependentWitness{ FirstNames: "John", Address: testAddress, }, - Tasks: donordata.DonorTasks{ - ChooseYourSignatory: actor.TaskCompleted, + Tasks: donordata.Tasks{ + ChooseYourSignatory: task.StateCompleted, }, }). Return(nil) - err := YourIndependentWitnessAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YourIndependentWitnessAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", IndependentWitness: donordata.IndependentWitness{ FirstNames: "John", @@ -262,7 +262,7 @@ func TestPostYourIndependentWitnessAddressManualWhenValidationError(t *testing.T }). Return(nil) - err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -303,7 +303,7 @@ func TestPostYourIndependentWitnessAddressSelect(t *testing.T) { }). Return(nil) - err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -346,7 +346,7 @@ func TestPostYourIndependentWitnessAddressSelectWhenValidationError(t *testing.T }). Return(nil) - err := YourIndependentWitnessAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourIndependentWitnessAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -388,7 +388,7 @@ func TestPostYourIndependentWitnessAddressLookup(t *testing.T) { }). Return(nil) - err := YourIndependentWitnessAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourIndependentWitnessAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -431,7 +431,7 @@ func TestPostYourIndependentWitnessAddressLookupError(t *testing.T) { }). Return(nil) - err := YourIndependentWitnessAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourIndependentWitnessAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -479,7 +479,7 @@ func TestPostYourIndependentWitnessAddressInvalidPostcodeError(t *testing.T) { }). Return(nil) - err := YourIndependentWitnessAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourIndependentWitnessAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -521,7 +521,7 @@ func TestPostYourIndependentWitnessAddressValidPostcodeNoAddresses(t *testing.T) }). Return(nil) - err := YourIndependentWitnessAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourIndependentWitnessAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -552,7 +552,7 @@ func TestPostYourIndependentWitnessAddressLookupWhenValidationError(t *testing.T }). Return(nil) - err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -572,16 +572,16 @@ func TestPostYourIndependentWitnessAddressReuseSelect(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", IndependentWitness: donordata.IndependentWitness{ Address: testAddress, }, - Tasks: donordata.DonorTasks{ChooseYourSignatory: actor.TaskCompleted}, + Tasks: donordata.Tasks{ChooseYourSignatory: task.StateCompleted}, }). Return(nil) - err := YourIndependentWitnessAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YourIndependentWitnessAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", }) resp := w.Result() @@ -616,7 +616,7 @@ func TestPostYourIndependentWitnessAddressReuseSelectWhenValidationError(t *test }). Return(nil) - err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{Address: place.Address{Line1: "donor lane"}}, }) resp := w.Result() diff --git a/internal/donor/donorpage/your_independent_witness_mobile.go b/internal/donor/donorpage/your_independent_witness_mobile.go index b5a56a87d8..cf7fcd824e 100644 --- a/internal/donor/donorpage/your_independent_witness_mobile.go +++ b/internal/donor/donorpage/your_independent_witness_mobile.go @@ -17,7 +17,7 @@ type yourIndependentWitnessMobileData struct { } func YourIndependentWitnessMobile(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &yourIndependentWitnessMobileData{ App: appData, AuthorisedSignatory: donor.AuthorisedSignatory, diff --git a/internal/donor/donorpage/your_independent_witness_mobile_test.go b/internal/donor/donorpage/your_independent_witness_mobile_test.go index e6ba07d064..e998cc028a 100644 --- a/internal/donor/donorpage/your_independent_witness_mobile_test.go +++ b/internal/donor/donorpage/your_independent_witness_mobile_test.go @@ -26,7 +26,7 @@ func TestGetYourIndependentWitnessMobile(t *testing.T) { }). Return(nil) - err := YourIndependentWitnessMobile(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourIndependentWitnessMobile(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -35,11 +35,11 @@ func TestGetYourIndependentWitnessMobile(t *testing.T) { func TestGetYourIndependentWitnessMobileFromStore(t *testing.T) { testcases := map[string]struct { - donor *donordata.DonorProvidedDetails + donor *donordata.Provided form *yourIndependentWitnessMobileForm }{ "uk mobile": { - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ IndependentWitness: donordata.IndependentWitness{ Mobile: "07777", }, @@ -49,7 +49,7 @@ func TestGetYourIndependentWitnessMobileFromStore(t *testing.T) { }, }, "non-uk mobile": { - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ IndependentWitness: donordata.IndependentWitness{ Mobile: "07777", HasNonUKMobile: true, @@ -96,7 +96,7 @@ func TestGetYourIndependentWitnessMobileWhenTemplateErrors(t *testing.T) { }). Return(expectedError) - err := YourIndependentWitnessMobile(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourIndependentWitnessMobile(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -136,13 +136,13 @@ func TestPostYourIndependentWitnessMobile(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", IndependentWitness: tc.yourIndependentWitnessMobile, }). Return(nil) - err := YourIndependentWitnessMobile(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) + err := YourIndependentWitnessMobile(nil, donorStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id"}) resp := w.Result() assert.Nil(t, err) @@ -168,7 +168,7 @@ func TestPostYourIndependentWitnessMobileWhenValidationError(t *testing.T) { })). Return(nil) - err := YourIndependentWitnessMobile(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourIndependentWitnessMobile(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -189,7 +189,7 @@ func TestPostYourIndependentWitnessMobileWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := YourIndependentWitnessMobile(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourIndependentWitnessMobile(nil, donorStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } diff --git a/internal/donor/donorpage/your_independent_witness_test.go b/internal/donor/donorpage/your_independent_witness_test.go index 03dacae5c8..cdb1985681 100644 --- a/internal/donor/donorpage/your_independent_witness_test.go +++ b/internal/donor/donorpage/your_independent_witness_test.go @@ -11,6 +11,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -28,7 +29,7 @@ func TestGetYourIndependentWitness(t *testing.T) { }). Return(nil) - err := YourIndependentWitness(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourIndependentWitness(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -49,7 +50,7 @@ func TestGetYourIndependentWitnessFromStore(t *testing.T) { }). Return(nil) - err := YourIndependentWitness(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YourIndependentWitness(template.Execute, nil)(testAppData, w, r, &donordata.Provided{ IndependentWitness: donordata.IndependentWitness{ FirstNames: "John", }, @@ -69,7 +70,7 @@ func TestGetYourIndependentWitnessWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := YourIndependentWitness(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourIndependentWitness(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -113,15 +114,15 @@ func TestPostYourIndependentWitness(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "John", LastName: "Smith"}, IndependentWitness: tc.person, - Tasks: donordata.DonorTasks{ChooseYourSignatory: actor.TaskInProgress}, + Tasks: donordata.Tasks{ChooseYourSignatory: task.StateInProgress}, }). Return(nil) - err := YourIndependentWitness(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YourIndependentWitness(nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "John", LastName: "Smith"}, }) @@ -147,22 +148,22 @@ func TestPostYourIndependentWitnessWhenTaskCompleted(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", IndependentWitness: donordata.IndependentWitness{ FirstNames: "John", LastName: "Doe", }, - Tasks: donordata.DonorTasks{ChooseYourSignatory: actor.TaskCompleted}, + Tasks: donordata.Tasks{ChooseYourSignatory: task.StateCompleted}, }). Return(nil) - err := YourIndependentWitness(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YourIndependentWitness(nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", IndependentWitness: donordata.IndependentWitness{ FirstNames: "John", }, - Tasks: donordata.DonorTasks{ChooseYourSignatory: actor.TaskCompleted}, + Tasks: donordata.Tasks{ChooseYourSignatory: task.StateCompleted}, }) resp := w.Result() @@ -227,7 +228,7 @@ func TestPostYourIndependentWitnessWhenInputRequired(t *testing.T) { })). Return(nil) - err := YourIndependentWitness(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YourIndependentWitness(template.Execute, nil)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{ FirstNames: "John", LastName: "Doe", @@ -256,7 +257,7 @@ func TestPostYourIndependentWitnessWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := YourIndependentWitness(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YourIndependentWitness(nil, donorStore)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{ FirstNames: "John", Address: place.Address{Line1: "abc"}, @@ -327,7 +328,7 @@ func TestYourIndependentWitnessFormValidate(t *testing.T) { } func TestIndependentWitnessMatches(t *testing.T) { - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "c", LastName: "d"}, @@ -360,7 +361,7 @@ func TestIndependentWitnessMatches(t *testing.T) { } func TestIndependentWitnessMatchesEmptyNamesIgnored(t *testing.T) { - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{}}}, ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{}}}, PeopleToNotify: donordata.PeopleToNotify{{}}, diff --git a/internal/donor/donorpage/your_lpa_language.go b/internal/donor/donorpage/your_lpa_language.go index 8722518562..8f21e14c6d 100644 --- a/internal/donor/donorpage/your_lpa_language.go +++ b/internal/donor/donorpage/your_lpa_language.go @@ -20,7 +20,7 @@ type yourLpaLanguageData struct { } func YourLpaLanguage(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &yourLpaLanguageData{ App: appData, Form: form.NewYesNoForm(form.YesNoUnknown), diff --git a/internal/donor/donorpage/your_lpa_language_test.go b/internal/donor/donorpage/your_lpa_language_test.go index 5c11cc4163..1450d88ef8 100644 --- a/internal/donor/donorpage/your_lpa_language_test.go +++ b/internal/donor/donorpage/your_lpa_language_test.go @@ -30,7 +30,7 @@ func TestGetYourLpaLanguage(t *testing.T) { }). Return(nil) - err := YourLpaLanguage(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YourLpaLanguage(template.Execute, nil)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{LpaLanguagePreference: localize.En}, }) resp := w.Result() @@ -48,7 +48,7 @@ func TestGetYourLpaLanguageWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := YourLpaLanguage(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourLpaLanguage(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -66,7 +66,7 @@ func TestPostYourLpaLanguageWhenContinue(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - err := YourLpaLanguage(nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YourLpaLanguage(nil, nil)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{LpaLanguagePreference: lang}, }) @@ -106,13 +106,13 @@ func TestPostYourLpaLanguageWhenSwitch(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{LpaLanguagePreference: tc.expectedLanguage}, }). Return(nil) - err := YourLpaLanguage(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YourLpaLanguage(nil, donorStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{LpaLanguagePreference: tc.selectedLanguage}, }) @@ -139,7 +139,7 @@ func TestPostYourLpaLanguageWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := YourLpaLanguage(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourLpaLanguage(nil, donorStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -156,7 +156,7 @@ func TestPostYourLpaLanguageWhenValidationErrors(t *testing.T) { })). Return(nil) - err := YourLpaLanguage(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourLpaLanguage(template.Execute, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/your_name.go b/internal/donor/donorpage/your_name.go index b908c2c38d..1bd69c256a 100644 --- a/internal/donor/donorpage/your_name.go +++ b/internal/donor/donorpage/your_name.go @@ -23,7 +23,7 @@ type yourNameData struct { } func YourName(tmpl template.Template, donorStore DonorStore, sessionStore SessionStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &yourNameData{ App: appData, Form: &yourNameForm{ @@ -129,7 +129,7 @@ func (f *yourNameForm) Validate() validation.List { return errors } -func donorMatches(donor *donordata.DonorProvidedDetails, firstNames, lastName string) actor.Type { +func donorMatches(donor *donordata.Provided, firstNames, lastName string) actor.Type { if firstNames == "" && lastName == "" { return actor.TypeNone } diff --git a/internal/donor/donorpage/your_name_test.go b/internal/donor/donorpage/your_name_test.go index 3b806dd7c6..992aaeb3bb 100644 --- a/internal/donor/donorpage/your_name_test.go +++ b/internal/donor/donorpage/your_name_test.go @@ -28,7 +28,7 @@ func TestGetYourName(t *testing.T) { }). Return(nil) - err := YourName(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourName(template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -51,7 +51,7 @@ func TestGetYourNameFromStore(t *testing.T) { }). Return(nil) - err := YourName(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YourName(template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{ Donor: donordata.Donor{ FirstNames: "John", LastName: "Doe", @@ -73,7 +73,7 @@ func TestGetYourNameWhenTemplateErrors(t *testing.T) { On("Execute", w, mock.Anything). Return(expectedError) - err := YourName(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{Donor: donordata.Donor{FirstNames: "John"}}) + err := YourName(template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{Donor: donordata.Donor{FirstNames: "John"}}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -147,14 +147,14 @@ func TestPostYourName(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Donor: tc.person, CertificateProvider: donordata.CertificateProvider{FirstNames: "Jane", LastName: "Bloggs"}, }). Return(nil) - err := YourName(nil, donorStore, sessionStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YourName(nil, donorStore, sessionStore)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "John"}, CertificateProvider: donordata.CertificateProvider{FirstNames: "Jane", LastName: "Bloggs"}, @@ -197,7 +197,7 @@ func TestPostYourNameWhenDetailsNotChanged(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, tc.url, strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - err := YourName(nil, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + err := YourName(nil, nil, nil)(testAppData, w, r, &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{ FirstNames: "John", @@ -243,7 +243,7 @@ func TestPostYourNameWhenInputRequired(t *testing.T) { })). Return(nil) - err := YourName(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourName(template.Execute, nil, nil)(testAppData, w, r, &donordata.Provided{}) resp := w.Result() assert.Nil(t, err) @@ -267,7 +267,7 @@ func TestPostYourNameWhenSessionStoreErrors(t *testing.T) { Login(r). Return(nil, expectedError) - err := YourName(nil, nil, sessionStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourName(nil, nil, sessionStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -286,7 +286,7 @@ func TestPostYourNameWhenSessionMissingEmail(t *testing.T) { Login(r). Return(&sesh.LoginSession{}, nil) - err := YourName(nil, nil, sessionStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourName(nil, nil, sessionStore)(testAppData, w, r, &donordata.Provided{}) assert.EqualError(t, err, "no email in login session") } @@ -310,12 +310,12 @@ func TestPostYourNameWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := YourName(nil, donorStore, sessionStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) + err := YourName(nil, donorStore, sessionStore)(testAppData, w, r, &donordata.Provided{}) assert.Equal(t, expectedError, err) } func TestDonorMatches(t *testing.T) { - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "c", LastName: "d"}, @@ -348,7 +348,7 @@ func TestDonorMatches(t *testing.T) { } func TestDonorMatchesEmptyNamesIgnored(t *testing.T) { - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ Donor: donordata.Donor{FirstNames: "", LastName: ""}, Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "", LastName: ""}, diff --git a/internal/donor/donorpage/your_preferred_language.go b/internal/donor/donorpage/your_preferred_language.go index 191d196876..caa764e18b 100644 --- a/internal/donor/donorpage/your_preferred_language.go +++ b/internal/donor/donorpage/your_preferred_language.go @@ -20,7 +20,7 @@ type yourPreferredLanguageData struct { } func YourPreferredLanguage(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error { data := &yourPreferredLanguageData{ App: appData, Form: &yourPreferredLanguageForm{ diff --git a/internal/donor/donorpage/your_preferred_language_test.go b/internal/donor/donorpage/your_preferred_language_test.go index 603783c6c1..70dec1f528 100644 --- a/internal/donor/donorpage/your_preferred_language_test.go +++ b/internal/donor/donorpage/your_preferred_language_test.go @@ -31,7 +31,7 @@ func TestGetYourPreferredLanguage(t *testing.T) { }). Return(nil) - err := YourPreferredLanguage(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", Donor: donordata.Donor{ContactLanguagePreference: localize.Cy}}) + err := YourPreferredLanguage(template.Execute, nil)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", Donor: donordata.Donor{ContactLanguagePreference: localize.Cy}}) resp := w.Result() @@ -48,7 +48,7 @@ func TestGetYourPreferredLanguageWhenTemplateError(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := YourPreferredLanguage(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", Donor: donordata.Donor{ContactLanguagePreference: localize.Cy}}) + err := YourPreferredLanguage(template.Execute, nil)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id", Donor: donordata.Donor{ContactLanguagePreference: localize.Cy}}) resp := w.Result() @@ -69,13 +69,13 @@ func TestPostYourPreferredLanguage(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{ContactLanguagePreference: lang, LpaLanguagePreference: lang}, }). Return(nil) - err := YourPreferredLanguage(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) + err := YourPreferredLanguage(nil, donorStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id"}) resp := w.Result() @@ -98,7 +98,7 @@ func TestPostYourPreferredLanguageWhenDonorStoreError(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := YourPreferredLanguage(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) + err := YourPreferredLanguage(nil, donorStore)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id"}) resp := w.Result() @@ -126,7 +126,7 @@ func TestPostYourPreferredLanguageWhenInvalidData(t *testing.T) { }). Return(nil) - err := YourPreferredLanguage(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) + err := YourPreferredLanguage(template.Execute, nil)(testAppData, w, r, &donordata.Provided{LpaID: "lpa-id"}) resp := w.Result() diff --git a/internal/lpastore/client_test.go b/internal/lpastore/client_test.go index a2f6663747..088d84176b 100644 --- a/internal/lpastore/client_test.go +++ b/internal/lpastore/client_test.go @@ -179,7 +179,7 @@ func TestClientServiceContract(t *testing.T) { now: now, } - err := client.SendLpa(context.Background(), &donordata.DonorProvidedDetails{ + err := client.SendLpa(context.Background(), &donordata.Provided{ LpaUID: "M-0000-1111-2222", Type: donordata.LpaTypePersonalWelfare, LifeSustainingTreatmentOption: donordata.LifeSustainingTreatmentOptionA, @@ -341,7 +341,7 @@ func TestClientServiceContract(t *testing.T) { now: now, } - err := client.SendLpa(context.Background(), &donordata.DonorProvidedDetails{ + err := client.SendLpa(context.Background(), &donordata.Provided{ LpaUID: "M-0000-1111-2222", Type: donordata.LpaTypePersonalWelfare, Donor: donordata.Donor{ diff --git a/internal/lpastore/lpa.go b/internal/lpastore/lpa.go index ebfe202bec..fd63ce6432 100644 --- a/internal/lpastore/lpa.go +++ b/internal/lpastore/lpa.go @@ -98,7 +98,7 @@ type lpaRequestPersonToNotify struct { Address place.Address `json:"address"` } -func (c *Client) SendLpa(ctx context.Context, donor *donordata.DonorProvidedDetails) error { +func (c *Client) SendLpa(ctx context.Context, donor *donordata.Provided) error { body := lpaRequest{ LpaType: donor.Type, Channel: donordata.ChannelOnline, @@ -594,7 +594,7 @@ func lpaResponseToLpa(l lpaResponse) *Lpa { } } -func FromDonorProvidedDetails(l *donordata.DonorProvidedDetails) *Lpa { +func FromDonorProvidedDetails(l *donordata.Provided) *Lpa { attorneys := Attorneys{} for _, a := range l.Attorneys.Attorneys { attorneys.Attorneys = append(attorneys.Attorneys, Attorney{ diff --git a/internal/lpastore/lpa_test.go b/internal/lpastore/lpa_test.go index 122e0ba2ad..eed50bda17 100644 --- a/internal/lpastore/lpa_test.go +++ b/internal/lpastore/lpa_test.go @@ -33,11 +33,11 @@ func TestClientSendLpa(t *testing.T) { personToNotifyUID := actoruid.New() testcases := map[string]struct { - donor *donordata.DonorProvidedDetails + donor *donordata.Provided json string }{ "minimal": { - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ LpaUID: "M-0000-1111-2222", Type: donordata.LpaTypePropertyAndAffairs, Donor: donordata.Donor{ @@ -95,7 +95,7 @@ func TestClientSendLpa(t *testing.T) { }`, }, "everything": { - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ LpaUID: "M-0000-1111-2222", Type: donordata.LpaTypePersonalWelfare, Donor: donordata.Donor{ @@ -316,7 +316,7 @@ func TestClientSendLpa(t *testing.T) { func TestClientSendLpaWhenNewRequestError(t *testing.T) { client := New("http://base", nil, nil) - err := client.SendLpa(nil, &donordata.DonorProvidedDetails{}) + err := client.SendLpa(nil, &donordata.Provided{}) assert.NotNil(t, err) } @@ -330,7 +330,7 @@ func TestClientSendLpaWhenSecretsClientError(t *testing.T) { Return("", expectedError) client := New("http://base", secretsClient, nil) - err := client.SendLpa(ctx, &donordata.DonorProvidedDetails{}) + err := client.SendLpa(ctx, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -349,7 +349,7 @@ func TestClientSendLpaWhenDoerError(t *testing.T) { Return(nil, expectedError) client := New("http://base", secretsClient, doer) - err := client.SendLpa(ctx, &donordata.DonorProvidedDetails{}) + err := client.SendLpa(ctx, &donordata.Provided{}) assert.Equal(t, expectedError, err) } @@ -375,7 +375,7 @@ func TestClientSendLpaWhenStatusCodeIsNotOK(t *testing.T) { Return(&http.Response{StatusCode: code, Body: io.NopCloser(strings.NewReader("hey"))}, nil) client := New("http://base", secretsClient, doer) - err := client.SendLpa(ctx, &donordata.DonorProvidedDetails{}) + err := client.SendLpa(ctx, &donordata.Provided{}) assert.Equal(t, responseError{name: errorName, body: "hey"}, err) }) diff --git a/internal/lpastore/mock_DonorStore_test.go b/internal/lpastore/mock_DonorStore_test.go index 0e7346efb8..e71c9c4cc0 100644 --- a/internal/lpastore/mock_DonorStore_test.go +++ b/internal/lpastore/mock_DonorStore_test.go @@ -23,23 +23,23 @@ func (_m *mockDonorStore) EXPECT() *mockDonorStore_Expecter { } // GetAny provides a mock function with given fields: ctx -func (_m *mockDonorStore) GetAny(ctx context.Context) (*donordata.DonorProvidedDetails, error) { +func (_m *mockDonorStore) GetAny(ctx context.Context) (*donordata.Provided, error) { ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for GetAny") } - var r0 *donordata.DonorProvidedDetails + var r0 *donordata.Provided var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (*donordata.DonorProvidedDetails, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context) (*donordata.Provided, error)); ok { return rf(ctx) } - if rf, ok := ret.Get(0).(func(context.Context) *donordata.DonorProvidedDetails); ok { + if rf, ok := ret.Get(0).(func(context.Context) *donordata.Provided); ok { r0 = rf(ctx) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*donordata.DonorProvidedDetails) + r0 = ret.Get(0).(*donordata.Provided) } } @@ -70,12 +70,12 @@ func (_c *mockDonorStore_GetAny_Call) Run(run func(ctx context.Context)) *mockDo return _c } -func (_c *mockDonorStore_GetAny_Call) Return(_a0 *donordata.DonorProvidedDetails, _a1 error) *mockDonorStore_GetAny_Call { +func (_c *mockDonorStore_GetAny_Call) Return(_a0 *donordata.Provided, _a1 error) *mockDonorStore_GetAny_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockDonorStore_GetAny_Call) RunAndReturn(run func(context.Context) (*donordata.DonorProvidedDetails, error)) *mockDonorStore_GetAny_Call { +func (_c *mockDonorStore_GetAny_Call) RunAndReturn(run func(context.Context) (*donordata.Provided, error)) *mockDonorStore_GetAny_Call { _c.Call.Return(run) return _c } diff --git a/internal/lpastore/resolving_service.go b/internal/lpastore/resolving_service.go index f17f78a886..a5e12aa41b 100644 --- a/internal/lpastore/resolving_service.go +++ b/internal/lpastore/resolving_service.go @@ -9,7 +9,7 @@ import ( ) type DonorStore interface { - GetAny(ctx context.Context) (*donordata.DonorProvidedDetails, error) + GetAny(ctx context.Context) (*donordata.Provided, error) } type LpaClient interface { @@ -48,7 +48,7 @@ func (s *ResolvingService) Get(ctx context.Context) (*Lpa, error) { return s.merge(lpa, donor), nil } -func (s *ResolvingService) ResolveList(ctx context.Context, donors []*donordata.DonorProvidedDetails) ([]*Lpa, error) { +func (s *ResolvingService) ResolveList(ctx context.Context, donors []*donordata.Provided) ([]*Lpa, error) { lpaUIDs := make([]string, len(donors)) for i, donor := range donors { lpaUIDs[i] = donor.LpaUID @@ -76,7 +76,7 @@ func (s *ResolvingService) ResolveList(ctx context.Context, donors []*donordata. return result, nil } -func (s *ResolvingService) merge(lpa *Lpa, donor *donordata.DonorProvidedDetails) *Lpa { +func (s *ResolvingService) merge(lpa *Lpa, donor *donordata.Provided) *Lpa { lpa.LpaKey = donor.PK lpa.LpaOwnerKey = donor.SK lpa.LpaID = donor.LpaID diff --git a/internal/lpastore/resolving_service_test.go b/internal/lpastore/resolving_service_test.go index e89b6b2bbd..32ada35eb2 100644 --- a/internal/lpastore/resolving_service_test.go +++ b/internal/lpastore/resolving_service_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" donordata "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/identity" @@ -16,13 +15,13 @@ import ( func TestResolvingServiceGet(t *testing.T) { testcases := map[string]struct { - donor *donordata.DonorProvidedDetails + donor *donordata.Provided resolved *Lpa error error expected *Lpa }{ "online with all true": { - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ SK: dynamo.LpaOwnerKey(dynamo.OrganisationKey("S")), LpaID: "1", LpaUID: "M-1111", @@ -31,8 +30,8 @@ func TestResolvingServiceGet(t *testing.T) { FirstNames: "Barry", Relationship: donordata.Personally, }, - Tasks: donordata.DonorTasks{ - CheckYourLpa: actor.TaskCompleted, + Tasks: donordata.Tasks{ + CheckYourLpa: task.StateCompleted, PayForLpa: task.PaymentStateCompleted, }, DonorIdentityUserData: identity.UserData{ @@ -62,7 +61,7 @@ func TestResolvingServiceGet(t *testing.T) { }, }, "online with no lpastore record": { - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ SK: dynamo.LpaOwnerKey(dynamo.DonorKey("S")), LpaUID: "M-1111", CertificateProvider: donordata.CertificateProvider{ @@ -109,7 +108,7 @@ func TestResolvingServiceGet(t *testing.T) { }, }, "online with all false": { - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ SK: dynamo.LpaOwnerKey(dynamo.DonorKey("S")), LpaID: "1", LpaUID: "M-1111", @@ -123,7 +122,7 @@ func TestResolvingServiceGet(t *testing.T) { }, }, "paper": { - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ SK: dynamo.LpaOwnerKey(dynamo.DonorKey("PAPER")), LpaID: "1", LpaUID: "M-1111", @@ -173,7 +172,7 @@ func TestResolvingServiceGetWhenNoUID(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). GetAny(ctx). - Return(&donordata.DonorProvidedDetails{LpaID: "1"}, nil) + Return(&donordata.Provided{LpaID: "1"}, nil) service := NewResolvingService(donorStore, nil) lpa, err := service.Get(ctx) @@ -191,7 +190,7 @@ func TestResolvingServiceGetWhenNotFound(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). GetAny(ctx). - Return(&donordata.DonorProvidedDetails{LpaID: "1", LpaUID: "M-1111"}, nil) + Return(&donordata.Provided{LpaID: "1", LpaUID: "M-1111"}, nil) lpaClient := newMockLpaClient(t) lpaClient.EXPECT(). @@ -229,7 +228,7 @@ func TestResolvingServiceGetWhenLpaClientErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). GetAny(ctx). - Return(&donordata.DonorProvidedDetails{LpaUID: "M-1111"}, nil) + Return(&donordata.Provided{LpaUID: "M-1111"}, nil) lpaClient := newMockLpaClient(t) lpaClient.EXPECT(). @@ -244,14 +243,14 @@ func TestResolvingServiceGetWhenLpaClientErrors(t *testing.T) { func TestResolvingServiceResolveList(t *testing.T) { testcases := map[string]struct { - donors []*donordata.DonorProvidedDetails + donors []*donordata.Provided uids []string resolved []*Lpa error error expected []*Lpa }{ "online with all true": { - donors: []*donordata.DonorProvidedDetails{{ + donors: []*donordata.Provided{{ SK: dynamo.LpaOwnerKey(dynamo.OrganisationKey("S")), LpaID: "1", LpaUID: "M-1111", @@ -260,8 +259,8 @@ func TestResolvingServiceResolveList(t *testing.T) { FirstNames: "Barry", Relationship: donordata.Personally, }, - Tasks: donordata.DonorTasks{ - CheckYourLpa: actor.TaskCompleted, + Tasks: donordata.Tasks{ + CheckYourLpa: task.StateCompleted, PayForLpa: task.PaymentStateCompleted, }, DonorIdentityUserData: identity.UserData{ @@ -292,7 +291,7 @@ func TestResolvingServiceResolveList(t *testing.T) { }}, }, "online with no lpastore record": { - donors: []*donordata.DonorProvidedDetails{{ + donors: []*donordata.Provided{{ SK: dynamo.LpaOwnerKey(dynamo.DonorKey("S")), LpaUID: "M-1111", CertificateProvider: donordata.CertificateProvider{ @@ -329,7 +328,7 @@ func TestResolvingServiceResolveList(t *testing.T) { }}, }, "online with all false": { - donors: []*donordata.DonorProvidedDetails{{ + donors: []*donordata.Provided{{ SK: dynamo.LpaOwnerKey(dynamo.DonorKey("S")), LpaID: "1", LpaUID: "M-1111", @@ -344,7 +343,7 @@ func TestResolvingServiceResolveList(t *testing.T) { }}, }, "paper": { - donors: []*donordata.DonorProvidedDetails{{ + donors: []*donordata.Provided{{ SK: dynamo.LpaOwnerKey(dynamo.DonorKey("PAPER")), LpaID: "1", LpaUID: "M-1111", diff --git a/internal/lpastore/update.go b/internal/lpastore/update.go index 83a315d2b8..3140001c1c 100644 --- a/internal/lpastore/update.go +++ b/internal/lpastore/update.go @@ -190,7 +190,7 @@ func (c *Client) SendCertificateProviderOptOut(ctx context.Context, lpaUID strin return c.sendUpdate(ctx, lpaUID, actorUID, body) } -func (c *Client) SendDonorConfirmIdentity(ctx context.Context, donor *donordata.DonorProvidedDetails) error { +func (c *Client) SendDonorConfirmIdentity(ctx context.Context, donor *donordata.Provided) error { body := updateRequest{ Type: "DONOR_CONFIRM_IDENTITY", Changes: []updateRequestChange{ diff --git a/internal/lpastore/update_test.go b/internal/lpastore/update_test.go index 7898f30df3..863de665ef 100644 --- a/internal/lpastore/update_test.go +++ b/internal/lpastore/update_test.go @@ -375,7 +375,7 @@ func TestClientSendDonorConfirmIdentity(t *testing.T) { client := New("http://base", secretsClient, doer) client.now = func() time.Time { return time.Date(2000, time.January, 2, 3, 4, 5, 6, time.UTC) } - err := client.SendDonorConfirmIdentity(ctx, &donordata.DonorProvidedDetails{ + err := client.SendDonorConfirmIdentity(ctx, &donordata.Provided{ LpaUID: "lpa-uid", Donor: donordata.Donor{UID: uid}, DonorIdentityUserData: identity.UserData{ diff --git a/internal/page/common.go b/internal/page/common.go index 622429456f..19afd2b4fa 100644 --- a/internal/page/common.go +++ b/internal/page/common.go @@ -15,6 +15,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/onelogin" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" ) const FormUrlEncoded = "application/x-www-form-urlencoded" @@ -27,8 +28,8 @@ type Logger interface { } type ShareCodeStore interface { - Get(ctx context.Context, actorType actor.Type, shareCode string) (actor.ShareCodeData, error) - Put(ctx context.Context, actorType actor.Type, shareCode string, data actor.ShareCodeData) error + Get(ctx context.Context, actorType actor.Type, shareCode string) (sharecode.Data, error) + Put(ctx context.Context, actorType actor.Type, shareCode string, data sharecode.Data) error } type NotifyClient interface { @@ -44,8 +45,8 @@ type OneLoginClient interface { } type DonorStore interface { - Create(context.Context) (*donordata.DonorProvidedDetails, error) - Put(context.Context, *donordata.DonorProvidedDetails) error + Create(context.Context) (*donordata.Provided, error) + Put(context.Context, *donordata.Provided) error } type Bundle interface { diff --git a/internal/page/dashboard_test.go b/internal/page/dashboard_test.go index cb5055a51a..8755c5be70 100644 --- a/internal/page/dashboard_test.go +++ b/internal/page/dashboard_test.go @@ -134,7 +134,7 @@ func TestPostDashboard(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Create(r.Context()). - Return(&donordata.DonorProvidedDetails{LpaID: "lpa-id"}, nil) + Return(&donordata.Provided{LpaID: "lpa-id"}, nil) err := Dashboard(nil, donorStore, nil)(AppData{}, w, r) resp := w.Result() @@ -153,7 +153,7 @@ func TestPostDashboardWhenDonorStoreError(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Create(r.Context()). - Return(&donordata.DonorProvidedDetails{LpaID: "123"}, expectedError) + Return(&donordata.Provided{LpaID: "123"}, expectedError) err := Dashboard(nil, donorStore, nil)(AppData{}, w, r) resp := w.Result() diff --git a/internal/page/data.go b/internal/page/data.go index d247550173..2952dfdb4e 100644 --- a/internal/page/data.go +++ b/internal/page/data.go @@ -12,65 +12,65 @@ package page import ( - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" ) var SessionDataFromContext = appcontext.SessionDataFromContext var ContextWithSessionData = appcontext.ContextWithSessionData -func ChooseAttorneysState(attorneys donordata.Attorneys, decisions donordata.AttorneyDecisions) actor.TaskState { +func ChooseAttorneysState(attorneys donordata.Attorneys, decisions donordata.AttorneyDecisions) task.State { if attorneys.Len() == 0 { - return actor.TaskNotStarted + return task.StateNotStarted } if !attorneys.Complete() { - return actor.TaskInProgress + return task.StateInProgress } if attorneys.Len() > 1 && !decisions.IsComplete() { - return actor.TaskInProgress + return task.StateInProgress } - return actor.TaskCompleted + return task.StateCompleted } -func ChooseReplacementAttorneysState(donor *donordata.DonorProvidedDetails) actor.TaskState { +func ChooseReplacementAttorneysState(donor *donordata.Provided) task.State { if donor.WantReplacementAttorneys == form.No { - return actor.TaskCompleted + return task.StateCompleted } if donor.ReplacementAttorneys.Len() == 0 { if donor.WantReplacementAttorneys.IsUnknown() { - return actor.TaskNotStarted + return task.StateNotStarted } - return actor.TaskInProgress + return task.StateInProgress } if !donor.ReplacementAttorneys.Complete() { - return actor.TaskInProgress + return task.StateInProgress } if donor.ReplacementAttorneys.Len() > 1 && (donor.Attorneys.Len() == 1 || donor.AttorneyDecisions.How.IsJointly()) && !donor.ReplacementAttorneyDecisions.IsComplete() { - return actor.TaskInProgress + return task.StateInProgress } if donor.AttorneyDecisions.How.IsJointlyAndSeverally() { if donor.HowShouldReplacementAttorneysStepIn.Empty() { - return actor.TaskInProgress + return task.StateInProgress } if donor.ReplacementAttorneys.Len() > 1 && donor.HowShouldReplacementAttorneysStepIn.IsWhenAllCanNoLongerAct() && !donor.ReplacementAttorneyDecisions.IsComplete() { - return actor.TaskInProgress + return task.StateInProgress } } - return actor.TaskCompleted + return task.StateCompleted } diff --git a/internal/page/data_test.go b/internal/page/data_test.go index 71ff881aa9..148d55377c 100644 --- a/internal/page/data_test.go +++ b/internal/page/data_test.go @@ -3,7 +3,6 @@ package page import ( "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/pay" @@ -16,43 +15,43 @@ func TestChooseAttorneysState(t *testing.T) { testcases := map[string]struct { attorneys donordata.Attorneys decisions donordata.AttorneyDecisions - taskState actor.TaskState + taskState task.State }{ "empty": { - taskState: actor.TaskNotStarted, + taskState: task.StateNotStarted, }, "trust corporation": { attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{ Name: "a", Address: place.Address{Line1: "a"}, }}, - taskState: actor.TaskCompleted, + taskState: task.StateCompleted, }, "trust corporation incomplete": { attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{ Name: "a", }}, - taskState: actor.TaskInProgress, + taskState: task.StateInProgress, }, "single with email": { attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ FirstNames: "a", Email: "a", }}}, - taskState: actor.TaskInProgress, + taskState: task.StateInProgress, }, "single with address": { attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ FirstNames: "a", Address: place.Address{Line1: "a"}, }}}, - taskState: actor.TaskCompleted, + taskState: task.StateCompleted, }, "single incomplete": { attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ FirstNames: "a", }}}, - taskState: actor.TaskInProgress, + taskState: task.StateInProgress, }, "multiple without decisions": { attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ @@ -62,7 +61,7 @@ func TestChooseAttorneysState(t *testing.T) { FirstNames: "b", Address: testAddress, }}}, - taskState: actor.TaskInProgress, + taskState: task.StateInProgress, }, "multiple with decisions": { attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ @@ -73,7 +72,7 @@ func TestChooseAttorneysState(t *testing.T) { Address: testAddress, }}}, decisions: donordata.AttorneyDecisions{How: donordata.JointlyAndSeverally}, - taskState: actor.TaskCompleted, + taskState: task.StateCompleted, }, "multiple incomplete with decisions": { attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ @@ -83,7 +82,7 @@ func TestChooseAttorneysState(t *testing.T) { Address: testAddress, }}}, decisions: donordata.AttorneyDecisions{How: donordata.JointlyAndSeverally}, - taskState: actor.TaskInProgress, + taskState: task.StateInProgress, }, } @@ -101,18 +100,18 @@ func TestChooseReplacementAttorneysState(t *testing.T) { attorneyDecisions donordata.AttorneyDecisions howReplacementsStepIn donordata.ReplacementAttorneysStepIn replacementAttorneyDecisions donordata.AttorneyDecisions - taskState actor.TaskState + taskState task.State }{ "empty": { - taskState: actor.TaskNotStarted, + taskState: task.StateNotStarted, }, "do not want": { want: form.No, - taskState: actor.TaskCompleted, + taskState: task.StateCompleted, }, "do want": { want: form.Yes, - taskState: actor.TaskInProgress, + taskState: task.StateInProgress, }, "single with email": { want: form.Yes, @@ -120,7 +119,7 @@ func TestChooseReplacementAttorneysState(t *testing.T) { FirstNames: "a", Email: "a", }}}, - taskState: actor.TaskInProgress, + taskState: task.StateInProgress, }, "single with address": { want: form.Yes, @@ -128,14 +127,14 @@ func TestChooseReplacementAttorneysState(t *testing.T) { FirstNames: "a", Address: place.Address{Line1: "a"}, }}}, - taskState: actor.TaskCompleted, + taskState: task.StateCompleted, }, "single incomplete": { want: form.Yes, replacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ FirstNames: "a", }}}, - taskState: actor.TaskInProgress, + taskState: task.StateInProgress, }, "multiple without decisions": { want: form.Yes, @@ -146,7 +145,7 @@ func TestChooseReplacementAttorneysState(t *testing.T) { FirstNames: "b", Address: testAddress, }}}, - taskState: actor.TaskCompleted, + taskState: task.StateCompleted, }, "multiple jointly and severally": { want: form.Yes, @@ -158,7 +157,7 @@ func TestChooseReplacementAttorneysState(t *testing.T) { Address: testAddress, }}}, replacementAttorneyDecisions: donordata.AttorneyDecisions{How: donordata.JointlyAndSeverally}, - taskState: actor.TaskCompleted, + taskState: task.StateCompleted, }, "multiple jointly": { want: form.Yes, @@ -170,7 +169,7 @@ func TestChooseReplacementAttorneysState(t *testing.T) { Address: testAddress, }}}, replacementAttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, - taskState: actor.TaskCompleted, + taskState: task.StateCompleted, }, "multiple jointly for some severally for others": { want: form.Yes, @@ -182,7 +181,7 @@ func TestChooseReplacementAttorneysState(t *testing.T) { Address: testAddress, }}}, replacementAttorneyDecisions: donordata.AttorneyDecisions{How: donordata.JointlyForSomeSeverallyForOthers}, - taskState: actor.TaskCompleted, + taskState: task.StateCompleted, }, "jointly and severally attorneys single": { want: form.Yes, @@ -191,7 +190,7 @@ func TestChooseReplacementAttorneysState(t *testing.T) { Address: testAddress, }}}, attorneyDecisions: donordata.AttorneyDecisions{How: donordata.JointlyAndSeverally}, - taskState: actor.TaskInProgress, + taskState: task.StateInProgress, }, "jointly and severally attorneys single with step in": { want: form.Yes, @@ -201,7 +200,7 @@ func TestChooseReplacementAttorneysState(t *testing.T) { }}}, attorneyDecisions: donordata.AttorneyDecisions{How: donordata.JointlyAndSeverally}, howReplacementsStepIn: donordata.ReplacementAttorneysStepInWhenAllCanNoLongerAct, - taskState: actor.TaskCompleted, + taskState: task.StateCompleted, }, "jointly attorneys single": { want: form.Yes, @@ -210,7 +209,7 @@ func TestChooseReplacementAttorneysState(t *testing.T) { Address: testAddress, }}}, attorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, - taskState: actor.TaskCompleted, + taskState: task.StateCompleted, }, "jointly for some severally for others attorneys single": { want: form.Yes, @@ -219,7 +218,7 @@ func TestChooseReplacementAttorneysState(t *testing.T) { Address: testAddress, }}}, attorneyDecisions: donordata.AttorneyDecisions{How: donordata.JointlyForSomeSeverallyForOthers}, - taskState: actor.TaskCompleted, + taskState: task.StateCompleted, }, "jointly for some severally for others attorneys multiple": { want: form.Yes, @@ -231,7 +230,7 @@ func TestChooseReplacementAttorneysState(t *testing.T) { Address: testAddress, }}}, attorneyDecisions: donordata.AttorneyDecisions{How: donordata.JointlyForSomeSeverallyForOthers}, - taskState: actor.TaskCompleted, + taskState: task.StateCompleted, }, "jointly and severally attorneys multiple": { want: form.Yes, @@ -243,7 +242,7 @@ func TestChooseReplacementAttorneysState(t *testing.T) { Address: testAddress, }}}, attorneyDecisions: donordata.AttorneyDecisions{How: donordata.JointlyAndSeverally}, - taskState: actor.TaskInProgress, + taskState: task.StateInProgress, }, "jointly and severally attorneys multiple with step in": { want: form.Yes, @@ -256,7 +255,7 @@ func TestChooseReplacementAttorneysState(t *testing.T) { }}}, attorneyDecisions: donordata.AttorneyDecisions{How: donordata.JointlyAndSeverally}, howReplacementsStepIn: donordata.ReplacementAttorneysStepInWhenOneCanNoLongerAct, - taskState: actor.TaskCompleted, + taskState: task.StateCompleted, }, "jointly and severally attorneys multiple with step in when none can act": { want: form.Yes, @@ -269,7 +268,7 @@ func TestChooseReplacementAttorneysState(t *testing.T) { }}}, attorneyDecisions: donordata.AttorneyDecisions{How: donordata.JointlyAndSeverally}, howReplacementsStepIn: donordata.ReplacementAttorneysStepInWhenAllCanNoLongerAct, - taskState: actor.TaskInProgress, + taskState: task.StateInProgress, }, "jointly and severally attorneys multiple with step in when none can act jointly": { want: form.Yes, @@ -283,7 +282,7 @@ func TestChooseReplacementAttorneysState(t *testing.T) { attorneyDecisions: donordata.AttorneyDecisions{How: donordata.JointlyAndSeverally}, howReplacementsStepIn: donordata.ReplacementAttorneysStepInWhenAllCanNoLongerAct, replacementAttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, - taskState: actor.TaskCompleted, + taskState: task.StateCompleted, }, "jointly and severally attorneys multiple with step in when none can act jointly for some severally for others": { want: form.Yes, @@ -297,7 +296,7 @@ func TestChooseReplacementAttorneysState(t *testing.T) { attorneyDecisions: donordata.AttorneyDecisions{How: donordata.JointlyAndSeverally}, howReplacementsStepIn: donordata.ReplacementAttorneysStepInWhenAllCanNoLongerAct, replacementAttorneyDecisions: donordata.AttorneyDecisions{How: donordata.JointlyForSomeSeverallyForOthers}, - taskState: actor.TaskCompleted, + taskState: task.StateCompleted, }, "jointly attorneys multiple without decisions": { want: form.Yes, @@ -309,7 +308,7 @@ func TestChooseReplacementAttorneysState(t *testing.T) { Address: testAddress, }}}, attorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, - taskState: actor.TaskInProgress, + taskState: task.StateInProgress, }, "jointly attorneys multiple jointly and severally": { want: form.Yes, @@ -322,7 +321,7 @@ func TestChooseReplacementAttorneysState(t *testing.T) { }}}, attorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, replacementAttorneyDecisions: donordata.AttorneyDecisions{How: donordata.JointlyAndSeverally}, - taskState: actor.TaskCompleted, + taskState: task.StateCompleted, }, "jointly attorneys multiple with jointly": { want: form.Yes, @@ -335,7 +334,7 @@ func TestChooseReplacementAttorneysState(t *testing.T) { }}}, attorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, replacementAttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, - taskState: actor.TaskCompleted, + taskState: task.StateCompleted, }, "jointly attorneys multiple jointly for some severally for others": { want: form.Yes, @@ -348,13 +347,13 @@ func TestChooseReplacementAttorneysState(t *testing.T) { }}}, attorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, replacementAttorneyDecisions: donordata.AttorneyDecisions{How: donordata.JointlyForSomeSeverallyForOthers}, - taskState: actor.TaskCompleted, + taskState: task.StateCompleted, }, } for name, tc := range testcases { t.Run(name, func(t *testing.T) { - assert.Equal(t, tc.taskState, ChooseReplacementAttorneysState(&donordata.DonorProvidedDetails{ + assert.Equal(t, tc.taskState, ChooseReplacementAttorneysState(&donordata.Provided{ WantReplacementAttorneys: tc.want, AttorneyDecisions: tc.attorneyDecisions, ReplacementAttorneys: tc.replacementAttorneys, @@ -367,15 +366,15 @@ func TestChooseReplacementAttorneysState(t *testing.T) { func TestLpaCost(t *testing.T) { testCases := map[string]struct { - donor *donordata.DonorProvidedDetails + donor *donordata.Provided expected int }{ "denied": { - donor: &donordata.DonorProvidedDetails{FeeType: pay.HalfFee, Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateDenied}}, + donor: &donordata.Provided{FeeType: pay.HalfFee, Tasks: donordata.Tasks{PayForLpa: task.PaymentStateDenied}}, expected: 8200, }, "half": { - donor: &donordata.DonorProvidedDetails{FeeType: pay.HalfFee}, + donor: &donordata.Provided{FeeType: pay.HalfFee}, expected: 4100, }, } @@ -389,23 +388,23 @@ func TestLpaCost(t *testing.T) { func TestFeeAmount(t *testing.T) { testCases := map[string]struct { - Donor *donordata.DonorProvidedDetails + Donor *donordata.Provided ExpectedCost pay.AmountPence }{ "not paid": { - Donor: &donordata.DonorProvidedDetails{FeeType: pay.HalfFee}, + Donor: &donordata.Provided{FeeType: pay.HalfFee}, ExpectedCost: pay.AmountPence(4100), }, "fully paid": { - Donor: &donordata.DonorProvidedDetails{FeeType: pay.HalfFee, PaymentDetails: []donordata.Payment{{Amount: 4100}}}, + Donor: &donordata.Provided{FeeType: pay.HalfFee, PaymentDetails: []donordata.Payment{{Amount: 4100}}}, ExpectedCost: pay.AmountPence(0), }, "denied partially paid": { - Donor: &donordata.DonorProvidedDetails{FeeType: pay.HalfFee, PaymentDetails: []donordata.Payment{{Amount: 4100}}, Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateDenied}}, + Donor: &donordata.Provided{FeeType: pay.HalfFee, PaymentDetails: []donordata.Payment{{Amount: 4100}}, Tasks: donordata.Tasks{PayForLpa: task.PaymentStateDenied}}, ExpectedCost: pay.AmountPence(4100), }, "denied fully paid": { - Donor: &donordata.DonorProvidedDetails{FeeType: pay.HalfFee, PaymentDetails: []donordata.Payment{{Amount: 4100}, {Amount: 4100}}, Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateDenied}}, + Donor: &donordata.Provided{FeeType: pay.HalfFee, PaymentDetails: []donordata.Payment{{Amount: 4100}, {Amount: 4100}}, Tasks: donordata.Tasks{PayForLpa: task.PaymentStateDenied}}, ExpectedCost: pay.AmountPence(0), }, } @@ -510,7 +509,7 @@ func TestCertificateProviderSharesDetailsNames(t *testing.T) { for name, tc := range testcases { t.Run(name, func(t *testing.T) { - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ Donor: donordata.Donor{LastName: tc.donor}, CertificateProvider: donordata.CertificateProvider{LastName: tc.certificateProvider, Address: place.Address{Line1: "x"}}, } @@ -564,7 +563,7 @@ func TestCertificateProviderSharesDetailsAddresses(t *testing.T) { for name, tc := range testcases { t.Run(name, func(t *testing.T) { - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ Donor: donordata.Donor{Address: tc.donor}, CertificateProvider: donordata.CertificateProvider{LastName: "x", Address: tc.certificateProvider}, } diff --git a/internal/page/fixtures/attorney.go b/internal/page/fixtures/attorney.go index c56ce55941..3d98c6c9c1 100644 --- a/internal/page/fixtures/attorney.go +++ b/internal/page/fixtures/attorney.go @@ -9,7 +9,6 @@ import ( "time" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" @@ -22,23 +21,25 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/random" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/uid" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) type DonorStore interface { - Create(ctx context.Context) (*donordata.DonorProvidedDetails, error) - Link(ctx context.Context, shareCode actor.ShareCodeData, donorEmail string) error - Put(ctx context.Context, donorProvidedDetails *donordata.DonorProvidedDetails) error + Create(ctx context.Context) (*donordata.Provided, error) + Link(ctx context.Context, shareCode sharecode.Data, donorEmail string) error + Put(ctx context.Context, donorProvidedDetails *donordata.Provided) error } type CertificateProviderStore interface { - Create(ctx context.Context, shareCode actor.ShareCodeData, email string) (*certificateproviderdata.Provided, error) + Create(ctx context.Context, shareCode sharecode.Data, email string) (*certificateproviderdata.Provided, error) Put(ctx context.Context, certificateProvider *certificateproviderdata.Provided) error } type AttorneyStore interface { - Create(ctx context.Context, shareCode actor.ShareCodeData, email string) (*attorneydata.Provided, error) + Create(ctx context.Context, shareCode sharecode.Data, email string) (*attorneydata.Provided, error) Put(ctx context.Context, attorney *attorneydata.Provided) error } @@ -131,7 +132,7 @@ func Attorney( } if isSupported { - if err := donorStore.Link(page.ContextWithSessionData(r.Context(), createSession), actor.ShareCodeData{ + if err := donorStore.Link(page.ContextWithSessionData(r.Context(), createSession), sharecode.Data{ LpaKey: donorDetails.PK, LpaOwnerKey: donorDetails.SK, }, donorDetails.Donor.Email); err != nil { @@ -241,15 +242,15 @@ func Attorney( if progress >= slices.Index(progressValues, "confirmYourDetails") { attorney.Mobile = testMobile attorney.ContactLanguagePreference = localize.En - attorney.Tasks.ConfirmYourDetails = actor.TaskCompleted + attorney.Tasks.ConfirmYourDetails = task.StateCompleted } if progress >= slices.Index(progressValues, "readTheLPA") { - attorney.Tasks.ReadTheLpa = actor.TaskCompleted + attorney.Tasks.ReadTheLpa = task.StateCompleted } if progress >= slices.Index(progressValues, "signedByAttorney") { - attorney.Tasks.SignTheLpa = actor.TaskCompleted + attorney.Tasks.SignTheLpa = task.StateCompleted if isTrustCorporation { attorney.WouldLikeSecondSignatory = form.No @@ -286,9 +287,9 @@ func Attorney( attorney.Mobile = testMobile attorney.ContactLanguagePreference = localize.En - attorney.Tasks.ConfirmYourDetails = actor.TaskCompleted - attorney.Tasks.ReadTheLpa = actor.TaskCompleted - attorney.Tasks.SignTheLpa = actor.TaskCompleted + attorney.Tasks.ConfirmYourDetails = task.StateCompleted + attorney.Tasks.ReadTheLpa = task.StateCompleted + attorney.Tasks.SignTheLpa = task.StateCompleted attorney.SignedAt = donorDetails.SignedAt.Add(2 * time.Hour) if err := attorneyStore.Put(ctx, attorney); err != nil { @@ -317,9 +318,9 @@ func Attorney( attorney.Mobile = testMobile attorney.ContactLanguagePreference = localize.En - attorney.Tasks.ConfirmYourDetails = actor.TaskCompleted - attorney.Tasks.ReadTheLpa = actor.TaskCompleted - attorney.Tasks.SignTheLpa = actor.TaskCompleted + attorney.Tasks.ConfirmYourDetails = task.StateCompleted + attorney.Tasks.ReadTheLpa = task.StateCompleted + attorney.Tasks.SignTheLpa = task.StateCompleted attorney.WouldLikeSecondSignatory = form.No attorney.AuthorisedSignatories = [2]attorneydata.TrustCorporationSignatory{{ FirstNames: "A", diff --git a/internal/page/fixtures/certificate_provider.go b/internal/page/fixtures/certificate_provider.go index d4e9c719f2..38a5acc638 100644 --- a/internal/page/fixtures/certificate_provider.go +++ b/internal/page/fixtures/certificate_provider.go @@ -7,7 +7,6 @@ import ( "time" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/date" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" @@ -20,6 +19,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/place" "github.com/ministryofjustice/opg-modernising-lpa/internal/random" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/uid" ) @@ -84,11 +84,11 @@ func CertificateProvider( return err } - var donorDetails *donordata.DonorProvidedDetails + var donorDetails *donordata.Provided if donorChannel == "paper" { lpaID := random.UuidString() - donorDetails = &donordata.DonorProvidedDetails{ + donorDetails = &donordata.Provided{ PK: dynamo.LpaKey(lpaID), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("PAPER")), LpaID: lpaID, @@ -121,7 +121,7 @@ func CertificateProvider( return err } - if err := donorStore.Link(page.ContextWithSessionData(r.Context(), orgSession), actor.ShareCodeData{ + if err := donorStore.Link(page.ContextWithSessionData(r.Context(), orgSession), sharecode.Data{ LpaKey: donorDetails.PK, LpaOwnerKey: donorDetails.SK, }, donorDetails.Donor.Email); err != nil { @@ -196,7 +196,7 @@ func CertificateProvider( } if progress >= slices.Index(progressValues, "signedByDonor") { - donorDetails.Tasks.ConfirmYourIdentityAndSign = actor.IdentityTaskCompleted + donorDetails.Tasks.ConfirmYourIdentityAndSign = task.IdentityStateCompleted donorDetails.WitnessedByCertificateProviderAt = time.Now() donorDetails.SignedAt = time.Now() } @@ -204,7 +204,7 @@ func CertificateProvider( if progress >= slices.Index(progressValues, "confirmYourDetails") { certificateProvider.DateOfBirth = date.New("1990", "1", "2") certificateProvider.ContactLanguagePreference = localize.En - certificateProvider.Tasks.ConfirmYourDetails = actor.TaskCompleted + certificateProvider.Tasks.ConfirmYourDetails = task.StateCompleted if asProfessionalCertificateProvider { certificateProvider.HomeAddress = place.Address{ @@ -225,7 +225,7 @@ func CertificateProvider( LastName: donorDetails.CertificateProvider.LastName, DateOfBirth: certificateProvider.DateOfBirth, } - certificateProvider.Tasks.ConfirmYourIdentity = actor.TaskCompleted + certificateProvider.Tasks.ConfirmYourIdentity = task.StateCompleted } if err := donorStore.Put(donorCtx, donorDetails); err != nil { diff --git a/internal/page/fixtures/donor.go b/internal/page/fixtures/donor.go index 5c9e3a75eb..1c52c27af2 100644 --- a/internal/page/fixtures/donor.go +++ b/internal/page/fixtures/donor.go @@ -10,7 +10,6 @@ import ( "time" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" @@ -37,7 +36,7 @@ type DynamoClient interface { type DocumentStore interface { GetAll(context.Context) (page.Documents, error) Put(context.Context, page.Document) error - Create(ctx context.Context, donor *donordata.DonorProvidedDetails, filename string, data []byte) (page.Document, error) + Create(ctx context.Context, donor *donordata.Provided, filename string, data []byte) (page.Document, error) } var progressValues = []string{ @@ -172,7 +171,7 @@ func Donor( func updateLPAProgress( data FixtureData, - donorDetails *donordata.DonorProvidedDetails, + donorDetails *donordata.Provided, donorSessionID string, r *http.Request, certificateProviderStore CertificateProviderStore, @@ -180,7 +179,7 @@ func updateLPAProgress( documentStore DocumentStore, eventClient *event.Client, shareCodeStore ShareCodeStore, -) (*donordata.DonorProvidedDetails, []func(context.Context, *lpastore.Client, *lpastore.Lpa) error, error) { +) (*donordata.Provided, []func(context.Context, *lpastore.Client, *lpastore.Lpa) error, error) { var fns []func(context.Context, *lpastore.Client, *lpastore.Lpa) error if data.Progress >= slices.Index(progressValues, "provideYourDetails") { @@ -224,10 +223,10 @@ func updateLPAProgress( LastName: "Irwin", } - donorDetails.Tasks.ChooseYourSignatory = actor.TaskCompleted + donorDetails.Tasks.ChooseYourSignatory = task.StateCompleted } - donorDetails.Tasks.YourDetails = actor.TaskCompleted + donorDetails.Tasks.YourDetails = task.StateCompleted } var withoutAddressUID actoruid.UID @@ -256,7 +255,7 @@ func updateLPAProgress( donorDetails.AttorneyDecisions.Details = "do this and that" } - donorDetails.Tasks.ChooseAttorneys = actor.TaskCompleted + donorDetails.Tasks.ChooseAttorneys = task.StateCompleted } if data.Progress >= slices.Index(progressValues, "chooseYourReplacementAttorneys") { @@ -277,22 +276,22 @@ func updateLPAProgress( donorDetails.HowShouldReplacementAttorneysStepIn = donordata.ReplacementAttorneysStepIn(0) } - donorDetails.Tasks.ChooseReplacementAttorneys = actor.TaskCompleted + donorDetails.Tasks.ChooseReplacementAttorneys = task.StateCompleted } if data.Progress >= slices.Index(progressValues, "chooseWhenTheLpaCanBeUsed") { if donorDetails.Type == donordata.LpaTypePersonalWelfare { donorDetails.LifeSustainingTreatmentOption = donordata.LifeSustainingTreatmentOptionA - donorDetails.Tasks.LifeSustainingTreatment = actor.TaskCompleted + donorDetails.Tasks.LifeSustainingTreatment = task.StateCompleted } else { donorDetails.WhenCanTheLpaBeUsed = donordata.CanBeUsedWhenHasCapacity - donorDetails.Tasks.WhenCanTheLpaBeUsed = actor.TaskCompleted + donorDetails.Tasks.WhenCanTheLpaBeUsed = task.StateCompleted } } if data.Progress >= slices.Index(progressValues, "addRestrictionsToTheLpa") { donorDetails.Restrictions = "My attorneys must not sell my home unless, in my doctor’s opinion, I can no longer live independently" - donorDetails.Tasks.Restrictions = actor.TaskCompleted + donorDetails.Tasks.Restrictions = task.StateCompleted } if data.Progress >= slices.Index(progressValues, "chooseYourCertificateProvider") { @@ -309,7 +308,7 @@ func updateLPAProgress( donorDetails.CertificateProvider.Mobile = data.CertificateProviderMobile } - donorDetails.Tasks.CertificateProvider = actor.TaskCompleted + donorDetails.Tasks.CertificateProvider = task.StateCompleted } if data.Progress >= slices.Index(progressValues, "peopleToNotifyAboutYourLpa") { @@ -323,7 +322,7 @@ func updateLPAProgress( donorDetails.PeopleToNotify = append(donorDetails.PeopleToNotify, makePersonToNotify(peopleToNotifyNames[2]), makePersonToNotify(peopleToNotifyNames[3]), makePersonToNotify(peopleToNotifyNames[4])) } - donorDetails.Tasks.PeopleToNotify = actor.TaskCompleted + donorDetails.Tasks.PeopleToNotify = task.StateCompleted } if data.Progress >= slices.Index(progressValues, "addCorrespondent") { @@ -333,12 +332,12 @@ func updateLPAProgress( Lastname: "Ashfurlong", }) - donorDetails.Tasks.AddCorrespondent = actor.TaskCompleted + donorDetails.Tasks.AddCorrespondent = task.StateCompleted } if data.Progress >= slices.Index(progressValues, "checkAndSendToYourCertificateProvider") { donorDetails.CheckedAt = time.Now() - donorDetails.Tasks.CheckYourLpa = actor.TaskCompleted + donorDetails.Tasks.CheckYourLpa = task.StateCompleted } if data.Progress >= slices.Index(progressValues, "payForTheLpa") { @@ -435,7 +434,7 @@ func updateLPAProgress( } donorDetails.DonorIdentityUserData = userData - donorDetails.Tasks.ConfirmYourIdentityAndSign = actor.IdentityTaskInProgress + donorDetails.Tasks.ConfirmYourIdentityAndSign = task.IdentityStateInProgress } if data.Progress >= slices.Index(progressValues, "signTheLpa") { @@ -443,7 +442,7 @@ func updateLPAProgress( donorDetails.WantToSignLpa = true donorDetails.SignedAt = time.Date(2023, time.January, 2, 3, 4, 5, 6, time.UTC) donorDetails.WitnessedByCertificateProviderAt = time.Date(2023, time.January, 2, 3, 4, 5, 6, time.UTC) - donorDetails.Tasks.ConfirmYourIdentityAndSign = actor.IdentityTaskCompleted + donorDetails.Tasks.ConfirmYourIdentityAndSign = task.IdentityStateCompleted } var certificateProviderUID actoruid.UID @@ -491,9 +490,9 @@ func updateLPAProgress( attorney.Mobile = testMobile attorney.ContactLanguagePreference = localize.En - attorney.Tasks.ConfirmYourDetails = actor.TaskCompleted - attorney.Tasks.ReadTheLpa = actor.TaskCompleted - attorney.Tasks.SignTheLpa = actor.TaskCompleted + attorney.Tasks.ConfirmYourDetails = task.StateCompleted + attorney.Tasks.ReadTheLpa = task.StateCompleted + attorney.Tasks.SignTheLpa = task.StateCompleted attorney.SignedAt = donorDetails.SignedAt.Add(2 * time.Hour) if err := attorneyStore.Put(ctx, attorney); err != nil { @@ -523,9 +522,9 @@ func updateLPAProgress( } attorney.Mobile = testMobile - attorney.Tasks.ConfirmYourDetails = actor.TaskCompleted - attorney.Tasks.ReadTheLpa = actor.TaskCompleted - attorney.Tasks.SignTheLpa = actor.TaskCompleted + attorney.Tasks.ConfirmYourDetails = task.StateCompleted + attorney.Tasks.ReadTheLpa = task.StateCompleted + attorney.Tasks.SignTheLpa = task.StateCompleted attorney.WouldLikeSecondSignatory = form.No attorney.AuthorisedSignatories = [2]attorneydata.TrustCorporationSignatory{{ FirstNames: "A", diff --git a/internal/page/fixtures/fixtures.go b/internal/page/fixtures/fixtures.go index 5f0b877738..87583eaaef 100644 --- a/internal/page/fixtures/fixtures.go +++ b/internal/page/fixtures/fixtures.go @@ -19,6 +19,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" "github.com/ministryofjustice/opg-modernising-lpa/internal/random" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -214,7 +215,7 @@ func acceptCookiesConsent(w http.ResponseWriter) { func createAttorney(ctx context.Context, shareCodeStore ShareCodeStore, attorneyStore AttorneyStore, actorUID actoruid.UID, isReplacement, isTrustCorporation bool, lpaOwnerKey dynamo.LpaOwnerKeyType, email string) (*attorneydata.Provided, error) { shareCode := random.String(16) - shareCodeData := actor.ShareCodeData{ + shareCodeData := sharecode.Data{ PK: dynamo.ShareKey(dynamo.AttorneyShareKey(shareCode)), SK: dynamo.ShareSortKey(dynamo.MetadataKey(shareCode)), ActorUID: actorUID, @@ -238,7 +239,7 @@ func createAttorney(ctx context.Context, shareCodeStore ShareCodeStore, attorney func createCertificateProvider(ctx context.Context, shareCodeStore ShareCodeStore, certificateProviderStore CertificateProviderStore, actorUID actoruid.UID, lpaOwnerKey dynamo.LpaOwnerKeyType, email string) (*certificateproviderdata.Provided, error) { shareCode := random.String(16) - shareCodeData := actor.ShareCodeData{ + shareCodeData := sharecode.Data{ PK: dynamo.ShareKey(dynamo.CertificateProviderShareKey(shareCode)), SK: dynamo.ShareSortKey(dynamo.MetadataKey(shareCode)), ActorUID: actorUID, diff --git a/internal/page/fixtures/supporter.go b/internal/page/fixtures/supporter.go index 6f29797e37..7cbdbccf1b 100644 --- a/internal/page/fixtures/supporter.go +++ b/internal/page/fixtures/supporter.go @@ -20,11 +20,13 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/random" "github.com/ministryofjustice/opg-modernising-lpa/internal/search" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" ) type OrganisationStore interface { Create(context.Context, *actor.Member, string) (*actor.Organisation, error) - CreateLPA(context.Context) (*donordata.DonorProvidedDetails, error) + CreateLPA(context.Context) (*donordata.Provided, error) } type MemberStore interface { @@ -35,8 +37,8 @@ type MemberStore interface { } type ShareCodeStore interface { - Put(ctx context.Context, actorType actor.Type, shareCode string, data actor.ShareCodeData) error - PutDonor(ctx context.Context, code string, data actor.ShareCodeData) error + Put(ctx context.Context, actorType actor.Type, shareCode string, data sharecode.Data) error + PutDonor(ctx context.Context, code string, data sharecode.Data) error } func Supporter( @@ -115,15 +117,15 @@ func Supporter( donor.Attorneys = donordata.Attorneys{ Attorneys: []donordata.Attorney{makeAttorney(attorneyNames[0])}, } - donor.Tasks.YourDetails = actor.TaskCompleted - donor.Tasks.ChooseAttorneys = actor.TaskCompleted - donor.Tasks.CertificateProvider = actor.TaskCompleted + donor.Tasks.YourDetails = task.StateCompleted + donor.Tasks.ChooseAttorneys = task.StateCompleted + donor.Tasks.CertificateProvider = task.StateCompleted if err := donorStore.Put(donorCtx, donor); err != nil { return err } - shareCodeData := actor.ShareCodeData{ + shareCodeData := sharecode.Data{ LpaOwnerKey: dynamo.LpaOwnerKey(org.PK), LpaKey: donor.PK, ActorUID: donor.Donor.UID, diff --git a/internal/page/lpa_progress_tracker.go b/internal/page/lpa_progress_tracker.go index e5b386a962..0185ea8cdc 100644 --- a/internal/page/lpa_progress_tracker.go +++ b/internal/page/lpa_progress_tracker.go @@ -1,8 +1,8 @@ package page import ( - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" ) type ProgressTracker struct { @@ -10,7 +10,7 @@ type ProgressTracker struct { } type ProgressTask struct { - State actor.TaskState + State task.State Label string } @@ -91,90 +91,90 @@ func (pt ProgressTracker) Progress(lpa *lpastore.Lpa) Progress { progress := Progress{ isOrganisation: lpa.IsOrganisationDonor, Paid: ProgressTask{ - State: actor.TaskNotStarted, + State: task.StateNotStarted, Label: labels["paid"], }, ConfirmedID: ProgressTask{ - State: actor.TaskNotStarted, + State: task.StateNotStarted, Label: labels["confirmedID"], }, DonorSigned: ProgressTask{ - State: actor.TaskNotStarted, + State: task.StateNotStarted, Label: labels["donorSigned"], }, CertificateProviderSigned: ProgressTask{ - State: actor.TaskNotStarted, + State: task.StateNotStarted, Label: labels["certificateProviderSigned"], }, AttorneysSigned: ProgressTask{ - State: actor.TaskNotStarted, + State: task.StateNotStarted, Label: labels["attorneysSigned"], }, LpaSubmitted: ProgressTask{ - State: actor.TaskNotStarted, + State: task.StateNotStarted, Label: labels["lpaSubmitted"], }, NoticesOfIntentSent: ProgressTask{ - State: actor.TaskNotStarted, + State: task.StateNotStarted, }, StatutoryWaitingPeriod: ProgressTask{ - State: actor.TaskNotStarted, + State: task.StateNotStarted, Label: labels["statutoryWaitingPeriod"], }, LpaRegistered: ProgressTask{ - State: actor.TaskNotStarted, + State: task.StateNotStarted, Label: labels["lpaRegistered"], }, } if lpa.IsOrganisationDonor { - progress.Paid.State = actor.TaskInProgress + progress.Paid.State = task.StateInProgress if !lpa.Paid { return progress } - progress.Paid.State = actor.TaskCompleted - progress.ConfirmedID.State = actor.TaskInProgress + progress.Paid.State = task.StateCompleted + progress.ConfirmedID.State = task.StateInProgress if lpa.Donor.IdentityCheck.CheckedAt.IsZero() { return progress } - progress.ConfirmedID.State = actor.TaskCompleted - progress.DonorSigned.State = actor.TaskInProgress + progress.ConfirmedID.State = task.StateCompleted + progress.DonorSigned.State = task.StateInProgress if lpa.SignedAt.IsZero() { return progress } } else { - progress.DonorSigned.State = actor.TaskInProgress + progress.DonorSigned.State = task.StateInProgress if lpa.SignedAt.IsZero() { return progress } } - progress.DonorSigned.State = actor.TaskCompleted - progress.CertificateProviderSigned.State = actor.TaskInProgress + progress.DonorSigned.State = task.StateCompleted + progress.CertificateProviderSigned.State = task.StateInProgress if lpa.CertificateProvider.SignedAt.IsZero() { return progress } - progress.CertificateProviderSigned.State = actor.TaskCompleted - progress.AttorneysSigned.State = actor.TaskInProgress + progress.CertificateProviderSigned.State = task.StateCompleted + progress.AttorneysSigned.State = task.StateInProgress if !lpa.AllAttorneysSigned() { return progress } - progress.AttorneysSigned.State = actor.TaskCompleted - progress.LpaSubmitted.State = actor.TaskInProgress + progress.AttorneysSigned.State = task.StateCompleted + progress.LpaSubmitted.State = task.StateInProgress if !lpa.Submitted { return progress } - progress.LpaSubmitted.State = actor.TaskCompleted + progress.LpaSubmitted.State = task.StateCompleted if lpa.PerfectAt.IsZero() { return progress @@ -183,15 +183,15 @@ func (pt ProgressTracker) Progress(lpa *lpastore.Lpa) Progress { progress.NoticesOfIntentSent.Label = pt.Localizer.Format(labels["noticesOfIntentSent"], map[string]any{ "SentOn": pt.Localizer.FormatDate(lpa.PerfectAt), }) - progress.NoticesOfIntentSent.State = actor.TaskCompleted - progress.StatutoryWaitingPeriod.State = actor.TaskInProgress + progress.NoticesOfIntentSent.State = task.StateCompleted + progress.StatutoryWaitingPeriod.State = task.StateInProgress if lpa.RegisteredAt.IsZero() { return progress } - progress.StatutoryWaitingPeriod.State = actor.TaskCompleted - progress.LpaRegistered.State = actor.TaskCompleted + progress.StatutoryWaitingPeriod.State = task.StateCompleted + progress.LpaRegistered.State = task.StateCompleted return progress } diff --git a/internal/page/lpa_progress_tracker_test.go b/internal/page/lpa_progress_tracker_test.go index f2d572e03f..8c16265c08 100644 --- a/internal/page/lpa_progress_tracker_test.go +++ b/internal/page/lpa_progress_tracker_test.go @@ -4,10 +4,10 @@ import ( "testing" "time" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/date" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" ) @@ -38,7 +38,7 @@ func TestProgressToSlice(t *testing.T) { } }, "donor notices sent": func(p Progress) (Progress, []ProgressTask) { - p.NoticesOfIntentSent.State = actor.TaskCompleted + p.NoticesOfIntentSent.State = task.StateCompleted return p, []ProgressTask{ p.DonorSigned, @@ -52,7 +52,7 @@ func TestProgressToSlice(t *testing.T) { }, "organisation notices sent": func(p Progress) (Progress, []ProgressTask) { p.isOrganisation = true - p.NoticesOfIntentSent.State = actor.TaskCompleted + p.NoticesOfIntentSent.State = task.StateCompleted return p, []ProgressTask{ p.Paid, @@ -71,15 +71,15 @@ func TestProgressToSlice(t *testing.T) { for name, fn := range testcases { t.Run(name, func(t *testing.T) { progress, slice := fn(Progress{ - Paid: ProgressTask{State: actor.TaskNotStarted, Label: "Paid translation"}, - ConfirmedID: ProgressTask{State: actor.TaskNotStarted, Label: "ConfirmedID translation"}, - DonorSigned: ProgressTask{State: actor.TaskInProgress, Label: "DonorSigned translation"}, - CertificateProviderSigned: ProgressTask{State: actor.TaskNotStarted, Label: "CertificateProviderSigned translation"}, - AttorneysSigned: ProgressTask{State: actor.TaskNotStarted, Label: "AttorneysSigned translation"}, - LpaSubmitted: ProgressTask{State: actor.TaskNotStarted, Label: "LpaSubmitted translation"}, - NoticesOfIntentSent: ProgressTask{State: actor.TaskNotStarted, Label: "NoticesOfIntentSent translation"}, - StatutoryWaitingPeriod: ProgressTask{State: actor.TaskNotStarted, Label: "StatutoryWaitingPeriod translation"}, - LpaRegistered: ProgressTask{State: actor.TaskNotStarted, Label: "LpaRegistered translation"}, + Paid: ProgressTask{State: task.StateNotStarted, Label: "Paid translation"}, + ConfirmedID: ProgressTask{State: task.StateNotStarted, Label: "ConfirmedID translation"}, + DonorSigned: ProgressTask{State: task.StateInProgress, Label: "DonorSigned translation"}, + CertificateProviderSigned: ProgressTask{State: task.StateNotStarted, Label: "CertificateProviderSigned translation"}, + AttorneysSigned: ProgressTask{State: task.StateNotStarted, Label: "AttorneysSigned translation"}, + LpaSubmitted: ProgressTask{State: task.StateNotStarted, Label: "LpaSubmitted translation"}, + NoticesOfIntentSent: ProgressTask{State: task.StateNotStarted, Label: "NoticesOfIntentSent translation"}, + StatutoryWaitingPeriod: ProgressTask{State: task.StateNotStarted, Label: "StatutoryWaitingPeriod translation"}, + LpaRegistered: ProgressTask{State: task.StateNotStarted, Label: "LpaRegistered translation"}, }) assert.Equal(t, slice, progress.ToSlice()) @@ -92,14 +92,14 @@ func TestProgressTrackerProgress(t *testing.T) { uid1 := actoruid.New() uid2 := actoruid.New() initialProgress := Progress{ - Paid: ProgressTask{State: actor.TaskNotStarted, Label: ""}, - ConfirmedID: ProgressTask{State: actor.TaskNotStarted, Label: ""}, - DonorSigned: ProgressTask{State: actor.TaskInProgress, Label: "DonorSigned translation"}, - CertificateProviderSigned: ProgressTask{State: actor.TaskNotStarted, Label: "CertificateProviderSigned translation"}, - AttorneysSigned: ProgressTask{State: actor.TaskNotStarted, Label: "AttorneysSigned translation"}, - LpaSubmitted: ProgressTask{State: actor.TaskNotStarted, Label: "LpaSubmitted translation"}, - StatutoryWaitingPeriod: ProgressTask{State: actor.TaskNotStarted, Label: "StatutoryWaitingPeriod translation"}, - LpaRegistered: ProgressTask{State: actor.TaskNotStarted, Label: "LpaRegistered translation"}, + Paid: ProgressTask{State: task.StateNotStarted, Label: ""}, + ConfirmedID: ProgressTask{State: task.StateNotStarted, Label: ""}, + DonorSigned: ProgressTask{State: task.StateInProgress, Label: "DonorSigned translation"}, + CertificateProviderSigned: ProgressTask{State: task.StateNotStarted, Label: "CertificateProviderSigned translation"}, + AttorneysSigned: ProgressTask{State: task.StateNotStarted, Label: "AttorneysSigned translation"}, + LpaSubmitted: ProgressTask{State: task.StateNotStarted, Label: "LpaSubmitted translation"}, + StatutoryWaitingPeriod: ProgressTask{State: task.StateNotStarted, Label: "StatutoryWaitingPeriod translation"}, + LpaRegistered: ProgressTask{State: task.StateNotStarted, Label: "LpaRegistered translation"}, } testCases := map[string]struct { @@ -150,8 +150,8 @@ func TestProgressTrackerProgress(t *testing.T) { }, expectedProgress: func() Progress { progress := initialProgress - progress.DonorSigned.State = actor.TaskCompleted - progress.CertificateProviderSigned.State = actor.TaskInProgress + progress.DonorSigned.State = task.StateCompleted + progress.CertificateProviderSigned.State = task.StateInProgress return progress }, @@ -174,9 +174,9 @@ func TestProgressTrackerProgress(t *testing.T) { }, expectedProgress: func() Progress { progress := initialProgress - progress.DonorSigned.State = actor.TaskCompleted - progress.CertificateProviderSigned.State = actor.TaskCompleted - progress.AttorneysSigned.State = actor.TaskInProgress + progress.DonorSigned.State = task.StateCompleted + progress.CertificateProviderSigned.State = task.StateCompleted + progress.AttorneysSigned.State = task.StateInProgress return progress }, @@ -199,10 +199,10 @@ func TestProgressTrackerProgress(t *testing.T) { }, expectedProgress: func() Progress { progress := initialProgress - progress.DonorSigned.State = actor.TaskCompleted - progress.CertificateProviderSigned.State = actor.TaskCompleted - progress.AttorneysSigned.State = actor.TaskCompleted - progress.LpaSubmitted.State = actor.TaskInProgress + progress.DonorSigned.State = task.StateCompleted + progress.CertificateProviderSigned.State = task.StateCompleted + progress.AttorneysSigned.State = task.StateCompleted + progress.LpaSubmitted.State = task.StateInProgress return progress }, @@ -226,10 +226,10 @@ func TestProgressTrackerProgress(t *testing.T) { }, expectedProgress: func() Progress { progress := initialProgress - progress.DonorSigned.State = actor.TaskCompleted - progress.CertificateProviderSigned.State = actor.TaskCompleted - progress.AttorneysSigned.State = actor.TaskCompleted - progress.LpaSubmitted.State = actor.TaskCompleted + progress.DonorSigned.State = task.StateCompleted + progress.CertificateProviderSigned.State = task.StateCompleted + progress.AttorneysSigned.State = task.StateCompleted + progress.LpaSubmitted.State = task.StateCompleted return progress }, @@ -254,13 +254,13 @@ func TestProgressTrackerProgress(t *testing.T) { }, expectedProgress: func() Progress { progress := initialProgress - progress.DonorSigned.State = actor.TaskCompleted - progress.CertificateProviderSigned.State = actor.TaskCompleted - progress.AttorneysSigned.State = actor.TaskCompleted - progress.LpaSubmitted.State = actor.TaskCompleted - progress.NoticesOfIntentSent.State = actor.TaskCompleted + progress.DonorSigned.State = task.StateCompleted + progress.CertificateProviderSigned.State = task.StateCompleted + progress.AttorneysSigned.State = task.StateCompleted + progress.LpaSubmitted.State = task.StateCompleted + progress.NoticesOfIntentSent.State = task.StateCompleted progress.NoticesOfIntentSent.Label = "NoticesOfIntentSent translation" - progress.StatutoryWaitingPeriod.State = actor.TaskInProgress + progress.StatutoryWaitingPeriod.State = task.StateInProgress return progress }, @@ -292,14 +292,14 @@ func TestProgressTrackerProgress(t *testing.T) { }, expectedProgress: func() Progress { progress := initialProgress - progress.DonorSigned.State = actor.TaskCompleted - progress.CertificateProviderSigned.State = actor.TaskCompleted - progress.AttorneysSigned.State = actor.TaskCompleted - progress.LpaSubmitted.State = actor.TaskCompleted - progress.NoticesOfIntentSent.State = actor.TaskCompleted + progress.DonorSigned.State = task.StateCompleted + progress.CertificateProviderSigned.State = task.StateCompleted + progress.AttorneysSigned.State = task.StateCompleted + progress.LpaSubmitted.State = task.StateCompleted + progress.NoticesOfIntentSent.State = task.StateCompleted progress.NoticesOfIntentSent.Label = "NoticesOfIntentSent translation" - progress.StatutoryWaitingPeriod.State = actor.TaskCompleted - progress.LpaRegistered.State = actor.TaskCompleted + progress.StatutoryWaitingPeriod.State = task.StateCompleted + progress.LpaRegistered.State = task.StateCompleted return progress }, @@ -353,15 +353,15 @@ func TestLpaProgressAsSupporter(t *testing.T) { uid := actoruid.New() initialProgress := Progress{ isOrganisation: true, - Paid: ProgressTask{State: actor.TaskInProgress, Label: "Paid translation"}, - ConfirmedID: ProgressTask{State: actor.TaskNotStarted, Label: "ConfirmedID translation"}, - DonorSigned: ProgressTask{State: actor.TaskNotStarted, Label: "DonorSigned translation"}, - CertificateProviderSigned: ProgressTask{State: actor.TaskNotStarted, Label: "CertificateProviderSigned translation"}, - AttorneysSigned: ProgressTask{State: actor.TaskNotStarted, Label: "AttorneysSigned translation"}, - LpaSubmitted: ProgressTask{State: actor.TaskNotStarted, Label: "LpaSubmitted translation"}, - NoticesOfIntentSent: ProgressTask{State: actor.TaskNotStarted}, - StatutoryWaitingPeriod: ProgressTask{State: actor.TaskNotStarted, Label: "StatutoryWaitingPeriod translation"}, - LpaRegistered: ProgressTask{State: actor.TaskNotStarted, Label: "LpaRegistered translation"}, + Paid: ProgressTask{State: task.StateInProgress, Label: "Paid translation"}, + ConfirmedID: ProgressTask{State: task.StateNotStarted, Label: "ConfirmedID translation"}, + DonorSigned: ProgressTask{State: task.StateNotStarted, Label: "DonorSigned translation"}, + CertificateProviderSigned: ProgressTask{State: task.StateNotStarted, Label: "CertificateProviderSigned translation"}, + AttorneysSigned: ProgressTask{State: task.StateNotStarted, Label: "AttorneysSigned translation"}, + LpaSubmitted: ProgressTask{State: task.StateNotStarted, Label: "LpaSubmitted translation"}, + NoticesOfIntentSent: ProgressTask{State: task.StateNotStarted}, + StatutoryWaitingPeriod: ProgressTask{State: task.StateNotStarted, Label: "StatutoryWaitingPeriod translation"}, + LpaRegistered: ProgressTask{State: task.StateNotStarted, Label: "LpaRegistered translation"}, } testCases := map[string]struct { @@ -388,8 +388,8 @@ func TestLpaProgressAsSupporter(t *testing.T) { }, expectedProgress: func() Progress { progress := initialProgress - progress.Paid.State = actor.TaskCompleted - progress.ConfirmedID.State = actor.TaskInProgress + progress.Paid.State = task.StateCompleted + progress.ConfirmedID.State = task.StateInProgress return progress }, @@ -408,9 +408,9 @@ func TestLpaProgressAsSupporter(t *testing.T) { }, expectedProgress: func() Progress { progress := initialProgress - progress.Paid.State = actor.TaskCompleted - progress.ConfirmedID.State = actor.TaskCompleted - progress.DonorSigned.State = actor.TaskInProgress + progress.Paid.State = task.StateCompleted + progress.ConfirmedID.State = task.StateCompleted + progress.DonorSigned.State = task.StateInProgress return progress }, @@ -430,10 +430,10 @@ func TestLpaProgressAsSupporter(t *testing.T) { }, expectedProgress: func() Progress { progress := initialProgress - progress.Paid.State = actor.TaskCompleted - progress.ConfirmedID.State = actor.TaskCompleted - progress.DonorSigned.State = actor.TaskCompleted - progress.CertificateProviderSigned.State = actor.TaskInProgress + progress.Paid.State = task.StateCompleted + progress.ConfirmedID.State = task.StateCompleted + progress.DonorSigned.State = task.StateCompleted + progress.CertificateProviderSigned.State = task.StateInProgress return progress }, @@ -454,11 +454,11 @@ func TestLpaProgressAsSupporter(t *testing.T) { }, expectedProgress: func() Progress { progress := initialProgress - progress.Paid.State = actor.TaskCompleted - progress.ConfirmedID.State = actor.TaskCompleted - progress.DonorSigned.State = actor.TaskCompleted - progress.CertificateProviderSigned.State = actor.TaskCompleted - progress.AttorneysSigned.State = actor.TaskInProgress + progress.Paid.State = task.StateCompleted + progress.ConfirmedID.State = task.StateCompleted + progress.DonorSigned.State = task.StateCompleted + progress.CertificateProviderSigned.State = task.StateCompleted + progress.AttorneysSigned.State = task.StateInProgress return progress }, @@ -479,12 +479,12 @@ func TestLpaProgressAsSupporter(t *testing.T) { }, expectedProgress: func() Progress { progress := initialProgress - progress.Paid.State = actor.TaskCompleted - progress.ConfirmedID.State = actor.TaskCompleted - progress.DonorSigned.State = actor.TaskCompleted - progress.CertificateProviderSigned.State = actor.TaskCompleted - progress.AttorneysSigned.State = actor.TaskCompleted - progress.LpaSubmitted.State = actor.TaskInProgress + progress.Paid.State = task.StateCompleted + progress.ConfirmedID.State = task.StateCompleted + progress.DonorSigned.State = task.StateCompleted + progress.CertificateProviderSigned.State = task.StateCompleted + progress.AttorneysSigned.State = task.StateCompleted + progress.LpaSubmitted.State = task.StateInProgress return progress }, @@ -506,12 +506,12 @@ func TestLpaProgressAsSupporter(t *testing.T) { }, expectedProgress: func() Progress { progress := initialProgress - progress.Paid.State = actor.TaskCompleted - progress.ConfirmedID.State = actor.TaskCompleted - progress.DonorSigned.State = actor.TaskCompleted - progress.CertificateProviderSigned.State = actor.TaskCompleted - progress.AttorneysSigned.State = actor.TaskCompleted - progress.LpaSubmitted.State = actor.TaskCompleted + progress.Paid.State = task.StateCompleted + progress.ConfirmedID.State = task.StateCompleted + progress.DonorSigned.State = task.StateCompleted + progress.CertificateProviderSigned.State = task.StateCompleted + progress.AttorneysSigned.State = task.StateCompleted + progress.LpaSubmitted.State = task.StateCompleted return progress }, @@ -534,15 +534,15 @@ func TestLpaProgressAsSupporter(t *testing.T) { }, expectedProgress: func() Progress { progress := initialProgress - progress.Paid.State = actor.TaskCompleted - progress.ConfirmedID.State = actor.TaskCompleted - progress.DonorSigned.State = actor.TaskCompleted - progress.CertificateProviderSigned.State = actor.TaskCompleted - progress.AttorneysSigned.State = actor.TaskCompleted - progress.LpaSubmitted.State = actor.TaskCompleted + progress.Paid.State = task.StateCompleted + progress.ConfirmedID.State = task.StateCompleted + progress.DonorSigned.State = task.StateCompleted + progress.CertificateProviderSigned.State = task.StateCompleted + progress.AttorneysSigned.State = task.StateCompleted + progress.LpaSubmitted.State = task.StateCompleted progress.NoticesOfIntentSent.Label = "NoticesOfIntentSent translation" - progress.NoticesOfIntentSent.State = actor.TaskCompleted - progress.StatutoryWaitingPeriod.State = actor.TaskInProgress + progress.NoticesOfIntentSent.State = task.StateCompleted + progress.StatutoryWaitingPeriod.State = task.StateInProgress return progress }, @@ -574,16 +574,16 @@ func TestLpaProgressAsSupporter(t *testing.T) { }, expectedProgress: func() Progress { progress := initialProgress - progress.Paid.State = actor.TaskCompleted - progress.ConfirmedID.State = actor.TaskCompleted - progress.DonorSigned.State = actor.TaskCompleted - progress.CertificateProviderSigned.State = actor.TaskCompleted - progress.AttorneysSigned.State = actor.TaskCompleted - progress.LpaSubmitted.State = actor.TaskCompleted + progress.Paid.State = task.StateCompleted + progress.ConfirmedID.State = task.StateCompleted + progress.DonorSigned.State = task.StateCompleted + progress.CertificateProviderSigned.State = task.StateCompleted + progress.AttorneysSigned.State = task.StateCompleted + progress.LpaSubmitted.State = task.StateCompleted progress.NoticesOfIntentSent.Label = "NoticesOfIntentSent translation" - progress.NoticesOfIntentSent.State = actor.TaskCompleted - progress.StatutoryWaitingPeriod.State = actor.TaskCompleted - progress.LpaRegistered.State = actor.TaskCompleted + progress.NoticesOfIntentSent.State = task.StateCompleted + progress.StatutoryWaitingPeriod.State = task.StateCompleted + progress.LpaRegistered.State = task.StateCompleted return progress }, diff --git a/internal/page/mock_DonorStore_test.go b/internal/page/mock_DonorStore_test.go index f62b20241c..dd76dc3c46 100644 --- a/internal/page/mock_DonorStore_test.go +++ b/internal/page/mock_DonorStore_test.go @@ -23,23 +23,23 @@ func (_m *mockDonorStore) EXPECT() *mockDonorStore_Expecter { } // Create provides a mock function with given fields: _a0 -func (_m *mockDonorStore) Create(_a0 context.Context) (*donordata.DonorProvidedDetails, error) { +func (_m *mockDonorStore) Create(_a0 context.Context) (*donordata.Provided, error) { ret := _m.Called(_a0) if len(ret) == 0 { panic("no return value specified for Create") } - var r0 *donordata.DonorProvidedDetails + var r0 *donordata.Provided var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (*donordata.DonorProvidedDetails, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context) (*donordata.Provided, error)); ok { return rf(_a0) } - if rf, ok := ret.Get(0).(func(context.Context) *donordata.DonorProvidedDetails); ok { + if rf, ok := ret.Get(0).(func(context.Context) *donordata.Provided); ok { r0 = rf(_a0) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*donordata.DonorProvidedDetails) + r0 = ret.Get(0).(*donordata.Provided) } } @@ -70,18 +70,18 @@ func (_c *mockDonorStore_Create_Call) Run(run func(_a0 context.Context)) *mockDo return _c } -func (_c *mockDonorStore_Create_Call) Return(_a0 *donordata.DonorProvidedDetails, _a1 error) *mockDonorStore_Create_Call { +func (_c *mockDonorStore_Create_Call) Return(_a0 *donordata.Provided, _a1 error) *mockDonorStore_Create_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockDonorStore_Create_Call) RunAndReturn(run func(context.Context) (*donordata.DonorProvidedDetails, error)) *mockDonorStore_Create_Call { +func (_c *mockDonorStore_Create_Call) RunAndReturn(run func(context.Context) (*donordata.Provided, error)) *mockDonorStore_Create_Call { _c.Call.Return(run) return _c } // Put provides a mock function with given fields: _a0, _a1 -func (_m *mockDonorStore) Put(_a0 context.Context, _a1 *donordata.DonorProvidedDetails) error { +func (_m *mockDonorStore) Put(_a0 context.Context, _a1 *donordata.Provided) error { ret := _m.Called(_a0, _a1) if len(ret) == 0 { @@ -89,7 +89,7 @@ func (_m *mockDonorStore) Put(_a0 context.Context, _a1 *donordata.DonorProvidedD } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *donordata.DonorProvidedDetails) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, *donordata.Provided) error); ok { r0 = rf(_a0, _a1) } else { r0 = ret.Error(0) @@ -110,9 +110,9 @@ func (_e *mockDonorStore_Expecter) Put(_a0 interface{}, _a1 interface{}) *mockDo return &mockDonorStore_Put_Call{Call: _e.mock.On("Put", _a0, _a1)} } -func (_c *mockDonorStore_Put_Call) Run(run func(_a0 context.Context, _a1 *donordata.DonorProvidedDetails)) *mockDonorStore_Put_Call { +func (_c *mockDonorStore_Put_Call) Run(run func(_a0 context.Context, _a1 *donordata.Provided)) *mockDonorStore_Put_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*donordata.DonorProvidedDetails)) + run(args[0].(context.Context), args[1].(*donordata.Provided)) }) return _c } @@ -122,7 +122,7 @@ func (_c *mockDonorStore_Put_Call) Return(_a0 error) *mockDonorStore_Put_Call { return _c } -func (_c *mockDonorStore_Put_Call) RunAndReturn(run func(context.Context, *donordata.DonorProvidedDetails) error) *mockDonorStore_Put_Call { +func (_c *mockDonorStore_Put_Call) RunAndReturn(run func(context.Context, *donordata.Provided) error) *mockDonorStore_Put_Call { _c.Call.Return(run) return _c } diff --git a/internal/page/mock_ShareCodeStore_test.go b/internal/page/mock_ShareCodeStore_test.go index 97c1b8110b..a25f5ad227 100644 --- a/internal/page/mock_ShareCodeStore_test.go +++ b/internal/page/mock_ShareCodeStore_test.go @@ -25,22 +25,22 @@ func (_m *mockShareCodeStore) EXPECT() *mockShareCodeStore_Expecter { } // Get provides a mock function with given fields: ctx, actorType, shareCode -func (_m *mockShareCodeStore) Get(ctx context.Context, actorType temporary.ActorType, shareCode string) (sharecode.ShareCodeData, error) { +func (_m *mockShareCodeStore) Get(ctx context.Context, actorType temporary.ActorType, shareCode string) (sharecode.Data, error) { ret := _m.Called(ctx, actorType, shareCode) if len(ret) == 0 { panic("no return value specified for Get") } - var r0 sharecode.ShareCodeData + var r0 sharecode.Data var r1 error - if rf, ok := ret.Get(0).(func(context.Context, temporary.ActorType, string) (sharecode.ShareCodeData, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, temporary.ActorType, string) (sharecode.Data, error)); ok { return rf(ctx, actorType, shareCode) } - if rf, ok := ret.Get(0).(func(context.Context, temporary.ActorType, string) sharecode.ShareCodeData); ok { + if rf, ok := ret.Get(0).(func(context.Context, temporary.ActorType, string) sharecode.Data); ok { r0 = rf(ctx, actorType, shareCode) } else { - r0 = ret.Get(0).(sharecode.ShareCodeData) + r0 = ret.Get(0).(sharecode.Data) } if rf, ok := ret.Get(1).(func(context.Context, temporary.ActorType, string) error); ok { @@ -72,18 +72,18 @@ func (_c *mockShareCodeStore_Get_Call) Run(run func(ctx context.Context, actorTy return _c } -func (_c *mockShareCodeStore_Get_Call) Return(_a0 sharecode.ShareCodeData, _a1 error) *mockShareCodeStore_Get_Call { +func (_c *mockShareCodeStore_Get_Call) Return(_a0 sharecode.Data, _a1 error) *mockShareCodeStore_Get_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockShareCodeStore_Get_Call) RunAndReturn(run func(context.Context, temporary.ActorType, string) (sharecode.ShareCodeData, error)) *mockShareCodeStore_Get_Call { +func (_c *mockShareCodeStore_Get_Call) RunAndReturn(run func(context.Context, temporary.ActorType, string) (sharecode.Data, error)) *mockShareCodeStore_Get_Call { _c.Call.Return(run) return _c } // Put provides a mock function with given fields: ctx, actorType, shareCode, data -func (_m *mockShareCodeStore) Put(ctx context.Context, actorType temporary.ActorType, shareCode string, data sharecode.ShareCodeData) error { +func (_m *mockShareCodeStore) Put(ctx context.Context, actorType temporary.ActorType, shareCode string, data sharecode.Data) error { ret := _m.Called(ctx, actorType, shareCode, data) if len(ret) == 0 { @@ -91,7 +91,7 @@ func (_m *mockShareCodeStore) Put(ctx context.Context, actorType temporary.Actor } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, temporary.ActorType, string, sharecode.ShareCodeData) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, temporary.ActorType, string, sharecode.Data) error); ok { r0 = rf(ctx, actorType, shareCode, data) } else { r0 = ret.Error(0) @@ -109,14 +109,14 @@ type mockShareCodeStore_Put_Call struct { // - ctx context.Context // - actorType temporary.ActorType // - shareCode string -// - data sharecode.ShareCodeData +// - data sharecode.Data func (_e *mockShareCodeStore_Expecter) Put(ctx interface{}, actorType interface{}, shareCode interface{}, data interface{}) *mockShareCodeStore_Put_Call { return &mockShareCodeStore_Put_Call{Call: _e.mock.On("Put", ctx, actorType, shareCode, data)} } -func (_c *mockShareCodeStore_Put_Call) Run(run func(ctx context.Context, actorType temporary.ActorType, shareCode string, data sharecode.ShareCodeData)) *mockShareCodeStore_Put_Call { +func (_c *mockShareCodeStore_Put_Call) Run(run func(ctx context.Context, actorType temporary.ActorType, shareCode string, data sharecode.Data)) *mockShareCodeStore_Put_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(temporary.ActorType), args[2].(string), args[3].(sharecode.ShareCodeData)) + run(args[0].(context.Context), args[1].(temporary.ActorType), args[2].(string), args[3].(sharecode.Data)) }) return _c } @@ -126,7 +126,7 @@ func (_c *mockShareCodeStore_Put_Call) Return(_a0 error) *mockShareCodeStore_Put return _c } -func (_c *mockShareCodeStore_Put_Call) RunAndReturn(run func(context.Context, temporary.ActorType, string, sharecode.ShareCodeData) error) *mockShareCodeStore_Put_Call { +func (_c *mockShareCodeStore_Put_Call) RunAndReturn(run func(context.Context, temporary.ActorType, string, sharecode.Data) error) *mockShareCodeStore_Put_Call { _c.Call.Return(run) return _c } diff --git a/internal/page/mock_shareCodeSender_test.go b/internal/page/mock_shareCodeSender_test.go index 19b3bea33b..d33d03eb24 100644 --- a/internal/page/mock_shareCodeSender_test.go +++ b/internal/page/mock_shareCodeSender_test.go @@ -15,11 +15,11 @@ type mockShareCodeSender struct { } // SendAttorneys provides a mock function with given fields: ctx, appData, donor -func (_m *mockShareCodeSender) SendAttorneys(ctx context.Context, appData AppData, donor *donordata.DonorProvidedDetails) error { +func (_m *mockShareCodeSender) SendAttorneys(ctx context.Context, appData AppData, donor *donordata.Provided) error { ret := _m.Called(ctx, appData, donor) var r0 error - if rf, ok := ret.Get(0).(func(context.Context, AppData, *donordata.DonorProvidedDetails) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, AppData, *donordata.Provided) error); ok { r0 = rf(ctx, appData, donor) } else { r0 = ret.Error(0) @@ -29,11 +29,11 @@ func (_m *mockShareCodeSender) SendAttorneys(ctx context.Context, appData AppDat } // SendCertificateProvider provides a mock function with given fields: ctx, appData, identity, donor -func (_m *mockShareCodeSender) SendCertificateProvider(ctx context.Context, appData AppData, identity bool, donor *donordata.DonorProvidedDetails) error { +func (_m *mockShareCodeSender) SendCertificateProvider(ctx context.Context, appData AppData, identity bool, donor *donordata.Provided) error { ret := _m.Called(ctx, appData, identity, donor) var r0 error - if rf, ok := ret.Get(0).(func(context.Context, AppData, bool, *donordata.DonorProvidedDetails) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, AppData, bool, *donordata.Provided) error); ok { r0 = rf(ctx, appData, identity, donor) } else { r0 = ret.Error(0) diff --git a/internal/page/paths.go b/internal/page/paths.go index e95bc5ee4f..317c2a3554 100644 --- a/internal/page/paths.go +++ b/internal/page/paths.go @@ -40,7 +40,7 @@ func (p LpaPath) Format(id string) string { return "/lpa/" + id + string(p) } -func (p LpaPath) Redirect(w http.ResponseWriter, r *http.Request, appData AppData, donor *donordata.DonorProvidedDetails) error { +func (p LpaPath) Redirect(w http.ResponseWriter, r *http.Request, appData AppData, donor *donordata.Provided) error { rurl := p.Format(donor.LpaID) if fromURL := r.FormValue("from"); fromURL != "" { rurl = fromURL @@ -50,7 +50,7 @@ func (p LpaPath) Redirect(w http.ResponseWriter, r *http.Request, appData AppDat return nil } -func (p LpaPath) RedirectQuery(w http.ResponseWriter, r *http.Request, appData AppData, donor *donordata.DonorProvidedDetails, query url.Values) error { +func (p LpaPath) RedirectQuery(w http.ResponseWriter, r *http.Request, appData AppData, donor *donordata.Provided, query url.Values) error { rurl := p.Format(donor.LpaID) + "?" + query.Encode() if fromURL := r.FormValue("from"); fromURL != "" { rurl = fromURL @@ -60,7 +60,7 @@ func (p LpaPath) RedirectQuery(w http.ResponseWriter, r *http.Request, appData A return nil } -func (p LpaPath) canVisit(donor *donordata.DonorProvidedDetails) bool { +func (p LpaPath) canVisit(donor *donordata.Provided) bool { section1Completed := donor.Tasks.YourDetails.Completed() && donor.Tasks.ChooseAttorneys.Completed() && donor.Tasks.ChooseReplacementAttorneys.Completed() && @@ -678,7 +678,7 @@ var Paths = AppPaths{ YourPreferredLanguage: "/your-preferred-language", } -func DonorCanGoTo(donor *donordata.DonorProvidedDetails, url string) bool { +func DonorCanGoTo(donor *donordata.Provided, url string) bool { path, _, _ := strings.Cut(url, "?") if path == "" { return false diff --git a/internal/page/paths_test.go b/internal/page/paths_test.go index 0124090c76..756f247c71 100644 --- a/internal/page/paths_test.go +++ b/internal/page/paths_test.go @@ -6,7 +6,6 @@ import ( "net/url" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" @@ -62,26 +61,26 @@ func TestLpaPathFormat(t *testing.T) { func TestLpaPathRedirect(t *testing.T) { testCases := map[string]struct { url string - donor *donordata.DonorProvidedDetails + donor *donordata.Provided expected string }{ "redirect": { url: "/", - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ LpaID: "lpa-id", Donor: donordata.Donor{ CanSign: form.Yes, }, Type: donordata.LpaTypePersonalWelfare, - Tasks: donordata.DonorTasks{ - YourDetails: actor.TaskCompleted, - ChooseAttorneys: actor.TaskCompleted, - ChooseReplacementAttorneys: actor.TaskCompleted, - LifeSustainingTreatment: actor.TaskCompleted, - Restrictions: actor.TaskCompleted, - CertificateProvider: actor.TaskCompleted, - PeopleToNotify: actor.TaskCompleted, - CheckYourLpa: actor.TaskCompleted, + Tasks: donordata.Tasks{ + YourDetails: task.StateCompleted, + ChooseAttorneys: task.StateCompleted, + ChooseReplacementAttorneys: task.StateCompleted, + LifeSustainingTreatment: task.StateCompleted, + Restrictions: task.StateCompleted, + CertificateProvider: task.StateCompleted, + PeopleToNotify: task.StateCompleted, + CheckYourLpa: task.StateCompleted, PayForLpa: task.PaymentStateCompleted, }, }, @@ -89,7 +88,7 @@ func TestLpaPathRedirect(t *testing.T) { }, "redirect with from": { url: "/?from=" + Paths.Restrictions.Format("lpa-id"), - donor: &donordata.DonorProvidedDetails{LpaID: "lpa-id", Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted}}, + donor: &donordata.Provided{LpaID: "lpa-id", Tasks: donordata.Tasks{YourDetails: task.StateCompleted, ChooseAttorneys: task.StateCompleted}}, expected: Paths.Restrictions.Format("lpa-id"), }, } @@ -113,7 +112,7 @@ func TestLpaPathRedirectQuery(t *testing.T) { r, _ := http.NewRequest(http.MethodGet, "/", nil) w := httptest.NewRecorder() - err := Paths.TaskList.RedirectQuery(w, r, AppData{Lang: localize.En}, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}, url.Values{"q": {"1"}}) + err := Paths.TaskList.RedirectQuery(w, r, AppData{Lang: localize.En}, &donordata.Provided{LpaID: "lpa-id"}, url.Values{"q": {"1"}}) resp := w.Result() assert.Nil(t, err) @@ -246,100 +245,100 @@ func TestSupporterLpaPathIsManageOrganisation(t *testing.T) { func TestDonorCanGoTo(t *testing.T) { testCases := map[string]struct { - donor *donordata.DonorProvidedDetails + donor *donordata.Provided url string expected bool }{ "empty path": { - donor: &donordata.DonorProvidedDetails{}, + donor: &donordata.Provided{}, url: "", expected: false, }, "unexpected path": { - donor: &donordata.DonorProvidedDetails{}, + donor: &donordata.Provided{}, url: "/whatever", expected: true, }, "check your lpa when unsure if can sign": { - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ Type: donordata.LpaTypePersonalWelfare, - Tasks: donordata.DonorTasks{ - YourDetails: actor.TaskCompleted, - ChooseAttorneys: actor.TaskCompleted, - ChooseReplacementAttorneys: actor.TaskCompleted, - LifeSustainingTreatment: actor.TaskCompleted, - Restrictions: actor.TaskCompleted, - CertificateProvider: actor.TaskCompleted, - PeopleToNotify: actor.TaskCompleted, - AddCorrespondent: actor.TaskCompleted, + Tasks: donordata.Tasks{ + YourDetails: task.StateCompleted, + ChooseAttorneys: task.StateCompleted, + ChooseReplacementAttorneys: task.StateCompleted, + LifeSustainingTreatment: task.StateCompleted, + Restrictions: task.StateCompleted, + CertificateProvider: task.StateCompleted, + PeopleToNotify: task.StateCompleted, + AddCorrespondent: task.StateCompleted, }, }, url: Paths.CheckYourLpa.Format("123"), expected: false, }, "check your lpa when can sign": { - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ Donor: donordata.Donor{CanSign: form.Yes}, Type: donordata.LpaTypePersonalWelfare, - Tasks: donordata.DonorTasks{ - YourDetails: actor.TaskCompleted, - ChooseAttorneys: actor.TaskCompleted, - ChooseReplacementAttorneys: actor.TaskCompleted, - LifeSustainingTreatment: actor.TaskCompleted, - Restrictions: actor.TaskCompleted, - CertificateProvider: actor.TaskCompleted, - PeopleToNotify: actor.TaskCompleted, - AddCorrespondent: actor.TaskCompleted, + Tasks: donordata.Tasks{ + YourDetails: task.StateCompleted, + ChooseAttorneys: task.StateCompleted, + ChooseReplacementAttorneys: task.StateCompleted, + LifeSustainingTreatment: task.StateCompleted, + Restrictions: task.StateCompleted, + CertificateProvider: task.StateCompleted, + PeopleToNotify: task.StateCompleted, + AddCorrespondent: task.StateCompleted, }, }, url: Paths.CheckYourLpa.Format("123"), expected: true, }, "about payment without task": { - donor: &donordata.DonorProvidedDetails{LpaID: "123"}, + donor: &donordata.Provided{LpaID: "123"}, url: Paths.AboutPayment.Format("123"), expected: false, }, "about payment with tasks": { - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ Donor: donordata.Donor{ CanSign: form.Yes, }, Type: donordata.LpaTypePropertyAndAffairs, - Tasks: donordata.DonorTasks{ - YourDetails: actor.TaskCompleted, - ChooseAttorneys: actor.TaskCompleted, - ChooseReplacementAttorneys: actor.TaskCompleted, - WhenCanTheLpaBeUsed: actor.TaskCompleted, - Restrictions: actor.TaskCompleted, - CertificateProvider: actor.TaskCompleted, - PeopleToNotify: actor.TaskCompleted, - CheckYourLpa: actor.TaskCompleted, + Tasks: donordata.Tasks{ + YourDetails: task.StateCompleted, + ChooseAttorneys: task.StateCompleted, + ChooseReplacementAttorneys: task.StateCompleted, + WhenCanTheLpaBeUsed: task.StateCompleted, + Restrictions: task.StateCompleted, + CertificateProvider: task.StateCompleted, + PeopleToNotify: task.StateCompleted, + CheckYourLpa: task.StateCompleted, }, }, url: Paths.AboutPayment.Format("123"), expected: true, }, "identity without task": { - donor: &donordata.DonorProvidedDetails{}, + donor: &donordata.Provided{}, url: Paths.IdentityWithOneLogin.Format("123"), expected: false, }, "identity with tasks": { - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ Donor: donordata.Donor{ CanSign: form.Yes, }, Type: donordata.LpaTypePersonalWelfare, - Tasks: donordata.DonorTasks{ - YourDetails: actor.TaskCompleted, - ChooseAttorneys: actor.TaskCompleted, - ChooseReplacementAttorneys: actor.TaskCompleted, - LifeSustainingTreatment: actor.TaskCompleted, - Restrictions: actor.TaskCompleted, - CertificateProvider: actor.TaskCompleted, - PeopleToNotify: actor.TaskCompleted, - CheckYourLpa: actor.TaskCompleted, + Tasks: donordata.Tasks{ + YourDetails: task.StateCompleted, + ChooseAttorneys: task.StateCompleted, + ChooseReplacementAttorneys: task.StateCompleted, + LifeSustainingTreatment: task.StateCompleted, + Restrictions: task.StateCompleted, + CertificateProvider: task.StateCompleted, + PeopleToNotify: task.StateCompleted, + CheckYourLpa: task.StateCompleted, PayForLpa: task.PaymentStateCompleted, }, }, @@ -347,26 +346,26 @@ func TestDonorCanGoTo(t *testing.T) { expected: true, }, "read lpa without task": { - donor: &donordata.DonorProvidedDetails{}, + donor: &donordata.Provided{}, url: Paths.ReadYourLpa.Format("123"), expected: false, }, "read lpa with tasks": { - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ Donor: donordata.Donor{ CanSign: form.Yes, }, DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, Type: donordata.LpaTypePersonalWelfare, - Tasks: donordata.DonorTasks{ - YourDetails: actor.TaskCompleted, - ChooseAttorneys: actor.TaskCompleted, - ChooseReplacementAttorneys: actor.TaskCompleted, - LifeSustainingTreatment: actor.TaskCompleted, - Restrictions: actor.TaskCompleted, - CertificateProvider: actor.TaskCompleted, - PeopleToNotify: actor.TaskCompleted, - CheckYourLpa: actor.TaskCompleted, + Tasks: donordata.Tasks{ + YourDetails: task.StateCompleted, + ChooseAttorneys: task.StateCompleted, + ChooseReplacementAttorneys: task.StateCompleted, + LifeSustainingTreatment: task.StateCompleted, + Restrictions: task.StateCompleted, + CertificateProvider: task.StateCompleted, + PeopleToNotify: task.StateCompleted, + CheckYourLpa: task.StateCompleted, PayForLpa: task.PaymentStateCompleted, }, }, @@ -374,12 +373,12 @@ func TestDonorCanGoTo(t *testing.T) { expected: true, }, "your name when identity not set": { - donor: &donordata.DonorProvidedDetails{}, + donor: &donordata.Provided{}, url: Paths.YourName.Format("123"), expected: true, }, "your name when identity set": { - donor: &donordata.DonorProvidedDetails{ + donor: &donordata.Provided{ DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, }, url: Paths.YourName.Format("123"), @@ -423,7 +422,7 @@ func TestCertificateProviderCanGoTo(t *testing.T) { "identity with task": { certificateProvider: &certificateproviderdata.Provided{ Tasks: certificateproviderdata.Tasks{ - ConfirmYourDetails: actor.TaskCompleted, + ConfirmYourDetails: task.StateCompleted, }, }, url: Paths.CertificateProvider.IdentityWithOneLogin.Format("123"), @@ -432,7 +431,7 @@ func TestCertificateProviderCanGoTo(t *testing.T) { "provide certificate without task": { certificateProvider: &certificateproviderdata.Provided{ Tasks: certificateproviderdata.Tasks{ - ConfirmYourDetails: actor.TaskCompleted, + ConfirmYourDetails: task.StateCompleted, }, }, url: Paths.CertificateProvider.ProvideCertificate.Format("123"), @@ -441,8 +440,8 @@ func TestCertificateProviderCanGoTo(t *testing.T) { "provide certificate with task": { certificateProvider: &certificateproviderdata.Provided{ Tasks: certificateproviderdata.Tasks{ - ConfirmYourDetails: actor.TaskCompleted, - ConfirmYourIdentity: actor.TaskCompleted, + ConfirmYourDetails: task.StateCompleted, + ConfirmYourIdentity: task.StateCompleted, }, }, url: Paths.CertificateProvider.ProvideCertificate.Format("123"), @@ -481,7 +480,7 @@ func TestAttorneyCanGoTo(t *testing.T) { "sign without task": { attorney: &attorneydata.Provided{ Tasks: attorneydata.Tasks{ - ConfirmYourDetails: actor.TaskCompleted, + ConfirmYourDetails: task.StateCompleted, }, }, url: Paths.Attorney.Sign.Format("123"), @@ -490,8 +489,8 @@ func TestAttorneyCanGoTo(t *testing.T) { "sign with task": { attorney: &attorneydata.Provided{ Tasks: attorneydata.Tasks{ - ConfirmYourDetails: actor.TaskCompleted, - ReadTheLpa: actor.TaskCompleted, + ConfirmYourDetails: task.StateCompleted, + ReadTheLpa: task.StateCompleted, }, }, url: Paths.Attorney.Sign.Format("123"), @@ -500,8 +499,8 @@ func TestAttorneyCanGoTo(t *testing.T) { "would like second signatory not trust corp": { attorney: &attorneydata.Provided{ Tasks: attorneydata.Tasks{ - ConfirmYourDetails: actor.TaskCompleted, - ReadTheLpa: actor.TaskCompleted, + ConfirmYourDetails: task.StateCompleted, + ReadTheLpa: task.StateCompleted, }, }, url: Paths.Attorney.WouldLikeSecondSignatory.Format("123"), @@ -510,8 +509,8 @@ func TestAttorneyCanGoTo(t *testing.T) { "would like second signatory as trust corp": { attorney: &attorneydata.Provided{ Tasks: attorneydata.Tasks{ - ConfirmYourDetails: actor.TaskCompleted, - ReadTheLpa: actor.TaskCompleted, + ConfirmYourDetails: task.StateCompleted, + ReadTheLpa: task.StateCompleted, }, IsTrustCorporation: true, }, diff --git a/internal/page/share_code.go b/internal/page/share_code.go index 6239f7e652..77666b2522 100644 --- a/internal/page/share_code.go +++ b/internal/page/share_code.go @@ -12,6 +12,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" ) type ShareCodeSender struct { @@ -68,7 +69,7 @@ func (s *ShareCodeSender) SendCertificateProviderInvite(ctx context.Context, app }) } -func (s *ShareCodeSender) SendCertificateProviderPrompt(ctx context.Context, appData AppData, donor *donordata.DonorProvidedDetails) error { +func (s *ShareCodeSender) SendCertificateProviderPrompt(ctx context.Context, appData AppData, donor *donordata.Provided) error { shareCode, err := s.createShareCode(ctx, donor.PK, donor.SK, donor.CertificateProvider.UID, actor.TypeCertificateProvider) if err != nil { return err @@ -217,7 +218,7 @@ func (s *ShareCodeSender) createShareCode(ctx context.Context, lpaKey dynamo.Lpa s.testCode = "" } - shareCodeData := actor.ShareCodeData{ + shareCodeData := sharecode.Data{ LpaKey: lpaKey, LpaOwnerKey: lpaOwnerKey, ActorUID: actorUID, diff --git a/internal/page/share_code_test.go b/internal/page/share_code_test.go index 866b597185..6f883a7a35 100644 --- a/internal/page/share_code_test.go +++ b/internal/page/share_code_test.go @@ -13,12 +13,13 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/event" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) func TestShareCodeSenderSendCertificateProviderInvite(t *testing.T) { - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ CertificateProvider: donordata.CertificateProvider{ FirstNames: "Joanna", LastName: "Jones", @@ -50,7 +51,7 @@ func TestShareCodeSenderSendCertificateProviderInvite(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeCertificateProvider, testRandomString, actor.ShareCodeData{ + Put(ctx, actor.TypeCertificateProvider, testRandomString, sharecode.Data{ LpaKey: dynamo.LpaKey("lpa"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), }). @@ -102,7 +103,7 @@ func TestShareCodeSenderSendCertificateProviderInviteWithTestCode(t *testing.T) }, } - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ CertificateProvider: donordata.CertificateProvider{ FirstNames: "Joanna", LastName: "Jones", @@ -135,14 +136,14 @@ func TestShareCodeSenderSendCertificateProviderInviteWithTestCode(t *testing.T) shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeCertificateProvider, tc.expectedTestCode, actor.ShareCodeData{ + Put(ctx, actor.TypeCertificateProvider, tc.expectedTestCode, sharecode.Data{ LpaKey: dynamo.LpaKey("lpa"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), }). Once(). Return(nil) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeCertificateProvider, testRandomString, actor.ShareCodeData{ + Put(ctx, actor.TypeCertificateProvider, testRandomString, sharecode.Data{ LpaKey: dynamo.LpaKey("lpa"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), }). @@ -217,7 +218,7 @@ func TestShareCodeSenderSendCertificateProviderInviteWithTestCode(t *testing.T) func TestShareCodeSenderSendCertificateProviderInviteWhenEmailErrors(t *testing.T) { ctx := context.Background() - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ CertificateProvider: donordata.CertificateProvider{ FirstNames: "Joanna", LastName: "Jones", @@ -278,7 +279,7 @@ func TestShareCodeSenderSendCertificateProviderInviteWhenShareCodeStoreErrors(t } func TestShareCodeSenderSendCertificateProviderPromptOnline(t *testing.T) { - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ CertificateProvider: donordata.CertificateProvider{ FirstNames: "Joanna", LastName: "Jones", @@ -317,7 +318,7 @@ func TestShareCodeSenderSendCertificateProviderPromptOnline(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeCertificateProvider, testRandomString, actor.ShareCodeData{ + Put(ctx, actor.TypeCertificateProvider, testRandomString, sharecode.Data{ LpaKey: dynamo.LpaKey("lpa"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), }). @@ -332,7 +333,7 @@ func TestShareCodeSenderSendCertificateProviderPromptOnline(t *testing.T) { func TestShareCodeSenderSendCertificateProviderPromptPaper(t *testing.T) { actorUID := actoruid.New() - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ CertificateProvider: donordata.CertificateProvider{ UID: actorUID, FirstNames: "Joanna", @@ -354,7 +355,7 @@ func TestShareCodeSenderSendCertificateProviderPromptPaper(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeCertificateProvider, testRandomString, actor.ShareCodeData{ + Put(ctx, actor.TypeCertificateProvider, testRandomString, sharecode.Data{ LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: actorUID, @@ -392,7 +393,7 @@ func TestShareCodeSenderSendCertificateProviderPromptWithTestCode(t *testing.T) }, } - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ CertificateProvider: donordata.CertificateProvider{ FirstNames: "Joanna", LastName: "Jones", @@ -422,7 +423,7 @@ func TestShareCodeSenderSendCertificateProviderPromptWithTestCode(t *testing.T) shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeCertificateProvider, tc.expectedTestCode, actor.ShareCodeData{ + Put(ctx, actor.TypeCertificateProvider, tc.expectedTestCode, sharecode.Data{ LpaKey: dynamo.LpaKey("lpa"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), }). @@ -430,7 +431,7 @@ func TestShareCodeSenderSendCertificateProviderPromptWithTestCode(t *testing.T) Return(nil) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeCertificateProvider, testRandomString, actor.ShareCodeData{ + Put(ctx, actor.TypeCertificateProvider, testRandomString, sharecode.Data{ LpaKey: dynamo.LpaKey("lpa"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), }). @@ -475,7 +476,7 @@ func TestShareCodeSenderSendCertificateProviderPromptWithTestCode(t *testing.T) } func TestShareCodeSenderSendCertificateProviderPromptPaperWhenShareCodeStoreError(t *testing.T) { - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ CertificateProvider: donordata.CertificateProvider{ CarryOutBy: donordata.ChannelPaper, }, @@ -495,7 +496,7 @@ func TestShareCodeSenderSendCertificateProviderPromptPaperWhenShareCodeStoreErro } func TestShareCodeSenderSendCertificateProviderPromptPaperWhenEventClientError(t *testing.T) { - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ CertificateProvider: donordata.CertificateProvider{ CarryOutBy: donordata.ChannelPaper, }, @@ -522,7 +523,7 @@ func TestShareCodeSenderSendCertificateProviderPromptPaperWhenEventClientError(t func TestShareCodeSenderSendCertificateProviderPromptWhenEmailErrors(t *testing.T) { ctx := context.Background() - donor := &donordata.DonorProvidedDetails{ + donor := &donordata.Provided{ CertificateProvider: donordata.CertificateProvider{ FirstNames: "Joanna", LastName: "Jones", @@ -567,7 +568,7 @@ func TestShareCodeSenderSendCertificateProviderPromptWhenShareCodeStoreErrors(t Return(expectedError) sender := NewShareCodeSender(shareCodeStore, nil, "http://app", testRandomStringFn, nil) - err := sender.SendCertificateProviderPrompt(ctx, TestAppData, &donordata.DonorProvidedDetails{}) + err := sender.SendCertificateProviderPrompt(ctx, TestAppData, &donordata.Provided{}) assert.Equal(t, expectedError, errors.Unwrap(err)) } @@ -652,25 +653,25 @@ func TestShareCodeSenderSendAttorneys(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeTrustCorporation, testRandomString, actor.ShareCodeData{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: trustCorporationUID, IsTrustCorporation: true}). + Put(ctx, actor.TypeTrustCorporation, testRandomString, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: trustCorporationUID, IsTrustCorporation: true}). Return(nil) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeReplacementTrustCorporation, testRandomString, actor.ShareCodeData{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: replacementTrustCorporationUID, IsTrustCorporation: true, IsReplacementAttorney: true}). + Put(ctx, actor.TypeReplacementTrustCorporation, testRandomString, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: replacementTrustCorporationUID, IsTrustCorporation: true, IsReplacementAttorney: true}). Return(nil) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeAttorney, testRandomString, actor.ShareCodeData{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: attorney1UID}). + Put(ctx, actor.TypeAttorney, testRandomString, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: attorney1UID}). Return(nil) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeAttorney, testRandomString, actor.ShareCodeData{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: attorney2UID}). + Put(ctx, actor.TypeAttorney, testRandomString, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: attorney2UID}). Return(nil) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeAttorney, testRandomString, actor.ShareCodeData{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: attorney3UID}). + Put(ctx, actor.TypeAttorney, testRandomString, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: attorney3UID}). Return(nil) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeReplacementAttorney, testRandomString, actor.ShareCodeData{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: replacement1UID, IsReplacementAttorney: true}). + Put(ctx, actor.TypeReplacementAttorney, testRandomString, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: replacement1UID, IsReplacementAttorney: true}). Return(nil) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeReplacementAttorney, testRandomString, actor.ShareCodeData{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: replacement2UID, IsReplacementAttorney: true}). + Put(ctx, actor.TypeReplacementAttorney, testRandomString, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: replacement2UID, IsReplacementAttorney: true}). Return(nil) notifyClient := newMockNotifyClient(t) @@ -789,7 +790,7 @@ func TestShareCodeSenderSendAttorneysTrustCorporationsNoEmail(t *testing.T) { ctx := context.Background() shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeTrustCorporation, testRandomString, actor.ShareCodeData{ + Put(ctx, actor.TypeTrustCorporation, testRandomString, sharecode.Data{ LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: uid1, @@ -797,7 +798,7 @@ func TestShareCodeSenderSendAttorneysTrustCorporationsNoEmail(t *testing.T) { }). Return(nil) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeReplacementTrustCorporation, testRandomString, actor.ShareCodeData{ + Put(ctx, actor.TypeReplacementTrustCorporation, testRandomString, sharecode.Data{ LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa"), ActorUID: uid2, @@ -879,10 +880,10 @@ func TestShareCodeSenderSendAttorneysWithTestCode(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeAttorney, tc.expectedTestCode, actor.ShareCodeData{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa")}). + Put(ctx, actor.TypeAttorney, tc.expectedTestCode, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa")}). Return(nil) shareCodeStore.EXPECT(). - Put(ctx, actor.TypeAttorney, testRandomString, actor.ShareCodeData{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa")}). + Put(ctx, actor.TypeAttorney, testRandomString, sharecode.Data{LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), LpaKey: dynamo.LpaKey("lpa")}). Return(nil) notifyClient := newMockNotifyClient(t) diff --git a/internal/page/supporter/confirm_donor_can_interact_online_test.go b/internal/page/supporter/confirm_donor_can_interact_online_test.go index 9c088c557d..8bcc03ceb6 100644 --- a/internal/page/supporter/confirm_donor_can_interact_online_test.go +++ b/internal/page/supporter/confirm_donor_can_interact_online_test.go @@ -45,7 +45,7 @@ func TestPostConfirmDonorCanInteractOnlineWhenYes(t *testing.T) { organisationStore := newMockOrganisationStore(t) organisationStore.EXPECT(). CreateLPA(r.Context()). - Return(&donordata.DonorProvidedDetails{LpaID: "lpa-id"}, nil) + Return(&donordata.Provided{LpaID: "lpa-id"}, nil) err := ConfirmDonorCanInteractOnline(nil, organisationStore)(testAppData, w, r, &actor.Organisation{ID: "org-id"}, nil) resp := w.Result() @@ -101,7 +101,7 @@ func TestPostConfirmDonorCanInteractOnlineWhenOrganisationStoreError(t *testing. organisationStore := newMockOrganisationStore(t) organisationStore.EXPECT(). CreateLPA(r.Context()). - Return(&donordata.DonorProvidedDetails{}, expectedError) + Return(&donordata.Provided{}, expectedError) err := ConfirmDonorCanInteractOnline(nil, organisationStore)(testAppData, w, r, &actor.Organisation{ID: "org-id"}, nil) resp := w.Result() diff --git a/internal/page/supporter/dashboard.go b/internal/page/supporter/dashboard.go index b3afb5cca9..d886e3a99e 100644 --- a/internal/page/supporter/dashboard.go +++ b/internal/page/supporter/dashboard.go @@ -21,7 +21,7 @@ type SearchClient interface { type dashboardData struct { App page.AppData Errors validation.List - Donors []donordata.DonorProvidedDetails + Donors []donordata.Provided CurrentPage int Pagination *search.Pagination } diff --git a/internal/page/supporter/dashboard_test.go b/internal/page/supporter/dashboard_test.go index e972161527..ae7187f8f4 100644 --- a/internal/page/supporter/dashboard_test.go +++ b/internal/page/supporter/dashboard_test.go @@ -26,7 +26,7 @@ func TestGetDashboard(t *testing.T) { keys := []dynamo.Keys{{PK: dynamo.LpaKey("a"), SK: dynamo.OrganisationKey("b")}} pagination := &search.Pagination{Total: 10} - donors := []donordata.DonorProvidedDetails{{LpaID: "abc"}} + donors := []donordata.Provided{{LpaID: "abc"}} searchClient := newMockSearchClient(t) searchClient.EXPECT(). diff --git a/internal/page/supporter/donor_access.go b/internal/page/supporter/donor_access.go index 0ecf5802d7..06f1cf2863 100644 --- a/internal/page/supporter/donor_access.go +++ b/internal/page/supporter/donor_access.go @@ -13,6 +13,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -20,8 +21,8 @@ type donorAccessData struct { App page.AppData Errors validation.List Form *donorAccessForm - Donor *donordata.DonorProvidedDetails - ShareCode *actor.ShareCodeData + Donor *donordata.Provided + ShareCode *sharecode.Data } func DonorAccess(logger Logger, tmpl template.Template, donorStore DonorStore, shareCodeStore ShareCodeStore, notifyClient NotifyClient, appPublicURL string, randomString func(int) string) Handler { @@ -88,7 +89,7 @@ func DonorAccess(logger Logger, tmpl template.Template, donorStore DonorStore, s } shareCode := randomString(12) - shareCodeData := actor.ShareCodeData{ + shareCodeData := sharecode.Data{ LpaOwnerKey: dynamo.LpaOwnerKey(organisation.PK), LpaKey: dynamo.LpaKey(appData.LpaID), ActorUID: donor.Donor.UID, diff --git a/internal/page/supporter/donor_access_test.go b/internal/page/supporter/donor_access_test.go index 5ddd62bcbb..cb4983d9ff 100644 --- a/internal/page/supporter/donor_access_test.go +++ b/internal/page/supporter/donor_access_test.go @@ -14,6 +14,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" @@ -21,8 +22,8 @@ import ( ) func TestGetDonorAccess(t *testing.T) { - donor := &donordata.DonorProvidedDetails{Donor: donordata.Donor{Email: "x"}} - shareCodeData := actor.ShareCodeData{PK: dynamo.ShareKey(dynamo.DonorShareKey("1"))} + donor := &donordata.Provided{Donor: donordata.Donor{Email: "x"}} + shareCodeData := sharecode.Data{PK: dynamo.ShareKey(dynamo.DonorShareKey("1"))} testcases := map[string]struct { data *donorAccessData @@ -82,7 +83,7 @@ func TestGetDonorAccessWhenDonorStoreErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(r.Context()). - Return(&donordata.DonorProvidedDetails{}, expectedError) + Return(&donordata.Provided{}, expectedError) err := DonorAccess(nil, nil, donorStore, nil, nil, "", nil)(testLpaAppData, w, r, nil, nil) assert.Equal(t, expectedError, err) @@ -95,12 +96,12 @@ func TestGetDonorAccessWhenShareCodeStoreErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(r.Context()). - Return(&donordata.DonorProvidedDetails{}, nil) + Return(&donordata.Provided{}, nil) shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). GetDonor(r.Context()). - Return(actor.ShareCodeData{}, expectedError) + Return(sharecode.Data{}, expectedError) err := DonorAccess(nil, nil, donorStore, shareCodeStore, nil, "", nil)(testLpaAppData, w, r, nil, nil) assert.Equal(t, expectedError, err) @@ -118,12 +119,12 @@ func TestPostDonorAccess(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(r.Context()). - Return(&donordata.DonorProvidedDetails{ + Return(&donordata.Provided{ Type: donordata.LpaTypePropertyAndAffairs, Donor: donordata.Donor{UID: donorUID, FirstNames: "Barry", LastName: "Boy"}, }, nil) donorStore.EXPECT(). - Put(r.Context(), &donordata.DonorProvidedDetails{ + Put(r.Context(), &donordata.Provided{ Type: donordata.LpaTypePropertyAndAffairs, Donor: donordata.Donor{UID: donorUID, FirstNames: "Barry", LastName: "Boy", Email: "email@example.com"}, }). @@ -132,9 +133,9 @@ func TestPostDonorAccess(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). GetDonor(r.Context()). - Return(actor.ShareCodeData{}, dynamo.NotFoundError{}) + Return(sharecode.Data{}, dynamo.NotFoundError{}) shareCodeStore.EXPECT(). - PutDonor(r.Context(), testRandomString, actor.ShareCodeData{ + PutDonor(r.Context(), testRandomString, sharecode.Data{ LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), LpaKey: dynamo.LpaKey("lpa-id"), ActorUID: donorUID, @@ -178,7 +179,7 @@ func TestPostDonorAccessWhenDonorUpdateErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(r.Context()). - Return(&donordata.DonorProvidedDetails{}, nil) + Return(&donordata.Provided{}, nil) donorStore.EXPECT(). Put(r.Context(), mock.Anything). Return(expectedError) @@ -186,7 +187,7 @@ func TestPostDonorAccessWhenDonorUpdateErrors(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). GetDonor(r.Context()). - Return(actor.ShareCodeData{}, dynamo.NotFoundError{}) + Return(sharecode.Data{}, dynamo.NotFoundError{}) err := DonorAccess(nil, nil, donorStore, shareCodeStore, nil, "", nil)(testLpaAppData, w, r, &actor.Organisation{ID: "org-id"}, nil) assert.Equal(t, expectedError, err) @@ -202,12 +203,12 @@ func TestPostDonorAccessWhenShareCodeStoreErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(r.Context()). - Return(&donordata.DonorProvidedDetails{Donor: donordata.Donor{Email: "email@example.com"}}, nil) + Return(&donordata.Provided{Donor: donordata.Donor{Email: "email@example.com"}}, nil) shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). GetDonor(r.Context()). - Return(actor.ShareCodeData{}, dynamo.NotFoundError{}) + Return(sharecode.Data{}, dynamo.NotFoundError{}) shareCodeStore.EXPECT(). PutDonor(r.Context(), mock.Anything, mock.Anything). Return(expectedError) @@ -226,12 +227,12 @@ func TestPostDonorAccessWhenNotifyErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(r.Context()). - Return(&donordata.DonorProvidedDetails{Donor: donordata.Donor{Email: "email@example.com"}}, nil) + Return(&donordata.Provided{Donor: donordata.Donor{Email: "email@example.com"}}, nil) shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). GetDonor(r.Context()). - Return(actor.ShareCodeData{}, dynamo.NotFoundError{}) + Return(sharecode.Data{}, dynamo.NotFoundError{}) shareCodeStore.EXPECT(). PutDonor(r.Context(), mock.Anything, mock.Anything). Return(nil) @@ -261,12 +262,12 @@ func TestPostDonorAccessWhenValidationError(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(r.Context()). - Return(&donordata.DonorProvidedDetails{}, nil) + Return(&donordata.Provided{}, nil) shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). GetDonor(r.Context()). - Return(actor.ShareCodeData{}, dynamo.NotFoundError{}) + Return(sharecode.Data{}, dynamo.NotFoundError{}) template := newMockTemplate(t) template.EXPECT(). @@ -289,12 +290,12 @@ func TestPostDonorAccessRecall(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - shareCodeData := actor.ShareCodeData{PK: dynamo.ShareKey(dynamo.DonorShareKey("1")), InviteSentTo: "email@example.com"} + shareCodeData := sharecode.Data{PK: dynamo.ShareKey(dynamo.DonorShareKey("1")), InviteSentTo: "email@example.com"} donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(r.Context()). - Return(&donordata.DonorProvidedDetails{}, nil) + Return(&donordata.Provided{}, nil) shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). @@ -319,12 +320,12 @@ func TestPostDonorAccessRecallWhenDeleteErrors(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - shareCodeData := actor.ShareCodeData{PK: dynamo.ShareKey(dynamo.DonorShareKey("1")), InviteSentTo: "email@example.com"} + shareCodeData := sharecode.Data{PK: dynamo.ShareKey(dynamo.DonorShareKey("1")), InviteSentTo: "email@example.com"} donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(r.Context()). - Return(&donordata.DonorProvidedDetails{}, nil) + Return(&donordata.Provided{}, nil) shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). @@ -387,7 +388,7 @@ func TestPostDonorAccessRemove(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - shareCodeData := actor.ShareCodeData{ + shareCodeData := sharecode.Data{ PK: dynamo.ShareKey(dynamo.DonorShareKey("1")), SK: dynamo.ShareSortKey(dynamo.DonorInviteKey("donor-session-id", "lpa-id")), InviteSentTo: "email@example.com", @@ -399,7 +400,7 @@ func TestPostDonorAccessRemove(t *testing.T) { GetDonor(r.Context()). Return(shareCodeData, nil) - donor := &donordata.DonorProvidedDetails{SK: dynamo.LpaOwnerKey(dynamo.DonorKey("donor-session-id"))} + donor := &donordata.Provided{SK: dynamo.LpaOwnerKey(dynamo.DonorKey("donor-session-id"))} donorStore := newMockDonorStore(t) donorStore.EXPECT(). @@ -428,7 +429,7 @@ func TestPostDonorAccessRemoveWhenDonorHasPaid(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - shareCodeData := actor.ShareCodeData{ + shareCodeData := sharecode.Data{ PK: dynamo.ShareKey(dynamo.DonorShareKey("1")), SK: dynamo.ShareSortKey(dynamo.DonorInviteKey("donor-session-id", "lpa-id")), InviteSentTo: "email@example.com", @@ -440,7 +441,7 @@ func TestPostDonorAccessRemoveWhenDonorHasPaid(t *testing.T) { GetDonor(r.Context()). Return(shareCodeData, nil) - donor := &donordata.DonorProvidedDetails{SK: dynamo.LpaOwnerKey(dynamo.DonorKey("donor-session-id")), Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateCompleted}} + donor := &donordata.Provided{SK: dynamo.LpaOwnerKey(dynamo.DonorKey("donor-session-id")), Tasks: donordata.Tasks{PayForLpa: task.PaymentStateCompleted}} donorStore := newMockDonorStore(t) donorStore.EXPECT(). @@ -464,9 +465,9 @@ func TestPostDonorAccessRemoveWhenDeleteLinkError(t *testing.T) { shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). GetDonor(mock.Anything). - Return(actor.ShareCodeData{}, nil) + Return(sharecode.Data{}, nil) - donor := &donordata.DonorProvidedDetails{SK: dynamo.LpaOwnerKey(dynamo.DonorKey("donor-session-id"))} + donor := &donordata.Provided{SK: dynamo.LpaOwnerKey(dynamo.DonorKey("donor-session-id"))} donorStore := newMockDonorStore(t) donorStore.EXPECT(). diff --git a/internal/page/supporter/mock_DonorStore_test.go b/internal/page/supporter/mock_DonorStore_test.go index 04498589b4..8ff6e878b4 100644 --- a/internal/page/supporter/mock_DonorStore_test.go +++ b/internal/page/supporter/mock_DonorStore_test.go @@ -27,7 +27,7 @@ func (_m *mockDonorStore) EXPECT() *mockDonorStore_Expecter { } // DeleteDonorAccess provides a mock function with given fields: ctx, shareCodeData -func (_m *mockDonorStore) DeleteDonorAccess(ctx context.Context, shareCodeData sharecode.ShareCodeData) error { +func (_m *mockDonorStore) DeleteDonorAccess(ctx context.Context, shareCodeData sharecode.Data) error { ret := _m.Called(ctx, shareCodeData) if len(ret) == 0 { @@ -35,7 +35,7 @@ func (_m *mockDonorStore) DeleteDonorAccess(ctx context.Context, shareCodeData s } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, sharecode.ShareCodeData) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, sharecode.Data) error); ok { r0 = rf(ctx, shareCodeData) } else { r0 = ret.Error(0) @@ -51,14 +51,14 @@ type mockDonorStore_DeleteDonorAccess_Call struct { // DeleteDonorAccess is a helper method to define mock.On call // - ctx context.Context -// - shareCodeData sharecode.ShareCodeData +// - shareCodeData sharecode.Data func (_e *mockDonorStore_Expecter) DeleteDonorAccess(ctx interface{}, shareCodeData interface{}) *mockDonorStore_DeleteDonorAccess_Call { return &mockDonorStore_DeleteDonorAccess_Call{Call: _e.mock.On("DeleteDonorAccess", ctx, shareCodeData)} } -func (_c *mockDonorStore_DeleteDonorAccess_Call) Run(run func(ctx context.Context, shareCodeData sharecode.ShareCodeData)) *mockDonorStore_DeleteDonorAccess_Call { +func (_c *mockDonorStore_DeleteDonorAccess_Call) Run(run func(ctx context.Context, shareCodeData sharecode.Data)) *mockDonorStore_DeleteDonorAccess_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(sharecode.ShareCodeData)) + run(args[0].(context.Context), args[1].(sharecode.Data)) }) return _c } @@ -68,29 +68,29 @@ func (_c *mockDonorStore_DeleteDonorAccess_Call) Return(_a0 error) *mockDonorSto return _c } -func (_c *mockDonorStore_DeleteDonorAccess_Call) RunAndReturn(run func(context.Context, sharecode.ShareCodeData) error) *mockDonorStore_DeleteDonorAccess_Call { +func (_c *mockDonorStore_DeleteDonorAccess_Call) RunAndReturn(run func(context.Context, sharecode.Data) error) *mockDonorStore_DeleteDonorAccess_Call { _c.Call.Return(run) return _c } // Get provides a mock function with given fields: ctx -func (_m *mockDonorStore) Get(ctx context.Context) (*donordata.DonorProvidedDetails, error) { +func (_m *mockDonorStore) Get(ctx context.Context) (*donordata.Provided, error) { ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for Get") } - var r0 *donordata.DonorProvidedDetails + var r0 *donordata.Provided var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (*donordata.DonorProvidedDetails, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context) (*donordata.Provided, error)); ok { return rf(ctx) } - if rf, ok := ret.Get(0).(func(context.Context) *donordata.DonorProvidedDetails); ok { + if rf, ok := ret.Get(0).(func(context.Context) *donordata.Provided); ok { r0 = rf(ctx) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*donordata.DonorProvidedDetails) + r0 = ret.Get(0).(*donordata.Provided) } } @@ -121,34 +121,34 @@ func (_c *mockDonorStore_Get_Call) Run(run func(ctx context.Context)) *mockDonor return _c } -func (_c *mockDonorStore_Get_Call) Return(_a0 *donordata.DonorProvidedDetails, _a1 error) *mockDonorStore_Get_Call { +func (_c *mockDonorStore_Get_Call) Return(_a0 *donordata.Provided, _a1 error) *mockDonorStore_Get_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockDonorStore_Get_Call) RunAndReturn(run func(context.Context) (*donordata.DonorProvidedDetails, error)) *mockDonorStore_Get_Call { +func (_c *mockDonorStore_Get_Call) RunAndReturn(run func(context.Context) (*donordata.Provided, error)) *mockDonorStore_Get_Call { _c.Call.Return(run) return _c } // GetByKeys provides a mock function with given fields: ctx, keys -func (_m *mockDonorStore) GetByKeys(ctx context.Context, keys []dynamo.Keys) ([]donordata.DonorProvidedDetails, error) { +func (_m *mockDonorStore) GetByKeys(ctx context.Context, keys []dynamo.Keys) ([]donordata.Provided, error) { ret := _m.Called(ctx, keys) if len(ret) == 0 { panic("no return value specified for GetByKeys") } - var r0 []donordata.DonorProvidedDetails + var r0 []donordata.Provided var r1 error - if rf, ok := ret.Get(0).(func(context.Context, []dynamo.Keys) ([]donordata.DonorProvidedDetails, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, []dynamo.Keys) ([]donordata.Provided, error)); ok { return rf(ctx, keys) } - if rf, ok := ret.Get(0).(func(context.Context, []dynamo.Keys) []donordata.DonorProvidedDetails); ok { + if rf, ok := ret.Get(0).(func(context.Context, []dynamo.Keys) []donordata.Provided); ok { r0 = rf(ctx, keys) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]donordata.DonorProvidedDetails) + r0 = ret.Get(0).([]donordata.Provided) } } @@ -180,18 +180,18 @@ func (_c *mockDonorStore_GetByKeys_Call) Run(run func(ctx context.Context, keys return _c } -func (_c *mockDonorStore_GetByKeys_Call) Return(_a0 []donordata.DonorProvidedDetails, _a1 error) *mockDonorStore_GetByKeys_Call { +func (_c *mockDonorStore_GetByKeys_Call) Return(_a0 []donordata.Provided, _a1 error) *mockDonorStore_GetByKeys_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockDonorStore_GetByKeys_Call) RunAndReturn(run func(context.Context, []dynamo.Keys) ([]donordata.DonorProvidedDetails, error)) *mockDonorStore_GetByKeys_Call { +func (_c *mockDonorStore_GetByKeys_Call) RunAndReturn(run func(context.Context, []dynamo.Keys) ([]donordata.Provided, error)) *mockDonorStore_GetByKeys_Call { _c.Call.Return(run) return _c } // Put provides a mock function with given fields: ctx, donor -func (_m *mockDonorStore) Put(ctx context.Context, donor *donordata.DonorProvidedDetails) error { +func (_m *mockDonorStore) Put(ctx context.Context, donor *donordata.Provided) error { ret := _m.Called(ctx, donor) if len(ret) == 0 { @@ -199,7 +199,7 @@ func (_m *mockDonorStore) Put(ctx context.Context, donor *donordata.DonorProvide } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *donordata.DonorProvidedDetails) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, *donordata.Provided) error); ok { r0 = rf(ctx, donor) } else { r0 = ret.Error(0) @@ -220,9 +220,9 @@ func (_e *mockDonorStore_Expecter) Put(ctx interface{}, donor interface{}) *mock return &mockDonorStore_Put_Call{Call: _e.mock.On("Put", ctx, donor)} } -func (_c *mockDonorStore_Put_Call) Run(run func(ctx context.Context, donor *donordata.DonorProvidedDetails)) *mockDonorStore_Put_Call { +func (_c *mockDonorStore_Put_Call) Run(run func(ctx context.Context, donor *donordata.Provided)) *mockDonorStore_Put_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*donordata.DonorProvidedDetails)) + run(args[0].(context.Context), args[1].(*donordata.Provided)) }) return _c } @@ -232,7 +232,7 @@ func (_c *mockDonorStore_Put_Call) Return(_a0 error) *mockDonorStore_Put_Call { return _c } -func (_c *mockDonorStore_Put_Call) RunAndReturn(run func(context.Context, *donordata.DonorProvidedDetails) error) *mockDonorStore_Put_Call { +func (_c *mockDonorStore_Put_Call) RunAndReturn(run func(context.Context, *donordata.Provided) error) *mockDonorStore_Put_Call { _c.Call.Return(run) return _c } diff --git a/internal/page/supporter/mock_OrganisationStore_test.go b/internal/page/supporter/mock_OrganisationStore_test.go index f7d30efeed..8157c66678 100644 --- a/internal/page/supporter/mock_OrganisationStore_test.go +++ b/internal/page/supporter/mock_OrganisationStore_test.go @@ -86,23 +86,23 @@ func (_c *mockOrganisationStore_Create_Call) RunAndReturn(run func(context.Conte } // CreateLPA provides a mock function with given fields: ctx -func (_m *mockOrganisationStore) CreateLPA(ctx context.Context) (*donordata.DonorProvidedDetails, error) { +func (_m *mockOrganisationStore) CreateLPA(ctx context.Context) (*donordata.Provided, error) { ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for CreateLPA") } - var r0 *donordata.DonorProvidedDetails + var r0 *donordata.Provided var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (*donordata.DonorProvidedDetails, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context) (*donordata.Provided, error)); ok { return rf(ctx) } - if rf, ok := ret.Get(0).(func(context.Context) *donordata.DonorProvidedDetails); ok { + if rf, ok := ret.Get(0).(func(context.Context) *donordata.Provided); ok { r0 = rf(ctx) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*donordata.DonorProvidedDetails) + r0 = ret.Get(0).(*donordata.Provided) } } @@ -133,12 +133,12 @@ func (_c *mockOrganisationStore_CreateLPA_Call) Run(run func(ctx context.Context return _c } -func (_c *mockOrganisationStore_CreateLPA_Call) Return(_a0 *donordata.DonorProvidedDetails, _a1 error) *mockOrganisationStore_CreateLPA_Call { +func (_c *mockOrganisationStore_CreateLPA_Call) Return(_a0 *donordata.Provided, _a1 error) *mockOrganisationStore_CreateLPA_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockOrganisationStore_CreateLPA_Call) RunAndReturn(run func(context.Context) (*donordata.DonorProvidedDetails, error)) *mockOrganisationStore_CreateLPA_Call { +func (_c *mockOrganisationStore_CreateLPA_Call) RunAndReturn(run func(context.Context) (*donordata.Provided, error)) *mockOrganisationStore_CreateLPA_Call { _c.Call.Return(run) return _c } diff --git a/internal/page/supporter/mock_ShareCodeStore_test.go b/internal/page/supporter/mock_ShareCodeStore_test.go index 4dc4eb057d..aa45031e63 100644 --- a/internal/page/supporter/mock_ShareCodeStore_test.go +++ b/internal/page/supporter/mock_ShareCodeStore_test.go @@ -23,7 +23,7 @@ func (_m *mockShareCodeStore) EXPECT() *mockShareCodeStore_Expecter { } // Delete provides a mock function with given fields: ctx, data -func (_m *mockShareCodeStore) Delete(ctx context.Context, data sharecode.ShareCodeData) error { +func (_m *mockShareCodeStore) Delete(ctx context.Context, data sharecode.Data) error { ret := _m.Called(ctx, data) if len(ret) == 0 { @@ -31,7 +31,7 @@ func (_m *mockShareCodeStore) Delete(ctx context.Context, data sharecode.ShareCo } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, sharecode.ShareCodeData) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, sharecode.Data) error); ok { r0 = rf(ctx, data) } else { r0 = ret.Error(0) @@ -47,14 +47,14 @@ type mockShareCodeStore_Delete_Call struct { // Delete is a helper method to define mock.On call // - ctx context.Context -// - data sharecode.ShareCodeData +// - data sharecode.Data func (_e *mockShareCodeStore_Expecter) Delete(ctx interface{}, data interface{}) *mockShareCodeStore_Delete_Call { return &mockShareCodeStore_Delete_Call{Call: _e.mock.On("Delete", ctx, data)} } -func (_c *mockShareCodeStore_Delete_Call) Run(run func(ctx context.Context, data sharecode.ShareCodeData)) *mockShareCodeStore_Delete_Call { +func (_c *mockShareCodeStore_Delete_Call) Run(run func(ctx context.Context, data sharecode.Data)) *mockShareCodeStore_Delete_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(sharecode.ShareCodeData)) + run(args[0].(context.Context), args[1].(sharecode.Data)) }) return _c } @@ -64,28 +64,28 @@ func (_c *mockShareCodeStore_Delete_Call) Return(_a0 error) *mockShareCodeStore_ return _c } -func (_c *mockShareCodeStore_Delete_Call) RunAndReturn(run func(context.Context, sharecode.ShareCodeData) error) *mockShareCodeStore_Delete_Call { +func (_c *mockShareCodeStore_Delete_Call) RunAndReturn(run func(context.Context, sharecode.Data) error) *mockShareCodeStore_Delete_Call { _c.Call.Return(run) return _c } // GetDonor provides a mock function with given fields: ctx -func (_m *mockShareCodeStore) GetDonor(ctx context.Context) (sharecode.ShareCodeData, error) { +func (_m *mockShareCodeStore) GetDonor(ctx context.Context) (sharecode.Data, error) { ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for GetDonor") } - var r0 sharecode.ShareCodeData + var r0 sharecode.Data var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (sharecode.ShareCodeData, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context) (sharecode.Data, error)); ok { return rf(ctx) } - if rf, ok := ret.Get(0).(func(context.Context) sharecode.ShareCodeData); ok { + if rf, ok := ret.Get(0).(func(context.Context) sharecode.Data); ok { r0 = rf(ctx) } else { - r0 = ret.Get(0).(sharecode.ShareCodeData) + r0 = ret.Get(0).(sharecode.Data) } if rf, ok := ret.Get(1).(func(context.Context) error); ok { @@ -115,18 +115,18 @@ func (_c *mockShareCodeStore_GetDonor_Call) Run(run func(ctx context.Context)) * return _c } -func (_c *mockShareCodeStore_GetDonor_Call) Return(_a0 sharecode.ShareCodeData, _a1 error) *mockShareCodeStore_GetDonor_Call { +func (_c *mockShareCodeStore_GetDonor_Call) Return(_a0 sharecode.Data, _a1 error) *mockShareCodeStore_GetDonor_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockShareCodeStore_GetDonor_Call) RunAndReturn(run func(context.Context) (sharecode.ShareCodeData, error)) *mockShareCodeStore_GetDonor_Call { +func (_c *mockShareCodeStore_GetDonor_Call) RunAndReturn(run func(context.Context) (sharecode.Data, error)) *mockShareCodeStore_GetDonor_Call { _c.Call.Return(run) return _c } // PutDonor provides a mock function with given fields: ctx, shareCode, data -func (_m *mockShareCodeStore) PutDonor(ctx context.Context, shareCode string, data sharecode.ShareCodeData) error { +func (_m *mockShareCodeStore) PutDonor(ctx context.Context, shareCode string, data sharecode.Data) error { ret := _m.Called(ctx, shareCode, data) if len(ret) == 0 { @@ -134,7 +134,7 @@ func (_m *mockShareCodeStore) PutDonor(ctx context.Context, shareCode string, da } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, sharecode.ShareCodeData) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, string, sharecode.Data) error); ok { r0 = rf(ctx, shareCode, data) } else { r0 = ret.Error(0) @@ -151,14 +151,14 @@ type mockShareCodeStore_PutDonor_Call struct { // PutDonor is a helper method to define mock.On call // - ctx context.Context // - shareCode string -// - data sharecode.ShareCodeData +// - data sharecode.Data func (_e *mockShareCodeStore_Expecter) PutDonor(ctx interface{}, shareCode interface{}, data interface{}) *mockShareCodeStore_PutDonor_Call { return &mockShareCodeStore_PutDonor_Call{Call: _e.mock.On("PutDonor", ctx, shareCode, data)} } -func (_c *mockShareCodeStore_PutDonor_Call) Run(run func(ctx context.Context, shareCode string, data sharecode.ShareCodeData)) *mockShareCodeStore_PutDonor_Call { +func (_c *mockShareCodeStore_PutDonor_Call) Run(run func(ctx context.Context, shareCode string, data sharecode.Data)) *mockShareCodeStore_PutDonor_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(string), args[2].(sharecode.ShareCodeData)) + run(args[0].(context.Context), args[1].(string), args[2].(sharecode.Data)) }) return _c } @@ -168,7 +168,7 @@ func (_c *mockShareCodeStore_PutDonor_Call) Return(_a0 error) *mockShareCodeStor return _c } -func (_c *mockShareCodeStore_PutDonor_Call) RunAndReturn(run func(context.Context, string, sharecode.ShareCodeData) error) *mockShareCodeStore_PutDonor_Call { +func (_c *mockShareCodeStore_PutDonor_Call) RunAndReturn(run func(context.Context, string, sharecode.Data) error) *mockShareCodeStore_PutDonor_Call { _c.Call.Return(run) return _c } diff --git a/internal/page/supporter/register.go b/internal/page/supporter/register.go index 4bdba18a97..48ed297448 100644 --- a/internal/page/supporter/register.go +++ b/internal/page/supporter/register.go @@ -20,6 +20,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/random" "github.com/ministryofjustice/opg-modernising-lpa/internal/search" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" + "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -33,7 +34,7 @@ type LpaStoreResolvingService interface { type OrganisationStore interface { Create(ctx context.Context, member *actor.Member, name string) (*actor.Organisation, error) - CreateLPA(ctx context.Context) (*donordata.DonorProvidedDetails, error) + CreateLPA(ctx context.Context) (*donordata.Provided, error) Get(ctx context.Context) (*actor.Organisation, error) Put(ctx context.Context, organisation *actor.Organisation) error SoftDelete(ctx context.Context, organisation *actor.Organisation) error @@ -55,10 +56,10 @@ type MemberStore interface { } type DonorStore interface { - DeleteDonorAccess(ctx context.Context, shareCodeData actor.ShareCodeData) error - Get(ctx context.Context) (*donordata.DonorProvidedDetails, error) - GetByKeys(ctx context.Context, keys []dynamo.Keys) ([]donordata.DonorProvidedDetails, error) - Put(ctx context.Context, donor *donordata.DonorProvidedDetails) error + DeleteDonorAccess(ctx context.Context, shareCodeData sharecode.Data) error + Get(ctx context.Context) (*donordata.Provided, error) + GetByKeys(ctx context.Context, keys []dynamo.Keys) ([]donordata.Provided, error) + Put(ctx context.Context, donor *donordata.Provided) error } type CertificateProviderStore interface { @@ -88,9 +89,9 @@ type NotifyClient interface { } type ShareCodeStore interface { - PutDonor(ctx context.Context, shareCode string, data actor.ShareCodeData) error - GetDonor(ctx context.Context) (actor.ShareCodeData, error) - Delete(ctx context.Context, data actor.ShareCodeData) error + PutDonor(ctx context.Context, shareCode string, data sharecode.Data) error + GetDonor(ctx context.Context) (sharecode.Data, error) + Delete(ctx context.Context, data sharecode.Data) error } type Template func(w io.Writer, data interface{}) error diff --git a/internal/page/supporter/view_lpa_test.go b/internal/page/supporter/view_lpa_test.go index 464aef97b3..8a67d72c31 100644 --- a/internal/page/supporter/view_lpa_test.go +++ b/internal/page/supporter/view_lpa_test.go @@ -8,6 +8,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" lpastore "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -26,14 +27,14 @@ func TestGetViewLPA(t *testing.T) { progressTracker := newMockProgressTracker(t) progressTracker.EXPECT(). Progress(lpa). - Return(page.Progress{Paid: page.ProgressTask{State: actor.TaskInProgress}}) + Return(page.Progress{Paid: page.ProgressTask{State: task.StateInProgress}}) template := newMockTemplate(t) template.EXPECT(). Execute(w, &viewLPAData{ App: testAppData, Lpa: lpa, - Progress: page.Progress{Paid: page.ProgressTask{State: actor.TaskInProgress}}, + Progress: page.Progress{Paid: page.ProgressTask{State: task.StateInProgress}}, }). Return(nil) diff --git a/internal/page/witness_code.go b/internal/page/witness_code.go index 1e87b9213b..06639b6cf4 100644 --- a/internal/page/witness_code.go +++ b/internal/page/witness_code.go @@ -33,7 +33,7 @@ func NewWitnessCodeSender(donorStore DonorStore, notifyClient NotifyClient) *Wit } } -func (s *WitnessCodeSender) SendToCertificateProvider(ctx context.Context, donor *donordata.DonorProvidedDetails, localizer Localizer) error { +func (s *WitnessCodeSender) SendToCertificateProvider(ctx context.Context, donor *donordata.Provided, localizer Localizer) error { if !donor.CertificateProviderCodes.CanRequest(s.now()) { return ErrTooManyWitnessCodeRequests } @@ -56,7 +56,7 @@ func (s *WitnessCodeSender) SendToCertificateProvider(ctx context.Context, donor }) } -func (s *WitnessCodeSender) SendToIndependentWitness(ctx context.Context, donor *donordata.DonorProvidedDetails, localizer Localizer) error { +func (s *WitnessCodeSender) SendToIndependentWitness(ctx context.Context, donor *donordata.Provided, localizer Localizer) error { if !donor.IndependentWitnessCodes.CanRequest(s.now()) { return ErrTooManyWitnessCodeRequests } diff --git a/internal/page/witness_code_test.go b/internal/page/witness_code_test.go index 239529db1a..96f67985e0 100644 --- a/internal/page/witness_code_test.go +++ b/internal/page/witness_code_test.go @@ -45,7 +45,7 @@ func TestWitnessCodeSenderSendToCertificateProvider(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(ctx, &donordata.DonorProvidedDetails{ + Put(ctx, &donordata.Provided{ LpaUID: "lpa-uid", Donor: donordata.Donor{FirstNames: "Joe", LastName: "Jones"}, CertificateProvider: donordata.CertificateProvider{Mobile: "0777"}, @@ -68,7 +68,7 @@ func TestWitnessCodeSenderSendToCertificateProvider(t *testing.T) { randomCode: func(int) string { return tc.randomCode }, now: func() time.Time { return now }, } - err := sender.SendToCertificateProvider(ctx, &donordata.DonorProvidedDetails{ + err := sender.SendToCertificateProvider(ctx, &donordata.Provided{ LpaUID: "lpa-uid", Donor: donordata.Donor{FirstNames: "Joe", LastName: "Jones"}, CertificateProvider: donordata.CertificateProvider{Mobile: "0777"}, @@ -85,7 +85,7 @@ func TestWitnessCodeSenderSendToCertificateProviderWhenTooRecentlySent(t *testin ctx := context.Background() sender := &WitnessCodeSender{now: func() time.Time { return now }} - err := sender.SendToCertificateProvider(ctx, &donordata.DonorProvidedDetails{ + err := sender.SendToCertificateProvider(ctx, &donordata.Provided{ CertificateProviderCodes: donordata.WitnessCodes{{Created: now.Add(-time.Minute)}}, }, nil) @@ -117,7 +117,7 @@ func TestWitnessCodeSenderSendToCertificateProviderWhenNotifyClientErrors(t *tes randomCode: func(int) string { return "1234" }, now: time.Now, } - err := sender.SendToCertificateProvider(context.Background(), &donordata.DonorProvidedDetails{ + err := sender.SendToCertificateProvider(context.Background(), &donordata.Provided{ CertificateProvider: donordata.CertificateProvider{Mobile: "0777"}, Donor: donordata.Donor{FirstNames: "Joe", LastName: "Jones"}, Type: donordata.LpaTypePropertyAndAffairs, @@ -137,7 +137,7 @@ func TestWitnessCodeSenderSendToCertificateProviderWhenDonorStoreErrors(t *testi randomCode: func(int) string { return "1234" }, now: time.Now, } - err := sender.SendToCertificateProvider(context.Background(), &donordata.DonorProvidedDetails{ + err := sender.SendToCertificateProvider(context.Background(), &donordata.Provided{ CertificateProvider: donordata.CertificateProvider{Mobile: "0777"}, Donor: donordata.Donor{FirstNames: "Joe", LastName: "Jones"}, Type: donordata.LpaTypePropertyAndAffairs, @@ -161,7 +161,7 @@ func TestWitnessCodeSenderSendToIndependentWitness(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(ctx, &donordata.DonorProvidedDetails{ + Put(ctx, &donordata.Provided{ LpaUID: "lpa-uid", Donor: donordata.Donor{FirstNames: "Joe", LastName: "Jones"}, IndependentWitness: donordata.IndependentWitness{Mobile: "0777"}, @@ -184,7 +184,7 @@ func TestWitnessCodeSenderSendToIndependentWitness(t *testing.T) { randomCode: func(int) string { return "1234" }, now: func() time.Time { return now }, } - err := sender.SendToIndependentWitness(ctx, &donordata.DonorProvidedDetails{ + err := sender.SendToIndependentWitness(ctx, &donordata.Provided{ LpaUID: "lpa-uid", Donor: donordata.Donor{FirstNames: "Joe", LastName: "Jones"}, IndependentWitness: donordata.IndependentWitness{Mobile: "0777"}, @@ -199,7 +199,7 @@ func TestWitnessCodeSenderSendToIndependentWitnessWhenTooRecentlySent(t *testing ctx := context.Background() sender := &WitnessCodeSender{now: func() time.Time { return now }} - err := sender.SendToIndependentWitness(ctx, &donordata.DonorProvidedDetails{ + err := sender.SendToIndependentWitness(ctx, &donordata.Provided{ IndependentWitnessCodes: donordata.WitnessCodes{{Created: now.Add(-time.Minute)}}, }, nil) @@ -231,7 +231,7 @@ func TestWitnessCodeSenderSendToIndependentWitnessWhenNotifyClientErrors(t *test randomCode: func(int) string { return "1234" }, now: time.Now, } - err := sender.SendToIndependentWitness(context.Background(), &donordata.DonorProvidedDetails{ + err := sender.SendToIndependentWitness(context.Background(), &donordata.Provided{ IndependentWitness: donordata.IndependentWitness{Mobile: "0777"}, Donor: donordata.Donor{FirstNames: "Joe", LastName: "Jones"}, Type: donordata.LpaTypePropertyAndAffairs, @@ -251,7 +251,7 @@ func TestWitnessCodeSenderSendToIndependentWitnessWhenDonorStoreErrors(t *testin randomCode: func(int) string { return "1234" }, now: time.Now, } - err := sender.SendToIndependentWitness(context.Background(), &donordata.DonorProvidedDetails{ + err := sender.SendToIndependentWitness(context.Background(), &donordata.Provided{ IndependentWitness: donordata.IndependentWitness{Mobile: "0777"}, Donor: donordata.Donor{FirstNames: "Joe", LastName: "Jones"}, Type: donordata.LpaTypePropertyAndAffairs, diff --git a/internal/sharecode/data.go b/internal/sharecode/data.go index 5873ecbc8a..7dc046cae1 100644 --- a/internal/sharecode/data.go +++ b/internal/sharecode/data.go @@ -7,7 +7,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" ) -type ShareCodeData struct { +type Data struct { PK dynamo.ShareKeyType SK dynamo.ShareSortKeyType UpdatedAt time.Time diff --git a/internal/templatefn/fn.go b/internal/templatefn/fn.go index abbeb85416..b99e9ca7dc 100644 --- a/internal/templatefn/fn.go +++ b/internal/templatefn/fn.go @@ -487,7 +487,7 @@ func lpaDecisions(app page.AppData, lpa any, canChange bool) lpaDecisionsData { switch v := lpa.(type) { case *lpastore.Lpa: data.Lpa = v - case *donordata.DonorProvidedDetails: + case *donordata.Provided: data.Lpa = lpastore.FromDonorProvidedDetails(v) } diff --git a/internal/templatefn/fn_test.go b/internal/templatefn/fn_test.go index e65831346a..1b6880cf65 100644 --- a/internal/templatefn/fn_test.go +++ b/internal/templatefn/fn_test.go @@ -562,7 +562,7 @@ func TestLpaDecisionsWithDonorProvidedDetails(t *testing.T) { App: app, Lpa: &lpastore.Lpa{}, CanChange: true, - }, lpaDecisions(app, &donordata.DonorProvidedDetails{}, true)) + }, lpaDecisions(app, &donordata.Provided{}, true)) } func TestSummaryRow(t *testing.T) {