-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: app 강제 업데이트 판별 기능 추가 (MZ-309) (#84)
* feat: 버전 체크 기능 추가 및 applicationMetadata 엔티티 변경 * feat: 버전 체크 기능 테스트 추가
- Loading branch information
Showing
9 changed files
with
220 additions
and
43 deletions.
There are no files selected for viewing
76 changes: 72 additions & 4 deletions
76
api/src/main/kotlin/com/oksusu/susu/api/metadata/application/ApplicationMetadataService.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
27 changes: 27 additions & 0 deletions
27
api/src/main/kotlin/com/oksusu/susu/api/metadata/model/ApplicationMetadataModel.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,27 @@ | ||
package com.oksusu.susu.api.metadata.model | ||
|
||
import com.oksusu.susu.domain.metadata.domain.ApplicationMetadata | ||
|
||
class ApplicationMetadataModel( | ||
val id: Long, | ||
|
||
/** ios 최소 지원 어플리케이션 버전 */ | ||
val iosMinSupportVersion: String, | ||
|
||
/** aos 최소 지원 어플리케이션 버전 */ | ||
val aosMinSupportVersion: String, | ||
|
||
/** 활성화 여부 / 활성화 : 1, 비활성화 : 0 */ | ||
val isActive: Boolean, | ||
) { | ||
companion object { | ||
fun from(metadata: ApplicationMetadata): ApplicationMetadataModel { | ||
return ApplicationMetadataModel( | ||
id = metadata.id, | ||
iosMinSupportVersion = metadata.iosMinSupportVersion, | ||
aosMinSupportVersion = metadata.aosMinSupportVersion, | ||
isActive = metadata.isActive | ||
) | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
api/src/main/kotlin/com/oksusu/susu/api/metadata/model/DeviceOS.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.oksusu.susu.api.metadata.model | ||
|
||
enum class DeviceOS { | ||
AOS, | ||
IOS, | ||
; | ||
} |
23 changes: 0 additions & 23 deletions
23
.../kotlin/com/oksusu/susu/api/metadata/model/response/ApplicationVersionMetadataResponse.kt
This file was deleted.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
...ain/kotlin/com/oksusu/susu/api/metadata/model/response/CheckApplicationVersionResposne.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,5 @@ | ||
package com.oksusu.susu.api.metadata.model.response | ||
|
||
class CheckApplicationVersionResposne( | ||
val needForceUpdate: Boolean, | ||
) |
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
94 changes: 94 additions & 0 deletions
94
...rc/test/kotlin/com/oksusu/susu/api/metadata/application/ApplicationMetadataServiceTest.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,94 @@ | ||
package com.oksusu.susu.api.metadata.application | ||
|
||
import com.oksusu.susu.api.metadata.model.DeviceOS | ||
import com.oksusu.susu.client.common.coroutine.ErrorPublishingCoroutineExceptionHandler | ||
import com.oksusu.susu.domain.metadata.domain.ApplicationMetadata | ||
import com.oksusu.susu.domain.metadata.infrastructure.ApplicationMetadataRepository | ||
import io.github.oshai.kotlinlogging.KotlinLogging | ||
import io.kotest.core.spec.style.DescribeSpec | ||
import io.kotest.matchers.equals.shouldBeEqual | ||
import io.mockk.every | ||
import io.mockk.mockk | ||
import kotlinx.coroutines.CoroutineExceptionHandler | ||
import kotlinx.coroutines.delay | ||
|
||
class ApplicationMetadataServiceTest : DescribeSpec({ | ||
val logger = KotlinLogging.logger { } | ||
|
||
val mockApplicationMetadataRepository = mockk<ApplicationMetadataRepository>() | ||
val mockCoroutineExceptionHandler = mockk<ErrorPublishingCoroutineExceptionHandler>() | ||
|
||
every { mockApplicationMetadataRepository.findTop1ByIsActiveOrderByCreatedAtDesc(any()) } returns ApplicationMetadata( | ||
id = 1L, | ||
iosMinSupportVersion = "1.1.1", | ||
aosMinSupportVersion = "1.1.1", | ||
isActive = true | ||
) | ||
every { mockCoroutineExceptionHandler.handler } returns CoroutineExceptionHandler { _, _ -> } | ||
|
||
val service = ApplicationMetadataService(mockApplicationMetadataRepository, mockCoroutineExceptionHandler) | ||
|
||
beforeSpec { | ||
service.refreshApplicationMetadata() | ||
|
||
delay(100) | ||
} | ||
|
||
describe("checkApplicationVersion") { | ||
context("ios 버전을 체크했을 때,") { | ||
it("버전이 최소 지원 버전 미만이면 강제 업데이트를 해야한다.") { | ||
service.checkApplicationVersion(DeviceOS.IOS, "0.0.0").needForceUpdate shouldBeEqual true | ||
|
||
service.checkApplicationVersion(DeviceOS.IOS, "1.0.0").needForceUpdate shouldBeEqual true | ||
service.checkApplicationVersion(DeviceOS.IOS, "0.1.0").needForceUpdate shouldBeEqual true | ||
service.checkApplicationVersion(DeviceOS.IOS, "0.0.1").needForceUpdate shouldBeEqual true | ||
|
||
service.checkApplicationVersion(DeviceOS.IOS, "1.1.0").needForceUpdate shouldBeEqual true | ||
service.checkApplicationVersion(DeviceOS.IOS, "1.0.1").needForceUpdate shouldBeEqual true | ||
service.checkApplicationVersion(DeviceOS.IOS, "0.1.1").needForceUpdate shouldBeEqual true | ||
|
||
service.checkApplicationVersion(DeviceOS.IOS, "1.0.2").needForceUpdate shouldBeEqual true | ||
service.checkApplicationVersion(DeviceOS.IOS, "0.2.0").needForceUpdate shouldBeEqual true | ||
service.checkApplicationVersion(DeviceOS.IOS, "0.2.2").needForceUpdate shouldBeEqual true | ||
|
||
service.checkApplicationVersion(DeviceOS.AOS, "0.0.0").needForceUpdate shouldBeEqual true | ||
|
||
service.checkApplicationVersion(DeviceOS.AOS, "1.0.0").needForceUpdate shouldBeEqual true | ||
service.checkApplicationVersion(DeviceOS.AOS, "0.1.0").needForceUpdate shouldBeEqual true | ||
service.checkApplicationVersion(DeviceOS.AOS, "0.0.1").needForceUpdate shouldBeEqual true | ||
|
||
service.checkApplicationVersion(DeviceOS.AOS, "1.1.0").needForceUpdate shouldBeEqual true | ||
service.checkApplicationVersion(DeviceOS.AOS, "1.0.1").needForceUpdate shouldBeEqual true | ||
service.checkApplicationVersion(DeviceOS.AOS, "0.1.1").needForceUpdate shouldBeEqual true | ||
|
||
service.checkApplicationVersion(DeviceOS.AOS, "1.0.2").needForceUpdate shouldBeEqual true | ||
service.checkApplicationVersion(DeviceOS.AOS, "0.2.0").needForceUpdate shouldBeEqual true | ||
service.checkApplicationVersion(DeviceOS.AOS, "0.2.2").needForceUpdate shouldBeEqual true | ||
} | ||
|
||
it("버전이 최소 지원 버전 이상이면 강제 업데이트를 하지않아도 된다.") { | ||
service.checkApplicationVersion(DeviceOS.IOS, "1.1.1").needForceUpdate shouldBeEqual false | ||
service.checkApplicationVersion(DeviceOS.IOS, "1.1.2").needForceUpdate shouldBeEqual false | ||
service.checkApplicationVersion(DeviceOS.IOS, "1.2.0").needForceUpdate shouldBeEqual false | ||
service.checkApplicationVersion(DeviceOS.IOS, "1.2.1").needForceUpdate shouldBeEqual false | ||
service.checkApplicationVersion(DeviceOS.IOS, "2.0.0").needForceUpdate shouldBeEqual false | ||
service.checkApplicationVersion(DeviceOS.IOS, "2.0.1").needForceUpdate shouldBeEqual false | ||
service.checkApplicationVersion(DeviceOS.IOS, "2.1.0").needForceUpdate shouldBeEqual false | ||
service.checkApplicationVersion(DeviceOS.IOS, "2.1.1").needForceUpdate shouldBeEqual false | ||
service.checkApplicationVersion(DeviceOS.IOS, "2.1.2").needForceUpdate shouldBeEqual false | ||
service.checkApplicationVersion(DeviceOS.IOS, "2.2.2").needForceUpdate shouldBeEqual false | ||
|
||
service.checkApplicationVersion(DeviceOS.AOS, "1.1.1").needForceUpdate shouldBeEqual false | ||
service.checkApplicationVersion(DeviceOS.AOS, "1.1.2").needForceUpdate shouldBeEqual false | ||
service.checkApplicationVersion(DeviceOS.AOS, "1.2.0").needForceUpdate shouldBeEqual false | ||
service.checkApplicationVersion(DeviceOS.AOS, "1.2.1").needForceUpdate shouldBeEqual false | ||
service.checkApplicationVersion(DeviceOS.AOS, "2.0.0").needForceUpdate shouldBeEqual false | ||
service.checkApplicationVersion(DeviceOS.AOS, "2.0.1").needForceUpdate shouldBeEqual false | ||
service.checkApplicationVersion(DeviceOS.AOS, "2.1.0").needForceUpdate shouldBeEqual false | ||
service.checkApplicationVersion(DeviceOS.AOS, "2.1.1").needForceUpdate shouldBeEqual false | ||
service.checkApplicationVersion(DeviceOS.AOS, "2.1.2").needForceUpdate shouldBeEqual false | ||
service.checkApplicationVersion(DeviceOS.AOS, "2.2.2").needForceUpdate shouldBeEqual false | ||
} | ||
} | ||
} | ||
}) |
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