mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-08-19 09:40:58 +00:00
Add endpoint to list reaction types
This commit is contained in:
@@ -15,6 +15,14 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
public class ReactionController {
|
public class ReactionController {
|
||||||
private final ReactionService reactionService;
|
private final ReactionService reactionService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all available reaction types.
|
||||||
|
*/
|
||||||
|
@GetMapping("/reaction-types")
|
||||||
|
public ReactionType[] listReactionTypes() {
|
||||||
|
return ReactionType.values();
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/posts/{postId}/reactions")
|
@PostMapping("/posts/{postId}/reactions")
|
||||||
public ResponseEntity<ReactionDto> reactToPost(@PathVariable Long postId,
|
public ResponseEntity<ReactionDto> reactToPost(@PathVariable Long postId,
|
||||||
@RequestBody ReactionRequest req,
|
@RequestBody ReactionRequest req,
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import org.springframework.test.web.servlet.MockMvc;
|
|||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||||
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
@@ -70,4 +71,11 @@ class ReactionControllerTest {
|
|||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.commentId").value(2));
|
.andExpect(jsonPath("$.commentId").value(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void listReactionTypes() throws Exception {
|
||||||
|
mockMvc.perform(get("/api/reaction-types"))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(jsonPath("$[0]").value("LIKE"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user