diff --git a/.mockery.yaml b/.mockery.yaml index e0f7b72324..a67052a88f 100644 --- a/.mockery.yaml +++ b/.mockery.yaml @@ -36,5 +36,6 @@ packages: github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata: github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterpage: github.com/ministryofjustice/opg-modernising-lpa/internal/supporter: + github.com/ministryofjustice/opg-modernising-lpa/internal/task: github.com/ministryofjustice/opg-modernising-lpa/internal/uid: github.com/ministryofjustice/opg-modernising-lpa/internal/validation: diff --git a/cmd/event-received/factory.go b/cmd/event-received/factory.go index d384b00159..82ea414b62 100644 --- a/cmd/event-received/factory.go +++ b/cmd/event-received/factory.go @@ -16,6 +16,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/lambda" "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/random" @@ -31,7 +32,7 @@ type LambdaClient interface { type LpaStoreClient interface { SendLpa(ctx context.Context, donor *donordata.Provided) error - Lpa(ctx context.Context, uid string) (*lpastore.Lpa, error) + Lpa(ctx context.Context, uid string) (*lpadata.Lpa, error) } type SecretsClient interface { @@ -41,7 +42,7 @@ type SecretsClient interface { type ShareCodeSender interface { SendCertificateProviderInvite(context.Context, appcontext.Data, page.CertificateProviderInvite) error SendCertificateProviderPrompt(context.Context, appcontext.Data, *donordata.Provided) error - SendAttorneys(context.Context, appcontext.Data, *lpastore.Lpa) error + SendAttorneys(context.Context, appcontext.Data, *lpadata.Lpa) error } type UidStore interface { diff --git a/cmd/event-received/mock_lpaStoreClient_test.go b/cmd/event-received/mock_lpaStoreClient_test.go index e804d439e0..8a438b6ed7 100644 --- a/cmd/event-received/mock_lpaStoreClient_test.go +++ b/cmd/event-received/mock_lpaStoreClient_test.go @@ -6,7 +6,7 @@ import ( context "context" donordata "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" - lpastore "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + lpadata "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" mock "github.com/stretchr/testify/mock" ) @@ -25,23 +25,23 @@ func (_m *mockLpaStoreClient) EXPECT() *mockLpaStoreClient_Expecter { } // Lpa provides a mock function with given fields: ctx, uid -func (_m *mockLpaStoreClient) Lpa(ctx context.Context, uid string) (*lpastore.Lpa, error) { +func (_m *mockLpaStoreClient) Lpa(ctx context.Context, uid string) (*lpadata.Lpa, error) { ret := _m.Called(ctx, uid) if len(ret) == 0 { panic("no return value specified for Lpa") } - var r0 *lpastore.Lpa + var r0 *lpadata.Lpa var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string) (*lpastore.Lpa, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string) (*lpadata.Lpa, error)); ok { return rf(ctx, uid) } - if rf, ok := ret.Get(0).(func(context.Context, string) *lpastore.Lpa); ok { + if rf, ok := ret.Get(0).(func(context.Context, string) *lpadata.Lpa); ok { r0 = rf(ctx, uid) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*lpastore.Lpa) + r0 = ret.Get(0).(*lpadata.Lpa) } } @@ -73,12 +73,12 @@ func (_c *mockLpaStoreClient_Lpa_Call) Run(run func(ctx context.Context, uid str return _c } -func (_c *mockLpaStoreClient_Lpa_Call) Return(_a0 *lpastore.Lpa, _a1 error) *mockLpaStoreClient_Lpa_Call { +func (_c *mockLpaStoreClient_Lpa_Call) Return(_a0 *lpadata.Lpa, _a1 error) *mockLpaStoreClient_Lpa_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockLpaStoreClient_Lpa_Call) RunAndReturn(run func(context.Context, string) (*lpastore.Lpa, error)) *mockLpaStoreClient_Lpa_Call { +func (_c *mockLpaStoreClient_Lpa_Call) RunAndReturn(run func(context.Context, string) (*lpadata.Lpa, error)) *mockLpaStoreClient_Lpa_Call { _c.Call.Return(run) return _c } diff --git a/cmd/event-received/mock_shareCodeSender_test.go b/cmd/event-received/mock_shareCodeSender_test.go index d12387e2bd..c8aad0b74c 100644 --- a/cmd/event-received/mock_shareCodeSender_test.go +++ b/cmd/event-received/mock_shareCodeSender_test.go @@ -9,7 +9,7 @@ import ( donordata "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" - lpastore "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + lpadata "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" mock "github.com/stretchr/testify/mock" @@ -30,7 +30,7 @@ func (_m *mockShareCodeSender) EXPECT() *mockShareCodeSender_Expecter { } // SendAttorneys provides a mock function with given fields: _a0, _a1, _a2 -func (_m *mockShareCodeSender) SendAttorneys(_a0 context.Context, _a1 appcontext.Data, _a2 *lpastore.Lpa) error { +func (_m *mockShareCodeSender) SendAttorneys(_a0 context.Context, _a1 appcontext.Data, _a2 *lpadata.Lpa) error { ret := _m.Called(_a0, _a1, _a2) if len(ret) == 0 { @@ -38,7 +38,7 @@ func (_m *mockShareCodeSender) SendAttorneys(_a0 context.Context, _a1 appcontext } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, appcontext.Data, *lpastore.Lpa) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, appcontext.Data, *lpadata.Lpa) error); ok { r0 = rf(_a0, _a1, _a2) } else { r0 = ret.Error(0) @@ -55,14 +55,14 @@ type mockShareCodeSender_SendAttorneys_Call struct { // SendAttorneys is a helper method to define mock.On call // - _a0 context.Context // - _a1 appcontext.Data -// - _a2 *lpastore.Lpa +// - _a2 *lpadata.Lpa func (_e *mockShareCodeSender_Expecter) SendAttorneys(_a0 interface{}, _a1 interface{}, _a2 interface{}) *mockShareCodeSender_SendAttorneys_Call { return &mockShareCodeSender_SendAttorneys_Call{Call: _e.mock.On("SendAttorneys", _a0, _a1, _a2)} } -func (_c *mockShareCodeSender_SendAttorneys_Call) Run(run func(_a0 context.Context, _a1 appcontext.Data, _a2 *lpastore.Lpa)) *mockShareCodeSender_SendAttorneys_Call { +func (_c *mockShareCodeSender_SendAttorneys_Call) Run(run func(_a0 context.Context, _a1 appcontext.Data, _a2 *lpadata.Lpa)) *mockShareCodeSender_SendAttorneys_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(appcontext.Data), args[2].(*lpastore.Lpa)) + run(args[0].(context.Context), args[1].(appcontext.Data), args[2].(*lpadata.Lpa)) }) return _c } @@ -72,7 +72,7 @@ func (_c *mockShareCodeSender_SendAttorneys_Call) Return(_a0 error) *mockShareCo return _c } -func (_c *mockShareCodeSender_SendAttorneys_Call) RunAndReturn(run func(context.Context, appcontext.Data, *lpastore.Lpa) error) *mockShareCodeSender_SendAttorneys_Call { +func (_c *mockShareCodeSender_SendAttorneys_Call) RunAndReturn(run func(context.Context, appcontext.Data, *lpadata.Lpa) error) *mockShareCodeSender_SendAttorneys_Call { _c.Call.Return(run) return _c } diff --git a/cmd/event-received/sirius_event_handler_test.go b/cmd/event-received/sirius_event_handler_test.go index 5a63edfc90..9614473bd8 100644 --- a/cmd/event-received/sirius_event_handler_test.go +++ b/cmd/event-received/sirius_event_handler_test.go @@ -14,7 +14,6 @@ import ( 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/event" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/pay" @@ -722,9 +721,9 @@ func TestHandleDonorSubmissionCompleted(t *testing.T) { appData := appcontext.Data{} uid := actoruid.New() - lpa := &lpastore.Lpa{ - Donor: lpastore.Donor{FirstNames: "Dave", LastName: "Smith"}, - CertificateProvider: lpastore.CertificateProvider{ + lpa := &lpadata.Lpa{ + Donor: lpadata.Donor{FirstNames: "Dave", LastName: "Smith"}, + CertificateProvider: lpadata.CertificateProvider{ Channel: lpadata.ChannelOnline, UID: uid, FirstNames: "John", @@ -793,8 +792,8 @@ func TestHandleDonorSubmissionCompleted(t *testing.T) { func TestHandleDonorSubmissionCompletedWhenPaperCertificateProvider(t *testing.T) { appData := appcontext.Data{} - lpa := &lpastore.Lpa{ - CertificateProvider: lpastore.CertificateProvider{ + lpa := &lpadata.Lpa{ + CertificateProvider: lpadata.CertificateProvider{ Channel: lpadata.ChannelPaper, }, } @@ -858,8 +857,8 @@ func TestHandleDonorSubmissionCompletedWhenDynamoPutError(t *testing.T) { func TestHandleDonorSubmissionCompletedWhenLpaStoreError(t *testing.T) { appData := appcontext.Data{} - lpa := &lpastore.Lpa{ - CertificateProvider: lpastore.CertificateProvider{ + lpa := &lpadata.Lpa{ + CertificateProvider: lpadata.CertificateProvider{ Channel: lpadata.ChannelOnline, }, } @@ -884,8 +883,8 @@ func TestHandleDonorSubmissionCompletedWhenLpaStoreError(t *testing.T) { func TestHandleDonorSubmissionCompletedWhenShareCodeSenderError(t *testing.T) { appData := appcontext.Data{} - lpa := &lpastore.Lpa{ - CertificateProvider: lpastore.CertificateProvider{ + lpa := &lpadata.Lpa{ + CertificateProvider: lpadata.CertificateProvider{ Channel: lpadata.ChannelOnline, }, } @@ -920,8 +919,8 @@ var certificateProviderSubmissionCompletedEvent = events.CloudWatchEvent{ func TestHandleCertificateProviderSubmissionCompleted(t *testing.T) { appData := appcontext.Data{} - lpa := &lpastore.Lpa{ - CertificateProvider: lpastore.CertificateProvider{ + lpa := &lpadata.Lpa{ + CertificateProvider: lpadata.CertificateProvider{ Channel: lpadata.ChannelPaper, }, } @@ -954,8 +953,8 @@ func TestHandleCertificateProviderSubmissionCompleted(t *testing.T) { } func TestHandleCertificateProviderSubmissionCompletedWhenOnline(t *testing.T) { - lpa := &lpastore.Lpa{ - CertificateProvider: lpastore.CertificateProvider{ + lpa := &lpadata.Lpa{ + CertificateProvider: lpadata.CertificateProvider{ Channel: lpadata.ChannelOnline, }, } @@ -1006,8 +1005,8 @@ func TestHandleCertificateProviderSubmissionCompletedWhenShareCodeSenderErrors(t lpaStoreClient := newMockLpaStoreClient(t) lpaStoreClient.EXPECT(). Lpa(ctx, "M-1111-2222-3333"). - Return(&lpastore.Lpa{ - CertificateProvider: lpastore.CertificateProvider{ + Return(&lpadata.Lpa{ + CertificateProvider: lpadata.CertificateProvider{ Channel: lpadata.ChannelPaper, }, }, nil) @@ -1037,8 +1036,8 @@ func TestHandleCertificateProviderSubmissionCompletedWhenShareCodeSenderFactoryE lpaStoreClient := newMockLpaStoreClient(t) lpaStoreClient.EXPECT(). Lpa(ctx, "M-1111-2222-3333"). - Return(&lpastore.Lpa{ - CertificateProvider: lpastore.CertificateProvider{ + Return(&lpadata.Lpa{ + CertificateProvider: lpadata.CertificateProvider{ Channel: lpadata.ChannelPaper, }, }, nil) @@ -1060,8 +1059,8 @@ func TestHandleCertificateProviderSubmissionCompletedWhenAppDataFactoryErrors(t lpaStoreClient := newMockLpaStoreClient(t) lpaStoreClient.EXPECT(). Lpa(ctx, "M-1111-2222-3333"). - Return(&lpastore.Lpa{ - CertificateProvider: lpastore.CertificateProvider{ + Return(&lpadata.Lpa{ + CertificateProvider: lpadata.CertificateProvider{ Channel: lpadata.ChannelPaper, }, }, nil) diff --git a/internal/app/app.go b/internal/app/app.go index 0a80631963..485cb6a19b 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -34,6 +34,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter" "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterpage" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" ) type ErrorHandler func(http.ResponseWriter, *http.Request, error) @@ -103,7 +104,7 @@ func App( evidenceReceivedStore := &evidenceReceivedStore{dynamoClient: lpaDynamoClient} organisationStore := supporter.NewOrganisationStore(lpaDynamoClient) memberStore := supporter.NewMemberStore(lpaDynamoClient) - progressTracker := page.ProgressTracker{Localizer: localizer} + progressTracker := task.ProgressTracker{Localizer: localizer} shareCodeSender := page.NewShareCodeSender(shareCodeStore, notifyClient, appPublicURL, random.String, eventClient) witnessCodeSender := page.NewWitnessCodeSender(donorStore, notifyClient) diff --git a/internal/app/app_test.go b/internal/app/app_test.go index 06b9caa933..b9ffd376f3 100644 --- a/internal/app/app_test.go +++ b/internal/app/app_test.go @@ -14,7 +14,6 @@ import ( "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" "github.com/ministryofjustice/opg-go-common/template" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" @@ -26,7 +25,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/search" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" "github.com/stretchr/testify/assert" - mock "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/mock" ) var ( @@ -34,8 +33,6 @@ var ( expectedError = errors.New("err") testNow = time.Date(2023, time.April, 2, 3, 4, 5, 6, time.UTC) testNowFn = func() time.Time { return testNow } - testUID = actoruid.New() - testUIDFn = func() actoruid.UID { return testUID } ) func (m *mockDynamoClient) ExpectOne(ctx, pk, sk, data interface{}, err error) { diff --git a/internal/app/mock_LpaStoreResolvingService_test.go b/internal/app/mock_LpaStoreResolvingService_test.go index c0fa94d2df..04543216b9 100644 --- a/internal/app/mock_LpaStoreResolvingService_test.go +++ b/internal/app/mock_LpaStoreResolvingService_test.go @@ -6,7 +6,7 @@ import ( context "context" donordata "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/lpastore/lpadata" mock "github.com/stretchr/testify/mock" ) @@ -25,23 +25,23 @@ func (_m *mockLpaStoreResolvingService) EXPECT() *mockLpaStoreResolvingService_E } // ResolveList provides a mock function with given fields: ctx, donors -func (_m *mockLpaStoreResolvingService) ResolveList(ctx context.Context, donors []*donordata.Provided) ([]*lpastore.Lpa, error) { +func (_m *mockLpaStoreResolvingService) ResolveList(ctx context.Context, donors []*donordata.Provided) ([]*lpadata.Lpa, error) { ret := _m.Called(ctx, donors) if len(ret) == 0 { panic("no return value specified for ResolveList") } - var r0 []*lpastore.Lpa + var r0 []*lpadata.Lpa var r1 error - if rf, ok := ret.Get(0).(func(context.Context, []*donordata.Provided) ([]*lpastore.Lpa, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, []*donordata.Provided) ([]*lpadata.Lpa, error)); ok { return rf(ctx, donors) } - if rf, ok := ret.Get(0).(func(context.Context, []*donordata.Provided) []*lpastore.Lpa); ok { + if rf, ok := ret.Get(0).(func(context.Context, []*donordata.Provided) []*lpadata.Lpa); ok { r0 = rf(ctx, donors) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]*lpastore.Lpa) + r0 = ret.Get(0).([]*lpadata.Lpa) } } @@ -73,12 +73,12 @@ func (_c *mockLpaStoreResolvingService_ResolveList_Call) Run(run func(ctx contex return _c } -func (_c *mockLpaStoreResolvingService_ResolveList_Call) Return(_a0 []*lpastore.Lpa, _a1 error) *mockLpaStoreResolvingService_ResolveList_Call { +func (_c *mockLpaStoreResolvingService_ResolveList_Call) Return(_a0 []*lpadata.Lpa, _a1 error) *mockLpaStoreResolvingService_ResolveList_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockLpaStoreResolvingService_ResolveList_Call) RunAndReturn(run func(context.Context, []*donordata.Provided) ([]*lpastore.Lpa, error)) *mockLpaStoreResolvingService_ResolveList_Call { +func (_c *mockLpaStoreResolvingService_ResolveList_Call) RunAndReturn(run func(context.Context, []*donordata.Provided) ([]*lpadata.Lpa, error)) *mockLpaStoreResolvingService_ResolveList_Call { _c.Call.Return(run) return _c } diff --git a/internal/attorney/attorneypage/confirm_dont_want_to_be_attorney.go b/internal/attorney/attorneypage/confirm_dont_want_to_be_attorney.go index 2f5caf15d7..beb29941d4 100644 --- a/internal/attorney/attorneypage/confirm_dont_want_to_be_attorney.go +++ b/internal/attorney/attorneypage/confirm_dont_want_to_be_attorney.go @@ -7,7 +7,7 @@ import ( "github.com/ministryofjustice/opg-go-common/template" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -16,7 +16,7 @@ import ( type confirmDontWantToBeAttorneyData struct { App appcontext.Data Errors validation.List - Lpa *lpastore.Lpa + Lpa *lpadata.Lpa } func ConfirmDontWantToBeAttorney(tmpl template.Template, lpaStoreResolvingService LpaStoreResolvingService, attorneyStore AttorneyStore, notifyClient NotifyClient, appPublicURL string) Handler { @@ -32,7 +32,7 @@ func ConfirmDontWantToBeAttorney(tmpl template.Template, lpaStoreResolvingServic } if r.Method == http.MethodPost { - attorneyFullName, err := findAttorneyFullName(lpa, attorneyProvidedDetails.UID, attorneyProvidedDetails.IsTrustCorporation, attorneyProvidedDetails.IsReplacement) + attorneyFullName, err := findAttorneyFullName(lpa, attorneyProvidedDetails.UID) if err != nil { return err } diff --git a/internal/attorney/attorneypage/confirm_dont_want_to_be_attorney_logged_out.go b/internal/attorney/attorneypage/confirm_dont_want_to_be_attorney_logged_out.go index 849621040b..4d1f884a50 100644 --- a/internal/attorney/attorneypage/confirm_dont_want_to_be_attorney_logged_out.go +++ b/internal/attorney/attorneypage/confirm_dont_want_to_be_attorney_logged_out.go @@ -9,7 +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/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -18,7 +18,7 @@ import ( type confirmDontWantToBeAttorneyDataLoggedOut struct { App appcontext.Data Errors validation.List - Lpa *lpastore.Lpa + Lpa *lpadata.Lpa } func ConfirmDontWantToBeAttorneyLoggedOut(tmpl template.Template, shareCodeStore ShareCodeStore, lpaStoreResolvingService LpaStoreResolvingService, sessionStore SessionStore, notifyClient NotifyClient, appPublicURL string) page.Handler { @@ -46,7 +46,7 @@ func ConfirmDontWantToBeAttorneyLoggedOut(tmpl template.Template, shareCodeStore return err } - attorneyFullName, err := findAttorneyFullName(lpa, shareCode.ActorUID, shareCode.IsTrustCorporation, shareCode.IsReplacementAttorney) + attorneyFullName, err := findAttorneyFullName(lpa, shareCode.ActorUID) if err != nil { return err } @@ -75,7 +75,7 @@ func ConfirmDontWantToBeAttorneyLoggedOut(tmpl template.Template, shareCodeStore } } -func findAttorneyFullName(lpa *lpastore.Lpa, uid actoruid.UID, isTrustCorporation, isReplacement bool) (string, error) { +func findAttorneyFullName(lpa *lpadata.Lpa, uid actoruid.UID) (string, error) { if t := lpa.ReplacementAttorneys.TrustCorporation; t.UID == uid { return t.Name, nil } 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 d2838544c8..8724d3e3ba 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 @@ -10,7 +10,6 @@ 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/dynamo" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" @@ -24,7 +23,7 @@ func TestGetConfirmDontWantToBeAttorneyLoggedOut(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - lpa := lpastore.Lpa{LpaUID: "lpa-uid"} + lpa := lpadata.Lpa{LpaUID: "lpa-uid"} sessionStore := newMockSessionStore(t) sessionStore.EXPECT(). @@ -79,7 +78,7 @@ func TestGetConfirmDontWantToBeAttorneyLoggedOutWhenLpaStoreResolvingServiceErro lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(mock.Anything). - Return(&lpastore.Lpa{}, expectedError) + Return(&lpadata.Lpa{}, expectedError) err := ConfirmDontWantToBeAttorneyLoggedOut(nil, nil, lpaStoreResolvingService, sessionStore, nil, "example.com")(testAppData, w, r) resp := w.Result() @@ -100,7 +99,7 @@ func TestGetConfirmDontWantToBeAttorneyLoggedOutWhenTemplateErrors(t *testing.T) lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(mock.Anything). - Return(&lpastore.Lpa{}, nil) + Return(&lpadata.Lpa{}, nil) template := newMockTemplate(t) template.EXPECT(). @@ -148,21 +147,21 @@ func TestPostConfirmDontWantToBeAttorneyLoggedOut(t *testing.T) { w := httptest.NewRecorder() ctx := appcontext.ContextWithSession(r.Context(), &appcontext.Session{LpaID: "lpa-id"}) - lpa := &lpastore.Lpa{ + lpa := &lpadata.Lpa{ LpaUID: "lpa-uid", SignedAt: time.Now(), - Donor: lpastore.Donor{ + Donor: lpadata.Donor{ FirstNames: "a b", LastName: "c", Email: "a@example.com", }, - Attorneys: lpastore.Attorneys{ - TrustCorporation: lpastore.TrustCorporation{UID: trustCorporationUID, Name: "trusty"}, - Attorneys: []lpastore.Attorney{ + Attorneys: lpadata.Attorneys{ + TrustCorporation: lpadata.TrustCorporation{UID: trustCorporationUID, Name: "trusty"}, + Attorneys: []lpadata.Attorney{ {UID: attorneyUID, FirstNames: "d e", LastName: "f"}, }, }, - ReplacementAttorneys: lpastore.Attorneys{ - TrustCorporation: lpastore.TrustCorporation{UID: replacementTrustCorporationUID, Name: "untrusty"}, - Attorneys: []lpastore.Attorney{ + ReplacementAttorneys: lpadata.Attorneys{ + TrustCorporation: lpadata.TrustCorporation{UID: replacementTrustCorporationUID, Name: "untrusty"}, + Attorneys: []lpadata.Attorney{ {UID: replacementAttorneyUID, FirstNames: "x y", LastName: "z"}, }, }, @@ -250,10 +249,10 @@ func TestPostConfirmDontWantToBeAttorneyLoggedOutWhenAttorneyNotFound(t *testing lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(ctx). - Return(&lpastore.Lpa{ + Return(&lpadata.Lpa{ LpaUID: "lpa-uid", SignedAt: time.Now(), - Donor: lpastore.Donor{ + Donor: lpadata.Donor{ FirstNames: "a b", LastName: "c", Email: "a@example.com", }, Type: lpadata.LpaTypePersonalWelfare, @@ -271,7 +270,7 @@ func TestPostConfirmDontWantToBeAttorneyLoggedOutErrors(t *testing.T) { LpaKey: dynamo.LpaKey("lpa-id"), } - signedLPA := lpastore.Lpa{LpaUID: "lpa-uid", SignedAt: time.Now()} + signedLPA := lpadata.Lpa{LpaUID: "lpa-uid", SignedAt: time.Now()} localizer := func(t *testing.T) *mockLocalizer { l := newMockLocalizer(t) 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 3604693289..4ccc6dc37d 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 @@ -10,7 +10,6 @@ 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/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" @@ -22,7 +21,7 @@ func TestGetConfirmDontWantToBeAttorney(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - lpa := lpastore.Lpa{LpaUID: "lpa-uid"} + lpa := lpadata.Lpa{LpaUID: "lpa-uid"} lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). @@ -51,7 +50,7 @@ func TestGetConfirmDontWantToBeAttorneyWhenLpaStoreResolvingServiceErrors(t *tes lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(mock.Anything). - Return(&lpastore.Lpa{}, expectedError) + Return(&lpadata.Lpa{}, expectedError) err := ConfirmDontWantToBeAttorney(nil, lpaStoreResolvingService, nil, nil, "example.com")(testAppData, w, r, &attorneydata.Provided{}) resp := w.Result() @@ -67,7 +66,7 @@ func TestGetConfirmDontWantToBeAttorneyWhenTemplateErrors(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(mock.Anything). - Return(&lpastore.Lpa{}, nil) + Return(&lpadata.Lpa{}, nil) template := newMockTemplate(t) template.EXPECT(). @@ -89,14 +88,14 @@ func TestPostConfirmDontWantToBeAttorney(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{ + Return(&lpadata.Lpa{ LpaUID: "lpa-uid", SignedAt: time.Now(), - Donor: lpastore.Donor{ + Donor: lpadata.Donor{ FirstNames: "a b", LastName: "c", Email: "a@example.com", }, - Attorneys: lpastore.Attorneys{ - Attorneys: []lpastore.Attorney{ + Attorneys: lpadata.Attorneys{ + Attorneys: []lpadata.Attorney{ {FirstNames: "d e", LastName: "f", UID: uid}, }, }, @@ -149,10 +148,10 @@ func TestPostConfirmDontWantToBeAttorneyWhenAttorneyNotFound(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{ + Return(&lpadata.Lpa{ LpaUID: "lpa-uid", SignedAt: time.Now(), - Donor: lpastore.Donor{ + Donor: lpadata.Donor{ FirstNames: "a b", LastName: "c", Email: "a@example.com", }, Type: lpadata.LpaTypePersonalWelfare, @@ -219,7 +218,7 @@ func TestPostConfirmDontWantToBeAttorneyErrors(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{LpaUID: "lpa-uid", SignedAt: time.Now()}, nil) + Return(&lpadata.Lpa{LpaUID: "lpa-uid", SignedAt: time.Now()}, nil) localizer := newMockLocalizer(t) localizer.EXPECT(). diff --git a/internal/attorney/attorneypage/confirm_your_details.go b/internal/attorney/attorneypage/confirm_your_details.go index 9da2878924..a20f45ffc1 100644 --- a/internal/attorney/attorneypage/confirm_your_details.go +++ b/internal/attorney/attorneypage/confirm_your_details.go @@ -7,7 +7,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -15,9 +15,9 @@ import ( type confirmYourDetailsData struct { App appcontext.Data Errors validation.List - Lpa *lpastore.Lpa - Attorney lpastore.Attorney - TrustCorporation lpastore.TrustCorporation + Lpa *lpadata.Lpa + Attorney lpadata.Attorney + TrustCorporation lpadata.TrustCorporation AttorneyProvidedDetails *attorneydata.Provided } diff --git a/internal/attorney/attorneypage/confirm_your_details_test.go b/internal/attorney/attorneypage/confirm_your_details_test.go index ad74b799a0..72c522633a 100644 --- a/internal/attorney/attorneypage/confirm_your_details_test.go +++ b/internal/attorney/attorneypage/confirm_your_details_test.go @@ -9,7 +9,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -21,34 +21,34 @@ func TestGetConfirmYourDetails(t *testing.T) { testcases := map[string]struct { appData appcontext.Data - donor *lpastore.Lpa + donor *lpadata.Lpa data *confirmYourDetailsData }{ "attorney": { appData: testAppData, - donor: &lpastore.Lpa{ - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{UID: uid, FirstNames: "John"}}}, + donor: &lpadata.Lpa{ + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{UID: uid, FirstNames: "John"}}}, }, data: &confirmYourDetailsData{ App: testAppData, - Lpa: &lpastore.Lpa{ - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{UID: uid, FirstNames: "John"}}}, + Lpa: &lpadata.Lpa{ + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{UID: uid, FirstNames: "John"}}}, }, - Attorney: lpastore.Attorney{UID: uid, FirstNames: "John"}, + Attorney: lpadata.Attorney{UID: uid, FirstNames: "John"}, AttorneyProvidedDetails: attorneyProvidedDetails, }, }, "trust corporation": { appData: testTrustCorporationAppData, - donor: &lpastore.Lpa{ - Attorneys: lpastore.Attorneys{TrustCorporation: lpastore.TrustCorporation{Name: "company"}}, + donor: &lpadata.Lpa{ + Attorneys: lpadata.Attorneys{TrustCorporation: lpadata.TrustCorporation{Name: "company"}}, }, data: &confirmYourDetailsData{ App: testTrustCorporationAppData, - Lpa: &lpastore.Lpa{ - Attorneys: lpastore.Attorneys{TrustCorporation: lpastore.TrustCorporation{Name: "company"}}, + Lpa: &lpadata.Lpa{ + Attorneys: lpadata.Attorneys{TrustCorporation: lpadata.TrustCorporation{Name: "company"}}, }, - TrustCorporation: lpastore.TrustCorporation{Name: "company"}, + TrustCorporation: lpadata.TrustCorporation{Name: "company"}, AttorneyProvidedDetails: attorneyProvidedDetails, }, }, @@ -82,7 +82,7 @@ func TestGetConfirmYourDetailsWhenLpaStoreResolvingServiceErrors(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &lpastore.Lpa{} + donor := &lpadata.Lpa{} lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). @@ -101,7 +101,7 @@ func TestGetConfirmYourDetailsWhenTemplateErrors(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, nil) + Return(&lpadata.Lpa{}, nil) template := newMockTemplate(t) template.EXPECT(). diff --git a/internal/attorney/attorneypage/guidance.go b/internal/attorney/attorneypage/guidance.go index 1706165a55..5228a1b08b 100644 --- a/internal/attorney/attorneypage/guidance.go +++ b/internal/attorney/attorneypage/guidance.go @@ -6,14 +6,14 @@ import ( "github.com/ministryofjustice/opg-go-common/template" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) type guidanceData struct { App appcontext.Data Errors validation.List - Lpa *lpastore.Lpa + Lpa *lpadata.Lpa } func Guidance(tmpl template.Template, lpaStoreResolvingService LpaStoreResolvingService) Handler { diff --git a/internal/attorney/attorneypage/guidance_test.go b/internal/attorney/attorneypage/guidance_test.go index 668d4b1f60..b138da0bcf 100644 --- a/internal/attorney/attorneypage/guidance_test.go +++ b/internal/attorney/attorneypage/guidance_test.go @@ -5,7 +5,7 @@ import ( "net/http/httptest" "testing" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/stretchr/testify/assert" ) @@ -13,7 +13,7 @@ func TestGuidance(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &lpastore.Lpa{} + donor := &lpadata.Lpa{} lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). @@ -53,7 +53,7 @@ func TestGuidanceWhenLpaStoreResolvingServiceErrors(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &lpastore.Lpa{} + donor := &lpadata.Lpa{} lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). @@ -72,11 +72,11 @@ func TestGuidanceWhenTemplateErrors(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, nil) + Return(&lpadata.Lpa{}, nil) template := newMockTemplate(t) template.EXPECT(). - Execute(w, &guidanceData{App: testAppData, Lpa: &lpastore.Lpa{}}). + Execute(w, &guidanceData{App: testAppData, Lpa: &lpadata.Lpa{}}). Return(expectedError) err := Guidance(template.Execute, lpaStoreResolvingService)(testAppData, w, r, nil) diff --git a/internal/attorney/attorneypage/mobile_number.go b/internal/attorney/attorneypage/mobile_number.go index 52f960c7a0..4ee12f4359 100644 --- a/internal/attorney/attorneypage/mobile_number.go +++ b/internal/attorney/attorneypage/mobile_number.go @@ -7,7 +7,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -15,7 +15,7 @@ import ( type mobileNumberData struct { App appcontext.Data - Donor *lpastore.Lpa + Donor *lpadata.Lpa Form *mobileNumberForm Errors validation.List } diff --git a/internal/attorney/attorneypage/mock_LpaStoreClient_test.go b/internal/attorney/attorneypage/mock_LpaStoreClient_test.go index de14110168..63e31a23af 100644 --- a/internal/attorney/attorneypage/mock_LpaStoreClient_test.go +++ b/internal/attorney/attorneypage/mock_LpaStoreClient_test.go @@ -7,7 +7,7 @@ import ( attorneydata "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" - lpastore "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + lpadata "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" mock "github.com/stretchr/testify/mock" ) @@ -26,7 +26,7 @@ func (_m *mockLpaStoreClient) EXPECT() *mockLpaStoreClient_Expecter { } // SendAttorney provides a mock function with given fields: _a0, _a1, _a2 -func (_m *mockLpaStoreClient) SendAttorney(_a0 context.Context, _a1 *lpastore.Lpa, _a2 *attorneydata.Provided) error { +func (_m *mockLpaStoreClient) SendAttorney(_a0 context.Context, _a1 *lpadata.Lpa, _a2 *attorneydata.Provided) error { ret := _m.Called(_a0, _a1, _a2) if len(ret) == 0 { @@ -34,7 +34,7 @@ func (_m *mockLpaStoreClient) SendAttorney(_a0 context.Context, _a1 *lpastore.Lp } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *lpastore.Lpa, *attorneydata.Provided) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, *lpadata.Lpa, *attorneydata.Provided) error); ok { r0 = rf(_a0, _a1, _a2) } else { r0 = ret.Error(0) @@ -50,15 +50,15 @@ type mockLpaStoreClient_SendAttorney_Call struct { // SendAttorney is a helper method to define mock.On call // - _a0 context.Context -// - _a1 *lpastore.Lpa +// - _a1 *lpadata.Lpa // - _a2 *attorneydata.Provided func (_e *mockLpaStoreClient_Expecter) SendAttorney(_a0 interface{}, _a1 interface{}, _a2 interface{}) *mockLpaStoreClient_SendAttorney_Call { return &mockLpaStoreClient_SendAttorney_Call{Call: _e.mock.On("SendAttorney", _a0, _a1, _a2)} } -func (_c *mockLpaStoreClient_SendAttorney_Call) Run(run func(_a0 context.Context, _a1 *lpastore.Lpa, _a2 *attorneydata.Provided)) *mockLpaStoreClient_SendAttorney_Call { +func (_c *mockLpaStoreClient_SendAttorney_Call) Run(run func(_a0 context.Context, _a1 *lpadata.Lpa, _a2 *attorneydata.Provided)) *mockLpaStoreClient_SendAttorney_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*lpastore.Lpa), args[2].(*attorneydata.Provided)) + run(args[0].(context.Context), args[1].(*lpadata.Lpa), args[2].(*attorneydata.Provided)) }) return _c } @@ -68,7 +68,7 @@ func (_c *mockLpaStoreClient_SendAttorney_Call) Return(_a0 error) *mockLpaStoreC return _c } -func (_c *mockLpaStoreClient_SendAttorney_Call) RunAndReturn(run func(context.Context, *lpastore.Lpa, *attorneydata.Provided) error) *mockLpaStoreClient_SendAttorney_Call { +func (_c *mockLpaStoreClient_SendAttorney_Call) RunAndReturn(run func(context.Context, *lpadata.Lpa, *attorneydata.Provided) error) *mockLpaStoreClient_SendAttorney_Call { _c.Call.Return(run) return _c } diff --git a/internal/attorney/attorneypage/mock_LpaStoreResolvingService_test.go b/internal/attorney/attorneypage/mock_LpaStoreResolvingService_test.go index 75e205b853..c47535b497 100644 --- a/internal/attorney/attorneypage/mock_LpaStoreResolvingService_test.go +++ b/internal/attorney/attorneypage/mock_LpaStoreResolvingService_test.go @@ -5,7 +5,7 @@ package attorneypage import ( context "context" - lpastore "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + lpadata "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" mock "github.com/stretchr/testify/mock" ) @@ -23,23 +23,23 @@ func (_m *mockLpaStoreResolvingService) EXPECT() *mockLpaStoreResolvingService_E } // Get provides a mock function with given fields: ctx -func (_m *mockLpaStoreResolvingService) Get(ctx context.Context) (*lpastore.Lpa, error) { +func (_m *mockLpaStoreResolvingService) Get(ctx context.Context) (*lpadata.Lpa, error) { ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for Get") } - var r0 *lpastore.Lpa + var r0 *lpadata.Lpa var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (*lpastore.Lpa, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context) (*lpadata.Lpa, error)); ok { return rf(ctx) } - if rf, ok := ret.Get(0).(func(context.Context) *lpastore.Lpa); ok { + if rf, ok := ret.Get(0).(func(context.Context) *lpadata.Lpa); ok { r0 = rf(ctx) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*lpastore.Lpa) + r0 = ret.Get(0).(*lpadata.Lpa) } } @@ -70,12 +70,12 @@ func (_c *mockLpaStoreResolvingService_Get_Call) Run(run func(ctx context.Contex return _c } -func (_c *mockLpaStoreResolvingService_Get_Call) Return(_a0 *lpastore.Lpa, _a1 error) *mockLpaStoreResolvingService_Get_Call { +func (_c *mockLpaStoreResolvingService_Get_Call) Return(_a0 *lpadata.Lpa, _a1 error) *mockLpaStoreResolvingService_Get_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockLpaStoreResolvingService_Get_Call) RunAndReturn(run func(context.Context) (*lpastore.Lpa, error)) *mockLpaStoreResolvingService_Get_Call { +func (_c *mockLpaStoreResolvingService_Get_Call) RunAndReturn(run func(context.Context) (*lpadata.Lpa, error)) *mockLpaStoreResolvingService_Get_Call { _c.Call.Return(run) return _c } diff --git a/internal/attorney/attorneypage/mock_NotifyClient_test.go b/internal/attorney/attorneypage/mock_NotifyClient_test.go index 2aa34a0bbb..681ce58674 100644 --- a/internal/attorney/attorneypage/mock_NotifyClient_test.go +++ b/internal/attorney/attorneypage/mock_NotifyClient_test.go @@ -5,7 +5,7 @@ package attorneypage import ( context "context" - lpastore "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + lpadata "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" mock "github.com/stretchr/testify/mock" notify "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" @@ -25,7 +25,7 @@ func (_m *mockNotifyClient) EXPECT() *mockNotifyClient_Expecter { } // EmailGreeting provides a mock function with given fields: lpa -func (_m *mockNotifyClient) EmailGreeting(lpa *lpastore.Lpa) string { +func (_m *mockNotifyClient) EmailGreeting(lpa *lpadata.Lpa) string { ret := _m.Called(lpa) if len(ret) == 0 { @@ -33,7 +33,7 @@ func (_m *mockNotifyClient) EmailGreeting(lpa *lpastore.Lpa) string { } var r0 string - if rf, ok := ret.Get(0).(func(*lpastore.Lpa) string); ok { + if rf, ok := ret.Get(0).(func(*lpadata.Lpa) string); ok { r0 = rf(lpa) } else { r0 = ret.Get(0).(string) @@ -48,14 +48,14 @@ type mockNotifyClient_EmailGreeting_Call struct { } // EmailGreeting is a helper method to define mock.On call -// - lpa *lpastore.Lpa +// - lpa *lpadata.Lpa func (_e *mockNotifyClient_Expecter) EmailGreeting(lpa interface{}) *mockNotifyClient_EmailGreeting_Call { return &mockNotifyClient_EmailGreeting_Call{Call: _e.mock.On("EmailGreeting", lpa)} } -func (_c *mockNotifyClient_EmailGreeting_Call) Run(run func(lpa *lpastore.Lpa)) *mockNotifyClient_EmailGreeting_Call { +func (_c *mockNotifyClient_EmailGreeting_Call) Run(run func(lpa *lpadata.Lpa)) *mockNotifyClient_EmailGreeting_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*lpastore.Lpa)) + run(args[0].(*lpadata.Lpa)) }) return _c } @@ -65,7 +65,7 @@ func (_c *mockNotifyClient_EmailGreeting_Call) Return(_a0 string) *mockNotifyCli return _c } -func (_c *mockNotifyClient_EmailGreeting_Call) RunAndReturn(run func(*lpastore.Lpa) string) *mockNotifyClient_EmailGreeting_Call { +func (_c *mockNotifyClient_EmailGreeting_Call) RunAndReturn(run func(*lpadata.Lpa) string) *mockNotifyClient_EmailGreeting_Call { _c.Call.Return(run) return _c } diff --git a/internal/attorney/attorneypage/progress.go b/internal/attorney/attorneypage/progress.go index 01815481f3..8d8d4fd4fc 100644 --- a/internal/attorney/attorneypage/progress.go +++ b/internal/attorney/attorneypage/progress.go @@ -6,14 +6,14 @@ import ( "github.com/ministryofjustice/opg-go-common/template" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) type progressData struct { App appcontext.Data Errors validation.List - Lpa *lpastore.Lpa + Lpa *lpadata.Lpa Signed bool AttorneysSigned bool } diff --git a/internal/attorney/attorneypage/progress_test.go b/internal/attorney/attorneypage/progress_test.go index b4c5e57f34..1752d2745a 100644 --- a/internal/attorney/attorneypage/progress_test.go +++ b/internal/attorney/attorneypage/progress_test.go @@ -7,7 +7,7 @@ import ( "time" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/stretchr/testify/assert" ) @@ -17,7 +17,7 @@ func TestProgress(t *testing.T) { testcases := map[string]struct { attorney *attorneydata.Provided - attorneys []lpastore.Attorney + attorneys []lpadata.Attorney signed bool attorneysSigned bool }{ @@ -28,12 +28,12 @@ func TestProgress(t *testing.T) { attorney: &attorneydata.Provided{ SignedAt: attorneySignedAt, }, - attorneys: []lpastore.Attorney{{}}, + attorneys: []lpadata.Attorney{{}}, signed: true, }, "all signed": { attorney: &attorneydata.Provided{}, - attorneys: []lpastore.Attorney{{ + attorneys: []lpadata.Attorney{{ SignedAt: attorneySignedAt, }}, attorneysSigned: true, @@ -45,9 +45,9 @@ func TestProgress(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &lpastore.Lpa{ + donor := &lpadata.Lpa{ SignedAt: lpaSignedAt, - Attorneys: lpastore.Attorneys{Attorneys: tc.attorneys}, + Attorneys: lpadata.Attorneys{Attorneys: tc.attorneys}, } lpaStoreResolvingService := newMockLpaStoreResolvingService(t) @@ -73,7 +73,7 @@ func TestProgressWhenLpaStoreResolvingServiceErrors(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &lpastore.Lpa{} + donor := &lpadata.Lpa{} lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). @@ -91,11 +91,11 @@ func TestProgressWhenTemplateErrors(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, nil) + Return(&lpadata.Lpa{}, nil) template := newMockTemplate(t) template.EXPECT(). - Execute(w, &progressData{App: testAppData, Lpa: &lpastore.Lpa{}}). + Execute(w, &progressData{App: testAppData, Lpa: &lpadata.Lpa{}}). Return(expectedError) err := Progress(template.Execute, lpaStoreResolvingService)(testAppData, w, r, &attorneydata.Provided{}) diff --git a/internal/attorney/attorneypage/read_the_lpa.go b/internal/attorney/attorneypage/read_the_lpa.go index c22918fab8..880c94ee59 100644 --- a/internal/attorney/attorneypage/read_the_lpa.go +++ b/internal/attorney/attorneypage/read_the_lpa.go @@ -7,7 +7,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -15,7 +15,7 @@ import ( type readTheLpaData struct { App appcontext.Data Errors validation.List - Lpa *lpastore.Lpa + Lpa *lpadata.Lpa } func ReadTheLpa(tmpl template.Template, lpaStoreResolvingService LpaStoreResolvingService, attorneyStore AttorneyStore) Handler { diff --git a/internal/attorney/attorneypage/read_the_lpa_test.go b/internal/attorney/attorneypage/read_the_lpa_test.go index bd689e7d75..2843f251b9 100644 --- a/internal/attorney/attorneypage/read_the_lpa_test.go +++ b/internal/attorney/attorneypage/read_the_lpa_test.go @@ -8,7 +8,7 @@ import ( "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/attorney/attorneydata" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" ) @@ -21,13 +21,13 @@ func TestGetReadTheLpaWithAttorney(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{UID: uid}}}}, nil) + Return(&lpadata.Lpa{Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{UID: uid}}}}, nil) template := newMockTemplate(t) template.EXPECT(). Execute(w, &readTheLpaData{ App: testAppData, - Lpa: &lpastore.Lpa{Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{UID: uid}}}}, + Lpa: &lpadata.Lpa{Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{UID: uid}}}}, }). Return(nil) @@ -46,13 +46,13 @@ func TestGetReadTheLpaWithReplacementAttorney(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{ReplacementAttorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{UID: uid}}}}, nil) + Return(&lpadata.Lpa{ReplacementAttorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{UID: uid}}}}, nil) template := newMockTemplate(t) template.EXPECT(). Execute(w, &readTheLpaData{ App: testReplacementAppData, - Lpa: &lpastore.Lpa{ReplacementAttorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{UID: uid}}}}, + Lpa: &lpadata.Lpa{ReplacementAttorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{UID: uid}}}}, }). Return(nil) @@ -71,7 +71,7 @@ func TestGetReadTheLpaWithAttorneyWhenLpaStoreResolvingServiceErrors(t *testing. lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{UID: uid}}}}, expectedError) + Return(&lpadata.Lpa{Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{UID: uid}}}}, expectedError) err := ReadTheLpa(nil, lpaStoreResolvingService, nil)(testAppData, w, r, nil) resp := w.Result() @@ -88,13 +88,13 @@ func TestGetReadTheLpaWhenTemplateError(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{UID: uid}}}}, nil) + Return(&lpadata.Lpa{Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{UID: uid}}}}, nil) template := newMockTemplate(t) template.EXPECT(). Execute(w, &readTheLpaData{ App: testAppData, - Lpa: &lpastore.Lpa{Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{UID: uid}}}}, + Lpa: &lpadata.Lpa{Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{UID: uid}}}}, }). Return(expectedError) diff --git a/internal/attorney/attorneypage/register.go b/internal/attorney/attorneypage/register.go index 2d5e244057..2509479be0 100644 --- a/internal/attorney/attorneypage/register.go +++ b/internal/attorney/attorneypage/register.go @@ -13,7 +13,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/onelogin" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" @@ -28,7 +28,7 @@ type Localizer interface { } type LpaStoreResolvingService interface { - Get(ctx context.Context) (*lpastore.Lpa, error) + Get(ctx context.Context) (*lpadata.Lpa, error) } type Handler func(data appcontext.Data, w http.ResponseWriter, r *http.Request, details *attorneydata.Provided) error @@ -79,11 +79,11 @@ type DashboardStore interface { } type LpaStoreClient interface { - SendAttorney(context.Context, *lpastore.Lpa, *attorneydata.Provided) error + SendAttorney(context.Context, *lpadata.Lpa, *attorneydata.Provided) error } type NotifyClient interface { - EmailGreeting(lpa *lpastore.Lpa) string + EmailGreeting(lpa *lpadata.Lpa) string SendActorEmail(ctx context.Context, to, lpaUID string, email notify.Email) error } diff --git a/internal/attorney/attorneypage/sign.go b/internal/attorney/attorneypage/sign.go index e80bd835e2..21fb6d1415 100644 --- a/internal/attorney/attorneypage/sign.go +++ b/internal/attorney/attorneypage/sign.go @@ -8,7 +8,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -18,8 +18,8 @@ type signData struct { App appcontext.Data Errors validation.List LpaID string - Attorney lpastore.Attorney - TrustCorporation lpastore.TrustCorporation + Attorney lpadata.Attorney + TrustCorporation lpadata.TrustCorporation IsReplacement bool IsSecondSignatory bool LpaCanBeUsedWhenHasCapacity bool @@ -33,7 +33,7 @@ func Sign( lpaStoreClient LpaStoreClient, now func() time.Time, ) Handler { - signAttorney := func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, attorneyProvidedDetails *attorneydata.Provided, lpa *lpastore.Lpa) error { + signAttorney := func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, attorneyProvidedDetails *attorneydata.Provided, lpa *lpadata.Lpa) error { data := &signData{ App: appData, LpaID: lpa.LpaID, @@ -83,7 +83,7 @@ func Sign( return tmpl(w, data) } - signTrustCorporation := func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, attorneyProvidedDetails *attorneydata.Provided, lpa *lpastore.Lpa) error { + signTrustCorporation := func(appData appcontext.Data, w http.ResponseWriter, r *http.Request, attorneyProvidedDetails *attorneydata.Provided, lpa *lpadata.Lpa) error { signatoryIndex := 0 if r.URL.Query().Has("second") { signatoryIndex = 1 diff --git a/internal/attorney/attorneypage/sign_test.go b/internal/attorney/attorneypage/sign_test.go index debb6cfdb9..b2b48eaaf0 100644 --- a/internal/attorney/attorneypage/sign_test.go +++ b/internal/attorney/attorneypage/sign_test.go @@ -13,7 +13,6 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" @@ -25,105 +24,105 @@ import ( func TestGetSign(t *testing.T) { testcases := map[string]struct { appData appcontext.Data - lpa *lpastore.Lpa + lpa *lpadata.Lpa data *signData }{ "attorney use when registered": { appData: testAppData, - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ SignedAt: time.Now(), WhenCanTheLpaBeUsed: lpadata.CanBeUsedWhenHasCapacity, - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{ + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{ {UID: testUID, FirstNames: "Bob", LastName: "Smith"}, {UID: actoruid.New(), FirstNames: "Dave", LastName: "Smith"}, }}, - CertificateProvider: lpastore.CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ SignedAt: time.Now(), }, }, data: &signData{ App: testAppData, Form: &signForm{}, - Attorney: lpastore.Attorney{UID: testUID, FirstNames: "Bob", LastName: "Smith"}, + Attorney: lpadata.Attorney{UID: testUID, FirstNames: "Bob", LastName: "Smith"}, LpaCanBeUsedWhenHasCapacity: true, }, }, "attorney use when capacity lost": { appData: testAppData, - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ SignedAt: time.Now(), WhenCanTheLpaBeUsed: lpadata.CanBeUsedWhenCapacityLost, - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{ + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{ {UID: testUID, FirstNames: "Bob", LastName: "Smith"}, {UID: actoruid.New(), FirstNames: "Dave", LastName: "Smith"}, }}, - CertificateProvider: lpastore.CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ SignedAt: time.Now(), }, }, data: &signData{ App: testAppData, Form: &signForm{}, - Attorney: lpastore.Attorney{UID: testUID, FirstNames: "Bob", LastName: "Smith"}, + Attorney: lpadata.Attorney{UID: testUID, FirstNames: "Bob", LastName: "Smith"}, }, }, "replacement attorney use when registered": { appData: testReplacementAppData, - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ SignedAt: time.Now(), WhenCanTheLpaBeUsed: lpadata.CanBeUsedWhenHasCapacity, - ReplacementAttorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{ + ReplacementAttorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{ {UID: testUID, FirstNames: "Bob", LastName: "Smith"}, {UID: actoruid.New(), FirstNames: "Dave", LastName: "Smith"}, }}, - CertificateProvider: lpastore.CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ SignedAt: time.Now(), }, }, data: &signData{ App: testReplacementAppData, Form: &signForm{}, - Attorney: lpastore.Attorney{UID: testUID, FirstNames: "Bob", LastName: "Smith"}, + Attorney: lpadata.Attorney{UID: testUID, FirstNames: "Bob", LastName: "Smith"}, IsReplacement: true, LpaCanBeUsedWhenHasCapacity: true, }, }, "replacement attorney use when capacity lost": { appData: testReplacementAppData, - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ SignedAt: time.Now(), WhenCanTheLpaBeUsed: lpadata.CanBeUsedWhenCapacityLost, - ReplacementAttorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{ + ReplacementAttorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{ {UID: testUID, FirstNames: "Bob", LastName: "Smith"}, {UID: actoruid.New(), FirstNames: "Dave", LastName: "Smith"}, }}, - CertificateProvider: lpastore.CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ SignedAt: time.Now(), }, }, data: &signData{ App: testReplacementAppData, Form: &signForm{}, - Attorney: lpastore.Attorney{UID: testUID, FirstNames: "Bob", LastName: "Smith"}, + Attorney: lpadata.Attorney{UID: testUID, FirstNames: "Bob", LastName: "Smith"}, IsReplacement: true, }, }, "trust corporation": { appData: testTrustCorporationAppData, - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ SignedAt: time.Now(), WhenCanTheLpaBeUsed: lpadata.CanBeUsedWhenHasCapacity, - Attorneys: lpastore.Attorneys{TrustCorporation: lpastore.TrustCorporation{ + Attorneys: lpadata.Attorneys{TrustCorporation: lpadata.TrustCorporation{ Name: "Corp", }}, - CertificateProvider: lpastore.CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ SignedAt: time.Now(), }, }, data: &signData{ App: testTrustCorporationAppData, Form: &signForm{}, - TrustCorporation: lpastore.TrustCorporation{Name: "Corp"}, + TrustCorporation: lpadata.TrustCorporation{Name: "Corp"}, LpaCanBeUsedWhenHasCapacity: true, }, }, @@ -189,13 +188,13 @@ func TestGetSignCantSignYet(t *testing.T) { testcases := map[string]struct { appData appcontext.Data - lpa *lpastore.Lpa + lpa *lpadata.Lpa }{ "submitted but not certified": { appData: testAppData, - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ SignedAt: time.Now(), - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{ + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{ {UID: uid, FirstNames: "Bob", LastName: "Smith"}, {UID: actoruid.New(), FirstNames: "Dave", LastName: "Smith"}, }}, @@ -203,13 +202,13 @@ func TestGetSignCantSignYet(t *testing.T) { }, "certified but not submitted": { appData: testAppData, - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ WhenCanTheLpaBeUsed: lpadata.CanBeUsedWhenCapacityLost, - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{ + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{ {UID: uid, FirstNames: "Bob", LastName: "Smith"}, {UID: actoruid.New(), FirstNames: "Dave", LastName: "Smith"}, }}, - CertificateProvider: lpastore.CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ SignedAt: time.Now(), }, }, @@ -241,28 +240,28 @@ func TestGetSignWhenAttorneyDoesNotExist(t *testing.T) { testcases := map[string]struct { appData appcontext.Data - lpa *lpastore.Lpa + lpa *lpadata.Lpa }{ "attorney": { appData: testAppData, - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ SignedAt: time.Now(), - ReplacementAttorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{ + ReplacementAttorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{ {UID: uid, FirstNames: "Bob", LastName: "Smith"}, }}, - CertificateProvider: lpastore.CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ SignedAt: time.Now(), }, }, }, "replacement attorney": { appData: testReplacementAppData, - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ SignedAt: time.Now(), - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{ + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{ {UID: uid, FirstNames: "Bob", LastName: "Smith"}, }}, - CertificateProvider: lpastore.CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ SignedAt: time.Now(), }, }, @@ -298,7 +297,7 @@ func TestGetSignOnLpaStoreResolvingServiceError(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, expectedError) + Return(&lpadata.Lpa{}, expectedError) err := Sign(template.Execute, lpaStoreResolvingService, nil, nil, nil)(testAppData, w, r, &attorneydata.Provided{}) resp := w.Result() @@ -319,10 +318,10 @@ func TestGetSignOnTemplateError(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{ + Return(&lpadata.Lpa{ SignedAt: time.Now(), - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{UID: testUID}}}, - CertificateProvider: lpastore.CertificateProvider{SignedAt: time.Now()}, + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{UID: testUID}}}, + CertificateProvider: lpadata.CertificateProvider{SignedAt: time.Now()}, }, nil) err := Sign(template.Execute, lpaStoreResolvingService, nil, nil, nil)(testAppData, w, r, &attorneydata.Provided{}) @@ -340,16 +339,16 @@ func TestPostSign(t *testing.T) { url string appData appcontext.Data form url.Values - lpa *lpastore.Lpa + lpa *lpadata.Lpa updatedAttorney *attorneydata.Provided }{ "attorney": { appData: testAppData, form: url.Values{"confirm": {"1"}}, - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ SignedAt: lpaSignedAt, - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{UID: testUID, FirstNames: "Bob", LastName: "Smith"}}}, - CertificateProvider: lpastore.CertificateProvider{SignedAt: time.Now()}, + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{UID: testUID, FirstNames: "Bob", LastName: "Smith"}}}, + CertificateProvider: lpadata.CertificateProvider{SignedAt: time.Now()}, }, updatedAttorney: &attorneydata.Provided{ LpaID: "lpa-id", @@ -360,10 +359,10 @@ func TestPostSign(t *testing.T) { "replacement attorney": { appData: testReplacementAppData, form: url.Values{"confirm": {"1"}}, - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ SignedAt: lpaSignedAt, - ReplacementAttorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{UID: testUID, FirstNames: "Bob", LastName: "Smith"}}}, - CertificateProvider: lpastore.CertificateProvider{SignedAt: time.Now()}, + ReplacementAttorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{UID: testUID, FirstNames: "Bob", LastName: "Smith"}}}, + CertificateProvider: lpadata.CertificateProvider{SignedAt: time.Now()}, }, updatedAttorney: &attorneydata.Provided{ LpaID: "lpa-id", @@ -380,10 +379,10 @@ func TestPostSign(t *testing.T) { "professional-title": {"c"}, "confirm": {"1"}, }, - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ SignedAt: lpaSignedAt, - Attorneys: lpastore.Attorneys{TrustCorporation: lpastore.TrustCorporation{Name: "Corp"}}, - CertificateProvider: lpastore.CertificateProvider{SignedAt: time.Now()}, + Attorneys: lpadata.Attorneys{TrustCorporation: lpadata.TrustCorporation{Name: "Corp"}}, + CertificateProvider: lpadata.CertificateProvider{SignedAt: time.Now()}, }, updatedAttorney: &attorneydata.Provided{ LpaID: "lpa-id", @@ -405,10 +404,10 @@ func TestPostSign(t *testing.T) { "professional-title": {"c"}, "confirm": {"1"}, }, - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ SignedAt: lpaSignedAt, - ReplacementAttorneys: lpastore.Attorneys{TrustCorporation: lpastore.TrustCorporation{Name: "Corp"}}, - CertificateProvider: lpastore.CertificateProvider{SignedAt: time.Now()}, + ReplacementAttorneys: lpadata.Attorneys{TrustCorporation: lpadata.TrustCorporation{Name: "Corp"}}, + CertificateProvider: lpadata.CertificateProvider{SignedAt: time.Now()}, }, updatedAttorney: &attorneydata.Provided{ LpaID: "lpa-id", @@ -464,16 +463,16 @@ func TestPostSignWhenSignedInLpaStore(t *testing.T) { url string appData appcontext.Data form url.Values - lpa *lpastore.Lpa + lpa *lpadata.Lpa updatedAttorney *attorneydata.Provided }{ "attorney": { appData: testAppData, form: url.Values{"confirm": {"1"}}, - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ SignedAt: lpaSignedAt, - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{UID: testUID, FirstNames: "Bob", LastName: "Smith", SignedAt: attorneySignedAt}}}, - CertificateProvider: lpastore.CertificateProvider{SignedAt: time.Now()}, + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{UID: testUID, FirstNames: "Bob", LastName: "Smith", SignedAt: attorneySignedAt}}}, + CertificateProvider: lpadata.CertificateProvider{SignedAt: time.Now()}, }, updatedAttorney: &attorneydata.Provided{ LpaID: "lpa-id", @@ -484,10 +483,10 @@ func TestPostSignWhenSignedInLpaStore(t *testing.T) { "replacement attorney": { appData: testReplacementAppData, form: url.Values{"confirm": {"1"}}, - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ SignedAt: lpaSignedAt, - ReplacementAttorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{UID: testUID, FirstNames: "Bob", LastName: "Smith", SignedAt: attorneySignedAt}}}, - CertificateProvider: lpastore.CertificateProvider{SignedAt: time.Now()}, + ReplacementAttorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{UID: testUID, FirstNames: "Bob", LastName: "Smith", SignedAt: attorneySignedAt}}}, + CertificateProvider: lpadata.CertificateProvider{SignedAt: time.Now()}, }, updatedAttorney: &attorneydata.Provided{ LpaID: "lpa-id", @@ -504,10 +503,10 @@ func TestPostSignWhenSignedInLpaStore(t *testing.T) { "professional-title": {"c"}, "confirm": {"1"}, }, - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ SignedAt: lpaSignedAt, - Attorneys: lpastore.Attorneys{TrustCorporation: lpastore.TrustCorporation{Name: "Corp", Signatories: []lpastore.TrustCorporationSignatory{{}, {SignedAt: attorneySignedAt}}}}, - CertificateProvider: lpastore.CertificateProvider{SignedAt: time.Now()}, + Attorneys: lpadata.Attorneys{TrustCorporation: lpadata.TrustCorporation{Name: "Corp", Signatories: []lpadata.TrustCorporationSignatory{{}, {SignedAt: attorneySignedAt}}}}, + CertificateProvider: lpadata.CertificateProvider{SignedAt: time.Now()}, }, updatedAttorney: &attorneydata.Provided{ LpaID: "lpa-id", @@ -529,10 +528,10 @@ func TestPostSignWhenSignedInLpaStore(t *testing.T) { "professional-title": {"c"}, "confirm": {"1"}, }, - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ SignedAt: lpaSignedAt, - ReplacementAttorneys: lpastore.Attorneys{TrustCorporation: lpastore.TrustCorporation{Name: "Corp", Signatories: []lpastore.TrustCorporationSignatory{{}, {SignedAt: attorneySignedAt}}}}, - CertificateProvider: lpastore.CertificateProvider{SignedAt: time.Now()}, + ReplacementAttorneys: lpadata.Attorneys{TrustCorporation: lpadata.TrustCorporation{Name: "Corp", Signatories: []lpadata.TrustCorporationSignatory{{}, {SignedAt: attorneySignedAt}}}}, + CertificateProvider: lpadata.CertificateProvider{SignedAt: time.Now()}, }, updatedAttorney: &attorneydata.Provided{ LpaID: "lpa-id", @@ -582,7 +581,7 @@ func TestPostSignWhenWantSecondSignatory(t *testing.T) { url string appData appcontext.Data form url.Values - lpa *lpastore.Lpa + lpa *lpadata.Lpa updatedAttorney *attorneydata.Provided }{ "trust corporation": { @@ -593,10 +592,10 @@ func TestPostSignWhenWantSecondSignatory(t *testing.T) { "professional-title": {"c"}, "confirm": {"1"}, }, - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ SignedAt: lpaSignedAt, - Attorneys: lpastore.Attorneys{TrustCorporation: lpastore.TrustCorporation{Name: "Corp"}}, - CertificateProvider: lpastore.CertificateProvider{SignedAt: time.Now()}, + Attorneys: lpadata.Attorneys{TrustCorporation: lpadata.TrustCorporation{Name: "Corp"}}, + CertificateProvider: lpadata.CertificateProvider{SignedAt: time.Now()}, }, updatedAttorney: &attorneydata.Provided{ LpaID: "lpa-id", @@ -617,10 +616,10 @@ func TestPostSignWhenWantSecondSignatory(t *testing.T) { "professional-title": {"c"}, "confirm": {"1"}, }, - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ SignedAt: lpaSignedAt, - ReplacementAttorneys: lpastore.Attorneys{TrustCorporation: lpastore.TrustCorporation{Name: "Corp"}}, - CertificateProvider: lpastore.CertificateProvider{SignedAt: time.Now()}, + ReplacementAttorneys: lpadata.Attorneys{TrustCorporation: lpadata.TrustCorporation{Name: "Corp"}}, + CertificateProvider: lpadata.CertificateProvider{SignedAt: time.Now()}, }, updatedAttorney: &attorneydata.Provided{ LpaID: "lpa-id", @@ -672,10 +671,10 @@ func TestPostSignWhenLpaStoreClientErrors(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{ + Return(&lpadata.Lpa{ SignedAt: time.Now(), - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{UID: testUID, FirstNames: "Bob", LastName: "Smith"}}}, - CertificateProvider: lpastore.CertificateProvider{SignedAt: time.Now()}, + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{UID: testUID, FirstNames: "Bob", LastName: "Smith"}}}, + CertificateProvider: lpadata.CertificateProvider{SignedAt: time.Now()}, }, nil) lpaStoreClient := newMockLpaStoreClient(t) @@ -699,10 +698,10 @@ func TestPostSignWhenStoreError(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{ + Return(&lpadata.Lpa{ SignedAt: time.Now(), - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{UID: testUID, FirstNames: "Bob", LastName: "Smith"}}}, - CertificateProvider: lpastore.CertificateProvider{SignedAt: time.Now()}, + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{UID: testUID, FirstNames: "Bob", LastName: "Smith"}}}, + CertificateProvider: lpadata.CertificateProvider{SignedAt: time.Now()}, }, nil) lpaStoreClient := newMockLpaStoreClient(t) @@ -732,10 +731,10 @@ func TestPostSignOnValidationError(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{ + Return(&lpadata.Lpa{ SignedAt: time.Now(), - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{UID: testUID, FirstNames: "Bob", LastName: "Smith"}}}, - CertificateProvider: lpastore.CertificateProvider{SignedAt: time.Now()}, + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{UID: testUID, FirstNames: "Bob", LastName: "Smith"}}}, + CertificateProvider: lpadata.CertificateProvider{SignedAt: time.Now()}, }, nil) template := newMockTemplate(t) @@ -743,7 +742,7 @@ func TestPostSignOnValidationError(t *testing.T) { Execute(w, &signData{ App: testAppData, Form: &signForm{}, - Attorney: lpastore.Attorney{UID: testUID, FirstNames: "Bob", LastName: "Smith"}, + Attorney: lpadata.Attorney{UID: testUID, FirstNames: "Bob", LastName: "Smith"}, Errors: validation.With("confirm", validation.CustomError{Label: "youMustSelectTheBoxToSignAttorney"}), }). Return(nil) diff --git a/internal/attorney/attorneypage/task_list.go b/internal/attorney/attorneypage/task_list.go index 015fc4db8c..5bfe106e66 100644 --- a/internal/attorney/attorneypage/task_list.go +++ b/internal/attorney/attorneypage/task_list.go @@ -7,7 +7,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -15,7 +15,7 @@ import ( type taskListData struct { App appcontext.Data Errors validation.List - Lpa *lpastore.Lpa + Lpa *lpadata.Lpa Items []taskListItem } diff --git a/internal/attorney/attorneypage/task_list_test.go b/internal/attorney/attorneypage/task_list_test.go index afceaff302..11c8ad4904 100644 --- a/internal/attorney/attorneypage/task_list_test.go +++ b/internal/attorney/attorneypage/task_list_test.go @@ -10,7 +10,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -18,13 +18,13 @@ import ( func TestGetTaskList(t *testing.T) { testCases := map[string]struct { - lpa *lpastore.Lpa + lpa *lpadata.Lpa attorney *attorneydata.Provided appData appcontext.Data expected func([]taskListItem) []taskListItem }{ "empty": { - lpa: &lpastore.Lpa{LpaID: "lpa-id"}, + lpa: &lpadata.Lpa{LpaID: "lpa-id"}, attorney: &attorneydata.Provided{}, appData: testAppData, expected: func(items []taskListItem) []taskListItem { @@ -32,7 +32,7 @@ func TestGetTaskList(t *testing.T) { }, }, "trust corporation": { - lpa: &lpastore.Lpa{LpaID: "lpa-id"}, + lpa: &lpadata.Lpa{LpaID: "lpa-id"}, attorney: &attorneydata.Provided{}, appData: testTrustCorporationAppData, expected: func(items []taskListItem) []taskListItem { @@ -42,10 +42,10 @@ func TestGetTaskList(t *testing.T) { }, }, "trust corporation with two signatories": { - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ LpaID: "lpa-id", SignedAt: time.Now(), - CertificateProvider: lpastore.CertificateProvider{SignedAt: time.Now()}, + CertificateProvider: lpadata.CertificateProvider{SignedAt: time.Now()}, }, attorney: &attorneydata.Provided{ WouldLikeSecondSignatory: form.Yes, @@ -69,7 +69,7 @@ func TestGetTaskList(t *testing.T) { }, }, "tasks completed not signed": { - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ LpaID: "lpa-id", SignedAt: time.Now(), }, @@ -88,10 +88,10 @@ func TestGetTaskList(t *testing.T) { }, }, "tasks completed and signed": { - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ LpaID: "lpa-id", SignedAt: time.Now(), - CertificateProvider: lpastore.CertificateProvider{SignedAt: time.Now()}, + CertificateProvider: lpadata.CertificateProvider{SignedAt: time.Now()}, }, attorney: &attorneydata.Provided{ Tasks: attorneydata.Tasks{ @@ -109,10 +109,10 @@ func TestGetTaskList(t *testing.T) { }, }, "completed": { - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ LpaID: "lpa-id", SignedAt: time.Now(), - CertificateProvider: lpastore.CertificateProvider{SignedAt: time.Now()}, + CertificateProvider: lpadata.CertificateProvider{SignedAt: time.Now()}, }, attorney: &attorneydata.Provided{ Tasks: attorneydata.Tasks{ @@ -132,10 +132,10 @@ func TestGetTaskList(t *testing.T) { }, }, "completed replacement": { - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ LpaID: "lpa-id", SignedAt: time.Now(), - CertificateProvider: lpastore.CertificateProvider{SignedAt: time.Now()}, + CertificateProvider: lpadata.CertificateProvider{SignedAt: time.Now()}, }, attorney: &attorneydata.Provided{ Tasks: attorneydata.Tasks{ @@ -195,7 +195,7 @@ func TestGetTaskListWhenLpaStoreResolvingServiceErrors(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, expectedError) + Return(&lpadata.Lpa{}, expectedError) err := TaskList(nil, lpaStoreResolvingService)(testAppData, w, r, nil) @@ -209,7 +209,7 @@ func TestGetTaskListWhenTemplateErrors(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{LpaID: "lpa-id"}, nil) + Return(&lpadata.Lpa{LpaID: "lpa-id"}, nil) template := newMockTemplate(t) template.EXPECT(). diff --git a/internal/attorney/attorneypage/would_like_second_signatory_test.go b/internal/attorney/attorneypage/would_like_second_signatory_test.go index 04377a7c8b..38a8a3d231 100644 --- a/internal/attorney/attorneypage/would_like_second_signatory_test.go +++ b/internal/attorney/attorneypage/would_like_second_signatory_test.go @@ -12,7 +12,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney" "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" "github.com/stretchr/testify/assert" @@ -100,7 +100,7 @@ func TestPostWouldLikeSecondSignatoryWhenYes(t *testing.T) { } func TestPostWouldLikeSecondSignatoryWhenNo(t *testing.T) { - donor := &lpastore.Lpa{SignedAt: time.Now()} + donor := &lpadata.Lpa{SignedAt: time.Now()} updatedAttorney := &attorneydata.Provided{ LpaID: "lpa-id", WouldLikeSecondSignatory: form.No, @@ -142,21 +142,21 @@ func TestPostWouldLikeSecondSignatoryWhenNo(t *testing.T) { func TestPostWouldLikeSecondSignatoryWhenNoAndSignedInLpaStore(t *testing.T) { testcases := map[string]struct { appData appcontext.Data - lpa *lpastore.Lpa + lpa *lpadata.Lpa }{ "trust corporation": { appData: testTrustCorporationAppData, - lpa: &lpastore.Lpa{ - Attorneys: lpastore.Attorneys{TrustCorporation: lpastore.TrustCorporation{ - Signatories: []lpastore.TrustCorporationSignatory{{SignedAt: time.Now()}}, + lpa: &lpadata.Lpa{ + Attorneys: lpadata.Attorneys{TrustCorporation: lpadata.TrustCorporation{ + Signatories: []lpadata.TrustCorporationSignatory{{SignedAt: time.Now()}}, }}, }, }, "replacement trust corporation": { appData: testReplacementTrustCorporationAppData, - lpa: &lpastore.Lpa{ - ReplacementAttorneys: lpastore.Attorneys{TrustCorporation: lpastore.TrustCorporation{ - Signatories: []lpastore.TrustCorporationSignatory{{SignedAt: time.Now()}}, + lpa: &lpadata.Lpa{ + ReplacementAttorneys: lpadata.Attorneys{TrustCorporation: lpadata.TrustCorporation{ + Signatories: []lpadata.TrustCorporationSignatory{{SignedAt: time.Now()}}, }}, }, }, @@ -200,7 +200,7 @@ func TestPostWouldLikeSecondSignatoryWhenNoAndSignedInLpaStore(t *testing.T) { } func TestPostWouldLikeSecondSignatoryWhenLpaStoreClientErrors(t *testing.T) { - donor := &lpastore.Lpa{SignedAt: time.Now()} + donor := &lpadata.Lpa{SignedAt: time.Now()} f := url.Values{ form.FieldNames.YesNo: {form.No.String()}, @@ -254,7 +254,7 @@ func TestPostWouldLikeSecondSignatoryWhenAttorneyStoreErrors(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, nil) + Return(&lpadata.Lpa{}, nil) lpaStoreClient := newMockLpaStoreClient(t) lpaStoreClient.EXPECT(). diff --git a/internal/attorney/attorneypage/your_preferred_language.go b/internal/attorney/attorneypage/your_preferred_language.go index 6d7af03aaf..2f56ec4186 100644 --- a/internal/attorney/attorneypage/your_preferred_language.go +++ b/internal/attorney/attorneypage/your_preferred_language.go @@ -9,7 +9,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -19,7 +19,7 @@ type yourPreferredLanguageData struct { Form *form.LanguagePreferenceForm Options localize.LangOptions FieldName string - Lpa *lpastore.Lpa + Lpa *lpadata.Lpa } func YourPreferredLanguage(tmpl template.Template, attorneyStore AttorneyStore, lpaStoreResolvingService LpaStoreResolvingService) Handler { diff --git a/internal/attorney/attorneypage/your_preferred_language_test.go b/internal/attorney/attorneypage/your_preferred_language_test.go index 9afa4e4781..7d065ad10b 100644 --- a/internal/attorney/attorneypage/your_preferred_language_test.go +++ b/internal/attorney/attorneypage/your_preferred_language_test.go @@ -12,7 +12,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/attorney/attorneydata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "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 TestGetYourPreferredLanguage(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, nil) + Return(&lpadata.Lpa{}, nil) template := newMockTemplate(t) template.EXPECT(). @@ -37,7 +37,7 @@ func TestGetYourPreferredLanguage(t *testing.T) { }, Options: localize.LangValues, FieldName: form.FieldNames.LanguagePreference, - Lpa: &lpastore.Lpa{}, + Lpa: &lpadata.Lpa{}, }). Return(nil) @@ -56,7 +56,7 @@ func TestGetYourPreferredLanguageWhenLpaStoreResolvingServiceError(t *testing.T) lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, expectedError) + Return(&lpadata.Lpa{}, expectedError) err := YourPreferredLanguage(nil, nil, lpaStoreResolvingService)(testAppData, w, r, &attorneydata.Provided{LpaID: "lpa-id", ContactLanguagePreference: localize.Cy}) @@ -73,7 +73,7 @@ func TestGetYourPreferredLanguageWhenTemplateError(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, nil) + Return(&lpadata.Lpa{}, nil) template := newMockTemplate(t) template.EXPECT(). @@ -102,7 +102,7 @@ func TestPostYourPreferredLanguage(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, nil) + Return(&lpadata.Lpa{}, nil) attorneyStore := newMockAttorneyStore(t) attorneyStore.EXPECT(). @@ -130,7 +130,7 @@ func TestPostYourPreferredLanguageWhenAttorneyStoreError(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, nil) + Return(&lpadata.Lpa{}, nil) attorneyStore := newMockAttorneyStore(t) attorneyStore.EXPECT(). @@ -155,7 +155,7 @@ func TestPostYourPreferredLanguageWhenInvalidData(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, nil) + Return(&lpadata.Lpa{}, nil) template := newMockTemplate(t) template.EXPECT(). @@ -168,7 +168,7 @@ func TestPostYourPreferredLanguageWhenInvalidData(t *testing.T) { Options: localize.LangValues, FieldName: form.FieldNames.LanguagePreference, Errors: validation.With(form.FieldNames.LanguagePreference, validation.SelectError{Label: "whichLanguageYouWouldLikeUsToUseWhenWeContactYou"}), - Lpa: &lpastore.Lpa{}, + Lpa: &lpadata.Lpa{}, }). Return(nil) diff --git a/internal/attorney/mock_test.go b/internal/attorney/mock_test.go index 97d37f09fb..755c556c36 100644 --- a/internal/attorney/mock_test.go +++ b/internal/attorney/mock_test.go @@ -4,10 +4,8 @@ import ( "context" "encoding/json" "errors" - "time" "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" - "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/stretchr/testify/mock" ) @@ -15,10 +13,6 @@ import ( var ( ctx = context.Background() expectedError = errors.New("err") - testNow = time.Date(2023, time.April, 2, 3, 4, 5, 6, time.UTC) - testNowFn = func() time.Time { return testNow } - testUID = actoruid.New() - testUIDFn = func() actoruid.UID { return testUID } ) func (m *mockDynamoClient) ExpectOne(ctx, pk, sk, data interface{}, err error) { 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 2a25af10d2..985fbe0dac 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 @@ -8,7 +8,7 @@ import ( "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/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" @@ -18,7 +18,7 @@ import ( type confirmDontWantToBeCertificateProviderData struct { App appcontext.Data Errors validation.List - Lpa *lpastore.Lpa + Lpa *lpadata.Lpa } func ConfirmDontWantToBeCertificateProvider(tmpl template.Template, lpaStoreResolvingService LpaStoreResolvingService, lpaStoreClient LpaStoreClient, donorStore DonorStore, certificateProviderStore CertificateProviderStore, notifyClient NotifyClient, appPublicURL string) Handler { 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 5b3335f7dc..daba935e8b 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 @@ -9,7 +9,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/donor/donordata" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" @@ -19,7 +19,7 @@ import ( type confirmDontWantToBeCertificateProviderDataLoggedOut struct { App appcontext.Data Errors validation.List - Lpa *lpastore.Lpa + Lpa *lpadata.Lpa } func ConfirmDontWantToBeCertificateProviderLoggedOut(tmpl template.Template, shareCodeStore ShareCodeStore, lpaStoreResolvingService LpaStoreResolvingService, lpaStoreClient LpaStoreClient, donorStore DonorStore, sessionStore SessionStore, notifyClient NotifyClient, appPublicURL string) page.Handler { 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 0873d6cf3f..e3b41ba386 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 @@ -11,7 +11,6 @@ import ( "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/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" @@ -26,7 +25,7 @@ func TestGetConfirmDontWantToBeCertificateProviderLoggedOut(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - lpa := lpastore.Lpa{LpaUID: "lpa-uid"} + lpa := lpadata.Lpa{LpaUID: "lpa-uid"} sessionStore := newMockSessionStore(t) sessionStore.EXPECT(). @@ -87,7 +86,7 @@ func TestGetConfirmDontWantToBeCertificateProviderLoggedOutErrors(t *testing.T) lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(mock.Anything). - Return(&lpastore.Lpa{}, expectedError) + Return(&lpadata.Lpa{}, expectedError) return lpaStoreResolvingService }, @@ -106,7 +105,7 @@ func TestGetConfirmDontWantToBeCertificateProviderLoggedOutErrors(t *testing.T) lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(mock.Anything). - Return(&lpastore.Lpa{}, nil) + Return(&lpadata.Lpa{}, nil) return lpaStoreResolvingService }, @@ -138,19 +137,19 @@ func TestPostConfirmDontWantToBeCertificateProviderLoggedOut(t *testing.T) { ctx := appcontext.ContextWithSession(r.Context(), &appcontext.Session{LpaID: "lpa-id"}) testcases := map[string]struct { - lpa lpastore.Lpa + lpa lpadata.Lpa lpaStoreClient func() *mockLpaStoreClient donorStore func() *mockDonorStore email notify.Email }{ "witnessed and signed": { - lpa: lpastore.Lpa{ + lpa: lpadata.Lpa{ LpaUID: "lpa-uid", SignedAt: time.Now(), - Donor: lpastore.Donor{ + Donor: lpadata.Donor{ FirstNames: "a b", LastName: "c", Email: "a@example.com", }, - CertificateProvider: lpastore.CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ FirstNames: "d e", LastName: "f", }, Type: lpadata.LpaTypePersonalWelfare, @@ -175,11 +174,11 @@ func TestPostConfirmDontWantToBeCertificateProviderLoggedOut(t *testing.T) { }, }, "cannot-register": { - lpa: lpastore.Lpa{ + lpa: lpadata.Lpa{ LpaUID: "lpa-uid", SignedAt: time.Now(), - Donor: lpastore.Donor{FirstNames: "a b", LastName: "c", Email: "a@example.com"}, - CertificateProvider: lpastore.CertificateProvider{ + Donor: lpadata.Donor{FirstNames: "a b", LastName: "c", Email: "a@example.com"}, + CertificateProvider: lpadata.CertificateProvider{ FirstNames: "d e", LastName: "f", }, CannotRegister: true, @@ -198,9 +197,9 @@ func TestPostConfirmDontWantToBeCertificateProviderLoggedOut(t *testing.T) { }, }, "not witnessed and signed": { - lpa: lpastore.Lpa{ + lpa: lpadata.Lpa{ LpaUID: "lpa-uid", - Donor: lpastore.Donor{ + Donor: lpadata.Donor{ FirstNames: "a b", LastName: "c", Email: "a@example.com", }, }, @@ -311,8 +310,8 @@ func TestPostConfirmDontWantToBeCertificateProviderLoggedOutErrors(t *testing.T) LpaKey: dynamo.LpaKey("lpa-id"), } - unsignedLPA := lpastore.Lpa{LpaUID: "lpa-uid"} - signedLPA := lpastore.Lpa{LpaUID: "lpa-uid", SignedAt: time.Now()} + unsignedLPA := lpadata.Lpa{LpaUID: "lpa-uid"} + signedLPA := lpadata.Lpa{LpaUID: "lpa-uid", SignedAt: time.Now()} localizer := newMockLocalizer(t) localizer.EXPECT(). T(mock.Anything). 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 abf427dbb8..5289209edd 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,7 +10,6 @@ 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/donor/donordata" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" @@ -24,7 +23,7 @@ func TestGetConfirmDontWantToBeCertificateProvider(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - lpa := lpastore.Lpa{LpaUID: "lpa-uid"} + lpa := lpadata.Lpa{LpaUID: "lpa-uid"} lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). @@ -59,7 +58,7 @@ func TestGetConfirmDontWantToBeCertificateProviderErrors(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(mock.Anything). - Return(&lpastore.Lpa{}, expectedError) + Return(&lpadata.Lpa{}, expectedError) return lpaStoreResolvingService }, @@ -70,7 +69,7 @@ func TestGetConfirmDontWantToBeCertificateProviderErrors(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(mock.Anything). - Return(&lpastore.Lpa{}, nil) + Return(&lpadata.Lpa{}, nil) return lpaStoreResolvingService }, @@ -102,19 +101,19 @@ func TestPostConfirmDontWantToBeCertificateProvider(t *testing.T) { uid := actoruid.New() testcases := map[string]struct { - lpa lpastore.Lpa + lpa lpadata.Lpa lpaStoreClient func() *mockLpaStoreClient donorStore func() *mockDonorStore email notify.Email }{ "witnessed and signed": { - lpa: lpastore.Lpa{ + lpa: lpadata.Lpa{ LpaUID: "lpa-uid", SignedAt: time.Now(), - Donor: lpastore.Donor{ + Donor: lpadata.Donor{ FirstNames: "a b", LastName: "c", Email: "a@example.com", }, - CertificateProvider: lpastore.CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ FirstNames: "d e", LastName: "f", UID: uid, }, Type: lpadata.LpaTypePersonalWelfare, @@ -139,13 +138,13 @@ func TestPostConfirmDontWantToBeCertificateProvider(t *testing.T) { }, }, "cannot-register": { - lpa: lpastore.Lpa{ + lpa: lpadata.Lpa{ LpaUID: "lpa-uid", SignedAt: time.Now(), - Donor: lpastore.Donor{ + Donor: lpadata.Donor{ FirstNames: "a b", LastName: "c", Email: "a@example.com", }, - CertificateProvider: lpastore.CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ FirstNames: "d e", LastName: "f", UID: uid, }, Type: lpadata.LpaTypePersonalWelfare, @@ -164,9 +163,9 @@ func TestPostConfirmDontWantToBeCertificateProvider(t *testing.T) { }, }, "not witnessed and signed": { - lpa: lpastore.Lpa{ + lpa: lpadata.Lpa{ LpaUID: "lpa-uid", - Donor: lpastore.Donor{FirstNames: "a b", LastName: "c", Email: "a@example.com"}, + Donor: lpadata.Donor{FirstNames: "a b", LastName: "c", Email: "a@example.com"}, }, lpaStoreClient: func() *mockLpaStoreClient { return nil }, donorStore: func() *mockDonorStore { @@ -257,8 +256,8 @@ func TestPostConfirmDontWantToBeCertificateProvider(t *testing.T) { func TestPostConfirmDontWantToBeCertificateProviderErrors(t *testing.T) { r, _ := http.NewRequest(http.MethodPost, "/?referenceNumber=123", nil) - unsignedLPA := lpastore.Lpa{LpaUID: "lpa-uid"} - signedLPA := lpastore.Lpa{LpaUID: "lpa-uid", SignedAt: time.Now()} + unsignedLPA := lpadata.Lpa{LpaUID: "lpa-uid"} + signedLPA := lpadata.Lpa{LpaUID: "lpa-uid", SignedAt: time.Now()} localizer := newMockLocalizer(t) localizer.EXPECT(). diff --git a/internal/certificateprovider/certificateproviderpage/confirm_your_details.go b/internal/certificateprovider/certificateproviderpage/confirm_your_details.go index 1da417f516..e93d61cf79 100644 --- a/internal/certificateprovider/certificateproviderpage/confirm_your_details.go +++ b/internal/certificateprovider/certificateproviderpage/confirm_your_details.go @@ -7,7 +7,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -15,7 +15,7 @@ import ( type confirmYourDetailsData struct { App appcontext.Data Errors validation.List - Lpa *lpastore.Lpa + Lpa *lpadata.Lpa CertificateProvider *certificateproviderdata.Provided PhoneNumberLabel string AddressLabel string diff --git a/internal/certificateprovider/certificateproviderpage/confirm_your_details_test.go b/internal/certificateprovider/certificateproviderpage/confirm_your_details_test.go index 56ec264280..3947a41e10 100644 --- a/internal/certificateprovider/certificateproviderpage/confirm_your_details_test.go +++ b/internal/certificateprovider/certificateproviderpage/confirm_your_details_test.go @@ -8,7 +8,6 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" @@ -54,9 +53,9 @@ func TestGetConfirmYourDetails(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - lpa := &lpastore.Lpa{ - Donor: lpastore.Donor{Channel: tc.DonorChannel}, - CertificateProvider: lpastore.CertificateProvider{Relationship: tc.CertificateProviderRelationship}, + lpa := &lpadata.Lpa{ + Donor: lpadata.Donor{Channel: tc.DonorChannel}, + CertificateProvider: lpadata.CertificateProvider{Relationship: tc.CertificateProviderRelationship}, } certificateProvider := &certificateproviderdata.Provided{} @@ -93,7 +92,7 @@ func TestGetConfirmYourDetailsWhenLpaStoreResolvingServiceErrors(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, expectedError) + Return(&lpadata.Lpa{}, expectedError) err := ConfirmYourDetails(nil, lpaStoreResolvingService, nil)(testAppData, w, r, &certificateproviderdata.Provided{}) @@ -107,7 +106,7 @@ func TestGetConfirmYourDetailsWhenTemplateErrors(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, nil) + Return(&lpadata.Lpa{}, nil) template := newMockTemplate(t) template.EXPECT(). @@ -136,7 +135,7 @@ func TestPostConfirmYourDetails(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{SignedAt: tc.signedAt}, nil) + Return(&lpadata.Lpa{SignedAt: tc.signedAt}, nil) certificateProviderStore := newMockCertificateProviderStore(t) certificateProviderStore.EXPECT(). @@ -165,7 +164,7 @@ func TestPostConfirmYourDetailsWhenStoreErrors(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, nil) + Return(&lpadata.Lpa{}, nil) certificateProviderStore := newMockCertificateProviderStore(t) certificateProviderStore.EXPECT(). diff --git a/internal/certificateprovider/certificateproviderpage/enter_date_of_birth.go b/internal/certificateprovider/certificateproviderpage/enter_date_of_birth.go index e14ba0f999..4c0bb67987 100644 --- a/internal/certificateprovider/certificateproviderpage/enter_date_of_birth.go +++ b/internal/certificateprovider/certificateproviderpage/enter_date_of_birth.go @@ -8,7 +8,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/date" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" @@ -16,7 +16,7 @@ import ( type dateOfBirthData struct { App appcontext.Data - Lpa *lpastore.Lpa + Lpa *lpadata.Lpa Form *dateOfBirthForm Errors validation.List DobWarning string diff --git a/internal/certificateprovider/certificateproviderpage/enter_date_of_birth_test.go b/internal/certificateprovider/certificateproviderpage/enter_date_of_birth_test.go index e9bf1a7332..da5a7169d9 100644 --- a/internal/certificateprovider/certificateproviderpage/enter_date_of_birth_test.go +++ b/internal/certificateprovider/certificateproviderpage/enter_date_of_birth_test.go @@ -12,7 +12,6 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/date" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" @@ -25,7 +24,7 @@ func TestGetEnterDateOfBirth(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &lpastore.Lpa{ + donor := &lpadata.Lpa{ LpaID: "lpa-id", } @@ -57,13 +56,13 @@ func TestGetEnterDateOfBirthFromStore(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, nil) + Return(&lpadata.Lpa{}, nil) template := newMockTemplate(t) template.EXPECT(). Execute(w, &dateOfBirthData{ App: testAppData, - Lpa: &lpastore.Lpa{}, + Lpa: &lpadata.Lpa{}, Form: &dateOfBirthForm{ Dob: date.New("1997", "1", "2"), }, @@ -84,7 +83,7 @@ func TestGetEnterDateOfBirthWhenLpaStoreResolvingServiceErrors(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, expectedError) + Return(&lpadata.Lpa{}, expectedError) err := EnterDateOfBirth(nil, lpaStoreResolvingService, nil)(testAppData, w, r, nil) resp := w.Result() @@ -97,7 +96,7 @@ func TestGetEnterDateOfBirthWhenTemplateErrors(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &lpastore.Lpa{ + donor := &lpadata.Lpa{ LpaID: "lpa-id", } @@ -193,7 +192,7 @@ func TestPostEnterDateOfBirth(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{LpaID: "lpa-id"}, nil) + Return(&lpadata.Lpa{LpaID: "lpa-id"}, nil) certificateProviderStore := newMockCertificateProviderStore(t) certificateProviderStore.EXPECT(). @@ -225,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: lpadata.Professionally}}, nil) + Return(&lpadata.Lpa{LpaID: "lpa-id", CertificateProvider: lpadata.CertificateProvider{Relationship: lpadata.Professionally}}, nil) certificateProviderStore := newMockCertificateProviderStore(t) certificateProviderStore.EXPECT(). @@ -285,7 +284,7 @@ func TestPostEnterDateOfBirthWhenInputRequired(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{LpaID: "lpa-id"}, nil) + Return(&lpadata.Lpa{LpaID: "lpa-id"}, nil) template := newMockTemplate(t) template.EXPECT(). @@ -318,7 +317,7 @@ func TestPostYourDetailsWhenLpaStoreResolvingServiceErrors(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, expectedError) + Return(&lpadata.Lpa{}, expectedError) err := EnterDateOfBirth(nil, lpaStoreResolvingService, nil)(testAppData, w, r, nil) resp := w.Result() diff --git a/internal/certificateprovider/certificateproviderpage/guidance.go b/internal/certificateprovider/certificateproviderpage/guidance.go index c9349934e9..77d98b99e6 100644 --- a/internal/certificateprovider/certificateproviderpage/guidance.go +++ b/internal/certificateprovider/certificateproviderpage/guidance.go @@ -6,14 +6,14 @@ import ( "github.com/ministryofjustice/opg-go-common/template" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) type guidanceData struct { App appcontext.Data Errors validation.List - Lpa *lpastore.Lpa + Lpa *lpadata.Lpa CertificateProvider *certificateproviderdata.Provided } diff --git a/internal/certificateprovider/certificateproviderpage/guidance_test.go b/internal/certificateprovider/certificateproviderpage/guidance_test.go index a06156ee65..709cc5d187 100644 --- a/internal/certificateprovider/certificateproviderpage/guidance_test.go +++ b/internal/certificateprovider/certificateproviderpage/guidance_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/stretchr/testify/assert" ) @@ -14,7 +14,7 @@ func TestGuidance(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &lpastore.Lpa{} + donor := &lpadata.Lpa{} certificateProvider := &certificateproviderdata.Provided{} lpaStoreResolvingService := newMockLpaStoreResolvingService(t) @@ -58,7 +58,7 @@ func TestGuidanceWhenLpaStoreResolvingServiceErrors(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, expectedError) + Return(&lpadata.Lpa{}, expectedError) err := Guidance(nil, lpaStoreResolvingService)(testAppData, w, r, nil) @@ -72,11 +72,11 @@ func TestGuidanceWhenTemplateErrors(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, nil) + Return(&lpadata.Lpa{}, nil) template := newMockTemplate(t) template.EXPECT(). - Execute(w, &guidanceData{App: testAppData, Lpa: &lpastore.Lpa{}}). + Execute(w, &guidanceData{App: testAppData, Lpa: &lpadata.Lpa{}}). Return(expectedError) err := Guidance(template.Execute, lpaStoreResolvingService)(testAppData, w, r, nil) 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 7fc05cd4ea..ed2aabeb23 100644 --- a/internal/certificateprovider/certificateproviderpage/identity_with_one_login_callback_test.go +++ b/internal/certificateprovider/certificateproviderpage/identity_with_one_login_callback_test.go @@ -11,7 +11,6 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/identity" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/onelogin" @@ -42,7 +41,7 @@ func TestGetIdentityWithOneLoginCallback(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{LpaUID: "lpa-uid", CertificateProvider: lpastore.CertificateProvider{FirstNames: "John", LastName: "Doe"}}, nil) + Return(&lpadata.Lpa{LpaUID: "lpa-uid", CertificateProvider: lpadata.CertificateProvider{FirstNames: "John", LastName: "Doe"}}, nil) sessionStore := newMockSessionStore(t) sessionStore.EXPECT(). @@ -93,10 +92,10 @@ func TestGetIdentityWithOneLoginCallbackWhenFailedIDCheck(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{ + Return(&lpadata.Lpa{ LpaUID: "lpa-uid", - CertificateProvider: lpastore.CertificateProvider{FirstNames: "a", LastName: "b"}, - Donor: lpastore.Donor{Email: "a@example.com", FirstNames: "c", LastName: "d"}, + CertificateProvider: lpadata.CertificateProvider{FirstNames: "a", LastName: "b"}, + Donor: lpadata.Donor{Email: "a@example.com", FirstNames: "c", LastName: "d"}, Type: lpadata.LpaTypePersonalWelfare, SignedAt: time.Now(), }, nil) @@ -166,10 +165,10 @@ func TestGetIdentityWithOneLoginCallbackWhenSendingEmailError(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(mock.Anything). - Return(&lpastore.Lpa{ + Return(&lpadata.Lpa{ LpaUID: "lpa-uid", - CertificateProvider: lpastore.CertificateProvider{FirstNames: "a", LastName: "b"}, - Donor: lpastore.Donor{Email: "a@example.com", FirstNames: "c", LastName: "d"}, + CertificateProvider: lpadata.CertificateProvider{FirstNames: "a", LastName: "b"}, + Donor: lpadata.Donor{Email: "a@example.com", FirstNames: "c", LastName: "d"}, Type: lpadata.LpaTypePersonalWelfare, SignedAt: time.Now(), }, nil) @@ -337,7 +336,7 @@ func TestGetIdentityWithOneLoginCallbackWhenIdentityNotConfirmed(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{CertificateProvider: lpastore.CertificateProvider{}}, nil) + Return(&lpadata.Lpa{CertificateProvider: lpadata.CertificateProvider{}}, nil) sessionStore := tc.sessionStore(t) oneLoginClient := tc.oneLoginClient(t) @@ -359,7 +358,7 @@ func TestGetIdentityWithOneLoginCallbackWhenGetLpaStoreResolvingServiceError(t * lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{CertificateProvider: lpastore.CertificateProvider{}}, expectedError) + Return(&lpadata.Lpa{CertificateProvider: lpadata.CertificateProvider{}}, expectedError) err := IdentityWithOneLoginCallback(nil, nil, nil, lpaStoreResolvingService, nil, nil, "www.example.com")(testAppData, w, r, &certificateproviderdata.Provided{}) @@ -379,7 +378,7 @@ func TestGetIdentityWithOneLoginCallbackWhenPutCertificateProviderStoreError(t * lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{CertificateProvider: lpastore.CertificateProvider{}}, nil) + Return(&lpadata.Lpa{CertificateProvider: lpadata.CertificateProvider{}}, nil) sessionStore := newMockSessionStore(t) sessionStore.EXPECT(). @@ -415,7 +414,7 @@ func TestGetIdentityWithOneLoginCallbackWhenLpaStoreClientError(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{CertificateProvider: lpastore.CertificateProvider{}}, nil) + Return(&lpadata.Lpa{CertificateProvider: lpadata.CertificateProvider{}}, nil) sessionStore := newMockSessionStore(t) sessionStore.EXPECT(). @@ -452,7 +451,7 @@ func TestGetIdentityWithOneLoginCallbackWhenReturning(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{CertificateProvider: lpastore.CertificateProvider{FirstNames: "first-names", LastName: "last-name"}}, nil) + Return(&lpadata.Lpa{CertificateProvider: lpadata.CertificateProvider{FirstNames: "first-names", LastName: "last-name"}}, nil) err := IdentityWithOneLoginCallback(nil, nil, nil, lpaStoreResolvingService, nil, nil, "www.example.com")(testAppData, w, r, &certificateproviderdata.Provided{ IdentityUserData: userData, diff --git a/internal/certificateprovider/certificateproviderpage/mock_LpaStoreClient_test.go b/internal/certificateprovider/certificateproviderpage/mock_LpaStoreClient_test.go index 3c52ec65c9..d2488eb46b 100644 --- a/internal/certificateprovider/certificateproviderpage/mock_LpaStoreClient_test.go +++ b/internal/certificateprovider/certificateproviderpage/mock_LpaStoreClient_test.go @@ -8,7 +8,7 @@ import ( actoruid "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" certificateproviderdata "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" - lpastore "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + lpadata "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" mock "github.com/stretchr/testify/mock" ) @@ -27,7 +27,7 @@ func (_m *mockLpaStoreClient) EXPECT() *mockLpaStoreClient_Expecter { } // SendCertificateProvider provides a mock function with given fields: ctx, certificateProvider, lpa -func (_m *mockLpaStoreClient) SendCertificateProvider(ctx context.Context, certificateProvider *certificateproviderdata.Provided, lpa *lpastore.Lpa) error { +func (_m *mockLpaStoreClient) SendCertificateProvider(ctx context.Context, certificateProvider *certificateproviderdata.Provided, lpa *lpadata.Lpa) error { ret := _m.Called(ctx, certificateProvider, lpa) if len(ret) == 0 { @@ -35,7 +35,7 @@ func (_m *mockLpaStoreClient) SendCertificateProvider(ctx context.Context, certi } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, *certificateproviderdata.Provided, *lpastore.Lpa) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, *certificateproviderdata.Provided, *lpadata.Lpa) error); ok { r0 = rf(ctx, certificateProvider, lpa) } else { r0 = ret.Error(0) @@ -52,14 +52,14 @@ type mockLpaStoreClient_SendCertificateProvider_Call struct { // SendCertificateProvider is a helper method to define mock.On call // - ctx context.Context // - certificateProvider *certificateproviderdata.Provided -// - lpa *lpastore.Lpa +// - lpa *lpadata.Lpa func (_e *mockLpaStoreClient_Expecter) SendCertificateProvider(ctx interface{}, certificateProvider interface{}, lpa interface{}) *mockLpaStoreClient_SendCertificateProvider_Call { return &mockLpaStoreClient_SendCertificateProvider_Call{Call: _e.mock.On("SendCertificateProvider", ctx, certificateProvider, lpa)} } -func (_c *mockLpaStoreClient_SendCertificateProvider_Call) Run(run func(ctx context.Context, certificateProvider *certificateproviderdata.Provided, lpa *lpastore.Lpa)) *mockLpaStoreClient_SendCertificateProvider_Call { +func (_c *mockLpaStoreClient_SendCertificateProvider_Call) Run(run func(ctx context.Context, certificateProvider *certificateproviderdata.Provided, lpa *lpadata.Lpa)) *mockLpaStoreClient_SendCertificateProvider_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(*certificateproviderdata.Provided), args[2].(*lpastore.Lpa)) + run(args[0].(context.Context), args[1].(*certificateproviderdata.Provided), args[2].(*lpadata.Lpa)) }) return _c } @@ -69,7 +69,7 @@ func (_c *mockLpaStoreClient_SendCertificateProvider_Call) Return(_a0 error) *mo return _c } -func (_c *mockLpaStoreClient_SendCertificateProvider_Call) RunAndReturn(run func(context.Context, *certificateproviderdata.Provided, *lpastore.Lpa) error) *mockLpaStoreClient_SendCertificateProvider_Call { +func (_c *mockLpaStoreClient_SendCertificateProvider_Call) RunAndReturn(run func(context.Context, *certificateproviderdata.Provided, *lpadata.Lpa) error) *mockLpaStoreClient_SendCertificateProvider_Call { _c.Call.Return(run) return _c } diff --git a/internal/certificateprovider/certificateproviderpage/mock_LpaStoreResolvingService_test.go b/internal/certificateprovider/certificateproviderpage/mock_LpaStoreResolvingService_test.go index 9383545306..c39aab36ec 100644 --- a/internal/certificateprovider/certificateproviderpage/mock_LpaStoreResolvingService_test.go +++ b/internal/certificateprovider/certificateproviderpage/mock_LpaStoreResolvingService_test.go @@ -5,7 +5,7 @@ package certificateproviderpage import ( context "context" - lpastore "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + lpadata "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" mock "github.com/stretchr/testify/mock" ) @@ -23,23 +23,23 @@ func (_m *mockLpaStoreResolvingService) EXPECT() *mockLpaStoreResolvingService_E } // Get provides a mock function with given fields: ctx -func (_m *mockLpaStoreResolvingService) Get(ctx context.Context) (*lpastore.Lpa, error) { +func (_m *mockLpaStoreResolvingService) Get(ctx context.Context) (*lpadata.Lpa, error) { ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for Get") } - var r0 *lpastore.Lpa + var r0 *lpadata.Lpa var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (*lpastore.Lpa, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context) (*lpadata.Lpa, error)); ok { return rf(ctx) } - if rf, ok := ret.Get(0).(func(context.Context) *lpastore.Lpa); ok { + if rf, ok := ret.Get(0).(func(context.Context) *lpadata.Lpa); ok { r0 = rf(ctx) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*lpastore.Lpa) + r0 = ret.Get(0).(*lpadata.Lpa) } } @@ -70,12 +70,12 @@ func (_c *mockLpaStoreResolvingService_Get_Call) Run(run func(ctx context.Contex return _c } -func (_c *mockLpaStoreResolvingService_Get_Call) Return(_a0 *lpastore.Lpa, _a1 error) *mockLpaStoreResolvingService_Get_Call { +func (_c *mockLpaStoreResolvingService_Get_Call) Return(_a0 *lpadata.Lpa, _a1 error) *mockLpaStoreResolvingService_Get_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockLpaStoreResolvingService_Get_Call) RunAndReturn(run func(context.Context) (*lpastore.Lpa, error)) *mockLpaStoreResolvingService_Get_Call { +func (_c *mockLpaStoreResolvingService_Get_Call) RunAndReturn(run func(context.Context) (*lpadata.Lpa, error)) *mockLpaStoreResolvingService_Get_Call { _c.Call.Return(run) return _c } diff --git a/internal/certificateprovider/certificateproviderpage/mock_NotifyClient_test.go b/internal/certificateprovider/certificateproviderpage/mock_NotifyClient_test.go index 13d1a33f0a..6207141471 100644 --- a/internal/certificateprovider/certificateproviderpage/mock_NotifyClient_test.go +++ b/internal/certificateprovider/certificateproviderpage/mock_NotifyClient_test.go @@ -5,7 +5,7 @@ package certificateproviderpage import ( context "context" - lpastore "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + lpadata "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" mock "github.com/stretchr/testify/mock" notify "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" @@ -25,7 +25,7 @@ func (_m *mockNotifyClient) EXPECT() *mockNotifyClient_Expecter { } // EmailGreeting provides a mock function with given fields: lpa -func (_m *mockNotifyClient) EmailGreeting(lpa *lpastore.Lpa) string { +func (_m *mockNotifyClient) EmailGreeting(lpa *lpadata.Lpa) string { ret := _m.Called(lpa) if len(ret) == 0 { @@ -33,7 +33,7 @@ func (_m *mockNotifyClient) EmailGreeting(lpa *lpastore.Lpa) string { } var r0 string - if rf, ok := ret.Get(0).(func(*lpastore.Lpa) string); ok { + if rf, ok := ret.Get(0).(func(*lpadata.Lpa) string); ok { r0 = rf(lpa) } else { r0 = ret.Get(0).(string) @@ -48,14 +48,14 @@ type mockNotifyClient_EmailGreeting_Call struct { } // EmailGreeting is a helper method to define mock.On call -// - lpa *lpastore.Lpa +// - lpa *lpadata.Lpa func (_e *mockNotifyClient_Expecter) EmailGreeting(lpa interface{}) *mockNotifyClient_EmailGreeting_Call { return &mockNotifyClient_EmailGreeting_Call{Call: _e.mock.On("EmailGreeting", lpa)} } -func (_c *mockNotifyClient_EmailGreeting_Call) Run(run func(lpa *lpastore.Lpa)) *mockNotifyClient_EmailGreeting_Call { +func (_c *mockNotifyClient_EmailGreeting_Call) Run(run func(lpa *lpadata.Lpa)) *mockNotifyClient_EmailGreeting_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*lpastore.Lpa)) + run(args[0].(*lpadata.Lpa)) }) return _c } @@ -65,7 +65,7 @@ func (_c *mockNotifyClient_EmailGreeting_Call) Return(_a0 string) *mockNotifyCli return _c } -func (_c *mockNotifyClient_EmailGreeting_Call) RunAndReturn(run func(*lpastore.Lpa) string) *mockNotifyClient_EmailGreeting_Call { +func (_c *mockNotifyClient_EmailGreeting_Call) RunAndReturn(run func(*lpadata.Lpa) string) *mockNotifyClient_EmailGreeting_Call { _c.Call.Return(run) return _c } diff --git a/internal/certificateprovider/certificateproviderpage/mock_ShareCodeSender_test.go b/internal/certificateprovider/certificateproviderpage/mock_ShareCodeSender_test.go index 1876a1ed7c..4dd1c1b288 100644 --- a/internal/certificateprovider/certificateproviderpage/mock_ShareCodeSender_test.go +++ b/internal/certificateprovider/certificateproviderpage/mock_ShareCodeSender_test.go @@ -7,7 +7,7 @@ import ( appcontext "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" - lpastore "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + lpadata "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" mock "github.com/stretchr/testify/mock" ) @@ -26,7 +26,7 @@ func (_m *mockShareCodeSender) EXPECT() *mockShareCodeSender_Expecter { } // SendAttorneys provides a mock function with given fields: _a0, _a1, _a2 -func (_m *mockShareCodeSender) SendAttorneys(_a0 context.Context, _a1 appcontext.Data, _a2 *lpastore.Lpa) error { +func (_m *mockShareCodeSender) SendAttorneys(_a0 context.Context, _a1 appcontext.Data, _a2 *lpadata.Lpa) error { ret := _m.Called(_a0, _a1, _a2) if len(ret) == 0 { @@ -34,7 +34,7 @@ func (_m *mockShareCodeSender) SendAttorneys(_a0 context.Context, _a1 appcontext } var r0 error - if rf, ok := ret.Get(0).(func(context.Context, appcontext.Data, *lpastore.Lpa) error); ok { + if rf, ok := ret.Get(0).(func(context.Context, appcontext.Data, *lpadata.Lpa) error); ok { r0 = rf(_a0, _a1, _a2) } else { r0 = ret.Error(0) @@ -51,14 +51,14 @@ type mockShareCodeSender_SendAttorneys_Call struct { // SendAttorneys is a helper method to define mock.On call // - _a0 context.Context // - _a1 appcontext.Data -// - _a2 *lpastore.Lpa +// - _a2 *lpadata.Lpa func (_e *mockShareCodeSender_Expecter) SendAttorneys(_a0 interface{}, _a1 interface{}, _a2 interface{}) *mockShareCodeSender_SendAttorneys_Call { return &mockShareCodeSender_SendAttorneys_Call{Call: _e.mock.On("SendAttorneys", _a0, _a1, _a2)} } -func (_c *mockShareCodeSender_SendAttorneys_Call) Run(run func(_a0 context.Context, _a1 appcontext.Data, _a2 *lpastore.Lpa)) *mockShareCodeSender_SendAttorneys_Call { +func (_c *mockShareCodeSender_SendAttorneys_Call) Run(run func(_a0 context.Context, _a1 appcontext.Data, _a2 *lpadata.Lpa)) *mockShareCodeSender_SendAttorneys_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(appcontext.Data), args[2].(*lpastore.Lpa)) + run(args[0].(context.Context), args[1].(appcontext.Data), args[2].(*lpadata.Lpa)) }) return _c } @@ -68,7 +68,7 @@ func (_c *mockShareCodeSender_SendAttorneys_Call) Return(_a0 error) *mockShareCo return _c } -func (_c *mockShareCodeSender_SendAttorneys_Call) RunAndReturn(run func(context.Context, appcontext.Data, *lpastore.Lpa) error) *mockShareCodeSender_SendAttorneys_Call { +func (_c *mockShareCodeSender_SendAttorneys_Call) RunAndReturn(run func(context.Context, appcontext.Data, *lpadata.Lpa) error) *mockShareCodeSender_SendAttorneys_Call { _c.Call.Return(run) return _c } diff --git a/internal/certificateprovider/certificateproviderpage/one_login_identity_details_test.go b/internal/certificateprovider/certificateproviderpage/one_login_identity_details_test.go index d189bf73e8..21fbd0cdf9 100644 --- a/internal/certificateprovider/certificateproviderpage/one_login_identity_details_test.go +++ b/internal/certificateprovider/certificateproviderpage/one_login_identity_details_test.go @@ -9,7 +9,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/date" "github.com/ministryofjustice/opg-modernising-lpa/internal/identity" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -74,7 +74,7 @@ func TestPostOneLoginIdentityDetails(t *testing.T) { lpaResolvingService := newMockLpaStoreResolvingService(t) lpaResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{LpaUID: "lpa-uid", CertificateProvider: lpastore.CertificateProvider{FirstNames: "a", LastName: "b"}}, nil) + Return(&lpadata.Lpa{LpaUID: "lpa-uid", CertificateProvider: lpadata.CertificateProvider{FirstNames: "a", LastName: "b"}}, nil) err := OneLoginIdentityDetails(nil, certificateProviderStore, lpaResolvingService)(testAppData, w, r, &certificateproviderdata.Provided{ IdentityUserData: identity.UserData{Status: identity.StatusConfirmed, FirstNames: "a", LastName: "b", DateOfBirth: date.New("2000", "1", "1")}, @@ -95,7 +95,7 @@ func TestPostOneLoginIdentityDetailsWhenDetailsDoNotMatch(t *testing.T) { lpaResolvingService := newMockLpaStoreResolvingService(t) lpaResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{LpaUID: "lpa-uid", CertificateProvider: lpastore.CertificateProvider{FirstNames: "x", LastName: "y"}}, nil) + Return(&lpadata.Lpa{LpaUID: "lpa-uid", CertificateProvider: lpadata.CertificateProvider{FirstNames: "x", LastName: "y"}}, nil) err := OneLoginIdentityDetails(nil, nil, lpaResolvingService)(testAppData, w, r, &certificateproviderdata.Provided{ IdentityUserData: identity.UserData{Status: identity.StatusConfirmed, FirstNames: "a", LastName: "b", DateOfBirth: date.New("2000", "1", "1")}, @@ -125,7 +125,7 @@ func TestPostOneLoginIdentityDetailsErrors(t *testing.T) { service := newMockLpaStoreResolvingService(t) service.EXPECT(). Get(mock.Anything). - Return(&lpastore.Lpa{}, expectedError) + Return(&lpadata.Lpa{}, expectedError) return service }, certificateProviderStore: func() *mockCertificateProviderStore { @@ -138,7 +138,7 @@ func TestPostOneLoginIdentityDetailsErrors(t *testing.T) { service := newMockLpaStoreResolvingService(t) service.EXPECT(). Get(mock.Anything). - Return(&lpastore.Lpa{CertificateProvider: lpastore.CertificateProvider{FirstNames: "a", LastName: "b"}}, nil) + Return(&lpadata.Lpa{CertificateProvider: lpadata.CertificateProvider{FirstNames: "a", LastName: "b"}}, nil) return service }, certificateProviderStore: func() *mockCertificateProviderStore { diff --git a/internal/certificateprovider/certificateproviderpage/provide_certificate.go b/internal/certificateprovider/certificateproviderpage/provide_certificate.go index 59b63670a6..52e68e4de2 100644 --- a/internal/certificateprovider/certificateproviderpage/provide_certificate.go +++ b/internal/certificateprovider/certificateproviderpage/provide_certificate.go @@ -10,7 +10,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" @@ -21,7 +21,7 @@ type provideCertificateData struct { App appcontext.Data Errors validation.List CertificateProvider *certificateproviderdata.Provided - Lpa *lpastore.Lpa + Lpa *lpadata.Lpa Form *provideCertificateForm } diff --git a/internal/certificateprovider/certificateproviderpage/provide_certificate_test.go b/internal/certificateprovider/certificateproviderpage/provide_certificate_test.go index f04414553f..31193b0b6c 100644 --- a/internal/certificateprovider/certificateproviderpage/provide_certificate_test.go +++ b/internal/certificateprovider/certificateproviderpage/provide_certificate_test.go @@ -11,7 +11,6 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" @@ -25,7 +24,7 @@ func TestGetProvideCertificate(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &lpastore.Lpa{SignedAt: time.Now()} + donor := &lpadata.Lpa{SignedAt: time.Now()} lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). @@ -56,7 +55,7 @@ func TestGetProvideCertificateRedirectsToStartOnLpaNotSubmitted(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{LpaID: "lpa-id"}, nil) + Return(&lpadata.Lpa{LpaID: "lpa-id"}, nil) err := ProvideCertificate(nil, lpaStoreResolvingService, nil, nil, nil, nil, nil)(testAppData, w, r, nil) resp := w.Result() @@ -70,7 +69,7 @@ func TestGetProvideCertificateWhenAlreadyAgreed(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &lpastore.Lpa{LpaID: "lpa-id", SignedAt: time.Now()} + donor := &lpadata.Lpa{LpaID: "lpa-id", SignedAt: time.Now()} lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). @@ -94,7 +93,7 @@ func TestGetProvideCertificateWhenLpaStoreResolvingServiceErrors(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, expectedError) + Return(&lpadata.Lpa{}, expectedError) err := ProvideCertificate(nil, lpaStoreResolvingService, nil, nil, nil, nil, nil)(testAppData, w, r, nil) resp := w.Result() @@ -115,15 +114,15 @@ func TestPostProvideCertificate(t *testing.T) { now := time.Now() - lpa := &lpastore.Lpa{ + lpa := &lpadata.Lpa{ LpaUID: "lpa-uid", SignedAt: now, - CertificateProvider: lpastore.CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ Email: "cp@example.org", FirstNames: "a", LastName: "b", }, - Donor: lpastore.Donor{FirstNames: "c", LastName: "d"}, + Donor: lpadata.Donor{FirstNames: "c", LastName: "d"}, Type: lpadata.LpaTypePropertyAndAffairs, } @@ -204,16 +203,16 @@ func TestPostProvideCertificateWhenSignedInLpaStore(t *testing.T) { now := time.Now() signedAt := time.Now().Add(-5 * time.Minute) - lpa := &lpastore.Lpa{ + lpa := &lpadata.Lpa{ LpaUID: "lpa-uid", SignedAt: now, - CertificateProvider: lpastore.CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ Email: "cp@example.org", FirstNames: "a", LastName: "b", SignedAt: signedAt, }, - Donor: lpastore.Donor{FirstNames: "c", LastName: "d"}, + Donor: lpadata.Donor{FirstNames: "c", LastName: "d"}, Type: lpadata.LpaTypePropertyAndAffairs, } @@ -288,15 +287,15 @@ func TestPostProvideCertificateWhenCannotSubmit(t *testing.T) { now := time.Now() - lpa := &lpastore.Lpa{ + lpa := &lpadata.Lpa{ LpaUID: "lpa-uid", SignedAt: now, - CertificateProvider: lpastore.CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ Email: "cp@example.org", FirstNames: "a", LastName: "b", }, - Donor: lpastore.Donor{FirstNames: "c", LastName: "d"}, + Donor: lpadata.Donor{FirstNames: "c", LastName: "d"}, Type: lpadata.LpaTypePropertyAndAffairs, } @@ -328,7 +327,7 @@ func TestPostProvideCertificateOnStoreError(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{SignedAt: now}, nil) + Return(&lpadata.Lpa{SignedAt: now}, nil) lpaStoreClient := newMockLpaStoreClient(t) lpaStoreClient.EXPECT(). @@ -385,15 +384,15 @@ func TestPostProvideCertificateWhenLpaStoreClientError(t *testing.T) { now := time.Now() - donor := &lpastore.Lpa{ + donor := &lpadata.Lpa{ LpaUID: "lpa-uid", SignedAt: now, - CertificateProvider: lpastore.CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ Email: "cp@example.org", FirstNames: "a", LastName: "b", }, - Donor: lpastore.Donor{FirstNames: "c", LastName: "d"}, + Donor: lpadata.Donor{FirstNames: "c", LastName: "d"}, Type: lpadata.LpaTypePropertyAndAffairs, } @@ -426,14 +425,14 @@ func TestPostProvideCertificateOnNotifyClientError(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{ + Return(&lpadata.Lpa{ SignedAt: now, - CertificateProvider: lpastore.CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ Email: "cp@example.org", FirstNames: "a", LastName: "b", }, - Donor: lpastore.Donor{FirstNames: "c", LastName: "d"}, + Donor: lpadata.Donor{FirstNames: "c", LastName: "d"}, Type: lpadata.LpaTypePropertyAndAffairs, }, nil) @@ -485,9 +484,9 @@ func TestPostProvideCertificateWhenShareCodeSenderErrors(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{ + Return(&lpadata.Lpa{ SignedAt: now, - Donor: lpastore.Donor{FirstNames: "c", LastName: "d"}, + Donor: lpadata.Donor{FirstNames: "c", LastName: "d"}, Type: lpadata.LpaTypePropertyAndAffairs, }, nil) @@ -541,7 +540,7 @@ func TestPostProvideCertificateWhenValidationErrors(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{SignedAt: now}, nil) + Return(&lpadata.Lpa{SignedAt: now}, nil) template := newMockTemplate(t) template.EXPECT(). diff --git a/internal/certificateprovider/certificateproviderpage/read_the_lpa.go b/internal/certificateprovider/certificateproviderpage/read_the_lpa.go index 0ffc3e6e6e..2583889027 100644 --- a/internal/certificateprovider/certificateproviderpage/read_the_lpa.go +++ b/internal/certificateprovider/certificateproviderpage/read_the_lpa.go @@ -7,7 +7,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -15,7 +15,7 @@ import ( type readTheLpaData struct { App appcontext.Data Errors validation.List - Lpa *lpastore.Lpa + Lpa *lpadata.Lpa } func ReadTheLpa(tmpl template.Template, lpaStoreResolvingService LpaStoreResolvingService, certificateProviderStore CertificateProviderStore) Handler { diff --git a/internal/certificateprovider/certificateproviderpage/read_the_lpa_test.go b/internal/certificateprovider/certificateproviderpage/read_the_lpa_test.go index 52af71404b..c56959bc2a 100644 --- a/internal/certificateprovider/certificateproviderpage/read_the_lpa_test.go +++ b/internal/certificateprovider/certificateproviderpage/read_the_lpa_test.go @@ -8,7 +8,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -18,7 +18,7 @@ func TestGetReadTheLpa(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &lpastore.Lpa{} + donor := &lpadata.Lpa{} lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). @@ -41,7 +41,7 @@ func TestGetReadTheLpaWhenLpaStoreResolvingServiceErrors(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - donor := &lpastore.Lpa{} + donor := &lpadata.Lpa{} lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). @@ -60,7 +60,7 @@ func TestGetReadTheLpaWhenTemplateErrors(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, nil) + Return(&lpadata.Lpa{}, nil) template := newMockTemplate(t) template.EXPECT(). @@ -79,7 +79,7 @@ func TestPostReadTheLpa(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{ + Return(&lpadata.Lpa{ LpaID: "lpa-id", SignedAt: time.Now(), Paid: true, @@ -103,7 +103,7 @@ func TestPostReadTheLpa(t *testing.T) { } func TestPostReadTheLpaWhenNotReady(t *testing.T) { - testcases := map[string]*lpastore.Lpa{ + testcases := map[string]*lpadata.Lpa{ "not submitted": { LpaID: "lpa-id", Paid: true, @@ -141,7 +141,7 @@ func TestPostReadTheLpaWithAttorneyWhenCertificateStorePutErrors(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{ + Return(&lpadata.Lpa{ LpaID: "lpa-id", SignedAt: time.Now(), Paid: true, diff --git a/internal/certificateprovider/certificateproviderpage/register.go b/internal/certificateprovider/certificateproviderpage/register.go index e6a2d62032..06c2d0d232 100644 --- a/internal/certificateprovider/certificateproviderpage/register.go +++ b/internal/certificateprovider/certificateproviderpage/register.go @@ -16,7 +16,7 @@ import ( "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/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/onelogin" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" @@ -29,7 +29,7 @@ import ( type Handler func(data appcontext.Data, w http.ResponseWriter, r *http.Request, details *certificateproviderdata.Provided) error type LpaStoreResolvingService interface { - Get(ctx context.Context) (*lpastore.Lpa, error) + Get(ctx context.Context) (*lpadata.Lpa, error) } type Logger interface { @@ -70,13 +70,13 @@ type SessionStore interface { } type NotifyClient interface { - EmailGreeting(lpa *lpastore.Lpa) string + EmailGreeting(lpa *lpadata.Lpa) string SendEmail(ctx context.Context, to string, email notify.Email) error SendActorEmail(ctx context.Context, to, lpaUID string, email notify.Email) error } type ShareCodeSender interface { - SendAttorneys(context.Context, appcontext.Data, *lpastore.Lpa) error + SendAttorneys(context.Context, appcontext.Data, *lpadata.Lpa) error } type AddressClient interface { @@ -93,7 +93,7 @@ type DashboardStore interface { } type LpaStoreClient interface { - SendCertificateProvider(ctx context.Context, certificateProvider *certificateproviderdata.Provided, lpa *lpastore.Lpa) error + SendCertificateProvider(ctx context.Context, certificateProvider *certificateproviderdata.Provided, lpa *lpadata.Lpa) error SendCertificateProviderConfirmIdentity(ctx context.Context, lpaUID string, certificateProvider *certificateproviderdata.Provided) error SendCertificateProviderOptOut(ctx context.Context, lpaUID string, actorUID actoruid.UID) error } diff --git a/internal/certificateprovider/certificateproviderpage/task_list.go b/internal/certificateprovider/certificateproviderpage/task_list.go index eea668a2d4..05eee0f2f0 100644 --- a/internal/certificateprovider/certificateproviderpage/task_list.go +++ b/internal/certificateprovider/certificateproviderpage/task_list.go @@ -7,7 +7,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -15,7 +15,7 @@ import ( type taskListData struct { App appcontext.Data Errors validation.List - Lpa *lpastore.Lpa + Lpa *lpadata.Lpa Items []taskListItem } diff --git a/internal/certificateprovider/certificateproviderpage/task_list_test.go b/internal/certificateprovider/certificateproviderpage/task_list_test.go index 357d85473e..b39f11a52a 100644 --- a/internal/certificateprovider/certificateproviderpage/task_list_test.go +++ b/internal/certificateprovider/certificateproviderpage/task_list_test.go @@ -10,7 +10,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/identity" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -18,13 +18,13 @@ import ( func TestGetTaskList(t *testing.T) { testCases := map[string]struct { - donor *lpastore.Lpa + donor *lpadata.Lpa certificateProvider *certificateproviderdata.Provided appData appcontext.Data expected func([]taskListItem) []taskListItem }{ "empty": { - donor: &lpastore.Lpa{LpaID: "lpa-id"}, + donor: &lpadata.Lpa{LpaID: "lpa-id"}, certificateProvider: &certificateproviderdata.Provided{}, appData: testAppData, expected: func(items []taskListItem) []taskListItem { @@ -35,7 +35,7 @@ func TestGetTaskList(t *testing.T) { }, }, "paid": { - donor: &lpastore.Lpa{ + donor: &lpadata.Lpa{ LpaID: "lpa-id", Paid: true, }, @@ -54,7 +54,7 @@ func TestGetTaskList(t *testing.T) { }, }, "submitted": { - donor: &lpastore.Lpa{ + donor: &lpadata.Lpa{ LpaID: "lpa-id", SignedAt: time.Now(), }, @@ -73,7 +73,7 @@ func TestGetTaskList(t *testing.T) { }, }, "identity confirmed": { - donor: &lpastore.Lpa{ + donor: &lpadata.Lpa{ LpaID: "lpa-id", SignedAt: time.Now(), Paid: true, @@ -97,7 +97,7 @@ func TestGetTaskList(t *testing.T) { }, }, "all": { - donor: &lpastore.Lpa{ + donor: &lpadata.Lpa{ LpaID: "lpa-id", SignedAt: time.Now(), Paid: true, @@ -160,7 +160,7 @@ func TestGetTaskListWhenLpaStoreResolvingServiceErrors(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, expectedError) + Return(&lpadata.Lpa{}, expectedError) err := TaskList(nil, lpaStoreResolvingService)(testAppData, w, r, &certificateproviderdata.Provided{}) @@ -174,7 +174,7 @@ func TestGetTaskListWhenTemplateErrors(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{LpaID: "lpa-id"}, nil) + Return(&lpadata.Lpa{LpaID: "lpa-id"}, nil) template := newMockTemplate(t) template.EXPECT(). diff --git a/internal/certificateprovider/certificateproviderpage/unable_to_confirm_identity.go b/internal/certificateprovider/certificateproviderpage/unable_to_confirm_identity.go index 8d801b7775..c9d94634fe 100644 --- a/internal/certificateprovider/certificateproviderpage/unable_to_confirm_identity.go +++ b/internal/certificateprovider/certificateproviderpage/unable_to_confirm_identity.go @@ -7,14 +7,14 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) type unableToConfirmIdentityData struct { App appcontext.Data - Donor lpastore.Donor + Donor lpadata.Donor Errors validation.List } diff --git a/internal/certificateprovider/certificateproviderpage/unable_to_confirm_identity_test.go b/internal/certificateprovider/certificateproviderpage/unable_to_confirm_identity_test.go index bf5f7e8316..4ce481911d 100644 --- a/internal/certificateprovider/certificateproviderpage/unable_to_confirm_identity_test.go +++ b/internal/certificateprovider/certificateproviderpage/unable_to_confirm_identity_test.go @@ -7,7 +7,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider" "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -20,13 +20,13 @@ func TestGetUnableToConfirmIdentity(t *testing.T) { lpaResolvingService := newMockLpaStoreResolvingService(t) lpaResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{Donor: lpastore.Donor{FirstNames: "a"}}, nil) + Return(&lpadata.Lpa{Donor: lpadata.Donor{FirstNames: "a"}}, nil) template := newMockTemplate(t) template.EXPECT(). Execute(w, &unableToConfirmIdentityData{ App: testAppData, - Donor: lpastore.Donor{FirstNames: "a"}, + Donor: lpadata.Donor{FirstNames: "a"}, }). Return(nil) @@ -60,7 +60,7 @@ func TestGetUnableToConfirmIdentityErrors(t *testing.T) { service := newMockLpaStoreResolvingService(t) service.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, nil) + Return(&lpadata.Lpa{}, nil) return service }, template: func() *mockTemplate { diff --git a/internal/certificateprovider/certificateproviderpage/your_preferred_language.go b/internal/certificateprovider/certificateproviderpage/your_preferred_language.go index 3c95deb5fc..1bc425c919 100644 --- a/internal/certificateprovider/certificateproviderpage/your_preferred_language.go +++ b/internal/certificateprovider/certificateproviderpage/your_preferred_language.go @@ -9,7 +9,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -19,7 +19,7 @@ type yourPreferredLanguageData struct { Form *form.LanguagePreferenceForm Options localize.LangOptions FieldName string - Lpa *lpastore.Lpa + Lpa *lpadata.Lpa } func YourPreferredLanguage(tmpl template.Template, certificateProviderStore CertificateProviderStore, lpaStoreResolvingService LpaStoreResolvingService) Handler { diff --git a/internal/certificateprovider/certificateproviderpage/your_preferred_language_test.go b/internal/certificateprovider/certificateproviderpage/your_preferred_language_test.go index 19e2608bdc..4b95732453 100644 --- a/internal/certificateprovider/certificateproviderpage/your_preferred_language_test.go +++ b/internal/certificateprovider/certificateproviderpage/your_preferred_language_test.go @@ -12,7 +12,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/certificateprovider/certificateproviderdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "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 TestGetYourPreferredLanguage(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, nil) + Return(&lpadata.Lpa{}, nil) template := newMockTemplate(t) template.EXPECT(). @@ -37,7 +37,7 @@ func TestGetYourPreferredLanguage(t *testing.T) { }, Options: localize.LangValues, FieldName: form.FieldNames.LanguagePreference, - Lpa: &lpastore.Lpa{}, + Lpa: &lpadata.Lpa{}, }). Return(nil) @@ -56,7 +56,7 @@ func TestGetYourPreferredLanguageWhenLpaStoreResolvingServiceError(t *testing.T) lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, expectedError) + Return(&lpadata.Lpa{}, expectedError) err := YourPreferredLanguage(nil, nil, lpaStoreResolvingService)(testAppData, w, r, &certificateproviderdata.Provided{LpaID: "lpa-id", ContactLanguagePreference: localize.Cy}) resp := w.Result() @@ -72,7 +72,7 @@ func TestGetYourPreferredLanguageWhenTemplateError(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, nil) + Return(&lpadata.Lpa{}, nil) template := newMockTemplate(t) template.EXPECT(). @@ -105,7 +105,7 @@ func TestPostYourPreferredLanguage(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, nil) + Return(&lpadata.Lpa{}, nil) err := YourPreferredLanguage(nil, certificateProviderStore, lpaStoreResolvingService)(testAppData, w, r, &certificateproviderdata.Provided{LpaID: "lpa-id"}) resp := w.Result() @@ -132,7 +132,7 @@ func TestPostYourPreferredLanguageWhenAttorneyStoreError(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, nil) + Return(&lpadata.Lpa{}, nil) err := YourPreferredLanguage(nil, certificateProviderStore, lpaStoreResolvingService)(testAppData, w, r, &certificateproviderdata.Provided{}) resp := w.Result() @@ -151,7 +151,7 @@ func TestPostYourPreferredLanguageWhenInvalidData(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, nil) + Return(&lpadata.Lpa{}, nil) template := newMockTemplate(t) template.EXPECT(). @@ -164,7 +164,7 @@ func TestPostYourPreferredLanguageWhenInvalidData(t *testing.T) { Options: localize.LangValues, FieldName: form.FieldNames.LanguagePreference, Errors: validation.With(form.FieldNames.LanguagePreference, validation.SelectError{Label: "whichLanguageYouWouldLikeUsToUseWhenWeContactYou"}), - Lpa: &lpastore.Lpa{}, + Lpa: &lpadata.Lpa{}, }). Return(nil) diff --git a/internal/dashboard/mock_LpaStoreResolvingService_test.go b/internal/dashboard/mock_LpaStoreResolvingService_test.go index ff0db02c40..299fc7a163 100644 --- a/internal/dashboard/mock_LpaStoreResolvingService_test.go +++ b/internal/dashboard/mock_LpaStoreResolvingService_test.go @@ -6,7 +6,7 @@ import ( context "context" donordata "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" - lpastore "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + lpadata "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" mock "github.com/stretchr/testify/mock" ) @@ -25,23 +25,23 @@ func (_m *mockLpaStoreResolvingService) EXPECT() *mockLpaStoreResolvingService_E } // ResolveList provides a mock function with given fields: ctx, donors -func (_m *mockLpaStoreResolvingService) ResolveList(ctx context.Context, donors []*donordata.Provided) ([]*lpastore.Lpa, error) { +func (_m *mockLpaStoreResolvingService) ResolveList(ctx context.Context, donors []*donordata.Provided) ([]*lpadata.Lpa, error) { ret := _m.Called(ctx, donors) if len(ret) == 0 { panic("no return value specified for ResolveList") } - var r0 []*lpastore.Lpa + var r0 []*lpadata.Lpa var r1 error - if rf, ok := ret.Get(0).(func(context.Context, []*donordata.Provided) ([]*lpastore.Lpa, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, []*donordata.Provided) ([]*lpadata.Lpa, error)); ok { return rf(ctx, donors) } - if rf, ok := ret.Get(0).(func(context.Context, []*donordata.Provided) []*lpastore.Lpa); ok { + if rf, ok := ret.Get(0).(func(context.Context, []*donordata.Provided) []*lpadata.Lpa); ok { r0 = rf(ctx, donors) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]*lpastore.Lpa) + r0 = ret.Get(0).([]*lpadata.Lpa) } } @@ -73,12 +73,12 @@ func (_c *mockLpaStoreResolvingService_ResolveList_Call) Run(run func(ctx contex return _c } -func (_c *mockLpaStoreResolvingService_ResolveList_Call) Return(_a0 []*lpastore.Lpa, _a1 error) *mockLpaStoreResolvingService_ResolveList_Call { +func (_c *mockLpaStoreResolvingService_ResolveList_Call) Return(_a0 []*lpadata.Lpa, _a1 error) *mockLpaStoreResolvingService_ResolveList_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockLpaStoreResolvingService_ResolveList_Call) RunAndReturn(run func(context.Context, []*donordata.Provided) ([]*lpastore.Lpa, error)) *mockLpaStoreResolvingService_ResolveList_Call { +func (_c *mockLpaStoreResolvingService_ResolveList_Call) RunAndReturn(run func(context.Context, []*donordata.Provided) ([]*lpadata.Lpa, error)) *mockLpaStoreResolvingService_ResolveList_Call { _c.Call.Return(run) return _c } diff --git a/internal/dashboard/store.go b/internal/dashboard/store.go index 9f0a6b8180..c00537ad6e 100644 --- a/internal/dashboard/store.go +++ b/internal/dashboard/store.go @@ -15,7 +15,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/dashboard/dashboarddata" "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/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" ) @@ -40,7 +40,7 @@ type DynamoClient interface { } type LpaStoreResolvingService interface { - ResolveList(ctx context.Context, donors []*donordata.Provided) ([]*lpastore.Lpa, error) + ResolveList(ctx context.Context, donors []*donordata.Provided) ([]*lpadata.Lpa, error) } type dashboardStore struct { diff --git a/internal/dashboard/store_test.go b/internal/dashboard/store_test.go index 76b3882967..2c939bed5f 100644 --- a/internal/dashboard/store_test.go +++ b/internal/dashboard/store_test.go @@ -16,7 +16,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/dashboard/dashboarddata" "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/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" @@ -45,7 +45,7 @@ func TestDashboardStoreGetAll(t *testing.T) { sessionID := "an-id" aTime := time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC) - lpa0 := &lpastore.Lpa{LpaID: "0", LpaUID: "M", UpdatedAt: aTime} + lpa0 := &lpadata.Lpa{LpaID: "0", LpaUID: "M", UpdatedAt: aTime} lpa0Donor := &donordata.Provided{ PK: dynamo.LpaKey("0"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey(sessionID)), @@ -53,7 +53,7 @@ func TestDashboardStoreGetAll(t *testing.T) { LpaUID: "M", UpdatedAt: aTime, } - lpa123 := &lpastore.Lpa{LpaID: "123", LpaUID: "M", UpdatedAt: aTime} + lpa123 := &lpadata.Lpa{LpaID: "123", LpaUID: "M", UpdatedAt: aTime} lpa123Donor := &donordata.Provided{ PK: dynamo.LpaKey("123"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey(sessionID)), @@ -61,7 +61,7 @@ func TestDashboardStoreGetAll(t *testing.T) { LpaUID: "M", UpdatedAt: aTime, } - lpa456 := &lpastore.Lpa{LpaID: "456", LpaUID: "M"} + lpa456 := &lpadata.Lpa{LpaID: "456", LpaUID: "M"} lpa456Donor := &donordata.Provided{ PK: dynamo.LpaKey("456"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("another-id")), @@ -74,7 +74,7 @@ func TestDashboardStoreGetAll(t *testing.T) { LpaID: "456", Tasks: certificateproviderdata.Tasks{ConfirmYourDetails: task.StateCompleted}, } - lpa789 := &lpastore.Lpa{LpaID: "789", LpaUID: "M"} + lpa789 := &lpadata.Lpa{LpaID: "789", LpaUID: "M"} lpa789Donor := &donordata.Provided{ PK: dynamo.LpaKey("789"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("different-id")), @@ -93,7 +93,7 @@ func TestDashboardStoreGetAll(t *testing.T) { LpaID: "999", UpdatedAt: aTime, } - lpaCertified := &lpastore.Lpa{LpaID: "signed-by-cp", LpaUID: "M"} + lpaCertified := &lpadata.Lpa{LpaID: "signed-by-cp", LpaUID: "M"} lpaCertifiedDonor := &donordata.Provided{ PK: dynamo.LpaKey("signed-by-cp"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("another-id")), @@ -106,7 +106,7 @@ func TestDashboardStoreGetAll(t *testing.T) { LpaID: "signed-by-cp", SignedAt: time.Now(), } - lpaReferenced := &lpastore.Lpa{LpaID: "referenced", LpaUID: "X"} + lpaReferenced := &lpadata.Lpa{LpaID: "referenced", LpaUID: "X"} lpaReferencedLink := map[string]any{ "PK": dynamo.LpaKey("referenced"), "SK": dynamo.DonorKey(sessionID), @@ -181,7 +181,7 @@ func TestDashboardStoreGetAll(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). ResolveList(ctx, []*donordata.Provided{lpa123Donor, lpa456Donor, lpa789Donor, lpa0Donor, lpaCertifiedDonor, lpaReferencedDonor}). - Return([]*lpastore.Lpa{lpa123, lpa456, lpa789, lpa0, lpaCertified, lpaReferenced}, nil) + Return([]*lpadata.Lpa{lpa123, lpa456, lpa789, lpa0, lpaCertified, lpaReferenced}, nil) dashboardStore := &dashboardStore{dynamoClient: dynamoClient, lpaStoreResolvingService: lpaStoreResolvingService} @@ -199,7 +199,7 @@ func TestDashboardStoreGetAllSubmittedForAttorneys(t *testing.T) { sessionID := "an-id" aTime := time.Date(2000, time.January, 1, 0, 0, 0, 0, time.UTC) - lpaSubmitted := &lpastore.Lpa{LpaID: "submitted", LpaUID: "M", Submitted: true} + lpaSubmitted := &lpadata.Lpa{LpaID: "submitted", LpaUID: "M", Submitted: true} lpaSubmittedDonor := &donordata.Provided{ PK: dynamo.LpaKey("submitted"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("another-id")), @@ -212,7 +212,7 @@ func TestDashboardStoreGetAllSubmittedForAttorneys(t *testing.T) { SK: dynamo.AttorneyKey(sessionID), LpaID: "submitted", } - lpaSubmittedReplacement := &lpastore.Lpa{LpaID: "submitted-replacement", LpaUID: "M", Submitted: true} + lpaSubmittedReplacement := &lpadata.Lpa{LpaID: "submitted-replacement", LpaUID: "M", Submitted: true} lpaSubmittedReplacementDonor := &donordata.Provided{ PK: dynamo.LpaKey("submitted-replacement"), SK: dynamo.LpaOwnerKey(dynamo.DonorKey("another-id")), @@ -250,7 +250,7 @@ func TestDashboardStoreGetAllSubmittedForAttorneys(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). ResolveList(ctx, []*donordata.Provided{lpaSubmittedDonor, lpaSubmittedReplacementDonor}). - Return([]*lpastore.Lpa{lpaSubmitted, lpaSubmittedReplacement}, nil) + Return([]*lpadata.Lpa{lpaSubmitted, lpaSubmittedReplacement}, nil) dashboardStore := &dashboardStore{dynamoClient: dynamoClient, lpaStoreResolvingService: lpaStoreResolvingService} diff --git a/internal/donor/donorpage/certificate_provider_address.go b/internal/donor/donorpage/certificate_provider_address.go index 7f60bcd2a3..52cf76af67 100644 --- a/internal/donor/donorpage/certificate_provider_address.go +++ b/internal/donor/donorpage/certificate_provider_address.go @@ -44,7 +44,7 @@ func CertificateProviderAddress(logger Logger, tmpl template.Template, addressCl data.Errors = data.Form.Validate(false) setAddress := func(address place.Address) error { - provided.CertificateProvider.Address = *data.Form.Address + provided.CertificateProvider.Address = address provided.Tasks.CertificateProvider = task.StateCompleted if err := donorStore.Put(r.Context(), provided); err != nil { diff --git a/internal/donor/donorpage/choose_people_to_notify_address.go b/internal/donor/donorpage/choose_people_to_notify_address.go index 87987233e6..7f2e524759 100644 --- a/internal/donor/donorpage/choose_people_to_notify_address.go +++ b/internal/donor/donorpage/choose_people_to_notify_address.go @@ -38,7 +38,7 @@ func ChoosePeopleToNotifyAddress(logger Logger, tmpl template.Template, addressC data.Errors = data.Form.Validate(false) setAddress := func(address place.Address) error { - personToNotify.Address = *data.Form.Address + personToNotify.Address = address provided.PeopleToNotify.Put(personToNotify) provided.Tasks.PeopleToNotify = task.StateCompleted diff --git a/internal/donor/donorpage/enter_correspondent_address.go b/internal/donor/donorpage/enter_correspondent_address.go index aaee0423dd..e585d30915 100644 --- a/internal/donor/donorpage/enter_correspondent_address.go +++ b/internal/donor/donorpage/enter_correspondent_address.go @@ -33,7 +33,7 @@ func EnterCorrespondentAddress(logger Logger, tmpl template.Template, addressCli setAddress := func(address place.Address) error { provided.Tasks.AddCorrespondent = task.StateCompleted - provided.Correspondent.Address = *data.Form.Address + provided.Correspondent.Address = address if err := donorStore.Put(r.Context(), provided); err != nil { return err diff --git a/internal/donor/donorpage/lpa_progress.go b/internal/donor/donorpage/lpa_progress.go index d5d6836484..c6a24435fb 100644 --- a/internal/donor/donorpage/lpa_progress.go +++ b/internal/donor/donorpage/lpa_progress.go @@ -6,14 +6,14 @@ import ( "github.com/ministryofjustice/opg-go-common/template" "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/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) type lpaProgressData struct { App appcontext.Data Donor *donordata.Provided - Progress page.Progress + Progress task.Progress Errors validation.List } diff --git a/internal/donor/donorpage/lpa_progress_test.go b/internal/donor/donorpage/lpa_progress_test.go index c864d52fd0..bdfe2b65f8 100644 --- a/internal/donor/donorpage/lpa_progress_test.go +++ b/internal/donor/donorpage/lpa_progress_test.go @@ -6,8 +6,7 @@ import ( "testing" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" - lpastore "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" - "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -17,7 +16,7 @@ func TestGetLpaProgress(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - lpa := &lpastore.Lpa{LpaUID: "lpa-uid"} + lpa := &lpadata.Lpa{LpaUID: "lpa-uid"} lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). @@ -27,14 +26,14 @@ func TestGetLpaProgress(t *testing.T) { progressTracker := newMockProgressTracker(t) progressTracker.EXPECT(). Progress(lpa). - Return(page.Progress{DonorSigned: page.ProgressTask{State: task.StateInProgress}}) + Return(task.Progress{DonorSigned: task.ProgressTask{State: task.StateInProgress}}) template := newMockTemplate(t) template.EXPECT(). Execute(w, &lpaProgressData{ App: testAppData, Donor: &donordata.Provided{LpaUID: "lpa-uid"}, - Progress: page.Progress{DonorSigned: page.ProgressTask{State: task.StateInProgress}}, + Progress: task.Progress{DonorSigned: task.ProgressTask{State: task.StateInProgress}}, }). Return(nil) @@ -65,12 +64,12 @@ func TestGetLpaProgressOnTemplateError(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, nil) + Return(&lpadata.Lpa{}, nil) progressTracker := newMockProgressTracker(t) progressTracker.EXPECT(). Progress(mock.Anything). - Return(page.Progress{}) + Return(task.Progress{}) template := newMockTemplate(t) template.EXPECT(). diff --git a/internal/donor/donorpage/mock_LpaStoreClient_test.go b/internal/donor/donorpage/mock_LpaStoreClient_test.go index 1d437ff9a3..8ba9cfd169 100644 --- a/internal/donor/donorpage/mock_LpaStoreClient_test.go +++ b/internal/donor/donorpage/mock_LpaStoreClient_test.go @@ -6,7 +6,7 @@ import ( context "context" donordata "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" - lpastore "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + lpadata "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" mock "github.com/stretchr/testify/mock" ) @@ -25,23 +25,23 @@ func (_m *mockLpaStoreClient) EXPECT() *mockLpaStoreClient_Expecter { } // Lpa provides a mock function with given fields: ctx, lpaUID -func (_m *mockLpaStoreClient) Lpa(ctx context.Context, lpaUID string) (*lpastore.Lpa, error) { +func (_m *mockLpaStoreClient) Lpa(ctx context.Context, lpaUID string) (*lpadata.Lpa, error) { ret := _m.Called(ctx, lpaUID) if len(ret) == 0 { panic("no return value specified for Lpa") } - var r0 *lpastore.Lpa + var r0 *lpadata.Lpa var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string) (*lpastore.Lpa, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string) (*lpadata.Lpa, error)); ok { return rf(ctx, lpaUID) } - if rf, ok := ret.Get(0).(func(context.Context, string) *lpastore.Lpa); ok { + if rf, ok := ret.Get(0).(func(context.Context, string) *lpadata.Lpa); ok { r0 = rf(ctx, lpaUID) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*lpastore.Lpa) + r0 = ret.Get(0).(*lpadata.Lpa) } } @@ -73,12 +73,12 @@ func (_c *mockLpaStoreClient_Lpa_Call) Run(run func(ctx context.Context, lpaUID return _c } -func (_c *mockLpaStoreClient_Lpa_Call) Return(_a0 *lpastore.Lpa, _a1 error) *mockLpaStoreClient_Lpa_Call { +func (_c *mockLpaStoreClient_Lpa_Call) Return(_a0 *lpadata.Lpa, _a1 error) *mockLpaStoreClient_Lpa_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockLpaStoreClient_Lpa_Call) RunAndReturn(run func(context.Context, string) (*lpastore.Lpa, error)) *mockLpaStoreClient_Lpa_Call { +func (_c *mockLpaStoreClient_Lpa_Call) RunAndReturn(run func(context.Context, string) (*lpadata.Lpa, error)) *mockLpaStoreClient_Lpa_Call { _c.Call.Return(run) return _c } diff --git a/internal/donor/donorpage/mock_LpaStoreResolvingService_test.go b/internal/donor/donorpage/mock_LpaStoreResolvingService_test.go index f1388245c8..28964a178a 100644 --- a/internal/donor/donorpage/mock_LpaStoreResolvingService_test.go +++ b/internal/donor/donorpage/mock_LpaStoreResolvingService_test.go @@ -5,7 +5,7 @@ package donorpage import ( context "context" - lpastore "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + lpadata "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" mock "github.com/stretchr/testify/mock" ) @@ -23,23 +23,23 @@ func (_m *mockLpaStoreResolvingService) EXPECT() *mockLpaStoreResolvingService_E } // Get provides a mock function with given fields: ctx -func (_m *mockLpaStoreResolvingService) Get(ctx context.Context) (*lpastore.Lpa, error) { +func (_m *mockLpaStoreResolvingService) Get(ctx context.Context) (*lpadata.Lpa, error) { ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for Get") } - var r0 *lpastore.Lpa + var r0 *lpadata.Lpa var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (*lpastore.Lpa, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context) (*lpadata.Lpa, error)); ok { return rf(ctx) } - if rf, ok := ret.Get(0).(func(context.Context) *lpastore.Lpa); ok { + if rf, ok := ret.Get(0).(func(context.Context) *lpadata.Lpa); ok { r0 = rf(ctx) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*lpastore.Lpa) + r0 = ret.Get(0).(*lpadata.Lpa) } } @@ -70,12 +70,12 @@ func (_c *mockLpaStoreResolvingService_Get_Call) Run(run func(ctx context.Contex return _c } -func (_c *mockLpaStoreResolvingService_Get_Call) Return(_a0 *lpastore.Lpa, _a1 error) *mockLpaStoreResolvingService_Get_Call { +func (_c *mockLpaStoreResolvingService_Get_Call) Return(_a0 *lpadata.Lpa, _a1 error) *mockLpaStoreResolvingService_Get_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockLpaStoreResolvingService_Get_Call) RunAndReturn(run func(context.Context) (*lpastore.Lpa, error)) *mockLpaStoreResolvingService_Get_Call { +func (_c *mockLpaStoreResolvingService_Get_Call) RunAndReturn(run func(context.Context) (*lpadata.Lpa, error)) *mockLpaStoreResolvingService_Get_Call { _c.Call.Return(run) return _c } diff --git a/internal/donor/donorpage/mock_ProgressTracker_test.go b/internal/donor/donorpage/mock_ProgressTracker_test.go index dec938ed08..06f82e0a19 100644 --- a/internal/donor/donorpage/mock_ProgressTracker_test.go +++ b/internal/donor/donorpage/mock_ProgressTracker_test.go @@ -3,10 +3,10 @@ package donorpage import ( - lpastore "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + lpadata "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" mock "github.com/stretchr/testify/mock" - page "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + task "github.com/ministryofjustice/opg-modernising-lpa/internal/task" ) // mockProgressTracker is an autogenerated mock type for the ProgressTracker type @@ -23,18 +23,18 @@ func (_m *mockProgressTracker) EXPECT() *mockProgressTracker_Expecter { } // Progress provides a mock function with given fields: lpa -func (_m *mockProgressTracker) Progress(lpa *lpastore.Lpa) page.Progress { +func (_m *mockProgressTracker) Progress(lpa *lpadata.Lpa) task.Progress { ret := _m.Called(lpa) if len(ret) == 0 { panic("no return value specified for Progress") } - var r0 page.Progress - if rf, ok := ret.Get(0).(func(*lpastore.Lpa) page.Progress); ok { + var r0 task.Progress + if rf, ok := ret.Get(0).(func(*lpadata.Lpa) task.Progress); ok { r0 = rf(lpa) } else { - r0 = ret.Get(0).(page.Progress) + r0 = ret.Get(0).(task.Progress) } return r0 @@ -46,24 +46,24 @@ type mockProgressTracker_Progress_Call struct { } // Progress is a helper method to define mock.On call -// - lpa *lpastore.Lpa +// - lpa *lpadata.Lpa func (_e *mockProgressTracker_Expecter) Progress(lpa interface{}) *mockProgressTracker_Progress_Call { return &mockProgressTracker_Progress_Call{Call: _e.mock.On("Progress", lpa)} } -func (_c *mockProgressTracker_Progress_Call) Run(run func(lpa *lpastore.Lpa)) *mockProgressTracker_Progress_Call { +func (_c *mockProgressTracker_Progress_Call) Run(run func(lpa *lpadata.Lpa)) *mockProgressTracker_Progress_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*lpastore.Lpa)) + run(args[0].(*lpadata.Lpa)) }) return _c } -func (_c *mockProgressTracker_Progress_Call) Return(_a0 page.Progress) *mockProgressTracker_Progress_Call { +func (_c *mockProgressTracker_Progress_Call) Return(_a0 task.Progress) *mockProgressTracker_Progress_Call { _c.Call.Return(_a0) return _c } -func (_c *mockProgressTracker_Progress_Call) RunAndReturn(run func(*lpastore.Lpa) page.Progress) *mockProgressTracker_Progress_Call { +func (_c *mockProgressTracker_Progress_Call) RunAndReturn(run func(*lpadata.Lpa) task.Progress) *mockProgressTracker_Progress_Call { _c.Call.Return(run) return _c } diff --git a/internal/donor/donorpage/mock_test.go b/internal/donor/donorpage/mock_test.go index 14ab45f4e7..b55c45d036 100644 --- a/internal/donor/donorpage/mock_test.go +++ b/internal/donor/donorpage/mock_test.go @@ -14,8 +14,6 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" ) -var mockUuidString = func() string { return "123" } - var ( testAddress = place.Address{ Line1: "a", diff --git a/internal/donor/donorpage/payment_confirmation_test.go b/internal/donor/donorpage/payment_confirmation_test.go index ef7e276610..ecba37277c 100644 --- a/internal/donor/donorpage/payment_confirmation_test.go +++ b/internal/donor/donorpage/payment_confirmation_test.go @@ -44,7 +44,7 @@ func TestGetPaymentConfirmationFullFee(t *testing.T) { r, _ := http.NewRequest(http.MethodGet, "/payment-confirmation", nil) payClient := newMockPayClient(t). - withASuccessfulPayment("abc123", "123456789012", 8200, r.Context()) + withASuccessfulPayment(8200, r.Context()) localizer := newMockLocalizer(t). withEmailLocalizations() @@ -126,7 +126,7 @@ func TestGetPaymentConfirmationHalfFee(t *testing.T) { r, _ := http.NewRequest(http.MethodGet, "/payment-confirmation", nil) payClient := newMockPayClient(t). - withASuccessfulPayment("abc123", "123456789012", 4100, r.Context()) + withASuccessfulPayment(4100, r.Context()) localizer := newMockLocalizer(t). withEmailLocalizations() @@ -205,7 +205,7 @@ func TestGetPaymentConfirmationApprovedOrDenied(t *testing.T) { r, _ := http.NewRequest(http.MethodGet, "/payment-confirmation", nil) payClient := newMockPayClient(t). - withASuccessfulPayment("abc123", "123456789012", 8200, r.Context()) + withASuccessfulPayment(8200, r.Context()) localizer := newMockLocalizer(t). withEmailLocalizations() @@ -305,7 +305,7 @@ func TestGetPaymentConfirmationApprovedOrDeniedWhenSigned(t *testing.T) { } payClient := newMockPayClient(t). - withASuccessfulPayment("abc123", "123456789012", 8200, r.Context()) + withASuccessfulPayment(8200, r.Context()) localizer := newMockLocalizer(t). withEmailLocalizations() @@ -386,7 +386,7 @@ func TestGetPaymentConfirmationApprovedOrDeniedWhenVoucherAllowed(t *testing.T) r, _ := http.NewRequest(http.MethodGet, "/payment-confirmation", nil) payClient := newMockPayClient(t). - withASuccessfulPayment("abc123", "123456789012", 8200, r.Context()) + withASuccessfulPayment(8200, r.Context()) localizer := newMockLocalizer(t). withEmailLocalizations() @@ -530,7 +530,7 @@ func TestGetPaymentConfirmationWhenErrorExpiringSession(t *testing.T) { InfoContext(r.Context(), "unable to expire cookie in session", slog.Any("err", expectedError)) payClient := newMockPayClient(t). - withASuccessfulPayment("abc123", "123456789012", 8200, r.Context()) + withASuccessfulPayment(8200, r.Context()) template := newMockTemplate(t) template.EXPECT(). @@ -568,7 +568,7 @@ func TestGetPaymentConfirmationWhenEventClientError(t *testing.T) { r, _ := http.NewRequest(http.MethodGet, "/payment-confirmation", nil) payClient := newMockPayClient(t). - withASuccessfulPayment("abc123", "123456789012", 4100, r.Context()) + withASuccessfulPayment(4100, r.Context()) sessionStore := newMockSessionStore(t). withPaySession(r) @@ -595,7 +595,7 @@ func TestGetPaymentConfirmationWhenNotifyClientError(t *testing.T) { r, _ := http.NewRequest(http.MethodGet, "/payment-confirmation", nil) payClient := newMockPayClient(t). - withASuccessfulPayment("abc123", "123456789012", 4100, r.Context()) + withASuccessfulPayment(4100, r.Context()) sessionStore := newMockSessionStore(t). withPaySession(r) @@ -634,7 +634,7 @@ func TestGetPaymentConfirmationHalfFeeWhenDonorStorePutError(t *testing.T) { r, _ := http.NewRequest(http.MethodGet, "/payment-confirmation", nil) payClient := newMockPayClient(t). - withASuccessfulPayment("abc123", "123456789012", 4100, r.Context()) + withASuccessfulPayment(4100, r.Context()) sessionStore := newMockSessionStore(t). withPaySession(r) @@ -677,7 +677,7 @@ func TestGetPaymentConfirmationWhenLpaStoreClientErrors(t *testing.T) { r, _ := http.NewRequest(http.MethodGet, "/payment-confirmation", nil) payClient := newMockPayClient(t). - withASuccessfulPayment("abc123", "123456789012", 8200, r.Context()) + withASuccessfulPayment(8200, r.Context()) sessionStore := newMockSessionStore(t). withPaySession(r) @@ -730,7 +730,7 @@ func TestGetPaymentConfirmationWhenEventClientErrors(t *testing.T) { r, _ := http.NewRequest(http.MethodGet, "/payment-confirmation", nil) payClient := newMockPayClient(t). - withASuccessfulPayment("abc123", "123456789012", 8200, r.Context()) + withASuccessfulPayment(8200, r.Context()) sessionStore := newMockSessionStore(t). withPaySession(r) @@ -778,7 +778,7 @@ func TestGetPaymentConfirmationWhenShareCodeSenderErrors(t *testing.T) { r, _ := http.NewRequest(http.MethodGet, "/payment-confirmation", nil) payClient := newMockPayClient(t). - withASuccessfulPayment("abc123", "123456789012", 8200, r.Context()) + withASuccessfulPayment(8200, r.Context()) sessionStore := newMockSessionStore(t). withPaySession(r) @@ -818,17 +818,17 @@ func TestGetPaymentConfirmationWhenShareCodeSenderErrors(t *testing.T) { assert.ErrorIs(t, err, expectedError) } -func (m *mockPayClient) withASuccessfulPayment(paymentId, reference string, amount int, ctx context.Context) *mockPayClient { +func (m *mockPayClient) withASuccessfulPayment(amount int, ctx context.Context) *mockPayClient { m.EXPECT(). - GetPayment(ctx, paymentId). + GetPayment(ctx, "abc123"). Return(pay.GetPaymentResponse{ Email: "a@example.com", State: pay.State{ Status: "success", Finished: true, }, - PaymentID: paymentId, - Reference: reference, + PaymentID: "abc123", + Reference: "123456789012", AmountPence: pay.AmountPence(amount), SettlementSummary: pay.SettlementSummary{ CaptureSubmitTime: time.Date(2000, 1, 2, 0, 0, 0, 0, time.UTC), diff --git a/internal/donor/donorpage/register.go b/internal/donor/donorpage/register.go index ceb6f637e5..58a155111f 100644 --- a/internal/donor/donorpage/register.go +++ b/internal/donor/donorpage/register.go @@ -17,7 +17,7 @@ import ( "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" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/onelogin" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" @@ -26,11 +26,12 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/random" "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/uid" ) type LpaStoreResolvingService interface { - Get(ctx context.Context) (*lpastore.Lpa, error) + Get(ctx context.Context) (*lpadata.Lpa, error) } type Handler func(data appcontext.Data, w http.ResponseWriter, r *http.Request, donor *donordata.Provided) error @@ -145,7 +146,7 @@ type DashboardStore interface { } type LpaStoreClient interface { - Lpa(ctx context.Context, lpaUID string) (*lpastore.Lpa, error) + Lpa(ctx context.Context, lpaUID string) (*lpadata.Lpa, error) SendDonorConfirmIdentity(ctx context.Context, donor *donordata.Provided) error SendLpa(ctx context.Context, details *donordata.Provided) error SendDonorWithdrawLPA(ctx context.Context, lpaUID string) error @@ -158,7 +159,7 @@ type ShareCodeStore interface { type ErrorHandler func(http.ResponseWriter, *http.Request, error) type ProgressTracker interface { - Progress(lpa *lpastore.Lpa) page.Progress + Progress(lpa *lpadata.Lpa) task.Progress } func Register( diff --git a/internal/donor/donorpage/your_independent_witness_address.go b/internal/donor/donorpage/your_independent_witness_address.go index 7d787318e6..bbe2dc7105 100644 --- a/internal/donor/donorpage/your_independent_witness_address.go +++ b/internal/donor/donorpage/your_independent_witness_address.go @@ -33,7 +33,7 @@ func YourIndependentWitnessAddress(logger Logger, tmpl template.Template, addres setAddress := func(address place.Address) error { provided.Tasks.ChooseYourSignatory = task.StateCompleted - provided.IndependentWitness.Address = *data.Form.Address + provided.IndependentWitness.Address = address if err := donorStore.Put(r.Context(), provided); err != nil { return err diff --git a/internal/lpastore/client_test.go b/internal/lpastore/client_test.go index 09517de25b..e091b6e40a 100644 --- a/internal/lpastore/client_test.go +++ b/internal/lpastore/client_test.go @@ -18,7 +18,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" - donordata "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/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/lpastore/lpadata" @@ -26,7 +26,7 @@ import ( "github.com/pact-foundation/pact-go/v2/consumer" "github.com/pact-foundation/pact-go/v2/matchers" "github.com/stretchr/testify/assert" - mock "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/mock" ) var expectedError = errors.New("err") @@ -458,10 +458,10 @@ func TestClientServiceContract(t *testing.T) { } err := client.SendAttorney(context.Background(), - &Lpa{ + &lpadata.Lpa{ LpaUID: "M-0000-1111-2222", - Attorneys: Attorneys{ - Attorneys: []Attorney{{UID: uid}}, + Attorneys: lpadata.Attorneys{ + Attorneys: []lpadata.Attorney{{UID: uid}}, }, }, &attorneydata.Provided{ @@ -546,10 +546,10 @@ func TestClientServiceContract(t *testing.T) { } err := client.SendAttorney(context.Background(), - &Lpa{ + &lpadata.Lpa{ LpaUID: "M-0000-1111-2222", - Attorneys: Attorneys{ - TrustCorporation: TrustCorporation{ + Attorneys: lpadata.Attorneys{ + TrustCorporation: lpadata.TrustCorporation{ UID: uid, Name: "Trust us Corp.", CompanyNumber: "66654321", @@ -634,7 +634,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: lpadata.ChannelPaper}, LpaUID: "M-0000-1111-2222"}) + }, &lpadata.Lpa{CertificateProvider: lpadata.CertificateProvider{Channel: lpadata.ChannelPaper}, LpaUID: "M-0000-1111-2222"}) assert.Nil(t, err) return nil })) @@ -714,8 +714,8 @@ func TestClientServiceContract(t *testing.T) { Country: "GB", }, Email: "a@example.com", - }, &Lpa{ - CertificateProvider: CertificateProvider{ + }, &lpadata.Lpa{ + CertificateProvider: lpadata.CertificateProvider{ Channel: lpadata.ChannelPaper, Address: place.Address{ Line1: "71 South Western Terrace", @@ -860,10 +860,10 @@ func TestClientServiceContract(t *testing.T) { return err } - assert.Equal(t, &Lpa{ + assert.Equal(t, &lpadata.Lpa{ LpaUID: "M-0000-1111-2222", Type: lpadata.LpaTypePersonalWelfare, - Donor: Donor{ + Donor: lpadata.Donor{ FirstNames: "Homer", LastName: "Zoller", DateOfBirth: date.New("1960", "04", "06"), @@ -875,8 +875,8 @@ func TestClientServiceContract(t *testing.T) { }, Channel: lpadata.ChannelOnline, }, - Attorneys: Attorneys{ - Attorneys: []Attorney{{ + Attorneys: lpadata.Attorneys{ + Attorneys: []lpadata.Attorney{{ FirstNames: "Jake", LastName: "Valler", DateOfBirth: date.New("2001", "01", "17"), @@ -888,7 +888,7 @@ func TestClientServiceContract(t *testing.T) { Channel: lpadata.ChannelPaper, }}, }, - CertificateProvider: CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ FirstNames: "Some", LastName: "Provider", Email: "some@example.com", @@ -992,10 +992,10 @@ func TestClientServiceContract(t *testing.T) { return err } - assert.Equal(t, []*Lpa{{ + assert.Equal(t, []*lpadata.Lpa{{ LpaUID: "M-0000-1111-2222", Type: lpadata.LpaTypePersonalWelfare, - Donor: Donor{ + Donor: lpadata.Donor{ FirstNames: "Homer", LastName: "Zoller", DateOfBirth: date.New("1960", "04", "06"), @@ -1007,8 +1007,8 @@ func TestClientServiceContract(t *testing.T) { }, Channel: lpadata.ChannelOnline, }, - Attorneys: Attorneys{ - Attorneys: []Attorney{{ + Attorneys: lpadata.Attorneys{ + Attorneys: []lpadata.Attorney{{ FirstNames: "Jake", LastName: "Valler", DateOfBirth: date.New("2001", "01", "17"), @@ -1020,7 +1020,7 @@ func TestClientServiceContract(t *testing.T) { Channel: lpadata.ChannelOnline, }}, }, - CertificateProvider: CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ FirstNames: "Some", LastName: "Provider", Email: "some@example.com", diff --git a/internal/lpastore/lpa.go b/internal/lpastore/lpa.go index caad58b567..7ca2ef6691 100644 --- a/internal/lpastore/lpa.go +++ b/internal/lpastore/lpa.go @@ -7,13 +7,11 @@ import ( "fmt" "io" "net/http" - "slices" "time" "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/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" @@ -274,88 +272,9 @@ type lpaResponseAttorney struct { type lpaResponseTrustCorporation struct { lpaRequestTrustCorporation - Mobile string `json:"mobile"` - Signatories []TrustCorporationSignatory `json:"signatories"` - ContactLanguagePreference localize.Lang `json:"contactLanguagePreference"` -} - -type Donor struct { - UID actoruid.UID - FirstNames string - LastName string - Email string - OtherNames string - DateOfBirth date.Date - Address place.Address - Channel lpadata.Channel - ContactLanguagePreference localize.Lang - IdentityCheck IdentityCheck -} - -func (d Donor) FullName() string { - return d.FirstNames + " " + d.LastName -} - -type Attorney struct { - UID actoruid.UID - FirstNames string - LastName string - DateOfBirth date.Date - Email string - Address place.Address - Mobile string - SignedAt time.Time - ContactLanguagePreference localize.Lang - Channel lpadata.Channel -} - -func (a Attorney) FullName() string { - return a.FirstNames + " " + a.LastName -} - -type TrustCorporation struct { - UID actoruid.UID - Name string - CompanyNumber string - Email string - Address place.Address - Mobile string - Signatories []TrustCorporationSignatory - ContactLanguagePreference localize.Lang - Channel lpadata.Channel -} - -type TrustCorporationSignatory struct { - FirstNames string `json:"firstNames"` - LastName string `json:"lastName"` - ProfessionalTitle string `json:"professionalTitle"` - SignedAt time.Time `json:"signedAt"` -} - -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 lpadata.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 lpadata.CertificateProviderRelationship -} - -func (c CertificateProvider) FullName() string { - return c.FirstNames + " " + c.LastName -} - -type IdentityCheck struct { - CheckedAt time.Time `json:"checkedAt"` - Type string `json:"type"` + Mobile string `json:"mobile"` + Signatories []lpadata.TrustCorporationSignatory `json:"signatories"` + ContactLanguagePreference localize.Lang `json:"contactLanguagePreference"` } type lpaResponse struct { @@ -364,7 +283,7 @@ type lpaResponse struct { Channel lpadata.Channel `json:"channel"` Attorneys []lpaResponseAttorney `json:"attorneys"` TrustCorporations []lpaResponseTrustCorporation `json:"trustCorporations,omitempty"` - CertificateProvider CertificateProvider `json:"certificateProvider"` + CertificateProvider lpadata.CertificateProvider `json:"certificateProvider"` PeopleToNotify []lpaRequestPersonToNotify `json:"peopleToNotify,omitempty"` HowAttorneysMakeDecisions lpadata.AttorneysAct `json:"howAttorneysMakeDecisions,omitempty"` HowAttorneysMakeDecisionsDetails string `json:"howAttorneysMakeDecisionsDetails,omitempty"` @@ -383,146 +302,10 @@ type lpaResponse struct { UpdatedAt time.Time `json:"updatedAt"` } -type Attorneys struct { - Attorneys []Attorney - TrustCorporation TrustCorporation -} - -func (a Attorneys) Len() int { - if a.TrustCorporation.Name != "" { - return 1 + len(a.Attorneys) - } - - return len(a.Attorneys) -} - -func (a Attorneys) Index(uid actoruid.UID) int { - return slices.IndexFunc(a.Attorneys, func(a Attorney) bool { return a.UID == uid }) -} - -func (a Attorneys) Get(uid actoruid.UID) (Attorney, bool) { - idx := a.Index(uid) - if idx == -1 { - return Attorney{}, false - } - - return a.Attorneys[idx], true -} - -func (a Attorneys) FullNames() []string { - var names []string - - if a.TrustCorporation.Name != "" { - names = append(names, a.TrustCorporation.Name) - } - - for _, a := range a.Attorneys { - names = append(names, fmt.Sprintf("%s %s", a.FirstNames, a.LastName)) - } - - return names -} - -type AttorneyDecisions struct { - How lpadata.AttorneysAct - Details string -} - -type PersonToNotify struct { - UID actoruid.UID - FirstNames string - LastName string - Address place.Address -} - -func (p PersonToNotify) FullName() string { - return p.FirstNames + " " + p.LastName -} - -type Correspondent struct { - FirstNames string - LastName string - Email string -} - -func (c Correspondent) FullName() string { - return c.FirstNames + " " + c.LastName -} - -type Lpa struct { - LpaKey dynamo.LpaKeyType - LpaOwnerKey dynamo.LpaOwnerKeyType - LpaID string - LpaUID string - RegisteredAt time.Time - WithdrawnAt time.Time - PerfectAt time.Time - UpdatedAt time.Time - Type lpadata.LpaType - Donor Donor - Attorneys Attorneys - ReplacementAttorneys Attorneys - CertificateProvider CertificateProvider - PeopleToNotify []PersonToNotify - AttorneyDecisions AttorneyDecisions - ReplacementAttorneyDecisions AttorneyDecisions - HowShouldReplacementAttorneysStepIn lpadata.ReplacementAttorneysStepIn - HowShouldReplacementAttorneysStepInDetails string - Restrictions string - WhenCanTheLpaBeUsed lpadata.CanBeUsedWhen - LifeSustainingTreatmentOption lpadata.LifeSustainingTreatment - // SignedAt is the date the Donor signed their LPA (and signifies it has been - // witnessed by their CertificateProvider) - SignedAt time.Time - CertificateProviderNotRelatedConfirmedAt time.Time - Submitted bool - Paid bool - IsOrganisationDonor bool - Drafted bool - CannotRegister bool - Correspondent Correspondent -} - -func (l *Lpa) CorrespondentEmail() string { - if l.Correspondent.Email == "" { - return l.Donor.Email - } - - return l.Correspondent.Email -} - -func (l Lpa) AllAttorneysSigned() bool { - if l.Attorneys.Len() == 0 { - return false - } - - for _, attorneys := range []Attorneys{l.Attorneys, l.ReplacementAttorneys} { - for _, a := range attorneys.Attorneys { - if a.SignedAt.IsZero() { - return false - } - } - - if t := attorneys.TrustCorporation; t.Name != "" { - if len(t.Signatories) == 0 { - return false - } - - for _, s := range t.Signatories { - if s.SignedAt.IsZero() { - return false - } - } - } - } - - return true -} - -func lpaResponseToLpa(l lpaResponse) *Lpa { - var attorneys, replacementAttorneys []Attorney +func lpaResponseToLpa(l lpaResponse) *lpadata.Lpa { + var attorneys, replacementAttorneys []lpadata.Attorney for _, a := range l.Attorneys { - at := Attorney{ + at := lpadata.Attorney{ UID: a.UID, FirstNames: a.FirstNames, LastName: a.LastName, @@ -542,9 +325,9 @@ func lpaResponseToLpa(l lpaResponse) *Lpa { } } - var trustCorporation, replacementTrustCorporation TrustCorporation + var trustCorporation, replacementTrustCorporation lpadata.TrustCorporation for _, t := range l.TrustCorporations { - tc := TrustCorporation{ + tc := lpadata.TrustCorporation{ UID: t.UID, Name: t.Name, CompanyNumber: t.CompanyNumber, @@ -563,9 +346,9 @@ func lpaResponseToLpa(l lpaResponse) *Lpa { } } - var peopleToNotify []PersonToNotify + var peopleToNotify []lpadata.PersonToNotify for _, p := range l.PeopleToNotify { - peopleToNotify = append(peopleToNotify, PersonToNotify{ + peopleToNotify = append(peopleToNotify, lpadata.PersonToNotify{ UID: p.UID, FirstNames: p.FirstNames, LastName: p.LastName, @@ -578,18 +361,18 @@ func lpaResponseToLpa(l lpaResponse) *Lpa { confirmedAt = *v } - var identityCheck IdentityCheck + var identityCheck lpadata.IdentityCheck if l.Donor.IdentityCheck != nil { identityCheck.CheckedAt = l.Donor.IdentityCheck.CheckedAt identityCheck.Type = l.Donor.IdentityCheck.Type } - return &Lpa{ + return &lpadata.Lpa{ LpaUID: l.UID, RegisteredAt: l.RegistrationDate, UpdatedAt: l.UpdatedAt, Type: l.LpaType, - Donor: Donor{ + Donor: lpadata.Donor{ UID: l.Donor.UID, FirstNames: l.Donor.FirstNames, LastName: l.Donor.LastName, @@ -601,21 +384,21 @@ func lpaResponseToLpa(l lpaResponse) *Lpa { ContactLanguagePreference: l.Donor.ContactLanguagePreference, IdentityCheck: identityCheck, }, - Attorneys: Attorneys{ + Attorneys: lpadata.Attorneys{ Attorneys: attorneys, TrustCorporation: trustCorporation, }, - ReplacementAttorneys: Attorneys{ + ReplacementAttorneys: lpadata.Attorneys{ Attorneys: replacementAttorneys, TrustCorporation: replacementTrustCorporation, }, CertificateProvider: l.CertificateProvider, PeopleToNotify: peopleToNotify, - AttorneyDecisions: AttorneyDecisions{ + AttorneyDecisions: lpadata.AttorneyDecisions{ How: l.HowAttorneysMakeDecisions, Details: l.HowAttorneysMakeDecisionsDetails, }, - ReplacementAttorneyDecisions: AttorneyDecisions{ + ReplacementAttorneyDecisions: lpadata.AttorneyDecisions{ How: l.HowReplacementAttorneysMakeDecisions, Details: l.HowReplacementAttorneysMakeDecisionsDetails, }, @@ -630,10 +413,10 @@ func lpaResponseToLpa(l lpaResponse) *Lpa { } } -func FromDonorProvidedDetails(l *donordata.Provided) *Lpa { - attorneys := Attorneys{} +func FromDonorProvidedDetails(l *donordata.Provided) *lpadata.Lpa { + attorneys := lpadata.Attorneys{} for _, a := range l.Attorneys.Attorneys { - attorneys.Attorneys = append(attorneys.Attorneys, Attorney{ + attorneys.Attorneys = append(attorneys.Attorneys, lpadata.Attorney{ UID: a.UID, FirstNames: a.FirstNames, LastName: a.LastName, @@ -644,7 +427,7 @@ func FromDonorProvidedDetails(l *donordata.Provided) *Lpa { } if c := l.Attorneys.TrustCorporation; c.Name != "" { - attorneys.TrustCorporation = TrustCorporation{ + attorneys.TrustCorporation = lpadata.TrustCorporation{ UID: c.UID, Name: c.Name, CompanyNumber: c.CompanyNumber, @@ -653,9 +436,9 @@ func FromDonorProvidedDetails(l *donordata.Provided) *Lpa { } } - var replacementAttorneys Attorneys + var replacementAttorneys lpadata.Attorneys for _, a := range l.ReplacementAttorneys.Attorneys { - replacementAttorneys.Attorneys = append(replacementAttorneys.Attorneys, Attorney{ + replacementAttorneys.Attorneys = append(replacementAttorneys.Attorneys, lpadata.Attorney{ UID: a.UID, FirstNames: a.FirstNames, LastName: a.LastName, @@ -666,7 +449,7 @@ func FromDonorProvidedDetails(l *donordata.Provided) *Lpa { } if c := l.ReplacementAttorneys.TrustCorporation; c.Name != "" { - replacementAttorneys.TrustCorporation = TrustCorporation{ + replacementAttorneys.TrustCorporation = lpadata.TrustCorporation{ UID: c.UID, Name: c.Name, CompanyNumber: c.CompanyNumber, @@ -675,15 +458,15 @@ func FromDonorProvidedDetails(l *donordata.Provided) *Lpa { } } - var identityCheck IdentityCheck + var identityCheck lpadata.IdentityCheck if l.DonorIdentityConfirmed() { identityCheck.CheckedAt = l.DonorIdentityUserData.RetrievedAt identityCheck.Type = "one-login" } - var peopleToNotify []PersonToNotify + var peopleToNotify []lpadata.PersonToNotify for _, p := range l.PeopleToNotify { - peopleToNotify = append(peopleToNotify, PersonToNotify{ + peopleToNotify = append(peopleToNotify, lpadata.PersonToNotify{ UID: p.UID, FirstNames: p.FirstNames, LastName: p.LastName, @@ -691,12 +474,12 @@ func FromDonorProvidedDetails(l *donordata.Provided) *Lpa { }) } - return &Lpa{ + return &lpadata.Lpa{ LpaID: l.LpaID, LpaUID: l.LpaUID, UpdatedAt: l.UpdatedAt, Type: l.Type, - Donor: Donor{ + Donor: lpadata.Donor{ UID: l.Donor.UID, FirstNames: l.Donor.FirstNames, LastName: l.Donor.LastName, @@ -710,7 +493,7 @@ func FromDonorProvidedDetails(l *donordata.Provided) *Lpa { }, Attorneys: attorneys, ReplacementAttorneys: replacementAttorneys, - CertificateProvider: CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ UID: l.CertificateProvider.UID, FirstNames: l.CertificateProvider.FirstNames, LastName: l.CertificateProvider.LastName, @@ -720,11 +503,11 @@ func FromDonorProvidedDetails(l *donordata.Provided) *Lpa { Channel: l.CertificateProvider.CarryOutBy, }, PeopleToNotify: peopleToNotify, - AttorneyDecisions: AttorneyDecisions{ + AttorneyDecisions: lpadata.AttorneyDecisions{ How: l.AttorneyDecisions.How, Details: l.AttorneyDecisions.Details, }, - ReplacementAttorneyDecisions: AttorneyDecisions{ + ReplacementAttorneyDecisions: lpadata.AttorneyDecisions{ How: l.ReplacementAttorneyDecisions.How, Details: l.ReplacementAttorneyDecisions.Details, }, @@ -735,7 +518,7 @@ func FromDonorProvidedDetails(l *donordata.Provided) *Lpa { LifeSustainingTreatmentOption: l.LifeSustainingTreatmentOption, SignedAt: l.SignedAt, CertificateProviderNotRelatedConfirmedAt: l.CertificateProviderNotRelatedConfirmedAt, - Correspondent: Correspondent{ + Correspondent: lpadata.Correspondent{ FirstNames: l.Correspondent.FirstNames, LastName: l.Correspondent.LastName, Email: l.Correspondent.Email, @@ -743,7 +526,7 @@ func FromDonorProvidedDetails(l *donordata.Provided) *Lpa { } } -func (c *Client) Lpa(ctx context.Context, lpaUID string) (*Lpa, error) { +func (c *Client) Lpa(ctx context.Context, lpaUID string) (*lpadata.Lpa, error) { req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.baseURL+"/lpas/"+lpaUID, nil) if err != nil { return nil, err @@ -784,7 +567,7 @@ type lpasResponse struct { Lpas []lpaResponse `json:"lpas"` } -func (c *Client) Lpas(ctx context.Context, lpaUIDs []string) ([]*Lpa, error) { +func (c *Client) Lpas(ctx context.Context, lpaUIDs []string) ([]*lpadata.Lpa, error) { var buf bytes.Buffer if err := json.NewEncoder(&buf).Encode(lpasRequest{UIDs: lpaUIDs}); err != nil { return nil, err @@ -815,7 +598,7 @@ func (c *Client) Lpas(ctx context.Context, lpaUIDs []string) ([]*Lpa, error) { return nil, err } - var lpas []*Lpa + var lpas []*lpadata.Lpa for _, l := range v.Lpas { lpas = append(lpas, lpaResponseToLpa(l)) } diff --git a/internal/lpastore/lpa_test.go b/internal/lpastore/lpa_test.go index 74fa54d49d..4d4675e39a 100644 --- a/internal/lpastore/lpa_test.go +++ b/internal/lpastore/lpa_test.go @@ -11,14 +11,14 @@ import ( "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/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/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" "github.com/ministryofjustice/opg-modernising-lpa/internal/secrets" "github.com/stretchr/testify/assert" - mock "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/mock" ) func TestClientSendLpa(t *testing.T) { @@ -396,14 +396,14 @@ func TestClientLpa(t *testing.T) { personToNotifyUID := actoruid.New() testcases := map[string]struct { - donor *Lpa + donor *lpadata.Lpa json string }{ "minimal": { - donor: &Lpa{ + donor: &lpadata.Lpa{ LpaUID: "M-0000-1111-2222", Type: lpadata.LpaTypePropertyAndAffairs, - Donor: Donor{ + Donor: lpadata.Donor{ UID: donorUID, FirstNames: "John Johnson", LastName: "Smith", @@ -417,8 +417,8 @@ func TestClientLpa(t *testing.T) { OtherNames: "JJ", Channel: lpadata.ChannelOnline, }, - Attorneys: Attorneys{ - Attorneys: []Attorney{{ + Attorneys: lpadata.Attorneys{ + Attorneys: []lpadata.Attorney{{ UID: attorneyUID, FirstNames: "Adam", LastName: "Attorney", @@ -431,9 +431,9 @@ func TestClientLpa(t *testing.T) { }, }}, }, - ReplacementAttorneys: Attorneys{}, + ReplacementAttorneys: lpadata.Attorneys{}, WhenCanTheLpaBeUsed: lpadata.CanBeUsedWhenCapacityLost, - CertificateProvider: CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ UID: certificateProviderUID, FirstNames: "Carol", LastName: "Cert", @@ -459,10 +459,10 @@ func TestClientLpa(t *testing.T) { }`, }, "everything": { - donor: &Lpa{ + donor: &lpadata.Lpa{ LpaUID: "M-0000-1111-2222", Type: lpadata.LpaTypePersonalWelfare, - Donor: Donor{ + Donor: lpadata.Donor{ UID: donorUID, FirstNames: "John Johnson", LastName: "Smith", @@ -478,13 +478,13 @@ func TestClientLpa(t *testing.T) { }, OtherNames: "JJ", Channel: lpadata.ChannelOnline, - IdentityCheck: IdentityCheck{ + IdentityCheck: lpadata.IdentityCheck{ CheckedAt: time.Date(2002, time.January, 2, 12, 13, 14, 1, time.UTC), Type: "one-login", }, }, - Attorneys: Attorneys{ - TrustCorporation: TrustCorporation{ + Attorneys: lpadata.Attorneys{ + TrustCorporation: lpadata.TrustCorporation{ UID: trustCorporationUID, Name: "Trusty", CompanyNumber: "55555", @@ -499,7 +499,7 @@ func TestClientLpa(t *testing.T) { }, Channel: lpadata.ChannelOnline, }, - Attorneys: []Attorney{{ + Attorneys: []lpadata.Attorney{{ UID: attorneyUID, FirstNames: "Adam", LastName: "Attorney", @@ -529,11 +529,11 @@ func TestClientLpa(t *testing.T) { }, }}, }, - AttorneyDecisions: AttorneyDecisions{ + AttorneyDecisions: lpadata.AttorneyDecisions{ How: lpadata.Jointly, }, - ReplacementAttorneys: Attorneys{ - TrustCorporation: TrustCorporation{ + ReplacementAttorneys: lpadata.Attorneys{ + TrustCorporation: lpadata.TrustCorporation{ UID: replacementTrustCorporationUID, Name: "UnTrusty", CompanyNumber: "65555", @@ -547,7 +547,7 @@ func TestClientLpa(t *testing.T) { }, Channel: lpadata.ChannelPaper, }, - Attorneys: []Attorney{{ + Attorneys: []lpadata.Attorney{{ UID: replacementAttorneyUID, FirstNames: "Richard", LastName: "Attorney", @@ -577,14 +577,14 @@ func TestClientLpa(t *testing.T) { }, }}, }, - ReplacementAttorneyDecisions: AttorneyDecisions{ + ReplacementAttorneyDecisions: lpadata.AttorneyDecisions{ How: lpadata.JointlyForSomeSeverallyForOthers, Details: "umm", }, HowShouldReplacementAttorneysStepIn: lpadata.ReplacementAttorneysStepInWhenAllCanNoLongerAct, LifeSustainingTreatmentOption: lpadata.LifeSustainingTreatmentOptionA, Restrictions: "do not do this", - CertificateProvider: CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ UID: certificateProviderUID, FirstNames: "Carol", LastName: "Cert", @@ -599,12 +599,12 @@ func TestClientLpa(t *testing.T) { Country: "GB", }, Channel: lpadata.ChannelOnline, - IdentityCheck: IdentityCheck{ + IdentityCheck: lpadata.IdentityCheck{ CheckedAt: time.Date(2002, time.January, 1, 13, 14, 15, 16, time.UTC), Type: "one-login", }, }, - PeopleToNotify: []PersonToNotify{{ + PeopleToNotify: []lpadata.PersonToNotify{{ UID: personToNotifyUID, FirstNames: "Peter", LastName: "Notify", @@ -769,15 +769,15 @@ func TestClientLpas(t *testing.T) { personToNotifyUID := actoruid.New() testcases := map[string]struct { - lpas []*Lpa + lpas []*lpadata.Lpa json string }{ "minimal": { - lpas: []*Lpa{ + lpas: []*lpadata.Lpa{ { LpaUID: "M-0000-1111-2222", Type: lpadata.LpaTypePropertyAndAffairs, - Donor: Donor{ + Donor: lpadata.Donor{ UID: donorUID, FirstNames: "John Johnson", LastName: "Smith", @@ -791,8 +791,8 @@ func TestClientLpas(t *testing.T) { OtherNames: "JJ", Channel: lpadata.ChannelOnline, }, - Attorneys: Attorneys{ - Attorneys: []Attorney{{ + Attorneys: lpadata.Attorneys{ + Attorneys: []lpadata.Attorney{{ UID: attorneyUID, FirstNames: "Adam", LastName: "Attorney", @@ -805,9 +805,9 @@ func TestClientLpas(t *testing.T) { }, }}, }, - ReplacementAttorneys: Attorneys{}, + ReplacementAttorneys: lpadata.Attorneys{}, WhenCanTheLpaBeUsed: lpadata.CanBeUsedWhenCapacityLost, - CertificateProvider: CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ UID: certificateProviderUID, FirstNames: "Carol", LastName: "Cert", @@ -834,11 +834,11 @@ func TestClientLpas(t *testing.T) { }]}`, }, "everything": { - lpas: []*Lpa{ + lpas: []*lpadata.Lpa{ { LpaUID: "M-0000-1111-2222", Type: lpadata.LpaTypePersonalWelfare, - Donor: Donor{ + Donor: lpadata.Donor{ UID: donorUID, FirstNames: "John Johnson", LastName: "Smith", @@ -855,8 +855,8 @@ func TestClientLpas(t *testing.T) { OtherNames: "JJ", Channel: lpadata.ChannelOnline, }, - Attorneys: Attorneys{ - TrustCorporation: TrustCorporation{ + Attorneys: lpadata.Attorneys{ + TrustCorporation: lpadata.TrustCorporation{ UID: trustCorporationUID, Name: "Trusty", CompanyNumber: "55555", @@ -870,7 +870,7 @@ func TestClientLpas(t *testing.T) { Country: "GB", }, }, - Attorneys: []Attorney{{ + Attorneys: []lpadata.Attorney{{ UID: attorneyUID, FirstNames: "Adam", LastName: "Attorney", @@ -900,11 +900,11 @@ func TestClientLpas(t *testing.T) { }, }}, }, - AttorneyDecisions: AttorneyDecisions{ + AttorneyDecisions: lpadata.AttorneyDecisions{ How: lpadata.Jointly, }, - ReplacementAttorneys: Attorneys{ - TrustCorporation: TrustCorporation{ + ReplacementAttorneys: lpadata.Attorneys{ + TrustCorporation: lpadata.TrustCorporation{ UID: replacementTrustCorporationUID, Name: "UnTrusty", CompanyNumber: "65555", @@ -918,7 +918,7 @@ func TestClientLpas(t *testing.T) { Country: "GB", }, }, - Attorneys: []Attorney{{ + Attorneys: []lpadata.Attorney{{ UID: replacementAttorneyUID, FirstNames: "Richard", LastName: "Attorney", @@ -948,14 +948,14 @@ func TestClientLpas(t *testing.T) { }, }}, }, - ReplacementAttorneyDecisions: AttorneyDecisions{ + ReplacementAttorneyDecisions: lpadata.AttorneyDecisions{ How: lpadata.JointlyForSomeSeverallyForOthers, Details: "umm", }, HowShouldReplacementAttorneysStepIn: lpadata.ReplacementAttorneysStepInWhenAllCanNoLongerAct, LifeSustainingTreatmentOption: lpadata.LifeSustainingTreatmentOptionA, Restrictions: "do not do this", - CertificateProvider: CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ UID: certificateProviderUID, FirstNames: "Carol", LastName: "Cert", @@ -971,7 +971,7 @@ func TestClientLpas(t *testing.T) { }, Channel: lpadata.ChannelOnline, }, - PeopleToNotify: []PersonToNotify{{ + PeopleToNotify: []lpadata.PersonToNotify{{ UID: personToNotifyUID, FirstNames: "Peter", LastName: "Notify", @@ -1105,208 +1105,3 @@ func TestClientLpasWhenStatusCodeIsNotOK(t *testing.T) { assert.Equal(t, responseError{name: "expected 200 response but got 400", body: "hey"}, err) } - -func TestAllAttorneysSigned(t *testing.T) { - attorneySigned := time.Now() - - testcases := map[string]struct { - lpa Lpa - expected bool - }{ - "no attorneys": { - expected: false, - }, - "need attorney to sign": { - lpa: Lpa{ - Attorneys: Attorneys{Attorneys: []Attorney{{SignedAt: attorneySigned}, {}}}, - ReplacementAttorneys: Attorneys{Attorneys: []Attorney{{SignedAt: attorneySigned}}}, - }, - expected: false, - }, - "need replacement attorney to sign": { - lpa: Lpa{ - Attorneys: Attorneys{Attorneys: []Attorney{{SignedAt: attorneySigned}}}, - ReplacementAttorneys: Attorneys{Attorneys: []Attorney{{}, {SignedAt: attorneySigned}}}, - }, - expected: false, - }, - "all attorneys signed": { - lpa: Lpa{ - Attorneys: Attorneys{Attorneys: []Attorney{{SignedAt: attorneySigned}, {SignedAt: attorneySigned}}}, - ReplacementAttorneys: Attorneys{Attorneys: []Attorney{{SignedAt: attorneySigned}}}, - }, - expected: true, - }, - "trust corporations not signed": { - lpa: Lpa{ - Attorneys: Attorneys{TrustCorporation: TrustCorporation{Name: "a"}}, - }, - expected: false, - }, - "trust corporations signatory not signed": { - lpa: Lpa{ - Attorneys: Attorneys{TrustCorporation: TrustCorporation{Name: "a", Signatories: []TrustCorporationSignatory{{}}}}, - }, - expected: false, - }, - "replacement trust corporations not signed": { - lpa: Lpa{ - Attorneys: Attorneys{TrustCorporation: TrustCorporation{Name: "a", Signatories: []TrustCorporationSignatory{{SignedAt: attorneySigned}}}}, - ReplacementAttorneys: Attorneys{TrustCorporation: TrustCorporation{Name: "r"}}, - }, - expected: false, - }, - "trust corporations signed": { - lpa: Lpa{ - Attorneys: Attorneys{TrustCorporation: TrustCorporation{Name: "a", Signatories: []TrustCorporationSignatory{{SignedAt: attorneySigned}, {SignedAt: attorneySigned}}}}, - ReplacementAttorneys: Attorneys{TrustCorporation: TrustCorporation{Name: "r", Signatories: []TrustCorporationSignatory{{SignedAt: attorneySigned}}}}, - }, - expected: true, - }, - } - - for name, tc := range testcases { - t.Run(name, func(t *testing.T) { - assert.Equal(t, tc.expected, tc.lpa.AllAttorneysSigned()) - }) - } -} - -func TestDonorFullName(t *testing.T) { - assert.Equal(t, "John Smith", Donor{FirstNames: "John", LastName: "Smith"}.FullName()) -} - -func TestAttorneyFullName(t *testing.T) { - assert.Equal(t, "John Smith", Attorney{FirstNames: "John", LastName: "Smith"}.FullName()) -} - -func TestCertificateProviderFullName(t *testing.T) { - assert.Equal(t, "John Smith", CertificateProvider{FirstNames: "John", LastName: "Smith"}.FullName()) -} - -func TestPersonToNotifyFullName(t *testing.T) { - assert.Equal(t, "John Smith", PersonToNotify{FirstNames: "John", LastName: "Smith"}.FullName()) -} - -func TestCorrespondentFullName(t *testing.T) { - assert.Equal(t, "John Smith", Correspondent{FirstNames: "John", LastName: "Smith"}.FullName()) -} - -func TestAttorneysLen(t *testing.T) { - testcases := map[string]struct { - attorneys Attorneys - len int - }{ - "trust corporation": { - attorneys: Attorneys{TrustCorporation: TrustCorporation{Name: "a"}}, - len: 1, - }, - "attorneys": { - attorneys: Attorneys{Attorneys: []Attorney{{}, {}}}, - len: 2, - }, - "both": { - attorneys: Attorneys{TrustCorporation: TrustCorporation{Name: "a"}, Attorneys: []Attorney{{}, {}}}, - len: 3, - }, - } - - for name, tc := range testcases { - t.Run(name, func(t *testing.T) { - assert.Equal(t, tc.len, tc.attorneys.Len()) - }) - } -} - -func TestAttorneysGet(t *testing.T) { - uid1 := actoruid.New() - uid2 := actoruid.New() - - testCases := map[string]struct { - attorneys Attorneys - expectedAttorney Attorney - uid actoruid.UID - expectedFound bool - }{ - "attorney exists": { - attorneys: Attorneys{Attorneys: []Attorney{{UID: uid1, FirstNames: "Bob"}, {UID: uid2}}}, - expectedAttorney: Attorney{UID: uid1, FirstNames: "Bob"}, - uid: uid1, - expectedFound: true, - }, - "attorney does not exist": { - attorneys: Attorneys{Attorneys: []Attorney{{UID: uid1, FirstNames: "Bob"}, {UID: uid2}}}, - expectedAttorney: Attorney{}, - uid: actoruid.New(), - expectedFound: false, - }, - } - - for name, tc := range testCases { - t.Run(name, func(t *testing.T) { - a, found := tc.attorneys.Get(tc.uid) - - assert.Equal(t, tc.expectedFound, found) - assert.Equal(t, tc.expectedAttorney, a) - }) - } -} - -func TestAttorneysFullNames(t *testing.T) { - testcases := map[string]struct { - attorneys Attorneys - fullNames []string - firstNames []string - }{ - "empty": {}, - "attorneys": { - attorneys: Attorneys{ - Attorneys: []Attorney{ - {FirstNames: "Bob Alan George", LastName: "Jones"}, - {FirstNames: "Samantha", LastName: "Smith"}, - {FirstNames: "Abby Helen", LastName: "Burns-Simpson"}, - }, - }, - fullNames: []string{"Bob Alan George Jones", "Samantha Smith", "Abby Helen Burns-Simpson"}, - firstNames: []string{"Bob Alan George", "Samantha", "Abby Helen"}, - }, - "trust corporation": { - attorneys: Attorneys{ - TrustCorporation: TrustCorporation{Name: "Corp corp"}, - }, - fullNames: []string{"Corp corp"}, - firstNames: []string{"Corp corp"}, - }, - "both": { - attorneys: Attorneys{ - TrustCorporation: TrustCorporation{Name: "Corp corp"}, - Attorneys: []Attorney{ - {FirstNames: "Bob", LastName: "Jones"}, - }, - }, - fullNames: []string{"Corp corp", "Bob Jones"}, - firstNames: []string{"Corp corp", "Bob"}, - }, - } - - for name, tc := range testcases { - t.Run(name, func(t *testing.T) { - assert.Equal(t, tc.fullNames, tc.attorneys.FullNames()) - }) - } -} - -func TestLpaCorrespondentEmail(t *testing.T) { - lpa := &Lpa{ - Donor: Donor{Email: "donor"}, - } - assert.Equal(t, "donor", lpa.CorrespondentEmail()) -} - -func TestLpaCorrespondentEmailWhenCorrespondentProvided(t *testing.T) { - lpa := &Lpa{ - Donor: Donor{Email: "donor"}, - Correspondent: Correspondent{Email: "correspondent"}, - } - assert.Equal(t, "correspondent", lpa.CorrespondentEmail()) -} diff --git a/internal/lpastore/lpadata/attorney.go b/internal/lpastore/lpadata/attorney.go new file mode 100644 index 0000000000..69459e8638 --- /dev/null +++ b/internal/lpastore/lpadata/attorney.go @@ -0,0 +1,27 @@ +package lpadata + +import ( + "time" + + "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" + "github.com/ministryofjustice/opg-modernising-lpa/internal/date" + "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" + "github.com/ministryofjustice/opg-modernising-lpa/internal/place" +) + +type Attorney struct { + UID actoruid.UID + FirstNames string + LastName string + DateOfBirth date.Date + Email string + Address place.Address + Mobile string + SignedAt time.Time + ContactLanguagePreference localize.Lang + Channel Channel +} + +func (a Attorney) FullName() string { + return a.FirstNames + " " + a.LastName +} diff --git a/internal/lpastore/lpadata/attorney_decisions.go b/internal/lpastore/lpadata/attorney_decisions.go new file mode 100644 index 0000000000..7a38abc502 --- /dev/null +++ b/internal/lpastore/lpadata/attorney_decisions.go @@ -0,0 +1,6 @@ +package lpadata + +type AttorneyDecisions struct { + How AttorneysAct + Details string +} diff --git a/internal/lpastore/lpadata/attorney_test.go b/internal/lpastore/lpadata/attorney_test.go new file mode 100644 index 0000000000..793225965a --- /dev/null +++ b/internal/lpastore/lpadata/attorney_test.go @@ -0,0 +1,11 @@ +package lpadata + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestAttorneyFullName(t *testing.T) { + assert.Equal(t, "John Smith", Attorney{FirstNames: "John", LastName: "Smith"}.FullName()) +} diff --git a/internal/lpastore/lpadata/attorneys.go b/internal/lpastore/lpadata/attorneys.go new file mode 100644 index 0000000000..e0d5d42f4d --- /dev/null +++ b/internal/lpastore/lpadata/attorneys.go @@ -0,0 +1,48 @@ +package lpadata + +import ( + "fmt" + "slices" + + "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" +) + +type Attorneys struct { + Attorneys []Attorney + TrustCorporation TrustCorporation +} + +func (a Attorneys) Len() int { + if a.TrustCorporation.Name != "" { + return 1 + len(a.Attorneys) + } + + return len(a.Attorneys) +} + +func (a Attorneys) Index(uid actoruid.UID) int { + return slices.IndexFunc(a.Attorneys, func(a Attorney) bool { return a.UID == uid }) +} + +func (a Attorneys) Get(uid actoruid.UID) (Attorney, bool) { + idx := a.Index(uid) + if idx == -1 { + return Attorney{}, false + } + + return a.Attorneys[idx], true +} + +func (a Attorneys) FullNames() []string { + var names []string + + if a.TrustCorporation.Name != "" { + names = append(names, a.TrustCorporation.Name) + } + + for _, a := range a.Attorneys { + names = append(names, fmt.Sprintf("%s %s", a.FirstNames, a.LastName)) + } + + return names +} diff --git a/internal/lpastore/lpadata/attorneys_test.go b/internal/lpastore/lpadata/attorneys_test.go new file mode 100644 index 0000000000..00ba15e37e --- /dev/null +++ b/internal/lpastore/lpadata/attorneys_test.go @@ -0,0 +1,112 @@ +package lpadata + +import ( + "testing" + + "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" + "github.com/stretchr/testify/assert" +) + +func TestAttorneysLen(t *testing.T) { + testcases := map[string]struct { + attorneys Attorneys + len int + }{ + "trust corporation": { + attorneys: Attorneys{TrustCorporation: TrustCorporation{Name: "a"}}, + len: 1, + }, + "attorneys": { + attorneys: Attorneys{Attorneys: []Attorney{{}, {}}}, + len: 2, + }, + "both": { + attorneys: Attorneys{TrustCorporation: TrustCorporation{Name: "a"}, Attorneys: []Attorney{{}, {}}}, + len: 3, + }, + } + + for name, tc := range testcases { + t.Run(name, func(t *testing.T) { + assert.Equal(t, tc.len, tc.attorneys.Len()) + }) + } +} + +func TestAttorneysGet(t *testing.T) { + uid1 := actoruid.New() + uid2 := actoruid.New() + + testCases := map[string]struct { + attorneys Attorneys + expectedAttorney Attorney + uid actoruid.UID + expectedFound bool + }{ + "attorney exists": { + attorneys: Attorneys{Attorneys: []Attorney{{UID: uid1, FirstNames: "Bob"}, {UID: uid2}}}, + expectedAttorney: Attorney{UID: uid1, FirstNames: "Bob"}, + uid: uid1, + expectedFound: true, + }, + "attorney does not exist": { + attorneys: Attorneys{Attorneys: []Attorney{{UID: uid1, FirstNames: "Bob"}, {UID: uid2}}}, + expectedAttorney: Attorney{}, + uid: actoruid.New(), + expectedFound: false, + }, + } + + for name, tc := range testCases { + t.Run(name, func(t *testing.T) { + a, found := tc.attorneys.Get(tc.uid) + + assert.Equal(t, tc.expectedFound, found) + assert.Equal(t, tc.expectedAttorney, a) + }) + } +} + +func TestAttorneysFullNames(t *testing.T) { + testcases := map[string]struct { + attorneys Attorneys + fullNames []string + firstNames []string + }{ + "empty": {}, + "attorneys": { + attorneys: Attorneys{ + Attorneys: []Attorney{ + {FirstNames: "Bob Alan George", LastName: "Jones"}, + {FirstNames: "Samantha", LastName: "Smith"}, + {FirstNames: "Abby Helen", LastName: "Burns-Simpson"}, + }, + }, + fullNames: []string{"Bob Alan George Jones", "Samantha Smith", "Abby Helen Burns-Simpson"}, + firstNames: []string{"Bob Alan George", "Samantha", "Abby Helen"}, + }, + "trust corporation": { + attorneys: Attorneys{ + TrustCorporation: TrustCorporation{Name: "Corp corp"}, + }, + fullNames: []string{"Corp corp"}, + firstNames: []string{"Corp corp"}, + }, + "both": { + attorneys: Attorneys{ + TrustCorporation: TrustCorporation{Name: "Corp corp"}, + Attorneys: []Attorney{ + {FirstNames: "Bob", LastName: "Jones"}, + }, + }, + fullNames: []string{"Corp corp", "Bob Jones"}, + firstNames: []string{"Corp corp", "Bob"}, + }, + } + + for name, tc := range testcases { + t.Run(name, func(t *testing.T) { + assert.Equal(t, tc.fullNames, tc.attorneys.FullNames()) + }) + } +} diff --git a/internal/lpastore/lpadata/certificate_provider.go b/internal/lpastore/lpadata/certificate_provider.go new file mode 100644 index 0000000000..3b27835358 --- /dev/null +++ b/internal/lpastore/lpadata/certificate_provider.go @@ -0,0 +1,31 @@ +package lpadata + +import ( + "time" + + "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" + "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" + "github.com/ministryofjustice/opg-modernising-lpa/internal/place" +) + +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 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 CertificateProviderRelationship +} + +func (c CertificateProvider) FullName() string { + return c.FirstNames + " " + c.LastName +} diff --git a/internal/lpastore/lpadata/certificate_provider_test.go b/internal/lpastore/lpadata/certificate_provider_test.go new file mode 100644 index 0000000000..eb9dffb88e --- /dev/null +++ b/internal/lpastore/lpadata/certificate_provider_test.go @@ -0,0 +1,11 @@ +package lpadata + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestCertificateProviderFullName(t *testing.T) { + assert.Equal(t, "John Smith", CertificateProvider{FirstNames: "John", LastName: "Smith"}.FullName()) +} diff --git a/internal/lpastore/lpadata/correspondent.go b/internal/lpastore/lpadata/correspondent.go new file mode 100644 index 0000000000..cb7d034951 --- /dev/null +++ b/internal/lpastore/lpadata/correspondent.go @@ -0,0 +1,11 @@ +package lpadata + +type Correspondent struct { + FirstNames string + LastName string + Email string +} + +func (c Correspondent) FullName() string { + return c.FirstNames + " " + c.LastName +} diff --git a/internal/lpastore/lpadata/correspondent_test.go b/internal/lpastore/lpadata/correspondent_test.go new file mode 100644 index 0000000000..10bdb0b3df --- /dev/null +++ b/internal/lpastore/lpadata/correspondent_test.go @@ -0,0 +1,11 @@ +package lpadata + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestCorrespondentFullName(t *testing.T) { + assert.Equal(t, "John Smith", Correspondent{FirstNames: "John", LastName: "Smith"}.FullName()) +} diff --git a/internal/lpastore/lpadata/donor.go b/internal/lpastore/lpadata/donor.go new file mode 100644 index 0000000000..67eb1c2da7 --- /dev/null +++ b/internal/lpastore/lpadata/donor.go @@ -0,0 +1,25 @@ +package lpadata + +import ( + "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" + "github.com/ministryofjustice/opg-modernising-lpa/internal/date" + "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" + "github.com/ministryofjustice/opg-modernising-lpa/internal/place" +) + +type Donor struct { + UID actoruid.UID + FirstNames string + LastName string + Email string + OtherNames string + DateOfBirth date.Date + Address place.Address + Channel Channel + ContactLanguagePreference localize.Lang + IdentityCheck IdentityCheck +} + +func (d Donor) FullName() string { + return d.FirstNames + " " + d.LastName +} diff --git a/internal/lpastore/lpadata/donor_test.go b/internal/lpastore/lpadata/donor_test.go new file mode 100644 index 0000000000..997653755e --- /dev/null +++ b/internal/lpastore/lpadata/donor_test.go @@ -0,0 +1,11 @@ +package lpadata + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestDonorFullName(t *testing.T) { + assert.Equal(t, "John Smith", Donor{FirstNames: "John", LastName: "Smith"}.FullName()) +} diff --git a/internal/lpastore/lpadata/identity_check.go b/internal/lpastore/lpadata/identity_check.go new file mode 100644 index 0000000000..3027178114 --- /dev/null +++ b/internal/lpastore/lpadata/identity_check.go @@ -0,0 +1,8 @@ +package lpadata + +import "time" + +type IdentityCheck struct { + CheckedAt time.Time `json:"checkedAt"` + Type string `json:"type"` +} diff --git a/internal/lpastore/lpadata/lpa.go b/internal/lpastore/lpadata/lpa.go new file mode 100644 index 0000000000..39be089b48 --- /dev/null +++ b/internal/lpastore/lpadata/lpa.go @@ -0,0 +1,78 @@ +package lpadata + +import ( + "time" + + "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" +) + +type Lpa struct { + LpaKey dynamo.LpaKeyType + LpaOwnerKey dynamo.LpaOwnerKeyType + LpaID string + LpaUID string + RegisteredAt time.Time + WithdrawnAt time.Time + PerfectAt time.Time + UpdatedAt time.Time + Type LpaType + Donor Donor + Attorneys Attorneys + ReplacementAttorneys Attorneys + CertificateProvider CertificateProvider + PeopleToNotify []PersonToNotify + AttorneyDecisions AttorneyDecisions + ReplacementAttorneyDecisions AttorneyDecisions + HowShouldReplacementAttorneysStepIn ReplacementAttorneysStepIn + HowShouldReplacementAttorneysStepInDetails string + Restrictions string + WhenCanTheLpaBeUsed CanBeUsedWhen + LifeSustainingTreatmentOption LifeSustainingTreatment + + // SignedAt is the date the Donor signed their LPA (and signifies it has been + // witnessed by their CertificateProvider) + SignedAt time.Time + CertificateProviderNotRelatedConfirmedAt time.Time + Submitted bool + Paid bool + IsOrganisationDonor bool + Drafted bool + CannotRegister bool + Correspondent Correspondent +} + +func (l *Lpa) CorrespondentEmail() string { + if l.Correspondent.Email == "" { + return l.Donor.Email + } + + return l.Correspondent.Email +} + +func (l Lpa) AllAttorneysSigned() bool { + if l.Attorneys.Len() == 0 { + return false + } + + for _, attorneys := range []Attorneys{l.Attorneys, l.ReplacementAttorneys} { + for _, a := range attorneys.Attorneys { + if a.SignedAt.IsZero() { + return false + } + } + + if t := attorneys.TrustCorporation; t.Name != "" { + if len(t.Signatories) == 0 { + return false + } + + for _, s := range t.Signatories { + if s.SignedAt.IsZero() { + return false + } + } + } + } + + return true +} diff --git a/internal/lpastore/lpadata/lpa_test.go b/internal/lpastore/lpadata/lpa_test.go new file mode 100644 index 0000000000..0c5a9554f3 --- /dev/null +++ b/internal/lpastore/lpadata/lpa_test.go @@ -0,0 +1,89 @@ +package lpadata + +import ( + "testing" + "time" + + "github.com/stretchr/testify/assert" +) + +func TestAllAttorneysSigned(t *testing.T) { + attorneySigned := time.Now() + + testcases := map[string]struct { + lpa Lpa + expected bool + }{ + "no attorneys": { + expected: false, + }, + "need attorney to sign": { + lpa: Lpa{ + Attorneys: Attorneys{Attorneys: []Attorney{{SignedAt: attorneySigned}, {}}}, + ReplacementAttorneys: Attorneys{Attorneys: []Attorney{{SignedAt: attorneySigned}}}, + }, + expected: false, + }, + "need replacement attorney to sign": { + lpa: Lpa{ + Attorneys: Attorneys{Attorneys: []Attorney{{SignedAt: attorneySigned}}}, + ReplacementAttorneys: Attorneys{Attorneys: []Attorney{{}, {SignedAt: attorneySigned}}}, + }, + expected: false, + }, + "all attorneys signed": { + lpa: Lpa{ + Attorneys: Attorneys{Attorneys: []Attorney{{SignedAt: attorneySigned}, {SignedAt: attorneySigned}}}, + ReplacementAttorneys: Attorneys{Attorneys: []Attorney{{SignedAt: attorneySigned}}}, + }, + expected: true, + }, + "trust corporations not signed": { + lpa: Lpa{ + Attorneys: Attorneys{TrustCorporation: TrustCorporation{Name: "a"}}, + }, + expected: false, + }, + "trust corporations signatory not signed": { + lpa: Lpa{ + Attorneys: Attorneys{TrustCorporation: TrustCorporation{Name: "a", Signatories: []TrustCorporationSignatory{{}}}}, + }, + expected: false, + }, + "replacement trust corporations not signed": { + lpa: Lpa{ + Attorneys: Attorneys{TrustCorporation: TrustCorporation{Name: "a", Signatories: []TrustCorporationSignatory{{SignedAt: attorneySigned}}}}, + ReplacementAttorneys: Attorneys{TrustCorporation: TrustCorporation{Name: "r"}}, + }, + expected: false, + }, + "trust corporations signed": { + lpa: Lpa{ + Attorneys: Attorneys{TrustCorporation: TrustCorporation{Name: "a", Signatories: []TrustCorporationSignatory{{SignedAt: attorneySigned}, {SignedAt: attorneySigned}}}}, + ReplacementAttorneys: Attorneys{TrustCorporation: TrustCorporation{Name: "r", Signatories: []TrustCorporationSignatory{{SignedAt: attorneySigned}}}}, + }, + expected: true, + }, + } + + for name, tc := range testcases { + t.Run(name, func(t *testing.T) { + assert.Equal(t, tc.expected, tc.lpa.AllAttorneysSigned()) + }) + } +} + +func TestLpaCorrespondentEmail(t *testing.T) { + lpa := &Lpa{ + Donor: Donor{Email: "donor"}, + } + assert.Equal(t, "donor", lpa.CorrespondentEmail()) +} + +func TestLpaCorrespondentEmailWhenCorrespondentProvided(t *testing.T) { + lpa := &Lpa{ + Donor: Donor{Email: "donor"}, + Correspondent: Correspondent{Email: "correspondent"}, + } + assert.Equal(t, "correspondent", lpa.CorrespondentEmail()) +} diff --git a/internal/lpastore/lpadata/person_to_notify.go b/internal/lpastore/lpadata/person_to_notify.go new file mode 100644 index 0000000000..88f317ac87 --- /dev/null +++ b/internal/lpastore/lpadata/person_to_notify.go @@ -0,0 +1,17 @@ +package lpadata + +import ( + "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" + "github.com/ministryofjustice/opg-modernising-lpa/internal/place" +) + +type PersonToNotify struct { + UID actoruid.UID + FirstNames string + LastName string + Address place.Address +} + +func (p PersonToNotify) FullName() string { + return p.FirstNames + " " + p.LastName +} diff --git a/internal/lpastore/lpadata/person_to_notify_test.go b/internal/lpastore/lpadata/person_to_notify_test.go new file mode 100644 index 0000000000..c5ed93b995 --- /dev/null +++ b/internal/lpastore/lpadata/person_to_notify_test.go @@ -0,0 +1,11 @@ +package lpadata + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestPersonToNotifyFullName(t *testing.T) { + assert.Equal(t, "John Smith", PersonToNotify{FirstNames: "John", LastName: "Smith"}.FullName()) +} diff --git a/internal/lpastore/lpadata/trust_corporation.go b/internal/lpastore/lpadata/trust_corporation.go new file mode 100644 index 0000000000..355ca3aaa9 --- /dev/null +++ b/internal/lpastore/lpadata/trust_corporation.go @@ -0,0 +1,19 @@ +package lpadata + +import ( + "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" + "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" + "github.com/ministryofjustice/opg-modernising-lpa/internal/place" +) + +type TrustCorporation struct { + UID actoruid.UID + Name string + CompanyNumber string + Email string + Address place.Address + Mobile string + Signatories []TrustCorporationSignatory + ContactLanguagePreference localize.Lang + Channel Channel +} diff --git a/internal/lpastore/lpadata/trust_corporation_signatory.go b/internal/lpastore/lpadata/trust_corporation_signatory.go new file mode 100644 index 0000000000..8c4c2a1c4b --- /dev/null +++ b/internal/lpastore/lpadata/trust_corporation_signatory.go @@ -0,0 +1,10 @@ +package lpadata + +import "time" + +type TrustCorporationSignatory struct { + FirstNames string `json:"firstNames"` + LastName string `json:"lastName"` + ProfessionalTitle string `json:"professionalTitle"` + SignedAt time.Time `json:"signedAt"` +} diff --git a/internal/lpastore/mock_LpaClient_test.go b/internal/lpastore/mock_LpaClient_test.go index 54301752c7..8e18f4de4d 100644 --- a/internal/lpastore/mock_LpaClient_test.go +++ b/internal/lpastore/mock_LpaClient_test.go @@ -5,6 +5,7 @@ package lpastore import ( context "context" + lpadata "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" mock "github.com/stretchr/testify/mock" ) @@ -22,23 +23,23 @@ func (_m *mockLpaClient) EXPECT() *mockLpaClient_Expecter { } // Lpa provides a mock function with given fields: ctx, lpaUID -func (_m *mockLpaClient) Lpa(ctx context.Context, lpaUID string) (*Lpa, error) { +func (_m *mockLpaClient) Lpa(ctx context.Context, lpaUID string) (*lpadata.Lpa, error) { ret := _m.Called(ctx, lpaUID) if len(ret) == 0 { panic("no return value specified for Lpa") } - var r0 *Lpa + var r0 *lpadata.Lpa var r1 error - if rf, ok := ret.Get(0).(func(context.Context, string) (*Lpa, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, string) (*lpadata.Lpa, error)); ok { return rf(ctx, lpaUID) } - if rf, ok := ret.Get(0).(func(context.Context, string) *Lpa); ok { + if rf, ok := ret.Get(0).(func(context.Context, string) *lpadata.Lpa); ok { r0 = rf(ctx, lpaUID) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*Lpa) + r0 = ret.Get(0).(*lpadata.Lpa) } } @@ -70,34 +71,34 @@ func (_c *mockLpaClient_Lpa_Call) Run(run func(ctx context.Context, lpaUID strin return _c } -func (_c *mockLpaClient_Lpa_Call) Return(_a0 *Lpa, _a1 error) *mockLpaClient_Lpa_Call { +func (_c *mockLpaClient_Lpa_Call) Return(_a0 *lpadata.Lpa, _a1 error) *mockLpaClient_Lpa_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockLpaClient_Lpa_Call) RunAndReturn(run func(context.Context, string) (*Lpa, error)) *mockLpaClient_Lpa_Call { +func (_c *mockLpaClient_Lpa_Call) RunAndReturn(run func(context.Context, string) (*lpadata.Lpa, error)) *mockLpaClient_Lpa_Call { _c.Call.Return(run) return _c } // Lpas provides a mock function with given fields: ctx, lpaUIDs -func (_m *mockLpaClient) Lpas(ctx context.Context, lpaUIDs []string) ([]*Lpa, error) { +func (_m *mockLpaClient) Lpas(ctx context.Context, lpaUIDs []string) ([]*lpadata.Lpa, error) { ret := _m.Called(ctx, lpaUIDs) if len(ret) == 0 { panic("no return value specified for Lpas") } - var r0 []*Lpa + var r0 []*lpadata.Lpa var r1 error - if rf, ok := ret.Get(0).(func(context.Context, []string) ([]*Lpa, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, []string) ([]*lpadata.Lpa, error)); ok { return rf(ctx, lpaUIDs) } - if rf, ok := ret.Get(0).(func(context.Context, []string) []*Lpa); ok { + if rf, ok := ret.Get(0).(func(context.Context, []string) []*lpadata.Lpa); ok { r0 = rf(ctx, lpaUIDs) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]*Lpa) + r0 = ret.Get(0).([]*lpadata.Lpa) } } @@ -129,12 +130,12 @@ func (_c *mockLpaClient_Lpas_Call) Run(run func(ctx context.Context, lpaUIDs []s return _c } -func (_c *mockLpaClient_Lpas_Call) Return(_a0 []*Lpa, _a1 error) *mockLpaClient_Lpas_Call { +func (_c *mockLpaClient_Lpas_Call) Return(_a0 []*lpadata.Lpa, _a1 error) *mockLpaClient_Lpas_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockLpaClient_Lpas_Call) RunAndReturn(run func(context.Context, []string) ([]*Lpa, error)) *mockLpaClient_Lpas_Call { +func (_c *mockLpaClient_Lpas_Call) RunAndReturn(run func(context.Context, []string) ([]*lpadata.Lpa, error)) *mockLpaClient_Lpas_Call { _c.Call.Return(run) return _c } diff --git a/internal/lpastore/resolving_service.go b/internal/lpastore/resolving_service.go index 91f1947598..b2089c459e 100644 --- a/internal/lpastore/resolving_service.go +++ b/internal/lpastore/resolving_service.go @@ -14,8 +14,8 @@ type DonorStore interface { } type LpaClient interface { - Lpa(ctx context.Context, lpaUID string) (*Lpa, error) - Lpas(ctx context.Context, lpaUIDs []string) ([]*Lpa, error) + Lpa(ctx context.Context, lpaUID string) (*lpadata.Lpa, error) + Lpas(ctx context.Context, lpaUIDs []string) ([]*lpadata.Lpa, error) } // A ResolvingService wraps a Client so that an Lpa can be retrieved without @@ -29,7 +29,7 @@ func NewResolvingService(donorStore DonorStore, client LpaClient) *ResolvingServ return &ResolvingService{donorStore: donorStore, client: client} } -func (s *ResolvingService) Get(ctx context.Context) (*Lpa, error) { +func (s *ResolvingService) Get(ctx context.Context) (*lpadata.Lpa, error) { donor, err := s.donorStore.GetAny(ctx) if err != nil { return nil, err @@ -49,7 +49,7 @@ func (s *ResolvingService) Get(ctx context.Context) (*Lpa, error) { return s.merge(lpa, donor), nil } -func (s *ResolvingService) ResolveList(ctx context.Context, donors []*donordata.Provided) ([]*Lpa, error) { +func (s *ResolvingService) ResolveList(ctx context.Context, donors []*donordata.Provided) ([]*lpadata.Lpa, error) { lpaUIDs := make([]string, len(donors)) for i, donor := range donors { lpaUIDs[i] = donor.LpaUID @@ -60,12 +60,12 @@ func (s *ResolvingService) ResolveList(ctx context.Context, donors []*donordata. return nil, err } - lpaMap := map[string]*Lpa{} + lpaMap := map[string]*lpadata.Lpa{} for _, lpa := range lpas { lpaMap[lpa.LpaUID] = lpa } - result := make([]*Lpa, len(donors)) + result := make([]*lpadata.Lpa, len(donors)) for i, donor := range donors { if lpa, ok := lpaMap[donor.LpaUID]; ok { result[i] = s.merge(lpa, donor) @@ -77,7 +77,7 @@ func (s *ResolvingService) ResolveList(ctx context.Context, donors []*donordata. return result, nil } -func (s *ResolvingService) merge(lpa *Lpa, donor *donordata.Provided) *Lpa { +func (s *ResolvingService) merge(lpa *lpadata.Lpa, donor *donordata.Provided) *lpadata.Lpa { lpa.LpaKey = donor.PK lpa.LpaOwnerKey = donor.SK lpa.LpaID = donor.LpaID diff --git a/internal/lpastore/resolving_service_test.go b/internal/lpastore/resolving_service_test.go index 0c0314765d..e34eca7a03 100644 --- a/internal/lpastore/resolving_service_test.go +++ b/internal/lpastore/resolving_service_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - donordata "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/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/lpastore/lpadata" @@ -17,9 +17,9 @@ import ( func TestResolvingServiceGet(t *testing.T) { testcases := map[string]struct { donor *donordata.Provided - resolved *Lpa + resolved *lpadata.Lpa error error - expected *Lpa + expected *lpadata.Lpa }{ "online with all true": { donor: &donordata.Provided{ @@ -40,13 +40,13 @@ func TestResolvingServiceGet(t *testing.T) { RetrievedAt: time.Now(), }, }, - resolved: &Lpa{ + resolved: &lpadata.Lpa{ LpaID: "1", - CertificateProvider: CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ FirstNames: "Paul", }, }, - expected: &Lpa{ + expected: &lpadata.Lpa{ LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("S")), LpaID: "1", LpaUID: "M-1111", @@ -54,11 +54,11 @@ func TestResolvingServiceGet(t *testing.T) { Submitted: true, Paid: true, IsOrganisationDonor: true, - CertificateProvider: CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ FirstNames: "Paul", Relationship: lpadata.Personally, }, - Donor: Donor{Channel: lpadata.ChannelOnline}, + Donor: lpadata.Donor{Channel: lpadata.ChannelOnline}, }, }, "online with no lpastore record": { @@ -84,27 +84,27 @@ func TestResolvingServiceGet(t *testing.T) { }, }, error: ErrNotFound, - expected: &Lpa{ + expected: &lpadata.Lpa{ LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("S")), LpaUID: "M-1111", - CertificateProvider: CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ FirstNames: "John", Relationship: lpadata.Personally, }, - Donor: Donor{ + Donor: lpadata.Donor{ Channel: lpadata.ChannelOnline, - IdentityCheck: IdentityCheck{ + IdentityCheck: lpadata.IdentityCheck{ CheckedAt: time.Date(2020, time.January, 2, 12, 13, 14, 5, time.UTC), Type: "one-login", }, }, - Attorneys: Attorneys{ - Attorneys: []Attorney{{FirstNames: "a"}}, - TrustCorporation: TrustCorporation{Name: "b"}, + Attorneys: lpadata.Attorneys{ + Attorneys: []lpadata.Attorney{{FirstNames: "a"}}, + TrustCorporation: lpadata.TrustCorporation{Name: "b"}, }, - ReplacementAttorneys: Attorneys{ - Attorneys: []Attorney{{FirstNames: "c"}}, - TrustCorporation: TrustCorporation{Name: "d"}, + ReplacementAttorneys: lpadata.Attorneys{ + Attorneys: []lpadata.Attorney{{FirstNames: "c"}}, + TrustCorporation: lpadata.TrustCorporation{Name: "d"}, }, }, }, @@ -114,12 +114,12 @@ func TestResolvingServiceGet(t *testing.T) { LpaID: "1", LpaUID: "M-1111", }, - resolved: &Lpa{LpaID: "1"}, - expected: &Lpa{ + resolved: &lpadata.Lpa{LpaID: "1"}, + expected: &lpadata.Lpa{ LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("S")), LpaID: "1", LpaUID: "M-1111", - Donor: Donor{Channel: lpadata.ChannelOnline}, + Donor: lpadata.Donor{Channel: lpadata.ChannelOnline}, }, }, "paper": { @@ -128,18 +128,18 @@ func TestResolvingServiceGet(t *testing.T) { LpaID: "1", LpaUID: "M-1111", }, - resolved: &Lpa{LpaID: "1"}, - expected: &Lpa{ + resolved: &lpadata.Lpa{LpaID: "1"}, + expected: &lpadata.Lpa{ LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("PAPER")), LpaID: "1", LpaUID: "M-1111", Submitted: true, Drafted: true, Paid: true, - CertificateProvider: CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ Relationship: lpadata.Professionally, }, - Donor: Donor{Channel: lpadata.ChannelPaper}, + Donor: lpadata.Donor{Channel: lpadata.ChannelPaper}, }, }, } @@ -178,9 +178,9 @@ func TestResolvingServiceGetWhenNoUID(t *testing.T) { service := NewResolvingService(donorStore, nil) lpa, err := service.Get(ctx) - assert.Equal(t, &Lpa{ + assert.Equal(t, &lpadata.Lpa{ LpaID: "1", - Donor: Donor{Channel: lpadata.ChannelOnline}, + Donor: lpadata.Donor{Channel: lpadata.ChannelOnline}, }, lpa) assert.Nil(t, err) } @@ -201,10 +201,10 @@ func TestResolvingServiceGetWhenNotFound(t *testing.T) { service := NewResolvingService(donorStore, lpaClient) lpa, err := service.Get(ctx) - assert.Equal(t, &Lpa{ + assert.Equal(t, &lpadata.Lpa{ LpaID: "1", LpaUID: "M-1111", - Donor: Donor{Channel: lpadata.ChannelOnline}, + Donor: lpadata.Donor{Channel: lpadata.ChannelOnline}, }, lpa) assert.Nil(t, err) } @@ -246,9 +246,9 @@ func TestResolvingServiceResolveList(t *testing.T) { testcases := map[string]struct { donors []*donordata.Provided uids []string - resolved []*Lpa + resolved []*lpadata.Lpa error error - expected []*Lpa + expected []*lpadata.Lpa }{ "online with all true": { donors: []*donordata.Provided{{ @@ -269,14 +269,14 @@ func TestResolvingServiceResolveList(t *testing.T) { }, }}, uids: []string{"M-1111"}, - resolved: []*Lpa{{ + resolved: []*lpadata.Lpa{{ LpaID: "1", LpaUID: "M-1111", - CertificateProvider: CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ FirstNames: "Paul", }, }}, - expected: []*Lpa{{ + expected: []*lpadata.Lpa{{ LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.OrganisationKey("S")), LpaID: "1", LpaUID: "M-1111", @@ -284,11 +284,11 @@ func TestResolvingServiceResolveList(t *testing.T) { Submitted: true, Paid: true, IsOrganisationDonor: true, - CertificateProvider: CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ FirstNames: "Paul", Relationship: lpadata.Personally, }, - Donor: Donor{Channel: lpadata.ChannelOnline}, + Donor: lpadata.Donor{Channel: lpadata.ChannelOnline}, }}, }, "online with no lpastore record": { @@ -310,21 +310,21 @@ func TestResolvingServiceResolveList(t *testing.T) { }, }}, uids: []string{"M-1111"}, - expected: []*Lpa{{ + expected: []*lpadata.Lpa{{ LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("S")), LpaUID: "M-1111", - CertificateProvider: CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ FirstNames: "John", Relationship: lpadata.Personally, }, - Donor: Donor{Channel: lpadata.ChannelOnline}, - Attorneys: Attorneys{ - Attorneys: []Attorney{{FirstNames: "a"}}, - TrustCorporation: TrustCorporation{Name: "b"}, + Donor: lpadata.Donor{Channel: lpadata.ChannelOnline}, + Attorneys: lpadata.Attorneys{ + Attorneys: []lpadata.Attorney{{FirstNames: "a"}}, + TrustCorporation: lpadata.TrustCorporation{Name: "b"}, }, - ReplacementAttorneys: Attorneys{ - Attorneys: []Attorney{{FirstNames: "c"}}, - TrustCorporation: TrustCorporation{Name: "d"}, + ReplacementAttorneys: lpadata.Attorneys{ + Attorneys: []lpadata.Attorney{{FirstNames: "c"}}, + TrustCorporation: lpadata.TrustCorporation{Name: "d"}, }, }}, }, @@ -335,12 +335,12 @@ func TestResolvingServiceResolveList(t *testing.T) { LpaUID: "M-1111", }}, uids: []string{"M-1111"}, - resolved: []*Lpa{{LpaID: "1", LpaUID: "M-1111"}}, - expected: []*Lpa{{ + resolved: []*lpadata.Lpa{{LpaID: "1", LpaUID: "M-1111"}}, + expected: []*lpadata.Lpa{{ LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("S")), LpaID: "1", LpaUID: "M-1111", - Donor: Donor{Channel: lpadata.ChannelOnline}, + Donor: lpadata.Donor{Channel: lpadata.ChannelOnline}, }}, }, "paper": { @@ -350,18 +350,18 @@ func TestResolvingServiceResolveList(t *testing.T) { LpaUID: "M-1111", }}, uids: []string{"M-1111"}, - resolved: []*Lpa{{LpaID: "1", LpaUID: "M-1111"}}, - expected: []*Lpa{{ + resolved: []*lpadata.Lpa{{LpaID: "1", LpaUID: "M-1111"}}, + expected: []*lpadata.Lpa{{ LpaOwnerKey: dynamo.LpaOwnerKey(dynamo.DonorKey("PAPER")), LpaID: "1", LpaUID: "M-1111", Drafted: true, Submitted: true, Paid: true, - CertificateProvider: CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ Relationship: lpadata.Professionally, }, - Donor: Donor{Channel: lpadata.ChannelPaper}, + Donor: lpadata.Donor{Channel: lpadata.ChannelPaper}, }}, }, } diff --git a/internal/lpastore/update.go b/internal/lpastore/update.go index d19abc4714..529631018a 100644 --- a/internal/lpastore/update.go +++ b/internal/lpastore/update.go @@ -79,7 +79,7 @@ func (c *Client) SendDonorWithdrawLPA(ctx context.Context, lpaUID string) error return c.sendUpdate(ctx, lpaUID, actoruid.Service, body) } -func (c *Client) SendCertificateProvider(ctx context.Context, certificateProvider *certificateproviderdata.Provided, lpa *Lpa) error { +func (c *Client) SendCertificateProvider(ctx context.Context, certificateProvider *certificateproviderdata.Provided, lpa *lpadata.Lpa) error { body := updateRequest{ Type: "CERTIFICATE_PROVIDER_SIGN", Changes: []updateRequestChange{ @@ -123,10 +123,10 @@ func (c *Client) SendCertificateProvider(ctx context.Context, certificateProvide return c.sendUpdate(ctx, lpa.LpaUID, certificateProvider.UID, body) } -func (c *Client) SendAttorney(ctx context.Context, lpa *Lpa, attorney *attorneydata.Provided) error { +func (c *Client) SendAttorney(ctx context.Context, lpa *lpadata.Lpa, attorney *attorneydata.Provided) error { var attorneyKey string - var lpaAttorney Attorney - var lpaTrustCorp TrustCorporation + var lpaAttorney lpadata.Attorney + var lpaTrustCorp lpadata.TrustCorporation if attorney.IsTrustCorporation && attorney.IsReplacement && lpa.Attorneys.TrustCorporation.Name != "" { attorneyKey = "/trustCorporations/1" diff --git a/internal/lpastore/update_test.go b/internal/lpastore/update_test.go index fcedf4f98b..5aa8163ac1 100644 --- a/internal/lpastore/update_test.go +++ b/internal/lpastore/update_test.go @@ -141,9 +141,9 @@ func TestClientSendCertificateProvider(t *testing.T) { Email: "b@example.com", } - lpa := &Lpa{ + lpa := &lpadata.Lpa{ LpaUID: "lpa-uid", - CertificateProvider: CertificateProvider{ + CertificateProvider: lpadata.CertificateProvider{ Channel: lpadata.ChannelOnline, Email: "a@example.com", }, @@ -188,7 +188,7 @@ func TestClientSendAttorney(t *testing.T) { testcases := map[string]struct { attorney *attorneydata.Provided - donor *Lpa + donor *lpadata.Lpa json string }{ "attorney": { @@ -199,10 +199,10 @@ func TestClientSendAttorney(t *testing.T) { ContactLanguagePreference: localize.Cy, Email: "b@example.com", }, - donor: &Lpa{ + donor: &lpadata.Lpa{ LpaUID: "lpa-uid", - Attorneys: Attorneys{ - Attorneys: []Attorney{ + Attorneys: lpadata.Attorneys{ + Attorneys: []lpadata.Attorney{ {UID: uid1}, {UID: uid2, Email: "a@example.com", Channel: lpadata.ChannelPaper}, }, }, @@ -218,15 +218,15 @@ func TestClientSendAttorney(t *testing.T) { ContactLanguagePreference: localize.Cy, Email: "b@example.com", }, - donor: &Lpa{ + donor: &lpadata.Lpa{ LpaUID: "lpa-uid", - Attorneys: Attorneys{ - Attorneys: []Attorney{ + Attorneys: lpadata.Attorneys{ + Attorneys: []lpadata.Attorney{ {UID: uid1}, {UID: uid2}, }, }, - ReplacementAttorneys: Attorneys{ - Attorneys: []Attorney{ + ReplacementAttorneys: lpadata.Attorneys{ + Attorneys: []lpadata.Attorney{ {UID: uid1}, {UID: uid2, Email: "a@example.com", Channel: lpadata.ChannelPaper}, }, }, @@ -252,10 +252,10 @@ func TestClientSendAttorney(t *testing.T) { ContactLanguagePreference: localize.En, Email: "a@example.com", }, - donor: &Lpa{ + donor: &lpadata.Lpa{ LpaUID: "lpa-uid", - Attorneys: Attorneys{ - TrustCorporation: TrustCorporation{Channel: lpadata.ChannelPaper}, + Attorneys: lpadata.Attorneys{ + TrustCorporation: lpadata.TrustCorporation{Channel: lpadata.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"}]}`, @@ -274,13 +274,13 @@ func TestClientSendAttorney(t *testing.T) { }}, ContactLanguagePreference: localize.En, }, - donor: &Lpa{ + donor: &lpadata.Lpa{ LpaUID: "lpa-uid", - Attorneys: Attorneys{ - TrustCorporation: TrustCorporation{Name: "a"}, + Attorneys: lpadata.Attorneys{ + TrustCorporation: lpadata.TrustCorporation{Name: "a"}, }, - ReplacementAttorneys: Attorneys{ - TrustCorporation: TrustCorporation{Channel: lpadata.ChannelPaper}, + ReplacementAttorneys: lpadata.Attorneys{ + TrustCorporation: lpadata.TrustCorporation{Channel: lpadata.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"}]}`, @@ -299,9 +299,9 @@ func TestClientSendAttorney(t *testing.T) { }}, ContactLanguagePreference: localize.En, }, - donor: &Lpa{ + donor: &lpadata.Lpa{ LpaUID: "lpa-uid", - Attorneys: Attorneys{TrustCorporation: TrustCorporation{Name: "a"}}, + Attorneys: lpadata.Attorneys{TrustCorporation: lpadata.TrustCorporation{Name: "a"}}, }, 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/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"}]}`, }, diff --git a/internal/notify/client.go b/internal/notify/client.go index eb304b171e..b69f0af536 100644 --- a/internal/notify/client.go +++ b/internal/notify/client.go @@ -17,7 +17,7 @@ import ( "github.com/golang-jwt/jwt/v5" "github.com/ministryofjustice/opg-modernising-lpa/internal/event" "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" ) var ( @@ -77,7 +77,7 @@ func New(logger Logger, isProduction bool, baseURL, apiKey string, httpClient Do }, nil } -func (c *Client) EmailGreeting(lpa *lpastore.Lpa) string { +func (c *Client) EmailGreeting(lpa *lpadata.Lpa) string { localizer := c.bundle.For(lpa.Donor.ContactLanguagePreference) if lpa.Correspondent.FirstNames == "" { diff --git a/internal/notify/client_test.go b/internal/notify/client_test.go index cbbc68d9e4..d96fac50eb 100644 --- a/internal/notify/client_test.go +++ b/internal/notify/client_test.go @@ -14,7 +14,6 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/event" "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -46,12 +45,12 @@ func TestEmailGreeting(t *testing.T) { client := &Client{bundle: bundle} testcases := map[string]struct { - lpa *lpastore.Lpa + lpa *lpadata.Lpa expected string }{ "english donor": { - lpa: &lpastore.Lpa{ - Donor: lpastore.Donor{ + lpa: &lpadata.Lpa{ + Donor: lpadata.Donor{ ContactLanguagePreference: localize.En, FirstNames: "John", LastName: "Smith", @@ -60,8 +59,8 @@ func TestEmailGreeting(t *testing.T) { expected: "Hi John Smith", }, "welsh donor": { - lpa: &lpastore.Lpa{ - Donor: lpastore.Donor{ + lpa: &lpadata.Lpa{ + Donor: lpadata.Donor{ ContactLanguagePreference: localize.Cy, FirstNames: "John", LastName: "Smith", @@ -70,15 +69,15 @@ func TestEmailGreeting(t *testing.T) { expected: "Hy John Smith", }, "english donor with correspondent": { - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ LpaUID: "M-FAKE-1111", Type: lpadata.LpaTypePersonalWelfare, - Donor: lpastore.Donor{ + Donor: lpadata.Donor{ ContactLanguagePreference: localize.En, FirstNames: "John", LastName: "Smith", }, - Correspondent: lpastore.Correspondent{ + Correspondent: lpadata.Correspondent{ FirstNames: "Dave", LastName: "David", }, @@ -86,15 +85,15 @@ func TestEmailGreeting(t *testing.T) { expected: "Hello Dave David for John Smith’s Personal welfare LPA (M-FAKE-1111)", }, "welsh donor with correspondent": { - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ LpaUID: "M-FAKE-1111", Type: lpadata.LpaTypePropertyAndAffairs, - Donor: lpastore.Donor{ + Donor: lpadata.Donor{ ContactLanguagePreference: localize.Cy, FirstNames: "John", LastName: "Smith", }, - Correspondent: lpastore.Correspondent{ + Correspondent: lpadata.Correspondent{ FirstNames: "Dave", LastName: "David", }, diff --git a/internal/onelogin/exchange.go b/internal/onelogin/exchange.go index b0e53ebe0e..ac668713c2 100644 --- a/internal/onelogin/exchange.go +++ b/internal/onelogin/exchange.go @@ -13,14 +13,6 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/secrets" ) -type tokenRequestBody struct { - GrantType string `json:"grant_type"` - AuthorizationCode string `json:"code"` - RedirectUri string `json:"redirect_uri"` - ClientAssertionType string `json:"client_assertion_type"` - ClientAssertion string `json:"client_assertion"` -} - type tokenResponseBody struct { AccessToken string `json:"access_token"` TokenType string `json:"token_type"` diff --git a/internal/page/csrf.go b/internal/page/csrf.go index 21e7f7b3ce..39b27ac078 100644 --- a/internal/page/csrf.go +++ b/internal/page/csrf.go @@ -12,8 +12,6 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/sesh" ) -type contextKey string - var ErrCsrfInvalid = errors.New("CSRF token not valid") const csrfTokenLength = 12 @@ -66,7 +64,7 @@ func csrfValid(r *http.Request, csrfSession *sesh.CsrfSession) bool { lmt := io.LimitReader(part, csrfTokenLength+1) value, _ := io.ReadAll(lmt) - r.Body = MultiReadCloser(io.NopCloser(&buf), r.Body) + r.Body = newMultiReadCloser(io.NopCloser(&buf), r.Body) return string(value) == cookieValue } diff --git a/internal/page/dashboard.go b/internal/page/dashboard.go index 00ded869be..4344793d88 100644 --- a/internal/page/dashboard.go +++ b/internal/page/dashboard.go @@ -10,7 +10,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/donor" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -20,7 +20,7 @@ type DashboardStore interface { } type LpaAndActorTasks struct { - Lpa *lpastore.Lpa + Lpa *lpadata.Lpa CertificateProvider *certificateproviderdata.Provided Attorney *attorneydata.Provided } diff --git a/internal/page/dashboard_test.go b/internal/page/dashboard_test.go index dc1eac3697..57d239e6f1 100644 --- a/internal/page/dashboard_test.go +++ b/internal/page/dashboard_test.go @@ -10,7 +10,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor" "github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -20,12 +20,12 @@ func TestGetDashboard(t *testing.T) { r, _ := http.NewRequest(http.MethodGet, "/", nil) donorLpas := []LpaAndActorTasks{ - {Lpa: &lpastore.Lpa{LpaID: "123"}}, - {Lpa: &lpastore.Lpa{LpaID: "456"}}, + {Lpa: &lpadata.Lpa{LpaID: "123"}}, + {Lpa: &lpadata.Lpa{LpaID: "456"}}, } - certificateProviderLpas := []LpaAndActorTasks{{Lpa: &lpastore.Lpa{LpaID: "abc"}}} - attorneyLpas := []LpaAndActorTasks{{Lpa: &lpastore.Lpa{LpaID: "def"}}} + certificateProviderLpas := []LpaAndActorTasks{{Lpa: &lpadata.Lpa{LpaID: "abc"}}} + attorneyLpas := []LpaAndActorTasks{{Lpa: &lpadata.Lpa{LpaID: "def"}}} dashboardStore := newMockDashboardStore(t) dashboardStore.EXPECT(). @@ -55,8 +55,8 @@ func TestGetDashboardOnlyDonor(t *testing.T) { r, _ := http.NewRequest(http.MethodGet, "/", nil) donorLpas := []LpaAndActorTasks{ - {Lpa: &lpastore.Lpa{LpaID: "123"}}, - {Lpa: &lpastore.Lpa{LpaID: "456"}}, + {Lpa: &lpadata.Lpa{LpaID: "123"}}, + {Lpa: &lpadata.Lpa{LpaID: "456"}}, } dashboardStore := newMockDashboardStore(t) diff --git a/internal/page/doc.go b/internal/page/doc.go index c3c56607be..63da1a672b 100644 --- a/internal/page/doc.go +++ b/internal/page/doc.go @@ -1,12 +1,2 @@ -// Package page contains the core code and business logic of Make and Register a Lasting Power of Attorney (MRLPA) -// -// Useful links: -// - [actor.Lpa] - details about the LPA being drafted -// - [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 -// - [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 -// - [donordata.PersonToNotify] - details about a person to notify, provided by the applicant +// Package page provides middleware and handlers for root-level pages. package page diff --git a/internal/page/fixtures/donor.go b/internal/page/fixtures/donor.go index 6cd214bc87..a10d0c9503 100644 --- a/internal/page/fixtures/donor.go +++ b/internal/page/fixtures/donor.go @@ -123,7 +123,7 @@ func Donor( return err } - var fns []func(context.Context, *lpastore.Client, *lpastore.Lpa) error + var fns []func(context.Context, *lpastore.Client, *lpadata.Lpa) error donorDetails, fns, err = updateLPAProgress(data, donorDetails, donorSessionID, r, certificateProviderStore, attorneyStore, documentStore, eventClient, shareCodeStore) if err != nil { return err @@ -181,8 +181,8 @@ func updateLPAProgress( documentStore DocumentStore, eventClient *event.Client, shareCodeStore ShareCodeStore, -) (*donordata.Provided, []func(context.Context, *lpastore.Client, *lpastore.Lpa) error, error) { - var fns []func(context.Context, *lpastore.Client, *lpastore.Lpa) error +) (*donordata.Provided, []func(context.Context, *lpastore.Client, *lpadata.Lpa) error, error) { + var fns []func(context.Context, *lpastore.Client, *lpadata.Lpa) error if data.Progress >= slices.Index(progressValues, "provideYourDetails") { donorDetails.Donor = makeDonor(data.DonorEmail) @@ -466,7 +466,7 @@ func updateLPAProgress( certificateProviderUID = certificateProvider.UID - fns = append(fns, func(ctx context.Context, client *lpastore.Client, lpa *lpastore.Lpa) error { + fns = append(fns, func(ctx context.Context, client *lpastore.Client, lpa *lpadata.Lpa) error { return client.SendCertificateProvider(ctx, certificateProvider, lpa) }) } @@ -501,7 +501,7 @@ func updateLPAProgress( return nil, nil, err } - fns = append(fns, func(ctx context.Context, client *lpastore.Client, lpa *lpastore.Lpa) error { + fns = append(fns, func(ctx context.Context, client *lpastore.Client, lpa *lpadata.Lpa) error { return client.SendAttorney(ctx, lpa, attorney) }) } @@ -539,7 +539,7 @@ func updateLPAProgress( return nil, nil, err } - fns = append(fns, func(ctx context.Context, client *lpastore.Client, lpa *lpastore.Lpa) error { + fns = append(fns, func(ctx context.Context, client *lpastore.Client, lpa *lpadata.Lpa) error { return client.SendAttorney(ctx, lpa, attorney) }) } @@ -551,7 +551,7 @@ func updateLPAProgress( } if data.Progress >= slices.Index(progressValues, "perfect") { - fns = append(fns, func(ctx context.Context, client *lpastore.Client, _ *lpastore.Lpa) error { + fns = append(fns, func(ctx context.Context, client *lpastore.Client, _ *lpadata.Lpa) error { return client.SendPerfect(ctx, donorDetails.LpaUID) }) donorDetails.PerfectAt = time.Now() @@ -562,13 +562,13 @@ func updateLPAProgress( } if data.Progress == slices.Index(progressValues, "certificateProviderOptedOut") { - fns = append(fns, func(ctx context.Context, client *lpastore.Client, _ *lpastore.Lpa) error { + fns = append(fns, func(ctx context.Context, client *lpastore.Client, _ *lpadata.Lpa) error { return client.SendCertificateProviderOptOut(ctx, donorDetails.LpaUID, certificateProviderUID) }) } if data.Progress >= slices.Index(progressValues, "registered") { - fns = append(fns, func(ctx context.Context, client *lpastore.Client, _ *lpastore.Lpa) error { + fns = append(fns, func(ctx context.Context, client *lpastore.Client, _ *lpadata.Lpa) error { return client.SendRegister(ctx, donorDetails.LpaUID) }) } diff --git a/internal/page/fixtures/fixtures.go b/internal/page/fixtures/fixtures.go index 563cb00a44..f5366694e6 100644 --- a/internal/page/fixtures/fixtures.go +++ b/internal/page/fixtures/fixtures.go @@ -16,7 +16,6 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/form" "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" "github.com/ministryofjustice/opg-modernising-lpa/internal/place" @@ -27,7 +26,7 @@ import ( type ShareCodeSender interface { SendCertificateProviderInvite(context context.Context, appData appcontext.Data, donorProvided page.CertificateProviderInvite) error - SendAttorneys(context context.Context, appData appcontext.Data, donorProvided *lpastore.Lpa) error + SendAttorneys(context context.Context, appData appcontext.Data, donorProvided *lpadata.Lpa) error UseTestCode(shareCode string) } diff --git a/internal/page/fixtures/supporter.go b/internal/page/fixtures/supporter.go index 1fc2b8d8ef..9e747024e2 100644 --- a/internal/page/fixtures/supporter.go +++ b/internal/page/fixtures/supporter.go @@ -194,7 +194,7 @@ func Supporter( Attorneys: []donordata.Attorney{makeAttorney(attorneyNames[0])}, } - var fns []func(context.Context, *lpastore.Client, *lpastore.Lpa) error + var fns []func(context.Context, *lpastore.Client, *lpadata.Lpa) error if setLPAProgress { donor, fns, err = updateLPAProgress(donorFixtureData, donor, random.String(16), r, certificateProviderStore, attorneyStore, documentStore, eventClient, shareCodeStore) if err != nil { diff --git a/internal/page/mock_test.go b/internal/page/mock_test.go index 87dbaacb18..f132d6143d 100644 --- a/internal/page/mock_test.go +++ b/internal/page/mock_test.go @@ -5,14 +5,12 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" - "github.com/ministryofjustice/opg-modernising-lpa/internal/place" ) const testRandomString = "123" var ( expectedError = errors.New("err") - testAddress = place.Address{Line1: "1"} TestAppData = appcontext.Data{ SessionID: "session-id", LpaID: "lpa-id", diff --git a/internal/page/multi_read_closer.go b/internal/page/multi_read_closer.go index 79fde49ebe..3a1b25c191 100644 --- a/internal/page/multi_read_closer.go +++ b/internal/page/multi_read_closer.go @@ -1,9 +1,10 @@ +package page + // Modified from io/multi.go which carries the following licence: // // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package page import ( "errors" @@ -88,11 +89,11 @@ func (mr *multiReadCloser) Close() error { var _ io.WriterTo = (*multiReadCloser)(nil) -// MultiReadCloser returns a io.ReadCloser that's the logical concatenation of +// newMultiReadCloser returns a io.ReadCloser that's the logical concatenation of // the provided input readClosers. They're read sequentially. Once all inputs // have returned EOF, Read will return EOF. If any of the readClosers return a // non-nil, non-EOF error, Read will return that error. -func MultiReadCloser(readClosers ...io.ReadCloser) io.ReadCloser { +func newMultiReadCloser(readClosers ...io.ReadCloser) io.ReadCloser { r := make([]io.ReadCloser, len(readClosers)) copy(r, readClosers) return &multiReadCloser{r} diff --git a/internal/page/multi_read_closer_test.go b/internal/page/multi_read_closer_test.go index 7bfb88ce62..7fe9ae07ed 100644 --- a/internal/page/multi_read_closer_test.go +++ b/internal/page/multi_read_closer_test.go @@ -23,7 +23,7 @@ func TestMultiReadCloser(t *testing.T) { r1 := io.NopCloser(strings.NewReader("foo ")) r2 := io.NopCloser(strings.NewReader("")) r3 := io.NopCloser(strings.NewReader("bar")) - mr = MultiReadCloser(r1, r2, r3) + mr = newMultiReadCloser(r1, r2, r3) buf = make([]byte, 20) tests() } @@ -63,9 +63,9 @@ func TestMultiReadCloser(t *testing.T) { } func TestMultiReadCloserAsWriterTo(t *testing.T) { - mr := MultiReadCloser( + mr := newMultiReadCloser( io.NopCloser(strings.NewReader("foo ")), - MultiReadCloser( // Tickle the buffer reusing codepath + newMultiReadCloser( // Tickle the buffer reusing codepath io.NopCloser(strings.NewReader("")), io.NopCloser(strings.NewReader("bar")), ), @@ -115,7 +115,7 @@ func TestMultiReadCloserFlatten(t *testing.T) { n := runtime.Callers(0, pc) var myDepth = callDepth(pc[:n]) var readDepth int // will contain the depth from which fakeReader.Read was called - var r io.ReadCloser = MultiReadCloser(readerFunc(func(p []byte) (int, error) { + var r io.ReadCloser = newMultiReadCloser(readerFunc(func(p []byte) (int, error) { n := runtime.Callers(1, pc) readDepth = callDepth(pc[:n]) return 0, errors.New("irrelevant") @@ -123,7 +123,7 @@ func TestMultiReadCloserFlatten(t *testing.T) { // chain a bunch of multiReaders for i := 0; i < 100; i++ { - r = MultiReadCloser(r) + r = newMultiReadCloser(r) } r.Read(nil) // don't care about errors, just want to check the call-depth for Read @@ -150,7 +150,7 @@ func (b byteAndEOFReader) Read(p []byte) (n int, err error) { // This used to yield bytes forever; issue 16795. func TestMultiReadCloserSingleByteWithEOF(t *testing.T) { - got, err := io.ReadAll(io.LimitReader(MultiReadCloser(io.NopCloser(byteAndEOFReader('a')), io.NopCloser(byteAndEOFReader('b'))), 10)) + got, err := io.ReadAll(io.LimitReader(newMultiReadCloser(io.NopCloser(byteAndEOFReader('a')), io.NopCloser(byteAndEOFReader('b'))), 10)) if err != nil { t.Fatal(err) } @@ -164,7 +164,7 @@ func TestMultiReadCloserSingleByteWithEOF(t *testing.T) { // chain continues to return EOF on its final read, rather than // yielding a (0, EOF). func TestMultiReadCloserFinalEOF(t *testing.T) { - r := MultiReadCloser(io.NopCloser(bytes.NewReader(nil)), io.NopCloser(byteAndEOFReader('a'))) + r := newMultiReadCloser(io.NopCloser(bytes.NewReader(nil)), io.NopCloser(byteAndEOFReader('a'))) buf := make([]byte, 2) n, err := r.Read(buf) if n != 1 || err != io.EOF { @@ -176,8 +176,8 @@ func TestInterleavedMultiReadCloser(t *testing.T) { r1 := io.NopCloser(strings.NewReader("123")) r2 := io.NopCloser(strings.NewReader("45678")) - mr1 := MultiReadCloser(r1, r2) - mr2 := MultiReadCloser(mr1) + mr1 := newMultiReadCloser(r1, r2) + mr2 := newMultiReadCloser(mr1) buf := make([]byte, 4) @@ -214,7 +214,7 @@ func TestMultiReadCloserClose(t *testing.T) { rc1 := &rc{} rc2 := &rc{} - mr := MultiReadCloser(rc1, rc2) + mr := newMultiReadCloser(rc1, rc2) if err := mr.Close(); err != nil { t.Errorf(`Close() = %v, want nil`, err) } @@ -234,7 +234,7 @@ func TestMultiReadCloserCloseWhenErrors(t *testing.T) { rc1 := &rc{err: err1} rc2 := &rc{err: err2} - mr := MultiReadCloser(rc1, rc2) + mr := newMultiReadCloser(rc1, rc2) if err := mr.Close(); err.Error() != expected.Error() { t.Errorf(`Close() = %v, want %v`, err, expected) } diff --git a/internal/page/share_code.go b/internal/page/share_code.go index b5e3cd0e8b..ed1e19dd56 100644 --- a/internal/page/share_code.go +++ b/internal/page/share_code.go @@ -11,7 +11,6 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo" "github.com/ministryofjustice/opg-modernising-lpa/internal/event" "github.com/ministryofjustice/opg-modernising-lpa/internal/localize" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" @@ -90,7 +89,7 @@ func (s *ShareCodeSender) SendCertificateProviderPrompt(ctx context.Context, app }) } -func (s *ShareCodeSender) SendAttorneys(ctx context.Context, appData appcontext.Data, donor *lpastore.Lpa) error { +func (s *ShareCodeSender) SendAttorneys(ctx context.Context, appData appcontext.Data, donor *lpadata.Lpa) error { if err := s.sendTrustCorporation(ctx, appData, donor, donor.Attorneys.TrustCorporation); err != nil { return err } @@ -113,7 +112,7 @@ func (s *ShareCodeSender) SendAttorneys(ctx context.Context, appData appcontext. return nil } -func (s *ShareCodeSender) sendOriginalAttorney(ctx context.Context, appData appcontext.Data, lpa *lpastore.Lpa, attorney lpastore.Attorney) error { +func (s *ShareCodeSender) sendOriginalAttorney(ctx context.Context, appData appcontext.Data, lpa *lpadata.Lpa, attorney lpadata.Attorney) error { shareCode, err := s.createShareCode(ctx, lpa.LpaKey, lpa.LpaOwnerKey, attorney.UID, actor.TypeAttorney) if err != nil { return err @@ -136,7 +135,7 @@ func (s *ShareCodeSender) sendOriginalAttorney(ctx context.Context, appData appc }) } -func (s *ShareCodeSender) sendReplacementAttorney(ctx context.Context, appData appcontext.Data, lpa *lpastore.Lpa, attorney lpastore.Attorney) error { +func (s *ShareCodeSender) sendReplacementAttorney(ctx context.Context, appData appcontext.Data, lpa *lpadata.Lpa, attorney lpadata.Attorney) error { shareCode, err := s.createShareCode(ctx, lpa.LpaKey, lpa.LpaOwnerKey, attorney.UID, actor.TypeReplacementAttorney) if err != nil { return err @@ -159,7 +158,7 @@ func (s *ShareCodeSender) sendReplacementAttorney(ctx context.Context, appData a }) } -func (s *ShareCodeSender) sendTrustCorporation(ctx context.Context, appData appcontext.Data, lpa *lpastore.Lpa, trustCorporation lpastore.TrustCorporation) error { +func (s *ShareCodeSender) sendTrustCorporation(ctx context.Context, appData appcontext.Data, lpa *lpadata.Lpa, trustCorporation lpadata.TrustCorporation) error { if trustCorporation.Name == "" { return nil } @@ -186,7 +185,7 @@ func (s *ShareCodeSender) sendTrustCorporation(ctx context.Context, appData appc }) } -func (s *ShareCodeSender) sendReplacementTrustCorporation(ctx context.Context, appData appcontext.Data, lpa *lpastore.Lpa, trustCorporation lpastore.TrustCorporation) error { +func (s *ShareCodeSender) sendReplacementTrustCorporation(ctx context.Context, appData appcontext.Data, lpa *lpadata.Lpa, trustCorporation lpadata.TrustCorporation) error { if trustCorporation.Name == "" { return nil } diff --git a/internal/page/share_code_test.go b/internal/page/share_code_test.go index 2d3d9525c9..72f345c142 100644 --- a/internal/page/share_code_test.go +++ b/internal/page/share_code_test.go @@ -11,7 +11,6 @@ import ( "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" "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" @@ -583,14 +582,14 @@ func TestShareCodeSenderSendAttorneys(t *testing.T) { replacement1UID := actoruid.New() replacement2UID := actoruid.New() - donor := &lpastore.Lpa{ - Attorneys: lpastore.Attorneys{ - TrustCorporation: lpastore.TrustCorporation{ + donor := &lpadata.Lpa{ + Attorneys: lpadata.Attorneys{ + TrustCorporation: lpadata.TrustCorporation{ UID: trustCorporationUID, Name: "Trusty", Email: "trusted@example.com", }, - Attorneys: []lpastore.Attorney{ + Attorneys: []lpadata.Attorney{ { UID: attorney1UID, FirstNames: "Joanna", @@ -610,13 +609,13 @@ func TestShareCodeSenderSendAttorneys(t *testing.T) { }, }, }, - ReplacementAttorneys: lpastore.Attorneys{ - TrustCorporation: lpastore.TrustCorporation{ + ReplacementAttorneys: lpadata.Attorneys{ + TrustCorporation: lpadata.TrustCorporation{ UID: replacementTrustCorporationUID, Name: "Untrusty", Email: "untrusted@example.com", }, - Attorneys: []lpastore.Attorney{ + Attorneys: []lpadata.Attorney{ { UID: replacement1UID, FirstNames: "Dave", @@ -630,7 +629,7 @@ func TestShareCodeSenderSendAttorneys(t *testing.T) { }, }, }, - Donor: lpastore.Donor{ + Donor: lpadata.Donor{ FirstNames: "Jan", LastName: "Smith", }, @@ -765,20 +764,20 @@ func TestShareCodeSenderSendAttorneysTrustCorporationsNoEmail(t *testing.T) { uid1 := actoruid.New() uid2 := actoruid.New() - donor := &lpastore.Lpa{ - Attorneys: lpastore.Attorneys{ - TrustCorporation: lpastore.TrustCorporation{ + donor := &lpadata.Lpa{ + Attorneys: lpadata.Attorneys{ + TrustCorporation: lpadata.TrustCorporation{ UID: uid1, Name: "Trusty", }, }, - ReplacementAttorneys: lpastore.Attorneys{ - TrustCorporation: lpastore.TrustCorporation{ + ReplacementAttorneys: lpadata.Attorneys{ + TrustCorporation: lpadata.TrustCorporation{ UID: uid2, Name: "Untrusty", }, }, - Donor: lpastore.Donor{ + Donor: lpadata.Donor{ FirstNames: "Jan", LastName: "Smith", }, @@ -847,15 +846,15 @@ func TestShareCodeSenderSendAttorneysWithTestCode(t *testing.T) { }, } - donor := &lpastore.Lpa{ - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{ + donor := &lpadata.Lpa{ + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{ { FirstNames: "Joanna", LastName: "Jones", Email: "name@example.org", }, }}, - Donor: lpastore.Donor{ + Donor: lpadata.Donor{ FirstNames: "Jan", LastName: "Smith", }, @@ -931,15 +930,15 @@ func TestShareCodeSenderSendAttorneysWithTestCode(t *testing.T) { func TestShareCodeSenderSendAttorneysWhenEmailErrors(t *testing.T) { ctx := context.Background() - donor := &lpastore.Lpa{ - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{ + donor := &lpadata.Lpa{ + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{ { FirstNames: "Joanna", LastName: "Jones", Email: "name@example.org", }, }}, - Donor: lpastore.Donor{ + Donor: lpadata.Donor{ FirstNames: "Jan", LastName: "Smith", }, @@ -980,8 +979,8 @@ func TestShareCodeSenderSendAttorneysWhenShareCodeStoreErrors(t *testing.T) { Return(expectedError) sender := NewShareCodeSender(shareCodeStore, nil, "http://app", testRandomStringFn, nil) - err := sender.SendAttorneys(ctx, TestAppData, &lpastore.Lpa{ - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{Email: "hey@example.com"}}}, + err := sender.SendAttorneys(ctx, TestAppData, &lpadata.Lpa{ + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{Email: "hey@example.com"}}}, }) assert.Equal(t, expectedError, errors.Unwrap(err)) diff --git a/internal/sesh/sesh.go b/internal/sesh/sesh.go index d25bcb4ba3..818c3dad33 100644 --- a/internal/sesh/sesh.go +++ b/internal/sesh/sesh.go @@ -55,12 +55,6 @@ func init() { gob.Register(&LpaDataSession{}) } -type cookieStore interface { - Get(r *http.Request, name string) (*sessions.Session, error) - New(r *http.Request, name string) (*sessions.Session, error) - Save(r *http.Request, w http.ResponseWriter, s *sessions.Session) error -} - type MissingSessionError string func (e MissingSessionError) Error() string { diff --git a/internal/supporter/mock_test.go b/internal/supporter/mock_test.go index f418960016..fde2575364 100644 --- a/internal/supporter/mock_test.go +++ b/internal/supporter/mock_test.go @@ -12,7 +12,6 @@ import ( ) var ( - ctx = context.Background() expectedError = errors.New("err") testNow = time.Date(2023, time.April, 2, 3, 4, 5, 6, time.UTC) testNowFn = func() time.Time { return testNow } diff --git a/internal/supporter/supporterpage/mock_LpaStoreResolvingService_test.go b/internal/supporter/supporterpage/mock_LpaStoreResolvingService_test.go index df1570025a..07c548612f 100644 --- a/internal/supporter/supporterpage/mock_LpaStoreResolvingService_test.go +++ b/internal/supporter/supporterpage/mock_LpaStoreResolvingService_test.go @@ -5,7 +5,7 @@ package supporterpage import ( context "context" - lpastore "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + lpadata "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" mock "github.com/stretchr/testify/mock" ) @@ -23,23 +23,23 @@ func (_m *mockLpaStoreResolvingService) EXPECT() *mockLpaStoreResolvingService_E } // Get provides a mock function with given fields: ctx -func (_m *mockLpaStoreResolvingService) Get(ctx context.Context) (*lpastore.Lpa, error) { +func (_m *mockLpaStoreResolvingService) Get(ctx context.Context) (*lpadata.Lpa, error) { ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for Get") } - var r0 *lpastore.Lpa + var r0 *lpadata.Lpa var r1 error - if rf, ok := ret.Get(0).(func(context.Context) (*lpastore.Lpa, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context) (*lpadata.Lpa, error)); ok { return rf(ctx) } - if rf, ok := ret.Get(0).(func(context.Context) *lpastore.Lpa); ok { + if rf, ok := ret.Get(0).(func(context.Context) *lpadata.Lpa); ok { r0 = rf(ctx) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*lpastore.Lpa) + r0 = ret.Get(0).(*lpadata.Lpa) } } @@ -70,12 +70,12 @@ func (_c *mockLpaStoreResolvingService_Get_Call) Run(run func(ctx context.Contex return _c } -func (_c *mockLpaStoreResolvingService_Get_Call) Return(_a0 *lpastore.Lpa, _a1 error) *mockLpaStoreResolvingService_Get_Call { +func (_c *mockLpaStoreResolvingService_Get_Call) Return(_a0 *lpadata.Lpa, _a1 error) *mockLpaStoreResolvingService_Get_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *mockLpaStoreResolvingService_Get_Call) RunAndReturn(run func(context.Context) (*lpastore.Lpa, error)) *mockLpaStoreResolvingService_Get_Call { +func (_c *mockLpaStoreResolvingService_Get_Call) RunAndReturn(run func(context.Context) (*lpadata.Lpa, error)) *mockLpaStoreResolvingService_Get_Call { _c.Call.Return(run) return _c } diff --git a/internal/supporter/supporterpage/mock_ProgressTracker_test.go b/internal/supporter/supporterpage/mock_ProgressTracker_test.go index 259046c282..b282fb3af0 100644 --- a/internal/supporter/supporterpage/mock_ProgressTracker_test.go +++ b/internal/supporter/supporterpage/mock_ProgressTracker_test.go @@ -3,10 +3,10 @@ package supporterpage import ( - lpastore "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" + lpadata "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" mock "github.com/stretchr/testify/mock" - page "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + task "github.com/ministryofjustice/opg-modernising-lpa/internal/task" ) // mockProgressTracker is an autogenerated mock type for the ProgressTracker type @@ -23,18 +23,18 @@ func (_m *mockProgressTracker) EXPECT() *mockProgressTracker_Expecter { } // Progress provides a mock function with given fields: lpa -func (_m *mockProgressTracker) Progress(lpa *lpastore.Lpa) page.Progress { +func (_m *mockProgressTracker) Progress(lpa *lpadata.Lpa) task.Progress { ret := _m.Called(lpa) if len(ret) == 0 { panic("no return value specified for Progress") } - var r0 page.Progress - if rf, ok := ret.Get(0).(func(*lpastore.Lpa) page.Progress); ok { + var r0 task.Progress + if rf, ok := ret.Get(0).(func(*lpadata.Lpa) task.Progress); ok { r0 = rf(lpa) } else { - r0 = ret.Get(0).(page.Progress) + r0 = ret.Get(0).(task.Progress) } return r0 @@ -46,24 +46,24 @@ type mockProgressTracker_Progress_Call struct { } // Progress is a helper method to define mock.On call -// - lpa *lpastore.Lpa +// - lpa *lpadata.Lpa func (_e *mockProgressTracker_Expecter) Progress(lpa interface{}) *mockProgressTracker_Progress_Call { return &mockProgressTracker_Progress_Call{Call: _e.mock.On("Progress", lpa)} } -func (_c *mockProgressTracker_Progress_Call) Run(run func(lpa *lpastore.Lpa)) *mockProgressTracker_Progress_Call { +func (_c *mockProgressTracker_Progress_Call) Run(run func(lpa *lpadata.Lpa)) *mockProgressTracker_Progress_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*lpastore.Lpa)) + run(args[0].(*lpadata.Lpa)) }) return _c } -func (_c *mockProgressTracker_Progress_Call) Return(_a0 page.Progress) *mockProgressTracker_Progress_Call { +func (_c *mockProgressTracker_Progress_Call) Return(_a0 task.Progress) *mockProgressTracker_Progress_Call { _c.Call.Return(_a0) return _c } -func (_c *mockProgressTracker_Progress_Call) RunAndReturn(run func(*lpastore.Lpa) page.Progress) *mockProgressTracker_Progress_Call { +func (_c *mockProgressTracker_Progress_Call) RunAndReturn(run func(*lpadata.Lpa) task.Progress) *mockProgressTracker_Progress_Call { _c.Call.Return(run) return _c } diff --git a/internal/supporter/supporterpage/register.go b/internal/supporter/supporterpage/register.go index ecd134de54..72a37d846c 100644 --- a/internal/supporter/supporterpage/register.go +++ b/internal/supporter/supporterpage/register.go @@ -12,7 +12,7 @@ import ( "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/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/notify" "github.com/ministryofjustice/opg-modernising-lpa/internal/onelogin" "github.com/ministryofjustice/opg-modernising-lpa/internal/page" @@ -22,6 +22,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/sharecode" "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter" "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) @@ -30,7 +31,7 @@ type Logger interface { } type LpaStoreResolvingService interface { - Get(ctx context.Context) (*lpastore.Lpa, error) + Get(ctx context.Context) (*lpadata.Lpa, error) } type OrganisationStore interface { @@ -102,7 +103,7 @@ type Handler func(data appcontext.Data, w http.ResponseWriter, r *http.Request, type ErrorHandler func(http.ResponseWriter, *http.Request, error) type ProgressTracker interface { - Progress(lpa *lpastore.Lpa) page.Progress + Progress(lpa *lpadata.Lpa) task.Progress } func Register( diff --git a/internal/supporter/supporterpage/view_lpa.go b/internal/supporter/supporterpage/view_lpa.go index aa50b5e476..c8f76d5aeb 100644 --- a/internal/supporter/supporterpage/view_lpa.go +++ b/internal/supporter/supporterpage/view_lpa.go @@ -5,17 +5,17 @@ import ( "github.com/ministryofjustice/opg-go-common/template" "github.com/ministryofjustice/opg-modernising-lpa/internal/appcontext" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" - "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" + "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/ministryofjustice/opg-modernising-lpa/internal/validation" ) type viewLPAData struct { App appcontext.Data Errors validation.List - Lpa *lpastore.Lpa - Progress page.Progress + Lpa *lpadata.Lpa + Progress task.Progress } func ViewLPA(tmpl template.Template, lpaStoreResolvingService LpaStoreResolvingService, progressTracker ProgressTracker) Handler { diff --git a/internal/supporter/supporterpage/view_lpa_test.go b/internal/supporter/supporterpage/view_lpa_test.go index 8882e58433..18fdae664f 100644 --- a/internal/supporter/supporterpage/view_lpa_test.go +++ b/internal/supporter/supporterpage/view_lpa_test.go @@ -5,8 +5,7 @@ import ( "net/http/httptest" "testing" - lpastore "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" - "github.com/ministryofjustice/opg-modernising-lpa/internal/page" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/ministryofjustice/opg-modernising-lpa/internal/supporter/supporterdata" "github.com/ministryofjustice/opg-modernising-lpa/internal/task" "github.com/stretchr/testify/assert" @@ -17,7 +16,7 @@ func TestGetViewLPA(t *testing.T) { w := httptest.NewRecorder() r, _ := http.NewRequest(http.MethodGet, "/", nil) - lpa := &lpastore.Lpa{LpaUID: "lpa-uid"} + lpa := &lpadata.Lpa{LpaUID: "lpa-uid"} lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). @@ -27,14 +26,14 @@ func TestGetViewLPA(t *testing.T) { progressTracker := newMockProgressTracker(t) progressTracker.EXPECT(). Progress(lpa). - Return(page.Progress{Paid: page.ProgressTask{State: task.StateInProgress}}) + Return(task.Progress{Paid: task.ProgressTask{State: task.StateInProgress}}) template := newMockTemplate(t) template.EXPECT(). Execute(w, &viewLPAData{ App: testAppData, Lpa: lpa, - Progress: page.Progress{Paid: page.ProgressTask{State: task.StateInProgress}}, + Progress: task.Progress{Paid: task.ProgressTask{State: task.StateInProgress}}, }). Return(nil) @@ -64,12 +63,12 @@ func TestGetViewLPAWhenTemplateError(t *testing.T) { lpaStoreResolvingService := newMockLpaStoreResolvingService(t) lpaStoreResolvingService.EXPECT(). Get(r.Context()). - Return(&lpastore.Lpa{}, nil) + Return(&lpadata.Lpa{}, nil) progressTracker := newMockProgressTracker(t) progressTracker.EXPECT(). Progress(mock.Anything). - Return(page.Progress{}) + Return(task.Progress{}) template := newMockTemplate(t) template.EXPECT(). diff --git a/internal/task/mock_Localizer_test.go b/internal/task/mock_Localizer_test.go new file mode 100644 index 0000000000..adda961c4e --- /dev/null +++ b/internal/task/mock_Localizer_test.go @@ -0,0 +1,534 @@ +// Code generated by mockery v2.42.2. DO NOT EDIT. + +package task + +import ( + date "github.com/ministryofjustice/opg-modernising-lpa/internal/date" + mock "github.com/stretchr/testify/mock" + + time "time" +) + +// mockLocalizer is an autogenerated mock type for the Localizer type +type mockLocalizer struct { + mock.Mock +} + +type mockLocalizer_Expecter struct { + mock *mock.Mock +} + +func (_m *mockLocalizer) EXPECT() *mockLocalizer_Expecter { + return &mockLocalizer_Expecter{mock: &_m.Mock} +} + +// Concat provides a mock function with given fields: list, joiner +func (_m *mockLocalizer) Concat(list []string, joiner string) string { + ret := _m.Called(list, joiner) + + if len(ret) == 0 { + panic("no return value specified for Concat") + } + + var r0 string + if rf, ok := ret.Get(0).(func([]string, string) string); ok { + r0 = rf(list, joiner) + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// mockLocalizer_Concat_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Concat' +type mockLocalizer_Concat_Call struct { + *mock.Call +} + +// Concat is a helper method to define mock.On call +// - list []string +// - joiner string +func (_e *mockLocalizer_Expecter) Concat(list interface{}, joiner interface{}) *mockLocalizer_Concat_Call { + return &mockLocalizer_Concat_Call{Call: _e.mock.On("Concat", list, joiner)} +} + +func (_c *mockLocalizer_Concat_Call) Run(run func(list []string, joiner string)) *mockLocalizer_Concat_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].([]string), args[1].(string)) + }) + return _c +} + +func (_c *mockLocalizer_Concat_Call) Return(_a0 string) *mockLocalizer_Concat_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockLocalizer_Concat_Call) RunAndReturn(run func([]string, string) string) *mockLocalizer_Concat_Call { + _c.Call.Return(run) + return _c +} + +// Count provides a mock function with given fields: messageID, count +func (_m *mockLocalizer) Count(messageID string, count int) string { + ret := _m.Called(messageID, count) + + if len(ret) == 0 { + panic("no return value specified for Count") + } + + var r0 string + if rf, ok := ret.Get(0).(func(string, int) string); ok { + r0 = rf(messageID, count) + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// mockLocalizer_Count_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Count' +type mockLocalizer_Count_Call struct { + *mock.Call +} + +// Count is a helper method to define mock.On call +// - messageID string +// - count int +func (_e *mockLocalizer_Expecter) Count(messageID interface{}, count interface{}) *mockLocalizer_Count_Call { + return &mockLocalizer_Count_Call{Call: _e.mock.On("Count", messageID, count)} +} + +func (_c *mockLocalizer_Count_Call) Run(run func(messageID string, count int)) *mockLocalizer_Count_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(int)) + }) + return _c +} + +func (_c *mockLocalizer_Count_Call) Return(_a0 string) *mockLocalizer_Count_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockLocalizer_Count_Call) RunAndReturn(run func(string, int) string) *mockLocalizer_Count_Call { + _c.Call.Return(run) + return _c +} + +// Format provides a mock function with given fields: messageID, data +func (_m *mockLocalizer) Format(messageID string, data map[string]interface{}) string { + ret := _m.Called(messageID, data) + + if len(ret) == 0 { + panic("no return value specified for Format") + } + + var r0 string + if rf, ok := ret.Get(0).(func(string, map[string]interface{}) string); ok { + r0 = rf(messageID, data) + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// mockLocalizer_Format_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Format' +type mockLocalizer_Format_Call struct { + *mock.Call +} + +// Format is a helper method to define mock.On call +// - messageID string +// - data map[string]interface{} +func (_e *mockLocalizer_Expecter) Format(messageID interface{}, data interface{}) *mockLocalizer_Format_Call { + return &mockLocalizer_Format_Call{Call: _e.mock.On("Format", messageID, data)} +} + +func (_c *mockLocalizer_Format_Call) Run(run func(messageID string, data map[string]interface{})) *mockLocalizer_Format_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(map[string]interface{})) + }) + return _c +} + +func (_c *mockLocalizer_Format_Call) Return(_a0 string) *mockLocalizer_Format_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockLocalizer_Format_Call) RunAndReturn(run func(string, map[string]interface{}) string) *mockLocalizer_Format_Call { + _c.Call.Return(run) + return _c +} + +// FormatCount provides a mock function with given fields: messageID, count, data +func (_m *mockLocalizer) FormatCount(messageID string, count int, data map[string]interface{}) string { + ret := _m.Called(messageID, count, data) + + if len(ret) == 0 { + panic("no return value specified for FormatCount") + } + + var r0 string + if rf, ok := ret.Get(0).(func(string, int, map[string]interface{}) string); ok { + r0 = rf(messageID, count, data) + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// mockLocalizer_FormatCount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FormatCount' +type mockLocalizer_FormatCount_Call struct { + *mock.Call +} + +// FormatCount is a helper method to define mock.On call +// - messageID string +// - count int +// - data map[string]interface{} +func (_e *mockLocalizer_Expecter) FormatCount(messageID interface{}, count interface{}, data interface{}) *mockLocalizer_FormatCount_Call { + return &mockLocalizer_FormatCount_Call{Call: _e.mock.On("FormatCount", messageID, count, data)} +} + +func (_c *mockLocalizer_FormatCount_Call) Run(run func(messageID string, count int, data map[string]interface{})) *mockLocalizer_FormatCount_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(int), args[2].(map[string]interface{})) + }) + return _c +} + +func (_c *mockLocalizer_FormatCount_Call) Return(_a0 string) *mockLocalizer_FormatCount_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockLocalizer_FormatCount_Call) RunAndReturn(run func(string, int, map[string]interface{}) string) *mockLocalizer_FormatCount_Call { + _c.Call.Return(run) + return _c +} + +// FormatDate provides a mock function with given fields: t +func (_m *mockLocalizer) FormatDate(t date.TimeOrDate) string { + ret := _m.Called(t) + + if len(ret) == 0 { + panic("no return value specified for FormatDate") + } + + var r0 string + if rf, ok := ret.Get(0).(func(date.TimeOrDate) string); ok { + r0 = rf(t) + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// mockLocalizer_FormatDate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FormatDate' +type mockLocalizer_FormatDate_Call struct { + *mock.Call +} + +// FormatDate is a helper method to define mock.On call +// - t date.TimeOrDate +func (_e *mockLocalizer_Expecter) FormatDate(t interface{}) *mockLocalizer_FormatDate_Call { + return &mockLocalizer_FormatDate_Call{Call: _e.mock.On("FormatDate", t)} +} + +func (_c *mockLocalizer_FormatDate_Call) Run(run func(t date.TimeOrDate)) *mockLocalizer_FormatDate_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(date.TimeOrDate)) + }) + return _c +} + +func (_c *mockLocalizer_FormatDate_Call) Return(_a0 string) *mockLocalizer_FormatDate_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockLocalizer_FormatDate_Call) RunAndReturn(run func(date.TimeOrDate) string) *mockLocalizer_FormatDate_Call { + _c.Call.Return(run) + return _c +} + +// FormatDateTime provides a mock function with given fields: t +func (_m *mockLocalizer) FormatDateTime(t time.Time) string { + ret := _m.Called(t) + + if len(ret) == 0 { + panic("no return value specified for FormatDateTime") + } + + var r0 string + if rf, ok := ret.Get(0).(func(time.Time) string); ok { + r0 = rf(t) + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// mockLocalizer_FormatDateTime_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FormatDateTime' +type mockLocalizer_FormatDateTime_Call struct { + *mock.Call +} + +// FormatDateTime is a helper method to define mock.On call +// - t time.Time +func (_e *mockLocalizer_Expecter) FormatDateTime(t interface{}) *mockLocalizer_FormatDateTime_Call { + return &mockLocalizer_FormatDateTime_Call{Call: _e.mock.On("FormatDateTime", t)} +} + +func (_c *mockLocalizer_FormatDateTime_Call) Run(run func(t time.Time)) *mockLocalizer_FormatDateTime_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(time.Time)) + }) + return _c +} + +func (_c *mockLocalizer_FormatDateTime_Call) Return(_a0 string) *mockLocalizer_FormatDateTime_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockLocalizer_FormatDateTime_Call) RunAndReturn(run func(time.Time) string) *mockLocalizer_FormatDateTime_Call { + _c.Call.Return(run) + return _c +} + +// FormatTime provides a mock function with given fields: t +func (_m *mockLocalizer) FormatTime(t time.Time) string { + ret := _m.Called(t) + + if len(ret) == 0 { + panic("no return value specified for FormatTime") + } + + var r0 string + if rf, ok := ret.Get(0).(func(time.Time) string); ok { + r0 = rf(t) + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// mockLocalizer_FormatTime_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FormatTime' +type mockLocalizer_FormatTime_Call struct { + *mock.Call +} + +// FormatTime is a helper method to define mock.On call +// - t time.Time +func (_e *mockLocalizer_Expecter) FormatTime(t interface{}) *mockLocalizer_FormatTime_Call { + return &mockLocalizer_FormatTime_Call{Call: _e.mock.On("FormatTime", t)} +} + +func (_c *mockLocalizer_FormatTime_Call) Run(run func(t time.Time)) *mockLocalizer_FormatTime_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(time.Time)) + }) + return _c +} + +func (_c *mockLocalizer_FormatTime_Call) Return(_a0 string) *mockLocalizer_FormatTime_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockLocalizer_FormatTime_Call) RunAndReturn(run func(time.Time) string) *mockLocalizer_FormatTime_Call { + _c.Call.Return(run) + return _c +} + +// Possessive provides a mock function with given fields: s +func (_m *mockLocalizer) Possessive(s string) string { + ret := _m.Called(s) + + if len(ret) == 0 { + panic("no return value specified for Possessive") + } + + var r0 string + if rf, ok := ret.Get(0).(func(string) string); ok { + r0 = rf(s) + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// mockLocalizer_Possessive_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Possessive' +type mockLocalizer_Possessive_Call struct { + *mock.Call +} + +// Possessive is a helper method to define mock.On call +// - s string +func (_e *mockLocalizer_Expecter) Possessive(s interface{}) *mockLocalizer_Possessive_Call { + return &mockLocalizer_Possessive_Call{Call: _e.mock.On("Possessive", s)} +} + +func (_c *mockLocalizer_Possessive_Call) Run(run func(s string)) *mockLocalizer_Possessive_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *mockLocalizer_Possessive_Call) Return(_a0 string) *mockLocalizer_Possessive_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockLocalizer_Possessive_Call) RunAndReturn(run func(string) string) *mockLocalizer_Possessive_Call { + _c.Call.Return(run) + return _c +} + +// SetShowTranslationKeys provides a mock function with given fields: s +func (_m *mockLocalizer) SetShowTranslationKeys(s bool) { + _m.Called(s) +} + +// mockLocalizer_SetShowTranslationKeys_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetShowTranslationKeys' +type mockLocalizer_SetShowTranslationKeys_Call struct { + *mock.Call +} + +// SetShowTranslationKeys is a helper method to define mock.On call +// - s bool +func (_e *mockLocalizer_Expecter) SetShowTranslationKeys(s interface{}) *mockLocalizer_SetShowTranslationKeys_Call { + return &mockLocalizer_SetShowTranslationKeys_Call{Call: _e.mock.On("SetShowTranslationKeys", s)} +} + +func (_c *mockLocalizer_SetShowTranslationKeys_Call) Run(run func(s bool)) *mockLocalizer_SetShowTranslationKeys_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool)) + }) + return _c +} + +func (_c *mockLocalizer_SetShowTranslationKeys_Call) Return() *mockLocalizer_SetShowTranslationKeys_Call { + _c.Call.Return() + return _c +} + +func (_c *mockLocalizer_SetShowTranslationKeys_Call) RunAndReturn(run func(bool)) *mockLocalizer_SetShowTranslationKeys_Call { + _c.Call.Return(run) + return _c +} + +// ShowTranslationKeys provides a mock function with given fields: +func (_m *mockLocalizer) ShowTranslationKeys() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for ShowTranslationKeys") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// mockLocalizer_ShowTranslationKeys_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ShowTranslationKeys' +type mockLocalizer_ShowTranslationKeys_Call struct { + *mock.Call +} + +// ShowTranslationKeys is a helper method to define mock.On call +func (_e *mockLocalizer_Expecter) ShowTranslationKeys() *mockLocalizer_ShowTranslationKeys_Call { + return &mockLocalizer_ShowTranslationKeys_Call{Call: _e.mock.On("ShowTranslationKeys")} +} + +func (_c *mockLocalizer_ShowTranslationKeys_Call) Run(run func()) *mockLocalizer_ShowTranslationKeys_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *mockLocalizer_ShowTranslationKeys_Call) Return(_a0 bool) *mockLocalizer_ShowTranslationKeys_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockLocalizer_ShowTranslationKeys_Call) RunAndReturn(run func() bool) *mockLocalizer_ShowTranslationKeys_Call { + _c.Call.Return(run) + return _c +} + +// T provides a mock function with given fields: messageID +func (_m *mockLocalizer) T(messageID string) string { + ret := _m.Called(messageID) + + if len(ret) == 0 { + panic("no return value specified for T") + } + + var r0 string + if rf, ok := ret.Get(0).(func(string) string); ok { + r0 = rf(messageID) + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// mockLocalizer_T_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'T' +type mockLocalizer_T_Call struct { + *mock.Call +} + +// T is a helper method to define mock.On call +// - messageID string +func (_e *mockLocalizer_Expecter) T(messageID interface{}) *mockLocalizer_T_Call { + return &mockLocalizer_T_Call{Call: _e.mock.On("T", messageID)} +} + +func (_c *mockLocalizer_T_Call) Run(run func(messageID string)) *mockLocalizer_T_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *mockLocalizer_T_Call) Return(_a0 string) *mockLocalizer_T_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *mockLocalizer_T_Call) RunAndReturn(run func(string) string) *mockLocalizer_T_Call { + _c.Call.Return(run) + return _c +} + +// newMockLocalizer creates a new instance of mockLocalizer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func newMockLocalizer(t interface { + mock.TestingT + Cleanup(func()) +}) *mockLocalizer { + mock := &mockLocalizer{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/internal/page/lpa_progress_tracker.go b/internal/task/progress.go similarity index 71% rename from internal/page/lpa_progress_tracker.go rename to internal/task/progress.go index 0185ea8cdc..7d831ab58f 100644 --- a/internal/page/lpa_progress_tracker.go +++ b/internal/task/progress.go @@ -1,16 +1,32 @@ -package page +package task import ( - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" - "github.com/ministryofjustice/opg-modernising-lpa/internal/task" + "time" + + "github.com/ministryofjustice/opg-modernising-lpa/internal/date" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" ) +type Localizer interface { + Concat(list []string, joiner string) string + Count(messageID string, count int) string + Format(messageID string, data map[string]interface{}) string + FormatCount(messageID string, count int, data map[string]any) string + FormatDate(t date.TimeOrDate) string + FormatTime(t time.Time) string + FormatDateTime(t time.Time) string + Possessive(s string) string + SetShowTranslationKeys(s bool) + ShowTranslationKeys() bool + T(messageID string) string +} + type ProgressTracker struct { Localizer Localizer } type ProgressTask struct { - State task.State + State State Label string } @@ -44,7 +60,7 @@ func (p Progress) ToSlice() []ProgressTask { return list } -func (pt ProgressTracker) Progress(lpa *lpastore.Lpa) Progress { +func (pt ProgressTracker) Progress(lpa *lpadata.Lpa) Progress { var labels map[string]string if lpa.IsOrganisationDonor { @@ -91,90 +107,90 @@ func (pt ProgressTracker) Progress(lpa *lpastore.Lpa) Progress { progress := Progress{ isOrganisation: lpa.IsOrganisationDonor, Paid: ProgressTask{ - State: task.StateNotStarted, + State: StateNotStarted, Label: labels["paid"], }, ConfirmedID: ProgressTask{ - State: task.StateNotStarted, + State: StateNotStarted, Label: labels["confirmedID"], }, DonorSigned: ProgressTask{ - State: task.StateNotStarted, + State: StateNotStarted, Label: labels["donorSigned"], }, CertificateProviderSigned: ProgressTask{ - State: task.StateNotStarted, + State: StateNotStarted, Label: labels["certificateProviderSigned"], }, AttorneysSigned: ProgressTask{ - State: task.StateNotStarted, + State: StateNotStarted, Label: labels["attorneysSigned"], }, LpaSubmitted: ProgressTask{ - State: task.StateNotStarted, + State: StateNotStarted, Label: labels["lpaSubmitted"], }, NoticesOfIntentSent: ProgressTask{ - State: task.StateNotStarted, + State: StateNotStarted, }, StatutoryWaitingPeriod: ProgressTask{ - State: task.StateNotStarted, + State: StateNotStarted, Label: labels["statutoryWaitingPeriod"], }, LpaRegistered: ProgressTask{ - State: task.StateNotStarted, + State: StateNotStarted, Label: labels["lpaRegistered"], }, } if lpa.IsOrganisationDonor { - progress.Paid.State = task.StateInProgress + progress.Paid.State = StateInProgress if !lpa.Paid { return progress } - progress.Paid.State = task.StateCompleted - progress.ConfirmedID.State = task.StateInProgress + progress.Paid.State = StateCompleted + progress.ConfirmedID.State = StateInProgress if lpa.Donor.IdentityCheck.CheckedAt.IsZero() { return progress } - progress.ConfirmedID.State = task.StateCompleted - progress.DonorSigned.State = task.StateInProgress + progress.ConfirmedID.State = StateCompleted + progress.DonorSigned.State = StateInProgress if lpa.SignedAt.IsZero() { return progress } } else { - progress.DonorSigned.State = task.StateInProgress + progress.DonorSigned.State = StateInProgress if lpa.SignedAt.IsZero() { return progress } } - progress.DonorSigned.State = task.StateCompleted - progress.CertificateProviderSigned.State = task.StateInProgress + progress.DonorSigned.State = StateCompleted + progress.CertificateProviderSigned.State = StateInProgress if lpa.CertificateProvider.SignedAt.IsZero() { return progress } - progress.CertificateProviderSigned.State = task.StateCompleted - progress.AttorneysSigned.State = task.StateInProgress + progress.CertificateProviderSigned.State = StateCompleted + progress.AttorneysSigned.State = StateInProgress if !lpa.AllAttorneysSigned() { return progress } - progress.AttorneysSigned.State = task.StateCompleted - progress.LpaSubmitted.State = task.StateInProgress + progress.AttorneysSigned.State = StateCompleted + progress.LpaSubmitted.State = StateInProgress if !lpa.Submitted { return progress } - progress.LpaSubmitted.State = task.StateCompleted + progress.LpaSubmitted.State = StateCompleted if lpa.PerfectAt.IsZero() { return progress @@ -183,15 +199,15 @@ func (pt ProgressTracker) Progress(lpa *lpastore.Lpa) Progress { progress.NoticesOfIntentSent.Label = pt.Localizer.Format(labels["noticesOfIntentSent"], map[string]any{ "SentOn": pt.Localizer.FormatDate(lpa.PerfectAt), }) - progress.NoticesOfIntentSent.State = task.StateCompleted - progress.StatutoryWaitingPeriod.State = task.StateInProgress + progress.NoticesOfIntentSent.State = StateCompleted + progress.StatutoryWaitingPeriod.State = StateInProgress if lpa.RegisteredAt.IsZero() { return progress } - progress.StatutoryWaitingPeriod.State = task.StateCompleted - progress.LpaRegistered.State = task.StateCompleted + progress.StatutoryWaitingPeriod.State = StateCompleted + progress.LpaRegistered.State = StateCompleted return progress } diff --git a/internal/page/lpa_progress_tracker_test.go b/internal/task/progress_test.go similarity index 52% rename from internal/page/lpa_progress_tracker_test.go rename to internal/task/progress_test.go index 8c16265c08..2f4f3bc8af 100644 --- a/internal/page/lpa_progress_tracker_test.go +++ b/internal/task/progress_test.go @@ -1,4 +1,4 @@ -package page +package task import ( "testing" @@ -6,8 +6,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid" "github.com/ministryofjustice/opg-modernising-lpa/internal/date" - "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore" - "github.com/ministryofjustice/opg-modernising-lpa/internal/task" + "github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata" "github.com/stretchr/testify/assert" ) @@ -38,7 +37,7 @@ func TestProgressToSlice(t *testing.T) { } }, "donor notices sent": func(p Progress) (Progress, []ProgressTask) { - p.NoticesOfIntentSent.State = task.StateCompleted + p.NoticesOfIntentSent.State = StateCompleted return p, []ProgressTask{ p.DonorSigned, @@ -52,7 +51,7 @@ func TestProgressToSlice(t *testing.T) { }, "organisation notices sent": func(p Progress) (Progress, []ProgressTask) { p.isOrganisation = true - p.NoticesOfIntentSent.State = task.StateCompleted + p.NoticesOfIntentSent.State = StateCompleted return p, []ProgressTask{ p.Paid, @@ -71,15 +70,15 @@ func TestProgressToSlice(t *testing.T) { for name, fn := range testcases { t.Run(name, func(t *testing.T) { progress, slice := fn(Progress{ - Paid: ProgressTask{State: task.StateNotStarted, Label: "Paid translation"}, - ConfirmedID: ProgressTask{State: task.StateNotStarted, Label: "ConfirmedID translation"}, - DonorSigned: ProgressTask{State: task.StateInProgress, Label: "DonorSigned translation"}, - CertificateProviderSigned: ProgressTask{State: task.StateNotStarted, Label: "CertificateProviderSigned translation"}, - AttorneysSigned: ProgressTask{State: task.StateNotStarted, Label: "AttorneysSigned translation"}, - LpaSubmitted: ProgressTask{State: task.StateNotStarted, Label: "LpaSubmitted translation"}, - NoticesOfIntentSent: ProgressTask{State: task.StateNotStarted, Label: "NoticesOfIntentSent translation"}, - StatutoryWaitingPeriod: ProgressTask{State: task.StateNotStarted, Label: "StatutoryWaitingPeriod translation"}, - LpaRegistered: ProgressTask{State: task.StateNotStarted, Label: "LpaRegistered translation"}, + Paid: ProgressTask{State: StateNotStarted, Label: "Paid translation"}, + ConfirmedID: ProgressTask{State: StateNotStarted, Label: "ConfirmedID translation"}, + DonorSigned: ProgressTask{State: StateInProgress, Label: "DonorSigned translation"}, + CertificateProviderSigned: ProgressTask{State: StateNotStarted, Label: "CertificateProviderSigned translation"}, + AttorneysSigned: ProgressTask{State: StateNotStarted, Label: "AttorneysSigned translation"}, + LpaSubmitted: ProgressTask{State: StateNotStarted, Label: "LpaSubmitted translation"}, + NoticesOfIntentSent: ProgressTask{State: StateNotStarted, Label: "NoticesOfIntentSent translation"}, + StatutoryWaitingPeriod: ProgressTask{State: StateNotStarted, Label: "StatutoryWaitingPeriod translation"}, + LpaRegistered: ProgressTask{State: StateNotStarted, Label: "LpaRegistered translation"}, }) assert.Equal(t, slice, progress.ToSlice()) @@ -92,24 +91,24 @@ func TestProgressTrackerProgress(t *testing.T) { uid1 := actoruid.New() uid2 := actoruid.New() initialProgress := Progress{ - Paid: ProgressTask{State: task.StateNotStarted, Label: ""}, - ConfirmedID: ProgressTask{State: task.StateNotStarted, Label: ""}, - DonorSigned: ProgressTask{State: task.StateInProgress, Label: "DonorSigned translation"}, - CertificateProviderSigned: ProgressTask{State: task.StateNotStarted, Label: "CertificateProviderSigned translation"}, - AttorneysSigned: ProgressTask{State: task.StateNotStarted, Label: "AttorneysSigned translation"}, - LpaSubmitted: ProgressTask{State: task.StateNotStarted, Label: "LpaSubmitted translation"}, - StatutoryWaitingPeriod: ProgressTask{State: task.StateNotStarted, Label: "StatutoryWaitingPeriod translation"}, - LpaRegistered: ProgressTask{State: task.StateNotStarted, Label: "LpaRegistered translation"}, + Paid: ProgressTask{State: StateNotStarted, Label: ""}, + ConfirmedID: ProgressTask{State: StateNotStarted, Label: ""}, + DonorSigned: ProgressTask{State: StateInProgress, Label: "DonorSigned translation"}, + CertificateProviderSigned: ProgressTask{State: StateNotStarted, Label: "CertificateProviderSigned translation"}, + AttorneysSigned: ProgressTask{State: StateNotStarted, Label: "AttorneysSigned translation"}, + LpaSubmitted: ProgressTask{State: StateNotStarted, Label: "LpaSubmitted translation"}, + StatutoryWaitingPeriod: ProgressTask{State: StateNotStarted, Label: "StatutoryWaitingPeriod translation"}, + LpaRegistered: ProgressTask{State: StateNotStarted, Label: "LpaRegistered translation"}, } testCases := map[string]struct { - lpa *lpastore.Lpa + lpa *lpadata.Lpa expectedProgress func() Progress setupLocalizer func(*mockLocalizer) }{ "initial state": { - lpa: &lpastore.Lpa{ - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{}}}, + lpa: &lpadata.Lpa{ + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{}}}, }, expectedProgress: func() Progress { return initialProgress @@ -124,9 +123,9 @@ func TestProgressTrackerProgress(t *testing.T) { }, }, "initial state with certificate provider name": { - lpa: &lpastore.Lpa{ - CertificateProvider: lpastore.CertificateProvider{FirstNames: "A", LastName: "B"}, - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{}}}, + lpa: &lpadata.Lpa{ + CertificateProvider: lpadata.CertificateProvider{FirstNames: "A", LastName: "B"}, + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{}}}, }, expectedProgress: func() Progress { return initialProgress @@ -143,15 +142,15 @@ func TestProgressTrackerProgress(t *testing.T) { }, }, "lpa signed": { - lpa: &lpastore.Lpa{ - Donor: lpastore.Donor{FirstNames: "a", LastName: "b"}, - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{}}}, + lpa: &lpadata.Lpa{ + Donor: lpadata.Donor{FirstNames: "a", LastName: "b"}, + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{}}}, SignedAt: lpaSignedAt, }, expectedProgress: func() Progress { progress := initialProgress - progress.DonorSigned.State = task.StateCompleted - progress.CertificateProviderSigned.State = task.StateInProgress + progress.DonorSigned.State = StateCompleted + progress.CertificateProviderSigned.State = StateInProgress return progress }, @@ -165,18 +164,18 @@ func TestProgressTrackerProgress(t *testing.T) { }, }, "certificate provider signed": { - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ Paid: true, - Donor: lpastore.Donor{FirstNames: "a", LastName: "b"}, - CertificateProvider: lpastore.CertificateProvider{SignedAt: lpaSignedAt}, - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{}}}, + Donor: lpadata.Donor{FirstNames: "a", LastName: "b"}, + CertificateProvider: lpadata.CertificateProvider{SignedAt: lpaSignedAt}, + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{}}}, SignedAt: lpaSignedAt, }, expectedProgress: func() Progress { progress := initialProgress - progress.DonorSigned.State = task.StateCompleted - progress.CertificateProviderSigned.State = task.StateCompleted - progress.AttorneysSigned.State = task.StateInProgress + progress.DonorSigned.State = StateCompleted + progress.CertificateProviderSigned.State = StateCompleted + progress.AttorneysSigned.State = StateInProgress return progress }, @@ -190,19 +189,19 @@ func TestProgressTrackerProgress(t *testing.T) { }, }, "attorneys signed": { - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ Paid: true, - Donor: lpastore.Donor{FirstNames: "a", LastName: "b"}, - CertificateProvider: lpastore.CertificateProvider{SignedAt: lpaSignedAt}, - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{UID: uid1, SignedAt: lpaSignedAt.Add(time.Minute)}, {UID: uid2, SignedAt: lpaSignedAt.Add(time.Minute)}}}, + Donor: lpadata.Donor{FirstNames: "a", LastName: "b"}, + CertificateProvider: lpadata.CertificateProvider{SignedAt: lpaSignedAt}, + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{UID: uid1, SignedAt: lpaSignedAt.Add(time.Minute)}, {UID: uid2, SignedAt: lpaSignedAt.Add(time.Minute)}}}, SignedAt: lpaSignedAt, }, expectedProgress: func() Progress { progress := initialProgress - progress.DonorSigned.State = task.StateCompleted - progress.CertificateProviderSigned.State = task.StateCompleted - progress.AttorneysSigned.State = task.StateCompleted - progress.LpaSubmitted.State = task.StateInProgress + progress.DonorSigned.State = StateCompleted + progress.CertificateProviderSigned.State = StateCompleted + progress.AttorneysSigned.State = StateCompleted + progress.LpaSubmitted.State = StateInProgress return progress }, @@ -216,20 +215,20 @@ func TestProgressTrackerProgress(t *testing.T) { }, }, "submitted": { - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ Paid: true, - Donor: lpastore.Donor{FirstNames: "a", LastName: "b"}, - CertificateProvider: lpastore.CertificateProvider{SignedAt: lpaSignedAt}, - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{UID: uid1, SignedAt: lpaSignedAt}}}, + Donor: lpadata.Donor{FirstNames: "a", LastName: "b"}, + CertificateProvider: lpadata.CertificateProvider{SignedAt: lpaSignedAt}, + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{UID: uid1, SignedAt: lpaSignedAt}}}, SignedAt: lpaSignedAt, Submitted: true, }, expectedProgress: func() Progress { progress := initialProgress - progress.DonorSigned.State = task.StateCompleted - progress.CertificateProviderSigned.State = task.StateCompleted - progress.AttorneysSigned.State = task.StateCompleted - progress.LpaSubmitted.State = task.StateCompleted + progress.DonorSigned.State = StateCompleted + progress.CertificateProviderSigned.State = StateCompleted + progress.AttorneysSigned.State = StateCompleted + progress.LpaSubmitted.State = StateCompleted return progress }, @@ -243,24 +242,24 @@ func TestProgressTrackerProgress(t *testing.T) { }, }, "perfect": { - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ Paid: true, - Donor: lpastore.Donor{FirstNames: "a", LastName: "b"}, - CertificateProvider: lpastore.CertificateProvider{SignedAt: lpaSignedAt}, - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{UID: uid1, SignedAt: lpaSignedAt}}}, + Donor: lpadata.Donor{FirstNames: "a", LastName: "b"}, + CertificateProvider: lpadata.CertificateProvider{SignedAt: lpaSignedAt}, + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{UID: uid1, SignedAt: lpaSignedAt}}}, SignedAt: lpaSignedAt, Submitted: true, PerfectAt: lpaSignedAt, }, expectedProgress: func() Progress { progress := initialProgress - progress.DonorSigned.State = task.StateCompleted - progress.CertificateProviderSigned.State = task.StateCompleted - progress.AttorneysSigned.State = task.StateCompleted - progress.LpaSubmitted.State = task.StateCompleted - progress.NoticesOfIntentSent.State = task.StateCompleted + progress.DonorSigned.State = StateCompleted + progress.CertificateProviderSigned.State = StateCompleted + progress.AttorneysSigned.State = StateCompleted + progress.LpaSubmitted.State = StateCompleted + progress.NoticesOfIntentSent.State = StateCompleted progress.NoticesOfIntentSent.Label = "NoticesOfIntentSent translation" - progress.StatutoryWaitingPeriod.State = task.StateInProgress + progress.StatutoryWaitingPeriod.State = StateInProgress return progress }, @@ -280,26 +279,26 @@ func TestProgressTrackerProgress(t *testing.T) { }, }, "registered": { - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ Paid: true, - Donor: lpastore.Donor{FirstNames: "a", LastName: "b"}, + Donor: lpadata.Donor{FirstNames: "a", LastName: "b"}, SignedAt: lpaSignedAt, - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{UID: uid1, SignedAt: lpaSignedAt.Add(time.Minute)}}}, - CertificateProvider: lpastore.CertificateProvider{SignedAt: lpaSignedAt}, + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{UID: uid1, SignedAt: lpaSignedAt.Add(time.Minute)}}}, + CertificateProvider: lpadata.CertificateProvider{SignedAt: lpaSignedAt}, Submitted: true, PerfectAt: lpaSignedAt, RegisteredAt: lpaSignedAt, }, expectedProgress: func() Progress { progress := initialProgress - progress.DonorSigned.State = task.StateCompleted - progress.CertificateProviderSigned.State = task.StateCompleted - progress.AttorneysSigned.State = task.StateCompleted - progress.LpaSubmitted.State = task.StateCompleted - progress.NoticesOfIntentSent.State = task.StateCompleted + progress.DonorSigned.State = StateCompleted + progress.CertificateProviderSigned.State = StateCompleted + progress.AttorneysSigned.State = StateCompleted + progress.LpaSubmitted.State = StateCompleted + progress.NoticesOfIntentSent.State = StateCompleted progress.NoticesOfIntentSent.Label = "NoticesOfIntentSent translation" - progress.StatutoryWaitingPeriod.State = task.StateCompleted - progress.LpaRegistered.State = task.StateCompleted + progress.StatutoryWaitingPeriod.State = StateCompleted + progress.LpaRegistered.State = StateCompleted return progress }, @@ -353,180 +352,180 @@ func TestLpaProgressAsSupporter(t *testing.T) { uid := actoruid.New() initialProgress := Progress{ isOrganisation: true, - Paid: ProgressTask{State: task.StateInProgress, Label: "Paid translation"}, - ConfirmedID: ProgressTask{State: task.StateNotStarted, Label: "ConfirmedID translation"}, - DonorSigned: ProgressTask{State: task.StateNotStarted, Label: "DonorSigned translation"}, - CertificateProviderSigned: ProgressTask{State: task.StateNotStarted, Label: "CertificateProviderSigned translation"}, - AttorneysSigned: ProgressTask{State: task.StateNotStarted, Label: "AttorneysSigned translation"}, - LpaSubmitted: ProgressTask{State: task.StateNotStarted, Label: "LpaSubmitted translation"}, - NoticesOfIntentSent: ProgressTask{State: task.StateNotStarted}, - StatutoryWaitingPeriod: ProgressTask{State: task.StateNotStarted, Label: "StatutoryWaitingPeriod translation"}, - LpaRegistered: ProgressTask{State: task.StateNotStarted, Label: "LpaRegistered translation"}, + Paid: ProgressTask{State: StateInProgress, Label: "Paid translation"}, + ConfirmedID: ProgressTask{State: StateNotStarted, Label: "ConfirmedID translation"}, + DonorSigned: ProgressTask{State: StateNotStarted, Label: "DonorSigned translation"}, + CertificateProviderSigned: ProgressTask{State: StateNotStarted, Label: "CertificateProviderSigned translation"}, + AttorneysSigned: ProgressTask{State: StateNotStarted, Label: "AttorneysSigned translation"}, + LpaSubmitted: ProgressTask{State: StateNotStarted, Label: "LpaSubmitted translation"}, + NoticesOfIntentSent: ProgressTask{State: StateNotStarted}, + StatutoryWaitingPeriod: ProgressTask{State: StateNotStarted, Label: "StatutoryWaitingPeriod translation"}, + LpaRegistered: ProgressTask{State: StateNotStarted, Label: "LpaRegistered translation"}, } testCases := map[string]struct { - lpa *lpastore.Lpa + lpa *lpadata.Lpa expectedProgress func() Progress setupLocalizer func(*mockLocalizer) }{ "initial state": { - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ IsOrganisationDonor: true, - Donor: lpastore.Donor{FirstNames: "a", LastName: "b"}, - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{}}}, + Donor: lpadata.Donor{FirstNames: "a", LastName: "b"}, + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{}}}, }, expectedProgress: func() Progress { return initialProgress }, }, "paid": { - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ IsOrganisationDonor: true, - Donor: lpastore.Donor{FirstNames: "a", LastName: "b"}, - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{}}}, + Donor: lpadata.Donor{FirstNames: "a", LastName: "b"}, + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{}}}, Paid: true, }, expectedProgress: func() Progress { progress := initialProgress - progress.Paid.State = task.StateCompleted - progress.ConfirmedID.State = task.StateInProgress + progress.Paid.State = StateCompleted + progress.ConfirmedID.State = StateInProgress return progress }, }, "confirmed ID": { - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ IsOrganisationDonor: true, - Donor: lpastore.Donor{ + Donor: lpadata.Donor{ FirstNames: "a", LastName: "b", DateOfBirth: dateOfBirth, - IdentityCheck: lpastore.IdentityCheck{CheckedAt: time.Now()}, + IdentityCheck: lpadata.IdentityCheck{CheckedAt: time.Now()}, }, - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{}}}, + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{}}}, Paid: true, }, expectedProgress: func() Progress { progress := initialProgress - progress.Paid.State = task.StateCompleted - progress.ConfirmedID.State = task.StateCompleted - progress.DonorSigned.State = task.StateInProgress + progress.Paid.State = StateCompleted + progress.ConfirmedID.State = StateCompleted + progress.DonorSigned.State = StateInProgress return progress }, }, "donor signed": { - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ IsOrganisationDonor: true, - Donor: lpastore.Donor{ + Donor: lpadata.Donor{ FirstNames: "a", LastName: "b", DateOfBirth: dateOfBirth, - IdentityCheck: lpastore.IdentityCheck{CheckedAt: time.Now()}, + IdentityCheck: lpadata.IdentityCheck{CheckedAt: time.Now()}, }, - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{}}}, + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{}}}, Paid: true, SignedAt: lpaSignedAt, }, expectedProgress: func() Progress { progress := initialProgress - progress.Paid.State = task.StateCompleted - progress.ConfirmedID.State = task.StateCompleted - progress.DonorSigned.State = task.StateCompleted - progress.CertificateProviderSigned.State = task.StateInProgress + progress.Paid.State = StateCompleted + progress.ConfirmedID.State = StateCompleted + progress.DonorSigned.State = StateCompleted + progress.CertificateProviderSigned.State = StateInProgress return progress }, }, "certificate provider signed": { - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ IsOrganisationDonor: true, - Donor: lpastore.Donor{ + Donor: lpadata.Donor{ FirstNames: "a", LastName: "b", DateOfBirth: dateOfBirth, - IdentityCheck: lpastore.IdentityCheck{CheckedAt: time.Now()}, + IdentityCheck: lpadata.IdentityCheck{CheckedAt: time.Now()}, }, - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{}}}, - CertificateProvider: lpastore.CertificateProvider{SignedAt: lpaSignedAt}, + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{}}}, + CertificateProvider: lpadata.CertificateProvider{SignedAt: lpaSignedAt}, Paid: true, SignedAt: lpaSignedAt, }, expectedProgress: func() Progress { progress := initialProgress - progress.Paid.State = task.StateCompleted - progress.ConfirmedID.State = task.StateCompleted - progress.DonorSigned.State = task.StateCompleted - progress.CertificateProviderSigned.State = task.StateCompleted - progress.AttorneysSigned.State = task.StateInProgress + progress.Paid.State = StateCompleted + progress.ConfirmedID.State = StateCompleted + progress.DonorSigned.State = StateCompleted + progress.CertificateProviderSigned.State = StateCompleted + progress.AttorneysSigned.State = StateInProgress return progress }, }, "attorneys signed": { - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ IsOrganisationDonor: true, - Donor: lpastore.Donor{ + Donor: lpadata.Donor{ FirstNames: "a", LastName: "b", DateOfBirth: dateOfBirth, - IdentityCheck: lpastore.IdentityCheck{CheckedAt: time.Now()}, + IdentityCheck: lpadata.IdentityCheck{CheckedAt: time.Now()}, }, - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{UID: uid, SignedAt: lpaSignedAt.Add(time.Minute)}}}, - CertificateProvider: lpastore.CertificateProvider{SignedAt: lpaSignedAt}, + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{UID: uid, SignedAt: lpaSignedAt.Add(time.Minute)}}}, + CertificateProvider: lpadata.CertificateProvider{SignedAt: lpaSignedAt}, Paid: true, SignedAt: lpaSignedAt, }, expectedProgress: func() Progress { progress := initialProgress - progress.Paid.State = task.StateCompleted - progress.ConfirmedID.State = task.StateCompleted - progress.DonorSigned.State = task.StateCompleted - progress.CertificateProviderSigned.State = task.StateCompleted - progress.AttorneysSigned.State = task.StateCompleted - progress.LpaSubmitted.State = task.StateInProgress + progress.Paid.State = StateCompleted + progress.ConfirmedID.State = StateCompleted + progress.DonorSigned.State = StateCompleted + progress.CertificateProviderSigned.State = StateCompleted + progress.AttorneysSigned.State = StateCompleted + progress.LpaSubmitted.State = StateInProgress return progress }, }, "submitted": { - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ IsOrganisationDonor: true, - Donor: lpastore.Donor{ + Donor: lpadata.Donor{ FirstNames: "a", LastName: "b", DateOfBirth: dateOfBirth, - IdentityCheck: lpastore.IdentityCheck{CheckedAt: time.Now()}, + IdentityCheck: lpadata.IdentityCheck{CheckedAt: time.Now()}, }, - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{UID: uid, SignedAt: lpaSignedAt.Add(time.Minute)}}}, - CertificateProvider: lpastore.CertificateProvider{SignedAt: lpaSignedAt}, + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{UID: uid, SignedAt: lpaSignedAt.Add(time.Minute)}}}, + CertificateProvider: lpadata.CertificateProvider{SignedAt: lpaSignedAt}, Paid: true, SignedAt: lpaSignedAt, Submitted: true, }, expectedProgress: func() Progress { progress := initialProgress - progress.Paid.State = task.StateCompleted - progress.ConfirmedID.State = task.StateCompleted - progress.DonorSigned.State = task.StateCompleted - progress.CertificateProviderSigned.State = task.StateCompleted - progress.AttorneysSigned.State = task.StateCompleted - progress.LpaSubmitted.State = task.StateCompleted + progress.Paid.State = StateCompleted + progress.ConfirmedID.State = StateCompleted + progress.DonorSigned.State = StateCompleted + progress.CertificateProviderSigned.State = StateCompleted + progress.AttorneysSigned.State = StateCompleted + progress.LpaSubmitted.State = StateCompleted return progress }, }, "perfect": { - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ IsOrganisationDonor: true, - Donor: lpastore.Donor{ + Donor: lpadata.Donor{ FirstNames: "a", LastName: "b", DateOfBirth: dateOfBirth, - IdentityCheck: lpastore.IdentityCheck{CheckedAt: time.Now()}, + IdentityCheck: lpadata.IdentityCheck{CheckedAt: time.Now()}, }, - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{UID: uid, SignedAt: lpaSignedAt.Add(time.Minute)}}}, - CertificateProvider: lpastore.CertificateProvider{SignedAt: lpaSignedAt}, + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{UID: uid, SignedAt: lpaSignedAt.Add(time.Minute)}}}, + CertificateProvider: lpadata.CertificateProvider{SignedAt: lpaSignedAt}, Paid: true, SignedAt: lpaSignedAt, Submitted: true, @@ -534,15 +533,15 @@ func TestLpaProgressAsSupporter(t *testing.T) { }, expectedProgress: func() Progress { progress := initialProgress - progress.Paid.State = task.StateCompleted - progress.ConfirmedID.State = task.StateCompleted - progress.DonorSigned.State = task.StateCompleted - progress.CertificateProviderSigned.State = task.StateCompleted - progress.AttorneysSigned.State = task.StateCompleted - progress.LpaSubmitted.State = task.StateCompleted + progress.Paid.State = StateCompleted + progress.ConfirmedID.State = StateCompleted + progress.DonorSigned.State = StateCompleted + progress.CertificateProviderSigned.State = StateCompleted + progress.AttorneysSigned.State = StateCompleted + progress.LpaSubmitted.State = StateCompleted progress.NoticesOfIntentSent.Label = "NoticesOfIntentSent translation" - progress.NoticesOfIntentSent.State = task.StateCompleted - progress.StatutoryWaitingPeriod.State = task.StateInProgress + progress.NoticesOfIntentSent.State = StateCompleted + progress.StatutoryWaitingPeriod.State = StateInProgress return progress }, @@ -556,16 +555,16 @@ func TestLpaProgressAsSupporter(t *testing.T) { }, }, "registered": { - lpa: &lpastore.Lpa{ + lpa: &lpadata.Lpa{ IsOrganisationDonor: true, - Donor: lpastore.Donor{ + Donor: lpadata.Donor{ FirstNames: "a", LastName: "b", DateOfBirth: dateOfBirth, - IdentityCheck: lpastore.IdentityCheck{CheckedAt: time.Now()}, + IdentityCheck: lpadata.IdentityCheck{CheckedAt: time.Now()}, }, - Attorneys: lpastore.Attorneys{Attorneys: []lpastore.Attorney{{UID: uid, SignedAt: lpaSignedAt.Add(time.Minute)}}}, - CertificateProvider: lpastore.CertificateProvider{SignedAt: lpaSignedAt}, + Attorneys: lpadata.Attorneys{Attorneys: []lpadata.Attorney{{UID: uid, SignedAt: lpaSignedAt.Add(time.Minute)}}}, + CertificateProvider: lpadata.CertificateProvider{SignedAt: lpaSignedAt}, Paid: true, SignedAt: lpaSignedAt, Submitted: true, @@ -574,16 +573,16 @@ func TestLpaProgressAsSupporter(t *testing.T) { }, expectedProgress: func() Progress { progress := initialProgress - progress.Paid.State = task.StateCompleted - progress.ConfirmedID.State = task.StateCompleted - progress.DonorSigned.State = task.StateCompleted - progress.CertificateProviderSigned.State = task.StateCompleted - progress.AttorneysSigned.State = task.StateCompleted - progress.LpaSubmitted.State = task.StateCompleted + progress.Paid.State = StateCompleted + progress.ConfirmedID.State = StateCompleted + progress.DonorSigned.State = StateCompleted + progress.CertificateProviderSigned.State = StateCompleted + progress.AttorneysSigned.State = StateCompleted + progress.LpaSubmitted.State = StateCompleted progress.NoticesOfIntentSent.Label = "NoticesOfIntentSent translation" - progress.NoticesOfIntentSent.State = task.StateCompleted - progress.StatutoryWaitingPeriod.State = task.StateCompleted - progress.LpaRegistered.State = task.StateCompleted + progress.NoticesOfIntentSent.State = StateCompleted + progress.StatutoryWaitingPeriod.State = StateCompleted + progress.LpaRegistered.State = StateCompleted return progress }, diff --git a/internal/templatefn/fn.go b/internal/templatefn/fn.go index 753754e600..0a1febc14c 100644 --- a/internal/templatefn/fn.go +++ b/internal/templatefn/fn.go @@ -17,6 +17,7 @@ import ( "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/lpastore/lpadata" ) // Globals contains values that are used in templates and do not change as the @@ -333,8 +334,8 @@ func formatPhone(s string) string { type attorneySummaryData struct { App appcontext.Data CanChange bool - TrustCorporation lpastore.TrustCorporation - Attorneys []lpastore.Attorney + TrustCorporation lpadata.TrustCorporation + Attorneys []lpadata.Attorney Link attorneySummaryDataLinks HeadingLevel int } @@ -352,12 +353,12 @@ func listAttorneys(app appcontext.Data, attorneys any, attorneyType string, head } switch v := attorneys.(type) { - case lpastore.Attorneys: + case lpadata.Attorneys: data.Attorneys = v.Attorneys data.TrustCorporation = v.TrustCorporation case donordata.Attorneys: for _, a := range v.Attorneys { - data.Attorneys = append(data.Attorneys, lpastore.Attorney{ + data.Attorneys = append(data.Attorneys, lpadata.Attorney{ UID: a.UID, FirstNames: a.FirstNames, LastName: a.LastName, @@ -368,7 +369,7 @@ func listAttorneys(app appcontext.Data, attorneys any, attorneyType string, head } if t := v.TrustCorporation; t.Name != "" { - data.TrustCorporation = lpastore.TrustCorporation{ + data.TrustCorporation = lpadata.TrustCorporation{ UID: t.UID, Name: t.Name, CompanyNumber: t.CompanyNumber, @@ -478,7 +479,7 @@ func notificationBanner(app appcontext.Data, title string, content template.HTML type lpaDecisionsData struct { App appcontext.Data - Lpa *lpastore.Lpa + Lpa *lpadata.Lpa CanChange bool } @@ -489,7 +490,7 @@ func lpaDecisions(app appcontext.Data, lpa any, canChange bool) lpaDecisionsData } switch v := lpa.(type) { - case *lpastore.Lpa: + case *lpadata.Lpa: data.Lpa = v case *donordata.Provided: data.Lpa = lpastore.FromDonorProvidedDetails(v) diff --git a/internal/templatefn/fn_test.go b/internal/templatefn/fn_test.go index e71d18a632..db109328be 100644 --- a/internal/templatefn/fn_test.go +++ b/internal/templatefn/fn_test.go @@ -14,7 +14,7 @@ import ( "github.com/ministryofjustice/opg-modernising-lpa/internal/donor" "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/lpastore/lpadata" "github.com/stretchr/testify/assert" ) @@ -343,11 +343,11 @@ func TestListAttorneysWithAttorneys(t *testing.T) { RemoveTrustCorporation: donor.PathRemoveReplacementTrustCorporation.Format("lpa-id") + "?from=/here", } - lpaStoreAttorneys := []lpastore.Attorney{ + lpaStoreAttorneys := []lpadata.Attorney{ {UID: uid1}, {UID: uid2}, } - lpaStoreTrustCorporation := lpastore.TrustCorporation{Name: "a"} + lpaStoreTrustCorporation := lpadata.TrustCorporation{Name: "a"} actorAttorneys := []donordata.Attorney{ {UID: uid1}, @@ -361,7 +361,7 @@ func TestListAttorneysWithAttorneys(t *testing.T) { attorneyType string }{ "lpastore": { - attorneys: lpastore.Attorneys{ + attorneys: lpadata.Attorneys{ Attorneys: lpaStoreAttorneys, TrustCorporation: lpaStoreTrustCorporation, }, @@ -391,7 +391,7 @@ func TestListAttorneysWithAttorneys(t *testing.T) { }, }, "lpastore replacement": { - attorneys: lpastore.Attorneys{ + attorneys: lpadata.Attorneys{ Attorneys: lpaStoreAttorneys, TrustCorporation: lpaStoreTrustCorporation, }, @@ -552,9 +552,9 @@ func TestLpaDecisions(t *testing.T) { assert.Equal(t, lpaDecisionsData{ App: app, - Lpa: &lpastore.Lpa{}, + Lpa: &lpadata.Lpa{}, CanChange: true, - }, lpaDecisions(app, &lpastore.Lpa{}, true)) + }, lpaDecisions(app, &lpadata.Lpa{}, true)) } func TestLpaDecisionsWithDonorProvidedDetails(t *testing.T) { @@ -562,7 +562,7 @@ func TestLpaDecisionsWithDonorProvidedDetails(t *testing.T) { assert.Equal(t, lpaDecisionsData{ App: app, - Lpa: &lpastore.Lpa{}, + Lpa: &lpadata.Lpa{}, CanChange: true, }, lpaDecisions(app, &donordata.Provided{}, true)) }