From 8322aed5e69e8874c105e956385efa488a733931 Mon Sep 17 00:00:00 2001 From: San Kim Date: Thu, 25 Apr 2024 13:16:33 +0900 Subject: [PATCH 1/8] =?UTF-8?q?[WEAV-350]=20=EC=B1=84=ED=8C=85=20=EB=A9=A4?= =?UTF-8?q?=EB=B2=84=20=EB=8F=84=EB=A9=94=EC=9D=B8=20=EC=84=A4=EA=B3=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weave/domain/chat/entity/ChatMember.kt | 30 +++++++++++++ .../weave/domain/chat/entity/ChatRoom.kt | 11 +++++ .../weave/domain/chat/entity/ChatRoomTest.kt | 42 ++++++++++++++++++- .../chat/entity/ChatMemberFixtureFactory.kt | 22 ++++++++++ .../chat/entity/ChatRoomFixtureFactory.kt | 4 +- 5 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMember.kt create mode 100644 domain/src/testFixtures/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMemberFixtureFactory.kt diff --git a/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMember.kt b/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMember.kt new file mode 100644 index 00000000..b71197b9 --- /dev/null +++ b/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMember.kt @@ -0,0 +1,30 @@ +package com.studentcenter.weave.domain.chat.entity + +import com.studentcenter.weave.domain.common.DomainEntity +import com.studentcenter.weave.support.common.uuid.UuidCreator +import java.time.LocalDateTime +import java.util.* + +data class ChatMember( + override val id: UUID = UuidCreator.create(), + val chatRoomId: UUID, + val userId: UUID, + val lastReadMessageId: UUID? = null, + val lastReadAt: LocalDateTime? = null, +) : DomainEntity { + + companion object { + + fun create( + chatRoomId: UUID, + userId: UUID, + ): ChatMember { + return ChatMember( + chatRoomId = chatRoomId, + userId = userId + ) + } + + } + +} diff --git a/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoom.kt b/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoom.kt index 58077879..f8313a37 100644 --- a/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoom.kt +++ b/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoom.kt @@ -12,8 +12,19 @@ data class ChatRoom( val receivingTeamId: UUID, val requestingTeamId: UUID, val createdAt: LocalDateTime = LocalDateTime.now(), + val members: List = emptyList(), ) : AggregateRoot { + fun addMember(userId: UUID): ChatRoom { + val existingMember: ChatMember? = members.find { it.userId == userId } + return if (existingMember != null) { + this + } else { + val newMember: ChatMember = ChatMember.create(this.id, userId) + this.copy(members = members + newMember) + } + } + companion object { fun create(meeting: Meeting): ChatRoom { diff --git a/domain/src/test/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoomTest.kt b/domain/src/test/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoomTest.kt index 5de10f65..1c6ea88a 100644 --- a/domain/src/test/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoomTest.kt +++ b/domain/src/test/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoomTest.kt @@ -2,16 +2,18 @@ package com.studentcenter.weave.domain.chat.entity import com.studentcenter.weave.domain.meeting.entity.MeetingFixtureFactory import com.studentcenter.weave.domain.meeting.enums.MeetingStatus +import com.studentcenter.weave.support.common.uuid.UuidCreator import io.kotest.assertions.throwables.shouldThrow import io.kotest.core.annotation.DisplayName import io.kotest.core.spec.style.DescribeSpec import io.kotest.matchers.shouldBe +import java.util.* @DisplayName("ChatRoomTest") class ChatRoomTest : DescribeSpec({ - describe("채팅방 생성 테스트") { + describe("채팅방 생성") { context("미팅이 매칭된 상태일 경우") { it("미팅 팀을 통해 채팅방을 생성한다") { // arrange @@ -49,4 +51,42 @@ class ChatRoomTest : DescribeSpec({ } } + describe("채팅 멤버 추가") { + context("멤버가 존재하지 않는 경우") { + it("멤버를 추가한다") { + // arrange + val chatRoom: ChatRoom = ChatRoomFixtureFactory.create() + val userId: UUID = UuidCreator.create() + + // act + val newMember: ChatRoom = chatRoom.addMember(userId) + + // assert + newMember.members.size shouldBe 1 + } + } + + context("멤버가 이미 존재하는 경우") { + it("멤버를 추가하지 않는다") { + // arrange + val chatRoomId: UUID = UuidCreator.create() + val userId: UUID = UuidCreator.create() + + val chatMember: ChatMember = ChatMemberFixtureFactory.create( + chatRoomId = chatRoomId, + userId = userId, + ) + val chatRoom: ChatRoom = ChatRoomFixtureFactory.create( + members = listOf(chatMember) + ) + + // act + val newMember: ChatRoom = chatRoom.addMember(userId) + + // assert + newMember.members.size shouldBe 1 + } + } + } + }) diff --git a/domain/src/testFixtures/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMemberFixtureFactory.kt b/domain/src/testFixtures/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMemberFixtureFactory.kt new file mode 100644 index 00000000..5ebbb43a --- /dev/null +++ b/domain/src/testFixtures/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMemberFixtureFactory.kt @@ -0,0 +1,22 @@ +package com.studentcenter.weave.domain.chat.entity + +import com.studentcenter.weave.support.common.uuid.UuidCreator +import java.time.LocalDateTime +import java.util.* + +object ChatMemberFixtureFactory { + + fun create( + chatRoomId: UUID = UuidCreator.create(), + userId: UUID = UuidCreator.create(), + lastReadMessageId: UUID? = null, + lastReadAt: LocalDateTime? = null, + ): ChatMember { + return ChatMember( + chatRoomId = chatRoomId, + userId = userId, + lastReadMessageId = lastReadMessageId, + lastReadAt = lastReadAt + ) + } +} diff --git a/domain/src/testFixtures/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoomFixtureFactory.kt b/domain/src/testFixtures/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoomFixtureFactory.kt index deb32a44..4ffa5ebf 100644 --- a/domain/src/testFixtures/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoomFixtureFactory.kt +++ b/domain/src/testFixtures/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoomFixtureFactory.kt @@ -12,6 +12,7 @@ object ChatRoomFixtureFactory { requestingTeamId: UUID = UuidCreator.create(), receivingTeamId: UUID = UuidCreator.create(), createdAt: LocalDateTime = LocalDateTime.now(), + members: List = emptyList(), ): ChatRoom { return ChatRoom( id = id, @@ -19,7 +20,8 @@ object ChatRoomFixtureFactory { requestingTeamId = requestingTeamId, receivingTeamId = receivingTeamId, createdAt = createdAt, + members = members ) - } + } From 2cd9cf0e8e21d99eea9f4259d7497ba89dc5f12b Mon Sep 17 00:00:00 2001 From: San Kim Date: Thu, 25 Apr 2024 13:32:30 +0900 Subject: [PATCH 2/8] =?UTF-8?q?[WEAV-350]=20=EC=B1=84=ED=8C=85=20=EB=A9=A4?= =?UTF-8?q?=EB=B2=84=20=EB=8F=84=EB=A9=94=EC=9D=B8=20=EC=84=A4=EA=B3=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../studentcenter/weave/domain/chat/entity/ChatMember.kt | 8 ++++---- .../studentcenter/weave/domain/chat/entity/ChatRoom.kt | 7 +++++-- .../weave/domain/chat/entity/ChatRoomTest.kt | 9 +++++---- .../weave/domain/chat/entity/ChatMemberFixtureFactory.kt | 7 +++++-- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMember.kt b/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMember.kt index b71197b9..2960c455 100644 --- a/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMember.kt +++ b/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMember.kt @@ -7,8 +7,8 @@ import java.util.* data class ChatMember( override val id: UUID = UuidCreator.create(), - val chatRoomId: UUID, val userId: UUID, + val meetingTeamId: UUID, val lastReadMessageId: UUID? = null, val lastReadAt: LocalDateTime? = null, ) : DomainEntity { @@ -16,12 +16,12 @@ data class ChatMember( companion object { fun create( - chatRoomId: UUID, userId: UUID, + meetingTeamId: UUID, ): ChatMember { return ChatMember( - chatRoomId = chatRoomId, - userId = userId + userId = userId, + meetingTeamId = meetingTeamId, ) } diff --git a/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoom.kt b/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoom.kt index f8313a37..a34516d7 100644 --- a/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoom.kt +++ b/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoom.kt @@ -15,12 +15,15 @@ data class ChatRoom( val members: List = emptyList(), ) : AggregateRoot { - fun addMember(userId: UUID): ChatRoom { + fun addMember( + userId: UUID, + meetingId: UUID, + ): ChatRoom { val existingMember: ChatMember? = members.find { it.userId == userId } return if (existingMember != null) { this } else { - val newMember: ChatMember = ChatMember.create(this.id, userId) + val newMember: ChatMember = ChatMember.create(userId, meetingId) this.copy(members = members + newMember) } } diff --git a/domain/src/test/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoomTest.kt b/domain/src/test/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoomTest.kt index 1c6ea88a..99e983d6 100644 --- a/domain/src/test/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoomTest.kt +++ b/domain/src/test/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoomTest.kt @@ -57,9 +57,10 @@ class ChatRoomTest : DescribeSpec({ // arrange val chatRoom: ChatRoom = ChatRoomFixtureFactory.create() val userId: UUID = UuidCreator.create() + val meetingTeamId: UUID = UuidCreator.create() // act - val newMember: ChatRoom = chatRoom.addMember(userId) + val newMember: ChatRoom = chatRoom.addMember(userId, meetingTeamId) // assert newMember.members.size shouldBe 1 @@ -69,19 +70,19 @@ class ChatRoomTest : DescribeSpec({ context("멤버가 이미 존재하는 경우") { it("멤버를 추가하지 않는다") { // arrange - val chatRoomId: UUID = UuidCreator.create() val userId: UUID = UuidCreator.create() + val meetingTeamId: UUID = UuidCreator.create() val chatMember: ChatMember = ChatMemberFixtureFactory.create( - chatRoomId = chatRoomId, userId = userId, + meetingTeamId = meetingTeamId ) val chatRoom: ChatRoom = ChatRoomFixtureFactory.create( members = listOf(chatMember) ) // act - val newMember: ChatRoom = chatRoom.addMember(userId) + val newMember: ChatRoom = chatRoom.addMember(userId, meetingTeamId) // assert newMember.members.size shouldBe 1 diff --git a/domain/src/testFixtures/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMemberFixtureFactory.kt b/domain/src/testFixtures/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMemberFixtureFactory.kt index 5ebbb43a..2517011c 100644 --- a/domain/src/testFixtures/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMemberFixtureFactory.kt +++ b/domain/src/testFixtures/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMemberFixtureFactory.kt @@ -7,16 +7,19 @@ import java.util.* object ChatMemberFixtureFactory { fun create( - chatRoomId: UUID = UuidCreator.create(), + id: UUID = UuidCreator.create(), userId: UUID = UuidCreator.create(), + meetingTeamId: UUID = UuidCreator.create(), lastReadMessageId: UUID? = null, lastReadAt: LocalDateTime? = null, ): ChatMember { return ChatMember( - chatRoomId = chatRoomId, + id = id, userId = userId, + meetingTeamId = meetingTeamId, lastReadMessageId = lastReadMessageId, lastReadAt = lastReadAt ) } + } From 021eefc42fa788486a13f3c69c6ea739b07d54dc Mon Sep 17 00:00:00 2001 From: San Kim Date: Thu, 25 Apr 2024 15:42:00 +0900 Subject: [PATCH 3/8] =?UTF-8?q?[WEAV-350]=20=EC=B1=84=ED=8C=85=20=EB=A9=A4?= =?UTF-8?q?=EB=B2=84=20=EB=8F=84=EB=A9=94=EC=9D=B8=20=EC=84=A4=EA=B3=84(me?= =?UTF-8?q?etingTeamId=20=EC=86=8D=EC=84=B1=EC=A0=9C=EA=B1=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weave/domain/chat/entity/ChatMember.kt | 11 ++--------- .../weave/domain/chat/entity/ChatRoom.kt | 7 ++----- .../weave/domain/chat/entity/ChatRoomTest.kt | 11 +++-------- .../domain/chat/entity/ChatMemberFixtureFactory.kt | 2 -- 4 files changed, 7 insertions(+), 24 deletions(-) diff --git a/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMember.kt b/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMember.kt index 2960c455..f478ceab 100644 --- a/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMember.kt +++ b/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMember.kt @@ -8,21 +8,14 @@ import java.util.* data class ChatMember( override val id: UUID = UuidCreator.create(), val userId: UUID, - val meetingTeamId: UUID, val lastReadMessageId: UUID? = null, val lastReadAt: LocalDateTime? = null, ) : DomainEntity { companion object { - fun create( - userId: UUID, - meetingTeamId: UUID, - ): ChatMember { - return ChatMember( - userId = userId, - meetingTeamId = meetingTeamId, - ) + fun create(userId: UUID, ): ChatMember { + return ChatMember(userId = userId) } } diff --git a/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoom.kt b/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoom.kt index a34516d7..aabe974e 100644 --- a/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoom.kt +++ b/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoom.kt @@ -15,15 +15,12 @@ data class ChatRoom( val members: List = emptyList(), ) : AggregateRoot { - fun addMember( - userId: UUID, - meetingId: UUID, - ): ChatRoom { + fun addMember(userId: UUID): ChatRoom { val existingMember: ChatMember? = members.find { it.userId == userId } return if (existingMember != null) { this } else { - val newMember: ChatMember = ChatMember.create(userId, meetingId) + val newMember: ChatMember = ChatMember.create(userId) this.copy(members = members + newMember) } } diff --git a/domain/src/test/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoomTest.kt b/domain/src/test/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoomTest.kt index 99e983d6..ef454b49 100644 --- a/domain/src/test/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoomTest.kt +++ b/domain/src/test/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoomTest.kt @@ -57,10 +57,9 @@ class ChatRoomTest : DescribeSpec({ // arrange val chatRoom: ChatRoom = ChatRoomFixtureFactory.create() val userId: UUID = UuidCreator.create() - val meetingTeamId: UUID = UuidCreator.create() // act - val newMember: ChatRoom = chatRoom.addMember(userId, meetingTeamId) + val newMember: ChatRoom = chatRoom.addMember(userId) // assert newMember.members.size shouldBe 1 @@ -71,18 +70,14 @@ class ChatRoomTest : DescribeSpec({ it("멤버를 추가하지 않는다") { // arrange val userId: UUID = UuidCreator.create() - val meetingTeamId: UUID = UuidCreator.create() - val chatMember: ChatMember = ChatMemberFixtureFactory.create( - userId = userId, - meetingTeamId = meetingTeamId - ) + val chatMember: ChatMember = ChatMemberFixtureFactory.create(userId = userId) val chatRoom: ChatRoom = ChatRoomFixtureFactory.create( members = listOf(chatMember) ) // act - val newMember: ChatRoom = chatRoom.addMember(userId, meetingTeamId) + val newMember: ChatRoom = chatRoom.addMember(userId) // assert newMember.members.size shouldBe 1 diff --git a/domain/src/testFixtures/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMemberFixtureFactory.kt b/domain/src/testFixtures/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMemberFixtureFactory.kt index 2517011c..2fc30d51 100644 --- a/domain/src/testFixtures/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMemberFixtureFactory.kt +++ b/domain/src/testFixtures/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMemberFixtureFactory.kt @@ -9,14 +9,12 @@ object ChatMemberFixtureFactory { fun create( id: UUID = UuidCreator.create(), userId: UUID = UuidCreator.create(), - meetingTeamId: UUID = UuidCreator.create(), lastReadMessageId: UUID? = null, lastReadAt: LocalDateTime? = null, ): ChatMember { return ChatMember( id = id, userId = userId, - meetingTeamId = meetingTeamId, lastReadMessageId = lastReadMessageId, lastReadAt = lastReadAt ) From 67fdf1a5f1081b572b4f2544bc4031a7aeca3287 Mon Sep 17 00:00:00 2001 From: San Kim Date: Thu, 25 Apr 2024 16:06:48 +0900 Subject: [PATCH 4/8] =?UTF-8?q?[WEAV-350]=20=EC=B1=84=ED=8C=85=20=EB=A9=A4?= =?UTF-8?q?=EB=B2=84=20=EB=8F=84=EB=A9=94=EC=9D=B8=20=EC=84=A4=EA=B3=84(?= =?UTF-8?q?=EB=A9=A4=EB=B2=84=EC=B6=94=EA=B0=80=20=EB=A9=B1=EB=93=B1=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weave/domain/chat/entity/ChatRoom.kt | 11 +++++------ .../weave/domain/chat/entity/ChatRoomTest.kt | 11 +++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoom.kt b/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoom.kt index aabe974e..f3008d44 100644 --- a/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoom.kt +++ b/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoom.kt @@ -16,13 +16,12 @@ data class ChatRoom( ) : AggregateRoot { fun addMember(userId: UUID): ChatRoom { - val existingMember: ChatMember? = members.find { it.userId == userId } - return if (existingMember != null) { - this - } else { - val newMember: ChatMember = ChatMember.create(userId) - this.copy(members = members + newMember) + require(members.none { it.userId == userId }) { + "이미 채팅방에 참여하고 있는 사용자입니다." } + + val newMember: ChatMember = ChatMember.create(userId) + return copy(members = members + newMember) } companion object { diff --git a/domain/src/test/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoomTest.kt b/domain/src/test/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoomTest.kt index ef454b49..d4023c05 100644 --- a/domain/src/test/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoomTest.kt +++ b/domain/src/test/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoomTest.kt @@ -67,7 +67,7 @@ class ChatRoomTest : DescribeSpec({ } context("멤버가 이미 존재하는 경우") { - it("멤버를 추가하지 않는다") { + it("예외를 발생시킨다.") { // arrange val userId: UUID = UuidCreator.create() @@ -76,11 +76,10 @@ class ChatRoomTest : DescribeSpec({ members = listOf(chatMember) ) - // act - val newMember: ChatRoom = chatRoom.addMember(userId) - - // assert - newMember.members.size shouldBe 1 + // act, assert + shouldThrow { + chatRoom.addMember(userId) + } } } } From 19e3817eff33a7498ac41ec22227ffcfbcfb3d36 Mon Sep 17 00:00:00 2001 From: San Kim Date: Sat, 27 Apr 2024 03:36:12 +0900 Subject: [PATCH 5/8] =?UTF-8?q?[WEAV-350]=20=EB=A6=AC=EB=B7=B0=20=EB=B0=98?= =?UTF-8?q?=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/studentcenter/weave/domain/chat/entity/ChatMember.kt | 4 +--- .../weave/domain/chat/entity/ChatMemberFixtureFactory.kt | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMember.kt b/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMember.kt index f478ceab..8b035518 100644 --- a/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMember.kt +++ b/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMember.kt @@ -2,19 +2,17 @@ package com.studentcenter.weave.domain.chat.entity import com.studentcenter.weave.domain.common.DomainEntity import com.studentcenter.weave.support.common.uuid.UuidCreator -import java.time.LocalDateTime import java.util.* data class ChatMember( override val id: UUID = UuidCreator.create(), val userId: UUID, val lastReadMessageId: UUID? = null, - val lastReadAt: LocalDateTime? = null, ) : DomainEntity { companion object { - fun create(userId: UUID, ): ChatMember { + fun create(userId: UUID): ChatMember { return ChatMember(userId = userId) } diff --git a/domain/src/testFixtures/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMemberFixtureFactory.kt b/domain/src/testFixtures/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMemberFixtureFactory.kt index 2fc30d51..f320226c 100644 --- a/domain/src/testFixtures/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMemberFixtureFactory.kt +++ b/domain/src/testFixtures/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMemberFixtureFactory.kt @@ -10,13 +10,11 @@ object ChatMemberFixtureFactory { id: UUID = UuidCreator.create(), userId: UUID = UuidCreator.create(), lastReadMessageId: UUID? = null, - lastReadAt: LocalDateTime? = null, ): ChatMember { return ChatMember( id = id, userId = userId, lastReadMessageId = lastReadMessageId, - lastReadAt = lastReadAt ) } From 177a7bde19789c8ccf8b7df419dffe1206b9a75a Mon Sep 17 00:00:00 2001 From: San Kim Date: Sat, 27 Apr 2024 03:36:45 +0900 Subject: [PATCH 6/8] =?UTF-8?q?[WEAV-350]=20=EB=A6=AC=EB=B7=B0=20=EB=B0=98?= =?UTF-8?q?=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weave/domain/chat/entity/ChatMemberFixtureFactory.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/domain/src/testFixtures/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMemberFixtureFactory.kt b/domain/src/testFixtures/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMemberFixtureFactory.kt index f320226c..4a8cbe64 100644 --- a/domain/src/testFixtures/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMemberFixtureFactory.kt +++ b/domain/src/testFixtures/kotlin/com/studentcenter/weave/domain/chat/entity/ChatMemberFixtureFactory.kt @@ -1,7 +1,6 @@ package com.studentcenter.weave.domain.chat.entity import com.studentcenter.weave.support.common.uuid.UuidCreator -import java.time.LocalDateTime import java.util.* object ChatMemberFixtureFactory { From 2eafdf2c3ca26ff1af7f0d3f98fcf713a571f89f Mon Sep 17 00:00:00 2001 From: San Kim Date: Sat, 27 Apr 2024 10:24:35 +0900 Subject: [PATCH 7/8] =?UTF-8?q?[WEAV-350]=20=EB=A6=AC=EB=B7=B0=20=EB=B0=98?= =?UTF-8?q?=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/studentcenter/weave/domain/chat/entity/ChatRoom.kt | 2 +- .../com/studentcenter/weave/domain/chat/entity/ChatRoomTest.kt | 2 +- .../weave/domain/chat/entity/ChatRoomFixtureFactory.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoom.kt b/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoom.kt index f3008d44..5538d47b 100644 --- a/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoom.kt +++ b/domain/src/main/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoom.kt @@ -12,7 +12,7 @@ data class ChatRoom( val receivingTeamId: UUID, val requestingTeamId: UUID, val createdAt: LocalDateTime = LocalDateTime.now(), - val members: List = emptyList(), + val members: Set = emptySet(), ) : AggregateRoot { fun addMember(userId: UUID): ChatRoom { diff --git a/domain/src/test/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoomTest.kt b/domain/src/test/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoomTest.kt index d4023c05..c7da8e64 100644 --- a/domain/src/test/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoomTest.kt +++ b/domain/src/test/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoomTest.kt @@ -73,7 +73,7 @@ class ChatRoomTest : DescribeSpec({ val chatMember: ChatMember = ChatMemberFixtureFactory.create(userId = userId) val chatRoom: ChatRoom = ChatRoomFixtureFactory.create( - members = listOf(chatMember) + members = setOf(chatMember) ) // act, assert diff --git a/domain/src/testFixtures/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoomFixtureFactory.kt b/domain/src/testFixtures/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoomFixtureFactory.kt index 4ffa5ebf..dc63247e 100644 --- a/domain/src/testFixtures/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoomFixtureFactory.kt +++ b/domain/src/testFixtures/kotlin/com/studentcenter/weave/domain/chat/entity/ChatRoomFixtureFactory.kt @@ -12,7 +12,7 @@ object ChatRoomFixtureFactory { requestingTeamId: UUID = UuidCreator.create(), receivingTeamId: UUID = UuidCreator.create(), createdAt: LocalDateTime = LocalDateTime.now(), - members: List = emptyList(), + members: Set = emptySet(), ): ChatRoom { return ChatRoom( id = id, From 231a02c9ad7c93251ee2fa073df43c16146d04f5 Mon Sep 17 00:00:00 2001 From: San Kim Date: Sat, 27 Apr 2024 10:34:11 +0900 Subject: [PATCH 8/8] =?UTF-8?q?[WEAV-350]=20=EB=A6=AC=EB=B7=B0=20=EB=B0=98?= =?UTF-8?q?=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/MeetingEventHandlerTest.kt | 39 ------------------- 1 file changed, 39 deletions(-) delete mode 100644 bootstrap/http/src/test/kotlin/com/studentcenter/weave/bootstrap/meeting/controller/MeetingEventHandlerTest.kt diff --git a/bootstrap/http/src/test/kotlin/com/studentcenter/weave/bootstrap/meeting/controller/MeetingEventHandlerTest.kt b/bootstrap/http/src/test/kotlin/com/studentcenter/weave/bootstrap/meeting/controller/MeetingEventHandlerTest.kt deleted file mode 100644 index 1d39812a..00000000 --- a/bootstrap/http/src/test/kotlin/com/studentcenter/weave/bootstrap/meeting/controller/MeetingEventHandlerTest.kt +++ /dev/null @@ -1,39 +0,0 @@ -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) } just runs - - // act - applicationEventPublisher.publishEvent(meetingCompletedEvent) - - // assert - verify { createChatRoom.invoke(meetingCompletedEvent) } - } - } - -})