Skip to content

Commit

Permalink
feat: 아티스트 북마크 컨트롤러 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
BGuga committed Mar 25, 2024
1 parent b8cc4ac commit f254c85
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
@Tag(name = "아티스트 북마크 V1")
@RequestMapping("/api/v1/bookmarks/artists")
public class ArtistBookmarkV1Controller {

private final ArtistBookmarkV1QueryService artistBookmarkV1QueryService;

@GetMapping
@Operation(description = "유저의 아티스트 북마크 목록을 조회한다.", summary = "아티스트 북마크 조회")
public ResponseEntity<List<ArtistBookmarkV1Response>> findArtistBookmarksByMemberId(@Member Long memberId) {
return ResponseEntity.ok(artistBookmarkV1QueryService.findArtistBookmarksByMemberId(memberId));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.festago.bookmark.presentation;

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

import com.festago.support.CustomWebMvcTest;
import com.festago.support.WithMockAuth;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.DisplayNameGeneration;
import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;

@CustomWebMvcTest
@DisplayNameGeneration(ReplaceUnderscores.class)
@SuppressWarnings("NonAsciiCharacters")
class ArtistBookmarkV1ControllerTest {

@Autowired
MockMvc mockMvc;

@Nested
class 아티스트_북마크_목록_조회_에서 {

final String uri = "/api/v1/bookmarks/artists";

@Nested
@DisplayName("GET " + uri)
class 올바른_주소로 {

@Test
@WithMockAuth
void 요청을_보내면_200_응답을_반환한다() throws Exception {
// when & then
mockMvc.perform(get(uri)
.contentType(MediaType.APPLICATION_JSON))
.andDo(print())
.andExpect(status().isOk());
}

@Test
void 인증을_안했으면_4xx_응답을_반환한다() throws Exception {
// when & then
mockMvc.perform(get(uri)
.contentType(MediaType.APPLICATION_JSON))
.andDo(print())
.andExpect(status().is4xxClientError());
}
}
}
}

0 comments on commit f254c85

Please sign in to comment.