forked from wine-area/DMS-Backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
189 additions
and
59 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
...plication/src/main/kotlin/team/aliens/dms/domain/notice/dto/QueryNoticeDetailsResponse.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
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
4 changes: 3 additions & 1 deletion
4
dms-application/src/main/kotlin/team/aliens/dms/domain/studyroom/spi/QuerySeatTypePort.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
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
88 changes: 88 additions & 0 deletions
88
...on/src/test/kotlin/team/aliens/dms/domain/studyroom/usecase/QuerySeatTypesUseCaseTests.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,88 @@ | ||
package team.aliens.dms.domain.studyroom.usecase | ||
|
||
import io.mockk.every | ||
import io.mockk.mockk | ||
import io.mockk.verify | ||
import java.util.UUID | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.assertAll | ||
import org.junit.jupiter.api.assertThrows | ||
import team.aliens.dms.domain.studyroom.spi.QuerySeatTypePort | ||
import team.aliens.dms.domain.studyroom.spi.StudyRoomQueryUserPort | ||
import team.aliens.dms.domain.studyroom.spi.StudyRoomSecurityPort | ||
import team.aliens.dms.domain.studyroom.stub.createSeatTypeStub | ||
import team.aliens.dms.domain.user.exception.UserNotFoundException | ||
import team.aliens.dms.domain.user.stub.createUserStub | ||
|
||
class QuerySeatTypesUseCaseTests { | ||
|
||
private val securityPort: StudyRoomSecurityPort = mockk(relaxed = true) | ||
private val queryUserPort: StudyRoomQueryUserPort = mockk(relaxed = true) | ||
private val querySeatTypePort: QuerySeatTypePort = mockk(relaxed = true) | ||
|
||
private val querySeatTypesUseCase = QuerySeatTypesUseCase( | ||
securityPort, queryUserPort, querySeatTypePort | ||
) | ||
|
||
private val userId = UUID.randomUUID() | ||
private val schoolId = UUID.randomUUID() | ||
private val studyRoomId = UUID.randomUUID() | ||
|
||
private val userStub by lazy { | ||
createUserStub( | ||
id = userId, | ||
schoolId = schoolId | ||
) | ||
} | ||
|
||
private val seatTypesStub by lazy { | ||
listOf(createSeatTypeStub()) | ||
} | ||
|
||
@Test | ||
fun `자리 종류 조회 성공 (studyRoomId가 null인 경우)`() { | ||
// given | ||
every { securityPort.getCurrentUserId() } returns userId | ||
every { queryUserPort.queryUserById(userId) } returns userStub | ||
every { querySeatTypePort.queryAllSeatTypeBySchoolId(schoolId) } returns seatTypesStub | ||
|
||
// when | ||
val response = querySeatTypesUseCase.execute(null) | ||
|
||
// then | ||
assertAll( | ||
{ verify(exactly = 1) { querySeatTypePort.queryAllSeatTypeBySchoolId(schoolId) } }, | ||
{ assertEquals(response.types.size, seatTypesStub.size) } | ||
) | ||
} | ||
|
||
@Test | ||
fun `자리 종류 조회 성공 (studyRoomId가 null이 아닌 경우)`() { | ||
// given | ||
every { securityPort.getCurrentUserId() } returns userId | ||
every { queryUserPort.queryUserById(userId) } returns userStub | ||
every { querySeatTypePort.queryAllSeatTypeByStudyRoomId(studyRoomId) } returns seatTypesStub | ||
|
||
// when | ||
val response = querySeatTypesUseCase.execute(studyRoomId) | ||
|
||
// then | ||
assertAll( | ||
{ verify(exactly = 1) { querySeatTypePort.queryAllSeatTypeByStudyRoomId(studyRoomId) } }, | ||
{ assertEquals(response.types.size, seatTypesStub.size) } | ||
) | ||
} | ||
|
||
@Test | ||
fun `유저가 존재하지 않음`() { | ||
// given | ||
every { securityPort.getCurrentUserId() } returns userId | ||
every { queryUserPort.queryUserById(userId) } returns null | ||
|
||
// when | ||
assertThrows<UserNotFoundException> { | ||
querySeatTypesUseCase.execute(null) | ||
} | ||
} | ||
} |
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
21 changes: 19 additions & 2 deletions
21
...cture/src/main/kotlin/team/aliens/dms/persistence/studyroom/SeatTypePersistenceAdapter.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
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
Oops, something went wrong.