-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
124 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...lication/src/main/kotlin/team/comit/simtong/domain/menu/usecase/QueryPublicMenuUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package team.comit.simtong.domain.menu.usecase | ||
|
||
import team.comit.simtong.domain.menu.dto.MenuResponse | ||
import team.comit.simtong.domain.menu.spi.QueryMenuPort | ||
import team.comit.simtong.global.annotation.ReadOnlyUseCase | ||
import java.time.LocalDate | ||
|
||
/** | ||
* | ||
* 공개된 Menu를 조회하는 QueryPublicMenuUseCase | ||
* | ||
* @author kimbeomjin | ||
* @date 2022/10/11 | ||
* @version 1.0.0 | ||
**/ | ||
@ReadOnlyUseCase | ||
class QueryPublicMenuUseCase( | ||
private val queryMenuPort: QueryMenuPort, | ||
) { | ||
|
||
fun execute(today: LocalDate): MenuResponse { | ||
val menu = queryMenuPort.queryMenuBySpotName(today.year, today.monthValue, HEAD_SHOP) | ||
val result = menu.map { MenuResponse.MenuElement(it.date, it.meal) } | ||
|
||
return MenuResponse(result) | ||
} | ||
|
||
companion object { | ||
private const val HEAD_SHOP = "은행동 본점" | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...ion/src/test/kotlin/team/comit/simtong/domain/menu/usecase/QueryPublicMenuUseCaseTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package team.comit.simtong.domain.menu.usecase | ||
|
||
import org.assertj.core.api.Assertions | ||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.extension.ExtendWith | ||
import org.mockito.BDDMockito.given | ||
import org.springframework.boot.test.mock.mockito.MockBean | ||
import org.springframework.test.context.junit.jupiter.SpringExtension | ||
import team.comit.simtong.domain.menu.model.Menu | ||
import team.comit.simtong.domain.menu.spi.QueryMenuPort | ||
import java.time.LocalDate | ||
import java.util.* | ||
|
||
@ExtendWith(SpringExtension::class) | ||
class QueryPublicMenuUseCaseTests { | ||
|
||
@MockBean | ||
private lateinit var queryMenuPort: QueryMenuPort | ||
|
||
private lateinit var queryPublicMenuUseCase: QueryPublicMenuUseCase | ||
|
||
private val menuStub: Menu by lazy { | ||
Menu( | ||
date = LocalDate.of(2022, 9, 1), | ||
meal = "오늘 아침은 아침밥", | ||
spotId = UUID.randomUUID() | ||
) | ||
} | ||
|
||
private val menuStub2: Menu by lazy { | ||
Menu( | ||
date = LocalDate.of(2022, 9, 30), | ||
meal = "오늘 점심은 점심밥", | ||
spotId = UUID.randomUUID() | ||
) | ||
} | ||
|
||
@BeforeEach | ||
fun setUp() { | ||
queryPublicMenuUseCase = QueryPublicMenuUseCase(queryMenuPort) | ||
} | ||
|
||
@Test | ||
fun `메뉴 조회 성공`() { | ||
// given | ||
val now = LocalDate.now() | ||
given(queryMenuPort.queryMenuBySpotName(now.year, now.monthValue, "은행동 본점")) | ||
.willReturn( | ||
listOf(menuStub, menuStub2) | ||
) | ||
|
||
// when | ||
val response = queryPublicMenuUseCase.execute(now) | ||
|
||
// then | ||
Assertions.assertThat(response).isNotNull | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters