:shared:tests module cleanup

This commit is contained in:
Milos Kozak 2023-09-21 16:53:21 +02:00
parent 1f8796fd34
commit 8b02daa7e7
111 changed files with 1851 additions and 115 deletions

View file

@ -2,6 +2,7 @@ package info.nightscout.plugins.aps.loop
import android.app.NotificationManager import android.app.NotificationManager
import android.content.Context import android.content.Context
import app.aaps.shared.tests.TestBase
import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
@ -24,7 +25,6 @@ import info.nightscout.sdk.interfaces.RunningConfiguration
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import info.nightscout.sharedtests.TestBase
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 import org.mockito.Mock

View file

@ -1,5 +1,6 @@
package info.nightscout.plugins.configBuilder package info.nightscout.plugins.configBuilder
import app.aaps.shared.tests.TestBase
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.configuration.configBuilder.ConfigBuilderPlugin import info.nightscout.configuration.configBuilder.ConfigBuilderPlugin
@ -10,7 +11,6 @@ import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.ui.UiInteraction import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.sharedtests.TestBase
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 import org.mockito.Mock

View file

@ -1,5 +1,6 @@
package info.nightscout.plugins.constraints package info.nightscout.plugins.constraints
import app.aaps.shared.tests.TestBaseWithProfile
import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
@ -42,7 +43,6 @@ import info.nightscout.pump.dana.R
import info.nightscout.pump.dana.database.DanaHistoryDatabase import info.nightscout.pump.dana.database.DanaHistoryDatabase
import info.nightscout.pump.danars.DanaRSPlugin import info.nightscout.pump.danars.DanaRSPlugin
import info.nightscout.pump.virtual.VirtualPumpPlugin import info.nightscout.pump.virtual.VirtualPumpPlugin
import info.nightscout.sharedtests.TestBaseWithProfile
import info.nightscout.source.GlimpPlugin import info.nightscout.source.GlimpPlugin
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,6 +1,7 @@
package info.nightscout.plugins.general.maintenance package info.nightscout.plugins.general.maintenance
import android.content.Context import android.content.Context
import app.aaps.shared.tests.TestBase
import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.configuration.maintenance.MaintenancePlugin import info.nightscout.configuration.maintenance.MaintenancePlugin
@ -10,7 +11,6 @@ import info.nightscout.interfaces.maintenance.PrefFileListProvider
import info.nightscout.interfaces.nsclient.NSSettingsStatus import info.nightscout.interfaces.nsclient.NSSettingsStatus
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.sharedtests.TestBase
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 import org.mockito.Mock

View file

@ -1,5 +1,6 @@
package info.nightscout.plugins.safety package info.nightscout.plugins.safety
import app.aaps.shared.tests.TestBaseWithProfile
import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
@ -20,7 +21,6 @@ import info.nightscout.plugins.aps.openAPSAMA.OpenAPSAMAPlugin
import info.nightscout.plugins.aps.openAPSSMB.OpenAPSSMBPlugin import info.nightscout.plugins.aps.openAPSSMB.OpenAPSSMBPlugin
import info.nightscout.plugins.constraints.safety.SafetyPlugin import info.nightscout.plugins.constraints.safety.SafetyPlugin
import info.nightscout.pump.virtual.VirtualPumpPlugin import info.nightscout.pump.virtual.VirtualPumpPlugin
import info.nightscout.sharedtests.TestBaseWithProfile
import info.nightscout.source.GlimpPlugin import info.nightscout.source.GlimpPlugin
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,5 +1,6 @@
package info.nightscout.plugins.sensitivity package info.nightscout.plugins.sensitivity
import app.aaps.shared.tests.TestBase
import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
@ -11,7 +12,6 @@ import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.sensitivity.AbstractSensitivityPlugin import info.nightscout.sensitivity.AbstractSensitivityPlugin
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.sharedtests.TestBase
import org.json.JSONObject import org.json.JSONObject
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.mockito.Mock import org.mockito.Mock

View file

