From 4293ce7bf717679b2b61b9305bd5b79396ea16dd Mon Sep 17 00:00:00 2001 From: Joshua Hawxwell Date: Thu, 1 Aug 2024 14:41:48 +0100 Subject: [PATCH] Move uses from actor.* to donordata.* (#1393) --- cmd/event-received/factory.go | 6 +- cmd/event-received/handlers.go | 8 +- cmd/event-received/handlers_test.go | 11 +- .../lpastore_event_handler_test.go | 12 +- .../makeregister_event_handler_test.go | 12 +- cmd/event-received/sirius_event_handler.go | 13 +- .../sirius_event_handler_test.go | 82 ++++---- internal/actor/attorney.go | 9 - internal/actor/attorney_decisions.go | 15 -- internal/actor/can_be_used_when.go | 11 - internal/actor/certificate_provider.go | 22 -- internal/actor/channel.go | 10 - internal/actor/correspondent.go | 7 - internal/actor/donor.go | 11 - internal/actor/donor_provided.go | 11 - internal/actor/life_sustaining_treatment.go | 10 - internal/actor/limiter.go | 7 - internal/actor/lpa_type.go | 10 - internal/actor/payment.go | 5 - internal/actor/person_to_notify.go | 8 - .../actor/replacement_attorneys_step_in.go | 11 - internal/actor/voucher.go | 5 - internal/actor/witness_codes.go | 8 - internal/actor/yes_no_maybe.go | 11 - internal/app/dashboard_store.go | 9 +- internal/app/dashboard_store_test.go | 25 +-- internal/app/document_store.go | 6 +- internal/app/document_store_test.go | 18 +- internal/app/evidence_received_store_test.go | 4 +- internal/app/organisation_store.go | 7 +- internal/app/organisation_store_test.go | 5 +- internal/app/uid_store.go | 4 +- internal/app/uid_store_test.go | 10 +- ...ont_want_to_be_attorney_logged_out_test.go | 5 +- .../confirm_dont_want_to_be_attorney_test.go | 6 +- .../mock_CertificateProviderStore_test.go | 2 +- .../attorneypage/mock_DonorStore_test.go | 17 +- internal/attorney/attorneypage/sign_test.go | 13 +- ...rm_dont_want_to_be_certificate_provider.go | 3 +- ...t_to_be_certificate_provider_logged_out.go | 3 +- ...be_certificate_provider_logged_out_test.go | 29 +-- ...nt_want_to_be_certificate_provider_test.go | 29 +-- .../confirm_your_details_test.go | 13 +- .../enter_date_of_birth_test.go | 3 +- .../identity_with_one_login_callback_test.go | 6 +- .../provide_certificate_test.go | 13 +- .../certificateproviderpage/register.go | 5 +- internal/donor/donorpage/add_correspondent.go | 7 +- .../donor/donorpage/add_correspondent_test.go | 33 +-- ..._applying_for_fee_discount_or_exemption.go | 9 +- ...ying_for_fee_discount_or_exemption_test.go | 29 +-- .../donor/donorpage/can_you_sign_your_lpa.go | 5 +- .../donorpage/can_you_sign_your_lpa_test.go | 39 ++-- .../donorpage/certificate_provider_address.go | 3 +- .../certificate_provider_address_test.go | 79 +++---- .../donorpage/certificate_provider_details.go | 5 +- .../certificate_provider_details_test.go | 95 ++++----- .../donor/donorpage/change_mobile_number.go | 5 +- .../donorpage/change_mobile_number_test.go | 53 ++--- .../donor/donorpage/check_you_can_sign.go | 4 +- .../donorpage/check_you_can_sign_test.go | 14 +- .../donor/donorpage/check_your_details.go | 6 +- .../donorpage/check_your_details_test.go | 17 +- internal/donor/donorpage/check_your_lpa.go | 11 +- .../donor/donorpage/check_your_lpa_test.go | 93 ++++----- .../choose_a_new_certificate_provider.go | 8 +- .../choose_a_new_certificate_provider_test.go | 18 +- internal/donor/donorpage/choose_attorneys.go | 11 +- .../donorpage/choose_attorneys_address.go | 4 +- .../choose_attorneys_address_test.go | 105 +++++----- .../donorpage/choose_attorneys_guidance.go | 6 +- .../choose_attorneys_guidance_test.go | 10 +- .../donorpage/choose_attorneys_summary.go | 6 +- .../choose_attorneys_summary_test.go | 24 +-- .../donor/donorpage/choose_attorneys_test.go | 135 ++++++------ .../donorpage/choose_people_to_notify.go | 7 +- .../choose_people_to_notify_address.go | 3 +- .../choose_people_to_notify_address_test.go | 85 ++++---- .../choose_people_to_notify_summary.go | 6 +- .../choose_people_to_notify_summary_test.go | 17 +- .../donorpage/choose_people_to_notify_test.go | 77 +++---- .../donorpage/choose_replacement_attorneys.go | 9 +- .../choose_replacement_attorneys_address.go | 4 +- ...oose_replacement_attorneys_address_test.go | 83 ++++---- .../choose_replacement_attorneys_summary.go | 6 +- ...oose_replacement_attorneys_summary_test.go | 69 +++---- .../choose_replacement_attorneys_test.go | 129 ++++++------ .../confirm_person_allowed_to_vouch.go | 5 +- .../confirm_person_allowed_to_vouch_test.go | 35 ++-- ...our_certificate_provider_is_not_related.go | 7 +- ...ertificate_provider_is_not_related_test.go | 41 ++-- internal/donor/donorpage/delete_lpa.go | 6 +- internal/donor/donorpage/delete_lpa_test.go | 12 +- .../donorpage/do_you_want_to_notify_people.go | 11 +- .../do_you_want_to_notify_people_test.go | 47 ++--- .../donorpage/enter_correspondent_address.go | 3 +- .../enter_correspondent_address_test.go | 67 +++--- .../donorpage/enter_correspondent_details.go | 5 +- .../enter_correspondent_details_test.go | 43 ++-- .../enter_replacement_trust_corporation.go | 4 +- ...r_replacement_trust_corporation_address.go | 4 +- ...lacement_trust_corporation_address_test.go | 97 ++++----- ...nter_replacement_trust_corporation_test.go | 21 +- .../donorpage/enter_trust_corporation.go | 4 +- .../enter_trust_corporation_address.go | 4 +- .../enter_trust_corporation_address_test.go | 97 ++++----- .../donorpage/enter_trust_corporation_test.go | 19 +- internal/donor/donorpage/enter_voucher.go | 4 +- .../donor/donorpage/enter_voucher_test.go | 40 ++-- internal/donor/donorpage/fee_denied.go | 6 +- internal/donor/donorpage/fee_denied_test.go | 9 +- internal/donor/donorpage/guidance.go | 6 +- internal/donor/donorpage/guidance_test.go | 8 +- ...w_do_you_know_your_certificate_provider.go | 8 +- ...you_know_your_certificate_provider_test.go | 80 ++++---- ...ong_have_you_known_certificate_provider.go | 11 +- ...ave_you_known_certificate_provider_test.go | 44 ++-- .../how_should_attorneys_make_decisions.go | 15 +- ...ow_should_attorneys_make_decisions_test.go | 64 +++--- ...ld_replacement_attorneys_make_decisions.go | 7 +- ...placement_attorneys_make_decisions_test.go | 58 +++--- ...ow_should_replacement_attorneys_step_in.go | 9 +- ...ould_replacement_attorneys_step_in_test.go | 102 +++++----- ...provider_prefer_to_carry_out_their_role.go | 7 +- ...der_prefer_to_carry_out_their_role_test.go | 67 +++--- .../how_would_you_like_to_send_evidence.go | 4 +- ...ow_would_you_like_to_send_evidence_test.go | 16 +- .../donorpage/identity_with_one_login.go | 4 +- .../identity_with_one_login_callback.go | 3 +- .../identity_with_one_login_callback_test.go | 39 ++-- .../donorpage/identity_with_one_login_test.go | 8 +- .../donorpage/life_sustaining_treatment.go | 4 +- .../life_sustaining_treatment_test.go | 32 +-- internal/donor/donorpage/lpa_details_saved.go | 6 +- .../donor/donorpage/lpa_details_saved_test.go | 8 +- internal/donor/donorpage/lpa_progress.go | 6 +- internal/donor/donorpage/lpa_progress_test.go | 9 +- internal/donor/donorpage/lpa_type.go | 6 +- internal/donor/donorpage/lpa_type_test.go | 64 +++--- .../donorpage/one_login_identity_details.go | 6 +- .../one_login_identity_details_test.go | 32 +-- internal/donor/donorpage/pay.go | 7 +- internal/donor/donorpage/pay_test.go | 43 ++-- .../donor/donorpage/payment_confirmation.go | 17 +- .../donorpage/payment_confirmation_test.go | 192 +++++++++--------- .../donorpage/previous_application_number.go | 4 +- .../previous_application_number_test.go | 18 +- internal/donor/donorpage/previous_fee.go | 4 +- internal/donor/donorpage/previous_fee_test.go | 22 +- internal/donor/donorpage/register.go | 25 +-- internal/donor/donorpage/register_test.go | 45 ++-- .../register_with_court_of_protection.go | 4 +- .../register_with_court_of_protection_test.go | 14 +- internal/donor/donorpage/remove_attorney.go | 6 +- .../donor/donorpage/remove_attorney_test.go | 69 +++---- .../donorpage/remove_person_to_notify.go | 5 +- .../donorpage/remove_person_to_notify_test.go | 49 ++--- .../donorpage/remove_replacement_attorney.go | 6 +- .../remove_replacement_attorney_test.go | 69 +++---- .../donorpage/remove_trust_corporation.go | 16 +- .../remove_trust_corporation_test.go | 97 ++++----- .../donor/donorpage/resend_witness_code.go | 3 +- .../donorpage/resend_witness_code_test.go | 23 ++- internal/donor/donorpage/restrictions.go | 5 +- internal/donor/donorpage/restrictions_test.go | 29 +-- .../send_us_your_evidence_by_post.go | 4 +- .../send_us_your_evidence_by_post_test.go | 12 +- internal/donor/donorpage/sign_your_lpa.go | 6 +- .../donor/donorpage/sign_your_lpa_test.go | 18 +- internal/donor/donorpage/task_list.go | 24 ++- internal/donor/donorpage/task_list_test.go | 122 +++++------ internal/donor/donorpage/upload_evidence.go | 4 +- .../donor/donorpage/upload_evidence_sse.go | 4 +- .../donorpage/upload_evidence_sse_test.go | 8 +- .../donor/donorpage/upload_evidence_test.go | 71 +++---- .../donorpage/want_replacement_attorneys.go | 8 +- .../want_replacement_attorneys_test.go | 37 ++-- internal/donor/donorpage/what_is_vouching.go | 4 +- .../donor/donorpage/what_is_vouching_test.go | 12 +- .../donor/donorpage/what_you_can_do_now.go | 3 +- .../donorpage/what_you_can_do_now_test.go | 21 +- .../donorpage/when_can_the_lpa_be_used.go | 6 +- .../when_can_the_lpa_be_used_test.go | 36 ++-- .../which_fee_type_are_you_applying_for.go | 4 +- ...hich_fee_type_are_you_applying_for_test.go | 18 +- internal/donor/donorpage/withdraw_lpa.go | 6 +- internal/donor/donorpage/withdraw_lpa_test.go | 14 +- .../witnessing_as_certificate_provider.go | 7 +- ...witnessing_as_certificate_provider_test.go | 128 ++++++------ .../witnessing_as_independent_witness.go | 8 +- .../witnessing_as_independent_witness_test.go | 88 ++++---- .../donorpage/witnessing_your_signature.go | 6 +- .../witnessing_your_signature_test.go | 32 +-- .../donorpage/you_cannot_sign_your_lpa_yet.go | 4 +- .../you_cannot_sign_your_lpa_yet_test.go | 14 +- internal/donor/donorpage/your_address.go | 4 +- internal/donor/donorpage/your_address_test.go | 54 ++--- .../donorpage/your_authorised_signatory.go | 5 +- .../your_authorised_signatory_test.go | 69 +++---- .../donor/donorpage/your_date_of_birth.go | 4 +- .../donorpage/your_date_of_birth_test.go | 38 ++-- internal/donor/donorpage/your_email.go | 4 +- internal/donor/donorpage/your_email_test.go | 18 +- .../donorpage/your_independent_witness.go | 5 +- .../your_independent_witness_address.go | 3 +- .../your_independent_witness_address_test.go | 61 +++--- .../your_independent_witness_mobile.go | 6 +- .../your_independent_witness_mobile_test.go | 30 +-- .../your_independent_witness_test.go | 69 +++---- internal/donor/donorpage/your_lpa_language.go | 4 +- .../donor/donorpage/your_lpa_language_test.go | 24 +-- internal/donor/donorpage/your_name.go | 5 +- internal/donor/donorpage/your_name_test.go | 67 +++--- .../donorpage/your_preferred_language.go | 4 +- .../donorpage/your_preferred_language_test.go | 16 +- internal/lpastore/client_test.go | 72 +++---- internal/lpastore/lpa.go | 186 ++++++++--------- internal/lpastore/lpa_test.go | 126 ++++++------ internal/lpastore/resolving_service.go | 14 +- internal/lpastore/resolving_service_test.go | 112 +++++----- internal/lpastore/update.go | 16 +- internal/lpastore/update_test.go | 16 +- internal/page/app_data.go | 3 +- internal/page/common.go | 5 +- internal/page/dashboard_test.go | 6 +- internal/page/data.go | 15 +- internal/page/data_test.go | 168 +++++++-------- internal/page/fixtures/attorney.go | 31 +-- .../page/fixtures/certificate_provider.go | 28 +-- internal/page/fixtures/dashboard.go | 12 +- internal/page/fixtures/donor.go | 51 ++--- internal/page/fixtures/fixtures.go | 37 ++-- internal/page/fixtures/supporter.go | 15 +- internal/page/mock_AttorneyStore_test.go | 1 - internal/page/mock_shareCodeSender_test.go | 11 +- internal/page/paths.go | 10 +- internal/page/paths_test.go | 76 +++---- internal/page/share_code.go | 5 +- internal/page/share_code_test.go | 83 ++++---- .../confirm_donor_can_interact_online_test.go | 5 +- internal/page/supporter/dashboard.go | 3 +- internal/page/supporter/dashboard_test.go | 4 +- internal/page/supporter/donor_access.go | 3 +- internal/page/supporter/donor_access_test.go | 40 ++-- internal/page/supporter/register.go | 9 +- internal/page/witness_code.go | 10 +- internal/page/witness_code_test.go | 78 +++---- internal/templatefn/fn.go | 7 +- internal/templatefn/fn_test.go | 13 +- 249 files changed, 3202 insertions(+), 3263 deletions(-) delete mode 100644 internal/actor/attorney.go delete mode 100644 internal/actor/attorney_decisions.go delete mode 100644 internal/actor/can_be_used_when.go delete mode 100644 internal/actor/certificate_provider.go delete mode 100644 internal/actor/channel.go delete mode 100644 internal/actor/correspondent.go delete mode 100644 internal/actor/donor.go delete mode 100644 internal/actor/donor_provided.go delete mode 100644 internal/actor/life_sustaining_treatment.go delete mode 100644 internal/actor/limiter.go delete mode 100644 internal/actor/lpa_type.go delete mode 100644 internal/actor/payment.go delete mode 100644 internal/actor/person_to_notify.go delete mode 100644 internal/actor/replacement_attorneys_step_in.go delete mode 100644 internal/actor/voucher.go delete mode 100644 internal/actor/witness_codes.go delete mode 100644 internal/actor/yes_no_maybe.go diff --git a/cmd/event-received/factory.go b/cmd/event-received/factory.go index 87cd345865..43b8afee41 100644 --- a/cmd/event-received/factory.go +++ b/cmd/event-received/factory.go @@ -9,8 +9,8 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" v4 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" "github.com/ministryofjustice/opg-modernising-lpa/internal/app" + "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/event" "github.com/ministryofjustice/opg-modernising-lpa/internal/lambda" "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" @@ -28,7 +28,7 @@ type LambdaClient interface { } type LpaStoreClient interface { - SendLpa(ctx context.Context, donor *actor.DonorProvidedDetails) error + SendLpa(ctx context.Context, donor *donordata.DonorProvidedDetails) 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, *actor.DonorProvidedDetails) error + SendCertificateProviderPrompt(context.Context, page.AppData, *donordata.DonorProvidedDetails) error SendAttorneys(context.Context, page.AppData, *lpastore.Lpa) error } diff --git a/cmd/event-received/handlers.go b/cmd/event-received/handlers.go index c68e2977c3..fa0b94be52 100644 --- a/cmd/event-received/handlers.go +++ b/cmd/event-received/handlers.go @@ -7,7 +7,7 @@ import ( "time" "github.com/aws/aws-lambda-go/events" - "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" ) @@ -52,7 +52,7 @@ func handleObjectTagsAdded(ctx context.Context, dynamodbClient dynamodbClient, e return nil } -func putDonor(ctx context.Context, donor *actor.DonorProvidedDetails, now func() time.Time, client dynamodbClient) error { +func putDonor(ctx context.Context, donor *donordata.DonorProvidedDetails, 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 *actor.DonorProvidedDetails, now func() return client.Put(ctx, donor) } -func getDonorByLpaUID(ctx context.Context, client dynamodbClient, uid string) (*actor.DonorProvidedDetails, error) { +func getDonorByLpaUID(ctx context.Context, client dynamodbClient, uid string) (*donordata.DonorProvidedDetails, 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 actor.DonorProvidedDetails + var donor donordata.DonorProvidedDetails 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 5a7fe13e46..df05073d69 100644 --- a/cmd/event-received/handlers_test.go +++ b/cmd/event-received/handlers_test.go @@ -10,8 +10,9 @@ import ( "github.com/aws/aws-lambda-go/events" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/s3/types" - "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/task" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -48,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(actor.DonorProvidedDetails{LpaID: "123", Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskPending}}) + b, _ := json.Marshal(donordata.DonorProvidedDetails{LpaID: "123", Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}}) json.Unmarshal(b, v) return nil }) @@ -134,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(actor.DonorProvidedDetails{LpaID: "123", Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskPending}}) + b, _ := json.Marshal(donordata.DonorProvidedDetails{LpaID: "123", Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}}) json.Unmarshal(b, v) return expectedError }) @@ -168,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(actor.DonorProvidedDetails{LpaID: "123", Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskPending}}) + b, _ := json.Marshal(donordata.DonorProvidedDetails{LpaID: "123", Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}}) json.Unmarshal(b, v) return nil }) @@ -183,7 +184,7 @@ func TestHandleObjectTagsAddedWhenDocumentStoreUpdateScanResultsError(t *testing } func TestGetLpaByUID(t *testing.T) { - expectedDonor := &actor.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456"))} + expectedDonor := &donordata.DonorProvidedDetails{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 871e98de95..4a89aa7af1 100644 --- a/cmd/event-received/lpastore_event_handler_test.go +++ b/cmd/event-received/lpastore_event_handler_test.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/aws/aws-lambda-go/events" - "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/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -26,7 +26,7 @@ func TestLpaStoreEventHandlerHandleLpaUpdated(t *testing.T) { Detail: json.RawMessage(`{"uid":"M-1111-2222-3333","changeType":"PERFECT"}`), } - updated := &actor.DonorProvidedDetails{ + updated := &donordata.DonorProvidedDetails{ 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(actor.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456"))}) + b, _ := json.Marshal(donordata.DonorProvidedDetails{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 := &actor.DonorProvidedDetails{ + updated := &donordata.DonorProvidedDetails{ 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 := &actor.DonorProvidedDetails{ + updated := &donordata.DonorProvidedDetails{ 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(actor.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456"))}) + b, _ := json.Marshal(donordata.DonorProvidedDetails{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 39fd6e3b26..1e8c53ab98 100644 --- a/cmd/event-received/makeregister_event_handler_test.go +++ b/cmd/event-received/makeregister_event_handler_test.go @@ -8,8 +8,8 @@ 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/date" + "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/event" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" @@ -61,9 +61,9 @@ 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(&actor.DonorProvidedDetails{ - Donor: actor.Donor{FirstNames: "a", LastName: "b", Address: place.Address{Line1: "a"}, DateOfBirth: dob}, - Type: actor.LpaTypePersonalWelfare, + b, _ := attributevalue.Marshal(&donordata.DonorProvidedDetails{ + Donor: donordata.Donor{FirstNames: "a", LastName: "b", Address: place.Address{Line1: "a"}, DateOfBirth: dob}, + Type: donordata.LpaTypePersonalWelfare, CreatedAt: testNow, LpaUID: "M-1111-2222-3333", PK: dynamo.LpaKey("123"), @@ -77,7 +77,7 @@ func TestHandleUidRequested(t *testing.T) { eventClient.EXPECT(). SendApplicationUpdated(ctx, event.ApplicationUpdated{ UID: "M-1111-2222-3333", - Type: actor.LpaTypePersonalWelfare.String(), + Type: donordata.LpaTypePersonalWelfare.String(), CreatedAt: testNow, Donor: event.ApplicationUpdatedDonor{ FirstNames: "a", @@ -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(&actor.DonorProvidedDetails{}) + b, _ := attributevalue.Marshal(&donordata.DonorProvidedDetails{}) attributevalue.Unmarshal(b, v) return nil }) diff --git a/cmd/event-received/sirius_event_handler.go b/cmd/event-received/sirius_event_handler.go index be55ef96fe..a27d7618b9 100644 --- a/cmd/event-received/sirius_event_handler.go +++ b/cmd/event-received/sirius_event_handler.go @@ -8,10 +8,11 @@ import ( "time" "github.com/aws/aws-lambda-go/events" - "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/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/pay" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" ) type siriusEventHandler struct{} @@ -109,7 +110,7 @@ func handleFeeApproved(ctx context.Context, client dynamodbClient, event events. } if donor.FeeAmount() == 0 { - donor.Tasks.PayForLpa = actor.PaymentTaskCompleted + donor.Tasks.PayForLpa = task.PaymentStateCompleted if donor.Tasks.ConfirmYourIdentityAndSign.IsCompleted() { if err := lpaStoreClient.SendLpa(ctx, donor); err != nil { @@ -121,7 +122,7 @@ func handleFeeApproved(ctx context.Context, client dynamodbClient, event events. } } } else { - donor.Tasks.PayForLpa = actor.PaymentTaskApproved + donor.Tasks.PayForLpa = task.PaymentStateApproved } if err := putDonor(ctx, donor, now, client); err != nil { @@ -146,7 +147,7 @@ func handleFurtherInfoRequested(ctx context.Context, client dynamodbClient, even return nil } - donor.Tasks.PayForLpa = actor.PaymentTaskMoreEvidenceRequired + donor.Tasks.PayForLpa = task.PaymentStateMoreEvidenceRequired if err := putDonor(ctx, donor, now, client); err != nil { return fmt.Errorf("failed to update LPA task status: %w", err) @@ -171,7 +172,7 @@ func handleFeeDenied(ctx context.Context, client dynamodbClient, event events.Cl } donor.FeeType = pay.FullFee - donor.Tasks.PayForLpa = actor.PaymentTaskDenied + donor.Tasks.PayForLpa = task.PaymentStateDenied if err := putDonor(ctx, donor, now, client); err != nil { return fmt.Errorf("failed to update LPA task status: %w", err) @@ -193,7 +194,7 @@ func handleDonorSubmissionCompleted(ctx context.Context, client dynamodbClient, lpaID := uuidString() - if err := client.Put(ctx, &actor.DonorProvidedDetails{ + if err := client.Put(ctx, &donordata.DonorProvidedDetails{ 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 5242f058f6..75e0ca2e9f 100644 --- a/cmd/event-received/sirius_event_handler_test.go +++ b/cmd/event-received/sirius_event_handler_test.go @@ -12,10 +12,12 @@ import ( "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" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/pay" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -124,15 +126,15 @@ func TestHandleFeeApproved(t *testing.T) { Detail: json.RawMessage(`{"uid":"M-1111-2222-3333"}`), } - donorProvided := actor.DonorProvidedDetails{ + donorProvided := donordata.DonorProvidedDetails{ PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), FeeType: pay.NoFee, - Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskPending, ConfirmYourIdentityAndSign: actor.IdentityTaskCompleted}, + Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending, ConfirmYourIdentityAndSign: actor.IdentityTaskCompleted}, } completedDonorProvided := donorProvided - completedDonorProvided.Tasks.PayForLpa = actor.PaymentTaskCompleted + completedDonorProvided.Tasks.PayForLpa = task.PaymentStateCompleted lpaStoreClient := newMockLpaStoreClient(t) lpaStoreClient.EXPECT(). @@ -202,15 +204,15 @@ func TestHandleFeeApprovedWhenNotPaid(t *testing.T) { Detail: json.RawMessage(`{"uid":"M-1111-2222-3333"}`), } - donorProvided := actor.DonorProvidedDetails{ + donorProvided := donordata.DonorProvidedDetails{ PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), FeeType: pay.HalfFee, - Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskPending, ConfirmYourIdentityAndSign: actor.IdentityTaskCompleted}, + Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending, ConfirmYourIdentityAndSign: actor.IdentityTaskCompleted}, } completedDonorProvided := donorProvided - completedDonorProvided.Tasks.PayForLpa = actor.PaymentTaskApproved + completedDonorProvided.Tasks.PayForLpa = task.PaymentStateApproved client := newMockDynamodbClient(t) client. @@ -270,11 +272,11 @@ func TestHandleFeeApprovedWhenNotSigned(t *testing.T) { Detail: json.RawMessage(`{"uid":"M-1111-2222-3333"}`), } - donorProvided := actor.DonorProvidedDetails{ + donorProvided := donordata.DonorProvidedDetails{ PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), FeeType: pay.NoFee, - Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskPending}, + Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}, } client := newMockDynamodbClient(t) @@ -296,7 +298,7 @@ func TestHandleFeeApprovedWhenNotSigned(t *testing.T) { now := time.Now() updatedDonorProvided := donorProvided - updatedDonorProvided.Tasks.PayForLpa = actor.PaymentTaskCompleted + updatedDonorProvided.Tasks.PayForLpa = task.PaymentStateCompleted updatedDonorProvided.UpdateHash() updatedDonorProvided.UpdatedAt = now @@ -309,9 +311,9 @@ func TestHandleFeeApprovedWhenNotSigned(t *testing.T) { } func TestHandleFeeApprovedWhenAlreadyPaidOrApproved(t *testing.T) { - testcases := []actor.PaymentTask{ - actor.PaymentTaskCompleted, - actor.PaymentTaskApproved, + testcases := []task.PaymentState{ + task.PaymentStateCompleted, + task.PaymentStateApproved, } for _, taskState := range testcases { @@ -332,11 +334,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(&actor.DonorProvidedDetails{ + b, _ := attributevalue.Marshal(&donordata.DonorProvidedDetails{ PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), FeeType: pay.NoFee, - Tasks: actor.DonorTasks{PayForLpa: taskState}, + Tasks: donordata.DonorTasks{PayForLpa: taskState}, }) attributevalue.Unmarshal(b, v) return nil @@ -360,14 +362,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(actor.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456"))}) + b, _ := attributevalue.Marshal(donordata.DonorProvidedDetails{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(actor.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskPending}}) + b, _ := attributevalue.Marshal(donordata.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}}) attributevalue.Unmarshal(b, v) return nil }) @@ -398,11 +400,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(actor.DonorProvidedDetails{ + b, _ := attributevalue.Marshal(donordata.DonorProvidedDetails{ PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), FeeType: pay.NoFee, - Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskPending, ConfirmYourIdentityAndSign: actor.IdentityTaskCompleted}, + Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending, ConfirmYourIdentityAndSign: actor.IdentityTaskCompleted}, }) attributevalue.Unmarshal(b, v) return nil @@ -441,11 +443,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(actor.DonorProvidedDetails{ + b, _ := attributevalue.Marshal(donordata.DonorProvidedDetails{ PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), FeeType: pay.NoFee, - Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskPending, ConfirmYourIdentityAndSign: actor.IdentityTaskCompleted}, + Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending, ConfirmYourIdentityAndSign: actor.IdentityTaskCompleted}, }) attributevalue.Unmarshal(b, v) return nil @@ -467,7 +469,7 @@ func TestHandleFurtherInfoRequested(t *testing.T) { } now := time.Now() - updated := &actor.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskMoreEvidenceRequired}, UpdatedAt: now} + updated := &donordata.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateMoreEvidenceRequired}, UpdatedAt: now} updated.UpdateHash() client := newMockDynamodbClient(t) @@ -481,7 +483,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(actor.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskPending}}) + b, _ := attributevalue.Marshal(donordata.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}}) attributevalue.Unmarshal(b, v) return nil }) @@ -522,10 +524,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(&actor.DonorProvidedDetails{ + b, _ := attributevalue.Marshal(&donordata.DonorProvidedDetails{ PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), - Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskMoreEvidenceRequired}, + Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateMoreEvidenceRequired}, }) attributevalue.Unmarshal(b, v) @@ -544,7 +546,7 @@ func TestHandleFurtherInfoRequestedWhenPutError(t *testing.T) { } now := time.Now() - updated := &actor.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskMoreEvidenceRequired}, UpdatedAt: now} + updated := &donordata.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateMoreEvidenceRequired}, UpdatedAt: now} updated.UpdateHash() client := newMockDynamodbClient(t) @@ -558,7 +560,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(actor.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskPending}}) + b, _ := attributevalue.Marshal(donordata.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}}) attributevalue.Unmarshal(b, v) return nil }) @@ -577,7 +579,7 @@ func TestHandleFeeDenied(t *testing.T) { } now := time.Now() - updated := &actor.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskDenied}, FeeType: pay.FullFee, UpdatedAt: 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.UpdateHash() client := newMockDynamodbClient(t) @@ -591,7 +593,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(actor.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskPending}}) + b, _ := attributevalue.Marshal(donordata.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}}) attributevalue.Unmarshal(b, v) return nil }) @@ -632,7 +634,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(actor.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskDenied}}) + b, _ := attributevalue.Marshal(donordata.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateDenied}}) attributevalue.Unmarshal(b, v) return nil }) @@ -660,7 +662,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(actor.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskPending}}) + b, _ := attributevalue.Marshal(donordata.DonorProvidedDetails{PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("456")), Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}}) attributevalue.Unmarshal(b, v) return nil }) @@ -684,7 +686,7 @@ func TestHandleDonorSubmissionCompleted(t *testing.T) { lpa := &lpastore.Lpa{ Donor: lpastore.Donor{FirstNames: "Dave", LastName: "Smith"}, CertificateProvider: lpastore.CertificateProvider{ - Channel: actor.ChannelOnline, + Channel: donordata.ChannelOnline, UID: uid, FirstNames: "John", LastName: "Smith", @@ -697,7 +699,7 @@ func TestHandleDonorSubmissionCompleted(t *testing.T) { OneByUID(ctx, "M-1111-2222-3333", mock.Anything). Return(dynamo.NotFoundError{}) client.EXPECT(). - Put(ctx, &actor.DonorProvidedDetails{ + Put(ctx, &donordata.DonorProvidedDetails{ PK: dynamo.LpaKey(testUuidString), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("PAPER")), LpaID: testUuidString, @@ -754,7 +756,7 @@ func TestHandleDonorSubmissionCompletedWhenPaperCertificateProvider(t *testing.T lpa := &lpastore.Lpa{ CertificateProvider: lpastore.CertificateProvider{ - Channel: actor.ChannelPaper, + Channel: donordata.ChannelPaper, }, } @@ -819,7 +821,7 @@ func TestHandleDonorSubmissionCompletedWhenLpaStoreError(t *testing.T) { lpa := &lpastore.Lpa{ CertificateProvider: lpastore.CertificateProvider{ - Channel: actor.ChannelOnline, + Channel: donordata.ChannelOnline, }, } @@ -845,7 +847,7 @@ func TestHandleDonorSubmissionCompletedWhenShareCodeSenderError(t *testing.T) { lpa := &lpastore.Lpa{ CertificateProvider: lpastore.CertificateProvider{ - Channel: actor.ChannelOnline, + Channel: donordata.ChannelOnline, }, } @@ -881,7 +883,7 @@ func TestHandleCertificateProviderSubmissionCompleted(t *testing.T) { lpa := &lpastore.Lpa{ CertificateProvider: lpastore.CertificateProvider{ - Channel: actor.ChannelPaper, + Channel: donordata.ChannelPaper, }, } @@ -915,7 +917,7 @@ func TestHandleCertificateProviderSubmissionCompleted(t *testing.T) { func TestHandleCertificateProviderSubmissionCompletedWhenOnline(t *testing.T) { lpa := &lpastore.Lpa{ CertificateProvider: lpastore.CertificateProvider{ - Channel: actor.ChannelOnline, + Channel: donordata.ChannelOnline, }, } @@ -967,7 +969,7 @@ func TestHandleCertificateProviderSubmissionCompletedWhenShareCodeSenderErrors(t Lpa(ctx, "M-1111-2222-3333"). Return(&lpastore.Lpa{ CertificateProvider: lpastore.CertificateProvider{ - Channel: actor.ChannelPaper, + Channel: donordata.ChannelPaper, }, }, nil) @@ -998,7 +1000,7 @@ func TestHandleCertificateProviderSubmissionCompletedWhenShareCodeSenderFactoryE Lpa(ctx, "M-1111-2222-3333"). Return(&lpastore.Lpa{ CertificateProvider: lpastore.CertificateProvider{ - Channel: actor.ChannelPaper, + Channel: donordata.ChannelPaper, }, }, nil) @@ -1021,7 +1023,7 @@ func TestHandleCertificateProviderSubmissionCompletedWhenAppDataFactoryErrors(t Lpa(ctx, "M-1111-2222-3333"). Return(&lpastore.Lpa{ CertificateProvider: lpastore.CertificateProvider{ - Channel: actor.ChannelPaper, + Channel: donordata.ChannelPaper, }, }, nil) diff --git a/internal/actor/attorney.go b/internal/actor/attorney.go deleted file mode 100644 index d2635e8fbb..0000000000 --- a/internal/actor/attorney.go +++ /dev/null @@ -1,9 +0,0 @@ -package actor - -import ( - "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" -) - -type Attorney = donordata.Attorney -type TrustCorporation = donordata.TrustCorporation -type Attorneys = donordata.Attorneys diff --git a/internal/actor/attorney_decisions.go b/internal/actor/attorney_decisions.go deleted file mode 100644 index d2aa8fceb6..0000000000 --- a/internal/actor/attorney_decisions.go +++ /dev/null @@ -1,15 +0,0 @@ -package actor - -import "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" - -type AttorneysAct = donordata.AttorneysAct - -const ( - Jointly = donordata.Jointly - JointlyAndSeverally = donordata.JointlyAndSeverally - JointlyForSomeSeverallyForOthers = donordata.JointlyForSomeSeverallyForOthers -) - -type AttorneyDecisions = donordata.AttorneyDecisions - -var MakeAttorneyDecisions = donordata.MakeAttorneyDecisions diff --git a/internal/actor/can_be_used_when.go b/internal/actor/can_be_used_when.go deleted file mode 100644 index 5ef70127a9..0000000000 --- a/internal/actor/can_be_used_when.go +++ /dev/null @@ -1,11 +0,0 @@ -package actor - -import "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" - -type CanBeUsedWhen = donordata.CanBeUsedWhen - -const ( - CanBeUsedWhenUnknown = donordata.CanBeUsedWhenUnknown - CanBeUsedWhenCapacityLost = donordata.CanBeUsedWhenCapacityLost - CanBeUsedWhenHasCapacity = donordata.CanBeUsedWhenHasCapacity -) diff --git a/internal/actor/certificate_provider.go b/internal/actor/certificate_provider.go deleted file mode 100644 index 8bcfd36d50..0000000000 --- a/internal/actor/certificate_provider.go +++ /dev/null @@ -1,22 +0,0 @@ -package actor - -import ( - "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" -) - -type CertificateProviderRelationship = donordata.CertificateProviderRelationship - -const ( - Personally = donordata.Personally - Professionally = donordata.Professionally -) - -type CertificateProviderRelationshipLength = donordata.CertificateProviderRelationshipLength - -const ( - RelationshipLengthUnknown = donordata.RelationshipLengthUnknown - LessThanTwoYears = donordata.LessThanTwoYears - GreaterThanEqualToTwoYears = donordata.GreaterThanEqualToTwoYears -) - -type CertificateProvider = donordata.CertificateProvider diff --git a/internal/actor/channel.go b/internal/actor/channel.go deleted file mode 100644 index b31fa40d69..0000000000 --- a/internal/actor/channel.go +++ /dev/null @@ -1,10 +0,0 @@ -package actor - -import "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" - -type Channel = donordata.Channel - -const ( - ChannelPaper = donordata.ChannelPaper - ChannelOnline = donordata.ChannelOnline -) diff --git a/internal/actor/correspondent.go b/internal/actor/correspondent.go deleted file mode 100644 index dbeeded9ee..0000000000 --- a/internal/actor/correspondent.go +++ /dev/null @@ -1,7 +0,0 @@ -package actor - -import ( - "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" -) - -type Correspondent = donordata.Correspondent diff --git a/internal/actor/donor.go b/internal/actor/donor.go deleted file mode 100644 index 19a7fa54f2..0000000000 --- a/internal/actor/donor.go +++ /dev/null @@ -1,11 +0,0 @@ -package actor - -import ( - "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" -) - -type Donor = donordata.Donor - -type AuthorisedSignatory = donordata.AuthorisedSignatory - -type IndependentWitness = donordata.IndependentWitness diff --git a/internal/actor/donor_provided.go b/internal/actor/donor_provided.go deleted file mode 100644 index 135e195cb2..0000000000 --- a/internal/actor/donor_provided.go +++ /dev/null @@ -1,11 +0,0 @@ -package actor - -import ( - "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" -) - -type DonorTasks = donordata.DonorTasks - -type DonorProvidedDetails = donordata.DonorProvidedDetails - -type Under18ActorDetails = donordata.Under18ActorDetails diff --git a/internal/actor/life_sustaining_treatment.go b/internal/actor/life_sustaining_treatment.go deleted file mode 100644 index 43185beab5..0000000000 --- a/internal/actor/life_sustaining_treatment.go +++ /dev/null @@ -1,10 +0,0 @@ -package actor - -import "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" - -type LifeSustainingTreatment = donordata.LifeSustainingTreatment - -const ( - LifeSustainingTreatmentOptionA = donordata.LifeSustainingTreatmentOptionA - LifeSustainingTreatmentOptionB = donordata.LifeSustainingTreatmentOptionB -) diff --git a/internal/actor/limiter.go b/internal/actor/limiter.go deleted file mode 100644 index 4050961f91..0000000000 --- a/internal/actor/limiter.go +++ /dev/null @@ -1,7 +0,0 @@ -package actor - -import "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" - -type Limiter = donordata.Limiter - -var NewLimiter = donordata.NewLimiter diff --git a/internal/actor/lpa_type.go b/internal/actor/lpa_type.go deleted file mode 100644 index a1fa23e6f7..0000000000 --- a/internal/actor/lpa_type.go +++ /dev/null @@ -1,10 +0,0 @@ -package actor - -import "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" - -type LpaType = donordata.LpaType - -const ( - LpaTypePersonalWelfare = donordata.LpaTypePersonalWelfare - LpaTypePropertyAndAffairs = donordata.LpaTypePropertyAndAffairs -) diff --git a/internal/actor/payment.go b/internal/actor/payment.go deleted file mode 100644 index ab4d7b90e7..0000000000 --- a/internal/actor/payment.go +++ /dev/null @@ -1,5 +0,0 @@ -package actor - -import "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" - -type Payment = donordata.Payment diff --git a/internal/actor/person_to_notify.go b/internal/actor/person_to_notify.go deleted file mode 100644 index c74fb1d62f..0000000000 --- a/internal/actor/person_to_notify.go +++ /dev/null @@ -1,8 +0,0 @@ -package actor - -import ( - "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" -) - -type PersonToNotify = donordata.PersonToNotify -type PeopleToNotify = donordata.PeopleToNotify diff --git a/internal/actor/replacement_attorneys_step_in.go b/internal/actor/replacement_attorneys_step_in.go deleted file mode 100644 index 1040e65e56..0000000000 --- a/internal/actor/replacement_attorneys_step_in.go +++ /dev/null @@ -1,11 +0,0 @@ -package actor - -import "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" - -type ReplacementAttorneysStepIn = donordata.ReplacementAttorneysStepIn - -const ( - ReplacementAttorneysStepInWhenAllCanNoLongerAct = donordata.ReplacementAttorneysStepInWhenAllCanNoLongerAct - ReplacementAttorneysStepInWhenOneCanNoLongerAct = donordata.ReplacementAttorneysStepInWhenOneCanNoLongerAct - ReplacementAttorneysStepInAnotherWay = donordata.ReplacementAttorneysStepInAnotherWay -) diff --git a/internal/actor/voucher.go b/internal/actor/voucher.go deleted file mode 100644 index 21a00adda2..0000000000 --- a/internal/actor/voucher.go +++ /dev/null @@ -1,5 +0,0 @@ -package actor - -import "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" - -type Voucher = donordata.Voucher diff --git a/internal/actor/witness_codes.go b/internal/actor/witness_codes.go deleted file mode 100644 index 8fb693201f..0000000000 --- a/internal/actor/witness_codes.go +++ /dev/null @@ -1,8 +0,0 @@ -package actor - -import ( - "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" -) - -type WitnessCode = donordata.WitnessCode -type WitnessCodes = donordata.WitnessCodes diff --git a/internal/actor/yes_no_maybe.go b/internal/actor/yes_no_maybe.go deleted file mode 100644 index 5f6517ad45..0000000000 --- a/internal/actor/yes_no_maybe.go +++ /dev/null @@ -1,11 +0,0 @@ -package actor - -import "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" - -type YesNoMaybe = donordata.YesNoMaybe - -const ( - Yes = donordata.Yes - No = donordata.No - Maybe = donordata.Maybe -) diff --git a/internal/app/dashboard_store.go b/internal/app/dashboard_store.go index 0708488a23..869c57dd53 100644 --- a/internal/app/dashboard_store.go +++ b/internal/app/dashboard_store.go @@ -11,6 +11,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "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" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" @@ -18,7 +19,7 @@ import ( ) type LpaStoreResolvingService interface { - ResolveList(ctx context.Context, donors []*actor.DonorProvidedDetails) ([]*lpastore.Lpa, error) + ResolveList(ctx context.Context, donors []*donordata.DonorProvidedDetails) ([]*lpastore.Lpa, error) } // An lpaLink is used to join an actor to an LPA. @@ -104,7 +105,7 @@ func (s *dashboardStore) GetAll(ctx context.Context) (donor, attorney, certifica var ( referencedKeys []dynamo.Keys - donorsDetails []*actor.DonorProvidedDetails + donorsDetails []*donordata.DonorProvidedDetails ) for _, item := range lpasOrProvidedDetails { var ks dynamo.Keys @@ -114,7 +115,7 @@ func (s *dashboardStore) GetAll(ctx context.Context) (donor, attorney, certifica if isLpaKey(ks) { var donorDetails struct { - actor.DonorProvidedDetails + donordata.DonorProvidedDetails ReferencedSK dynamo.OrganisationKeyType } if err := attributevalue.UnmarshalMap(item, &donorDetails); err != nil { @@ -136,7 +137,7 @@ func (s *dashboardStore) GetAll(ctx context.Context) (donor, attorney, certifica } for _, item := range referencedLpas { - donorDetails := &actor.DonorProvidedDetails{} + donorDetails := &donordata.DonorProvidedDetails{} 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 7ae268d06f..d188572d42 100644 --- a/internal/app/dashboard_store_test.go +++ b/internal/app/dashboard_store_test.go @@ -11,6 +11,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "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" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" @@ -23,7 +24,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 := &actor.DonorProvidedDetails{ + lpa0Donor := &donordata.DonorProvidedDetails{ PK: dynamo.LpaKey("0"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey(sessionID)), LpaID: "0", @@ -31,7 +32,7 @@ func TestDashboardStoreGetAll(t *testing.T) { UpdatedAt: aTime, } lpa123 := &lpastore.Lpa{LpaID: "123", LpaUID: "M", UpdatedAt: aTime} - lpa123Donor := &actor.DonorProvidedDetails{ + lpa123Donor := &donordata.DonorProvidedDetails{ PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey(sessionID)), LpaID: "123", @@ -39,7 +40,7 @@ func TestDashboardStoreGetAll(t *testing.T) { UpdatedAt: aTime, } lpa456 := &lpastore.Lpa{LpaID: "456", LpaUID: "M"} - lpa456Donor := &actor.DonorProvidedDetails{ + lpa456Donor := &donordata.DonorProvidedDetails{ PK: dynamo.LpaKey("456"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("another-id")), LpaID: "456", @@ -52,7 +53,7 @@ func TestDashboardStoreGetAll(t *testing.T) { Tasks: certificateproviderdata.Tasks{ConfirmYourDetails: actor.TaskCompleted}, } lpa789 := &lpastore.Lpa{LpaID: "789", LpaUID: "M"} - lpa789Donor := &actor.DonorProvidedDetails{ + lpa789Donor := &donordata.DonorProvidedDetails{ PK: dynamo.LpaKey("789"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("different-id")), LpaID: "789", @@ -64,14 +65,14 @@ func TestDashboardStoreGetAll(t *testing.T) { LpaID: "789", Tasks: attorneydata.Tasks{ConfirmYourDetails: actor.TaskInProgress}, } - lpaNoUIDDonor := &actor.DonorProvidedDetails{ + lpaNoUIDDonor := &donordata.DonorProvidedDetails{ PK: dynamo.LpaKey("0"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey(sessionID)), LpaID: "999", UpdatedAt: aTime, } lpaCertified := &lpastore.Lpa{LpaID: "signed-by-cp", LpaUID: "M"} - lpaCertifiedDonor := &actor.DonorProvidedDetails{ + lpaCertifiedDonor := &donordata.DonorProvidedDetails{ PK: dynamo.LpaKey("signed-by-cp"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("another-id")), LpaID: "signed-by-cp", @@ -89,7 +90,7 @@ func TestDashboardStoreGetAll(t *testing.T) { "SK": dynamo.DonorKey(sessionID), "ReferencedSK": dynamo.OrganisationKey("org-id"), } - lpaReferencedDonor := &actor.DonorProvidedDetails{ + lpaReferencedDonor := &donordata.DonorProvidedDetails{ PK: dynamo.LpaKey("referenced"), SK: dynamo.LpaOwnerKey(dynamo.OrganisationKey("org-id")), LpaID: "referenced", @@ -157,7 +158,7 @@ func TestDashboardStoreGetAll(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). - ResolveList(ctx, []*actor.DonorProvidedDetails{lpa123Donor, lpa456Donor, lpa789Donor, lpa0Donor, lpaCertifiedDonor, lpaReferencedDonor}). + ResolveList(ctx, []*donordata.DonorProvidedDetails{lpa123Donor, lpa456Donor, lpa789Donor, lpa0Donor, lpaCertifiedDonor, lpaReferencedDonor}). Return([]*lpastore.Lpa{lpa123, lpa456, lpa789, lpa0, lpaCertified, lpaReferenced}, nil) dashboardStore := &dashboardStore{dynamoClient: dynamoClient, lpaStoreResolvingService: lpaStoreResolvingService} @@ -177,7 +178,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 := &actor.DonorProvidedDetails{ + lpaSubmittedDonor := &donordata.DonorProvidedDetails{ PK: dynamo.LpaKey("submitted"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("another-id")), LpaID: "submitted", @@ -190,7 +191,7 @@ func TestDashboardStoreGetAllSubmittedForAttorneys(t *testing.T) { LpaID: "submitted", } lpaSubmittedReplacement := &lpastore.Lpa{LpaID: "submitted-replacement", LpaUID: "M", Submitted: true} - lpaSubmittedReplacementDonor := &actor.DonorProvidedDetails{ + lpaSubmittedReplacementDonor := &donordata.DonorProvidedDetails{ PK: dynamo.LpaKey("submitted-replacement"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("another-id")), LpaID: "submitted-replacement", @@ -226,7 +227,7 @@ func TestDashboardStoreGetAllSubmittedForAttorneys(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). - ResolveList(ctx, []*actor.DonorProvidedDetails{lpaSubmittedDonor, lpaSubmittedReplacementDonor}). + ResolveList(ctx, []*donordata.DonorProvidedDetails{lpaSubmittedDonor, lpaSubmittedReplacementDonor}). Return([]*lpastore.Lpa{lpaSubmitted, lpaSubmittedReplacement}, nil) dashboardStore := &dashboardStore{dynamoClient: dynamoClient, lpaStoreResolvingService: lpaStoreResolvingService} @@ -248,7 +249,7 @@ func TestDashboardStoreGetAllWhenResolveErrors(t *testing.T) { sessionID := "an-id" aTime := time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC) - donor := &actor.DonorProvidedDetails{LpaID: "0", LpaUID: "M", UpdatedAt: aTime, SK: dynamo.LpaOwnerKey(dynamo.DonorKey(sessionID)), PK: dynamo.LpaKey("0")} + donor := &donordata.DonorProvidedDetails{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 c0179295be..0e72a69c0c 100644 --- a/internal/app/document_store.go +++ b/internal/app/document_store.go @@ -6,8 +6,8 @@ import ( "time" "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" - "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/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/event" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" @@ -38,7 +38,7 @@ func NewDocumentStore(dynamoClient DynamoClient, s3Client S3Client, eventClient } } -func (s *documentStore) Create(ctx context.Context, donor *actor.DonorProvidedDetails, filename string, data []byte) (page.Document, error) { +func (s *documentStore) Create(ctx context.Context, donor *donordata.DonorProvidedDetails, 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 *actor.DonorProvidedDetails, documents page.Documents) error { +func (s *documentStore) Submit(ctx context.Context, donor *donordata.DonorProvidedDetails, 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 b0fefdb371..19431da4fa 100644 --- a/internal/app/document_store_test.go +++ b/internal/app/document_store_test.go @@ -7,8 +7,8 @@ import ( "time" "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" - "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/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/event" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" @@ -286,7 +286,7 @@ func TestDocumentStoreSubmit(t *testing.T) { ctx := context.Background() now := time.Now() - donor := &actor.DonorProvidedDetails{LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload} + donor := &donordata.DonorProvidedDetails{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 := &actor.DonorProvidedDetails{LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload} + donor := &donordata.DonorProvidedDetails{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 := &actor.DonorProvidedDetails{LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload} + donor := &donordata.DonorProvidedDetails{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 := &actor.DonorProvidedDetails{LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload} + donor := &donordata.DonorProvidedDetails{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 := &actor.DonorProvidedDetails{LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload} + donor := &donordata.DonorProvidedDetails{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 := &actor.DonorProvidedDetails{LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload, LpaID: "lpa-id"} + donor := &donordata.DonorProvidedDetails{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 := &actor.DonorProvidedDetails{LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload, LpaID: "lpa-id"} + donor := &donordata.DonorProvidedDetails{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 := &actor.DonorProvidedDetails{LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload, LpaID: "lpa-id"} + donor := &donordata.DonorProvidedDetails{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 39e4f62db5..4a32724c4a 100644 --- a/internal/app/evidence_received_store_test.go +++ b/internal/app/evidence_received_store_test.go @@ -4,8 +4,8 @@ import ( "context" "testing" - "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/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/stretchr/testify/assert" @@ -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(), &actor.DonorProvidedDetails{LpaID: "an-id"}, expectedError) + dynamoClient.ExpectOne(ctx, dynamo.LpaKey("an-id"), dynamo.EvidenceReceivedKey(), &donordata.DonorProvidedDetails{LpaID: "an-id"}, expectedError) evidenceReceivedStore := &evidenceReceivedStore{dynamoClient: dynamoClient} diff --git a/internal/app/organisation_store.go b/internal/app/organisation_store.go index e3e26956b3..72399c1502 100644 --- a/internal/app/organisation_store.go +++ b/internal/app/organisation_store.go @@ -9,6 +9,7 @@ import ( "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" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" ) @@ -86,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) (*actor.DonorProvidedDetails, error) { +func (s *organisationStore) CreateLPA(ctx context.Context) (*donordata.DonorProvidedDetails, error) { data, err := appcontext.SessionDataFromContext(ctx) if err != nil { return nil, err @@ -99,13 +100,13 @@ func (s *organisationStore) CreateLPA(ctx context.Context) (*actor.DonorProvided lpaID := s.uuidString() donorUID := s.newUID() - donor := &actor.DonorProvidedDetails{ + donor := &donordata.DonorProvidedDetails{ PK: dynamo.LpaKey(lpaID), SK: dynamo.LpaOwnerKey(dynamo.OrganisationKey(data.OrganisationID)), LpaID: lpaID, CreatedAt: s.now(), Version: 1, - Donor: actor.Donor{ + Donor: donordata.Donor{ UID: donorUID, }, } diff --git a/internal/app/organisation_store_test.go b/internal/app/organisation_store_test.go index c775f8918b..45df097c90 100644 --- a/internal/app/organisation_store_test.go +++ b/internal/app/organisation_store_test.go @@ -6,6 +6,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/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/stretchr/testify/assert" @@ -178,13 +179,13 @@ func TestOrganisationStorePut(t *testing.T) { func TestOrganisationStoreCreateLPA(t *testing.T) { ctx := page.ContextWithSessionData(context.Background(), &appcontext.SessionData{OrganisationID: "an-id"}) - expectedDonor := &actor.DonorProvidedDetails{ + expectedDonor := &donordata.DonorProvidedDetails{ PK: dynamo.LpaKey("a-uuid"), SK: dynamo.LpaOwnerKey(dynamo.OrganisationKey("an-id")), LpaID: "a-uuid", CreatedAt: testNow, Version: 1, - Donor: actor.Donor{ + Donor: donordata.Donor{ UID: testUID, }, } diff --git a/internal/app/uid_store.go b/internal/app/uid_store.go index 4e0d659c99..3fb804b06e 100644 --- a/internal/app/uid_store.go +++ b/internal/app/uid_store.go @@ -7,7 +7,7 @@ import ( "github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue" "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" - "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/search" ) @@ -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 *actor.DonorProvidedDetails + var donor *donordata.DonorProvidedDetails 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 6150c3f58a..d8d76672c4 100644 --- a/internal/app/uid_store_test.go +++ b/internal/app/uid_store_test.go @@ -4,7 +4,7 @@ import ( "testing" "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/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/search" "github.com/stretchr/testify/assert" @@ -32,8 +32,8 @@ func TestUidStoreSet(t *testing.T) { ":now": testNow, }) - returnValues, _ := attributevalue.MarshalMap(actor.DonorProvidedDetails{ - Donor: actor.Donor{ + returnValues, _ := attributevalue.MarshalMap(donordata.DonorProvidedDetails{ + Donor: donordata.Donor{ FirstNames: "x", LastName: "y", }, @@ -79,8 +79,8 @@ func TestUidStoreSetWhenDynamoClientError(t *testing.T) { } func TestUidStoreSetWhenSearchIndexErrors(t *testing.T) { - returnValues, _ := attributevalue.MarshalMap(actor.DonorProvidedDetails{ - Donor: actor.Donor{ + returnValues, _ := attributevalue.MarshalMap(donordata.DonorProvidedDetails{ + Donor: donordata.Donor{ FirstNames: "x", LastName: "y", }, 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 3e6717d55c..1825ed7426 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 @@ -9,6 +9,7 @@ import ( "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" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" @@ -186,7 +187,7 @@ func TestPostConfirmDontWantToBeAttorneyLoggedOut(t *testing.T) { {UID: replacementAttorneyUID, FirstNames: "x y", LastName: "z"}, }, }, - Type: actor.LpaTypePersonalWelfare, + Type: donordata.LpaTypePersonalWelfare, }, nil) notifyClient := newMockNotifyClient(t) @@ -248,7 +249,7 @@ func TestPostConfirmDontWantToBeAttorneyLoggedOutWhenAttorneyNotFound(t *testing Donor: lpastore.Donor{ FirstNames: "a b", LastName: "c", Email: "a@example.com", }, - Type: actor.LpaTypePersonalWelfare, + Type: donordata.LpaTypePersonalWelfare, }, nil) err := ConfirmDontWantToBeAttorneyLoggedOut(nil, shareCodeStore, lpaStoreResolvingService, sessionStore, nil, "example.com")(testAppData, w, r) diff --git a/internal/attorney/attorneypage/confirm_dont_want_to_be_attorney_test.go b/internal/attorney/attorneypage/confirm_dont_want_to_be_attorney_test.go index 1ed0c6c21e..d78ed29b9a 100644 --- a/internal/attorney/attorneypage/confirm_dont_want_to_be_attorney_test.go +++ b/internal/attorney/attorneypage/confirm_dont_want_to_be_attorney_test.go @@ -7,10 +7,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/appcontext" "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/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" @@ -100,7 +100,7 @@ func TestPostConfirmDontWantToBeAttorney(t *testing.T) { {FirstNames: "d e", LastName: "f", UID: uid}, }, }, - Type: actor.LpaTypePersonalWelfare, + Type: donordata.LpaTypePersonalWelfare, }, nil) certificateProviderStore := newMockAttorneyStore(t) @@ -151,7 +151,7 @@ func TestPostConfirmDontWantToBeAttorneyWhenAttorneyNotFound(t *testing.T) { Donor: lpastore.Donor{ FirstNames: "a b", LastName: "c", Email: "a@example.com", }, - Type: actor.LpaTypePersonalWelfare, + Type: donordata.LpaTypePersonalWelfare, }, nil) err := ConfirmDontWantToBeAttorney(nil, lpaStoreResolvingService, nil, nil, "example.com")(testAppData, w, r, &attorneydata.Provided{ diff --git a/internal/attorney/attorneypage/mock_CertificateProviderStore_test.go b/internal/attorney/attorneypage/mock_CertificateProviderStore_test.go index 01f9522dbf..6921b2dc74 100644 --- a/internal/attorney/attorneypage/mock_CertificateProviderStore_test.go +++ b/internal/attorney/attorneypage/mock_CertificateProviderStore_test.go @@ -5,7 +5,7 @@ package attorneypage import ( context "context" - "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" + "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" mock "github.com/stretchr/testify/mock" ) diff --git a/internal/attorney/attorneypage/mock_DonorStore_test.go b/internal/attorney/attorneypage/mock_DonorStore_test.go index 8ac2eee25f..ff6bca7e5f 100644 --- a/internal/attorney/attorneypage/mock_DonorStore_test.go +++ b/internal/attorney/attorneypage/mock_DonorStore_test.go @@ -5,8 +5,7 @@ package attorneypage import ( context "context" - actor "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" - + "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" mock "github.com/stretchr/testify/mock" ) @@ -24,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) (*actor.DonorProvidedDetails, error) { +func (_m *mockDonorStore) GetAny(_a0 context.Context) (*donordata.DonorProvidedDetails, error) { ret := _m.Called(_a0) if len(ret) == 0 { panic("no return value specified for GetAny") } - var r0 *actor.DonorProvidedDetails + var r0 *donordata.DonorProvidedDetails var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (*actor.DonorProvidedDetails, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context) (*donordata.DonorProvidedDetails, error)); ok { return rf(_a0) } - if rf, ok := ret.Get(0).(func(context.Context) *actor.DonorProvidedDetails); ok { + if rf, ok := ret.Get(0).(func(context.Context) *donordata.DonorProvidedDetails); ok { r0 = rf(_a0) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*actor.DonorProvidedDetails) + r0 = ret.Get(0).(*donordata.DonorProvidedDetails) } } @@ -71,12 +70,12 @@ func (_c *mockDonorStore_GetAny_Call) Run(run func(_a0 context.Context)) *mockDo return _c } -func (_c *mockDonorStore_GetAny_Call) Return(_a0 *actor.DonorProvidedDetails, _a1 error) *mockDonorStore_GetAny_Call { +func (_c *mockDonorStore_GetAny_Call) Return(_a0 *donordata.DonorProvidedDetails, _a1 error) *mockDonorStore_GetAny_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockDonorStore_GetAny_Call) RunAndReturn(run func(context.Context) (*actor.DonorProvidedDetails, error)) *mockDonorStore_GetAny_Call { +func (_c *mockDonorStore_GetAny_Call) RunAndReturn(run func(context.Context) (*donordata.DonorProvidedDetails, error)) *mockDonorStore_GetAny_Call { _c.Call.Return(run) return _c } diff --git a/internal/attorney/attorneypage/sign_test.go b/internal/attorney/attorneypage/sign_test.go index 42b5cdf440..3abde96b58 100644 --- a/internal/attorney/attorneypage/sign_test.go +++ b/internal/attorney/attorneypage/sign_test.go @@ -11,6 +11,7 @@ import ( "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" @@ -29,7 +30,7 @@ func TestGetSign(t *testing.T) { appData: testAppData, lpa: &lpastore.Lpa{ SignedAt: time.Now(), - WhenCanTheLpaBeUsed: actor.CanBeUsedWhenHasCapacity, + WhenCanTheLpaBeUsed: donordata.CanBeUsedWhenHasCapacity, Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{ {UID: testUID, FirstNames: "Bob", LastName: "Smith"}, {UID: actoruid.New(), FirstNames: "Dave", LastName: "Smith"}, @@ -49,7 +50,7 @@ func TestGetSign(t *testing.T) { appData: testAppData, lpa: &lpastore.Lpa{ SignedAt: time.Now(), - WhenCanTheLpaBeUsed: actor.CanBeUsedWhenCapacityLost, + WhenCanTheLpaBeUsed: donordata.CanBeUsedWhenCapacityLost, Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{ {UID: testUID, FirstNames: "Bob", LastName: "Smith"}, {UID: actoruid.New(), FirstNames: "Dave", LastName: "Smith"}, @@ -68,7 +69,7 @@ func TestGetSign(t *testing.T) { appData: testReplacementAppData, lpa: &lpastore.Lpa{ SignedAt: time.Now(), - WhenCanTheLpaBeUsed: actor.CanBeUsedWhenHasCapacity, + WhenCanTheLpaBeUsed: donordata.CanBeUsedWhenHasCapacity, ReplacementAttorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{ {UID: testUID, FirstNames: "Bob", LastName: "Smith"}, {UID: actoruid.New(), FirstNames: "Dave", LastName: "Smith"}, @@ -89,7 +90,7 @@ func TestGetSign(t *testing.T) { appData: testReplacementAppData, lpa: &lpastore.Lpa{ SignedAt: time.Now(), - WhenCanTheLpaBeUsed: actor.CanBeUsedWhenCapacityLost, + WhenCanTheLpaBeUsed: donordata.CanBeUsedWhenCapacityLost, ReplacementAttorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{ {UID: testUID, FirstNames: "Bob", LastName: "Smith"}, {UID: actoruid.New(), FirstNames: "Dave", LastName: "Smith"}, @@ -109,7 +110,7 @@ func TestGetSign(t *testing.T) { appData: testTrustCorporationAppData, lpa: &lpastore.Lpa{ SignedAt: time.Now(), - WhenCanTheLpaBeUsed: actor.CanBeUsedWhenHasCapacity, + WhenCanTheLpaBeUsed: donordata.CanBeUsedWhenHasCapacity, Attorneys: lpastore.Attorneys{TrustCorporation: lpastore.TrustCorporation{ Name: "Corp", }}, @@ -201,7 +202,7 @@ func TestGetSignCantSignYet(t *testing.T) { "certified but not submitted": { appData: testAppData, lpa: &lpastore.Lpa{ - WhenCanTheLpaBeUsed: actor.CanBeUsedWhenCapacityLost, + WhenCanTheLpaBeUsed: donordata.CanBeUsedWhenCapacityLost, Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{ {UID: uid, FirstNames: "Bob", LastName: "Smith"}, {UID: actoruid.New(), FirstNames: "Dave", LastName: "Smith"}, 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 94fe753c42..efc3e40d09 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 @@ -7,6 +7,7 @@ import ( "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" @@ -63,7 +64,7 @@ func ConfirmDontWantToBeCertificateProvider(tmpl template.Template, lpaStoreReso DonorStartPageURL: appPublicURL + page.Paths.Start.Format(), } - donor.CertificateProvider = actor.CertificateProvider{} + donor.CertificateProvider = donordata.CertificateProvider{} donor.Tasks.CertificateProvider = actor.TaskNotStarted donor.Tasks.CheckYourLpa = actor.TaskNotStarted 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 4d34c986f0..659cbed121 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 @@ -8,6 +8,7 @@ import ( "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" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" @@ -76,7 +77,7 @@ func ConfirmDontWantToBeCertificateProviderLoggedOut(tmpl template.Template, sha DonorStartPageURL: appPublicURL + page.Paths.Start.Format(), } - donor.CertificateProvider = actor.CertificateProvider{} + donor.CertificateProvider = donordata.CertificateProvider{} donor.Tasks.CertificateProvider = actor.TaskNotStarted donor.Tasks.CheckYourLpa = actor.TaskNotStarted 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 ea4f22dd7a..eddc1fccbd 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 @@ -9,6 +9,7 @@ import ( "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" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" @@ -149,7 +150,7 @@ func TestPostConfirmDontWantToBeCertificateProviderLoggedOut(t *testing.T) { CertificateProvider: lpastore.CertificateProvider{ FirstNames: "d e", LastName: "f", }, - Type: actor.LpaTypePersonalWelfare, + Type: donordata.LpaTypePersonalWelfare, }, lpaStoreClient: func() *mockLpaStoreClient { lpaStoreClient := newMockLpaStoreClient(t) @@ -178,7 +179,7 @@ func TestPostConfirmDontWantToBeCertificateProviderLoggedOut(t *testing.T) { FirstNames: "d e", LastName: "f", }, CannotRegister: true, - Type: actor.LpaTypePersonalWelfare, + Type: donordata.LpaTypePersonalWelfare, }, lpaStoreClient: func() *mockLpaStoreClient { return nil }, donorStore: func() *mockDonorStore { return nil }, @@ -203,33 +204,33 @@ func TestPostConfirmDontWantToBeCertificateProviderLoggedOut(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). GetAny(ctx). - Return(&actor.DonorProvidedDetails{ + Return(&donordata.DonorProvidedDetails{ LpaUID: "lpa-uid", - Donor: actor.Donor{ + Donor: donordata.Donor{ FirstNames: "a b", LastName: "c", }, - Tasks: actor.DonorTasks{ + Tasks: donordata.DonorTasks{ CertificateProvider: actor.TaskCompleted, CheckYourLpa: actor.TaskCompleted, }, - CertificateProvider: actor.CertificateProvider{ + CertificateProvider: donordata.CertificateProvider{ UID: actoruid.New(), FirstNames: "d e", LastName: "f", }, - Type: actor.LpaTypePersonalWelfare, + Type: donordata.LpaTypePersonalWelfare, }, nil) donorStore.EXPECT(). - Put(ctx, &actor.DonorProvidedDetails{ + Put(ctx, &donordata.DonorProvidedDetails{ LpaUID: "lpa-uid", - Donor: actor.Donor{ + Donor: donordata.Donor{ FirstNames: "a b", LastName: "c", }, - Tasks: actor.DonorTasks{ + Tasks: donordata.DonorTasks{ CertificateProvider: actor.TaskNotStarted, CheckYourLpa: actor.TaskNotStarted, }, - CertificateProvider: actor.CertificateProvider{}, - Type: actor.LpaTypePersonalWelfare, + CertificateProvider: donordata.CertificateProvider{}, + Type: donordata.LpaTypePersonalWelfare, }). Return(nil) @@ -384,7 +385,7 @@ func TestPostConfirmDontWantToBeCertificateProviderLoggedOutErrors(t *testing.T) donorStore := newMockDonorStore(t) donorStore.EXPECT(). GetAny(ctx). - Return(&actor.DonorProvidedDetails{}, expectedError) + Return(&donordata.DonorProvidedDetails{}, expectedError) return donorStore }, @@ -421,7 +422,7 @@ func TestPostConfirmDontWantToBeCertificateProviderLoggedOutErrors(t *testing.T) donorStore := newMockDonorStore(t) donorStore.EXPECT(). GetAny(ctx). - Return(&actor.DonorProvidedDetails{}, nil) + Return(&donordata.DonorProvidedDetails{}, 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 4ccbed6a51..5fc30685b7 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 @@ -10,6 +10,7 @@ import ( "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" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" @@ -115,7 +116,7 @@ func TestPostConfirmDontWantToBeCertificateProvider(t *testing.T) { CertificateProvider: lpastore.CertificateProvider{ FirstNames: "d e", LastName: "f", UID: uid, }, - Type: actor.LpaTypePersonalWelfare, + Type: donordata.LpaTypePersonalWelfare, }, lpaStoreClient: func() *mockLpaStoreClient { lpaStoreClient := newMockLpaStoreClient(t) @@ -145,7 +146,7 @@ func TestPostConfirmDontWantToBeCertificateProvider(t *testing.T) { CertificateProvider: lpastore.CertificateProvider{ FirstNames: "d e", LastName: "f", UID: uid, }, - Type: actor.LpaTypePersonalWelfare, + Type: donordata.LpaTypePersonalWelfare, CannotRegister: true, }, lpaStoreClient: func() *mockLpaStoreClient { return nil }, @@ -169,33 +170,33 @@ func TestPostConfirmDontWantToBeCertificateProvider(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). GetAny(r.Context()). - Return(&actor.DonorProvidedDetails{ + Return(&donordata.DonorProvidedDetails{ LpaUID: "lpa-uid", - Donor: actor.Donor{ + Donor: donordata.Donor{ FirstNames: "a b", LastName: "c", }, - Tasks: actor.DonorTasks{ + Tasks: donordata.DonorTasks{ CertificateProvider: actor.TaskCompleted, CheckYourLpa: actor.TaskCompleted, }, - CertificateProvider: actor.CertificateProvider{ + CertificateProvider: donordata.CertificateProvider{ UID: uid, FirstNames: "d e", LastName: "f", }, - Type: actor.LpaTypePersonalWelfare, + Type: donordata.LpaTypePersonalWelfare, }, nil) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaUID: "lpa-uid", - Donor: actor.Donor{ + Donor: donordata.Donor{ FirstNames: "a b", LastName: "c", }, - Tasks: actor.DonorTasks{ + Tasks: donordata.DonorTasks{ CertificateProvider: actor.TaskNotStarted, CheckYourLpa: actor.TaskNotStarted, }, - CertificateProvider: actor.CertificateProvider{}, - Type: actor.LpaTypePersonalWelfare, + CertificateProvider: donordata.CertificateProvider{}, + Type: donordata.LpaTypePersonalWelfare, }). Return(nil) @@ -318,7 +319,7 @@ func TestPostConfirmDontWantToBeCertificateProviderErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). GetAny(r.Context()). - Return(&actor.DonorProvidedDetails{}, expectedError) + Return(&donordata.DonorProvidedDetails{}, expectedError) return donorStore }, @@ -348,7 +349,7 @@ func TestPostConfirmDontWantToBeCertificateProviderErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). GetAny(r.Context()). - Return(&actor.DonorProvidedDetails{}, nil) + Return(&donordata.DonorProvidedDetails{}, nil) donorStore.EXPECT(). Put(r.Context(), mock.Anything). Return(expectedError) diff --git a/internal/certificateprovider/certificateproviderpage/confirm_your_details_test.go b/internal/certificateprovider/certificateproviderpage/confirm_your_details_test.go index e4d594acf6..df7aa0b976 100644 --- a/internal/certificateprovider/certificateproviderpage/confirm_your_details_test.go +++ b/internal/certificateprovider/certificateproviderpage/confirm_your_details_test.go @@ -8,6 +8,7 @@ import ( "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/stretchr/testify/assert" @@ -16,32 +17,32 @@ import ( func TestGetConfirmYourDetails(t *testing.T) { testcases := map[string]struct { - DonorChannel actor.Channel + DonorChannel donordata.Channel PhoneNumberLabel string - CertificateProviderRelationship actor.CertificateProviderRelationship + CertificateProviderRelationship donordata.CertificateProviderRelationship AddressLabel string DetailsComponentContent string }{ "online donor": { - DonorChannel: actor.ChannelOnline, + DonorChannel: donordata.ChannelOnline, PhoneNumberLabel: "mobileNumber", AddressLabel: "address", DetailsComponentContent: "whatToDoIfAnyDetailsAreIncorrectCertificateProviderContentLay", }, "paper donor": { - DonorChannel: actor.ChannelPaper, + DonorChannel: donordata.ChannelPaper, PhoneNumberLabel: "contactNumber", AddressLabel: "address", DetailsComponentContent: "whatToDoIfAnyDetailsAreIncorrectCertificateProviderContentLay", }, "lay CP": { - CertificateProviderRelationship: actor.Personally, + CertificateProviderRelationship: donordata.Personally, AddressLabel: "address", DetailsComponentContent: "whatToDoIfAnyDetailsAreIncorrectCertificateProviderContentLay", PhoneNumberLabel: "mobileNumber", }, "professional CP": { - CertificateProviderRelationship: actor.Professionally, + CertificateProviderRelationship: donordata.Professionally, AddressLabel: "workAddress", DetailsComponentContent: "whatToDoIfAnyDetailsAreIncorrectCertificateProviderContentProfessional", PhoneNumberLabel: "mobileNumber", diff --git a/internal/certificateprovider/certificateproviderpage/enter_date_of_birth_test.go b/internal/certificateprovider/certificateproviderpage/enter_date_of_birth_test.go index 0131a643a0..071062f627 100644 --- a/internal/certificateprovider/certificateproviderpage/enter_date_of_birth_test.go +++ b/internal/certificateprovider/certificateproviderpage/enter_date_of_birth_test.go @@ -12,6 +12,7 @@ import ( "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/validation" @@ -223,7 +224,7 @@ func TestPostEnterDateOfBirthWhenProfessionalCertificateProvider(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{LpaID: "lpa-id", CertificateProvider: lpastore.CertificateProvider{Relationship: actor.Professionally}}, nil) + Return(&lpastore.Lpa{LpaID: "lpa-id", CertificateProvider: lpastore.CertificateProvider{Relationship: donordata.Professionally}}, nil) certificateProviderStore := newMockCertificateProviderStore(t) certificateProviderStore.EXPECT(). diff --git a/internal/certificateprovider/certificateproviderpage/identity_with_one_login_callback_test.go b/internal/certificateprovider/certificateproviderpage/identity_with_one_login_callback_test.go index 8c42700e68..634854e446 100644 --- a/internal/certificateprovider/certificateproviderpage/identity_with_one_login_callback_test.go +++ b/internal/certificateprovider/certificateproviderpage/identity_with_one_login_callback_test.go @@ -8,8 +8,8 @@ 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/identity" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" @@ -96,7 +96,7 @@ func TestGetIdentityWithOneLoginCallbackWhenFailedIDCheck(t *testing.T) { LpaUID: "lpa-uid", CertificateProvider: lpastore.CertificateProvider{FirstNames: "a", LastName: "b"}, Donor: lpastore.Donor{Email: "a@example.com", FirstNames: "c", LastName: "d"}, - Type: actor.LpaTypePersonalWelfare, + Type: donordata.LpaTypePersonalWelfare, SignedAt: time.Now(), }, nil) @@ -165,7 +165,7 @@ func TestGetIdentityWithOneLoginCallbackWhenSendingEmailError(t *testing.T) { LpaUID: "lpa-uid", CertificateProvider: lpastore.CertificateProvider{FirstNames: "a", LastName: "b"}, Donor: lpastore.Donor{Email: "a@example.com", FirstNames: "c", LastName: "d"}, - Type: actor.LpaTypePersonalWelfare, + Type: donordata.LpaTypePersonalWelfare, SignedAt: time.Now(), }, nil) diff --git a/internal/certificateprovider/certificateproviderpage/provide_certificate_test.go b/internal/certificateprovider/certificateproviderpage/provide_certificate_test.go index 822153700d..7cfeaae964 100644 --- a/internal/certificateprovider/certificateproviderpage/provide_certificate_test.go +++ b/internal/certificateprovider/certificateproviderpage/provide_certificate_test.go @@ -11,6 +11,7 @@ import ( "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" @@ -122,7 +123,7 @@ func TestPostProvideCertificate(t *testing.T) { LastName: "b", }, Donor: lpastore.Donor{FirstNames: "c", LastName: "d"}, - Type: actor.LpaTypePropertyAndAffairs, + Type: donordata.LpaTypePropertyAndAffairs, } certificateProvider := &certificateproviderdata.Provided{ @@ -212,7 +213,7 @@ func TestPostProvideCertificateWhenSignedInLpaStore(t *testing.T) { SignedAt: signedAt, }, Donor: lpastore.Donor{FirstNames: "c", LastName: "d"}, - Type: actor.LpaTypePropertyAndAffairs, + Type: donordata.LpaTypePropertyAndAffairs, } certificateProvider := &certificateproviderdata.Provided{ @@ -295,7 +296,7 @@ func TestPostProvideCertificateWhenCannotSubmit(t *testing.T) { LastName: "b", }, Donor: lpastore.Donor{FirstNames: "c", LastName: "d"}, - Type: actor.LpaTypePropertyAndAffairs, + Type: donordata.LpaTypePropertyAndAffairs, } lpaStoreResolvingService := newMockLpaStoreResolvingService(t) @@ -392,7 +393,7 @@ func TestPostProvideCertificateWhenLpaStoreClientError(t *testing.T) { LastName: "b", }, Donor: lpastore.Donor{FirstNames: "c", LastName: "d"}, - Type: actor.LpaTypePropertyAndAffairs, + Type: donordata.LpaTypePropertyAndAffairs, } lpaStoreResolvingService := newMockLpaStoreResolvingService(t) @@ -432,7 +433,7 @@ func TestPostProvideCertificateOnNotifyClientError(t *testing.T) { LastName: "b", }, Donor: lpastore.Donor{FirstNames: "c", LastName: "d"}, - Type: actor.LpaTypePropertyAndAffairs, + Type: donordata.LpaTypePropertyAndAffairs, }, nil) localizer := newMockLocalizer(t) @@ -486,7 +487,7 @@ func TestPostProvideCertificateWhenShareCodeSenderErrors(t *testing.T) { Return(&lpastore.Lpa{ SignedAt: now, Donor: lpastore.Donor{FirstNames: "c", LastName: "d"}, - Type: actor.LpaTypePropertyAndAffairs, + Type: donordata.LpaTypePropertyAndAffairs, }, nil) localizer := newMockLocalizer(t) diff --git a/internal/certificateprovider/certificateproviderpage/register.go b/internal/certificateprovider/certificateproviderpage/register.go index fa44b520eb..0ee460ff6b 100644 --- a/internal/certificateprovider/certificateproviderpage/register.go +++ b/internal/certificateprovider/certificateproviderpage/register.go @@ -11,6 +11,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "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/identity" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" @@ -95,8 +96,8 @@ type LpaStoreClient interface { type ErrorHandler func(http.ResponseWriter, *http.Request, error) type DonorStore interface { - GetAny(ctx context.Context) (*actor.DonorProvidedDetails, error) - Put(ctx context.Context, donor *actor.DonorProvidedDetails) error + GetAny(ctx context.Context) (*donordata.DonorProvidedDetails, error) + Put(ctx context.Context, donor *donordata.DonorProvidedDetails) error } func Register( diff --git a/internal/donor/donorpage/add_correspondent.go b/internal/donor/donorpage/add_correspondent.go index f8cfcaf2d2..2c89dfe68b 100644 --- a/internal/donor/donorpage/add_correspondent.go +++ b/internal/donor/donorpage/add_correspondent.go @@ -5,6 +5,7 @@ import ( "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/validation" @@ -14,11 +15,11 @@ type addCorrespondentData struct { App page.AppData Errors validation.List Form *form.YesNoForm - Donor *actor.DonorProvidedDetails + Donor *donordata.DonorProvidedDetails } func AddCorrespondent(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { data := &addCorrespondentData{ App: appData, Donor: donor, @@ -34,7 +35,7 @@ func AddCorrespondent(tmpl template.Template, donorStore DonorStore) Handler { var redirectUrl page.LpaPath if donor.AddCorrespondent.IsNo() { - donor.Correspondent = actor.Correspondent{} + donor.Correspondent = donordata.Correspondent{} donor.Tasks.AddCorrespondent = actor.TaskCompleted redirectUrl = page.Paths.TaskList } else { diff --git a/internal/donor/donorpage/add_correspondent_test.go b/internal/donor/donorpage/add_correspondent_test.go index a2bf2ad77a..40724782ce 100644 --- a/internal/donor/donorpage/add_correspondent_test.go +++ b/internal/donor/donorpage/add_correspondent_test.go @@ -8,6 +8,7 @@ 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/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -23,12 +24,12 @@ func TestGetAddCorrespondent(t *testing.T) { template.EXPECT(). Execute(w, &addCorrespondentData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{}, + Donor: &donordata.DonorProvidedDetails{}, Form: form.NewYesNoForm(form.YesNoUnknown), }). Return(nil) - err := AddCorrespondent(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := AddCorrespondent(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -43,12 +44,12 @@ func TestGetAddCorrespondentFromStore(t *testing.T) { template.EXPECT(). Execute(w, &addCorrespondentData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{AddCorrespondent: form.Yes}, + Donor: &donordata.DonorProvidedDetails{AddCorrespondent: form.Yes}, Form: form.NewYesNoForm(form.Yes), }). Return(nil) - err := AddCorrespondent(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{AddCorrespondent: form.Yes}) + err := AddCorrespondent(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{AddCorrespondent: form.Yes}) resp := w.Result() assert.Nil(t, err) @@ -64,7 +65,7 @@ func TestGetAddCorrespondentWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := AddCorrespondent(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := AddCorrespondent(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -74,17 +75,17 @@ func TestGetAddCorrespondentWhenTemplateErrors(t *testing.T) { func TestPostAddCorrespondent(t *testing.T) { testCases := map[string]struct { yesNo form.YesNo - existingCorrespondent actor.Correspondent + existingCorrespondent donordata.Correspondent existingTaskState actor.TaskState - expectedCorrespondent actor.Correspondent + expectedCorrespondent donordata.Correspondent expectedTaskState actor.TaskState redirect page.LpaPath }{ "yes was yes": { yesNo: form.Yes, - existingCorrespondent: actor.Correspondent{FirstNames: "John"}, + existingCorrespondent: donordata.Correspondent{FirstNames: "John"}, existingTaskState: actor.TaskCompleted, - expectedCorrespondent: actor.Correspondent{FirstNames: "John"}, + expectedCorrespondent: donordata.Correspondent{FirstNames: "John"}, expectedTaskState: actor.TaskCompleted, redirect: page.Paths.EnterCorrespondentDetails, }, @@ -101,7 +102,7 @@ func TestPostAddCorrespondent(t *testing.T) { }, "no was yes": { yesNo: form.No, - existingCorrespondent: actor.Correspondent{FirstNames: "John"}, + existingCorrespondent: donordata.Correspondent{FirstNames: "John"}, existingTaskState: actor.TaskCompleted, expectedTaskState: actor.TaskCompleted, redirect: page.Paths.TaskList, @@ -125,18 +126,18 @@ func TestPostAddCorrespondent(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", AddCorrespondent: tc.yesNo, Correspondent: tc.expectedCorrespondent, - Tasks: actor.DonorTasks{AddCorrespondent: tc.expectedTaskState}, + Tasks: donordata.DonorTasks{AddCorrespondent: tc.expectedTaskState}, }). Return(nil) - err := AddCorrespondent(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := AddCorrespondent(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", Correspondent: tc.existingCorrespondent, - Tasks: actor.DonorTasks{AddCorrespondent: tc.existingTaskState}, + Tasks: donordata.DonorTasks{AddCorrespondent: tc.existingTaskState}, }) resp := w.Result() @@ -161,7 +162,7 @@ func TestPostAddCorrespondentWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := AddCorrespondent(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := AddCorrespondent(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } @@ -178,7 +179,7 @@ func TestPostAddCorrespondentWhenValidationErrors(t *testing.T) { })). Return(nil) - err := AddCorrespondent(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := AddCorrespondent(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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 a0858ee2c4..010d6c8723 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 @@ -4,21 +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/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" ) type areYouApplyingForFeeDiscountOrExemptionData struct { App page.AppData Errors validation.List - CertificateProvider actor.CertificateProvider + CertificateProvider donordata.CertificateProvider Form *form.YesNoForm } func AreYouApplyingForFeeDiscountOrExemption(tmpl template.Template, payer Handler, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { data := &areYouApplyingForFeeDiscountOrExemptionData{ App: appData, CertificateProvider: donor.CertificateProvider, @@ -30,7 +31,7 @@ func AreYouApplyingForFeeDiscountOrExemption(tmpl template.Template, payer Handl data.Errors = data.Form.Validate() if data.Errors.None() { - donor.Tasks.PayForLpa = actor.PaymentTaskInProgress + donor.Tasks.PayForLpa = task.PaymentStateInProgress if err := donorStore.Put(r.Context(), donor); err != nil { return err } 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 6ddfc21510..0767aa55d8 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 @@ -7,9 +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" @@ -27,7 +28,7 @@ func TestGetAreYouApplyingForFeeDiscountOrExemption(t *testing.T) { }). Return(nil) - err := AreYouApplyingForFeeDiscountOrExemption(template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := AreYouApplyingForFeeDiscountOrExemption(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -46,7 +47,7 @@ func TestGetAreYouApplyingForFeeDiscountOrExemptionWhenTemplateErrors(t *testing }). Return(expectedError) - err := AreYouApplyingForFeeDiscountOrExemption(template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := AreYouApplyingForFeeDiscountOrExemption(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -62,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 := &actor.DonorProvidedDetails{LpaID: "lpa-id", Donor: actor.Donor{Email: "a@b.com"}} + donor := &donordata.DonorProvidedDetails{LpaID: "lpa-id", Donor: donordata.Donor{Email: "a@b.com"}} payer := newMockHandler(t) payer.EXPECT(). @@ -71,10 +72,10 @@ func TestPostAreYouApplyingForFeeDiscountOrExemption(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{Email: "a@b.com"}, - Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskInProgress}, + Donor: donordata.Donor{Email: "a@b.com"}, + Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateInProgress}, }). Return(nil) @@ -96,7 +97,7 @@ func TestPostAreYouApplyingForFeeDiscountOrExemptionWhenDonorStoreErrors(t *test Put(r.Context(), mock.Anything). Return(expectedError) - err := AreYouApplyingForFeeDiscountOrExemption(nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := AreYouApplyingForFeeDiscountOrExemption(nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } @@ -119,7 +120,7 @@ func TestPostAreYouApplyingForFeeDiscountOrExemptionWhenPayerErrors(t *testing.T Put(r.Context(), mock.Anything). Return(nil) - err := AreYouApplyingForFeeDiscountOrExemption(nil, payer.Execute, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := AreYouApplyingForFeeDiscountOrExemption(nil, payer.Execute, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } @@ -134,14 +135,14 @@ func TestPostAreYouApplyingForFeeDiscountOrExemptionWhenYes(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{Email: "a@b.com"}, - Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskInProgress}, + Donor: donordata.Donor{Email: "a@b.com"}, + Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateInProgress}, }). Return(nil) - err := AreYouApplyingForFeeDiscountOrExemption(nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id", Donor: actor.Donor{Email: "a@b.com"}}) + err := AreYouApplyingForFeeDiscountOrExemption(nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", Donor: donordata.Donor{Email: "a@b.com"}}) resp := w.Result() assert.Nil(t, err) @@ -167,7 +168,7 @@ func TestPostAreYouApplyingForFeeDiscountOrExemptionWhenValidationError(t *testi })). Return(nil) - err := AreYouApplyingForFeeDiscountOrExemption(template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id", Donor: actor.Donor{Email: "a@b.com"}}) + err := AreYouApplyingForFeeDiscountOrExemption(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{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 5d98d05c81..2fde767a14 100644 --- a/internal/donor/donorpage/can_you_sign_your_lpa.go +++ b/internal/donor/donorpage/can_you_sign_your_lpa.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/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" @@ -20,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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { data := &canYouSignYourLpaData{ App: appData, Form: &canYouSignYourLpaForm{ @@ -58,7 +57,7 @@ func CanYouSignYourLpa(tmpl template.Template, donorStore DonorStore) Handler { } type canYouSignYourLpaForm struct { - CanSign actor.YesNoMaybe + CanSign donordata.YesNoMaybe CanSignError error } 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 8eb1d5a7b1..715e14d2aa 100644 --- a/internal/donor/donorpage/can_you_sign_your_lpa_test.go +++ b/internal/donor/donorpage/can_you_sign_your_lpa_test.go @@ -7,7 +7,6 @@ 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" @@ -29,7 +28,7 @@ func TestGetCanYouSignYourLpa(t *testing.T) { }). Return(nil) - err := CanYouSignYourLpa(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := CanYouSignYourLpa(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -45,7 +44,7 @@ func TestGetCanYouSignYourLpaWhenTemplateErrors(t *testing.T) { On("Execute", w, mock.Anything). Return(expectedError) - err := CanYouSignYourLpa(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := CanYouSignYourLpa(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -55,34 +54,34 @@ func TestGetCanYouSignYourLpaWhenTemplateErrors(t *testing.T) { func TestPostCanYouSignYourLpa(t *testing.T) { testCases := map[string]struct { form url.Values - person actor.Donor + person donordata.Donor redirect page.LpaPath }{ "can sign": { form: url.Values{ - "can-sign": {actor.Yes.String()}, + "can-sign": {donordata.Yes.String()}, }, - person: actor.Donor{ - ThinksCanSign: actor.Yes, + person: donordata.Donor{ + ThinksCanSign: donordata.Yes, CanSign: form.Yes, }, redirect: page.Paths.YourPreferredLanguage, }, "cannot sign": { form: url.Values{ - "can-sign": {actor.No.String()}, + "can-sign": {donordata.No.String()}, }, - person: actor.Donor{ - ThinksCanSign: actor.No, + person: donordata.Donor{ + ThinksCanSign: donordata.No, }, redirect: page.Paths.CheckYouCanSign, }, "maybe can sign": { form: url.Values{ - "can-sign": {actor.Maybe.String()}, + "can-sign": {donordata.Maybe.String()}, }, - person: actor.Donor{ - ThinksCanSign: actor.Maybe, + person: donordata.Donor{ + ThinksCanSign: donordata.Maybe, }, redirect: page.Paths.CheckYouCanSign, }, @@ -97,13 +96,13 @@ func TestPostCanYouSignYourLpa(t *testing.T) { donorStore := newMockDonorStore(t) donorStore. - On("Put", r.Context(), &actor.DonorProvidedDetails{ + On("Put", r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", Donor: tc.person, }). Return(nil) - err := CanYouSignYourLpa(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := CanYouSignYourLpa(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", }) resp := w.Result() @@ -131,7 +130,7 @@ func TestPostCanYouSignYourLpaWhenValidationError(t *testing.T) { })). Return(nil) - err := CanYouSignYourLpa(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := CanYouSignYourLpa(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -140,7 +139,7 @@ func TestPostCanYouSignYourLpaWhenValidationError(t *testing.T) { func TestPostCanYouSignYourLpaWhenStoreErrors(t *testing.T) { form := url.Values{ - "can-sign": {actor.Yes.String()}, + "can-sign": {donordata.Yes.String()}, } w := httptest.NewRecorder() @@ -152,13 +151,13 @@ func TestPostCanYouSignYourLpaWhenStoreErrors(t *testing.T) { On("Put", r.Context(), mock.Anything). Return(expectedError) - err := CanYouSignYourLpa(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := CanYouSignYourLpa(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } func TestReadCanYouSignYourLpaForm(t *testing.T) { f := url.Values{ - "can-sign": {actor.Yes.String()}, + "can-sign": {donordata.Yes.String()}, } r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(f.Encode())) @@ -166,7 +165,7 @@ func TestReadCanYouSignYourLpaForm(t *testing.T) { result := readCanYouSignYourLpaForm(r) - assert.Equal(t, actor.Yes, result.CanSign) + assert.Equal(t, donordata.Yes, result.CanSign) assert.Nil(t, result.CanSignError) } diff --git a/internal/donor/donorpage/certificate_provider_address.go b/internal/donor/donorpage/certificate_provider_address.go index 0a5993945c..9bb31c6664 100644 --- a/internal/donor/donorpage/certificate_provider_address.go +++ b/internal/donor/donorpage/certificate_provider_address.go @@ -5,13 +5,14 @@ import ( "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" ) func CertificateProviderAddress(logger Logger, tmpl template.Template, addressClient AddressClient, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { data := newChooseAddressData( appData, "certificateProvider", diff --git a/internal/donor/donorpage/certificate_provider_address_test.go b/internal/donor/donorpage/certificate_provider_address_test.go index 4d6674e173..9019dafb30 100644 --- a/internal/donor/donorpage/certificate_provider_address_test.go +++ b/internal/donor/donorpage/certificate_provider_address_test.go @@ -9,6 +9,7 @@ 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/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" @@ -21,7 +22,7 @@ func TestGetCertificateProviderAddress(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - certificateProvider := actor.CertificateProvider{ + certificateProvider := donordata.CertificateProvider{ FirstNames: "John", LastName: "Smith", Address: place.Address{}, @@ -38,7 +39,7 @@ func TestGetCertificateProviderAddress(t *testing.T) { }). Return(nil) - err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{CertificateProvider: certificateProvider}) + err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{CertificateProvider: certificateProvider}) resp := w.Result() assert.Nil(t, err) @@ -49,11 +50,11 @@ func TestGetCertificateProviderAddressWhenProfessionalCertificateProvider(t *tes w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - certificateProvider := actor.CertificateProvider{ + certificateProvider := donordata.CertificateProvider{ FirstNames: "John", LastName: "Smith", Address: place.Address{}, - Relationship: actor.Professionally, + Relationship: donordata.Professionally, } template := newMockTemplate(t) @@ -73,7 +74,7 @@ func TestGetCertificateProviderAddressWhenProfessionalCertificateProvider(t *tes }). Return(nil) - err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{CertificateProvider: certificateProvider}) + err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{CertificateProvider: certificateProvider}) resp := w.Result() assert.Nil(t, err) @@ -84,7 +85,7 @@ func TestGetCertificateProviderAddressFromStore(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - certificateProvider := actor.CertificateProvider{ + certificateProvider := donordata.CertificateProvider{ Address: testAddress, } @@ -103,7 +104,7 @@ func TestGetCertificateProviderAddressFromStore(t *testing.T) { }). Return(nil) - err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{CertificateProvider: certificateProvider}) + err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{CertificateProvider: certificateProvider}) resp := w.Result() assert.Nil(t, err) @@ -114,7 +115,7 @@ func TestGetCertificateProviderAddressManual(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/?action=manual", nil) - certificateProvider := actor.CertificateProvider{ + certificateProvider := donordata.CertificateProvider{ Address: testAddress, } @@ -133,7 +134,7 @@ func TestGetCertificateProviderAddressManual(t *testing.T) { }). Return(nil) - err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{CertificateProvider: certificateProvider}) + err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{CertificateProvider: certificateProvider}) resp := w.Result() assert.Nil(t, err) @@ -155,7 +156,7 @@ func TestGetCertificateProviderAddressWhenTemplateErrors(t *testing.T) { }). Return(expectedError) - err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -178,14 +179,14 @@ func TestPostCertificateProviderAddressManual(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - CertificateProvider: actor.CertificateProvider{Address: testAddress}, - Tasks: actor.DonorTasks{CertificateProvider: actor.TaskCompleted}, + CertificateProvider: donordata.CertificateProvider{Address: testAddress}, + Tasks: donordata.DonorTasks{CertificateProvider: actor.TaskCompleted}, }). Return(nil) - err := CertificateProviderAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id"}) + err := CertificateProviderAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) resp := w.Result() assert.Nil(t, err) @@ -209,13 +210,13 @@ func TestPostCertificateProviderAddressManualWhenStoreErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ - CertificateProvider: actor.CertificateProvider{Address: testAddress}, - Tasks: actor.DonorTasks{CertificateProvider: actor.TaskCompleted}, + Put(r.Context(), &donordata.DonorProvidedDetails{ + CertificateProvider: donordata.CertificateProvider{Address: testAddress}, + Tasks: donordata.DonorTasks{CertificateProvider: actor.TaskCompleted}, }). Return(expectedError) - err := CertificateProviderAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := CertificateProviderAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } @@ -236,19 +237,19 @@ func TestPostCertificateProviderAddressManualFromStore(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - CertificateProvider: actor.CertificateProvider{ + CertificateProvider: donordata.CertificateProvider{ FirstNames: "John", Address: testAddress, }, - Tasks: actor.DonorTasks{CertificateProvider: actor.TaskCompleted}, + Tasks: donordata.DonorTasks{CertificateProvider: actor.TaskCompleted}, }). Return(nil) - err := CertificateProviderAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := CertificateProviderAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - CertificateProvider: actor.CertificateProvider{ + CertificateProvider: donordata.CertificateProvider{ FirstNames: "John", Address: place.Address{Line1: "abc"}, }, @@ -295,7 +296,7 @@ func TestPostCertificateProviderAddressManualWhenValidationError(t *testing.T) { }). Return(nil) - err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -329,7 +330,7 @@ func TestPostCertificateProviderPostcodeSelect(t *testing.T) { }). Return(nil) - err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -372,7 +373,7 @@ func TestPostCertificateProviderPostcodeSelectWhenValidationError(t *testing.T) }). Return(nil) - err := CertificateProviderAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := CertificateProviderAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -414,7 +415,7 @@ func TestPostCertificateProviderPostcodeLookup(t *testing.T) { }). Return(nil) - err := CertificateProviderAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := CertificateProviderAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -457,7 +458,7 @@ func TestPostCertificateProviderPostcodeLookupError(t *testing.T) { }). Return(nil) - err := CertificateProviderAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := CertificateProviderAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -505,7 +506,7 @@ func TestPostCertificateProviderPostcodeLookupInvalidPostcodeError(t *testing.T) }). Return(nil) - err := CertificateProviderAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := CertificateProviderAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -547,7 +548,7 @@ func TestPostCertificateProviderPostcodeLookupValidPostcodeNoAddresses(t *testin }). Return(nil) - err := CertificateProviderAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := CertificateProviderAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -578,7 +579,7 @@ func TestPostCertificateProviderPostcodeLookupWhenValidationError(t *testing.T) }). Return(nil) - err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -608,8 +609,8 @@ func TestPostCertificateProviderAddressReuse(t *testing.T) { }). Return(nil) - err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{Address: place.Address{Line1: "donor lane"}}, + err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{Address: place.Address{Line1: "donor lane"}}, }) resp := w.Result() @@ -629,9 +630,9 @@ func TestPostCertificateProviderAddressReuseSelect(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - CertificateProvider: actor.CertificateProvider{ + CertificateProvider: donordata.CertificateProvider{ Address: place.Address{ Line1: "a", Line2: "b", @@ -641,11 +642,11 @@ func TestPostCertificateProviderAddressReuseSelect(t *testing.T) { Country: "GB", }, }, - Tasks: actor.DonorTasks{CertificateProvider: actor.TaskCompleted}, + Tasks: donordata.DonorTasks{CertificateProvider: actor.TaskCompleted}, }). Return(nil) - err := CertificateProviderAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id"}) + err := CertificateProviderAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) resp := w.Result() assert.Nil(t, err) @@ -678,8 +679,8 @@ func TestPostCertificateProviderAddressReuseSelectWhenValidationError(t *testing }). Return(nil) - err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{Address: place.Address{Line1: "donor lane"}}, + err := CertificateProviderAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + 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 f35749478b..ffdb1ee6dc 100644 --- a/internal/donor/donorpage/certificate_provider_details.go +++ b/internal/donor/donorpage/certificate_provider_details.go @@ -7,6 +7,7 @@ import ( "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/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -19,7 +20,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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { data := &certificateProviderDetailsData{ App: appData, Form: &certificateProviderDetailsForm{ @@ -125,7 +126,7 @@ func (d *certificateProviderDetailsForm) Validate() validation.List { return errors } -func certificateProviderMatches(donor *actor.DonorProvidedDetails, firstNames, lastName string) actor.Type { +func certificateProviderMatches(donor *donordata.DonorProvidedDetails, 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 bd7fe03014..7775cca2f9 100644 --- a/internal/donor/donorpage/certificate_provider_details_test.go +++ b/internal/donor/donorpage/certificate_provider_details_test.go @@ -8,6 +8,7 @@ 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/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" @@ -26,7 +27,7 @@ func TestGetCertificateProviderDetails(t *testing.T) { }). Return(nil) - err := CertificateProviderDetails(template.Execute, nil, testUIDFn)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := CertificateProviderDetails(template.Execute, nil, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -35,12 +36,12 @@ func TestGetCertificateProviderDetails(t *testing.T) { func TestGetCertificateProviderDetailsFromStore(t *testing.T) { testcases := map[string]struct { - donor *actor.DonorProvidedDetails + donor *donordata.DonorProvidedDetails form *certificateProviderDetailsForm }{ "uk mobile": { - donor: &actor.DonorProvidedDetails{ - CertificateProvider: actor.CertificateProvider{ + donor: &donordata.DonorProvidedDetails{ + CertificateProvider: donordata.CertificateProvider{ FirstNames: "John", Mobile: "07777", }, @@ -51,8 +52,8 @@ func TestGetCertificateProviderDetailsFromStore(t *testing.T) { }, }, "non-uk mobile": { - donor: &actor.DonorProvidedDetails{ - CertificateProvider: actor.CertificateProvider{ + donor: &donordata.DonorProvidedDetails{ + CertificateProvider: donordata.CertificateProvider{ FirstNames: "John", Mobile: "07777", HasNonUKMobile: true, @@ -100,7 +101,7 @@ func TestGetCertificateProviderDetailsWhenTemplateErrors(t *testing.T) { }). Return(expectedError) - err := CertificateProviderDetails(template.Execute, nil, testUIDFn)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := CertificateProviderDetails(template.Execute, nil, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -110,7 +111,7 @@ func TestGetCertificateProviderDetailsWhenTemplateErrors(t *testing.T) { func TestPostCertificateProviderDetails(t *testing.T) { testCases := map[string]struct { form url.Values - certificateProviderDetails actor.CertificateProvider + certificateProviderDetails donordata.CertificateProvider }{ "valid": { form: url.Values{ @@ -118,7 +119,7 @@ func TestPostCertificateProviderDetails(t *testing.T) { "last-name": {"Rey"}, "mobile": {"07535111111"}, }, - certificateProviderDetails: actor.CertificateProvider{ + certificateProviderDetails: donordata.CertificateProvider{ UID: testUID, FirstNames: "John", LastName: "Rey", @@ -132,7 +133,7 @@ func TestPostCertificateProviderDetails(t *testing.T) { "has-non-uk-mobile": {"1"}, "non-uk-mobile": {"+337575757"}, }, - certificateProviderDetails: actor.CertificateProvider{ + certificateProviderDetails: donordata.CertificateProvider{ UID: testUID, FirstNames: "John", LastName: "Rey", @@ -147,7 +148,7 @@ func TestPostCertificateProviderDetails(t *testing.T) { "mobile": {"07535111111"}, "ignore-name-warning": {actor.NewSameNameWarning(actor.TypeCertificateProvider, actor.TypeDonor, "Jane", "Doe").String()}, }, - certificateProviderDetails: actor.CertificateProvider{ + certificateProviderDetails: donordata.CertificateProvider{ UID: testUID, FirstNames: "Jane", LastName: "Doe", @@ -161,7 +162,7 @@ func TestPostCertificateProviderDetails(t *testing.T) { "mobile": {"07535111111"}, "ignore-similar-name-warning": {"yes"}, }, - certificateProviderDetails: actor.CertificateProvider{ + certificateProviderDetails: donordata.CertificateProvider{ UID: testUID, FirstNames: "Joyce", LastName: "Doe", @@ -178,20 +179,20 @@ func TestPostCertificateProviderDetails(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{ + Donor: donordata.Donor{ FirstNames: "Jane", LastName: "Doe", }, CertificateProvider: tc.certificateProviderDetails, - Tasks: actor.DonorTasks{CertificateProvider: actor.TaskInProgress}, + Tasks: donordata.DonorTasks{CertificateProvider: actor.TaskInProgress}, }). Return(nil) - err := CertificateProviderDetails(nil, donorStore, testUIDFn)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := CertificateProviderDetails(nil, donorStore, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{ + Donor: donordata.Donor{ FirstNames: "Jane", LastName: "Doe", }, @@ -218,29 +219,29 @@ func TestPostCertificateProviderDetailsWhenAmendingDetailsAfterStateComplete(t * donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{ + Donor: donordata.Donor{ FirstNames: "Jane", LastName: "Doe", }, - CertificateProvider: actor.CertificateProvider{ + CertificateProvider: donordata.CertificateProvider{ UID: testUID, FirstNames: "John", LastName: "Rey", Mobile: "07535111111", }, - Tasks: actor.DonorTasks{CertificateProvider: actor.TaskCompleted}, + Tasks: donordata.DonorTasks{CertificateProvider: actor.TaskCompleted}, }). Return(nil) - err := CertificateProviderDetails(nil, donorStore, testUIDFn)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := CertificateProviderDetails(nil, donorStore, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{ + Donor: donordata.Donor{ FirstNames: "Jane", LastName: "Doe", }, - Tasks: actor.DonorTasks{CertificateProvider: actor.TaskCompleted}, + Tasks: donordata.DonorTasks{CertificateProvider: actor.TaskCompleted}, }) resp := w.Result() @@ -252,7 +253,7 @@ func TestPostCertificateProviderDetailsWhenAmendingDetailsAfterStateComplete(t * func TestPostCertificateProviderDetailsWhenInputRequired(t *testing.T) { testCases := map[string]struct { form url.Values - existingDonor *actor.DonorProvidedDetails + existingDonor *donordata.DonorProvidedDetails dataMatcher func(t *testing.T, data *certificateProviderDetailsData) bool }{ "validation error": { @@ -260,7 +261,7 @@ func TestPostCertificateProviderDetailsWhenInputRequired(t *testing.T) { "last-name": {"Doe"}, "mobile": {"07535111111"}, }, - existingDonor: &actor.DonorProvidedDetails{}, + existingDonor: &donordata.DonorProvidedDetails{}, dataMatcher: func(t *testing.T, data *certificateProviderDetailsData) bool { return assert.Equal(t, validation.With("first-names", validation.EnterError{Label: "firstNames"}), data.Errors) }, @@ -271,8 +272,8 @@ func TestPostCertificateProviderDetailsWhenInputRequired(t *testing.T) { "last-name": {"Doe"}, "mobile": {"07535111111"}, }, - existingDonor: &actor.DonorProvidedDetails{ - Donor: actor.Donor{ + existingDonor: &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{ FirstNames: "John", LastName: "Doe", }, @@ -287,8 +288,8 @@ func TestPostCertificateProviderDetailsWhenInputRequired(t *testing.T) { "last-name": {"Doe"}, "ignore-name-warning": {"errorDonorMatchesActor|theCertificateProvider|John|Doe"}, }, - existingDonor: &actor.DonorProvidedDetails{ - Donor: actor.Donor{ + existingDonor: &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{ FirstNames: "John", LastName: "Doe", }, @@ -304,8 +305,8 @@ func TestPostCertificateProviderDetailsWhenInputRequired(t *testing.T) { "mobile": {"07535111111"}, "ignore-name-warning": {"errorAttorneyMatchesActor|theCertificateProvider|John|Doe"}, }, - existingDonor: &actor.DonorProvidedDetails{ - Donor: actor.Donor{ + existingDonor: &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{ FirstNames: "John", LastName: "Doe", }, @@ -354,7 +355,7 @@ func TestPostCertificateProviderDetailsWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := CertificateProviderDetails(nil, donorStore, testUIDFn)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := CertificateProviderDetails(nil, donorStore, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } @@ -435,23 +436,23 @@ func TestCertificateProviderDetailsFormValidate(t *testing.T) { } func TestCertificateProviderMatches(t *testing.T) { - donor := &actor.DonorProvidedDetails{ - Donor: actor.Donor{FirstNames: "a", LastName: "b"}, - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + donor := &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "c", LastName: "d"}, {FirstNames: "e", LastName: "f"}, }}, - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "g", LastName: "h"}, {FirstNames: "i", LastName: "j"}, }}, - CertificateProvider: actor.CertificateProvider{FirstNames: "k", LastName: "l"}, - PeopleToNotify: actor.PeopleToNotify{ + CertificateProvider: donordata.CertificateProvider{FirstNames: "k", LastName: "l"}, + PeopleToNotify: donordata.PeopleToNotify{ {FirstNames: "m", LastName: "n"}, {FirstNames: "o", LastName: "p"}, }, - AuthorisedSignatory: actor.AuthorisedSignatory{FirstNames: "a", LastName: "s"}, - IndependentWitness: actor.IndependentWitness{FirstNames: "i", LastName: "w"}, + AuthorisedSignatory: donordata.AuthorisedSignatory{FirstNames: "a", LastName: "s"}, + IndependentWitness: donordata.IndependentWitness{FirstNames: "i", LastName: "w"}, } assert.Equal(t, actor.TypeNone, certificateProviderMatches(donor, "x", "y")) @@ -468,16 +469,16 @@ func TestCertificateProviderMatches(t *testing.T) { } func TestCertificateProviderMatchesEmptyNamesIgnored(t *testing.T) { - donor := &actor.DonorProvidedDetails{ - Donor: actor.Donor{FirstNames: "", LastName: ""}, - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + donor := &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{FirstNames: "", LastName: ""}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "", LastName: ""}, }}, - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "", LastName: ""}, }}, - CertificateProvider: actor.CertificateProvider{FirstNames: "", LastName: ""}, - PeopleToNotify: actor.PeopleToNotify{ + CertificateProvider: donordata.CertificateProvider{FirstNames: "", LastName: ""}, + PeopleToNotify: donordata.PeopleToNotify{ {FirstNames: "", LastName: ""}, }, } diff --git a/internal/donor/donorpage/change_mobile_number.go b/internal/donor/donorpage/change_mobile_number.go index 6f96734749..1af88fa2f7 100644 --- a/internal/donor/donorpage/change_mobile_number.go +++ b/internal/donor/donorpage/change_mobile_number.go @@ -7,6 +7,7 @@ import ( "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/validation" ) @@ -20,7 +21,7 @@ type changeMobileNumberData struct { } func ChangeMobileNumber(tmpl template.Template, witnessCodeSender WitnessCodeSender, actorType actor.Type) Handler { - var send func(context.Context, *actor.DonorProvidedDetails, page.Localizer) error + var send func(context.Context, *donordata.DonorProvidedDetails, page.Localizer) error var redirect page.LpaPath switch actorType { case actor.TypeIndependentWitness: @@ -33,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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 4a9b9f947e..b18cd03279 100644 --- a/internal/donor/donorpage/change_mobile_number_test.go +++ b/internal/donor/donorpage/change_mobile_number_test.go @@ -8,6 +8,7 @@ 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/identity" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -34,9 +35,9 @@ func TestGetChangeMobileNumber(t *testing.T) { }). Return(nil) - err := ChangeMobileNumber(template.Execute, newMockWitnessCodeSender(t), actorType)(testAppData, w, r, &actor.DonorProvidedDetails{ - CertificateProvider: actor.CertificateProvider{FirstNames: "Certificate", LastName: "Provided"}, - IndependentWitness: actor.IndependentWitness{FirstNames: "Independent", LastName: "Witness"}, + err := ChangeMobileNumber(template.Execute, newMockWitnessCodeSender(t), actorType)(testAppData, w, r, &donordata.DonorProvidedDetails{ + CertificateProvider: donordata.CertificateProvider{FirstNames: "Certificate", LastName: "Provided"}, + IndependentWitness: donordata.IndependentWitness{FirstNames: "Independent", LastName: "Witness"}, }) resp := w.Result() @@ -48,20 +49,20 @@ func TestGetChangeMobileNumber(t *testing.T) { func TestGetChangeMobileNumberFromStore(t *testing.T) { testcases := map[string]struct { - donor *actor.DonorProvidedDetails + donor *donordata.DonorProvidedDetails actorType actor.Type }{ "certificate provider uk mobile": { - donor: &actor.DonorProvidedDetails{ - CertificateProvider: actor.CertificateProvider{ + donor: &donordata.DonorProvidedDetails{ + CertificateProvider: donordata.CertificateProvider{ Mobile: "07777", }, }, actorType: actor.TypeCertificateProvider, }, "certificate provider non-uk mobile": { - donor: &actor.DonorProvidedDetails{ - CertificateProvider: actor.CertificateProvider{ + donor: &donordata.DonorProvidedDetails{ + CertificateProvider: donordata.CertificateProvider{ Mobile: "07777", HasNonUKMobile: true, }, @@ -69,16 +70,16 @@ func TestGetChangeMobileNumberFromStore(t *testing.T) { actorType: actor.TypeCertificateProvider, }, "independent witness uk mobile": { - donor: &actor.DonorProvidedDetails{ - IndependentWitness: actor.IndependentWitness{ + donor: &donordata.DonorProvidedDetails{ + IndependentWitness: donordata.IndependentWitness{ Mobile: "07777", }, }, actorType: actor.TypeIndependentWitness, }, "independent witness non-uk mobile": { - donor: &actor.DonorProvidedDetails{ - IndependentWitness: actor.IndependentWitness{ + donor: &donordata.DonorProvidedDetails{ + IndependentWitness: donordata.IndependentWitness{ Mobile: "07777", HasNonUKMobile: true, }, @@ -119,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, &actor.DonorProvidedDetails{}) + err := ChangeMobileNumber(template.Execute, newMockWitnessCodeSender(t), actor.TypeCertificateProvider)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -130,7 +131,7 @@ func TestPostChangeMobileNumber(t *testing.T) { testCases := map[string]struct { form url.Values actorType actor.Type - donor *actor.DonorProvidedDetails + donor *donordata.DonorProvidedDetails send string redirect page.LpaPath }{ @@ -139,9 +140,9 @@ func TestPostChangeMobileNumber(t *testing.T) { "mobile": {"07535111111"}, }, actorType: actor.TypeCertificateProvider, - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - CertificateProvider: actor.CertificateProvider{ + CertificateProvider: donordata.CertificateProvider{ Mobile: "07535111111", }, DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, @@ -155,9 +156,9 @@ func TestPostChangeMobileNumber(t *testing.T) { "non-uk-mobile": {"+337575757"}, }, actorType: actor.TypeCertificateProvider, - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - CertificateProvider: actor.CertificateProvider{ + CertificateProvider: donordata.CertificateProvider{ Mobile: "+337575757", HasNonUKMobile: true, }, @@ -171,9 +172,9 @@ func TestPostChangeMobileNumber(t *testing.T) { "mobile": {"07535111111"}, }, actorType: actor.TypeIndependentWitness, - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - IndependentWitness: actor.IndependentWitness{ + IndependentWitness: donordata.IndependentWitness{ Mobile: "07535111111", }, DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, @@ -187,9 +188,9 @@ func TestPostChangeMobileNumber(t *testing.T) { "non-uk-mobile": {"+337575757"}, }, actorType: actor.TypeIndependentWitness, - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - IndependentWitness: actor.IndependentWitness{ + IndependentWitness: donordata.IndependentWitness{ Mobile: "+337575757", HasNonUKMobile: true, }, @@ -211,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, &actor.DonorProvidedDetails{ + err := ChangeMobileNumber(nil, witnessCodeSender, tc.actorType)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, }) @@ -238,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, &actor.DonorProvidedDetails{LpaID: "lpa-id"}) + err := ChangeMobileNumber(nil, witnessCodeSender, actor.TypeCertificateProvider)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) assert.Equal(t, expectedError, err) } @@ -263,7 +264,7 @@ func TestPostChangeMobileNumberWhenSendErrorsWithTooManyRequests(t *testing.T) { })). Return(nil) - err := ChangeMobileNumber(template.Execute, witnessCodeSender, actor.TypeCertificateProvider)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id"}) + err := ChangeMobileNumber(template.Execute, witnessCodeSender, actor.TypeCertificateProvider)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) resp := w.Result() assert.Nil(t, err) @@ -286,7 +287,7 @@ func TestPostChangeMobileNumberWhenValidationError(t *testing.T) { })). Return(nil) - err := ChangeMobileNumber(template.Execute, newMockWitnessCodeSender(t), actor.TypeCertificateProvider)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := ChangeMobileNumber(template.Execute, newMockWitnessCodeSender(t), actor.TypeCertificateProvider)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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 b01479e989..911b541e5a 100644 --- a/internal/donor/donorpage/check_you_can_sign.go +++ b/internal/donor/donorpage/check_you_can_sign.go @@ -4,7 +4,7 @@ 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/validation" @@ -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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 e8e6d2f7c7..94df922a00 100644 --- a/internal/donor/donorpage/check_you_can_sign_test.go +++ b/internal/donor/donorpage/check_you_can_sign_test.go @@ -7,7 +7,7 @@ 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/validation" @@ -28,8 +28,8 @@ func TestGetCheckYouCanSign(t *testing.T) { }). Return(nil) - err := CheckYouCanSign(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{CanSign: form.No}, + err := CheckYouCanSign(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{CanSign: form.No}, }) resp := w.Result() @@ -57,10 +57,10 @@ func TestPostCheckYouCanSign(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{LpaID: "lpa-id", Donor: actor.Donor{CanSign: yesNo}}). + Put(r.Context(), &donordata.DonorProvidedDetails{LpaID: "lpa-id", Donor: donordata.Donor{CanSign: yesNo}}). Return(nil) - err := CheckYouCanSign(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id"}) + err := CheckYouCanSign(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{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, &actor.DonorProvidedDetails{}) + err := CheckYouCanSign(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() @@ -111,7 +111,7 @@ func TestCheckYouCanSignFormValidation(t *testing.T) { })). Return(nil) - err := CheckYouCanSign(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := CheckYouCanSign(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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 e8de93b617..f69427bd04 100644 --- a/internal/donor/donorpage/check_your_details.go +++ b/internal/donor/donorpage/check_your_details.go @@ -4,7 +4,7 @@ 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/validation" ) @@ -12,11 +12,11 @@ import ( type checkYourDetailsData struct { App page.AppData Errors validation.List - Donor *actor.DonorProvidedDetails + Donor *donordata.DonorProvidedDetails } func CheckYourDetails(tmpl template.Template) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 de30865542..ba0cc1c6ca 100644 --- a/internal/donor/donorpage/check_your_details_test.go +++ b/internal/donor/donorpage/check_your_details_test.go @@ -5,8 +5,9 @@ import ( "net/http/httptest" "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/stretchr/testify/assert" ) @@ -14,7 +15,7 @@ func TestGetCheckYourDetails(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &actor.DonorProvidedDetails{} + donor := &donordata.DonorProvidedDetails{} template := newMockTemplate(t) template.EXPECT(). @@ -34,10 +35,10 @@ func TestGetCheckYourDetailsWhenTemplateErrors(t *testing.T) { template := newMockTemplate(t) template.EXPECT(). - Execute(w, &checkYourDetailsData{App: testAppData, Donor: &actor.DonorProvidedDetails{}}). + Execute(w, &checkYourDetailsData{App: testAppData, Donor: &donordata.DonorProvidedDetails{}}). Return(expectedError) - err := CheckYourDetails(template.Execute)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := CheckYourDetails(template.Execute)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } @@ -46,10 +47,10 @@ func TestPostCheckYourDetails(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodPost, "/", nil) - err := CheckYourDetails(nil)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := CheckYourDetails(nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Tasks: actor.DonorTasks{ - PayForLpa: actor.PaymentTaskCompleted, + Tasks: donordata.DonorTasks{ + PayForLpa: task.PaymentStateCompleted, }, }) resp := w.Result() @@ -63,7 +64,7 @@ func TestPostCheckYourDetailsWhenUnpaid(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodPost, "/", nil) - err := CheckYourDetails(nil)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id"}) + err := CheckYourDetails(nil)(testAppData, w, r, &donordata.DonorProvidedDetails{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 49c0306a3c..0ce75f51e5 100644 --- a/internal/donor/donorpage/check_your_lpa.go +++ b/internal/donor/donorpage/check_your_lpa.go @@ -9,6 +9,7 @@ import ( "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" @@ -19,7 +20,7 @@ import ( type checkYourLpaData struct { App page.AppData Errors validation.List - Donor *actor.DonorProvidedDetails + Donor *donordata.DonorProvidedDetails Form *checkYourLpaForm CertificateProviderContacted bool CanContinue bool @@ -32,7 +33,7 @@ type checkYourLpaNotifier struct { appPublicURL string } -func (n *checkYourLpaNotifier) Notify(ctx context.Context, appData page.AppData, donor *actor.DonorProvidedDetails, wasCompleted bool) error { +func (n *checkYourLpaNotifier) Notify(ctx context.Context, appData page.AppData, donor *donordata.DonorProvidedDetails, wasCompleted bool) error { if donor.CertificateProvider.CarryOutBy.IsPaper() { return n.sendPaperNotification(ctx, appData, donor, wasCompleted) } @@ -40,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 *actor.DonorProvidedDetails, wasCompleted bool) error { +func (n *checkYourLpaNotifier) sendPaperNotification(ctx context.Context, appData page.AppData, donor *donordata.DonorProvidedDetails, wasCompleted bool) error { var sms notify.SMS if wasCompleted { sms = notify.CertificateProviderActingOnPaperDetailsChangedSMS{ @@ -60,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 *actor.DonorProvidedDetails, wasCompleted bool) error { +func (n *checkYourLpaNotifier) sendOnlineNotification(ctx context.Context, appData page.AppData, donor *donordata.DonorProvidedDetails, wasCompleted bool) error { if !wasCompleted { return n.shareCodeSender.SendCertificateProviderInvite(ctx, appData, page.CertificateProviderInvite{ LpaKey: donor.PK, @@ -106,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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { data := &checkYourLpaData{ App: appData, Donor: donor, diff --git a/internal/donor/donorpage/check_your_lpa_test.go b/internal/donor/donorpage/check_your_lpa_test.go index 07e9e52c5c..00e7920028 100644 --- a/internal/donor/donorpage/check_your_lpa_test.go +++ b/internal/donor/donorpage/check_your_lpa_test.go @@ -10,6 +10,7 @@ import ( "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/validation" @@ -26,12 +27,12 @@ func TestGetCheckYourLpa(t *testing.T) { Execute(w, &checkYourLpaData{ App: testAppData, Form: &checkYourLpaForm{}, - Donor: &actor.DonorProvidedDetails{}, + Donor: &donordata.DonorProvidedDetails{}, CanContinue: true, }). Return(nil) - err := CheckYourLpa(template.Execute, nil, nil, nil, nil, testNowFn, "http://example.org")(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := CheckYourLpa(template.Execute, nil, nil, nil, nil, testNowFn, "http://example.org")(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -42,7 +43,7 @@ func TestGetCheckYourLpaFromStore(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &actor.DonorProvidedDetails{ + donor := &donordata.DonorProvidedDetails{ CheckedAt: testNow, } donor.UpdateCheckedHash() @@ -75,11 +76,11 @@ func TestPostCheckYourLpaWhenNotChanged(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - donor := &actor.DonorProvidedDetails{ + donor := &donordata.DonorProvidedDetails{ LpaID: "lpa-id", CheckedAt: testNow, - Tasks: actor.DonorTasks{CheckYourLpa: actor.TaskCompleted}, - CertificateProvider: actor.CertificateProvider{CarryOutBy: actor.ChannelOnline}, + Tasks: donordata.DonorTasks{CheckYourLpa: actor.TaskCompleted}, + CertificateProvider: donordata.CertificateProvider{CarryOutBy: donordata.ChannelOnline}, } donor.UpdateCheckedHash() @@ -119,19 +120,19 @@ func TestPostCheckYourLpaDigitalCertificateProviderOnFirstCheck(t *testing.T) { r.Header.Add("Content-Type", page.FormUrlEncoded) uid := actoruid.New() - donor := &actor.DonorProvidedDetails{ + donor := &donordata.DonorProvidedDetails{ LpaID: "lpa-id", Hash: 5, - Tasks: actor.DonorTasks{CheckYourLpa: existingTaskState}, - CertificateProvider: actor.CertificateProvider{UID: uid, FirstNames: "John", LastName: "Smith", Email: "john@example.com", CarryOutBy: actor.ChannelOnline}, + Tasks: donordata.DonorTasks{CheckYourLpa: existingTaskState}, + CertificateProvider: donordata.CertificateProvider{UID: uid, FirstNames: "John", LastName: "Smith", Email: "john@example.com", CarryOutBy: donordata.ChannelOnline}, } - updatedDonor := &actor.DonorProvidedDetails{ + updatedDonor := &donordata.DonorProvidedDetails{ LpaID: "lpa-id", Hash: 5, CheckedAt: testNow, - Tasks: actor.DonorTasks{CheckYourLpa: actor.TaskCompleted}, - CertificateProvider: actor.CertificateProvider{UID: uid, FirstNames: "John", LastName: "Smith", Email: "john@example.com", CarryOutBy: actor.ChannelOnline}, + Tasks: donordata.DonorTasks{CheckYourLpa: actor.TaskCompleted}, + CertificateProvider: donordata.CertificateProvider{UID: uid, FirstNames: "John", LastName: "Smith", Email: "john@example.com", CarryOutBy: donordata.ChannelOnline}, } updatedDonor.UpdateCheckedHash() @@ -210,15 +211,15 @@ func TestPostCheckYourLpaDigitalCertificateProviderOnSubsequentChecks(t *testing testAppData.Localizer = localizer - donor := &actor.DonorProvidedDetails{ + donor := &donordata.DonorProvidedDetails{ LpaID: "lpa-id", LpaUID: "lpa-uid", Hash: 5, - Type: actor.LpaTypePropertyAndAffairs, - Donor: actor.Donor{FirstNames: "Teneil", LastName: "Throssell"}, + Type: donordata.LpaTypePropertyAndAffairs, + Donor: donordata.Donor{FirstNames: "Teneil", LastName: "Throssell"}, CheckedAt: testNow, - Tasks: actor.DonorTasks{CheckYourLpa: actor.TaskCompleted}, - CertificateProvider: actor.CertificateProvider{CarryOutBy: actor.ChannelOnline, Mobile: "07700900000"}, + Tasks: donordata.DonorTasks{CheckYourLpa: actor.TaskCompleted}, + CertificateProvider: donordata.CertificateProvider{CarryOutBy: donordata.ChannelOnline, Mobile: "07700900000"}, } notifyClient := newMockNotifyClient(t) @@ -262,14 +263,14 @@ func TestPostCheckYourLpaDigitalCertificateProviderOnSubsequentChecksCertificate GetAny(r.Context()). Return(nil, expectedError) - err := CheckYourLpa(nil, nil, nil, nil, certificateProviderStore, testNowFn, "http://example.org")(testAppData, w, r, &actor.DonorProvidedDetails{ + err := CheckYourLpa(nil, nil, nil, nil, certificateProviderStore, testNowFn, "http://example.org")(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", Hash: 5, - Type: actor.LpaTypePropertyAndAffairs, - Donor: actor.Donor{FirstNames: "Teneil", LastName: "Throssell"}, + Type: donordata.LpaTypePropertyAndAffairs, + Donor: donordata.Donor{FirstNames: "Teneil", LastName: "Throssell"}, CheckedAt: testNow, - Tasks: actor.DonorTasks{CheckYourLpa: actor.TaskCompleted}, - CertificateProvider: actor.CertificateProvider{CarryOutBy: actor.ChannelOnline, Mobile: "07700900000"}, + Tasks: donordata.DonorTasks{CheckYourLpa: actor.TaskCompleted}, + CertificateProvider: donordata.CertificateProvider{CarryOutBy: donordata.ChannelOnline, Mobile: "07700900000"}, }) assert.Equal(t, expectedError, err) } @@ -292,25 +293,25 @@ func TestPostCheckYourLpaPaperCertificateProviderOnFirstCheck(t *testing.T) { testAppData.Localizer = localizer - donor := &actor.DonorProvidedDetails{ + donor := &donordata.DonorProvidedDetails{ LpaID: "lpa-id", LpaUID: "lpa-uid", Hash: 5, - Donor: actor.Donor{FirstNames: "Teneil", LastName: "Throssell"}, - Tasks: actor.DonorTasks{CheckYourLpa: existingTaskState}, - CertificateProvider: actor.CertificateProvider{CarryOutBy: actor.ChannelPaper, Mobile: "07700900000"}, - Type: actor.LpaTypePropertyAndAffairs, + Donor: donordata.Donor{FirstNames: "Teneil", LastName: "Throssell"}, + Tasks: donordata.DonorTasks{CheckYourLpa: existingTaskState}, + CertificateProvider: donordata.CertificateProvider{CarryOutBy: donordata.ChannelPaper, Mobile: "07700900000"}, + Type: donordata.LpaTypePropertyAndAffairs, } - updatedDonor := &actor.DonorProvidedDetails{ + updatedDonor := &donordata.DonorProvidedDetails{ LpaID: "lpa-id", LpaUID: "lpa-uid", Hash: 5, - Donor: actor.Donor{FirstNames: "Teneil", LastName: "Throssell"}, + Donor: donordata.Donor{FirstNames: "Teneil", LastName: "Throssell"}, CheckedAt: testNow, - Tasks: actor.DonorTasks{CheckYourLpa: actor.TaskCompleted}, - CertificateProvider: actor.CertificateProvider{CarryOutBy: actor.ChannelPaper, Mobile: "07700900000"}, - Type: actor.LpaTypePropertyAndAffairs, + Tasks: donordata.DonorTasks{CheckYourLpa: actor.TaskCompleted}, + CertificateProvider: donordata.CertificateProvider{CarryOutBy: donordata.ChannelPaper, Mobile: "07700900000"}, + Type: donordata.LpaTypePropertyAndAffairs, } updatedDonor.UpdateCheckedHash() @@ -348,15 +349,15 @@ func TestPostCheckYourLpaPaperCertificateProviderOnSubsequentCheck(t *testing.T) r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - donor := &actor.DonorProvidedDetails{ + donor := &donordata.DonorProvidedDetails{ LpaID: "lpa-id", LpaUID: "lpa-uid", Hash: 5, - Donor: actor.Donor{FirstNames: "Teneil", LastName: "Throssell"}, + Donor: donordata.Donor{FirstNames: "Teneil", LastName: "Throssell"}, CheckedAt: testNow, - Tasks: actor.DonorTasks{CheckYourLpa: actor.TaskCompleted}, - CertificateProvider: actor.CertificateProvider{CarryOutBy: actor.ChannelPaper, Mobile: "07700900000"}, - Type: actor.LpaTypePropertyAndAffairs, + Tasks: donordata.DonorTasks{CheckYourLpa: actor.TaskCompleted}, + CertificateProvider: donordata.CertificateProvider{CarryOutBy: donordata.ChannelPaper, Mobile: "07700900000"}, + Type: donordata.LpaTypePropertyAndAffairs, } donorStore := newMockDonorStore(t) @@ -390,15 +391,15 @@ func TestPostCheckYourLpaWhenStoreErrors(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - donor := &actor.DonorProvidedDetails{ + donor := &donordata.DonorProvidedDetails{ LpaID: "lpa-id", LpaUID: "lpa-uid", Hash: 5, - Donor: actor.Donor{FirstNames: "Teneil", LastName: "Throssell"}, + Donor: donordata.Donor{FirstNames: "Teneil", LastName: "Throssell"}, CheckedAt: testNow, - Tasks: actor.DonorTasks{CheckYourLpa: actor.TaskCompleted}, - CertificateProvider: actor.CertificateProvider{CarryOutBy: actor.ChannelPaper, Mobile: "07700900000"}, - Type: actor.LpaTypePropertyAndAffairs, + Tasks: donordata.DonorTasks{CheckYourLpa: actor.TaskCompleted}, + CertificateProvider: donordata.CertificateProvider{CarryOutBy: donordata.ChannelPaper, Mobile: "07700900000"}, + Type: donordata.LpaTypePropertyAndAffairs, } notifyClient := newMockNotifyClient(t) @@ -427,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 := &actor.DonorProvidedDetails{ + donor := &donordata.DonorProvidedDetails{ LpaID: "lpa-id", Hash: 5, - Tasks: actor.DonorTasks{CheckYourLpa: actor.TaskInProgress}, + Tasks: donordata.DonorTasks{CheckYourLpa: actor.TaskInProgress}, } shareCodeSender := newMockShareCodeSender(t) @@ -466,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, &actor.DonorProvidedDetails{Hash: 5, CertificateProvider: actor.CertificateProvider{CarryOutBy: actor.ChannelPaper}}) + err := CheckYourLpa(nil, nil, nil, notifyClient, nil, testNowFn, "http://example.org")(testAppData, w, r, &donordata.DonorProvidedDetails{Hash: 5, CertificateProvider: donordata.CertificateProvider{CarryOutBy: donordata.ChannelPaper}}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -489,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, &actor.DonorProvidedDetails{Hash: 5}) + err := CheckYourLpa(template.Execute, nil, nil, nil, nil, nil, "http://example.org")(testAppData, w, r, &donordata.DonorProvidedDetails{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 fe51a6cfe7..39e3fae11a 100644 --- a/internal/donor/donorpage/choose_a_new_certificate_provider.go +++ b/internal/donor/donorpage/choose_a_new_certificate_provider.go @@ -4,23 +4,23 @@ 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/validation" ) type chooseNewCertificateProviderData struct { - Donor *actor.DonorProvidedDetails + Donor *donordata.DonorProvidedDetails 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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { data := &chooseNewCertificateProviderData{Donor: donor, App: appData} if r.Method == http.MethodPost { - donor.CertificateProvider = actor.CertificateProvider{} + donor.CertificateProvider = donordata.CertificateProvider{} if err := donorStore.Put(r.Context(), donor); err != nil { return err 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 1d67d365a7..b600e7bafc 100644 --- a/internal/donor/donorpage/choose_a_new_certificate_provider_test.go +++ b/internal/donor/donorpage/choose_a_new_certificate_provider_test.go @@ -5,7 +5,7 @@ import ( "net/http/httptest" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" + "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/stretchr/testify/assert" ) @@ -15,10 +15,10 @@ func TestGetChooseNewCertificateProvider(t *testing.T) { template := newMockTemplate(t) template.EXPECT(). - Execute(w, &chooseNewCertificateProviderData{Donor: &actor.DonorProvidedDetails{}, App: testAppData}). + Execute(w, &chooseNewCertificateProviderData{Donor: &donordata.DonorProvidedDetails{}, App: testAppData}). Return(nil) - err := ChooseNewCertificateProvider(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := ChooseNewCertificateProvider(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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: &actor.DonorProvidedDetails{}, App: testAppData}). + Execute(w, &chooseNewCertificateProviderData{Donor: &donordata.DonorProvidedDetails{}, App: testAppData}). Return(expectedError) - err := ChooseNewCertificateProvider(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := ChooseNewCertificateProvider(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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(), &actor.DonorProvidedDetails{CertificateProvider: actor.CertificateProvider{}}). + Put(r.Context(), &donordata.DonorProvidedDetails{CertificateProvider: donordata.CertificateProvider{}}). Return(nil) - err := ChooseNewCertificateProvider(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{CertificateProvider: actor.CertificateProvider{FirstNames: "first-names"}}) + err := ChooseNewCertificateProvider(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{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(), &actor.DonorProvidedDetails{CertificateProvider: actor.CertificateProvider{}}). + Put(r.Context(), &donordata.DonorProvidedDetails{CertificateProvider: donordata.CertificateProvider{}}). Return(expectedError) - err := ChooseNewCertificateProvider(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{CertificateProvider: actor.CertificateProvider{FirstNames: "first-names"}}) + err := ChooseNewCertificateProvider(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{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 0cf26b7851..54ba6145d3 100644 --- a/internal/donor/donorpage/choose_attorneys.go +++ b/internal/donor/donorpage/choose_attorneys.go @@ -9,6 +9,7 @@ import ( "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/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -16,7 +17,7 @@ import ( type chooseAttorneysData struct { App page.AppData Errors validation.List - Donor *actor.DonorProvidedDetails + Donor *donordata.DonorProvidedDetails Form *chooseAttorneysForm ShowDetails bool DobWarning string @@ -25,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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { uid := actoruid.FromRequest(r) if uid.IsZero() { @@ -70,7 +71,7 @@ func ChooseAttorneys(tmpl template.Template, donorStore DonorStore) Handler { if data.Errors.None() && data.DobWarning == "" && data.NameWarning == nil { if attorneyFound == false { - attorney = actor.Attorney{UID: uid} + attorney = donordata.Attorney{UID: uid} } attorney.FirstNames = data.Form.FirstNames @@ -165,7 +166,7 @@ func (f *chooseAttorneysForm) DobWarning() string { return "" } -func attorneyMatches(donor *actor.DonorProvidedDetails, uid actoruid.UID, firstNames, lastName string) actor.Type { +func attorneyMatches(donor *donordata.DonorProvidedDetails, uid actoruid.UID, firstNames, lastName string) actor.Type { if firstNames == "" && lastName == "" { return actor.TypeNone } @@ -207,6 +208,6 @@ func attorneyMatches(donor *actor.DonorProvidedDetails, uid actoruid.UID, firstN return actor.TypeNone } -func (f *chooseAttorneysForm) NameHasChanged(attorney actor.Attorney) bool { +func (f *chooseAttorneysForm) NameHasChanged(attorney donordata.Attorney) bool { return attorney.FirstNames != f.FirstNames || attorney.LastName != f.LastName } diff --git a/internal/donor/donorpage/choose_attorneys_address.go b/internal/donor/donorpage/choose_attorneys_address.go index 81afad08b0..a4f1a8d6ea 100644 --- a/internal/donor/donorpage/choose_attorneys_address.go +++ b/internal/donor/donorpage/choose_attorneys_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/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" ) func ChooseAttorneysAddress(logger Logger, tmpl template.Template, addressClient AddressClient, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 88b05aafd2..6d66b47acd 100644 --- a/internal/donor/donorpage/choose_attorneys_address_test.go +++ b/internal/donor/donorpage/choose_attorneys_address_test.go @@ -10,6 +10,7 @@ import ( "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" @@ -35,8 +36,8 @@ func TestGetChooseAttorneysAddress(t *testing.T) { }). Return(nil) - err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ UID: uid, FirstNames: "John", LastName: "Smith", @@ -54,7 +55,7 @@ func TestGetChooseAttorneysAddressFromStore(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/?id="+uid.String(), nil) - attorney := actor.Attorney{ + attorney := donordata.Attorney{ UID: uid, Address: testAddress, } @@ -75,8 +76,8 @@ func TestGetChooseAttorneysAddressFromStore(t *testing.T) { }). Return(nil) - err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorney}}, + err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney}}, }) resp := w.Result() @@ -105,8 +106,8 @@ func TestGetChooseAttorneysAddressManual(t *testing.T) { }). Return(nil) - err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{UID: uid}}}, + err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) resp := w.Result() @@ -131,8 +132,8 @@ func TestGetChooseAttorneysAddressWhenTemplateErrors(t *testing.T) { }). Return(expectedError) - err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{UID: uid}}}, + err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) resp := w.Result() @@ -157,10 +158,10 @@ func TestPostChooseAttorneysAddressManual(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Tasks: actor.DonorTasks{ChooseAttorneys: actor.TaskCompleted}, - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + Tasks: donordata.DonorTasks{ChooseAttorneys: actor.TaskCompleted}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ UID: uid, FirstNames: "a", Address: testAddress, @@ -168,9 +169,9 @@ func TestPostChooseAttorneysAddressManual(t *testing.T) { }). Return(nil) - err := ChooseAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := ChooseAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ UID: uid, FirstNames: "a", Address: place.Address{}, @@ -203,8 +204,8 @@ func TestPostChooseAttorneysAddressManualWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := ChooseAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + err := ChooseAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ UID: uid, Address: place.Address{}, }}}, @@ -230,10 +231,10 @@ func TestPostChooseAttorneysAddressManualFromStore(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Tasks: actor.DonorTasks{ChooseAttorneys: actor.TaskCompleted}, - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + Tasks: donordata.DonorTasks{ChooseAttorneys: actor.TaskCompleted}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ UID: uid, FirstNames: "John", Address: testAddress, @@ -241,9 +242,9 @@ func TestPostChooseAttorneysAddressManualFromStore(t *testing.T) { }). Return(nil) - err := ChooseAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := ChooseAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ UID: uid, FirstNames: "John", Address: place.Address{Line1: "abc"}, @@ -269,7 +270,7 @@ func TestPostChooseAttorneysAddressManualWhenValidationError(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/?id="+uid.String(), strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - attorney := actor.Attorney{ + attorney := donordata.Attorney{ UID: uid, Address: place.Address{}, } @@ -298,8 +299,8 @@ func TestPostChooseAttorneysAddressManualWhenValidationError(t *testing.T) { }). Return(nil) - err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorney}}, + err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney}}, }) resp := w.Result() @@ -336,8 +337,8 @@ func TestPostChooseAttorneysAddressPostcodeSelect(t *testing.T) { }). Return(nil) - err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{UID: uid}}}, + err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) resp := w.Result() @@ -383,8 +384,8 @@ func TestPostChooseAttorneysAddressPostcodeSelectWhenValidationError(t *testing. }). Return(nil) - err := ChooseAttorneysAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{UID: uid}}}, + err := ChooseAttorneysAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) resp := w.Result() @@ -429,8 +430,8 @@ func TestPostChooseAttorneysPostcodeLookup(t *testing.T) { }). Return(nil) - err := ChooseAttorneysAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{UID: uid}}}, + err := ChooseAttorneysAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) resp := w.Result() @@ -476,8 +477,8 @@ func TestPostChooseAttorneysPostcodeLookupError(t *testing.T) { }). Return(nil) - err := ChooseAttorneysAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{UID: uid}}}, + err := ChooseAttorneysAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) resp := w.Result() @@ -528,8 +529,8 @@ func TestPostChooseAttorneysPostcodeLookupInvalidPostcodeError(t *testing.T) { }). Return(nil) - err := ChooseAttorneysAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{UID: uid}}}, + err := ChooseAttorneysAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) resp := w.Result() @@ -572,8 +573,8 @@ func TestPostChooseAttorneysPostcodeLookupValidPostcodeNoAddresses(t *testing.T) }). Return(nil) - err := ChooseAttorneysAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{UID: uid}}}, + err := ChooseAttorneysAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) resp := w.Result() @@ -607,8 +608,8 @@ func TestPostChooseAttorneysPostcodeLookupWhenValidationError(t *testing.T) { }). Return(nil) - err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{UID: uid}}}, + err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) resp := w.Result() @@ -642,9 +643,9 @@ func TestPostChooseAttorneysAddressReuse(t *testing.T) { }). Return(nil) - err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{Address: place.Address{Line1: "donor lane"}}, - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{UID: uid}}}, + err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{Address: place.Address{Line1: "donor lane"}}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) resp := w.Result() @@ -663,7 +664,7 @@ func TestPostChooseAttorneysAddressReuseSelect(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/?id="+uid.String(), strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - updatedAttorney := actor.Attorney{ + updatedAttorney := donordata.Attorney{ UID: uid, Address: place.Address{ Line1: "a", @@ -677,16 +678,16 @@ func TestPostChooseAttorneysAddressReuseSelect(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{updatedAttorney}}, - Tasks: actor.DonorTasks{ChooseAttorneys: actor.TaskInProgress}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{updatedAttorney}}, + Tasks: donordata.DonorTasks{ChooseAttorneys: actor.TaskInProgress}, }). Return(nil) - err := ChooseAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := ChooseAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{UID: uid}}}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) resp := w.Result() @@ -722,9 +723,9 @@ func TestPostChooseAttorneysAddressReuseSelectWhenValidationError(t *testing.T) }). Return(nil) - err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{Address: place.Address{Line1: "donor lane"}}, - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{UID: uid}}}, + err := ChooseAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{Address: place.Address{Line1: "donor lane"}}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) resp := w.Result() @@ -766,9 +767,9 @@ func TestPostChooseAttorneysManuallyFromAnotherPage(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, tc.requestUrl, strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - donor := &actor.DonorProvidedDetails{ + donor := &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ { UID: uid, Address: place.Address{ diff --git a/internal/donor/donorpage/choose_attorneys_guidance.go b/internal/donor/donorpage/choose_attorneys_guidance.go index 1c33e6ba42..4bfd224c5a 100644 --- a/internal/donor/donorpage/choose_attorneys_guidance.go +++ b/internal/donor/donorpage/choose_attorneys_guidance.go @@ -5,8 +5,8 @@ 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/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/validation" ) @@ -14,11 +14,11 @@ import ( type chooseAttorneysGuidanceData struct { App page.AppData Errors validation.List - Donor *actor.DonorProvidedDetails + Donor *donordata.DonorProvidedDetails } func ChooseAttorneysGuidance(tmpl template.Template, newUID func() actoruid.UID) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 84787e88be..cd149f3d7f 100644 --- a/internal/donor/donorpage/choose_attorneys_guidance_test.go +++ b/internal/donor/donorpage/choose_attorneys_guidance_test.go @@ -5,7 +5,7 @@ import ( "net/http/httptest" "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/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -19,11 +19,11 @@ func TestGetChooseAttorneysGuidance(t *testing.T) { template.EXPECT(). Execute(w, &chooseAttorneysGuidanceData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{}, + Donor: &donordata.DonorProvidedDetails{}, }). Return(nil) - err := ChooseAttorneysGuidance(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := ChooseAttorneysGuidance(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := ChooseAttorneysGuidance(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{LpaID: "lpa-id"}) + err := ChooseAttorneysGuidance(nil, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{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 225877ec80..0e87668af9 100644 --- a/internal/donor/donorpage/choose_attorneys_summary.go +++ b/internal/donor/donorpage/choose_attorneys_summary.go @@ -5,8 +5,8 @@ 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/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/validation" @@ -16,11 +16,11 @@ type chooseAttorneysSummaryData struct { App page.AppData Errors validation.List Form *form.YesNoForm - Donor *actor.DonorProvidedDetails + Donor *donordata.DonorProvidedDetails } func ChooseAttorneysSummary(tmpl template.Template, newUID func() actoruid.UID) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 3ebf814e3c..2bce8a2262 100644 --- a/internal/donor/donorpage/choose_attorneys_summary_test.go +++ b/internal/donor/donorpage/choose_attorneys_summary_test.go @@ -7,8 +7,8 @@ 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/validation" @@ -17,12 +17,12 @@ import ( ) func TestGetChooseAttorneysSummary(t *testing.T) { - testcases := map[string]*actor.DonorProvidedDetails{ + testcases := map[string]*donordata.DonorProvidedDetails{ "attorney": { - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{}}}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{}}}, }, "trust corporation": { - Attorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{Name: "a"}}, + Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{Name: "a"}}, }, } @@ -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, &actor.DonorProvidedDetails{LpaID: "lpa-id"}) + err := ChooseAttorneysSummary(nil, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) resp := w.Result() assert.Nil(t, err) @@ -65,27 +65,27 @@ func TestPostChooseAttorneysSummaryAddAttorney(t *testing.T) { testcases := map[string]struct { addMoreFormValue form.YesNo expectedUrl string - Attorneys actor.Attorneys + Attorneys donordata.Attorneys }{ "add attorney - no attorneys": { addMoreFormValue: form.Yes, expectedUrl: page.Paths.ChooseAttorneys.Format("lpa-id") + "?id=" + testUID.String(), - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{}}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{}}, }, "add attorney - with attorney": { addMoreFormValue: form.Yes, expectedUrl: page.Paths.ChooseAttorneys.Format("lpa-id") + "?addAnother=1&id=" + testUID.String(), - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{UID: actoruid.New()}}}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: actoruid.New()}}}, }, "do not add attorney - with single attorney": { addMoreFormValue: form.No, expectedUrl: page.Paths.TaskList.Format("lpa-id"), - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{UID: actoruid.New()}}}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: actoruid.New()}}}, }, "do not add attorney - with multiple attorneys": { addMoreFormValue: form.No, expectedUrl: page.Paths.HowShouldAttorneysMakeDecisions.Format("lpa-id"), - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{UID: actoruid.New()}, {UID: actoruid.New()}}}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: actoruid.New()}, {UID: actoruid.New()}}}, }, } @@ -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, &actor.DonorProvidedDetails{LpaID: "lpa-id", Attorneys: tc.Attorneys}) + err := ChooseAttorneysSummary(nil, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{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, &actor.DonorProvidedDetails{Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{}}}}) + err := ChooseAttorneysSummary(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{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 3cf312ce81..46aa79c1b5 100644 --- a/internal/donor/donorpage/choose_attorneys_test.go +++ b/internal/donor/donorpage/choose_attorneys_test.go @@ -12,6 +12,7 @@ import ( "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/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/validation" @@ -21,36 +22,36 @@ import ( func TestGetChooseAttorneys(t *testing.T) { testcases := map[string]struct { - lpaType actor.LpaType - replacementAttorneys actor.Attorneys + lpaType donordata.LpaType + replacementAttorneys donordata.Attorneys expectedShowTrustCorpLink bool }{ "property and affairs": { - lpaType: actor.LpaTypePropertyAndAffairs, + lpaType: donordata.LpaTypePropertyAndAffairs, expectedShowTrustCorpLink: true, }, "personal welfare": { - lpaType: actor.LpaTypePersonalWelfare, + lpaType: donordata.LpaTypePersonalWelfare, expectedShowTrustCorpLink: false, }, "property and affairs with lay replacement attorney": { - lpaType: actor.LpaTypePropertyAndAffairs, - replacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{}}}, + lpaType: donordata.LpaTypePropertyAndAffairs, + replacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{}}}, expectedShowTrustCorpLink: true, }, "personal welfare with lay replacement attorney": { - lpaType: actor.LpaTypePersonalWelfare, - replacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{}}}, + lpaType: donordata.LpaTypePersonalWelfare, + replacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{}}}, expectedShowTrustCorpLink: false, }, "property and affairs with replacement trust corporation": { - lpaType: actor.LpaTypePropertyAndAffairs, - replacementAttorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{Name: "a"}}, + lpaType: donordata.LpaTypePropertyAndAffairs, + replacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{Name: "a"}}, expectedShowTrustCorpLink: false, }, "personal welfare with replacement trust corporation": { - lpaType: actor.LpaTypePersonalWelfare, - replacementAttorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{Name: "a"}}, + lpaType: donordata.LpaTypePersonalWelfare, + replacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{Name: "a"}}, expectedShowTrustCorpLink: false, }, } @@ -64,7 +65,7 @@ func TestGetChooseAttorneys(t *testing.T) { template.EXPECT(). Execute(w, &chooseAttorneysData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{ + Donor: &donordata.DonorProvidedDetails{ Type: tc.lpaType, ReplacementAttorneys: tc.replacementAttorneys, }, @@ -74,7 +75,7 @@ func TestGetChooseAttorneys(t *testing.T) { }). Return(nil) - err := ChooseAttorneys(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := ChooseAttorneys(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ Type: tc.lpaType, ReplacementAttorneys: tc.replacementAttorneys, }) @@ -90,9 +91,9 @@ func TestGetChooseAttorneysWhenNoID(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - err := ChooseAttorneys(nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := ChooseAttorneys(nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "John", UID: testUID}, }}, }) @@ -111,8 +112,8 @@ func TestGetChooseAttorneysDobWarningIsAlwaysShown(t *testing.T) { template.EXPECT(). Execute(w, &chooseAttorneysData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{ - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + Donor: &donordata.DonorProvidedDetails{ + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {UID: testUID, DateOfBirth: date.New("1900", "1", "2")}, }}, }, @@ -124,9 +125,9 @@ func TestGetChooseAttorneysDobWarningIsAlwaysShown(t *testing.T) { }). Return(nil) - err := ChooseAttorneys(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{}, - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + err := ChooseAttorneys(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {UID: testUID, DateOfBirth: date.New("1900", "1", "2")}, }}, }) @@ -145,7 +146,7 @@ func TestGetChooseAttorneysWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := ChooseAttorneys(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := ChooseAttorneys(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -157,7 +158,7 @@ func TestPostChooseAttorneysAttorneyDoesNotExist(t *testing.T) { testCases := map[string]struct { form url.Values - attorney actor.Attorney + attorney donordata.Attorney }{ "valid": { form: url.Values{ @@ -168,7 +169,7 @@ func TestPostChooseAttorneysAttorneyDoesNotExist(t *testing.T) { "date-of-birth-month": {"1"}, "date-of-birth-year": {validBirthYear}, }, - attorney: actor.Attorney{ + attorney: donordata.Attorney{ FirstNames: "John", LastName: "Doe", Email: "john@example.com", @@ -186,7 +187,7 @@ func TestPostChooseAttorneysAttorneyDoesNotExist(t *testing.T) { "date-of-birth-year": {"1900"}, "ignore-dob-warning": {"dateOfBirthIsOver100"}, }, - attorney: actor.Attorney{ + attorney: donordata.Attorney{ FirstNames: "John", LastName: "Doe", Email: "john@example.com", @@ -204,7 +205,7 @@ func TestPostChooseAttorneysAttorneyDoesNotExist(t *testing.T) { "date-of-birth-year": {validBirthYear}, "ignore-name-warning": {actor.NewSameNameWarning(actor.TypeAttorney, actor.TypeDonor, "Jane", "Doe").String()}, }, - attorney: actor.Attorney{ + attorney: donordata.Attorney{ FirstNames: "Jane", LastName: "Doe", Email: "john@example.com", @@ -222,20 +223,20 @@ func TestPostChooseAttorneysAttorneyDoesNotExist(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{ + Donor: donordata.Donor{ FirstNames: "Jane", LastName: "Doe", }, - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{tc.attorney}}, - Tasks: actor.DonorTasks{ChooseAttorneys: actor.TaskInProgress}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{tc.attorney}}, + Tasks: donordata.DonorTasks{ChooseAttorneys: actor.TaskInProgress}, }). Return(nil) - err := ChooseAttorneys(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := ChooseAttorneys(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{ + Donor: donordata.Donor{ FirstNames: "Jane", LastName: "Doe", }, @@ -255,7 +256,7 @@ func TestPostChooseAttorneysAttorneyExists(t *testing.T) { testCases := map[string]struct { form url.Values - attorney actor.Attorney + attorney donordata.Attorney }{ "valid": { form: url.Values{ @@ -266,7 +267,7 @@ func TestPostChooseAttorneysAttorneyExists(t *testing.T) { "date-of-birth-month": {"1"}, "date-of-birth-year": {validBirthYear}, }, - attorney: actor.Attorney{ + attorney: donordata.Attorney{ FirstNames: "John", LastName: "Doe", Email: "john@example.com", @@ -285,7 +286,7 @@ func TestPostChooseAttorneysAttorneyExists(t *testing.T) { "date-of-birth-year": {"1900"}, "ignore-dob-warning": {"dateOfBirthIsOver100"}, }, - attorney: actor.Attorney{ + attorney: donordata.Attorney{ FirstNames: "John", LastName: "Doe", Email: "john@example.com", @@ -304,7 +305,7 @@ func TestPostChooseAttorneysAttorneyExists(t *testing.T) { "date-of-birth-year": {validBirthYear}, "ignore-name-warning": {actor.NewSameNameWarning(actor.TypeAttorney, actor.TypeDonor, "Jane", "Doe").String()}, }, - attorney: actor.Attorney{ + attorney: donordata.Attorney{ FirstNames: "Jane", LastName: "Doe", Email: "john@example.com", @@ -323,18 +324,18 @@ func TestPostChooseAttorneysAttorneyExists(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{FirstNames: "Jane", LastName: "Doe"}, - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{tc.attorney}}, - Tasks: actor.DonorTasks{ChooseAttorneys: actor.TaskCompleted}, + Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{tc.attorney}}, + Tasks: donordata.DonorTasks{ChooseAttorneys: actor.TaskCompleted}, }). Return(nil) - err := ChooseAttorneys(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := ChooseAttorneys(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{FirstNames: "Jane", LastName: "Doe"}, - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ { FirstNames: "John", UID: uid, @@ -367,10 +368,10 @@ func TestPostChooseAttorneysNameWarningOnlyShownWhenAttorneyAndFormNamesAreDiffe donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{FirstNames: "Jane", LastName: "Doe"}, - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ { FirstNames: "Jane", LastName: "Doe", @@ -379,14 +380,14 @@ func TestPostChooseAttorneysNameWarningOnlyShownWhenAttorneyAndFormNamesAreDiffe DateOfBirth: date.New("2000", "1", "2"), }, }}, - Tasks: actor.DonorTasks{ChooseAttorneys: actor.TaskCompleted}, + Tasks: donordata.DonorTasks{ChooseAttorneys: actor.TaskCompleted}, }). Return(nil) - err := ChooseAttorneys(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := ChooseAttorneys(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{FirstNames: "Jane", LastName: "Doe"}, - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "Jane", LastName: "Doe", UID: uid, Address: place.Address{Line1: "abc"}}, }}, }) @@ -522,8 +523,8 @@ func TestPostChooseAttorneysWhenInputRequired(t *testing.T) { })). Return(nil) - err := ChooseAttorneys(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{FirstNames: "Jane", LastName: "Doe"}, + err := ChooseAttorneys(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, }) resp := w.Result() @@ -552,7 +553,7 @@ func TestPostChooseAttorneysWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := ChooseAttorneys(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := ChooseAttorneys(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } @@ -713,23 +714,23 @@ func TestChooseAttorneysFormDobWarning(t *testing.T) { func TestAttorneyMatches(t *testing.T) { uid := actoruid.New() - donor := &actor.DonorProvidedDetails{ - Donor: actor.Donor{FirstNames: "a", LastName: "b"}, - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + donor := &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "c", LastName: "d"}, {UID: uid, FirstNames: "e", LastName: "f"}, }}, - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "g", LastName: "h"}, {FirstNames: "i", LastName: "j"}, }}, - CertificateProvider: actor.CertificateProvider{FirstNames: "k", LastName: "l"}, - PeopleToNotify: actor.PeopleToNotify{ + CertificateProvider: donordata.CertificateProvider{FirstNames: "k", LastName: "l"}, + PeopleToNotify: donordata.PeopleToNotify{ {FirstNames: "m", LastName: "n"}, {FirstNames: "o", LastName: "p"}, }, - AuthorisedSignatory: actor.AuthorisedSignatory{FirstNames: "a", LastName: "s"}, - IndependentWitness: actor.IndependentWitness{FirstNames: "i", LastName: "w"}, + AuthorisedSignatory: donordata.AuthorisedSignatory{FirstNames: "a", LastName: "s"}, + IndependentWitness: donordata.IndependentWitness{FirstNames: "i", LastName: "w"}, } assert.Equal(t, actor.TypeNone, attorneyMatches(donor, uid, "x", "y")) @@ -748,17 +749,17 @@ func TestAttorneyMatches(t *testing.T) { func TestAttorneyMatchesEmptyNamesIgnored(t *testing.T) { uid := actoruid.New() - donor := &actor.DonorProvidedDetails{ - Donor: actor.Donor{FirstNames: "", LastName: ""}, - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + donor := &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{FirstNames: "", LastName: ""}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {UID: uid, FirstNames: "", LastName: ""}, {FirstNames: "", LastName: ""}, }}, - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "", LastName: ""}, }}, - CertificateProvider: actor.CertificateProvider{FirstNames: "", LastName: ""}, - PeopleToNotify: actor.PeopleToNotify{ + CertificateProvider: donordata.CertificateProvider{FirstNames: "", LastName: ""}, + PeopleToNotify: donordata.PeopleToNotify{ {FirstNames: "", LastName: ""}, }, } diff --git a/internal/donor/donorpage/choose_people_to_notify.go b/internal/donor/donorpage/choose_people_to_notify.go index 3cc2cb4a56..444a4fe691 100644 --- a/internal/donor/donorpage/choose_people_to_notify.go +++ b/internal/donor/donorpage/choose_people_to_notify.go @@ -8,6 +8,7 @@ import ( "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/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -20,7 +21,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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { if len(donor.PeopleToNotify) > 4 { return page.Paths.ChoosePeopleToNotifySummary.Redirect(w, r, appData, donor) } @@ -57,7 +58,7 @@ func ChoosePeopleToNotify(tmpl template.Template, donorStore DonorStore, newUID if data.Errors.None() && data.NameWarning == nil { if personFound == false { - personToNotify = actor.PersonToNotify{ + personToNotify = donordata.PersonToNotify{ UID: newUID(), FirstNames: data.Form.FirstNames, LastName: data.Form.LastName, @@ -115,7 +116,7 @@ func (f *choosePeopleToNotifyForm) Validate() validation.List { return errors } -func personToNotifyMatches(donor *actor.DonorProvidedDetails, uid actoruid.UID, firstNames, lastName string) actor.Type { +func personToNotifyMatches(donor *donordata.DonorProvidedDetails, 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 b55bde7834..587c1884f5 100644 --- a/internal/donor/donorpage/choose_people_to_notify_address.go +++ b/internal/donor/donorpage/choose_people_to_notify_address.go @@ -6,13 +6,14 @@ import ( "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" ) func ChoosePeopleToNotifyAddress(logger Logger, tmpl template.Template, addressClient AddressClient, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { personToNotify, found := donor.PeopleToNotify.Get(actoruid.FromRequest(r)) if found == false { 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 e77ddb1de1..806d1bbb23 100644 --- a/internal/donor/donorpage/choose_people_to_notify_address_test.go +++ b/internal/donor/donorpage/choose_people_to_notify_address_test.go @@ -10,6 +10,7 @@ import ( "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" @@ -23,7 +24,7 @@ func TestGetChoosePeopleToNotifyAddress(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/?id="+uid.String(), nil) - personToNotify := actor.PersonToNotify{ + personToNotify := donordata.PersonToNotify{ UID: uid, FirstNames: "John", LastName: "Smith", @@ -42,7 +43,7 @@ func TestGetChoosePeopleToNotifyAddress(t *testing.T) { }). Return(nil) - err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{PeopleToNotify: actor.PeopleToNotify{personToNotify}}) + err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{PeopleToNotify: donordata.PeopleToNotify{personToNotify}}) resp := w.Result() assert.Nil(t, err) @@ -70,8 +71,8 @@ func TestGetChoosePeopleToNotifyAddressFromStore(t *testing.T) { }). Return(nil) - err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - PeopleToNotify: actor.PeopleToNotify{{UID: uid, Address: testAddress}}, + err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + PeopleToNotify: donordata.PeopleToNotify{{UID: uid, Address: testAddress}}, }) resp := w.Result() @@ -100,7 +101,7 @@ func TestGetChoosePeopleToNotifyAddressManual(t *testing.T) { }). Return(nil) - err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{PeopleToNotify: actor.PeopleToNotify{{UID: uid, Address: testAddress}}}) + err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{PeopleToNotify: donordata.PeopleToNotify{{UID: uid, Address: testAddress}}}) resp := w.Result() assert.Nil(t, err) @@ -112,7 +113,7 @@ func TestGetChoosePeopleToNotifyAddressWhenTemplateErrors(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/?id="+uid.String(), nil) - personToNotify := actor.PersonToNotify{ + personToNotify := donordata.PersonToNotify{ UID: uid, Address: place.Address{}, } @@ -129,7 +130,7 @@ func TestGetChoosePeopleToNotifyAddressWhenTemplateErrors(t *testing.T) { }). Return(expectedError) - err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{PeopleToNotify: actor.PeopleToNotify{personToNotify}}) + err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{PeopleToNotify: donordata.PeopleToNotify{personToNotify}}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -153,17 +154,17 @@ func TestPostChoosePeopleToNotifyAddressManual(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - PeopleToNotify: actor.PeopleToNotify{{UID: uid, Address: testAddress}}, - Tasks: actor.DonorTasks{PeopleToNotify: actor.TaskCompleted}, + PeopleToNotify: donordata.PeopleToNotify{{UID: uid, Address: testAddress}}, + Tasks: donordata.DonorTasks{PeopleToNotify: actor.TaskCompleted}, }). Return(nil) - err := ChoosePeopleToNotifyAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := ChoosePeopleToNotifyAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - PeopleToNotify: actor.PeopleToNotify{{UID: uid}}, - Tasks: actor.DonorTasks{PeopleToNotify: actor.TaskInProgress}, + PeopleToNotify: donordata.PeopleToNotify{{UID: uid}}, + Tasks: donordata.DonorTasks{PeopleToNotify: actor.TaskInProgress}, }) resp := w.Result() @@ -189,13 +190,13 @@ func TestPostChoosePeopleToNotifyAddressManualWhenStoreErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ - PeopleToNotify: actor.PeopleToNotify{{UID: uid, Address: testAddress}}, - Tasks: actor.DonorTasks{PeopleToNotify: actor.TaskCompleted}, + Put(r.Context(), &donordata.DonorProvidedDetails{ + PeopleToNotify: donordata.PeopleToNotify{{UID: uid, Address: testAddress}}, + Tasks: donordata.DonorTasks{PeopleToNotify: actor.TaskCompleted}, }). Return(expectedError) - err := ChoosePeopleToNotifyAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{PeopleToNotify: actor.PeopleToNotify{{UID: uid}}}) + err := ChoosePeopleToNotifyAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{PeopleToNotify: donordata.PeopleToNotify{{UID: uid}}}) assert.Equal(t, expectedError, err) } @@ -218,25 +219,25 @@ func TestPostChoosePeopleToNotifyAddressManualFromStore(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - PeopleToNotify: actor.PeopleToNotify{actor.PersonToNotify{ + PeopleToNotify: donordata.PeopleToNotify{donordata.PersonToNotify{ UID: uid, FirstNames: "John", Address: testAddress, }}, - Tasks: actor.DonorTasks{PeopleToNotify: actor.TaskCompleted}, + Tasks: donordata.DonorTasks{PeopleToNotify: actor.TaskCompleted}, }). Return(nil) - err := ChoosePeopleToNotifyAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := ChoosePeopleToNotifyAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - PeopleToNotify: actor.PeopleToNotify{actor.PersonToNotify{ + PeopleToNotify: donordata.PeopleToNotify{donordata.PersonToNotify{ UID: uid, FirstNames: "John", Address: place.Address{Line1: "line1"}, }}, - Tasks: actor.DonorTasks{PeopleToNotify: actor.TaskInProgress}, + Tasks: donordata.DonorTasks{PeopleToNotify: actor.TaskInProgress}, }) resp := w.Result() @@ -275,8 +276,8 @@ func TestPostChoosePeopleToNotifyPostcodeSelect(t *testing.T) { }). Return(nil) - err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - PeopleToNotify: actor.PeopleToNotify{{ + err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + PeopleToNotify: donordata.PeopleToNotify{{ UID: uid, FirstNames: "John", Address: place.Address{Line1: "abc"}, @@ -326,7 +327,7 @@ func TestPostChoosePeopleToNotifyPostcodeSelectWhenValidationError(t *testing.T) }). Return(nil) - err := ChoosePeopleToNotifyAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{PeopleToNotify: actor.PeopleToNotify{{UID: uid}}}) + err := ChoosePeopleToNotifyAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{PeopleToNotify: donordata.PeopleToNotify{{UID: uid}}}) resp := w.Result() assert.Nil(t, err) @@ -370,7 +371,7 @@ func TestPostChoosePeopleToNotifyPostcodeLookup(t *testing.T) { }). Return(nil) - err := ChoosePeopleToNotifyAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{PeopleToNotify: actor.PeopleToNotify{{UID: uid, FirstNames: "John"}}}) + err := ChoosePeopleToNotifyAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{PeopleToNotify: donordata.PeopleToNotify{{UID: uid, FirstNames: "John"}}}) resp := w.Result() assert.Nil(t, err) @@ -415,7 +416,7 @@ func TestPostChoosePeopleToNotifyPostcodeLookupError(t *testing.T) { }). Return(nil) - err := ChoosePeopleToNotifyAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{PeopleToNotify: actor.PeopleToNotify{{UID: uid}}}) + err := ChoosePeopleToNotifyAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{PeopleToNotify: donordata.PeopleToNotify{{UID: uid}}}) resp := w.Result() assert.Nil(t, err) @@ -465,7 +466,7 @@ func TestPostChoosePeopleToNotifyPostcodeLookupInvalidPostcodeError(t *testing.T }). Return(nil) - err := ChoosePeopleToNotifyAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{PeopleToNotify: actor.PeopleToNotify{{UID: uid}}}) + err := ChoosePeopleToNotifyAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{PeopleToNotify: donordata.PeopleToNotify{{UID: uid}}}) resp := w.Result() assert.Nil(t, err) @@ -509,7 +510,7 @@ func TestPostChoosePeopleToNotifyPostcodeLookupValidPostcodeNoAddresses(t *testi }). Return(nil) - err := ChoosePeopleToNotifyAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{PeopleToNotify: actor.PeopleToNotify{{UID: uid}}}) + err := ChoosePeopleToNotifyAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{PeopleToNotify: donordata.PeopleToNotify{{UID: uid}}}) resp := w.Result() assert.Nil(t, err) @@ -526,7 +527,7 @@ func TestPostChoosePeopleToNotifyPostcodeLookupWhenValidationError(t *testing.T) r, _ := http.NewRequest(http.MethodPost, "/?id="+uid.String(), strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - personToNotify := actor.PersonToNotify{ + personToNotify := donordata.PersonToNotify{ UID: uid, Address: place.Address{}, } @@ -547,7 +548,7 @@ func TestPostChoosePeopleToNotifyPostcodeLookupWhenValidationError(t *testing.T) }). Return(nil) - err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{PeopleToNotify: actor.PeopleToNotify{personToNotify}}) + err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{PeopleToNotify: donordata.PeopleToNotify{personToNotify}}) resp := w.Result() assert.Nil(t, err) @@ -580,9 +581,9 @@ func TestPostChoosePeopleToNotifyAddressReuse(t *testing.T) { }). Return(nil) - err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{Address: place.Address{Line1: "donor lane"}}, - PeopleToNotify: actor.PeopleToNotify{{UID: uid}}, + err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{Address: place.Address{Line1: "donor lane"}}, + PeopleToNotify: donordata.PeopleToNotify{{UID: uid}}, }) resp := w.Result() @@ -603,9 +604,9 @@ func TestPostChoosePeopleToNotifyAddressReuseSelect(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - PeopleToNotify: actor.PeopleToNotify{{ + PeopleToNotify: donordata.PeopleToNotify{{ UID: uid, Address: place.Address{ Line1: "a", @@ -616,11 +617,11 @@ func TestPostChoosePeopleToNotifyAddressReuseSelect(t *testing.T) { Country: "GB", }, }}, - Tasks: actor.DonorTasks{PeopleToNotify: actor.TaskCompleted}, + Tasks: donordata.DonorTasks{PeopleToNotify: actor.TaskCompleted}, }). Return(nil) - err := ChoosePeopleToNotifyAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id", PeopleToNotify: actor.PeopleToNotify{{UID: uid}}}) + err := ChoosePeopleToNotifyAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", PeopleToNotify: donordata.PeopleToNotify{{UID: uid}}}) resp := w.Result() assert.Nil(t, err) @@ -655,9 +656,9 @@ func TestPostChoosePeopleToNotifyAddressReuseSelectWhenValidationError(t *testin }). Return(nil) - err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{Address: place.Address{Line1: "donor lane"}}, - PeopleToNotify: actor.PeopleToNotify{{UID: uid}}, + err := ChoosePeopleToNotifyAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{Address: place.Address{Line1: "donor lane"}}, + PeopleToNotify: donordata.PeopleToNotify{{UID: uid}}, }) resp := w.Result() diff --git a/internal/donor/donorpage/choose_people_to_notify_summary.go b/internal/donor/donorpage/choose_people_to_notify_summary.go index 85faf44936..8dd14e23cf 100644 --- a/internal/donor/donorpage/choose_people_to_notify_summary.go +++ b/internal/donor/donorpage/choose_people_to_notify_summary.go @@ -5,7 +5,7 @@ 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/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/validation" @@ -15,11 +15,11 @@ type choosePeopleToNotifySummaryData struct { App page.AppData Errors validation.List Form *form.YesNoForm - Donor *actor.DonorProvidedDetails + Donor *donordata.DonorProvidedDetails } func ChoosePeopleToNotifySummary(tmpl template.Template) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 02a886a4af..3e5ba46890 100644 --- a/internal/donor/donorpage/choose_people_to_notify_summary_test.go +++ b/internal/donor/donorpage/choose_people_to_notify_summary_test.go @@ -9,6 +9,7 @@ import ( "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/validation" @@ -20,7 +21,7 @@ func TestGetChoosePeopleToNotifySummary(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &actor.DonorProvidedDetails{PeopleToNotify: actor.PeopleToNotify{{}}} + donor := &donordata.DonorProvidedDetails{PeopleToNotify: donordata.PeopleToNotify{{}}} template := newMockTemplate(t) template.EXPECT(). @@ -42,9 +43,9 @@ func TestGetChoosePeopleToNotifySummaryWhenNoPeopleToNotify(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - err := ChoosePeopleToNotifySummary(nil)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := ChoosePeopleToNotifySummary(nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Tasks: actor.DonorTasks{ + Tasks: donordata.DonorTasks{ YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, ChooseReplacementAttorneys: actor.TaskCompleted, @@ -70,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, &actor.DonorProvidedDetails{LpaID: "lpa-id", PeopleToNotify: actor.PeopleToNotify{{UID: actoruid.New()}}}) + err := ChoosePeopleToNotifySummary(nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", PeopleToNotify: donordata.PeopleToNotify{{UID: actoruid.New()}}}) resp := w.Result() assert.Nil(t, err) @@ -87,10 +88,10 @@ 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, &actor.DonorProvidedDetails{ + err := ChoosePeopleToNotifySummary(nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - PeopleToNotify: actor.PeopleToNotify{{UID: actoruid.New()}}, - Tasks: actor.DonorTasks{ + PeopleToNotify: donordata.PeopleToNotify{{UID: actoruid.New()}}, + Tasks: donordata.DonorTasks{ YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, ChooseReplacementAttorneys: actor.TaskCompleted, @@ -125,7 +126,7 @@ func TestPostChoosePeopleToNotifySummaryFormValidation(t *testing.T) { })). Return(nil) - err := ChoosePeopleToNotifySummary(template.Execute)(testAppData, w, r, &actor.DonorProvidedDetails{PeopleToNotify: actor.PeopleToNotify{{}}}) + err := ChoosePeopleToNotifySummary(template.Execute)(testAppData, w, r, &donordata.DonorProvidedDetails{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 79ac5d2313..c82a6a41af 100644 --- a/internal/donor/donorpage/choose_people_to_notify_test.go +++ b/internal/donor/donorpage/choose_people_to_notify_test.go @@ -9,6 +9,7 @@ import ( "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/validation" "github.com/stretchr/testify/assert" @@ -27,7 +28,7 @@ func TestGetChoosePeopleToNotify(t *testing.T) { }). Return(nil) - err := ChoosePeopleToNotify(template.Execute, nil, testUIDFn)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := ChoosePeopleToNotify(template.Execute, nil, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -40,9 +41,9 @@ func TestGetChoosePeopleToNotifyFromStore(t *testing.T) { template := newMockTemplate(t) - err := ChoosePeopleToNotify(template.Execute, nil, testUIDFn)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := ChoosePeopleToNotify(template.Execute, nil, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - PeopleToNotify: actor.PeopleToNotify{ + PeopleToNotify: donordata.PeopleToNotify{ { UID: actoruid.New(), Address: testAddress, @@ -70,7 +71,7 @@ func TestGetChoosePeopleToNotifyWhenTemplateErrors(t *testing.T) { }). Return(expectedError) - err := ChoosePeopleToNotify(template.Execute, nil, testUIDFn)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := ChoosePeopleToNotify(template.Execute, nil, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -78,18 +79,18 @@ func TestGetChoosePeopleToNotifyWhenTemplateErrors(t *testing.T) { } func TestGetChoosePeopleToNotifyPeopleLimitReached(t *testing.T) { - personToNotify := actor.PersonToNotify{ + personToNotify := donordata.PersonToNotify{ FirstNames: "John", LastName: "Doe", UID: actoruid.New(), } testcases := map[string]struct { - addedPeople actor.PeopleToNotify + addedPeople donordata.PeopleToNotify expectedUrl page.LpaPath }{ "5 people": { - addedPeople: actor.PeopleToNotify{ + addedPeople: donordata.PeopleToNotify{ personToNotify, personToNotify, personToNotify, @@ -99,7 +100,7 @@ func TestGetChoosePeopleToNotifyPeopleLimitReached(t *testing.T) { expectedUrl: page.Paths.ChoosePeopleToNotifySummary, }, "6 people": { - addedPeople: actor.PeopleToNotify{ + addedPeople: donordata.PeopleToNotify{ personToNotify, personToNotify, personToNotify, @@ -116,7 +117,7 @@ func TestGetChoosePeopleToNotifyPeopleLimitReached(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - err := ChoosePeopleToNotify(nil, nil, testUIDFn)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := ChoosePeopleToNotify(nil, nil, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", PeopleToNotify: tc.addedPeople, }) @@ -132,14 +133,14 @@ func TestGetChoosePeopleToNotifyPeopleLimitReached(t *testing.T) { func TestPostChoosePeopleToNotifyPersonDoesNotExists(t *testing.T) { testCases := map[string]struct { form url.Values - personToNotify actor.PersonToNotify + personToNotify donordata.PersonToNotify }{ "valid": { form: url.Values{ "first-names": {"John"}, "last-name": {"Doe"}, }, - personToNotify: actor.PersonToNotify{ + personToNotify: donordata.PersonToNotify{ FirstNames: "John", LastName: "Doe", UID: testUID, @@ -151,7 +152,7 @@ func TestPostChoosePeopleToNotifyPersonDoesNotExists(t *testing.T) { "last-name": {"Doe"}, "ignore-name-warning": {actor.NewSameNameWarning(actor.TypePersonToNotify, actor.TypeDonor, "Jane", "Doe").String()}, }, - personToNotify: actor.PersonToNotify{ + personToNotify: donordata.PersonToNotify{ FirstNames: "Jane", LastName: "Doe", UID: testUID, @@ -167,17 +168,17 @@ func TestPostChoosePeopleToNotifyPersonDoesNotExists(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{FirstNames: "Jane", LastName: "Doe"}, - PeopleToNotify: actor.PeopleToNotify{tc.personToNotify}, - Tasks: actor.DonorTasks{PeopleToNotify: actor.TaskInProgress}, + Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, + PeopleToNotify: donordata.PeopleToNotify{tc.personToNotify}, + Tasks: donordata.DonorTasks{PeopleToNotify: actor.TaskInProgress}, }). Return(nil) - err := ChoosePeopleToNotify(nil, donorStore, testUIDFn)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := ChoosePeopleToNotify(nil, donorStore, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{FirstNames: "Jane", LastName: "Doe"}, + Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, }) resp := w.Result() @@ -201,20 +202,20 @@ func TestPostChoosePeopleToNotifyPersonExists(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - PeopleToNotify: actor.PeopleToNotify{{ + PeopleToNotify: donordata.PeopleToNotify{{ FirstNames: "Johnny", LastName: "Dear", UID: uid, }}, - Tasks: actor.DonorTasks{PeopleToNotify: actor.TaskInProgress}, + Tasks: donordata.DonorTasks{PeopleToNotify: actor.TaskInProgress}, }). Return(nil) - err := ChoosePeopleToNotify(nil, donorStore, testUIDFn)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := ChoosePeopleToNotify(nil, donorStore, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - PeopleToNotify: actor.PeopleToNotify{{ + PeopleToNotify: donordata.PeopleToNotify{{ FirstNames: "John", LastName: "Doe", UID: uid, @@ -277,8 +278,8 @@ func TestPostChoosePeopleToNotifyWhenInputRequired(t *testing.T) { })). Return(nil) - err := ChoosePeopleToNotify(template.Execute, nil, testUIDFn)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{FirstNames: "Jane", LastName: "Doe"}, + err := ChoosePeopleToNotify(template.Execute, nil, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, }) resp := w.Result() @@ -303,7 +304,7 @@ func TestPostChoosePeopleToNotifyWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := ChoosePeopleToNotify(nil, donorStore, testUIDFn)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := ChoosePeopleToNotify(nil, donorStore, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } @@ -368,18 +369,18 @@ func TestChoosePeopleToNotifyFormValidate(t *testing.T) { func TestPersonToNotifyMatches(t *testing.T) { uid := actoruid.New() - donor := &actor.DonorProvidedDetails{ - Donor: actor.Donor{FirstNames: "a", LastName: "b"}, - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + donor := &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "c", LastName: "d"}, {FirstNames: "e", LastName: "f"}, }}, - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "g", LastName: "h"}, {FirstNames: "i", LastName: "j"}, }}, - CertificateProvider: actor.CertificateProvider{FirstNames: "k", LastName: "l"}, - PeopleToNotify: actor.PeopleToNotify{ + CertificateProvider: donordata.CertificateProvider{FirstNames: "k", LastName: "l"}, + PeopleToNotify: donordata.PeopleToNotify{ {FirstNames: "m", LastName: "n"}, {UID: uid, FirstNames: "o", LastName: "p"}, }, @@ -398,16 +399,16 @@ func TestPersonToNotifyMatches(t *testing.T) { func TestPersonToNotifyMatchesEmptyNamesIgnored(t *testing.T) { uid := actoruid.New() - donor := &actor.DonorProvidedDetails{ - Donor: actor.Donor{FirstNames: "", LastName: ""}, - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + donor := &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{FirstNames: "", LastName: ""}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "", LastName: ""}, }}, - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "", LastName: ""}, }}, - CertificateProvider: actor.CertificateProvider{FirstNames: "", LastName: ""}, - PeopleToNotify: actor.PeopleToNotify{ + CertificateProvider: donordata.CertificateProvider{FirstNames: "", LastName: ""}, + PeopleToNotify: donordata.PeopleToNotify{ {FirstNames: "", LastName: ""}, {UID: uid, FirstNames: "", LastName: ""}, }, diff --git a/internal/donor/donorpage/choose_replacement_attorneys.go b/internal/donor/donorpage/choose_replacement_attorneys.go index 869701d6e7..445724cf74 100644 --- a/internal/donor/donorpage/choose_replacement_attorneys.go +++ b/internal/donor/donorpage/choose_replacement_attorneys.go @@ -8,6 +8,7 @@ import ( "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/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -15,7 +16,7 @@ import ( type chooseReplacementAttorneysData struct { App page.AppData Errors validation.List - Donor *actor.DonorProvidedDetails + Donor *donordata.DonorProvidedDetails Form *chooseAttorneysForm DobWarning string NameWarning *actor.SameNameWarning @@ -23,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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { uid := actoruid.FromRequest(r) if uid.IsZero() { @@ -66,7 +67,7 @@ func ChooseReplacementAttorneys(tmpl template.Template, donorStore DonorStore) H if data.Errors.None() && data.DobWarning == "" && data.NameWarning == nil { if attorneyFound == false { - attorney = actor.Attorney{UID: uid} + attorney = donordata.Attorney{UID: uid} } attorney.FirstNames = data.Form.FirstNames @@ -94,7 +95,7 @@ func ChooseReplacementAttorneys(tmpl template.Template, donorStore DonorStore) H } } -func replacementAttorneyMatches(donor *actor.DonorProvidedDetails, uid actoruid.UID, firstNames, lastName string) actor.Type { +func replacementAttorneyMatches(donor *donordata.DonorProvidedDetails, 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 6dbd51429d..d1b05781d1 100644 --- a/internal/donor/donorpage/choose_replacement_attorneys_address.go +++ b/internal/donor/donorpage/choose_replacement_attorneys_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/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" ) func ChooseReplacementAttorneysAddress(logger Logger, tmpl template.Template, addressClient AddressClient, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 9c2e47b850..6965cba93e 100644 --- a/internal/donor/donorpage/choose_replacement_attorneys_address_test.go +++ b/internal/donor/donorpage/choose_replacement_attorneys_address_test.go @@ -10,6 +10,7 @@ import ( "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" @@ -23,7 +24,7 @@ func TestGetChooseReplacementAttorneysAddress(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/?id="+uid.String(), nil) - ra := actor.Attorney{ + ra := donordata.Attorney{ UID: uid, FirstNames: "John", LastName: "Smith", @@ -42,7 +43,7 @@ func TestGetChooseReplacementAttorneysAddress(t *testing.T) { }). Return(nil) - err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{ra}}}) + err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ra}}}) resp := w.Result() assert.Nil(t, err) @@ -54,7 +55,7 @@ func TestGetChooseReplacementAttorneysAddressFromStore(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/?id="+uid.String(), nil) - ra := actor.Attorney{ + ra := donordata.Attorney{ UID: uid, Address: testAddress, } @@ -75,7 +76,7 @@ func TestGetChooseReplacementAttorneysAddressFromStore(t *testing.T) { }). Return(nil) - err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{ra}}}) + err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ra}}}) resp := w.Result() assert.Nil(t, err) @@ -87,7 +88,7 @@ func TestGetChooseReplacementAttorneysAddressManual(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/?action=manual&id="+uid.String(), nil) - ra := actor.Attorney{ + ra := donordata.Attorney{ UID: uid, Address: testAddress, } @@ -108,7 +109,7 @@ func TestGetChooseReplacementAttorneysAddressManual(t *testing.T) { }). Return(nil) - err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{ra}}}) + err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ra}}}) resp := w.Result() assert.Nil(t, err) @@ -120,7 +121,7 @@ func TestGetChooseReplacementAttorneysAddressWhenTemplateErrors(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/?id="+uid.String(), nil) - ra := actor.Attorney{ + ra := donordata.Attorney{ UID: uid, Address: place.Address{}, } @@ -137,7 +138,7 @@ func TestGetChooseReplacementAttorneysAddressWhenTemplateErrors(t *testing.T) { }). Return(expectedError) - err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{ra}}}) + err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ra}}}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -161,20 +162,20 @@ func TestPostChooseReplacementAttorneysAddressManual(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ UID: uid, FirstNames: "a", Address: testAddress, }}}, - Tasks: actor.DonorTasks{ChooseReplacementAttorneys: actor.TaskCompleted}, + Tasks: donordata.DonorTasks{ChooseReplacementAttorneys: actor.TaskCompleted}, }). Return(nil) - err := ChooseReplacementAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := ChooseReplacementAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{UID: uid, FirstNames: "a"}}}, + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid, FirstNames: "a"}}}, }) resp := w.Result() @@ -203,7 +204,7 @@ func TestPostChooseReplacementAttorneysAddressManualWhenStoreErrors(t *testing.T Put(r.Context(), mock.Anything). Return(expectedError) - err := ChooseReplacementAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{UID: uid}}}}) + err := ChooseReplacementAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}}) assert.Equal(t, expectedError, err) } @@ -225,20 +226,20 @@ func TestPostChooseReplacementAttorneysAddressManualFromStore(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ UID: uid, FirstNames: "John", Address: testAddress, }}}, - Tasks: actor.DonorTasks{ChooseReplacementAttorneys: actor.TaskCompleted}, + Tasks: donordata.DonorTasks{ChooseReplacementAttorneys: actor.TaskCompleted}, }). Return(nil) - err := ChooseReplacementAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := ChooseReplacementAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ UID: uid, FirstNames: "John", Address: place.Address{Line1: "abc"}, @@ -288,7 +289,7 @@ func TestPostChooseReplacementAttorneysAddressManualWhenValidationError(t *testi }). Return(nil) - err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{UID: uid}}}}) + err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}}) resp := w.Result() assert.Nil(t, err) @@ -324,7 +325,7 @@ func TestPostChooseReplacementAttorneysPostcodeSelect(t *testing.T) { }). Return(nil) - err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{UID: uid}}}}) + err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}}) resp := w.Result() assert.Nil(t, err) @@ -369,7 +370,7 @@ func TestPostChooseReplacementAttorneysPostcodeSelectWhenValidationError(t *test }). Return(nil) - err := ChooseReplacementAttorneysAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{UID: uid}}}}) + err := ChooseReplacementAttorneysAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}}) resp := w.Result() assert.Nil(t, err) @@ -413,7 +414,7 @@ func TestPostChooseReplacementAttorneysPostcodeLookup(t *testing.T) { }). Return(nil) - err := ChooseReplacementAttorneysAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{UID: uid}}}}) + err := ChooseReplacementAttorneysAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}}) resp := w.Result() assert.Nil(t, err) @@ -458,7 +459,7 @@ func TestPostChooseReplacementAttorneysPostcodeLookupError(t *testing.T) { }). Return(nil) - err := ChooseReplacementAttorneysAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{UID: uid}}}}) + err := ChooseReplacementAttorneysAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}}) resp := w.Result() assert.Nil(t, err) @@ -508,8 +509,8 @@ func TestPostChooseReplacementAttorneysPostcodeLookupInvalidPostcodeError(t *tes }). Return(nil) - err := ChooseReplacementAttorneysAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{UID: uid}}}, + err := ChooseReplacementAttorneysAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) resp := w.Result() @@ -554,8 +555,8 @@ func TestPostChooseReplacementAttorneysPostcodeLookupValidPostcodeNoAddresses(t }). Return(nil) - err := ChooseReplacementAttorneysAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{UID: uid}}}, + err := ChooseReplacementAttorneysAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) resp := w.Result() @@ -589,7 +590,7 @@ func TestPostChooseReplacementAttorneysPostcodeLookupWhenValidationError(t *test }). Return(nil) - err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{UID: uid}}}}) + err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}}) resp := w.Result() assert.Nil(t, err) @@ -622,9 +623,9 @@ func TestPostChooseReplacementAttorneysAddressReuse(t *testing.T) { }). Return(nil) - err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{Address: place.Address{Line1: "donor lane"}}, - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{UID: uid}}}, + err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{Address: place.Address{Line1: "donor lane"}}, + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) resp := w.Result() @@ -643,7 +644,7 @@ func TestPostChooseReplacementAttorneysAddressReuseSelect(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/?id="+uid.String(), strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - updatedAttorney := actor.Attorney{ + updatedAttorney := donordata.Attorney{ UID: uid, Address: place.Address{ Line1: "a", @@ -657,16 +658,16 @@ func TestPostChooseReplacementAttorneysAddressReuseSelect(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{updatedAttorney}}, - Tasks: actor.DonorTasks{ChooseReplacementAttorneys: actor.TaskInProgress}, + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{updatedAttorney}}, + Tasks: donordata.DonorTasks{ChooseReplacementAttorneys: actor.TaskInProgress}, }). Return(nil) - err := ChooseReplacementAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := ChooseReplacementAttorneysAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{UID: uid}}}, + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) resp := w.Result() @@ -702,9 +703,9 @@ func TestPostChooseReplacementAttorneysAddressReuseSelectWhenValidationError(t * }). Return(nil) - err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{Address: place.Address{Line1: "donor lane"}}, - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{UID: uid}}}, + err := ChooseReplacementAttorneysAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{Address: place.Address{Line1: "donor lane"}}, + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, }) resp := w.Result() diff --git a/internal/donor/donorpage/choose_replacement_attorneys_summary.go b/internal/donor/donorpage/choose_replacement_attorneys_summary.go index 61b54fc396..e1342fafdd 100644 --- a/internal/donor/donorpage/choose_replacement_attorneys_summary.go +++ b/internal/donor/donorpage/choose_replacement_attorneys_summary.go @@ -5,8 +5,8 @@ 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/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/validation" @@ -16,11 +16,11 @@ type chooseReplacementAttorneysSummaryData struct { App page.AppData Errors validation.List Form *form.YesNoForm - Donor *actor.DonorProvidedDetails + Donor *donordata.DonorProvidedDetails } func ChooseReplacementAttorneysSummary(tmpl template.Template, newUID func() actoruid.UID) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 86edb0aefa..b3afd1fb82 100644 --- a/internal/donor/donorpage/choose_replacement_attorneys_summary_test.go +++ b/internal/donor/donorpage/choose_replacement_attorneys_summary_test.go @@ -9,6 +9,7 @@ import ( "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" @@ -18,9 +19,9 @@ import ( ) func TestGetChooseReplacementAttorneysSummary(t *testing.T) { - testcases := map[string]actor.Attorneys{ - "attorneys": {Attorneys: []actor.Attorney{{}}}, - "trust corporation": {TrustCorporation: actor.TrustCorporation{Name: "a"}}, + testcases := map[string]donordata.Attorneys{ + "attorneys": {Attorneys: []donordata.Attorney{{}}}, + "trust corporation": {TrustCorporation: donordata.TrustCorporation{Name: "a"}}, } for name, attorneys := range testcases { @@ -28,7 +29,7 @@ func TestGetChooseReplacementAttorneysSummary(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &actor.DonorProvidedDetails{ReplacementAttorneys: attorneys} + donor := &donordata.DonorProvidedDetails{ReplacementAttorneys: attorneys} template := newMockTemplate(t) template.EXPECT(). @@ -52,9 +53,9 @@ func TestGetChooseReplacementAttorneysSummaryWhenNoReplacementAttorneys(t *testi w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - err := ChooseReplacementAttorneysSummary(nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := ChooseReplacementAttorneysSummary(nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Tasks: actor.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted}, + Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted}, }) resp := w.Result() @@ -72,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, &actor.DonorProvidedDetails{LpaID: "lpa-id", ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{}}}}) + err := ChooseReplacementAttorneysSummary(nil, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{}}}}) resp := w.Result() assert.Nil(t, err) @@ -81,53 +82,53 @@ func TestPostChooseReplacementAttorneysSummaryAddAttorney(t *testing.T) { } func TestPostChooseReplacementAttorneysSummaryDoNotAddAttorney(t *testing.T) { - attorney1 := actor.Attorney{FirstNames: "a", LastName: "b", Address: place.Address{Line1: "c"}, DateOfBirth: date.New("1990", "1", "1")} - attorney2 := actor.Attorney{FirstNames: "x", LastName: "y", Address: place.Address{Line1: "z"}, DateOfBirth: date.New("2000", "1", "1")} + attorney1 := donordata.Attorney{FirstNames: "a", LastName: "b", Address: place.Address{Line1: "c"}, DateOfBirth: date.New("1990", "1", "1")} + attorney2 := donordata.Attorney{FirstNames: "x", LastName: "y", Address: place.Address{Line1: "z"}, DateOfBirth: date.New("2000", "1", "1")} testcases := map[string]struct { redirectUrl page.LpaPath - attorneys actor.Attorneys - replacementAttorneys actor.Attorneys - howAttorneysAct actor.AttorneysAct + attorneys donordata.Attorneys + replacementAttorneys donordata.Attorneys + howAttorneysAct donordata.AttorneysAct decisionDetails string }{ "with multiple attorneys acting jointly and severally and single replacement attorney": { redirectUrl: page.Paths.HowShouldReplacementAttorneysStepIn, - attorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorney1, attorney2}}, - replacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorney1}}, - howAttorneysAct: actor.JointlyAndSeverally, + attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney1, attorney2}}, + replacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney1}}, + howAttorneysAct: donordata.JointlyAndSeverally, }, "with multiple attorneys acting jointly and severally and multiple replacement attorney": { redirectUrl: page.Paths.HowShouldReplacementAttorneysStepIn, - attorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorney1, attorney2}}, - replacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorney1, attorney2}}, - howAttorneysAct: actor.JointlyAndSeverally, + attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney1, attorney2}}, + replacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney1, attorney2}}, + howAttorneysAct: donordata.JointlyAndSeverally, }, "with multiple attorneys acting jointly and multiple replacement attorneys": { redirectUrl: page.Paths.HowShouldReplacementAttorneysMakeDecisions, - attorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorney1, attorney2}}, - replacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorney1, attorney2}}, - howAttorneysAct: actor.Jointly, + attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney1, attorney2}}, + replacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney1, attorney2}}, + howAttorneysAct: donordata.Jointly, }, "with multiple attorneys acting jointly for some decisions and jointly and severally for other decisions and single replacement attorney": { redirectUrl: page.Paths.TaskList, - attorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorney1, attorney2}}, - replacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorney1}}, - howAttorneysAct: actor.JointlyForSomeSeverallyForOthers, + attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney1, attorney2}}, + replacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney1}}, + howAttorneysAct: donordata.JointlyForSomeSeverallyForOthers, decisionDetails: "some words", }, "with multiple attorneys acting jointly for some decisions, and jointly and severally for other decisions and multiple replacement attorneys": { redirectUrl: page.Paths.TaskList, - attorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorney1, attorney2}}, - replacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorney1, attorney2}}, - howAttorneysAct: actor.JointlyForSomeSeverallyForOthers, + attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney1, attorney2}}, + replacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney1, attorney2}}, + howAttorneysAct: donordata.JointlyForSomeSeverallyForOthers, decisionDetails: "some words", }, "with multiple attorneys acting jointly and single replacement attorneys": { redirectUrl: page.Paths.TaskList, - attorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorney1, attorney2}}, - replacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorney1}}, - howAttorneysAct: actor.Jointly, + attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney1, attorney2}}, + replacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney1}}, + howAttorneysAct: donordata.Jointly, }, } @@ -141,15 +142,15 @@ 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, &actor.DonorProvidedDetails{ + err := ChooseReplacementAttorneysSummary(nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", ReplacementAttorneys: tc.replacementAttorneys, - AttorneyDecisions: actor.AttorneyDecisions{ + AttorneyDecisions: donordata.AttorneyDecisions{ How: tc.howAttorneysAct, Details: tc.decisionDetails, }, Attorneys: tc.attorneys, - Tasks: actor.DonorTasks{ + Tasks: donordata.DonorTasks{ YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, }, @@ -181,7 +182,7 @@ func TestPostChooseReplacementAttorneySummaryFormValidation(t *testing.T) { })). Return(nil) - err := ChooseReplacementAttorneysSummary(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{}}}}) + err := ChooseReplacementAttorneysSummary(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{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 8592f3714b..22415c4de6 100644 --- a/internal/donor/donorpage/choose_replacement_attorneys_test.go +++ b/internal/donor/donorpage/choose_replacement_attorneys_test.go @@ -12,6 +12,7 @@ import ( "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/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/validation" @@ -21,36 +22,36 @@ import ( func TestGetChooseReplacementAttorneys(t *testing.T) { testcases := map[string]struct { - lpaType actor.LpaType - attorneys actor.Attorneys + lpaType donordata.LpaType + attorneys donordata.Attorneys expectedShowTrustCorpLink bool }{ "property and affairs": { - lpaType: actor.LpaTypePropertyAndAffairs, + lpaType: donordata.LpaTypePropertyAndAffairs, expectedShowTrustCorpLink: true, }, "personal welfare": { - lpaType: actor.LpaTypePersonalWelfare, + lpaType: donordata.LpaTypePersonalWelfare, expectedShowTrustCorpLink: false, }, "property and affairs with lay attorney": { - lpaType: actor.LpaTypePropertyAndAffairs, - attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{}}}, + lpaType: donordata.LpaTypePropertyAndAffairs, + attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{}}}, expectedShowTrustCorpLink: true, }, "personal welfare with lay attorney": { - lpaType: actor.LpaTypePersonalWelfare, - attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{}}}, + lpaType: donordata.LpaTypePersonalWelfare, + attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{}}}, expectedShowTrustCorpLink: false, }, "property and affairs with trust corporation": { - lpaType: actor.LpaTypePropertyAndAffairs, - attorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{Name: "a"}}, + lpaType: donordata.LpaTypePropertyAndAffairs, + attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{Name: "a"}}, expectedShowTrustCorpLink: false, }, "personal welfare with trust corporation": { - lpaType: actor.LpaTypePersonalWelfare, - attorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{Name: "a"}}, + lpaType: donordata.LpaTypePersonalWelfare, + attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{Name: "a"}}, expectedShowTrustCorpLink: false, }, } @@ -64,7 +65,7 @@ func TestGetChooseReplacementAttorneys(t *testing.T) { template.EXPECT(). Execute(w, &chooseReplacementAttorneysData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{ + Donor: &donordata.DonorProvidedDetails{ Type: tc.lpaType, Attorneys: tc.attorneys, }, @@ -73,7 +74,7 @@ func TestGetChooseReplacementAttorneys(t *testing.T) { }). Return(nil) - err := ChooseReplacementAttorneys(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := ChooseReplacementAttorneys(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ Type: tc.lpaType, Attorneys: tc.attorneys, }) @@ -89,7 +90,7 @@ func TestGetChooseReplacementAttorneysWhenNoID(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - err := ChooseReplacementAttorneys(nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id", ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{FirstNames: "John", UID: actoruid.New()}}}}) + err := ChooseReplacementAttorneys(nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{FirstNames: "John", UID: actoruid.New()}}}}) resp := w.Result() assert.Nil(t, err) @@ -105,8 +106,8 @@ func TestGetChooseReplacementAttorneysDobWarningIsAlwaysShown(t *testing.T) { template.EXPECT(). Execute(w, &chooseReplacementAttorneysData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{ - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + Donor: &donordata.DonorProvidedDetails{ + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {UID: testUID, DateOfBirth: date.New("1900", "1", "2")}, }}, }, @@ -117,9 +118,9 @@ func TestGetChooseReplacementAttorneysDobWarningIsAlwaysShown(t *testing.T) { }). Return(nil) - err := ChooseReplacementAttorneys(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{}, - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + err := ChooseReplacementAttorneys(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{}, + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {UID: testUID, DateOfBirth: date.New("1900", "1", "2")}, }}, }) @@ -138,7 +139,7 @@ func TestGetChooseReplacementAttorneysWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := ChooseReplacementAttorneys(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := ChooseReplacementAttorneys(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -150,7 +151,7 @@ func TestPostChooseReplacementAttorneysAttorneyDoesNotExists(t *testing.T) { testCases := map[string]struct { form url.Values - attorney actor.Attorney + attorney donordata.Attorney }{ "valid": { form: url.Values{ @@ -161,7 +162,7 @@ func TestPostChooseReplacementAttorneysAttorneyDoesNotExists(t *testing.T) { "date-of-birth-month": {"1"}, "date-of-birth-year": {validBirthYear}, }, - attorney: actor.Attorney{ + attorney: donordata.Attorney{ FirstNames: "John", LastName: "Doe", Email: "john@example.com", @@ -179,7 +180,7 @@ func TestPostChooseReplacementAttorneysAttorneyDoesNotExists(t *testing.T) { "date-of-birth-year": {"1900"}, "ignore-dob-warning": {"dateOfBirthIsOver100"}, }, - attorney: actor.Attorney{ + attorney: donordata.Attorney{ FirstNames: "John", LastName: "Doe", Email: "john@example.com", @@ -197,7 +198,7 @@ func TestPostChooseReplacementAttorneysAttorneyDoesNotExists(t *testing.T) { "date-of-birth-year": {validBirthYear}, "ignore-name-warning": {actor.NewSameNameWarning(actor.TypeReplacementAttorney, actor.TypeDonor, "Jane", "Doe").String()}, }, - attorney: actor.Attorney{ + attorney: donordata.Attorney{ FirstNames: "Jane", LastName: "Doe", Email: "john@example.com", @@ -215,15 +216,15 @@ func TestPostChooseReplacementAttorneysAttorneyDoesNotExists(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{FirstNames: "Jane", LastName: "Doe"}, - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{tc.attorney}}, - Tasks: actor.DonorTasks{ChooseReplacementAttorneys: actor.TaskInProgress}, + Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{tc.attorney}}, + Tasks: donordata.DonorTasks{ChooseReplacementAttorneys: actor.TaskInProgress}, }). Return(nil) - err := ChooseReplacementAttorneys(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id", Donor: actor.Donor{FirstNames: "Jane", LastName: "Doe"}}) + err := ChooseReplacementAttorneys(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}}) resp := w.Result() assert.Nil(t, err) @@ -239,7 +240,7 @@ func TestPostChooseReplacementAttorneysAttorneyExists(t *testing.T) { testCases := map[string]struct { form url.Values - attorney actor.Attorney + attorney donordata.Attorney }{ "valid": { form: url.Values{ @@ -250,7 +251,7 @@ func TestPostChooseReplacementAttorneysAttorneyExists(t *testing.T) { "date-of-birth-month": {"1"}, "date-of-birth-year": {validBirthYear}, }, - attorney: actor.Attorney{ + attorney: donordata.Attorney{ FirstNames: "John", LastName: "Doe", Email: "john@example.com", @@ -269,7 +270,7 @@ func TestPostChooseReplacementAttorneysAttorneyExists(t *testing.T) { "date-of-birth-year": {"1900"}, "ignore-dob-warning": {"dateOfBirthIsOver100"}, }, - attorney: actor.Attorney{ + attorney: donordata.Attorney{ FirstNames: "John", LastName: "Doe", Email: "john@example.com", @@ -288,7 +289,7 @@ func TestPostChooseReplacementAttorneysAttorneyExists(t *testing.T) { "date-of-birth-year": {validBirthYear}, "ignore-name-warning": {actor.NewSameNameWarning(actor.TypeReplacementAttorney, actor.TypeDonor, "Jane", "Doe").String()}, }, - attorney: actor.Attorney{ + attorney: donordata.Attorney{ FirstNames: "Jane", LastName: "Doe", Email: "john@example.com", @@ -307,18 +308,18 @@ func TestPostChooseReplacementAttorneysAttorneyExists(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{FirstNames: "Jane", LastName: "Doe"}, - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{tc.attorney}}, - Tasks: actor.DonorTasks{ChooseReplacementAttorneys: actor.TaskCompleted}, + Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{tc.attorney}}, + Tasks: donordata.DonorTasks{ChooseReplacementAttorneys: actor.TaskCompleted}, }). Return(nil) - err := ChooseReplacementAttorneys(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := ChooseReplacementAttorneys(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{FirstNames: "Jane", LastName: "Doe"}, - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ { FirstNames: "John", UID: uid, @@ -350,10 +351,10 @@ func TestPostChooseReplacementAttorneysNameWarningOnlyShownWhenAttorneyAndFormNa donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{FirstNames: "Jane", LastName: "Doe"}, - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ { FirstNames: "Jane", LastName: "Doe", @@ -362,14 +363,14 @@ func TestPostChooseReplacementAttorneysNameWarningOnlyShownWhenAttorneyAndFormNa DateOfBirth: date.New("2000", "1", "2"), }, }}, - Tasks: actor.DonorTasks{ChooseReplacementAttorneys: actor.TaskCompleted}, + Tasks: donordata.DonorTasks{ChooseReplacementAttorneys: actor.TaskCompleted}, }). Return(nil) - err := ChooseReplacementAttorneys(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := ChooseReplacementAttorneys(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{FirstNames: "Jane", LastName: "Doe"}, - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "Jane", LastName: "Doe", UID: testUID, Address: place.Address{Line1: "abc"}}, }}, }) @@ -499,7 +500,7 @@ func TestPostChooseReplacementAttorneysWhenInputRequired(t *testing.T) { })). Return(nil) - err := ChooseReplacementAttorneys(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{Donor: actor.Donor{FirstNames: "Jane", LastName: "Doe"}}) + err := ChooseReplacementAttorneys(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}}) resp := w.Result() assert.Nil(t, err) @@ -527,30 +528,30 @@ func TestPostChooseReplacementAttorneysWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := ChooseReplacementAttorneys(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := ChooseReplacementAttorneys(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } func TestReplacementAttorneyMatches(t *testing.T) { uid := actoruid.New() - donor := &actor.DonorProvidedDetails{ - Donor: actor.Donor{FirstNames: "a", LastName: "b"}, - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + donor := &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "c", LastName: "d"}, {FirstNames: "e", LastName: "f"}, }}, - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "g", LastName: "h"}, {UID: uid, FirstNames: "i", LastName: "j"}, }}, - CertificateProvider: actor.CertificateProvider{FirstNames: "k", LastName: "l"}, - PeopleToNotify: actor.PeopleToNotify{ + CertificateProvider: donordata.CertificateProvider{FirstNames: "k", LastName: "l"}, + PeopleToNotify: donordata.PeopleToNotify{ {FirstNames: "m", LastName: "n"}, {FirstNames: "o", LastName: "p"}, }, - AuthorisedSignatory: actor.AuthorisedSignatory{FirstNames: "a", LastName: "s"}, - IndependentWitness: actor.IndependentWitness{FirstNames: "i", LastName: "w"}, + AuthorisedSignatory: donordata.AuthorisedSignatory{FirstNames: "a", LastName: "s"}, + IndependentWitness: donordata.IndependentWitness{FirstNames: "i", LastName: "w"}, } assert.Equal(t, actor.TypeNone, replacementAttorneyMatches(donor, uid, "x", "y")) @@ -568,17 +569,17 @@ func TestReplacementAttorneyMatches(t *testing.T) { func TestReplacementAttorneyMatchesEmptyNamesIgnored(t *testing.T) { uid := actoruid.New() - donor := &actor.DonorProvidedDetails{ - Donor: actor.Donor{FirstNames: "", LastName: ""}, - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + donor := &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{FirstNames: "", LastName: ""}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "", LastName: ""}, }}, - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "", LastName: ""}, {UID: uid, FirstNames: "", LastName: ""}, }}, - CertificateProvider: actor.CertificateProvider{FirstNames: "", LastName: ""}, - PeopleToNotify: actor.PeopleToNotify{ + CertificateProvider: donordata.CertificateProvider{FirstNames: "", LastName: ""}, + PeopleToNotify: donordata.PeopleToNotify{ {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 1f9b256005..1d14eea3ed 100644 --- a/internal/donor/donorpage/confirm_person_allowed_to_vouch.go +++ b/internal/donor/donorpage/confirm_person_allowed_to_vouch.go @@ -7,6 +7,7 @@ import ( "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/validation" @@ -31,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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { matches := donor.Voucher.Matches(donor) data := &confirmPersonAllowedToVouchData{ @@ -52,7 +53,7 @@ func ConfirmPersonAllowedToVouch(tmpl template.Template, donorStore DonorStore) donor.Voucher.Allowed = true redirect = page.Paths.CheckYourDetails } else { - donor.Voucher = actor.Voucher{} + donor.Voucher = donordata.Voucher{} redirect = page.Paths.EnterVoucher } 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 e49e750ea4..c970acfd09 100644 --- a/internal/donor/donorpage/confirm_person_allowed_to_vouch_test.go +++ b/internal/donor/donorpage/confirm_person_allowed_to_vouch_test.go @@ -8,6 +8,7 @@ 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/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -31,23 +32,23 @@ func TestConfirmPersonAllowedToVouchDataMultipleMatches(t *testing.T) { func TestGetConfirmPersonAllowedToVouch(t *testing.T) { testcases := map[string]struct { - donor *actor.DonorProvidedDetails + donor *donordata.DonorProvidedDetails matches []actor.Type matchSurname bool }{ "matches donor": { - donor: &actor.DonorProvidedDetails{ - Donor: actor.Donor{FirstNames: "John", LastName: "Smith"}, - CertificateProvider: actor.CertificateProvider{FirstNames: "John", LastName: "Smith"}, - Voucher: actor.Voucher{FirstNames: "John", LastName: "Smith"}, + donor: &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{FirstNames: "John", LastName: "Smith"}, + CertificateProvider: donordata.CertificateProvider{FirstNames: "John", LastName: "Smith"}, + Voucher: donordata.Voucher{FirstNames: "John", LastName: "Smith"}, }, matches: []actor.Type{actor.TypeDonor, actor.TypeCertificateProvider}, }, "matches donor last name": { - donor: &actor.DonorProvidedDetails{ - Donor: actor.Donor{FirstNames: "Dave", LastName: "Smith"}, - CertificateProvider: actor.CertificateProvider{FirstNames: "John", LastName: "Smith"}, - Voucher: actor.Voucher{FirstNames: "John", LastName: "Smith"}, + donor: &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{FirstNames: "Dave", LastName: "Smith"}, + CertificateProvider: donordata.CertificateProvider{FirstNames: "John", LastName: "Smith"}, + Voucher: donordata.Voucher{FirstNames: "John", LastName: "Smith"}, }, matches: []actor.Type{actor.TypeCertificateProvider}, matchSurname: true, @@ -88,7 +89,7 @@ func TestGetConfirmPersonAllowedToVouchWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := ConfirmPersonAllowedToVouch(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := ConfirmPersonAllowedToVouch(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -98,12 +99,12 @@ func TestGetConfirmPersonAllowedToVouchWhenTemplateErrors(t *testing.T) { func TestPostConfirmPersonAllowedToVouch(t *testing.T) { testCases := map[string]struct { yesNo form.YesNo - voucher actor.Voucher + voucher donordata.Voucher redirect page.LpaPath }{ "yes": { yesNo: form.Yes, - voucher: actor.Voucher{FirstNames: "John", Allowed: true}, + voucher: donordata.Voucher{FirstNames: "John", Allowed: true}, redirect: page.Paths.CheckYourDetails, }, "no": { @@ -124,15 +125,15 @@ func TestPostConfirmPersonAllowedToVouch(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", Voucher: tc.voucher, }). Return(nil) - err := ConfirmPersonAllowedToVouch(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := ConfirmPersonAllowedToVouch(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Voucher: actor.Voucher{FirstNames: "John"}, + Voucher: donordata.Voucher{FirstNames: "John"}, }) resp := w.Result() @@ -157,7 +158,7 @@ func TestPostConfirmPersonAllowedToVouchWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := ConfirmPersonAllowedToVouch(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := ConfirmPersonAllowedToVouch(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } @@ -174,7 +175,7 @@ func TestPostConfirmPersonAllowedToVouchWhenValidationErrors(t *testing.T) { })). Return(nil) - err := ConfirmPersonAllowedToVouch(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := ConfirmPersonAllowedToVouch(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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 872628b484..40f906fbfe 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 @@ -6,6 +6,7 @@ import ( "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/validation" @@ -15,11 +16,11 @@ type confirmYourCertificateProviderIsNotRelatedData struct { App page.AppData Errors validation.List Form *form.YesNoForm - Donor *actor.DonorProvidedDetails + Donor *donordata.DonorProvidedDetails } func ConfirmYourCertificateProviderIsNotRelated(tmpl template.Template, donorStore DonorStore, now func() time.Time) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { data := &confirmYourCertificateProviderIsNotRelatedData{ App: appData, Form: form.NewYesNoForm(form.YesNoUnknown), @@ -34,7 +35,7 @@ func ConfirmYourCertificateProviderIsNotRelated(tmpl template.Template, donorSto if r.Method == http.MethodPost { if r.PostFormValue("action") == "choose-new" { - donor.CertificateProvider = actor.CertificateProvider{} + donor.CertificateProvider = donordata.CertificateProvider{} donor.Tasks.CertificateProvider = actor.TaskNotStarted 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 9f14911b02..3f6a494596 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 @@ -8,6 +8,7 @@ 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/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -19,8 +20,8 @@ func TestGetConfirmYourCertificateProviderIsNotRelated(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &actor.DonorProvidedDetails{ - Tasks: actor.DonorTasks{ + donor := &donordata.DonorProvidedDetails{ + Tasks: donordata.DonorTasks{ CertificateProvider: actor.TaskCompleted, }, } @@ -45,7 +46,7 @@ func TestGetConfirmYourCertificateProviderIsNotRelatedWhenNoCertificateProvider( w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - err := ConfirmYourCertificateProviderIsNotRelated(nil, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := ConfirmYourCertificateProviderIsNotRelated(nil, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", }) resp := w.Result() @@ -64,8 +65,8 @@ func TestGetConfirmYourCertificateProviderIsNotRelatedWhenTemplateErrors(t *test Execute(w, mock.Anything). Return(expectedError) - err := ConfirmYourCertificateProviderIsNotRelated(template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Tasks: actor.DonorTasks{ + err := ConfirmYourCertificateProviderIsNotRelated(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Tasks: donordata.DonorTasks{ CertificateProvider: actor.TaskCompleted, }, }) @@ -86,11 +87,11 @@ func TestPostConfirmYourCertificateProviderIsNotRelated(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{CanSign: form.Yes}, + Donor: donordata.Donor{CanSign: form.Yes}, HasSentApplicationUpdatedEvent: true, - Tasks: actor.DonorTasks{ + Tasks: donordata.DonorTasks{ YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, ChooseReplacementAttorneys: actor.TaskCompleted, @@ -105,11 +106,11 @@ func TestPostConfirmYourCertificateProviderIsNotRelated(t *testing.T) { }). Return(nil) - err := ConfirmYourCertificateProviderIsNotRelated(nil, donorStore, testNowFn)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := ConfirmYourCertificateProviderIsNotRelated(nil, donorStore, testNowFn)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{CanSign: form.Yes}, + Donor: donordata.Donor{CanSign: form.Yes}, HasSentApplicationUpdatedEvent: true, - Tasks: actor.DonorTasks{ + Tasks: donordata.DonorTasks{ YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, ChooseReplacementAttorneys: actor.TaskCompleted, @@ -138,20 +139,20 @@ func TestPostConfirmYourCertificateProviderIsNotRelatedChooseNew(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Tasks: actor.DonorTasks{ + Tasks: donordata.DonorTasks{ CertificateProvider: actor.TaskNotStarted, }, }). Return(nil) - err := ConfirmYourCertificateProviderIsNotRelated(nil, donorStore, testNowFn)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := ConfirmYourCertificateProviderIsNotRelated(nil, donorStore, testNowFn)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - CertificateProvider: actor.CertificateProvider{ + CertificateProvider: donordata.CertificateProvider{ FirstNames: "John", }, - Tasks: actor.DonorTasks{ + Tasks: donordata.DonorTasks{ CertificateProvider: actor.TaskCompleted, }, }) @@ -183,8 +184,8 @@ func TestPostConfirmYourCertificateProviderIsNotRelatedWhenStoreErrors(t *testin Put(r.Context(), mock.Anything). Return(expectedError) - err := ConfirmYourCertificateProviderIsNotRelated(nil, donorStore, testNowFn)(testAppData, w, r, &actor.DonorProvidedDetails{ - Tasks: actor.DonorTasks{ + err := ConfirmYourCertificateProviderIsNotRelated(nil, donorStore, testNowFn)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Tasks: donordata.DonorTasks{ CertificateProvider: actor.TaskCompleted, }, }) @@ -206,8 +207,8 @@ func TestPostConfirmYourCertificateProviderIsNotRelatedWhenValidationErrors(t *t })). Return(nil) - err := ConfirmYourCertificateProviderIsNotRelated(template.Execute, nil, testNowFn)(testAppData, w, r, &actor.DonorProvidedDetails{ - Tasks: actor.DonorTasks{ + err := ConfirmYourCertificateProviderIsNotRelated(template.Execute, nil, testNowFn)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Tasks: donordata.DonorTasks{ CertificateProvider: actor.TaskCompleted, }, }) diff --git a/internal/donor/donorpage/delete_lpa.go b/internal/donor/donorpage/delete_lpa.go index bdfd3f28ed..bfe3826b54 100644 --- a/internal/donor/donorpage/delete_lpa.go +++ b/internal/donor/donorpage/delete_lpa.go @@ -5,7 +5,7 @@ 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/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -13,12 +13,12 @@ import ( type deleteLpaData struct { App page.AppData Errors validation.List - Donor *actor.DonorProvidedDetails + Donor *donordata.DonorProvidedDetails } func DeleteLpa(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 879ac51fcb..5523aacc0b 100644 --- a/internal/donor/donorpage/delete_lpa_test.go +++ b/internal/donor/donorpage/delete_lpa_test.go @@ -6,7 +6,7 @@ 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/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -20,11 +20,11 @@ func TestGetDeleteLpa(t *testing.T) { template.EXPECT(). Execute(w, &deleteLpaData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{}, + Donor: &donordata.DonorProvidedDetails{}, }). Return(nil) - err := DeleteLpa(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := DeleteLpa(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := DeleteLpa(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{LpaUID: "lpa-uid"}) + err := DeleteLpa(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{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, &actor.DonorProvidedDetails{}) + err := DeleteLpa(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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 f975b69a84..476469a967 100644 --- a/internal/donor/donorpage/do_you_want_to_notify_people.go +++ b/internal/donor/donorpage/do_you_want_to_notify_people.go @@ -5,6 +5,7 @@ import ( "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/validation" @@ -14,12 +15,12 @@ type doYouWantToNotifyPeopleData struct { App page.AppData Errors validation.List Form *form.YesNoForm - Donor *actor.DonorProvidedDetails + Donor *donordata.DonorProvidedDetails HowWorkTogether string } func DoYouWantToNotifyPeople(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { if len(donor.PeopleToNotify) > 0 { return page.Paths.ChoosePeopleToNotifySummary.Redirect(w, r, appData, donor) } @@ -31,11 +32,11 @@ func DoYouWantToNotifyPeople(tmpl template.Template, donorStore DonorStore) Hand } switch donor.AttorneyDecisions.How { - case actor.Jointly: + case donordata.Jointly: data.HowWorkTogether = "jointlyDescription" - case actor.JointlyAndSeverally: + case donordata.JointlyAndSeverally: data.HowWorkTogether = "jointlyAndSeverallyDescription" - case actor.JointlyForSomeSeverallyForOthers: + case donordata.JointlyForSomeSeverallyForOthers: data.HowWorkTogether = "jointlyForSomeSeverallyForOthersDescription" } 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 46181a51c6..60b44a239d 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 @@ -9,6 +9,7 @@ import ( "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/validation" @@ -24,12 +25,12 @@ func TestGetDoYouWantToNotifyPeople(t *testing.T) { template.EXPECT(). Execute(w, &doYouWantToNotifyPeopleData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{}, + Donor: &donordata.DonorProvidedDetails{}, Form: form.NewYesNoForm(form.YesNoUnknown), }). Return(nil) - err := DoYouWantToNotifyPeople(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := DoYouWantToNotifyPeople(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -44,14 +45,14 @@ func TestGetDoYouWantToNotifyPeopleFromStore(t *testing.T) { template.EXPECT(). Execute(w, &doYouWantToNotifyPeopleData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{ + Donor: &donordata.DonorProvidedDetails{ DoYouWantToNotifyPeople: form.Yes, }, Form: form.NewYesNoForm(form.Yes), }). Return(nil) - err := DoYouWantToNotifyPeople(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := DoYouWantToNotifyPeople(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ DoYouWantToNotifyPeople: form.Yes, }) resp := w.Result() @@ -62,19 +63,19 @@ func TestGetDoYouWantToNotifyPeopleFromStore(t *testing.T) { func TestGetDoYouWantToNotifyPeopleHowAttorneysWorkTogether(t *testing.T) { testCases := map[string]struct { - howWorkTogether actor.AttorneysAct + howWorkTogether donordata.AttorneysAct expectedTransKey string }{ "jointly": { - howWorkTogether: actor.Jointly, + howWorkTogether: donordata.Jointly, expectedTransKey: "jointlyDescription", }, "jointly and severally": { - howWorkTogether: actor.JointlyAndSeverally, + howWorkTogether: donordata.JointlyAndSeverally, expectedTransKey: "jointlyAndSeverallyDescription", }, "jointly for some severally for others": { - howWorkTogether: actor.JointlyForSomeSeverallyForOthers, + howWorkTogether: donordata.JointlyForSomeSeverallyForOthers, expectedTransKey: "jointlyForSomeSeverallyForOthersDescription", }, } @@ -88,18 +89,18 @@ func TestGetDoYouWantToNotifyPeopleHowAttorneysWorkTogether(t *testing.T) { template.EXPECT(). Execute(w, &doYouWantToNotifyPeopleData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{ + Donor: &donordata.DonorProvidedDetails{ DoYouWantToNotifyPeople: form.Yes, - AttorneyDecisions: actor.AttorneyDecisions{How: tc.howWorkTogether}, + AttorneyDecisions: donordata.AttorneyDecisions{How: tc.howWorkTogether}, }, Form: form.NewYesNoForm(form.Yes), HowWorkTogether: tc.expectedTransKey, }). Return(nil) - err := DoYouWantToNotifyPeople(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := DoYouWantToNotifyPeople(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ DoYouWantToNotifyPeople: form.Yes, - AttorneyDecisions: actor.AttorneyDecisions{How: tc.howWorkTogether}, + AttorneyDecisions: donordata.AttorneyDecisions{How: tc.howWorkTogether}, }) resp := w.Result() @@ -115,9 +116,9 @@ func TestGetDoYouWantToNotifyPeopleFromStoreWithPeople(t *testing.T) { template := newMockTemplate(t) - err := DoYouWantToNotifyPeople(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := DoYouWantToNotifyPeople(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - PeopleToNotify: actor.PeopleToNotify{ + PeopleToNotify: donordata.PeopleToNotify{ {UID: actoruid.New()}, }, }) @@ -137,7 +138,7 @@ func TestGetDoYouWantToNotifyPeopleWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := DoYouWantToNotifyPeople(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := DoYouWantToNotifyPeople(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -177,10 +178,10 @@ func TestPostDoYouWantToNotifyPeople(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", DoYouWantToNotifyPeople: tc.YesNo, - Tasks: actor.DonorTasks{ + Tasks: donordata.DonorTasks{ YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, ChooseReplacementAttorneys: actor.TaskCompleted, @@ -192,10 +193,10 @@ func TestPostDoYouWantToNotifyPeople(t *testing.T) { }). Return(nil) - err := DoYouWantToNotifyPeople(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := DoYouWantToNotifyPeople(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", DoYouWantToNotifyPeople: tc.ExistingAnswer, - Tasks: actor.DonorTasks{ + Tasks: donordata.DonorTasks{ YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, ChooseReplacementAttorneys: actor.TaskCompleted, @@ -224,13 +225,13 @@ func TestPostDoYouWantToNotifyPeopleWhenStoreErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ DoYouWantToNotifyPeople: form.Yes, - Tasks: actor.DonorTasks{PeopleToNotify: actor.TaskInProgress}, + Tasks: donordata.DonorTasks{PeopleToNotify: actor.TaskInProgress}, }). Return(expectedError) - err := DoYouWantToNotifyPeople(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := DoYouWantToNotifyPeople(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } @@ -247,7 +248,7 @@ func TestPostDoYouWantToNotifyPeopleWhenValidationErrors(t *testing.T) { })). Return(nil) - err := DoYouWantToNotifyPeople(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := DoYouWantToNotifyPeople(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/enter_correspondent_address.go b/internal/donor/donorpage/enter_correspondent_address.go index b1bfd4e112..e6082388e0 100644 --- a/internal/donor/donorpage/enter_correspondent_address.go +++ b/internal/donor/donorpage/enter_correspondent_address.go @@ -6,13 +6,14 @@ import ( "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" ) func EnterCorrespondentAddress(logger Logger, tmpl template.Template, addressClient AddressClient, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { data := newChooseAddressData( appData, "correspondent", diff --git a/internal/donor/donorpage/enter_correspondent_address_test.go b/internal/donor/donorpage/enter_correspondent_address_test.go index 72fdb843b8..4dd5738351 100644 --- a/internal/donor/donorpage/enter_correspondent_address_test.go +++ b/internal/donor/donorpage/enter_correspondent_address_test.go @@ -9,6 +9,7 @@ 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/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" @@ -32,8 +33,8 @@ func TestGetEnterCorrespondentAddress(t *testing.T) { }). Return(nil) - err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Correspondent: actor.Correspondent{ + err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Correspondent: donordata.Correspondent{ FirstNames: "John", LastName: "Smith", }, @@ -65,8 +66,8 @@ func TestGetEnterCorrespondentAddressFromStore(t *testing.T) { }). Return(nil) - err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Correspondent: actor.Correspondent{ + err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Correspondent: donordata.Correspondent{ Address: address, }, }) @@ -95,7 +96,7 @@ func TestGetEnterCorrespondentAddressManual(t *testing.T) { }). Return(nil) - err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -117,7 +118,7 @@ func TestGetEnterCorrespondentAddressWhenTemplateErrors(t *testing.T) { }). Return(expectedError) - err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -140,18 +141,18 @@ func TestPostEnterCorrespondentAddressManual(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Correspondent: actor.Correspondent{ + Correspondent: donordata.Correspondent{ Address: testAddress, }, - Tasks: actor.DonorTasks{ + Tasks: donordata.DonorTasks{ AddCorrespondent: actor.TaskCompleted, }, }). Return(nil) - err := EnterCorrespondentAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := EnterCorrespondentAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", }) resp := w.Result() @@ -180,7 +181,7 @@ func TestPostEnterCorrespondentAddressManualWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := EnterCorrespondentAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := EnterCorrespondentAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } @@ -201,21 +202,21 @@ func TestPostEnterCorrespondentAddressManualFromStore(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Correspondent: actor.Correspondent{ + Correspondent: donordata.Correspondent{ FirstNames: "John", Address: testAddress, }, - Tasks: actor.DonorTasks{ + Tasks: donordata.DonorTasks{ AddCorrespondent: actor.TaskCompleted, }, }). Return(nil) - err := EnterCorrespondentAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := EnterCorrespondentAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Correspondent: actor.Correspondent{ + Correspondent: donordata.Correspondent{ FirstNames: "John", Address: place.Address{Line1: "abc"}, }, @@ -260,7 +261,7 @@ func TestPostEnterCorrespondentAddressManualWhenValidationError(t *testing.T) { }). Return(nil) - err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -301,7 +302,7 @@ func TestPostEnterCorrespondentAddressSelect(t *testing.T) { }). Return(nil) - err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -344,7 +345,7 @@ func TestPostEnterCorrespondentAddressSelectWhenValidationError(t *testing.T) { }). Return(nil) - err := EnterCorrespondentAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := EnterCorrespondentAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -386,7 +387,7 @@ func TestPostEnterCorrespondentAddressLookup(t *testing.T) { }). Return(nil) - err := EnterCorrespondentAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := EnterCorrespondentAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -429,7 +430,7 @@ func TestPostEnterCorrespondentAddressLookupError(t *testing.T) { }). Return(nil) - err := EnterCorrespondentAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := EnterCorrespondentAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -477,7 +478,7 @@ func TestPostEnterCorrespondentAddressInvalidPostcodeError(t *testing.T) { }). Return(nil) - err := EnterCorrespondentAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := EnterCorrespondentAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -519,7 +520,7 @@ func TestPostEnterCorrespondentAddressValidPostcodeNoAddresses(t *testing.T) { }). Return(nil) - err := EnterCorrespondentAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := EnterCorrespondentAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -550,7 +551,7 @@ func TestPostEnterCorrespondentAddressLookupWhenValidationError(t *testing.T) { }). Return(nil) - err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -581,8 +582,8 @@ func TestPostEnterCorrespondentAddressReuse(t *testing.T) { }). Return(nil) - err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{Address: place.Address{Line1: "donor lane"}}, + err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{Address: place.Address{Line1: "donor lane"}}, }) resp := w.Result() @@ -600,7 +601,7 @@ func TestPostEnterCorrespondentAddressReuseSelect(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - updatedCorrespondent := actor.Correspondent{ + updatedCorrespondent := donordata.Correspondent{ Address: place.Address{ Line1: "a", Line2: "b", @@ -613,14 +614,14 @@ func TestPostEnterCorrespondentAddressReuseSelect(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", Correspondent: updatedCorrespondent, - Tasks: actor.DonorTasks{AddCorrespondent: actor.TaskCompleted}, + Tasks: donordata.DonorTasks{AddCorrespondent: actor.TaskCompleted}, }). Return(nil) - err := EnterCorrespondentAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := EnterCorrespondentAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", }) resp := w.Result() @@ -645,7 +646,7 @@ func TestPostEnterCorrespondentAddressReuseSelectWhenError(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := EnterCorrespondentAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := EnterCorrespondentAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", }) @@ -677,8 +678,8 @@ func TestPostEnterCorrespondentAddressReuseSelectWhenValidationError(t *testing. }). Return(nil) - err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{Address: place.Address{Line1: "donor lane"}}, + err := EnterCorrespondentAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + 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 038c602384..9da2bd88d1 100644 --- a/internal/donor/donorpage/enter_correspondent_details.go +++ b/internal/donor/donorpage/enter_correspondent_details.go @@ -5,6 +5,7 @@ import ( "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" @@ -19,7 +20,7 @@ type enterCorrespondentDetailsData struct { } func EnterCorrespondentDetails(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { data := &enterCorrespondentDetailsData{ App: appData, Form: &enterCorrespondentDetailsForm{ @@ -79,7 +80,7 @@ type enterCorrespondentDetailsForm struct { DonorFullName string } -func readEnterCorrespondentDetailsForm(r *http.Request, donor actor.Donor) *enterCorrespondentDetailsForm { +func readEnterCorrespondentDetailsForm(r *http.Request, donor donordata.Donor) *enterCorrespondentDetailsForm { email := page.PostFormString(r, "email") return &enterCorrespondentDetailsForm{ diff --git a/internal/donor/donorpage/enter_correspondent_details_test.go b/internal/donor/donorpage/enter_correspondent_details_test.go index 2147d45ea1..1748d4932a 100644 --- a/internal/donor/donorpage/enter_correspondent_details_test.go +++ b/internal/donor/donorpage/enter_correspondent_details_test.go @@ -8,6 +8,7 @@ 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/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" @@ -28,7 +29,7 @@ func TestGetEnterCorrespondentDetails(t *testing.T) { }). Return(nil) - err := EnterCorrespondentDetails(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := EnterCorrespondentDetails(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -50,8 +51,8 @@ func TestGetEnterCorrespondentDetailsFromStore(t *testing.T) { }). Return(nil) - err := EnterCorrespondentDetails(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Correspondent: actor.Correspondent{ + err := EnterCorrespondentDetails(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Correspondent: donordata.Correspondent{ FirstNames: "John", }, }) @@ -70,7 +71,7 @@ func TestGetEnterCorrespondentDetailsWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := EnterCorrespondentDetails(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := EnterCorrespondentDetails(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -91,22 +92,22 @@ func TestPostEnterCorrespondentDetails(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{FirstNames: "John", LastName: "Smith"}, - Correspondent: actor.Correspondent{ + Donor: donordata.Donor{FirstNames: "John", LastName: "Smith"}, + Correspondent: donordata.Correspondent{ FirstNames: "John", LastName: "Doe", Email: "email@example.com", WantAddress: form.No, }, - Tasks: actor.DonorTasks{AddCorrespondent: actor.TaskCompleted}, + Tasks: donordata.DonorTasks{AddCorrespondent: actor.TaskCompleted}, }). Return(nil) - err := EnterCorrespondentDetails(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := EnterCorrespondentDetails(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{FirstNames: "John", LastName: "Smith"}, + Donor: donordata.Donor{FirstNames: "John", LastName: "Smith"}, }) resp := w.Result() @@ -129,22 +130,22 @@ func TestPostEnterCorrespondentDetailsWhenWantsAddress(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{FirstNames: "John", LastName: "Smith"}, - Correspondent: actor.Correspondent{ + Donor: donordata.Donor{FirstNames: "John", LastName: "Smith"}, + Correspondent: donordata.Correspondent{ FirstNames: "John", LastName: "Doe", Email: "email@example.com", WantAddress: form.Yes, }, - Tasks: actor.DonorTasks{AddCorrespondent: actor.TaskInProgress}, + Tasks: donordata.DonorTasks{AddCorrespondent: actor.TaskInProgress}, }). Return(nil) - err := EnterCorrespondentDetails(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := EnterCorrespondentDetails(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{FirstNames: "John", LastName: "Smith"}, + Donor: donordata.Donor{FirstNames: "John", LastName: "Smith"}, }) resp := w.Result() @@ -171,8 +172,8 @@ func TestPostEnterCorrespondentDetailsWhenValidationError(t *testing.T) { })). Return(nil) - err := EnterCorrespondentDetails(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{ + err := EnterCorrespondentDetails(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{ FirstNames: "John", LastName: "Doe", }, @@ -200,8 +201,8 @@ func TestPostEnterCorrespondentDetailsWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := EnterCorrespondentDetails(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{ + err := EnterCorrespondentDetails(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{ FirstNames: "John", Address: place.Address{Line1: "abc"}, }, @@ -222,7 +223,7 @@ func TestReadEnterCorrespondentDetailsForm(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - result := readEnterCorrespondentDetailsForm(r, actor.Donor{FirstNames: "Dave", LastName: "Smith", Email: "email@example.com"}) + result := readEnterCorrespondentDetailsForm(r, donordata.Donor{FirstNames: "Dave", LastName: "Smith", Email: "email@example.com"}) assert.Equal("John", result.FirstNames) assert.Equal("Doe", result.LastName) diff --git a/internal/donor/donorpage/enter_replacement_trust_corporation.go b/internal/donor/donorpage/enter_replacement_trust_corporation.go index ebb1d36a77..8b0fa6db40 100644 --- a/internal/donor/donorpage/enter_replacement_trust_corporation.go +++ b/internal/donor/donorpage/enter_replacement_trust_corporation.go @@ -4,7 +4,7 @@ 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/validation" ) @@ -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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 b4e4394294..1503fbc7fa 100644 --- a/internal/donor/donorpage/enter_replacement_trust_corporation_address.go +++ b/internal/donor/donorpage/enter_replacement_trust_corporation_address.go @@ -4,14 +4,14 @@ 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" ) func EnterReplacementTrustCorporationAddress(logger Logger, tmpl template.Template, addressClient AddressClient, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 d039cd2c2d..8a920eeebb 100644 --- a/internal/donor/donorpage/enter_replacement_trust_corporation_address_test.go +++ b/internal/donor/donorpage/enter_replacement_trust_corporation_address_test.go @@ -9,6 +9,7 @@ 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/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" @@ -31,8 +32,8 @@ func TestGetEnterReplacementTrustCorporationAddress(t *testing.T) { }). Return(nil) - err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - ReplacementAttorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{Name: "a"}}, + err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{Name: "a"}}, }) resp := w.Result() @@ -58,8 +59,8 @@ func TestGetEnterReplacementTrustCorporationAddressManual(t *testing.T) { }). Return(nil) - err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - ReplacementAttorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{}}, + err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -81,8 +82,8 @@ func TestGetEnterReplacementTrustCorporationAddressWhenTemplateErrors(t *testing }). Return(expectedError) - err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - ReplacementAttorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{}}, + err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -106,19 +107,19 @@ func TestPostEnterReplacementTrustCorporationAddressManual(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Tasks: actor.DonorTasks{ChooseReplacementAttorneys: actor.TaskCompleted}, - ReplacementAttorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{ + Tasks: donordata.DonorTasks{ChooseReplacementAttorneys: actor.TaskCompleted}, + ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{ Name: "a", Address: testAddress, }}, }). Return(nil) - err := EnterReplacementTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := EnterReplacementTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - ReplacementAttorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{ + ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{ Name: "a", Address: place.Address{}, }}, @@ -149,8 +150,8 @@ func TestPostEnterReplacementTrustCorporationAddressManualWhenStoreErrors(t *tes Put(r.Context(), mock.Anything). Return(expectedError) - err := EnterReplacementTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ - ReplacementAttorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{}}, + err := EnterReplacementTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) assert.Equal(t, expectedError, err) @@ -172,19 +173,19 @@ func TestPostEnterReplacementTrustCorporationAddressManualFromStore(t *testing.T donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Tasks: actor.DonorTasks{ChooseReplacementAttorneys: actor.TaskCompleted}, - ReplacementAttorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{ + Tasks: donordata.DonorTasks{ChooseReplacementAttorneys: actor.TaskCompleted}, + ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{ Name: "John", Address: testAddress, }}, }). Return(nil) - err := EnterReplacementTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := EnterReplacementTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - ReplacementAttorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{ + ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{ Name: "John", Address: place.Address{Line1: "abc"}, }}, @@ -230,8 +231,8 @@ func TestPostEnterReplacementTrustCorporationAddressManualWhenValidationError(t }). Return(nil) - err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - ReplacementAttorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{}}, + err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -265,8 +266,8 @@ func TestPostEnterReplacementTrustCorporationAddressPostcodeSelect(t *testing.T) }). Return(nil) - err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - ReplacementAttorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{}}, + err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -309,8 +310,8 @@ func TestPostEnterReplacementTrustCorporationAddressPostcodeSelectWhenValidation }). Return(nil) - err := EnterReplacementTrustCorporationAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - ReplacementAttorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{}}, + err := EnterReplacementTrustCorporationAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -352,8 +353,8 @@ func TestPostEnterReplacementTrustCorporationPostcodeLookup(t *testing.T) { }). Return(nil) - err := EnterReplacementTrustCorporationAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - ReplacementAttorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{}}, + err := EnterReplacementTrustCorporationAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -396,8 +397,8 @@ func TestPostEnterReplacementTrustCorporationPostcodeLookupError(t *testing.T) { }). Return(nil) - err := EnterReplacementTrustCorporationAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - ReplacementAttorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{}}, + err := EnterReplacementTrustCorporationAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -445,8 +446,8 @@ func TestPostEnterReplacementTrustCorporationAddressPostcodeLookupInvalidPostcod }). Return(nil) - err := EnterReplacementTrustCorporationAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - ReplacementAttorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{}}, + err := EnterReplacementTrustCorporationAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -486,8 +487,8 @@ func TestPostEnterReplacementTrustCorporationAddressPostcodeLookupValidPostcodeN }). Return(nil) - err := EnterReplacementTrustCorporationAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - ReplacementAttorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{}}, + err := EnterReplacementTrustCorporationAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -518,8 +519,8 @@ func TestPostEnterReplacementTrustCorporationAddressPostcodeLookupWhenValidation }). Return(nil) - err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - ReplacementAttorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{}}, + err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -550,9 +551,9 @@ func TestPostEnterReplacementTrustCorporationAddressReuse(t *testing.T) { }). Return(nil) - err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{Address: place.Address{Line1: "donor lane"}}, - ReplacementAttorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{}}, + err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{Address: place.Address{Line1: "donor lane"}}, + ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -570,7 +571,7 @@ func TestPostEnterReplacementTrustCorporationAddressReuseSelect(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - updatedTrustCorporation := actor.TrustCorporation{ + updatedTrustCorporation := donordata.TrustCorporation{ Name: "a", Address: place.Address{ Line1: "a", @@ -584,16 +585,16 @@ func TestPostEnterReplacementTrustCorporationAddressReuseSelect(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - ReplacementAttorneys: actor.Attorneys{TrustCorporation: updatedTrustCorporation}, - Tasks: actor.DonorTasks{ChooseReplacementAttorneys: actor.TaskCompleted}, + ReplacementAttorneys: donordata.Attorneys{TrustCorporation: updatedTrustCorporation}, + Tasks: donordata.DonorTasks{ChooseReplacementAttorneys: actor.TaskCompleted}, }). Return(nil) - err := EnterReplacementTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := EnterReplacementTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - ReplacementAttorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{ + ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{ Name: "a", }}, }) @@ -628,9 +629,9 @@ func TestPostEnterReplacementTrustCorporationAddressReuseSelectWhenValidationErr }). Return(nil) - err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{Address: place.Address{Line1: "donor lane"}}, - ReplacementAttorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{}}, + err := EnterReplacementTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{Address: place.Address{Line1: "donor lane"}}, + ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -670,9 +671,9 @@ func TestPostEnterReplacementTrustCorporationAddressManuallyFromAnotherPage(t *t r, _ := http.NewRequest(http.MethodPost, tc.requestUrl, strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - donor := &actor.DonorProvidedDetails{ + donor := &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - ReplacementAttorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{ + ReplacementAttorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{ Address: place.Address{ Line1: "a", TownOrCity: "b", diff --git a/internal/donor/donorpage/enter_replacement_trust_corporation_test.go b/internal/donor/donorpage/enter_replacement_trust_corporation_test.go index 9ddf624a0e..4ad4118f32 100644 --- a/internal/donor/donorpage/enter_replacement_trust_corporation_test.go +++ b/internal/donor/donorpage/enter_replacement_trust_corporation_test.go @@ -8,6 +8,7 @@ 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/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" @@ -26,7 +27,7 @@ func TestGetEnterReplacementTrustCorporation(t *testing.T) { }). Return(nil) - err := EnterReplacementTrustCorporation(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := EnterReplacementTrustCorporation(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -45,7 +46,7 @@ func TestGetEnterReplacementTrustCorporationWhenTemplateErrors(t *testing.T) { }). Return(expectedError) - err := EnterReplacementTrustCorporation(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := EnterReplacementTrustCorporation(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -65,22 +66,22 @@ func TestPostEnterReplacementTrustCorporation(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - ReplacementAttorneys: actor.Attorneys{ - TrustCorporation: actor.TrustCorporation{ + ReplacementAttorneys: donordata.Attorneys{ + TrustCorporation: donordata.TrustCorporation{ Name: "Co co.", CompanyNumber: "453345", Email: "name@example.com", }, }, - Tasks: actor.DonorTasks{ + Tasks: donordata.DonorTasks{ ChooseReplacementAttorneys: actor.TaskInProgress, }, }). Return(nil) - err := EnterReplacementTrustCorporation(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := EnterReplacementTrustCorporation(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", }) resp := w.Result() @@ -107,8 +108,8 @@ func TestPostEnterReplacementTrustCorporationWhenValidationError(t *testing.T) { })). Return(nil) - err := EnterReplacementTrustCorporation(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{FirstNames: "Jane", LastName: "Doe"}, + err := EnterReplacementTrustCorporation(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, }) resp := w.Result() @@ -132,7 +133,7 @@ func TestPostEnterReplacementTrustCorporationWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := EnterReplacementTrustCorporation(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := EnterReplacementTrustCorporation(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } diff --git a/internal/donor/donorpage/enter_trust_corporation.go b/internal/donor/donorpage/enter_trust_corporation.go index 9cd4fd8429..936c58d10b 100644 --- a/internal/donor/donorpage/enter_trust_corporation.go +++ b/internal/donor/donorpage/enter_trust_corporation.go @@ -4,7 +4,7 @@ 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/validation" ) @@ -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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 826d7ea2a4..7b3b40cd7f 100644 --- a/internal/donor/donorpage/enter_trust_corporation_address.go +++ b/internal/donor/donorpage/enter_trust_corporation_address.go @@ -4,14 +4,14 @@ 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" ) func EnterTrustCorporationAddress(logger Logger, tmpl template.Template, addressClient AddressClient, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 17fdf2c0e1..3d129d1400 100644 --- a/internal/donor/donorpage/enter_trust_corporation_address_test.go +++ b/internal/donor/donorpage/enter_trust_corporation_address_test.go @@ -9,6 +9,7 @@ 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/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" @@ -31,8 +32,8 @@ func TestGetEnterTrustCorporationAddress(t *testing.T) { }). Return(nil) - err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Attorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{Name: "a"}}, + err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{Name: "a"}}, }) resp := w.Result() @@ -58,8 +59,8 @@ func TestGetEnterTrustCorporationAddressManual(t *testing.T) { }). Return(nil) - err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Attorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{}}, + err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -81,8 +82,8 @@ func TestGetEnterTrustCorporationAddressWhenTemplateErrors(t *testing.T) { }). Return(expectedError) - err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Attorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{}}, + err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -106,19 +107,19 @@ func TestPostEnterTrustCorporationAddressManual(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Tasks: actor.DonorTasks{ChooseAttorneys: actor.TaskCompleted}, - Attorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{ + Tasks: donordata.DonorTasks{ChooseAttorneys: actor.TaskCompleted}, + Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{ Name: "a", Address: testAddress, }}, }). Return(nil) - err := EnterTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := EnterTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Attorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{ + Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{ Name: "a", Address: place.Address{}, }}, @@ -149,8 +150,8 @@ func TestPostEnterTrustCorporationAddressManualWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := EnterTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ - Attorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{}}, + err := EnterTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) assert.Equal(t, expectedError, err) @@ -172,19 +173,19 @@ func TestPostEnterTrustCorporationAddressManualFromStore(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Tasks: actor.DonorTasks{ChooseAttorneys: actor.TaskCompleted}, - Attorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{ + Tasks: donordata.DonorTasks{ChooseAttorneys: actor.TaskCompleted}, + Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{ Name: "John", Address: testAddress, }}, }). Return(nil) - err := EnterTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := EnterTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Attorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{ + Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{ Name: "John", Address: place.Address{Line1: "abc"}, }}, @@ -230,8 +231,8 @@ func TestPostEnterTrustCorporationAddressManualWhenValidationError(t *testing.T) }). Return(nil) - err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Attorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{}}, + err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -265,8 +266,8 @@ func TestPostEnterTrustCorporationAddressPostcodeSelect(t *testing.T) { }). Return(nil) - err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Attorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{}}, + err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -309,8 +310,8 @@ func TestPostEnterTrustCorporationAddressPostcodeSelectWhenValidationError(t *te }). Return(nil) - err := EnterTrustCorporationAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Attorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{}}, + err := EnterTrustCorporationAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -352,8 +353,8 @@ func TestPostEnterTrustCorporationPostcodeLookup(t *testing.T) { }). Return(nil) - err := EnterTrustCorporationAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Attorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{}}, + err := EnterTrustCorporationAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -396,8 +397,8 @@ func TestPostEnterTrustCorporationPostcodeLookupError(t *testing.T) { }). Return(nil) - err := EnterTrustCorporationAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Attorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{}}, + err := EnterTrustCorporationAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -445,8 +446,8 @@ func TestPostEnterTrustCorporationAddressPostcodeLookupInvalidPostcodeError(t *t }). Return(nil) - err := EnterTrustCorporationAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Attorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{}}, + err := EnterTrustCorporationAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -486,8 +487,8 @@ func TestPostEnterTrustCorporationAddressPostcodeLookupValidPostcodeNoAddresses( }). Return(nil) - err := EnterTrustCorporationAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Attorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{}}, + err := EnterTrustCorporationAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -518,8 +519,8 @@ func TestPostEnterTrustCorporationAddressPostcodeLookupWhenValidationError(t *te }). Return(nil) - err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Attorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{}}, + err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -550,9 +551,9 @@ func TestPostEnterTrustCorporationAddressReuse(t *testing.T) { }). Return(nil) - err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{Address: place.Address{Line1: "donor lane"}}, - Attorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{}}, + err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{Address: place.Address{Line1: "donor lane"}}, + Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -570,7 +571,7 @@ func TestPostEnterTrustCorporationAddressReuseSelect(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - updatedTrustCorporation := actor.TrustCorporation{ + updatedTrustCorporation := donordata.TrustCorporation{ Name: "a", Address: place.Address{ Line1: "a", @@ -584,16 +585,16 @@ func TestPostEnterTrustCorporationAddressReuseSelect(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Attorneys: actor.Attorneys{TrustCorporation: updatedTrustCorporation}, - Tasks: actor.DonorTasks{ChooseAttorneys: actor.TaskCompleted}, + Attorneys: donordata.Attorneys{TrustCorporation: updatedTrustCorporation}, + Tasks: donordata.DonorTasks{ChooseAttorneys: actor.TaskCompleted}, }). Return(nil) - err := EnterTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := EnterTrustCorporationAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Attorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{ + Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{ Name: "a", }}, }) @@ -628,9 +629,9 @@ func TestPostEnterTrustCorporationAddressReuseSelectWhenValidationError(t *testi }). Return(nil) - err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{Address: place.Address{Line1: "donor lane"}}, - Attorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{}}, + err := EnterTrustCorporationAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{Address: place.Address{Line1: "donor lane"}}, + Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{}}, }) resp := w.Result() @@ -670,9 +671,9 @@ func TestPostEnterTrustCorporationAddressManuallyFromAnotherPage(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, tc.requestUrl, strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - donor := &actor.DonorProvidedDetails{ + donor := &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Attorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{ + Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{ Address: place.Address{ Line1: "a", TownOrCity: "b", diff --git a/internal/donor/donorpage/enter_trust_corporation_test.go b/internal/donor/donorpage/enter_trust_corporation_test.go index 038ce78730..ca0d1320d2 100644 --- a/internal/donor/donorpage/enter_trust_corporation_test.go +++ b/internal/donor/donorpage/enter_trust_corporation_test.go @@ -8,6 +8,7 @@ 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/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" @@ -26,7 +27,7 @@ func TestGetEnterTrustCorporation(t *testing.T) { }). Return(nil) - err := EnterTrustCorporation(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := EnterTrustCorporation(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -45,7 +46,7 @@ func TestGetEnterTrustCorporationWhenTemplateErrors(t *testing.T) { }). Return(expectedError) - err := EnterTrustCorporation(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := EnterTrustCorporation(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -65,18 +66,18 @@ func TestPostEnterTrustCorporation(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Attorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{ + Attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{ Name: "Co co.", CompanyNumber: "453345", Email: "name@example.com", }}, - Tasks: actor.DonorTasks{ChooseAttorneys: actor.TaskInProgress}, + Tasks: donordata.DonorTasks{ChooseAttorneys: actor.TaskInProgress}, }). Return(nil) - err := EnterTrustCorporation(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := EnterTrustCorporation(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", }) resp := w.Result() @@ -103,8 +104,8 @@ func TestPostEnterTrustCorporationWhenValidationError(t *testing.T) { })). Return(nil) - err := EnterTrustCorporation(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{FirstNames: "Jane", LastName: "Doe"}, + err := EnterTrustCorporation(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, }) resp := w.Result() @@ -128,7 +129,7 @@ func TestPostEnterTrustCorporationWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := EnterTrustCorporation(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := EnterTrustCorporation(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } diff --git a/internal/donor/donorpage/enter_voucher.go b/internal/donor/donorpage/enter_voucher.go index ab7140b6d4..43e40481f6 100644 --- a/internal/donor/donorpage/enter_voucher.go +++ b/internal/donor/donorpage/enter_voucher.go @@ -5,7 +5,7 @@ import ( "strings" "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/validation" ) @@ -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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 e249644dc9..598ad8db5f 100644 --- a/internal/donor/donorpage/enter_voucher_test.go +++ b/internal/donor/donorpage/enter_voucher_test.go @@ -7,7 +7,7 @@ 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/validation" "github.com/stretchr/testify/assert" @@ -26,7 +26,7 @@ func TestGetEnterVoucher(t *testing.T) { }). Return(nil) - err := EnterVoucher(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := EnterVoucher(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := EnterVoucher(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } @@ -59,11 +59,11 @@ func TestPostEnterVoucher(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{FirstNames: "Jane", LastName: "Doe"}, - CertificateProvider: actor.CertificateProvider{FirstNames: "Barry", LastName: "Bloggs"}, - Voucher: actor.Voucher{ + Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, + CertificateProvider: donordata.CertificateProvider{FirstNames: "Barry", LastName: "Bloggs"}, + Voucher: donordata.Voucher{ FirstNames: "John", LastName: "Bloggs", Email: "john@example.com", @@ -72,10 +72,10 @@ func TestPostEnterVoucher(t *testing.T) { }). Return(nil) - err := EnterVoucher(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := EnterVoucher(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{FirstNames: "Jane", LastName: "Doe"}, - CertificateProvider: actor.CertificateProvider{FirstNames: "Barry", LastName: "Bloggs"}, + Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, + CertificateProvider: donordata.CertificateProvider{FirstNames: "Barry", LastName: "Bloggs"}, }) resp := w.Result() @@ -105,11 +105,11 @@ func TestPostEnterVoucherWhenMatches(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{FirstNames: "Jane", LastName: "Doe"}, - CertificateProvider: actor.CertificateProvider{FirstNames: "Barry", LastName: "Bloggs"}, - Voucher: actor.Voucher{ + Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, + CertificateProvider: donordata.CertificateProvider{FirstNames: "Barry", LastName: "Bloggs"}, + Voucher: donordata.Voucher{ FirstNames: tc.First, LastName: tc.Last, Email: "jane@example.com", @@ -117,10 +117,10 @@ func TestPostEnterVoucherWhenMatches(t *testing.T) { }). Return(nil) - err := EnterVoucher(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := EnterVoucher(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{FirstNames: "Jane", LastName: "Doe"}, - CertificateProvider: actor.CertificateProvider{FirstNames: "Barry", LastName: "Bloggs"}, + Donor: donordata.Donor{FirstNames: "Jane", LastName: "Doe"}, + CertificateProvider: donordata.CertificateProvider{FirstNames: "Barry", LastName: "Bloggs"}, }) resp := w.Result() @@ -148,8 +148,8 @@ func TestPostEnterVoucherWhenValidationErrors(t *testing.T) { })). Return(nil) - err := EnterVoucher(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{FirstNames: "Jane", LastName: "Doe"}, + err := EnterVoucher(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + 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, &actor.DonorProvidedDetails{}) + err := EnterVoucher(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } diff --git a/internal/donor/donorpage/fee_denied.go b/internal/donor/donorpage/fee_denied.go index 51cd239f01..843ea688e4 100644 --- a/internal/donor/donorpage/fee_denied.go +++ b/internal/donor/donorpage/fee_denied.go @@ -4,19 +4,19 @@ 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/validation" ) type feeDeniedData struct { - Donor *actor.DonorProvidedDetails + Donor *donordata.DonorProvidedDetails 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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 17168727a1..ca7a42a8d3 100644 --- a/internal/donor/donorpage/fee_denied_test.go +++ b/internal/donor/donorpage/fee_denied_test.go @@ -5,7 +5,8 @@ import ( "net/http/httptest" "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/task" "github.com/stretchr/testify/assert" ) @@ -13,7 +14,7 @@ func TestGetFeeDenied(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &actor.DonorProvidedDetails{Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskDenied}} + donor := &donordata.DonorProvidedDetails{Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateDenied}} template := newMockTemplate(t) template.EXPECT(). @@ -31,7 +32,7 @@ func TestPostFeeDenied(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodPost, "/", nil) - donor := &actor.DonorProvidedDetails{Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskDenied}} + donor := &donordata.DonorProvidedDetails{Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateDenied}} payer := newMockHandler(t) payer.EXPECT(). @@ -49,7 +50,7 @@ func TestPostFeeDeniedWhenPayerError(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodPost, "/", nil) - donor := &actor.DonorProvidedDetails{Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskDenied}} + donor := &donordata.DonorProvidedDetails{Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateDenied}} payer := newMockHandler(t) payer.EXPECT(). diff --git a/internal/donor/donorpage/guidance.go b/internal/donor/donorpage/guidance.go index cf538c4c3a..f84a10d037 100644 --- a/internal/donor/donorpage/guidance.go +++ b/internal/donor/donorpage/guidance.go @@ -4,7 +4,7 @@ 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/validation" ) @@ -12,11 +12,11 @@ import ( type guidanceData struct { App page.AppData Errors validation.List - Donor *actor.DonorProvidedDetails + Donor *donordata.DonorProvidedDetails } func Guidance(tmpl template.Template) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { data := &guidanceData{ App: appData, Donor: donor, diff --git a/internal/donor/donorpage/guidance_test.go b/internal/donor/donorpage/guidance_test.go index c1675e1483..7e4a48e314 100644 --- a/internal/donor/donorpage/guidance_test.go +++ b/internal/donor/donorpage/guidance_test.go @@ -5,7 +5,7 @@ import ( "net/http/httptest" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" + "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/stretchr/testify/assert" ) @@ -14,7 +14,7 @@ func TestGuidance(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &actor.DonorProvidedDetails{} + donor := &donordata.DonorProvidedDetails{} 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: &actor.DonorProvidedDetails{}}). + Execute(w, &guidanceData{App: testAppData, Donor: &donordata.DonorProvidedDetails{}}). Return(expectedError) - err := Guidance(template.Execute)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := Guidance(template.Execute)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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 97d9bfb4e8..4017c219df 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 @@ -14,13 +14,13 @@ import ( type howDoYouKnowYourCertificateProviderData struct { App page.AppData Errors validation.List - CertificateProvider actor.CertificateProvider + CertificateProvider donordata.CertificateProvider Form *howDoYouKnowYourCertificateProviderForm Options donordata.CertificateProviderRelationshipOptions } func HowDoYouKnowYourCertificateProvider(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { data := &howDoYouKnowYourCertificateProviderData{ App: appData, CertificateProvider: donor.CertificateProvider, @@ -36,7 +36,7 @@ func HowDoYouKnowYourCertificateProvider(tmpl template.Template, donorStore Dono if data.Errors.None() { if data.Form.How.IsProfessionally() && donor.CertificateProvider.Relationship.IsPersonally() { - donor.CertificateProvider.RelationshipLength = actor.RelationshipLengthUnknown + donor.CertificateProvider.RelationshipLength = donordata.RelationshipLengthUnknown } if !donor.CertificateProvider.Relationship.Empty() && data.Form.How != donor.CertificateProvider.Relationship { @@ -63,7 +63,7 @@ func HowDoYouKnowYourCertificateProvider(tmpl template.Template, donorStore Dono } type howDoYouKnowYourCertificateProviderForm struct { - How actor.CertificateProviderRelationship + How donordata.CertificateProviderRelationship Error error } 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 87c9e997db..d8c2a3dec9 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 @@ -29,7 +29,7 @@ func TestGetHowDoYouKnowYourCertificateProvider(t *testing.T) { }). Return(nil) - err := HowDoYouKnowYourCertificateProvider(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := HowDoYouKnowYourCertificateProvider(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -40,8 +40,8 @@ func TestGetHowDoYouKnowYourCertificateProviderFromStore(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - certificateProvider := actor.CertificateProvider{ - Relationship: actor.Personally, + certificateProvider := donordata.CertificateProvider{ + Relationship: donordata.Personally, } template := newMockTemplate(t) @@ -49,12 +49,12 @@ func TestGetHowDoYouKnowYourCertificateProviderFromStore(t *testing.T) { Execute(w, &howDoYouKnowYourCertificateProviderData{ App: testAppData, CertificateProvider: certificateProvider, - Form: &howDoYouKnowYourCertificateProviderForm{How: actor.Personally}, + Form: &howDoYouKnowYourCertificateProviderForm{How: donordata.Personally}, Options: donordata.CertificateProviderRelationshipValues, }). Return(nil) - err := HowDoYouKnowYourCertificateProvider(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := HowDoYouKnowYourCertificateProvider(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ 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, &actor.DonorProvidedDetails{}) + err := HowDoYouKnowYourCertificateProvider(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -82,22 +82,22 @@ func TestGetHowDoYouKnowYourCertificateProviderWhenTemplateErrors(t *testing.T) func TestPostHowDoYouKnowYourCertificateProvider(t *testing.T) { testCases := map[string]struct { form url.Values - certificateProviderDetails actor.CertificateProvider + certificateProviderDetails donordata.CertificateProvider redirect page.LpaPath }{ "professionally": { - form: url.Values{"how": {actor.Professionally.String()}}, - certificateProviderDetails: actor.CertificateProvider{ + form: url.Values{"how": {donordata.Professionally.String()}}, + certificateProviderDetails: donordata.CertificateProvider{ FirstNames: "John", - Relationship: actor.Professionally, + Relationship: donordata.Professionally, }, redirect: page.Paths.HowWouldCertificateProviderPreferToCarryOutTheirRole, }, "personally": { - form: url.Values{"how": {actor.Personally.String()}}, - certificateProviderDetails: actor.CertificateProvider{ + form: url.Values{"how": {donordata.Personally.String()}}, + certificateProviderDetails: donordata.CertificateProvider{ FirstNames: "John", - Relationship: actor.Personally, + Relationship: donordata.Personally, }, redirect: page.Paths.HowLongHaveYouKnownCertificateProvider, }, @@ -111,20 +111,20 @@ func TestPostHowDoYouKnowYourCertificateProvider(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", CertificateProvider: tc.certificateProviderDetails, - Tasks: actor.DonorTasks{ + Tasks: donordata.DonorTasks{ YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, }, }). Return(nil) - err := HowDoYouKnowYourCertificateProvider(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := HowDoYouKnowYourCertificateProvider(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - CertificateProvider: actor.CertificateProvider{FirstNames: "John"}, - Tasks: actor.DonorTasks{ + CertificateProvider: donordata.CertificateProvider{FirstNames: "John"}, + Tasks: donordata.DonorTasks{ YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, }, @@ -141,32 +141,32 @@ func TestPostHowDoYouKnowYourCertificateProvider(t *testing.T) { func TestPostHowDoYouKnowYourCertificateProviderWhenSwitchingRelationship(t *testing.T) { testCases := map[string]struct { form url.Values - existingCertificateProviderDetails actor.CertificateProvider - updatedCertificateProviderDetails actor.CertificateProvider + existingCertificateProviderDetails donordata.CertificateProvider + updatedCertificateProviderDetails donordata.CertificateProvider redirect page.LpaPath taskState actor.TaskState }{ "personally to professionally": { - form: url.Values{"how": {actor.Professionally.String()}}, - existingCertificateProviderDetails: actor.CertificateProvider{ - RelationshipLength: actor.GreaterThanEqualToTwoYears, - Relationship: actor.Personally, + form: url.Values{"how": {donordata.Professionally.String()}}, + existingCertificateProviderDetails: donordata.CertificateProvider{ + RelationshipLength: donordata.GreaterThanEqualToTwoYears, + Relationship: donordata.Personally, Address: testAddress, }, - updatedCertificateProviderDetails: actor.CertificateProvider{ - Relationship: actor.Professionally, + updatedCertificateProviderDetails: donordata.CertificateProvider{ + Relationship: donordata.Professionally, Address: place.Address{}, }, redirect: page.Paths.HowWouldCertificateProviderPreferToCarryOutTheirRole, }, "professionally to personally": { - form: url.Values{"how": {actor.Personally.String()}}, - existingCertificateProviderDetails: actor.CertificateProvider{ - Relationship: actor.Professionally, + form: url.Values{"how": {donordata.Personally.String()}}, + existingCertificateProviderDetails: donordata.CertificateProvider{ + Relationship: donordata.Professionally, Address: testAddress, }, - updatedCertificateProviderDetails: actor.CertificateProvider{ - Relationship: actor.Personally, + updatedCertificateProviderDetails: donordata.CertificateProvider{ + Relationship: donordata.Personally, Address: place.Address{}, }, redirect: page.Paths.HowLongHaveYouKnownCertificateProvider, @@ -181,10 +181,10 @@ func TestPostHowDoYouKnowYourCertificateProviderWhenSwitchingRelationship(t *tes donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", CertificateProvider: tc.updatedCertificateProviderDetails, - Tasks: actor.DonorTasks{ + Tasks: donordata.DonorTasks{ YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, CertificateProvider: actor.TaskInProgress, @@ -192,10 +192,10 @@ func TestPostHowDoYouKnowYourCertificateProviderWhenSwitchingRelationship(t *tes }). Return(nil) - err := HowDoYouKnowYourCertificateProvider(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := HowDoYouKnowYourCertificateProvider(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", CertificateProvider: tc.existingCertificateProviderDetails, - Tasks: actor.DonorTasks{ + Tasks: donordata.DonorTasks{ YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, CertificateProvider: actor.TaskCompleted, @@ -212,7 +212,7 @@ func TestPostHowDoYouKnowYourCertificateProviderWhenSwitchingRelationship(t *tes func TestPostHowDoYouKnowYourCertificateProviderWhenStoreErrors(t *testing.T) { form := url.Values{ - "how": {actor.Personally.String()}, + "how": {donordata.Personally.String()}, } w := httptest.NewRecorder() @@ -224,7 +224,7 @@ func TestPostHowDoYouKnowYourCertificateProviderWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := HowDoYouKnowYourCertificateProvider(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := HowDoYouKnowYourCertificateProvider(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } @@ -241,7 +241,7 @@ func TestPostHowDoYouKnowYourCertificateProviderWhenValidationErrors(t *testing. })). Return(nil) - err := HowDoYouKnowYourCertificateProvider(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := HowDoYouKnowYourCertificateProvider(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -250,7 +250,7 @@ func TestPostHowDoYouKnowYourCertificateProviderWhenValidationErrors(t *testing. func TestReadHowDoYouKnowYourCertificateProviderForm(t *testing.T) { form := url.Values{ - "how": {actor.Personally.String()}, + "how": {donordata.Personally.String()}, } r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) @@ -258,7 +258,7 @@ func TestReadHowDoYouKnowYourCertificateProviderForm(t *testing.T) { result := readHowDoYouKnowYourCertificateProviderForm(r) - assert.Equal(t, actor.Personally, result.How) + assert.Equal(t, donordata.Personally, result.How) } func TestHowDoYouKnowYourCertificateProviderFormValidate(t *testing.T) { 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 df3ce116c0..06b10dd5d0 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 @@ -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/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -13,13 +12,13 @@ import ( type howLongHaveYouKnownCertificateProviderData struct { App page.AppData Errors validation.List - CertificateProvider actor.CertificateProvider - RelationshipLength actor.CertificateProviderRelationshipLength + CertificateProvider donordata.CertificateProvider + RelationshipLength donordata.CertificateProviderRelationshipLength Options donordata.CertificateProviderRelationshipLengthOptions } func HowLongHaveYouKnownCertificateProvider(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { data := &howLongHaveYouKnownCertificateProviderData{ App: appData, CertificateProvider: donor.CertificateProvider, @@ -32,7 +31,7 @@ func HowLongHaveYouKnownCertificateProvider(tmpl template.Template, donorStore D data.Errors = form.Validate() if data.Errors.None() { - if form.RelationshipLength == actor.LessThanTwoYears { + if form.RelationshipLength == donordata.LessThanTwoYears { return page.Paths.ChooseNewCertificateProvider.Redirect(w, r, appData, donor) } @@ -50,7 +49,7 @@ func HowLongHaveYouKnownCertificateProvider(tmpl template.Template, donorStore D } type howLongHaveYouKnownCertificateProviderForm struct { - RelationshipLength actor.CertificateProviderRelationshipLength + RelationshipLength donordata.CertificateProviderRelationshipLength Error error } 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 2d020c46ab..2003951c6e 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 @@ -29,7 +29,7 @@ func TestGetHowLongHaveYouKnownCertificateProvider(t *testing.T) { }). Return(nil) - err := HowLongHaveYouKnownCertificateProvider(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := HowLongHaveYouKnownCertificateProvider(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -40,19 +40,19 @@ func TestGetHowLongHaveYouKnownCertificateProviderFromStore(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - certificateProvider := actor.CertificateProvider{RelationshipLength: actor.GreaterThanEqualToTwoYears} + certificateProvider := donordata.CertificateProvider{RelationshipLength: donordata.GreaterThanEqualToTwoYears} template := newMockTemplate(t) template.EXPECT(). Execute(w, &howLongHaveYouKnownCertificateProviderData{ App: testAppData, CertificateProvider: certificateProvider, - RelationshipLength: actor.GreaterThanEqualToTwoYears, + RelationshipLength: donordata.GreaterThanEqualToTwoYears, Options: donordata.CertificateProviderRelationshipLengthValues, }). Return(nil) - err := HowLongHaveYouKnownCertificateProvider(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{CertificateProvider: certificateProvider}) + err := HowLongHaveYouKnownCertificateProvider(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{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, &actor.DonorProvidedDetails{}) + err := HowLongHaveYouKnownCertificateProvider(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -80,7 +80,7 @@ func TestGetHowLongHaveYouKnownCertificateProviderWhenTemplateErrors(t *testing. func TestPostHowLongHaveYouKnownCertificateProviderMoreThan2Years(t *testing.T) { form := url.Values{ - "relationship-length": {actor.GreaterThanEqualToTwoYears.String()}, + "relationship-length": {donordata.GreaterThanEqualToTwoYears.String()}, } w := httptest.NewRecorder() @@ -89,20 +89,20 @@ func TestPostHowLongHaveYouKnownCertificateProviderMoreThan2Years(t *testing.T) donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{FirstNames: "a", LastName: "b", Address: place.Address{Line1: "c"}, DateOfBirth: date.New("1990", "1", "1")}}}, - AttorneyDecisions: actor.AttorneyDecisions{How: actor.Jointly}, - CertificateProvider: actor.CertificateProvider{RelationshipLength: actor.GreaterThanEqualToTwoYears}, - Tasks: actor.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted}, + 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}, }). Return(nil) - err := HowLongHaveYouKnownCertificateProvider(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := HowLongHaveYouKnownCertificateProvider(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{FirstNames: "a", LastName: "b", Address: place.Address{Line1: "c"}, DateOfBirth: date.New("1990", "1", "1")}}}, - AttorneyDecisions: actor.AttorneyDecisions{How: actor.Jointly}, - Tasks: actor.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted}, + 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}, }) 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, &actor.DonorProvidedDetails{LpaID: "lpa-id"}) + err := HowLongHaveYouKnownCertificateProvider(nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) resp := w.Result() assert.Nil(t, err) @@ -130,7 +130,7 @@ func TestPostHowLongHaveYouKnownCertificateProviderLessThan2Years(t *testing.T) func TestPostHowLongHaveYouKnownCertificateProviderWhenStoreErrors(t *testing.T) { form := url.Values{ - "relationship-length": {actor.GreaterThanEqualToTwoYears.String()}, + "relationship-length": {donordata.GreaterThanEqualToTwoYears.String()}, } w := httptest.NewRecorder() @@ -142,7 +142,7 @@ func TestPostHowLongHaveYouKnownCertificateProviderWhenStoreErrors(t *testing.T) Put(r.Context(), mock.Anything). Return(expectedError) - err := HowLongHaveYouKnownCertificateProvider(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := HowLongHaveYouKnownCertificateProvider(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } @@ -161,7 +161,7 @@ func TestPostHowLongHaveYouKnownCertificateProviderWhenValidationErrors(t *testi }). Return(nil) - err := HowLongHaveYouKnownCertificateProvider(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := HowLongHaveYouKnownCertificateProvider(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -170,7 +170,7 @@ func TestPostHowLongHaveYouKnownCertificateProviderWhenValidationErrors(t *testi func TestReadHowLongHaveYouKnownCertificateProviderForm(t *testing.T) { form := url.Values{ - "relationship-length": {actor.GreaterThanEqualToTwoYears.String()}, + "relationship-length": {donordata.GreaterThanEqualToTwoYears.String()}, } r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) @@ -178,7 +178,7 @@ func TestReadHowLongHaveYouKnownCertificateProviderForm(t *testing.T) { result := readHowLongHaveYouKnownCertificateProviderForm(r) - assert.Equal(t, actor.GreaterThanEqualToTwoYears, result.RelationshipLength) + assert.Equal(t, donordata.GreaterThanEqualToTwoYears, result.RelationshipLength) } func TestHowLongHaveYouKnownCertificateProviderFormValidate(t *testing.T) { @@ -188,7 +188,7 @@ func TestHowLongHaveYouKnownCertificateProviderFormValidate(t *testing.T) { }{ "valid": { form: &howLongHaveYouKnownCertificateProviderForm{ - RelationshipLength: actor.GreaterThanEqualToTwoYears, + RelationshipLength: donordata.GreaterThanEqualToTwoYears, }, }, "invalid": { diff --git a/internal/donor/donorpage/how_should_attorneys_make_decisions.go b/internal/donor/donorpage/how_should_attorneys_make_decisions.go index d1ffdafb1b..9a0817ad25 100644 --- a/internal/donor/donorpage/how_should_attorneys_make_decisions.go +++ b/internal/donor/donorpage/how_should_attorneys_make_decisions.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/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -14,12 +13,12 @@ type howShouldAttorneysMakeDecisionsData struct { App page.AppData Errors validation.List Form *howShouldAttorneysMakeDecisionsForm - Donor *actor.DonorProvidedDetails + Donor *donordata.DonorProvidedDetails Options donordata.AttorneysActOptions } func HowShouldAttorneysMakeDecisions(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { data := &howShouldAttorneysMakeDecisionsData{ App: appData, Form: &howShouldAttorneysMakeDecisionsForm{ @@ -35,7 +34,7 @@ func HowShouldAttorneysMakeDecisions(tmpl template.Template, donorStore DonorSto data.Errors = data.Form.Validate() if data.Errors.None() { - donor.AttorneyDecisions = actor.MakeAttorneyDecisions( + donor.AttorneyDecisions = donordata.MakeAttorneyDecisions( donor.AttorneyDecisions, data.Form.DecisionsType, data.Form.DecisionsDetails) @@ -47,9 +46,9 @@ func HowShouldAttorneysMakeDecisions(tmpl template.Template, donorStore DonorSto } switch donor.AttorneyDecisions.How { - case actor.Jointly: + case donordata.Jointly: return page.Paths.BecauseYouHaveChosenJointly.Redirect(w, r, appData, donor) - case actor.JointlyForSomeSeverallyForOthers: + case donordata.JointlyForSomeSeverallyForOthers: return page.Paths.BecauseYouHaveChosenJointlyForSomeSeverallyForOthers.Redirect(w, r, appData, donor) default: return page.Paths.TaskList.Redirect(w, r, appData, donor) @@ -62,7 +61,7 @@ func HowShouldAttorneysMakeDecisions(tmpl template.Template, donorStore DonorSto } type howShouldAttorneysMakeDecisionsForm struct { - DecisionsType actor.AttorneysAct + DecisionsType donordata.AttorneysAct Error error DecisionsDetails string errorLabel string @@ -87,7 +86,7 @@ func (f *howShouldAttorneysMakeDecisionsForm) Validate() validation.List { errors.Error("decision-type", f.errorLabel, f.Error, validation.Selected()) - if f.DecisionsType == actor.JointlyForSomeSeverallyForOthers { + if f.DecisionsType == donordata.JointlyForSomeSeverallyForOthers { errors.String("mixed-details", f.detailsErrorLabel, f.DecisionsDetails, validation.Empty()) } 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 3c084a193d..051937bacc 100644 --- a/internal/donor/donorpage/how_should_attorneys_make_decisions_test.go +++ b/internal/donor/donorpage/how_should_attorneys_make_decisions_test.go @@ -24,12 +24,12 @@ func TestGetHowShouldAttorneysMakeDecisions(t *testing.T) { Execute(w, &howShouldAttorneysMakeDecisionsData{ App: testAppData, Form: &howShouldAttorneysMakeDecisionsForm{}, - Donor: &actor.DonorProvidedDetails{}, + Donor: &donordata.DonorProvidedDetails{}, Options: donordata.AttorneysActValues, }). Return(nil) - err := HowShouldAttorneysMakeDecisions(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := HowShouldAttorneysMakeDecisions(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -45,15 +45,15 @@ func TestGetHowShouldAttorneysMakeDecisionsFromStore(t *testing.T) { Execute(w, &howShouldAttorneysMakeDecisionsData{ App: testAppData, Form: &howShouldAttorneysMakeDecisionsForm{ - DecisionsType: actor.Jointly, + DecisionsType: donordata.Jointly, DecisionsDetails: "some decisions", }, - Donor: &actor.DonorProvidedDetails{AttorneyDecisions: actor.AttorneyDecisions{Details: "some decisions", How: actor.Jointly}}, + Donor: &donordata.DonorProvidedDetails{AttorneyDecisions: donordata.AttorneyDecisions{Details: "some decisions", How: donordata.Jointly}}, Options: donordata.AttorneysActValues, }). Return(nil) - err := HowShouldAttorneysMakeDecisions(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{AttorneyDecisions: actor.AttorneyDecisions{Details: "some decisions", How: actor.Jointly}}) + err := HowShouldAttorneysMakeDecisions(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{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, &actor.DonorProvidedDetails{}) + err := HowShouldAttorneysMakeDecisions(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -78,7 +78,7 @@ func TestGetHowShouldAttorneysMakeDecisionsWhenTemplateErrors(t *testing.T) { func TestPostHowShouldAttorneysMakeDecisions(t *testing.T) { form := url.Values{ - "decision-type": {actor.JointlyAndSeverally.String()}, + "decision-type": {donordata.JointlyAndSeverally.String()}, "mixed-details": {""}, } @@ -86,21 +86,21 @@ func TestPostHowShouldAttorneysMakeDecisions(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - attorneys := actor.Attorneys{Attorneys: []actor.Attorney{{FirstNames: "a", Address: testAddress}, {FirstNames: "b", Address: testAddress}}} + attorneys := donordata.Attorneys{Attorneys: []donordata.Attorney{{FirstNames: "a", Address: testAddress}, {FirstNames: "b", Address: testAddress}}} donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", Attorneys: attorneys, - AttorneyDecisions: actor.AttorneyDecisions{How: actor.JointlyAndSeverally}, - Tasks: actor.DonorTasks{ChooseAttorneys: actor.TaskCompleted}, + AttorneyDecisions: donordata.AttorneyDecisions{How: donordata.JointlyAndSeverally}, + Tasks: donordata.DonorTasks{ChooseAttorneys: actor.TaskCompleted}, }). Return(nil) template := newMockTemplate(t) - err := HowShouldAttorneysMakeDecisions(template.Execute, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id", Attorneys: attorneys}) + err := HowShouldAttorneysMakeDecisions(template.Execute, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", Attorneys: attorneys}) resp := w.Result() assert.Nil(t, err) @@ -110,29 +110,29 @@ func TestPostHowShouldAttorneysMakeDecisions(t *testing.T) { func TestPostHowShouldAttorneysMakeDecisionsFromStore(t *testing.T) { testCases := map[string]struct { - existingType actor.AttorneysAct + existingType donordata.AttorneysAct existingDetails string - updatedType actor.AttorneysAct + updatedType donordata.AttorneysAct updatedDetails string formType string formDetails string redirect page.LpaPath }{ "existing details not set": { - existingType: actor.JointlyAndSeverally, + existingType: donordata.JointlyAndSeverally, existingDetails: "", - updatedType: actor.JointlyForSomeSeverallyForOthers, + updatedType: donordata.JointlyForSomeSeverallyForOthers, updatedDetails: "some details", - formType: actor.JointlyForSomeSeverallyForOthers.String(), + formType: donordata.JointlyForSomeSeverallyForOthers.String(), formDetails: "some details", redirect: page.Paths.BecauseYouHaveChosenJointlyForSomeSeverallyForOthers, }, "existing details set": { - existingType: actor.JointlyForSomeSeverallyForOthers, + existingType: donordata.JointlyForSomeSeverallyForOthers, existingDetails: "some details", - updatedType: actor.Jointly, + updatedType: donordata.Jointly, updatedDetails: "", - formType: actor.Jointly.String(), + formType: donordata.Jointly.String(), formDetails: "some details", redirect: page.Paths.BecauseYouHaveChosenJointly, }, @@ -151,20 +151,20 @@ func TestPostHowShouldAttorneysMakeDecisionsFromStore(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{FirstNames: "a", Address: testAddress}, {FirstNames: "b", Address: testAddress}}}, - AttorneyDecisions: actor.AttorneyDecisions{Details: tc.updatedDetails, How: tc.updatedType}, - Tasks: actor.DonorTasks{ChooseAttorneys: actor.TaskCompleted}, + 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}, }). Return(nil) template := newMockTemplate(t) - err := HowShouldAttorneysMakeDecisions(template.Execute, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := HowShouldAttorneysMakeDecisions(template.Execute, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{FirstNames: "a", Address: testAddress}, {FirstNames: "b", Address: testAddress}}}, - AttorneyDecisions: actor.AttorneyDecisions{Details: tc.existingDetails, How: tc.existingType}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{FirstNames: "a", Address: testAddress}, {FirstNames: "b", Address: testAddress}}}, + AttorneyDecisions: donordata.AttorneyDecisions{Details: tc.existingDetails, How: tc.existingType}, }) resp := w.Result() @@ -191,7 +191,7 @@ func TestPostHowShouldAttorneysMakeDecisionsWhenValidationErrors(t *testing.T) { })). Return(nil) - err := HowShouldAttorneysMakeDecisions(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := HowShouldAttorneysMakeDecisions(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -200,7 +200,7 @@ func TestPostHowShouldAttorneysMakeDecisionsWhenValidationErrors(t *testing.T) { func TestPostHowShouldAttorneysMakeDecisionsErrorOnPutStore(t *testing.T) { form := url.Values{ - "decision-type": {actor.JointlyAndSeverally.String()}, + "decision-type": {donordata.JointlyAndSeverally.String()}, "mixed-details": {""}, } @@ -215,7 +215,7 @@ func TestPostHowShouldAttorneysMakeDecisionsErrorOnPutStore(t *testing.T) { template := newMockTemplate(t) - err := HowShouldAttorneysMakeDecisions(template.Execute, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := HowShouldAttorneysMakeDecisions(template.Execute, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -234,7 +234,7 @@ func TestHowShouldAttorneysMakeDecisionsFormValidate(t *testing.T) { }, "valid with detail": { form: &howShouldAttorneysMakeDecisionsForm{ - DecisionsType: actor.JointlyForSomeSeverallyForOthers, + DecisionsType: donordata.JointlyForSomeSeverallyForOthers, DecisionsDetails: "some details", errorLabel: "xyz", }, @@ -248,7 +248,7 @@ func TestHowShouldAttorneysMakeDecisionsFormValidate(t *testing.T) { }, "missing decision detail when jointly for some severally for others": { form: &howShouldAttorneysMakeDecisionsForm{ - DecisionsType: actor.JointlyForSomeSeverallyForOthers, + DecisionsType: donordata.JointlyForSomeSeverallyForOthers, detailsErrorLabel: "xyz", }, errors: validation.With("mixed-details", validation.EnterError{Label: "xyz"}), 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 9b82f6cc8b..4d6b7c5e9e 100644 --- a/internal/donor/donorpage/how_should_replacement_attorneys_make_decisions.go +++ b/internal/donor/donorpage/how_should_replacement_attorneys_make_decisions.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/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -15,11 +14,11 @@ type howShouldReplacementAttorneysMakeDecisionsData struct { Errors validation.List Form *howShouldAttorneysMakeDecisionsForm Options donordata.AttorneysActOptions - Donor *actor.DonorProvidedDetails + Donor *donordata.DonorProvidedDetails } func HowShouldReplacementAttorneysMakeDecisions(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { data := &howShouldReplacementAttorneysMakeDecisionsData{ App: appData, Form: &howShouldAttorneysMakeDecisionsForm{ @@ -35,7 +34,7 @@ func HowShouldReplacementAttorneysMakeDecisions(tmpl template.Template, donorSto data.Errors = data.Form.Validate() if data.Errors.None() { - donor.ReplacementAttorneyDecisions = actor.MakeAttorneyDecisions( + donor.ReplacementAttorneyDecisions = donordata.MakeAttorneyDecisions( donor.ReplacementAttorneyDecisions, data.Form.DecisionsType, data.Form.DecisionsDetails) 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 5fc629c7f3..63f51fa790 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 @@ -25,11 +25,11 @@ func TestGetHowShouldReplacementAttorneysMakeDecisions(t *testing.T) { App: testAppData, Form: &howShouldAttorneysMakeDecisionsForm{}, Options: donordata.AttorneysActValues, - Donor: &actor.DonorProvidedDetails{}, + Donor: &donordata.DonorProvidedDetails{}, }). Return(nil) - err := HowShouldReplacementAttorneysMakeDecisions(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := HowShouldReplacementAttorneysMakeDecisions(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -45,15 +45,15 @@ func TestGetHowShouldReplacementAttorneysMakeDecisionsFromStore(t *testing.T) { Execute(w, &howShouldReplacementAttorneysMakeDecisionsData{ App: testAppData, Form: &howShouldAttorneysMakeDecisionsForm{ - DecisionsType: actor.Jointly, + DecisionsType: donordata.Jointly, DecisionsDetails: "some decisions", }, Options: donordata.AttorneysActValues, - Donor: &actor.DonorProvidedDetails{ReplacementAttorneyDecisions: actor.AttorneyDecisions{Details: "some decisions", How: actor.Jointly}}, + Donor: &donordata.DonorProvidedDetails{ReplacementAttorneyDecisions: donordata.AttorneyDecisions{Details: "some decisions", How: donordata.Jointly}}, }). Return(nil) - err := HowShouldReplacementAttorneysMakeDecisions(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ReplacementAttorneyDecisions: actor.AttorneyDecisions{Details: "some decisions", How: actor.Jointly}}) + err := HowShouldReplacementAttorneysMakeDecisions(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{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, &actor.DonorProvidedDetails{}) + err := HowShouldReplacementAttorneysMakeDecisions(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -78,7 +78,7 @@ func TestGetHowShouldReplacementAttorneysMakeDecisionsWhenTemplateErrors(t *test func TestPostHowShouldReplacementAttorneysMakeDecisions(t *testing.T) { form := url.Values{ - "decision-type": {actor.Jointly.String()}, + "decision-type": {donordata.Jointly.String()}, "mixed-details": {""}, } @@ -88,12 +88,12 @@ func TestPostHowShouldReplacementAttorneysMakeDecisions(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{LpaID: "lpa-id", ReplacementAttorneyDecisions: actor.AttorneyDecisions{How: actor.Jointly}}). + Put(r.Context(), &donordata.DonorProvidedDetails{LpaID: "lpa-id", ReplacementAttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}}). Return(nil) template := newMockTemplate(t) - err := HowShouldReplacementAttorneysMakeDecisions(template.Execute, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id"}) + err := HowShouldReplacementAttorneysMakeDecisions(template.Execute, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) resp := w.Result() assert.Nil(t, err) @@ -104,31 +104,31 @@ func TestPostHowShouldReplacementAttorneysMakeDecisions(t *testing.T) { func TestPostHowShouldReplacementAttorneysMakeDecisionsFromStore(t *testing.T) { testCases := map[string]struct { form url.Values - existing actor.AttorneyDecisions - attorneys actor.Attorneys - updated actor.AttorneyDecisions + existing donordata.AttorneyDecisions + attorneys donordata.Attorneys + updated donordata.AttorneyDecisions taskState actor.TaskState redirect page.LpaPath }{ "existing details not set": { form: url.Values{ - "decision-type": {actor.JointlyForSomeSeverallyForOthers.String()}, + "decision-type": {donordata.JointlyForSomeSeverallyForOthers.String()}, "mixed-details": {"some details"}, }, - existing: actor.AttorneyDecisions{How: actor.JointlyAndSeverally}, - attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{FirstNames: "a", Address: testAddress, Email: "a"}}}, - updated: actor.AttorneyDecisions{How: actor.JointlyForSomeSeverallyForOthers, Details: "some details"}, + 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, redirect: page.Paths.TaskList, }, "existing details set": { form: url.Values{ - "decision-type": {actor.Jointly.String()}, + "decision-type": {donordata.Jointly.String()}, "mixed-details": {"some details"}, }, - existing: actor.AttorneyDecisions{How: actor.JointlyForSomeSeverallyForOthers, Details: "some details"}, - attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{FirstNames: "a", Address: testAddress, Email: "a"}}}, - updated: actor.AttorneyDecisions{How: actor.Jointly}, + 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, redirect: page.Paths.TaskList, }, @@ -142,17 +142,17 @@ func TestPostHowShouldReplacementAttorneysMakeDecisionsFromStore(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", ReplacementAttorneys: tc.attorneys, ReplacementAttorneyDecisions: tc.updated, - Tasks: actor.DonorTasks{ChooseReplacementAttorneys: tc.taskState}, + Tasks: donordata.DonorTasks{ChooseReplacementAttorneys: tc.taskState}, }). Return(nil) template := newMockTemplate(t) - err := HowShouldReplacementAttorneysMakeDecisions(template.Execute, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := HowShouldReplacementAttorneysMakeDecisions(template.Execute, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", ReplacementAttorneys: tc.attorneys, ReplacementAttorneyDecisions: tc.existing, @@ -168,7 +168,7 @@ func TestPostHowShouldReplacementAttorneysMakeDecisionsFromStore(t *testing.T) { func TestPostHowShouldReplacementAttorneysMakeDecisionsWhenStoreErrors(t *testing.T) { form := url.Values{ - "decision-type": {actor.Jointly.String()}, + "decision-type": {donordata.Jointly.String()}, "mixed-details": {"some decisions"}, } @@ -181,7 +181,7 @@ func TestPostHowShouldReplacementAttorneysMakeDecisionsWhenStoreErrors(t *testin Put(r.Context(), mock.Anything). Return(expectedError) - err := HowShouldReplacementAttorneysMakeDecisions(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := HowShouldReplacementAttorneysMakeDecisions(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := HowShouldReplacementAttorneysMakeDecisions(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -213,7 +213,7 @@ func TestPostHowShouldReplacementAttorneysMakeDecisionsWhenValidationErrors(t *t func TestPostHowShouldReplacementAttorneysMakeDecisionsErrorOnPutStore(t *testing.T) { form := url.Values{ - "decision-type": {actor.Jointly.String()}, + "decision-type": {donordata.Jointly.String()}, "mixed-details": {""}, } @@ -223,12 +223,12 @@ func TestPostHowShouldReplacementAttorneysMakeDecisionsErrorOnPutStore(t *testin donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ReplacementAttorneyDecisions: actor.AttorneyDecisions{Details: "", How: actor.Jointly}}). + Put(r.Context(), &donordata.DonorProvidedDetails{ReplacementAttorneyDecisions: donordata.AttorneyDecisions{Details: "", How: donordata.Jointly}}). Return(expectedError) template := newMockTemplate(t) - err := HowShouldReplacementAttorneysMakeDecisions(template.Execute, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := HowShouldReplacementAttorneysMakeDecisions(template.Execute, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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 51d648aaac..4942fa9c03 100644 --- a/internal/donor/donorpage/how_should_replacement_attorneys_step_in.go +++ b/internal/donor/donorpage/how_should_replacement_attorneys_step_in.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/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -18,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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { data := &howShouldReplacementAttorneysStepInData{ App: appData, Form: &howShouldReplacementAttorneysStepInForm{ @@ -35,7 +34,7 @@ func HowShouldReplacementAttorneysStepIn(tmpl template.Template, donorStore Dono if data.Errors.None() { donor.HowShouldReplacementAttorneysStepIn = data.Form.WhenToStepIn - if donor.HowShouldReplacementAttorneysStepIn != actor.ReplacementAttorneysStepInAnotherWay { + if donor.HowShouldReplacementAttorneysStepIn != donordata.ReplacementAttorneysStepInAnotherWay { donor.HowShouldReplacementAttorneysStepInDetails = "" } else { donor.HowShouldReplacementAttorneysStepInDetails = data.Form.OtherDetails @@ -60,7 +59,7 @@ func HowShouldReplacementAttorneysStepIn(tmpl template.Template, donorStore Dono } type howShouldReplacementAttorneysStepInForm struct { - WhenToStepIn actor.ReplacementAttorneysStepIn + WhenToStepIn donordata.ReplacementAttorneysStepIn Error error OtherDetails string } @@ -81,7 +80,7 @@ func (f *howShouldReplacementAttorneysStepInForm) Validate() validation.List { errors.Error("when-to-step-in", "whenYourReplacementAttorneysStepIn", f.Error, validation.Selected()) - if f.WhenToStepIn == actor.ReplacementAttorneysStepInAnotherWay { + if f.WhenToStepIn == donordata.ReplacementAttorneysStepInAnotherWay { errors.String("other-details", "detailsOfWhenToStepIn", f.OtherDetails, validation.Empty()) } 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 9d2bb65772..d1f0646e09 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 @@ -29,8 +29,8 @@ func TestGetHowShouldReplacementAttorneysStepIn(t *testing.T) { }). Return(nil) - err := HowShouldReplacementAttorneysStepIn(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{}}}, + err := HowShouldReplacementAttorneysStepIn(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{}}}, }) resp := w.Result() @@ -47,15 +47,15 @@ func TestGetHowShouldReplacementAttorneysStepInFromStore(t *testing.T) { Execute(w, &howShouldReplacementAttorneysStepInData{ App: testAppData, Form: &howShouldReplacementAttorneysStepInForm{ - WhenToStepIn: actor.ReplacementAttorneysStepInAnotherWay, + WhenToStepIn: donordata.ReplacementAttorneysStepInAnotherWay, OtherDetails: "some details", }, Options: donordata.ReplacementAttorneysStepInValues, }). Return(nil) - err := HowShouldReplacementAttorneysStepIn(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - HowShouldReplacementAttorneysStepIn: actor.ReplacementAttorneysStepInAnotherWay, + err := HowShouldReplacementAttorneysStepIn(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + HowShouldReplacementAttorneysStepIn: donordata.ReplacementAttorneysStepInAnotherWay, HowShouldReplacementAttorneysStepInDetails: "some details", }) resp := w.Result() @@ -66,7 +66,7 @@ func TestGetHowShouldReplacementAttorneysStepInFromStore(t *testing.T) { func TestPostHowShouldReplacementAttorneysStepIn(t *testing.T) { form := url.Values{ - "when-to-step-in": {actor.ReplacementAttorneysStepInAnotherWay.String()}, + "when-to-step-in": {donordata.ReplacementAttorneysStepInAnotherWay.String()}, "other-details": {"some details"}, } @@ -76,15 +76,15 @@ func TestPostHowShouldReplacementAttorneysStepIn(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - HowShouldReplacementAttorneysStepIn: actor.ReplacementAttorneysStepInAnotherWay, + HowShouldReplacementAttorneysStepIn: donordata.ReplacementAttorneysStepInAnotherWay, HowShouldReplacementAttorneysStepInDetails: "some details"}). Return(nil) template := newMockTemplate(t) - err := HowShouldReplacementAttorneysStepIn(template.Execute, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id"}) + err := HowShouldReplacementAttorneysStepIn(template.Execute, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) resp := w.Result() assert.Nil(t, err) @@ -94,60 +94,60 @@ func TestPostHowShouldReplacementAttorneysStepIn(t *testing.T) { func TestPostHowShouldReplacementAttorneysStepInRedirects(t *testing.T) { testCases := map[string]struct { - Attorneys actor.Attorneys - ReplacementAttorneys actor.Attorneys - HowAttorneysMakeDecisions actor.AttorneysAct - HowReplacementAttorneysMakeDecisions actor.AttorneysAct - HowShouldReplacementAttorneysStepIn actor.ReplacementAttorneysStepIn + Attorneys donordata.Attorneys + ReplacementAttorneys donordata.Attorneys + HowAttorneysMakeDecisions donordata.AttorneysAct + HowReplacementAttorneysMakeDecisions donordata.AttorneysAct + HowShouldReplacementAttorneysStepIn donordata.ReplacementAttorneysStepIn ExpectedRedirectUrl page.LpaPath TaskState actor.TaskState }{ "multiple attorneys acting jointly and severally replacements step in when none left": { - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {UID: actoruid.New()}, {UID: actoruid.New()}, }}, - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {UID: actoruid.New()}, {UID: actoruid.New()}, }}, - HowAttorneysMakeDecisions: actor.JointlyAndSeverally, - HowShouldReplacementAttorneysStepIn: actor.ReplacementAttorneysStepInWhenAllCanNoLongerAct, + HowAttorneysMakeDecisions: donordata.JointlyAndSeverally, + HowShouldReplacementAttorneysStepIn: donordata.ReplacementAttorneysStepInWhenAllCanNoLongerAct, ExpectedRedirectUrl: page.Paths.HowShouldReplacementAttorneysMakeDecisions, TaskState: actor.TaskInProgress, }, "multiple attorneys acting jointly": { - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {UID: actoruid.New()}, {UID: actoruid.New()}, }}, - HowAttorneysMakeDecisions: actor.Jointly, - HowShouldReplacementAttorneysStepIn: actor.ReplacementAttorneysStepInWhenOneCanNoLongerAct, - HowReplacementAttorneysMakeDecisions: actor.Jointly, + HowAttorneysMakeDecisions: donordata.Jointly, + HowShouldReplacementAttorneysStepIn: donordata.ReplacementAttorneysStepInWhenOneCanNoLongerAct, + HowReplacementAttorneysMakeDecisions: donordata.Jointly, ExpectedRedirectUrl: page.Paths.TaskList, TaskState: actor.TaskInProgress, }, "multiple attorneys acting jointly and severally replacements step in when one loses capacity": { - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {UID: actoruid.New()}, {UID: actoruid.New()}, }}, - HowAttorneysMakeDecisions: actor.JointlyAndSeverally, - HowShouldReplacementAttorneysStepIn: actor.ReplacementAttorneysStepInWhenOneCanNoLongerAct, + HowAttorneysMakeDecisions: donordata.JointlyAndSeverally, + HowShouldReplacementAttorneysStepIn: donordata.ReplacementAttorneysStepInWhenOneCanNoLongerAct, ExpectedRedirectUrl: page.Paths.TaskList, TaskState: actor.TaskNotStarted, }, "multiple attorneys acting jointly and severally": { - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {UID: actoruid.New()}, {UID: actoruid.New()}, }}, - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {UID: actoruid.New()}, {UID: actoruid.New()}, }}, - HowAttorneysMakeDecisions: actor.JointlyAndSeverally, - HowShouldReplacementAttorneysStepIn: actor.ReplacementAttorneysStepInWhenOneCanNoLongerAct, + HowAttorneysMakeDecisions: donordata.JointlyAndSeverally, + HowShouldReplacementAttorneysStepIn: donordata.ReplacementAttorneysStepInWhenOneCanNoLongerAct, ExpectedRedirectUrl: page.Paths.TaskList, TaskState: actor.TaskInProgress, }, @@ -165,25 +165,25 @@ func TestPostHowShouldReplacementAttorneysStepInRedirects(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", Attorneys: tc.Attorneys, - AttorneyDecisions: actor.AttorneyDecisions{How: tc.HowAttorneysMakeDecisions}, + AttorneyDecisions: donordata.AttorneyDecisions{How: tc.HowAttorneysMakeDecisions}, ReplacementAttorneys: tc.ReplacementAttorneys, - ReplacementAttorneyDecisions: actor.AttorneyDecisions{How: tc.HowReplacementAttorneysMakeDecisions}, + ReplacementAttorneyDecisions: donordata.AttorneyDecisions{How: tc.HowReplacementAttorneysMakeDecisions}, HowShouldReplacementAttorneysStepIn: tc.HowShouldReplacementAttorneysStepIn, - Tasks: actor.DonorTasks{ChooseReplacementAttorneys: tc.TaskState}, + Tasks: donordata.DonorTasks{ChooseReplacementAttorneys: tc.TaskState}, }). Return(nil) template := newMockTemplate(t) - err := HowShouldReplacementAttorneysStepIn(template.Execute, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := HowShouldReplacementAttorneysStepIn(template.Execute, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", Attorneys: tc.Attorneys, - AttorneyDecisions: actor.AttorneyDecisions{How: tc.HowAttorneysMakeDecisions}, + AttorneyDecisions: donordata.AttorneyDecisions{How: tc.HowAttorneysMakeDecisions}, ReplacementAttorneys: tc.ReplacementAttorneys, - ReplacementAttorneyDecisions: actor.AttorneyDecisions{How: tc.HowReplacementAttorneysMakeDecisions}, + ReplacementAttorneyDecisions: donordata.AttorneyDecisions{How: tc.HowReplacementAttorneysMakeDecisions}, }) resp := w.Result() @@ -196,23 +196,23 @@ func TestPostHowShouldReplacementAttorneysStepInRedirects(t *testing.T) { func TestPostHowShouldReplacementAttorneysStepInFromStore(t *testing.T) { testCases := map[string]struct { - existingWhenStepIn actor.ReplacementAttorneysStepIn + existingWhenStepIn donordata.ReplacementAttorneysStepIn existingOtherDetails string - updatedWhenStepIn actor.ReplacementAttorneysStepIn + updatedWhenStepIn donordata.ReplacementAttorneysStepIn updatedOtherDetails string - formWhenStepIn actor.ReplacementAttorneysStepIn + formWhenStepIn donordata.ReplacementAttorneysStepIn formOtherDetails string }{ "existing otherDetails not set": { - existingWhenStepIn: actor.ReplacementAttorneysStepInWhenAllCanNoLongerAct, + existingWhenStepIn: donordata.ReplacementAttorneysStepInWhenAllCanNoLongerAct, existingOtherDetails: "", - updatedWhenStepIn: actor.ReplacementAttorneysStepInAnotherWay, + updatedWhenStepIn: donordata.ReplacementAttorneysStepInAnotherWay, updatedOtherDetails: "some details", }, "existing otherDetails set": { - existingWhenStepIn: actor.ReplacementAttorneysStepInAnotherWay, + existingWhenStepIn: donordata.ReplacementAttorneysStepInAnotherWay, existingOtherDetails: "some details", - updatedWhenStepIn: actor.ReplacementAttorneysStepInWhenOneCanNoLongerAct, + updatedWhenStepIn: donordata.ReplacementAttorneysStepInWhenOneCanNoLongerAct, updatedOtherDetails: "", }, } @@ -230,7 +230,7 @@ func TestPostHowShouldReplacementAttorneysStepInFromStore(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ 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, &actor.DonorProvidedDetails{ + err := HowShouldReplacementAttorneysStepIn(template.Execute, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ 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, &actor.DonorProvidedDetails{}) + err := HowShouldReplacementAttorneysStepIn(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -278,7 +278,7 @@ func TestPostHowShouldReplacementAttorneysStepInFormValidation(t *testing.T) { func TestPostHowShouldReplacementAttorneysStepInWhenPutStoreError(t *testing.T) { form := url.Values{ - "when-to-step-in": {actor.ReplacementAttorneysStepInAnotherWay.String()}, + "when-to-step-in": {donordata.ReplacementAttorneysStepInAnotherWay.String()}, "other-details": {"some details"}, } @@ -288,14 +288,14 @@ func TestPostHowShouldReplacementAttorneysStepInWhenPutStoreError(t *testing.T) donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ - HowShouldReplacementAttorneysStepIn: actor.ReplacementAttorneysStepInAnotherWay, + Put(r.Context(), &donordata.DonorProvidedDetails{ + HowShouldReplacementAttorneysStepIn: donordata.ReplacementAttorneysStepInAnotherWay, HowShouldReplacementAttorneysStepInDetails: "some details"}). Return(expectedError) template := newMockTemplate(t) - err := HowShouldReplacementAttorneysStepIn(template.Execute, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := HowShouldReplacementAttorneysStepIn(template.Execute, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -318,7 +318,7 @@ func TestHowShouldReplacementAttorneysStepInFormValidate(t *testing.T) { }, "missing other details": { form: &howShouldReplacementAttorneysStepInForm{ - WhenToStepIn: actor.ReplacementAttorneysStepInAnotherWay, + WhenToStepIn: donordata.ReplacementAttorneysStepInAnotherWay, }, expectedErrors: validation.With("other-details", validation.EnterError{Label: "detailsOfWhenToStepIn"}), }, 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 ea78f4a71d..2046e7441b 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 @@ -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/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -13,13 +12,13 @@ import ( type howWouldCertificateProviderPreferToCarryOutTheirRoleData struct { App page.AppData Errors validation.List - CertificateProvider actor.CertificateProvider + CertificateProvider donordata.CertificateProvider Form *howWouldCertificateProviderPreferToCarryOutTheirRoleForm Options donordata.ChannelOptions } func HowWouldCertificateProviderPreferToCarryOutTheirRole(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { data := &howWouldCertificateProviderPreferToCarryOutTheirRoleData{ App: appData, CertificateProvider: donor.CertificateProvider, @@ -51,7 +50,7 @@ func HowWouldCertificateProviderPreferToCarryOutTheirRole(tmpl template.Template } type howWouldCertificateProviderPreferToCarryOutTheirRoleForm struct { - CarryOutBy actor.Channel + CarryOutBy donordata.Channel Email string Error error } 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 91ea22f283..2a9f41f7c9 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 @@ -7,7 +7,6 @@ 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/validation" @@ -28,7 +27,7 @@ func TestGetHowWouldCertificateProviderPreferToCarryOutTheirRole(t *testing.T) { }). Return(nil) - err := HowWouldCertificateProviderPreferToCarryOutTheirRole(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := HowWouldCertificateProviderPreferToCarryOutTheirRole(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -43,14 +42,14 @@ func TestGetHowWouldCertificateProviderPreferToCarryOutTheirRoleFromStore(t *tes template.EXPECT(). Execute(w, &howWouldCertificateProviderPreferToCarryOutTheirRoleData{ App: testAppData, - CertificateProvider: actor.CertificateProvider{CarryOutBy: actor.ChannelPaper}, - Form: &howWouldCertificateProviderPreferToCarryOutTheirRoleForm{CarryOutBy: actor.ChannelPaper}, + CertificateProvider: donordata.CertificateProvider{CarryOutBy: donordata.ChannelPaper}, + Form: &howWouldCertificateProviderPreferToCarryOutTheirRoleForm{CarryOutBy: donordata.ChannelPaper}, Options: donordata.ChannelValues, }). Return(nil) - err := HowWouldCertificateProviderPreferToCarryOutTheirRole(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - CertificateProvider: actor.CertificateProvider{CarryOutBy: actor.ChannelPaper}, + err := HowWouldCertificateProviderPreferToCarryOutTheirRole(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + CertificateProvider: donordata.CertificateProvider{CarryOutBy: donordata.ChannelPaper}, }) resp := w.Result() @@ -71,7 +70,7 @@ func TestGetHowWouldCertificateProviderPreferToCarryOutTheirRoleWhenTemplateErro }). Return(expectedError) - err := HowWouldCertificateProviderPreferToCarryOutTheirRole(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := HowWouldCertificateProviderPreferToCarryOutTheirRole(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -80,14 +79,14 @@ func TestGetHowWouldCertificateProviderPreferToCarryOutTheirRoleWhenTemplateErro func TestPostHowWouldCertificateProviderPreferToCarryOutTheirRole(t *testing.T) { testCases := []struct { - carryOutBy actor.Channel + carryOutBy donordata.Channel email string }{ { - carryOutBy: actor.ChannelPaper, + carryOutBy: donordata.ChannelPaper, }, { - carryOutBy: actor.ChannelOnline, + carryOutBy: donordata.ChannelOnline, email: "someone@example.com", }, } @@ -105,13 +104,13 @@ func TestPostHowWouldCertificateProviderPreferToCarryOutTheirRole(t *testing.T) donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - CertificateProvider: actor.CertificateProvider{CarryOutBy: tc.carryOutBy, Email: tc.email}, + CertificateProvider: donordata.CertificateProvider{CarryOutBy: tc.carryOutBy, Email: tc.email}, }). Return(nil) - err := HowWouldCertificateProviderPreferToCarryOutTheirRole(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id"}) + err := HowWouldCertificateProviderPreferToCarryOutTheirRole(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) resp := w.Result() assert.Nil(t, err) @@ -123,7 +122,7 @@ func TestPostHowWouldCertificateProviderPreferToCarryOutTheirRole(t *testing.T) func TestPostHowWouldCertificateProviderPreferToCarryOutTheirRoleChangingFromOnlineToPaper(t *testing.T) { form := url.Values{ - "carry-out-by": {actor.ChannelPaper.String()}, + "carry-out-by": {donordata.ChannelPaper.String()}, "email": {"a@b.com"}, } @@ -133,15 +132,15 @@ func TestPostHowWouldCertificateProviderPreferToCarryOutTheirRoleChangingFromOnl donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - CertificateProvider: actor.CertificateProvider{CarryOutBy: actor.ChannelPaper, Email: ""}, + CertificateProvider: donordata.CertificateProvider{CarryOutBy: donordata.ChannelPaper, Email: ""}, }). Return(nil) - err := HowWouldCertificateProviderPreferToCarryOutTheirRole(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := HowWouldCertificateProviderPreferToCarryOutTheirRole(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - CertificateProvider: actor.CertificateProvider{CarryOutBy: actor.ChannelOnline, Email: "a@b.com"}, + CertificateProvider: donordata.CertificateProvider{CarryOutBy: donordata.ChannelOnline, Email: "a@b.com"}, }) resp := w.Result() @@ -152,7 +151,7 @@ func TestPostHowWouldCertificateProviderPreferToCarryOutTheirRoleChangingFromOnl func TestPostHowWouldCertificateProviderPreferToCarryOutTheirRoleWhenStoreErrors(t *testing.T) { form := url.Values{ - "carry-out-by": {actor.ChannelPaper.String()}, + "carry-out-by": {donordata.ChannelPaper.String()}, } w := httptest.NewRecorder() @@ -164,7 +163,7 @@ func TestPostHowWouldCertificateProviderPreferToCarryOutTheirRoleWhenStoreErrors Put(r.Context(), mock.Anything). Return(expectedError) - err := HowWouldCertificateProviderPreferToCarryOutTheirRole(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := HowWouldCertificateProviderPreferToCarryOutTheirRole(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } @@ -181,7 +180,7 @@ func TestPostHowWouldCertificateProviderPreferToCarryOutTheirRoleWhenValidationE })). Return(nil) - err := HowWouldCertificateProviderPreferToCarryOutTheirRole(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := HowWouldCertificateProviderPreferToCarryOutTheirRole(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -190,36 +189,36 @@ func TestPostHowWouldCertificateProviderPreferToCarryOutTheirRoleWhenValidationE func TestReadHowWouldCertificateProviderPreferToCarryOutTheirRoleForm(t *testing.T) { testcases := map[string]struct { - carryOutBy actor.Channel + carryOutBy donordata.Channel email string formValues url.Values expectedForm *howWouldCertificateProviderPreferToCarryOutTheirRoleForm }{ "online with email": { formValues: url.Values{ - "carry-out-by": {actor.ChannelOnline.String()}, + "carry-out-by": {donordata.ChannelOnline.String()}, "email": {"a@b.com"}, }, expectedForm: &howWouldCertificateProviderPreferToCarryOutTheirRoleForm{ - CarryOutBy: actor.ChannelOnline, + CarryOutBy: donordata.ChannelOnline, Email: "a@b.com", }, }, "paper": { formValues: url.Values{ - "carry-out-by": {actor.ChannelPaper.String()}, + "carry-out-by": {donordata.ChannelPaper.String()}, }, expectedForm: &howWouldCertificateProviderPreferToCarryOutTheirRoleForm{ - CarryOutBy: actor.ChannelPaper, + CarryOutBy: donordata.ChannelPaper, }, }, "paper with email": { formValues: url.Values{ - "carry-out-by": {actor.ChannelPaper.String()}, + "carry-out-by": {donordata.ChannelPaper.String()}, "email": {"a@b.com"}, }, expectedForm: &howWouldCertificateProviderPreferToCarryOutTheirRoleForm{ - CarryOutBy: actor.ChannelPaper, + CarryOutBy: donordata.ChannelPaper, }, }, } @@ -243,38 +242,38 @@ func TestHowWouldCertificateProviderPreferToCarryOutTheirRoleFormValidate(t *tes }{ "paper": { form: &howWouldCertificateProviderPreferToCarryOutTheirRoleForm{ - CarryOutBy: actor.ChannelPaper, + CarryOutBy: donordata.ChannelPaper, }, }, "online": { form: &howWouldCertificateProviderPreferToCarryOutTheirRoleForm{ - CarryOutBy: actor.ChannelOnline, + CarryOutBy: donordata.ChannelOnline, Email: "someone@example.com", }, }, "online email invalid": { form: &howWouldCertificateProviderPreferToCarryOutTheirRoleForm{ - CarryOutBy: actor.ChannelOnline, + CarryOutBy: donordata.ChannelOnline, Email: "what", }, errors: validation.With("email", validation.EmailError{Label: "certificateProvidersEmail"}), }, "online email missing": { form: &howWouldCertificateProviderPreferToCarryOutTheirRoleForm{ - CarryOutBy: actor.ChannelOnline, + CarryOutBy: donordata.ChannelOnline, }, errors: validation.With("email", validation.EnterError{Label: "certificateProvidersEmail"}), }, "missing": { form: &howWouldCertificateProviderPreferToCarryOutTheirRoleForm{ - CarryOutBy: actor.Channel(0), + CarryOutBy: donordata.Channel(0), Error: expectedError, }, errors: validation.With("carry-out-by", validation.SelectError{Label: "howYourCertificateProviderWouldPreferToCarryOutTheirRole"}), }, "invalid": { form: &howWouldCertificateProviderPreferToCarryOutTheirRoleForm{ - CarryOutBy: actor.Channel(99), + CarryOutBy: donordata.Channel(99), Error: expectedError, }, errors: validation.With("carry-out-by", validation.SelectError{Label: "howYourCertificateProviderWouldPreferToCarryOutTheirRole"}), 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 10045989f6..4f17a4c95d 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 @@ -4,7 +4,7 @@ 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/pay" @@ -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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 6df1e2e3eb..229eaa9fc9 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 @@ -7,7 +7,7 @@ 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/pay" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -27,7 +27,7 @@ func TestGetHowWouldYouLikeToSendEvidence(t *testing.T) { }). Return(nil) - err := HowWouldYouLikeToSendEvidence(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := HowWouldYouLikeToSendEvidence(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := HowWouldYouLikeToSendEvidence(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := HowWouldYouLikeToSendEvidence(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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(), &actor.DonorProvidedDetails{LpaID: "lpa-id", EvidenceDelivery: evidenceDelivery}). + Put(r.Context(), &donordata.DonorProvidedDetails{LpaID: "lpa-id", EvidenceDelivery: evidenceDelivery}). Return(nil) - err := HowWouldYouLikeToSendEvidence(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id"}) + err := HowWouldYouLikeToSendEvidence(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{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, &actor.DonorProvidedDetails{LpaID: "lpa-id"}) + err := HowWouldYouLikeToSendEvidence(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{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, &actor.DonorProvidedDetails{}) + err := HowWouldYouLikeToSendEvidence(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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 9fe0a720b2..2ce4e75f15 100644 --- a/internal/donor/donorpage/identity_with_one_login.go +++ b/internal/donor/donorpage/identity_with_one_login.go @@ -3,14 +3,14 @@ package donorpage import ( "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/localize" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" ) func IdentityWithOneLogin(oneLoginClient OneLoginClient, sessionStore SessionStore, randomString func(int) string) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 40b265cf14..6f52a6fb8a 100644 --- a/internal/donor/donorpage/identity_with_one_login_callback.go +++ b/internal/donor/donorpage/identity_with_one_login_callback.go @@ -5,12 +5,13 @@ import ( "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" ) func IdentityWithOneLoginCallback(oneLoginClient OneLoginClient, sessionStore SessionStore, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { if donor.DonorIdentityConfirmed() { return page.Paths.OneLoginIdentityDetails.Redirect(w, r, appData, donor) } 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 14084a0c98..f73551657f 100644 --- a/internal/donor/donorpage/identity_with_one_login_callback_test.go +++ b/internal/donor/donorpage/identity_with_one_login_callback_test.go @@ -8,6 +8,7 @@ import ( "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" @@ -23,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 := &actor.DonorProvidedDetails{ + updatedDonor := &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{FirstNames: "John", LastName: "Doe"}, + Donor: donordata.Donor{FirstNames: "John", LastName: "Doe"}, DonorIdentityUserData: userData, - Tasks: actor.DonorTasks{ConfirmYourIdentityAndSign: actor.IdentityTaskInProgress}, + Tasks: donordata.DonorTasks{ConfirmYourIdentityAndSign: actor.IdentityTaskInProgress}, } donorStore := newMockDonorStore(t) @@ -51,9 +52,9 @@ func TestGetIdentityWithOneLoginCallback(t *testing.T) { ParseIdentityClaim(r.Context(), userInfo). Return(userData, nil) - err := IdentityWithOneLoginCallback(oneLoginClient, sessionStore, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := IdentityWithOneLoginCallback(oneLoginClient, sessionStore, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{FirstNames: "John", LastName: "Doe"}, + Donor: donordata.Donor{FirstNames: "John", LastName: "Doe"}, }) resp := w.Result() @@ -181,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, &actor.DonorProvidedDetails{}) + err := IdentityWithOneLoginCallback(oneLoginClient, sessionStore, tc.donorStore(t))(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, tc.error, err) @@ -197,11 +198,11 @@ func TestGetIdentityWithOneLoginCallbackWhenInsufficientEvidenceReturnCodeClaimP donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ - Donor: actor.Donor{FirstNames: "John", LastName: "Doe"}, + Put(r.Context(), &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{FirstNames: "John", LastName: "Doe"}, LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusInsufficientEvidence}, - Tasks: actor.DonorTasks{ConfirmYourIdentityAndSign: actor.IdentityTaskInProgress}, + Tasks: donordata.DonorTasks{ConfirmYourIdentityAndSign: actor.IdentityTaskInProgress}, }). Return(nil) @@ -221,8 +222,8 @@ func TestGetIdentityWithOneLoginCallbackWhenInsufficientEvidenceReturnCodeClaimP ParseIdentityClaim(mock.Anything, mock.Anything). Return(identity.UserData{Status: identity.StatusInsufficientEvidence}, nil) - err := IdentityWithOneLoginCallback(oneLoginClient, sessionStore, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{FirstNames: "John", LastName: "Doe"}, + err := IdentityWithOneLoginCallback(oneLoginClient, sessionStore, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{FirstNames: "John", LastName: "Doe"}, LpaID: "lpa-id", }) resp := w.Result() @@ -239,11 +240,11 @@ func TestGetIdentityWithOneLoginCallbackWhenAnyOtherReturnCodeClaimPresent(t *te donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ - Donor: actor.Donor{FirstNames: "John", LastName: "Doe"}, + Put(r.Context(), &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{FirstNames: "John", LastName: "Doe"}, LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusFailed}, - Tasks: actor.DonorTasks{ConfirmYourIdentityAndSign: actor.IdentityTaskProblem}, + Tasks: donordata.DonorTasks{ConfirmYourIdentityAndSign: actor.IdentityTaskProblem}, }). Return(nil) @@ -263,8 +264,8 @@ func TestGetIdentityWithOneLoginCallbackWhenAnyOtherReturnCodeClaimPresent(t *te ParseIdentityClaim(mock.Anything, mock.Anything). Return(identity.UserData{Status: identity.StatusFailed}, nil) - err := IdentityWithOneLoginCallback(oneLoginClient, sessionStore, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{FirstNames: "John", LastName: "Doe"}, + err := IdentityWithOneLoginCallback(oneLoginClient, sessionStore, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{FirstNames: "John", LastName: "Doe"}, LpaID: "lpa-id", }) resp := w.Result() @@ -300,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, &actor.DonorProvidedDetails{}) + err := IdentityWithOneLoginCallback(oneLoginClient, sessionStore, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } @@ -311,9 +312,9 @@ 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, &actor.DonorProvidedDetails{ + err := IdentityWithOneLoginCallback(nil, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{FirstNames: "first-name", LastName: "last-name"}, + Donor: donordata.Donor{FirstNames: "first-name", LastName: "last-name"}, DonorIdentityUserData: userData, }) resp := w.Result() diff --git a/internal/donor/donorpage/identity_with_one_login_test.go b/internal/donor/donorpage/identity_with_one_login_test.go index b26403fa29..72ea8c2f30 100644 --- a/internal/donor/donorpage/identity_with_one_login_test.go +++ b/internal/donor/donorpage/identity_with_one_login_test.go @@ -5,7 +5,7 @@ import ( "net/http/httptest" "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/localize" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" @@ -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, &actor.DonorProvidedDetails{LpaID: "lpa-id"}) + err := IdentityWithOneLogin(client, sessionStore, func(int) string { return "i am random" })(page.AppData{Lang: localize.Cy}, w, r, &donordata.DonorProvidedDetails{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, &actor.DonorProvidedDetails{}) + err := IdentityWithOneLogin(client, nil, func(int) string { return "i am random" })(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := IdentityWithOneLogin(client, sessionStore, func(int) string { return "i am random" })(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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 67d6ca0355..29122d88ee 100644 --- a/internal/donor/donorpage/life_sustaining_treatment.go +++ b/internal/donor/donorpage/life_sustaining_treatment.go @@ -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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { data := &lifeSustainingTreatmentData{ App: appData, Form: &lifeSustainingTreatmentForm{ @@ -47,7 +47,7 @@ func LifeSustainingTreatment(tmpl template.Template, donorStore DonorStore) Hand } type lifeSustainingTreatmentForm struct { - Option actor.LifeSustainingTreatment + Option donordata.LifeSustainingTreatment Error error } diff --git a/internal/donor/donorpage/life_sustaining_treatment_test.go b/internal/donor/donorpage/life_sustaining_treatment_test.go index edc7af8c6c..0513a95b94 100644 --- a/internal/donor/donorpage/life_sustaining_treatment_test.go +++ b/internal/donor/donorpage/life_sustaining_treatment_test.go @@ -28,7 +28,7 @@ func TestGetLifeSustainingTreatment(t *testing.T) { }). Return(nil) - err := LifeSustainingTreatment(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := LifeSustainingTreatment(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -44,13 +44,13 @@ func TestGetLifeSustainingTreatmentFromStore(t *testing.T) { Execute(w, &lifeSustainingTreatmentData{ App: testAppData, Form: &lifeSustainingTreatmentForm{ - Option: actor.LifeSustainingTreatmentOptionA, + Option: donordata.LifeSustainingTreatmentOptionA, }, Options: donordata.LifeSustainingTreatmentValues, }). Return(nil) - err := LifeSustainingTreatment(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{LifeSustainingTreatmentOption: actor.LifeSustainingTreatmentOptionA}) + err := LifeSustainingTreatment(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{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, &actor.DonorProvidedDetails{}) + err := LifeSustainingTreatment(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -75,7 +75,7 @@ func TestGetLifeSustainingTreatmentWhenTemplateErrors(t *testing.T) { func TestPostLifeSustainingTreatment(t *testing.T) { form := url.Values{ - "option": {actor.LifeSustainingTreatmentOptionA.String()}, + "option": {donordata.LifeSustainingTreatmentOptionA.String()}, } w := httptest.NewRecorder() @@ -84,16 +84,16 @@ func TestPostLifeSustainingTreatment(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - LifeSustainingTreatmentOption: actor.LifeSustainingTreatmentOptionA, - Tasks: actor.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, LifeSustainingTreatment: actor.TaskCompleted}, + LifeSustainingTreatmentOption: donordata.LifeSustainingTreatmentOptionA, + Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, LifeSustainingTreatment: actor.TaskCompleted}, }). Return(nil) - err := LifeSustainingTreatment(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := LifeSustainingTreatment(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Tasks: actor.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted}, + Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted}, }) resp := w.Result() @@ -104,7 +104,7 @@ func TestPostLifeSustainingTreatment(t *testing.T) { func TestPostLifeSustainingTreatmentWhenStoreErrors(t *testing.T) { form := url.Values{ - "option": {actor.LifeSustainingTreatmentOptionA.String()}, + "option": {donordata.LifeSustainingTreatmentOptionA.String()}, } w := httptest.NewRecorder() @@ -113,10 +113,10 @@ func TestPostLifeSustainingTreatmentWhenStoreErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{LifeSustainingTreatmentOption: actor.LifeSustainingTreatmentOptionA, Tasks: actor.DonorTasks{LifeSustainingTreatment: actor.TaskCompleted}}). + Put(r.Context(), &donordata.DonorProvidedDetails{LifeSustainingTreatmentOption: donordata.LifeSustainingTreatmentOptionA, Tasks: donordata.DonorTasks{LifeSustainingTreatment: actor.TaskCompleted}}). Return(expectedError) - err := LifeSustainingTreatment(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := LifeSustainingTreatment(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } @@ -133,7 +133,7 @@ func TestPostLifeSustainingTreatmentWhenValidationErrors(t *testing.T) { })). Return(nil) - err := LifeSustainingTreatment(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := LifeSustainingTreatment(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -142,7 +142,7 @@ func TestPostLifeSustainingTreatmentWhenValidationErrors(t *testing.T) { func TestReadLifeSustainingTreatmentForm(t *testing.T) { form := url.Values{ - "option": {actor.LifeSustainingTreatmentOptionA.String()}, + "option": {donordata.LifeSustainingTreatmentOptionA.String()}, } r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) @@ -150,7 +150,7 @@ func TestReadLifeSustainingTreatmentForm(t *testing.T) { result := readLifeSustainingTreatmentForm(r) - assert.Equal(t, actor.LifeSustainingTreatmentOptionA, result.Option) + assert.Equal(t, donordata.LifeSustainingTreatmentOptionA, result.Option) } func TestLifeSustainingTreatmentFormValidate(t *testing.T) { diff --git a/internal/donor/donorpage/lpa_details_saved.go b/internal/donor/donorpage/lpa_details_saved.go index 1dd3536e4e..6199810b2a 100644 --- a/internal/donor/donorpage/lpa_details_saved.go +++ b/internal/donor/donorpage/lpa_details_saved.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/validation" ) type LpaDetailsSavedData struct { App page.AppData - Donor *actor.DonorProvidedDetails + Donor *donordata.DonorProvidedDetails IsFirstCheck bool Errors validation.List } func LpaDetailsSaved(tmpl template.Template) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 c9aa6247fe..ac30f4cef4 100644 --- a/internal/donor/donorpage/lpa_details_saved_test.go +++ b/internal/donor/donorpage/lpa_details_saved_test.go @@ -5,7 +5,7 @@ import ( "net/http/httptest" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" + "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -26,11 +26,11 @@ func TestGetLpaDetailsSaved(t *testing.T) { Execute(w, LpaDetailsSavedData{ App: testAppData, IsFirstCheck: expectedIsFirstCheck, - Donor: &actor.DonorProvidedDetails{}, + Donor: &donordata.DonorProvidedDetails{}, }). Return(nil) - err := LpaDetailsSaved(template.Execute)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := LpaDetailsSaved(template.Execute)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := LpaDetailsSaved(template.Execute)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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 16ff32132d..4675706193 100644 --- a/internal/donor/donorpage/lpa_progress.go +++ b/internal/donor/donorpage/lpa_progress.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/validation" ) type lpaProgressData struct { App page.AppData - Donor *actor.DonorProvidedDetails + Donor *donordata.DonorProvidedDetails 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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 4ecd2b29cd..e6e2ffa11f 100644 --- a/internal/donor/donorpage/lpa_progress_test.go +++ b/internal/donor/donorpage/lpa_progress_test.go @@ -6,6 +6,7 @@ import ( "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/stretchr/testify/assert" @@ -32,12 +33,12 @@ func TestGetLpaProgress(t *testing.T) { template.EXPECT(). Execute(w, &lpaProgressData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{LpaUID: "lpa-uid"}, + Donor: &donordata.DonorProvidedDetails{LpaUID: "lpa-uid"}, Progress: page.Progress{DonorSigned: page.ProgressTask{State: actor.TaskInProgress}}, }). Return(nil) - err := LpaProgress(template.Execute, lpaStoreResolvingService, progressTracker)(testAppData, w, r, &actor.DonorProvidedDetails{LpaUID: "lpa-uid"}) + err := LpaProgress(template.Execute, lpaStoreResolvingService, progressTracker)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaUID: "lpa-uid"}) resp := w.Result() assert.Nil(t, err) @@ -53,7 +54,7 @@ func TestGetLpaProgressWhenLpaStoreClientErrors(t *testing.T) { Get(r.Context()). Return(nil, expectedError) - err := LpaProgress(nil, lpaStoreResolvingService, nil)(testAppData, w, r, &actor.DonorProvidedDetails{LpaUID: "lpa-uid"}) + err := LpaProgress(nil, lpaStoreResolvingService, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaUID: "lpa-uid"}) assert.Equal(t, expectedError, err) } @@ -76,6 +77,6 @@ func TestGetLpaProgressOnTemplateError(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := LpaProgress(template.Execute, lpaStoreResolvingService, progressTracker)(testAppData, w, r, &actor.DonorProvidedDetails{LpaUID: "lpa-uid"}) + err := LpaProgress(template.Execute, lpaStoreResolvingService, progressTracker)(testAppData, w, r, &donordata.DonorProvidedDetails{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 a91718bf48..3836238a19 100644 --- a/internal/donor/donorpage/lpa_type.go +++ b/internal/donor/donorpage/lpa_type.go @@ -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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { data := &lpaTypeData{ App: appData, Form: &lpaTypeForm{ @@ -44,7 +44,7 @@ func LpaType(tmpl template.Template, donorStore DonorStore, eventClient EventCli donor.Type = data.Form.LpaType if donor.Type.IsPersonalWelfare() { - donor.WhenCanTheLpaBeUsed = actor.CanBeUsedWhenCapacityLost + donor.WhenCanTheLpaBeUsed = donordata.CanBeUsedWhenCapacityLost } donor.Tasks.YourDetails = actor.TaskCompleted donor.HasSentApplicationUpdatedEvent = false @@ -76,7 +76,7 @@ func LpaType(tmpl template.Template, donorStore DonorStore, eventClient EventCli } type lpaTypeForm struct { - LpaType actor.LpaType + LpaType donordata.LpaType Error error } diff --git a/internal/donor/donorpage/lpa_type_test.go b/internal/donor/donorpage/lpa_type_test.go index f45bb3cd36..ff49788aaa 100644 --- a/internal/donor/donorpage/lpa_type_test.go +++ b/internal/donor/donorpage/lpa_type_test.go @@ -34,7 +34,7 @@ func TestGetLpaType(t *testing.T) { }). Return(nil) - err := LpaType(template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := LpaType(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -50,14 +50,14 @@ func TestGetLpaTypeFromStore(t *testing.T) { Execute(w, &lpaTypeData{ App: testAppData, Form: &lpaTypeForm{ - LpaType: actor.LpaTypePropertyAndAffairs, + LpaType: donordata.LpaTypePropertyAndAffairs, }, Options: donordata.LpaTypeValues, CanTaskList: true, }). Return(nil) - err := LpaType(template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{Type: actor.LpaTypePropertyAndAffairs}) + err := LpaType(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{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, &actor.DonorProvidedDetails{}) + err := LpaType(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -81,29 +81,29 @@ func TestGetLpaTypeWhenTemplateErrors(t *testing.T) { } func TestPostLpaType(t *testing.T) { - testcases := map[actor.LpaType]*actor.DonorProvidedDetails{ - actor.LpaTypePropertyAndAffairs: { + testcases := map[donordata.LpaType]*donordata.DonorProvidedDetails{ + donordata.LpaTypePropertyAndAffairs: { LpaID: "lpa-id", - Donor: actor.Donor{ + Donor: donordata.Donor{ FirstNames: "John", LastName: "Smith", DateOfBirth: date.New("2000", "01", "01"), Address: place.Address{Postcode: "F1 1FF"}, }, - Type: actor.LpaTypePropertyAndAffairs, - Tasks: actor.DonorTasks{YourDetails: actor.TaskCompleted}, + Type: donordata.LpaTypePropertyAndAffairs, + Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted}, }, - actor.LpaTypePersonalWelfare: { + donordata.LpaTypePersonalWelfare: { LpaID: "lpa-id", - Donor: actor.Donor{ + Donor: donordata.Donor{ FirstNames: "John", LastName: "Smith", DateOfBirth: date.New("2000", "01", "01"), Address: place.Address{Postcode: "F1 1FF"}, }, - Type: actor.LpaTypePersonalWelfare, - WhenCanTheLpaBeUsed: actor.CanBeUsedWhenCapacityLost, - Tasks: actor.DonorTasks{YourDetails: actor.TaskCompleted}, + Type: donordata.LpaTypePersonalWelfare, + WhenCanTheLpaBeUsed: donordata.CanBeUsedWhenCapacityLost, + Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted}, }, } @@ -138,9 +138,9 @@ func TestPostLpaType(t *testing.T) { }). Return(nil) - err := LpaType(nil, donorStore, eventClient)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := LpaType(nil, donorStore, eventClient)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{ + Donor: donordata.Donor{ FirstNames: "John", LastName: "Smith", DateOfBirth: date.New("2000", "01", "01"), @@ -159,7 +159,7 @@ func TestPostLpaType(t *testing.T) { func TestPostLpaTypeWhenTrustCorporation(t *testing.T) { form := url.Values{ - "lpa-type": {actor.LpaTypePersonalWelfare.String()}, + "lpa-type": {donordata.LpaTypePersonalWelfare.String()}, } ctx := page.ContextWithSessionData(context.Background(), &appcontext.SessionData{SessionID: "an-id"}) @@ -175,16 +175,16 @@ func TestPostLpaTypeWhenTrustCorporation(t *testing.T) { })). Return(nil) - err := LpaType(template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := LpaType(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{ + Donor: donordata.Donor{ FirstNames: "John", LastName: "Smith", DateOfBirth: date.New("2000", "01", "01"), Address: place.Address{Postcode: "F1 1FF"}, }, - Attorneys: actor.Attorneys{ - TrustCorporation: actor.TrustCorporation{Name: "a"}, + Attorneys: donordata.Attorneys{ + TrustCorporation: donordata.TrustCorporation{Name: "a"}, }, HasSentApplicationUpdatedEvent: true, }) @@ -194,14 +194,14 @@ func TestPostLpaTypeWhenTrustCorporation(t *testing.T) { func TestPostLpaTypeWhenSessionErrors(t *testing.T) { form := url.Values{ - "lpa-type": {actor.LpaTypePropertyAndAffairs.String()}, + "lpa-type": {donordata.LpaTypePropertyAndAffairs.String()}, } w := httptest.NewRecorder() 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, &actor.DonorProvidedDetails{ + err := LpaType(nil, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", }) @@ -210,7 +210,7 @@ func TestPostLpaTypeWhenSessionErrors(t *testing.T) { func TestPostLpaTypeWhenEventErrors(t *testing.T) { form := url.Values{ - "lpa-type": {actor.LpaTypePropertyAndAffairs.String()}, + "lpa-type": {donordata.LpaTypePropertyAndAffairs.String()}, } ctx := page.ContextWithSessionData(context.Background(), &appcontext.SessionData{SessionID: "an-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, &actor.DonorProvidedDetails{ + err := LpaType(nil, donorStore, eventClient)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", }) @@ -238,7 +238,7 @@ func TestPostLpaTypeWhenEventErrors(t *testing.T) { func TestPostLpaTypeWhenStoreErrors(t *testing.T) { form := url.Values{ - "lpa-type": {actor.LpaTypePropertyAndAffairs.String()}, + "lpa-type": {donordata.LpaTypePropertyAndAffairs.String()}, } ctx := page.ContextWithSessionData(context.Background(), &appcontext.SessionData{SessionID: "an-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, &actor.DonorProvidedDetails{}) + err := LpaType(nil, donorStore, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := LpaType(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -278,7 +278,7 @@ func TestPostLpaTypeWhenValidationErrors(t *testing.T) { func TestReadLpaTypeForm(t *testing.T) { form := url.Values{ - "lpa-type": {actor.LpaTypePropertyAndAffairs.String()}, + "lpa-type": {donordata.LpaTypePropertyAndAffairs.String()}, } r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) @@ -286,7 +286,7 @@ func TestReadLpaTypeForm(t *testing.T) { result := readLpaTypeForm(r) - assert.Equal(t, actor.LpaTypePropertyAndAffairs, result.LpaType) + assert.Equal(t, donordata.LpaTypePropertyAndAffairs, result.LpaType) } func TestLpaTypeFormValidate(t *testing.T) { @@ -306,12 +306,12 @@ func TestLpaTypeFormValidate(t *testing.T) { }, "to personal welfare": { form: &lpaTypeForm{ - LpaType: actor.LpaTypePersonalWelfare, + LpaType: donordata.LpaTypePersonalWelfare, }, }, "to personal welfare when trust corporation": { form: &lpaTypeForm{ - LpaType: actor.LpaTypePersonalWelfare, + LpaType: donordata.LpaTypePersonalWelfare, }, hasTrustCorporation: true, errors: validation.With("lpa-type", validation.CustomError{Label: "youMustDeleteTrustCorporationToChangeLpaType"}), diff --git a/internal/donor/donorpage/one_login_identity_details.go b/internal/donor/donorpage/one_login_identity_details.go index ecd23981d8..5bb3400611 100644 --- a/internal/donor/donorpage/one_login_identity_details.go +++ b/internal/donor/donorpage/one_login_identity_details.go @@ -5,7 +5,7 @@ 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/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/validation" @@ -14,14 +14,14 @@ import ( type oneLoginIdentityDetailsData struct { App page.AppData Errors validation.List - DonorProvided *actor.DonorProvidedDetails + DonorProvided *donordata.DonorProvidedDetails 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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 d4b512c143..14c396fa34 100644 --- a/internal/donor/donorpage/one_login_identity_details_test.go +++ b/internal/donor/donorpage/one_login_identity_details_test.go @@ -7,8 +7,8 @@ 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/identity" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" @@ -22,29 +22,29 @@ func TestGetOneLoginIdentityDetails(t *testing.T) { dob := date.New("1", "2", "3") testcases := map[string]struct { - donorProvided *actor.DonorProvidedDetails + donorProvided *donordata.DonorProvidedDetails expectedDetailsMatch bool expectedDetailsUpdated bool url string }{ "details match": { - donorProvided: &actor.DonorProvidedDetails{ - Donor: actor.Donor{FirstNames: "a", LastName: "b", DateOfBirth: dob, Address: testAddress}, + donorProvided: &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{FirstNames: "a", LastName: "b", DateOfBirth: dob, Address: testAddress}, DonorIdentityUserData: identity.UserData{FirstNames: "a", LastName: "b", DateOfBirth: dob, CurrentAddress: testAddress}, }, expectedDetailsMatch: true, url: "/", }, "details do not match": { - donorProvided: &actor.DonorProvidedDetails{ - Donor: actor.Donor{FirstNames: "a"}, + donorProvided: &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{FirstNames: "a"}, DonorIdentityUserData: identity.UserData{FirstNames: "b"}, }, url: "/", }, "details updated": { - donorProvided: &actor.DonorProvidedDetails{ - Donor: actor.Donor{FirstNames: "a"}, + donorProvided: &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{FirstNames: "a"}, DonorIdentityUserData: identity.UserData{FirstNames: "b"}, }, url: "/?detailsUpdated=1", @@ -87,9 +87,9 @@ func TestPostOneLoginIdentityDetailsWhenYes(t *testing.T) { existingDob := date.New("1", "2", "3") identityDob := date.New("4", "5", "6") - updated := &actor.DonorProvidedDetails{ + updated := &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{FirstNames: "b", LastName: "b", DateOfBirth: identityDob, Address: place.Address{Line1: "a"}}, + 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"}}, } updated.UpdateCheckedHash() @@ -99,9 +99,9 @@ func TestPostOneLoginIdentityDetailsWhenYes(t *testing.T) { Put(r.Context(), updated). Return(nil) - err := OneLoginIdentityDetails(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := OneLoginIdentityDetails(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{FirstNames: "a", LastName: "a", DateOfBirth: existingDob, Address: testAddress}, + 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"}}, }) resp := w.Result() @@ -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, &actor.DonorProvidedDetails{LpaID: "lpa-id"}) + err := OneLoginIdentityDetails(nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{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, &actor.DonorProvidedDetails{LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}}) + err := OneLoginIdentityDetails(nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{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, &actor.DonorProvidedDetails{}) + err := OneLoginIdentityDetails(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{Donor: actor.Donor{FirstNames: "a"}}) + err := OneLoginIdentityDetails(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{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 214433a123..cfca3b4311 100644 --- a/internal/donor/donorpage/pay.go +++ b/internal/donor/donorpage/pay.go @@ -5,10 +5,11 @@ import ( "log/slog" "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/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/pay" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" ) func Pay( @@ -19,9 +20,9 @@ func Pay( randomString func(int) string, appPublicURL string, ) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { if donor.FeeType.IsNoFee() || donor.FeeType.IsHardshipFee() || donor.Tasks.PayForLpa.IsMoreEvidenceRequired() { - donor.Tasks.PayForLpa = actor.PaymentTaskPending + donor.Tasks.PayForLpa = task.PaymentStatePending if err := donorStore.Put(r.Context(), donor); err != nil { return err } diff --git a/internal/donor/donorpage/pay_test.go b/internal/donor/donorpage/pay_test.go index a01d6882f3..d821a9d0cc 100644 --- a/internal/donor/donorpage/pay_test.go +++ b/internal/donor/donorpage/pay_test.go @@ -6,10 +6,11 @@ import ( "net/http/httptest" "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/pay" "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" ) @@ -69,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, &actor.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", Donor: actor.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.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", Donor: donordata.Donor{Email: "a@b.com"}, FeeType: pay.FullFee}) resp := w.Result() assert.Nil(t, err) @@ -92,15 +93,15 @@ func TestPayWhenPaymentNotRequired(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", FeeType: feeType, - Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskPending}, + Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}, EvidenceDelivery: pay.Upload, }). Return(nil) - err := Pay(nil, nil, donorStore, nil, nil, "")(testAppData, w, r, &actor.DonorProvidedDetails{ + err := Pay(nil, nil, donorStore, nil, nil, "")(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", FeeType: feeType, EvidenceDelivery: pay.Upload, @@ -127,15 +128,15 @@ func TestPayWhenPostingEvidence(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", FeeType: feeType, - Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskPending}, + Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}, EvidenceDelivery: pay.Post, }). Return(nil) - err := Pay(nil, nil, donorStore, nil, nil, "")(testAppData, w, r, &actor.DonorProvidedDetails{ + err := Pay(nil, nil, donorStore, nil, nil, "")(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", FeeType: feeType, EvidenceDelivery: pay.Post, @@ -155,18 +156,18 @@ func TestPayWhenMoreEvidenceProvided(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", FeeType: pay.HalfFee, - Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskPending}, + Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}, EvidenceDelivery: pay.Upload, }). Return(nil) - err := Pay(nil, nil, donorStore, nil, nil, "")(testAppData, w, r, &actor.DonorProvidedDetails{ + err := Pay(nil, nil, donorStore, nil, nil, "")(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", FeeType: pay.HalfFee, - Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskMoreEvidenceRequired}, + Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateMoreEvidenceRequired}, EvidenceDelivery: pay.Upload, }) resp := w.Result() @@ -182,14 +183,14 @@ func TestPayWhenPaymentNotRequiredWhenDonorStorePutError(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", FeeType: pay.NoFee, - Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskPending}, + Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}, }). Return(expectedError) - err := Pay(nil, nil, donorStore, nil, nil, "")(testAppData, w, r, &actor.DonorProvidedDetails{ + err := Pay(nil, nil, donorStore, nil, nil, "")(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", FeeType: pay.NoFee, }) @@ -234,13 +235,13 @@ 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, &actor.DonorProvidedDetails{ + 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: actor.Donor{Email: "a@b.com"}, + Donor: donordata.Donor{Email: "a@b.com"}, FeeType: pay.HalfFee, - Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskDenied}, - PaymentDetails: []actor.Payment{{Amount: 4100}}, + Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateDenied}, + PaymentDetails: []donordata.Payment{{Amount: 4100}}, }) resp := w.Result() @@ -258,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, &actor.DonorProvidedDetails{}) + err := Pay(nil, nil, nil, payClient, func(int) string { return "123456789012" }, "")(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.ErrorIs(t, err, expectedError) } @@ -284,7 +285,7 @@ func TestPayWhenSessionErrors(t *testing.T) { }, }, nil) - err := Pay(nil, sessionStore, nil, payClient, func(int) string { return "123456789012" }, "")(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := Pay(nil, sessionStore, nil, payClient, func(int) string { return "123456789012" }, "")(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } diff --git a/internal/donor/donorpage/payment_confirmation.go b/internal/donor/donorpage/payment_confirmation.go index 5ecc753f00..c247af9ea2 100644 --- a/internal/donor/donorpage/payment_confirmation.go +++ b/internal/donor/donorpage/payment_confirmation.go @@ -8,11 +8,12 @@ import ( "slices" "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/event" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/pay" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -27,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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { paymentSession, err := sessionStore.Payment(r) if err != nil { return err @@ -42,7 +43,7 @@ func PaymentConfirmation(logger Logger, tmpl template.Template, payClient PayCli return errors.New("TODO: we need to give some options") } - paymentDetail := actor.Payment{ + paymentDetail := donordata.Payment{ PaymentReference: payment.Reference, PaymentId: payment.PaymentID, Amount: payment.AmountPence.Pence(), @@ -79,15 +80,15 @@ func PaymentConfirmation(logger Logger, tmpl template.Template, payClient PayCli } switch donor.Tasks.PayForLpa { - case actor.PaymentTaskInProgress: + case task.PaymentStateInProgress: if donor.FeeType.IsFullFee() && donor.FeeAmount() == 0 { - donor.Tasks.PayForLpa = actor.PaymentTaskCompleted + donor.Tasks.PayForLpa = task.PaymentStateCompleted } else { - donor.Tasks.PayForLpa = actor.PaymentTaskPending + donor.Tasks.PayForLpa = task.PaymentStatePending } - case actor.PaymentTaskApproved, actor.PaymentTaskDenied: + case task.PaymentStateApproved, task.PaymentStateDenied: if donor.FeeAmount() == 0 { - donor.Tasks.PayForLpa = actor.PaymentTaskCompleted + donor.Tasks.PayForLpa = task.PaymentStateCompleted nextPage = page.Paths.TaskList if donor.Voucher.Allowed { diff --git a/internal/donor/donorpage/payment_confirmation_test.go b/internal/donor/donorpage/payment_confirmation_test.go index 0e478a5ee5..72c366df08 100644 --- a/internal/donor/donorpage/payment_confirmation_test.go +++ b/internal/donor/donorpage/payment_confirmation_test.go @@ -10,10 +10,12 @@ import ( "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" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/pay" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -66,22 +68,22 @@ func TestGetPaymentConfirmationFullFee(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ - Type: actor.LpaTypePersonalWelfare, - Donor: actor.Donor{FirstNames: "a", LastName: "b"}, + Put(r.Context(), &donordata.DonorProvidedDetails{ + Type: donordata.LpaTypePersonalWelfare, + Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, LpaUID: "lpa-uid", FeeType: pay.FullFee, EvidenceDelivery: tc.evidenceDelivery, - CertificateProvider: actor.CertificateProvider{ + CertificateProvider: donordata.CertificateProvider{ Email: "certificateprovider@example.com", }, - PaymentDetails: []actor.Payment{{ + PaymentDetails: []donordata.Payment{{ PaymentId: "abc123", PaymentReference: "123456789012", Amount: 8200, }}, - Tasks: actor.DonorTasks{ - PayForLpa: actor.PaymentTaskCompleted, + Tasks: donordata.DonorTasks{ + PayForLpa: task.PaymentStateCompleted, }, }). Return(nil) @@ -98,18 +100,18 @@ 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, &actor.DonorProvidedDetails{ + err := PaymentConfirmation(newMockLogger(t), template.Execute, payClient, donorStore, sessionStore, nil, nil, eventClient, notifyClient)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaUID: "lpa-uid", FeeType: pay.FullFee, EvidenceDelivery: tc.evidenceDelivery, - CertificateProvider: actor.CertificateProvider{ + CertificateProvider: donordata.CertificateProvider{ Email: "certificateprovider@example.com", }, - Tasks: actor.DonorTasks{ - PayForLpa: actor.PaymentTaskInProgress, + Tasks: donordata.DonorTasks{ + PayForLpa: task.PaymentStateInProgress, }, - Donor: actor.Donor{FirstNames: "a", LastName: "b"}, - Type: actor.LpaTypePersonalWelfare, + Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, + Type: donordata.LpaTypePersonalWelfare, }) resp := w.Result() @@ -147,21 +149,21 @@ func TestGetPaymentConfirmationHalfFee(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ - Type: actor.LpaTypePersonalWelfare, - Donor: actor.Donor{FirstNames: "a", LastName: "b"}, + Put(r.Context(), &donordata.DonorProvidedDetails{ + Type: donordata.LpaTypePersonalWelfare, + Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, LpaUID: "lpa-uid", FeeType: pay.HalfFee, - CertificateProvider: actor.CertificateProvider{ + CertificateProvider: donordata.CertificateProvider{ Email: "certificateprovider@example.com", }, - PaymentDetails: []actor.Payment{{ + PaymentDetails: []donordata.Payment{{ PaymentId: "abc123", PaymentReference: "123456789012", Amount: 4100, }}, - Tasks: actor.DonorTasks{ - PayForLpa: actor.PaymentTaskPending, + Tasks: donordata.DonorTasks{ + PayForLpa: task.PaymentStatePending, }, }). Return(nil) @@ -178,16 +180,16 @@ 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, &actor.DonorProvidedDetails{ - Type: actor.LpaTypePersonalWelfare, - Donor: actor.Donor{FirstNames: "a", LastName: "b"}, + err := PaymentConfirmation(newMockLogger(t), template.Execute, payClient, donorStore, sessionStore, nil, nil, eventClient, notifyClient)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Type: donordata.LpaTypePersonalWelfare, + Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, LpaUID: "lpa-uid", FeeType: pay.HalfFee, - CertificateProvider: actor.CertificateProvider{ + CertificateProvider: donordata.CertificateProvider{ Email: "certificateprovider@example.com", }, - Tasks: actor.DonorTasks{ - PayForLpa: actor.PaymentTaskInProgress, + Tasks: donordata.DonorTasks{ + PayForLpa: task.PaymentStateInProgress, }, }) resp := w.Result() @@ -197,8 +199,8 @@ func TestGetPaymentConfirmationHalfFee(t *testing.T) { } func TestGetPaymentConfirmationApprovedOrDenied(t *testing.T) { - for _, task := range []actor.PaymentTask{actor.PaymentTaskApproved, actor.PaymentTaskDenied} { - t.Run(task.String(), func(t *testing.T) { + for _, taskState := range []task.PaymentState{task.PaymentStateApproved, task.PaymentStateDenied} { + t.Run(taskState.String(), func(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/payment-confirmation", nil) @@ -226,21 +228,21 @@ func TestGetPaymentConfirmationApprovedOrDenied(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ - Type: actor.LpaTypePersonalWelfare, - Donor: actor.Donor{FirstNames: "a", LastName: "b"}, + Put(r.Context(), &donordata.DonorProvidedDetails{ + Type: donordata.LpaTypePersonalWelfare, + Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, LpaUID: "lpa-uid", FeeType: pay.FullFee, - CertificateProvider: actor.CertificateProvider{ + CertificateProvider: donordata.CertificateProvider{ Email: "certificateprovider@example.com", }, - PaymentDetails: []actor.Payment{{ + PaymentDetails: []donordata.Payment{{ PaymentId: "abc123", PaymentReference: "123456789012", Amount: 8200, }}, - Tasks: actor.DonorTasks{ - PayForLpa: actor.PaymentTaskCompleted, + Tasks: donordata.DonorTasks{ + PayForLpa: task.PaymentStateCompleted, }, }). Return(nil) @@ -257,16 +259,16 @@ 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, &actor.DonorProvidedDetails{ - Type: actor.LpaTypePersonalWelfare, - Donor: actor.Donor{FirstNames: "a", LastName: "b"}, + err := PaymentConfirmation(newMockLogger(t), template.Execute, payClient, donorStore, sessionStore, nil, nil, eventClient, notifyClient)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Type: donordata.LpaTypePersonalWelfare, + Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, LpaUID: "lpa-uid", FeeType: pay.FullFee, - CertificateProvider: actor.CertificateProvider{ + CertificateProvider: donordata.CertificateProvider{ Email: "certificateprovider@example.com", }, - Tasks: actor.DonorTasks{ - PayForLpa: task, + Tasks: donordata.DonorTasks{ + PayForLpa: taskState, }, }) resp := w.Result() @@ -278,26 +280,26 @@ func TestGetPaymentConfirmationApprovedOrDenied(t *testing.T) { } func TestGetPaymentConfirmationApprovedOrDeniedWhenSigned(t *testing.T) { - for _, task := range []actor.PaymentTask{actor.PaymentTaskApproved, actor.PaymentTaskDenied} { - t.Run(task.String(), func(t *testing.T) { + for _, taskState := range []task.PaymentState{task.PaymentStateApproved, task.PaymentStateDenied} { + t.Run(taskState.String(), func(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/payment-confirmation", nil) - updatedDonor := &actor.DonorProvidedDetails{ - Type: actor.LpaTypePersonalWelfare, - Donor: actor.Donor{FirstNames: "a", LastName: "b"}, + updatedDonor := &donordata.DonorProvidedDetails{ + Type: donordata.LpaTypePersonalWelfare, + Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, LpaUID: "lpa-uid", FeeType: pay.FullFee, - CertificateProvider: actor.CertificateProvider{ + CertificateProvider: donordata.CertificateProvider{ Email: "certificateprovider@example.com", }, - PaymentDetails: []actor.Payment{{ + PaymentDetails: []donordata.Payment{{ PaymentId: "abc123", PaymentReference: "123456789012", Amount: 8200, }}, - Tasks: actor.DonorTasks{ - PayForLpa: actor.PaymentTaskCompleted, + Tasks: donordata.DonorTasks{ + PayForLpa: task.PaymentStateCompleted, ConfirmYourIdentityAndSign: actor.IdentityTaskCompleted, }, } @@ -351,16 +353,16 @@ 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, &actor.DonorProvidedDetails{ - Type: actor.LpaTypePersonalWelfare, - Donor: actor.Donor{FirstNames: "a", LastName: "b"}, + err := PaymentConfirmation(newMockLogger(t), template.Execute, payClient, donorStore, sessionStore, shareCodeSender, lpaStoreClient, eventClient, notifyClient)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Type: donordata.LpaTypePersonalWelfare, + Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, LpaUID: "lpa-uid", FeeType: pay.FullFee, - CertificateProvider: actor.CertificateProvider{ + CertificateProvider: donordata.CertificateProvider{ Email: "certificateprovider@example.com", }, - Tasks: actor.DonorTasks{ - PayForLpa: task, + Tasks: donordata.DonorTasks{ + PayForLpa: taskState, ConfirmYourIdentityAndSign: actor.IdentityTaskCompleted, }, }) @@ -373,7 +375,7 @@ func TestGetPaymentConfirmationApprovedOrDeniedWhenSigned(t *testing.T) { } func TestGetPaymentConfirmationApprovedOrDeniedWhenVoucherAllowed(t *testing.T) { - for _, task := range []actor.PaymentTask{actor.PaymentTaskApproved, actor.PaymentTaskDenied} { + for _, task := range []task.PaymentState{task.PaymentStateApproved, task.PaymentStateDenied} { t.Run(task.String(), func(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/payment-confirmation", nil) @@ -413,16 +415,16 @@ 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, &actor.DonorProvidedDetails{ - Type: actor.LpaTypePersonalWelfare, - Donor: actor.Donor{FirstNames: "a", LastName: "b"}, + err := PaymentConfirmation(newMockLogger(t), template.Execute, payClient, donorStore, sessionStore, nil, nil, eventClient, notifyClient)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Type: donordata.LpaTypePersonalWelfare, + Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, LpaUID: "lpa-uid", FeeType: pay.FullFee, - CertificateProvider: actor.CertificateProvider{ + CertificateProvider: donordata.CertificateProvider{ Email: "certificateprovider@example.com", }, - Voucher: actor.Voucher{Allowed: true}, - Tasks: actor.DonorTasks{ + Voucher: donordata.Voucher{Allowed: true}, + Tasks: donordata.DonorTasks{ PayForLpa: task, }, }) @@ -451,13 +453,13 @@ func TestGetPaymentConfirmationWhenNotSuccess(t *testing.T) { }, }, nil) - err := PaymentConfirmation(newMockLogger(t), nil, payClient, nil, sessionStore, nil, nil, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := PaymentConfirmation(newMockLogger(t), nil, payClient, nil, sessionStore, nil, nil, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaUID: "lpa-uid", - CertificateProvider: actor.CertificateProvider{ + CertificateProvider: donordata.CertificateProvider{ Email: "certificateprovider@example.com", }, - Tasks: actor.DonorTasks{ - PayForLpa: actor.PaymentTaskInProgress, + Tasks: donordata.DonorTasks{ + PayForLpa: task.PaymentStateInProgress, }, }) @@ -475,7 +477,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, &actor.DonorProvidedDetails{}) + err := PaymentConfirmation(nil, template.Execute, newMockPayClient(t), nil, sessionStore, nil, nil, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -496,7 +498,7 @@ func TestGetPaymentConfirmationWhenErrorGettingPayment(t *testing.T) { template := newMockTemplate(t) - err := PaymentConfirmation(nil, template.Execute, payClient, nil, sessionStore, nil, nil, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := PaymentConfirmation(nil, template.Execute, payClient, nil, sessionStore, nil, nil, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.ErrorIs(t, err, expectedError) @@ -543,12 +545,12 @@ 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, &actor.DonorProvidedDetails{ - CertificateProvider: actor.CertificateProvider{ + err := PaymentConfirmation(logger, template.Execute, payClient, donorStore, sessionStore, nil, nil, eventClient, notifyClient)(testAppData, w, r, &donordata.DonorProvidedDetails{ + CertificateProvider: donordata.CertificateProvider{ Email: "certificateprovider@example.com", }, - Type: actor.LpaTypePersonalWelfare, - Donor: actor.Donor{FirstNames: "a", LastName: "b"}, + Type: donordata.LpaTypePersonalWelfare, + Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, LpaUID: "lpa-uid"}) resp := w.Result() @@ -571,9 +573,9 @@ 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, &actor.DonorProvidedDetails{ + err := PaymentConfirmation(nil, nil, payClient, nil, sessionStore, nil, nil, eventClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ FeeType: pay.HalfFee, - CertificateProvider: actor.CertificateProvider{ + CertificateProvider: donordata.CertificateProvider{ Email: "certificateprovider@example.com", }, }) @@ -608,11 +610,11 @@ func TestGetPaymentConfirmationWhenNotifyClientError(t *testing.T) { testAppData.Localizer = localizer - err := PaymentConfirmation(nil, nil, payClient, nil, sessionStore, nil, nil, eventClient, notifyClient)(testAppData, w, r, &actor.DonorProvidedDetails{ - Type: actor.LpaTypePersonalWelfare, - Donor: actor.Donor{FirstNames: "a", LastName: "b"}, + err := PaymentConfirmation(nil, nil, payClient, nil, sessionStore, nil, nil, eventClient, notifyClient)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Type: donordata.LpaTypePersonalWelfare, + Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, FeeType: pay.HalfFee, - CertificateProvider: actor.CertificateProvider{ + CertificateProvider: donordata.CertificateProvider{ Email: "certificateprovider@example.com", }, }) @@ -650,12 +652,12 @@ 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, &actor.DonorProvidedDetails{ + err := PaymentConfirmation(nil, nil, payClient, donorStore, sessionStore, nil, nil, eventClient, notifyClient)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaUID: "lpa-uid", - Type: actor.LpaTypePersonalWelfare, - Donor: actor.Donor{FirstNames: "a", LastName: "b"}, + Type: donordata.LpaTypePersonalWelfare, + Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, FeeType: pay.HalfFee, - CertificateProvider: actor.CertificateProvider{ + CertificateProvider: donordata.CertificateProvider{ Email: "certificateprovider@example.com", }, }) @@ -698,16 +700,16 @@ 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, &actor.DonorProvidedDetails{ + err := PaymentConfirmation(newMockLogger(t), nil, payClient, nil, sessionStore, shareCodeSender, lpaStoreClient, eventClient, notifyClient)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaUID: "lpa-uid", - Type: actor.LpaTypePersonalWelfare, - Donor: actor.Donor{FirstNames: "a", LastName: "b"}, + Type: donordata.LpaTypePersonalWelfare, + Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, FeeType: pay.FullFee, - CertificateProvider: actor.CertificateProvider{ + CertificateProvider: donordata.CertificateProvider{ Email: "certificateprovider@example.com", }, - Tasks: actor.DonorTasks{ - PayForLpa: actor.PaymentTaskApproved, + Tasks: donordata.DonorTasks{ + PayForLpa: task.PaymentStateApproved, ConfirmYourIdentityAndSign: actor.IdentityTaskCompleted, }, }) @@ -743,16 +745,16 @@ 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, &actor.DonorProvidedDetails{ + err := PaymentConfirmation(newMockLogger(t), nil, payClient, nil, sessionStore, shareCodeSender, nil, eventClient, notifyClient)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaUID: "lpa-uid", - Type: actor.LpaTypePersonalWelfare, - Donor: actor.Donor{FirstNames: "a", LastName: "b"}, + Type: donordata.LpaTypePersonalWelfare, + Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, FeeType: pay.FullFee, - CertificateProvider: actor.CertificateProvider{ + CertificateProvider: donordata.CertificateProvider{ Email: "certificateprovider@example.com", }, - Tasks: actor.DonorTasks{ - PayForLpa: actor.PaymentTaskApproved, + Tasks: donordata.DonorTasks{ + PayForLpa: task.PaymentStateApproved, ConfirmYourIdentityAndSign: actor.IdentityTaskCompleted, }, }) diff --git a/internal/donor/donorpage/previous_application_number.go b/internal/donor/donorpage/previous_application_number.go index 7815c8603c..19a458eef9 100644 --- a/internal/donor/donorpage/previous_application_number.go +++ b/internal/donor/donorpage/previous_application_number.go @@ -4,7 +4,7 @@ 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/event" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 bbb06298df..73d8ef0324 100644 --- a/internal/donor/donorpage/previous_application_number_test.go +++ b/internal/donor/donorpage/previous_application_number_test.go @@ -7,7 +7,7 @@ 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/event" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -27,7 +27,7 @@ func TestGetPreviousApplicationNumber(t *testing.T) { }). Return(nil) - err := PreviousApplicationNumber(template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := PreviousApplicationNumber(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{PreviousApplicationNumber: "ABC"}) + err := PreviousApplicationNumber(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{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, &actor.DonorProvidedDetails{}) + err := PreviousApplicationNumber(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ 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, &actor.DonorProvidedDetails{ + err := PreviousApplicationNumber(nil, donorStore, eventClient)(testAppData, w, r, &donordata.DonorProvidedDetails{ 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, &actor.DonorProvidedDetails{ + err := PreviousApplicationNumber(nil, donorStore, eventClient)(testAppData, w, r, &donordata.DonorProvidedDetails{ 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, &actor.DonorProvidedDetails{}) + err := PreviousApplicationNumber(nil, donorStore, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := PreviousApplicationNumber(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/previous_fee.go b/internal/donor/donorpage/previous_fee.go index 324105e750..f245584630 100644 --- a/internal/donor/donorpage/previous_fee.go +++ b/internal/donor/donorpage/previous_fee.go @@ -4,7 +4,7 @@ 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/pay" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 0d541c645f..9b2a478143 100644 --- a/internal/donor/donorpage/previous_fee_test.go +++ b/internal/donor/donorpage/previous_fee_test.go @@ -7,7 +7,7 @@ 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/pay" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -28,7 +28,7 @@ func TestGetPreviousFee(t *testing.T) { }). Return(nil) - err := PreviousFee(template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := PreviousFee(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{PreviousFee: pay.PreviousFeeHalf}) + err := PreviousFee(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{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, &actor.DonorProvidedDetails{}) + err := PreviousFee(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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 := &actor.DonorProvidedDetails{ + donor := &donordata.DonorProvidedDetails{ 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, &actor.DonorProvidedDetails{LpaID: "lpa-id"}) + err := PreviousFee(nil, payer.Execute, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) assert.Nil(t, err) } @@ -112,13 +112,13 @@ func TestPostPreviousFeeWhenOtherFee(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", PreviousFee: pay.PreviousFeeHalf, }). Return(nil) - err := PreviousFee(nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id"}) + err := PreviousFee(nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{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, &actor.DonorProvidedDetails{ + err := PreviousFee(nil, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ 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, &actor.DonorProvidedDetails{}) + err := PreviousFee(nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := PreviousFee(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/register.go b/internal/donor/donorpage/register.go index fd44b5ac22..a2b93d7a08 100644 --- a/internal/donor/donorpage/register.go +++ b/internal/donor/donorpage/register.go @@ -11,6 +11,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "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/event" "github.com/ministryofjustice/opg-modernising-lpa/internal/identity" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" @@ -28,7 +29,7 @@ type LpaStoreResolvingService interface { Get(ctx context.Context) (*lpastore.Lpa, error) } -type Handler func(data page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error +type Handler func(data page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error type Template func(io.Writer, interface{}) error @@ -39,15 +40,15 @@ type Logger interface { } type DonorStore interface { - Get(ctx context.Context) (*actor.DonorProvidedDetails, error) - Latest(ctx context.Context) (*actor.DonorProvidedDetails, error) - Put(ctx context.Context, donor *actor.DonorProvidedDetails) error + Get(ctx context.Context) (*donordata.DonorProvidedDetails, error) + Latest(ctx context.Context) (*donordata.DonorProvidedDetails, error) + Put(ctx context.Context, donor *donordata.DonorProvidedDetails) error Delete(ctx context.Context) error Link(ctx context.Context, data actor.ShareCodeData, donorEmail string) error } type GetDonorStore interface { - Get(context.Context) (*actor.DonorProvidedDetails, error) + Get(context.Context) (*donordata.DonorProvidedDetails, error) } type CertificateProviderStore interface { @@ -75,7 +76,7 @@ type AddressClient interface { type ShareCodeSender interface { SendCertificateProviderInvite(context.Context, page.AppData, page.CertificateProviderInvite) error - SendCertificateProviderPrompt(context.Context, page.AppData, *actor.DonorProvidedDetails) error + SendCertificateProviderPrompt(context.Context, page.AppData, *donordata.DonorProvidedDetails) error } type OneLoginClient interface { @@ -101,8 +102,8 @@ type SessionStore interface { } type WitnessCodeSender interface { - SendToCertificateProvider(context.Context, *actor.DonorProvidedDetails, page.Localizer) error - SendToIndependentWitness(context.Context, *actor.DonorProvidedDetails, page.Localizer) error + SendToCertificateProvider(context.Context, *donordata.DonorProvidedDetails, page.Localizer) error + SendToIndependentWitness(context.Context, *donordata.DonorProvidedDetails, page.Localizer) error } type UidClient interface { @@ -122,8 +123,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, *actor.DonorProvidedDetails, string, []byte) (page.Document, error) - Submit(context.Context, *actor.DonorProvidedDetails, page.Documents) error + Create(context.Context, *donordata.DonorProvidedDetails, string, []byte) (page.Document, error) + Submit(context.Context, *donordata.DonorProvidedDetails, page.Documents) error } type EventClient interface { @@ -140,8 +141,8 @@ type DashboardStore interface { type LpaStoreClient interface { Lpa(ctx context.Context, lpaUID string) (*lpastore.Lpa, error) - SendDonorConfirmIdentity(ctx context.Context, donor *actor.DonorProvidedDetails) error - SendLpa(ctx context.Context, details *actor.DonorProvidedDetails) error + SendDonorConfirmIdentity(ctx context.Context, donor *donordata.DonorProvidedDetails) error + SendLpa(ctx context.Context, details *donordata.DonorProvidedDetails) error } type ShareCodeStore interface { diff --git a/internal/donor/donorpage/register_test.go b/internal/donor/donorpage/register_test.go index 22158016e9..52a757a663 100644 --- a/internal/donor/donorpage/register_test.go +++ b/internal/donor/donorpage/register_test.go @@ -11,6 +11,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/date" + "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/onelogin" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" @@ -144,7 +145,7 @@ func TestMakeLpaHandleWhenDetailsProvidedAndUIDExists(t *testing.T) { LpaID: "123", SupporterData: &page.SupporterData{ DonorFullName: "Jane Smith", - LpaType: actor.LpaTypePropertyAndAffairs, + LpaType: donordata.LpaTypePropertyAndAffairs, }, }, loginSesh: &sesh.LoginSession{Sub: "random", OrganisationID: "org-id"}, @@ -167,20 +168,20 @@ func TestMakeLpaHandleWhenDetailsProvidedAndUIDExists(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(mock.Anything). - Return(&actor.DonorProvidedDetails{Donor: actor.Donor{ + Return(&donordata.DonorProvidedDetails{Donor: donordata.Donor{ FirstNames: "Jane", LastName: "Smith", DateOfBirth: date.New("2000", "1", "2"), Address: place.Address{Postcode: "ABC123"}, Email: "a@example.com", }, - Type: actor.LpaTypePropertyAndAffairs, - Tasks: actor.DonorTasks{YourDetails: actor.TaskCompleted}, + Type: donordata.LpaTypePropertyAndAffairs, + Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted}, LpaUID: "a-uid", }, nil) handle := makeLpaHandle(mux, sessionStore, nil, donorStore) - handle("/path", page.None, func(appData page.AppData, hw http.ResponseWriter, hr *http.Request, _ *actor.DonorProvidedDetails) error { + handle("/path", page.None, func(appData page.AppData, hw http.ResponseWriter, hr *http.Request, _ *donordata.DonorProvidedDetails) error { assert.Equal(t, tc.expectedAppData, appData) assert.Equal(t, w, hw) @@ -214,32 +215,32 @@ func TestMakeHandleLpaWhenDonorEmailNotSet(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(mock.Anything). - Return(&actor.DonorProvidedDetails{Donor: actor.Donor{ + Return(&donordata.DonorProvidedDetails{Donor: donordata.Donor{ FirstNames: "Jane", LastName: "Smith", DateOfBirth: date.New("2000", "1", "2"), Address: place.Address{Postcode: "ABC123"}, }, - Type: actor.LpaTypePropertyAndAffairs, - Tasks: actor.DonorTasks{YourDetails: actor.TaskCompleted}, + Type: donordata.LpaTypePropertyAndAffairs, + Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted}, LpaUID: "a-uid", }, nil) donorStore.EXPECT(). - Put(mock.Anything, &actor.DonorProvidedDetails{Donor: actor.Donor{ + Put(mock.Anything, &donordata.DonorProvidedDetails{Donor: donordata.Donor{ FirstNames: "Jane", LastName: "Smith", DateOfBirth: date.New("2000", "1", "2"), Address: place.Address{Postcode: "ABC123"}, Email: "a@example.com", }, - Type: actor.LpaTypePropertyAndAffairs, - Tasks: actor.DonorTasks{YourDetails: actor.TaskCompleted}, + Type: donordata.LpaTypePropertyAndAffairs, + Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted}, 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, _ *actor.DonorProvidedDetails) error { + handle("/path", page.None, func(appData page.AppData, hw http.ResponseWriter, hr *http.Request, _ *donordata.DonorProvidedDetails) error { hw.WriteHeader(http.StatusTeapot) return nil }) @@ -262,7 +263,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, _ *actor.DonorProvidedDetails) error { + handle("/path", page.None, func(_ page.AppData, _ http.ResponseWriter, _ *http.Request, _ *donordata.DonorProvidedDetails) error { return expectedError }) @@ -279,14 +280,14 @@ func TestMakeLpaHandleWhenDonorStoreError(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(mock.Anything). - Return(&actor.DonorProvidedDetails{}, expectedError) + Return(&donordata.DonorProvidedDetails{}, expectedError) return donorStore }, "put": func() *mockDonorStore { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(mock.Anything). - Return(&actor.DonorProvidedDetails{}, nil) + Return(&donordata.DonorProvidedDetails{}, nil) donorStore.EXPECT(). Put(mock.Anything, mock.Anything). Return(expectedError) @@ -311,7 +312,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, _ *actor.DonorProvidedDetails) error { + handle("/path", page.None, func(_ page.AppData, _ http.ResponseWriter, _ *http.Request, _ *donordata.DonorProvidedDetails) error { return expectedError }) @@ -339,10 +340,10 @@ func TestMakeLpaHandleWhenCannotGoToURL(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(mock.Anything). - Return(&actor.DonorProvidedDetails{LpaID: "123", Donor: actor.Donor{Email: "a@example.com"}}, nil) + Return(&donordata.DonorProvidedDetails{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, _ *actor.DonorProvidedDetails) error { + handle(path, page.None, func(_ page.AppData, _ http.ResponseWriter, _ *http.Request, _ *donordata.DonorProvidedDetails) error { return nil }) @@ -366,11 +367,11 @@ func TestMakeLpaHandleSessionExistingSessionData(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(mock.Anything). - Return(&actor.DonorProvidedDetails{Donor: actor.Donor{Email: "a@example.com"}}, nil) + Return(&donordata.DonorProvidedDetails{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, _ *actor.DonorProvidedDetails) error { + handle("/path", page.RequireSession|page.CanGoBack, func(appData page.AppData, hw http.ResponseWriter, hr *http.Request, _ *donordata.DonorProvidedDetails) error { assert.Equal(t, page.AppData{ Page: "/lpa/123/path", SessionID: "cmFuZG9t", @@ -409,11 +410,11 @@ func TestMakeLpaHandleErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(mock.Anything). - Return(&actor.DonorProvidedDetails{Donor: actor.Donor{Email: "a@example.com"}}, nil) + Return(&donordata.DonorProvidedDetails{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, _ *actor.DonorProvidedDetails) error { + handle("/path", page.RequireSession, func(_ page.AppData, _ http.ResponseWriter, _ *http.Request, _ *donordata.DonorProvidedDetails) 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 876f95559c..90fc36e142 100644 --- a/internal/donor/donorpage/register_with_court_of_protection.go +++ b/internal/donor/donorpage/register_with_court_of_protection.go @@ -5,7 +5,7 @@ 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/validation" @@ -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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 90ea18a61d..0742236aae 100644 --- a/internal/donor/donorpage/register_with_court_of_protection_test.go +++ b/internal/donor/donorpage/register_with_court_of_protection_test.go @@ -8,7 +8,7 @@ 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/validation" @@ -28,7 +28,7 @@ func TestGetRegisterWithCourtOfProtection(t *testing.T) { }). Return(nil) - err := RegisterWithCourtOfProtection(template.Execute, nil, testNowFn)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := RegisterWithCourtOfProtection(template.Execute, nil, testNowFn)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := RegisterWithCourtOfProtection(template.Execute, nil, testNowFn)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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(), &actor.DonorProvidedDetails{LpaID: "lpa-id", RegisteringWithCourtOfProtection: true}). + Put(context.Background(), &donordata.DonorProvidedDetails{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, &actor.DonorProvidedDetails{LpaID: "lpa-id"}) + err := RegisterWithCourtOfProtection(nil, tc.donorStore(), testNowFn)(testAppData, w, r, &donordata.DonorProvidedDetails{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, &actor.DonorProvidedDetails{}) + err := RegisterWithCourtOfProtection(nil, donorStore, testNowFn)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := RegisterWithCourtOfProtection(template.Execute, nil, testNowFn)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/remove_attorney.go b/internal/donor/donorpage/remove_attorney.go index bcdf1fea25..8a09bcb04f 100644 --- a/internal/donor/donorpage/remove_attorney.go +++ b/internal/donor/donorpage/remove_attorney.go @@ -5,8 +5,8 @@ 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/validation" @@ -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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { attorney, found := donor.Attorneys.Get(actoruid.FromRequest(r)) if found == false { @@ -43,7 +43,7 @@ func RemoveAttorney(tmpl template.Template, donorStore DonorStore) Handler { if data.Form.YesNo == form.Yes { donor.Attorneys.Delete(attorney) if donor.Attorneys.Len() == 1 { - donor.AttorneyDecisions = actor.AttorneyDecisions{} + donor.AttorneyDecisions = donordata.AttorneyDecisions{} } donor.Tasks.ChooseAttorneys = page.ChooseAttorneysState(donor.Attorneys, donor.AttorneyDecisions) diff --git a/internal/donor/donorpage/remove_attorney_test.go b/internal/donor/donorpage/remove_attorney_test.go index 07ba7c4545..41e0de5f33 100644 --- a/internal/donor/donorpage/remove_attorney_test.go +++ b/internal/donor/donorpage/remove_attorney_test.go @@ -9,6 +9,7 @@ import ( "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" @@ -22,7 +23,7 @@ func TestGetRemoveAttorney(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/?id="+uid.String(), nil) - attorney := actor.Attorney{ + attorney := donordata.Attorney{ UID: uid, FirstNames: "John", LastName: "Smith", @@ -41,7 +42,7 @@ func TestGetRemoveAttorney(t *testing.T) { }). Return(nil) - err := RemoveAttorney(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorney}}}) + err := RemoveAttorney(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney}}}) resp := w.Result() @@ -55,14 +56,14 @@ func TestGetRemoveAttorneyAttorneyDoesNotExist(t *testing.T) { template := newMockTemplate(t) - attorney := actor.Attorney{ + attorney := donordata.Attorney{ UID: actoruid.New(), Address: place.Address{ Line1: "1 Road way", }, } - err := RemoveAttorney(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id", Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorney}}}) + err := RemoveAttorney(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney}}}) resp := w.Result() @@ -72,47 +73,47 @@ func TestGetRemoveAttorneyAttorneyDoesNotExist(t *testing.T) { } func TestPostRemoveAttorney(t *testing.T) { - attorneyWithEmail := actor.Attorney{UID: actoruid.New(), Email: "a"} - attorneyWithAddress := actor.Attorney{UID: actoruid.New(), Address: place.Address{Line1: "1 Road way"}} - attorneyWithoutAddress := actor.Attorney{UID: actoruid.New()} + attorneyWithEmail := donordata.Attorney{UID: actoruid.New(), Email: "a"} + attorneyWithAddress := donordata.Attorney{UID: actoruid.New(), Address: place.Address{Line1: "1 Road way"}} + attorneyWithoutAddress := donordata.Attorney{UID: actoruid.New()} testcases := map[string]struct { - donor *actor.DonorProvidedDetails - updatedDonor *actor.DonorProvidedDetails + donor *donordata.DonorProvidedDetails + updatedDonor *donordata.DonorProvidedDetails redirect page.LpaPath }{ "many left": { - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorneyWithEmail, attorneyWithAddress, attorneyWithoutAddress}}, - AttorneyDecisions: actor.AttorneyDecisions{How: actor.Jointly}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithEmail, attorneyWithAddress, attorneyWithoutAddress}}, + AttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, }, - updatedDonor: &actor.DonorProvidedDetails{ + updatedDonor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorneyWithEmail, attorneyWithAddress}}, - AttorneyDecisions: actor.AttorneyDecisions{How: actor.Jointly}, - Tasks: actor.DonorTasks{ChooseAttorneys: actor.TaskInProgress}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithEmail, attorneyWithAddress}}, + AttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, + Tasks: donordata.DonorTasks{ChooseAttorneys: actor.TaskInProgress}, }, redirect: page.Paths.ChooseAttorneysSummary, }, "one left": { - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorneyWithAddress, attorneyWithoutAddress}}, - AttorneyDecisions: actor.AttorneyDecisions{How: actor.Jointly}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithAddress, attorneyWithoutAddress}}, + AttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, }, - updatedDonor: &actor.DonorProvidedDetails{ + updatedDonor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorneyWithAddress}}, - Tasks: actor.DonorTasks{ChooseAttorneys: actor.TaskInProgress}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithAddress}}, + Tasks: donordata.DonorTasks{ChooseAttorneys: actor.TaskInProgress}, }, redirect: page.Paths.ChooseAttorneysSummary, }, "none left": { - donor: &actor.DonorProvidedDetails{LpaID: "lpa-id", Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorneyWithoutAddress}}}, - updatedDonor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithoutAddress}}}, + updatedDonor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{}}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{}}, }, redirect: page.Paths.ChooseAttorneysSummary, }, @@ -148,14 +149,14 @@ func TestPostRemoveAttorneyWithFormValueNo(t *testing.T) { form.FieldNames.YesNo: {form.No.String()}, } - attorneyWithAddress := actor.Attorney{ + attorneyWithAddress := donordata.Attorney{ UID: actoruid.New(), Address: place.Address{ Line1: "1 Road way", }, } - attorneyWithoutAddress := actor.Attorney{ + attorneyWithoutAddress := donordata.Attorney{ UID: actoruid.New(), Address: place.Address{}, } @@ -164,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, &actor.DonorProvidedDetails{LpaID: "lpa-id", Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorneyWithoutAddress, attorneyWithAddress}}}) + err := RemoveAttorney(nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithoutAddress, attorneyWithAddress}}}) resp := w.Result() assert.Nil(t, err) @@ -177,14 +178,14 @@ func TestPostRemoveAttorneyErrorOnPutStore(t *testing.T) { form.FieldNames.YesNo: {form.Yes.String()}, } - attorneyWithAddress := actor.Attorney{ + attorneyWithAddress := donordata.Attorney{ UID: actoruid.New(), Address: place.Address{ Line1: "1 Road way", }, } - attorneyWithoutAddress := actor.Attorney{ + attorneyWithoutAddress := donordata.Attorney{ UID: actoruid.New(), Address: place.Address{}, } @@ -200,7 +201,7 @@ func TestPostRemoveAttorneyErrorOnPutStore(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := RemoveAttorney(template.Execute, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorneyWithoutAddress, attorneyWithAddress}}}) + err := RemoveAttorney(template.Execute, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithoutAddress, attorneyWithAddress}}}) resp := w.Result() assert.ErrorIs(t, err, expectedError) @@ -226,9 +227,9 @@ func TestRemoveAttorneyFormValidation(t *testing.T) { })). Return(nil) - err := RemoveAttorney(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Attorneys: actor.Attorneys{ - Attorneys: []actor.Attorney{{ + err := RemoveAttorney(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Attorneys: donordata.Attorneys{ + Attorneys: []donordata.Attorney{{ UID: uid, Address: place.Address{}, }}, diff --git a/internal/donor/donorpage/remove_person_to_notify.go b/internal/donor/donorpage/remove_person_to_notify.go index 333948576f..e55eb6931a 100644 --- a/internal/donor/donorpage/remove_person_to_notify.go +++ b/internal/donor/donorpage/remove_person_to_notify.go @@ -7,6 +7,7 @@ import ( "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/validation" @@ -14,13 +15,13 @@ import ( type removePersonToNotifyData struct { App page.AppData - PersonToNotify actor.PersonToNotify + PersonToNotify donordata.PersonToNotify Errors validation.List Form *form.YesNoForm } func RemovePersonToNotify(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { person, found := donor.PeopleToNotify.Get(actoruid.FromRequest(r)) if found == false { diff --git a/internal/donor/donorpage/remove_person_to_notify_test.go b/internal/donor/donorpage/remove_person_to_notify_test.go index 9e131777f8..64a4e9f431 100644 --- a/internal/donor/donorpage/remove_person_to_notify_test.go +++ b/internal/donor/donorpage/remove_person_to_notify_test.go @@ -9,6 +9,7 @@ import ( "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" @@ -22,7 +23,7 @@ func TestGetRemovePersonToNotify(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/?id="+uid.String(), nil) - personToNotify := actor.PersonToNotify{ + personToNotify := donordata.PersonToNotify{ UID: uid, Address: place.Address{ Line1: "1 Road way", @@ -39,7 +40,7 @@ func TestGetRemovePersonToNotify(t *testing.T) { }). Return(nil) - err := RemovePersonToNotify(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{PeopleToNotify: actor.PeopleToNotify{personToNotify}}) + err := RemovePersonToNotify(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{PeopleToNotify: donordata.PeopleToNotify{personToNotify}}) resp := w.Result() @@ -51,14 +52,14 @@ func TestGetRemovePersonToNotifyAttorneyDoesNotExist(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/?id=invalid-id", nil) - personToNotify := actor.PersonToNotify{ + personToNotify := donordata.PersonToNotify{ UID: actoruid.New(), Address: place.Address{ Line1: "1 Road way", }, } - err := RemovePersonToNotify(nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id", PeopleToNotify: actor.PeopleToNotify{personToNotify}}) + err := RemovePersonToNotify(nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", PeopleToNotify: donordata.PeopleToNotify{personToNotify}}) resp := w.Result() assert.Nil(t, err) @@ -76,24 +77,24 @@ func TestPostRemovePersonToNotify(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/?id="+uid.String(), strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - personToNotifyWithAddress := actor.PersonToNotify{ + personToNotifyWithAddress := donordata.PersonToNotify{ UID: actoruid.New(), Address: place.Address{ Line1: "1 Road way", }, } - personToNotifyWithoutAddress := actor.PersonToNotify{ + personToNotifyWithoutAddress := donordata.PersonToNotify{ UID: uid, Address: place.Address{}, } donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{LpaID: "lpa-id", PeopleToNotify: actor.PeopleToNotify{personToNotifyWithAddress}}). + Put(r.Context(), &donordata.DonorProvidedDetails{LpaID: "lpa-id", PeopleToNotify: donordata.PeopleToNotify{personToNotifyWithAddress}}). Return(nil) - err := RemovePersonToNotify(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id", PeopleToNotify: actor.PeopleToNotify{personToNotifyWithoutAddress, personToNotifyWithAddress}}) + err := RemovePersonToNotify(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", PeopleToNotify: donordata.PeopleToNotify{personToNotifyWithoutAddress, personToNotifyWithAddress}}) resp := w.Result() assert.Nil(t, err) @@ -111,19 +112,19 @@ func TestPostRemovePersonToNotifyWithFormValueNo(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/?id="+uid.String(), strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - personToNotifyWithAddress := actor.PersonToNotify{ + personToNotifyWithAddress := donordata.PersonToNotify{ UID: actoruid.New(), Address: place.Address{ Line1: "1 Road way", }, } - personToNotifyWithoutAddress := actor.PersonToNotify{ + personToNotifyWithoutAddress := donordata.PersonToNotify{ UID: uid, Address: place.Address{}, } - err := RemovePersonToNotify(nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id", PeopleToNotify: actor.PeopleToNotify{personToNotifyWithoutAddress, personToNotifyWithAddress}}) + err := RemovePersonToNotify(nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", PeopleToNotify: donordata.PeopleToNotify{personToNotifyWithoutAddress, personToNotifyWithAddress}}) resp := w.Result() assert.Nil(t, err) @@ -141,24 +142,24 @@ func TestPostRemovePersonToNotifyErrorOnPutStore(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/?id="+uid.String(), strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - personToNotifyWithAddress := actor.PersonToNotify{ + personToNotifyWithAddress := donordata.PersonToNotify{ UID: actoruid.New(), Address: place.Address{ Line1: "1 Road way", }, } - personToNotifyWithoutAddress := actor.PersonToNotify{ + personToNotifyWithoutAddress := donordata.PersonToNotify{ UID: uid, Address: place.Address{}, } donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{PeopleToNotify: actor.PeopleToNotify{personToNotifyWithAddress}}). + Put(r.Context(), &donordata.DonorProvidedDetails{PeopleToNotify: donordata.PeopleToNotify{personToNotifyWithAddress}}). Return(expectedError) - err := RemovePersonToNotify(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{PeopleToNotify: actor.PeopleToNotify{personToNotifyWithoutAddress, personToNotifyWithAddress}}) + err := RemovePersonToNotify(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{PeopleToNotify: donordata.PeopleToNotify{personToNotifyWithoutAddress, personToNotifyWithAddress}}) resp := w.Result() assert.ErrorIs(t, err, expectedError) @@ -175,7 +176,7 @@ func TestRemovePersonToNotifyFormValidation(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/?id="+uid.String(), strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - personToNotifyWithoutAddress := actor.PersonToNotify{ + personToNotifyWithoutAddress := donordata.PersonToNotify{ UID: uid, Address: place.Address{}, } @@ -189,7 +190,7 @@ func TestRemovePersonToNotifyFormValidation(t *testing.T) { })). Return(nil) - err := RemovePersonToNotify(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{PeopleToNotify: actor.PeopleToNotify{personToNotifyWithoutAddress}}) + err := RemovePersonToNotify(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{PeopleToNotify: donordata.PeopleToNotify{personToNotifyWithoutAddress}}) resp := w.Result() assert.Nil(t, err) @@ -206,24 +207,24 @@ func TestRemovePersonToNotifyRemoveLastPerson(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/?id="+uid.String(), strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - personToNotifyWithoutAddress := actor.PersonToNotify{ + personToNotifyWithoutAddress := donordata.PersonToNotify{ UID: uid, Address: place.Address{}, } donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - PeopleToNotify: actor.PeopleToNotify{}, - Tasks: actor.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, PeopleToNotify: actor.TaskNotStarted}, + PeopleToNotify: donordata.PeopleToNotify{}, + Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, PeopleToNotify: actor.TaskNotStarted}, }). Return(nil) - err := RemovePersonToNotify(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := RemovePersonToNotify(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - PeopleToNotify: actor.PeopleToNotify{personToNotifyWithoutAddress}, - Tasks: actor.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, PeopleToNotify: actor.TaskCompleted}, + PeopleToNotify: donordata.PeopleToNotify{personToNotifyWithoutAddress}, + Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, PeopleToNotify: actor.TaskCompleted}, }) resp := w.Result() diff --git a/internal/donor/donorpage/remove_replacement_attorney.go b/internal/donor/donorpage/remove_replacement_attorney.go index 4c58401be4..77ab804615 100644 --- a/internal/donor/donorpage/remove_replacement_attorney.go +++ b/internal/donor/donorpage/remove_replacement_attorney.go @@ -5,14 +5,14 @@ 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" ) func RemoveReplacementAttorney(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { attorney, found := donor.ReplacementAttorneys.Get(actoruid.FromRequest(r)) if found == false { @@ -34,7 +34,7 @@ func RemoveReplacementAttorney(tmpl template.Template, donorStore DonorStore) Ha if data.Form.YesNo == form.Yes { donor.ReplacementAttorneys.Delete(attorney) if donor.ReplacementAttorneys.Len() == 1 { - donor.ReplacementAttorneyDecisions = actor.AttorneyDecisions{} + donor.ReplacementAttorneyDecisions = donordata.AttorneyDecisions{} } donor.Tasks.ChooseReplacementAttorneys = page.ChooseReplacementAttorneysState(donor) diff --git a/internal/donor/donorpage/remove_replacement_attorney_test.go b/internal/donor/donorpage/remove_replacement_attorney_test.go index 25e9a3973c..42ef8f6ec7 100644 --- a/internal/donor/donorpage/remove_replacement_attorney_test.go +++ b/internal/donor/donorpage/remove_replacement_attorney_test.go @@ -9,6 +9,7 @@ import ( "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" @@ -22,7 +23,7 @@ func TestGetRemoveReplacementAttorney(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/?id="+uid.String(), nil) - attorney := actor.Attorney{ + attorney := donordata.Attorney{ UID: uid, FirstNames: "John", LastName: "Smith", @@ -41,7 +42,7 @@ func TestGetRemoveReplacementAttorney(t *testing.T) { }). Return(nil) - err := RemoveReplacementAttorney(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorney}}}) + err := RemoveReplacementAttorney(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney}}}) resp := w.Result() @@ -53,14 +54,14 @@ func TestGetRemoveReplacementAttorneyAttorneyDoesNotExist(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/?id=invalid-id", nil) - attorney := actor.Attorney{ + attorney := donordata.Attorney{ UID: actoruid.New(), Address: place.Address{ Line1: "1 Road way", }, } - err := RemoveReplacementAttorney(nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id", ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorney}}}) + err := RemoveReplacementAttorney(nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney}}}) resp := w.Result() assert.Nil(t, err) @@ -69,47 +70,47 @@ func TestGetRemoveReplacementAttorneyAttorneyDoesNotExist(t *testing.T) { } func TestPostRemoveReplacementAttorney(t *testing.T) { - attorneyWithEmail := actor.Attorney{UID: actoruid.New(), Email: "a"} - attorneyWithAddress := actor.Attorney{UID: actoruid.New(), Address: place.Address{Line1: "1 Road way"}} - attorneyWithoutAddress := actor.Attorney{UID: actoruid.New()} + attorneyWithEmail := donordata.Attorney{UID: actoruid.New(), Email: "a"} + attorneyWithAddress := donordata.Attorney{UID: actoruid.New(), Address: place.Address{Line1: "1 Road way"}} + attorneyWithoutAddress := donordata.Attorney{UID: actoruid.New()} testcases := map[string]struct { - donor *actor.DonorProvidedDetails - updatedDonor *actor.DonorProvidedDetails + donor *donordata.DonorProvidedDetails + updatedDonor *donordata.DonorProvidedDetails redirect page.LpaPath }{ "many left": { - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorneyWithEmail, attorneyWithAddress, attorneyWithoutAddress}}, - ReplacementAttorneyDecisions: actor.AttorneyDecisions{How: actor.Jointly}, + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithEmail, attorneyWithAddress, attorneyWithoutAddress}}, + ReplacementAttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, }, - updatedDonor: &actor.DonorProvidedDetails{ + updatedDonor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorneyWithEmail, attorneyWithAddress}}, - ReplacementAttorneyDecisions: actor.AttorneyDecisions{How: actor.Jointly}, - Tasks: actor.DonorTasks{ChooseReplacementAttorneys: actor.TaskInProgress}, + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithEmail, attorneyWithAddress}}, + ReplacementAttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, + Tasks: donordata.DonorTasks{ChooseReplacementAttorneys: actor.TaskInProgress}, }, redirect: page.Paths.ChooseReplacementAttorneysSummary, }, "one left": { - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorneyWithAddress, attorneyWithoutAddress}}, - ReplacementAttorneyDecisions: actor.AttorneyDecisions{How: actor.Jointly}, + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithAddress, attorneyWithoutAddress}}, + ReplacementAttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, }, - updatedDonor: &actor.DonorProvidedDetails{ + updatedDonor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorneyWithAddress}}, - Tasks: actor.DonorTasks{ChooseReplacementAttorneys: actor.TaskInProgress}, + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithAddress}}, + Tasks: donordata.DonorTasks{ChooseReplacementAttorneys: actor.TaskInProgress}, }, redirect: page.Paths.ChooseReplacementAttorneysSummary, }, "none left": { - donor: &actor.DonorProvidedDetails{LpaID: "lpa-id", ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorneyWithoutAddress}}}, - updatedDonor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithoutAddress}}}, + updatedDonor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{}}, + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{}}, }, redirect: page.Paths.ChooseReplacementAttorneysSummary, }, @@ -151,19 +152,19 @@ func TestPostRemoveReplacementAttorneyWithFormValueNo(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/?id="+uid.String(), strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - attorneyWithAddress := actor.Attorney{ + attorneyWithAddress := donordata.Attorney{ UID: actoruid.New(), Address: place.Address{ Line1: "1 Road way", }, } - attorneyWithoutAddress := actor.Attorney{ + attorneyWithoutAddress := donordata.Attorney{ UID: uid, Address: place.Address{}, } - err := RemoveReplacementAttorney(nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id", ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorneyWithoutAddress, attorneyWithAddress}}}) + err := RemoveReplacementAttorney(nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithoutAddress, attorneyWithAddress}}}) resp := w.Result() assert.Nil(t, err) @@ -181,14 +182,14 @@ func TestPostRemoveReplacementAttorneyErrorOnPutStore(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/?id="+uid.String(), strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - attorneyWithAddress := actor.Attorney{ + attorneyWithAddress := donordata.Attorney{ UID: actoruid.New(), Address: place.Address{ Line1: "1 Road way", }, } - attorneyWithoutAddress := actor.Attorney{ + attorneyWithoutAddress := donordata.Attorney{ UID: uid, Address: place.Address{}, } @@ -198,9 +199,9 @@ func TestPostRemoveReplacementAttorneyErrorOnPutStore(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := RemoveReplacementAttorney(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := RemoveReplacementAttorney(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ WantReplacementAttorneys: form.Yes, - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorneyWithoutAddress, attorneyWithAddress}}, + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithoutAddress, attorneyWithAddress}}, }) resp := w.Result() @@ -219,7 +220,7 @@ func TestRemoveReplacementAttorneyFormValidation(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/?id="+uid.String(), strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - attorneyWithoutAddress := actor.Attorney{ + attorneyWithoutAddress := donordata.Attorney{ UID: uid, Address: place.Address{}, } @@ -233,7 +234,7 @@ func TestRemoveReplacementAttorneyFormValidation(t *testing.T) { })). Return(nil) - err := RemoveReplacementAttorney(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorneyWithoutAddress}}}) + err := RemoveReplacementAttorney(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{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 462c70f3d0..c429bc6c98 100644 --- a/internal/donor/donorpage/remove_trust_corporation.go +++ b/internal/donor/donorpage/remove_trust_corporation.go @@ -4,7 +4,7 @@ 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" ) @@ -17,23 +17,23 @@ func RemoveTrustCorporation(tmpl template.Template, donorStore DonorStore, isRep titleLabel = "removeReplacementTrustCorporation" } - updateDonor := func(donor *actor.DonorProvidedDetails) { - donor.Attorneys.TrustCorporation = actor.TrustCorporation{} + updateDonor := func(donor *donordata.DonorProvidedDetails) { + donor.Attorneys.TrustCorporation = donordata.TrustCorporation{} if donor.Attorneys.Len() == 1 { - donor.AttorneyDecisions = actor.AttorneyDecisions{} + donor.AttorneyDecisions = donordata.AttorneyDecisions{} } } if isReplacement { - updateDonor = func(donor *actor.DonorProvidedDetails) { - donor.ReplacementAttorneys.TrustCorporation = actor.TrustCorporation{} + updateDonor = func(donor *donordata.DonorProvidedDetails) { + donor.ReplacementAttorneys.TrustCorporation = donordata.TrustCorporation{} if donor.ReplacementAttorneys.Len() == 1 { - donor.ReplacementAttorneyDecisions = actor.AttorneyDecisions{} + donor.ReplacementAttorneyDecisions = donordata.AttorneyDecisions{} } } } - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 cdd3d3411a..9c717907a3 100644 --- a/internal/donor/donorpage/remove_trust_corporation_test.go +++ b/internal/donor/donorpage/remove_trust_corporation_test.go @@ -9,6 +9,7 @@ import ( "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" @@ -18,21 +19,21 @@ import ( ) func TestGetRemoveTrustCorporation(t *testing.T) { - trustCorporation := actor.TrustCorporation{Name: "hey ltd"} + trustCorporation := donordata.TrustCorporation{Name: "hey ltd"} testcases := map[string]struct { isReplacement bool titleLabel string - donor *actor.DonorProvidedDetails + donor *donordata.DonorProvidedDetails }{ "attorney": { titleLabel: "removeTrustCorporation", - donor: &actor.DonorProvidedDetails{Attorneys: actor.Attorneys{TrustCorporation: trustCorporation}}, + donor: &donordata.DonorProvidedDetails{Attorneys: donordata.Attorneys{TrustCorporation: trustCorporation}}, }, "replacement": { isReplacement: true, titleLabel: "removeReplacementTrustCorporation", - donor: &actor.DonorProvidedDetails{ReplacementAttorneys: actor.Attorneys{TrustCorporation: trustCorporation}}, + donor: &donordata.DonorProvidedDetails{ReplacementAttorneys: donordata.Attorneys{TrustCorporation: trustCorporation}}, }, } @@ -62,85 +63,85 @@ func TestGetRemoveTrustCorporation(t *testing.T) { } func TestPostRemoveTrustCorporation(t *testing.T) { - attorney := actor.Attorney{UID: actoruid.New(), Email: "a"} - trustCorporation := actor.TrustCorporation{Name: "a"} + attorney := donordata.Attorney{UID: actoruid.New(), Email: "a"} + trustCorporation := donordata.TrustCorporation{Name: "a"} testcases := map[string]struct { isReplacement bool - donor *actor.DonorProvidedDetails - updatedDonor *actor.DonorProvidedDetails + donor *donordata.DonorProvidedDetails + updatedDonor *donordata.DonorProvidedDetails redirect page.LpaPath }{ "many left": { - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Attorneys: actor.Attorneys{TrustCorporation: trustCorporation, Attorneys: []actor.Attorney{attorney, attorney}}, - AttorneyDecisions: actor.AttorneyDecisions{How: actor.Jointly}, + Attorneys: donordata.Attorneys{TrustCorporation: trustCorporation, Attorneys: []donordata.Attorney{attorney, attorney}}, + AttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, }, - updatedDonor: &actor.DonorProvidedDetails{ + updatedDonor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorney, attorney}}, - AttorneyDecisions: actor.AttorneyDecisions{How: actor.Jointly}, - Tasks: actor.DonorTasks{ChooseAttorneys: actor.TaskInProgress}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney, attorney}}, + AttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, + Tasks: donordata.DonorTasks{ChooseAttorneys: actor.TaskInProgress}, }, redirect: page.Paths.ChooseAttorneysSummary, }, "replacement many left": { isReplacement: true, - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - ReplacementAttorneys: actor.Attorneys{TrustCorporation: trustCorporation, Attorneys: []actor.Attorney{attorney, attorney}}, - ReplacementAttorneyDecisions: actor.AttorneyDecisions{How: actor.Jointly}, + ReplacementAttorneys: donordata.Attorneys{TrustCorporation: trustCorporation, Attorneys: []donordata.Attorney{attorney, attorney}}, + ReplacementAttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, }, - updatedDonor: &actor.DonorProvidedDetails{ + updatedDonor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorney, attorney}}, - ReplacementAttorneyDecisions: actor.AttorneyDecisions{How: actor.Jointly}, - Tasks: actor.DonorTasks{ChooseReplacementAttorneys: actor.TaskInProgress}, + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney, attorney}}, + ReplacementAttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, + Tasks: donordata.DonorTasks{ChooseReplacementAttorneys: actor.TaskInProgress}, }, redirect: page.Paths.ChooseReplacementAttorneysSummary, }, "one left": { - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Attorneys: actor.Attorneys{TrustCorporation: trustCorporation, Attorneys: []actor.Attorney{attorney}}, - AttorneyDecisions: actor.AttorneyDecisions{How: actor.Jointly}, + Attorneys: donordata.Attorneys{TrustCorporation: trustCorporation, Attorneys: []donordata.Attorney{attorney}}, + AttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, }, - updatedDonor: &actor.DonorProvidedDetails{ + updatedDonor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorney}}, - Tasks: actor.DonorTasks{ChooseAttorneys: actor.TaskInProgress}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney}}, + Tasks: donordata.DonorTasks{ChooseAttorneys: actor.TaskInProgress}, }, redirect: page.Paths.ChooseAttorneysSummary, }, "replacement one left": { isReplacement: true, - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - ReplacementAttorneys: actor.Attorneys{TrustCorporation: trustCorporation, Attorneys: []actor.Attorney{attorney}}, - ReplacementAttorneyDecisions: actor.AttorneyDecisions{How: actor.Jointly}, + ReplacementAttorneys: donordata.Attorneys{TrustCorporation: trustCorporation, Attorneys: []donordata.Attorney{attorney}}, + ReplacementAttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, }, - updatedDonor: &actor.DonorProvidedDetails{ + updatedDonor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorney}}, - Tasks: actor.DonorTasks{ChooseReplacementAttorneys: actor.TaskInProgress}, + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorney}}, + Tasks: donordata.DonorTasks{ChooseReplacementAttorneys: actor.TaskInProgress}, }, redirect: page.Paths.ChooseReplacementAttorneysSummary, }, "none left": { - donor: &actor.DonorProvidedDetails{LpaID: "lpa-id", Attorneys: actor.Attorneys{TrustCorporation: trustCorporation}}, - updatedDonor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{LpaID: "lpa-id", Attorneys: donordata.Attorneys{TrustCorporation: trustCorporation}}, + updatedDonor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Attorneys: actor.Attorneys{}, + Attorneys: donordata.Attorneys{}, }, redirect: page.Paths.ChooseAttorneysSummary, }, "replacement none left": { isReplacement: true, - donor: &actor.DonorProvidedDetails{LpaID: "lpa-id", ReplacementAttorneys: actor.Attorneys{TrustCorporation: trustCorporation}}, - updatedDonor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{TrustCorporation: trustCorporation}}, + updatedDonor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - ReplacementAttorneys: actor.Attorneys{}, + ReplacementAttorneys: donordata.Attorneys{}, }, redirect: page.Paths.ChooseReplacementAttorneysSummary, }, @@ -186,19 +187,19 @@ func TestPostRemoveTrustCorporationWithFormValueNo(t *testing.T) { template := newMockTemplate(t) - attorneyWithAddress := actor.Attorney{ + attorneyWithAddress := donordata.Attorney{ UID: actoruid.New(), Address: place.Address{ Line1: "1 Road way", }, } - attorneyWithoutAddress := actor.Attorney{ + attorneyWithoutAddress := donordata.Attorney{ UID: uid, Address: place.Address{}, } - err := RemoveTrustCorporation(template.Execute, nil, false)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id", Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorneyWithoutAddress, attorneyWithAddress}}}) + err := RemoveTrustCorporation(template.Execute, nil, false)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithoutAddress, attorneyWithAddress}}}) resp := w.Result() @@ -219,14 +220,14 @@ func TestPostRemoveTrustCorporationErrorOnPutStore(t *testing.T) { template := newMockTemplate(t) - attorneyWithAddress := actor.Attorney{ + attorneyWithAddress := donordata.Attorney{ UID: actoruid.New(), Address: place.Address{ Line1: "1 Road way", }, } - attorneyWithoutAddress := actor.Attorney{ + attorneyWithoutAddress := donordata.Attorney{ UID: uid, Address: place.Address{}, } @@ -236,7 +237,7 @@ func TestPostRemoveTrustCorporationErrorOnPutStore(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := RemoveTrustCorporation(template.Execute, donorStore, false)(testAppData, w, r, &actor.DonorProvidedDetails{Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorneyWithoutAddress, attorneyWithAddress}}}) + err := RemoveTrustCorporation(template.Execute, donorStore, false)(testAppData, w, r, &donordata.DonorProvidedDetails{Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{attorneyWithoutAddress, attorneyWithAddress}}}) resp := w.Result() @@ -254,7 +255,7 @@ func TestRemoveTrustCorporationFormValidation(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/?id="+uid.String(), strings.NewReader(f.Encode())) r.Header.Add("Content-Type", page.FormUrlEncoded) - attorneyWithoutAddress := actor.Attorney{ + attorneyWithoutAddress := donordata.Attorney{ UID: uid, Address: place.Address{}, } @@ -268,7 +269,7 @@ func TestRemoveTrustCorporationFormValidation(t *testing.T) { })). Return(nil) - err := RemoveTrustCorporation(template.Execute, nil, false)(testAppData, w, r, &actor.DonorProvidedDetails{Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{attorneyWithoutAddress}}}) + err := RemoveTrustCorporation(template.Execute, nil, false)(testAppData, w, r, &donordata.DonorProvidedDetails{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 ae2766d33a..b90d892a05 100644 --- a/internal/donor/donorpage/resend_witness_code.go +++ b/internal/donor/donorpage/resend_witness_code.go @@ -6,6 +6,7 @@ import ( "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/validation" ) @@ -24,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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 cfda906969..f264910e97 100644 --- a/internal/donor/donorpage/resend_witness_code_test.go +++ b/internal/donor/donorpage/resend_witness_code_test.go @@ -8,6 +8,7 @@ import ( "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" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -28,7 +29,7 @@ func TestGetResendWitnessCode(t *testing.T) { }). Return(nil) - err := ResendWitnessCode(template.Execute, &mockWitnessCodeSender{}, actorType)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := ResendWitnessCode(template.Execute, &mockWitnessCodeSender{}, actorType)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -46,7 +47,7 @@ func TestGetResendWitnessCodeWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := ResendWitnessCode(template.Execute, &mockWitnessCodeSender{}, actor.TypeCertificateProvider)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := ResendWitnessCode(template.Execute, &mockWitnessCodeSender{}, actor.TypeCertificateProvider)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -74,7 +75,7 @@ func TestPostResendWitnessCode(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader("")) r.Header.Add("Content-Type", page.FormUrlEncoded) - donor := &actor.DonorProvidedDetails{ + donor := &donordata.DonorProvidedDetails{ LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, } @@ -99,7 +100,7 @@ func TestPostResendWitnessCodeWhenSendErrors(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader("")) r.Header.Add("Content-Type", page.FormUrlEncoded) - donor := &actor.DonorProvidedDetails{Donor: actor.Donor{FirstNames: "john"}} + donor := &donordata.DonorProvidedDetails{Donor: donordata.Donor{FirstNames: "john"}} witnessCodeSender := newMockWitnessCodeSender(t) witnessCodeSender.EXPECT(). @@ -113,20 +114,20 @@ func TestPostResendWitnessCodeWhenSendErrors(t *testing.T) { func TestPostResendWitnessCodeWhenTooRecentlySent(t *testing.T) { testcases := map[actor.Type]struct { - donor *actor.DonorProvidedDetails + donor *donordata.DonorProvidedDetails send string }{ actor.TypeIndependentWitness: { - donor: &actor.DonorProvidedDetails{ - Donor: actor.Donor{FirstNames: "john"}, - IndependentWitnessCodes: actor.WitnessCodes{{Created: time.Now()}}, + donor: &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{FirstNames: "john"}, + IndependentWitnessCodes: donordata.WitnessCodes{{Created: time.Now()}}, }, send: "SendToIndependentWitness", }, actor.TypeCertificateProvider: { - donor: &actor.DonorProvidedDetails{ - Donor: actor.Donor{FirstNames: "john"}, - CertificateProviderCodes: actor.WitnessCodes{{Created: time.Now()}}, + donor: &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{FirstNames: "john"}, + CertificateProviderCodes: donordata.WitnessCodes{{Created: time.Now()}}, }, send: "SendToCertificateProvider", }, diff --git a/internal/donor/donorpage/restrictions.go b/internal/donor/donorpage/restrictions.go index cdde3d264e..59dfc7356f 100644 --- a/internal/donor/donorpage/restrictions.go +++ b/internal/donor/donorpage/restrictions.go @@ -5,6 +5,7 @@ import ( "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/validation" ) @@ -12,11 +13,11 @@ import ( type restrictionsData struct { App page.AppData Errors validation.List - Donor *actor.DonorProvidedDetails + Donor *donordata.DonorProvidedDetails } func Restrictions(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { data := &restrictionsData{ App: appData, Donor: donor, diff --git a/internal/donor/donorpage/restrictions_test.go b/internal/donor/donorpage/restrictions_test.go index 123a59e7c0..6bf18c045a 100644 --- a/internal/donor/donorpage/restrictions_test.go +++ b/internal/donor/donorpage/restrictions_test.go @@ -8,6 +8,7 @@ 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/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/random" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -22,11 +23,11 @@ func TestGetRestrictions(t *testing.T) { template.EXPECT(). Execute(w, &restrictionsData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{}, + Donor: &donordata.DonorProvidedDetails{}, }). Return(nil) - err := Restrictions(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := Restrictions(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -41,11 +42,11 @@ func TestGetRestrictionsFromStore(t *testing.T) { template.EXPECT(). Execute(w, &restrictionsData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{Restrictions: "blah"}, + Donor: &donordata.DonorProvidedDetails{Restrictions: "blah"}, }). Return(nil) - err := Restrictions(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{Restrictions: "blah"}) + err := Restrictions(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{Restrictions: "blah"}) resp := w.Result() assert.Nil(t, err) @@ -60,11 +61,11 @@ func TestGetRestrictionsWhenTemplateErrors(t *testing.T) { template.EXPECT(). Execute(w, &restrictionsData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{}, + Donor: &donordata.DonorProvidedDetails{}, }). Return(expectedError) - err := Restrictions(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := Restrictions(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -82,16 +83,16 @@ func TestPostRestrictions(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", Restrictions: "blah", - Tasks: actor.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, Restrictions: actor.TaskCompleted}, + Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, Restrictions: actor.TaskCompleted}, }). Return(nil) - err := Restrictions(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := Restrictions(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Tasks: actor.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted}, + Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted}, }) resp := w.Result() @@ -111,10 +112,10 @@ func TestPostRestrictionsWhenStoreErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{Restrictions: "blah", Tasks: actor.DonorTasks{Restrictions: actor.TaskCompleted}}). + Put(r.Context(), &donordata.DonorProvidedDetails{Restrictions: "blah", Tasks: donordata.DonorTasks{Restrictions: actor.TaskCompleted}}). Return(expectedError) - err := Restrictions(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := Restrictions(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } @@ -133,11 +134,11 @@ func TestPostRestrictionsWhenValidationErrors(t *testing.T) { Execute(w, &restrictionsData{ App: testAppData, Errors: validation.With("restrictions", validation.StringTooLongError{Label: "restrictions", Length: 10000}), - Donor: &actor.DonorProvidedDetails{}, + Donor: &donordata.DonorProvidedDetails{}, }). Return(nil) - err := Restrictions(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := Restrictions(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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 c59edfb230..23b4f2b448 100644 --- a/internal/donor/donorpage/send_us_your_evidence_by_post.go +++ b/internal/donor/donorpage/send_us_your_evidence_by_post.go @@ -4,7 +4,7 @@ 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/event" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/pay" @@ -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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 be876e3a8a..ad884ba1ab 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 @@ -5,7 +5,7 @@ import ( "net/http/httptest" "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/event" "github.com/ministryofjustice/opg-modernising-lpa/internal/pay" "github.com/stretchr/testify/assert" @@ -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, &actor.DonorProvidedDetails{}) + err := SendUsYourEvidenceByPost(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := SendUsYourEvidenceByPost(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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 := &actor.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Post} + donor := &donordata.DonorProvidedDetails{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, &actor.DonorProvidedDetails{}) + err := SendUsYourEvidenceByPost(nil, nil, eventClient)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := SendUsYourEvidenceByPost(nil, payer.Execute, eventClient)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } diff --git a/internal/donor/donorpage/sign_your_lpa.go b/internal/donor/donorpage/sign_your_lpa.go index 8ccf07dc3a..bf52b0566e 100644 --- a/internal/donor/donorpage/sign_your_lpa.go +++ b/internal/donor/donorpage/sign_your_lpa.go @@ -5,7 +5,7 @@ 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/validation" ) @@ -13,7 +13,7 @@ import ( type signYourLpaData struct { App page.AppData Errors validation.List - Donor *actor.DonorProvidedDetails + Donor *donordata.DonorProvidedDetails 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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 25cf92360e..89acd5cce3 100644 --- a/internal/donor/donorpage/sign_your_lpa_test.go +++ b/internal/donor/donorpage/sign_your_lpa_test.go @@ -8,7 +8,7 @@ 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" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -25,13 +25,13 @@ func TestGetSignYourLpa(t *testing.T) { Execute(w, &signYourLpaData{ App: testAppData, Form: &signYourLpaForm{}, - Donor: &actor.DonorProvidedDetails{}, + Donor: &donordata.DonorProvidedDetails{}, WantToSignFormValue: WantToSignLpa, WantToApplyFormValue: WantToApplyForLpa, }). Return(nil) - err := SignYourLpa(template.Execute, nil, testNowFn)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := SignYourLpa(template.Execute, nil, testNowFn)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{ + err := SignYourLpa(nil, nil, testNowFn)(testAppData, w, r, &donordata.DonorProvidedDetails{ 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 := &actor.DonorProvidedDetails{ + donor := &donordata.DonorProvidedDetails{ WantToSignLpa: true, WantToApplyForLpa: false, } @@ -95,7 +95,7 @@ func TestPostSignYourLpa(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ 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, &actor.DonorProvidedDetails{LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}}) + err := SignYourLpa(nil, donorStore, testNowFn)(testAppData, w, r, &donordata.DonorProvidedDetails{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, &actor.DonorProvidedDetails{}) + err := SignYourLpa(nil, donorStore, testNowFn)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := SignYourLpa(template.Execute, nil, testNowFn)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/task_list.go b/internal/donor/donorpage/task_list.go index 8b6923a677..6283022ca3 100644 --- a/internal/donor/donorpage/task_list.go +++ b/internal/donor/donorpage/task_list.go @@ -5,15 +5,17 @@ import ( "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" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) type taskListData struct { App page.AppData Errors validation.List - Donor *actor.DonorProvidedDetails + Donor *donordata.DonorProvidedDetails Sections []taskListSection EvidenceReceived bool } @@ -22,7 +24,7 @@ type taskListItem struct { Name string Path string State actor.TaskState - PaymentState actor.PaymentTask + PaymentState task.PaymentState IdentityState actor.IdentityTask Count int Hidden bool @@ -34,7 +36,7 @@ type taskListSection struct { } func TaskList(tmpl template.Template, evidenceReceivedStore EvidenceReceivedStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { evidenceReceived, err := evidenceReceivedStore.Get(r.Context()) if err != nil { return err @@ -122,8 +124,8 @@ func TaskList(tmpl template.Template, evidenceReceivedStore EvidenceReceivedStor } } -func taskListTypeSpecificStep(donor *actor.DonorProvidedDetails) taskListItem { - if donor.Type == actor.LpaTypePersonalWelfare { +func taskListTypeSpecificStep(donor *donordata.DonorProvidedDetails) taskListItem { + if donor.Type == donordata.LpaTypePersonalWelfare { return taskListItem{ Name: "lifeSustainingTreatment", Path: page.Paths.LifeSustainingTreatment.Format(donor.LpaID), @@ -138,7 +140,7 @@ func taskListTypeSpecificStep(donor *actor.DonorProvidedDetails) taskListItem { } } -func taskListCheckLpaPath(donor *actor.DonorProvidedDetails) page.LpaPath { +func taskListCheckLpaPath(donor *donordata.DonorProvidedDetails) page.LpaPath { if len(donor.Under18ActorDetails()) > 0 { return page.Paths.YouCannotSignYourLpaYet } else if donor.CertificateProviderSharesDetails() { @@ -148,14 +150,14 @@ func taskListCheckLpaPath(donor *actor.DonorProvidedDetails) page.LpaPath { } } -func taskListPaymentSection(donor *actor.DonorProvidedDetails) taskListSection { +func taskListPaymentSection(donor *donordata.DonorProvidedDetails) taskListSection { var paymentPath string switch donor.Tasks.PayForLpa { - case actor.PaymentTaskApproved: + case task.PaymentStateApproved: paymentPath = page.Paths.FeeApproved.Format(donor.LpaID) - case actor.PaymentTaskDenied: + case task.PaymentStateDenied: paymentPath = page.Paths.FeeDenied.Format(donor.LpaID) - case actor.PaymentTaskMoreEvidenceRequired: + case task.PaymentStateMoreEvidenceRequired: paymentPath = page.Paths.UploadEvidence.Format(donor.LpaID) default: paymentPath = page.Paths.AboutPayment.Format(donor.LpaID) @@ -173,7 +175,7 @@ func taskListPaymentSection(donor *actor.DonorProvidedDetails) taskListSection { } } -func taskListSignSection(donor *actor.DonorProvidedDetails) taskListSection { +func taskListSignSection(donor *donordata.DonorProvidedDetails) 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 7a43c93e58..4d18a75074 100644 --- a/internal/donor/donorpage/task_list_test.go +++ b/internal/donor/donorpage/task_list_test.go @@ -8,11 +8,13 @@ import ( "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/identity" "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" "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/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -20,20 +22,20 @@ import ( func TestGetTaskList(t *testing.T) { testCases := map[string]struct { appData page.AppData - donor *actor.DonorProvidedDetails + donor *donordata.DonorProvidedDetails evidenceReceived bool expected func([]taskListSection) []taskListSection }{ "empty": { appData: testAppData, - donor: &actor.DonorProvidedDetails{LpaID: "lpa-id", Donor: actor.Donor{LastName: "a", Address: place.Address{Line1: "x"}}}, + donor: &donordata.DonorProvidedDetails{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: &actor.DonorProvidedDetails{LpaID: "lpa-id", Donor: actor.Donor{LastName: "a", Address: place.Address{Line1: "x"}, CanSign: form.No}}, + donor: &donordata.DonorProvidedDetails{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 @@ -42,7 +44,7 @@ func TestGetTaskList(t *testing.T) { }, "evidence received": { appData: testAppData, - donor: &actor.DonorProvidedDetails{LpaID: "lpa-id", Donor: actor.Donor{LastName: "a", Address: place.Address{Line1: "x"}}}, + donor: &donordata.DonorProvidedDetails{LpaID: "lpa-id", Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}}, evidenceReceived: true, expected: func(sections []taskListSection) []taskListSection { return sections @@ -50,11 +52,11 @@ func TestGetTaskList(t *testing.T) { }, "more evidence required": { appData: testAppData, - donor: &actor.DonorProvidedDetails{LpaID: "lpa-id", Donor: actor.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskMoreEvidenceRequired}}, + donor: &donordata.DonorProvidedDetails{LpaID: "lpa-id", Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateMoreEvidenceRequired}}, evidenceReceived: true, expected: func(sections []taskListSection) []taskListSection { sections[1].Items = []taskListItem{ - {Name: "payForTheLpa", Path: page.Paths.UploadEvidence.Format("lpa-id"), PaymentState: actor.PaymentTaskMoreEvidenceRequired}, + {Name: "payForTheLpa", Path: page.Paths.UploadEvidence.Format("lpa-id"), PaymentState: task.PaymentStateMoreEvidenceRequired}, } return sections @@ -62,11 +64,11 @@ func TestGetTaskList(t *testing.T) { }, "fee denied": { appData: testAppData, - donor: &actor.DonorProvidedDetails{LpaID: "lpa-id", Donor: actor.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskDenied}}, + donor: &donordata.DonorProvidedDetails{LpaID: "lpa-id", Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateDenied}}, evidenceReceived: true, expected: func(sections []taskListSection) []taskListSection { sections[1].Items = []taskListItem{ - {Name: "payForTheLpa", Path: page.Paths.FeeDenied.Format("lpa-id"), PaymentState: actor.PaymentTaskDenied}, + {Name: "payForTheLpa", Path: page.Paths.FeeDenied.Format("lpa-id"), PaymentState: task.PaymentStateDenied}, } return sections @@ -74,11 +76,11 @@ func TestGetTaskList(t *testing.T) { }, "fee approved": { appData: testAppData, - donor: &actor.DonorProvidedDetails{LpaID: "lpa-id", Donor: actor.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskApproved}}, + donor: &donordata.DonorProvidedDetails{LpaID: "lpa-id", Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateApproved}}, evidenceReceived: true, expected: func(sections []taskListSection) []taskListSection { sections[1].Items = []taskListItem{ - {Name: "payForTheLpa", Path: page.Paths.FeeApproved.Format("lpa-id"), PaymentState: actor.PaymentTaskApproved}, + {Name: "payForTheLpa", Path: page.Paths.FeeApproved.Format("lpa-id"), PaymentState: task.PaymentStateApproved}, } return sections @@ -86,7 +88,7 @@ func TestGetTaskList(t *testing.T) { }, "personal welfare": { appData: testAppData, - donor: &actor.DonorProvidedDetails{LpaID: "lpa-id", Type: actor.LpaTypePersonalWelfare, Donor: actor.Donor{LastName: "a", Address: place.Address{Line1: "x"}}}, + donor: &donordata.DonorProvidedDetails{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", @@ -98,9 +100,9 @@ func TestGetTaskList(t *testing.T) { }, "confirmed identity": { appData: testAppData, - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, + Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed, LastName: "a"}, }, expected: func(sections []taskListSection) []taskListSection { @@ -113,9 +115,9 @@ func TestGetTaskList(t *testing.T) { }, "confirmed identity does not match LPA": { appData: testAppData, - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{LastName: "b", Address: place.Address{Line1: "x"}}, + Donor: donordata.Donor{LastName: "b", Address: place.Address{Line1: "x"}}, DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed, LastName: "a"}, }, expected: func(sections []taskListSection) []taskListSection { @@ -128,9 +130,9 @@ func TestGetTaskList(t *testing.T) { }, "failed identity": { appData: testAppData, - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, + Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, DonorIdentityUserData: identity.UserData{Status: identity.StatusFailed, LastName: "a"}, }, expected: func(sections []taskListSection) []taskListSection { @@ -143,9 +145,9 @@ func TestGetTaskList(t *testing.T) { }, "insufficient evidence for identity": { appData: testAppData, - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, + Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, DonorIdentityUserData: identity.UserData{Status: identity.StatusInsufficientEvidence, LastName: "a"}, }, expected: func(sections []taskListSection) []taskListSection { @@ -158,11 +160,11 @@ func TestGetTaskList(t *testing.T) { }, "insufficient evidence for identity with voucher details": { appData: testAppData, - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, + Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, DonorIdentityUserData: identity.UserData{Status: identity.StatusInsufficientEvidence, LastName: "a"}, - Voucher: actor.Voucher{FirstNames: "a"}, + Voucher: donordata.Voucher{FirstNames: "a"}, }, expected: func(sections []taskListSection) []taskListSection { sections[2].Items = []taskListItem{ @@ -174,9 +176,9 @@ func TestGetTaskList(t *testing.T) { }, "does not want a voucher": { appData: testAppData, - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, + Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, DonorIdentityUserData: identity.UserData{Status: identity.StatusInsufficientEvidence, LastName: "a"}, WantVoucher: form.No, }, @@ -190,9 +192,9 @@ func TestGetTaskList(t *testing.T) { }, "wants a voucher": { appData: testAppData, - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, + Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, DonorIdentityUserData: identity.UserData{Status: identity.StatusInsufficientEvidence, LastName: "a"}, WantVoucher: form.Yes, }, @@ -206,9 +208,9 @@ func TestGetTaskList(t *testing.T) { }, "is applying to court of protection": { appData: testAppData, - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, + Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, DonorIdentityUserData: identity.UserData{Status: identity.StatusInsufficientEvidence, LastName: "a"}, WantVoucher: form.No, RegisteringWithCourtOfProtection: true, @@ -223,9 +225,9 @@ func TestGetTaskList(t *testing.T) { }, "is applying to court of protection and has signed": { appData: testAppData, - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, + Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, DonorIdentityUserData: identity.UserData{Status: identity.StatusInsufficientEvidence, LastName: "a"}, WantVoucher: form.No, RegisteringWithCourtOfProtection: true, @@ -241,10 +243,10 @@ func TestGetTaskList(t *testing.T) { }, "attorneys under 18": { appData: testAppData, - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{LastName: "a", Address: place.Address{Line1: "xx"}}, - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "xx"}}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "aa", LastName: "bb", DateOfBirth: date.Today().AddDate(-17, 0, 0), Address: place.Address{Line1: "zz"}}, }}, }, @@ -263,10 +265,10 @@ func TestGetTaskList(t *testing.T) { }, "certificate provider has similar name": { appData: testAppData, - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, - CertificateProvider: actor.CertificateProvider{LastName: "a"}, + Donor: donordata.Donor{LastName: "a", Address: place.Address{Line1: "x"}}, + CertificateProvider: donordata.CertificateProvider{LastName: "a"}, }, expected: func(sections []taskListSection) []taskListSection { sections[0].Items[9].Path = page.Paths.ConfirmYourCertificateProviderIsNotRelated.Format("lpa-id") @@ -276,18 +278,18 @@ func TestGetTaskList(t *testing.T) { }, "mixed": { appData: testAppData, - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{FirstNames: "this"}, - CertificateProvider: actor.CertificateProvider{LastName: "a", Address: place.Address{Line1: "x"}}, - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + Donor: donordata.Donor{FirstNames: "this"}, + CertificateProvider: donordata.CertificateProvider{LastName: "a", Address: place.Address{Line1: "x"}}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {DateOfBirth: date.Today().AddDate(-20, 0, 0)}, {DateOfBirth: date.Today().AddDate(-20, 0, 0)}, }}, - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {DateOfBirth: date.Today().AddDate(-20, 0, 0)}, }}, - Tasks: actor.DonorTasks{ + Tasks: donordata.DonorTasks{ YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, ChooseReplacementAttorneys: actor.TaskInProgress, @@ -295,7 +297,7 @@ func TestGetTaskList(t *testing.T) { Restrictions: actor.TaskCompleted, CertificateProvider: actor.TaskInProgress, CheckYourLpa: actor.TaskCompleted, - PayForLpa: actor.PaymentTaskInProgress, + PayForLpa: task.PaymentStateInProgress, }, }, expected: func(sections []taskListSection) []taskListSection { @@ -313,7 +315,7 @@ func TestGetTaskList(t *testing.T) { } sections[1].Items = []taskListItem{ - {Name: "payForTheLpa", Path: page.Paths.AboutPayment.Format("lpa-id"), PaymentState: actor.PaymentTaskInProgress}, + {Name: "payForTheLpa", Path: page.Paths.AboutPayment.Format("lpa-id"), PaymentState: task.PaymentStateInProgress}, } return sections @@ -321,20 +323,20 @@ func TestGetTaskList(t *testing.T) { }, "signed": { appData: testAppData, - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", SignedAt: time.Now(), - Donor: actor.Donor{FirstNames: "this"}, - CertificateProvider: actor.CertificateProvider{LastName: "a", Address: place.Address{Line1: "x"}}, - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + Donor: donordata.Donor{FirstNames: "this"}, + CertificateProvider: donordata.CertificateProvider{LastName: "a", Address: place.Address{Line1: "x"}}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {DateOfBirth: date.Today().AddDate(-20, 0, 0)}, {DateOfBirth: date.Today().AddDate(-20, 0, 0)}, }}, - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {DateOfBirth: date.Today().AddDate(-20, 0, 0)}, }}, DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed, LastName: "a"}, - Tasks: actor.DonorTasks{ + Tasks: donordata.DonorTasks{ YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, ChooseReplacementAttorneys: actor.TaskCompleted, @@ -343,7 +345,7 @@ func TestGetTaskList(t *testing.T) { CertificateProvider: actor.TaskCompleted, CheckYourLpa: actor.TaskCompleted, AddCorrespondent: actor.TaskCompleted, - PayForLpa: actor.PaymentTaskCompleted, + PayForLpa: task.PaymentStateCompleted, ConfirmYourIdentityAndSign: actor.IdentityTaskCompleted, }, }, @@ -362,7 +364,7 @@ func TestGetTaskList(t *testing.T) { } sections[1].Items = []taskListItem{ - {Name: "payForTheLpa", Path: page.Paths.AboutPayment.Format("lpa-id"), PaymentState: actor.PaymentTaskCompleted}, + {Name: "payForTheLpa", Path: page.Paths.AboutPayment.Format("lpa-id"), PaymentState: task.PaymentStateCompleted}, } sections[2].Items = []taskListItem{ @@ -379,18 +381,18 @@ func TestGetTaskList(t *testing.T) { Lang: localize.En, SupporterData: &page.SupporterData{}, }, - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{FirstNames: "this"}, - CertificateProvider: actor.CertificateProvider{LastName: "a", Address: place.Address{Line1: "x"}}, - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + Donor: donordata.Donor{FirstNames: "this"}, + CertificateProvider: donordata.CertificateProvider{LastName: "a", Address: place.Address{Line1: "x"}}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {DateOfBirth: date.Today().AddDate(-20, 0, 0)}, {DateOfBirth: date.Today().AddDate(-20, 0, 0)}, }}, - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {DateOfBirth: date.Today().AddDate(-20, 0, 0)}, }}, - Tasks: actor.DonorTasks{ + Tasks: donordata.DonorTasks{ YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, ChooseReplacementAttorneys: actor.TaskInProgress, @@ -483,7 +485,7 @@ func TestGetTaskListWhenEvidenceReceivedStoreErrors(t *testing.T) { Get(r.Context()). Return(false, expectedError) - err := TaskList(nil, evidenceReceivedStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := TaskList(nil, evidenceReceivedStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -504,7 +506,7 @@ func TestGetTaskListWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := TaskList(template.Execute, evidenceReceivedStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := TaskList(template.Execute, evidenceReceivedStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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 07a073f782..eeaf7cf152 100644 --- a/internal/donor/donorpage/upload_evidence.go +++ b/internal/donor/donorpage/upload_evidence.go @@ -12,7 +12,7 @@ import ( "github.com/gabriel-vasile/mimetype" "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/pay" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 3608f08499..45d704eee2 100644 --- a/internal/donor/donorpage/upload_evidence_sse.go +++ b/internal/donor/donorpage/upload_evidence_sse.go @@ -6,12 +6,12 @@ import ( "net/http" "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/page" ) 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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 6a59baa845..260dd01a01 100644 --- a/internal/donor/donorpage/upload_evidence_sse_test.go +++ b/internal/donor/donorpage/upload_evidence_sse_test.go @@ -7,7 +7,7 @@ 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/page" "github.com/stretchr/testify/assert" ) @@ -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, &actor.DonorProvidedDetails{}) + err := UploadEvidenceSSE(documentStore, 4*time.Millisecond, 2*time.Millisecond, func() time.Time { return now })(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := UploadEvidenceSSE(documentStore, 4*time.Millisecond, 2*time.Millisecond, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := UploadEvidenceSSE(documentStore, 4*time.Millisecond, 2*time.Millisecond, func() time.Time { return now })(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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 e38985fcde..f55ff110fc 100644 --- a/internal/donor/donorpage/upload_evidence_test.go +++ b/internal/donor/donorpage/upload_evidence_test.go @@ -12,10 +12,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/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/pay" + "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" @@ -41,7 +42,7 @@ func TestGetUploadEvidence(t *testing.T) { }). Return(nil) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &actor.DonorProvidedDetails{FeeType: pay.FullFee}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{FeeType: pay.FullFee}) resp := w.Result() assert.Nil(t, err) @@ -52,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, &actor.DonorProvidedDetails{LpaID: "lpa-id", FeeType: pay.FullFee, Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskPending}}) + err := UploadEvidence(nil, nil, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", FeeType: pay.FullFee, Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}}) resp := w.Result() assert.Nil(t, err) @@ -74,7 +75,7 @@ func TestGetUploadEvidenceWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } @@ -105,7 +106,7 @@ func TestPostUploadEvidenceWithUploadActionAcceptedFileTypes(t *testing.T) { GetAll(r.Context()). Return(page.Documents{}, nil) documentStore.EXPECT(). - Create(r.Context(), &actor.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}, filename, mock.Anything). + Create(r.Context(), &donordata.DonorProvidedDetails{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"), @@ -130,7 +131,7 @@ func TestPostUploadEvidenceWithUploadActionAcceptedFileTypes(t *testing.T) { }). Return(nil) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) assert.Nil(t, err) }) } @@ -140,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, &actor.DonorProvidedDetails{LpaID: "lpa-id", FeeType: pay.FullFee, Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskPending}}) + err := UploadEvidence(nil, nil, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", FeeType: pay.FullFee, Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}}) resp := w.Result() assert.Nil(t, err) @@ -160,7 +161,7 @@ func TestPostUploadEvidenceWithUploadActionMultipleFiles(t *testing.T) { GetAll(r.Context()). Return(page.Documents{}, nil) documentStore.EXPECT(). - Create(r.Context(), &actor.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}, "dummy.pdf", mock.Anything). + Create(r.Context(), &donordata.DonorProvidedDetails{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"), @@ -169,7 +170,7 @@ func TestPostUploadEvidenceWithUploadActionMultipleFiles(t *testing.T) { }, nil). Once() documentStore.EXPECT(). - Create(r.Context(), &actor.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}, "dummy.png", mock.Anything). + Create(r.Context(), &donordata.DonorProvidedDetails{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"), @@ -203,7 +204,7 @@ func TestPostUploadEvidenceWithUploadActionMultipleFiles(t *testing.T) { }). Return(nil) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) assert.Nil(t, err) } @@ -233,7 +234,7 @@ func TestPostUploadEvidenceWithUploadActionFilenameSpecialCharactersAreEscaped(t GetAll(r.Context()). Return(page.Documents{}, nil) documentStore.EXPECT(). - Create(r.Context(), &actor.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.DonorProvidedDetails{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"), @@ -260,7 +261,7 @@ func TestPostUploadEvidenceWithUploadActionFilenameSpecialCharactersAreEscaped(t }). Return(nil) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) assert.Nil(t, err) } @@ -271,7 +272,7 @@ func TestPostUploadEvidenceWithPayAction(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", &buf) r.Header.Set("Content-Type", contentType) - donor := &actor.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload} + donor := &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload} documents := page.Documents{{ PK: dynamo.LpaKey("lpa-id"), @@ -323,10 +324,10 @@ func TestPostUploadEvidenceWithPayActionWhenPayerError(t *testing.T) { payer := newMockHandler(t) payer.EXPECT(). - Execute(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}). + Execute(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}). Return(expectedError) - err := UploadEvidence(nil, nil, payer.Execute, documentStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) + err := UploadEvidence(nil, nil, payer.Execute, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) assert.Equal(t, expectedError, err) } @@ -338,7 +339,7 @@ func TestPostUploadEvidenceWithPayActionWhenDocumentStoreSubmitErrors(t *testing r, _ := http.NewRequest(http.MethodPost, "/", &buf) r.Header.Set("Content-Type", contentType) - donor := &actor.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload} + donor := &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload} documentStore := newMockDocumentStore(t) documentStore.EXPECT(). @@ -365,7 +366,7 @@ func TestPostUploadEvidenceWithPayActionWhenUnscannedDocument(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/", &buf) r.Header.Set("Content-Type", contentType) - donor := &actor.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload} + donor := &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee, EvidenceDelivery: pay.Upload} documentStore := newMockDocumentStore(t) documentStore.EXPECT(). @@ -439,7 +440,7 @@ func TestPostUploadEvidenceWithScanResultsActionWithInfectedFiles(t *testing.T) }). Return(nil) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) assert.Nil(t, err) } @@ -468,7 +469,7 @@ func TestPostUploadEvidenceWithScanResultsActionWithoutInfectedFiles(t *testing. }). Return(nil) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) assert.Nil(t, err) } @@ -489,7 +490,7 @@ func TestPostUploadEvidenceWithPayActionWithInfectedFilesWhenDocumentStoreGetAll {Filename: "d", VirusDetected: true}, }, expectedError) - err := UploadEvidence(nil, nil, nil, documentStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) + err := UploadEvidence(nil, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) assert.Equal(t, expectedError, err) } @@ -518,7 +519,7 @@ func TestPostUploadEvidenceWithScanResultsActionWithInfectedFilesWhenDocumentSto }). Return(expectedError) - err := UploadEvidence(nil, nil, nil, documentStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) + err := UploadEvidence(nil, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) assert.Equal(t, expectedError, err) } @@ -554,7 +555,7 @@ func TestPostUploadEvidenceWithScanResultsActionWithInfectedFilesWhenDocumentSto }, expectedError). Once() - err := UploadEvidence(nil, nil, nil, documentStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) + err := UploadEvidence(nil, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) assert.Equal(t, expectedError, err) } @@ -602,7 +603,7 @@ func TestPostUploadEvidenceWithScanResultsActionWithInfectedFilesWhenTemplateErr }). Return(expectedError) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", LpaUID: "lpa-uid", FeeType: pay.HalfFee}) assert.Equal(t, expectedError, err) } @@ -637,7 +638,7 @@ func TestPostUploadEvidenceWhenBadCsrfField(t *testing.T) { }). Return(nil) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id", FeeType: pay.FullFee}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", FeeType: pay.FullFee}) resp := w.Result() assert.Nil(t, err) @@ -677,7 +678,7 @@ func TestPostUploadEvidenceWhenBadActionField(t *testing.T) { }). Return(nil) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id", FeeType: pay.FullFee}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", FeeType: pay.FullFee}) resp := w.Result() assert.Nil(t, err) @@ -725,7 +726,7 @@ func TestPostUploadEvidenceNumberOfFilesLimitPassed(t *testing.T) { }). Return(nil) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaUID: "lpa-uid", FeeType: pay.FullFee}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaUID: "lpa-uid", FeeType: pay.FullFee}) assert.Nil(t, err) } @@ -810,7 +811,7 @@ func TestPostUploadEvidenceWhenBadUpload(t *testing.T) { }). Return(nil) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id", FeeType: pay.FullFee}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", FeeType: pay.FullFee}) resp := w.Result() assert.Nil(t, err) @@ -863,7 +864,7 @@ func TestGetUploadEvidenceDeleteEvidence(t *testing.T) { }). Return(nil) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Nil(t, err) } @@ -908,7 +909,7 @@ func TestGetUploadEvidenceDeleteEvidenceWhenUnexpectedFieldName(t *testing.T) { }). Return(nil) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Nil(t, err) } @@ -943,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, &actor.DonorProvidedDetails{}) + err := UploadEvidence(nil, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } @@ -991,7 +992,7 @@ func TestGetUploadEvidenceDeleteEvidenceWhenTemplateError(t *testing.T) { }). Return(expectedError) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } @@ -1036,7 +1037,7 @@ func TestPostUploadEvidenceWithCloseConnectionAction(t *testing.T) { }). Return(nil) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaUID: "lpa-uid", FeeType: pay.HalfFee}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaUID: "lpa-uid", FeeType: pay.HalfFee}) resp := w.Result() @@ -1071,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, &actor.DonorProvidedDetails{LpaUID: "lpa-uid", FeeType: pay.HalfFee}) + err := UploadEvidence(nil, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaUID: "lpa-uid", FeeType: pay.HalfFee}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -1119,7 +1120,7 @@ func TestPostUploadEvidenceWithCloseConnectionActionWhenTemplateError(t *testing }). Return(expectedError) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaUID: "lpa-uid", FeeType: pay.HalfFee}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaUID: "lpa-uid", FeeType: pay.HalfFee}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -1166,7 +1167,7 @@ func TestPostUploadEvidenceWithCancelUploadAction(t *testing.T) { }). Return(nil) - err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaUID: "lpa-uid", FeeType: pay.HalfFee}) + err := UploadEvidence(template.Execute, nil, nil, documentStore)(testAppData, w, r, &donordata.DonorProvidedDetails{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 b34b2cc7eb..51ed91b92e 100644 --- a/internal/donor/donorpage/want_replacement_attorneys.go +++ b/internal/donor/donorpage/want_replacement_attorneys.go @@ -5,8 +5,8 @@ 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/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/validation" @@ -16,11 +16,11 @@ type wantReplacementAttorneysData struct { App page.AppData Errors validation.List Form *form.YesNoForm - Donor *actor.DonorProvidedDetails + Donor *donordata.DonorProvidedDetails } func WantReplacementAttorneys(tmpl template.Template, donorStore DonorStore, newUID func() actoruid.UID) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { data := &wantReplacementAttorneysData{ App: appData, Donor: donor, @@ -35,7 +35,7 @@ func WantReplacementAttorneys(tmpl template.Template, donorStore DonorStore, new donor.WantReplacementAttorneys = f.YesNo if donor.WantReplacementAttorneys.IsNo() { - donor.ReplacementAttorneys = actor.Attorneys{} + donor.ReplacementAttorneys = donordata.Attorneys{} } donor.Tasks.ChooseReplacementAttorneys = page.ChooseReplacementAttorneysState(donor) diff --git a/internal/donor/donorpage/want_replacement_attorneys_test.go b/internal/donor/donorpage/want_replacement_attorneys_test.go index 13fae74c5f..54fb3f541c 100644 --- a/internal/donor/donorpage/want_replacement_attorneys_test.go +++ b/internal/donor/donorpage/want_replacement_attorneys_test.go @@ -9,6 +9,7 @@ import ( "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/validation" @@ -24,12 +25,12 @@ func TestGetWantReplacementAttorneys(t *testing.T) { template.EXPECT(). Execute(w, &wantReplacementAttorneysData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{}, + Donor: &donordata.DonorProvidedDetails{}, Form: form.NewYesNoForm(form.YesNoUnknown), }). Return(nil) - err := WantReplacementAttorneys(template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := WantReplacementAttorneys(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -42,7 +43,7 @@ func TestGetWantReplacementAttorneysWithExistingReplacementAttorneys(t *testing. template := newMockTemplate(t) - err := WantReplacementAttorneys(template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id", ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{FirstNames: "this"}}}}) + err := WantReplacementAttorneys(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{FirstNames: "this"}}}}) resp := w.Result() assert.Nil(t, err) @@ -58,12 +59,12 @@ func TestGetWantReplacementAttorneysFromStore(t *testing.T) { template.EXPECT(). Execute(w, &wantReplacementAttorneysData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{WantReplacementAttorneys: form.Yes}, + Donor: &donordata.DonorProvidedDetails{WantReplacementAttorneys: form.Yes}, Form: form.NewYesNoForm(form.Yes), }). Return(nil) - err := WantReplacementAttorneys(template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{WantReplacementAttorneys: form.Yes}) + err := WantReplacementAttorneys(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{WantReplacementAttorneys: form.Yes}) resp := w.Result() assert.Nil(t, err) @@ -79,7 +80,7 @@ func TestGetWantReplacementAttorneysWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := WantReplacementAttorneys(template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := WantReplacementAttorneys(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -91,25 +92,25 @@ func TestPostWantReplacementAttorneys(t *testing.T) { testCases := map[string]struct { yesNo form.YesNo - existingReplacementAttorneys actor.Attorneys - expectedReplacementAttorneys actor.Attorneys + existingReplacementAttorneys donordata.Attorneys + expectedReplacementAttorneys donordata.Attorneys taskState actor.TaskState redirect string }{ "yes": { yesNo: form.Yes, - existingReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{UID: uid}}}, - expectedReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{UID: uid}}}, + existingReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, + expectedReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{UID: uid}}}, taskState: actor.TaskInProgress, redirect: page.Paths.ChooseReplacementAttorneys.Format("lpa-id") + "?id=" + testUID.String(), }, "no": { yesNo: form.No, - existingReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + existingReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {UID: uid}, {UID: actoruid.New()}, }}, - expectedReplacementAttorneys: actor.Attorneys{}, + expectedReplacementAttorneys: donordata.Attorneys{}, taskState: actor.TaskCompleted, redirect: page.Paths.TaskList.Format("lpa-id"), }, @@ -127,18 +128,18 @@ func TestPostWantReplacementAttorneys(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", WantReplacementAttorneys: tc.yesNo, ReplacementAttorneys: tc.expectedReplacementAttorneys, - Tasks: actor.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, ChooseReplacementAttorneys: tc.taskState}, + Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, ChooseReplacementAttorneys: tc.taskState}, }). Return(nil) - err := WantReplacementAttorneys(nil, donorStore, testUIDFn)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := WantReplacementAttorneys(nil, donorStore, testUIDFn)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", ReplacementAttorneys: tc.existingReplacementAttorneys, - Tasks: actor.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted}, + Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted}, }) resp := w.Result() @@ -163,7 +164,7 @@ func TestPostWantReplacementAttorneysWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := WantReplacementAttorneys(nil, donorStore, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := WantReplacementAttorneys(nil, donorStore, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } @@ -180,7 +181,7 @@ func TestPostWantReplacementAttorneysWhenValidationErrors(t *testing.T) { })). Return(nil) - err := WantReplacementAttorneys(template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := WantReplacementAttorneys(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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 a1c6bd9a0c..2e9b6f4124 100644 --- a/internal/donor/donorpage/what_is_vouching.go +++ b/internal/donor/donorpage/what_is_vouching.go @@ -4,7 +4,7 @@ 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/validation" @@ -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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 e706094832..43897f2d54 100644 --- a/internal/donor/donorpage/what_is_vouching_test.go +++ b/internal/donor/donorpage/what_is_vouching_test.go @@ -7,7 +7,7 @@ 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/stretchr/testify/assert" @@ -30,7 +30,7 @@ func TestGetWhatIsVouching(t *testing.T) { }). Return(nil) - err := WhatIsVouching(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{WantVoucher: form.Yes}) + err := WhatIsVouching(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{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, &actor.DonorProvidedDetails{}) + err := WhatIsVouching(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Error(t, err) } @@ -67,13 +67,13 @@ func TestPostWhatIsVouching(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", WantVoucher: yesNo, }). Return(nil) - err := WhatIsVouching(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id"}) + err := WhatIsVouching(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{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, &actor.DonorProvidedDetails{LpaID: "lpa-id"}) + err := WhatIsVouching(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{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 4a2d068b9d..5988c3e447 100644 --- a/internal/donor/donorpage/what_you_can_do_now.go +++ b/internal/donor/donorpage/what_you_can_do_now.go @@ -5,6 +5,7 @@ import ( "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/identity" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" @@ -18,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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 520370a552..cae748ac69 100644 --- a/internal/donor/donorpage/what_you_can_do_now_test.go +++ b/internal/donor/donorpage/what_you_can_do_now_test.go @@ -8,6 +8,7 @@ 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/identity" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" @@ -30,7 +31,7 @@ func TestGetWhatYouCanDoNow(t *testing.T) { }). Return(nil) - err := WhatYouCanDoNow(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := WhatYouCanDoNow(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Nil(t, err) } @@ -44,7 +45,7 @@ func TestGetWhatYouCanDoNowWhenTemplateError(t *testing.T) { Execute(mock.Anything, mock.Anything). Return(expectedError) - err := WhatYouCanDoNow(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := WhatYouCanDoNow(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Error(t, err) } @@ -52,18 +53,18 @@ func TestGetWhatYouCanDoNowWhenTemplateError(t *testing.T) { func TestPostWhatYouCanDoNow(t *testing.T) { testcases := map[actor.NoVoucherDecision]struct { expectedPath string - expectedDonor *actor.DonorProvidedDetails + expectedDonor *donordata.DonorProvidedDetails }{ actor.ProveOwnID: { expectedPath: page.Paths.TaskList.Format("lpa-id"), - expectedDonor: &actor.DonorProvidedDetails{ + expectedDonor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{}, }, }, actor.SelectNewVoucher: { expectedPath: page.Paths.EnterVoucher.Format("lpa-id"), - expectedDonor: &actor.DonorProvidedDetails{ + expectedDonor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", WantVoucher: form.Yes, DonorIdentityUserData: identity.UserData{Status: identity.StatusInsufficientEvidence}, @@ -71,14 +72,14 @@ func TestPostWhatYouCanDoNow(t *testing.T) { }, actor.WithdrawLPA: { expectedPath: page.Paths.WithdrawThisLpa.Format("lpa-id"), - expectedDonor: &actor.DonorProvidedDetails{ + expectedDonor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusInsufficientEvidence}, }, }, actor.ApplyToCOP: { expectedPath: page.Paths.WhatHappensNextRegisteringWithCourtOfProtection.Format("lpa-id"), - expectedDonor: &actor.DonorProvidedDetails{ + expectedDonor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", RegisteringWithCourtOfProtection: true, DonorIdentityUserData: identity.UserData{Status: identity.StatusInsufficientEvidence}, @@ -101,7 +102,7 @@ func TestPostWhatYouCanDoNow(t *testing.T) { Put(r.Context(), tc.expectedDonor). Return(nil) - err := WhatYouCanDoNow(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusInsufficientEvidence}}) + err := WhatYouCanDoNow(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusInsufficientEvidence}}) resp := w.Result() assert.Nil(t, err) @@ -125,7 +126,7 @@ func TestPostWhatYouCanDoNowWhenDonorStoreError(t *testing.T) { Put(mock.Anything, mock.Anything). Return(expectedError) - err := WhatYouCanDoNow(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id"}) + err := WhatYouCanDoNow(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) resp := w.Result() assert.Error(t, err) @@ -148,7 +149,7 @@ func TestPostWhatYouCanDoNowWhenValidationErrors(t *testing.T) { })). Return(nil) - err := WhatYouCanDoNow(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id"}) + err := WhatYouCanDoNow(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{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 601a657d42..b6598888a8 100644 --- a/internal/donor/donorpage/when_can_the_lpa_be_used.go +++ b/internal/donor/donorpage/when_can_the_lpa_be_used.go @@ -13,13 +13,13 @@ import ( type whenCanTheLpaBeUsedData struct { App page.AppData Errors validation.List - Donor *actor.DonorProvidedDetails + Donor *donordata.DonorProvidedDetails 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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { data := &whenCanTheLpaBeUsedData{ App: appData, Donor: donor, @@ -49,7 +49,7 @@ func WhenCanTheLpaBeUsed(tmpl template.Template, donorStore DonorStore) Handler } type whenCanTheLpaBeUsedForm struct { - When actor.CanBeUsedWhen + When donordata.CanBeUsedWhen Error error } 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 bcc52f9186..b88d0b2b2d 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 @@ -23,13 +23,13 @@ func TestGetWhenCanTheLpaBeUsed(t *testing.T) { template.EXPECT(). Execute(w, &whenCanTheLpaBeUsedData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{}, + Donor: &donordata.DonorProvidedDetails{}, Form: &whenCanTheLpaBeUsedForm{}, Options: donordata.CanBeUsedWhenValues, }). Return(nil) - err := WhenCanTheLpaBeUsed(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := WhenCanTheLpaBeUsed(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -44,15 +44,15 @@ func TestGetWhenCanTheLpaBeUsedFromStore(t *testing.T) { template.EXPECT(). Execute(w, &whenCanTheLpaBeUsedData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{WhenCanTheLpaBeUsed: actor.CanBeUsedWhenHasCapacity}, + Donor: &donordata.DonorProvidedDetails{WhenCanTheLpaBeUsed: donordata.CanBeUsedWhenHasCapacity}, Form: &whenCanTheLpaBeUsedForm{ - When: actor.CanBeUsedWhenHasCapacity, + When: donordata.CanBeUsedWhenHasCapacity, }, Options: donordata.CanBeUsedWhenValues, }). Return(nil) - err := WhenCanTheLpaBeUsed(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{WhenCanTheLpaBeUsed: actor.CanBeUsedWhenHasCapacity}) + err := WhenCanTheLpaBeUsed(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{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, &actor.DonorProvidedDetails{}) + err := WhenCanTheLpaBeUsed(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -77,7 +77,7 @@ func TestGetWhenCanTheLpaBeUsedWhenTemplateErrors(t *testing.T) { func TestPostWhenCanTheLpaBeUsed(t *testing.T) { form := url.Values{ - "when": {actor.CanBeUsedWhenHasCapacity.String()}, + "when": {donordata.CanBeUsedWhenHasCapacity.String()}, } w := httptest.NewRecorder() @@ -86,16 +86,16 @@ func TestPostWhenCanTheLpaBeUsed(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - WhenCanTheLpaBeUsed: actor.CanBeUsedWhenHasCapacity, - Tasks: actor.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, WhenCanTheLpaBeUsed: actor.TaskCompleted}, + WhenCanTheLpaBeUsed: donordata.CanBeUsedWhenHasCapacity, + Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, WhenCanTheLpaBeUsed: actor.TaskCompleted}, }). Return(nil) - err := WhenCanTheLpaBeUsed(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := WhenCanTheLpaBeUsed(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Tasks: actor.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted}, + Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted}, }) resp := w.Result() @@ -106,7 +106,7 @@ func TestPostWhenCanTheLpaBeUsed(t *testing.T) { func TestPostWhenCanTheLpaBeUsedWhenStoreErrors(t *testing.T) { form := url.Values{ - "when": {actor.CanBeUsedWhenHasCapacity.String()}, + "when": {donordata.CanBeUsedWhenHasCapacity.String()}, } w := httptest.NewRecorder() @@ -115,10 +115,10 @@ func TestPostWhenCanTheLpaBeUsedWhenStoreErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{WhenCanTheLpaBeUsed: actor.CanBeUsedWhenHasCapacity, Tasks: actor.DonorTasks{WhenCanTheLpaBeUsed: actor.TaskCompleted}}). + Put(r.Context(), &donordata.DonorProvidedDetails{WhenCanTheLpaBeUsed: donordata.CanBeUsedWhenHasCapacity, Tasks: donordata.DonorTasks{WhenCanTheLpaBeUsed: actor.TaskCompleted}}). Return(expectedError) - err := WhenCanTheLpaBeUsed(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := WhenCanTheLpaBeUsed(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } @@ -135,7 +135,7 @@ func TestPostWhenCanTheLpaBeUsedWhenValidationErrors(t *testing.T) { })). Return(nil) - err := WhenCanTheLpaBeUsed(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := WhenCanTheLpaBeUsed(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -144,7 +144,7 @@ func TestPostWhenCanTheLpaBeUsedWhenValidationErrors(t *testing.T) { func TestReadWhenCanTheLpaBeUsedForm(t *testing.T) { form := url.Values{ - "when": {actor.CanBeUsedWhenHasCapacity.String()}, + "when": {donordata.CanBeUsedWhenHasCapacity.String()}, } r, _ := http.NewRequest(http.MethodPost, "/", strings.NewReader(form.Encode())) @@ -152,7 +152,7 @@ func TestReadWhenCanTheLpaBeUsedForm(t *testing.T) { result := readWhenCanTheLpaBeUsedForm(r) - assert.Equal(t, actor.CanBeUsedWhenHasCapacity, result.When) + assert.Equal(t, donordata.CanBeUsedWhenHasCapacity, result.When) } func TestWhenCanTheLpaBeUsedFormValidate(t *testing.T) { 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 86c85ddc26..3555662c6a 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 @@ -4,7 +4,7 @@ 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/pay" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 2964f31a17..42b3997c36 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 @@ -7,7 +7,7 @@ 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" pay "github.com/ministryofjustice/opg-modernising-lpa/internal/pay" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -28,7 +28,7 @@ func TestGetWhichFeeTypeAreYouApplyingFor(t *testing.T) { }). Return(nil) - err := WhichFeeTypeAreYouApplyingFor(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := WhichFeeTypeAreYouApplyingFor(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{FeeType: pay.HalfFee}) + err := WhichFeeTypeAreYouApplyingFor(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{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, &actor.DonorProvidedDetails{}) + err := WhichFeeTypeAreYouApplyingFor(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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(), &actor.DonorProvidedDetails{LpaID: "lpa-id", FeeType: feeType}). + Put(r.Context(), &donordata.DonorProvidedDetails{LpaID: "lpa-id", FeeType: feeType}). Return(nil) - err := WhichFeeTypeAreYouApplyingFor(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id"}) + err := WhichFeeTypeAreYouApplyingFor(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{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(), &actor.DonorProvidedDetails{LpaID: "lpa-id", FeeType: pay.HalfFee}). + Put(r.Context(), &donordata.DonorProvidedDetails{LpaID: "lpa-id", FeeType: pay.HalfFee}). Return(expectedError) - err := WhichFeeTypeAreYouApplyingFor(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id"}) + err := WhichFeeTypeAreYouApplyingFor(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{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, &actor.DonorProvidedDetails{LpaID: "lpa-id"}) + err := WhichFeeTypeAreYouApplyingFor(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{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 0e86b17cca..875b43f682 100644 --- a/internal/donor/donorpage/withdraw_lpa.go +++ b/internal/donor/donorpage/withdraw_lpa.go @@ -6,7 +6,7 @@ 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/validation" ) @@ -14,11 +14,11 @@ import ( type withdrawLpaData struct { App page.AppData Errors validation.List - Donor *actor.DonorProvidedDetails + Donor *donordata.DonorProvidedDetails } func WithdrawLpa(tmpl template.Template, donorStore DonorStore, now func() time.Time) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 14068b983a..7e4328754b 100644 --- a/internal/donor/donorpage/withdraw_lpa_test.go +++ b/internal/donor/donorpage/withdraw_lpa_test.go @@ -7,7 +7,7 @@ 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/page" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -21,11 +21,11 @@ func TestGetWithdrawLpa(t *testing.T) { template.EXPECT(). Execute(w, &withdrawLpaData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{}, + Donor: &donordata.DonorProvidedDetails{}, }). Return(nil) - err := WithdrawLpa(template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := WithdrawLpa(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := WithdrawLpa(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaUID: "lpa-uid", WithdrawnAt: now, }). Return(nil) - err := WithdrawLpa(nil, donorStore, func() time.Time { return now })(testAppData, w, r, &actor.DonorProvidedDetails{LpaUID: "lpa-uid"}) + err := WithdrawLpa(nil, donorStore, func() time.Time { return now })(testAppData, w, r, &donordata.DonorProvidedDetails{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, &actor.DonorProvidedDetails{LpaUID: "lpa-uid"}) + err := WithdrawLpa(nil, donorStore, time.Now)(testAppData, w, r, &donordata.DonorProvidedDetails{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 75b5667d0b..657c54fb06 100644 --- a/internal/donor/donorpage/witnessing_as_certificate_provider.go +++ b/internal/donor/donorpage/witnessing_as_certificate_provider.go @@ -6,6 +6,7 @@ import ( "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/validation" ) @@ -14,7 +15,7 @@ type witnessingAsCertificateProviderData struct { App page.AppData Errors validation.List Form *witnessingAsCertificateProviderForm - Donor *actor.DonorProvidedDetails + Donor *donordata.DonorProvidedDetails } func WitnessingAsCertificateProvider( @@ -24,7 +25,7 @@ func WitnessingAsCertificateProvider( lpaStoreClient LpaStoreClient, now func() time.Time, ) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { data := &witnessingAsCertificateProviderData{ App: appData, Donor: donor, @@ -36,7 +37,7 @@ func WitnessingAsCertificateProvider( data.Errors = data.Form.Validate() if donor.WitnessCodeLimiter == nil { - donor.WitnessCodeLimiter = actor.NewLimiter(time.Minute, 5, 10) + donor.WitnessCodeLimiter = donordata.NewLimiter(time.Minute, 5, 10) } if !donor.WitnessCodeLimiter.Allow(now()) { diff --git a/internal/donor/donorpage/witnessing_as_certificate_provider_test.go b/internal/donor/donorpage/witnessing_as_certificate_provider_test.go index a91e4a2968..e7340b38e4 100644 --- a/internal/donor/donorpage/witnessing_as_certificate_provider_test.go +++ b/internal/donor/donorpage/witnessing_as_certificate_provider_test.go @@ -9,8 +9,10 @@ import ( "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" + "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 +26,12 @@ func TestGetWitnessingAsCertificateProvider(t *testing.T) { template.EXPECT(). Execute(w, &witnessingAsCertificateProviderData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{}, + Donor: &donordata.DonorProvidedDetails{}, Form: &witnessingAsCertificateProviderForm{}, }). Return(nil) - err := WitnessingAsCertificateProvider(template.Execute, nil, nil, nil, time.Now)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := WitnessingAsCertificateProvider(template.Execute, nil, nil, nil, time.Now)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -44,15 +46,15 @@ func TestGetWitnessingAsCertificateProviderFromStore(t *testing.T) { template.EXPECT(). Execute(w, &witnessingAsCertificateProviderData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{ - CertificateProvider: actor.CertificateProvider{FirstNames: "Joan"}, + Donor: &donordata.DonorProvidedDetails{ + CertificateProvider: donordata.CertificateProvider{FirstNames: "Joan"}, }, Form: &witnessingAsCertificateProviderForm{}, }). Return(nil) - err := WitnessingAsCertificateProvider(template.Execute, nil, nil, nil, time.Now)(testAppData, w, r, &actor.DonorProvidedDetails{ - CertificateProvider: actor.CertificateProvider{FirstNames: "Joan"}, + err := WitnessingAsCertificateProvider(template.Execute, nil, nil, nil, time.Now)(testAppData, w, r, &donordata.DonorProvidedDetails{ + CertificateProvider: donordata.CertificateProvider{FirstNames: "Joan"}, }) resp := w.Result() @@ -68,12 +70,12 @@ func TestGetWitnessingAsCertificateProviderWhenTemplateErrors(t *testing.T) { template.EXPECT(). Execute(w, &witnessingAsCertificateProviderData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{}, + Donor: &donordata.DonorProvidedDetails{}, Form: &witnessingAsCertificateProviderForm{}, }). Return(expectedError) - err := WitnessingAsCertificateProvider(template.Execute, nil, nil, nil, time.Now)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := WitnessingAsCertificateProvider(template.Execute, nil, nil, nil, time.Now)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -105,15 +107,15 @@ func TestPostWitnessingAsCertificateProvider(t *testing.T) { r.Header.Add("Content-Type", page.FormUrlEncoded) now := time.Now() - donor := &actor.DonorProvidedDetails{ + donor := &donordata.DonorProvidedDetails{ LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, - CertificateProviderCodes: actor.WitnessCodes{{Code: "1234", Created: now}}, - CertificateProvider: actor.CertificateProvider{FirstNames: "Fred"}, + CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, + CertificateProvider: donordata.CertificateProvider{FirstNames: "Fred"}, WitnessedByCertificateProviderAt: now, - Tasks: actor.DonorTasks{ + Tasks: donordata.DonorTasks{ ConfirmYourIdentityAndSign: tc.expectedIdentityAndSignTaskStatus, - PayForLpa: actor.PaymentTaskCompleted, + PayForLpa: task.PaymentStateCompleted, }, RegisteringWithCourtOfProtection: tc.registeringWithCOP, } @@ -133,12 +135,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, &actor.DonorProvidedDetails{ + err := WitnessingAsCertificateProvider(nil, donorStore, shareCodeSender, lpaStoreClient, func() time.Time { return now })(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, - CertificateProviderCodes: actor.WitnessCodes{{Code: "1234", Created: now}}, - CertificateProvider: actor.CertificateProvider{FirstNames: "Fred"}, - Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskCompleted}, + CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, + CertificateProvider: donordata.CertificateProvider{FirstNames: "Fred"}, + Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateCompleted}, RegisteringWithCourtOfProtection: tc.registeringWithCOP, }) resp := w.Result() @@ -161,14 +163,14 @@ func TestPostWitnessingAsCertificateProviderWhenPaymentPending(t *testing.T) { r.Header.Add("Content-Type", page.FormUrlEncoded) now := time.Now() - donor := &actor.DonorProvidedDetails{ + donor := &donordata.DonorProvidedDetails{ LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, - CertificateProvider: actor.CertificateProvider{Email: "name@example.com"}, - CertificateProviderCodes: actor.WitnessCodes{{Code: "1234", Created: now}}, + CertificateProvider: donordata.CertificateProvider{Email: "name@example.com"}, + CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, WitnessedByCertificateProviderAt: now, - Tasks: actor.DonorTasks{ - PayForLpa: actor.PaymentTaskPending, + Tasks: donordata.DonorTasks{ + PayForLpa: task.PaymentStatePending, ConfirmYourIdentityAndSign: actor.IdentityTaskCompleted, }, } @@ -177,12 +179,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, &actor.DonorProvidedDetails{ + err := WitnessingAsCertificateProvider(nil, donorStore, nil, nil, func() time.Time { return now })(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, - CertificateProvider: actor.CertificateProvider{Email: "name@example.com"}, - CertificateProviderCodes: actor.WitnessCodes{{Code: "1234", Created: now}}, - Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskPending}, + CertificateProvider: donordata.CertificateProvider{Email: "name@example.com"}, + CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, + Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStatePending}, }) resp := w.Result() @@ -216,12 +218,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, &actor.DonorProvidedDetails{ + err := WitnessingAsCertificateProvider(nil, donorStore, shareCodeSender, lpaStoreClient, func() time.Time { return now })(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, - CertificateProviderCodes: actor.WitnessCodes{{Code: "1234", Created: now}}, - CertificateProvider: actor.CertificateProvider{FirstNames: "Fred"}, - Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskCompleted}, + CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, + CertificateProvider: donordata.CertificateProvider{FirstNames: "Fred"}, + Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateCompleted}, }) assert.Equal(t, expectedError, err) } @@ -246,10 +248,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, &actor.DonorProvidedDetails{ - CertificateProvider: actor.CertificateProvider{Email: "name@example.com"}, - CertificateProviderCodes: actor.WitnessCodes{{Code: "1234", Created: now}}, - Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskCompleted}, + err := WitnessingAsCertificateProvider(nil, donorStore, shareCodeSender, nil, func() time.Time { return now })(testAppData, w, r, &donordata.DonorProvidedDetails{ + CertificateProvider: donordata.CertificateProvider{Email: "name@example.com"}, + CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, + Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateCompleted}, }) assert.Equal(t, expectedError, err) @@ -269,10 +271,10 @@ func TestPostWitnessingAsCertificateProviderCodeTooOld(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), mock.MatchedBy(func(donor *actor.DonorProvidedDetails) bool { + Put(r.Context(), mock.MatchedBy(func(donor *donordata.DonorProvidedDetails) bool { donor.WitnessCodeLimiter = nil - return assert.Equal(t, donor, &actor.DonorProvidedDetails{ - CertificateProviderCodes: actor.WitnessCodes{{Code: "1234", Created: invalidCreated}}, + return assert.Equal(t, donor, &donordata.DonorProvidedDetails{ + CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: invalidCreated}}, }) })). Return(nil) @@ -281,16 +283,16 @@ func TestPostWitnessingAsCertificateProviderCodeTooOld(t *testing.T) { template.EXPECT(). Execute(w, &witnessingAsCertificateProviderData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{ - CertificateProviderCodes: actor.WitnessCodes{{Code: "1234", Created: invalidCreated}}, + Donor: &donordata.DonorProvidedDetails{ + CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: invalidCreated}}, }, Errors: validation.With("witness-code", validation.CustomError{Label: "witnessCodeExpired"}), Form: &witnessingAsCertificateProviderForm{Code: "1234"}, }). Return(nil) - err := WitnessingAsCertificateProvider(template.Execute, donorStore, nil, nil, time.Now)(testAppData, w, r, &actor.DonorProvidedDetails{ - CertificateProviderCodes: actor.WitnessCodes{{Code: "1234", Created: invalidCreated}}, + err := WitnessingAsCertificateProvider(template.Execute, donorStore, nil, nil, time.Now)(testAppData, w, r, &donordata.DonorProvidedDetails{ + CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: invalidCreated}}, }) resp := w.Result() @@ -311,10 +313,10 @@ func TestPostWitnessingAsCertificateProviderCodeDoesNotMatch(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), mock.MatchedBy(func(donor *actor.DonorProvidedDetails) bool { + Put(r.Context(), mock.MatchedBy(func(donor *donordata.DonorProvidedDetails) bool { donor.WitnessCodeLimiter = nil - return assert.Equal(t, donor, &actor.DonorProvidedDetails{ - CertificateProviderCodes: actor.WitnessCodes{{Code: "1234", Created: now}}, + return assert.Equal(t, donor, &donordata.DonorProvidedDetails{ + CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, }) })). Return(nil) @@ -323,16 +325,16 @@ func TestPostWitnessingAsCertificateProviderCodeDoesNotMatch(t *testing.T) { template.EXPECT(). Execute(w, &witnessingAsCertificateProviderData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{ - CertificateProviderCodes: actor.WitnessCodes{{Code: "1234", Created: now}}, + Donor: &donordata.DonorProvidedDetails{ + CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, }, Errors: validation.With("witness-code", validation.CustomError{Label: "witnessCodeDoesNotMatch"}), Form: &witnessingAsCertificateProviderForm{Code: "4321"}, }). Return(nil) - err := WitnessingAsCertificateProvider(template.Execute, donorStore, nil, nil, time.Now)(testAppData, w, r, &actor.DonorProvidedDetails{ - CertificateProviderCodes: actor.WitnessCodes{{Code: "1234", Created: now}}, + err := WitnessingAsCertificateProvider(template.Execute, donorStore, nil, nil, time.Now)(testAppData, w, r, &donordata.DonorProvidedDetails{ + CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, }) resp := w.Result() @@ -354,10 +356,10 @@ func TestPostWitnessingAsCertificateProviderWhenCodeExpired(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), mock.MatchedBy(func(donor *actor.DonorProvidedDetails) bool { + Put(r.Context(), mock.MatchedBy(func(donor *donordata.DonorProvidedDetails) bool { donor.WitnessCodeLimiter = nil - return assert.Equal(t, donor, &actor.DonorProvidedDetails{ - CertificateProviderCodes: actor.WitnessCodes{{Code: "1234", Created: invalidCreated}}, + return assert.Equal(t, donor, &donordata.DonorProvidedDetails{ + CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: invalidCreated}}, }) })). Return(nil) @@ -366,16 +368,16 @@ func TestPostWitnessingAsCertificateProviderWhenCodeExpired(t *testing.T) { template.EXPECT(). Execute(w, &witnessingAsCertificateProviderData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{ - CertificateProviderCodes: actor.WitnessCodes{{Code: "1234", Created: invalidCreated}}, + Donor: &donordata.DonorProvidedDetails{ + CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: invalidCreated}}, }, Errors: validation.With("witness-code", validation.CustomError{Label: "witnessCodeExpired"}), Form: &witnessingAsCertificateProviderForm{Code: "1234"}, }). Return(nil) - err := WitnessingAsCertificateProvider(template.Execute, donorStore, nil, nil, time.Now)(testAppData, w, r, &actor.DonorProvidedDetails{ - CertificateProviderCodes: actor.WitnessCodes{{Code: "1234", Created: invalidCreated}}, + err := WitnessingAsCertificateProvider(template.Execute, donorStore, nil, nil, time.Now)(testAppData, w, r, &donordata.DonorProvidedDetails{ + CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: invalidCreated}}, }) resp := w.Result() @@ -396,10 +398,10 @@ func TestPostWitnessingAsCertificateProviderCodeLimitBreached(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), mock.MatchedBy(func(donor *actor.DonorProvidedDetails) bool { + Put(r.Context(), mock.MatchedBy(func(donor *donordata.DonorProvidedDetails) bool { donor.WitnessCodeLimiter = nil - return assert.Equal(t, donor, &actor.DonorProvidedDetails{ - CertificateProviderCodes: actor.WitnessCodes{{Code: "1234", Created: now}}, + return assert.Equal(t, donor, &donordata.DonorProvidedDetails{ + CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, }) })). Return(nil) @@ -408,17 +410,17 @@ func TestPostWitnessingAsCertificateProviderCodeLimitBreached(t *testing.T) { template.EXPECT(). Execute(w, &witnessingAsCertificateProviderData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{ - CertificateProviderCodes: actor.WitnessCodes{{Code: "1234", Created: now}}, + Donor: &donordata.DonorProvidedDetails{ + CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, }, Errors: validation.With("witness-code", validation.CustomError{Label: "tooManyWitnessCodeAttempts"}), Form: &witnessingAsCertificateProviderForm{Code: "4321"}, }). Return(nil) - err := WitnessingAsCertificateProvider(template.Execute, donorStore, nil, nil, time.Now)(testAppData, w, r, &actor.DonorProvidedDetails{ - WitnessCodeLimiter: actor.NewLimiter(time.Minute, 0, 10), - CertificateProviderCodes: actor.WitnessCodes{{Code: "1234", Created: now}}, + err := WitnessingAsCertificateProvider(template.Execute, donorStore, nil, nil, time.Now)(testAppData, w, r, &donordata.DonorProvidedDetails{ + WitnessCodeLimiter: donordata.NewLimiter(time.Minute, 0, 10), + CertificateProviderCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, }) resp := w.Result() diff --git a/internal/donor/donorpage/witnessing_as_independent_witness.go b/internal/donor/donorpage/witnessing_as_independent_witness.go index ea6d83c0c9..8e3bcf7a8b 100644 --- a/internal/donor/donorpage/witnessing_as_independent_witness.go +++ b/internal/donor/donorpage/witnessing_as_independent_witness.go @@ -5,7 +5,7 @@ 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/validation" ) @@ -14,11 +14,11 @@ type witnessingAsIndependentWitnessData struct { App page.AppData Errors validation.List Form *witnessingAsIndependentWitnessForm - Donor *actor.DonorProvidedDetails + Donor *donordata.DonorProvidedDetails } func WitnessingAsIndependentWitness(tmpl template.Template, donorStore DonorStore, now func() time.Time) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { data := &witnessingAsIndependentWitnessData{ App: appData, Donor: donor, @@ -30,7 +30,7 @@ func WitnessingAsIndependentWitness(tmpl template.Template, donorStore DonorStor data.Errors = data.Form.Validate() if donor.WitnessCodeLimiter == nil { - donor.WitnessCodeLimiter = actor.NewLimiter(time.Minute, 5, 10) + donor.WitnessCodeLimiter = donordata.NewLimiter(time.Minute, 5, 10) } if !donor.WitnessCodeLimiter.Allow(now()) { diff --git a/internal/donor/donorpage/witnessing_as_independent_witness_test.go b/internal/donor/donorpage/witnessing_as_independent_witness_test.go index dd5a5c2d9a..be77a95b14 100644 --- a/internal/donor/donorpage/witnessing_as_independent_witness_test.go +++ b/internal/donor/donorpage/witnessing_as_independent_witness_test.go @@ -8,7 +8,7 @@ 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" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -24,12 +24,12 @@ func TestGetWitnessingAsIndependentWitness(t *testing.T) { template.EXPECT(). Execute(w, &witnessingAsIndependentWitnessData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{}, + Donor: &donordata.DonorProvidedDetails{}, Form: &witnessingAsIndependentWitnessForm{}, }). Return(nil) - err := WitnessingAsIndependentWitness(template.Execute, nil, time.Now)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := WitnessingAsIndependentWitness(template.Execute, nil, time.Now)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -44,15 +44,15 @@ func TestGetWitnessingAsIndependentWitnessFromStore(t *testing.T) { template.EXPECT(). Execute(w, &witnessingAsIndependentWitnessData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{ - IndependentWitness: actor.IndependentWitness{FirstNames: "Joan"}, + Donor: &donordata.DonorProvidedDetails{ + IndependentWitness: donordata.IndependentWitness{FirstNames: "Joan"}, }, Form: &witnessingAsIndependentWitnessForm{}, }). Return(nil) - err := WitnessingAsIndependentWitness(template.Execute, nil, time.Now)(testAppData, w, r, &actor.DonorProvidedDetails{ - IndependentWitness: actor.IndependentWitness{FirstNames: "Joan"}, + err := WitnessingAsIndependentWitness(template.Execute, nil, time.Now)(testAppData, w, r, &donordata.DonorProvidedDetails{ + 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: &actor.DonorProvidedDetails{}, + Donor: &donordata.DonorProvidedDetails{}, Form: &witnessingAsIndependentWitnessForm{}, }). Return(expectedError) - err := WitnessingAsIndependentWitness(template.Execute, nil, time.Now)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := WitnessingAsIndependentWitness(template.Execute, nil, time.Now)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -92,18 +92,18 @@ func TestPostWitnessingAsIndependentWitness(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, - IndependentWitnessCodes: actor.WitnessCodes{{Code: "1234", Created: now}}, + IndependentWitnessCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, WitnessedByIndependentWitnessAt: now, }). Return(nil) - err := WitnessingAsIndependentWitness(nil, donorStore, func() time.Time { return now })(testAppData, w, r, &actor.DonorProvidedDetails{ + err := WitnessingAsIndependentWitness(nil, donorStore, func() time.Time { return now })(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, - IndependentWitnessCodes: actor.WitnessCodes{{Code: "1234", Created: now}}, + IndependentWitnessCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, }) resp := w.Result() @@ -127,10 +127,10 @@ func TestPostWitnessingAsIndependentWitnessWhenDonorStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := WitnessingAsIndependentWitness(nil, donorStore, func() time.Time { return now })(testAppData, w, r, &actor.DonorProvidedDetails{ + err := WitnessingAsIndependentWitness(nil, donorStore, func() time.Time { return now })(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, - IndependentWitnessCodes: actor.WitnessCodes{{Code: "1234", Created: now}}, + IndependentWitnessCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, }) assert.Equal(t, expectedError, err) } @@ -149,10 +149,10 @@ func TestPostWitnessingAsIndependentWitnessCodeTooOld(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), mock.MatchedBy(func(donor *actor.DonorProvidedDetails) bool { + Put(r.Context(), mock.MatchedBy(func(donor *donordata.DonorProvidedDetails) bool { donor.WitnessCodeLimiter = nil - return assert.Equal(t, donor, &actor.DonorProvidedDetails{ - IndependentWitnessCodes: actor.WitnessCodes{{Code: "1234", Created: invalidCreated}}, + return assert.Equal(t, donor, &donordata.DonorProvidedDetails{ + IndependentWitnessCodes: donordata.WitnessCodes{{Code: "1234", Created: invalidCreated}}, }) })). Return(nil) @@ -161,16 +161,16 @@ func TestPostWitnessingAsIndependentWitnessCodeTooOld(t *testing.T) { template.EXPECT(). Execute(w, &witnessingAsIndependentWitnessData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{ - IndependentWitnessCodes: actor.WitnessCodes{{Code: "1234", Created: invalidCreated}}, + Donor: &donordata.DonorProvidedDetails{ + IndependentWitnessCodes: donordata.WitnessCodes{{Code: "1234", Created: invalidCreated}}, }, Errors: validation.With("witness-code", validation.CustomError{Label: "witnessCodeExpired"}), Form: &witnessingAsIndependentWitnessForm{Code: "1234"}, }). Return(nil) - err := WitnessingAsIndependentWitness(template.Execute, donorStore, time.Now)(testAppData, w, r, &actor.DonorProvidedDetails{ - IndependentWitnessCodes: actor.WitnessCodes{{Code: "1234", Created: invalidCreated}}, + err := WitnessingAsIndependentWitness(template.Execute, donorStore, time.Now)(testAppData, w, r, &donordata.DonorProvidedDetails{ + IndependentWitnessCodes: donordata.WitnessCodes{{Code: "1234", Created: invalidCreated}}, }) resp := w.Result() @@ -191,10 +191,10 @@ func TestPostWitnessingAsIndependentWitnessCodeDoesNotMatch(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), mock.MatchedBy(func(donor *actor.DonorProvidedDetails) bool { + Put(r.Context(), mock.MatchedBy(func(donor *donordata.DonorProvidedDetails) bool { donor.WitnessCodeLimiter = nil - return assert.Equal(t, donor, &actor.DonorProvidedDetails{ - IndependentWitnessCodes: actor.WitnessCodes{{Code: "1234", Created: now}}, + return assert.Equal(t, donor, &donordata.DonorProvidedDetails{ + IndependentWitnessCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, }) })). Return(nil) @@ -203,16 +203,16 @@ func TestPostWitnessingAsIndependentWitnessCodeDoesNotMatch(t *testing.T) { template.EXPECT(). Execute(w, &witnessingAsIndependentWitnessData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{ - IndependentWitnessCodes: actor.WitnessCodes{{Code: "1234", Created: now}}, + Donor: &donordata.DonorProvidedDetails{ + IndependentWitnessCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, }, Errors: validation.With("witness-code", validation.CustomError{Label: "witnessCodeDoesNotMatch"}), Form: &witnessingAsIndependentWitnessForm{Code: "4321"}, }). Return(nil) - err := WitnessingAsIndependentWitness(template.Execute, donorStore, time.Now)(testAppData, w, r, &actor.DonorProvidedDetails{ - IndependentWitnessCodes: actor.WitnessCodes{{Code: "1234", Created: now}}, + err := WitnessingAsIndependentWitness(template.Execute, donorStore, time.Now)(testAppData, w, r, &donordata.DonorProvidedDetails{ + IndependentWitnessCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, }) resp := w.Result() @@ -234,10 +234,10 @@ func TestPostWitnessingAsIndependentWitnessWhenCodeExpired(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), mock.MatchedBy(func(donor *actor.DonorProvidedDetails) bool { + Put(r.Context(), mock.MatchedBy(func(donor *donordata.DonorProvidedDetails) bool { donor.WitnessCodeLimiter = nil - return assert.Equal(t, donor, &actor.DonorProvidedDetails{ - IndependentWitnessCodes: actor.WitnessCodes{{Code: "1234", Created: invalidCreated}}, + return assert.Equal(t, donor, &donordata.DonorProvidedDetails{ + IndependentWitnessCodes: donordata.WitnessCodes{{Code: "1234", Created: invalidCreated}}, }) })). Return(nil) @@ -246,16 +246,16 @@ func TestPostWitnessingAsIndependentWitnessWhenCodeExpired(t *testing.T) { template.EXPECT(). Execute(w, &witnessingAsIndependentWitnessData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{ - IndependentWitnessCodes: actor.WitnessCodes{{Code: "1234", Created: invalidCreated}}, + Donor: &donordata.DonorProvidedDetails{ + IndependentWitnessCodes: donordata.WitnessCodes{{Code: "1234", Created: invalidCreated}}, }, Errors: validation.With("witness-code", validation.CustomError{Label: "witnessCodeExpired"}), Form: &witnessingAsIndependentWitnessForm{Code: "1234"}, }). Return(nil) - err := WitnessingAsIndependentWitness(template.Execute, donorStore, time.Now)(testAppData, w, r, &actor.DonorProvidedDetails{ - IndependentWitnessCodes: actor.WitnessCodes{{Code: "1234", Created: invalidCreated}}, + err := WitnessingAsIndependentWitness(template.Execute, donorStore, time.Now)(testAppData, w, r, &donordata.DonorProvidedDetails{ + IndependentWitnessCodes: donordata.WitnessCodes{{Code: "1234", Created: invalidCreated}}, }) resp := w.Result() @@ -276,10 +276,10 @@ func TestPostWitnessingAsIndependentWitnessCodeLimitBreached(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), mock.MatchedBy(func(donor *actor.DonorProvidedDetails) bool { + Put(r.Context(), mock.MatchedBy(func(donor *donordata.DonorProvidedDetails) bool { donor.WitnessCodeLimiter = nil - return assert.Equal(t, donor, &actor.DonorProvidedDetails{ - IndependentWitnessCodes: actor.WitnessCodes{{Code: "1234", Created: now}}, + return assert.Equal(t, donor, &donordata.DonorProvidedDetails{ + IndependentWitnessCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, }) })). Return(nil) @@ -288,17 +288,17 @@ func TestPostWitnessingAsIndependentWitnessCodeLimitBreached(t *testing.T) { template.EXPECT(). Execute(w, &witnessingAsIndependentWitnessData{ App: testAppData, - Donor: &actor.DonorProvidedDetails{ - IndependentWitnessCodes: actor.WitnessCodes{{Code: "1234", Created: now}}, + Donor: &donordata.DonorProvidedDetails{ + IndependentWitnessCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, }, Errors: validation.With("witness-code", validation.CustomError{Label: "tooManyWitnessCodeAttempts"}), Form: &witnessingAsIndependentWitnessForm{Code: "4321"}, }). Return(nil) - err := WitnessingAsIndependentWitness(template.Execute, donorStore, time.Now)(testAppData, w, r, &actor.DonorProvidedDetails{ - WitnessCodeLimiter: actor.NewLimiter(time.Minute, 0, 10), - IndependentWitnessCodes: actor.WitnessCodes{{Code: "1234", Created: now}}, + err := WitnessingAsIndependentWitness(template.Execute, donorStore, time.Now)(testAppData, w, r, &donordata.DonorProvidedDetails{ + WitnessCodeLimiter: donordata.NewLimiter(time.Minute, 0, 10), + IndependentWitnessCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, }) resp := w.Result() diff --git a/internal/donor/donorpage/witnessing_your_signature.go b/internal/donor/donorpage/witnessing_your_signature.go index 55345c78c2..a9f11b6c7d 100644 --- a/internal/donor/donorpage/witnessing_your_signature.go +++ b/internal/donor/donorpage/witnessing_your_signature.go @@ -4,7 +4,7 @@ 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/validation" ) @@ -12,11 +12,11 @@ import ( type witnessingYourSignatureData struct { App page.AppData Errors validation.List - Donor *actor.DonorProvidedDetails + Donor *donordata.DonorProvidedDetails } func WitnessingYourSignature(tmpl template.Template, witnessCodeSender WitnessCodeSender, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 99a80bb564..df0d015833 100644 --- a/internal/donor/donorpage/witnessing_your_signature_test.go +++ b/internal/donor/donorpage/witnessing_your_signature_test.go @@ -6,7 +6,7 @@ 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/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/identity" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" @@ -20,7 +20,7 @@ func TestGetWitnessingYourSignature(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &actor.DonorProvidedDetails{CertificateProvider: actor.CertificateProvider{Mobile: "07535111111"}} + donor := &donordata.DonorProvidedDetails{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 := &actor.DonorProvidedDetails{CertificateProvider: actor.CertificateProvider{Mobile: "07535111111"}} + donor := &donordata.DonorProvidedDetails{CertificateProvider: donordata.CertificateProvider{Mobile: "07535111111"}} template := newMockTemplate(t) template.EXPECT(). @@ -54,11 +54,11 @@ func TestPostWitnessingYourSignature(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodPost, "/", nil) - donor := &actor.DonorProvidedDetails{ + donor := &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{CanSign: form.Yes}, + Donor: donordata.Donor{CanSign: form.Yes}, DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, - CertificateProvider: actor.CertificateProvider{Mobile: "07535111111"}, + CertificateProvider: donordata.CertificateProvider{Mobile: "07535111111"}, } witnessCodeSender := newMockWitnessCodeSender(t) @@ -78,11 +78,11 @@ func TestPostWitnessingYourSignatureCannotSign(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodPost, "/", nil) - donor := &actor.DonorProvidedDetails{ + donor := &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{CanSign: form.No}, + Donor: donordata.Donor{CanSign: form.No}, DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, - CertificateProvider: actor.CertificateProvider{Mobile: "07535111111"}, + CertificateProvider: donordata.CertificateProvider{Mobile: "07535111111"}, } witnessCodeSender := newMockWitnessCodeSender(t) @@ -90,22 +90,22 @@ func TestPostWitnessingYourSignatureCannotSign(t *testing.T) { SendToCertificateProvider(r.Context(), donor, mock.Anything). Return(nil) witnessCodeSender.EXPECT(). - SendToIndependentWitness(r.Context(), &actor.DonorProvidedDetails{ + SendToIndependentWitness(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{CanSign: form.No}, + Donor: donordata.Donor{CanSign: form.No}, DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, - CertificateProvider: actor.CertificateProvider{Mobile: "07535111111"}, + CertificateProvider: donordata.CertificateProvider{Mobile: "07535111111"}, }, mock.Anything). Return(nil) donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(r.Context()). - Return(&actor.DonorProvidedDetails{ + Return(&donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{CanSign: form.No}, + Donor: donordata.Donor{CanSign: form.No}, DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, - CertificateProvider: actor.CertificateProvider{Mobile: "07535111111"}, + CertificateProvider: donordata.CertificateProvider{Mobile: "07535111111"}, }, nil) err := WitnessingYourSignature(nil, witnessCodeSender, donorStore)(testAppData, w, r, donor) @@ -117,7 +117,7 @@ func TestPostWitnessingYourSignatureCannotSign(t *testing.T) { } func TestPostWitnessingYourSignatureWhenWitnessCodeSenderErrors(t *testing.T) { - donor := &actor.DonorProvidedDetails{Donor: actor.Donor{CanSign: form.No}, CertificateProvider: actor.CertificateProvider{Mobile: "07535111111"}} + donor := &donordata.DonorProvidedDetails{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 27a822ca95..518b7cd900 100644 --- a/internal/donor/donorpage/you_cannot_sign_your_lpa_yet.go +++ b/internal/donor/donorpage/you_cannot_sign_your_lpa_yet.go @@ -4,12 +4,12 @@ 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" ) func YouCannotSignYourLpaYet(tmpl template.Template) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 647cee1acf..c474e35790 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 @@ -5,8 +5,8 @@ import ( "net/http/httptest" "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/stretchr/testify/assert" ) @@ -15,9 +15,9 @@ func TestGetYouCannotSignYourLpaYetWithUnder18Actors(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &actor.DonorProvidedDetails{ + donor := &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {DateOfBirth: date.New(date.Today().YearString(), "1", "2")}, }}, } @@ -38,9 +38,9 @@ func TestGetYouCannotSignYourLpaYetWithUnder18ActorsWhenTemplateError(t *testing w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &actor.DonorProvidedDetails{ + donor := &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {DateOfBirth: date.New(date.Today().YearString(), "1", "2")}, }}, } @@ -61,9 +61,9 @@ func TestGetYouCannotSignYourLpaYetWithoutUnder18Actors(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - err := YouCannotSignYourLpaYet(nil)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := YouCannotSignYourLpaYet(nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + 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 16aeacb06e..5d768a80fb 100644 --- a/internal/donor/donorpage/your_address.go +++ b/internal/donor/donorpage/your_address.go @@ -5,14 +5,14 @@ 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/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" ) func YourAddress(logger Logger, tmpl template.Template, addressClient AddressClient, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { data := newChooseAddressData( appData, "", diff --git a/internal/donor/donorpage/your_address_test.go b/internal/donor/donorpage/your_address_test.go index c21f8bea59..e1e2118e4e 100644 --- a/internal/donor/donorpage/your_address_test.go +++ b/internal/donor/donorpage/your_address_test.go @@ -8,7 +8,7 @@ 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" @@ -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, &actor.DonorProvidedDetails{}) + err := YourAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -78,8 +78,8 @@ func TestGetYourAddressFromStore(t *testing.T) { }). Return(nil) - err := YourAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{ + err := YourAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + 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, &actor.DonorProvidedDetails{}) + err := YourAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := YourAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -173,18 +173,18 @@ func TestPostYourAddressManual(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{ + Donor: donordata.Donor{ Address: testAddress, }, HasSentApplicationUpdatedEvent: false, }). Return(nil) - err := YourAddress(nil, nil, nil, donorStore)(tc.appData, w, r, &actor.DonorProvidedDetails{ + err := YourAddress(nil, nil, nil, donorStore)(tc.appData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{ + Donor: donordata.Donor{ Address: place.Address{Line1: "a", Line2: "b", Line3: "c", TownOrCity: "d"}, }, HasSentApplicationUpdatedEvent: true, @@ -228,9 +228,9 @@ 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, &actor.DonorProvidedDetails{ + err := YourAddress(nil, nil, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{ + Donor: donordata.Donor{ Address: place.Address{ Line1: "a", Line2: "b", @@ -266,14 +266,14 @@ func TestPostYourAddressManualWhenStoreErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ - Donor: actor.Donor{ + Put(r.Context(), &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{ Address: testAddress, }, }). Return(expectedError) - err := YourAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := YourAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } @@ -294,18 +294,18 @@ func TestPostYourAddressManualFromStore(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{ + Donor: donordata.Donor{ FirstNames: "John", Address: testAddress, }, }). Return(nil) - err := YourAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := YourAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{ + Donor: donordata.Donor{ FirstNames: "John", Address: place.Address{Line1: "abc"}, }, @@ -348,7 +348,7 @@ func TestPostYourAddressManualWhenValidationError(t *testing.T) { }). Return(nil) - err := YourAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := YourAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := YourAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := YourAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := YourAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := YourAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := YourAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := YourAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := YourAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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 a84cdfbed1..747043d7cf 100644 --- a/internal/donor/donorpage/your_authorised_signatory.go +++ b/internal/donor/donorpage/your_authorised_signatory.go @@ -6,6 +6,7 @@ import ( "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/validation" ) @@ -18,7 +19,7 @@ type yourAuthorisedSignatoryData struct { } func YourAuthorisedSignatory(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { data := &yourAuthorisedSignatoryData{ App: appData, Form: &yourAuthorisedSignatoryForm{ @@ -90,7 +91,7 @@ func (f *yourAuthorisedSignatoryForm) Validate() validation.List { return errors } -func signatoryMatches(donor *actor.DonorProvidedDetails, firstNames, lastName string) actor.Type { +func signatoryMatches(donor *donordata.DonorProvidedDetails, 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 d5922c35d3..455d873a43 100644 --- a/internal/donor/donorpage/your_authorised_signatory_test.go +++ b/internal/donor/donorpage/your_authorised_signatory_test.go @@ -8,6 +8,7 @@ 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/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -27,7 +28,7 @@ func TestGetYourAuthorisedSignatory(t *testing.T) { }). Return(nil) - err := YourAuthorisedSignatory(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := YourAuthorisedSignatory(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -48,8 +49,8 @@ func TestGetYourAuthorisedSignatoryFromStore(t *testing.T) { }). Return(nil) - err := YourAuthorisedSignatory(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - AuthorisedSignatory: actor.AuthorisedSignatory{ + err := YourAuthorisedSignatory(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + AuthorisedSignatory: donordata.AuthorisedSignatory{ FirstNames: "John", }, }) @@ -68,7 +69,7 @@ func TestGetYourAuthorisedSignatoryWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := YourAuthorisedSignatory(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := YourAuthorisedSignatory(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -78,14 +79,14 @@ func TestGetYourAuthorisedSignatoryWhenTemplateErrors(t *testing.T) { func TestPostYourAuthorisedSignatory(t *testing.T) { testCases := map[string]struct { form url.Values - person actor.AuthorisedSignatory + person donordata.AuthorisedSignatory }{ "valid": { form: url.Values{ "first-names": {"John"}, "last-name": {"Doe"}, }, - person: actor.AuthorisedSignatory{ + person: donordata.AuthorisedSignatory{ FirstNames: "John", LastName: "Doe", }, @@ -96,7 +97,7 @@ func TestPostYourAuthorisedSignatory(t *testing.T) { "last-name": {"Smith"}, "ignore-name-warning": {actor.NewSameNameWarning(actor.TypeAuthorisedSignatory, actor.TypeDonor, "John", "Smith").String()}, }, - person: actor.AuthorisedSignatory{ + person: donordata.AuthorisedSignatory{ FirstNames: "John", LastName: "Smith", }, @@ -112,17 +113,17 @@ func TestPostYourAuthorisedSignatory(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{FirstNames: "John", LastName: "Smith"}, + Donor: donordata.Donor{FirstNames: "John", LastName: "Smith"}, AuthorisedSignatory: tc.person, - Tasks: actor.DonorTasks{ChooseYourSignatory: actor.TaskInProgress}, + Tasks: donordata.DonorTasks{ChooseYourSignatory: actor.TaskInProgress}, }). Return(nil) - err := YourAuthorisedSignatory(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := YourAuthorisedSignatory(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{FirstNames: "John", LastName: "Smith"}, + Donor: donordata.Donor{FirstNames: "John", LastName: "Smith"}, }) resp := w.Result() @@ -146,22 +147,22 @@ func TestPostYourAuthorisedSignatoryWhenTaskCompleted(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - AuthorisedSignatory: actor.AuthorisedSignatory{ + AuthorisedSignatory: donordata.AuthorisedSignatory{ FirstNames: "John", LastName: "Doe", }, - Tasks: actor.DonorTasks{ChooseYourSignatory: actor.TaskCompleted}, + Tasks: donordata.DonorTasks{ChooseYourSignatory: actor.TaskCompleted}, }). Return(nil) - err := YourAuthorisedSignatory(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := YourAuthorisedSignatory(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - AuthorisedSignatory: actor.AuthorisedSignatory{ + AuthorisedSignatory: donordata.AuthorisedSignatory{ FirstNames: "John", }, - Tasks: actor.DonorTasks{ChooseYourSignatory: actor.TaskCompleted}, + Tasks: donordata.DonorTasks{ChooseYourSignatory: actor.TaskCompleted}, }) resp := w.Result() @@ -226,8 +227,8 @@ func TestPostYourAuthorisedSignatoryWhenInputRequired(t *testing.T) { })). Return(nil) - err := YourAuthorisedSignatory(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{ + err := YourAuthorisedSignatory(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{ FirstNames: "John", LastName: "Doe", }, @@ -255,8 +256,8 @@ func TestPostYourAuthorisedSignatoryWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := YourAuthorisedSignatory(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{ + err := YourAuthorisedSignatory(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{ FirstNames: "John", Address: place.Address{Line1: "abc"}, }, @@ -326,23 +327,23 @@ func TestYourAuthorisedSignatoryFormValidate(t *testing.T) { } func TestSignatoryMatches(t *testing.T) { - donor := &actor.DonorProvidedDetails{ - Donor: actor.Donor{FirstNames: "a", LastName: "b"}, - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + donor := &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "c", LastName: "d"}, {FirstNames: "e", LastName: "f"}, }}, - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "g", LastName: "h"}, {FirstNames: "i", LastName: "j"}, }}, - CertificateProvider: actor.CertificateProvider{FirstNames: "k", LastName: "l"}, - PeopleToNotify: actor.PeopleToNotify{ + CertificateProvider: donordata.CertificateProvider{FirstNames: "k", LastName: "l"}, + PeopleToNotify: donordata.PeopleToNotify{ {FirstNames: "m", LastName: "n"}, {FirstNames: "o", LastName: "p"}, }, - AuthorisedSignatory: actor.AuthorisedSignatory{FirstNames: "a", LastName: "s"}, - IndependentWitness: actor.IndependentWitness{FirstNames: "i", LastName: "w"}, + AuthorisedSignatory: donordata.AuthorisedSignatory{FirstNames: "a", LastName: "s"}, + IndependentWitness: donordata.IndependentWitness{FirstNames: "i", LastName: "w"}, } assert.Equal(t, actor.TypeNone, signatoryMatches(donor, "x", "y")) @@ -359,10 +360,10 @@ func TestSignatoryMatches(t *testing.T) { } func TestSignatoryMatchesEmptyNamesIgnored(t *testing.T) { - donor := &actor.DonorProvidedDetails{ - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{}}}, - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{}}}, - PeopleToNotify: actor.PeopleToNotify{{}}, + donor := &donordata.DonorProvidedDetails{ + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{}}}, + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{}}}, + PeopleToNotify: donordata.PeopleToNotify{{}}, } assert.Equal(t, actor.TypeNone, signatoryMatches(donor, "", "")) diff --git a/internal/donor/donorpage/your_date_of_birth.go b/internal/donor/donorpage/your_date_of_birth.go index 75688fbeb0..37eb0e54cd 100644 --- a/internal/donor/donorpage/your_date_of_birth.go +++ b/internal/donor/donorpage/your_date_of_birth.go @@ -5,8 +5,8 @@ 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/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/validation" ) @@ -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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 1ac8ed6d6c..902f8eb5f8 100644 --- a/internal/donor/donorpage/your_date_of_birth_test.go +++ b/internal/donor/donorpage/your_date_of_birth_test.go @@ -9,8 +9,8 @@ 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/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" @@ -29,7 +29,7 @@ func TestGetYourDateOfBirth(t *testing.T) { }). Return(nil) - err := YourDateOfBirth(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := YourDateOfBirth(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -50,8 +50,8 @@ func TestGetYourDateOfBirthFromStore(t *testing.T) { }). Return(nil) - err := YourDateOfBirth(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{ + err := YourDateOfBirth(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{ DateOfBirth: date.New("2000", "1", "2"), }, }) @@ -76,8 +76,8 @@ func TestGetYourDateOfBirthDobWarningIsAlwaysShown(t *testing.T) { }). Return(nil) - err := YourDateOfBirth(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{ + err := YourDateOfBirth(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + 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, &actor.DonorProvidedDetails{Donor: actor.Donor{FirstNames: "John", DateOfBirth: date.New("2000", "1", "2")}}) + err := YourDateOfBirth(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{Donor: donordata.Donor{FirstNames: "John", DateOfBirth: date.New("2000", "1", "2")}}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -109,7 +109,7 @@ func TestPostYourDateOfBirth(t *testing.T) { testCases := map[string]struct { url string form url.Values - person actor.Donor + person donordata.Donor redirect string }{ "valid": { @@ -119,7 +119,7 @@ func TestPostYourDateOfBirth(t *testing.T) { "date-of-birth-month": {"1"}, "date-of-birth-year": {validBirthYear}, }, - person: actor.Donor{ + person: donordata.Donor{ DateOfBirth: date.New(validBirthYear, "1", "2"), }, redirect: page.Paths.YourAddress.Format("lpa-id"), @@ -132,7 +132,7 @@ func TestPostYourDateOfBirth(t *testing.T) { "date-of-birth-year": {"1900"}, "ignore-dob-warning": {"dateOfBirthIsOver100"}, }, - person: actor.Donor{ + person: donordata.Donor{ DateOfBirth: date.New("1900", "1", "2"), }, redirect: page.Paths.YourAddress.Format("lpa-id"), @@ -144,7 +144,7 @@ func TestPostYourDateOfBirth(t *testing.T) { "date-of-birth-month": {"1"}, "date-of-birth-year": {validBirthYear}, }, - person: actor.Donor{ + person: donordata.Donor{ DateOfBirth: date.New(validBirthYear, "1", "2"), }, redirect: page.Paths.WeHaveUpdatedYourDetails.Format("lpa-id") + "?detail=dateOfBirth", @@ -160,15 +160,15 @@ func TestPostYourDateOfBirth(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", Donor: tc.person, }). Return(nil) - err := YourDateOfBirth(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := YourDateOfBirth(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{ + Donor: donordata.Donor{ DateOfBirth: date.New("2000", "1", "2"), }, HasSentApplicationUpdatedEvent: true, @@ -212,9 +212,9 @@ 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, &actor.DonorProvidedDetails{ + err := YourDateOfBirth(nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{ + Donor: donordata.Donor{ DateOfBirth: date.New(validBirthYear, "1", "2"), }, HasSentApplicationUpdatedEvent: true, @@ -279,7 +279,7 @@ func TestPostYourDateOfBirthWhenInputRequired(t *testing.T) { })). Return(nil) - err := YourDateOfBirth(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{Donor: actor.Donor{DateOfBirth: date.New("2000", "1", "2")}}) + err := YourDateOfBirth(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{Donor: donordata.Donor{DateOfBirth: date.New("2000", "1", "2")}}) resp := w.Result() assert.Nil(t, err) @@ -304,8 +304,8 @@ func TestPostYourDateOfBirthWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := YourDateOfBirth(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{ + err := YourDateOfBirth(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + 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 9c782dfb04..667440e79b 100644 --- a/internal/donor/donorpage/your_email.go +++ b/internal/donor/donorpage/your_email.go @@ -4,7 +4,7 @@ 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/validation" ) @@ -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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 a5651a9493..9cbe6f1e00 100644 --- a/internal/donor/donorpage/your_email_test.go +++ b/internal/donor/donorpage/your_email_test.go @@ -7,7 +7,7 @@ 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/validation" "github.com/stretchr/testify/assert" @@ -26,7 +26,7 @@ func TestGetYourEmail(t *testing.T) { }). Return(nil) - err := YourEmail(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := YourEmail(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := YourEmail(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -61,18 +61,18 @@ func TestPostYourEmail(t *testing.T) { donorStore := newMockDonorStore(t) donorStore. - On("Put", r.Context(), &actor.DonorProvidedDetails{ + On("Put", r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{ + Donor: donordata.Donor{ FirstNames: "John", Email: "john@example.com", }, }). Return(nil) - err := YourEmail(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := YourEmail(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{ + Donor: donordata.Donor{ FirstNames: "John", }, }) @@ -99,7 +99,7 @@ func TestPostYourEmailWhenValidationError(t *testing.T) { })). Return(nil) - err := YourEmail(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := YourEmail(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := YourEmail(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } diff --git a/internal/donor/donorpage/your_independent_witness.go b/internal/donor/donorpage/your_independent_witness.go index 693fde5071..497dec051c 100644 --- a/internal/donor/donorpage/your_independent_witness.go +++ b/internal/donor/donorpage/your_independent_witness.go @@ -6,6 +6,7 @@ import ( "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/validation" ) @@ -18,7 +19,7 @@ type yourIndependentWitnessData struct { } func YourIndependentWitness(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { data := &yourIndependentWitnessData{ App: appData, Form: &yourIndependentWitnessForm{ @@ -90,7 +91,7 @@ func (f *yourIndependentWitnessForm) Validate() validation.List { return errors } -func independentWitnessMatches(donor *actor.DonorProvidedDetails, firstNames, lastName string) actor.Type { +func independentWitnessMatches(donor *donordata.DonorProvidedDetails, 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 fe1eae1ff3..355f211033 100644 --- a/internal/donor/donorpage/your_independent_witness_address.go +++ b/internal/donor/donorpage/your_independent_witness_address.go @@ -6,13 +6,14 @@ import ( "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" ) func YourIndependentWitnessAddress(logger Logger, tmpl template.Template, addressClient AddressClient, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { data := newChooseAddressData( appData, "independentWitness", diff --git a/internal/donor/donorpage/your_independent_witness_address_test.go b/internal/donor/donorpage/your_independent_witness_address_test.go index 4412172b9f..c30b29cbba 100644 --- a/internal/donor/donorpage/your_independent_witness_address_test.go +++ b/internal/donor/donorpage/your_independent_witness_address_test.go @@ -10,6 +10,7 @@ import ( "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" @@ -33,8 +34,8 @@ func TestGetYourIndependentWitnessAddress(t *testing.T) { }). Return(nil) - err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - IndependentWitness: actor.IndependentWitness{ + err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + IndependentWitness: donordata.IndependentWitness{ FirstNames: "John", LastName: "Smith", }, @@ -66,8 +67,8 @@ func TestGetYourIndependentWitnessAddressFromStore(t *testing.T) { }). Return(nil) - err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - IndependentWitness: actor.IndependentWitness{ + err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + IndependentWitness: donordata.IndependentWitness{ Address: address, }, }) @@ -96,7 +97,7 @@ func TestGetYourIndependentWitnessAddressManual(t *testing.T) { }). Return(nil) - err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -118,7 +119,7 @@ func TestGetYourIndependentWitnessAddressWhenTemplateErrors(t *testing.T) { }). Return(expectedError) - err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -141,18 +142,18 @@ func TestPostYourIndependentWitnessAddressManual(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - IndependentWitness: actor.IndependentWitness{ + IndependentWitness: donordata.IndependentWitness{ Address: testAddress, }, - Tasks: actor.DonorTasks{ + Tasks: donordata.DonorTasks{ ChooseYourSignatory: actor.TaskCompleted, }, }). Return(nil) - err := YourIndependentWitnessAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := YourIndependentWitnessAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", }) resp := w.Result() @@ -181,7 +182,7 @@ func TestPostYourIndependentWitnessAddressManualWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := YourIndependentWitnessAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := YourIndependentWitnessAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } @@ -202,21 +203,21 @@ func TestPostYourIndependentWitnessAddressManualFromStore(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - IndependentWitness: actor.IndependentWitness{ + IndependentWitness: donordata.IndependentWitness{ FirstNames: "John", Address: testAddress, }, - Tasks: actor.DonorTasks{ + Tasks: donordata.DonorTasks{ ChooseYourSignatory: actor.TaskCompleted, }, }). Return(nil) - err := YourIndependentWitnessAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := YourIndependentWitnessAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - IndependentWitness: actor.IndependentWitness{ + IndependentWitness: donordata.IndependentWitness{ FirstNames: "John", Address: place.Address{Line1: "abc"}, }, @@ -261,7 +262,7 @@ func TestPostYourIndependentWitnessAddressManualWhenValidationError(t *testing.T }). Return(nil) - err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -302,7 +303,7 @@ func TestPostYourIndependentWitnessAddressSelect(t *testing.T) { }). Return(nil) - err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -345,7 +346,7 @@ func TestPostYourIndependentWitnessAddressSelectWhenValidationError(t *testing.T }). Return(nil) - err := YourIndependentWitnessAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := YourIndependentWitnessAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -387,7 +388,7 @@ func TestPostYourIndependentWitnessAddressLookup(t *testing.T) { }). Return(nil) - err := YourIndependentWitnessAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := YourIndependentWitnessAddress(nil, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -430,7 +431,7 @@ func TestPostYourIndependentWitnessAddressLookupError(t *testing.T) { }). Return(nil) - err := YourIndependentWitnessAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := YourIndependentWitnessAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -478,7 +479,7 @@ func TestPostYourIndependentWitnessAddressInvalidPostcodeError(t *testing.T) { }). Return(nil) - err := YourIndependentWitnessAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := YourIndependentWitnessAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -520,7 +521,7 @@ func TestPostYourIndependentWitnessAddressValidPostcodeNoAddresses(t *testing.T) }). Return(nil) - err := YourIndependentWitnessAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := YourIndependentWitnessAddress(logger, template.Execute, addressClient, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -551,7 +552,7 @@ func TestPostYourIndependentWitnessAddressLookupWhenValidationError(t *testing.T }). Return(nil) - err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -571,16 +572,16 @@ func TestPostYourIndependentWitnessAddressReuseSelect(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - IndependentWitness: actor.IndependentWitness{ + IndependentWitness: donordata.IndependentWitness{ Address: testAddress, }, - Tasks: actor.DonorTasks{ChooseYourSignatory: actor.TaskCompleted}, + Tasks: donordata.DonorTasks{ChooseYourSignatory: actor.TaskCompleted}, }). Return(nil) - err := YourIndependentWitnessAddress(nil, nil, nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := YourIndependentWitnessAddress(nil, nil, nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", }) resp := w.Result() @@ -615,8 +616,8 @@ func TestPostYourIndependentWitnessAddressReuseSelectWhenValidationError(t *test }). Return(nil) - err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{Address: place.Address{Line1: "donor lane"}}, + err := YourIndependentWitnessAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + 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 e94c33ca35..b5a56a87d8 100644 --- a/internal/donor/donorpage/your_independent_witness_mobile.go +++ b/internal/donor/donorpage/your_independent_witness_mobile.go @@ -4,7 +4,7 @@ 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/validation" ) @@ -12,12 +12,12 @@ import ( type yourIndependentWitnessMobileData struct { App page.AppData Errors validation.List - AuthorisedSignatory actor.AuthorisedSignatory + AuthorisedSignatory donordata.AuthorisedSignatory Form *yourIndependentWitnessMobileForm } func YourIndependentWitnessMobile(tmpl template.Template, donorStore DonorStore) Handler { - return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 7dc754bf1e..e6ba07d064 100644 --- a/internal/donor/donorpage/your_independent_witness_mobile_test.go +++ b/internal/donor/donorpage/your_independent_witness_mobile_test.go @@ -7,7 +7,7 @@ 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/validation" "github.com/stretchr/testify/assert" @@ -26,7 +26,7 @@ func TestGetYourIndependentWitnessMobile(t *testing.T) { }). Return(nil) - err := YourIndependentWitnessMobile(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := YourIndependentWitnessMobile(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -35,12 +35,12 @@ func TestGetYourIndependentWitnessMobile(t *testing.T) { func TestGetYourIndependentWitnessMobileFromStore(t *testing.T) { testcases := map[string]struct { - donor *actor.DonorProvidedDetails + donor *donordata.DonorProvidedDetails form *yourIndependentWitnessMobileForm }{ "uk mobile": { - donor: &actor.DonorProvidedDetails{ - IndependentWitness: actor.IndependentWitness{ + donor: &donordata.DonorProvidedDetails{ + IndependentWitness: donordata.IndependentWitness{ Mobile: "07777", }, }, @@ -49,8 +49,8 @@ func TestGetYourIndependentWitnessMobileFromStore(t *testing.T) { }, }, "non-uk mobile": { - donor: &actor.DonorProvidedDetails{ - IndependentWitness: actor.IndependentWitness{ + donor: &donordata.DonorProvidedDetails{ + 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, &actor.DonorProvidedDetails{}) + err := YourIndependentWitnessMobile(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -106,13 +106,13 @@ func TestGetYourIndependentWitnessMobileWhenTemplateErrors(t *testing.T) { func TestPostYourIndependentWitnessMobile(t *testing.T) { testCases := map[string]struct { form url.Values - yourIndependentWitnessMobile actor.IndependentWitness + yourIndependentWitnessMobile donordata.IndependentWitness }{ "valid": { form: url.Values{ "mobile": {"07535111111"}, }, - yourIndependentWitnessMobile: actor.IndependentWitness{ + yourIndependentWitnessMobile: donordata.IndependentWitness{ Mobile: "07535111111", }, }, @@ -121,7 +121,7 @@ func TestPostYourIndependentWitnessMobile(t *testing.T) { "has-non-uk-mobile": {"1"}, "non-uk-mobile": {"+337575757"}, }, - yourIndependentWitnessMobile: actor.IndependentWitness{ + yourIndependentWitnessMobile: donordata.IndependentWitness{ Mobile: "+337575757", HasNonUKMobile: true, }, @@ -136,13 +136,13 @@ func TestPostYourIndependentWitnessMobile(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", IndependentWitness: tc.yourIndependentWitnessMobile, }). Return(nil) - err := YourIndependentWitnessMobile(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id"}) + err := YourIndependentWitnessMobile(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{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, &actor.DonorProvidedDetails{}) + err := YourIndependentWitnessMobile(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := YourIndependentWitnessMobile(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) 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 a9fe7ceb73..03dacae5c8 100644 --- a/internal/donor/donorpage/your_independent_witness_test.go +++ b/internal/donor/donorpage/your_independent_witness_test.go @@ -8,6 +8,7 @@ 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/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -27,7 +28,7 @@ func TestGetYourIndependentWitness(t *testing.T) { }). Return(nil) - err := YourIndependentWitness(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := YourIndependentWitness(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -48,8 +49,8 @@ func TestGetYourIndependentWitnessFromStore(t *testing.T) { }). Return(nil) - err := YourIndependentWitness(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - IndependentWitness: actor.IndependentWitness{ + err := YourIndependentWitness(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + IndependentWitness: donordata.IndependentWitness{ FirstNames: "John", }, }) @@ -68,7 +69,7 @@ func TestGetYourIndependentWitnessWhenTemplateErrors(t *testing.T) { Execute(w, mock.Anything). Return(expectedError) - err := YourIndependentWitness(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := YourIndependentWitness(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -78,14 +79,14 @@ func TestGetYourIndependentWitnessWhenTemplateErrors(t *testing.T) { func TestPostYourIndependentWitness(t *testing.T) { testCases := map[string]struct { form url.Values - person actor.IndependentWitness + person donordata.IndependentWitness }{ "valid": { form: url.Values{ "first-names": {"John"}, "last-name": {"Doe"}, }, - person: actor.IndependentWitness{ + person: donordata.IndependentWitness{ FirstNames: "John", LastName: "Doe", }, @@ -96,7 +97,7 @@ func TestPostYourIndependentWitness(t *testing.T) { "last-name": {"Smith"}, "ignore-name-warning": {actor.NewSameNameWarning(actor.TypeIndependentWitness, actor.TypeDonor, "John", "Smith").String()}, }, - person: actor.IndependentWitness{ + person: donordata.IndependentWitness{ FirstNames: "John", LastName: "Smith", }, @@ -112,17 +113,17 @@ func TestPostYourIndependentWitness(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{FirstNames: "John", LastName: "Smith"}, + Donor: donordata.Donor{FirstNames: "John", LastName: "Smith"}, IndependentWitness: tc.person, - Tasks: actor.DonorTasks{ChooseYourSignatory: actor.TaskInProgress}, + Tasks: donordata.DonorTasks{ChooseYourSignatory: actor.TaskInProgress}, }). Return(nil) - err := YourIndependentWitness(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := YourIndependentWitness(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{FirstNames: "John", LastName: "Smith"}, + Donor: donordata.Donor{FirstNames: "John", LastName: "Smith"}, }) resp := w.Result() @@ -146,22 +147,22 @@ func TestPostYourIndependentWitnessWhenTaskCompleted(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - IndependentWitness: actor.IndependentWitness{ + IndependentWitness: donordata.IndependentWitness{ FirstNames: "John", LastName: "Doe", }, - Tasks: actor.DonorTasks{ChooseYourSignatory: actor.TaskCompleted}, + Tasks: donordata.DonorTasks{ChooseYourSignatory: actor.TaskCompleted}, }). Return(nil) - err := YourIndependentWitness(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := YourIndependentWitness(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - IndependentWitness: actor.IndependentWitness{ + IndependentWitness: donordata.IndependentWitness{ FirstNames: "John", }, - Tasks: actor.DonorTasks{ChooseYourSignatory: actor.TaskCompleted}, + Tasks: donordata.DonorTasks{ChooseYourSignatory: actor.TaskCompleted}, }) resp := w.Result() @@ -226,8 +227,8 @@ func TestPostYourIndependentWitnessWhenInputRequired(t *testing.T) { })). Return(nil) - err := YourIndependentWitness(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{ + err := YourIndependentWitness(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{ FirstNames: "John", LastName: "Doe", }, @@ -255,8 +256,8 @@ func TestPostYourIndependentWitnessWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := YourIndependentWitness(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{ + err := YourIndependentWitness(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{ FirstNames: "John", Address: place.Address{Line1: "abc"}, }, @@ -326,23 +327,23 @@ func TestYourIndependentWitnessFormValidate(t *testing.T) { } func TestIndependentWitnessMatches(t *testing.T) { - donor := &actor.DonorProvidedDetails{ - Donor: actor.Donor{FirstNames: "a", LastName: "b"}, - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + donor := &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "c", LastName: "d"}, {FirstNames: "e", LastName: "f"}, }}, - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "g", LastName: "h"}, {FirstNames: "i", LastName: "j"}, }}, - CertificateProvider: actor.CertificateProvider{FirstNames: "k", LastName: "l"}, - PeopleToNotify: actor.PeopleToNotify{ + CertificateProvider: donordata.CertificateProvider{FirstNames: "k", LastName: "l"}, + PeopleToNotify: donordata.PeopleToNotify{ {FirstNames: "m", LastName: "n"}, {FirstNames: "o", LastName: "p"}, }, - AuthorisedSignatory: actor.AuthorisedSignatory{FirstNames: "a", LastName: "s"}, - IndependentWitness: actor.IndependentWitness{FirstNames: "i", LastName: "w"}, + AuthorisedSignatory: donordata.AuthorisedSignatory{FirstNames: "a", LastName: "s"}, + IndependentWitness: donordata.IndependentWitness{FirstNames: "i", LastName: "w"}, } assert.Equal(t, actor.TypeNone, independentWitnessMatches(donor, "x", "y")) @@ -359,10 +360,10 @@ func TestIndependentWitnessMatches(t *testing.T) { } func TestIndependentWitnessMatchesEmptyNamesIgnored(t *testing.T) { - donor := &actor.DonorProvidedDetails{ - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{}}}, - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{}}}, - PeopleToNotify: actor.PeopleToNotify{{}}, + donor := &donordata.DonorProvidedDetails{ + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{}}}, + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{}}}, + PeopleToNotify: donordata.PeopleToNotify{{}}, } assert.Equal(t, actor.TypeNone, independentWitnessMatches(donor, "", "")) diff --git a/internal/donor/donorpage/your_lpa_language.go b/internal/donor/donorpage/your_lpa_language.go index 653e64e765..8722518562 100644 --- a/internal/donor/donorpage/your_lpa_language.go +++ b/internal/donor/donorpage/your_lpa_language.go @@ -4,7 +4,7 @@ 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/localize" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" @@ -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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 033c8bf1c4..5c11cc4163 100644 --- a/internal/donor/donorpage/your_lpa_language_test.go +++ b/internal/donor/donorpage/your_lpa_language_test.go @@ -7,7 +7,7 @@ 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/localize" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" @@ -30,8 +30,8 @@ func TestGetYourLpaLanguage(t *testing.T) { }). Return(nil) - err := YourLpaLanguage(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{LpaLanguagePreference: localize.En}, + err := YourLpaLanguage(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + 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, &actor.DonorProvidedDetails{}) + err := YourLpaLanguage(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -66,9 +66,9 @@ 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, &actor.DonorProvidedDetails{ + err := YourLpaLanguage(nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{LpaLanguagePreference: lang}, + Donor: donordata.Donor{LpaLanguagePreference: lang}, }) resp := w.Result() @@ -106,15 +106,15 @@ func TestPostYourLpaLanguageWhenSwitch(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{LpaLanguagePreference: tc.expectedLanguage}, + Donor: donordata.Donor{LpaLanguagePreference: tc.expectedLanguage}, }). Return(nil) - err := YourLpaLanguage(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := YourLpaLanguage(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{LpaLanguagePreference: tc.selectedLanguage}, + Donor: donordata.Donor{LpaLanguagePreference: tc.selectedLanguage}, }) resp := w.Result() @@ -139,7 +139,7 @@ func TestPostYourLpaLanguageWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := YourLpaLanguage(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := YourLpaLanguage(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } @@ -156,7 +156,7 @@ func TestPostYourLpaLanguageWhenValidationErrors(t *testing.T) { })). Return(nil) - err := YourLpaLanguage(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := YourLpaLanguage(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) diff --git a/internal/donor/donorpage/your_name.go b/internal/donor/donorpage/your_name.go index 09fc6f2dec..b908c2c38d 100644 --- a/internal/donor/donorpage/your_name.go +++ b/internal/donor/donorpage/your_name.go @@ -8,6 +8,7 @@ import ( "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/validation" ) @@ -22,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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) error { data := &yourNameData{ App: appData, Form: &yourNameForm{ @@ -128,7 +129,7 @@ func (f *yourNameForm) Validate() validation.List { return errors } -func donorMatches(donor *actor.DonorProvidedDetails, firstNames, lastName string) actor.Type { +func donorMatches(donor *donordata.DonorProvidedDetails, 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 654531f862..3b806dd7c6 100644 --- a/internal/donor/donorpage/your_name_test.go +++ b/internal/donor/donorpage/your_name_test.go @@ -8,6 +8,7 @@ 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/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -27,7 +28,7 @@ func TestGetYourName(t *testing.T) { }). Return(nil) - err := YourName(template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := YourName(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -50,8 +51,8 @@ func TestGetYourNameFromStore(t *testing.T) { }). Return(nil) - err := YourName(template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{ - Donor: actor.Donor{ + err := YourName(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{ FirstNames: "John", LastName: "Doe", OtherNames: "Fawn", @@ -72,7 +73,7 @@ func TestGetYourNameWhenTemplateErrors(t *testing.T) { On("Execute", w, mock.Anything). Return(expectedError) - err := YourName(template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{Donor: actor.Donor{FirstNames: "John"}}) + err := YourName(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{Donor: donordata.Donor{FirstNames: "John"}}) resp := w.Result() assert.Equal(t, expectedError, err) @@ -83,7 +84,7 @@ func TestPostYourName(t *testing.T) { testCases := map[string]struct { url string form url.Values - person actor.Donor + person donordata.Donor redirect string }{ "valid": { @@ -93,7 +94,7 @@ func TestPostYourName(t *testing.T) { "last-name": {"Doe"}, "other-names": {"Fawn"}, }, - person: actor.Donor{ + person: donordata.Donor{ FirstNames: "John", LastName: "Doe", OtherNames: "Fawn", @@ -108,7 +109,7 @@ func TestPostYourName(t *testing.T) { "last-name": {"Bloggs"}, "ignore-name-warning": {"1|4|Jane|Bloggs"}, }, - person: actor.Donor{ + person: donordata.Donor{ FirstNames: "Jane", LastName: "Bloggs", Email: "what", @@ -122,7 +123,7 @@ func TestPostYourName(t *testing.T) { "last-name": {"Doe"}, "other-names": {"Fawn"}, }, - person: actor.Donor{ + person: donordata.Donor{ FirstNames: "John", LastName: "Doe", OtherNames: "Fawn", @@ -146,17 +147,17 @@ func TestPostYourName(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", Donor: tc.person, - CertificateProvider: actor.CertificateProvider{FirstNames: "Jane", LastName: "Bloggs"}, + CertificateProvider: donordata.CertificateProvider{FirstNames: "Jane", LastName: "Bloggs"}, }). Return(nil) - err := YourName(nil, donorStore, sessionStore)(testAppData, w, r, &actor.DonorProvidedDetails{ + err := YourName(nil, donorStore, sessionStore)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{FirstNames: "John"}, - CertificateProvider: actor.CertificateProvider{FirstNames: "Jane", LastName: "Bloggs"}, + Donor: donordata.Donor{FirstNames: "John"}, + CertificateProvider: donordata.CertificateProvider{FirstNames: "Jane", LastName: "Bloggs"}, HasSentApplicationUpdatedEvent: true, }) resp := w.Result() @@ -196,9 +197,9 @@ 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, &actor.DonorProvidedDetails{ + err := YourName(nil, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{ + Donor: donordata.Donor{ FirstNames: "John", LastName: "Doe", OtherNames: "Fawn", @@ -242,7 +243,7 @@ func TestPostYourNameWhenInputRequired(t *testing.T) { })). Return(nil) - err := YourName(template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := YourName(template.Execute, nil, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{}) resp := w.Result() assert.Nil(t, err) @@ -266,7 +267,7 @@ func TestPostYourNameWhenSessionStoreErrors(t *testing.T) { Login(r). Return(nil, expectedError) - err := YourName(nil, nil, sessionStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := YourName(nil, nil, sessionStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } @@ -285,7 +286,7 @@ func TestPostYourNameWhenSessionMissingEmail(t *testing.T) { Login(r). Return(&sesh.LoginSession{}, nil) - err := YourName(nil, nil, sessionStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := YourName(nil, nil, sessionStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.EqualError(t, err, "no email in login session") } @@ -309,28 +310,28 @@ func TestPostYourNameWhenStoreErrors(t *testing.T) { Put(r.Context(), mock.Anything). Return(expectedError) - err := YourName(nil, donorStore, sessionStore)(testAppData, w, r, &actor.DonorProvidedDetails{}) + err := YourName(nil, donorStore, sessionStore)(testAppData, w, r, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, err) } func TestDonorMatches(t *testing.T) { - donor := &actor.DonorProvidedDetails{ - Donor: actor.Donor{FirstNames: "a", LastName: "b"}, - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + donor := &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{FirstNames: "a", LastName: "b"}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "c", LastName: "d"}, {FirstNames: "e", LastName: "f"}, }}, - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "g", LastName: "h"}, {FirstNames: "i", LastName: "j"}, }}, - CertificateProvider: actor.CertificateProvider{FirstNames: "k", LastName: "l"}, - PeopleToNotify: actor.PeopleToNotify{ + CertificateProvider: donordata.CertificateProvider{FirstNames: "k", LastName: "l"}, + PeopleToNotify: donordata.PeopleToNotify{ {FirstNames: "m", LastName: "n"}, {FirstNames: "o", LastName: "p"}, }, - AuthorisedSignatory: actor.AuthorisedSignatory{FirstNames: "a", LastName: "s"}, - IndependentWitness: actor.IndependentWitness{FirstNames: "i", LastName: "w"}, + AuthorisedSignatory: donordata.AuthorisedSignatory{FirstNames: "a", LastName: "s"}, + IndependentWitness: donordata.IndependentWitness{FirstNames: "i", LastName: "w"}, } assert.Equal(t, actor.TypeNone, donorMatches(donor, "x", "y")) @@ -347,16 +348,16 @@ func TestDonorMatches(t *testing.T) { } func TestDonorMatchesEmptyNamesIgnored(t *testing.T) { - donor := &actor.DonorProvidedDetails{ - Donor: actor.Donor{FirstNames: "", LastName: ""}, - Attorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + donor := &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{FirstNames: "", LastName: ""}, + Attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "", LastName: ""}, }}, - ReplacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{ + ReplacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{ {FirstNames: "", LastName: ""}, }}, - CertificateProvider: actor.CertificateProvider{FirstNames: "", LastName: ""}, - PeopleToNotify: actor.PeopleToNotify{ + CertificateProvider: donordata.CertificateProvider{FirstNames: "", LastName: ""}, + PeopleToNotify: donordata.PeopleToNotify{ {FirstNames: "", LastName: ""}, }, } diff --git a/internal/donor/donorpage/your_preferred_language.go b/internal/donor/donorpage/your_preferred_language.go index 9aba129564..191d196876 100644 --- a/internal/donor/donorpage/your_preferred_language.go +++ b/internal/donor/donorpage/your_preferred_language.go @@ -4,7 +4,7 @@ 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/localize" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" @@ -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 *actor.DonorProvidedDetails) error { + return func(appData page.AppData, w http.ResponseWriter, r *http.Request, donor *donordata.DonorProvidedDetails) 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 2fba996886..603783c6c1 100644 --- a/internal/donor/donorpage/your_preferred_language_test.go +++ b/internal/donor/donorpage/your_preferred_language_test.go @@ -8,7 +8,7 @@ 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/localize" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -31,7 +31,7 @@ func TestGetYourPreferredLanguage(t *testing.T) { }). Return(nil) - err := YourPreferredLanguage(template.Execute, nil)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id", Donor: actor.Donor{ContactLanguagePreference: localize.Cy}}) + err := YourPreferredLanguage(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{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, &actor.DonorProvidedDetails{LpaID: "lpa-id", Donor: actor.Donor{ContactLanguagePreference: localize.Cy}}) + err := YourPreferredLanguage(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{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(), &actor.DonorProvidedDetails{ + Put(r.Context(), &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{ContactLanguagePreference: lang, LpaLanguagePreference: lang}, + Donor: donordata.Donor{ContactLanguagePreference: lang, LpaLanguagePreference: lang}, }). Return(nil) - err := YourPreferredLanguage(nil, donorStore)(testAppData, w, r, &actor.DonorProvidedDetails{LpaID: "lpa-id"}) + err := YourPreferredLanguage(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{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, &actor.DonorProvidedDetails{LpaID: "lpa-id"}) + err := YourPreferredLanguage(nil, donorStore)(testAppData, w, r, &donordata.DonorProvidedDetails{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, &actor.DonorProvidedDetails{LpaID: "lpa-id"}) + err := YourPreferredLanguage(template.Execute, nil)(testAppData, w, r, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}) resp := w.Result() diff --git a/internal/lpastore/client_test.go b/internal/lpastore/client_test.go index ca94a93eea..a2f6663747 100644 --- a/internal/lpastore/client_test.go +++ b/internal/lpastore/client_test.go @@ -14,11 +14,11 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" v4 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" - "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/certificateprovider/certificateproviderdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/date" + donordata "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/lambda" "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" @@ -179,11 +179,11 @@ func TestClientServiceContract(t *testing.T) { now: now, } - err := client.SendLpa(context.Background(), &actor.DonorProvidedDetails{ + err := client.SendLpa(context.Background(), &donordata.DonorProvidedDetails{ LpaUID: "M-0000-1111-2222", - Type: actor.LpaTypePersonalWelfare, - LifeSustainingTreatmentOption: actor.LifeSustainingTreatmentOptionA, - Donor: actor.Donor{ + Type: donordata.LpaTypePersonalWelfare, + LifeSustainingTreatmentOption: donordata.LifeSustainingTreatmentOptionA, + Donor: donordata.Donor{ UID: actoruid.New(), FirstNames: "John Johnson", LastName: "Smith", @@ -192,8 +192,8 @@ func TestClientServiceContract(t *testing.T) { Address: address, ContactLanguagePreference: localize.En, }, - Attorneys: actor.Attorneys{ - Attorneys: []actor.Attorney{{ + Attorneys: donordata.Attorneys{ + Attorneys: []donordata.Attorney{{ UID: actoruid.New(), FirstNames: "Alice", LastName: "Attorney", @@ -201,16 +201,16 @@ func TestClientServiceContract(t *testing.T) { Email: "alice@example.com", Address: address, }}, - TrustCorporation: actor.TrustCorporation{ + TrustCorporation: donordata.TrustCorporation{ UID: actoruid.New(), Name: "Trust us Corp.", CompanyNumber: "66654321", Address: address, }, }, - AttorneyDecisions: actor.AttorneyDecisions{How: actor.Jointly}, - ReplacementAttorneys: actor.Attorneys{ - Attorneys: []actor.Attorney{{ + AttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, + ReplacementAttorneys: donordata.Attorneys{ + Attorneys: []donordata.Attorney{{ UID: actoruid.New(), FirstNames: "Richard", LastName: "Attorney", @@ -219,14 +219,14 @@ func TestClientServiceContract(t *testing.T) { Address: address, }}, }, - CertificateProvider: actor.CertificateProvider{ + CertificateProvider: donordata.CertificateProvider{ UID: actoruid.New(), FirstNames: "Charles", LastName: "Certificate", Email: "charles@example.com", Mobile: "0700009000", Address: address, - CarryOutBy: actor.ChannelOnline, + CarryOutBy: donordata.ChannelOnline, }, Restrictions: "hmm", SignedAt: time.Date(2000, time.January, 2, 12, 13, 14, 0, time.UTC), @@ -341,10 +341,10 @@ func TestClientServiceContract(t *testing.T) { now: now, } - err := client.SendLpa(context.Background(), &actor.DonorProvidedDetails{ + err := client.SendLpa(context.Background(), &donordata.DonorProvidedDetails{ LpaUID: "M-0000-1111-2222", - Type: actor.LpaTypePersonalWelfare, - Donor: actor.Donor{ + Type: donordata.LpaTypePersonalWelfare, + Donor: donordata.Donor{ UID: actoruid.New(), FirstNames: "John Johnson", LastName: "Smith", @@ -354,8 +354,8 @@ func TestClientServiceContract(t *testing.T) { OtherNames: "JJ", ContactLanguagePreference: localize.Cy, }, - Attorneys: actor.Attorneys{ - Attorneys: []actor.Attorney{{ + Attorneys: donordata.Attorneys{ + Attorneys: []donordata.Attorney{{ UID: actoruid.New(), FirstNames: "Alice", LastName: "Attorney", @@ -364,8 +364,8 @@ func TestClientServiceContract(t *testing.T) { Address: address, }}, }, - ReplacementAttorneys: actor.Attorneys{ - Attorneys: []actor.Attorney{{ + ReplacementAttorneys: donordata.Attorneys{ + Attorneys: []donordata.Attorney{{ UID: actoruid.New(), FirstNames: "Richard", LastName: "Attorney", @@ -374,16 +374,16 @@ func TestClientServiceContract(t *testing.T) { Address: address, }}, }, - CertificateProvider: actor.CertificateProvider{ + CertificateProvider: donordata.CertificateProvider{ UID: actoruid.New(), FirstNames: "Charles", LastName: "Certificate", Email: "charles@example.com", Mobile: "0700009000", Address: address, - CarryOutBy: actor.ChannelOnline, + CarryOutBy: donordata.ChannelOnline, }, - PeopleToNotify: actor.PeopleToNotify{{ + PeopleToNotify: donordata.PeopleToNotify{{ UID: actoruid.New(), FirstNames: "Peter", LastName: "Person", @@ -552,7 +552,7 @@ func TestClientServiceContract(t *testing.T) { UID: uid, Name: "Trust us Corp.", CompanyNumber: "66654321", - Channel: actor.ChannelPaper, + Channel: donordata.ChannelPaper, }, }, }, @@ -633,7 +633,7 @@ func TestClientServiceContract(t *testing.T) { SignedAt: time.Date(2020, time.January, 1, 12, 13, 14, 0, time.UTC), ContactLanguagePreference: localize.Cy, Email: "a@example.com", - }, &Lpa{CertificateProvider: CertificateProvider{Channel: actor.ChannelPaper}, LpaUID: "M-0000-1111-2222"}) + }, &Lpa{CertificateProvider: CertificateProvider{Channel: donordata.ChannelPaper}, LpaUID: "M-0000-1111-2222"}) assert.Nil(t, err) return nil })) @@ -715,7 +715,7 @@ func TestClientServiceContract(t *testing.T) { Email: "a@example.com", }, &Lpa{ CertificateProvider: CertificateProvider{ - Channel: actor.ChannelPaper, + Channel: donordata.ChannelPaper, Address: place.Address{ Line1: "71 South Western Terrace", TownOrCity: "Milton", @@ -861,7 +861,7 @@ func TestClientServiceContract(t *testing.T) { assert.Equal(t, &Lpa{ LpaUID: "M-0000-1111-2222", - Type: actor.LpaTypePersonalWelfare, + Type: donordata.LpaTypePersonalWelfare, Donor: Donor{ FirstNames: "Homer", LastName: "Zoller", @@ -872,7 +872,7 @@ func TestClientServiceContract(t *testing.T) { Postcode: "WR9 2PF", Country: "GB", }, - Channel: actor.ChannelOnline, + Channel: donordata.ChannelOnline, }, Attorneys: Attorneys{ Attorneys: []Attorney{{ @@ -884,7 +884,7 @@ func TestClientServiceContract(t *testing.T) { TownOrCity: "Milton", Country: "AU", }, - Channel: actor.ChannelPaper, + Channel: donordata.ChannelPaper, }}, }, CertificateProvider: CertificateProvider{ @@ -897,9 +897,9 @@ func TestClientServiceContract(t *testing.T) { TownOrCity: "Milton", Country: "AU", }, - Channel: actor.ChannelOnline, + Channel: donordata.ChannelOnline, }, - LifeSustainingTreatmentOption: actor.LifeSustainingTreatmentOptionA, + LifeSustainingTreatmentOption: donordata.LifeSustainingTreatmentOptionA, SignedAt: time.Date(2000, time.January, 2, 12, 13, 14, 0, time.UTC), }, donor) return nil @@ -993,7 +993,7 @@ func TestClientServiceContract(t *testing.T) { assert.Equal(t, []*Lpa{{ LpaUID: "M-0000-1111-2222", - Type: actor.LpaTypePersonalWelfare, + Type: donordata.LpaTypePersonalWelfare, Donor: Donor{ FirstNames: "Homer", LastName: "Zoller", @@ -1004,7 +1004,7 @@ func TestClientServiceContract(t *testing.T) { Postcode: "WR9 2PF", Country: "GB", }, - Channel: actor.ChannelOnline, + Channel: donordata.ChannelOnline, }, Attorneys: Attorneys{ Attorneys: []Attorney{{ @@ -1016,7 +1016,7 @@ func TestClientServiceContract(t *testing.T) { TownOrCity: "Milton", Country: "AU", }, - Channel: actor.ChannelOnline, + Channel: donordata.ChannelOnline, }}, }, CertificateProvider: CertificateProvider{ @@ -1029,9 +1029,9 @@ func TestClientServiceContract(t *testing.T) { TownOrCity: "Milton", Country: "AU", }, - Channel: actor.ChannelOnline, + Channel: donordata.ChannelOnline, }, - LifeSustainingTreatmentOption: actor.LifeSustainingTreatmentOptionA, + LifeSustainingTreatmentOption: donordata.LifeSustainingTreatmentOptionA, SignedAt: time.Date(2000, time.January, 2, 12, 13, 14, 0, time.UTC), }}, lpas) return nil diff --git a/internal/lpastore/lpa.go b/internal/lpastore/lpa.go index 4f18ab3009..ebfe202bec 100644 --- a/internal/lpastore/lpa.go +++ b/internal/lpastore/lpa.go @@ -10,9 +10,9 @@ import ( "slices" "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/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/place" @@ -23,24 +23,24 @@ type abstractError struct { } type lpaRequest struct { - LpaType actor.LpaType `json:"lpaType"` - Channel actor.Channel `json:"channel"` - Donor lpaRequestDonor `json:"donor"` - Attorneys []lpaRequestAttorney `json:"attorneys"` - TrustCorporations []lpaRequestTrustCorporation `json:"trustCorporations,omitempty"` - CertificateProvider lpaRequestCertificateProvider `json:"certificateProvider"` - PeopleToNotify []lpaRequestPersonToNotify `json:"peopleToNotify,omitempty"` - HowAttorneysMakeDecisions actor.AttorneysAct `json:"howAttorneysMakeDecisions,omitempty"` - HowAttorneysMakeDecisionsDetails string `json:"howAttorneysMakeDecisionsDetails,omitempty"` - HowReplacementAttorneysMakeDecisions actor.AttorneysAct `json:"howReplacementAttorneysMakeDecisions,omitempty"` - HowReplacementAttorneysMakeDecisionsDetails string `json:"howReplacementAttorneysMakeDecisionsDetails,omitempty"` - HowReplacementAttorneysStepIn actor.ReplacementAttorneysStepIn `json:"howReplacementAttorneysStepIn,omitempty"` - HowReplacementAttorneysStepInDetails string `json:"howReplacementAttorneysStepInDetails,omitempty"` - Restrictions string `json:"restrictionsAndConditions"` - WhenTheLpaCanBeUsed actor.CanBeUsedWhen `json:"whenTheLpaCanBeUsed,omitempty"` - LifeSustainingTreatmentOption actor.LifeSustainingTreatment `json:"lifeSustainingTreatmentOption,omitempty"` - SignedAt time.Time `json:"signedAt"` - CertificateProviderNotRelatedConfirmedAt *time.Time `json:"certificateProviderNotRelatedConfirmedAt,omitempty"` + LpaType donordata.LpaType `json:"lpaType"` + Channel donordata.Channel `json:"channel"` + Donor lpaRequestDonor `json:"donor"` + Attorneys []lpaRequestAttorney `json:"attorneys"` + TrustCorporations []lpaRequestTrustCorporation `json:"trustCorporations,omitempty"` + CertificateProvider lpaRequestCertificateProvider `json:"certificateProvider"` + PeopleToNotify []lpaRequestPersonToNotify `json:"peopleToNotify,omitempty"` + HowAttorneysMakeDecisions donordata.AttorneysAct `json:"howAttorneysMakeDecisions,omitempty"` + HowAttorneysMakeDecisionsDetails string `json:"howAttorneysMakeDecisionsDetails,omitempty"` + HowReplacementAttorneysMakeDecisions donordata.AttorneysAct `json:"howReplacementAttorneysMakeDecisions,omitempty"` + HowReplacementAttorneysMakeDecisionsDetails string `json:"howReplacementAttorneysMakeDecisionsDetails,omitempty"` + HowReplacementAttorneysStepIn donordata.ReplacementAttorneysStepIn `json:"howReplacementAttorneysStepIn,omitempty"` + HowReplacementAttorneysStepInDetails string `json:"howReplacementAttorneysStepInDetails,omitempty"` + Restrictions string `json:"restrictionsAndConditions"` + WhenTheLpaCanBeUsed donordata.CanBeUsedWhen `json:"whenTheLpaCanBeUsed,omitempty"` + LifeSustainingTreatmentOption donordata.LifeSustainingTreatment `json:"lifeSustainingTreatmentOption,omitempty"` + SignedAt time.Time `json:"signedAt"` + CertificateProviderNotRelatedConfirmedAt *time.Time `json:"certificateProviderNotRelatedConfirmedAt,omitempty"` } type lpaRequestIdentityCheck struct { @@ -61,34 +61,34 @@ type lpaRequestDonor struct { } type lpaRequestAttorney struct { - UID actoruid.UID `json:"uid"` - FirstNames string `json:"firstNames"` - LastName string `json:"lastName"` - DateOfBirth date.Date `json:"dateOfBirth"` - Email string `json:"email,omitempty"` - Address place.Address `json:"address"` - Status string `json:"status"` - Channel actor.Channel `json:"channel"` + UID actoruid.UID `json:"uid"` + FirstNames string `json:"firstNames"` + LastName string `json:"lastName"` + DateOfBirth date.Date `json:"dateOfBirth"` + Email string `json:"email,omitempty"` + Address place.Address `json:"address"` + Status string `json:"status"` + Channel donordata.Channel `json:"channel"` } type lpaRequestTrustCorporation struct { - UID actoruid.UID `json:"uid"` - Name string `json:"name"` - CompanyNumber string `json:"companyNumber"` - Email string `json:"email,omitempty"` - Address place.Address `json:"address"` - Status string `json:"status"` - Channel actor.Channel `json:"channel"` + UID actoruid.UID `json:"uid"` + Name string `json:"name"` + CompanyNumber string `json:"companyNumber"` + Email string `json:"email,omitempty"` + Address place.Address `json:"address"` + Status string `json:"status"` + Channel donordata.Channel `json:"channel"` } type lpaRequestCertificateProvider struct { - UID actoruid.UID `json:"uid"` - FirstNames string `json:"firstNames"` - LastName string `json:"lastName"` - Email string `json:"email,omitempty"` - Phone string `json:"phone,omitempty"` - Address place.Address `json:"address"` - Channel actor.Channel `json:"channel"` + UID actoruid.UID `json:"uid"` + FirstNames string `json:"firstNames"` + LastName string `json:"lastName"` + Email string `json:"email,omitempty"` + Phone string `json:"phone,omitempty"` + Address place.Address `json:"address"` + Channel donordata.Channel `json:"channel"` } type lpaRequestPersonToNotify struct { @@ -98,10 +98,10 @@ type lpaRequestPersonToNotify struct { Address place.Address `json:"address"` } -func (c *Client) SendLpa(ctx context.Context, donor *actor.DonorProvidedDetails) error { +func (c *Client) SendLpa(ctx context.Context, donor *donordata.DonorProvidedDetails) error { body := lpaRequest{ LpaType: donor.Type, - Channel: actor.ChannelOnline, + Channel: donordata.ChannelOnline, Donor: lpaRequestDonor{ UID: donor.Donor.UID, FirstNames: donor.Donor.FirstNames, @@ -137,9 +137,9 @@ func (c *Client) SendLpa(ctx context.Context, donor *actor.DonorProvidedDetails) } switch donor.Type { - case actor.LpaTypePropertyAndAffairs: + case donordata.LpaTypePropertyAndAffairs: body.WhenTheLpaCanBeUsed = donor.WhenCanTheLpaBeUsed - case actor.LpaTypePersonalWelfare: + case donordata.LpaTypePersonalWelfare: body.LifeSustainingTreatmentOption = donor.LifeSustainingTreatmentOption } @@ -286,7 +286,7 @@ type Donor struct { OtherNames string DateOfBirth date.Date Address place.Address - Channel actor.Channel + Channel donordata.Channel ContactLanguagePreference localize.Lang IdentityCheck IdentityCheck } @@ -305,7 +305,7 @@ type Attorney struct { Mobile string SignedAt time.Time ContactLanguagePreference localize.Lang - Channel actor.Channel + Channel donordata.Channel } func (a Attorney) FullName() string { @@ -321,7 +321,7 @@ type TrustCorporation struct { Mobile string Signatories []TrustCorporationSignatory ContactLanguagePreference localize.Lang - Channel actor.Channel + Channel donordata.Channel } type TrustCorporationSignatory struct { @@ -332,20 +332,20 @@ type TrustCorporationSignatory struct { } type CertificateProvider struct { - UID actoruid.UID `json:"uid"` - FirstNames string `json:"firstNames"` - LastName string `json:"lastName"` - Email string `json:"email,omitempty"` - Phone string `json:"phone,omitempty"` - Address place.Address `json:"address"` - Channel actor.Channel `json:"channel"` - SignedAt time.Time `json:"signedAt"` - ContactLanguagePreference localize.Lang `json:"contactLanguagePreference"` - IdentityCheck IdentityCheck `json:"identityCheck"` + UID actoruid.UID `json:"uid"` + FirstNames string `json:"firstNames"` + LastName string `json:"lastName"` + Email string `json:"email,omitempty"` + Phone string `json:"phone,omitempty"` + Address place.Address `json:"address"` + Channel donordata.Channel `json:"channel"` + SignedAt time.Time `json:"signedAt"` + ContactLanguagePreference localize.Lang `json:"contactLanguagePreference"` + IdentityCheck IdentityCheck `json:"identityCheck"` // Relationship is not stored in the lpa-store so is defaulted to // Professional. We require it to determine whether to show the home address // page to a certificate provider. - Relationship actor.CertificateProviderRelationship + Relationship donordata.CertificateProviderRelationship } func (c CertificateProvider) FullName() string { @@ -358,28 +358,28 @@ type IdentityCheck struct { } type lpaResponse struct { - LpaType actor.LpaType `json:"lpaType"` - Donor lpaRequestDonor `json:"donor"` - Channel actor.Channel `json:"channel"` - Attorneys []lpaResponseAttorney `json:"attorneys"` - TrustCorporations []lpaResponseTrustCorporation `json:"trustCorporations,omitempty"` - CertificateProvider CertificateProvider `json:"certificateProvider"` - PeopleToNotify []lpaRequestPersonToNotify `json:"peopleToNotify,omitempty"` - HowAttorneysMakeDecisions actor.AttorneysAct `json:"howAttorneysMakeDecisions,omitempty"` - HowAttorneysMakeDecisionsDetails string `json:"howAttorneysMakeDecisionsDetails,omitempty"` - HowReplacementAttorneysMakeDecisions actor.AttorneysAct `json:"howReplacementAttorneysMakeDecisions,omitempty"` - HowReplacementAttorneysMakeDecisionsDetails string `json:"howReplacementAttorneysMakeDecisionsDetails,omitempty"` - HowReplacementAttorneysStepIn actor.ReplacementAttorneysStepIn `json:"howReplacementAttorneysStepIn,omitempty"` - HowReplacementAttorneysStepInDetails string `json:"howReplacementAttorneysStepInDetails,omitempty"` - Restrictions string `json:"restrictionsAndConditions"` - WhenTheLpaCanBeUsed actor.CanBeUsedWhen `json:"whenTheLpaCanBeUsed,omitempty"` - LifeSustainingTreatmentOption actor.LifeSustainingTreatment `json:"lifeSustainingTreatmentOption,omitempty"` - SignedAt time.Time `json:"signedAt"` - CertificateProviderNotRelatedConfirmedAt *time.Time `json:"certificateProviderNotRelatedConfirmedAt,omitempty"` - UID string `json:"uid"` - Status string `json:"status"` - RegistrationDate time.Time `json:"registrationDate"` - UpdatedAt time.Time `json:"updatedAt"` + LpaType donordata.LpaType `json:"lpaType"` + Donor lpaRequestDonor `json:"donor"` + Channel donordata.Channel `json:"channel"` + Attorneys []lpaResponseAttorney `json:"attorneys"` + TrustCorporations []lpaResponseTrustCorporation `json:"trustCorporations,omitempty"` + CertificateProvider CertificateProvider `json:"certificateProvider"` + PeopleToNotify []lpaRequestPersonToNotify `json:"peopleToNotify,omitempty"` + HowAttorneysMakeDecisions donordata.AttorneysAct `json:"howAttorneysMakeDecisions,omitempty"` + HowAttorneysMakeDecisionsDetails string `json:"howAttorneysMakeDecisionsDetails,omitempty"` + HowReplacementAttorneysMakeDecisions donordata.AttorneysAct `json:"howReplacementAttorneysMakeDecisions,omitempty"` + HowReplacementAttorneysMakeDecisionsDetails string `json:"howReplacementAttorneysMakeDecisionsDetails,omitempty"` + HowReplacementAttorneysStepIn donordata.ReplacementAttorneysStepIn `json:"howReplacementAttorneysStepIn,omitempty"` + HowReplacementAttorneysStepInDetails string `json:"howReplacementAttorneysStepInDetails,omitempty"` + Restrictions string `json:"restrictionsAndConditions"` + WhenTheLpaCanBeUsed donordata.CanBeUsedWhen `json:"whenTheLpaCanBeUsed,omitempty"` + LifeSustainingTreatmentOption donordata.LifeSustainingTreatment `json:"lifeSustainingTreatmentOption,omitempty"` + SignedAt time.Time `json:"signedAt"` + CertificateProviderNotRelatedConfirmedAt *time.Time `json:"certificateProviderNotRelatedConfirmedAt,omitempty"` + UID string `json:"uid"` + Status string `json:"status"` + RegistrationDate time.Time `json:"registrationDate"` + UpdatedAt time.Time `json:"updatedAt"` } type Attorneys struct { @@ -431,19 +431,19 @@ type Lpa struct { WithdrawnAt time.Time PerfectAt time.Time UpdatedAt time.Time - Type actor.LpaType + Type donordata.LpaType Donor Donor Attorneys Attorneys ReplacementAttorneys Attorneys CertificateProvider CertificateProvider - PeopleToNotify actor.PeopleToNotify - AttorneyDecisions actor.AttorneyDecisions - ReplacementAttorneyDecisions actor.AttorneyDecisions - HowShouldReplacementAttorneysStepIn actor.ReplacementAttorneysStepIn + PeopleToNotify donordata.PeopleToNotify + AttorneyDecisions donordata.AttorneyDecisions + ReplacementAttorneyDecisions donordata.AttorneyDecisions + HowShouldReplacementAttorneysStepIn donordata.ReplacementAttorneysStepIn HowShouldReplacementAttorneysStepInDetails string Restrictions string - WhenCanTheLpaBeUsed actor.CanBeUsedWhen - LifeSustainingTreatmentOption actor.LifeSustainingTreatment + WhenCanTheLpaBeUsed donordata.CanBeUsedWhen + LifeSustainingTreatmentOption donordata.LifeSustainingTreatment // SignedAt is the date the Donor signed their LPA (and signifies it has been // witnessed by their CertificateProvider) SignedAt time.Time @@ -527,9 +527,9 @@ func lpaResponseToLpa(l lpaResponse) *Lpa { } } - var peopleToNotify []actor.PersonToNotify + var peopleToNotify []donordata.PersonToNotify for _, p := range l.PeopleToNotify { - peopleToNotify = append(peopleToNotify, actor.PersonToNotify{ + peopleToNotify = append(peopleToNotify, donordata.PersonToNotify{ UID: p.UID, FirstNames: p.FirstNames, LastName: p.LastName, @@ -575,11 +575,11 @@ func lpaResponseToLpa(l lpaResponse) *Lpa { }, CertificateProvider: l.CertificateProvider, PeopleToNotify: peopleToNotify, - AttorneyDecisions: actor.AttorneyDecisions{ + AttorneyDecisions: donordata.AttorneyDecisions{ How: l.HowAttorneysMakeDecisions, Details: l.HowAttorneysMakeDecisionsDetails, }, - ReplacementAttorneyDecisions: actor.AttorneyDecisions{ + ReplacementAttorneyDecisions: donordata.AttorneyDecisions{ How: l.HowReplacementAttorneysMakeDecisions, Details: l.HowReplacementAttorneysMakeDecisionsDetails, }, @@ -594,7 +594,7 @@ func lpaResponseToLpa(l lpaResponse) *Lpa { } } -func FromDonorProvidedDetails(l *actor.DonorProvidedDetails) *Lpa { +func FromDonorProvidedDetails(l *donordata.DonorProvidedDetails) *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 66596d3f64..122e0ba2ad 100644 --- a/internal/lpastore/lpa_test.go +++ b/internal/lpastore/lpa_test.go @@ -9,9 +9,9 @@ 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" + donordata "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/identity" "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" @@ -33,14 +33,14 @@ func TestClientSendLpa(t *testing.T) { personToNotifyUID := actoruid.New() testcases := map[string]struct { - donor *actor.DonorProvidedDetails + donor *donordata.DonorProvidedDetails json string }{ "minimal": { - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ LpaUID: "M-0000-1111-2222", - Type: actor.LpaTypePropertyAndAffairs, - Donor: actor.Donor{ + Type: donordata.LpaTypePropertyAndAffairs, + Donor: donordata.Donor{ UID: donorUID, FirstNames: "John Johnson", LastName: "Smith", @@ -54,8 +54,8 @@ func TestClientSendLpa(t *testing.T) { OtherNames: "JJ", ContactLanguagePreference: localize.Cy, }, - Attorneys: actor.Attorneys{ - Attorneys: []actor.Attorney{{ + Attorneys: donordata.Attorneys{ + Attorneys: []donordata.Attorney{{ UID: attorneyUID, FirstNames: "Adam", LastName: "Attorney", @@ -68,9 +68,9 @@ func TestClientSendLpa(t *testing.T) { }, }}, }, - ReplacementAttorneys: actor.Attorneys{}, - WhenCanTheLpaBeUsed: actor.CanBeUsedWhenCapacityLost, - CertificateProvider: actor.CertificateProvider{ + ReplacementAttorneys: donordata.Attorneys{}, + WhenCanTheLpaBeUsed: donordata.CanBeUsedWhenCapacityLost, + CertificateProvider: donordata.CertificateProvider{ UID: certificateProviderUID, FirstNames: "Carol", LastName: "Cert", @@ -79,7 +79,7 @@ func TestClientSendLpa(t *testing.T) { TownOrCity: "c-town", Country: "GB", }, - CarryOutBy: actor.ChannelPaper, + CarryOutBy: donordata.ChannelPaper, }, SignedAt: time.Date(2000, time.January, 2, 3, 4, 5, 6, time.UTC), }, @@ -95,10 +95,10 @@ func TestClientSendLpa(t *testing.T) { }`, }, "everything": { - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ LpaUID: "M-0000-1111-2222", - Type: actor.LpaTypePersonalWelfare, - Donor: actor.Donor{ + Type: donordata.LpaTypePersonalWelfare, + Donor: donordata.Donor{ UID: donorUID, FirstNames: "John Johnson", LastName: "Smith", @@ -115,8 +115,8 @@ func TestClientSendLpa(t *testing.T) { OtherNames: "JJ", ContactLanguagePreference: localize.En, }, - Attorneys: actor.Attorneys{ - TrustCorporation: actor.TrustCorporation{ + Attorneys: donordata.Attorneys{ + TrustCorporation: donordata.TrustCorporation{ UID: trustCorporationUID, Name: "Trusty", CompanyNumber: "55555", @@ -130,7 +130,7 @@ func TestClientSendLpa(t *testing.T) { Country: "GB", }, }, - Attorneys: []actor.Attorney{{ + Attorneys: []donordata.Attorney{{ UID: attorneyUID, FirstNames: "Adam", LastName: "Attorney", @@ -159,11 +159,11 @@ func TestClientSendLpa(t *testing.T) { }, }}, }, - AttorneyDecisions: actor.AttorneyDecisions{ - How: actor.Jointly, + AttorneyDecisions: donordata.AttorneyDecisions{ + How: donordata.Jointly, }, - ReplacementAttorneys: actor.Attorneys{ - TrustCorporation: actor.TrustCorporation{ + ReplacementAttorneys: donordata.Attorneys{ + TrustCorporation: donordata.TrustCorporation{ UID: replacementTrustCorporationUID, Name: "UnTrusty", CompanyNumber: "65555", @@ -176,7 +176,7 @@ func TestClientSendLpa(t *testing.T) { Country: "GB", }, }, - Attorneys: []actor.Attorney{{ + Attorneys: []donordata.Attorney{{ UID: replacementAttorneyUID, FirstNames: "Richard", LastName: "Attorney", @@ -206,14 +206,14 @@ func TestClientSendLpa(t *testing.T) { }, }}, }, - ReplacementAttorneyDecisions: actor.AttorneyDecisions{ - How: actor.JointlyForSomeSeverallyForOthers, + ReplacementAttorneyDecisions: donordata.AttorneyDecisions{ + How: donordata.JointlyForSomeSeverallyForOthers, Details: "umm", }, - HowShouldReplacementAttorneysStepIn: actor.ReplacementAttorneysStepInWhenAllCanNoLongerAct, - LifeSustainingTreatmentOption: actor.LifeSustainingTreatmentOptionA, + HowShouldReplacementAttorneysStepIn: donordata.ReplacementAttorneysStepInWhenAllCanNoLongerAct, + LifeSustainingTreatmentOption: donordata.LifeSustainingTreatmentOptionA, Restrictions: "do not do this", - CertificateProvider: actor.CertificateProvider{ + CertificateProvider: donordata.CertificateProvider{ UID: certificateProviderUID, FirstNames: "Carol", LastName: "Cert", @@ -227,9 +227,9 @@ func TestClientSendLpa(t *testing.T) { Postcode: "C1 1FF", Country: "GB", }, - CarryOutBy: actor.ChannelOnline, + CarryOutBy: donordata.ChannelOnline, }, - PeopleToNotify: actor.PeopleToNotify{{ + PeopleToNotify: donordata.PeopleToNotify{{ UID: personToNotifyUID, FirstNames: "Peter", LastName: "Notify", @@ -316,7 +316,7 @@ func TestClientSendLpa(t *testing.T) { func TestClientSendLpaWhenNewRequestError(t *testing.T) { client := New("http://base", nil, nil) - err := client.SendLpa(nil, &actor.DonorProvidedDetails{}) + err := client.SendLpa(nil, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := client.SendLpa(ctx, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := client.SendLpa(ctx, &donordata.DonorProvidedDetails{}) 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, &actor.DonorProvidedDetails{}) + err := client.SendLpa(ctx, &donordata.DonorProvidedDetails{}) assert.Equal(t, responseError{name: errorName, body: "hey"}, err) }) @@ -401,7 +401,7 @@ func TestClientLpa(t *testing.T) { "minimal": { donor: &Lpa{ LpaUID: "M-0000-1111-2222", - Type: actor.LpaTypePropertyAndAffairs, + Type: donordata.LpaTypePropertyAndAffairs, Donor: Donor{ UID: donorUID, FirstNames: "John Johnson", @@ -414,7 +414,7 @@ func TestClientLpa(t *testing.T) { Country: "GB", }, OtherNames: "JJ", - Channel: actor.ChannelOnline, + Channel: donordata.ChannelOnline, }, Attorneys: Attorneys{ Attorneys: []Attorney{{ @@ -431,7 +431,7 @@ func TestClientLpa(t *testing.T) { }}, }, ReplacementAttorneys: Attorneys{}, - WhenCanTheLpaBeUsed: actor.CanBeUsedWhenCapacityLost, + WhenCanTheLpaBeUsed: donordata.CanBeUsedWhenCapacityLost, CertificateProvider: CertificateProvider{ UID: certificateProviderUID, FirstNames: "Carol", @@ -441,7 +441,7 @@ func TestClientLpa(t *testing.T) { TownOrCity: "c-town", Country: "GB", }, - Channel: actor.ChannelPaper, + Channel: donordata.ChannelPaper, }, SignedAt: time.Date(2000, time.January, 2, 3, 4, 5, 6, time.UTC), }, @@ -460,7 +460,7 @@ func TestClientLpa(t *testing.T) { "everything": { donor: &Lpa{ LpaUID: "M-0000-1111-2222", - Type: actor.LpaTypePersonalWelfare, + Type: donordata.LpaTypePersonalWelfare, Donor: Donor{ UID: donorUID, FirstNames: "John Johnson", @@ -476,7 +476,7 @@ func TestClientLpa(t *testing.T) { Country: "GB", }, OtherNames: "JJ", - Channel: actor.ChannelOnline, + Channel: donordata.ChannelOnline, IdentityCheck: IdentityCheck{ CheckedAt: time.Date(2002, time.January, 2, 12, 13, 14, 1, time.UTC), Type: "one-login", @@ -496,7 +496,7 @@ func TestClientLpa(t *testing.T) { Postcode: "A1 1FF", Country: "GB", }, - Channel: actor.ChannelOnline, + Channel: donordata.ChannelOnline, }, Attorneys: []Attorney{{ UID: attorneyUID, @@ -528,8 +528,8 @@ func TestClientLpa(t *testing.T) { }, }}, }, - AttorneyDecisions: actor.AttorneyDecisions{ - How: actor.Jointly, + AttorneyDecisions: donordata.AttorneyDecisions{ + How: donordata.Jointly, }, ReplacementAttorneys: Attorneys{ TrustCorporation: TrustCorporation{ @@ -544,7 +544,7 @@ func TestClientLpa(t *testing.T) { Postcode: "A1 1FF", Country: "GB", }, - Channel: actor.ChannelPaper, + Channel: donordata.ChannelPaper, }, Attorneys: []Attorney{{ UID: replacementAttorneyUID, @@ -576,12 +576,12 @@ func TestClientLpa(t *testing.T) { }, }}, }, - ReplacementAttorneyDecisions: actor.AttorneyDecisions{ - How: actor.JointlyForSomeSeverallyForOthers, + ReplacementAttorneyDecisions: donordata.AttorneyDecisions{ + How: donordata.JointlyForSomeSeverallyForOthers, Details: "umm", }, - HowShouldReplacementAttorneysStepIn: actor.ReplacementAttorneysStepInWhenAllCanNoLongerAct, - LifeSustainingTreatmentOption: actor.LifeSustainingTreatmentOptionA, + HowShouldReplacementAttorneysStepIn: donordata.ReplacementAttorneysStepInWhenAllCanNoLongerAct, + LifeSustainingTreatmentOption: donordata.LifeSustainingTreatmentOptionA, Restrictions: "do not do this", CertificateProvider: CertificateProvider{ UID: certificateProviderUID, @@ -597,13 +597,13 @@ func TestClientLpa(t *testing.T) { Postcode: "C1 1FF", Country: "GB", }, - Channel: actor.ChannelOnline, + Channel: donordata.ChannelOnline, IdentityCheck: IdentityCheck{ CheckedAt: time.Date(2002, time.January, 1, 13, 14, 15, 16, time.UTC), Type: "one-login", }, }, - PeopleToNotify: actor.PeopleToNotify{{ + PeopleToNotify: donordata.PeopleToNotify{{ UID: personToNotifyUID, FirstNames: "Peter", LastName: "Notify", @@ -775,7 +775,7 @@ func TestClientLpas(t *testing.T) { lpas: []*Lpa{ { LpaUID: "M-0000-1111-2222", - Type: actor.LpaTypePropertyAndAffairs, + Type: donordata.LpaTypePropertyAndAffairs, Donor: Donor{ UID: donorUID, FirstNames: "John Johnson", @@ -788,7 +788,7 @@ func TestClientLpas(t *testing.T) { Country: "GB", }, OtherNames: "JJ", - Channel: actor.ChannelOnline, + Channel: donordata.ChannelOnline, }, Attorneys: Attorneys{ Attorneys: []Attorney{{ @@ -805,7 +805,7 @@ func TestClientLpas(t *testing.T) { }}, }, ReplacementAttorneys: Attorneys{}, - WhenCanTheLpaBeUsed: actor.CanBeUsedWhenCapacityLost, + WhenCanTheLpaBeUsed: donordata.CanBeUsedWhenCapacityLost, CertificateProvider: CertificateProvider{ UID: certificateProviderUID, FirstNames: "Carol", @@ -815,7 +815,7 @@ func TestClientLpas(t *testing.T) { TownOrCity: "c-town", Country: "GB", }, - Channel: actor.ChannelPaper, + Channel: donordata.ChannelPaper, }, SignedAt: time.Date(2000, time.January, 2, 3, 4, 5, 6, time.UTC), }, @@ -836,7 +836,7 @@ func TestClientLpas(t *testing.T) { lpas: []*Lpa{ { LpaUID: "M-0000-1111-2222", - Type: actor.LpaTypePersonalWelfare, + Type: donordata.LpaTypePersonalWelfare, Donor: Donor{ UID: donorUID, FirstNames: "John Johnson", @@ -852,7 +852,7 @@ func TestClientLpas(t *testing.T) { Country: "GB", }, OtherNames: "JJ", - Channel: actor.ChannelOnline, + Channel: donordata.ChannelOnline, }, Attorneys: Attorneys{ TrustCorporation: TrustCorporation{ @@ -899,8 +899,8 @@ func TestClientLpas(t *testing.T) { }, }}, }, - AttorneyDecisions: actor.AttorneyDecisions{ - How: actor.Jointly, + AttorneyDecisions: donordata.AttorneyDecisions{ + How: donordata.Jointly, }, ReplacementAttorneys: Attorneys{ TrustCorporation: TrustCorporation{ @@ -947,12 +947,12 @@ func TestClientLpas(t *testing.T) { }, }}, }, - ReplacementAttorneyDecisions: actor.AttorneyDecisions{ - How: actor.JointlyForSomeSeverallyForOthers, + ReplacementAttorneyDecisions: donordata.AttorneyDecisions{ + How: donordata.JointlyForSomeSeverallyForOthers, Details: "umm", }, - HowShouldReplacementAttorneysStepIn: actor.ReplacementAttorneysStepInWhenAllCanNoLongerAct, - LifeSustainingTreatmentOption: actor.LifeSustainingTreatmentOptionA, + HowShouldReplacementAttorneysStepIn: donordata.ReplacementAttorneysStepInWhenAllCanNoLongerAct, + LifeSustainingTreatmentOption: donordata.LifeSustainingTreatmentOptionA, Restrictions: "do not do this", CertificateProvider: CertificateProvider{ UID: certificateProviderUID, @@ -968,9 +968,9 @@ func TestClientLpas(t *testing.T) { Postcode: "C1 1FF", Country: "GB", }, - Channel: actor.ChannelOnline, + Channel: donordata.ChannelOnline, }, - PeopleToNotify: actor.PeopleToNotify{{ + PeopleToNotify: donordata.PeopleToNotify{{ UID: personToNotifyUID, FirstNames: "Peter", LastName: "Notify", diff --git a/internal/lpastore/resolving_service.go b/internal/lpastore/resolving_service.go index 54bcd85582..f17f78a886 100644 --- a/internal/lpastore/resolving_service.go +++ b/internal/lpastore/resolving_service.go @@ -4,12 +4,12 @@ import ( "context" "errors" - "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" ) type DonorStore interface { - GetAny(ctx context.Context) (*actor.DonorProvidedDetails, error) + GetAny(ctx context.Context) (*donordata.DonorProvidedDetails, 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 []*actor.DonorProvidedDetails) ([]*Lpa, error) { +func (s *ResolvingService) ResolveList(ctx context.Context, donors []*donordata.DonorProvidedDetails) ([]*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 []*actor.Dono return result, nil } -func (s *ResolvingService) merge(lpa *Lpa, donor *actor.DonorProvidedDetails) *Lpa { +func (s *ResolvingService) merge(lpa *Lpa, donor *donordata.DonorProvidedDetails) *Lpa { lpa.LpaKey = donor.PK lpa.LpaOwnerKey = donor.SK lpa.LpaID = donor.LpaID @@ -88,14 +88,14 @@ func (s *ResolvingService) merge(lpa *Lpa, donor *actor.DonorProvidedDetails) *L lpa.Paid = true // set to Professionally so we always show the certificate provider home // address question - lpa.CertificateProvider.Relationship = actor.Professionally - lpa.Donor.Channel = actor.ChannelPaper + lpa.CertificateProvider.Relationship = donordata.Professionally + lpa.Donor.Channel = donordata.ChannelPaper } else { lpa.Drafted = donor.Tasks.CheckYourLpa.Completed() lpa.Submitted = !donor.SubmittedAt.IsZero() lpa.Paid = donor.Tasks.PayForLpa.IsCompleted() _, lpa.IsOrganisationDonor = donor.SK.Organisation() - lpa.Donor.Channel = actor.ChannelOnline + lpa.Donor.Channel = donordata.ChannelOnline // copy the relationship as it isn't stored in the lpastore. lpa.CertificateProvider.Relationship = donor.CertificateProvider.Relationship diff --git a/internal/lpastore/resolving_service_test.go b/internal/lpastore/resolving_service_test.go index 4de82a575a..e89b6b2bbd 100644 --- a/internal/lpastore/resolving_service_test.go +++ b/internal/lpastore/resolving_service_test.go @@ -6,32 +6,34 @@ import ( "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" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) func TestResolvingServiceGet(t *testing.T) { testcases := map[string]struct { - donor *actor.DonorProvidedDetails + donor *donordata.DonorProvidedDetails resolved *Lpa error error expected *Lpa }{ "online with all true": { - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ SK: dynamo.LpaOwnerKey(dynamo.OrganisationKey("S")), LpaID: "1", LpaUID: "M-1111", SubmittedAt: time.Now(), - CertificateProvider: actor.CertificateProvider{ + CertificateProvider: donordata.CertificateProvider{ FirstNames: "Barry", - Relationship: actor.Personally, + Relationship: donordata.Personally, }, - Tasks: actor.DonorTasks{ + Tasks: donordata.DonorTasks{ CheckYourLpa: actor.TaskCompleted, - PayForLpa: actor.PaymentTaskCompleted, + PayForLpa: task.PaymentStateCompleted, }, DonorIdentityUserData: identity.UserData{ Status: identity.StatusConfirmed, @@ -54,27 +56,27 @@ func TestResolvingServiceGet(t *testing.T) { IsOrganisationDonor: true, CertificateProvider: CertificateProvider{ FirstNames: "Paul", - Relationship: actor.Personally, + Relationship: donordata.Personally, }, - Donor: Donor{Channel: actor.ChannelOnline}, + Donor: Donor{Channel: donordata.ChannelOnline}, }, }, "online with no lpastore record": { - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ SK: dynamo.LpaOwnerKey(dynamo.DonorKey("S")), LpaUID: "M-1111", - CertificateProvider: actor.CertificateProvider{ + CertificateProvider: donordata.CertificateProvider{ FirstNames: "John", - Relationship: actor.Personally, + Relationship: donordata.Personally, }, - Donor: actor.Donor{Channel: actor.ChannelOnline}, - Attorneys: actor.Attorneys{ - Attorneys: []actor.Attorney{{FirstNames: "a"}}, - TrustCorporation: actor.TrustCorporation{Name: "b"}, + Donor: donordata.Donor{Channel: donordata.ChannelOnline}, + Attorneys: donordata.Attorneys{ + Attorneys: []donordata.Attorney{{FirstNames: "a"}}, + TrustCorporation: donordata.TrustCorporation{Name: "b"}, }, - ReplacementAttorneys: actor.Attorneys{ - Attorneys: []actor.Attorney{{FirstNames: "c"}}, - TrustCorporation: actor.TrustCorporation{Name: "d"}, + ReplacementAttorneys: donordata.Attorneys{ + Attorneys: []donordata.Attorney{{FirstNames: "c"}}, + TrustCorporation: donordata.TrustCorporation{Name: "d"}, }, DonorIdentityUserData: identity.UserData{ Status: identity.StatusConfirmed, @@ -87,10 +89,10 @@ func TestResolvingServiceGet(t *testing.T) { LpaUID: "M-1111", CertificateProvider: CertificateProvider{ FirstNames: "John", - Relationship: actor.Personally, + Relationship: donordata.Personally, }, Donor: Donor{ - Channel: actor.ChannelOnline, + Channel: donordata.ChannelOnline, IdentityCheck: IdentityCheck{ CheckedAt: time.Date(2020, time.January, 2, 12, 13, 14, 5, time.UTC), Type: "one-login", @@ -107,7 +109,7 @@ func TestResolvingServiceGet(t *testing.T) { }, }, "online with all false": { - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ SK: dynamo.LpaOwnerKey(dynamo.DonorKey("S")), LpaID: "1", LpaUID: "M-1111", @@ -117,11 +119,11 @@ func TestResolvingServiceGet(t *testing.T) { LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("S")), LpaID: "1", LpaUID: "M-1111", - Donor: Donor{Channel: actor.ChannelOnline}, + Donor: Donor{Channel: donordata.ChannelOnline}, }, }, "paper": { - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ SK: dynamo.LpaOwnerKey(dynamo.DonorKey("PAPER")), LpaID: "1", LpaUID: "M-1111", @@ -135,9 +137,9 @@ func TestResolvingServiceGet(t *testing.T) { Drafted: true, Paid: true, CertificateProvider: CertificateProvider{ - Relationship: actor.Professionally, + Relationship: donordata.Professionally, }, - Donor: Donor{Channel: actor.ChannelPaper}, + Donor: Donor{Channel: donordata.ChannelPaper}, }, }, } @@ -171,14 +173,14 @@ func TestResolvingServiceGetWhenNoUID(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). GetAny(ctx). - Return(&actor.DonorProvidedDetails{LpaID: "1"}, nil) + Return(&donordata.DonorProvidedDetails{LpaID: "1"}, nil) service := NewResolvingService(donorStore, nil) lpa, err := service.Get(ctx) assert.Equal(t, &Lpa{ LpaID: "1", - Donor: Donor{Channel: actor.ChannelOnline}, + Donor: Donor{Channel: donordata.ChannelOnline}, }, lpa) assert.Nil(t, err) } @@ -189,7 +191,7 @@ func TestResolvingServiceGetWhenNotFound(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). GetAny(ctx). - Return(&actor.DonorProvidedDetails{LpaID: "1", LpaUID: "M-1111"}, nil) + Return(&donordata.DonorProvidedDetails{LpaID: "1", LpaUID: "M-1111"}, nil) lpaClient := newMockLpaClient(t) lpaClient.EXPECT(). @@ -202,7 +204,7 @@ func TestResolvingServiceGetWhenNotFound(t *testing.T) { assert.Equal(t, &Lpa{ LpaID: "1", LpaUID: "M-1111", - Donor: Donor{Channel: actor.ChannelOnline}, + Donor: Donor{Channel: donordata.ChannelOnline}, }, lpa) assert.Nil(t, err) } @@ -227,7 +229,7 @@ func TestResolvingServiceGetWhenLpaClientErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). GetAny(ctx). - Return(&actor.DonorProvidedDetails{LpaUID: "M-1111"}, nil) + Return(&donordata.DonorProvidedDetails{LpaUID: "M-1111"}, nil) lpaClient := newMockLpaClient(t) lpaClient.EXPECT(). @@ -242,25 +244,25 @@ func TestResolvingServiceGetWhenLpaClientErrors(t *testing.T) { func TestResolvingServiceResolveList(t *testing.T) { testcases := map[string]struct { - donors []*actor.DonorProvidedDetails + donors []*donordata.DonorProvidedDetails uids []string resolved []*Lpa error error expected []*Lpa }{ "online with all true": { - donors: []*actor.DonorProvidedDetails{{ + donors: []*donordata.DonorProvidedDetails{{ SK: dynamo.LpaOwnerKey(dynamo.OrganisationKey("S")), LpaID: "1", LpaUID: "M-1111", SubmittedAt: time.Now(), - CertificateProvider: actor.CertificateProvider{ + CertificateProvider: donordata.CertificateProvider{ FirstNames: "Barry", - Relationship: actor.Personally, + Relationship: donordata.Personally, }, - Tasks: actor.DonorTasks{ + Tasks: donordata.DonorTasks{ CheckYourLpa: actor.TaskCompleted, - PayForLpa: actor.PaymentTaskCompleted, + PayForLpa: task.PaymentStateCompleted, }, DonorIdentityUserData: identity.UserData{ Status: identity.StatusConfirmed, @@ -284,27 +286,27 @@ func TestResolvingServiceResolveList(t *testing.T) { IsOrganisationDonor: true, CertificateProvider: CertificateProvider{ FirstNames: "Paul", - Relationship: actor.Personally, + Relationship: donordata.Personally, }, - Donor: Donor{Channel: actor.ChannelOnline}, + Donor: Donor{Channel: donordata.ChannelOnline}, }}, }, "online with no lpastore record": { - donors: []*actor.DonorProvidedDetails{{ + donors: []*donordata.DonorProvidedDetails{{ SK: dynamo.LpaOwnerKey(dynamo.DonorKey("S")), LpaUID: "M-1111", - CertificateProvider: actor.CertificateProvider{ + CertificateProvider: donordata.CertificateProvider{ FirstNames: "John", - Relationship: actor.Personally, + Relationship: donordata.Personally, }, - Donor: actor.Donor{Channel: actor.ChannelOnline}, - Attorneys: actor.Attorneys{ - Attorneys: []actor.Attorney{{FirstNames: "a"}}, - TrustCorporation: actor.TrustCorporation{Name: "b"}, + Donor: donordata.Donor{Channel: donordata.ChannelOnline}, + Attorneys: donordata.Attorneys{ + Attorneys: []donordata.Attorney{{FirstNames: "a"}}, + TrustCorporation: donordata.TrustCorporation{Name: "b"}, }, - ReplacementAttorneys: actor.Attorneys{ - Attorneys: []actor.Attorney{{FirstNames: "c"}}, - TrustCorporation: actor.TrustCorporation{Name: "d"}, + ReplacementAttorneys: donordata.Attorneys{ + Attorneys: []donordata.Attorney{{FirstNames: "c"}}, + TrustCorporation: donordata.TrustCorporation{Name: "d"}, }, }}, uids: []string{"M-1111"}, @@ -313,9 +315,9 @@ func TestResolvingServiceResolveList(t *testing.T) { LpaUID: "M-1111", CertificateProvider: CertificateProvider{ FirstNames: "John", - Relationship: actor.Personally, + Relationship: donordata.Personally, }, - Donor: Donor{Channel: actor.ChannelOnline}, + Donor: Donor{Channel: donordata.ChannelOnline}, Attorneys: Attorneys{ Attorneys: []Attorney{{FirstNames: "a"}}, TrustCorporation: TrustCorporation{Name: "b"}, @@ -327,7 +329,7 @@ func TestResolvingServiceResolveList(t *testing.T) { }}, }, "online with all false": { - donors: []*actor.DonorProvidedDetails{{ + donors: []*donordata.DonorProvidedDetails{{ SK: dynamo.LpaOwnerKey(dynamo.DonorKey("S")), LpaID: "1", LpaUID: "M-1111", @@ -338,11 +340,11 @@ func TestResolvingServiceResolveList(t *testing.T) { LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("S")), LpaID: "1", LpaUID: "M-1111", - Donor: Donor{Channel: actor.ChannelOnline}, + Donor: Donor{Channel: donordata.ChannelOnline}, }}, }, "paper": { - donors: []*actor.DonorProvidedDetails{{ + donors: []*donordata.DonorProvidedDetails{{ SK: dynamo.LpaOwnerKey(dynamo.DonorKey("PAPER")), LpaID: "1", LpaUID: "M-1111", @@ -357,9 +359,9 @@ func TestResolvingServiceResolveList(t *testing.T) { Submitted: true, Paid: true, CertificateProvider: CertificateProvider{ - Relationship: actor.Professionally, + Relationship: donordata.Professionally, }, - Donor: Donor{Channel: actor.ChannelPaper}, + Donor: Donor{Channel: donordata.ChannelPaper}, }}, }, } diff --git a/internal/lpastore/update.go b/internal/lpastore/update.go index c161514423..83a315d2b8 100644 --- a/internal/lpastore/update.go +++ b/internal/lpastore/update.go @@ -8,10 +8,10 @@ import ( "io" "net/http" - "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/certificateprovider/certificateproviderdata" + "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" ) type updateRequest struct { @@ -107,8 +107,8 @@ func (c *Client) SendCertificateProvider(ctx context.Context, certificateProvide body.Changes = append(body.Changes, updateRequestChange{Key: "/certificateProvider/email", New: certificateProvider.Email, Old: lpa.CertificateProvider.Email}) } - if lpa.CertificateProvider.Channel == actor.ChannelPaper { - body.Changes = append(body.Changes, updateRequestChange{Key: "/certificateProvider/channel", New: actor.ChannelOnline, Old: actor.ChannelPaper}) + if lpa.CertificateProvider.Channel == donordata.ChannelPaper { + body.Changes = append(body.Changes, updateRequestChange{Key: "/certificateProvider/channel", New: donordata.ChannelOnline, Old: donordata.ChannelPaper}) } return c.sendUpdate(ctx, lpa.LpaUID, certificateProvider.UID, body) @@ -148,8 +148,8 @@ func (c *Client) SendAttorney(ctx context.Context, lpa *Lpa, attorney *attorneyd body.Changes = append(body.Changes, updateRequestChange{Key: attorneyKey + "/email", New: attorney.Email, Old: lpaTrustCorp.Email}) } - if lpaTrustCorp.Channel == actor.ChannelPaper { - body.Changes = append(body.Changes, updateRequestChange{Key: attorneyKey + "/channel", New: actor.ChannelOnline, Old: actor.ChannelPaper}) + if lpaTrustCorp.Channel == donordata.ChannelPaper { + body.Changes = append(body.Changes, updateRequestChange{Key: attorneyKey + "/channel", New: donordata.ChannelOnline, Old: donordata.ChannelPaper}) } body.Changes = append(body.Changes, @@ -172,8 +172,8 @@ func (c *Client) SendAttorney(ctx context.Context, lpa *Lpa, attorney *attorneyd body.Changes = append(body.Changes, updateRequestChange{Key: attorneyKey + "/email", New: attorney.Email, Old: lpaAttorney.Email}) } - if lpaAttorney.Channel == actor.ChannelPaper { - body.Changes = append(body.Changes, updateRequestChange{Key: attorneyKey + "/channel", New: actor.ChannelOnline, Old: actor.ChannelPaper}) + if lpaAttorney.Channel == donordata.ChannelPaper { + body.Changes = append(body.Changes, updateRequestChange{Key: attorneyKey + "/channel", New: donordata.ChannelOnline, Old: donordata.ChannelPaper}) } body.Changes = append(body.Changes, updateRequestChange{Key: attorneyKey + "/signedAt", New: attorney.SignedAt}) @@ -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 *actor.DonorProvidedDetails) error { +func (c *Client) SendDonorConfirmIdentity(ctx context.Context, donor *donordata.DonorProvidedDetails) error { body := updateRequest{ Type: "DONOR_CONFIRM_IDENTITY", Changes: []updateRequestChange{ diff --git a/internal/lpastore/update_test.go b/internal/lpastore/update_test.go index a0d92248de..7898f30df3 100644 --- a/internal/lpastore/update_test.go +++ b/internal/lpastore/update_test.go @@ -8,10 +8,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/attorney/attorneydata" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" + donordata "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/identity" "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" @@ -109,7 +109,7 @@ func TestClientSendCertificateProvider(t *testing.T) { lpa := &Lpa{ LpaUID: "lpa-uid", CertificateProvider: CertificateProvider{ - Channel: actor.ChannelOnline, + Channel: donordata.ChannelOnline, Email: "a@example.com", }, } @@ -168,7 +168,7 @@ func TestClientSendAttorney(t *testing.T) { LpaUID: "lpa-uid", Attorneys: Attorneys{ Attorneys: []Attorney{ - {UID: uid1}, {UID: uid2, Email: "a@example.com", Channel: actor.ChannelPaper}, + {UID: uid1}, {UID: uid2, Email: "a@example.com", Channel: donordata.ChannelPaper}, }, }, }, @@ -192,7 +192,7 @@ func TestClientSendAttorney(t *testing.T) { }, ReplacementAttorneys: Attorneys{ Attorneys: []Attorney{ - {UID: uid1}, {UID: uid2, Email: "a@example.com", Channel: actor.ChannelPaper}, + {UID: uid1}, {UID: uid2, Email: "a@example.com", Channel: donordata.ChannelPaper}, }, }, }, @@ -220,7 +220,7 @@ func TestClientSendAttorney(t *testing.T) { donor: &Lpa{ LpaUID: "lpa-uid", Attorneys: Attorneys{ - TrustCorporation: TrustCorporation{Channel: actor.ChannelPaper}, + TrustCorporation: TrustCorporation{Channel: donordata.ChannelPaper}, }, }, json: `{"type":"TRUST_CORPORATION_SIGN","changes":[{"key":"/trustCorporations/0/mobile","old":null,"new":"07777"},{"key":"/trustCorporations/0/contactLanguagePreference","old":null,"new":"en"},{"key":"/trustCorporations/0/email","old":"","new":"a@example.com"},{"key":"/trustCorporations/0/channel","old":"paper","new":"online"},{"key":"/trustCorporations/0/signatories/0/firstNames","old":null,"new":"John"},{"key":"/trustCorporations/0/signatories/0/lastName","old":null,"new":"Signer"},{"key":"/trustCorporations/0/signatories/0/professionalTitle","old":null,"new":"Director"},{"key":"/trustCorporations/0/signatories/0/signedAt","old":null,"new":"2000-01-02T03:04:05.000000006Z"},{"key":"/trustCorporations/0/signatories/1/firstNames","old":null,"new":"Dave"},{"key":"/trustCorporations/0/signatories/1/lastName","old":null,"new":"Signer"},{"key":"/trustCorporations/0/signatories/1/professionalTitle","old":null,"new":"Assistant to the Director"},{"key":"/trustCorporations/0/signatories/1/signedAt","old":null,"new":"2000-01-02T03:04:05.000000007Z"}]}`, @@ -245,7 +245,7 @@ func TestClientSendAttorney(t *testing.T) { TrustCorporation: TrustCorporation{Name: "a"}, }, ReplacementAttorneys: Attorneys{ - TrustCorporation: TrustCorporation{Channel: actor.ChannelPaper}, + TrustCorporation: TrustCorporation{Channel: donordata.ChannelPaper}, }, }, json: `{"type":"TRUST_CORPORATION_SIGN","changes":[{"key":"/trustCorporations/1/mobile","old":null,"new":"07777"},{"key":"/trustCorporations/1/contactLanguagePreference","old":null,"new":"en"},{"key":"/trustCorporations/1/channel","old":"paper","new":"online"},{"key":"/trustCorporations/1/signatories/0/firstNames","old":null,"new":"John"},{"key":"/trustCorporations/1/signatories/0/lastName","old":null,"new":"Signer"},{"key":"/trustCorporations/1/signatories/0/professionalTitle","old":null,"new":"Director"},{"key":"/trustCorporations/1/signatories/0/signedAt","old":null,"new":"2000-01-02T03:04:05.000000006Z"}]}`, @@ -375,9 +375,9 @@ 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, &actor.DonorProvidedDetails{ + err := client.SendDonorConfirmIdentity(ctx, &donordata.DonorProvidedDetails{ LpaUID: "lpa-uid", - Donor: actor.Donor{UID: uid}, + Donor: donordata.Donor{UID: uid}, DonorIdentityUserData: identity.UserData{ RetrievedAt: time.Date(2024, time.January, 2, 12, 13, 14, 6, time.UTC), }, diff --git a/internal/page/app_data.go b/internal/page/app_data.go index 8f0ac87448..de5bbe692f 100644 --- a/internal/page/app_data.go +++ b/internal/page/app_data.go @@ -7,6 +7,7 @@ import ( "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/localize" ) @@ -29,7 +30,7 @@ type AppData struct { } type SupporterData struct { - LpaType actor.LpaType + LpaType donordata.LpaType DonorFullName string OrganisationName string IsManageOrganisation bool diff --git a/internal/page/common.go b/internal/page/common.go index ca8a043f33..622429456f 100644 --- a/internal/page/common.go +++ b/internal/page/common.go @@ -9,6 +9,7 @@ import ( "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" "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" @@ -43,8 +44,8 @@ type OneLoginClient interface { } type DonorStore interface { - Create(context.Context) (*actor.DonorProvidedDetails, error) - Put(context.Context, *actor.DonorProvidedDetails) error + Create(context.Context) (*donordata.DonorProvidedDetails, error) + Put(context.Context, *donordata.DonorProvidedDetails) error } type Bundle interface { diff --git a/internal/page/dashboard_test.go b/internal/page/dashboard_test.go index f87ec0081d..cb5055a51a 100644 --- a/internal/page/dashboard_test.go +++ b/internal/page/dashboard_test.go @@ -7,7 +7,7 @@ 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/lpastore" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -134,7 +134,7 @@ func TestPostDashboard(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Create(r.Context()). - Return(&actor.DonorProvidedDetails{LpaID: "lpa-id"}, nil) + Return(&donordata.DonorProvidedDetails{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(&actor.DonorProvidedDetails{LpaID: "123"}, expectedError) + Return(&donordata.DonorProvidedDetails{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 eb3367655d..d247550173 100644 --- a/internal/page/data.go +++ b/internal/page/data.go @@ -2,25 +2,26 @@ // // Useful links: // - [actor.Lpa] - details about the LPA being drafted -// - [actor.Donor] - details about the donor, provided by the applicant -// - [actor.CertificateProvider] - details about the certificate provider, provided by the applicant +// - [donordata.Donor] - details about the donor, provided by the applicant +// - [donordata.CertificateProvider] - details about the certificate provider, provided by the applicant // - [certificateproviderdata.Provided] - details about the certificate provider, provided by the certificate provider -// - [actor.Attorney] - details about an attorney or replacement attorney, provided by the applicant -// - [actor.AttorneyDecisions] - details about how an attorney or replacement attorney should act, provided by the applicant +// - [donordata.Attorney] - details about an attorney or replacement attorney, provided by the applicant +// - [donordata.AttorneyDecisions] - details about how an attorney or replacement attorney should act, provided by the applicant // - [attorneydata.Provided] - details about an attorney or replacement attorney, provided by the attorney or replacement attorney -// - [actor.PersonToNotify] - details about a person to notify, provided by the applicant +// - [donordata.PersonToNotify] - details about a person to notify, provided by the applicant 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" ) var SessionDataFromContext = appcontext.SessionDataFromContext var ContextWithSessionData = appcontext.ContextWithSessionData -func ChooseAttorneysState(attorneys actor.Attorneys, decisions actor.AttorneyDecisions) actor.TaskState { +func ChooseAttorneysState(attorneys donordata.Attorneys, decisions donordata.AttorneyDecisions) actor.TaskState { if attorneys.Len() == 0 { return actor.TaskNotStarted } @@ -36,7 +37,7 @@ func ChooseAttorneysState(attorneys actor.Attorneys, decisions actor.AttorneyDec return actor.TaskCompleted } -func ChooseReplacementAttorneysState(donor *actor.DonorProvidedDetails) actor.TaskState { +func ChooseReplacementAttorneysState(donor *donordata.DonorProvidedDetails) actor.TaskState { if donor.WantReplacementAttorneys == form.No { return actor.TaskCompleted } diff --git a/internal/page/data_test.go b/internal/page/data_test.go index 388d5b62ca..71ff881aa9 100644 --- a/internal/page/data_test.go +++ b/internal/page/data_test.go @@ -4,56 +4,58 @@ 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" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" ) func TestChooseAttorneysState(t *testing.T) { testcases := map[string]struct { - attorneys actor.Attorneys - decisions actor.AttorneyDecisions + attorneys donordata.Attorneys + decisions donordata.AttorneyDecisions taskState actor.TaskState }{ "empty": { taskState: actor.TaskNotStarted, }, "trust corporation": { - attorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{ + attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{ Name: "a", Address: place.Address{Line1: "a"}, }}, taskState: actor.TaskCompleted, }, "trust corporation incomplete": { - attorneys: actor.Attorneys{TrustCorporation: actor.TrustCorporation{ + attorneys: donordata.Attorneys{TrustCorporation: donordata.TrustCorporation{ Name: "a", }}, taskState: actor.TaskInProgress, }, "single with email": { - attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ FirstNames: "a", Email: "a", }}}, taskState: actor.TaskInProgress, }, "single with address": { - attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ FirstNames: "a", Address: place.Address{Line1: "a"}, }}}, taskState: actor.TaskCompleted, }, "single incomplete": { - attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ FirstNames: "a", }}}, taskState: actor.TaskInProgress, }, "multiple without decisions": { - attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ FirstNames: "a", Address: testAddress, }, { @@ -63,24 +65,24 @@ func TestChooseAttorneysState(t *testing.T) { taskState: actor.TaskInProgress, }, "multiple with decisions": { - attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ FirstNames: "a", Address: testAddress, }, { FirstNames: "b", Address: testAddress, }}}, - decisions: actor.AttorneyDecisions{How: actor.JointlyAndSeverally}, + decisions: donordata.AttorneyDecisions{How: donordata.JointlyAndSeverally}, taskState: actor.TaskCompleted, }, "multiple incomplete with decisions": { - attorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + attorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ FirstNames: "a", }, { FirstNames: "b", Address: testAddress, }}}, - decisions: actor.AttorneyDecisions{How: actor.JointlyAndSeverally}, + decisions: donordata.AttorneyDecisions{How: donordata.JointlyAndSeverally}, taskState: actor.TaskInProgress, }, } @@ -95,10 +97,10 @@ func TestChooseAttorneysState(t *testing.T) { func TestChooseReplacementAttorneysState(t *testing.T) { testcases := map[string]struct { want form.YesNo - replacementAttorneys actor.Attorneys - attorneyDecisions actor.AttorneyDecisions - howReplacementsStepIn actor.ReplacementAttorneysStepIn - replacementAttorneyDecisions actor.AttorneyDecisions + replacementAttorneys donordata.Attorneys + attorneyDecisions donordata.AttorneyDecisions + howReplacementsStepIn donordata.ReplacementAttorneysStepIn + replacementAttorneyDecisions donordata.AttorneyDecisions taskState actor.TaskState }{ "empty": { @@ -114,7 +116,7 @@ func TestChooseReplacementAttorneysState(t *testing.T) { }, "single with email": { want: form.Yes, - replacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + replacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ FirstNames: "a", Email: "a", }}}, @@ -122,7 +124,7 @@ func TestChooseReplacementAttorneysState(t *testing.T) { }, "single with address": { want: form.Yes, - replacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + replacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ FirstNames: "a", Address: place.Address{Line1: "a"}, }}}, @@ -130,14 +132,14 @@ func TestChooseReplacementAttorneysState(t *testing.T) { }, "single incomplete": { want: form.Yes, - replacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + replacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ FirstNames: "a", }}}, taskState: actor.TaskInProgress, }, "multiple without decisions": { want: form.Yes, - replacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + replacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ FirstNames: "a", Address: testAddress, }, { @@ -148,211 +150,211 @@ func TestChooseReplacementAttorneysState(t *testing.T) { }, "multiple jointly and severally": { want: form.Yes, - replacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + replacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ FirstNames: "a", Address: testAddress, }, { FirstNames: "b", Address: testAddress, }}}, - replacementAttorneyDecisions: actor.AttorneyDecisions{How: actor.JointlyAndSeverally}, + replacementAttorneyDecisions: donordata.AttorneyDecisions{How: donordata.JointlyAndSeverally}, taskState: actor.TaskCompleted, }, "multiple jointly": { want: form.Yes, - replacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + replacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ FirstNames: "a", Address: testAddress, }, { FirstNames: "b", Address: testAddress, }}}, - replacementAttorneyDecisions: actor.AttorneyDecisions{How: actor.Jointly}, + replacementAttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, taskState: actor.TaskCompleted, }, "multiple jointly for some severally for others": { want: form.Yes, - replacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + replacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ FirstNames: "a", Address: testAddress, }, { FirstNames: "b", Address: testAddress, }}}, - replacementAttorneyDecisions: actor.AttorneyDecisions{How: actor.JointlyForSomeSeverallyForOthers}, + replacementAttorneyDecisions: donordata.AttorneyDecisions{How: donordata.JointlyForSomeSeverallyForOthers}, taskState: actor.TaskCompleted, }, "jointly and severally attorneys single": { want: form.Yes, - replacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + replacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ FirstNames: "a", Address: testAddress, }}}, - attorneyDecisions: actor.AttorneyDecisions{How: actor.JointlyAndSeverally}, + attorneyDecisions: donordata.AttorneyDecisions{How: donordata.JointlyAndSeverally}, taskState: actor.TaskInProgress, }, "jointly and severally attorneys single with step in": { want: form.Yes, - replacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + replacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ FirstNames: "a", Address: testAddress, }}}, - attorneyDecisions: actor.AttorneyDecisions{How: actor.JointlyAndSeverally}, - howReplacementsStepIn: actor.ReplacementAttorneysStepInWhenAllCanNoLongerAct, + attorneyDecisions: donordata.AttorneyDecisions{How: donordata.JointlyAndSeverally}, + howReplacementsStepIn: donordata.ReplacementAttorneysStepInWhenAllCanNoLongerAct, taskState: actor.TaskCompleted, }, "jointly attorneys single": { want: form.Yes, - replacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + replacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ FirstNames: "a", Address: testAddress, }}}, - attorneyDecisions: actor.AttorneyDecisions{How: actor.Jointly}, + attorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, taskState: actor.TaskCompleted, }, "jointly for some severally for others attorneys single": { want: form.Yes, - replacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + replacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ FirstNames: "a", Address: testAddress, }}}, - attorneyDecisions: actor.AttorneyDecisions{How: actor.JointlyForSomeSeverallyForOthers}, + attorneyDecisions: donordata.AttorneyDecisions{How: donordata.JointlyForSomeSeverallyForOthers}, taskState: actor.TaskCompleted, }, "jointly for some severally for others attorneys multiple": { want: form.Yes, - replacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + replacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ FirstNames: "a", Address: testAddress, }, { FirstNames: "b", Address: testAddress, }}}, - attorneyDecisions: actor.AttorneyDecisions{How: actor.JointlyForSomeSeverallyForOthers}, + attorneyDecisions: donordata.AttorneyDecisions{How: donordata.JointlyForSomeSeverallyForOthers}, taskState: actor.TaskCompleted, }, "jointly and severally attorneys multiple": { want: form.Yes, - replacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + replacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ FirstNames: "a", Address: testAddress, }, { FirstNames: "b", Address: testAddress, }}}, - attorneyDecisions: actor.AttorneyDecisions{How: actor.JointlyAndSeverally}, + attorneyDecisions: donordata.AttorneyDecisions{How: donordata.JointlyAndSeverally}, taskState: actor.TaskInProgress, }, "jointly and severally attorneys multiple with step in": { want: form.Yes, - replacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + replacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ FirstNames: "a", Address: testAddress, }, { FirstNames: "b", Address: testAddress, }}}, - attorneyDecisions: actor.AttorneyDecisions{How: actor.JointlyAndSeverally}, - howReplacementsStepIn: actor.ReplacementAttorneysStepInWhenOneCanNoLongerAct, + attorneyDecisions: donordata.AttorneyDecisions{How: donordata.JointlyAndSeverally}, + howReplacementsStepIn: donordata.ReplacementAttorneysStepInWhenOneCanNoLongerAct, taskState: actor.TaskCompleted, }, "jointly and severally attorneys multiple with step in when none can act": { want: form.Yes, - replacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + replacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ FirstNames: "a", Address: testAddress, }, { FirstNames: "b", Address: testAddress, }}}, - attorneyDecisions: actor.AttorneyDecisions{How: actor.JointlyAndSeverally}, - howReplacementsStepIn: actor.ReplacementAttorneysStepInWhenAllCanNoLongerAct, + attorneyDecisions: donordata.AttorneyDecisions{How: donordata.JointlyAndSeverally}, + howReplacementsStepIn: donordata.ReplacementAttorneysStepInWhenAllCanNoLongerAct, taskState: actor.TaskInProgress, }, "jointly and severally attorneys multiple with step in when none can act jointly": { want: form.Yes, - replacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + replacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ FirstNames: "a", Address: testAddress, }, { FirstNames: "b", Address: testAddress, }}}, - attorneyDecisions: actor.AttorneyDecisions{How: actor.JointlyAndSeverally}, - howReplacementsStepIn: actor.ReplacementAttorneysStepInWhenAllCanNoLongerAct, - replacementAttorneyDecisions: actor.AttorneyDecisions{How: actor.Jointly}, + attorneyDecisions: donordata.AttorneyDecisions{How: donordata.JointlyAndSeverally}, + howReplacementsStepIn: donordata.ReplacementAttorneysStepInWhenAllCanNoLongerAct, + replacementAttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, taskState: actor.TaskCompleted, }, "jointly and severally attorneys multiple with step in when none can act jointly for some severally for others": { want: form.Yes, - replacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + replacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ FirstNames: "a", Address: testAddress, }, { FirstNames: "b", Address: testAddress, }}}, - attorneyDecisions: actor.AttorneyDecisions{How: actor.JointlyAndSeverally}, - howReplacementsStepIn: actor.ReplacementAttorneysStepInWhenAllCanNoLongerAct, - replacementAttorneyDecisions: actor.AttorneyDecisions{How: actor.JointlyForSomeSeverallyForOthers}, + attorneyDecisions: donordata.AttorneyDecisions{How: donordata.JointlyAndSeverally}, + howReplacementsStepIn: donordata.ReplacementAttorneysStepInWhenAllCanNoLongerAct, + replacementAttorneyDecisions: donordata.AttorneyDecisions{How: donordata.JointlyForSomeSeverallyForOthers}, taskState: actor.TaskCompleted, }, "jointly attorneys multiple without decisions": { want: form.Yes, - replacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + replacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ FirstNames: "a", Address: testAddress, }, { FirstNames: "b", Address: testAddress, }}}, - attorneyDecisions: actor.AttorneyDecisions{How: actor.Jointly}, + attorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, taskState: actor.TaskInProgress, }, "jointly attorneys multiple jointly and severally": { want: form.Yes, - replacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + replacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ FirstNames: "a", Address: testAddress, }, { FirstNames: "b", Address: testAddress, }}}, - attorneyDecisions: actor.AttorneyDecisions{How: actor.Jointly}, - replacementAttorneyDecisions: actor.AttorneyDecisions{How: actor.JointlyAndSeverally}, + attorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, + replacementAttorneyDecisions: donordata.AttorneyDecisions{How: donordata.JointlyAndSeverally}, taskState: actor.TaskCompleted, }, "jointly attorneys multiple with jointly": { want: form.Yes, - replacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + replacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ FirstNames: "a", Address: testAddress, }, { FirstNames: "b", Address: testAddress, }}}, - attorneyDecisions: actor.AttorneyDecisions{How: actor.Jointly}, - replacementAttorneyDecisions: actor.AttorneyDecisions{How: actor.Jointly}, + attorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, + replacementAttorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, taskState: actor.TaskCompleted, }, "jointly attorneys multiple jointly for some severally for others": { want: form.Yes, - replacementAttorneys: actor.Attorneys{Attorneys: []actor.Attorney{{ + replacementAttorneys: donordata.Attorneys{Attorneys: []donordata.Attorney{{ FirstNames: "a", Address: testAddress, }, { FirstNames: "b", Address: testAddress, }}}, - attorneyDecisions: actor.AttorneyDecisions{How: actor.Jointly}, - replacementAttorneyDecisions: actor.AttorneyDecisions{How: actor.JointlyForSomeSeverallyForOthers}, + attorneyDecisions: donordata.AttorneyDecisions{How: donordata.Jointly}, + replacementAttorneyDecisions: donordata.AttorneyDecisions{How: donordata.JointlyForSomeSeverallyForOthers}, taskState: actor.TaskCompleted, }, } for name, tc := range testcases { t.Run(name, func(t *testing.T) { - assert.Equal(t, tc.taskState, ChooseReplacementAttorneysState(&actor.DonorProvidedDetails{ + assert.Equal(t, tc.taskState, ChooseReplacementAttorneysState(&donordata.DonorProvidedDetails{ WantReplacementAttorneys: tc.want, AttorneyDecisions: tc.attorneyDecisions, ReplacementAttorneys: tc.replacementAttorneys, @@ -365,15 +367,15 @@ func TestChooseReplacementAttorneysState(t *testing.T) { func TestLpaCost(t *testing.T) { testCases := map[string]struct { - donor *actor.DonorProvidedDetails + donor *donordata.DonorProvidedDetails expected int }{ "denied": { - donor: &actor.DonorProvidedDetails{FeeType: pay.HalfFee, Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskDenied}}, + donor: &donordata.DonorProvidedDetails{FeeType: pay.HalfFee, Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateDenied}}, expected: 8200, }, "half": { - donor: &actor.DonorProvidedDetails{FeeType: pay.HalfFee}, + donor: &donordata.DonorProvidedDetails{FeeType: pay.HalfFee}, expected: 4100, }, } @@ -387,23 +389,23 @@ func TestLpaCost(t *testing.T) { func TestFeeAmount(t *testing.T) { testCases := map[string]struct { - Donor *actor.DonorProvidedDetails + Donor *donordata.DonorProvidedDetails ExpectedCost pay.AmountPence }{ "not paid": { - Donor: &actor.DonorProvidedDetails{FeeType: pay.HalfFee}, + Donor: &donordata.DonorProvidedDetails{FeeType: pay.HalfFee}, ExpectedCost: pay.AmountPence(4100), }, "fully paid": { - Donor: &actor.DonorProvidedDetails{FeeType: pay.HalfFee, PaymentDetails: []actor.Payment{{Amount: 4100}}}, + Donor: &donordata.DonorProvidedDetails{FeeType: pay.HalfFee, PaymentDetails: []donordata.Payment{{Amount: 4100}}}, ExpectedCost: pay.AmountPence(0), }, "denied partially paid": { - Donor: &actor.DonorProvidedDetails{FeeType: pay.HalfFee, PaymentDetails: []actor.Payment{{Amount: 4100}}, Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskDenied}}, + Donor: &donordata.DonorProvidedDetails{FeeType: pay.HalfFee, PaymentDetails: []donordata.Payment{{Amount: 4100}}, Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateDenied}}, ExpectedCost: pay.AmountPence(4100), }, "denied fully paid": { - Donor: &actor.DonorProvidedDetails{FeeType: pay.HalfFee, PaymentDetails: []actor.Payment{{Amount: 4100}, {Amount: 4100}}, Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskDenied}}, + Donor: &donordata.DonorProvidedDetails{FeeType: pay.HalfFee, PaymentDetails: []donordata.Payment{{Amount: 4100}, {Amount: 4100}}, Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateDenied}}, ExpectedCost: pay.AmountPence(0), }, } @@ -508,17 +510,17 @@ func TestCertificateProviderSharesDetailsNames(t *testing.T) { for name, tc := range testcases { t.Run(name, func(t *testing.T) { - donor := &actor.DonorProvidedDetails{ - Donor: actor.Donor{LastName: tc.donor}, - CertificateProvider: actor.CertificateProvider{LastName: tc.certificateProvider, Address: place.Address{Line1: "x"}}, + donor := &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{LastName: tc.donor}, + CertificateProvider: donordata.CertificateProvider{LastName: tc.certificateProvider, Address: place.Address{Line1: "x"}}, } for _, a := range tc.attorneys { - donor.Attorneys.Attorneys = append(donor.Attorneys.Attorneys, actor.Attorney{LastName: a}) + donor.Attorneys.Attorneys = append(donor.Attorneys.Attorneys, donordata.Attorney{LastName: a}) } for _, a := range tc.replacementAttorneys { - donor.ReplacementAttorneys.Attorneys = append(donor.ReplacementAttorneys.Attorneys, actor.Attorney{LastName: a}) + donor.ReplacementAttorneys.Attorneys = append(donor.ReplacementAttorneys.Attorneys, donordata.Attorney{LastName: a}) } assert.Equal(t, tc.expected, donor.CertificateProviderSharesDetails()) @@ -562,17 +564,17 @@ func TestCertificateProviderSharesDetailsAddresses(t *testing.T) { for name, tc := range testcases { t.Run(name, func(t *testing.T) { - donor := &actor.DonorProvidedDetails{ - Donor: actor.Donor{Address: tc.donor}, - CertificateProvider: actor.CertificateProvider{LastName: "x", Address: tc.certificateProvider}, + donor := &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{Address: tc.donor}, + CertificateProvider: donordata.CertificateProvider{LastName: "x", Address: tc.certificateProvider}, } for _, attorney := range tc.attorneys { - donor.Attorneys.Attorneys = append(donor.Attorneys.Attorneys, actor.Attorney{Address: attorney}) + donor.Attorneys.Attorneys = append(donor.Attorneys.Attorneys, donordata.Attorney{Address: attorney}) } for _, attorney := range tc.replacementAttorneys { - donor.ReplacementAttorneys.Attorneys = append(donor.ReplacementAttorneys.Attorneys, actor.Attorney{Address: attorney}) + donor.ReplacementAttorneys.Attorneys = append(donor.ReplacementAttorneys.Attorneys, donordata.Attorney{Address: attorney}) } assert.Equal(t, tc.expected, donor.CertificateProviderSharesDetails()) diff --git a/internal/page/fixtures/attorney.go b/internal/page/fixtures/attorney.go index ed27333432..c56ce55941 100644 --- a/internal/page/fixtures/attorney.go +++ b/internal/page/fixtures/attorney.go @@ -14,6 +14,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "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" "github.com/ministryofjustice/opg-modernising-lpa/internal/event" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" @@ -26,9 +27,9 @@ import ( ) type DonorStore interface { - Create(ctx context.Context) (*actor.DonorProvidedDetails, error) + Create(ctx context.Context) (*donordata.DonorProvidedDetails, error) Link(ctx context.Context, shareCode actor.ShareCodeData, donorEmail string) error - Put(ctx context.Context, donorProvidedDetails *actor.DonorProvidedDetails) error + Put(ctx context.Context, donorProvidedDetails *donordata.DonorProvidedDetails) error } type CertificateProviderStore interface { @@ -148,12 +149,12 @@ func Attorney( donorDetails.Donor = makeDonor(testEmail) if lpaType == "personal-welfare" && !isTrustCorporation { - donorDetails.Type = actor.LpaTypePersonalWelfare - donorDetails.WhenCanTheLpaBeUsed = actor.CanBeUsedWhenCapacityLost - donorDetails.LifeSustainingTreatmentOption = actor.LifeSustainingTreatmentOptionA + donorDetails.Type = donordata.LpaTypePersonalWelfare + donorDetails.WhenCanTheLpaBeUsed = donordata.CanBeUsedWhenCapacityLost + donorDetails.LifeSustainingTreatmentOption = donordata.LifeSustainingTreatmentOptionA } else { - donorDetails.Type = actor.LpaTypePropertyAndAffairs - donorDetails.WhenCanTheLpaBeUsed = actor.CanBeUsedWhenHasCapacity + donorDetails.Type = donordata.LpaTypePropertyAndAffairs + donorDetails.WhenCanTheLpaBeUsed = donordata.CanBeUsedWhenHasCapacity } if useRealUID { @@ -175,12 +176,12 @@ func Attorney( donorDetails.CertificateProvider = makeCertificateProvider() - donorDetails.Attorneys = actor.Attorneys{ - Attorneys: []actor.Attorney{makeAttorney(attorneyNames[0])}, + donorDetails.Attorneys = donordata.Attorneys{ + Attorneys: []donordata.Attorney{makeAttorney(attorneyNames[0])}, TrustCorporation: makeTrustCorporation("First Choice Trust Corporation Ltd."), } - donorDetails.ReplacementAttorneys = actor.Attorneys{ - Attorneys: []actor.Attorney{makeAttorney(replacementAttorneyNames[0])}, + donorDetails.ReplacementAttorneys = donordata.Attorneys{ + Attorneys: []donordata.Attorney{makeAttorney(replacementAttorneyNames[0])}, TrustCorporation: makeTrustCorporation("Second Choice Trust Corporation Ltd."), } @@ -207,9 +208,9 @@ func Attorney( attorneyUID = donorDetails.Attorneys.Attorneys[0].UID } - donorDetails.AttorneyDecisions = actor.AttorneyDecisions{How: actor.JointlyAndSeverally} - donorDetails.ReplacementAttorneyDecisions = actor.AttorneyDecisions{How: actor.JointlyAndSeverally} - donorDetails.HowShouldReplacementAttorneysStepIn = actor.ReplacementAttorneysStepInWhenAllCanNoLongerAct + donorDetails.AttorneyDecisions = donordata.AttorneyDecisions{How: donordata.JointlyAndSeverally} + donorDetails.ReplacementAttorneyDecisions = donordata.AttorneyDecisions{How: donordata.JointlyAndSeverally} + donorDetails.HowShouldReplacementAttorneysStepIn = donordata.ReplacementAttorneysStepInWhenAllCanNoLongerAct certificateProvider, err := createCertificateProvider(certificateProviderCtx, shareCodeStore, certificateProviderStore, donorDetails.CertificateProvider.UID, donorDetails.SK, donorDetails.CertificateProvider.Email) if err != nil { @@ -265,7 +266,7 @@ func Attorney( var signings []*attorneydata.Provided if progress >= slices.Index(progressValues, "signedByAllAttorneys") { - for isReplacement, list := range map[bool]actor.Attorneys{false: donorDetails.Attorneys, true: donorDetails.ReplacementAttorneys} { + for isReplacement, list := range map[bool]donordata.Attorneys{false: donorDetails.Attorneys, true: donorDetails.ReplacementAttorneys} { for _, a := range list.Attorneys { ctx := page.ContextWithSessionData(r.Context(), &appcontext.SessionData{SessionID: random.String(16), LpaID: donorDetails.LpaID}) diff --git a/internal/page/fixtures/certificate_provider.go b/internal/page/fixtures/certificate_provider.go index 1855ce3b11..d4e9c719f2 100644 --- a/internal/page/fixtures/certificate_provider.go +++ b/internal/page/fixtures/certificate_provider.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/date" + "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/event" "github.com/ministryofjustice/opg-modernising-lpa/internal/identity" @@ -19,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/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/uid" ) @@ -82,11 +84,11 @@ func CertificateProvider( return err } - var donorDetails *actor.DonorProvidedDetails + var donorDetails *donordata.DonorProvidedDetails if donorChannel == "paper" { lpaID := random.UuidString() - donorDetails = &actor.DonorProvidedDetails{ + donorDetails = &donordata.DonorProvidedDetails{ PK: dynamo.LpaKey(lpaID), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("PAPER")), LpaID: lpaID, @@ -139,13 +141,13 @@ func CertificateProvider( donorDetails.Donor = makeDonor(donorEmail) - donorDetails.Type = actor.LpaTypePropertyAndAffairs + donorDetails.Type = donordata.LpaTypePropertyAndAffairs if lpaType == "personal-welfare" { - donorDetails.Type = actor.LpaTypePersonalWelfare - donorDetails.WhenCanTheLpaBeUsed = actor.CanBeUsedWhenCapacityLost - donorDetails.LifeSustainingTreatmentOption = actor.LifeSustainingTreatmentOptionA + donorDetails.Type = donordata.LpaTypePersonalWelfare + donorDetails.WhenCanTheLpaBeUsed = donordata.CanBeUsedWhenCapacityLost + donorDetails.LifeSustainingTreatmentOption = donordata.LifeSustainingTreatmentOptionA } else { - donorDetails.WhenCanTheLpaBeUsed = actor.CanBeUsedWhenHasCapacity + donorDetails.WhenCanTheLpaBeUsed = donordata.CanBeUsedWhenHasCapacity } if useRealUID { @@ -165,11 +167,11 @@ func CertificateProvider( donorDetails.LpaUID = makeUID() } - donorDetails.Attorneys = actor.Attorneys{ - Attorneys: []actor.Attorney{makeAttorney(attorneyNames[0]), makeAttorney(attorneyNames[1])}, + donorDetails.Attorneys = donordata.Attorneys{ + Attorneys: []donordata.Attorney{makeAttorney(attorneyNames[0]), makeAttorney(attorneyNames[1])}, } - donorDetails.AttorneyDecisions = actor.AttorneyDecisions{How: actor.JointlyAndSeverally} + donorDetails.AttorneyDecisions = donordata.AttorneyDecisions{How: donordata.JointlyAndSeverally} donorDetails.CertificateProvider = makeCertificateProvider() if email != "" { @@ -177,7 +179,7 @@ func CertificateProvider( } if asProfessionalCertificateProvider { - donorDetails.CertificateProvider.Relationship = actor.Professionally + donorDetails.CertificateProvider.Relationship = donordata.Professionally } certificateProvider, err := createCertificateProvider(certificateProviderCtx, shareCodeStore, certificateProviderStore, donorDetails.CertificateProvider.UID, donorDetails.SK, donorDetails.CertificateProvider.Email) @@ -186,11 +188,11 @@ func CertificateProvider( } if progress >= slices.Index(progressValues, "paid") { - donorDetails.PaymentDetails = append(donorDetails.PaymentDetails, actor.Payment{ + donorDetails.PaymentDetails = append(donorDetails.PaymentDetails, donordata.Payment{ PaymentReference: random.String(12), PaymentId: random.String(12), }) - donorDetails.Tasks.PayForLpa = actor.PaymentTaskCompleted + donorDetails.Tasks.PayForLpa = task.PaymentStateCompleted } if progress >= slices.Index(progressValues, "signedByDonor") { diff --git a/internal/page/fixtures/dashboard.go b/internal/page/fixtures/dashboard.go index 9df0cf4be5..6aeb3cc180 100644 --- a/internal/page/fixtures/dashboard.go +++ b/internal/page/fixtures/dashboard.go @@ -5,8 +5,8 @@ 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/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/random" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" @@ -54,10 +54,10 @@ func Dashboard( donor.LpaUID = makeUID() donor.Donor = makeDonor(testEmail) - donor.Type = actor.LpaTypePropertyAndAffairs + donor.Type = donordata.LpaTypePropertyAndAffairs - donor.Attorneys = actor.Attorneys{ - Attorneys: []actor.Attorney{makeAttorney(attorneyNames[0])}, + donor.Attorneys = donordata.Attorneys{ + Attorneys: []donordata.Attorney{makeAttorney(attorneyNames[0])}, } if err := donorStore.Put(donorCtx, donor); err != nil { @@ -91,8 +91,8 @@ func Dashboard( return err } donor.Donor = makeDonor(testEmail) - donor.Attorneys = actor.Attorneys{ - Attorneys: []actor.Attorney{makeAttorney(attorneyNames[0])}, + donor.Attorneys = donordata.Attorneys{ + Attorneys: []donordata.Attorney{makeAttorney(attorneyNames[0])}, } donor.LpaUID = makeUID() diff --git a/internal/page/fixtures/donor.go b/internal/page/fixtures/donor.go index f79669e58a..5c9e3a75eb 100644 --- a/internal/page/fixtures/donor.go +++ b/internal/page/fixtures/donor.go @@ -14,6 +14,7 @@ import ( "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" + "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/event" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/identity" @@ -36,7 +37,7 @@ type DynamoClient interface { type DocumentStore interface { GetAll(context.Context) (page.Documents, error) Put(context.Context, page.Document) error - Create(ctx context.Context, donor *actor.DonorProvidedDetails, filename string, data []byte) (page.Document, error) + Create(ctx context.Context, donor *donordata.DonorProvidedDetails, filename string, data []byte) (page.Document, error) } var progressValues = []string{ @@ -171,7 +172,7 @@ func Donor( func updateLPAProgress( data FixtureData, - donorDetails *actor.DonorProvidedDetails, + donorDetails *donordata.DonorProvidedDetails, donorSessionID string, r *http.Request, certificateProviderStore CertificateProviderStore, @@ -179,17 +180,17 @@ func updateLPAProgress( documentStore DocumentStore, eventClient *event.Client, shareCodeStore ShareCodeStore, -) (*actor.DonorProvidedDetails, []func(context.Context, *lpastore.Client, *lpastore.Lpa) error, error) { +) (*donordata.DonorProvidedDetails, []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") { donorDetails.Donor = makeDonor(data.DonorEmail) - donorDetails.Type = actor.LpaTypePropertyAndAffairs + donorDetails.Type = donordata.LpaTypePropertyAndAffairs if data.LpaType == "personal-welfare" { - donorDetails.Type = actor.LpaTypePersonalWelfare - donorDetails.WhenCanTheLpaBeUsed = actor.CanBeUsedWhenCapacityLost + donorDetails.Type = donordata.LpaTypePersonalWelfare + donorDetails.WhenCanTheLpaBeUsed = donordata.CanBeUsedWhenCapacityLost } if data.UseRealID { @@ -210,15 +211,15 @@ func updateLPAProgress( } if data.Donor == "cannot-sign" { - donorDetails.Donor.ThinksCanSign = actor.No + donorDetails.Donor.ThinksCanSign = donordata.No donorDetails.Donor.CanSign = form.No - donorDetails.AuthorisedSignatory = actor.AuthorisedSignatory{ + donorDetails.AuthorisedSignatory = donordata.AuthorisedSignatory{ FirstNames: "Allie", LastName: "Adams", } - donorDetails.IndependentWitness = actor.IndependentWitness{ + donorDetails.IndependentWitness = donordata.IndependentWitness{ FirstNames: "Indie", LastName: "Irwin", } @@ -233,8 +234,8 @@ func updateLPAProgress( json.Unmarshal([]byte(`"urn:opg:poas:makeregister:users:without-address"`), &withoutAddressUID) if data.Progress >= slices.Index(progressValues, "chooseYourAttorneys") { - donorDetails.Attorneys.Attorneys = []actor.Attorney{makeAttorney(attorneyNames[0]), makeAttorney(attorneyNames[1])} - donorDetails.AttorneyDecisions.How = actor.JointlyAndSeverally + donorDetails.Attorneys.Attorneys = []donordata.Attorney{makeAttorney(attorneyNames[0]), makeAttorney(attorneyNames[1])} + donorDetails.AttorneyDecisions.How = donordata.JointlyAndSeverally switch data.Attorneys { case "without-address": @@ -247,11 +248,11 @@ func updateLPAProgress( donorDetails.Attorneys.TrustCorporation = makeTrustCorporation("First Choice Trust Corporation Ltd.") case "single": donorDetails.Attorneys.Attorneys = donorDetails.Attorneys.Attorneys[:1] - donorDetails.AttorneyDecisions = actor.AttorneyDecisions{} + donorDetails.AttorneyDecisions = donordata.AttorneyDecisions{} case "jointly": - donorDetails.AttorneyDecisions.How = actor.Jointly + donorDetails.AttorneyDecisions.How = donordata.Jointly case "jointly-for-some-severally-for-others": - donorDetails.AttorneyDecisions.How = actor.JointlyForSomeSeverallyForOthers + donorDetails.AttorneyDecisions.How = donordata.JointlyForSomeSeverallyForOthers donorDetails.AttorneyDecisions.Details = "do this and that" } @@ -259,8 +260,8 @@ func updateLPAProgress( } if data.Progress >= slices.Index(progressValues, "chooseYourReplacementAttorneys") { - donorDetails.ReplacementAttorneys.Attorneys = []actor.Attorney{makeAttorney(replacementAttorneyNames[0]), makeAttorney(replacementAttorneyNames[1])} - donorDetails.HowShouldReplacementAttorneysStepIn = actor.ReplacementAttorneysStepInWhenOneCanNoLongerAct + donorDetails.ReplacementAttorneys.Attorneys = []donordata.Attorney{makeAttorney(replacementAttorneyNames[0]), makeAttorney(replacementAttorneyNames[1])} + donorDetails.HowShouldReplacementAttorneysStepIn = donordata.ReplacementAttorneysStepInWhenOneCanNoLongerAct switch data.ReplacementAttorneys { case "without-address": @@ -273,18 +274,18 @@ func updateLPAProgress( donorDetails.ReplacementAttorneys.TrustCorporation = makeTrustCorporation("First Choice Trust Corporation Ltd.") case "single": donorDetails.ReplacementAttorneys.Attorneys = donorDetails.ReplacementAttorneys.Attorneys[:1] - donorDetails.HowShouldReplacementAttorneysStepIn = actor.ReplacementAttorneysStepIn(0) + donorDetails.HowShouldReplacementAttorneysStepIn = donordata.ReplacementAttorneysStepIn(0) } donorDetails.Tasks.ChooseReplacementAttorneys = actor.TaskCompleted } if data.Progress >= slices.Index(progressValues, "chooseWhenTheLpaCanBeUsed") { - if donorDetails.Type == actor.LpaTypePersonalWelfare { - donorDetails.LifeSustainingTreatmentOption = actor.LifeSustainingTreatmentOptionA + if donorDetails.Type == donordata.LpaTypePersonalWelfare { + donorDetails.LifeSustainingTreatmentOption = donordata.LifeSustainingTreatmentOptionA donorDetails.Tasks.LifeSustainingTreatment = actor.TaskCompleted } else { - donorDetails.WhenCanTheLpaBeUsed = actor.CanBeUsedWhenHasCapacity + donorDetails.WhenCanTheLpaBeUsed = donordata.CanBeUsedWhenHasCapacity donorDetails.Tasks.WhenCanTheLpaBeUsed = actor.TaskCompleted } } @@ -297,7 +298,7 @@ func updateLPAProgress( if data.Progress >= slices.Index(progressValues, "chooseYourCertificateProvider") { donorDetails.CertificateProvider = makeCertificateProvider() if data.CertificateProvider == "paper" { - donorDetails.CertificateProvider.CarryOutBy = actor.ChannelPaper + donorDetails.CertificateProvider.CarryOutBy = donordata.ChannelPaper } if data.CertificateProviderEmail != "" { @@ -313,7 +314,7 @@ func updateLPAProgress( if data.Progress >= slices.Index(progressValues, "peopleToNotifyAboutYourLpa") { donorDetails.DoYouWantToNotifyPeople = form.Yes - donorDetails.PeopleToNotify = []actor.PersonToNotify{makePersonToNotify(peopleToNotifyNames[0]), makePersonToNotify(peopleToNotifyNames[1])} + donorDetails.PeopleToNotify = []donordata.PersonToNotify{makePersonToNotify(peopleToNotifyNames[0]), makePersonToNotify(peopleToNotifyNames[1])} switch data.PeopleToNotify { case "without-address": donorDetails.PeopleToNotify[0].UID = withoutAddressUID @@ -389,12 +390,12 @@ func updateLPAProgress( donorDetails.FeeType = pay.FullFee } - donorDetails.PaymentDetails = append(donorDetails.PaymentDetails, actor.Payment{ + donorDetails.PaymentDetails = append(donorDetails.PaymentDetails, donordata.Payment{ PaymentReference: random.String(12), PaymentId: random.String(12), }) - donorDetails.Tasks.PayForLpa = actor.PaymentTaskCompleted + donorDetails.Tasks.PayForLpa = task.PaymentStateCompleted if data.PaymentTaskProgress != "" { taskState, err := task.ParsePaymentState(data.PaymentTaskProgress) @@ -470,7 +471,7 @@ func updateLPAProgress( } if data.Progress >= slices.Index(progressValues, "signedByAttorneys") { - for isReplacement, list := range map[bool]actor.Attorneys{false: donorDetails.Attorneys, true: donorDetails.ReplacementAttorneys} { + for isReplacement, list := range map[bool]donordata.Attorneys{false: donorDetails.Attorneys, true: donorDetails.ReplacementAttorneys} { for _, a := range list.Attorneys { ctx := page.ContextWithSessionData(r.Context(), &appcontext.SessionData{SessionID: random.String(16), LpaID: donorDetails.LpaID}) diff --git a/internal/page/fixtures/fixtures.go b/internal/page/fixtures/fixtures.go index 597d9b21fa..5f0b877738 100644 --- a/internal/page/fixtures/fixtures.go +++ b/internal/page/fixtures/fixtures.go @@ -11,6 +11,7 @@ import ( "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/date" + "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" @@ -85,8 +86,8 @@ var ( } ) -func makeAttorney(name Name) actor.Attorney { - return actor.Attorney{ +func makeAttorney(name Name) donordata.Attorney { + return donordata.Attorney{ UID: actoruid.New(), FirstNames: name.Firstnames, LastName: name.Lastname, @@ -103,8 +104,8 @@ func makeAttorney(name Name) actor.Attorney { } } -func makeTrustCorporation(name string) actor.TrustCorporation { - return actor.TrustCorporation{ +func makeTrustCorporation(name string) donordata.TrustCorporation { + return donordata.TrustCorporation{ UID: actoruid.New(), Name: name, CompanyNumber: "555555555", @@ -120,8 +121,8 @@ func makeTrustCorporation(name string) actor.TrustCorporation { } } -func makeDonor(email string) actor.Donor { - return actor.Donor{ +func makeDonor(email string) donordata.Donor { + return donordata.Donor{ UID: actoruid.New(), FirstNames: "Sam", LastName: "Smith", @@ -135,23 +136,23 @@ func makeDonor(email string) actor.Donor { }, Email: email, DateOfBirth: date.New("2000", "1", "2"), - ThinksCanSign: actor.Yes, + ThinksCanSign: donordata.Yes, CanSign: form.Yes, ContactLanguagePreference: localize.En, LpaLanguagePreference: localize.En, } } -func makeCertificateProvider() actor.CertificateProvider { - return actor.CertificateProvider{ +func makeCertificateProvider() donordata.CertificateProvider { + return donordata.CertificateProvider{ UID: actoruid.New(), FirstNames: "Charlie", LastName: "Cooper", Email: testEmail, Mobile: testMobile, - Relationship: actor.Personally, - RelationshipLength: actor.GreaterThanEqualToTwoYears, - CarryOutBy: actor.ChannelOnline, + Relationship: donordata.Personally, + RelationshipLength: donordata.GreaterThanEqualToTwoYears, + CarryOutBy: donordata.ChannelOnline, Address: place.Address{ Line1: "5 RICHMOND PLACE", Line2: "KINGS HEATH", @@ -163,8 +164,8 @@ func makeCertificateProvider() actor.CertificateProvider { } } -func makePersonToNotify(name Name) actor.PersonToNotify { - return actor.PersonToNotify{ +func makePersonToNotify(name Name) donordata.PersonToNotify { + return donordata.PersonToNotify{ UID: actoruid.New(), FirstNames: name.Firstnames, LastName: name.Lastname, @@ -179,8 +180,8 @@ func makePersonToNotify(name Name) actor.PersonToNotify { } } -func makeCorrespondent(name Name) actor.Correspondent { - return actor.Correspondent{ +func makeCorrespondent(name Name) donordata.Correspondent { + return donordata.Correspondent{ FirstNames: name.Firstnames, LastName: name.Lastname, Address: place.Address{ @@ -252,8 +253,8 @@ func createCertificateProvider(ctx context.Context, shareCodeStore ShareCodeStor return certificateProviderStore.Create(ctx, shareCodeData, email) } -func makeVoucher(name Name) actor.Voucher { - return actor.Voucher{ +func makeVoucher(name Name) donordata.Voucher { + return donordata.Voucher{ FirstNames: name.Firstnames, LastName: name.Lastname, Email: fmt.Sprintf("%s.%s@example.org", name.Firstnames, name.Lastname), diff --git a/internal/page/fixtures/supporter.go b/internal/page/fixtures/supporter.go index 4c6ebdf408..6f29797e37 100644 --- a/internal/page/fixtures/supporter.go +++ b/internal/page/fixtures/supporter.go @@ -12,6 +12,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/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/event" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" @@ -23,7 +24,7 @@ import ( type OrganisationStore interface { Create(context.Context, *actor.Member, string) (*actor.Organisation, error) - CreateLPA(context.Context) (*actor.DonorProvidedDetails, error) + CreateLPA(context.Context) (*donordata.DonorProvidedDetails, error) } type MemberStore interface { @@ -109,10 +110,10 @@ func Supporter( donor.LpaUID = makeUID() donor.Donor = makeDonor(testEmail) - donor.Type = actor.LpaTypePropertyAndAffairs + donor.Type = donordata.LpaTypePropertyAndAffairs donor.CertificateProvider = makeCertificateProvider() - donor.Attorneys = actor.Attorneys{ - Attorneys: []actor.Attorney{makeAttorney(attorneyNames[0])}, + donor.Attorneys = donordata.Attorneys{ + Attorneys: []donordata.Attorney{makeAttorney(attorneyNames[0])}, } donor.Tasks.YourDetails = actor.TaskCompleted donor.Tasks.ChooseAttorneys = actor.TaskCompleted @@ -162,10 +163,10 @@ func Supporter( donor.LpaUID = makeUID() donor.Donor = makeDonor(testEmail) - donor.Type = actor.LpaTypePropertyAndAffairs + donor.Type = donordata.LpaTypePropertyAndAffairs donor.CertificateProvider = makeCertificateProvider() - donor.Attorneys = actor.Attorneys{ - Attorneys: []actor.Attorney{makeAttorney(attorneyNames[0])}, + donor.Attorneys = donordata.Attorneys{ + Attorneys: []donordata.Attorney{makeAttorney(attorneyNames[0])}, } var fns []func(context.Context, *lpastore.Client, *lpastore.Lpa) error diff --git a/internal/page/mock_AttorneyStore_test.go b/internal/page/mock_AttorneyStore_test.go index 357a006033..2247c96973 100644 --- a/internal/page/mock_AttorneyStore_test.go +++ b/internal/page/mock_AttorneyStore_test.go @@ -1,6 +1,5 @@ // Code generated by mockery v2.20.0. DO NOT EDIT. - package page import ( diff --git a/internal/page/mock_shareCodeSender_test.go b/internal/page/mock_shareCodeSender_test.go index 7315ced405..19b3bea33b 100644 --- a/internal/page/mock_shareCodeSender_test.go +++ b/internal/page/mock_shareCodeSender_test.go @@ -5,8 +5,7 @@ package page import ( context "context" - actor "github.com/ministryofjustice/opg-modernising-lpa/internal/actor" - + "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" mock "github.com/stretchr/testify/mock" ) @@ -16,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 *actor.DonorProvidedDetails) error { +func (_m *mockShareCodeSender) SendAttorneys(ctx context.Context, appData AppData, donor *donordata.DonorProvidedDetails) error { ret := _m.Called(ctx, appData, donor) var r0 error - if rf, ok := ret.Get(0).(func(context.Context, AppData, *actor.DonorProvidedDetails) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, AppData, *donordata.DonorProvidedDetails) error); ok { r0 = rf(ctx, appData, donor) } else { r0 = ret.Error(0) @@ -30,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 *actor.DonorProvidedDetails) error { +func (_m *mockShareCodeSender) SendCertificateProvider(ctx context.Context, appData AppData, identity bool, donor *donordata.DonorProvidedDetails) error { ret := _m.Called(ctx, appData, identity, donor) var r0 error - if rf, ok := ret.Get(0).(func(context.Context, AppData, bool, *actor.DonorProvidedDetails) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, AppData, bool, *donordata.DonorProvidedDetails) 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 6a4d855091..e95bc5ee4f 100644 --- a/internal/page/paths.go +++ b/internal/page/paths.go @@ -5,9 +5,9 @@ import ( "net/url" "strings" - "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" ) type Path string @@ -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 *actor.DonorProvidedDetails) error { +func (p LpaPath) Redirect(w http.ResponseWriter, r *http.Request, appData AppData, donor *donordata.DonorProvidedDetails) 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 *actor.DonorProvidedDetails, query url.Values) error { +func (p LpaPath) RedirectQuery(w http.ResponseWriter, r *http.Request, appData AppData, donor *donordata.DonorProvidedDetails, 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 *actor.DonorProvidedDetails) bool { +func (p LpaPath) canVisit(donor *donordata.DonorProvidedDetails) 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 *actor.DonorProvidedDetails, url string) bool { +func DonorCanGoTo(donor *donordata.DonorProvidedDetails, 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 3aec823288..0124090c76 100644 --- a/internal/page/paths_test.go +++ b/internal/page/paths_test.go @@ -9,9 +9,11 @@ import ( "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" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/identity" "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" ) @@ -60,18 +62,18 @@ func TestLpaPathFormat(t *testing.T) { func TestLpaPathRedirect(t *testing.T) { testCases := map[string]struct { url string - donor *actor.DonorProvidedDetails + donor *donordata.DonorProvidedDetails expected string }{ "redirect": { url: "/", - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ LpaID: "lpa-id", - Donor: actor.Donor{ + Donor: donordata.Donor{ CanSign: form.Yes, }, - Type: actor.LpaTypePersonalWelfare, - Tasks: actor.DonorTasks{ + Type: donordata.LpaTypePersonalWelfare, + Tasks: donordata.DonorTasks{ YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, ChooseReplacementAttorneys: actor.TaskCompleted, @@ -80,14 +82,14 @@ func TestLpaPathRedirect(t *testing.T) { CertificateProvider: actor.TaskCompleted, PeopleToNotify: actor.TaskCompleted, CheckYourLpa: actor.TaskCompleted, - PayForLpa: actor.PaymentTaskCompleted, + PayForLpa: task.PaymentStateCompleted, }, }, expected: Paths.HowToConfirmYourIdentityAndSign.Format("lpa-id"), }, "redirect with from": { url: "/?from=" + Paths.Restrictions.Format("lpa-id"), - donor: &actor.DonorProvidedDetails{LpaID: "lpa-id", Tasks: actor.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted}}, + donor: &donordata.DonorProvidedDetails{LpaID: "lpa-id", Tasks: donordata.DonorTasks{YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted}}, expected: Paths.Restrictions.Format("lpa-id"), }, } @@ -111,7 +113,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}, &actor.DonorProvidedDetails{LpaID: "lpa-id"}, url.Values{"q": {"1"}}) + err := Paths.TaskList.RedirectQuery(w, r, AppData{Lang: localize.En}, &donordata.DonorProvidedDetails{LpaID: "lpa-id"}, url.Values{"q": {"1"}}) resp := w.Result() assert.Nil(t, err) @@ -244,24 +246,24 @@ func TestSupporterLpaPathIsManageOrganisation(t *testing.T) { func TestDonorCanGoTo(t *testing.T) { testCases := map[string]struct { - donor *actor.DonorProvidedDetails + donor *donordata.DonorProvidedDetails url string expected bool }{ "empty path": { - donor: &actor.DonorProvidedDetails{}, + donor: &donordata.DonorProvidedDetails{}, url: "", expected: false, }, "unexpected path": { - donor: &actor.DonorProvidedDetails{}, + donor: &donordata.DonorProvidedDetails{}, url: "/whatever", expected: true, }, "check your lpa when unsure if can sign": { - donor: &actor.DonorProvidedDetails{ - Type: actor.LpaTypePersonalWelfare, - Tasks: actor.DonorTasks{ + donor: &donordata.DonorProvidedDetails{ + Type: donordata.LpaTypePersonalWelfare, + Tasks: donordata.DonorTasks{ YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, ChooseReplacementAttorneys: actor.TaskCompleted, @@ -276,10 +278,10 @@ func TestDonorCanGoTo(t *testing.T) { expected: false, }, "check your lpa when can sign": { - donor: &actor.DonorProvidedDetails{ - Donor: actor.Donor{CanSign: form.Yes}, - Type: actor.LpaTypePersonalWelfare, - Tasks: actor.DonorTasks{ + donor: &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{CanSign: form.Yes}, + Type: donordata.LpaTypePersonalWelfare, + Tasks: donordata.DonorTasks{ YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, ChooseReplacementAttorneys: actor.TaskCompleted, @@ -294,17 +296,17 @@ func TestDonorCanGoTo(t *testing.T) { expected: true, }, "about payment without task": { - donor: &actor.DonorProvidedDetails{LpaID: "123"}, + donor: &donordata.DonorProvidedDetails{LpaID: "123"}, url: Paths.AboutPayment.Format("123"), expected: false, }, "about payment with tasks": { - donor: &actor.DonorProvidedDetails{ - Donor: actor.Donor{ + donor: &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{ CanSign: form.Yes, }, - Type: actor.LpaTypePropertyAndAffairs, - Tasks: actor.DonorTasks{ + Type: donordata.LpaTypePropertyAndAffairs, + Tasks: donordata.DonorTasks{ YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, ChooseReplacementAttorneys: actor.TaskCompleted, @@ -319,17 +321,17 @@ func TestDonorCanGoTo(t *testing.T) { expected: true, }, "identity without task": { - donor: &actor.DonorProvidedDetails{}, + donor: &donordata.DonorProvidedDetails{}, url: Paths.IdentityWithOneLogin.Format("123"), expected: false, }, "identity with tasks": { - donor: &actor.DonorProvidedDetails{ - Donor: actor.Donor{ + donor: &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{ CanSign: form.Yes, }, - Type: actor.LpaTypePersonalWelfare, - Tasks: actor.DonorTasks{ + Type: donordata.LpaTypePersonalWelfare, + Tasks: donordata.DonorTasks{ YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, ChooseReplacementAttorneys: actor.TaskCompleted, @@ -338,25 +340,25 @@ func TestDonorCanGoTo(t *testing.T) { CertificateProvider: actor.TaskCompleted, PeopleToNotify: actor.TaskCompleted, CheckYourLpa: actor.TaskCompleted, - PayForLpa: actor.PaymentTaskCompleted, + PayForLpa: task.PaymentStateCompleted, }, }, url: Paths.IdentityWithOneLogin.Format("123"), expected: true, }, "read lpa without task": { - donor: &actor.DonorProvidedDetails{}, + donor: &donordata.DonorProvidedDetails{}, url: Paths.ReadYourLpa.Format("123"), expected: false, }, "read lpa with tasks": { - donor: &actor.DonorProvidedDetails{ - Donor: actor.Donor{ + donor: &donordata.DonorProvidedDetails{ + Donor: donordata.Donor{ CanSign: form.Yes, }, DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, - Type: actor.LpaTypePersonalWelfare, - Tasks: actor.DonorTasks{ + Type: donordata.LpaTypePersonalWelfare, + Tasks: donordata.DonorTasks{ YourDetails: actor.TaskCompleted, ChooseAttorneys: actor.TaskCompleted, ChooseReplacementAttorneys: actor.TaskCompleted, @@ -365,19 +367,19 @@ func TestDonorCanGoTo(t *testing.T) { CertificateProvider: actor.TaskCompleted, PeopleToNotify: actor.TaskCompleted, CheckYourLpa: actor.TaskCompleted, - PayForLpa: actor.PaymentTaskCompleted, + PayForLpa: task.PaymentStateCompleted, }, }, url: Paths.ReadYourLpa.Format("123"), expected: true, }, "your name when identity not set": { - donor: &actor.DonorProvidedDetails{}, + donor: &donordata.DonorProvidedDetails{}, url: Paths.YourName.Format("123"), expected: true, }, "your name when identity set": { - donor: &actor.DonorProvidedDetails{ + donor: &donordata.DonorProvidedDetails{ DonorIdentityUserData: identity.UserData{Status: identity.StatusConfirmed}, }, url: Paths.YourName.Format("123"), diff --git a/internal/page/share_code.go b/internal/page/share_code.go index 70640b979c..6239f7e652 100644 --- a/internal/page/share_code.go +++ b/internal/page/share_code.go @@ -6,6 +6,7 @@ import ( "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/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/event" "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" @@ -40,7 +41,7 @@ type CertificateProviderInvite struct { LpaKey dynamo.LpaKeyType LpaOwnerKey dynamo.LpaOwnerKeyType LpaUID string - Type actor.LpaType + Type donordata.LpaType DonorFirstNames string DonorFullName string CertificateProviderUID actoruid.UID @@ -67,7 +68,7 @@ func (s *ShareCodeSender) SendCertificateProviderInvite(ctx context.Context, app }) } -func (s *ShareCodeSender) SendCertificateProviderPrompt(ctx context.Context, appData AppData, donor *actor.DonorProvidedDetails) error { +func (s *ShareCodeSender) SendCertificateProviderPrompt(ctx context.Context, appData AppData, donor *donordata.DonorProvidedDetails) error { shareCode, err := s.createShareCode(ctx, donor.PK, donor.SK, donor.CertificateProvider.UID, actor.TypeCertificateProvider) if err != nil { return err diff --git a/internal/page/share_code_test.go b/internal/page/share_code_test.go index 1400c58357..866b597185 100644 --- a/internal/page/share_code_test.go +++ b/internal/page/share_code_test.go @@ -8,6 +8,7 @@ import ( "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/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/event" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" @@ -17,17 +18,17 @@ import ( ) func TestShareCodeSenderSendCertificateProviderInvite(t *testing.T) { - donor := &actor.DonorProvidedDetails{ - CertificateProvider: actor.CertificateProvider{ + donor := &donordata.DonorProvidedDetails{ + CertificateProvider: donordata.CertificateProvider{ FirstNames: "Joanna", LastName: "Jones", Email: "name@example.org", }, - Donor: actor.Donor{ + Donor: donordata.Donor{ FirstNames: "Jan", LastName: "Smith", }, - Type: actor.LpaTypePropertyAndAffairs, + Type: donordata.LpaTypePropertyAndAffairs, LpaUID: "lpa-uid", } @@ -101,17 +102,17 @@ func TestShareCodeSenderSendCertificateProviderInviteWithTestCode(t *testing.T) }, } - donor := &actor.DonorProvidedDetails{ - CertificateProvider: actor.CertificateProvider{ + donor := &donordata.DonorProvidedDetails{ + CertificateProvider: donordata.CertificateProvider{ FirstNames: "Joanna", LastName: "Jones", Email: "name@example.org", }, - Donor: actor.Donor{ + Donor: donordata.Donor{ FirstNames: "Jan", LastName: "Smith", }, - Type: actor.LpaTypePropertyAndAffairs, + Type: donordata.LpaTypePropertyAndAffairs, LpaUID: "lpa-uid", } @@ -216,17 +217,17 @@ func TestShareCodeSenderSendCertificateProviderInviteWithTestCode(t *testing.T) func TestShareCodeSenderSendCertificateProviderInviteWhenEmailErrors(t *testing.T) { ctx := context.Background() - donor := &actor.DonorProvidedDetails{ - CertificateProvider: actor.CertificateProvider{ + donor := &donordata.DonorProvidedDetails{ + CertificateProvider: donordata.CertificateProvider{ FirstNames: "Joanna", LastName: "Jones", Email: "name@example.org", }, - Donor: actor.Donor{ + Donor: donordata.Donor{ FirstNames: "Jan", LastName: "Smith", }, - Type: actor.LpaTypePropertyAndAffairs, + Type: donordata.LpaTypePropertyAndAffairs, } localizer := newMockLocalizer(t) @@ -277,18 +278,18 @@ func TestShareCodeSenderSendCertificateProviderInviteWhenShareCodeStoreErrors(t } func TestShareCodeSenderSendCertificateProviderPromptOnline(t *testing.T) { - donor := &actor.DonorProvidedDetails{ - CertificateProvider: actor.CertificateProvider{ + donor := &donordata.DonorProvidedDetails{ + CertificateProvider: donordata.CertificateProvider{ FirstNames: "Joanna", LastName: "Jones", Email: "name@example.org", - CarryOutBy: actor.ChannelOnline, + CarryOutBy: donordata.ChannelOnline, }, - Donor: actor.Donor{ + Donor: donordata.Donor{ FirstNames: "Jan", LastName: "Smith", }, - Type: actor.LpaTypePropertyAndAffairs, + Type: donordata.LpaTypePropertyAndAffairs, LpaUID: "lpa-uid", PK: dynamo.LpaKey("lpa"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), @@ -331,19 +332,19 @@ func TestShareCodeSenderSendCertificateProviderPromptOnline(t *testing.T) { func TestShareCodeSenderSendCertificateProviderPromptPaper(t *testing.T) { actorUID := actoruid.New() - donor := &actor.DonorProvidedDetails{ - CertificateProvider: actor.CertificateProvider{ + donor := &donordata.DonorProvidedDetails{ + CertificateProvider: donordata.CertificateProvider{ UID: actorUID, FirstNames: "Joanna", LastName: "Jones", Email: "name@example.org", - CarryOutBy: actor.ChannelPaper, + CarryOutBy: donordata.ChannelPaper, }, - Donor: actor.Donor{ + Donor: donordata.Donor{ FirstNames: "Jan", LastName: "Smith", }, - Type: actor.LpaTypePropertyAndAffairs, + Type: donordata.LpaTypePropertyAndAffairs, LpaUID: "lpa-uid", PK: dynamo.LpaKey("lpa"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), @@ -391,17 +392,17 @@ func TestShareCodeSenderSendCertificateProviderPromptWithTestCode(t *testing.T) }, } - donor := &actor.DonorProvidedDetails{ - CertificateProvider: actor.CertificateProvider{ + donor := &donordata.DonorProvidedDetails{ + CertificateProvider: donordata.CertificateProvider{ FirstNames: "Joanna", LastName: "Jones", Email: "name@example.org", }, - Donor: actor.Donor{ + Donor: donordata.Donor{ FirstNames: "Jan", LastName: "Smith", }, - Type: actor.LpaTypePropertyAndAffairs, + Type: donordata.LpaTypePropertyAndAffairs, LpaUID: "lpa-uid", PK: dynamo.LpaKey("lpa"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), @@ -474,9 +475,9 @@ func TestShareCodeSenderSendCertificateProviderPromptWithTestCode(t *testing.T) } func TestShareCodeSenderSendCertificateProviderPromptPaperWhenShareCodeStoreError(t *testing.T) { - donor := &actor.DonorProvidedDetails{ - CertificateProvider: actor.CertificateProvider{ - CarryOutBy: actor.ChannelPaper, + donor := &donordata.DonorProvidedDetails{ + CertificateProvider: donordata.CertificateProvider{ + CarryOutBy: donordata.ChannelPaper, }, } @@ -494,9 +495,9 @@ func TestShareCodeSenderSendCertificateProviderPromptPaperWhenShareCodeStoreErro } func TestShareCodeSenderSendCertificateProviderPromptPaperWhenEventClientError(t *testing.T) { - donor := &actor.DonorProvidedDetails{ - CertificateProvider: actor.CertificateProvider{ - CarryOutBy: actor.ChannelPaper, + donor := &donordata.DonorProvidedDetails{ + CertificateProvider: donordata.CertificateProvider{ + CarryOutBy: donordata.ChannelPaper, }, } @@ -521,17 +522,17 @@ func TestShareCodeSenderSendCertificateProviderPromptPaperWhenEventClientError(t func TestShareCodeSenderSendCertificateProviderPromptWhenEmailErrors(t *testing.T) { ctx := context.Background() - donor := &actor.DonorProvidedDetails{ - CertificateProvider: actor.CertificateProvider{ + donor := &donordata.DonorProvidedDetails{ + CertificateProvider: donordata.CertificateProvider{ FirstNames: "Joanna", LastName: "Jones", Email: "name@example.org", }, - Donor: actor.Donor{ + Donor: donordata.Donor{ FirstNames: "Jan", LastName: "Smith", }, - Type: actor.LpaTypePropertyAndAffairs, + Type: donordata.LpaTypePropertyAndAffairs, } localizer := newMockLocalizer(t) @@ -566,7 +567,7 @@ func TestShareCodeSenderSendCertificateProviderPromptWhenShareCodeStoreErrors(t Return(expectedError) sender := NewShareCodeSender(shareCodeStore, nil, "http://app", testRandomStringFn, nil) - err := sender.SendCertificateProviderPrompt(ctx, TestAppData, &actor.DonorProvidedDetails{}) + err := sender.SendCertificateProviderPrompt(ctx, TestAppData, &donordata.DonorProvidedDetails{}) assert.Equal(t, expectedError, errors.Unwrap(err)) } @@ -631,7 +632,7 @@ func TestShareCodeSenderSendAttorneys(t *testing.T) { FirstNames: "Jan", LastName: "Smith", }, - Type: actor.LpaTypePropertyAndAffairs, + Type: donordata.LpaTypePropertyAndAffairs, LpaUID: "lpa-uid", LpaKey: dynamo.LpaKey("lpa"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), @@ -779,7 +780,7 @@ func TestShareCodeSenderSendAttorneysTrustCorporationsNoEmail(t *testing.T) { FirstNames: "Jan", LastName: "Smith", }, - Type: actor.LpaTypePropertyAndAffairs, + Type: donordata.LpaTypePropertyAndAffairs, LpaUID: "lpa-uid", LpaKey: dynamo.LpaKey("lpa"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), @@ -856,7 +857,7 @@ func TestShareCodeSenderSendAttorneysWithTestCode(t *testing.T) { FirstNames: "Jan", LastName: "Smith", }, - Type: actor.LpaTypePropertyAndAffairs, + Type: donordata.LpaTypePropertyAndAffairs, LpaUID: "lpa-uid", LpaKey: dynamo.LpaKey("lpa"), LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("donor")), @@ -940,7 +941,7 @@ func TestShareCodeSenderSendAttorneysWhenEmailErrors(t *testing.T) { FirstNames: "Jan", LastName: "Smith", }, - Type: actor.LpaTypePropertyAndAffairs, + Type: donordata.LpaTypePropertyAndAffairs, } localizer := newMockLocalizer(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 03b032a985..9c088c557d 100644 --- a/internal/page/supporter/confirm_donor_can_interact_online_test.go +++ b/internal/page/supporter/confirm_donor_can_interact_online_test.go @@ -8,6 +8,7 @@ import ( "testing" "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/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -44,7 +45,7 @@ func TestPostConfirmDonorCanInteractOnlineWhenYes(t *testing.T) { organisationStore := newMockOrganisationStore(t) organisationStore.EXPECT(). CreateLPA(r.Context()). - Return(&actor.DonorProvidedDetails{LpaID: "lpa-id"}, nil) + Return(&donordata.DonorProvidedDetails{LpaID: "lpa-id"}, nil) err := ConfirmDonorCanInteractOnline(nil, organisationStore)(testAppData, w, r, &actor.Organisation{ID: "org-id"}, nil) resp := w.Result() @@ -100,7 +101,7 @@ func TestPostConfirmDonorCanInteractOnlineWhenOrganisationStoreError(t *testing. organisationStore := newMockOrganisationStore(t) organisationStore.EXPECT(). CreateLPA(r.Context()). - Return(&actor.DonorProvidedDetails{}, expectedError) + Return(&donordata.DonorProvidedDetails{}, 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 dda3f10d21..b3afb5cca9 100644 --- a/internal/page/supporter/dashboard.go +++ b/internal/page/supporter/dashboard.go @@ -7,6 +7,7 @@ import ( "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/search" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -20,7 +21,7 @@ type SearchClient interface { type dashboardData struct { App page.AppData Errors validation.List - Donors []actor.DonorProvidedDetails + Donors []donordata.DonorProvidedDetails CurrentPage int Pagination *search.Pagination } diff --git a/internal/page/supporter/dashboard_test.go b/internal/page/supporter/dashboard_test.go index 29439733b4..e972161527 100644 --- a/internal/page/supporter/dashboard_test.go +++ b/internal/page/supporter/dashboard_test.go @@ -5,7 +5,7 @@ import ( "net/http/httptest" "testing" - "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/search" "github.com/stretchr/testify/assert" @@ -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 := []actor.DonorProvidedDetails{{LpaID: "abc"}} + donors := []donordata.DonorProvidedDetails{{LpaID: "abc"}} searchClient := newMockSearchClient(t) searchClient.EXPECT(). diff --git a/internal/page/supporter/donor_access.go b/internal/page/supporter/donor_access.go index 9594b28442..0ecf5802d7 100644 --- a/internal/page/supporter/donor_access.go +++ b/internal/page/supporter/donor_access.go @@ -8,6 +8,7 @@ import ( "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" @@ -19,7 +20,7 @@ type donorAccessData struct { App page.AppData Errors validation.List Form *donorAccessForm - Donor *actor.DonorProvidedDetails + Donor *donordata.DonorProvidedDetails ShareCode *actor.ShareCodeData } diff --git a/internal/page/supporter/donor_access_test.go b/internal/page/supporter/donor_access_test.go index ccf602194f..5ddd62bcbb 100644 --- a/internal/page/supporter/donor_access_test.go +++ b/internal/page/supporter/donor_access_test.go @@ -10,16 +10,18 @@ import ( "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" "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" ) func TestGetDonorAccess(t *testing.T) { - donor := &actor.DonorProvidedDetails{Donor: actor.Donor{Email: "x"}} + donor := &donordata.DonorProvidedDetails{Donor: donordata.Donor{Email: "x"}} shareCodeData := actor.ShareCodeData{PK: dynamo.ShareKey(dynamo.DonorShareKey("1"))} testcases := map[string]struct { @@ -80,7 +82,7 @@ func TestGetDonorAccessWhenDonorStoreErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(r.Context()). - Return(&actor.DonorProvidedDetails{}, expectedError) + Return(&donordata.DonorProvidedDetails{}, expectedError) err := DonorAccess(nil, nil, donorStore, nil, nil, "", nil)(testLpaAppData, w, r, nil, nil) assert.Equal(t, expectedError, err) @@ -93,7 +95,7 @@ func TestGetDonorAccessWhenShareCodeStoreErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(r.Context()). - Return(&actor.DonorProvidedDetails{}, nil) + Return(&donordata.DonorProvidedDetails{}, nil) shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). @@ -116,14 +118,14 @@ func TestPostDonorAccess(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(r.Context()). - Return(&actor.DonorProvidedDetails{ - Type: actor.LpaTypePropertyAndAffairs, - Donor: actor.Donor{UID: donorUID, FirstNames: "Barry", LastName: "Boy"}, + Return(&donordata.DonorProvidedDetails{ + Type: donordata.LpaTypePropertyAndAffairs, + Donor: donordata.Donor{UID: donorUID, FirstNames: "Barry", LastName: "Boy"}, }, nil) donorStore.EXPECT(). - Put(r.Context(), &actor.DonorProvidedDetails{ - Type: actor.LpaTypePropertyAndAffairs, - Donor: actor.Donor{UID: donorUID, FirstNames: "Barry", LastName: "Boy", Email: "email@example.com"}, + Put(r.Context(), &donordata.DonorProvidedDetails{ + Type: donordata.LpaTypePropertyAndAffairs, + Donor: donordata.Donor{UID: donorUID, FirstNames: "Barry", LastName: "Boy", Email: "email@example.com"}, }). Return(nil) @@ -154,7 +156,7 @@ func TestPostDonorAccess(t *testing.T) { localizer := newMockLocalizer(t) localizer.EXPECT(). - T(actor.LpaTypePropertyAndAffairs.String()). + T(donordata.LpaTypePropertyAndAffairs.String()). Return("Translation") testLpaAppData.Localizer = localizer @@ -176,7 +178,7 @@ func TestPostDonorAccessWhenDonorUpdateErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(r.Context()). - Return(&actor.DonorProvidedDetails{}, nil) + Return(&donordata.DonorProvidedDetails{}, nil) donorStore.EXPECT(). Put(r.Context(), mock.Anything). Return(expectedError) @@ -200,7 +202,7 @@ func TestPostDonorAccessWhenShareCodeStoreErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(r.Context()). - Return(&actor.DonorProvidedDetails{Donor: actor.Donor{Email: "email@example.com"}}, nil) + Return(&donordata.DonorProvidedDetails{Donor: donordata.Donor{Email: "email@example.com"}}, nil) shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). @@ -224,7 +226,7 @@ func TestPostDonorAccessWhenNotifyErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(r.Context()). - Return(&actor.DonorProvidedDetails{Donor: actor.Donor{Email: "email@example.com"}}, nil) + Return(&donordata.DonorProvidedDetails{Donor: donordata.Donor{Email: "email@example.com"}}, nil) shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). @@ -259,7 +261,7 @@ func TestPostDonorAccessWhenValidationError(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(r.Context()). - Return(&actor.DonorProvidedDetails{}, nil) + Return(&donordata.DonorProvidedDetails{}, nil) shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). @@ -292,7 +294,7 @@ func TestPostDonorAccessRecall(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(r.Context()). - Return(&actor.DonorProvidedDetails{}, nil) + Return(&donordata.DonorProvidedDetails{}, nil) shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). @@ -322,7 +324,7 @@ func TestPostDonorAccessRecallWhenDeleteErrors(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). Get(r.Context()). - Return(&actor.DonorProvidedDetails{}, nil) + Return(&donordata.DonorProvidedDetails{}, nil) shareCodeStore := newMockShareCodeStore(t) shareCodeStore.EXPECT(). @@ -397,7 +399,7 @@ func TestPostDonorAccessRemove(t *testing.T) { GetDonor(r.Context()). Return(shareCodeData, nil) - donor := &actor.DonorProvidedDetails{SK: dynamo.LpaOwnerKey(dynamo.DonorKey("donor-session-id"))} + donor := &donordata.DonorProvidedDetails{SK: dynamo.LpaOwnerKey(dynamo.DonorKey("donor-session-id"))} donorStore := newMockDonorStore(t) donorStore.EXPECT(). @@ -438,7 +440,7 @@ func TestPostDonorAccessRemoveWhenDonorHasPaid(t *testing.T) { GetDonor(r.Context()). Return(shareCodeData, nil) - donor := &actor.DonorProvidedDetails{SK: dynamo.LpaOwnerKey(dynamo.DonorKey("donor-session-id")), Tasks: actor.DonorTasks{PayForLpa: actor.PaymentTaskCompleted}} + donor := &donordata.DonorProvidedDetails{SK: dynamo.LpaOwnerKey(dynamo.DonorKey("donor-session-id")), Tasks: donordata.DonorTasks{PayForLpa: task.PaymentStateCompleted}} donorStore := newMockDonorStore(t) donorStore.EXPECT(). @@ -464,7 +466,7 @@ func TestPostDonorAccessRemoveWhenDeleteLinkError(t *testing.T) { GetDonor(mock.Anything). Return(actor.ShareCodeData{}, nil) - donor := &actor.DonorProvidedDetails{SK: dynamo.LpaOwnerKey(dynamo.DonorKey("donor-session-id"))} + donor := &donordata.DonorProvidedDetails{SK: dynamo.LpaOwnerKey(dynamo.DonorKey("donor-session-id"))} donorStore := newMockDonorStore(t) donorStore.EXPECT(). diff --git a/internal/page/supporter/register.go b/internal/page/supporter/register.go index 8cb0f93eb9..4bdba18a97 100644 --- a/internal/page/supporter/register.go +++ b/internal/page/supporter/register.go @@ -11,6 +11,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/certificateprovider/certificateproviderdata" + "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" @@ -32,7 +33,7 @@ type LpaStoreResolvingService interface { type OrganisationStore interface { Create(ctx context.Context, member *actor.Member, name string) (*actor.Organisation, error) - CreateLPA(ctx context.Context) (*actor.DonorProvidedDetails, error) + CreateLPA(ctx context.Context) (*donordata.DonorProvidedDetails, 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,9 +56,9 @@ type MemberStore interface { type DonorStore interface { DeleteDonorAccess(ctx context.Context, shareCodeData actor.ShareCodeData) error - Get(ctx context.Context) (*actor.DonorProvidedDetails, error) - GetByKeys(ctx context.Context, keys []dynamo.Keys) ([]actor.DonorProvidedDetails, error) - Put(ctx context.Context, donor *actor.DonorProvidedDetails) 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 } type CertificateProviderStore interface { diff --git a/internal/page/witness_code.go b/internal/page/witness_code.go index 27365c2b6a..1e87b9213b 100644 --- a/internal/page/witness_code.go +++ b/internal/page/witness_code.go @@ -5,7 +5,7 @@ import ( "errors" "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/localize" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/random" @@ -33,7 +33,7 @@ func NewWitnessCodeSender(donorStore DonorStore, notifyClient NotifyClient) *Wit } } -func (s *WitnessCodeSender) SendToCertificateProvider(ctx context.Context, donor *actor.DonorProvidedDetails, localizer Localizer) error { +func (s *WitnessCodeSender) SendToCertificateProvider(ctx context.Context, donor *donordata.DonorProvidedDetails, localizer Localizer) error { if !donor.CertificateProviderCodes.CanRequest(s.now()) { return ErrTooManyWitnessCodeRequests } @@ -43,7 +43,7 @@ func (s *WitnessCodeSender) SendToCertificateProvider(ctx context.Context, donor code = testWitnessCode } - donor.CertificateProviderCodes = append(donor.CertificateProviderCodes, actor.WitnessCode{Code: code, Created: s.now()}) + donor.CertificateProviderCodes = append(donor.CertificateProviderCodes, donordata.WitnessCode{Code: code, Created: s.now()}) if err := s.donorStore.Put(ctx, donor); err != nil { return err @@ -56,7 +56,7 @@ func (s *WitnessCodeSender) SendToCertificateProvider(ctx context.Context, donor }) } -func (s *WitnessCodeSender) SendToIndependentWitness(ctx context.Context, donor *actor.DonorProvidedDetails, localizer Localizer) error { +func (s *WitnessCodeSender) SendToIndependentWitness(ctx context.Context, donor *donordata.DonorProvidedDetails, localizer Localizer) error { if !donor.IndependentWitnessCodes.CanRequest(s.now()) { return ErrTooManyWitnessCodeRequests } @@ -66,7 +66,7 @@ func (s *WitnessCodeSender) SendToIndependentWitness(ctx context.Context, donor code = testWitnessCode } - donor.IndependentWitnessCodes = append(donor.IndependentWitnessCodes, actor.WitnessCode{Code: code, Created: s.now()}) + donor.IndependentWitnessCodes = append(donor.IndependentWitnessCodes, donordata.WitnessCode{Code: code, Created: s.now()}) if err := s.donorStore.Put(ctx, donor); err != nil { return err diff --git a/internal/page/witness_code_test.go b/internal/page/witness_code_test.go index 413df43dc7..239529db1a 100644 --- a/internal/page/witness_code_test.go +++ b/internal/page/witness_code_test.go @@ -5,7 +5,7 @@ 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/notify" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -45,12 +45,12 @@ func TestWitnessCodeSenderSendToCertificateProvider(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(ctx, &actor.DonorProvidedDetails{ + Put(ctx, &donordata.DonorProvidedDetails{ LpaUID: "lpa-uid", - Donor: actor.Donor{FirstNames: "Joe", LastName: "Jones"}, - CertificateProvider: actor.CertificateProvider{Mobile: "0777"}, - CertificateProviderCodes: actor.WitnessCodes{{Code: tc.expectedWitnessCode, Created: now}}, - Type: actor.LpaTypePropertyAndAffairs, + Donor: donordata.Donor{FirstNames: "Joe", LastName: "Jones"}, + CertificateProvider: donordata.CertificateProvider{Mobile: "0777"}, + CertificateProviderCodes: donordata.WitnessCodes{{Code: tc.expectedWitnessCode, Created: now}}, + Type: donordata.LpaTypePropertyAndAffairs, }). Return(nil) @@ -68,11 +68,11 @@ func TestWitnessCodeSenderSendToCertificateProvider(t *testing.T) { randomCode: func(int) string { return tc.randomCode }, now: func() time.Time { return now }, } - err := sender.SendToCertificateProvider(ctx, &actor.DonorProvidedDetails{ + err := sender.SendToCertificateProvider(ctx, &donordata.DonorProvidedDetails{ LpaUID: "lpa-uid", - Donor: actor.Donor{FirstNames: "Joe", LastName: "Jones"}, - CertificateProvider: actor.CertificateProvider{Mobile: "0777"}, - Type: actor.LpaTypePropertyAndAffairs, + Donor: donordata.Donor{FirstNames: "Joe", LastName: "Jones"}, + CertificateProvider: donordata.CertificateProvider{Mobile: "0777"}, + Type: donordata.LpaTypePropertyAndAffairs, }, localizer) assert.Nil(t, err) @@ -85,8 +85,8 @@ func TestWitnessCodeSenderSendToCertificateProviderWhenTooRecentlySent(t *testin ctx := context.Background() sender := &WitnessCodeSender{now: func() time.Time { return now }} - err := sender.SendToCertificateProvider(ctx, &actor.DonorProvidedDetails{ - CertificateProviderCodes: actor.WitnessCodes{{Created: now.Add(-time.Minute)}}, + err := sender.SendToCertificateProvider(ctx, &donordata.DonorProvidedDetails{ + CertificateProviderCodes: donordata.WitnessCodes{{Created: now.Add(-time.Minute)}}, }, nil) assert.Equal(t, ErrTooManyWitnessCodeRequests, err) @@ -117,10 +117,10 @@ func TestWitnessCodeSenderSendToCertificateProviderWhenNotifyClientErrors(t *tes randomCode: func(int) string { return "1234" }, now: time.Now, } - err := sender.SendToCertificateProvider(context.Background(), &actor.DonorProvidedDetails{ - CertificateProvider: actor.CertificateProvider{Mobile: "0777"}, - Donor: actor.Donor{FirstNames: "Joe", LastName: "Jones"}, - Type: actor.LpaTypePropertyAndAffairs, + err := sender.SendToCertificateProvider(context.Background(), &donordata.DonorProvidedDetails{ + CertificateProvider: donordata.CertificateProvider{Mobile: "0777"}, + Donor: donordata.Donor{FirstNames: "Joe", LastName: "Jones"}, + Type: donordata.LpaTypePropertyAndAffairs, }, localizer) assert.Equal(t, expectedError, err) @@ -137,10 +137,10 @@ func TestWitnessCodeSenderSendToCertificateProviderWhenDonorStoreErrors(t *testi randomCode: func(int) string { return "1234" }, now: time.Now, } - err := sender.SendToCertificateProvider(context.Background(), &actor.DonorProvidedDetails{ - CertificateProvider: actor.CertificateProvider{Mobile: "0777"}, - Donor: actor.Donor{FirstNames: "Joe", LastName: "Jones"}, - Type: actor.LpaTypePropertyAndAffairs, + err := sender.SendToCertificateProvider(context.Background(), &donordata.DonorProvidedDetails{ + CertificateProvider: donordata.CertificateProvider{Mobile: "0777"}, + Donor: donordata.Donor{FirstNames: "Joe", LastName: "Jones"}, + Type: donordata.LpaTypePropertyAndAffairs, }, nil) assert.Equal(t, expectedError, err) @@ -161,12 +161,12 @@ func TestWitnessCodeSenderSendToIndependentWitness(t *testing.T) { donorStore := newMockDonorStore(t) donorStore.EXPECT(). - Put(ctx, &actor.DonorProvidedDetails{ + Put(ctx, &donordata.DonorProvidedDetails{ LpaUID: "lpa-uid", - Donor: actor.Donor{FirstNames: "Joe", LastName: "Jones"}, - IndependentWitness: actor.IndependentWitness{Mobile: "0777"}, - IndependentWitnessCodes: actor.WitnessCodes{{Code: "1234", Created: now}}, - Type: actor.LpaTypePropertyAndAffairs, + Donor: donordata.Donor{FirstNames: "Joe", LastName: "Jones"}, + IndependentWitness: donordata.IndependentWitness{Mobile: "0777"}, + IndependentWitnessCodes: donordata.WitnessCodes{{Code: "1234", Created: now}}, + Type: donordata.LpaTypePropertyAndAffairs, }). Return(nil) @@ -184,11 +184,11 @@ func TestWitnessCodeSenderSendToIndependentWitness(t *testing.T) { randomCode: func(int) string { return "1234" }, now: func() time.Time { return now }, } - err := sender.SendToIndependentWitness(ctx, &actor.DonorProvidedDetails{ + err := sender.SendToIndependentWitness(ctx, &donordata.DonorProvidedDetails{ LpaUID: "lpa-uid", - Donor: actor.Donor{FirstNames: "Joe", LastName: "Jones"}, - IndependentWitness: actor.IndependentWitness{Mobile: "0777"}, - Type: actor.LpaTypePropertyAndAffairs, + Donor: donordata.Donor{FirstNames: "Joe", LastName: "Jones"}, + IndependentWitness: donordata.IndependentWitness{Mobile: "0777"}, + Type: donordata.LpaTypePropertyAndAffairs, }, localizer) assert.Nil(t, err) @@ -199,8 +199,8 @@ func TestWitnessCodeSenderSendToIndependentWitnessWhenTooRecentlySent(t *testing ctx := context.Background() sender := &WitnessCodeSender{now: func() time.Time { return now }} - err := sender.SendToIndependentWitness(ctx, &actor.DonorProvidedDetails{ - IndependentWitnessCodes: actor.WitnessCodes{{Created: now.Add(-time.Minute)}}, + err := sender.SendToIndependentWitness(ctx, &donordata.DonorProvidedDetails{ + IndependentWitnessCodes: donordata.WitnessCodes{{Created: now.Add(-time.Minute)}}, }, nil) assert.Equal(t, ErrTooManyWitnessCodeRequests, err) @@ -231,10 +231,10 @@ func TestWitnessCodeSenderSendToIndependentWitnessWhenNotifyClientErrors(t *test randomCode: func(int) string { return "1234" }, now: time.Now, } - err := sender.SendToIndependentWitness(context.Background(), &actor.DonorProvidedDetails{ - IndependentWitness: actor.IndependentWitness{Mobile: "0777"}, - Donor: actor.Donor{FirstNames: "Joe", LastName: "Jones"}, - Type: actor.LpaTypePropertyAndAffairs, + err := sender.SendToIndependentWitness(context.Background(), &donordata.DonorProvidedDetails{ + IndependentWitness: donordata.IndependentWitness{Mobile: "0777"}, + Donor: donordata.Donor{FirstNames: "Joe", LastName: "Jones"}, + Type: donordata.LpaTypePropertyAndAffairs, }, localizer) assert.Equal(t, expectedError, err) @@ -251,10 +251,10 @@ func TestWitnessCodeSenderSendToIndependentWitnessWhenDonorStoreErrors(t *testin randomCode: func(int) string { return "1234" }, now: time.Now, } - err := sender.SendToIndependentWitness(context.Background(), &actor.DonorProvidedDetails{ - IndependentWitness: actor.IndependentWitness{Mobile: "0777"}, - Donor: actor.Donor{FirstNames: "Joe", LastName: "Jones"}, - Type: actor.LpaTypePropertyAndAffairs, + err := sender.SendToIndependentWitness(context.Background(), &donordata.DonorProvidedDetails{ + IndependentWitness: donordata.IndependentWitness{Mobile: "0777"}, + Donor: donordata.Donor{FirstNames: "Joe", LastName: "Jones"}, + Type: donordata.LpaTypePropertyAndAffairs, }, nil) assert.Equal(t, expectedError, err) diff --git a/internal/templatefn/fn.go b/internal/templatefn/fn.go index 60c77ebc3b..abbeb85416 100644 --- a/internal/templatefn/fn.go +++ b/internal/templatefn/fn.go @@ -11,6 +11,7 @@ import ( "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/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" @@ -350,7 +351,7 @@ func listAttorneys(app page.AppData, attorneys any, attorneyType string, heading case lpastore.Attorneys: data.Attorneys = v.Attorneys data.TrustCorporation = v.TrustCorporation - case actor.Attorneys: + case donordata.Attorneys: for _, a := range v.Attorneys { data.Attorneys = append(data.Attorneys, lpastore.Attorney{ UID: a.UID, @@ -394,7 +395,7 @@ func listAttorneys(app page.AppData, attorneys any, attorneyType string, heading return data } -func listPeopleToNotify(app page.AppData, peopleToNotify actor.PeopleToNotify, headingLevel int, canChange bool) map[string]interface{} { +func listPeopleToNotify(app page.AppData, peopleToNotify donordata.PeopleToNotify, headingLevel int, canChange bool) map[string]interface{} { return map[string]interface{}{ "App": app, "HeadingLevel": headingLevel, @@ -486,7 +487,7 @@ func lpaDecisions(app page.AppData, lpa any, canChange bool) lpaDecisionsData { switch v := lpa.(type) { case *lpastore.Lpa: data.Lpa = v - case *actor.DonorProvidedDetails: + case *donordata.DonorProvidedDetails: data.Lpa = lpastore.FromDonorProvidedDetails(v) } diff --git a/internal/templatefn/fn_test.go b/internal/templatefn/fn_test.go index 0dcd8539de..e65831346a 100644 --- a/internal/templatefn/fn_test.go +++ b/internal/templatefn/fn_test.go @@ -9,6 +9,7 @@ import ( "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/donor/donordata" "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" @@ -346,11 +347,11 @@ func TestListAttorneysWithAttorneys(t *testing.T) { } lpaStoreTrustCorporation := lpastore.TrustCorporation{Name: "a"} - actorAttorneys := []actor.Attorney{ + actorAttorneys := []donordata.Attorney{ {UID: uid1}, {UID: uid2}, } - actorTrustCorporation := actor.TrustCorporation{Name: "a"} + actorTrustCorporation := donordata.TrustCorporation{Name: "a"} testcases := map[string]struct { attorneys any @@ -373,7 +374,7 @@ func TestListAttorneysWithAttorneys(t *testing.T) { }, }, "dynamo": { - attorneys: actor.Attorneys{ + attorneys: donordata.Attorneys{ Attorneys: actorAttorneys, TrustCorporation: actorTrustCorporation, }, @@ -403,7 +404,7 @@ func TestListAttorneysWithAttorneys(t *testing.T) { }, }, "dynamo replacement": { - attorneys: actor.Attorneys{ + attorneys: donordata.Attorneys{ Attorneys: actorAttorneys, TrustCorporation: actorTrustCorporation, }, @@ -437,7 +438,7 @@ func TestListAttorneysWithIncorrectType(t *testing.T) { func TestListPeopleToNotify(t *testing.T) { app := page.AppData{SessionID: "abc"} headingLevel := 3 - peopleToNotify := actor.PeopleToNotify{{}} + peopleToNotify := donordata.PeopleToNotify{{}} want := map[string]interface{}{ "App": app, @@ -561,7 +562,7 @@ func TestLpaDecisionsWithDonorProvidedDetails(t *testing.T) { App: app, Lpa: &lpastore.Lpa{}, CanChange: true, - }, lpaDecisions(app, &actor.DonorProvidedDetails{}, true)) + }, lpaDecisions(app, &donordata.DonorProvidedDetails{}, true)) } func TestSummaryRow(t *testing.T) {