-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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 test when nested jpaDerivedIdentifier is used #18067
fix test when nested jpaDerivedIdentifier is used #18067
Conversation
6cc8d17
to
08ee70c
Compare
The failing test Either way, I'd like to add a test for the changes I made but I haven't figured out where exactly it should be placed. Could someone help me with that? |
08ee70c
to
fa67538
Compare
Tests pass. Is this good enough? |
@mraible The existing tests never caught the issue this PR fixes. As a measure to avoid regressions, in my opinion, we should add one JDL integration test. I am just still not sure how to go about that. The JDL I want to test should look something like that:
Where should I add such a test case? |
It's possible to add an and add here
Or add to one of customId samples:
|
@mshima Thank you. I added the test cases. |
66763f2
to
8ce1162
Compare
@emilpaw is this PR ready? |
@mshima Yes, now that the E2E tests are working again it's ready. Thank you for the commit. |
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.
Simplify the condition.
generators/entity-server/templates/src/test/java/package/web/rest/EntityResourceIT.java.ejs
Outdated
Show resolved
Hide resolved
generators/entity-server/templates/src/test/java/package/web/rest/EntityResourceIT.java.ejs
Outdated
Show resolved
Hide resolved
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.
Remove back reference, it's not there
"id": true, | ||
"otherEntityField": "id", | ||
"otherEntityName": "mapsIdChildEntityWithDTO", | ||
"otherEntityRelationshipName": "mapsIdGrandchildEntityWithDTO", |
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.
"otherEntityRelationshipName": "mapsIdGrandchildEntityWithDTO", |
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.
"otherEntityRelationshipName"
is needed even if the relationship is unidirectional, right?
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 is a bug.
otherEntityRelationshipName
should exist only in bidirectional.
generators/entity-server/templates/src/test/java/package/web/rest/EntityResourceIT.java.ejs
Outdated
Show resolved
Hide resolved
test-integration/samples/.jhipster/MapsIdGrandchildEntityWithoutDTO.json
Outdated
Show resolved
Hide resolved
b699af4
to
a813573
Compare
when a relationship is used with the jpaDerivedIdentifier option and the related entity also has a relationship with that option set the `updateEntityMapsIdAssociationWithNewId` test fails. This is caused by the `createUpdatedEntity` reusing the needed parent entity. This can't work because a parent entity, which already has a child, can't be used as the parent for a new entity. The reason being jpaDerivedIdentifier enforces that parent and child share the same id, which can't be fulfilled with a reused parent entity. Remove the reuse of the parent entity in `createUpdatedEntity` when the entity uses jpaDerivedIdentifier to fix the test. Fixes jhipster#17906
a813573
to
08e87bd
Compare
I squashed the commits and now it's ready to merge. |
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 need investigation if one-to-one works without otherEntity filtering (removes already used ids). But not really related to this PR.
For now, if otherEntityRelationshipName
is set, otherEntity is not set and the relationship is id, we should throw. Filtering will not work as expected.
@emilpaw can you run prettier and add relationships back-reference for the GrandChild? |
df0b4a4
to
bb8e267
Compare
@mshima Done. |
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.
LGTM
Thanks @emilpaw |
Bug bounty claimed: https://opencollective.com/generator-jhipster/expenses/115030 Thanks :) |
@emilpaw approved |
when a relationship is used with the jpaDerivedIdentifier option and the
related entity also has a relationship with that option set the
updateEntityMapsIdAssociationWithNewId
test fails. Thisis caused by the
createUpdatedEntity
reusing the needed parententity. This can't work because a parent entity, which already has a child,
can't be used as the parent for a new entity. The reason being
jpaDerivedIdentifier enforces that parent and child share the same id,
which can't be fulfilled with a reused parent entity.
Remove the reuse of the parent entity in
createUpdatedEntity
when theentity uses jpaDerivedIdentifier to fix the test.
Fixes #17906
Please make sure the below checklist is followed for Pull Requests.
When you are still working on the PR, consider converting it to Draft (below reviewers) and adding
skip-ci
label, you can still see CI build result at your branch.