@ -1,5 +1,6 @@
package info.nightscout.pump package info.nightscout.pump
import app.aaps.shared.tests.TestBaseWithProfile
import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
@ -7,7 +8,6 @@ import info.nightscout.core.pump.toHtml
import info.nightscout.interfaces.pump.PumpEnactResult import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.plugins.aps.loop.extensions.json import info.nightscout.plugins.aps.loop.extensions.json
import info.nightscout.pump.virtual.extensions.toText import info.nightscout.pump.virtual.extensions.toText
import info.nightscout.sharedtests.TestBaseWithProfile
import org.json.JSONObject import org.json.JSONObject
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,9 +1,8 @@
package info.nightscout.core.data package info.nightscout.core.data
import app.aaps.shared.tests.TestBase
import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat
import info.nightscout.core.constraints.ConstraintObject import info.nightscout.core.constraints.ConstraintObject
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
/** /**

View file

@ -1,13 +1,13 @@
package info.nightscout.core.data package info.nightscout.core.data
import com.google.common.truth.Truth.assertThat
import android.content.Context import android.content.Context
import app.aaps.shared.tests.TestBase
import com.google.common.truth.Truth.assertThat
import com.google.gson.Gson import com.google.gson.Gson
import info.nightscout.database.entities.Bolus import info.nightscout.database.entities.Bolus
import info.nightscout.database.entities.BolusCalculatorResult import info.nightscout.database.entities.BolusCalculatorResult
import info.nightscout.database.entities.TherapyEvent import info.nightscout.database.entities.TherapyEvent
import info.nightscout.interfaces.pump.DetailedBolusInfo import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.sharedtests.TestBase
import org.apache.commons.lang3.builder.EqualsBuilder import org.apache.commons.lang3.builder.EqualsBuilder
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.mockito.Mock import org.mockito.Mock

View file

@ -2,6 +2,7 @@ package info.nightscout.core.data
import android.content.Context import android.content.Context
import app.aaps.shared.impl.utils.DateUtilImpl import app.aaps.shared.impl.utils.DateUtilImpl
import app.aaps.shared.tests.TestBase
import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat
import info.nightscout.core.iob.combine import info.nightscout.core.iob.combine
import info.nightscout.core.iob.copy import info.nightscout.core.iob.copy
@ -11,7 +12,6 @@ import info.nightscout.core.iob.plus
import info.nightscout.core.iob.round import info.nightscout.core.iob.round
import info.nightscout.interfaces.iob.IobTotal import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import info.nightscout.sharedtests.TestBase
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 import org.mockito.Mock

View file

@ -2,6 +2,9 @@ package info.nightscout.core.data
import android.content.Context import android.content.Context
import app.aaps.shared.impl.utils.DateUtilImpl import app.aaps.shared.impl.utils.DateUtilImpl
import app.aaps.shared.tests.HardLimitsMock
import app.aaps.shared.tests.TestBase
import app.aaps.shared.tests.TestPumpPlugin
import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import info.nightscout.core.extensions.pureProfileFromJson import info.nightscout.core.extensions.pureProfileFromJson
@ -12,9 +15,6 @@ import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import info.nightscout.sharedtests.HardLimitsMock
import info.nightscout.sharedtests.TestBase
import info.nightscout.sharedtests.TestPumpPlugin
import org.json.JSONObject import org.json.JSONObject
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,8 +1,8 @@
package info.nightscout.core.utils package info.nightscout.core.utils
import app.aaps.shared.tests.TestBase
import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat
import com.google.common.truth.TruthJUnit.assume import com.google.common.truth.TruthJUnit.assume
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
// https://stackoverflow.com/questions/52344522/joseexception-couldnt-create-aes-gcm-nopadding-cipher-illegal-key-size // https://stackoverflow.com/questions/52344522/joseexception-couldnt-create-aes-gcm-nopadding-cipher-illegal-key-size

View file

@ -2,10 +2,10 @@ package info.nightscout.core.utils
import android.content.Context import android.content.Context
import app.aaps.shared.impl.utils.DateUtilImpl import app.aaps.shared.impl.utils.DateUtilImpl
import app.aaps.shared.tests.TestBase
import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.T import info.nightscout.shared.utils.T
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.AfterAll import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.BeforeAll import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,12 +1,12 @@
package info.nightscout.core.wizard package info.nightscout.core.wizard
import app.aaps.shared.tests.TestBase
import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.interfaces.aps.Loop import info.nightscout.interfaces.aps.Loop
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.sharedtests.TestBase
import org.json.JSONArray import org.json.JSONArray
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,5 +1,6 @@
package info.nightscout.implementation.iob package info.nightscout.implementation.iob
import app.aaps.shared.tests.TestBaseWithProfile
import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat
import info.nightscout.core.iob.asRounded import info.nightscout.core.iob.asRounded
import info.nightscout.core.iob.log import info.nightscout.core.iob.log
@ -9,7 +10,6 @@ import info.nightscout.interfaces.iob.GlucoseStatus
import info.nightscout.interfaces.iob.InMemoryGlucoseValue import info.nightscout.interfaces.iob.InMemoryGlucoseValue
import info.nightscout.interfaces.iob.IobCobCalculator import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.shared.utils.T import info.nightscout.shared.utils.T
import info.nightscout.sharedtests.TestBaseWithProfile
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 import org.mockito.Mock

View file

@ -1,5 +1,6 @@
package info.nightscout.implementation.overview package info.nightscout.implementation.overview
import app.aaps.shared.tests.TestBaseWithProfile
import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat
import info.nightscout.database.ValueWrapper import info.nightscout.database.ValueWrapper
import info.nightscout.database.entities.GlucoseValue import info.nightscout.database.entities.GlucoseValue
@ -9,7 +10,6 @@ import info.nightscout.interfaces.aps.AutosensDataStore
import info.nightscout.interfaces.iob.InMemoryGlucoseValue import info.nightscout.interfaces.iob.InMemoryGlucoseValue
import info.nightscout.interfaces.profile.DefaultValueHelper import info.nightscout.interfaces.profile.DefaultValueHelper
import info.nightscout.shared.utils.T import info.nightscout.shared.utils.T
import info.nightscout.sharedtests.TestBaseWithProfile
import io.reactivex.rxjava3.core.Single import io.reactivex.rxjava3.core.Single
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,8 +1,8 @@
package info.nightscout.implementation.profile package info.nightscout.implementation.profile
import app.aaps.shared.tests.TestBaseWithProfile
import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat
import info.nightscout.interfaces.profile.PureProfile import info.nightscout.interfaces.profile.PureProfile
import info.nightscout.sharedtests.TestBaseWithProfile
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
internal class ProfileStoreTest : TestBaseWithProfile() { internal class ProfileStoreTest : TestBaseWithProfile() {

View file

@ -1,12 +1,12 @@
package info.nightscout.implementation.profile package info.nightscout.implementation.profile
import app.aaps.shared.tests.TestBase
import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat
import info.nightscout.database.entities.GlucoseValue import info.nightscout.database.entities.GlucoseValue
import info.nightscout.implementation.utils.DecimalFormatterImpl import info.nightscout.implementation.utils.DecimalFormatterImpl
import info.nightscout.interfaces.GlucoseUnit import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.sharedtests.TestBase
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 import org.mockito.Mock

View file

@ -1,11 +1,11 @@
package info.nightscout.implementation.pump package info.nightscout.implementation.pump
import app.aaps.shared.tests.TestBase
import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat
import info.nightscout.implementation.R import info.nightscout.implementation.R
import info.nightscout.interfaces.pump.DetailedBolusInfo import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.sharedtests.TestBase
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 import org.mockito.Mock

View file

@ -1,8 +1,8 @@
package info.nightscout.implementation.pump package info.nightscout.implementation.pump
import app.aaps.shared.tests.TestBase
import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat
import info.nightscout.interfaces.pump.PumpSync import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,9 +1,11 @@
package info.nightscout.implementation.queue package info.nightscout.implementation.queue
import com.google.common.truth.Truth.assertThat
import android.content.Context import android.content.Context
import android.os.Handler import android.os.Handler
import android.os.PowerManager import android.os.PowerManager
import app.aaps.shared.tests.TestBaseWithProfile
import app.aaps.shared.tests.TestPumpPlugin
import com.google.common.truth.Truth.assertThat
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.core.constraints.ConstraintObject import info.nightscout.core.constraints.ConstraintObject
@ -36,8 +38,6 @@ import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import info.nightscout.sharedtests.TestBaseWithProfile
import info.nightscout.sharedtests.TestPumpPlugin
import io.reactivex.rxjava3.core.Single import io.reactivex.rxjava3.core.Single
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,8 +1,10 @@
package info.nightscout.implementation.queue package info.nightscout.implementation.queue
import com.google.common.truth.Truth.assertThat
import android.content.Context import android.content.Context
import android.os.PowerManager import android.os.PowerManager
import app.aaps.shared.tests.TestBaseWithProfile
import app.aaps.shared.tests.TestPumpPlugin
import com.google.common.truth.Truth.assertThat
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.core.constraints.ConstraintObject import info.nightscout.core.constraints.ConstraintObject
@ -15,8 +17,6 @@ import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.defs.PumpDescription import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.queue.Command import info.nightscout.interfaces.queue.Command
import info.nightscout.interfaces.ui.UiInteraction import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.sharedtests.TestBaseWithProfile
import info.nightscout.sharedtests.TestPumpPlugin
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.ArgumentMatchers import org.mockito.ArgumentMatchers

View file

@ -1,9 +1,9 @@
package info.nightscout.implementation.utils package info.nightscout.implementation.utils
import app.aaps.shared.tests.TestBase
import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat
import info.nightscout.interfaces.utils.DecimalFormatter import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.sharedtests.TestBase
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 import org.mockito.Mock

View file

@ -1,5 +1,6 @@
package info.nightscout.implementation.wizard package info.nightscout.implementation.wizard
import app.aaps.shared.tests.TestBaseWithProfile
import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
@ -13,7 +14,6 @@ import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.interfaces.profile.Profile import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.defs.PumpDescription import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.queue.CommandQueue import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.sharedtests.TestBaseWithProfile
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.mockito.Mock import org.mockito.Mock
import org.mockito.Mockito import org.mockito.Mockito

View file

@ -1,5 +1,6 @@
package info.nightscout.plugins.aps.loop package info.nightscout.plugins.aps.loop
import app.aaps.shared.tests.TestBaseWithProfile
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.core.constraints.ConstraintObject import info.nightscout.core.constraints.ConstraintObject
@ -10,7 +11,6 @@ import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.constraints.ConstraintsChecker import info.nightscout.interfaces.constraints.ConstraintsChecker
import info.nightscout.interfaces.pump.defs.PumpType import info.nightscout.interfaces.pump.defs.PumpType
import info.nightscout.plugins.aps.APSResultObject import info.nightscout.plugins.aps.APSResultObject
import info.nightscout.sharedtests.TestBaseWithProfile
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,5 +1,6 @@
package info.nightscout.plugins.general.autotune package info.nightscout.plugins.general.autotune
import app.aaps.shared.tests.TestBaseWithProfile
import info.nightscout.core.profile.ProfileSealed import info.nightscout.core.profile.ProfileSealed
import info.nightscout.core.utils.JsonHelper import info.nightscout.core.utils.JsonHelper
import info.nightscout.database.entities.data.Block import info.nightscout.database.entities.data.Block
@ -10,7 +11,6 @@ import info.nightscout.plugins.general.autotune.data.ATProfile
import info.nightscout.plugins.general.autotune.data.PreppedGlucose import info.nightscout.plugins.general.autotune.data.PreppedGlucose
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T import info.nightscout.shared.utils.T
import info.nightscout.sharedtests.TestBaseWithProfile
import org.json.JSONArray import org.json.JSONArray
import org.json.JSONObject import org.json.JSONObject
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions

View file

@ -1,5 +1,6 @@
package info.nightscout.plugins.general.autotune package info.nightscout.plugins.general.autotune
import app.aaps.shared.tests.TestBaseWithProfile
import info.nightscout.core.extensions.shiftBlock import info.nightscout.core.extensions.shiftBlock
import info.nightscout.core.profile.ProfileSealed import info.nightscout.core.profile.ProfileSealed
import info.nightscout.core.utils.JsonHelper import info.nightscout.core.utils.JsonHelper
@ -18,7 +19,6 @@ import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T import info.nightscout.shared.utils.T
import info.nightscout.sharedtests.TestBaseWithProfile
import org.json.JSONArray import org.json.JSONArray
import org.json.JSONObject import org.json.JSONObject
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions

View file

@ -1,9 +1,9 @@
package info.nightscout.plugins.general.autotune package info.nightscout.plugins.general.autotune
import app.aaps.shared.tests.TestBaseWithProfile
import info.nightscout.plugins.general.autotune.data.BGDatum import info.nightscout.plugins.general.autotune.data.BGDatum
import info.nightscout.plugins.general.autotune.data.CRDatum import info.nightscout.plugins.general.autotune.data.CRDatum
import info.nightscout.plugins.general.autotune.data.PreppedGlucose import info.nightscout.plugins.general.autotune.data.PreppedGlucose
import info.nightscout.sharedtests.TestBaseWithProfile
import org.json.JSONObject import org.json.JSONObject
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach

View file

@ -1,5 +1,6 @@
package info.nightscout.automation package info.nightscout.automation
import app.aaps.shared.tests.TestBase
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.automation.actions.Action import info.nightscout.automation.actions.Action
@ -11,7 +12,6 @@ import info.nightscout.automation.triggers.TriggerDummy
import info.nightscout.interfaces.ConfigBuilder import info.nightscout.interfaces.ConfigBuilder
import info.nightscout.interfaces.aps.Loop import info.nightscout.interfaces.aps.Loop
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.sharedtests.TestBase
import org.json.JSONObject import org.json.JSONObject
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -2,6 +2,7 @@ package info.nightscout.automation
import android.content.Context import android.content.Context
import app.aaps.shared.impl.utils.DateUtilImpl import app.aaps.shared.impl.utils.DateUtilImpl
import app.aaps.shared.tests.TestBase
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.automation.services.LocationServiceHelper import info.nightscout.automation.services.LocationServiceHelper
@ -17,7 +18,6 @@ import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -2,6 +2,7 @@ package info.nightscout.automation
import android.content.Context import android.content.Context
import app.aaps.shared.impl.utils.DateUtilImpl import app.aaps.shared.impl.utils.DateUtilImpl
import app.aaps.shared.tests.TestBase
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.automation.services.LocationServiceHelper import info.nightscout.automation.services.LocationServiceHelper
@ -17,7 +18,6 @@ import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,11 +1,11 @@
package info.nightscout.automation package info.nightscout.automation
import app.aaps.shared.tests.TestBase
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.automation.triggers.Trigger import info.nightscout.automation.triggers.Trigger
import info.nightscout.automation.triggers.TriggerConnector import info.nightscout.automation.triggers.TriggerConnector
import info.nightscout.automation.triggers.TriggerDummy import info.nightscout.automation.triggers.TriggerDummy
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,6 +1,7 @@
package info.nightscout.automation.actions package info.nightscout.automation.actions
import android.content.Context import android.content.Context
import app.aaps.shared.tests.TestBase
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.automation.R import info.nightscout.automation.R
@ -11,7 +12,6 @@ import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,6 +1,7 @@
package info.nightscout.automation.actions package info.nightscout.automation.actions
import android.content.Context import android.content.Context
import app.aaps.shared.tests.TestBase
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.automation.R import info.nightscout.automation.R
@ -12,7 +13,6 @@ import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.queue.Callback import info.nightscout.interfaces.queue.Callback
import info.nightscout.rx.bus.RxBus import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.sharedtests.TestBase
import io.reactivex.rxjava3.core.Completable import io.reactivex.rxjava3.core.Completable
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach

View file

@ -1,5 +1,6 @@
package info.nightscout.automation.actions package info.nightscout.automation.actions
import app.aaps.shared.tests.TestBaseWithProfile
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.automation.triggers.Trigger import info.nightscout.automation.triggers.Trigger
@ -21,7 +22,6 @@ import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.smsCommunicator.SmsCommunicator import info.nightscout.interfaces.smsCommunicator.SmsCommunicator
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.sharedtests.TestBaseWithProfile
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.mockito.Mock import org.mockito.Mock
import org.mockito.Mockito.`when` import org.mockito.Mockito.`when`

View file

@ -1,8 +1,8 @@
package info.nightscout.automation.elements package info.nightscout.automation.elements
import app.aaps.shared.tests.TestBase
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,5 +1,6 @@
package info.nightscout.automation.triggers package info.nightscout.automation.triggers
import app.aaps.shared.tests.TestBaseWithProfile
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.automation.AutomationPlugin import info.nightscout.automation.AutomationPlugin
@ -8,7 +9,6 @@ import info.nightscout.database.impl.AppRepository
import info.nightscout.implementation.iob.GlucoseStatusProviderImpl import info.nightscout.implementation.iob.GlucoseStatusProviderImpl
import info.nightscout.interfaces.aps.AutosensDataStore import info.nightscout.interfaces.aps.AutosensDataStore
import info.nightscout.interfaces.receivers.ReceiverStatusStore import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.sharedtests.TestBaseWithProfile
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.mockito.Mock import org.mockito.Mock
import org.mockito.Mockito.`when` import org.mockito.Mockito.`when`

View file

@ -1,5 +1,6 @@
package info.nightscout.configuration.maintenance.formats package info.nightscout.configuration.maintenance.formats
import app.aaps.shared.tests.TestBase
import com.google.common.truth.TruthJUnit.assume import com.google.common.truth.TruthJUnit.assume
import info.nightscout.configuration.maintenance.PrefsMetadataKeyImpl import info.nightscout.configuration.maintenance.PrefsMetadataKeyImpl
import info.nightscout.core.utils.CryptoUtil import info.nightscout.core.utils.CryptoUtil
@ -9,7 +10,6 @@ import info.nightscout.interfaces.maintenance.Prefs
import info.nightscout.interfaces.maintenance.PrefsFormat import info.nightscout.interfaces.maintenance.PrefsFormat
import info.nightscout.interfaces.maintenance.PrefsStatusImpl import info.nightscout.interfaces.maintenance.PrefsStatusImpl
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,5 +1,6 @@
package info.nightscout.plugins.constraints.bgQualityCheck package info.nightscout.plugins.constraints.bgQualityCheck
import app.aaps.shared.tests.TestBase
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.core.constraints.ConstraintObject import info.nightscout.core.constraints.ConstraintObject
@ -14,7 +15,6 @@ import info.nightscout.plugins.constraints.R
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T import info.nightscout.shared.utils.T
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,12 +1,12 @@
package info.nightscout.plugins.constraints.dstHelper package info.nightscout.plugins.constraints.dstHelper
import app.aaps.shared.tests.TestBase
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.interfaces.aps.Loop import info.nightscout.interfaces.aps.Loop
import info.nightscout.interfaces.plugin.ActivePlugin import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,5 +1,6 @@
package info.nightscout.plugins.constraints.objectives package info.nightscout.plugins.constraints.objectives
import app.aaps.shared.tests.TestBase
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.core.constraints.ConstraintObject import info.nightscout.core.constraints.ConstraintObject
@ -11,7 +12,6 @@ import info.nightscout.plugins.constraints.objectives.objectives.Objective
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,8 +1,8 @@
package info.nightscout.plugins.constraints.objectives package info.nightscout.plugins.constraints.objectives
import app.aaps.shared.tests.TestBase
import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.mockito.Mock import org.mockito.Mock
import kotlin.math.abs import kotlin.math.abs

View file

@ -1,6 +1,6 @@
package info.nightscout.plugins.constraints.signatureVerifier package info.nightscout.plugins.constraints.signatureVerifier
import info.nightscout.sharedtests.TestBase import app.aaps.shared.tests.TestBase
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,5 +1,6 @@
package info.nightscout.plugins.constraints.signatureVerifier package info.nightscout.plugins.constraints.signatureVerifier
import app.aaps.shared.tests.TestBase
import dagger.Lazy import dagger.Lazy
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.interfaces.receivers.ReceiverStatusStore import info.nightscout.interfaces.receivers.ReceiverStatusStore
@ -10,7 +11,6 @@ import info.nightscout.plugins.constraints.versionChecker.numericVersionPart
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,12 +1,12 @@
package info.nightscout.plugins.constraints.storage package info.nightscout.plugins.constraints.storage
import app.aaps.shared.tests.TestBase
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.core.constraints.ConstraintObject import info.nightscout.core.constraints.ConstraintObject
import info.nightscout.interfaces.ui.UiInteraction import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.rx.logging.AAPSLogger import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@ -27,7 +27,7 @@ class StorageConstraintPluginTest : TestBase() {
`when`(rh.gs(anyInt(), anyLong())).thenReturn("") `when`(rh.gs(anyInt(), anyLong())).thenReturn("")
} }
class MockedStorageConstraintPlugin constructor( class MockedStorageConstraintPlugin(
injector: HasAndroidInjector, injector: HasAndroidInjector,
aapsLogger: AAPSLogger, aapsLogger: AAPSLogger,
rh: ResourceHelper, rh: ResourceHelper,

View file

@ -1,5 +1,6 @@
package info.nightscout.insulin package info.nightscout.insulin
import app.aaps.shared.tests.TestBase
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
@ -9,7 +10,6 @@ import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.HardLimits import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,12 +1,12 @@
package info.nightscout.core.extensions package info.nightscout.core.extensions
import app.aaps.shared.tests.TestBaseWithProfile
import info.nightscout.database.entities.Bolus import info.nightscout.database.entities.Bolus
import info.nightscout.insulin.InsulinLyumjevPlugin import info.nightscout.insulin.InsulinLyumjevPlugin
import info.nightscout.interfaces.insulin.Insulin import info.nightscout.interfaces.insulin.Insulin
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.ui.UiInteraction import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.shared.utils.T import info.nightscout.shared.utils.T
import info.nightscout.sharedtests.TestBaseWithProfile
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,5 +1,6 @@
package info.nightscout.core.extensions package info.nightscout.core.extensions
import app.aaps.shared.tests.TestBaseWithProfile
import info.nightscout.database.entities.ExtendedBolus import info.nightscout.database.entities.ExtendedBolus
import info.nightscout.database.entities.TemporaryBasal import info.nightscout.database.entities.TemporaryBasal
import info.nightscout.insulin.InsulinLyumjevPlugin import info.nightscout.insulin.InsulinLyumjevPlugin
@ -9,7 +10,6 @@ import info.nightscout.interfaces.insulin.Insulin
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.ui.UiInteraction import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.shared.utils.T import info.nightscout.shared.utils.T
import info.nightscout.sharedtests.TestBaseWithProfile
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@ -54,9 +54,22 @@ class ExtendedBolusExtensionKtTest : TestBaseWithProfile() {
// there should be significant IOB at EB finish // there should be significant IOB at EB finish
Assertions.assertTrue(0.8 < bolus.iobCalc(now + T.hours(1).msecs(), validProfile, asResult, SMBDefaults.exercise_mode, SMBDefaults.half_basal_exercise_target, true, insulin).iob) Assertions.assertTrue(0.8 < bolus.iobCalc(now + T.hours(1).msecs(), validProfile, asResult, SMBDefaults.exercise_mode, SMBDefaults.half_basal_exercise_target, true, insulin).iob)
// there should be less that 5% after DIA -1 // there should be less that 5% after DIA -1
Assertions.assertTrue(0.05 > bolus.iobCalc(now + T.hours(dia.toLong() - 1).msecs(), validProfile, asResult, SMBDefaults.exercise_mode, SMBDefaults.half_basal_exercise_target, true, insulin).iob) Assertions.assertTrue(
0.05 > bolus.iobCalc(
now + T.hours(dia.toLong() - 1).msecs(),
validProfile,
asResult,
SMBDefaults.exercise_mode,
SMBDefaults.half_basal_exercise_target,
true,
insulin
).iob
)
// there should be zero after DIA // there should be zero after DIA
Assertions.assertEquals(0.0, bolus.iobCalc(now + T.hours(dia.toLong() + 1).msecs(), validProfile, asResult, SMBDefaults.exercise_mode, SMBDefaults.half_basal_exercise_target, true, insulin).iob) Assertions.assertEquals(
0.0,
bolus.iobCalc(now + T.hours(dia.toLong() + 1).msecs(), validProfile, asResult, SMBDefaults.exercise_mode, SMBDefaults.half_basal_exercise_target, true, insulin).iob
)
// no IOB for invalid record // no IOB for invalid record
bolus.isValid = false bolus.isValid = false
Assertions.assertEquals(0.0, bolus.iobCalc(now + T.hours(1).msecs(), validProfile, asResult, SMBDefaults.exercise_mode, SMBDefaults.half_basal_exercise_target, true, insulin).iob) Assertions.assertEquals(0.0, bolus.iobCalc(now + T.hours(1).msecs(), validProfile, asResult, SMBDefaults.exercise_mode, SMBDefaults.half_basal_exercise_target, true, insulin).iob)

View file

@ -1,25 +1,29 @@
package info.nightscout.core.extensions package info.nightscout.core.extensions
import app.aaps.shared.tests.TestBaseWithProfile
import info.nightscout.core.main.R import info.nightscout.core.main.R
import info.nightscout.database.entities.GlucoseValue import info.nightscout.database.entities.GlucoseValue
import info.nightscout.interfaces.GlucoseUnit import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.iob.InMemoryGlucoseValue import info.nightscout.interfaces.iob.InMemoryGlucoseValue
import info.nightscout.sharedtests.TestBaseWithProfile
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
class GlucoseValueExtensionKtTest : TestBaseWithProfile() { class GlucoseValueExtensionKtTest : TestBaseWithProfile() {
private val glucoseValue = GlucoseValue(raw = 0.0, noise = 0.0, value = 100.0, timestamp = 1514766900000, sourceSensor = GlucoseValue.SourceSensor.UNKNOWN, trendArrow = GlucoseValue.TrendArrow.FLAT) private val glucoseValue =
GlucoseValue(raw = 0.0, noise = 0.0, value = 100.0, timestamp = 1514766900000, sourceSensor = GlucoseValue.SourceSensor.UNKNOWN, trendArrow = GlucoseValue.TrendArrow.FLAT)
private val inMemoryGlucoseValue = InMemoryGlucoseValue(1000, 100.0, sourceSensor = GlucoseValue.SourceSensor.UNKNOWN) private val inMemoryGlucoseValue = InMemoryGlucoseValue(1000, 100.0, sourceSensor = GlucoseValue.SourceSensor.UNKNOWN)
@Test @Test
fun valueToUnitsString() { fun valueToUnitsString() {
} }
@Test @Test
fun inMemoryValueToUnits() { fun inMemoryValueToUnits() {
Assertions.assertEquals(100.0, inMemoryGlucoseValue.valueToUnits(GlucoseUnit.MGDL)) Assertions.assertEquals(100.0, inMemoryGlucoseValue.valueToUnits(GlucoseUnit.MGDL))
Assertions.assertEquals(5.55, inMemoryGlucoseValue.valueToUnits(GlucoseUnit.MMOL), 0.01) Assertions.assertEquals(5.55, inMemoryGlucoseValue.valueToUnits(GlucoseUnit.MMOL), 0.01)
} }
@Test @Test
fun directionToIcon() { fun directionToIcon() {
Assertions.assertEquals(R.drawable.ic_flat, glucoseValue.trendArrow.directionToIcon()) Assertions.assertEquals(R.drawable.ic_flat, glucoseValue.trendArrow.directionToIcon())

View file

@ -1,5 +1,6 @@
package info.nightscout.core.extensions package info.nightscout.core.extensions
import app.aaps.shared.tests.TestBaseWithProfile
import info.nightscout.database.entities.TemporaryBasal import info.nightscout.database.entities.TemporaryBasal
import info.nightscout.insulin.InsulinLyumjevPlugin import info.nightscout.insulin.InsulinLyumjevPlugin
import info.nightscout.interfaces.aps.AutosensResult import info.nightscout.interfaces.aps.AutosensResult
@ -8,7 +9,6 @@ import info.nightscout.interfaces.insulin.Insulin
import info.nightscout.interfaces.profile.ProfileFunction import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.ui.UiInteraction import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.shared.utils.T import info.nightscout.shared.utils.T
import info.nightscout.sharedtests.TestBaseWithProfile
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,8 +1,8 @@
package info.nightscout.core.extensions package info.nightscout.core.extensions
import app.aaps.shared.tests.TestBaseWithProfile
import info.nightscout.database.entities.TemporaryTarget import info.nightscout.database.entities.TemporaryTarget
import info.nightscout.interfaces.GlucoseUnit import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.sharedtests.TestBaseWithProfile
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@ -22,16 +22,19 @@ class TemporaryTargetExtensionKtTest : TestBaseWithProfile() {
lowTarget = 110.0, lowTarget = 110.0,
duration = 1800000 duration = 1800000
) )
@Test @Test
fun lowValueToUnitsToString() { fun lowValueToUnitsToString() {
Assertions.assertEquals("110", temporaryTarget.lowValueToUnitsToString(GlucoseUnit.MGDL, decimalFormatter)) Assertions.assertEquals("110", temporaryTarget.lowValueToUnitsToString(GlucoseUnit.MGDL, decimalFormatter))
Assertions.assertEquals("6.1", temporaryTarget.lowValueToUnitsToString(GlucoseUnit.MMOL, decimalFormatter)) Assertions.assertEquals("6.1", temporaryTarget.lowValueToUnitsToString(GlucoseUnit.MMOL, decimalFormatter))
} }
@Test @Test
fun highValueToUnitsToString() { fun highValueToUnitsToString() {
Assertions.assertEquals("120", temporaryTarget.highValueToUnitsToString(GlucoseUnit.MGDL, decimalFormatter)) Assertions.assertEquals("120", temporaryTarget.highValueToUnitsToString(GlucoseUnit.MGDL, decimalFormatter))
Assertions.assertEquals("6.7", temporaryTarget.highValueToUnitsToString(GlucoseUnit.MMOL, decimalFormatter)) Assertions.assertEquals("6.7", temporaryTarget.highValueToUnitsToString(GlucoseUnit.MMOL, decimalFormatter))
} }
@Test @Test
fun target() { fun target() {
Assertions.assertEquals(115.0, temporaryTarget.target()) Assertions.assertEquals(115.0, temporaryTarget.target())

View file

@ -1,14 +1,15 @@
package info.nightscout.core.extensions package info.nightscout.core.extensions
import app.aaps.shared.tests.TestBaseWithProfile
import info.nightscout.database.entities.TherapyEvent import info.nightscout.database.entities.TherapyEvent
import info.nightscout.database.entities.embedments.InterfaceIDs import info.nightscout.database.entities.embedments.InterfaceIDs
import info.nightscout.shared.utils.T import info.nightscout.shared.utils.T
import info.nightscout.sharedtests.TestBaseWithProfile
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.mockito.Mockito import org.mockito.Mockito
class TherapyEventExtensionKtTest : TestBaseWithProfile() { class TherapyEventExtensionKtTest : TestBaseWithProfile() {
@Test @Test
fun isOlderThan() { fun isOlderThan() {
val therapyEvent = TherapyEvent( val therapyEvent = TherapyEvent(

View file

@ -1,5 +1,6 @@
package info.nightscout.plugins.general.smsCommunicator package info.nightscout.plugins.general.smsCommunicator
import app.aaps.shared.tests.TestBase
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.interfaces.Constants import info.nightscout.interfaces.Constants
@ -11,7 +12,6 @@ import info.nightscout.plugins.general.smsCommunicator.otp.OneTimePasswordValida
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T import info.nightscout.shared.utils.T
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,6 +1,7 @@
package info.nightscout.plugins.general.smsCommunicator package info.nightscout.plugins.general.smsCommunicator
import android.telephony.SmsManager import android.telephony.SmsManager
import app.aaps.shared.tests.TestBaseWithProfile
import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
@ -33,7 +34,6 @@ import info.nightscout.plugins.general.smsCommunicator.otp.OneTimePassword
import info.nightscout.plugins.general.smsCommunicator.otp.OneTimePasswordValidationResult import info.nightscout.plugins.general.smsCommunicator.otp.OneTimePasswordValidationResult
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T import info.nightscout.shared.utils.T
import info.nightscout.sharedtests.TestBaseWithProfile
import io.reactivex.rxjava3.core.Single import io.reactivex.rxjava3.core.Single
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,8 +1,8 @@
package info.nightscout.plugins.general.smsCommunicator package info.nightscout.plugins.general.smsCommunicator
import android.telephony.SmsMessage import android.telephony.SmsMessage
import app.aaps.shared.tests.TestBase
import info.nightscout.interfaces.smsCommunicator.Sms import info.nightscout.interfaces.smsCommunicator.Sms
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.mockito.Mockito import org.mockito.Mockito

View file

@ -3,6 +3,7 @@ package info.nightscout.plugins.iob
import android.content.Context import android.content.Context
import androidx.collection.LongSparseArray import androidx.collection.LongSparseArray
import app.aaps.shared.impl.utils.DateUtilImpl import app.aaps.shared.impl.utils.DateUtilImpl
import app.aaps.shared.tests.TestBase
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.database.entities.GlucoseValue import info.nightscout.database.entities.GlucoseValue
@ -14,7 +15,6 @@ import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T import info.nightscout.shared.utils.T
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,8 +1,8 @@
package info.nightscout.source package info.nightscout.source
import app.aaps.shared.tests.TestBase
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,8 +1,8 @@
package info.nightscout.source package info.nightscout.source
import app.aaps.shared.tests.TestBase
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,9 +1,9 @@
package info.nightscout.source package info.nightscout.source
import app.aaps.shared.tests.TestBase
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,8 +1,8 @@
package info.nightscout.source package info.nightscout.source
import app.aaps.shared.tests.TestBase
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,5 +1,7 @@
package info.nightscout.plugins.sync.dataBroadcaster package info.nightscout.plugins.sync.dataBroadcaster
import app.aaps.shared.tests.BundleMock
import app.aaps.shared.tests.TestBaseWithProfile
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.database.entities.GlucoseValue import info.nightscout.database.entities.GlucoseValue
@ -17,7 +19,6 @@ import info.nightscout.interfaces.profile.DefaultValueHelper
import info.nightscout.interfaces.pump.PumpEnactResult import info.nightscout.interfaces.pump.PumpEnactResult
import info.nightscout.interfaces.receivers.ReceiverStatusStore import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.rx.events.EventOverviewBolusProgress import info.nightscout.rx.events.EventOverviewBolusProgress
import info.nightscout.sharedtests.TestBaseWithProfile
import org.json.JSONObject import org.json.JSONObject
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
@ -53,7 +54,8 @@ internal class DataBroadcastPluginTest : TestBaseWithProfile() {
Mockito.`when`(iobCobCalculator.calculateIobFromBolus()).thenReturn(IobTotal(System.currentTimeMillis())) Mockito.`when`(iobCobCalculator.calculateIobFromBolus()).thenReturn(IobTotal(System.currentTimeMillis()))
Mockito.`when`(iobCobCalculator.getCobInfo("broadcast")).thenReturn(CobInfo(1000, 100.0, 10.0)) Mockito.`when`(iobCobCalculator.getCobInfo("broadcast")).thenReturn(CobInfo(1000, 100.0, 10.0))
Mockito.`when`(iobCobCalculator.calculateIobFromTempBasalsIncludingConvertedExtended()).thenReturn(IobTotal(System.currentTimeMillis())) Mockito.`when`(iobCobCalculator.calculateIobFromTempBasalsIncludingConvertedExtended()).thenReturn(IobTotal(System.currentTimeMillis()))
Mockito.`when`(iobCobCalculator.getTempBasalIncludingConvertedExtended(anyLong())).thenReturn(TemporaryBasal(timestamp = 1000, duration = 60000, isAbsolute = true, rate = 1.0, type = TemporaryBasal.Type.NORMAL)) Mockito.`when`(iobCobCalculator.getTempBasalIncludingConvertedExtended(anyLong()))
.thenReturn(TemporaryBasal(timestamp = 1000, duration = 60000, isAbsolute = true, rate = 1.0, type = TemporaryBasal.Type.NORMAL))
Mockito.`when`(processedDeviceStatusData.uploaderStatus).thenReturn("100%") Mockito.`when`(processedDeviceStatusData.uploaderStatus).thenReturn("100%")
Mockito.`when`(loop.lastRun).thenReturn(Loop.LastRun().also { Mockito.`when`(loop.lastRun).thenReturn(Loop.LastRun().also {
it.lastTBREnact = 1000 it.lastTBREnact = 1000
@ -77,7 +79,7 @@ internal class DataBroadcastPluginTest : TestBaseWithProfile() {
it.status = "Some status" it.status = "Some status"
it.percent = 100 it.percent = 100
} }
val bundle = info.nightscout.sharedtests.BundleMock.mock() val bundle = BundleMock.mock()
sut.prepareData(event, bundle) sut.prepareData(event, bundle)
Assertions.assertTrue(bundle.containsKey("progressPercent")) Assertions.assertTrue(bundle.containsKey("progressPercent"))
Assertions.assertTrue(bundle.containsKey("progressStatus")) Assertions.assertTrue(bundle.containsKey("progressStatus"))
@ -119,7 +121,7 @@ internal class DataBroadcastPluginTest : TestBaseWithProfile() {
it.status = "Some status" it.status = "Some status"
it.percent = 100 it.percent = 100
} }
val bundle = info.nightscout.sharedtests.BundleMock.mock() val bundle = BundleMock.mock()
sut.prepareData(event, bundle) sut.prepareData(event, bundle)
Assertions.assertTrue(bundle.containsKey("progressPercent")) Assertions.assertTrue(bundle.containsKey("progressPercent"))
Assertions.assertTrue(bundle.containsKey("progressStatus")) Assertions.assertTrue(bundle.containsKey("progressStatus"))

View file

@ -1,5 +1,6 @@
package info.nightscout.plugins.sync.nsclient package info.nightscout.plugins.sync.nsclient
import app.aaps.shared.tests.TestBase
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.interfaces.receivers.ReceiverStatusStore import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.plugins.sync.R import info.nightscout.plugins.sync.R
@ -7,7 +8,6 @@ import info.nightscout.rx.events.EventChargingState
import info.nightscout.rx.events.EventNetworkChange import info.nightscout.rx.events.EventNetworkChange
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,5 +1,6 @@
package info.nightscout.plugins.sync.nsclientV3 package info.nightscout.plugins.sync.nsclientV3
import app.aaps.shared.tests.TestBaseWithProfile
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.core.extensions.fromConstant import info.nightscout.core.extensions.fromConstant
@ -34,7 +35,6 @@ import info.nightscout.plugins.sync.nsclient.data.NSDeviceStatusHandler
import info.nightscout.plugins.sync.nsclient.extensions.fromConstant import info.nightscout.plugins.sync.nsclient.extensions.fromConstant
import info.nightscout.sdk.interfaces.NSAndroidClient import info.nightscout.sdk.interfaces.NSAndroidClient
import info.nightscout.sdk.localmodel.treatment.CreateUpdateResponse import info.nightscout.sdk.localmodel.treatment.CreateUpdateResponse
import info.nightscout.sharedtests.TestBaseWithProfile
import kotlinx.coroutines.test.runTest import kotlinx.coroutines.test.runTest
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach

View file

@ -1,17 +1,17 @@
package info.nightscout.plugins.sync.nsclientV3.extensions package info.nightscout.plugins.sync.nsclientV3.extensions
import app.aaps.shared.tests.TestBase
import info.nightscout.database.entities.DeviceStatus import info.nightscout.database.entities.DeviceStatus
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.sdk.interfaces.RunningConfiguration
import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData
import info.nightscout.interfaces.profile.Instantiator import info.nightscout.interfaces.profile.Instantiator
import info.nightscout.plugins.sync.nsclient.data.NSDeviceStatusHandler import info.nightscout.plugins.sync.nsclient.data.NSDeviceStatusHandler
import info.nightscout.plugins.sync.nsclient.data.ProcessedDeviceStatusDataImpl import info.nightscout.plugins.sync.nsclient.data.ProcessedDeviceStatusDataImpl
import info.nightscout.sdk.interfaces.RunningConfiguration
import info.nightscout.sdk.mapper.convertToRemoteAndBack import info.nightscout.sdk.mapper.convertToRemoteAndBack
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,5 +1,6 @@
package info.nightscout.plugins.sync.nsclientV3.extensions package info.nightscout.plugins.sync.nsclientV3.extensions
import app.aaps.shared.tests.TestBaseWithProfile
import info.nightscout.database.entities.EffectiveProfileSwitch import info.nightscout.database.entities.EffectiveProfileSwitch
import info.nightscout.database.entities.embedments.InsulinConfiguration import info.nightscout.database.entities.embedments.InsulinConfiguration
import info.nightscout.database.entities.embedments.InterfaceIDs import info.nightscout.database.entities.embedments.InterfaceIDs
@ -7,7 +8,6 @@ import info.nightscout.interfaces.insulin.Insulin
import info.nightscout.plugins.sync.nsclient.extensions.fromConstant import info.nightscout.plugins.sync.nsclient.extensions.fromConstant
import info.nightscout.sdk.localmodel.treatment.NSEffectiveProfileSwitch import info.nightscout.sdk.localmodel.treatment.NSEffectiveProfileSwitch
import info.nightscout.sdk.mapper.convertToRemoteAndBack import info.nightscout.sdk.mapper.convertToRemoteAndBack
import info.nightscout.sharedtests.TestBaseWithProfile
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@ -26,6 +26,7 @@ internal class EffectiveProfileSwitchExtensionKtTest : TestBaseWithProfile() {
Mockito.`when`(insulin.insulinConfiguration).thenReturn(insulinConfiguration) Mockito.`when`(insulin.insulinConfiguration).thenReturn(insulinConfiguration)
Mockito.`when`(activePlugin.activeInsulin).thenReturn(insulin) Mockito.`when`(activePlugin.activeInsulin).thenReturn(insulin)
} }
@Test @Test
fun toEffectiveProfileSwitch() { fun toEffectiveProfileSwitch() {
val profileSwitch = EffectiveProfileSwitch( val profileSwitch = EffectiveProfileSwitch(

View file

@ -1,11 +1,11 @@
package info.nightscout.plugins.sync.nsclientV3.extensions package info.nightscout.plugins.sync.nsclientV3.extensions
import app.aaps.shared.tests.TestBaseWithProfile
import info.nightscout.database.entities.ExtendedBolus import info.nightscout.database.entities.ExtendedBolus
import info.nightscout.database.entities.embedments.InterfaceIDs import info.nightscout.database.entities.embedments.InterfaceIDs
import info.nightscout.sdk.localmodel.treatment.NSExtendedBolus import info.nightscout.sdk.localmodel.treatment.NSExtendedBolus
import info.nightscout.sdk.localmodel.treatment.NSTemporaryBasal import info.nightscout.sdk.localmodel.treatment.NSTemporaryBasal
import info.nightscout.sdk.mapper.convertToRemoteAndBack import info.nightscout.sdk.mapper.convertToRemoteAndBack
import info.nightscout.sharedtests.TestBaseWithProfile
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,9 +1,9 @@
package info.nightscout.plugins.sync.nsclientV3.extensions package info.nightscout.plugins.sync.nsclientV3.extensions
import app.aaps.shared.tests.TestBaseWithProfile
import info.nightscout.database.entities.GlucoseValue import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.entities.embedments.InterfaceIDs import info.nightscout.database.entities.embedments.InterfaceIDs
import info.nightscout.sdk.mapper.convertToRemoteAndBack import info.nightscout.sdk.mapper.convertToRemoteAndBack
import info.nightscout.sharedtests.TestBaseWithProfile
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,5 +1,6 @@
package info.nightscout.plugins.sync.nsclientV3.extensions package info.nightscout.plugins.sync.nsclientV3.extensions
import app.aaps.shared.tests.TestBaseWithProfile
import info.nightscout.core.extensions.fromConstant import info.nightscout.core.extensions.fromConstant
import info.nightscout.database.entities.ProfileSwitch import info.nightscout.database.entities.ProfileSwitch
import info.nightscout.database.entities.embedments.InsulinConfiguration import info.nightscout.database.entities.embedments.InsulinConfiguration
@ -7,7 +8,6 @@ import info.nightscout.database.entities.embedments.InterfaceIDs
import info.nightscout.interfaces.insulin.Insulin import info.nightscout.interfaces.insulin.Insulin
import info.nightscout.sdk.localmodel.treatment.NSProfileSwitch import info.nightscout.sdk.localmodel.treatment.NSProfileSwitch
import info.nightscout.sdk.mapper.convertToRemoteAndBack import info.nightscout.sdk.mapper.convertToRemoteAndBack
import info.nightscout.sharedtests.TestBaseWithProfile
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@ -26,6 +26,7 @@ internal class ProfileSwitchExtensionKtTest : TestBaseWithProfile() {
Mockito.`when`(insulin.insulinConfiguration).thenReturn(insulinConfiguration) Mockito.`when`(insulin.insulinConfiguration).thenReturn(insulinConfiguration)
Mockito.`when`(activePlugin.activeInsulin).thenReturn(insulin) Mockito.`when`(activePlugin.activeInsulin).thenReturn(insulin)
} }
@Test @Test
fun toProfileSwitch() { fun toProfileSwitch() {
var profileSwitch = ProfileSwitch( var profileSwitch = ProfileSwitch(

View file

@ -1,10 +1,10 @@
package info.nightscout.plugins.sync.nsclientV3.extensions package info.nightscout.plugins.sync.nsclientV3.extensions
import app.aaps.shared.tests.TestBaseWithProfile
import info.nightscout.database.entities.TemporaryBasal import info.nightscout.database.entities.TemporaryBasal
import info.nightscout.database.entities.embedments.InterfaceIDs import info.nightscout.database.entities.embedments.InterfaceIDs
import info.nightscout.sdk.localmodel.treatment.NSTemporaryBasal import info.nightscout.sdk.localmodel.treatment.NSTemporaryBasal
import info.nightscout.sdk.mapper.convertToRemoteAndBack import info.nightscout.sdk.mapper.convertToRemoteAndBack
import info.nightscout.sharedtests.TestBaseWithProfile
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,10 +1,10 @@
package info.nightscout.plugins.sync.nsclientV3.extensions package info.nightscout.plugins.sync.nsclientV3.extensions
import app.aaps.shared.tests.TestBaseWithProfile
import info.nightscout.database.entities.TemporaryTarget import info.nightscout.database.entities.TemporaryTarget
import info.nightscout.database.entities.embedments.InterfaceIDs import info.nightscout.database.entities.embedments.InterfaceIDs
import info.nightscout.sdk.localmodel.treatment.NSTemporaryTarget import info.nightscout.sdk.localmodel.treatment.NSTemporaryTarget
import info.nightscout.sdk.mapper.convertToRemoteAndBack import info.nightscout.sdk.mapper.convertToRemoteAndBack
import info.nightscout.sharedtests.TestBaseWithProfile
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,10 +1,10 @@
package info.nightscout.plugins.sync.nsclientV3.extensions package info.nightscout.plugins.sync.nsclientV3.extensions
import app.aaps.shared.tests.TestBaseWithProfile
import info.nightscout.database.entities.TherapyEvent import info.nightscout.database.entities.TherapyEvent
import info.nightscout.database.entities.embedments.InterfaceIDs import info.nightscout.database.entities.embedments.InterfaceIDs
import info.nightscout.sdk.localmodel.treatment.NSTherapyEvent import info.nightscout.sdk.localmodel.treatment.NSTherapyEvent
import info.nightscout.sdk.mapper.convertToRemoteAndBack import info.nightscout.sdk.mapper.convertToRemoteAndBack
import info.nightscout.sharedtests.TestBaseWithProfile
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -3,6 +3,7 @@ package info.nightscout.plugins.sync.nsclientV3.workers
import android.content.Context import android.content.Context
import androidx.work.ListenableWorker.Result.Success import androidx.work.ListenableWorker.Result.Success
import androidx.work.testing.TestListenableWorkerBuilder import androidx.work.testing.TestListenableWorkerBuilder
import app.aaps.shared.tests.TestBase
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
@ -10,7 +11,6 @@ import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.sync.NsClient import info.nightscout.interfaces.sync.NsClient
import info.nightscout.plugins.sync.nsclientV3.DataSyncSelectorV3 import info.nightscout.plugins.sync.nsclientV3.DataSyncSelectorV3
import info.nightscout.plugins.sync.nsclientV3.NSClientV3Plugin import info.nightscout.plugins.sync.nsclientV3.NSClientV3Plugin
import info.nightscout.sharedtests.TestBase
import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest import kotlinx.coroutines.test.runTest
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions

View file

@ -6,6 +6,7 @@ import androidx.work.OneTimeWorkRequest
import androidx.work.WorkContinuation import androidx.work.WorkContinuation
import androidx.work.WorkManager import androidx.work.WorkManager
import androidx.work.testing.TestListenableWorkerBuilder import androidx.work.testing.TestListenableWorkerBuilder
import app.aaps.shared.tests.TestBase
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
@ -31,7 +32,6 @@ import info.nightscout.sdk.remotemodel.LastModified
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import info.nightscout.sharedtests.TestBase
import kotlinx.coroutines.test.runTest import kotlinx.coroutines.test.runTest
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach

View file

@ -1,6 +1,7 @@
package info.nightscout.pump.combo package info.nightscout.pump.combo
import android.content.Context import android.content.Context
import app.aaps.shared.tests.TestBase
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.core.constraints.ConstraintObject import info.nightscout.core.constraints.ConstraintObject
@ -15,7 +16,6 @@ import info.nightscout.pump.combo.ruffyscripter.history.Bolus
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,8 +1,8 @@
package info.nightscout.pump.dana package info.nightscout.pump.dana
import app.aaps.shared.tests.TestBaseWithProfile
import com.google.common.truth.Truth.assertThat import com.google.common.truth.Truth.assertThat
import info.nightscout.interfaces.profile.Instantiator import info.nightscout.interfaces.profile.Instantiator
import info.nightscout.sharedtests.TestBaseWithProfile
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 import org.mockito.Mock

View file

@ -1,5 +1,6 @@
package info.nightscout.pump.danaR package info.nightscout.pump.danaR
import app.aaps.shared.tests.TestBaseWithProfile
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.danar.DanaRPlugin import info.nightscout.androidaps.danar.DanaRPlugin
@ -12,7 +13,6 @@ import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.UiInteraction import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.pump.dana.DanaPump import info.nightscout.pump.dana.DanaPump
import info.nightscout.pump.dana.database.DanaHistoryDatabase import info.nightscout.pump.dana.database.DanaHistoryDatabase
import info.nightscout.sharedtests.TestBaseWithProfile
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,5 +1,6 @@
package info.nightscout.pump.danaR.comm package info.nightscout.pump.danaR.comm
import app.aaps.shared.tests.TestBaseWithProfile
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin
@ -15,7 +16,6 @@ import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.UiInteraction import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.pump.dana.DanaPump import info.nightscout.pump.dana.DanaPump
import info.nightscout.pump.dana.database.DanaHistoryRecordDao import info.nightscout.pump.dana.database.DanaHistoryRecordDao
import info.nightscout.sharedtests.TestBaseWithProfile
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.mockito.ArgumentMatchers import org.mockito.ArgumentMatchers
import org.mockito.Mock import org.mockito.Mock

View file

@ -1,7 +1,7 @@
package info.nightscout.pump.danaR.comm package info.nightscout.pump.danaR.comm
import app.aaps.shared.tests.TestBase
import info.nightscout.androidaps.danar.comm.MessageOriginalNames import info.nightscout.androidaps.danar.comm.MessageOriginalNames
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,5 +1,6 @@
package info.nightscout.pump.danaRKorean package info.nightscout.pump.danaRKorean
import app.aaps.shared.tests.TestBaseWithProfile
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin import info.nightscout.androidaps.danaRKorean.DanaRKoreanPlugin
@ -12,7 +13,6 @@ import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.UiInteraction import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.pump.dana.DanaPump import info.nightscout.pump.dana.DanaPump
import info.nightscout.pump.dana.database.DanaHistoryDatabase import info.nightscout.pump.dana.database.DanaHistoryDatabase
import info.nightscout.sharedtests.TestBaseWithProfile
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,5 +1,6 @@
package info.nightscout.pump.danaRv2 package info.nightscout.pump.danaRv2
import app.aaps.shared.tests.TestBaseWithProfile
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.danaRv2.DanaRv2Plugin import info.nightscout.androidaps.danaRv2.DanaRv2Plugin
@ -14,7 +15,6 @@ import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.UiInteraction import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.pump.dana.DanaPump import info.nightscout.pump.dana.DanaPump
import info.nightscout.pump.dana.database.DanaHistoryDatabase import info.nightscout.pump.dana.database.DanaHistoryDatabase
import info.nightscout.sharedtests.TestBaseWithProfile
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,12 +1,12 @@
package info.nightscout.pump.danars package info.nightscout.pump.danars
import app.aaps.shared.tests.TestBaseWithProfile
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.interfaces.profile.Instantiator import info.nightscout.interfaces.profile.Instantiator
import info.nightscout.interfaces.ui.UiInteraction import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.pump.dana.DanaPump import info.nightscout.pump.dana.DanaPump
import info.nightscout.pump.danars.comm.DanaRSPacket import info.nightscout.pump.danars.comm.DanaRSPacket
import info.nightscout.sharedtests.TestBaseWithProfile
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.mockito.ArgumentMatchers import org.mockito.ArgumentMatchers
import org.mockito.Mock import org.mockito.Mock

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.plugins.pump.medtronic package info.nightscout.androidaps.plugins.pump.medtronic
import app.aaps.shared.tests.TestBase
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil
@ -12,7 +13,6 @@ import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.pump.common.sync.PumpSyncStorage import info.nightscout.pump.common.sync.PumpSyncStorage
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.sharedtests.TestBase
import org.mockito.Answers import org.mockito.Answers
import org.mockito.Mock import org.mockito.Mock

View file

@ -1,9 +1,9 @@
package info.nightscout.pump.medtrum package info.nightscout.pump.medtrum
import app.aaps.shared.tests.TestBaseWithProfile
import info.nightscout.interfaces.pump.PumpSync import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.TemporaryBasalStorage import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.stats.TddCalculator import info.nightscout.interfaces.stats.TddCalculator
import info.nightscout.sharedtests.TestBaseWithProfile
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.mockito.Mock import org.mockito.Mock
import org.mockito.Mockito import org.mockito.Mockito

View file

@ -4,11 +4,11 @@ import android.content.Context
import androidx.room.Room import androidx.room.Room
import androidx.test.core.app.ApplicationProvider import androidx.test.core.app.ApplicationProvider
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4
import app.aaps.shared.tests.AAPSLoggerTest
import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.DashHistoryDatabase import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.DashHistoryDatabase
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.HistoryRecordDao import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.database.HistoryRecordDao
import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.mapper.HistoryMapper import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.mapper.HistoryMapper
import info.nightscout.sharedtests.AAPSLoggerTest
import org.junit.Before import org.junit.Before
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith

View file

@ -1,8 +1,8 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.endecrypt package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.endecrypt
import app.aaps.shared.tests.AAPSLoggerTest
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.MessagePacket import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.message.MessagePacket
import info.nightscout.core.utils.toHex import info.nightscout.core.utils.toHex
import info.nightscout.sharedtests.AAPSLoggerTest
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.spongycastle.util.encoders.Hex import org.spongycastle.util.encoders.Hex

View file

@ -1,11 +1,11 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.pair package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.pair
import app.aaps.shared.tests.AAPSLoggerTest
import app.aaps.shared.tests.TestBase
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util.RandomByteGenerator import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util.RandomByteGenerator
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util.X25519KeyGenerator import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.util.X25519KeyGenerator
import info.nightscout.core.utils.toHex import info.nightscout.core.utils.toHex
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.sharedtests.AAPSLoggerTest
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.mockito.ArgumentMatchers.anyInt import org.mockito.ArgumentMatchers.anyInt

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session
import app.aaps.shared.tests.AAPSLoggerTest
import info.nightscout.core.utils.toHex import info.nightscout.core.utils.toHex
import info.nightscout.sharedtests.AAPSLoggerTest
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.spongycastle.util.encoders.Hex import org.spongycastle.util.encoders.Hex

View file

@ -1,9 +1,9 @@
package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.session
import app.aaps.shared.tests.AAPSLoggerTest
import app.aaps.shared.tests.TestBase
import info.nightscout.core.utils.toHex import info.nightscout.core.utils.toHex
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
import info.nightscout.sharedtests.AAPSLoggerTest
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.mockito.Mock import org.mockito.Mock

View file

@ -1,5 +1,7 @@
package info.nightscout.androidaps.plugins.pump.omnipod.eros package info.nightscout.androidaps.plugins.pump.omnipod.eros
import app.aaps.shared.tests.TestBase
import app.aaps.shared.tests.rx.TestAapsSchedulers
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil
@ -15,8 +17,6 @@ import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.interfaces.utils.DecimalFormatter import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.pump.common.defs.TempBasalPair import info.nightscout.pump.common.defs.TempBasalPair
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.sharedtests.TestBase
import info.nightscout.sharedtests.rx.TestAapsSchedulers
import org.joda.time.DateTimeZone import org.joda.time.DateTimeZone
import org.joda.time.tz.UTCProvider import org.joda.time.tz.UTCProvider
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions

View file

@ -1,9 +1,9 @@
package info.nightscout.androidaps.plugins.pump.omnipod.eros.manager package info.nightscout.androidaps.plugins.pump.omnipod.eros.manager
import app.aaps.shared.tests.TestBase
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.FirmwareVersion import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.FirmwareVersion
import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.PodProgressStatus import info.nightscout.androidaps.plugins.pump.omnipod.eros.driver.definition.PodProgressStatus
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.sharedtests.TestBase
import org.joda.time.DateTime import org.joda.time.DateTime
import org.joda.time.DateTimeUtils import org.joda.time.DateTimeUtils
import org.joda.time.DateTimeZone import org.joda.time.DateTimeZone

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble
import app.aaps.shared.tests.TestBase
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkFirmwareVersion import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkFirmwareVersion
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -1,5 +1,6 @@
package info.nightscout.pump.virtual package info.nightscout.pump.virtual
import app.aaps.shared.tests.TestBase
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import info.nightscout.core.utils.fabric.FabricPrivacy import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.interfaces.Config import info.nightscout.interfaces.Config
@ -12,7 +13,6 @@ import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.shared.interfaces.ResourceHelper import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.DateUtil
import info.nightscout.sharedtests.TestBase
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View file

@ -0,0 +1,50 @@
package app.aaps.shared.impl.di
import android.content.Context
import androidx.preference.PreferenceManager
import app.aaps.shared.impl.logging.AAPSLoggerProduction
import app.aaps.shared.impl.logging.LImpl
import app.aaps.shared.impl.rx.AapsSchedulersImpl
import app.aaps.shared.impl.rx.bus.RxBusImpl
import app.aaps.shared.impl.sharedPreferences.SPImplementation
import app.aaps.shared.impl.utils.DateUtilImpl
import dagger.Module
import dagger.Provides
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.interfaces.L
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil
import javax.inject.Singleton
@Module(
includes = [
]
)
open class SharedImplModule {
@Provides
@Singleton
fun provideSharedPreferences(context: Context): SP = SPImplementation(PreferenceManager.getDefaultSharedPreferences(context), context)
@Provides
@Singleton
fun provideL(sp: SP): L = LImpl(sp)
@Provides
@Singleton
fun provideDateUtil(context: Context): DateUtil = DateUtilImpl(context)
@Provides
@Singleton
fun provideAAPSLogger(l: L): AAPSLogger = AAPSLoggerProduction(l)
@Provides
@Singleton
fun provideRxBus(aapsSchedulers: AapsSchedulers, aapsLogger: AAPSLogger): RxBus = RxBusImpl(aapsSchedulers, aapsLogger)
@Provides
@Singleton
internal fun provideSchedulers(): AapsSchedulers = AapsSchedulersImpl()
}

View file

@ -0,0 +1,32 @@
package app.aaps.shared.impl.extensions
import android.content.Intent
import android.content.pm.PackageInfo
import android.content.pm.PackageManager
import android.content.pm.ResolveInfo
/**
* Safe version of getInstalledPackages depending on Android version running
*/
fun PackageManager.safeGetInstalledPackages(flags: Int): List<PackageInfo> =
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) getInstalledPackages(PackageManager.PackageInfoFlags.of(flags.toLong()))
else @Suppress("DEPRECATION") getInstalledPackages(flags)
/**
* Safe version of queryBroadcastReceivers depending on Android version running
*/
fun PackageManager.safeQueryBroadcastReceivers(intent: Intent, flags: Int): List<ResolveInfo> =
try {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) queryBroadcastReceivers(intent, PackageManager.ResolveInfoFlags.of(flags.toLong()))
else @Suppress("DEPRECATION") queryBroadcastReceivers(intent, flags)
} catch (ignored: Exception) {
emptyList()
}
/**
* Safe version of getPackageInfo depending on Android version running
*/
@Throws(PackageManager.NameNotFoundException::class)
fun PackageManager.safeGetPackageInfo(packageName: String, flags: Int): PackageInfo =
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) getPackageInfo(packageName, PackageManager.PackageInfoFlags.of(flags.toLong()))
else @Suppress("DEPRECATION") getPackageInfo(packageName, flags)

View file

@ -0,0 +1,106 @@
package app.aaps.shared.impl.logging
import info.nightscout.rx.interfaces.L
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import org.slf4j.LoggerFactory
/**
* Created by adrian on 2019-12-27.
*/
class AAPSLoggerProduction(val l: L) : AAPSLogger {
override fun debug(message: String) {
LoggerFactory.getLogger(LTag.CORE.tag).debug(stackLogMarker() + message)
}
override fun debug(enable: Boolean, tag: LTag, message: String) {
if (enable && l.findByName(tag.tag).enabled)
LoggerFactory.getLogger(tag.tag).debug(stackLogMarker() + message)
}
override fun debug(tag: LTag, message: String) {
if (l.findByName(tag.tag).enabled)
LoggerFactory.getLogger(tag.tag).debug(stackLogMarker() + message)
}
override fun debug(tag: LTag, accessor: () -> String) {
if (l.findByName(tag.tag).enabled)
LoggerFactory.getLogger(tag.tag).debug(stackLogMarker() + accessor.invoke())
}
override fun debug(tag: LTag, format: String, vararg arguments: Any?) {
if (l.findByName(tag.tag).enabled)
LoggerFactory.getLogger(tag.tag).debug(stackLogMarker() + format, arguments)
}
override fun warn(tag: LTag, message: String) {
if (l.findByName(tag.tag).enabled)
LoggerFactory.getLogger(tag.tag).warn(stackLogMarker() + message)
}
override fun warn(tag: LTag, format: String, vararg arguments: Any?) {
LoggerFactory.getLogger(tag.tag).warn(stackLogMarker() + format, arguments)
}
override fun info(tag: LTag, message: String) {
if (l.findByName(tag.tag).enabled)
LoggerFactory.getLogger(tag.tag).info(stackLogMarker() + message)
}
override fun info(tag: LTag, format: String, vararg arguments: Any?) {
if (l.findByName(tag.tag).enabled)
LoggerFactory.getLogger(tag.tag).info(stackLogMarker() + format, arguments)
}
override fun error(tag: LTag, message: String) {
LoggerFactory.getLogger(tag.tag).error(stackLogMarker() + message)
}
override fun error(message: String) {
LoggerFactory.getLogger(LTag.CORE.tag).error(stackLogMarker() + message)
}
override fun error(message: String, throwable: Throwable) {
LoggerFactory.getLogger(LTag.CORE.tag).error(stackLogMarker() + message, throwable)
}
override fun error(format: String, vararg arguments: Any?) {
LoggerFactory.getLogger(LTag.CORE.tag).error(stackLogMarker() + format, arguments)
}
override fun error(tag: LTag, message: String, throwable: Throwable) {
LoggerFactory.getLogger(tag.tag).error(stackLogMarker() + message, throwable)
}
override fun error(tag: LTag, format: String, vararg arguments: Any?) {
LoggerFactory.getLogger(tag.tag).error(stackLogMarker() + format, arguments)
}
override fun debug(className: String, methodName: String, lineNumber: Int, tag: LTag, message: String) {
LoggerFactory.getLogger(tag.tag).debug(logLocationPrefix(className, methodName, lineNumber) + message)
}
override fun info(className: String, methodName: String, lineNumber: Int, tag: LTag, message: String) {
LoggerFactory.getLogger(tag.tag).info(logLocationPrefix(className, methodName, lineNumber) + message)
}
override fun warn(className: String, methodName: String, lineNumber: Int, tag: LTag, message: String) {
LoggerFactory.getLogger(tag.tag).warn(logLocationPrefix(className, methodName, lineNumber) + message)
}
override fun error(className: String, methodName: String, lineNumber: Int, tag: LTag, message: String) {
LoggerFactory.getLogger(tag.tag).error(logLocationPrefix(className, methodName, lineNumber) + message)
}
}
private fun logLocationPrefix(className: String, methodName: String, lineNumber: Int) =
"[$className.$methodName():$lineNumber]: "
fun StackTraceElement.toLogString(): String =
logLocationPrefix(this.className.substringAfterLast("."), this.methodName, this.lineNumber)
/* Needs to be inline. Don't remove even if IDE suggests it. */
@Suppress("NOTHING_TO_INLINE")
inline fun stackLogMarker() = Throwable().stackTrace[1].toLogString()

View file

@ -0,0 +1,72 @@
package app.aaps.shared.impl.logging
import info.nightscout.rx.interfaces.L
import info.nightscout.rx.interfaces.LogElement
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.sharedPreferences.SP
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class LImpl @Inject constructor(
private val sp: SP
) : L {
private var logElements: MutableList<LogElement> = ArrayList()
init {
LTag.values().forEach { logElements.add(LogElementImpl(it, sp)) }
}
override fun findByName(name: String): LogElement {
for (element in logElements) {
if (element.name == name) return element
}
return LogElementImpl(false, sp)
}
override fun getLogElements(): List<LogElement> {
return logElements
}
override fun resetToDefaults() {
for (element in logElements) {
element.resetToDefault()
}
}
class LogElementImpl : LogElement {
var sp: SP
override var name: String
override var defaultValue: Boolean
override var enabled: Boolean
private var requiresRestart = false
internal constructor(tag: LTag, sp: SP) {
this.sp = sp
this.name = tag.tag
this.defaultValue = tag.defaultValue
this.requiresRestart = tag.requiresRestart
enabled = sp.getBoolean(getSPName(), defaultValue)
}
internal constructor(defaultValue: Boolean, sp: SP) {
this.sp = sp
name = "NONEXISTENT"
this.defaultValue = defaultValue
enabled = defaultValue
}
private fun getSPName(): String = "log_$name"
override fun enable(enabled: Boolean) {
this.enabled = enabled
sp.putBoolean(getSPName(), enabled)
}
override fun resetToDefault() {
enable(defaultValue)
}
}
}

View file

@ -0,0 +1,16 @@
package app.aaps.shared.impl.rx
import info.nightscout.rx.AapsSchedulers
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.core.Scheduler
import io.reactivex.rxjava3.schedulers.Schedulers
import javax.inject.Singleton
@Singleton
class AapsSchedulersImpl : AapsSchedulers {
override val main: Scheduler = AndroidSchedulers.mainThread()
override val io: Scheduler = Schedulers.io()
override val cpu: Scheduler = Schedulers.computation()
override val newThread: Scheduler = Schedulers.newThread()
}

View file

@ -0,0 +1,34 @@
package app.aaps.shared.impl.rx.bus
import info.nightscout.annotations.OpenForTesting
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.Event
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import io.reactivex.rxjava3.core.Observable
import io.reactivex.rxjava3.subjects.PublishSubject
import javax.inject.Inject
import javax.inject.Singleton
@OpenForTesting
@Singleton
class RxBusImpl @Inject constructor(
val aapsSchedulers: AapsSchedulers,
val aapsLogger: AAPSLogger
) : RxBus {
private val publisher = PublishSubject.create<Event>()
override fun send(event: Event) {
aapsLogger.debug(LTag.EVENTS, "Sending $event")
publisher.onNext(event)
}
// Listen should return an Observable and not the publisher
// Using ofType we filter only events that match that class type
override fun <T : Any> toObservable(eventType: Class<T>): Observable<T> =
publisher
.subscribeOn(aapsSchedulers.io)
.ofType(eventType)
}

View file

@ -0,0 +1,204 @@
package app.aaps.shared.impl.sharedPreferences
import android.annotation.SuppressLint
import android.content.Context
import android.content.SharedPreferences
import androidx.annotation.StringRes
import info.nightscout.shared.SafeParse
import info.nightscout.shared.sharedPreferences.SP
import javax.inject.Inject
import javax.inject.Singleton
@Singleton
class SPImplementation @Inject constructor(
private val sharedPreferences: SharedPreferences,
private val context: Context
) : SP {
@SuppressLint("ApplySharedPref")
override fun edit(commit: Boolean, block: SP.Editor.() -> Unit) {
val spEdit = sharedPreferences.edit()
val edit = object : SP.Editor {
override fun clear() {
spEdit.clear()
}
override fun remove(@StringRes resourceID: Int) {
spEdit.remove(context.getString(resourceID))
}
override fun remove(key: String) {
spEdit.remove(key)
}
override fun putBoolean(key: String, value: Boolean) {
spEdit.putBoolean(key, value)
}
override fun putBoolean(@StringRes resourceID: Int, value: Boolean) {
spEdit.putBoolean(context.getString(resourceID), value)
}
override fun putDouble(key: String, value: Double) {
spEdit.putString(key, value.toString())
}
override fun putDouble(@StringRes resourceID: Int, value: Double) {
spEdit.putString(context.getString(resourceID), value.toString())
}
override fun putLong(key: String, value: Long) {
spEdit.putLong(key, value)
}
override fun putLong(@StringRes resourceID: Int, value: Long) {
spEdit.putLong(context.getString(resourceID), value)
}
override fun putInt(key: String, value: Int) {
spEdit.putInt(key, value)
}
override fun putInt(@StringRes resourceID: Int, value: Int) {
spEdit.putInt(context.getString(resourceID), value)
}
override fun putString(key: String, value: String) {
spEdit.putString(key, value)
}
override fun putString(@StringRes resourceID: Int, value: String) {
spEdit.putString(context.getString(resourceID), value)
}
}
block(edit)
if (commit)
spEdit.commit()
else
spEdit.apply()
}
override fun getAll(): Map<String, *> = sharedPreferences.all
override fun clear() = sharedPreferences.edit().clear().apply()
override fun contains(key: String): Boolean = sharedPreferences.contains(key)
override fun contains(resourceId: Int): Boolean = sharedPreferences.contains(context.getString(resourceId))
override fun remove(resourceID: Int) =
sharedPreferences.edit().remove(context.getString(resourceID)).apply()
override fun remove(key: String) =
sharedPreferences.edit().remove(key).apply()
override fun getString(resourceID: Int, defaultValue: String): String =
sharedPreferences.getString(context.getString(resourceID), defaultValue) ?: defaultValue
override fun getString(key: String, defaultValue: String): String =
sharedPreferences.getString(key, defaultValue) ?: defaultValue
override fun getStringOrNull(resourceID: Int, defaultValue: String?): String? =
sharedPreferences.getString(context.getString(resourceID), defaultValue) ?: defaultValue
override fun getStringOrNull(key: String, defaultValue: String?): String? =
sharedPreferences.getString(key, defaultValue)
override fun getBoolean(resourceID: Int, defaultValue: Boolean): Boolean {
return try {
sharedPreferences.getBoolean(context.getString(resourceID), defaultValue)
} catch (e: Exception) {
defaultValue
}
}
override fun getBoolean(key: String, defaultValue: Boolean): Boolean {
return try {
sharedPreferences.getBoolean(key, defaultValue)
} catch (e: Exception) {
defaultValue
}
}
override fun getDouble(resourceID: Int, defaultValue: Double): Double =
SafeParse.stringToDouble(sharedPreferences.getString(context.getString(resourceID), defaultValue.toString()), defaultValue)
override fun getDouble(key: String, defaultValue: Double): Double =
SafeParse.stringToDouble(sharedPreferences.getString(key, defaultValue.toString()), defaultValue)
override fun getInt(resourceID: Int, defaultValue: Int): Int {
return try {
sharedPreferences.getInt(context.getString(resourceID), defaultValue)
} catch (e: Exception) {
SafeParse.stringToInt(sharedPreferences.getString(context.getString(resourceID), defaultValue.toString()), defaultValue)
}
}
override fun getInt(key: String, defaultValue: Int): Int {
return try {
sharedPreferences.getInt(key, defaultValue)
} catch (e: Exception) {
SafeParse.stringToInt(sharedPreferences.getString(key, defaultValue.toString()), defaultValue)
}
}
override fun getLong(resourceID: Int, defaultValue: Long): Long {
return try {
sharedPreferences.getLong(context.getString(resourceID), defaultValue)
} catch (e: Exception) {
SafeParse.stringToLong(sharedPreferences.getString(context.getString(resourceID), defaultValue.toString()), defaultValue)
}
}
override fun getLong(key: String, defaultValue: Long): Long {
return try {
sharedPreferences.getLong(key, defaultValue)
} catch (e: Exception) {
SafeParse.stringToLong(sharedPreferences.getString(key, defaultValue.toString()), defaultValue)
}
}
override fun incLong(resourceID: Int) {
val value = getLong(resourceID, 0) + 1L
sharedPreferences.edit().putLong(context.getString(resourceID), value).apply()
}
override fun putBoolean(key: String, value: Boolean) = sharedPreferences.edit().putBoolean(key, value).apply()
override fun putBoolean(resourceID: Int, value: Boolean) =
sharedPreferences.edit().putBoolean(context.getString(resourceID), value).apply()
override fun putDouble(key: String, value: Double) =
sharedPreferences.edit().putString(key, value.toString()).apply()
override fun putDouble(resourceID: Int, value: Double) {
sharedPreferences.edit().putString(context.getString(resourceID), value.toString()).apply()
}
override fun putLong(key: String, value: Long) =
sharedPreferences.edit().putLong(key, value).apply()
override fun putLong(resourceID: Int, value: Long) =
sharedPreferences.edit().putLong(context.getString(resourceID), value).apply()
override fun putInt(key: String, value: Int) =
sharedPreferences.edit().putInt(key, value).apply()
override fun putInt(resourceID: Int, value: Int) =
sharedPreferences.edit().putInt(context.getString(resourceID), value).apply()
override fun incInt(resourceID: Int) {
val value = getInt(resourceID, 0) + 1
sharedPreferences.edit().putInt(context.getString(resourceID), value).apply()
}
override fun putString(resourceID: Int, value: String) =
sharedPreferences.edit().putString(context.getString(resourceID), value).apply()
override fun putString(key: String, value: String) =
sharedPreferences.edit().putString(key, value).apply()
}

