You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@Test@TransactionalvoidgetAllMyEntityAS() throwsException {
// Initialize the databasemyEntityARepository.saveAndFlush(myEntityA);
// Get all the myEntityAListrestMyEntityAMockMvc
.perform(get(ENTITY_API_URL + "?sort=id,desc"))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.[*].id").value(hasItem(myEntityA.getId().intValue())))
.andExpect(jsonPath("$.[*].fieldName").value(hasItem(DEFAULT_FIELD_NAME)));
}
I assume that ?sort=id,desc was used so that in the case of pagination, it can be assured that the newly created entity will be in the returned page. This works for the default Long IDs because they are auto incremented and as such sortable, but this does not hold true for UUIDs. So, in the case UUID is selected as the ID type, the newly created entity could possibly not be in the returned page and the test would fail.
Motivation for or Use Case
The tests should work reliably regardless of the chosen options.
This issue is stale because it has been open for too long without any activity.
Due to the moving nature of jhipster generated application, bugs can become invalid.
If this issue still applies please comment otherwise it will be closed in 7 days
Overview of the issue
While working on jhipster/generator-jhipster-quarkus#220 I noticed that JHipster generates tests as such:
I assume that
?sort=id,desc
was used so that in the case of pagination, it can be assured that the newly created entity will be in the returned page. This works for the defaultLong
IDs because they are auto incremented and as such sortable, but this does not hold true for UUIDs. So, in the case UUID is selected as the ID type, the newly created entity could possibly not be in the returned page and the test would fail.Motivation for or Use Case
The tests should work reliably regardless of the chosen options.
Reproduce the error
Use an entity with UUID as the type. e.g.
Related issues
#13258
Suggest a Fix
I'm happy to help with working on the solution, but I am not sure what a good way to solve this is.
Loading all the entities by iterating over the pages could work, but this would introduce a lot of code.
JHipster Version(s)
v8.1.0
JHipster configuration
JDL entity definitions
The text was updated successfully, but these errors were encountered: