diff --git a/pida-core/core-api/src/main/kotlin/com/pida/presentation/v1/blooming/request/AddBloomingRequest.kt b/pida-core/core-api/src/main/kotlin/com/pida/presentation/v1/blooming/request/AddBloomingRequest.kt index 6ef224a..41de833 100644 --- a/pida-core/core-api/src/main/kotlin/com/pida/presentation/v1/blooming/request/AddBloomingRequest.kt +++ b/pida-core/core-api/src/main/kotlin/com/pida/presentation/v1/blooming/request/AddBloomingRequest.kt @@ -10,27 +10,36 @@ import io.swagger.v3.oas.annotations.media.Schema data class AddBloomingRequest( @Schema(description = "장소 ID", example = "1", nullable = true) val flowerSpotId: Long? = null, - @Schema(description = "꽃 이벤트 ID", example = "1", nullable = true) + @Schema(description = "벚꽃 축제 ID", example = "1", nullable = true) val flowerEventId: Long? = null, + @Schema(description = "카페 ID", example = "1", nullable = true) + val flowerSpotCafeId: Long? = null, @Schema(description = "개화 상태", example = "BLOOMED") val status: BloomingStatus, ) { fun toNewBlooming(userId: Long): NewBlooming = when { - flowerSpotId != null && flowerEventId == null -> + flowerSpotId != null && flowerEventId == null && flowerSpotCafeId == null -> NewBlooming.FlowerSpot( userId = userId, flowerSpotId = flowerSpotId, status = status, ) - flowerSpotId == null && flowerEventId != null -> + flowerSpotId == null && flowerEventId != null && flowerSpotCafeId == null -> NewBlooming.FlowerEvent( userId = userId, flowerEventId = flowerEventId, status = status, ) + flowerSpotId == null && flowerEventId == null && flowerSpotCafeId != null -> + NewBlooming.FlowerSpotCafe( + userId = userId, + flowerSpotCafeId = flowerSpotCafeId, + status = status, + ) + else -> throw ErrorException(ErrorType.INVALID_REQUEST) } } diff --git a/pida-core/core-api/src/test/kotlin/com/pida/presentation/v1/blooming/request/AddBloomingRequestTest.kt b/pida-core/core-api/src/test/kotlin/com/pida/presentation/v1/blooming/request/AddBloomingRequestTest.kt index e6b25b7..7468db6 100644 --- a/pida-core/core-api/src/test/kotlin/com/pida/presentation/v1/blooming/request/AddBloomingRequestTest.kt +++ b/pida-core/core-api/src/test/kotlin/com/pida/presentation/v1/blooming/request/AddBloomingRequestTest.kt @@ -25,6 +25,7 @@ class AddBloomingRequestTest { result.userId shouldBe 10L result.flowerSpotId shouldBe 1L result.flowerEventId shouldBe null + result.flowerSpotCafeId shouldBe null result.status shouldBe BloomingStatus.BLOOMED } @@ -43,19 +44,41 @@ class AddBloomingRequestTest { result.userId shouldBe 11L result.flowerSpotId shouldBe null result.flowerEventId shouldBe 2L + result.flowerSpotCafeId shouldBe null result.status shouldBe BloomingStatus.WITHERED } @Test - fun `flowerSpotId와 flowerEventId가 모두 없으면 INVALID_REQUEST를 던진다`() { + fun `flowerSpotCafeId만 있으면 FlowerSpotCafe 개화 입력으로 변환한다`() { val request = AddBloomingRequest( flowerSpotId = null, flowerEventId = null, + flowerSpotCafeId = 3L, + status = BloomingStatus.LITTLE, + ) + + val result = request.toNewBlooming(12L) + + result.shouldBeInstanceOf() + result.userId shouldBe 12L + result.flowerSpotId shouldBe null + result.flowerEventId shouldBe null + result.flowerSpotCafeId shouldBe 3L + result.status shouldBe BloomingStatus.LITTLE + } + + @Test + fun `flowerSpotId와 flowerEventId와 flowerSpotCafeId가 모두 없으면 INVALID_REQUEST를 던진다`() { + val request = + AddBloomingRequest( + flowerSpotId = null, + flowerEventId = null, + flowerSpotCafeId = null, status = BloomingStatus.BLOOMED, ) - val exception = assertThrows { request.toNewBlooming(12L) } + val exception = assertThrows { request.toNewBlooming(13L) } exception.errorType shouldBe ErrorType.INVALID_REQUEST } @@ -66,10 +89,26 @@ class AddBloomingRequestTest { AddBloomingRequest( flowerSpotId = 1L, flowerEventId = 2L, + flowerSpotCafeId = null, status = BloomingStatus.BLOOMED, ) - val exception = assertThrows { request.toNewBlooming(13L) } + val exception = assertThrows { request.toNewBlooming(14L) } + + exception.errorType shouldBe ErrorType.INVALID_REQUEST + } + + @Test + fun `flowerSpotId와 flowerSpotCafeId가 모두 있으면 INVALID_REQUEST를 던진다`() { + val request = + AddBloomingRequest( + flowerSpotId = 1L, + flowerEventId = null, + flowerSpotCafeId = 3L, + status = BloomingStatus.BLOOMED, + ) + + val exception = assertThrows { request.toNewBlooming(15L) } exception.errorType shouldBe ErrorType.INVALID_REQUEST }