From 40b873cebe6f870bbd33d1e2f1d48af59d45f5ac Mon Sep 17 00:00:00 2001 From: hong-sile Date: Thu, 8 Aug 2024 20:19:00 +0900 Subject: [PATCH 1/3] =?UTF-8?q?refactor:=20SourceMusic=20=EC=9C=84?= =?UTF-8?q?=EC=B9=98=20=EC=88=98=EC=A0=95(#68)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pluv/login/application/LoginService.java | 2 +- .../login/controller/LoginController.java | 4 +-- .../pluv/music/application/MusicExplorer.java | 2 +- .../application/MusicExplorerComposite.java | 2 +- .../pluv/music/application/MusicService.java | 2 +- .../application/dto/MusicAddRequest.java | 2 +- .../music/controller/MusicController.java | 4 +-- .../java/play/pluv/music/domain/MusicId.java | 2 ++ .../play/pluv/music/domain/SourceMusic.java | 2 +- .../oauth/application/SocialLoginClient.java | 2 +- .../SocialLoginClientComposite.java | 2 +- .../pluv/oauth/domain/OAuthMemberInfo.java | 2 +- .../pluv/oauth/google/GoogleConnector.java | 4 +-- .../google/dto/GoogleIdTokenResponse.java | 2 +- .../dto/YoutubeCreatePlayListResponse.java | 2 +- .../google/dto/YoutubePlayListResponses.java | 2 +- .../dto/YoutubeSearchMusicResponses.java | 2 +- .../pluv/oauth/spotify/SpotifyConnector.java | 4 +-- .../spotify/dto/SpotifyPlayListResponses.java | 2 +- .../dto/SpotifySearchMusicResponse.java | 2 +- .../spotify/dto/SpotifyUserResponse.java | 2 +- .../application/PlayListConnector.java | 2 +- .../PlayListConnectorComposite.java | 2 +- .../playlist/application/PlayListService.java | 2 +- .../controller/PlayListController.java | 4 +-- .../domain/MusicStreaming.java | 8 ++--- .../play/pluv/playlist/domain/PlayListId.java | 2 -- src/test/java/play/pluv/api/LoginApiTest.java | 4 +-- .../java/play/pluv/api/PlayListApiTest.java | 4 +-- .../play/pluv/api/fixture/MusicFixture.java | 30 +++++++++++++++++++ .../play/pluv/fixture/PlayListFixture.java | 2 +- .../login/application/LoginServiceTest.java | 2 +- .../login/application/RegisterReaderTest.java | 2 +- .../application/RegisterUpdaterTest.java | 3 +- .../music/application/MusicServiceTest.java | 2 +- .../music/domain/DestinationMusicTest.java | 2 +- .../application/PlayListServiceTest.java | 2 +- 37 files changed, 76 insertions(+), 47 deletions(-) rename src/main/java/play/pluv/{music => playlist}/domain/MusicStreaming.java (61%) diff --git a/src/main/java/play/pluv/login/application/LoginService.java b/src/main/java/play/pluv/login/application/LoginService.java index 89b9c0a..c31f908 100644 --- a/src/main/java/play/pluv/login/application/LoginService.java +++ b/src/main/java/play/pluv/login/application/LoginService.java @@ -3,7 +3,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import play.pluv.member.domain.Member; -import play.pluv.music.domain.MusicStreaming; +import play.pluv.playlist.domain.MusicStreaming; import play.pluv.oauth.application.SocialLoginClientComposite; import play.pluv.oauth.domain.OAuthMemberInfo; diff --git a/src/main/java/play/pluv/login/controller/LoginController.java b/src/main/java/play/pluv/login/controller/LoginController.java index b84dc55..e027de1 100644 --- a/src/main/java/play/pluv/login/controller/LoginController.java +++ b/src/main/java/play/pluv/login/controller/LoginController.java @@ -1,7 +1,7 @@ package play.pluv.login.controller; -import static play.pluv.music.domain.MusicStreaming.SPOTIFY; -import static play.pluv.music.domain.MusicStreaming.YOUTUBE; +import static play.pluv.playlist.domain.MusicStreaming.SPOTIFY; +import static play.pluv.playlist.domain.MusicStreaming.YOUTUBE; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.PostMapping; diff --git a/src/main/java/play/pluv/music/application/MusicExplorer.java b/src/main/java/play/pluv/music/application/MusicExplorer.java index 5b3ab27..a7e0595 100644 --- a/src/main/java/play/pluv/music/application/MusicExplorer.java +++ b/src/main/java/play/pluv/music/application/MusicExplorer.java @@ -4,7 +4,7 @@ import java.util.Optional; import play.pluv.music.domain.DestinationMusic; import play.pluv.music.domain.MusicId; -import play.pluv.music.domain.MusicStreaming; +import play.pluv.playlist.domain.MusicStreaming; import play.pluv.music.domain.SourceMusic; public interface MusicExplorer { diff --git a/src/main/java/play/pluv/music/application/MusicExplorerComposite.java b/src/main/java/play/pluv/music/application/MusicExplorerComposite.java index bcd90ae..01df9de 100644 --- a/src/main/java/play/pluv/music/application/MusicExplorerComposite.java +++ b/src/main/java/play/pluv/music/application/MusicExplorerComposite.java @@ -11,9 +11,9 @@ import org.springframework.stereotype.Component; import play.pluv.music.domain.DestinationMusic; import play.pluv.music.domain.MusicId; -import play.pluv.music.domain.MusicStreaming; import play.pluv.music.domain.SourceMusic; import play.pluv.music.exception.MusicException; +import play.pluv.playlist.domain.MusicStreaming; @Component public class MusicExplorerComposite { diff --git a/src/main/java/play/pluv/music/application/MusicService.java b/src/main/java/play/pluv/music/application/MusicService.java index 2d8abf6..5ba3f2a 100644 --- a/src/main/java/play/pluv/music/application/MusicService.java +++ b/src/main/java/play/pluv/music/application/MusicService.java @@ -10,7 +10,7 @@ import play.pluv.music.application.dto.MusicSearchResponse; import play.pluv.music.domain.DestinationMusic; import play.pluv.music.domain.MusicId; -import play.pluv.music.domain.MusicStreaming; +import play.pluv.playlist.domain.MusicStreaming; import play.pluv.music.domain.SourceMusic; @Service diff --git a/src/main/java/play/pluv/music/application/dto/MusicAddRequest.java b/src/main/java/play/pluv/music/application/dto/MusicAddRequest.java index 836885e..3b41918 100644 --- a/src/main/java/play/pluv/music/application/dto/MusicAddRequest.java +++ b/src/main/java/play/pluv/music/application/dto/MusicAddRequest.java @@ -2,7 +2,7 @@ import java.util.List; import play.pluv.music.domain.MusicId; -import play.pluv.music.domain.MusicStreaming; +import play.pluv.playlist.domain.MusicStreaming; public record MusicAddRequest( String playListName, diff --git a/src/main/java/play/pluv/music/controller/MusicController.java b/src/main/java/play/pluv/music/controller/MusicController.java index ddf4fed..66260a6 100644 --- a/src/main/java/play/pluv/music/controller/MusicController.java +++ b/src/main/java/play/pluv/music/controller/MusicController.java @@ -1,7 +1,7 @@ package play.pluv.music.controller; -import static play.pluv.music.domain.MusicStreaming.SPOTIFY; -import static play.pluv.music.domain.MusicStreaming.YOUTUBE; +import static play.pluv.playlist.domain.MusicStreaming.SPOTIFY; +import static play.pluv.playlist.domain.MusicStreaming.YOUTUBE; import java.util.List; import org.springframework.web.bind.annotation.PostMapping; diff --git a/src/main/java/play/pluv/music/domain/MusicId.java b/src/main/java/play/pluv/music/domain/MusicId.java index c169eca..a17a039 100644 --- a/src/main/java/play/pluv/music/domain/MusicId.java +++ b/src/main/java/play/pluv/music/domain/MusicId.java @@ -1,5 +1,7 @@ package play.pluv.music.domain; +import play.pluv.playlist.domain.MusicStreaming; + public record MusicId( MusicStreaming musicStreaming, String id diff --git a/src/main/java/play/pluv/music/domain/SourceMusic.java b/src/main/java/play/pluv/music/domain/SourceMusic.java index 210f327..9e1e1f9 100644 --- a/src/main/java/play/pluv/music/domain/SourceMusic.java +++ b/src/main/java/play/pluv/music/domain/SourceMusic.java @@ -17,7 +17,7 @@ public class SourceMusic { //Nullable private final String isrcCode; - public Optional getIsrcCode(){ + public Optional getIsrcCode() { return Optional.ofNullable(isrcCode); } } diff --git a/src/main/java/play/pluv/oauth/application/SocialLoginClient.java b/src/main/java/play/pluv/oauth/application/SocialLoginClient.java index dcb4333..7588b5f 100644 --- a/src/main/java/play/pluv/oauth/application/SocialLoginClient.java +++ b/src/main/java/play/pluv/oauth/application/SocialLoginClient.java @@ -1,6 +1,6 @@ package play.pluv.oauth.application; -import play.pluv.music.domain.MusicStreaming; +import play.pluv.playlist.domain.MusicStreaming; import play.pluv.oauth.domain.OAuthMemberInfo; public interface SocialLoginClient { diff --git a/src/main/java/play/pluv/oauth/application/SocialLoginClientComposite.java b/src/main/java/play/pluv/oauth/application/SocialLoginClientComposite.java index b07ef55..248fdd0 100644 --- a/src/main/java/play/pluv/oauth/application/SocialLoginClientComposite.java +++ b/src/main/java/play/pluv/oauth/application/SocialLoginClientComposite.java @@ -8,7 +8,7 @@ import java.util.Optional; import java.util.Set; import org.springframework.stereotype.Component; -import play.pluv.music.domain.MusicStreaming; +import play.pluv.playlist.domain.MusicStreaming; import play.pluv.oauth.domain.OAuthMemberInfo; import play.pluv.oauth.exception.OAuthException; diff --git a/src/main/java/play/pluv/oauth/domain/OAuthMemberInfo.java b/src/main/java/play/pluv/oauth/domain/OAuthMemberInfo.java index 8d9801c..4857441 100644 --- a/src/main/java/play/pluv/oauth/domain/OAuthMemberInfo.java +++ b/src/main/java/play/pluv/oauth/domain/OAuthMemberInfo.java @@ -4,7 +4,7 @@ import jakarta.persistence.Embeddable; import jakarta.persistence.Enumerated; -import play.pluv.music.domain.MusicStreaming; +import play.pluv.playlist.domain.MusicStreaming; @Embeddable public record OAuthMemberInfo( diff --git a/src/main/java/play/pluv/oauth/google/GoogleConnector.java b/src/main/java/play/pluv/oauth/google/GoogleConnector.java index 710bc25..16a90ae 100644 --- a/src/main/java/play/pluv/oauth/google/GoogleConnector.java +++ b/src/main/java/play/pluv/oauth/google/GoogleConnector.java @@ -1,6 +1,6 @@ package play.pluv.oauth.google; -import static play.pluv.music.domain.MusicStreaming.YOUTUBE; +import static play.pluv.playlist.domain.MusicStreaming.YOUTUBE; import java.util.ArrayList; import java.util.List; @@ -13,7 +13,7 @@ import play.pluv.music.application.MusicExplorer; import play.pluv.music.domain.DestinationMusic; import play.pluv.music.domain.MusicId; -import play.pluv.music.domain.MusicStreaming; +import play.pluv.playlist.domain.MusicStreaming; import play.pluv.music.domain.SourceMusic; import play.pluv.oauth.application.SocialLoginClient; import play.pluv.oauth.domain.OAuthMemberInfo; diff --git a/src/main/java/play/pluv/oauth/google/dto/GoogleIdTokenResponse.java b/src/main/java/play/pluv/oauth/google/dto/GoogleIdTokenResponse.java index 7724e7f..a6ab544 100644 --- a/src/main/java/play/pluv/oauth/google/dto/GoogleIdTokenResponse.java +++ b/src/main/java/play/pluv/oauth/google/dto/GoogleIdTokenResponse.java @@ -1,6 +1,6 @@ package play.pluv.oauth.google.dto; -import static play.pluv.music.domain.MusicStreaming.YOUTUBE; +import static play.pluv.playlist.domain.MusicStreaming.YOUTUBE; import play.pluv.oauth.domain.OAuthMemberInfo; diff --git a/src/main/java/play/pluv/oauth/google/dto/YoutubeCreatePlayListResponse.java b/src/main/java/play/pluv/oauth/google/dto/YoutubeCreatePlayListResponse.java index df077b7..dcc5b6c 100644 --- a/src/main/java/play/pluv/oauth/google/dto/YoutubeCreatePlayListResponse.java +++ b/src/main/java/play/pluv/oauth/google/dto/YoutubeCreatePlayListResponse.java @@ -1,6 +1,6 @@ package play.pluv.oauth.google.dto; -import static play.pluv.music.domain.MusicStreaming.YOUTUBE; +import static play.pluv.playlist.domain.MusicStreaming.YOUTUBE; import play.pluv.playlist.domain.PlayListId; diff --git a/src/main/java/play/pluv/oauth/google/dto/YoutubePlayListResponses.java b/src/main/java/play/pluv/oauth/google/dto/YoutubePlayListResponses.java index 729b56f..ec4323a 100644 --- a/src/main/java/play/pluv/oauth/google/dto/YoutubePlayListResponses.java +++ b/src/main/java/play/pluv/oauth/google/dto/YoutubePlayListResponses.java @@ -1,6 +1,6 @@ package play.pluv.oauth.google.dto; -import static play.pluv.music.domain.MusicStreaming.YOUTUBE; +import static play.pluv.playlist.domain.MusicStreaming.YOUTUBE; import java.util.List; import play.pluv.playlist.domain.PlayList; diff --git a/src/main/java/play/pluv/oauth/google/dto/YoutubeSearchMusicResponses.java b/src/main/java/play/pluv/oauth/google/dto/YoutubeSearchMusicResponses.java index 179cd49..ccc848f 100644 --- a/src/main/java/play/pluv/oauth/google/dto/YoutubeSearchMusicResponses.java +++ b/src/main/java/play/pluv/oauth/google/dto/YoutubeSearchMusicResponses.java @@ -1,6 +1,6 @@ package play.pluv.oauth.google.dto; -import static play.pluv.music.domain.MusicStreaming.YOUTUBE; +import static play.pluv.playlist.domain.MusicStreaming.YOUTUBE; import java.util.List; import java.util.Optional; diff --git a/src/main/java/play/pluv/oauth/spotify/SpotifyConnector.java b/src/main/java/play/pluv/oauth/spotify/SpotifyConnector.java index 3c8df5b..390a548 100644 --- a/src/main/java/play/pluv/oauth/spotify/SpotifyConnector.java +++ b/src/main/java/play/pluv/oauth/spotify/SpotifyConnector.java @@ -1,7 +1,7 @@ package play.pluv.oauth.spotify; import static java.lang.String.format; -import static play.pluv.music.domain.MusicStreaming.SPOTIFY; +import static play.pluv.playlist.domain.MusicStreaming.SPOTIFY; import java.util.ArrayList; import java.util.List; @@ -14,7 +14,7 @@ import play.pluv.music.application.MusicExplorer; import play.pluv.music.domain.DestinationMusic; import play.pluv.music.domain.MusicId; -import play.pluv.music.domain.MusicStreaming; +import play.pluv.playlist.domain.MusicStreaming; import play.pluv.music.domain.SourceMusic; import play.pluv.oauth.application.SocialLoginClient; import play.pluv.oauth.domain.OAuthMemberInfo; diff --git a/src/main/java/play/pluv/oauth/spotify/dto/SpotifyPlayListResponses.java b/src/main/java/play/pluv/oauth/spotify/dto/SpotifyPlayListResponses.java index f4ec6d5..e8d560e 100644 --- a/src/main/java/play/pluv/oauth/spotify/dto/SpotifyPlayListResponses.java +++ b/src/main/java/play/pluv/oauth/spotify/dto/SpotifyPlayListResponses.java @@ -1,6 +1,6 @@ package play.pluv.oauth.spotify.dto; -import static play.pluv.music.domain.MusicStreaming.SPOTIFY; +import static play.pluv.playlist.domain.MusicStreaming.SPOTIFY; import java.util.List; import play.pluv.playlist.domain.PlayList; diff --git a/src/main/java/play/pluv/oauth/spotify/dto/SpotifySearchMusicResponse.java b/src/main/java/play/pluv/oauth/spotify/dto/SpotifySearchMusicResponse.java index 822baaa..f1e3314 100644 --- a/src/main/java/play/pluv/oauth/spotify/dto/SpotifySearchMusicResponse.java +++ b/src/main/java/play/pluv/oauth/spotify/dto/SpotifySearchMusicResponse.java @@ -1,6 +1,6 @@ package play.pluv.oauth.spotify.dto; -import static play.pluv.music.domain.MusicStreaming.SPOTIFY; +import static play.pluv.playlist.domain.MusicStreaming.SPOTIFY; import java.util.List; import java.util.Optional; diff --git a/src/main/java/play/pluv/oauth/spotify/dto/SpotifyUserResponse.java b/src/main/java/play/pluv/oauth/spotify/dto/SpotifyUserResponse.java index 519e53a..07fbba6 100644 --- a/src/main/java/play/pluv/oauth/spotify/dto/SpotifyUserResponse.java +++ b/src/main/java/play/pluv/oauth/spotify/dto/SpotifyUserResponse.java @@ -1,6 +1,6 @@ package play.pluv.oauth.spotify.dto; -import static play.pluv.music.domain.MusicStreaming.SPOTIFY; +import static play.pluv.playlist.domain.MusicStreaming.SPOTIFY; import play.pluv.oauth.domain.OAuthMemberInfo; diff --git a/src/main/java/play/pluv/playlist/application/PlayListConnector.java b/src/main/java/play/pluv/playlist/application/PlayListConnector.java index 831e109..144a3fd 100644 --- a/src/main/java/play/pluv/playlist/application/PlayListConnector.java +++ b/src/main/java/play/pluv/playlist/application/PlayListConnector.java @@ -1,7 +1,7 @@ package play.pluv.playlist.application; import java.util.List; -import play.pluv.music.domain.MusicStreaming; +import play.pluv.playlist.domain.MusicStreaming; import play.pluv.playlist.domain.PlayList; import play.pluv.playlist.domain.PlayListId; import play.pluv.playlist.domain.PlayListMusic; diff --git a/src/main/java/play/pluv/playlist/application/PlayListConnectorComposite.java b/src/main/java/play/pluv/playlist/application/PlayListConnectorComposite.java index d4a8d4b..1ce5d35 100644 --- a/src/main/java/play/pluv/playlist/application/PlayListConnectorComposite.java +++ b/src/main/java/play/pluv/playlist/application/PlayListConnectorComposite.java @@ -9,7 +9,7 @@ import java.util.Optional; import java.util.Set; import org.springframework.stereotype.Component; -import play.pluv.music.domain.MusicStreaming; +import play.pluv.playlist.domain.MusicStreaming; import play.pluv.playlist.domain.PlayList; import play.pluv.playlist.domain.PlayListMusic; import play.pluv.playlist.exception.PlayListException; diff --git a/src/main/java/play/pluv/playlist/application/PlayListService.java b/src/main/java/play/pluv/playlist/application/PlayListService.java index 20c5a92..df16020 100644 --- a/src/main/java/play/pluv/playlist/application/PlayListService.java +++ b/src/main/java/play/pluv/playlist/application/PlayListService.java @@ -3,7 +3,7 @@ import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; -import play.pluv.music.domain.MusicStreaming; +import play.pluv.playlist.domain.MusicStreaming; import play.pluv.playlist.domain.PlayList; import play.pluv.playlist.domain.PlayListMusic; diff --git a/src/main/java/play/pluv/playlist/controller/PlayListController.java b/src/main/java/play/pluv/playlist/controller/PlayListController.java index d7984cb..142e4c5 100644 --- a/src/main/java/play/pluv/playlist/controller/PlayListController.java +++ b/src/main/java/play/pluv/playlist/controller/PlayListController.java @@ -1,7 +1,7 @@ package play.pluv.playlist.controller; -import static play.pluv.music.domain.MusicStreaming.SPOTIFY; -import static play.pluv.music.domain.MusicStreaming.YOUTUBE; +import static play.pluv.playlist.domain.MusicStreaming.SPOTIFY; +import static play.pluv.playlist.domain.MusicStreaming.YOUTUBE; import java.util.List; import org.springframework.http.ResponseEntity; diff --git a/src/main/java/play/pluv/music/domain/MusicStreaming.java b/src/main/java/play/pluv/playlist/domain/MusicStreaming.java similarity index 61% rename from src/main/java/play/pluv/music/domain/MusicStreaming.java rename to src/main/java/play/pluv/playlist/domain/MusicStreaming.java index 694da45..b3b8994 100644 --- a/src/main/java/play/pluv/music/domain/MusicStreaming.java +++ b/src/main/java/play/pluv/playlist/domain/MusicStreaming.java @@ -1,10 +1,10 @@ -package play.pluv.music.domain; +package play.pluv.playlist.domain; -import static play.pluv.music.exception.MusicExceptionType.MUSIC_STREAMING_NOT_FOUND; +import static play.pluv.playlist.exception.PlayListExceptionType.PLAYLIST_PROVIDER_NOT_FOUND; import java.util.Arrays; import lombok.Getter; -import play.pluv.music.exception.MusicException; +import play.pluv.playlist.exception.PlayListException; @Getter public enum MusicStreaming { @@ -23,6 +23,6 @@ public static MusicStreaming from(final String name) { return Arrays.stream(values()) .filter(streaming -> streaming.getName().equals(name)) .findAny() - .orElseThrow(() -> new MusicException(MUSIC_STREAMING_NOT_FOUND)); + .orElseThrow(() -> new PlayListException(PLAYLIST_PROVIDER_NOT_FOUND)); } } diff --git a/src/main/java/play/pluv/playlist/domain/PlayListId.java b/src/main/java/play/pluv/playlist/domain/PlayListId.java index 4fe8afd..c2e89ae 100644 --- a/src/main/java/play/pluv/playlist/domain/PlayListId.java +++ b/src/main/java/play/pluv/playlist/domain/PlayListId.java @@ -1,7 +1,5 @@ package play.pluv.playlist.domain; -import play.pluv.music.domain.MusicStreaming; - public record PlayListId( String id, MusicStreaming musicStreaming diff --git a/src/test/java/play/pluv/api/LoginApiTest.java b/src/test/java/play/pluv/api/LoginApiTest.java index 4bfabee..eff9d16 100644 --- a/src/test/java/play/pluv/api/LoginApiTest.java +++ b/src/test/java/play/pluv/api/LoginApiTest.java @@ -13,8 +13,8 @@ import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import static play.pluv.music.domain.MusicStreaming.SPOTIFY; -import static play.pluv.music.domain.MusicStreaming.YOUTUBE; +import static play.pluv.playlist.domain.MusicStreaming.SPOTIFY; +import static play.pluv.playlist.domain.MusicStreaming.YOUTUBE; import org.junit.jupiter.api.Test; import play.pluv.login.application.dto.GoogleLoginRequest; diff --git a/src/test/java/play/pluv/api/PlayListApiTest.java b/src/test/java/play/pluv/api/PlayListApiTest.java index 649ca91..2f91be6 100644 --- a/src/test/java/play/pluv/api/PlayListApiTest.java +++ b/src/test/java/play/pluv/api/PlayListApiTest.java @@ -14,8 +14,8 @@ import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import static play.pluv.music.domain.MusicStreaming.SPOTIFY; -import static play.pluv.music.domain.MusicStreaming.YOUTUBE; +import static play.pluv.playlist.domain.MusicStreaming.SPOTIFY; +import static play.pluv.playlist.domain.MusicStreaming.YOUTUBE; import java.util.List; import org.junit.jupiter.api.Test; diff --git a/src/test/java/play/pluv/api/fixture/MusicFixture.java b/src/test/java/play/pluv/api/fixture/MusicFixture.java index de85bc8..dd6e956 100644 --- a/src/test/java/play/pluv/api/fixture/MusicFixture.java +++ b/src/test/java/play/pluv/api/fixture/MusicFixture.java @@ -1,5 +1,7 @@ package play.pluv.api.fixture; +import static play.pluv.playlist.domain.MusicStreaming.SPOTIFY; + import java.util.List; import play.pluv.music.application.dto.MusicAddRequest; import play.pluv.music.application.dto.MusicSearchRequest; @@ -7,6 +9,9 @@ import play.pluv.music.application.dto.MusicSearchResponse; import play.pluv.music.application.dto.MusicSearchResponse.DestinationMusicResponse; import play.pluv.music.application.dto.MusicSearchResponse.SourceMusicResponse; +import play.pluv.music.domain.DestinationMusic; +import play.pluv.music.domain.MusicId; +import play.pluv.playlist.domain.PlayListMusic; public class MusicFixture { @@ -57,4 +62,29 @@ true, true, new SourceMusicResponse("좋은 날", "아이유"), List.of("musicId1", "musicId2", "musicId3", "musicId4") ); } + + public static List 이전된_음악_목록() { + return List.of( + DestinationMusic.builder() + .musicId(new MusicId(SPOTIFY, "musicId1")).title("ㅈㅣㅂ").imageUrl("imageUrl") + .isrcCode(null).artistNames(List.of("한로로")).build(), + DestinationMusic.builder() + .musicId(new MusicId(SPOTIFY, "musicId2")).title("좋은 날").imageUrl("imageUrl") + .isrcCode("KRDDAFA3").artistNames(List.of("아이유")).build(), + DestinationMusic.builder() + .musicId(new MusicId(SPOTIFY, "musicId3")).title("Always Awake").imageUrl("imageUrl") + .isrcCode(null).artistNames(List.of("재지팩트")).build() + ); + } + + public static List 이전되지_못한_음악_목록() { + return List.of( + PlayListMusic.builder() + .title("레이디버드").imageUrl("imageUrl").isrcCode(null).artistNames(List.of("잔나비")) + .build(), + PlayListMusic.builder() + .title("하루살이").imageUrl("imageUrl").isrcCode(null).artistNames(List.of("한로로")) + .build() + ); + } } diff --git a/src/test/java/play/pluv/fixture/PlayListFixture.java b/src/test/java/play/pluv/fixture/PlayListFixture.java index 552a294..eb78e01 100644 --- a/src/test/java/play/pluv/fixture/PlayListFixture.java +++ b/src/test/java/play/pluv/fixture/PlayListFixture.java @@ -1,6 +1,6 @@ package play.pluv.fixture; -import static play.pluv.music.domain.MusicStreaming.SPOTIFY; +import static play.pluv.playlist.domain.MusicStreaming.SPOTIFY; import play.pluv.playlist.domain.PlayList; import play.pluv.playlist.domain.PlayListId; diff --git a/src/test/java/play/pluv/login/application/LoginServiceTest.java b/src/test/java/play/pluv/login/application/LoginServiceTest.java index dcef431..cc2517f 100644 --- a/src/test/java/play/pluv/login/application/LoginServiceTest.java +++ b/src/test/java/play/pluv/login/application/LoginServiceTest.java @@ -1,7 +1,7 @@ package play.pluv.login.application; import static org.assertj.core.api.Assertions.assertThat; -import static play.pluv.music.domain.MusicStreaming.SPOTIFY; +import static play.pluv.playlist.domain.MusicStreaming.SPOTIFY; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/test/java/play/pluv/login/application/RegisterReaderTest.java b/src/test/java/play/pluv/login/application/RegisterReaderTest.java index a851b36..de112a6 100644 --- a/src/test/java/play/pluv/login/application/RegisterReaderTest.java +++ b/src/test/java/play/pluv/login/application/RegisterReaderTest.java @@ -2,7 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static play.pluv.fixture.MemberFixture.멤버_홍혁준; -import static play.pluv.music.domain.MusicStreaming.SPOTIFY; +import static play.pluv.playlist.domain.MusicStreaming.SPOTIFY; import java.util.Optional; import org.junit.jupiter.api.Nested; diff --git a/src/test/java/play/pluv/login/application/RegisterUpdaterTest.java b/src/test/java/play/pluv/login/application/RegisterUpdaterTest.java index 7b44a5b..5331011 100644 --- a/src/test/java/play/pluv/login/application/RegisterUpdaterTest.java +++ b/src/test/java/play/pluv/login/application/RegisterUpdaterTest.java @@ -1,9 +1,8 @@ package play.pluv.login.application; import static org.assertj.core.api.Assertions.assertThat; -import static play.pluv.music.domain.MusicStreaming.SPOTIFY; +import static play.pluv.playlist.domain.MusicStreaming.SPOTIFY; -import com.jayway.jsonpath.internal.Utils; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import play.pluv.member.domain.Member; diff --git a/src/test/java/play/pluv/music/application/MusicServiceTest.java b/src/test/java/play/pluv/music/application/MusicServiceTest.java index 765ef4b..5ed6508 100644 --- a/src/test/java/play/pluv/music/application/MusicServiceTest.java +++ b/src/test/java/play/pluv/music/application/MusicServiceTest.java @@ -1,7 +1,7 @@ package play.pluv.music.application; import static org.assertj.core.api.Assertions.assertThat; -import static play.pluv.music.domain.MusicStreaming.SPOTIFY; +import static play.pluv.playlist.domain.MusicStreaming.SPOTIFY; import java.util.List; import org.junit.jupiter.api.Test; diff --git a/src/test/java/play/pluv/music/domain/DestinationMusicTest.java b/src/test/java/play/pluv/music/domain/DestinationMusicTest.java index 9ffb25b..3048c15 100644 --- a/src/test/java/play/pluv/music/domain/DestinationMusicTest.java +++ b/src/test/java/play/pluv/music/domain/DestinationMusicTest.java @@ -1,7 +1,7 @@ package play.pluv.music.domain; import static org.assertj.core.api.Assertions.assertThat; -import static play.pluv.music.domain.MusicStreaming.SPOTIFY; +import static play.pluv.playlist.domain.MusicStreaming.SPOTIFY; import java.util.List; import org.junit.jupiter.api.Nested; diff --git a/src/test/java/play/pluv/playlist/application/PlayListServiceTest.java b/src/test/java/play/pluv/playlist/application/PlayListServiceTest.java index 8cb2679..530273d 100644 --- a/src/test/java/play/pluv/playlist/application/PlayListServiceTest.java +++ b/src/test/java/play/pluv/playlist/application/PlayListServiceTest.java @@ -3,7 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static play.pluv.fixture.PlayListFixture.스포티파이_플레이리스트_1; import static play.pluv.fixture.PlayListFixture.스포티파이_플레이리스트_2; -import static play.pluv.music.domain.MusicStreaming.SPOTIFY; +import static play.pluv.playlist.domain.MusicStreaming.SPOTIFY; import java.util.List; import org.junit.jupiter.api.Test; From 781ed62ac6208963b3343d8f1175d12102c45a51 Mon Sep 17 00:00:00 2001 From: hong-sile Date: Thu, 8 Aug 2024 21:19:03 +0900 Subject: [PATCH 2/3] =?UTF-8?q?style:=20=ED=8F=AC=EB=A7=B7=EC=97=90=20?= =?UTF-8?q?=EB=A7=9E=EA=B2=8C=20=EC=88=98=EC=A0=95(#68)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/play/pluv/oauth/spotify/SpotifyApiClient.java | 3 ++- src/main/java/play/pluv/oauth/spotify/SpotifyConnector.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/play/pluv/oauth/spotify/SpotifyApiClient.java b/src/main/java/play/pluv/oauth/spotify/SpotifyApiClient.java index 8e85700..211e055 100644 --- a/src/main/java/play/pluv/oauth/spotify/SpotifyApiClient.java +++ b/src/main/java/play/pluv/oauth/spotify/SpotifyApiClient.java @@ -33,7 +33,8 @@ SpotifyCreatePlayListResponse createPlayList( @RequestBody final SpotifyCreatePlayListRequest request ); - //최대 100개까지만 한 번에 가능 //추후 webflux로 바꾸기 + //최대 100개까지만 한 번에 가능 + //추후 webflux로 바꾸기 @PostExchange(url = "https://api.spotify.com/v1/playlists/{playListId}/tracks") void addMusics( @RequestHeader("Authorization") final String accessToken, diff --git a/src/main/java/play/pluv/oauth/spotify/SpotifyConnector.java b/src/main/java/play/pluv/oauth/spotify/SpotifyConnector.java index 390a548..0933631 100644 --- a/src/main/java/play/pluv/oauth/spotify/SpotifyConnector.java +++ b/src/main/java/play/pluv/oauth/spotify/SpotifyConnector.java @@ -14,7 +14,6 @@ import play.pluv.music.application.MusicExplorer; import play.pluv.music.domain.DestinationMusic; import play.pluv.music.domain.MusicId; -import play.pluv.playlist.domain.MusicStreaming; import play.pluv.music.domain.SourceMusic; import play.pluv.oauth.application.SocialLoginClient; import play.pluv.oauth.domain.OAuthMemberInfo; @@ -24,6 +23,7 @@ import play.pluv.oauth.spotify.dto.SpotifyPlayListResponses; import play.pluv.oauth.spotify.dto.SpotifyUserResponse; import play.pluv.playlist.application.PlayListConnector; +import play.pluv.playlist.domain.MusicStreaming; import play.pluv.playlist.domain.PlayList; import play.pluv.playlist.domain.PlayListId; import play.pluv.playlist.domain.PlayListMusic; From 6594fca908f1f0a35f1b0deb5c5c9729c649a6ed Mon Sep 17 00:00:00 2001 From: hong-sile Date: Thu, 8 Aug 2024 21:19:20 +0900 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20History=EB=A5=BC=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=ED=95=98=EB=8A=94=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80(#68)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../history/application/HistoryUpdater.java | 44 +++++++++++++ .../play/pluv/history/domain/History.java | 44 +++++++++++++ .../domain/repository/HistoryRepository.java | 8 +++ .../pluv/fixture/MemberEntityFixture.java | 12 ++++ .../application/HistoryUpdaterTest.java | 64 +++++++++++++++++++ 5 files changed, 172 insertions(+) create mode 100644 src/main/java/play/pluv/history/application/HistoryUpdater.java create mode 100644 src/main/java/play/pluv/history/domain/History.java create mode 100644 src/main/java/play/pluv/history/domain/repository/HistoryRepository.java create mode 100644 src/test/java/play/pluv/fixture/MemberEntityFixture.java create mode 100644 src/test/java/play/pluv/history/application/HistoryUpdaterTest.java diff --git a/src/main/java/play/pluv/history/application/HistoryUpdater.java b/src/main/java/play/pluv/history/application/HistoryUpdater.java new file mode 100644 index 0000000..17a1870 --- /dev/null +++ b/src/main/java/play/pluv/history/application/HistoryUpdater.java @@ -0,0 +1,44 @@ +package play.pluv.history.application; + +import java.util.List; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; +import play.pluv.history.domain.History; +import play.pluv.history.domain.repository.HistoryRepository; +import play.pluv.member.domain.Member; +import play.pluv.music.domain.DestinationMusic; +import play.pluv.playlist.domain.PlayListMusic; + +@Component +public class HistoryUpdater { + + private final HistoryRepository historyRepository; + + public HistoryUpdater(final HistoryRepository historyRepository) { + this.historyRepository = historyRepository; + } + + @Transactional + public Long createHistory( + final String title, final String thumbNailUrl, final Member member, + final List cantTransferredMusics, final int canTransferSongCount + ) { + final History history = History.builder() + .transferFailSongCount(cantTransferredMusics.size()) + .thumbNailUrl(thumbNailUrl) + .memberId(member.getId()) + .transferredSongCount(canTransferSongCount) + .title(title) + .build(); + + final History savedHistory = historyRepository.save(history); + + return savedHistory.getId(); + } + + public void appendTransferredMusics( + final Long historyId, final List transferredMusics + ) { + + } +} diff --git a/src/main/java/play/pluv/history/domain/History.java b/src/main/java/play/pluv/history/domain/History.java new file mode 100644 index 0000000..5fc76e8 --- /dev/null +++ b/src/main/java/play/pluv/history/domain/History.java @@ -0,0 +1,44 @@ +package play.pluv.history.domain; + +import static jakarta.persistence.GenerationType.IDENTITY; +import static lombok.AccessLevel.PROTECTED; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import play.pluv.base.BaseEntity; + +@Entity +@NoArgsConstructor(access = PROTECTED) +@Getter +public class History extends BaseEntity { + + @Id + @GeneratedValue(strategy = IDENTITY) + private Long id; + + private String title; + + private String thumbNailUrl; + + private int transferredSongCount; + + private int transferFailSongCount; + + private Long memberId; + + @Builder + public History( + final String title, final String thumbNailUrl, final int transferredSongCount, + final int transferFailSongCount, final Long memberId + ) { + this.title = title; + this.thumbNailUrl = thumbNailUrl; + this.transferredSongCount = transferredSongCount; + this.transferFailSongCount = transferFailSongCount; + this.memberId = memberId; + } +} diff --git a/src/main/java/play/pluv/history/domain/repository/HistoryRepository.java b/src/main/java/play/pluv/history/domain/repository/HistoryRepository.java new file mode 100644 index 0000000..4c4d764 --- /dev/null +++ b/src/main/java/play/pluv/history/domain/repository/HistoryRepository.java @@ -0,0 +1,8 @@ +package play.pluv.history.domain.repository; + +import org.springframework.data.jpa.repository.JpaRepository; +import play.pluv.history.domain.History; + +public interface HistoryRepository extends JpaRepository { + +} diff --git a/src/test/java/play/pluv/fixture/MemberEntityFixture.java b/src/test/java/play/pluv/fixture/MemberEntityFixture.java new file mode 100644 index 0000000..d52030e --- /dev/null +++ b/src/test/java/play/pluv/fixture/MemberEntityFixture.java @@ -0,0 +1,12 @@ +package play.pluv.fixture; + +import play.pluv.member.domain.Member; +import play.pluv.member.domain.MemberRepository; +import play.pluv.member.domain.NickName; + +public class MemberEntityFixture { + + public static Member 멤버_홍혁준(final MemberRepository memberRepository) { + return new Member(new NickName("홍혁준")); + } +} diff --git a/src/test/java/play/pluv/history/application/HistoryUpdaterTest.java b/src/test/java/play/pluv/history/application/HistoryUpdaterTest.java new file mode 100644 index 0000000..ff1881c --- /dev/null +++ b/src/test/java/play/pluv/history/application/HistoryUpdaterTest.java @@ -0,0 +1,64 @@ +package play.pluv.history.application; + +import static org.assertj.core.api.Assertions.assertThat; +import static play.pluv.api.fixture.MusicFixture.이전되지_못한_음악_목록; +import static play.pluv.fixture.MemberEntityFixture.멤버_홍혁준; + +import java.util.List; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import play.pluv.history.domain.History; +import play.pluv.history.domain.repository.HistoryRepository; +import play.pluv.member.domain.Member; +import play.pluv.member.domain.MemberRepository; +import play.pluv.playlist.domain.PlayListMusic; +import play.pluv.support.ApplicationTest; + +public class HistoryUpdaterTest extends ApplicationTest { + + @Autowired + private HistoryUpdater historyUpdater; + @Autowired + private HistoryRepository historyRepository; + @Autowired + private MemberRepository memberRepository; + + @Test + void DestinationMusic으로_히스토리를_생성한다() { + final List cantTransferredMusics = 이전되지_못한_음악_목록(); + final int canTransferSongCount = 3; + final Member member = 멤버_홍혁준(memberRepository); + + final Long historyId = historyUpdater.createHistory( + "title", "imageUrl", member, cantTransferredMusics, canTransferSongCount + ); + + final History history = historyRepository.findById(historyId).orElseThrow(); + final History expected = new History("title", "imageUrl", 3, 2, member.getId()); + + assertThat(history) + .usingRecursiveComparison() + .ignoringFields("id", "createdAt", "updatedAt") + .isEqualTo(expected); + } + +// @Test +// void 히스토리를_생성하는_경우_이전_못한_음악들이_저장된다() { +// final List cantTransferredMusics = 이전되지_못한_음악_목록(); +// final int canTransferSongCount = 3; +// final Member member = 멤버_홍혁준(memberRepository); +// +// final Long historyId = historyUpdater.createHistory( +// "title", "imageUrl", member, cantTransferredMusics, canTransferSongCount +// ); +// +// final var actual = failTransferMusicRepository.findByHistoryId(historyId); +// final var expected = List.of( +// new FailTransferMusic() +// ); +// +// assertThat(actual) +// .usingRecursiveFieldByFieldElementComparatorIgnoringFields("id", "createdAt", "updatedAt") +// .isEqualTo(expected); +// } +}