View file

@ -0,0 +1,472 @@
package app.aaps.shared.impl.utils
import android.content.Context
import android.os.Build
import androidx.annotation.RequiresApi
import androidx.collection.LongSparseArray
import info.nightscout.annotations.OpenForTesting
import info.nightscout.interfaces.R
import info.nightscout.shared.SafeParse
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T
import org.apache.commons.lang3.time.DateUtils.isSameDay
import org.joda.time.DateTime
import org.joda.time.format.DateTimeFormat
import org.joda.time.format.ISODateTimeFormat
import java.security.SecureRandom
import java.text.DateFormat
import java.text.DecimalFormat
import java.text.DecimalFormatSymbols
import java.text.SimpleDateFormat
import java.time.Instant
import java.time.ZoneId
import java.time.ZoneOffset
import java.util.Calendar
import java.util.Date
import java.util.EnumSet
import java.util.GregorianCalendar
import java.util.Locale
import java.util.TimeZone
import java.util.concurrent.TimeUnit
import java.util.regex.Pattern
import java.util.stream.Collectors
import javax.inject.Inject
import javax.inject.Singleton
import kotlin.math.ceil
import kotlin.math.floor
/**
* The Class DateUtil. A simple wrapper around SimpleDateFormat to ease the handling of iso date string &lt;-&gt; date obj
* with TZ
*/
@OpenForTesting
@Singleton
class DateUtilImpl @Inject constructor(private val context: Context) : DateUtil {
/**
* The date format in iso.
*/
@Suppress("PrivatePropertyName", "SpellCheckingInspection")
private val FORMAT_DATE_ISO_OUT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
/**
* Takes in an ISO date string of the following format:
* yyyy-mm-ddThh:mm:ss.ms+HoMo
*
* @param isoDateString the iso date string
* @return the date
*/
override fun fromISODateString(isoDateString: String): Long {
val parser = ISODateTimeFormat.dateTimeParser()
val dateTime = DateTime.parse(isoDateString, parser)
return dateTime.toDate().time
}
/**
* Render date
*
* @param date the date obj
* @return the iso-formatted date string
*/
override fun toISOString(date: Long): String {
val f: DateFormat = SimpleDateFormat(FORMAT_DATE_ISO_OUT, Locale.getDefault())
f.timeZone = TimeZone.getTimeZone("UTC")
return f.format(date)
}
@Suppress("SpellCheckingInspection")
override fun toISOAsUTC(timestamp: Long): String {
val format = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'0000Z'", Locale.US)
format.timeZone = TimeZone.getTimeZone("UTC")
return format.format(timestamp)
}
@Suppress("SpellCheckingInspection")
override fun toISONoZone(timestamp: Long): String {
val format = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.US)
format.timeZone = TimeZone.getDefault()
return format.format(timestamp)
}
override fun secondsOfTheDayToMilliseconds(seconds: Int): Long {
val calendar: Calendar = GregorianCalendar()
calendar[Calendar.MONTH] = 0 // Set january to be sure we miss DST changing
calendar[Calendar.HOUR_OF_DAY] = seconds / 60 / 60
calendar[Calendar.MINUTE] = seconds / 60 % 60
calendar[Calendar.SECOND] = 0
return calendar.timeInMillis
}
override fun toSeconds(hhColonMm: String): Int {
val p = Pattern.compile("(\\d+):(\\d+)( a.m.| p.m.| AM| PM|AM|PM|)")
val m = p.matcher(hhColonMm)
var retVal = 0
if (m.find()) {
retVal = SafeParse.stringToInt(m.group(1)) * 60 * 60 + SafeParse.stringToInt(m.group(2)) * 60
if ((m.group(3) == " a.m." || m.group(3) == " AM" || m.group(3) == "AM") && m.group(1) == "12") retVal -= 12 * 60 * 60
if ((m.group(3) == " p.m." || m.group(3) == " PM" || m.group(3) == "PM") && m.group(1) != "12") retVal += 12 * 60 * 60
}
return retVal
}
override fun dateString(mills: Long): String {
val df = DateFormat.getDateInstance(DateFormat.SHORT)
return df.format(mills)
}
override fun dateStringRelative(mills: Long, rh: ResourceHelper): String {
val df = DateFormat.getDateInstance(DateFormat.SHORT)
val day = df.format(mills)
val beginOfToday = beginOfDay(now())
return if (mills < now()) // Past
when {
mills > beginOfToday -> rh.gs(R.string.today)
mills > beginOfToday - T.days(1).msecs() -> rh.gs(R.string.yesterday)
mills > beginOfToday - T.days(7).msecs() -> dayAgo(mills, rh, true)
else -> day
}
else // Future
when {
mills < beginOfToday + T.days(1).msecs() -> rh.gs(R.string.later_today)
mills < beginOfToday + T.days(2).msecs() -> rh.gs(R.string.tomorrow)
mills < beginOfToday + T.days(7).msecs() -> dayAgo(mills, rh, true)
else -> day
}
}
override fun dateStringShort(mills: Long): String {
var format = "MM/dd"
if (android.text.format.DateFormat.is24HourFormat(context)) {
format = "dd/MM"
}
return DateTime(mills).toString(DateTimeFormat.forPattern(format))
}
override fun timeString(): String = timeString(now())
override fun timeString(mills: Long): String {
var format = "hh:mma"
if (android.text.format.DateFormat.is24HourFormat(context)) {
format = "HH:mm"
}
return DateTime(mills).toString(DateTimeFormat.forPattern(format))
}
override fun secondString(): String = secondString(now())
override fun secondString(mills: Long): String =
DateTime(mills).toString(DateTimeFormat.forPattern("ss"))
override fun minuteString(): String = minuteString(now())
override fun minuteString(mills: Long): String =
DateTime(mills).toString(DateTimeFormat.forPattern("mm"))
override fun hourString(): String = hourString(now())
override fun hourString(mills: Long): String {
var format = "hh"
if (android.text.format.DateFormat.is24HourFormat(context)) {
format = "HH"
}
return DateTime(mills).toString(DateTimeFormat.forPattern(format))
}
override fun amPm(): String = amPm(now())
override fun amPm(mills: Long): String =
DateTime(mills).toString(DateTimeFormat.forPattern("a"))
override fun dayNameString(format: String): String = dayNameString(now(), format)
override fun dayNameString(mills: Long, format: String): String =
DateTime(mills).toString(DateTimeFormat.forPattern(format))
override fun dayString(): String = dayString(now())
override fun dayString(mills: Long): String =
DateTime(mills).toString(DateTimeFormat.forPattern("dd"))
override fun monthString(format: String): String = monthString(now(), format)
override fun monthString(mills: Long, format: String): String =
DateTime(mills).toString(DateTimeFormat.forPattern(format))
override fun weekString(): String = weekString(now())
override fun weekString(mills: Long): String =
DateTime(mills).toString(DateTimeFormat.forPattern("ww"))
override fun timeStringWithSeconds(mills: Long): String {
var format = "hh:mm:ssa"
if (android.text.format.DateFormat.is24HourFormat(context)) {
format = "HH:mm:ss"
}
return DateTime(mills).toString(DateTimeFormat.forPattern(format))
}
override fun dateAndTimeRangeString(start: Long, end: Long): String {
return dateAndTimeString(start) + " - " + timeString(end)
}
override fun timeRangeString(start: Long, end: Long): String {
return timeString(start) + " - " + timeString(end)
}
override fun dateAndTimeString(mills: Long): String {
return if (mills == 0L) "" else dateString(mills) + " " + timeString(mills)
}
override fun dateAndTimeAndSecondsString(mills: Long): String {
return if (mills == 0L) "" else dateString(mills) + " " + timeStringWithSeconds(mills)
}
override fun minAgo(rh: ResourceHelper, time: Long?): String {
if (time == null) return ""
val minutes = ((now() - time) / 1000 / 60).toInt()
return rh.gs(R.string.minago, minutes)
}
override fun minAgoShort(time: Long?): String {
if (time == null) return ""
val minutes = ((time - now()) / 1000 / 60).toInt()
return (if (minutes > 0) "+" else "") + minutes
}
override fun minAgoLong(rh: ResourceHelper, time: Long?): String {
if (time == null) return ""
val minutes = ((now() - time) / 1000 / 60).toInt()
return rh.gs(R.string.minago_long, minutes)
}
override fun hourAgo(time: Long, rh: ResourceHelper): String {
val hours = (now() - time) / 1000.0 / 60 / 60
return rh.gs(R.string.hoursago, hours)
}
override fun dayAgo(time: Long, rh: ResourceHelper, round: Boolean): String {
var days = (now() - time) / 1000.0 / 60 / 60 / 24
if (round) {
return if (now() > time) {
days = ceil(days)
rh.gs(R.string.days_ago_round, days)
} else {
days = floor(days)
rh.gs(R.string.in_days_round, days)
}
}
return if (now() > time)
rh.gs(R.string.days_ago, days)
else
rh.gs(R.string.in_days, days)
}
override fun beginOfDay(mills: Long): Long {
val givenDate = Calendar.getInstance()
givenDate.timeInMillis = mills
givenDate[Calendar.HOUR_OF_DAY] = 0
givenDate[Calendar.MINUTE] = 0
givenDate[Calendar.SECOND] = 0
givenDate[Calendar.MILLISECOND] = 0
return givenDate.timeInMillis
}
override fun timeStringFromSeconds(seconds: Int): String {
val cached = timeStrings[seconds.toLong()]
if (cached != null) return cached
val t = timeString(secondsOfTheDayToMilliseconds(seconds))
timeStrings.put(seconds.toLong(), t)
return t
}
override fun timeFrameString(timeInMillis: Long, rh: ResourceHelper): String {
var remainingTimeMinutes = timeInMillis / (1000 * 60)
val remainingTimeHours = remainingTimeMinutes / 60
remainingTimeMinutes %= 60
return "(" + (if (remainingTimeHours > 0) remainingTimeHours.toString() + rh.gs(R.string.shorthour) + " " else "") + remainingTimeMinutes + "')"
}
override fun sinceString(timestamp: Long, rh: ResourceHelper): String {
return timeFrameString(System.currentTimeMillis() - timestamp, rh)
}
override fun untilString(timestamp: Long, rh: ResourceHelper): String {
return timeFrameString(timestamp - System.currentTimeMillis(), rh)
}
override fun now(): Long {
return System.currentTimeMillis()
}
override fun nowWithoutMilliseconds(): Long {
var n = System.currentTimeMillis()
n -= n % 1000
return n
}
override fun isOlderThan(date: Long, minutes: Long): Boolean {
val diff = now() - date
return diff > T.mins(minutes).msecs()
}
override fun getTimeZoneOffsetMs(): Long {
return GregorianCalendar().timeZone.rawOffset.toLong()
}
override fun getTimeZoneOffsetMinutes(timestamp: Long): Int {
return TimeZone.getDefault().getOffset(timestamp) / 60000
}
override fun isSameDay(timestamp1: Long, timestamp2: Long) = isSameDay(Date(timestamp1), Date(timestamp2))
override fun isSameDayGroup(timestamp1: Long, timestamp2: Long): Boolean {
val now = now()
if (now in (timestamp1 + 1) until timestamp2 || now in (timestamp2 + 1) until timestamp1)
return false
return isSameDay(Date(timestamp1), Date(timestamp2))
}
//Map:{DAYS=1, HOURS=3, MINUTES=46, SECONDS=40, MILLISECONDS=0, MICROSECONDS=0, NANOSECONDS=0}
override fun computeDiff(date1: Long, date2: Long): Map<TimeUnit, Long> {
val units: MutableList<TimeUnit> = ArrayList(EnumSet.allOf(TimeUnit::class.java))
units.reverse()
val result: MutableMap<TimeUnit, Long> = LinkedHashMap()
var millisecondsRest = date2 - date1
for (unit in units) {
val diff = unit.convert(millisecondsRest, TimeUnit.MILLISECONDS)
val diffInMillisecondsForUnit = unit.toMillis(diff)
millisecondsRest -= diffInMillisecondsForUnit
result[unit] = diff
}
return result
}
override fun age(milliseconds: Long, useShortText: Boolean, rh: ResourceHelper): String {
val diff = computeDiff(0L, milliseconds)
var days = " " + rh.gs(R.string.days) + " "
var hours = " " + rh.gs(R.string.hours) + " "
var minutes = " " + rh.gs(R.string.unit_minutes) + " "
if (useShortText) {
days = rh.gs(R.string.shortday)
hours = rh.gs(R.string.shorthour)
minutes = rh.gs(R.string.shortminute)
}
var result = ""
if (diff.getOrDefault(TimeUnit.DAYS, -1) > 0) result += diff[TimeUnit.DAYS].toString() + days
if (diff.getOrDefault(TimeUnit.HOURS, -1) > 0) result += diff[TimeUnit.HOURS].toString() + hours
if (diff[TimeUnit.DAYS] == 0L) result += diff[TimeUnit.MINUTES].toString() + minutes
return result
}
override fun niceTimeScalar(time: Long, rh: ResourceHelper): String {
var t = time
var unit = rh.gs(R.string.unit_second)
t /= 1000
if (t != 1L) unit = rh.gs(R.string.unit_seconds)
if (t > 59) {
unit = rh.gs(R.string.unit_minute)
t /= 60
if (t != 1L) unit = rh.gs(R.string.unit_minutes)
if (t > 59) {
unit = rh.gs(R.string.unit_hour)
t /= 60
if (t != 1L) unit = rh.gs(R.string.unit_hours)
if (t > 24) {
unit = rh.gs(R.string.unit_day)
t /= 24
if (t != 1L) unit = rh.gs(R.string.unit_days)
if (t > 28) {
unit = rh.gs(R.string.unit_week)
t /= 7
@Suppress("KotlinConstantConditions")
if (t != 1L) unit = rh.gs(R.string.unit_weeks)
}
}
}
}
//if (t != 1) unit = unit + "s"; //implemented plurality in every step, because in other languages plurality of time is not every time adding the same character
return qs(t.toDouble(), 0) + " " + unit
}
override fun qs(x: Double, numDigits: Int): String {
var digits = numDigits
if (digits == -1) {
digits = 0
if ((x.toInt() % x == 0.0)) {
digits++
if ((x.toInt() * 10 / 10).toDouble() != x) {
digits++
if ((x.toInt() * 100 / 100).toDouble() != x) digits++
}
}
}
if (dfs == null) {
val localDfs = DecimalFormatSymbols()
localDfs.decimalSeparator = '.'
dfs = localDfs // avoid race condition
}
val thisDf: DecimalFormat?
// use singleton if on ui thread otherwise allocate new as DecimalFormat is not thread safe
if (Thread.currentThread().id == 1L) {
if (df == null) {
val localDf = DecimalFormat("#", dfs)
localDf.minimumIntegerDigits = 1
df = localDf // avoid race condition
}
thisDf = df
} else {
thisDf = DecimalFormat("#", dfs)
}
thisDf?.maximumFractionDigits = digits
return thisDf?.format(x) ?: ""
}
override fun formatHHMM(timeAsSeconds: Int): String {
val hour = timeAsSeconds / 60 / 60
val minutes = (timeAsSeconds - hour * 60 * 60) / 60
val df = DecimalFormat("00")
return df.format(hour.toLong()) + ":" + df.format(minutes.toLong())
}
@RequiresApi(Build.VERSION_CODES.O)
override fun timeZoneByOffset(offsetInMilliseconds: Long): TimeZone =
TimeZone.getTimeZone(
if (offsetInMilliseconds == 0L) ZoneId.of("UTC")
else ZoneId.getAvailableZoneIds()
.stream()
.map(ZoneId::of)
.filter { z -> z.rules.getOffset(Instant.now()).totalSeconds == ZoneOffset.ofHours((offsetInMilliseconds / 1000 / 3600).toInt()).totalSeconds }
.collect(Collectors.toList())
.firstOrNull() ?: ZoneId.of("UTC")
)
override fun timeStampToUtcDateMillis(timestamp: Long): Long {
val current = Calendar.getInstance().apply { timeInMillis = timestamp }
return Calendar.getInstance().apply {
set(Calendar.YEAR, current[Calendar.YEAR])
set(Calendar.MONTH, current[Calendar.MONTH])
set(Calendar.DAY_OF_MONTH, current[Calendar.DAY_OF_MONTH])
}.timeInMillis
}
override fun mergeUtcDateToTimestamp(timestamp: Long, dateUtcMillis: Long): Long {
val selected = Calendar.getInstance().apply { timeInMillis = dateUtcMillis }
return Calendar.getInstance().apply {
timeInMillis = timestamp
set(Calendar.YEAR, selected[Calendar.YEAR])
set(Calendar.MONTH, selected[Calendar.MONTH])
set(Calendar.DAY_OF_MONTH, selected[Calendar.DAY_OF_MONTH])
}.timeInMillis
}
override fun mergeHourMinuteToTimestamp(timestamp: Long, hour: Int, minute: Int, randomSecond: Boolean): Long {
return Calendar.getInstance().apply {
timeInMillis = timestamp
set(Calendar.HOUR_OF_DAY, hour)
set(Calendar.MINUTE, minute)
if (randomSecond) set(Calendar.SECOND, seconds++)
}.timeInMillis
}
companion object {
private val timeStrings = LongSparseArray<String>()
private var seconds: Int = (SecureRandom().nextDouble() * 59.0).toInt()
// singletons to avoid repeated allocation
private var dfs: DecimalFormatSymbols? = null
private var df: DecimalFormat? = null
}
}

Some files were not shown because too many files have changed in this diff Show more