This repository has been archived by the owner on May 19, 2024. It is now read-only.
-
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
1 parent
c25b3c4
commit 9e159f2
Showing
13 changed files
with
152 additions
and
16 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
9 changes: 9 additions & 0 deletions
9
...kotlin/com/studentcenter/weave/application/meeting/port/outbound/MeetingEventPublisher.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,9 @@ | ||
package com.studentcenter.weave.application.meeting.port.outbound | ||
|
||
import com.studentcenter.weave.domain.meeting.event.MeetingCompletedEvent | ||
|
||
interface MeetingEventPublisher { | ||
|
||
fun publish(meetingCompletedEvent: MeetingCompletedEvent) | ||
|
||
} |
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
17 changes: 17 additions & 0 deletions
17
.../kotlin/com/studentcenter/weave/application/meeting/service/domain/MeetingEventService.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,17 @@ | ||
package com.studentcenter.weave.application.meeting.service.domain | ||
|
||
import com.studentcenter.weave.application.meeting.port.outbound.MeetingEventPublisher | ||
import com.studentcenter.weave.domain.meeting.event.MeetingCompletedEvent | ||
import org.springframework.context.ApplicationEventPublisher | ||
import org.springframework.stereotype.Service | ||
|
||
@Service | ||
class MeetingEventService( | ||
private val eventPublisher: ApplicationEventPublisher, | ||
): MeetingEventPublisher { | ||
|
||
override fun publish(meetingCompletedEvent: MeetingCompletedEvent) { | ||
eventPublisher.publishEvent(meetingCompletedEvent) | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
...c/main/kotlin/com/studentcenter/weave/bootstrap/meeting/controller/MeetingEventHandler.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,20 @@ | ||
package com.studentcenter.weave.bootstrap.meeting.controller | ||
|
||
import com.studentcenter.weave.application.chat.port.inbound.CreateChatRoom | ||
import com.studentcenter.weave.domain.meeting.event.MeetingCompletedEvent | ||
import org.springframework.context.event.EventListener | ||
import org.springframework.stereotype.Controller | ||
|
||
@Controller | ||
class MeetingEventHandler( | ||
private val createChatRoom: CreateChatRoom, | ||
) { | ||
|
||
@EventListener | ||
fun handleMeetingEvent(meetingCompletedEvent: MeetingCompletedEvent) { | ||
meetingCompletedEvent | ||
.entity | ||
.also { createChatRoom.invoke(it) } | ||
} | ||
|
||
} |
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
39 changes: 39 additions & 0 deletions
39
...st/kotlin/com/studentcenter/weave/bootstrap/meeting/controller/MeetingEventHandlerTest.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,39 @@ | ||
package com.studentcenter.weave.bootstrap.meeting.controller | ||
|
||
import com.ninjasquad.springmockk.MockkBean | ||
import com.studentcenter.weave.application.chat.port.inbound.CreateChatRoom | ||
import com.studentcenter.weave.bootstrap.integration.IntegrationTestDescribeSpec | ||
import com.studentcenter.weave.domain.meeting.entity.MeetingFixtureFactory | ||
import com.studentcenter.weave.domain.meeting.enums.MeetingStatus | ||
import com.studentcenter.weave.domain.meeting.event.MeetingCompletedEvent.Companion.createCompletedEvent | ||
import io.kotest.core.annotation.DisplayName | ||
import io.mockk.every | ||
import io.mockk.just | ||
import io.mockk.runs | ||
import io.mockk.verify | ||
import org.springframework.context.ApplicationEventPublisher | ||
|
||
@DisplayName("MeetingEventHandler 테스트") | ||
class MeetingEventHandlerTest( | ||
private val applicationEventPublisher: ApplicationEventPublisher, | ||
@MockkBean | ||
private val createChatRoom: CreateChatRoom, | ||
) : IntegrationTestDescribeSpec({ | ||
|
||
describe("미팅 완료 이벤트를 전달 받으면") { | ||
it("새로운 채팅방을 생성한다") { | ||
// arrange | ||
val meetingFixture = MeetingFixtureFactory.create(status = MeetingStatus.COMPLETED) | ||
val meetingCompletedEvent = meetingFixture.createCompletedEvent() | ||
|
||
every { createChatRoom.invoke(meetingCompletedEvent.entity) } just runs | ||
|
||
// act | ||
applicationEventPublisher.publishEvent(meetingCompletedEvent) | ||
|
||
// assert | ||
verify { createChatRoom.invoke(meetingCompletedEvent.entity) } | ||
} | ||
} | ||
|
||
}) |
3 changes: 3 additions & 0 deletions
3
domain/src/main/kotlin/com/studentcenter/weave/domain/common/AggregateRoot.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,3 @@ | ||
package com.studentcenter.weave.domain.common | ||
|
||
interface AggregateRoot : DomainEntity |
9 changes: 9 additions & 0 deletions
9
domain/src/main/kotlin/com/studentcenter/weave/domain/common/DomainEntity.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,9 @@ | ||
package com.studentcenter.weave.domain.common | ||
|
||
import java.util.* | ||
|
||
interface DomainEntity { | ||
|
||
val id: UUID | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
domain/src/main/kotlin/com/studentcenter/weave/domain/common/DomainEvent.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,7 @@ | ||
package com.studentcenter.weave.domain.common | ||
|
||
interface DomainEvent<T : AggregateRoot> { | ||
|
||
val entity: T | ||
|
||
} |
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
20 changes: 20 additions & 0 deletions
20
domain/src/main/kotlin/com/studentcenter/weave/domain/meeting/event/MeetingCompletedEvent.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,20 @@ | ||
package com.studentcenter.weave.domain.meeting.event | ||
|
||
import com.studentcenter.weave.domain.common.DomainEvent | ||
import com.studentcenter.weave.domain.meeting.entity.Meeting | ||
|
||
data class MeetingCompletedEvent( | ||
override val entity: Meeting, | ||
) : DomainEvent<Meeting> { | ||
|
||
companion object { | ||
|
||
fun Meeting.createCompletedEvent(): MeetingCompletedEvent { | ||
require(isCompleted()) { "미팅이 완료되지 않았습니다." } | ||
|
||
return MeetingCompletedEvent(this) | ||
} | ||
|
||
} | ||
|
||
} |