[BE] PR1/4 Refactor(user) create new rest path structures and endpoints for favorites and deprecate the legacy endpoints (#199)#1112
[BE] PR1/4 Refactor(user) create new rest path structures and endpoints for favorites and deprecate the legacy endpoints (#199)#1112polserrano8 wants to merge 27 commits intodevelopfrom
Conversation
…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
Removed Leg
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
…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
Removed Leg
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)
|
Apani13
left a comment
There was a problem hiding this comment.
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"}) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
|
|
||
| webTestClient.get() | ||
| .uri("/itachallenge/api/v1/userinteraction/favorites/{userId}", user1) | ||
| .uri("/itachallenge/api/v1/user/users/{userId}/favorites", user1) |
|
|
||
| webTestClient.get() | ||
| .uri("/itachallenge/api/v1/userinteraction/favorites/{userId}", userId) | ||
| .uri("/itachallenge/api/v1/user/users/{userId}/favorites", userId) |
|
|
||
| @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") |
|
|
||
| webTestClient.get() | ||
| .uri("/itachallenge/api/v1/userinteraction/favorites/{userId}", userId) | ||
| .uri("/itachallenge/api/v1/user/users/{userId}/favorites", userId) |
...t/java/com/itachallenge/user/controller/userinteraction/favorite/FavoriteControllerTest.java
Outdated
Show resolved
Hide resolved
|
|
||
| webTestClient.get() | ||
| .uri("/itachallenge/api/v1/userinteraction/favorites/{userId}", invalidUserId) | ||
| .uri("/itachallenge/api/v1/user/users/{userId}/favorites", invalidUserId) |
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)



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.