CROSSLINK-211 Add notification endpoint and populate notifications#430
CROSSLINK-211 Add notification endpoint and populate notifications#430JanisSaldabols merged 4 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds support for patron-request notifications: extracting notification-like data from ISO18626 messages into the DB and exposing it via a new REST endpoint, with corresponding unit/E2E test updates.
Changes:
- Persist notifications derived from Request, RequestingAgencyMessage, and SupplyingAgencyMessage fields (notes/costs/conditions).
- Add
GET /patron_requests/{id}/notificationsAPI endpoint plus OpenAPI schema. - Extend tests to validate notification creation and endpoint behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| broker/patron_request/service/message-handler.go | Extracts notification data from ISO18626 messages and saves it via SaveNotification. |
| broker/patron_request/service/message-handler_test.go | Adds unit tests for notification extraction from RAM/Request/SAM messages. |
| broker/patron_request/service/action_test.go | Extends MockPrRepo to support SaveNotification for tests. |
| broker/patron_request/api/api-handler.go | Adds notifications endpoint and DB-to-API mapping (toApiNotification). |
| broker/patron_request/api/api-handler_test.go | Adds handler tests for notifications endpoint error cases and repo stub method. |
| broker/test/patron_request/api/api-handler_test.go | Updates end-to-end test flow to assert notification count. |
| broker/oapi/open-api.yaml | Introduces PrNotification schema and the /patron_requests/{id}/notifications path. |
Comments suppressed due to low confidence (3)
broker/oapi/open-api.yaml:744
- The schema has trailing whitespace in
title: Notification(and some property descriptions), which is easy to miss but tends to create noisy diffs and can be flagged by linters. Please remove the trailing spaces.
type: object
title: Notification
description: Patron request notification
broker/test/patron_request/api/api-handler_test.go:393
- Comment says "item count" but this block is asserting on notifications. Please update the comment to match what the test is checking to avoid confusion during future debugging.
// Check requester patron request item count
respBytes = httpRequest(t, "GET", requesterPrPath+"/notifications"+queryParams, []byte{}, 200)
var prNotifications []proapi.PrNotification
err = json.Unmarshal(respBytes, &prNotifications)
assert.NoError(t, err, "failed to unmarshal patron request notifications")
assert.Len(t, prNotifications, 2)
broker/patron_request/api/api-handler_test.go:342
- Test name references "Events" but this test exercises the notifications endpoint. Renaming it to match the behavior under test will make failures easier to interpret.
func TestGetPatronRequestsIdNotificationsErrorGettingEvents(t *testing.T) {
handler := NewPrApiHandler(new(PrRepoError), mockEventBus, new(mocks.MockEventRepositoryError), common.NewTenant(""), 10)
req, _ := http.NewRequest("GET", "/", nil)
rr := httptest.NewRecorder()
handler.GetPatronRequestsIdNotifications(rr, req, "3", proapi.GetPatronRequestsIdNotificationsParams{Symbol: &symbol, Side: &proapiBorrowingSide})
assert.Equal(t, http.StatusInternalServerError, rr.Code)
assert.Contains(t, rr.Body.String(), "DB error")
}
|
@JanisSaldabols Copilot comments |
203dac4 to
5620728
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (3)
broker/patron_request/api/api-handler_test.go:342
- The test name
TestGetPatronRequestsIdNotificationsErrorGettingEventsdoesn't match what it exercises (notifications, not events). Renaming it to reference notifications will make failures easier to interpret and avoid confusion with the existing events tests.
func TestGetPatronRequestsIdNotificationsErrorGettingEvents(t *testing.T) {
handler := NewPrApiHandler(new(PrRepoError), mockEventBus, new(mocks.MockEventRepositoryError), common.NewTenant(""), 10)
req, _ := http.NewRequest("GET", "/", nil)
rr := httptest.NewRecorder()
handler.GetPatronRequestsIdNotifications(rr, req, "3", proapi.GetPatronRequestsIdNotificationsParams{Symbol: &symbol, Side: &proapiBorrowingSide})
assert.Equal(t, http.StatusInternalServerError, rr.Code)
assert.Contains(t, rr.Body.String(), "DB error")
}
broker/test/patron_request/api/api-handler_test.go:393
- Comment says "Check requester patron request item count" but this block is asserting the notifications count. Update the comment to avoid misleading future readers.
// Check requester patron request item count
respBytes = httpRequest(t, "GET", requesterPrPath+"/notifications"+queryParams, []byte{}, 200)
var prNotifications []proapi.PrNotification
err = json.Unmarshal(respBytes, &prNotifications)
assert.NoError(t, err, "failed to unmarshal patron request notifications")
assert.Len(t, prNotifications, 2)
broker/oapi/open-api.yaml:752
- There are trailing spaces in the OpenAPI schema metadata (e.g.,
title: Notificationanddescription: Symbol of notification sender). These can leak into generated docs/clients and may trip linters; please remove the extra whitespace.
PrNotification:
type: object
title: Notification
description: Patron request notification
properties:
id:
type: string
description: Notification id
fromSymbol:
type: string
description: Symbol of notification sender
toSymbol:
4c47b7a to
3b1d5ef
Compare
3b1d5ef to
782436f
Compare
No description provided.