Skip to content
Open
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
febe0f2
CROSSLINK-264 ask-retry action
adamdickmeiss May 29, 2026
ac9170a
RETRY_REQUESTED state
adamdickmeiss May 29, 2026
d2f057b
Merge branch 'main' into CROSSLINK-264-ask-retry-action
adamdickmeiss Jun 1, 2026
67708e4
Update state model for retry
adamdickmeiss Jun 1, 2026
fa8eb8c
Potential fix for pull request finding
adamdickmeiss Jun 1, 2026
920a937
Potential fix for pull request finding
adamdickmeiss Jun 1, 2026
ddb2333
update returnables.json
adamdickmeiss Jun 1, 2026
4f1c545
Implement ask-retry
adamdickmeiss Jun 2, 2026
e7bf570
Create retry-conditonal event
adamdickmeiss Jun 2, 2026
524a26a
illmock: RETRY:NOTFOUNDASCITED
adamdickmeiss Jun 2, 2026
9529072
reject-retry
adamdickmeiss Jun 2, 2026
0b7be58
illmock: sets DeliveryInfo.ItemId on RETRY:NOTFOUNDASCITED
adamdickmeiss Jun 2, 2026
d1f9912
acceptRetry begin
adamdickmeiss Jun 2, 2026
95586a0
Add {next,prev}_req_id
adamdickmeiss Jun 2, 2026
cb56c77
Merge remote-tracking branch 'origin/main' into CROSSLINK-264-ask-ret…
adamdickmeiss Jun 4, 2026
d6da9bb
Clone patronrequest WIP
adamdickmeiss Jun 8, 2026
217bfb7
lint
adamdickmeiss Jun 8, 2026
7544ce8
Potential fix for pull request finding
adamdickmeiss Jun 8, 2026
eb34de0
Potential fix for pull request finding
adamdickmeiss Jun 8, 2026
3bc091f
Potential fix for pull request finding
adamdickmeiss Jun 8, 2026
3f13e33
Potential fix for pull request finding
adamdickmeiss Jun 8, 2026
fdeb194
has_internal_note
adamdickmeiss Jun 8, 2026
317fcb3
update
adamdickmeiss Jun 8, 2026
a78c2a1
Merge remote-tracking branch 'origin/main' into CROSSLINK-264-ask-ret…
adamdickmeiss Jun 8, 2026
ff241ea
migrations update
adamdickmeiss Jun 8, 2026
846bac8
retry_item_id persisted
adamdickmeiss Jun 8, 2026
975772f
Merge branch 'main' into CROSSLINK-264-ask-retry-action
adamdickmeiss Jun 12, 2026
614664c
migrations merge
adamdickmeiss Jun 12, 2026
b281c10
retryItemId in API structure
adamdickmeiss Jun 14, 2026
780e65a
Set new patron request fields one by one
adamdickmeiss Jun 14, 2026
776c9c2
unfilled as last; fix SupplierUniqueRecordId overwrite
adamdickmeiss Jun 15, 2026
d742ac3
Revert go.work.sum
adamdickmeiss Jun 15, 2026
6cbd997
Use definition
adamdickmeiss Jun 15, 2026
a13ff15
ItemID
adamdickmeiss Jun 15, 2026
aa1678c
Remove Info log
adamdickmeiss Jun 15, 2026
48216b6
retry_bib_info
adamdickmeiss Jun 17, 2026
7db5fe9
Unused function
adamdickmeiss Jun 17, 2026
da4432d
Merge remote-tracking branch 'origin/main' into CROSSLINK-264-ask-ret…
adamdickmeiss Jun 19, 2026
4bb42cf
Merge remote-tracking branch 'origin/main' into CROSSLINK-264-ask-ret…
adamdickmeiss Jun 19, 2026
7c11f1e
Merge remote-tracking branch 'origin/main' into CROSSLINK-264-ask-ret…
adamdickmeiss Jun 19, 2026
8b06ced
Create as new; run actions
adamdickmeiss Jun 19, 2026
5fb2369
check err
adamdickmeiss Jun 19, 2026
ee67aa8
one transaction
adamdickmeiss Jun 19, 2026
4063416
slightly simpler
adamdickmeiss Jun 19, 2026
2906253
Wait longer for Postgres containers to start
adamdickmeiss Jun 19, 2026
22d8fcd
IllRequest headers align
adamdickmeiss Jun 19, 2026
a8fd1f6
rename
adamdickmeiss Jun 19, 2026
7a46c1c
CP
adamdickmeiss Jun 19, 2026
7d40955
CP
adamdickmeiss Jun 19, 2026
0fbc59f
ask-retry also in WILL_SUPPLY state
adamdickmeiss Jun 19, 2026
c959dc0
Failure on original PR when actions fail on retry PR
adamdickmeiss Jun 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion broker/cmd/archive/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestMain(m *testing.M) {
postgres.WithPassword("crosslink"),
testcontainers.WithWaitStrategy(
wait.ForLog("database system is ready to accept connections").
WithOccurrence(2).WithStartupTimeout(5*time.Second)),
WithOccurrence(2).WithStartupTimeout(30*time.Second)),
)
test.Expect(err, "failed to start db container")

Expand Down
2 changes: 1 addition & 1 deletion broker/cmd/broker/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestMain(m *testing.M) {
postgres.WithPassword("crosslink"),
testcontainers.WithWaitStrategy(
wait.ForLog("database system is ready to accept connections").
WithOccurrence(2).WithStartupTimeout(5*time.Second)),
WithOccurrence(2).WithStartupTimeout(30*time.Second)),
)
test.Expect(err, "failed to start db container")

Expand Down
11 changes: 11 additions & 0 deletions broker/handler/iso18626-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,17 @@ func handleRetryRequest(ctx common.ExtendedContext, request *iso18626.Request, r
illTrans.Timestamp = timestamp

_, err = repo.SaveIllTransaction(ctx, ill_db.SaveIllTransactionParams(illTrans))
if err != nil {
return err
}

// Keep the selected supplier's LocalID in sync with the updated SupplierUniqueRecordId.
// createRequestMessage overwrites BibliographicInfo.SupplierUniqueRecordId with LocalID, so
// without this update the stale LocalID from the original holdings lookup would be sent.
if newLocalId := request.BibliographicInfo.SupplierUniqueRecordId; newLocalId != "" {
selSup.LocalID = pgtype.Text{String: newLocalId, Valid: true}
_, err = repo.SaveLocatedSupplier(ctx, ill_db.SaveLocatedSupplierParams(selSup))
}
return err
})
return id, err
Expand Down
30 changes: 30 additions & 0 deletions broker/migrations/046_add_patron_links.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
DROP VIEW IF EXISTS patron_request_search_view;
ALTER TABLE patron_request DROP COLUMN next_req_id;
ALTER TABLE patron_request DROP COLUMN prev_req_id;
ALTER TABLE patron_request DROP COLUMN retry_bib_info;

CREATE VIEW patron_request_search_view AS
Comment thread
adamdickmeiss marked this conversation as resolved.
SELECT
pr.*,
EXISTS (
SELECT 1
FROM notification n
WHERE n.pr_id = pr.id
) AS has_notification,
EXISTS (
SELECT 1
FROM notification n
WHERE n.pr_id = pr.id and cost is not null
) AS has_cost,
(unread.unread_notifications_count > 0) AS has_unread_notification,
(pr.internal_note IS NOT NULL AND btrim(pr.internal_note) <> '') AS has_internal_note,
pr.ill_request -> 'serviceInfo' ->> 'serviceType' AS service_type,
pr.ill_request -> 'serviceInfo' -> 'serviceLevel' ->> '#text' AS service_level,
Comment thread
adamdickmeiss marked this conversation as resolved.
immutable_to_timestamp(pr.ill_request -> 'serviceInfo' ->> 'needBeforeDate') AS needed_at,
unread.unread_notifications_count AS unread_notifications_count
FROM patron_request pr
LEFT JOIN LATERAL (
SELECT COUNT(*) AS unread_notifications_count
FROM notification n
Comment thread
adamdickmeiss marked this conversation as resolved.
WHERE n.pr_id = pr.id and n.acknowledged_at is null
) unread ON true;
31 changes: 31 additions & 0 deletions broker/migrations/046_add_patron_links.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
ALTER TABLE patron_request ADD COLUMN next_req_id VARCHAR;
ALTER TABLE patron_request ADD COLUMN prev_req_id VARCHAR;
ALTER TABLE patron_request ADD COLUMN retry_bib_info JSONB;

DROP VIEW IF EXISTS patron_request_search_view;

CREATE VIEW patron_request_search_view AS
SELECT
pr.*,
Comment thread
adamdickmeiss marked this conversation as resolved.
EXISTS (
SELECT 1
FROM notification n
WHERE n.pr_id = pr.id
) AS has_notification,
EXISTS (
SELECT 1
FROM notification n
WHERE n.pr_id = pr.id and cost is not null
) AS has_cost,
(unread.unread_notifications_count > 0) AS has_unread_notification,
(pr.internal_note IS NOT NULL AND btrim(pr.internal_note) <> '') AS has_internal_note,
pr.ill_request -> 'serviceInfo' ->> 'serviceType' AS service_type,
pr.ill_request -> 'serviceInfo' -> 'serviceLevel' ->> '#text' AS service_level,
immutable_to_timestamp(pr.ill_request -> 'serviceInfo' ->> 'needBeforeDate') AS needed_at,
unread.unread_notifications_count AS unread_notifications_count
FROM patron_request pr
LEFT JOIN LATERAL (
SELECT COUNT(*) AS unread_notifications_count
FROM notification n
WHERE n.pr_id = pr.id and n.acknowledged_at is null
) unread ON true;
9 changes: 9 additions & 0 deletions broker/oapi/open-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,15 @@ components:
internalNote:
type: string
description: Staff-only internal note, local to this request and never shared with peers
nextReqId:
type: string
description: ID of the next patron request in the sequence
prevReqId:
type: string
description: ID of the previous patron request in the sequence
retryBibInfo:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should use a proper Go type in the API model via the overlay and avoid going through the map

type: object
description: Bibliographic information for the item to retry the request for when in retrying state
required:
- id
- createdAt
Expand Down
18 changes: 18 additions & 0 deletions broker/patron_request/api/api-handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,9 @@ func toApiPatronRequest(r *http.Request, request pr_db.PatronRequestSearchView)
EventsLink: eventsLink,
TerminalState: request.TerminalState,
InternalNote: toString(request.InternalNote),
NextReqId: toString(request.NextReqID),
PrevReqId: toString(request.PrevReqID),
RetryBibInfo: bibInfoToMap(request.RetryBibInfo),
}
if request.UpdatedAt.Valid {
pr.UpdatedAt = &request.UpdatedAt.Time
Expand All @@ -982,6 +985,21 @@ func toString(text pgtype.Text) *string {
return value
}

func bibInfoToMap(info *iso18626.BibliographicInfo) *map[string]interface{} {
if info == nil {
return nil
}
b, err := json.Marshal(info)
if err != nil {
return nil
}
var m map[string]interface{}
if err := json.Unmarshal(b, &m); err != nil {
return nil
}
return &m
}

func (a *PatronRequestApiHandler) parseAndValidateIllRequest(
ctx common.ExtendedContext,
request *proapi.CreatePatronRequest,
Expand Down
3 changes: 3 additions & 0 deletions broker/patron_request/db/prcql.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ func (q *Queries) ListPatronRequestsCql(ctx context.Context, db DBTX, arg ListPa
&i.PatronRequestSearchView.UpdatedAt,
&i.PatronRequestSearchView.IllResponse,
&i.PatronRequestSearchView.InternalNote,
&i.PatronRequestSearchView.NextReqID,
&i.PatronRequestSearchView.PrevReqID,
&i.PatronRequestSearchView.RetryBibInfo,
&i.PatronRequestSearchView.HasNotification,
&i.PatronRequestSearchView.HasCost,
&i.PatronRequestSearchView.HasUnreadNotification,
Expand Down
114 changes: 107 additions & 7 deletions broker/patron_request/service/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ type PatronRequestActionService struct {
}

type actionExecutionResult struct {
status events.EventStatus
result *events.EventResult
pr pr_db.PatronRequest
status events.EventStatus
result *events.EventResult
pr pr_db.PatronRequest
retryPr pr_db.PatronRequest
}

type autoActionFailure struct {
Expand All @@ -51,6 +52,8 @@ type actionParams struct {
Cost *float64 `json:"cost,omitempty"`
Currency string `json:"currency,omitempty"`
ReasonUnfilled string `json:"reasonUnfilled,omitempty"`
ReasonRetry string `json:"reasonRetry,omitempty"`
ItemID string `json:"itemId,omitempty"`
}
Comment thread
adamdickmeiss marked this conversation as resolved.

func CreatePatronRequestActionService(prRepo pr_db.PrRepo, eventBus events.EventBus, iso18626Handler handler.Iso18626HandlerInterface, lmsCreator lms.LmsCreator) *PatronRequestActionService {
Expand Down Expand Up @@ -186,12 +189,30 @@ func (a *PatronRequestActionService) finalizeActionExecution(ctx common.Extended
stateChanged = true
}

var err error
updatedPr, err = a.prRepo.UpdatePatronRequest(ctx, pr_db.UpdatePatronRequestParams(updatedPr))
var retryPr pr_db.PatronRequest
err := a.prRepo.WithTxFunc(ctx, func(repo pr_db.PrRepo) error {
var err error
if execResult.retryPr.ID != "" {
retryPr, err = repo.CreatePatronRequest(ctx, pr_db.CreatePatronRequestParams(execResult.retryPr))
if err != nil {
return fmt.Errorf("create retry patron request: %w", err)
}
}
updatedPr, err = repo.UpdatePatronRequest(ctx, pr_db.UpdatePatronRequestParams(updatedPr))
if err != nil {
return fmt.Errorf("update patron request: %w", err)
}
return nil
})
if err != nil {
return logActionErrorAndReturnResult(ctx, "failed to update patron request", err)
return logActionErrorAndReturnResult(ctx, "failed to persist patron request", err)
}
if retryPr.ID != "" {
err := a.RunAutoActionsOnStateEntry(ctx, retryPr, &event.ID, event.EventData.User)
if err != nil {
return logActionErrorAndReturnResult(ctx, "failed to run auto actions on state entry", err)
}
}

if stateChanged {
err := a.RunAutoActionsOnStateEntry(ctx, updatedPr, &event.ID, event.EventData.User)
if err != nil {
Expand Down Expand Up @@ -314,6 +335,10 @@ func (a *PatronRequestActionService) handleBorrowingAction(ctx common.ExtendedCo
return a.acceptConditionBorrowingRequest(ctx, pr)
case BorrowerActionRejectCondition:
return a.rejectConditionBorrowingRequest(ctx, pr)
case BorrowerActionRejectRetry:
return a.rejectRetryBorrowingRequest(pr)
case BorrowerActionAcceptRetry:
return a.acceptRetryBorrowingRequest(ctx, pr)
default:
status, result := logActionErrorAndReturnResult(ctx, "borrower action "+string(action)+" is not implemented yet", errors.New("invalid action"))
return actionExecutionResult{status: status, result: result, pr: pr}
Expand Down Expand Up @@ -368,6 +393,8 @@ func (a *PatronRequestActionService) handleLenderAction(ctx common.ExtendedConte
return a.markReceivedLenderRequest(ctx, pr, lms)
case LenderActionAcceptCancel:
return a.acceptCancelLenderRequest(ctx, pr)
case LenderActionAskRetry:
return a.askRetryLenderRequest(ctx, pr, params)
default:
status, result := logActionErrorAndReturnResult(ctx, "lender action "+string(action)+" is not implemented yet", errors.New("invalid action"))
return actionExecutionResult{status: status, result: result, pr: pr}
Expand Down Expand Up @@ -567,6 +594,53 @@ func (a *PatronRequestActionService) rejectConditionBorrowingRequest(ctx common.
return actionExecutionResult{status: events.EventStatusSuccess, result: &result, pr: pr}
}

func (a *PatronRequestActionService) rejectRetryBorrowingRequest(pr pr_db.PatronRequest) actionExecutionResult {
result := events.EventResult{}
return actionExecutionResult{status: events.EventStatusSuccess, result: &result, pr: pr}
}

func (a *PatronRequestActionService) acceptRetryBorrowingRequest(ctx common.ExtendedContext, pr pr_db.PatronRequest) actionExecutionResult {
result := events.EventResult{}

retryPr := pr_db.PatronRequest{}
retryPr.Side = pr.Side
retryPr.RequesterSymbol = pr.RequesterSymbol
retryPr.SupplierSymbol = pr.SupplierSymbol
retryPr.Patron = pr.Patron
retryPr.Tenant = pr.Tenant
var err error
retryPr.IllRequest, err = deepCopyISO18626Request(pr.IllRequest)
if err != nil {
status, result := logActionErrorAndReturnResult(ctx, "failed to clone IllRequest for retry", err)
return actionExecutionResult{status: status, result: result, pr: pr}
}
retryPr.State = BorrowerStateNew
retryPr.TerminalState = false
retryPr.ID = uuid.NewString()
retryPr.RequesterReqID = getDbTextPtr(&retryPr.ID)
retryPr.CreatedAt = pgtype.Timestamp{Valid: true, Time: time.Now()}
retryPr.IllRequest.Header.RequestingAgencyRequestId = retryPr.ID
retryPr.IllRequest.Header.Timestamp = utils.XSDDateTime{Time: retryPr.CreatedAt.Time}
retryPr.PrevReqID = getDbTextPtr(&pr.ID)
retryPr.Language = pr.Language
retryPr.Items = []pr_db.PrItem{}
retryPr.RetryBibInfo = nil
if pr.RetryBibInfo != nil {
// only take selected fields from retry bib info to allow for corrections without affecting other fields
if pr.RetryBibInfo.SupplierUniqueRecordId != "" {
retryPr.IllRequest.BibliographicInfo.SupplierUniqueRecordId = pr.RetryBibInfo.SupplierUniqueRecordId
}
if pr.RetryBibInfo.Title != "" {
retryPr.IllRequest.BibliographicInfo.Title = pr.RetryBibInfo.Title
}
if pr.RetryBibInfo.Author != "" {
retryPr.IllRequest.BibliographicInfo.Author = pr.RetryBibInfo.Author
}
}
pr.NextReqID = getDbTextPtr(&retryPr.ID)
return actionExecutionResult{status: events.EventStatusSuccess, result: &result, pr: pr, retryPr: retryPr}
}

func (a *PatronRequestActionService) validateLenderRequest(ctx common.ExtendedContext, pr pr_db.PatronRequest, lms lms.LmsAdapter) actionExecutionResult {
institutionalPatron := lms.InstitutionalPatron(pr.RequesterSymbol.String)
_, err := lms.LookupUser(institutionalPatron)
Expand Down Expand Up @@ -811,6 +885,32 @@ func (a *PatronRequestActionService) acceptCancelLenderRequest(ctx common.Extend
return a.checkSupplyingResponse(status, eventResult, &result, httpStatus, pr)
}

func (a *PatronRequestActionService) askRetryLenderRequest(ctx common.ExtendedContext, pr pr_db.PatronRequest, params actionParams) actionExecutionResult {
var deliveryInfo *iso18626.DeliveryInfo
if params.ItemID != "" {
deliveryInfo = &iso18626.DeliveryInfo{
ItemId: params.ItemID,
}
}
reasonRetry := string(iso18626.ReasonRetryNotFoundAsCited)
if params.ReasonRetry != "" {
reasonRetry = params.ReasonRetry
}
result := events.EventResult{}
status, eventResult, httpStatus := a.sendSupplyingAgencyMessage(ctx, pr, &result,
iso18626.MessageInfo{
ReasonRetry: &iso18626.TypeSchemeValuePair{Text: reasonRetry},
ReasonForMessage: iso18626.TypeReasonForMessageStatusChange,
Note: params.Note,
},
iso18626.StatusInfo{Status: iso18626.TypeStatusRetryPossible},
deliveryInfo)
if result.OutgoingMessage.SupplyingAgencyMessage != nil {
setSupplierMessage(*result.OutgoingMessage.SupplyingAgencyMessage, &pr)
}
return a.checkSupplyingResponse(status, eventResult, &result, httpStatus, pr)
}

func (a *PatronRequestActionService) checkSupplyingResponse(status events.EventStatus, eventResult *events.EventResult, result *events.EventResult, httpStatus *int, pr pr_db.PatronRequest) actionExecutionResult {
if httpStatus == nil {
return actionExecutionResult{status: status, result: eventResult, pr: pr}
Expand Down
14 changes: 8 additions & 6 deletions broker/patron_request/service/action_mapping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ func TestNewReturnableActionMapping(t *testing.T) {
BorrowerStateReceived: {{actionName: BorrowerActionCheckOut}},
BorrowerStateCheckedOut: {{actionName: BorrowerActionCheckIn}},
BorrowerStateCheckedIn: {{actionName: BorrowerActionShipReturn}},
BorrowerStateRetryPending: {{actionName: BorrowerActionAcceptRetry}, {actionName: BorrowerActionRejectRetry}},
}

lenderStateActionMapping := map[pr_db.PatronRequestState][]PatronRequestAction{
LenderStateNew: {{actionName: LenderActionValidate, auto: true}},
LenderStateValidated: {{actionName: LenderActionWillSupply, auto: true}, {actionName: LenderActionCannotSupply}, {actionName: LenderActionAddCondition}},
LenderStateWillSupply: {{actionName: LenderActionAddCondition}, {actionName: LenderActionShip}, {actionName: LenderActionCannotSupply}},
LenderStateValidated: {{actionName: LenderActionWillSupply, auto: true}, {actionName: LenderActionCannotSupply}, {actionName: LenderActionAddCondition}, {actionName: LenderActionAskRetry}},
LenderStateWillSupply: {{actionName: LenderActionAddCondition}, {actionName: LenderActionShip}, {actionName: LenderActionCannotSupply}, {actionName: LenderActionAskRetry}},
LenderStateConditionPending: {{actionName: LenderActionAddCondition}, {actionName: LenderActionCannotSupply}},
LenderStateConditionAccepted: {{actionName: LenderActionAddCondition}, {actionName: LenderActionShip}, {actionName: LenderActionCannotSupply}},
LenderStateShippedReturn: {{actionName: LenderActionMarkReceived}},
Expand All @@ -40,9 +41,9 @@ func TestNewReturnableActionMapping(t *testing.T) {

assert.NotNil(t, returnableActionMapping)

mapCompare(t, returnableActionMapping.borrowerStateActionMapping, borrowerStateActionMapping)
mapCompare(t, borrowerStateActionMapping, returnableActionMapping.borrowerStateActionMapping)

mapCompare(t, returnableActionMapping.lenderStateActionMapping, lenderStateActionMapping)
mapCompare(t, lenderStateActionMapping, returnableActionMapping.lenderStateActionMapping)
}

var actionMappingService = ActionMappingService{}
Expand Down Expand Up @@ -93,7 +94,7 @@ func TestGetActionsForPatronRequest(t *testing.T) {
listCompare(t, []pr_db.PatronRequestAction{BorrowerActionAcceptCondition, BorrowerActionRejectCondition}, mapping.GetActionsForPatronRequest(pr_db.PatronRequest{Side: SideBorrowing, State: BorrowerStateConditionPending}))

// Lender
listCompare(t, []pr_db.PatronRequestAction{LenderActionAddCondition, LenderActionCannotSupply, LenderActionShip}, mapping.GetActionsForPatronRequest(pr_db.PatronRequest{Side: SideLending, State: LenderStateWillSupply}))
listCompare(t, []pr_db.PatronRequestAction{LenderActionAddCondition, LenderActionCannotSupply, LenderActionShip, LenderActionAskRetry}, mapping.GetActionsForPatronRequest(pr_db.PatronRequest{Side: SideLending, State: LenderStateWillSupply}))
listCompare(t, []pr_db.PatronRequestAction{LenderActionAddCondition, LenderActionCannotSupply}, mapping.GetActionsForPatronRequest(pr_db.PatronRequest{Side: SideLending, State: LenderStateConditionPending}))
listCompare(t, []pr_db.PatronRequestAction{LenderActionAddCondition, LenderActionCannotSupply, LenderActionShip}, mapping.GetActionsForPatronRequest(pr_db.PatronRequest{Side: SideLending, State: LenderStateConditionAccepted}))
listCompare(t, []pr_db.PatronRequestAction{}, mapping.GetActionsForPatronRequest(pr_db.PatronRequest{Side: SideLending, State: LenderStateShipped}))
Expand Down Expand Up @@ -144,6 +145,7 @@ func TestGetAllowedActionsForPatronRequest1(t *testing.T) {
{Name: string(LenderActionAddCondition), Parameters: []string{"note", "loanCondition", "cost", "currency"}},
{Name: string(LenderActionShip), Parameters: []string{"note"}, Primary: &tt},
{Name: string(LenderActionCannotSupply), Parameters: []string{"note", "reasonUnfilled"}},
{Name: string(LenderActionAskRetry), Parameters: []string{"note", "reasonRetry", "itemId"}},
}}, mapping.GetAllowedActionsForPatronRequest(pr_db.PatronRequest{Side: SideLending, State: LenderStateWillSupply}))
}

Expand Down Expand Up @@ -198,7 +200,7 @@ func mapCompare(t *testing.T, map1 map[pr_db.PatronRequestState][]PatronRequestA
for stateName := range map1 {
listOne := map1[stateName]
listTwo := map2[stateName]
assert.Equal(t, len(listOne), len(listTwo))
assert.Equal(t, len(listOne), len(listTwo), "State %s has different number of actions in the two maps", stateName)
for i := range listOne {
assert.Equal(t, listOne[i].actionName, listTwo[i].actionName)
assert.Equal(t, listOne[i].auto, listTwo[i].auto)
Expand Down
Loading
Loading