Skip to content
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

refactor(/admin/groups/): Move parameter check from responder to endpoint #3093

Closed
wants to merge 1 commit into from

Conversation

mpro7
Copy link
Contributor

@mpro7 mpro7 commented Mar 5, 2024

Pull Request Checklist

Task Description/Number

Small PR which relates to DEV-3292 and two questions.

  1. Should we move checks which could be done ASAP to the endpoint or handler side instead of having them in responder/service?
  2. Does it make sense to test it on the endpoint side?

PR Type

  • build/chore: maintenance tasks (no production code change)
  • docs: documentation changes (no production code change)
  • feat: represents new features
  • fix: represents bug fixes
  • perf: performance improvements
  • refactor: represents production code refactoring
  • test: adding or refactoring tests (no production code change)

Basic requirements for bug fixes and features

  • Tests for the changes have been added
  • Docs have been added / updated

Does this PR introduce a breaking change?

  • Yes

Does this PR change client-test-data?

  • Yes

@mpro7 mpro7 self-assigned this Mar 5, 2024
@mpro7 mpro7 changed the title refactor: move parameter check from responder to /admin/groups/ endpoint refactor(/admin/groups/): Move parameter check from responder to endpoint Mar 5, 2024
Copy link

codecov bot commented Mar 5, 2024

Codecov Report

Attention: Patch coverage is 60.00000% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 88.60%. Comparing base (eac5751) to head (181838b).
Report is 106 commits behind head on main.

Files Patch % Lines
...knora/webapi/slice/admin/api/GroupsEndpoints.scala 60.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #3093       +/-   ##
===========================================
+ Coverage   11.74%   88.60%   +76.86%     
===========================================
  Files         246      261       +15     
  Lines       22907    22394      -513     
===========================================
+ Hits         2690    19842    +17152     
+ Misses      20217     2552    -17665     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Left("At least one field must be present.")
else Right(request),
identity,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: A serializer/deserializer contains validation logic for the value type

IMHO this behavior of a codec is surprising in a bad way. The product type GroupUpdateRequest allows for all combinations of params and that includes all being None. A serializer/deserializer should then also be able to produce a GroupUpdateRequest json reflecting the all None state.

I would rather like to see this done programatically in the rest service or in a smart constructor. A codec to me feels like the last place I would assume such logic exists.

@@ -186,20 +186,6 @@ class GroupsResponderADMSpec extends CoreSpec {
s"Group with the name '${groupName.value}' already exists.",
)
}

"return 'BadRequest' if nothing would be changed during the update" in {
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Maybe move this test to the GroupsADME2ESpec?

@mpro7
Copy link
Contributor Author

mpro7 commented Mar 6, 2024

@seakayone I will address your comments in another (follow-up) PR.

@mpro7 mpro7 closed this Mar 6, 2024
@mpro7 mpro7 deleted the endpoint-checks branch March 7, 2024 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants