Use accessors (new, get, set) instead of direct field access#715
Merged
Conversation
Signed-off-by: Arrobo, Gabriel <gabriel.arrobo@intel.com>
There was a problem hiding this comment.
Pull request overview
This PR updates AMF code to prefer OpenAPI model constructors/accessors (New*, Get*, Set*) over direct struct-field access, and adds/updates unit tests to validate multipart payload handling and RAT type behavior.
Changes:
- Refactor multiple call sites to use OpenAPI model constructors and setter/getter methods instead of direct field mutation.
- Adjust UE context / event exposure logic to construct nested model objects via accessors.
- Add/extend unit tests for SM context creation multipart payloads and RAT type upgrade behavior.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| producer/ue_context.go | Renames UE context procedures to unexported helpers and switches several model constructions to New*/Set*. |
| producer/event_exposure.go | Uses constructors/setters for event subscription responses and refactors expiry-duration calculation helper. |
| producer/callback/callback_test.go | Updates callback tests to use model constructors and decode into allocated structs. |
| ngap/message/send.go | Uses NewNgApCause(...) constructor. |
| ngap/message/send_test.go.test | Removes legacy test file. |
| ngap/message/build_test.go | Uses constructors/setters for subscription data setup in tests. |
| ngap/handler.go | Uses NewNgApCause(...) in multiple NGAP handlers. |
| nfregistration/nf_registration_test.go | Updates mocks to return NewNFProfileWithDefaults(). |
| gmm/rat_type_integration_test.go | Adds an integration-style test validating RAT type upgrade from NGSetup RATInformation. |
| gmm/handler.go | Uses constructors/setters for N1/N2 payload references, AllowedNssai, and resynchronization info. |
| gmm/handler_test.go | Updates tests to use setters/constructors for location and S-NSSAI. |
| context/ran_ue.go | Uses setters for NR location nested fields and N3GA location fields. |
| context/amf_ue.go | Uses constructors for nested JSON data containers during UE marshaling. |
| consumer/ue_authentication.go | Uses NewPlmnIdNid(...) constructor. |
| consumer/sm_context.go | Refactors SM context create/update/release payload building to use setters; threads requestType into create request builder. |
| consumer/sm_context_test.go | Adds SM context create test verifying requestType + N1 multipart payload, plus multipart helper improvements. |
| consumer/nf_management.go | Uses constructors/setters for default notification subscription and returns default NFProfile on error paths. |
| consumer/communication.go | Uses NewN1MessageContainer(...) constructor for RegRequest. |
| consumer/communication_test.go | Uses NewN2InfoContent(...) in UE context transfer response test. |
| consumer/am_policy.go | Uses NewPlmnIdNid(...) for ServingPlmn. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Arrobo, Gabriel <gabriel.arrobo@intel.com>
sureshmarikkannu
approved these changes
Jun 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Also add a couple unit tests