Skip to content

Commit

Permalink
Merge pull request #92 from whatever-mentoring/feature/goal-gifticon-…
Browse files Browse the repository at this point in the history
…application-service-test

Write test codes of GoalGifticonApplicationService
  • Loading branch information
mkSpace committed Apr 18, 2024
2 parents 9d86302 + ed2f9fe commit 0a988fc
Show file tree
Hide file tree
Showing 7 changed files with 406 additions and 12 deletions.
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

0 comments on commit 0a988fc

Please sign in to comment.