Spring Boot: fix test _entityClass_ResourceIT.java.ejs for composed types with OneToOne and @MapsId (eg when extending User) #29902
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.
See Issue #29901
Suggested changes
In the file
test _entityClass_ResourceIT.java.ejs
, I noticed that it's generating the name of the setter with:It's using the class name from the other entity (in this case
User
) when generating the name for the setter method. Which only works if the field/setter has the same name as the class. However, in my case (and in the case shown in the documentation for extending a user https://www.jhipster.tech/user-entity/ ): The field is calledinternalUser
and the class is calledUser
.I tried to find something containing
InternalUser
(case-sensitive) and found the following possibilities:mapsIdAssoc.relationshipNameCapitalized
mapsIdAssoc.propertyNameCapitalized
mapsIdAssoc.propertyJavaBeanName
All of these 3 options contained
InternalUser
. I'm not sure about the exact meanings of each.My proposed fix is to use:
Testing
I tested my changes from this commit locally (by using
npm ci
and setting an alias) and am now receiving Spring Boot (Java) code which compiles successfully. I started the application and verified that the entities are visible via the GUI. However, I haven't yet thoroughly tested my new composed types. I'm assuming that it works because it's something that's mentioned in the documentation. But I will be trying to use it (run-time) anyway in the near future because I want to use it.I haven't written any automated test for it. I might look into that if it's required. However I'm not sure if I'm able to figure out where to put such a test or which kind of test to write.
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.