1- package info.nightscout.androidaps
1+ package info.nightscout.sharedtests
22
33import android.content.Context
44import dagger.android.AndroidInjector
@@ -26,13 +26,12 @@ import org.mockito.ArgumentMatchers.anyInt
2626import org.mockito.ArgumentMatchers.anyString
2727import org.mockito.Mock
2828import org.mockito.Mockito
29- import org.mockito.Mockito.`when`
3029import org.mockito.invocation.InvocationOnMock
3130
3231@Suppress(" SpellCheckingInspection" )
3332open class TestBaseWithProfile : TestBase () {
3433
35- @Mock lateinit var activePluginProvider : ActivePlugin
34+ @Mock lateinit var activePlugin : ActivePlugin
3635 @Mock lateinit var rh: ResourceHelper
3736 @Mock lateinit var iobCobCalculator: IobCobCalculator
3837 @Mock lateinit var fabricPrivacy: FabricPrivacy
@@ -41,15 +40,15 @@ open class TestBaseWithProfile : TestBase() {
4140 @Mock lateinit var context: Context
4241 @Mock lateinit var sp: SP
4342
44- private lateinit var hardLimits: HardLimits
4543 lateinit var dateUtil: DateUtil
44+ lateinit var hardLimits: HardLimits
4645 val rxBus = RxBus (aapsSchedulers, aapsLogger)
4746
4847 val profileInjector = HasAndroidInjector {
4948 AndroidInjector {
5049 if (it is ProfileStoreObject ) {
5150 it.aapsLogger = aapsLogger
52- it.activePlugin = activePluginProvider
51+ it.activePlugin = activePlugin
5352 it.config = config
5453 it.rh = rh
5554 it.rxBus = rxBus
@@ -64,20 +63,22 @@ open class TestBaseWithProfile : TestBase() {
6463 lateinit var effectiveProfileSwitch: EffectiveProfileSwitch
6564 lateinit var testPumpPlugin: TestPumpPlugin
6665
66+ val now = 1656358822000L
67+
6768 @Suppress(" PropertyName" ) val TESTPROFILENAME = " someProfile"
6869
6970 @BeforeEach
7071 fun prepareMock () {
71- invalidProfileJSON = " {\" dia\" :\" 1 \" ,\" carbratio\" :[{\" time\" :\" 00:00\" ,\" value\" :\" 30\" }],\" carbs_hr\" :\" 20\" ,\" delay\" :\" 20\" ,\" sens\" :[{\" time\" :\" 00:00\" ,\" value\" :\" 3\" }," +
72+ validProfileJSON = " {\" dia\" :\" 5 \" ,\" carbratio\" :[{\" time\" :\" 00:00\" ,\" value\" :\" 30\" }],\" carbs_hr\" :\" 20\" ,\" delay\" :\" 20\" ,\" sens\" :[{\" time\" :\" 00:00\" ,\" value\" :\" 3\" }," +
7273 " {\" time\" :\" 2:00\" ,\" value\" :\" 3.4\" }],\" timezone\" :\" UTC\" ,\" basal\" :[{\" time\" :\" 00:00\" ,\" value\" :\" 1\" }],\" target_low\" :[{\" time\" :\" 00:00\" ,\" value\" :\" 4.5\" }]," +
7374 " \" target_high\" :[{\" time\" :\" 00:00\" ,\" value\" :\" 7\" }],\" startDate\" :\" 1970-01-01T00:00:00.000Z\" ,\" units\" :\" mmol\" }"
74- validProfileJSON = " {\" dia\" :\" 5 \" ,\" carbratio\" :[{\" time\" :\" 00:00\" ,\" value\" :\" 30\" }],\" carbs_hr\" :\" 20\" ,\" delay\" :\" 20\" ,\" sens\" :[{\" time\" :\" 00:00\" ,\" value\" :\" 3\" }," +
75+ invalidProfileJSON = " {\" dia\" :\" 1 \" ,\" carbratio\" :[{\" time\" :\" 00:00\" ,\" value\" :\" 30\" }],\" carbs_hr\" :\" 20\" ,\" delay\" :\" 20\" ,\" sens\" :[{\" time\" :\" 00:00\" ,\" value\" :\" 3\" }," +
7576 " {\" time\" :\" 2:00\" ,\" value\" :\" 3.4\" }],\" timezone\" :\" UTC\" ,\" basal\" :[{\" time\" :\" 00:00\" ,\" value\" :\" 1\" }],\" target_low\" :[{\" time\" :\" 00:00\" ,\" value\" :\" 4.5\" }]," +
7677 " \" target_high\" :[{\" time\" :\" 00:00\" ,\" value\" :\" 7\" }],\" startDate\" :\" 1970-01-01T00:00:00.000Z\" ,\" units\" :\" mmol\" }"
77- testPumpPlugin = TestPumpPlugin (profileInjector)
78- `when `(activePluginProvider.activePump).thenReturn(testPumpPlugin)
7978 dateUtil = Mockito .spy(DateUtil (context))
80- `when `(dateUtil.now()).thenReturn(1656358822000 )
79+ testPumpPlugin = TestPumpPlugin (profileInjector)
80+ Mockito .`when `(dateUtil.now()).thenReturn(now)
81+ Mockito .`when `(activePlugin.activePump).thenReturn(testPumpPlugin)
8182 hardLimits = HardLimitsMock (sp, rh)
8283 validProfile = ProfileSealed .Pure (pureProfileFromJson(JSONObject (validProfileJSON), dateUtil)!! )
8384 effectiveProfileSwitch = EffectiveProfileSwitch (
0 commit comments