diff --git a/android/app/src/main/assets/zero_shot_classname_to_unicode.json b/android/app/src/main/assets/zero_shot_classname_to_unicode.json index e0c53145..6c8d40bf 100644 --- a/android/app/src/main/assets/zero_shot_classname_to_unicode.json +++ b/android/app/src/main/assets/zero_shot_classname_to_unicode.json @@ -1,12 +1,12 @@ { - "call": "U+1F919", - "dislike": "U+1F645", - "fist": "U+1F44A", - "like": "U+1F44D", - "mute": "U+1F92B", - "ok": "U+1F646", - "palm": "U+1F64B", - "peace": "U+270C", - "rock": "U+1F918", - "stop": "U+270B" + "clapping hands": "U+1F44F", + "I love it": "U+2764 U+FE0F", + "selfie": "U+1F933", + "punch": "U+1F44A", + "I see you": "U+1F440", + "no": "U+1F645", + "so hot": "U+1F525", + "cool": "U+1F60E", + "angry": "U+1F620", + "praying hands": "U+1F64F" } \ No newline at end of file diff --git a/android/app/src/main/assets/zero_shot_classname_to_unicode_100.json b/android/app/src/main/assets/zero_shot_classname_to_unicode_100.json new file mode 100644 index 00000000..a5b6ee03 --- /dev/null +++ b/android/app/src/main/assets/zero_shot_classname_to_unicode_100.json @@ -0,0 +1,102 @@ +{ + "call": "U+1F919", + "dislike": "U+1F645", + "fist": "U+1F44A", + "like": "U+1F44D", + "mute": "U+1F92B", + "ok": "U+1F646", + "palm": "U+1F64B", + "peace": "U+270C", + "rock": "U+1F918", + "stop": "U+270B", + "clapping hands": "U+1F44F", + "thumbs up": "U+1F44D", + "thumbs down": "U+1F44E", + "waving hand": "U+1F44B", + "raised hand": "U+270B", + "victory hand": "U+270C", + "crossed fingers": "U+1F91E", + "love-you gesture": "U+1F91F", + "sign of the horns": "U+1F918", + "call me hand": "U+1F919", + "flexed biceps": "U+1F4AA", + "folded hands": "U+1F64F", + "handshake": "U+1F91D", + "writing hand": "U+270D", + "selfie": "U+1F933", + "mouth": "U+1F444", + "nose": "U+1F443", + "ear": "U+1F442", + "foot": "U+1F9B6", + "leg": "U+1F9B5", + "mechanical arm": "U+1F9BE", + "mechanical leg": "U+1F9BF", + "pointing up": "U+261D", + "pointing down": "U+1F447", + "pointing left": "U+1F448", + "pointing right": "U+1F449", + "raised fist": "U+270A", + "oncoming fist": "U+1F44A", + "left-facing fist": "U+1F91B", + "right-facing fist": "U+1F91C", + "raising hands": "U+1F64C", + "open hands": "U+1F450", + "palms up together": "U+1F932", + "hand with fingers splayed": "U+1F590", + "vulcan salute": "U+1F596", + "praying hands": "U+1F64F", + "eyes": "U+1F440", + "speaking head": "U+1F5E3", + "boy": "U+1F466", + "girl": "U+1F467", + "man": "U+1F468", + "woman": "U+1F469", + "person frowning": "U+1F64D", + "person pouting": "U+1F64E", + "person gesturing no": "U+1F645", + "person gesturing ok": "U+1F646", + "person tipping hand": "U+1F481", + "person raising hand": "U+1F64B", + "person bowing": "U+1F647", + "person facepalming": "U+1F926", + "person shrugging": "U+1F937", + "weight lifter": "U+1F3CB", + "wrestlers": "U+1F93C", + "handball": "U+1F93E", + "juggling": "U+1F939", + "smile": "U+1F642", + "heart": "U+2764", + "clap": "U+1F44F", + "star": "U+2B50", + "fire": "U+1F525", + "laugh": "U+1F602", + "wink": "U+1F609", + "sad": "U+1F641", + "angry": "U+1F620", + "wow": "U+1F62E", + "cool": "U+1F60E", + "kiss": "U+1F618", + "hug": "U+1F917", + "thinking": "U+1F914", + "scream": "U+1F631", + "rolling eyes": "U+1F644", + "sleep": "U+1F634", + "sweat": "U+1F613", + "nerd": "U+1F913", + "money-mouth": "U+1F911", + "sick": "U+1F912", + "dizzy": "U+1F635", + "party": "U+1F973", + "cat": "U+1F431", + "dog": "U+1F436", + "sun": "U+2600", + "moon": "U+1F319", + "cloud": "U+2601", + "rain": "U+1F327", + "snow": "U+1F328", + "lightning": "U+1F329", + "tornado": "U+1F32A", + "wind": "U+1F32C", + "fog": "U+1F32B", + "rainbow": "U+1F308" +} \ No newline at end of file diff --git a/android/app/src/main/java/com/goliath/emojihub/data_sources/ApiErrorController.kt b/android/app/src/main/java/com/goliath/emojihub/data_sources/ApiErrorController.kt index 69f5a820..d2b29a75 100644 --- a/android/app/src/main/java/com/goliath/emojihub/data_sources/ApiErrorController.kt +++ b/android/app/src/main/java/com/goliath/emojihub/data_sources/ApiErrorController.kt @@ -52,7 +52,10 @@ enum class CustomError( }, INTERNAL_SERVER_ERROR(500) { override fun body(): String = "네트워크 접속 오류가 발생했습니다." - },; + }, + NETWORK_IS_BUSY(503) { + override fun body(): String = "네트워크가 혼잡합니다.\n잠시 후 다시 시도해주세요." + }; companion object { fun getBy(statusCode: Int) = values().firstOrNull { it.statusCode == statusCode } diff --git a/android/app/src/main/java/com/goliath/emojihub/repositories/remote/ClipRepository.kt b/android/app/src/main/java/com/goliath/emojihub/repositories/remote/ClipRepository.kt index 75c19b95..fdcd4a69 100644 --- a/android/app/src/main/java/com/goliath/emojihub/repositories/remote/ClipRepository.kt +++ b/android/app/src/main/java/com/goliath/emojihub/repositories/remote/ClipRepository.kt @@ -2,6 +2,8 @@ package com.goliath.emojihub.repositories.remote import android.net.Uri import android.util.Log +import com.goliath.emojihub.data_sources.ApiErrorController +import com.goliath.emojihub.data_sources.CustomError import com.goliath.emojihub.data_sources.api.ClipApi import com.goliath.emojihub.data_sources.local.MediaDataSource import com.goliath.emojihub.models.ClipRequestDto @@ -18,7 +20,8 @@ interface ClipRepository { @Singleton class ClipRepositoryImpl @Inject constructor( private val clipApi: ClipApi, - private val mediaDataSource: MediaDataSource + private val mediaDataSource: MediaDataSource, + private val errorController: ApiErrorController ): ClipRepository { // FIXME: Default emojis should be topK different emojis -> use just 3 emojis for now override val DEFAULT_EMOJI_LIST = listOf( @@ -79,9 +82,11 @@ class ClipRepositoryImpl @Inject constructor( } } Log.e("ClipRepository", "Clip inference response is not successful") + errorController.setErrorState(CustomError.NETWORK_IS_BUSY.statusCode) return emptyList() } catch (e: Exception) { Log.e("ClipRepository", "Error running clip inference ${e.message}") + errorController.setErrorState(CustomError.NETWORK_IS_BUSY.statusCode) } return emptyList() } diff --git a/android/app/src/test/java/com/goliath/emojihub/repositories/remote/ClipRepositoryImplTest.kt b/android/app/src/test/java/com/goliath/emojihub/repositories/remote/ClipRepositoryImplTest.kt index 289f343c..bcf1f27a 100644 --- a/android/app/src/test/java/com/goliath/emojihub/repositories/remote/ClipRepositoryImplTest.kt +++ b/android/app/src/test/java/com/goliath/emojihub/repositories/remote/ClipRepositoryImplTest.kt @@ -3,6 +3,7 @@ package com.goliath.emojihub.repositories.remote import android.graphics.Bitmap import android.media.MediaMetadataRetriever import android.net.Uri +import com.goliath.emojihub.data_sources.ApiErrorController import com.goliath.emojihub.data_sources.api.ClipApi import com.goliath.emojihub.data_sources.local.MediaDataSource import com.goliath.emojihub.mockLogClass @@ -12,6 +13,7 @@ import io.mockk.coEvery import io.mockk.coVerify import io.mockk.every import io.mockk.mockk +import io.mockk.spyk import io.mockk.verify import kotlinx.coroutines.runBlocking import org.json.JSONObject @@ -27,7 +29,8 @@ import retrofit2.Response class ClipRepositoryImplTest { private val clipApi = mockk() private val mediaDataSource = mockk() - private val clipRepositoryImpl = ClipRepositoryImpl(clipApi, mediaDataSource) + private val errorController = spyk() + private val clipRepositoryImpl = ClipRepositoryImpl(clipApi, mediaDataSource, errorController) private val fakeJSONMap = hashMapOf( "like" to "U+1F44D", diff --git a/springboot/src/test/kotlin/com/goliath/emojihub/springboot/domain/emoji/dao/EmojiDaoTest.kt b/springboot/src/test/kotlin/com/goliath/emojihub/springboot/domain/emoji/dao/EmojiDaoTest.kt index f3be699a..7aad5f0e 100644 --- a/springboot/src/test/kotlin/com/goliath/emojihub/springboot/domain/emoji/dao/EmojiDaoTest.kt +++ b/springboot/src/test/kotlin/com/goliath/emojihub/springboot/domain/emoji/dao/EmojiDaoTest.kt @@ -79,6 +79,12 @@ internal class EmojiDaoTest { for (emoji in testDto.emojiList) { testDB.collection(EMOJI_COLLECTION_NAME.string).document(emoji.id).set(emoji) } + var docs = testDB.collection(EMOJI_COLLECTION_NAME.string).get().get().documents + var a = 1 + while (docs.size != testDto.emojiList.size && a <= 5) { + docs = testDB.collection(EMOJI_COLLECTION_NAME.string).get().get().documents + a++ + } } } @@ -236,6 +242,13 @@ internal class EmojiDaoTest { testDB.collection(EMOJI_COLLECTION_NAME.string) .document(emojiId) .set(emojiList[3]) + result = emojiDao.existsEmoji(emojiId) + var b = 1 + while (!result && b <= 5) { + result = emojiDao.existsEmoji(emojiId) + b++ + } + assertEquals(result, true) } @Test diff --git a/springboot/src/test/kotlin/com/goliath/emojihub/springboot/domain/post/dao/PostDaoTest.kt b/springboot/src/test/kotlin/com/goliath/emojihub/springboot/domain/post/dao/PostDaoTest.kt index 0069f279..2cc99f39 100644 --- a/springboot/src/test/kotlin/com/goliath/emojihub/springboot/domain/post/dao/PostDaoTest.kt +++ b/springboot/src/test/kotlin/com/goliath/emojihub/springboot/domain/post/dao/PostDaoTest.kt @@ -65,6 +65,12 @@ internal class PostDaoTest { for (post in testDto.postList) { testDB.collection(POST_COLLECTION_NAME.string).document(post.id).set(post) } + var docs = testDB.collection(POST_COLLECTION_NAME.string).get().get().documents + var a = 1 + while (docs.size != testDto.postList.size && a <= 5) { + docs = testDB.collection(POST_COLLECTION_NAME.string).get().get().documents + a++ + } } } @@ -124,8 +130,12 @@ internal class PostDaoTest { val index = 1 val count = testDto.postSize val postListForUser = mutableListOf() - postListForUser.add(postList[1]) - postListForUser.add(postList[0]) + for (post in testDto.postList) { + if (post.created_by == username) { + postListForUser.add(post) + } + } + postListForUser.sortByDescending { it.created_at } Mockito.`when`(db.collection(POST_COLLECTION_NAME.string)) .thenReturn(testDB.collection(POST_COLLECTION_NAME.string)) diff --git a/springboot/src/test/kotlin/com/goliath/emojihub/springboot/domain/reaction/dao/ReactionDaoTest.kt b/springboot/src/test/kotlin/com/goliath/emojihub/springboot/domain/reaction/dao/ReactionDaoTest.kt index 43796abe..72dd39d4 100644 --- a/springboot/src/test/kotlin/com/goliath/emojihub/springboot/domain/reaction/dao/ReactionDaoTest.kt +++ b/springboot/src/test/kotlin/com/goliath/emojihub/springboot/domain/reaction/dao/ReactionDaoTest.kt @@ -62,6 +62,12 @@ internal class ReactionDaoTest { for (reaction in testDto.reactionList) { testDB.collection(REACTION_COLLECTION_NAME.string).document(reaction.id).set(reaction) } + var docs = testDB.collection(REACTION_COLLECTION_NAME.string).get().get().documents + var a = 1 + while (docs.size != testDto.reactionList.size && a <= 5) { + docs = testDB.collection(REACTION_COLLECTION_NAME.string).get().get().documents + a++ + } } } diff --git a/springboot/src/test/kotlin/com/goliath/emojihub/springboot/domain/user/dao/UserDaoTest.kt b/springboot/src/test/kotlin/com/goliath/emojihub/springboot/domain/user/dao/UserDaoTest.kt index b9ad5973..a976f4e0 100644 --- a/springboot/src/test/kotlin/com/goliath/emojihub/springboot/domain/user/dao/UserDaoTest.kt +++ b/springboot/src/test/kotlin/com/goliath/emojihub/springboot/domain/user/dao/UserDaoTest.kt @@ -64,6 +64,12 @@ internal class UserDaoTest { for (user in testDto.userList) { testDB.collection(USER_COLLECTION_NAME.string).document(user.username).set(user) } + var docs = testDB.collection(USER_COLLECTION_NAME.string).get().get().documents + var a = 1 + while (docs.size != testDto.userList.size && a <= 5) { + docs = testDB.collection(USER_COLLECTION_NAME.string).get().get().documents + a++ + } } }