Skip to content

[BE] PR1/4 Refactor(user) create new rest path structures and endpoints for favorites and deprecate the legacy endpoints (#199)#1112

Open
polserrano8 wants to merge 27 commits intodevelopfrom
PR-1/3---refactor(user)-Create-new-REST-path-structures-and-endpoints-for-Favorites-and-deprecate-the-legacy-endpoints-#199
Open

[BE] PR1/4 Refactor(user) create new rest path structures and endpoints for favorites and deprecate the legacy endpoints (#199)#1112
polserrano8 wants to merge 27 commits intodevelopfrom
PR-1/3---refactor(user)-Create-new-REST-path-structures-and-endpoints-for-Favorites-and-deprecate-the-legacy-endpoints-#199

Conversation

@polserrano8
Copy link
Collaborator

Renamed the paths of the FavoritController because were not following REST standards. Made new endpoints with the new paths and deprecated the all endpoints. Also created new testing to ensure new endpoints are also correctly made and follow same standards as the legacy ones.

…h more consistend and with REST best practices in mind. Deprecated old endpoints wainting to update all clients paths to delete them.
…while maintaining the legacy integration test for the deprecated endpoints in FavoriteController from the user microservice.
…eparate classes since I had issues putting two separate paths to connect with the endpoints in the same classe. I chose to separate responsabilities, and I renamed the legacy class to FavoriteControllerLegacy. Also I created a new FavoriteController test and the legacy has been renamed to FavoriteControllerLegacyTest
Added user to the path of all new endpoints since I was not following the right convention to call in the path the microservice, which is the standard of the project. The new endpoints are the following.
POST /itachallenge/api/v1/user/users/{userId}/favorites/{challengeId}
GET /itachallenge/api/v1/user/users/{userId}/favorites
DELETE /itachallenge/api/v1/user/users/{userId}/favorites/{challengeId} All tests have passed
… since it was giving trouble with the actual favoritecontrollertest and it was giving problems to sonar cloud
…troller then the test was giving errors due to not changing the class to the legacy one FavoriteLegacyController. The issue was solved
@polserrano8 polserrano8 changed the title Pr 1/3 refactor(user) create new rest path structures and endpoints for favorites and deprecate the legacy endpoints #199 Pr 1/4 refactor(user) create new rest path structures and endpoints for favorites and deprecate the legacy endpoints #199 Feb 24, 2026
@polserrano8 polserrano8 changed the title Pr 1/4 refactor(user) create new rest path structures and endpoints for favorites and deprecate the legacy endpoints #199 [BE] PR1/4 refactor(user) create new rest path structures and endpoints for favorites and deprecate the legacy endpoints #199 Feb 24, 2026
@polserrano8 polserrano8 changed the title [BE] PR1/4 refactor(user) create new rest path structures and endpoints for favorites and deprecate the legacy endpoints #199 [BE] PR1/4 Refactor(user) create new rest path structures and endpoints for favorites and deprecate the legacy endpoints #199 Feb 24, 2026
@polserrano8 polserrano8 changed the title [BE] PR1/4 Refactor(user) create new rest path structures and endpoints for favorites and deprecate the legacy endpoints #199 [BE] PR1/4 Refactor(user) create new rest path structures and endpoints for favorites and deprecate the legacy endpoints (#199) Feb 24, 2026
polserrano8 and others added 13 commits February 24, 2026 16:38
…ath-structures-and-endpoints-for-Favorites-and-deprecate-the-legacy-endpoints-#199
…h more consistend and with REST best practices in mind. Deprecated old endpoints wainting to update all clients paths to delete them.
…while maintaining the legacy integration test for the deprecated endpoints in FavoriteController from the user microservice.
…eparate classes since I had issues putting two separate paths to connect with the endpoints in the same classe. I chose to separate responsabilities, and I renamed the legacy class to FavoriteControllerLegacy. Also I created a new FavoriteController test and the legacy has been renamed to FavoriteControllerLegacyTest
Added user to the path of all new endpoints since I was not following the right convention to call in the path the microservice, which is the standard of the project. The new endpoints are the following.
POST /itachallenge/api/v1/user/users/{userId}/favorites/{challengeId}
GET /itachallenge/api/v1/user/users/{userId}/favorites
DELETE /itachallenge/api/v1/user/users/{userId}/favorites/{challengeId} All tests have passed
… since it was giving trouble with the actual favoritecontrollertest and it was giving problems to sonar cloud
…troller then the test was giving errors due to not changing the class to the legacy one FavoriteLegacyController. The issue was solved
…ath-structures-and-endpoints-for-Favorites-and-deprecate-the-legacy-endpoints-#199
…-and-endpoints-for-Favorites-and-deprecate-the-legacy-endpoints-#199' of https://github.com/IT-Academy-BCN/ita-challenges-backend into #199-Feature-Refactor-Favorites-endpoints-to-REST-subresource-paths-and-deprecate-legacy-routes-(User-microservice,-staged-rollout)
@sonarqubecloud
Copy link

Copy link
Collaborator

@Apani13 Apani13 left a comment

Choose a reason for hiding this comment

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

Hey Pol!
Everything looks good, i would suggest that you take a look at the consistency of the endpoint path, since you are currently using two different ones, choose the one that best suits your purpose.

Everything else looks nice, good job!!!


@RestController
@RequestMapping("/itachallenge/api/v1/userinteraction/favorites")
@RequestMapping({"/itachallenge/api/v1/user/users"})
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe that path should be reviewed, because i think that it should only be ""users" and not ""user/users", as the path for the endpoint bookmark

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okey I'll adapt to the bookmark path structure since is more aligned of what we have now.


webTestClient.get()
.uri("/itachallenge/api/v1/userinteraction/favorites/{userId}", userId)
.uri("/itachallenge/api/v1/user/users/{userId}/favorites", userId)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as before, careful with path consistency :)


webTestClient.get()
.uri("/itachallenge/api/v1/userinteraction/favorites/{userId}", userId)
.uri("/itachallenge/api/v1/user/users/{userId}/favorites", userId)
Copy link
Collaborator

Choose a reason for hiding this comment

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

review the path!! :)


webTestClient.get()
.uri("/itachallenge/api/v1/userinteraction/favorites/{userId}", user1)
.uri("/itachallenge/api/v1/user/users/{userId}/favorites", user1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

path review :)


webTestClient.get()
.uri("/itachallenge/api/v1/userinteraction/favorites/{userId}", userId)
.uri("/itachallenge/api/v1/user/users/{userId}/favorites", userId)
Copy link
Collaborator

Choose a reason for hiding this comment

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

review path :)


@Test
@DisplayName("GET /userinteraction/favorites/{userId} returns 404 if user not found")
@DisplayName("GET /itachallenge/api/v1/user/users/{userId}/favorites returns 404 if user not found")
Copy link
Collaborator

Choose a reason for hiding this comment

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

review path :)


webTestClient.get()
.uri("/itachallenge/api/v1/userinteraction/favorites/{userId}", userId)
.uri("/itachallenge/api/v1/user/users/{userId}/favorites", userId)
Copy link
Collaborator

Choose a reason for hiding this comment

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

review path :)


webTestClient.get()
.uri("/itachallenge/api/v1/userinteraction/favorites/{userId}", invalidUserId)
.uri("/itachallenge/api/v1/user/users/{userId}/favorites", invalidUserId)
Copy link
Collaborator

Choose a reason for hiding this comment

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

review path :)

polserrano8 and others added 5 commits February 25, 2026 13:21
new request mapping path structure user is eliminated from the path.
Changing all the paths that target the favorite endpoints in the user microservice in the integration test.
Update of favorties endpoints in the controller unit test
…-and-endpoints-for-Favorites-and-deprecate-the-legacy-endpoints-#199' of https://github.com/IT-Academy-BCN/ita-challenges-backend into #199-Feature-Refactor-Favorites-endpoints-to-REST-subresource-paths-and-deprecate-legacy-routes-(User-microservice,-staged-rollout)
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