Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write test codes of GoalGifticonApplicationService #92

Merged
merged 3 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class GoalGifticonApplicationService(
userId: Long
): GifticonResponse {
val goal = goalService.findById(goalId)
isBrokenTiming(goal)

val goalGifticon = if (userId != goal.userId) {
null
Expand All @@ -86,15 +85,11 @@ class GoalGifticonApplicationService(

@Transactional
fun updateGifticonURLByGoalId(request: GoalGifticonUpdateServiceRequest): GoalGifticonResponse {
val userEntity = userService.findById(request.userId).fromDto()
val goal = goalService.findById(request.goalId).fromDto(userEntity).toDto()
val goal = goalService.findById(request.goalId)
validateIsRequestUserHasUpdateAuthority(goal, request.userId)
val goalGifticon = goalGifticonService.findByGoalId(goal.id)
?: throw BaseException.of(ExceptionCode.E404_NOT_FOUND, "다짐에 등록된 기프티콘을 찾을 수 없습니다.")
val gifticon = gifticonService.findById(goalGifticon.gifticonId)

validateIsRequestUserHasUpdateAuthority(goal, request.userId)

gifticon.url = URL(request.gifticonURL)
val gifticon = gifticonService.update(goalGifticon.gifticonId, URL(request.gifticonURL))

return GoalGifticonResponse(
goalGifticonId = goalGifticon.id,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.whatever.raisedragon.applicationservice.betting
package com.whatever.raisedragon.applicationservice

import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.ActiveProfiles
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.whatever.raisedragon.applicationservice.betting

import com.whatever.raisedragon.applicationservice.ApplicationServiceTestSupport
import com.whatever.raisedragon.applicationservice.betting.dto.BettingCreateServiceRequest
import com.whatever.raisedragon.applicationservice.betting.dto.BettingRetrieveResponse
import com.whatever.raisedragon.applicationservice.betting.dto.BettingUpdateServiceRequest
Expand All @@ -13,7 +14,6 @@ import com.whatever.raisedragon.domain.user.UserEntity
import com.whatever.raisedragon.domain.user.UserRepository
import jakarta.transaction.Transactional
import org.assertj.core.api.Assertions.*
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
Expand Down
Loading
Loading