Skip to content

CROSSLINK-211 Add notification endpoint and populate notifications#430

Merged
JanisSaldabols merged 4 commits intomainfrom
CROSSLINK-211
Mar 4, 2026
Merged

CROSSLINK-211 Add notification endpoint and populate notifications#430
JanisSaldabols merged 4 commits intomainfrom
CROSSLINK-211

Conversation

@JanisSaldabols
Copy link
Collaborator

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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}/notifications API 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")
}

@jakub-id
Copy link
Contributor

jakub-id commented Mar 2, 2026

@JanisSaldabols Copilot comments

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 TestGetPatronRequestsIdNotificationsErrorGettingEvents doesn'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: Notification and description: 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:

@JanisSaldabols JanisSaldabols merged commit 37bf001 into main Mar 4, 2026
4 checks passed
@JanisSaldabols JanisSaldabols deleted the CROSSLINK-211 branch March 4, 2026 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants