diff --git a/Whatnow-Api/src/main/kotlin/com/depromeet/whatnow/api/image/controller/ImageController.kt b/Whatnow-Api/src/main/kotlin/com/depromeet/whatnow/api/image/controller/ImageController.kt index ad6d1a3b..94549e46 100644 --- a/Whatnow-Api/src/main/kotlin/com/depromeet/whatnow/api/image/controller/ImageController.kt +++ b/Whatnow-Api/src/main/kotlin/com/depromeet/whatnow/api/image/controller/ImageController.kt @@ -3,17 +3,20 @@ package com.depromeet.whatnow.api.image.controller import com.depromeet.whatnow.api.image.dto.ImageUrlResponse import com.depromeet.whatnow.api.image.usecase.GetPresignedUrlUseCase import com.depromeet.whatnow.api.image.usecase.ImageUploadSuccessUseCase +import com.depromeet.whatnow.common.vo.CoordinateVo import com.depromeet.whatnow.config.s3.ImageFileExtension -import com.depromeet.whatnow.domains.image.domain.ImageCommentType +import com.depromeet.whatnow.domains.image.domain.PromiseImageCommentType import io.swagger.v3.oas.annotations.Operation import io.swagger.v3.oas.annotations.security.SecurityRequirement import io.swagger.v3.oas.annotations.tags.Tag import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PathVariable import org.springframework.web.bind.annotation.PostMapping +import org.springframework.web.bind.annotation.RequestBody import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RequestParam import org.springframework.web.bind.annotation.RestController +import javax.validation.Valid @RestController @Tag(name = "6. [이미지]") @@ -23,8 +26,8 @@ class ImageController( val getPresignedUrlUseCase: GetPresignedUrlUseCase, val successUseCase: ImageUploadSuccessUseCase, ) { - @Operation(summary = "약속 관련 이미지 업로드 Presigned URL 발급") - @GetMapping("/promises/{promiseId}/images") + @Operation(summary = "약속 이미지 업로드 Presigned URL 발급") + @GetMapping("/images/promises/{promiseId}") fun getPresignedUrlOfPromise( @PathVariable promiseId: Long, @RequestParam fileExtension: ImageFileExtension, @@ -33,21 +36,27 @@ class ImageController( } @Operation(summary = "유저 프로필 이미지 업로드 Presigned URL 발급") - @GetMapping("/users/me/images") + @GetMapping("/images/users/me") fun getPresignedUrlOfUser( @RequestParam fileExtension: ImageFileExtension, ): ImageUrlResponse { return getPresignedUrlUseCase.forUser(fileExtension) } - @Operation(summary = "약속 관련 이미지 업로드 성공 요청") - @PostMapping("/promises/{promiseId}/images/success/{imageKey}") - fun promiseUploadImageSuccess(@PathVariable promiseId: Long, @PathVariable imageKey: String, @RequestParam imageCommentType: ImageCommentType) { - successUseCase.promiseUploadImageSuccess(promiseId, imageKey, imageCommentType) + @Operation(summary = "약속 이미지 업로드 성공 요청") + @PostMapping("/images/{imageKey}/promises/{promiseId}") + fun promiseUploadImageSuccess( + @PathVariable promiseId: Long, + @PathVariable imageKey: String, + @RequestParam promiseImageCommentType: PromiseImageCommentType, + @RequestBody @Valid + userLocation: CoordinateVo, + ) { + successUseCase.promiseUploadImageSuccess(promiseId, imageKey, promiseImageCommentType, userLocation) } @Operation(summary = "유저 프로필 이미지 업로드 성공 요청") - @PostMapping("/users/me/images/success/{imageKey}") + @PostMapping("/images/{imageKey}/users/me") fun userUploadImageSuccess(@PathVariable imageKey: String) { successUseCase.userUploadImageSuccess(imageKey) } diff --git a/Whatnow-Api/src/main/kotlin/com/depromeet/whatnow/api/image/usecase/ImageUploadSuccessUseCase.kt b/Whatnow-Api/src/main/kotlin/com/depromeet/whatnow/api/image/usecase/ImageUploadSuccessUseCase.kt index 35b10402..cd5b78d7 100644 --- a/Whatnow-Api/src/main/kotlin/com/depromeet/whatnow/api/image/usecase/ImageUploadSuccessUseCase.kt +++ b/Whatnow-Api/src/main/kotlin/com/depromeet/whatnow/api/image/usecase/ImageUploadSuccessUseCase.kt @@ -1,21 +1,27 @@ package com.depromeet.whatnow.api.image.usecase import com.depromeet.whatnow.annotation.UseCase +import com.depromeet.whatnow.common.vo.CoordinateVo import com.depromeet.whatnow.config.security.SecurityUtils -import com.depromeet.whatnow.domains.image.domain.ImageCommentType +import com.depromeet.whatnow.domains.image.domain.PromiseImageCommentType import com.depromeet.whatnow.domains.image.service.ImageDomainService @UseCase class ImageUploadSuccessUseCase( val imageDomainService: ImageDomainService, ) { - fun promiseUploadImageSuccess(promiseId: Long, imageKey: String, imageCommentType: ImageCommentType) { + fun promiseUploadImageSuccess( + promiseId: Long, + imageKey: String, + promiseImageCommentType: PromiseImageCommentType, + userLocation: CoordinateVo, + ) { val currentUserId: Long = SecurityUtils.currentUserId - imageDomainService.promiseUploadImageSuccess(currentUserId, promiseId, imageKey, imageCommentType) + imageDomainService.promiseImageUploadSuccess(currentUserId, promiseId, imageKey, promiseImageCommentType, userLocation) } fun userUploadImageSuccess(imageKey: String) { val currentUserId: Long = SecurityUtils.currentUserId - imageDomainService.userUploadImageSuccess(currentUserId, imageKey) + imageDomainService.userImageUploadSuccess(currentUserId, imageKey) } } diff --git a/Whatnow-Api/src/test/kotlin/com/depromeet/whatnow/api/image/controller/ImageControllerTest.kt b/Whatnow-Api/src/test/kotlin/com/depromeet/whatnow/api/image/controller/PromiseImageControllerTest.kt similarity index 73% rename from Whatnow-Api/src/test/kotlin/com/depromeet/whatnow/api/image/controller/ImageControllerTest.kt rename to Whatnow-Api/src/test/kotlin/com/depromeet/whatnow/api/image/controller/PromiseImageControllerTest.kt index 61c84b83..fbf5e548 100644 --- a/Whatnow-Api/src/test/kotlin/com/depromeet/whatnow/api/image/controller/ImageControllerTest.kt +++ b/Whatnow-Api/src/test/kotlin/com/depromeet/whatnow/api/image/controller/PromiseImageControllerTest.kt @@ -2,13 +2,16 @@ package com.depromeet.whatnow.api.image.controller import com.depromeet.whatnow.api.image.usecase.GetPresignedUrlUseCase import com.depromeet.whatnow.api.image.usecase.ImageUploadSuccessUseCase +import com.depromeet.whatnow.common.vo.CoordinateVo import com.depromeet.whatnow.config.s3.ImageFileExtension -import com.depromeet.whatnow.domains.image.domain.ImageCommentType +import com.depromeet.whatnow.domains.image.domain.PromiseImageCommentType +import com.fasterxml.jackson.databind.ObjectMapper import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest import org.springframework.boot.test.mock.mockito.MockBean +import org.springframework.http.MediaType import org.springframework.test.context.ContextConfiguration import org.springframework.test.web.servlet.MockMvc import org.springframework.test.web.servlet.request.MockMvcRequestBuilders @@ -18,7 +21,7 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status @WebMvcTest(ImageController::class) @ContextConfiguration(classes = [ImageController::class]) @AutoConfigureMockMvc(addFilters = false) -class ImageControllerTest { +class PromiseImageControllerTest { @MockBean lateinit var getPresignedUrlUseCase: GetPresignedUrlUseCase @@ -28,6 +31,9 @@ class ImageControllerTest { @Autowired lateinit var mockMvc: MockMvc + @Autowired + lateinit var objectMapper: ObjectMapper + @Test fun `약속 이미지 presignedUrl 요청에 성공하면 200을 응답한다`() { // given @@ -36,7 +42,7 @@ class ImageControllerTest { // when, then mockMvc.perform( - get("/v1/promises/{promiseId}/images", promiseId) + get("/v1/images/promises/{promiseId}", promiseId) .param("fileExtension", fileExtension), ) .andExpect(status().isOk) @@ -50,7 +56,7 @@ class ImageControllerTest { // when, then mockMvc.perform( - get("/v1/users/me/images") + get("/v1/images/users/me") .param("fileExtension", fileExtension), ) .andExpect(status().isOk) @@ -62,12 +68,15 @@ class ImageControllerTest { // given val promiseId = 1 val imageKey = "imageKey" - val imageCommentType = ImageCommentType.SORRY_LATE + val promiseImageCommentType = PromiseImageCommentType.SORRY_LATE + val userLocation = CoordinateVo(127.3, 23.0) // when, then mockMvc.perform( - MockMvcRequestBuilders.post("/v1/promises/{promiseId}/images/success/{imageKey}", promiseId, imageKey) - .param("imageCommentType", imageCommentType.name), + MockMvcRequestBuilders.post("/v1/images/{imageKey}/promises/{promiseId}", imageKey, promiseId) + .param("promiseImageCommentType", promiseImageCommentType.name) + .contentType(MediaType.APPLICATION_JSON) + .content(objectMapper.writeValueAsString(userLocation)), ) .andExpect(status().isOk) .andDo { print(it) } @@ -80,7 +89,7 @@ class ImageControllerTest { // when, then mockMvc.perform( - MockMvcRequestBuilders.post("/v1/users/me/images/success/{imageKey}", imageKey), + MockMvcRequestBuilders.post("/v1/images/{imageKey}/users/me", imageKey), ) .andExpect(status().isOk) .andDo { print(it) } diff --git a/Whatnow-Api/src/test/kotlin/com/depromeet/whatnow/api/image/usecase/ImageUploadSuccessUseCaseTest.kt b/Whatnow-Api/src/test/kotlin/com/depromeet/whatnow/api/image/usecase/PromiseImageUploadSuccessUseCaseTest.kt similarity index 86% rename from Whatnow-Api/src/test/kotlin/com/depromeet/whatnow/api/image/usecase/ImageUploadSuccessUseCaseTest.kt rename to Whatnow-Api/src/test/kotlin/com/depromeet/whatnow/api/image/usecase/PromiseImageUploadSuccessUseCaseTest.kt index 0bf5aaa9..664f47fb 100644 --- a/Whatnow-Api/src/test/kotlin/com/depromeet/whatnow/api/image/usecase/ImageUploadSuccessUseCaseTest.kt +++ b/Whatnow-Api/src/test/kotlin/com/depromeet/whatnow/api/image/usecase/PromiseImageUploadSuccessUseCaseTest.kt @@ -1,6 +1,7 @@ package com.depromeet.whatnow.api.image.usecase -import com.depromeet.whatnow.domains.image.domain.ImageCommentType +import com.depromeet.whatnow.common.vo.CoordinateVo +import com.depromeet.whatnow.domains.image.domain.PromiseImageCommentType import com.depromeet.whatnow.domains.image.service.ImageDomainService import org.assertj.core.api.Assertions.assertThatCode import org.junit.jupiter.api.BeforeEach @@ -14,7 +15,7 @@ import org.springframework.security.core.authority.SimpleGrantedAuthority import org.springframework.security.core.context.SecurityContextHolder @ExtendWith(MockitoExtension::class) -class ImageUploadSuccessUseCaseTest { +class PromiseImageUploadSuccessUseCaseTest { @Mock lateinit var imageDomainService: ImageDomainService @@ -32,12 +33,13 @@ class ImageUploadSuccessUseCaseTest { @Test fun `약속 이미지 업로드 성공 요청시 정상적이라면 에러가 발생하지 않는다`() { // given + val coordinateVo = CoordinateVo(1.0, 1.0) // when // then assertThatCode { - imageUploadSuccessUseCase.promiseUploadImageSuccess(1, "imageKey", ImageCommentType.SORRY_LATE) + imageUploadSuccessUseCase.promiseUploadImageSuccess(1, "imageKey", PromiseImageCommentType.SORRY_LATE, coordinateVo) }.doesNotThrowAnyException() } diff --git a/Whatnow-Common/src/main/kotlin/com/depromeet/whatnow/consts/WhatNowStatic.kt b/Whatnow-Common/src/main/kotlin/com/depromeet/whatnow/consts/WhatNowStatic.kt index 050f09b1..298684b6 100644 --- a/Whatnow-Common/src/main/kotlin/com/depromeet/whatnow/consts/WhatNowStatic.kt +++ b/Whatnow-Common/src/main/kotlin/com/depromeet/whatnow/consts/WhatNowStatic.kt @@ -26,7 +26,7 @@ const val DEV = "dev" const val LOCAL = "local" const val WITHDRAW_PREFIX = "withdraw" -const val IMAGE_DOMAIN = "https://image.whatnow.kr/" +const val IMAGE_DOMAIN = "https://image.whatnow.kr" val SWAGGER_PATTERNS = arrayOf( "/swagger-resources/**", diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/adapter/ImageAdapter.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/adapter/ImageAdapter.kt deleted file mode 100644 index 46b1edbb..00000000 --- a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/adapter/ImageAdapter.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.depromeet.whatnow.domains.image.adapter - -import com.depromeet.whatnow.annotation.Adapter -import com.depromeet.whatnow.domains.image.domain.Image -import com.depromeet.whatnow.domains.image.domain.ImageCommentType -import com.depromeet.whatnow.domains.image.repository.ImageRepository - -@Adapter -class ImageAdapter( - val imageRepository: ImageRepository, -) { - fun saveForPromise(userId: Long, promiseId: Long, imageUrl: String, imageKey: String, imageCommentType: ImageCommentType): Image { - val image = Image.createForPromise(userId, promiseId, imageUrl, imageKey, imageCommentType) - return imageRepository.save(image) - } - - fun saveForUser(userId: Long, imageUrl: String, imageKey: String): Image { - val image = Image.createForUser(userId, imageUrl, imageKey) - return imageRepository.save(image) - } -} diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/adapter/PromiseImageAdapter.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/adapter/PromiseImageAdapter.kt new file mode 100644 index 00000000..05c09ea2 --- /dev/null +++ b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/adapter/PromiseImageAdapter.kt @@ -0,0 +1,14 @@ +package com.depromeet.whatnow.domains.image.adapter + +import com.depromeet.whatnow.annotation.Adapter +import com.depromeet.whatnow.domains.image.domain.PromiseImage +import com.depromeet.whatnow.domains.image.repository.PromiseImageRepository + +@Adapter +class PromiseImageAdapter( + val promiseImageRepository: PromiseImageRepository, +) { + fun save(promiseImage: PromiseImage): PromiseImage { + return promiseImageRepository.save(promiseImage) + } +} diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/adapter/UserImageAdapter.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/adapter/UserImageAdapter.kt new file mode 100644 index 00000000..ac0480ae --- /dev/null +++ b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/adapter/UserImageAdapter.kt @@ -0,0 +1,14 @@ +package com.depromeet.whatnow.domains.image.adapter + +import com.depromeet.whatnow.annotation.Adapter +import com.depromeet.whatnow.domains.image.domain.UserImage +import com.depromeet.whatnow.domains.image.repository.UserImageRepository + +@Adapter +class UserImageAdapter( + val userImageRepository: UserImageRepository, +) { + fun save(userImage: UserImage): UserImage { + return userImageRepository.save(userImage) + } +} diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/domain/Image.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/domain/Image.kt deleted file mode 100644 index a7c4a5b6..00000000 --- a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/domain/Image.kt +++ /dev/null @@ -1,69 +0,0 @@ -package com.depromeet.whatnow.domains.image.domain - -import com.depromeet.whatnow.common.BaseTimeEntity -import com.depromeet.whatnow.common.aop.event.Events -import com.depromeet.whatnow.events.domainEvent.ImageRegisterEvent -import javax.persistence.Column -import javax.persistence.Entity -import javax.persistence.EnumType -import javax.persistence.Enumerated -import javax.persistence.GeneratedValue -import javax.persistence.GenerationType -import javax.persistence.Id -import javax.persistence.PostPersist -import javax.persistence.Table - -@Entity -@Table(name = "tbl_image") -class Image( - var userId: Long, - - var promiseId: Long, - - var uri: String, - - var imageKey: String, - - @Enumerated(EnumType.STRING) - var imageType: ImageType, - - @Enumerated(EnumType.STRING) - var imageCommentType: ImageCommentType = ImageCommentType.NONE, - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "picture_id") - val id: Long? = null, -) : BaseTimeEntity() { - companion object { - fun createForPromise(userId: Long, promiseId: Long, uri: String, imageKey: String, imageCommentType: ImageCommentType): Image { - return Image( - userId = userId, - promiseId = promiseId, - uri = uri, - imageKey = imageKey, - imageType = ImageType.PROMISE, - imageCommentType = imageCommentType, - ) - } - - fun createForUser(userId: Long, uri: String, imageKey: String): Image { - return Image( - userId = userId, - promiseId = 0, - uri = uri, - imageKey = imageKey, - imageType = ImageType.USER, - imageCommentType = ImageCommentType.NONE, - ) - } - } - - @PostPersist - fun createImageEvent() { - if (this.imageType == ImageType.USER) { - return - } - Events.raise(ImageRegisterEvent(userId, promiseId)) - } -} diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/domain/ImageType.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/domain/ImageType.kt deleted file mode 100644 index dc7ee6f5..00000000 --- a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/domain/ImageType.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.depromeet.whatnow.domains.image.domain - -enum class ImageType { - PROMISE, USER -} diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/domain/PromiseImage.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/domain/PromiseImage.kt new file mode 100644 index 00000000..21863485 --- /dev/null +++ b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/domain/PromiseImage.kt @@ -0,0 +1,57 @@ +package com.depromeet.whatnow.domains.image.domain + +import com.depromeet.whatnow.common.BaseTimeEntity +import com.depromeet.whatnow.common.aop.event.Events +import com.depromeet.whatnow.common.vo.CoordinateVo +import com.depromeet.whatnow.events.domainEvent.PromiseImageRegisterEvent +import javax.persistence.Column +import javax.persistence.Embedded +import javax.persistence.Entity +import javax.persistence.EnumType +import javax.persistence.Enumerated +import javax.persistence.GeneratedValue +import javax.persistence.GenerationType +import javax.persistence.Id +import javax.persistence.PostPersist +import javax.persistence.Table + +@Entity +@Table(name = "tbl_promise_image") +class PromiseImage( + var userId: Long, + + var promiseId: Long, + + var uri: String, + + var imageKey: String, + + @Enumerated(EnumType.STRING) + var promiseImageCommentType: PromiseImageCommentType, + + @Embedded + var userLocation: CoordinateVo? = null, + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "promise_image_id") + val id: Long? = null, +) : BaseTimeEntity() { + companion object { + fun of( + userId: Long, + promiseId: Long, + uri: String, + imageKey: String, + promiseImageCommentType: PromiseImageCommentType, + userLocation: CoordinateVo, + ): PromiseImage { + return PromiseImage(userId, promiseId, uri, imageKey, promiseImageCommentType, userLocation) + } + } + + @PostPersist + fun createImageEvent() { + Events.raise(PromiseImageRegisterEvent(userId, promiseId)) + } +} diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/domain/ImageCommentType.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/domain/PromiseImageCommentType.kt similarity index 86% rename from Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/domain/ImageCommentType.kt rename to Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/domain/PromiseImageCommentType.kt index 24fb877a..5587c6df 100644 --- a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/domain/ImageCommentType.kt +++ b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/domain/PromiseImageCommentType.kt @@ -2,9 +2,7 @@ package com.depromeet.whatnow.domains.image.domain import com.depromeet.whatnow.domains.promiseuser.domain.PromiseUserType -enum class ImageCommentType(val value: String, val promiseUserType: PromiseUserType?) { - NONE("NONE", null), - +enum class PromiseImageCommentType(val value: String, val promiseUserType: PromiseUserType?) { // Can LATE RUNNING("달려가는 중️", PromiseUserType.LATE), GASPING("헐레벌떡", PromiseUserType.LATE), diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/domain/UserImage.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/domain/UserImage.kt new file mode 100644 index 00000000..425279d9 --- /dev/null +++ b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/domain/UserImage.kt @@ -0,0 +1,30 @@ +package com.depromeet.whatnow.domains.image.domain + +import com.depromeet.whatnow.common.BaseTimeEntity +import javax.persistence.Column +import javax.persistence.Entity +import javax.persistence.GeneratedValue +import javax.persistence.GenerationType +import javax.persistence.Id +import javax.persistence.Table + +@Entity +@Table(name = "tbl_user_image") +class UserImage( + var userId: Long, + + var uri: String, + + var imageKey: String, + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "user_image_id") + val id: Long? = null, +) : BaseTimeEntity() { + companion object { + fun of(userId: Long, uri: String, imageKey: String): UserImage { + return UserImage(userId, uri, imageKey) + } + } +} diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/repository/PromiseImageRepository.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/repository/PromiseImageRepository.kt new file mode 100644 index 00000000..87f0d213 --- /dev/null +++ b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/repository/PromiseImageRepository.kt @@ -0,0 +1,8 @@ +package com.depromeet.whatnow.domains.image.repository + +import com.depromeet.whatnow.domains.image.domain.PromiseImage +import org.springframework.data.jpa.repository.JpaRepository +import org.springframework.stereotype.Repository + +@Repository +interface PromiseImageRepository : JpaRepository diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/repository/ImageRepository.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/repository/UserImageRepository.kt similarity index 59% rename from Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/repository/ImageRepository.kt rename to Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/repository/UserImageRepository.kt index c1c07eac..a2c86e52 100644 --- a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/repository/ImageRepository.kt +++ b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/repository/UserImageRepository.kt @@ -1,8 +1,8 @@ package com.depromeet.whatnow.domains.image.repository -import com.depromeet.whatnow.domains.image.domain.Image +import com.depromeet.whatnow.domains.image.domain.UserImage import org.springframework.data.jpa.repository.JpaRepository import org.springframework.stereotype.Repository @Repository -interface ImageRepository : JpaRepository +interface UserImageRepository : JpaRepository diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/service/ImageDomainService.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/service/ImageDomainService.kt index 0b5bf74a..8247afb9 100644 --- a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/service/ImageDomainService.kt +++ b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/image/service/ImageDomainService.kt @@ -1,8 +1,12 @@ package com.depromeet.whatnow.domains.image.service +import com.depromeet.whatnow.common.vo.CoordinateVo import com.depromeet.whatnow.consts.IMAGE_DOMAIN -import com.depromeet.whatnow.domains.image.adapter.ImageAdapter -import com.depromeet.whatnow.domains.image.domain.ImageCommentType +import com.depromeet.whatnow.domains.image.adapter.PromiseImageAdapter +import com.depromeet.whatnow.domains.image.adapter.UserImageAdapter +import com.depromeet.whatnow.domains.image.domain.PromiseImage +import com.depromeet.whatnow.domains.image.domain.PromiseImageCommentType +import com.depromeet.whatnow.domains.image.domain.UserImage import com.depromeet.whatnow.domains.image.exception.CancelledUserUploadException import com.depromeet.whatnow.domains.image.exception.InvalidCommentTypeException import com.depromeet.whatnow.domains.image.exception.UploadBeforeTrackingException @@ -15,33 +19,41 @@ import org.springframework.transaction.annotation.Transactional @Service class ImageDomainService( - val imageAdapter: ImageAdapter, + val promiseImageAdapter: PromiseImageAdapter, + val userImageAdapter: UserImageAdapter, val promiseUserAdapter: PromiseUserAdaptor, val userAdapter: UserAdapter, val springEnvironmentHelper: SpringEnvironmentHelper, ) { @Transactional - fun promiseUploadImageSuccess(userId: Long, promiseId: Long, imageKey: String, imageCommentType: ImageCommentType) { + fun promiseImageUploadSuccess( + userId: Long, + promiseId: Long, + imageKey: String, + promiseImageCommentType: PromiseImageCommentType, + userLocation: CoordinateVo, + ) { val promiseUser = promiseUserAdapter.findByPromiseIdAndUserId(promiseId, userId) - validatePromiseUserType(promiseUser.promiseUserType!!, imageCommentType) + validatePromiseUserType(promiseUser.promiseUserType!!, promiseImageCommentType) - val imageUrl = IMAGE_DOMAIN + springEnvironmentHelper.activeProfile + "/" + "promise/$promiseId/$imageKey" - imageAdapter.saveForPromise(userId, promiseId, imageUrl, imageKey, imageCommentType) + val imageUrl = IMAGE_DOMAIN + "/" + springEnvironmentHelper.activeProfile + "/" + "promise/$promiseId/$imageKey" + promiseImageAdapter.save( + PromiseImage.of(promiseId, userId, imageUrl, imageKey, promiseImageCommentType, userLocation), + ) } - fun userUploadImageSuccess(userId: Long, imageKey: String) { - val user = userAdapter.queryUser(userId) - val imageUrl = IMAGE_DOMAIN + springEnvironmentHelper.activeProfile + "/" + "user/$userId/$imageKey" - imageAdapter.saveForUser(userId, imageUrl, imageKey) - user.updateProfileImg(imageUrl) + @Transactional + fun userImageUploadSuccess(userId: Long, imageKey: String) { + val imageUrl = IMAGE_DOMAIN + "/" + springEnvironmentHelper.activeProfile + "/" + "user/$userId/$imageKey" + userImageAdapter.save(UserImage.of(userId, imageUrl, imageKey)) } - private fun validatePromiseUserType(promiseUserType: PromiseUserType, imageCommentType: ImageCommentType) { + private fun validatePromiseUserType(promiseUserType: PromiseUserType, promiseImageCommentType: PromiseImageCommentType) { when (promiseUserType) { PromiseUserType.READY -> throw UploadBeforeTrackingException.EXCEPTION PromiseUserType.CANCEL -> throw CancelledUserUploadException.EXCEPTION PromiseUserType.WAIT, PromiseUserType.LATE -> { - if (imageCommentType.promiseUserType != promiseUserType) { + if (promiseImageCommentType.promiseUserType != promiseUserType) { throw InvalidCommentTypeException.EXCEPTION } } diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/user/domain/User.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/user/domain/User.kt index aa2db305..6a1e76fd 100644 --- a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/user/domain/User.kt +++ b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/domains/user/domain/User.kt @@ -99,13 +99,6 @@ class User( nickname = username } - fun updateProfileImg(imageUrl: String) { - if (profileImg != imageUrl) { - isDefaultImg = false - } - profileImg = imageUrl - } - fun toUserInfoVo(): UserInfoVo { return UserInfoVo.from(this) } diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/domainEvent/ImageRegisterEvent.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/domainEvent/PromiseImageRegisterEvent.kt similarity index 84% rename from Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/domainEvent/ImageRegisterEvent.kt rename to Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/domainEvent/PromiseImageRegisterEvent.kt index f46f4f08..4a36457e 100644 --- a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/domainEvent/ImageRegisterEvent.kt +++ b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/domainEvent/PromiseImageRegisterEvent.kt @@ -2,7 +2,7 @@ package com.depromeet.whatnow.events.domainEvent import com.depromeet.whatnow.common.aop.event.DomainEvent -class ImageRegisterEvent( +class PromiseImageRegisterEvent( val userId: Long, val promiseId: Long, ) : DomainEvent() diff --git a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/handler/ImageRegisterEventHandler.kt b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/handler/ImageRegisterEventHandler.kt index 5d57b349..a47bc846 100644 --- a/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/handler/ImageRegisterEventHandler.kt +++ b/Whatnow-Domain/src/main/kotlin/com/depromeet/whatnow/events/handler/ImageRegisterEventHandler.kt @@ -1,7 +1,7 @@ package com.depromeet.whatnow.events.handler import com.depromeet.whatnow.annotation.Handler -import com.depromeet.whatnow.events.domainEvent.ImageRegisterEvent +import com.depromeet.whatnow.events.domainEvent.PromiseImageRegisterEvent import org.springframework.scheduling.annotation.Async import org.springframework.transaction.event.TransactionPhase import org.springframework.transaction.event.TransactionalEventListener @@ -9,10 +9,10 @@ import org.springframework.transaction.event.TransactionalEventListener @Handler class ImageRegisterEventHandler { @Async - @TransactionalEventListener(classes = [ImageRegisterEvent::class], phase = TransactionPhase.AFTER_COMMIT) - fun handleRegisterPictureEvent(imageRegisterEvent: ImageRegisterEvent) { - val userId: Long = imageRegisterEvent.userId - val promiseId: Long = imageRegisterEvent.promiseId + @TransactionalEventListener(classes = [PromiseImageRegisterEvent::class], phase = TransactionPhase.AFTER_COMMIT) + fun handleRegisterPictureEvent(promiseImageRegisterEvent: PromiseImageRegisterEvent) { + val userId: Long = promiseImageRegisterEvent.userId + val promiseId: Long = promiseImageRegisterEvent.promiseId // TODO: FCM 토큰 발급 후 약속ID 기준 참여자들에게 푸시 알림 보내기 } } diff --git a/Whatnow-Domain/src/test/kotlin/com/depromeet/whatnow/domains/image/adapter/ImageAdapterTest.kt b/Whatnow-Domain/src/test/kotlin/com/depromeet/whatnow/domains/image/adapter/ImageAdapterTest.kt deleted file mode 100644 index 4f538f5c..00000000 --- a/Whatnow-Domain/src/test/kotlin/com/depromeet/whatnow/domains/image/adapter/ImageAdapterTest.kt +++ /dev/null @@ -1,57 +0,0 @@ -package com.depromeet.whatnow.domains.image.adapter - -import com.depromeet.whatnow.domains.image.domain.Image -import com.depromeet.whatnow.domains.image.domain.ImageCommentType -import com.depromeet.whatnow.domains.image.domain.ImageType -import com.depromeet.whatnow.domains.image.repository.ImageRepository -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith -import org.mockito.InjectMocks -import org.mockito.Mock -import org.mockito.Mockito -import org.mockito.junit.jupiter.MockitoExtension -import org.mockito.kotlin.given -import kotlin.test.assertEquals - -@ExtendWith(MockitoExtension::class) -class ImageAdapterTest { - @Mock - lateinit var imageRepository: ImageRepository - - @InjectMocks - lateinit var imageAdapter: ImageAdapter - - @Test - fun `약속 이미지 Picture 저장 시 정상적으로 저장된다`() { - given(imageRepository.save(Mockito.any(Image::class.java))) - .willReturn(Image.createForPromise(1, 1, "imageUri", "imageKey", ImageCommentType.RUNNING)) - - // when - val picture = imageAdapter.saveForPromise(1, 1, "imageUri", "imageKey", ImageCommentType.RUNNING) - - // then - assertEquals(picture.userId, 1) - assertEquals(picture.promiseId, 1) - assertEquals(picture.uri, "imageUri") - assertEquals(picture.imageKey, "imageKey") - assertEquals(picture.imageType, ImageType.PROMISE) - assertEquals(picture.imageCommentType, ImageCommentType.RUNNING) - } - - @Test - fun `유저 프로필 Picture 저장 시 정상적으로 저장된다`() { - given(imageRepository.save(Mockito.any(Image::class.java))) - .willReturn(Image.createForUser(1, "imageUri", "imageKey")) - - // when - val picture = imageAdapter.saveForUser(1, "imageUri", "imageKey") - - // then - assertEquals(picture.userId, 1) - assertEquals(picture.promiseId, 0) - assertEquals(picture.uri, "imageUri") - assertEquals(picture.imageKey, "imageKey") - assertEquals(picture.imageType, ImageType.USER) - assertEquals(picture.imageCommentType, ImageCommentType.NONE) - } -} diff --git a/Whatnow-Domain/src/test/kotlin/com/depromeet/whatnow/domains/image/adapter/PromisePromiseImageAdapterTest.kt b/Whatnow-Domain/src/test/kotlin/com/depromeet/whatnow/domains/image/adapter/PromisePromiseImageAdapterTest.kt new file mode 100644 index 00000000..19f08cd7 --- /dev/null +++ b/Whatnow-Domain/src/test/kotlin/com/depromeet/whatnow/domains/image/adapter/PromisePromiseImageAdapterTest.kt @@ -0,0 +1,42 @@ +package com.depromeet.whatnow.domains.image.adapter + +import com.depromeet.whatnow.common.vo.CoordinateVo +import com.depromeet.whatnow.domains.image.domain.PromiseImage +import com.depromeet.whatnow.domains.image.domain.PromiseImageCommentType +import com.depromeet.whatnow.domains.image.repository.PromiseImageRepository +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.mockito.InjectMocks +import org.mockito.Mock +import org.mockito.Mockito +import org.mockito.junit.jupiter.MockitoExtension +import org.mockito.kotlin.given +import kotlin.test.assertEquals + +@ExtendWith(MockitoExtension::class) +class PromisePromiseImageAdapterTest { + @Mock + lateinit var promiseImageRepository: PromiseImageRepository + + @InjectMocks + lateinit var promiseImageAdapter: PromiseImageAdapter + + @Test + fun `약속 이미지 저장 시 정상적으로 저장된다`() { + val userLocation = CoordinateVo(37.2, 128.05) + val promiseImage = PromiseImage.of(1, 1, "imageUri", "imageKey", PromiseImageCommentType.RUNNING, userLocation) + given(promiseImageRepository.save(Mockito.any(PromiseImage::class.java))) + .willReturn(promiseImage) + + // when + val savedPromiseImage = promiseImageAdapter.save(promiseImage) + + // then + assertEquals(savedPromiseImage.userId, 1) + assertEquals(savedPromiseImage.promiseId, 1) + assertEquals(savedPromiseImage.uri, "imageUri") + assertEquals(savedPromiseImage.imageKey, "imageKey") + assertEquals(savedPromiseImage.promiseImageCommentType, PromiseImageCommentType.RUNNING) + assertEquals(savedPromiseImage.userLocation, userLocation) + } +} diff --git a/Whatnow-Domain/src/test/kotlin/com/depromeet/whatnow/domains/image/service/ImageDomainServiceTest.kt b/Whatnow-Domain/src/test/kotlin/com/depromeet/whatnow/domains/image/service/PromiseImageDomainServiceTest.kt similarity index 77% rename from Whatnow-Domain/src/test/kotlin/com/depromeet/whatnow/domains/image/service/ImageDomainServiceTest.kt rename to Whatnow-Domain/src/test/kotlin/com/depromeet/whatnow/domains/image/service/PromiseImageDomainServiceTest.kt index db2b8714..faa2de8c 100644 --- a/Whatnow-Domain/src/test/kotlin/com/depromeet/whatnow/domains/image/service/ImageDomainServiceTest.kt +++ b/Whatnow-Domain/src/test/kotlin/com/depromeet/whatnow/domains/image/service/PromiseImageDomainServiceTest.kt @@ -1,8 +1,9 @@ package com.depromeet.whatnow.domains.image.service import com.depromeet.whatnow.common.vo.CoordinateVo -import com.depromeet.whatnow.domains.image.adapter.ImageAdapter -import com.depromeet.whatnow.domains.image.domain.ImageCommentType +import com.depromeet.whatnow.domains.image.adapter.PromiseImageAdapter +import com.depromeet.whatnow.domains.image.adapter.UserImageAdapter +import com.depromeet.whatnow.domains.image.domain.PromiseImageCommentType import com.depromeet.whatnow.domains.image.exception.CancelledUserUploadException import com.depromeet.whatnow.domains.image.exception.InvalidCommentTypeException import com.depromeet.whatnow.domains.image.exception.UploadBeforeTrackingException @@ -11,7 +12,6 @@ import com.depromeet.whatnow.domains.promiseuser.domain.PromiseUser import com.depromeet.whatnow.domains.promiseuser.domain.PromiseUserType import com.depromeet.whatnow.domains.user.adapter.UserAdapter import com.depromeet.whatnow.helper.SpringEnvironmentHelper -import com.depromeet.whatnow.helper.user_id_1_fixture import org.assertj.core.api.Assertions import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -22,13 +22,16 @@ import org.mockito.junit.jupiter.MockitoExtension import org.mockito.kotlin.given @ExtendWith(MockitoExtension::class) -class ImageDomainServiceTest { +class PromiseImageDomainServiceTest { @Mock - lateinit var imageAdapter: ImageAdapter + lateinit var promiseImageAdapter: PromiseImageAdapter @Mock lateinit var promiseUserAdapter: PromiseUserAdaptor + @Mock + lateinit var userImageAdapter: UserImageAdapter + @Mock lateinit var userAdapter: UserAdapter @@ -47,12 +50,13 @@ class ImageDomainServiceTest { userLocation = CoordinateVo(1.0, 1.0), promiseUserType = PromiseUserType.LATE, ) + val userLocation = CoordinateVo(37.2, 128.05) given(promiseUserAdapter.findByPromiseIdAndUserId(anyLong(), anyLong())) .willReturn(promiseUser) // when, then Assertions.assertThatCode { - imageDomainService.promiseUploadImageSuccess(1, 1, "imageKey", ImageCommentType.RUNNING) + imageDomainService.promiseImageUploadSuccess(1, 1, "imageKey", PromiseImageCommentType.RUNNING, userLocation) }.doesNotThrowAnyException() } @@ -65,12 +69,13 @@ class ImageDomainServiceTest { userLocation = CoordinateVo(1.0, 1.0), promiseUserType = PromiseUserType.READY, ) + val userLocation = CoordinateVo(37.2, 128.05) given(promiseUserAdapter.findByPromiseIdAndUserId(anyLong(), anyLong())) .willReturn(promiseUser) // when, then Assertions.assertThatThrownBy { - imageDomainService.promiseUploadImageSuccess(1, 1, "imageKey", ImageCommentType.RUNNING) + imageDomainService.promiseImageUploadSuccess(1, 1, "imageKey", PromiseImageCommentType.RUNNING, userLocation) }.isInstanceOf(UploadBeforeTrackingException::class.java) } @@ -83,12 +88,13 @@ class ImageDomainServiceTest { userLocation = CoordinateVo(1.0, 1.0), promiseUserType = PromiseUserType.CANCEL, ) + val userLocation = CoordinateVo(37.2, 128.05) given(promiseUserAdapter.findByPromiseIdAndUserId(anyLong(), anyLong())) .willReturn(promiseUser) // when, then Assertions.assertThatThrownBy { - imageDomainService.promiseUploadImageSuccess(1, 1, "imageKey", ImageCommentType.RUNNING) + imageDomainService.promiseImageUploadSuccess(1, 1, "imageKey", PromiseImageCommentType.RUNNING, userLocation) }.isInstanceOf(CancelledUserUploadException::class.java) } @@ -101,12 +107,13 @@ class ImageDomainServiceTest { userLocation = CoordinateVo(1.0, 1.0), promiseUserType = PromiseUserType.LATE, ) + val userLocation = CoordinateVo(37.2, 128.05) given(promiseUserAdapter.findByPromiseIdAndUserId(anyLong(), anyLong())) .willReturn(promiseUser) // when, then Assertions.assertThatThrownBy { - imageDomainService.promiseUploadImageSuccess(1, 1, "imageKey", ImageCommentType.DID_YOU_COME) + imageDomainService.promiseImageUploadSuccess(1, 1, "imageKey", PromiseImageCommentType.DID_YOU_COME, userLocation) }.isInstanceOf(InvalidCommentTypeException::class.java) } @@ -119,24 +126,13 @@ class ImageDomainServiceTest { userLocation = CoordinateVo(1.0, 1.0), promiseUserType = PromiseUserType.WAIT, ) + val userLocation = CoordinateVo(37.2, 128.05) given(promiseUserAdapter.findByPromiseIdAndUserId(anyLong(), anyLong())) .willReturn(promiseUser) // when, then Assertions.assertThatThrownBy { - imageDomainService.promiseUploadImageSuccess(1, 1, "imageKey", ImageCommentType.WAIT_A_BIT) + imageDomainService.promiseImageUploadSuccess(1, 1, "imageKey", PromiseImageCommentType.WAIT_A_BIT, userLocation) }.isInstanceOf(InvalidCommentTypeException::class.java) } - - @Test - fun `유저 프로필 업로드 성공 요청시 정상적이라면 에러를 반환하지 않는다`() { - // given - given(userAdapter.queryUser(anyLong())) - .willReturn(user_id_1_fixture()) - - // when, then - Assertions.assertThatCode { - imageDomainService.userUploadImageSuccess(1, "imageKey") - }.doesNotThrowAnyException() - } } diff --git a/Whatnow-Domain/src/test/kotlin/com/depromeet/whatnow/events/handler/ImageRegisterEventHandlerTest.kt b/Whatnow-Domain/src/test/kotlin/com/depromeet/whatnow/events/handler/PromisePromiseImageRegisterEventHandlerTest.kt similarity index 63% rename from Whatnow-Domain/src/test/kotlin/com/depromeet/whatnow/events/handler/ImageRegisterEventHandlerTest.kt rename to Whatnow-Domain/src/test/kotlin/com/depromeet/whatnow/events/handler/PromisePromiseImageRegisterEventHandlerTest.kt index f554ce2e..fc0d81c2 100644 --- a/Whatnow-Domain/src/test/kotlin/com/depromeet/whatnow/events/handler/ImageRegisterEventHandlerTest.kt +++ b/Whatnow-Domain/src/test/kotlin/com/depromeet/whatnow/events/handler/PromisePromiseImageRegisterEventHandlerTest.kt @@ -2,13 +2,12 @@ package com.depromeet.whatnow.events.handler import com.depromeet.whatnow.common.vo.CoordinateVo import com.depromeet.whatnow.config.DomainIntegrateSpringBootTest -import com.depromeet.whatnow.domains.image.domain.ImageCommentType +import com.depromeet.whatnow.domains.image.domain.PromiseImageCommentType import com.depromeet.whatnow.domains.image.service.ImageDomainService import com.depromeet.whatnow.domains.promiseuser.adaptor.PromiseUserAdaptor import com.depromeet.whatnow.domains.promiseuser.domain.PromiseUser import com.depromeet.whatnow.domains.promiseuser.domain.PromiseUserType import com.depromeet.whatnow.domains.user.adapter.UserAdapter -import com.depromeet.whatnow.helper.user_id_1_fixture import org.junit.jupiter.api.Test import org.mockito.Mockito import org.mockito.kotlin.any @@ -18,7 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.mock.mockito.MockBean @DomainIntegrateSpringBootTest -class ImageRegisterEventHandlerTest { +class PromisePromiseImageRegisterEventHandlerTest { @Autowired lateinit var imageDomainService: ImageDomainService @@ -32,28 +31,16 @@ class ImageRegisterEventHandlerTest { lateinit var imageRegisterEventHandler: ImageRegisterEventHandler @Test - fun `이미지 등록 성공 시 이미지 타입이 Promise라면 이미지 등록 이벤트가 발행되어야한다`() { + fun `약속 이미지 등록 성공 시 이미지 등록 이벤트가 발행되어야한다`() { // given val promiseUser = PromiseUser(1, 1, CoordinateVo(1.0, 1.0), PromiseUserType.LATE) + val userLocation = CoordinateVo(37.2, 128.05) given(promiseUserAdaptor.findByPromiseIdAndUserId(1, 1)).willReturn(promiseUser) // when - imageDomainService.promiseUploadImageSuccess(1, 1, "imageKey", ImageCommentType.RUNNING) + imageDomainService.promiseImageUploadSuccess(1, 1, "imageKey", PromiseImageCommentType.RUNNING, userLocation) // then then(imageRegisterEventHandler).should(Mockito.times(1)).handleRegisterPictureEvent(any()) } - - @Test - fun `이미지 등록 성공 시 이미지 타입이 User라면 이미지 등록 이벤트가 발행되지 않아야한다`() { - // given - val user = user_id_1_fixture() - given(userAdapter.queryUser(any())).willReturn(user) - - // when - imageDomainService.userUploadImageSuccess(1, "imageKey") - - // then - then(imageRegisterEventHandler).should(Mockito.times(0)).handleRegisterPictureEvent(any()) - } }