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

fix: 버전 업그레이드로 인한 mockito.kotlin.whenever import 오류 fix #21

Closed
wants to merge 1 commit into from
Closed
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
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
Loading