Fix/petcontroller api endpoint#206
Conversation
📝 WalkthroughWalkthroughThe PR updates the PetController base request mapping from Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/main/java/org/example/vet1177/controller/PetController.java (1)
19-19: Base path update is correct; align route literals in logs/comments for consistency.
@RequestMapping("/api/pets")matches the PR objective. Consider updating the/petsstrings used in method comments/log messages below so debugging/docs stay aligned with runtime routes.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/main/java/org/example/vet1177/controller/PetController.java` at line 19, The class-level route annotation `@RequestMapping`("/api/pets") in PetController is updated but some method comments and log/messages still use the old "/pets" literal; update all occurrences in comments and log statements (e.g., any use in methods of PetController like getAllPets, getPetById, createPet, updatePet, deletePet) to use "/api/pets" (or build messages from the `@RequestMapping` value) so literals in logs/docs match the runtime base path.src/test/java/org/example/vet1177/controller/PetControllerTest.java (1)
97-98: Extract a shared test constant for the pet base path.
"/api/pets"is repeated across many tests; centralizing it reduces churn for future route changes.♻️ Proposed refactor
public class PetControllerTest { + private static final String PETS_BASE = "/api/pets"; @@ - mockMvc.perform(post("/api/pets") + mockMvc.perform(post(PETS_BASE) @@ - mockMvc.perform(get("/api/pets/{petId}", petId) + mockMvc.perform(get(PETS_BASE + "/{petId}", petId) @@ - mockMvc.perform(get("/api/pets/owner/{ownerId}", ownerId) + mockMvc.perform(get(PETS_BASE + "/owner/{ownerId}", ownerId) @@ - mockMvc.perform(put("/api/pets/{petId}", petId) + mockMvc.perform(put(PETS_BASE + "/{petId}", petId) @@ - mockMvc.perform(delete("/api/pets/{petId}", petId) + mockMvc.perform(delete(PETS_BASE + "/{petId}", petId)Also applies to: 111-112, 124-125, 137-138, 150-151, 161-162, 171-172, 181-182, 192-193, 204-205, 218-219, 231-232, 246-247, 256-257, 266-267
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/test/java/org/example/vet1177/controller/PetControllerTest.java` around lines 97 - 98, In PetControllerTest, extract the repeated literal "/api/pets" into a single private static final String constant (e.g. PET_BASE_PATH) at the top of the test class, then replace every occurrence of the literal in mockMvc.perform(...) calls and any other assertions with that constant (references include the mockMvc.perform(post("/api/pets")... usages and similar post/get/delete requests) so future route changes only need one edit; ensure imports remain and tests compile after replacing the string with PET_BASE_PATH.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/main/java/org/example/vet1177/controller/PetController.java`:
- Line 19: The class-level route annotation `@RequestMapping`("/api/pets") in
PetController is updated but some method comments and log/messages still use the
old "/pets" literal; update all occurrences in comments and log statements
(e.g., any use in methods of PetController like getAllPets, getPetById,
createPet, updatePet, deletePet) to use "/api/pets" (or build messages from the
`@RequestMapping` value) so literals in logs/docs match the runtime base path.
In `@src/test/java/org/example/vet1177/controller/PetControllerTest.java`:
- Around line 97-98: In PetControllerTest, extract the repeated literal
"/api/pets" into a single private static final String constant (e.g.
PET_BASE_PATH) at the top of the test class, then replace every occurrence of
the literal in mockMvc.perform(...) calls and any other assertions with that
constant (references include the mockMvc.perform(post("/api/pets")... usages and
similar post/get/delete requests) so future route changes only need one edit;
ensure imports remain and tests compile after replacing the string with
PET_BASE_PATH.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 129693be-983a-4b10-8853-327907edaa06
📒 Files selected for processing (3)
API.mdsrc/main/java/org/example/vet1177/controller/PetController.javasrc/test/java/org/example/vet1177/controller/PetControllerTest.java
closes #205
Summary by CodeRabbit
Release Notes
Documentation
Updates
/api/petspath prefix instead of/pets.