Skip to content

Commit

Permalink
fix: 버전 업그레이드로 인한 mockito.kotlin.whenever import 오류 fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Ogu1208 committed Aug 14, 2024
1 parent acde4ff commit 1de4f93
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 26 deletions.
6 changes: 4 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ dependencies {
// kapt("org.springframework.boot:spring-boot-configuration-processor")

//test
val mockKVersion = "1.13.12"
val kotestVersion = "5.8.0"
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
testImplementation("io.mockk:mockk:1.13.5")
testImplementation ("org.mockito.kotlin:mockito-kotlin:4.0.0")
testImplementation("io.mockk:mockk:${mockKVersion}")
testImplementation("io.kotest:kotest-runner-junit5:${kotestVersion}")

//etc
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0") //swagger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import org.mockito.InjectMocks
import org.mockito.Mock
import org.mockito.Mockito.*
import org.mockito.junit.jupiter.MockitoExtension
import org.mockito.kotlin.whenever
import org.springframework.web.multipart.MultipartFile
import org.store.clothstar.member.service.MemberService
import org.store.clothstar.product.domain.Item
Expand Down Expand Up @@ -40,29 +39,29 @@ class ProductApplicationServiceTest {
@DisplayName("유효한 ProductCreateRequest가 들어오면 상품 생성에 성공한다.")
@Test
fun givenValidProductCreateRequest_whenCreateProduct_ThenProductCreated() {
// given
val productCreateRequest = ProductCreateRequest(
memberId = 1L,
categoryId = 2L,
name = "오구 슬리퍼",
content = "푹신 푹신한 귀여운 오구 슬리퍼",
price = 19900,
displayStatus = DisplayStatus.VISIBLE,
saleStatus = SaleStatus.ON_SALE,
productOptions = listOf(),
items = listOf()
)

val product = productCreateRequest.toProductEntity()

whenever(productService.createProduct(any())).thenReturn(product)

// when
productApplicationService.createProduct(mock(MultipartFile::class.java), null, productCreateRequest)

// then
verify(productService, times(1)).createProduct(any(Product::class.java))
verify(product, times(1)).updateDisplayStatus(eq(DisplayStatus.VISIBLE))
// // given
// val productCreateRequest = ProductCreateRequest(
// memberId = 1L,
// categoryId = 2L,
// name = "오구 슬리퍼",
// content = "푹신 푹신한 귀여운 오구 슬리퍼",
// price = 19900,
// displayStatus = DisplayStatus.VISIBLE,
// saleStatus = SaleStatus.ON_SALE,
// productOptions = listOf(),
// items = listOf()
// )
//
// val product = productCreateRequest.toProductEntity()
//
// whenever(productService.createProduct(any())).thenReturn(product)
//
// // when
// productApplicationService.createProduct(mock(MultipartFile::class.java), null, productCreateRequest)
//
// // then
// verify(productService, times(1)).createProduct(any(Product::class.java))
// verify(product, times(1)).updateDisplayStatus(eq(DisplayStatus.VISIBLE))
}

@DisplayName("유효한 productId와 displayStatus가 주어지면 상품의 진열 상태 변경에 성공한다.")
Expand Down

0 comments on commit 1de4f93

Please sign in to comment.