2021-02-19 00:47:22 +01:00
|
|
|
package info.nightscout.androidaps
|
|
|
|
|
|
|
|
import dagger.android.AndroidInjector
|
|
|
|
import dagger.android.HasAndroidInjector
|
2021-04-29 20:42:45 +02:00
|
|
|
import info.nightscout.androidaps.data.ProfileSealed
|
|
|
|
import info.nightscout.androidaps.extensions.pureProfileFromJson
|
2021-09-23 17:35:55 +02:00
|
|
|
import info.nightscout.androidaps.interfaces.ActivePlugin
|
|
|
|
import info.nightscout.androidaps.interfaces.Config
|
|
|
|
import info.nightscout.androidaps.interfaces.Profile
|
|
|
|
import info.nightscout.androidaps.interfaces.ProfileFunction
|
|
|
|
import info.nightscout.androidaps.interfaces.ProfileStore
|
2021-10-15 14:56:22 +02:00
|
|
|
import info.nightscout.androidaps.plugins.bus.RxBus
|
2021-02-19 00:47:22 +01:00
|
|
|
import info.nightscout.androidaps.utils.DateUtil
|
|
|
|
import info.nightscout.androidaps.utils.DefaultValueHelper
|
|
|
|
import info.nightscout.androidaps.utils.FabricPrivacy
|
|
|
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
|
|
|
import org.json.JSONObject
|
|
|
|
import org.junit.Before
|
|
|
|
import org.mockito.Mock
|
|
|
|
|
|
|
|
@Suppress("SpellCheckingInspection")
|
|
|
|
open class TestBaseWithProfile : TestBase() {
|
|
|
|
|
2021-04-14 00:45:30 +02:00
|
|
|
@Mock lateinit var activePluginProvider: ActivePlugin
|
2021-02-19 00:47:22 +01:00
|
|
|
@Mock lateinit var resourceHelper: ResourceHelper
|
|
|
|
@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 00:47:22 +01:00
|
|
|
|
2021-10-15 14:56:22 +02:00
|
|
|
val rxBus = RxBus(aapsSchedulers)
|
2021-02-19 00:47:22 +01:00
|
|
|
|
|
|
|
val profileInjector = HasAndroidInjector {
|
|
|
|
AndroidInjector {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private lateinit var validProfileJSON: String
|
|
|
|
lateinit var validProfile: Profile
|
|
|
|
@Suppress("PropertyName") val TESTPROFILENAME = "someProfile"
|
|
|
|
|
|
|
|
@Before
|
|
|
|
fun prepareMock() {
|
|
|
|
validProfileJSON = "{\"dia\":\"3\",\"carbratio\":[{\"time\":\"00:00\",\"value\":\"30\"}],\"carbs_hr\":\"20\",\"delay\":\"20\",\"sens\":[{\"time\":\"00:00\",\"value\":\"100\"},{\"time\":\"2:00\",\"value\":\"110\"}],\"timezone\":\"UTC\",\"basal\":[{\"time\":\"00:00\",\"value\":\"1\"}],\"target_low\":[{\"time\":\"00:00\",\"value\":\"4\"}],\"target_high\":[{\"time\":\"00:00\",\"value\":\"5\"}],\"startDate\":\"1970-01-01T00:00:00.000Z\",\"units\":\"mmol\"}"
|
2021-04-29 20:42:45 +02:00
|
|
|
validProfile = ProfileSealed.Pure(pureProfileFromJson(JSONObject(validProfileJSON), dateUtil)!!)
|
2021-02-19 00:47:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
fun getValidProfileStore(): ProfileStore {
|
|
|
|
val json = JSONObject()
|
|
|
|
val store = JSONObject()
|
|
|
|
store.put(TESTPROFILENAME, JSONObject(validProfileJSON))
|
|
|
|
json.put("defaultProfile", TESTPROFILENAME)
|
|
|
|
json.put("store", store)
|
2021-04-29 20:42:45 +02:00
|
|
|
return ProfileStore(profileInjector, json, dateUtil)
|
2021-02-19 00:47:22 +01:00
|
|
|
}
|
|
|
|
}
|