-
Notifications
You must be signed in to change notification settings - Fork 882
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
Bad Request Error while trying to get pet for a specific owner #145
Comments
The
|
I think that it would be more readable if we have something like this : Pet pet = this.clinicService.findPetByOwner(ownerId, petId); And the body of findPetByOwner() would be like this: Owner owner = this.clinicService.findOwnerById(ownerId);
Pet pet = owner.getPets().stream().filter(pet -> pet.getId().equals(petId)).findFirst().orElseThrow(); |
To fix this issue, we can start by adding a failed test case to the Then, you're right: I'm not sure we need to call the For error handling, we have to take care to return a |
@firasrg I let you review my fix in the PR bad request on GET /api/owners/{id}/pets/{pe…](#150) |
…ng a Owner::getPet(Integer petId) method
The
GET/api/owners/{id}/pets/{petId}
endpoint seems to be returning an incorrect response or handling errors improperly. This issue was encountered while attempting to retrieve specific pet for a given owner.cURL:
Response on Swagger-ui:
Error: response status is 400
I tried to debug code and found out that it comes from
OwnerRestController
:The problem is here :
if (!pet.getOwner().equals(owner)) {}
: theequals()
check returnsfalse
. Ive checked the entity Owner class and found out that it doesn't haveequals
andhashcode()
(same for Pet entity class), which is not recommended !The text was updated successfully, but these errors were encountered: