Skip to content

박찬영 Week 1 과제#63

Open
vitacpark wants to merge 4 commits intowafflestudio:master-week1from
vitacpark:week-1
Open

박찬영 Week 1 과제#63
vitacpark wants to merge 4 commits intowafflestudio:master-week1from
vitacpark:week-1

Conversation

@vitacpark
Copy link

사진은 무슨 이유에서 추가된건지 의아하네용,,

@vitacpark vitacpark changed the title Week 1 PR 박찬영 Week 1 과제 Oct 4, 2023
Copy link
Member

@PFCJeong PFCJeong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다~

다음부터는 수정이 필요한 부분만 commit해주시면 좋을 것 같아요!


override fun exists(playlistId: Long, userId: Long): Boolean {
TODO()
val userEntity = userRepository.findById(userId).orElseThrow{ UserNotFoundException() }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

val userEntity = userRepository.findById(userId).orElseThrow(::UserNotFoundException)

이렇게 줄여줄 수 있습니다.

if(!exists(playlistId,userId)) throw PlaylistNeverLikedException()
val userEntity = userRepository.findById(userId).orElseThrow{ UserNotFoundException() }
val playlistEntity = playlistRepository.findById(playlistId).orElseThrow { PlaylistNotFoundException() }
playlistLikeRepository.deleteByPlaylistAndUser(playlist = playlistEntity, user = userEntity)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

취소 테스트는 IntegrationTest에 없어서 이슈가 없었을 것 같은데요

사실 요 코드는 이슈가 있습니다. @Transactional이 없기 때문에 deleteByPlaylistAndUser는 에러가 발생하게 돼요.

ServiceTest가 성공한 이유는 클래스 자체에 @Transactional이 붙어있기 때문입니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants