Skip to content

Instantly share code, notes, and snippets.

@m0er
Created August 30, 2019 09:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m0er/17e18e4a17ff28acc99b455a399441ac to your computer and use it in GitHub Desktop.
Save m0er/17e18e4a17ff28acc99b455a399441ac to your computer and use it in GitHub Desktop.
package com.styleshare.android.feature.feed.hot
import com.google.gson.GsonBuilder
import com.styleshare.android.network.BaseContentDeserializer
import com.styleshare.android.network.deserializer.ComponentDeserializer
import com.styleshare.android.network.model.component.Component
import com.styleshare.android.network.model.feed.hot.featured.FeaturedContentList
import com.styleshare.android.network.model.feed.hot.featured.FeaturedLiveContent
import com.styleshare.android.rest.model.feed.content.BaseContent
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertTrue
import org.junit.Test
class FeaturedContentDeserializeTest {
private val gson = GsonBuilder()
.registerTypeAdapter(BaseContent::class.java, BaseContentDeserializer())
.registerTypeAdapter(Component::class.java, ComponentDeserializer())
.create()
@Test
fun testDeserializeFeaturedContent() {
val featuredContentList =
gson.fromJson<FeaturedContentList>(rawJson, FeaturedContentList::class.java)
val featuredContents = featuredContentList.data
assertNotNull(featuredContents)
val liveItem = requireNotNull(featuredContents)
.first { it.id == "1701" }
val liveContent = liveItem.content as FeaturedLiveContent
assertNotNull(liveContent)
assertTrue(requireNotNull(liveContent.liveContent).id == "b8a79172-3590-4fbe-b6d2-7458f66547ae")
}
companion object {
val rawJson = """
{
"data": [
{
"__type__": "FeaturedContent",
"content": {
"__type__": "Collection",
"cover": {
"__type__": "Picture",
"id": 41085976,
"originalHeight": 395,
"originalWidth": 640
},
"coverId": 41085976,
"createdAt": "2019-08-21T01:22:11.824428+00:00",
"creator": {
"__type__": "User",
"bio": "",
"collectionsCount": 131,
"country": "KR",
"facebookPublish": true,
"followersCount": 31543,
"followingsCount": 0,
"gender": "female",
"id": 104767505,
"isOfficial": true,
"likesCount": 5213,
"linkEnabled": true,
"nickname": "써보쉐어_뷰티",
"profileCover": {
"__type__": "Picture",
"id": 41057905,
"originalHeight": 720,
"originalWidth": 720
},
"profilePicture": {
"__type__": "Picture",
"id": 23384518,
"originalHeight": 317,
"originalWidth": 230
},
"uploadedStylesCount": 168,
"username": "usebeauty",
"website": ""
},
"creatorBio": "",
"creatorId": 104767505,
"creatorIsOfficial": true,
"creatorNickname": "써보쉐어_뷰티",
"creatorProfilePictureId": 23384518,
"description": "환절기가 될수록 더욱 깊어지는 여름철 피부 고민😧\r\n이럴 때일수록 꼼꼼한 클렌징이 필수이죠📍\r\n피부 고민을 해결하고 싶은 스쉐러들은\r\n해피바스 마이크로 미셀라 클렌징 폼을 주목해주세요!\r\n모공의 1/100 입자로 쫀쫀한 마이크로 거품이\r\n초미세먼지까지 싸악 딥 클렌징해준다고요🌊\r\n스쉐러들의 리얼 후기가 궁금하다면 같이 보러 갈까요?🏃♀️\r\n\r\n커버이미지 | 전민정(@m_in_j5131)님의 스타일",
"followersCount": 10,
"id": 6860793,
"relatedPictureIds": [
40897305,
40891952,
41076612
],
"relatedPictures": [
{
"__type__": "Picture",
"id": 40897305,
"originalHeight": 1242,
"originalWidth": 1242
},
{
"__type__": "Picture",
"id": 40891952,
"originalHeight": 3024,
"originalWidth": 3024
},
{
"__type__": "Picture",
"id": 41076612,
"originalHeight": 1242,
"originalWidth": 1242
}
],
"sponsored": false,
"stylesCount": 76,
"title": "초미세먼지까지 씻겨주는\r\n가성비 갑 클렌징 폼 추천🛁",
"viewsCount": 1038
},
"id": 1692,
"title": "초미세먼지까지 씻겨주는\r\n가성비 갑 클렌징 폼 추천🛁"
},
{
"__type__": "FeaturedContent",
"content": {
"__type__": "Livetv",
"author": {
"id": 17098813,
"nickname": "제타 zetta",
"profilePictureId": "40374535",
"username": "ubstop516"
},
"endedAt": "2019-08-29T12:16:51+00:00",
"entranceMessage": "가을 메이크업 꿀팁이 궁금하다면 물어보쉐어~",
"goods": [],
"id": "b8a79172-3590-4fbe-b6d2-7458f66547ae",
"originalHeight": 1280,
"originalWidth": 720,
"picture": {
"id": "e6c7043f-8173-4714-8e98-31ef73a78c3a",
"originalHeight": 300,
"originalWidth": 300
},
"replay": {
"highlights": [
{
"end": 120,
"start": 60
}
],
"url": "https://styleshare-live.s3.ap-northeast-2.amazonaws.com/lives/b8a79172-3590-4fbe-b6d2-7458f66547ae/vod.m3u8",
"viewCount": 42
},
"shareUrl": "https://www.styleshare.kr/livetv/b8a79172-3590-4fbe-b6d2-7458f66547ae",
"status": "off",
"title": "메이플 시럽 메이크업🍁",
"url": "https://livetv.styleshare.kr/api/v1/livetvs/b8a79172-3590-4fbe-b6d2-7458f66547ae/master.m3u8?time=1567132444",
"watcherCount": 1017
},
"id": 1701,
"title": "메이플 시럽 메이크업🍁"
}
]
}
""".trimIndent()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment