-
Notifications
You must be signed in to change notification settings - Fork 251
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
feat(DataManagementApi): returns id in Assest, Policy and Contract de… #2012
feat(DataManagementApi): returns id in Assest, Policy and Contract de… #2012
Conversation
…finition Post calls. Modify and added the unit tests and integration tests
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.
We are always happy to welcome new contributors ❤️ To make things easier for everyone, please make sure to follow our contribution guidelines, check if you have already signed the ECA, and relate this pull request to an existing issue or discussion.
Codecov ReportBase: 63.64% // Head: 5.39% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #2012 +/- ##
============================================
- Coverage 63.64% 5.39% -58.25%
- Complexity 0 166 +166
============================================
Files 772 780 +8
Lines 16370 16521 +151
Branches 1055 1074 +19
============================================
- Hits 10418 892 -9526
- Misses 5508 15563 +10055
+ Partials 444 66 -378
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
@ApiResponse(responseCode = "400", description = "Request body was malformed", | ||
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiErrorDetail.class)))), | ||
@ApiResponse(responseCode = "409", description = "Could not create asset, because an asset with that ID already exists", | ||
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ApiErrorDetail.class)))) } | ||
) | ||
void createAsset(@Valid AssetEntryDto assetEntryDto); | ||
AssetId createAsset(@Valid AssetEntryDto assetEntryDto); |
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.
Please do not use these unnecessary wrappers. Just return a String
.
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.
yes, I agree. I just tried to implement the same thing as contractnegotiation-api ,
org.eclipse.dataspaceconnector.api.datamanagement.contractnegotiation.model.NegotiationId
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.
looking at the other endpoints responses, using String will breaks the consistency of the api responses, since all the other endpoints either return nothing or a json. Furthermore, as I mentioned contractnegotiation-api and transferprocess-api are already implemented with the same approach(Using a wrapper for Id).
if this argument is convincing, then I can use the subclasses of BaseResponseDto not instead of wrappers. However my question is, if I should use the ones which are already implemented such as AssetResponseDto or ContractDefinitionResponseDto, which returns the whole object or a new one to return only the Id?
.../eclipse/dataspaceconnector/api/datamanagement/contractdefinition/ContractDefinitionApi.java
Outdated
Show resolved
Hide resolved
.../main/java/org/eclipse/dataspaceconnector/api/datamanagement/policy/PolicyDefinitionApi.java
Outdated
Show resolved
Hide resolved
...c/testFixtures/java/org/eclipse/dataspaceconnector/system/tests/local/BlobTransferUtils.java
Outdated
Show resolved
Hide resolved
...-transfer-test/runner/src/test/java/org/eclipse/dataspaceconnector/test/e2e/Participant.java
Outdated
Show resolved
Hide resolved
There is really no point in wrapping a |
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.
@git-masoud You need to create an Eclipse account and sign the ECA.
@paullatzelsperger if I remember correctly we decided for the wrapping (in the |
That is the reason I suggested the use of the |
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.
Looks neat, apart from some duplicated contentType(JSON)
for me it's good to go
Oh, yeah, you're right, for some reasons I lost that part :D |
@ndr_brt no worries :) However, this seems like an easy-enough thing to do, so I'd rather have this done properly now instead of introducing technical debt on purpose. I mean, we're talking about a trivial change, that would even reduce the surface of the current PR. |
…StringResponseDto to be used instead of the object's wrappers. Remove extra contentType tests in the integration tests. Change all the Data Management Api post return to StringResponseDto. Change openapi.yaml
Thanks for the tips. I implemented StringResponseDto to be used instead of the object's wrappers, although I am not sure about it's location(currently in extensions/common/api/api-core/src/main/java/org/eclipse/dataspaceconnector/api/model/StringResponseDto.java). |
...n/api/api-core/src/main/java/org/eclipse/dataspaceconnector/api/model/StringResponseDto.java
Outdated
Show resolved
Hide resolved
return new AssetId(result.getContent().getId()); | ||
return StringResponseDto.Builder.newInstance() | ||
.id(result.getContent().getId()) | ||
.createdAt(result.getContent().getCreatedAt()) |
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.
Please extract the "content" in a variable
@@ -111,7 +111,10 @@ public ContractDefinitionId createContractDefinition(@Valid ContractDefinitionRe | |||
var result = service.create(contractDefinition); | |||
if (result.succeeded()) { | |||
monitor.debug(format("Contract definition created %s", result.getContent().getId())); | |||
return new ContractDefinitionId(result.getContent().getId()); | |||
return StringResponseDto.Builder.newInstance() | |||
.id(result.getContent().getId()) |
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.
Please extract the "content" in a variable
return new PolicyDefinitionId(result.getContent().getId()); | ||
return StringResponseDto.Builder.newInstance() | ||
.id(result.getContent().getId()) | ||
.createdAt(result.getContent().getCreatedAt()) |
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.
Please extract the "content" in a variable
…to. Refactor and optimise the related classes
re-requesting my own review, so that I have it in my to-review list. |
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; | ||
|
||
@JsonDeserialize(builder = String.class) |
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.
that seems incorrect. should be IdResponseDto.Builder
. Also, there is no test for this class. There should at least be a test to verify correct serialization and deserialization, which would have surfaced the incorrect builder.
@git-masoud the Openapi test is failing. don't forget to regenerate the open api spec and the swagger ui: ./gradlew resolve
./gradlew mergeOpenApiFiles
./gradlew generateSwaggerUI Execute these three tasks in separate gradle calls (=do NOT join them together) and also commit that changeset. |
…seDto test. Update openApi files
…seDto test. Update openApi files
@git-masoud please note that I updated the PR title for merging so that it complies with our standards regarding conventional commits and contributing guidelines, specifically regarding the imperative mood. |
What this PR changes/adds
Made all the DataManagementApi POST resource return id of the created resource
Why it does that
Improving the DataManagementApi
Linked Issue(s)
Closes #1984
Checklist
no-changelog
)