-
Notifications
You must be signed in to change notification settings - Fork 3
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
75 changed files
with
1,424 additions
and
249 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
101 changes: 101 additions & 0 deletions
101
android/app/src/androidTest/java/com/happy/friendogly/ChatMessageDatabaseTest.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,101 @@ | ||
package com.happy.friendogly | ||
|
||
import android.content.Context | ||
import androidx.room.Room | ||
import androidx.test.core.app.ApplicationProvider | ||
import com.happy.friendogly.local.model.ChatMemberEntity | ||
import com.happy.friendogly.local.model.ChatMessageEntity | ||
import com.happy.friendogly.local.room.ChatMessageDao | ||
import com.happy.friendogly.local.room.ChatMessageDatabase | ||
import com.happy.friendogly.local.room.ChatRoomDao | ||
import com.happy.friendogly.local.room.MessageTypeEntity | ||
import kotlinx.coroutines.runBlocking | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.After | ||
import org.junit.Before | ||
import org.junit.Test | ||
import java.time.LocalDateTime | ||
|
||
class ChatMessageDatabaseTest { | ||
private lateinit var chatMessageDao: ChatMessageDao | ||
private lateinit var chatRoomDao: ChatRoomDao | ||
|
||
private lateinit var db: ChatMessageDatabase | ||
|
||
@Before | ||
fun setUp() { | ||
db = | ||
Room.inMemoryDatabaseBuilder( | ||
context = ApplicationProvider.getApplicationContext<Context>(), | ||
klass = ChatMessageDatabase::class.java, | ||
).build() | ||
|
||
chatMessageDao = db.chatMessageDao() | ||
chatRoomDao = db.chatRoomDao() | ||
} | ||
|
||
@After | ||
fun closeDb() { | ||
db.close() | ||
} | ||
|
||
@Test | ||
fun `can_save_chat_message_and_get_the_data`() { | ||
// when | ||
runBlocking { | ||
chatMessageDao.insert( | ||
DUMMY_MY_MESSAGE, | ||
) | ||
} | ||
|
||
// then | ||
runBlocking { | ||
val actual: List<ChatMessageEntity> = chatMessageDao.getAll() | ||
assertThat(actual).contains(DUMMY_MY_MESSAGE) | ||
} | ||
} | ||
|
||
@Test | ||
fun `can_update_chatRoom_message`() { | ||
// when | ||
runBlocking { | ||
chatRoomDao.addMessageToChatRoom(2, DUMMY_MY_MESSAGE) | ||
chatRoomDao.addMessageToChatRoom(2, DUMMY_CHAT_MESSAGE) | ||
} | ||
|
||
runBlocking { | ||
val messages = chatRoomDao.getMessagesByRoomId(2) | ||
assertThat(messages).contains(DUMMY_MY_MESSAGE, DUMMY_CHAT_MESSAGE) | ||
} | ||
} | ||
|
||
companion object { | ||
private val DUMMY_MY_MESSAGE = | ||
ChatMessageEntity( | ||
createdAt = LocalDateTime.of(2024, 6, 12, 14, 2), | ||
member = | ||
ChatMemberEntity( | ||
1, | ||
"벼리", | ||
"", | ||
), | ||
content = "", | ||
type = MessageTypeEntity.CHAT, | ||
id = 1, | ||
) | ||
|
||
private val DUMMY_CHAT_MESSAGE = | ||
ChatMessageEntity( | ||
createdAt = LocalDateTime.of(2024, 6, 12, 14, 2), | ||
member = | ||
ChatMemberEntity( | ||
2, | ||
"벼리", | ||
"", | ||
), | ||
content = "ZZZZZZZZ", | ||
type = MessageTypeEntity.CHAT, | ||
id = 2, | ||
) | ||
} | ||
} |
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
11 changes: 11 additions & 0 deletions
11
android/app/src/main/java/com/happy/friendogly/data/mapper/ClubChatRoomMapper.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,11 @@ | ||
package com.happy.friendogly.data.mapper | ||
|
||
import com.happy.friendogly.data.model.ChatRoomClubDto | ||
import com.happy.friendogly.domain.model.ChatRoomClub | ||
|
||
fun ChatRoomClubDto.toDomain(): ChatRoomClub = | ||
ChatRoomClub( | ||
clubId = clubId, | ||
allowedGender = allowedGender.map { it.toDomain() }, | ||
allowedSize = allowedSize.map { it.toDomain() }, | ||
) |
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
7 changes: 7 additions & 0 deletions
7
android/app/src/main/java/com/happy/friendogly/data/model/ChatRoomClubDto.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.happy.friendogly.data.model | ||
|
||
data class ChatRoomClubDto( | ||
val clubId: Long, | ||
val allowedGender: List<GenderDto>, | ||
val allowedSize: List<SizeTypeDto>, | ||
) |
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.