diff --git a/api/src/test/kotlin/com/few/api/domain/article/usecase/ReadArticleUseCaseTest.kt b/api/src/test/kotlin/com/few/api/domain/article/usecase/ReadArticleUseCaseTest.kt index c7ded8eeb..914fa4812 100644 --- a/api/src/test/kotlin/com/few/api/domain/article/usecase/ReadArticleUseCaseTest.kt +++ b/api/src/test/kotlin/com/few/api/domain/article/usecase/ReadArticleUseCaseTest.kt @@ -24,14 +24,14 @@ class ReadArticleUseCaseTest : BehaviorSpec({ lateinit var useCase: ReadArticleUseCase val useCaseIn = ReadArticleUseCaseIn(articleId = 1L) - given("아티클 조회 요청이 온 상황에서") { - beforeContainer { - articleDao = mockk() - readArticleWriterRecordService = mockk() - browseArticleProblemsService = mockk() - useCase = ReadArticleUseCase(articleDao, readArticleWriterRecordService, browseArticleProblemsService) - } + beforeContainer { + articleDao = mockk() + readArticleWriterRecordService = mockk() + browseArticleProblemsService = mockk() + useCase = ReadArticleUseCase(articleDao, readArticleWriterRecordService, browseArticleProblemsService) + } + given("아티클 조회 요청이 온 상황에서") { `when`("아티클과 작가가 존재할 경우") { val record = SelectArticleRecord( articleId = 1L, diff --git a/api/src/test/kotlin/com/few/api/domain/problem/usecase/BrowseProblemsUseCaseTest.kt b/api/src/test/kotlin/com/few/api/domain/problem/usecase/BrowseProblemsUseCaseTest.kt index ee581b60c..ca54ea69e 100644 --- a/api/src/test/kotlin/com/few/api/domain/problem/usecase/BrowseProblemsUseCaseTest.kt +++ b/api/src/test/kotlin/com/few/api/domain/problem/usecase/BrowseProblemsUseCaseTest.kt @@ -13,15 +13,14 @@ class BrowseProblemsUseCaseTest : BehaviorSpec({ lateinit var problemDao: ProblemDao lateinit var useCase: BrowseProblemsUseCase - lateinit var useCaseIn: BrowseProblemsUseCaseIn + val useCaseIn = BrowseProblemsUseCaseIn(articleId = 1L) - given("특정 아티클에 대한") { - beforeContainer { - problemDao = mockk() - useCase = BrowseProblemsUseCase(problemDao) - useCaseIn = BrowseProblemsUseCaseIn(articleId = 1L) - } + beforeContainer { + problemDao = mockk() + useCase = BrowseProblemsUseCase(problemDao) + } + given("특정 아티클에 대한") { `when`("문제가 존재할 경우") { val problemIdsRecord = ProblemIdsRecord(listOf(1, 2, 3)) every { problemDao.selectProblemsByArticleId(any()) } returns problemIdsRecord diff --git a/api/src/test/kotlin/com/few/api/domain/problem/usecase/CheckProblemUseCaseTest.kt b/api/src/test/kotlin/com/few/api/domain/problem/usecase/CheckProblemUseCaseTest.kt index d1dfd65ae..5bdd418b4 100644 --- a/api/src/test/kotlin/com/few/api/domain/problem/usecase/CheckProblemUseCaseTest.kt +++ b/api/src/test/kotlin/com/few/api/domain/problem/usecase/CheckProblemUseCaseTest.kt @@ -17,14 +17,13 @@ class CheckProblemUseCaseTest : BehaviorSpec({ lateinit var submitHistoryDao: SubmitHistoryDao lateinit var useCase: CheckProblemUseCase - given("문제 정답 확인 요청이 온 상황에서") { - - beforeContainer { - problemDao = mockk() - submitHistoryDao = mockk() - useCase = CheckProblemUseCase(problemDao, submitHistoryDao) - } + beforeContainer { + problemDao = mockk() + submitHistoryDao = mockk() + useCase = CheckProblemUseCase(problemDao, submitHistoryDao) + } + given("문제 정답 확인 요청이 온 상황에서") { `when`("제출 값과 문제 정답이 같을 경우") { val submissionVal = "1" val answer = submissionVal diff --git a/api/src/test/kotlin/com/few/api/domain/problem/usecase/ReadProblemUseCaseTest.kt b/api/src/test/kotlin/com/few/api/domain/problem/usecase/ReadProblemUseCaseTest.kt index d9d66ccda..d97f6490c 100644 --- a/api/src/test/kotlin/com/few/api/domain/problem/usecase/ReadProblemUseCaseTest.kt +++ b/api/src/test/kotlin/com/few/api/domain/problem/usecase/ReadProblemUseCaseTest.kt @@ -17,16 +17,15 @@ class ReadProblemUseCaseTest : BehaviorSpec({ lateinit var problemDao: ProblemDao lateinit var contentsJsonMapper: ContentsJsonMapper lateinit var useCase: ReadProblemUseCase - lateinit var useCaseIn: ReadProblemUseCaseIn + val useCaseIn = ReadProblemUseCaseIn(problemId = 1L) - given("문제를 조회할 상황에서") { - beforeContainer { - problemDao = mockk() - contentsJsonMapper = mockk() - useCase = ReadProblemUseCase(problemDao, contentsJsonMapper) - useCaseIn = ReadProblemUseCaseIn(problemId = 1L) - } + beforeContainer { + problemDao = mockk() + contentsJsonMapper = mockk() + useCase = ReadProblemUseCase(problemDao, contentsJsonMapper) + } + given("문제를 조회할 상황에서") { `when`("문제가 존재할 경우") { val problemRecord = SelectProblemRecord(id = 1L, title = "title", contents = "{}") val contents = Contents( diff --git a/api/src/test/kotlin/com/few/api/domain/subscription/usecase/SubscribeWorkbookUseCaseTest.kt b/api/src/test/kotlin/com/few/api/domain/subscription/usecase/SubscribeWorkbookUseCaseTest.kt index d17870528..cb781f828 100644 --- a/api/src/test/kotlin/com/few/api/domain/subscription/usecase/SubscribeWorkbookUseCaseTest.kt +++ b/api/src/test/kotlin/com/few/api/domain/subscription/usecase/SubscribeWorkbookUseCaseTest.kt @@ -21,19 +21,18 @@ class SubscribeWorkbookUseCaseTest : BehaviorSpec({ lateinit var memberService: MemberService lateinit var applicationEventPublisher: ApplicationEventPublisher lateinit var useCase: SubscribeWorkbookUseCase + val workbookId = 1L + val useCaseIn = SubscribeWorkbookUseCaseIn(workbookId = workbookId, email = "test@test.com") + + beforeContainer { + subscriptionDao = mockk() + memberService = mockk() + applicationEventPublisher = mockk() + useCase = SubscribeWorkbookUseCase(subscriptionDao, memberService, applicationEventPublisher) + } given("구독 요청이 온 상황에서") { - - beforeContainer { - subscriptionDao = mockk() - memberService = mockk() - applicationEventPublisher = mockk() - useCase = SubscribeWorkbookUseCase(subscriptionDao, memberService, applicationEventPublisher) - } - `when`("subscriptionStatus가 null일 경우") { - val workbookId = 1L - val useCaseIn = SubscribeWorkbookUseCaseIn(workbookId = workbookId, email = "test@test.com") val serviceOutDto = MemberIdOutDto(memberId = 1L) val event = WorkbookSubscriptionEvent(workbookId) @@ -57,8 +56,6 @@ class SubscribeWorkbookUseCaseTest : BehaviorSpec({ } `when`("구독을 취소한 경우") { - val workbookId = 1L - val useCaseIn = SubscribeWorkbookUseCaseIn(workbookId = workbookId, email = "test@test.com") val day = 2 val lastDay = 3 val serviceOutDto = MemberIdOutDto(memberId = 1L) @@ -86,8 +83,6 @@ class SubscribeWorkbookUseCaseTest : BehaviorSpec({ } `when`("이미 구독하고 있을 경우") { - val workbookId = 1L - val useCaseIn = SubscribeWorkbookUseCaseIn(workbookId = workbookId, email = "test@test.com") val day = 2 val lastDay = 3 val serviceOutDto = MemberIdOutDto(memberId = 1L) diff --git a/api/src/test/kotlin/com/few/api/domain/workbook/usecase/ReadWorkbookUseCaseTest.kt b/api/src/test/kotlin/com/few/api/domain/workbook/usecase/ReadWorkbookUseCaseTest.kt index ff0a248bf..2099903d2 100644 --- a/api/src/test/kotlin/com/few/api/domain/workbook/usecase/ReadWorkbookUseCaseTest.kt +++ b/api/src/test/kotlin/com/few/api/domain/workbook/usecase/ReadWorkbookUseCaseTest.kt @@ -23,14 +23,14 @@ class ReadWorkbookUseCaseTest : BehaviorSpec({ lateinit var useCase: ReadWorkbookUseCase val useCaseIn = ReadWorkbookUseCaseIn(workbookId = 1L) - given("워크북 조회 요청이 온 상황에서") { - beforeContainer { - workbookDao = mockk() - workbookArticleService = mockk() - workbookMemberService = mockk() - useCase = ReadWorkbookUseCase(workbookDao, workbookArticleService, workbookMemberService) - } + beforeContainer { + workbookDao = mockk() + workbookArticleService = mockk() + workbookMemberService = mockk() + useCase = ReadWorkbookUseCase(workbookDao, workbookArticleService, workbookMemberService) + } + given("워크북 조회 요청이 온 상황에서") { `when`("워크북과 작가가 존재할 경우") { every { workbookDao.selectWorkBook(any()) } returns SelectWorkBookRecord( id = 1L,