-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: transform policy to contract offer #3626
fix: transform policy to contract offer #3626
Conversation
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #3626 +/- ##
==========================================
+ Coverage 71.78% 71.87% +0.08%
==========================================
Files 909 914 +5
Lines 18134 18283 +149
Branches 1033 1037 +4
==========================================
+ Hits 13018 13140 +122
- Misses 4672 4691 +19
- Partials 444 452 +8 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some suggestions inline
if (callbackAddress != null) { | ||
var addresses = new ArrayList<CallbackAddress>(); | ||
transformArrayOrObject(callbackAddress, CallbackAddress.class, addresses::add, context); | ||
contractRequestBuilder.callbackAddresses(addresses); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be more elegant to add a callbackAddress(String)
method to ContractRequest.Builder
, like we do in several other builders. that would avoid having to create a new addresses
list here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was out of my jurisdiction here, anyway I used a cleaner approach. That transformArrayOrObject
method in my opinion does not make any sense... jsonld objects are always expanded as arrays, the decision on deserialization is to go with a single object (the first) or with the full array. This could be something do be addressed in another issue
contractRequestBuilder.policy(policy); | ||
if (policyJson != null && !policyJson.asJsonArray().isEmpty()) { | ||
var policy = transformObject(policyJson, Policy.class, context); | ||
var offerId = transformString(policyJson.asJsonArray().getJsonObject(0).get(ID), context); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe use transformArrayOrObject
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately our Policy
object does not have an id
field, because in fact the ContractOffer
could be seen as a Policy
extension, I think extracting a dedicate json-to-contractoffer transformer will make everything cleared
...api/management/contractnegotiation/transform/JsonObjectToContractRequestTransformerTest.java
Outdated
Show resolved
Hide resolved
32e236f
to
f747a1e
Compare
f747a1e
to
7dd0f71
Compare
What this PR changes/adds
Map the new
policy
field toContractOffer
Why it does that
avoid null pointer exceptions, because
ContractOffer
cannot be missing in aContractRequest
object.Further notes
policy
,counterPartyAddress
) instead of the deprecated onestarget
as an@id
, as requested by the ODRL information modelLinked Issue(s)
Closes #3624
Please be sure to take a look at the contributing guidelines and our etiquette for pull requests.