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

Cealnup codes #88

Merged
merged 1 commit into from
Mar 27, 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
@@ -1,7 +1,6 @@
package com.whatever.raisedragon.applicationservice.betting

import com.whatever.raisedragon.applicationservice.betting.dto.BettingCreateServiceRequest
import com.whatever.raisedragon.applicationservice.betting.dto.BettingCreateUpdateResponse
import com.whatever.raisedragon.applicationservice.betting.dto.BettingRetrieveResponse
import com.whatever.raisedragon.applicationservice.betting.dto.BettingUpdateServiceRequest
import com.whatever.raisedragon.common.exception.BaseException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ class GoalApplicationService(
hostUserNickname = hostUser.nickname.value,
betting = betting,
isSuccess = isSuccess,
winnerNickname = winnerNickname)
winnerNickname = winnerNickname
)
}

fun retrieveAllByUserId(userId: Long): List<GoalResponse> {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class UserInfoArgumentResolver : HandlerMethodArgumentResolver {

override fun supportsParameter(parameter: MethodParameter): Boolean {
return parameter.hasParameterAnnotation(GetAuth::class.java)
&& parameter.parameter.type == UserInfo::class.java
&& parameter.parameter.type == UserInfo::class.java
}

override fun resolveArgument(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,7 @@ package com.whatever.raisedragon
import com.fasterxml.jackson.databind.ObjectMapper
import com.whatever.raisedragon.applicationservice.betting.BettingApplicationService
import com.whatever.raisedragon.controller.betting.BettingController
import com.whatever.raisedragon.domain.user.Nickname
import com.whatever.raisedragon.domain.user.User
import com.whatever.raisedragon.security.authentication.UserInfo
import com.whatever.raisedragon.security.jwt.JwtAgent
import com.whatever.raisedragon.security.jwt.JwtToken
import com.whatever.raisedragon.security.resolver.UserInfoArgumentResolver
import org.junit.jupiter.api.BeforeEach
import org.mockito.Mockito.*
import org.mockito.Spy
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest
import org.springframework.boot.test.mock.mockito.MockBean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.whatever.raisedragon.applicationservice.betting

import com.whatever.raisedragon.applicationservice.betting.dto.BettingCreateServiceRequest
import com.whatever.raisedragon.applicationservice.betting.dto.BettingCreateUpdateResponse
import com.whatever.raisedragon.applicationservice.betting.dto.BettingRetrieveResponse
import com.whatever.raisedragon.applicationservice.betting.dto.BettingUpdateServiceRequest
import com.whatever.raisedragon.common.exception.BaseException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.springframework.web.multipart.MultipartFile

@Service
@Profile("test")
class FakeFileUploader: FileUploader {
class FakeFileUploader : FileUploader {
override fun upload(multipartFile: MultipartFile): String {
return ""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ class BettingServiceTest : IntegrationTestSupport {
val userEntity = UserEntity(nickname = Nickname("User1"))
userRepository.save(userEntity)

val goalEntity = createGoalEntity(userEntity,
val goalEntity = createGoalEntity(
userEntity,
BILLING,
PROCEEDING,
LocalDateTime.now(),
LocalDateTime.now().plusDays(7))
LocalDateTime.now().plusDays(7)
)
goalRepository.save(goalEntity)

// when
Expand All @@ -69,11 +71,13 @@ class BettingServiceTest : IntegrationTestSupport {
val userEntity = UserEntity(nickname = Nickname("User1"))
userRepository.save(userEntity)

val goalEntity = createGoalEntity(userEntity,
val goalEntity = createGoalEntity(
userEntity,
BILLING,
PROCEEDING,
LocalDateTime.now(),
LocalDateTime.now().plusDays(7))
LocalDateTime.now().plusDays(7)
)
goalRepository.save(goalEntity)

// when // then
Expand All @@ -93,11 +97,13 @@ class BettingServiceTest : IntegrationTestSupport {
val userEntity = UserEntity(nickname = Nickname("User1"))
userRepository.save(userEntity)

val goalEntity = createGoalEntity(userEntity,
val goalEntity = createGoalEntity(
userEntity,
BILLING,
PROCEEDING,
LocalDateTime.now(),
LocalDateTime.now().plusDays(7))
LocalDateTime.now().plusDays(7)
)
goalRepository.save(goalEntity)

// when // then
Expand All @@ -117,11 +123,13 @@ class BettingServiceTest : IntegrationTestSupport {
val userEntity = UserEntity(nickname = Nickname("User1"))
userRepository.save(userEntity)

val goalEntity = createGoalEntity(userEntity,
val goalEntity = createGoalEntity(
userEntity,
BILLING,
PROCEEDING,
LocalDateTime.now(),
LocalDateTime.now().plusDays(7))
LocalDateTime.now().plusDays(7)
)
goalRepository.save(goalEntity)

val bettingEntity = BettingEntity(
Expand Down Expand Up @@ -150,11 +158,13 @@ class BettingServiceTest : IntegrationTestSupport {
val userEntity2 = UserEntity(nickname = Nickname("User2"))
userRepository.saveAll(listOf(userEntity1, userEntity2))

val goalEntity = createGoalEntity(userEntity1,
val goalEntity = createGoalEntity(
userEntity1,
BILLING,
PROCEEDING,
LocalDateTime.now(),
LocalDateTime.now().plusDays(7))
LocalDateTime.now().plusDays(7)
)
goalRepository.save(goalEntity)

val bettingEntity = BettingEntity(
Expand All @@ -180,11 +190,13 @@ class BettingServiceTest : IntegrationTestSupport {
val userEntity2 = UserEntity(nickname = Nickname("User2"))
userRepository.saveAll(listOf(userEntity1, userEntity2))

val goalEntity = createGoalEntity(userEntity1,
val goalEntity = createGoalEntity(
userEntity1,
BILLING,
PROCEEDING,
LocalDateTime.now(),
LocalDateTime.now().plusDays(7))
LocalDateTime.now().plusDays(7)
)
goalRepository.save(goalEntity)

val bettingEntity = BettingEntity(
Expand All @@ -208,11 +220,13 @@ class BettingServiceTest : IntegrationTestSupport {
val userEntity2 = UserEntity(nickname = Nickname("User2"))
userRepository.saveAll(listOf(userEntity1, userEntity2))

val goalEntity = createGoalEntity(userEntity1,
val goalEntity = createGoalEntity(
userEntity1,
BILLING,
PROCEEDING,
LocalDateTime.now(),
LocalDateTime.now().plusDays(7))
LocalDateTime.now().plusDays(7)
)
goalRepository.save(goalEntity)

val bettingEntity = BettingEntity(
Expand Down Expand Up @@ -284,14 +298,18 @@ class BettingServiceTest : IntegrationTestSupport {
assertThat(foundBettingList).hasSize(2)
.extractingBettingProperties()
.containsExactlyInAnyOrder(
tuple(bettingEntity1.userEntity.id,
tuple(
bettingEntity1.userEntity.id,
bettingEntity1.goalEntity.id,
BettingPredictionType.FAIL,
BettingResult.PROCEEDING),
tuple(bettingEntity2.userEntity.id,
BettingResult.PROCEEDING
),
tuple(
bettingEntity2.userEntity.id,
bettingEntity2.goalEntity.id,
BettingPredictionType.SUCCESS,
BettingResult.NO_GIFTICON),
BettingResult.NO_GIFTICON
),
)
}

Expand Down Expand Up @@ -1024,10 +1042,16 @@ class BettingServiceTest : IntegrationTestSupport {
bettingService.hardDeleteByUserId(userEntity.id)

// then
assertThat(bettingRepository.findAllById(setOf(bettingEntity1.id,
bettingEntity2.id,
bettingEntity3.id,
bettingEntity4.id)))
assertThat(
bettingRepository.findAllById(
setOf(
bettingEntity1.id,
bettingEntity2.id,
bettingEntity3.id,
bettingEntity4.id
)
)
)
.isEmpty()
}

Expand Down Expand Up @@ -1079,15 +1103,19 @@ class BettingServiceTest : IntegrationTestSupport {

private fun ObjectAssert<*>.isInstanceOfBetting() = isInstanceOf(Betting::class.java)

private fun ObjectAssert<*>.extractingBettingProperties() = extracting("userId",
private fun ObjectAssert<*>.extractingBettingProperties() = extracting(
"userId",
"goalId",
"bettingPredictionType",
"bettingResult")
"bettingResult"
)

private fun ListAssert<*>.extractingBettingProperties() = extracting("userId",
private fun ListAssert<*>.extractingBettingProperties() = extracting(
"userId",
"goalId",
"bettingPredictionType",
"bettingResult")
"bettingResult"
)

private fun createGoalEntity(
userEntity: UserEntity,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ class GoalGifticonServiceTest : IntegrationTestSupport {
goalGifticonEntity1,
goalGifticonEntity2,
goalGifticonEntity3,
goalGifticonEntity4)
goalGifticonEntity4
)
)
// when
val foundGoalGifticon = goalGifticonService.findByGoalId(goalEntity1.id)
Expand Down Expand Up @@ -164,7 +165,8 @@ class GoalGifticonServiceTest : IntegrationTestSupport {
goalGifticonEntity1,
goalGifticonEntity2,
goalGifticonEntity3,
goalGifticonEntity4)
goalGifticonEntity4
)
)
// when
val foundGoalGifticon = goalGifticonService.findByGoalId(goalEntity1.id)
Expand Down Expand Up @@ -199,7 +201,8 @@ class GoalGifticonServiceTest : IntegrationTestSupport {
goalGifticonEntity1,
goalGifticonEntity2,
goalGifticonEntity3,
goalGifticonEntity4)
goalGifticonEntity4
)
)
// when // then
assertThatThrownBy { goalGifticonService.findByGoalId(-1L) }
Expand Down
Loading
Loading