Changed "/stars" mapping to "/star" for individual star requests.

This commit is contained in:
Jesse Brault 2024-08-13 11:45:10 -05:00
parent f47e767612
commit 941acf7f2b
2 changed files with 6 additions and 6 deletions

View File

@ -143,7 +143,7 @@ public class RecipeControllerTests {
final User starer = this.createTestUser("recipe-starer"); final User starer = this.createTestUser("recipe-starer");
final Recipe recipe = this.createTestRecipe(owner, true); final Recipe recipe = this.createTestRecipe(owner, true);
this.mockMvc.perform( this.mockMvc.perform(
post("/recipes/{username}/{slug}/stars", recipe.getOwner().getUsername(), recipe.getSlug()) post("/recipes/{username}/{slug}/star", recipe.getOwner().getUsername(), recipe.getSlug())
.header("Authorization", "Bearer " + this.getAccessToken(starer)) .header("Authorization", "Bearer " + this.getAccessToken(starer))
) )
.andExpect(status().isCreated()) .andExpect(status().isCreated())
@ -158,7 +158,7 @@ public class RecipeControllerTests {
final Recipe recipe = this.createTestRecipe(owner, true); final Recipe recipe = this.createTestRecipe(owner, true);
this.recipeStarService.create(recipe.getId(), starer.getUsername()); this.recipeStarService.create(recipe.getId(), starer.getUsername());
this.mockMvc.perform( this.mockMvc.perform(
get("/recipes/{username}/{slug}/stars", recipe.getOwner().getUsername(), recipe.getSlug()) get("/recipes/{username}/{slug}/star", recipe.getOwner().getUsername(), recipe.getSlug())
.header("Authorization", "Bearer " + this.getAccessToken(starer)) .header("Authorization", "Bearer " + this.getAccessToken(starer))
) )
.andExpect(status().isOk()) .andExpect(status().isOk())
@ -175,7 +175,7 @@ public class RecipeControllerTests {
final Recipe recipe = this.createTestRecipe(owner, true); final Recipe recipe = this.createTestRecipe(owner, true);
this.recipeStarService.create(recipe.getId(), starer.getUsername()); this.recipeStarService.create(recipe.getId(), starer.getUsername());
this.mockMvc.perform( this.mockMvc.perform(
delete("/recipes/{username}/{slug}/stars", recipe.getOwner().getUsername(), recipe.getSlug()) delete("/recipes/{username}/{slug}/star", recipe.getOwner().getUsername(), recipe.getSlug())
.header("Authorization", "Bearer " + this.getAccessToken(starer)) .header("Authorization", "Bearer " + this.getAccessToken(starer))
) )
.andExpect(status().isNoContent()); .andExpect(status().isNoContent());

View File

@ -66,7 +66,7 @@ public class RecipeController {
return ResponseEntity.ok(view); return ResponseEntity.ok(view);
} }
@PostMapping("/{username}/{slug}/stars") @PostMapping("/{username}/{slug}/star")
public ResponseEntity<RecipeStar> addStar( public ResponseEntity<RecipeStar> addStar(
@PathVariable String username, @PathVariable String username,
@PathVariable String slug, @PathVariable String slug,
@ -75,7 +75,7 @@ public class RecipeController {
return ResponseEntity.status(HttpStatus.CREATED).body(this.recipeStarService.create(username, slug, principal)); return ResponseEntity.status(HttpStatus.CREATED).body(this.recipeStarService.create(username, slug, principal));
} }
@GetMapping("/{username}/{slug}/stars") @GetMapping("/{username}/{slug}/star")
public ResponseEntity<Map<String, Object>> getStar( public ResponseEntity<Map<String, Object>> getStar(
@PathVariable String username, @PathVariable String username,
@PathVariable String slug, @PathVariable String slug,
@ -89,7 +89,7 @@ public class RecipeController {
} }
} }
@DeleteMapping("/{username}/{slug}/stars") @DeleteMapping("/{username}/{slug}/star")
public ResponseEntity<Object> removeStar( public ResponseEntity<Object> removeStar(
@PathVariable String username, @PathVariable String username,
@PathVariable String slug, @PathVariable String slug,