DetailedBolusInfoStorage: Fix unit tests
This commit is contained in:
parent
65e9c2b9e8
commit
863ad1d1ac
2 changed files with 8 additions and 2 deletions
|
@ -83,7 +83,7 @@ class DetailedBolusInfoStorageImpl @Inject constructor(
|
||||||
|
|
||||||
private fun loadStore(): ArrayList<DetailedBolusInfo> {
|
private fun loadStore(): ArrayList<DetailedBolusInfo> {
|
||||||
val jsonString = sp.getString(rh.gs(R.string.bolus_storage), "")
|
val jsonString = sp.getString(rh.gs(R.string.bolus_storage), "")
|
||||||
return if (jsonString.isNotEmpty()) {
|
return if (jsonString != null && jsonString.isNotEmpty()) {
|
||||||
val type = object : TypeToken<List<DetailedBolusInfo>>() {}.type
|
val type = object : TypeToken<List<DetailedBolusInfo>>() {}.type
|
||||||
Gson().fromJson(jsonString, type)
|
Gson().fromJson(jsonString, type)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -2,13 +2,19 @@ package info.nightscout.implementation.pump
|
||||||
|
|
||||||
import info.nightscout.androidaps.TestBase
|
import info.nightscout.androidaps.TestBase
|
||||||
import info.nightscout.interfaces.pump.DetailedBolusInfo
|
import info.nightscout.interfaces.pump.DetailedBolusInfo
|
||||||
|
import info.nightscout.shared.interfaces.ResourceHelper
|
||||||
|
import info.nightscout.shared.sharedPreferences.SP
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Assert.assertNull
|
import org.junit.Assert.assertNull
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
import org.mockito.Mock
|
||||||
|
|
||||||
class DetailedBolusInfoStorageTest : TestBase() {
|
class DetailedBolusInfoStorageTest : TestBase() {
|
||||||
|
|
||||||
|
@Mock lateinit var sp: SP
|
||||||
|
@Mock lateinit var rh: ResourceHelper
|
||||||
|
|
||||||
private val info1 = DetailedBolusInfo()
|
private val info1 = DetailedBolusInfo()
|
||||||
private val info2 = DetailedBolusInfo()
|
private val info2 = DetailedBolusInfo()
|
||||||
private val info3 = DetailedBolusInfo()
|
private val info3 = DetailedBolusInfo()
|
||||||
|
@ -26,7 +32,7 @@ class DetailedBolusInfoStorageTest : TestBase() {
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
fun prepare() {
|
fun prepare() {
|
||||||
detailedBolusInfoStorage = DetailedBolusInfoStorageImpl(aapsLogger)
|
detailedBolusInfoStorage = DetailedBolusInfoStorageImpl(aapsLogger, sp, rh)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setUp() {
|
private fun setUp() {
|
||||||
|
|
Loading…
Reference in a new issue