2021-02-19 10:29:35 +01:00
|
|
|
package info.nightscout.androidaps
|
|
|
|
|
|
|
|
import dagger.android.AndroidInjector
|
|
|
|
import dagger.android.HasAndroidInjector
|
2022-11-21 22:43:34 +01:00
|
|
|
import info.nightscout.core.utils.fabric.FabricPrivacy
|
2022-11-09 15:56:59 +01:00
|
|
|
import info.nightscout.interfaces.Config
|
2022-11-11 23:17:09 +01:00
|
|
|
import info.nightscout.interfaces.plugin.ActivePlugin
|
2022-11-22 21:39:19 +01:00
|
|
|
import info.nightscout.interfaces.profile.DefaultValueHelper
|
2022-11-11 18:54:30 +01:00
|
|
|
import info.nightscout.interfaces.profile.ProfileFunction
|
2022-11-10 16:55:18 +01:00
|
|
|
import info.nightscout.interfaces.profile.ProfileStore
|
2022-11-06 12:28:35 +01:00
|
|
|
import info.nightscout.rx.bus.RxBus
|
2022-11-09 15:56:59 +01:00
|
|
|
import info.nightscout.shared.interfaces.ResourceHelper
|
|
|
|
import info.nightscout.shared.utils.DateUtil
|
2021-02-19 10:29:35 +01:00
|
|
|
import org.json.JSONObject
|
2022-11-29 15:03:25 +01:00
|
|
|
import org.junit.jupiter.api.BeforeEach
|
2021-02-19 10:29:35 +01:00
|
|
|
import org.mockito.Mock
|
|
|
|
|
|
|
|
@Suppress("SpellCheckingInspection")
|
|
|
|
open class TestBaseWithProfile : TestBase() {
|
|
|
|
|
2021-04-14 00:45:30 +02:00
|
|
|
@Mock lateinit var activePluginProvider: ActivePlugin
|
2021-11-04 10:56:12 +01:00
|
|
|
@Mock lateinit var rh: ResourceHelper
|
2021-02-19 10:29:35 +01:00
|
|
|
@Mock lateinit var fabricPrivacy: FabricPrivacy
|
|
|
|
@Mock lateinit var profileFunction: ProfileFunction
|
|
|
|
@Mock lateinit var defaultValueHelper: DefaultValueHelper
|
|
|
|
@Mock lateinit var dateUtil: DateUtil
|
2021-04-14 18:42:12 +02:00
|
|
|
@Mock lateinit var config: Config
|
2021-02-19 10:29:35 +01:00
|
|
|
|
2021-10-30 18:29:00 +02:00
|
|
|
val rxBus = RxBus(aapsSchedulers, aapsLogger)
|
2021-02-19 10:29:35 +01:00
|
|
|
|
|
|
|
val profileInjector = HasAndroidInjector {
|
|
|
|
AndroidInjector {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private lateinit var validProfileJSON: String
|
|
|
|
@Suppress("PropertyName") val TESTPROFILENAME = "someProfile"
|
|
|
|
|
2022-11-29 15:03:25 +01:00
|
|
|
@BeforeEach
|
2021-02-19 10:29:35 +01:00
|
|
|
fun prepareMock() {
|
2021-11-10 14:10:27 +01:00
|
|
|
validProfileJSON = "{\"dia\":\"5\",\"carbratio\":[{\"time\":\"00:00\",\"value\":\"30\"}],\"carbs_hr\":\"20\",\"delay\":\"20\",\"sens\":[{\"time\":\"00:00\",\"value\":\"3\"}," +
|
|
|
|
"{\"time\":\"2:00\",\"value\":\"3.4\"}],\"timezone\":\"UTC\",\"basal\":[{\"time\":\"00:00\",\"value\":\"1\"}],\"target_low\":[{\"time\":\"00:00\",\"value\":\"4.5\"}]," +
|
|
|
|
"\"target_high\":[{\"time\":\"00:00\",\"value\":\"7\"}],\"startDate\":\"1970-01-01T00:00:00.000Z\",\"units\":\"mmol\"}"
|
2021-02-19 10:29:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
fun getValidProfileStore(): ProfileStore {
|
2021-11-10 14:10:27 +01:00
|
|
|
validProfileJSON = "{\"dia\":\"5\",\"carbratio\":[{\"time\":\"00:00\",\"value\":\"30\"}],\"carbs_hr\":\"20\",\"delay\":\"20\",\"sens\":[{\"time\":\"00:00\",\"value\":\"3\"}," +
|
|
|
|
"{\"time\":\"2:00\",\"value\":\"3.4\"}],\"timezone\":\"UTC\",\"basal\":[{\"time\":\"00:00\",\"value\":\"1\"}],\"target_low\":[{\"time\":\"00:00\",\"value\":\"4.5\"}]," +
|
|
|
|
"\"target_high\":[{\"time\":\"00:00\",\"value\":\"7\"}],\"startDate\":\"1970-01-01T00:00:00.000Z\",\"units\":\"mmol\"}"
|
|
|
|
|
2021-02-19 10:29:35 +01:00
|
|
|
val json = JSONObject()
|
|
|
|
val store = JSONObject()
|
|
|
|
store.put(TESTPROFILENAME, JSONObject(validProfileJSON))
|
|
|
|
json.put("defaultProfile", TESTPROFILENAME)
|
|
|
|
json.put("store", store)
|
2022-11-10 16:55:18 +01:00
|
|
|
return ProfileStoreObject(profileInjector, json, dateUtil)
|
2021-02-19 10:29:35 +01:00
|
|
|
}
|
2021-11-10 14:10:27 +01:00
|
|
|
}
|