Skip to content

Commit

Permalink
merge: 스포티파이 유사곡 검색 오류 수정
Browse files Browse the repository at this point in the history
Fix/#94 스포티파이 유사곡 검색 오류
  • Loading branch information
hong-sile authored Aug 18, 2024
2 parents 960b1a9 + a59b8bb commit f8afb52
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
3 changes: 1 addition & 2 deletions src/main/java/play/pluv/music/application/MusicService.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ public class MusicService {
private final MusicExplorerComposite musicExplorerComposite;
private final MusicTransferContextManager musicTransferContextManager;

//TODO : 추후 필요없는 파라미터 삭제
public List<MusicSearchResponse> searchMusics(
final Long memberId, final MusicStreaming musicStreaming, final MusicSearchRequest request
final MusicStreaming musicStreaming, final MusicSearchRequest request
) {
final String accessToken = request.destinationAccessToken();
final List<PlayListMusic> playListMusics = request.toPlayListMusics();
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/play/pluv/music/controller/MusicController.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,28 @@ public class MusicController {

@PostMapping("/spotify/search")
public BaseResponse<List<MusicSearchResponse>> searchSpotifyMusics(
final JwtMemberId jwtMemberId, @Valid @RequestBody final MusicSearchRequest musicSearchRequest
@Valid @RequestBody final MusicSearchRequest musicSearchRequest
) {
final var responses = musicService
.searchMusics(jwtMemberId.memberId(), SPOTIFY, musicSearchRequest);
.searchMusics(SPOTIFY, musicSearchRequest);
return BaseResponse.ok(responses);
}

@PostMapping("/youtube/search")
public BaseResponse<List<MusicSearchResponse>> searchYoutubeMusics(
final JwtMemberId jwtMemberId, @Valid @RequestBody final MusicSearchRequest musicSearchRequest
@Valid @RequestBody final MusicSearchRequest musicSearchRequest
) {
final var responses = musicService
.searchMusics(jwtMemberId.memberId(), YOUTUBE, musicSearchRequest);
.searchMusics(YOUTUBE, musicSearchRequest);
return BaseResponse.ok(responses);
}

@PostMapping("/apple/search")
public BaseResponse<List<MusicSearchResponse>> searchAppleMusics(
final JwtMemberId jwtMemberId, @Valid @RequestBody final MusicSearchRequest musicSearchRequest
@Valid @RequestBody final MusicSearchRequest musicSearchRequest
) {
final var responses = musicService
.searchMusics(jwtMemberId.memberId(), APPLE, musicSearchRequest);
.searchMusics(APPLE, musicSearchRequest);
return BaseResponse.ok(responses);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ SpotifyAccessTokenResponse getAccessToken(
@RequestParam final MultiValueMap<String, String> params
);

@GetExchange(url = "https://api.spotify.com/v1/search")
@GetExchange(url = "https://api.spotify.com/v1/search?limit=5")
SpotifySearchMusicResponse searchMusic(
@RequestHeader("Authorization") final String accessToken,
@RequestParam final MultiValueMap<String, String> params
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/play/pluv/api/MusicApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public class MusicApiTest extends ApiTest {

final String requestBody = objectMapper.writeValueAsString(검색_요청);

when(musicService.searchMusics(any(), any(), any())).thenReturn(검색_결과);
when(musicService.searchMusics(any(), any())).thenReturn(검색_결과);
setAccessToken(token, memberId);

mockMvc.perform(post("/music/spotify/search")
Expand All @@ -107,7 +107,7 @@ public class MusicApiTest extends ApiTest {
final String requestBody = objectMapper.writeValueAsString(검색_요청);

setAccessToken(token, memberId);
when(musicService.searchMusics(any(), any(), any())).thenReturn(검색_결과);
when(musicService.searchMusics(any(), any())).thenReturn(검색_결과);

mockMvc.perform(post("/music/youtube/search")
.contentType(APPLICATION_JSON_VALUE)
Expand All @@ -126,7 +126,7 @@ public class MusicApiTest extends ApiTest {

final String requestBody = objectMapper.writeValueAsString(검색_요청);

when(musicService.searchMusics(any(), any(), any())).thenReturn(검색_결과);
when(musicService.searchMusics(any(), any())).thenReturn(검색_결과);
setAccessToken(token, memberId);

mockMvc.perform(post("/music/apple/search")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class MusicServiceTest extends ApplicationTest {
List.of(new MusicQuery("좋은 날", "아이유", "KRA381001057", "imageUrl"))
);

final List<MusicSearchResponse> actual = musicService.searchMusics(3L, SPOTIFY, request);
final List<MusicSearchResponse> actual = musicService.searchMusics(SPOTIFY, request);
final List<MusicSearchResponse> expected = List.of(
new MusicSearchResponse(true, true,
new SourceMusicResponse("좋은 날", "아이유", "imageUrl"),
Expand Down

0 comments on commit f8afb52

Please sign in to comment.