remove PowerMockRunner where possible

This commit is contained in:
Milos Kozak 2021-09-21 21:57:56 +02:00
parent d43393e2af
commit d33f62b23d
82 changed files with 178 additions and 293 deletions

View file

@ -186,10 +186,10 @@ class SafetyPlugin @Inject constructor(
override fun applyMaxIOBConstraints(maxIob: Constraint<Double>): Constraint<Double> { override fun applyMaxIOBConstraints(maxIob: Constraint<Double>): Constraint<Double> {
val apsMode = sp.getString(R.string.key_aps_mode, "open") val apsMode = sp.getString(R.string.key_aps_mode, "open")
val maxIobPref: Double = if (openAPSSMBPlugin.isEnabled(PluginType.APS)) sp.getDouble(R.string.key_openapssmb_max_iob, 3.0) else sp.getDouble(R.string.key_openapsma_max_iob, 1.5) val maxIobPref: Double = if (openAPSSMBPlugin.isEnabled()) sp.getDouble(R.string.key_openapssmb_max_iob, 3.0) else sp.getDouble(R.string.key_openapsma_max_iob, 1.5)
maxIob.setIfSmaller(aapsLogger, maxIobPref, String.format(resourceHelper.gs(R.string.limitingiob), maxIobPref, resourceHelper.gs(R.string.maxvalueinpreferences)), this) maxIob.setIfSmaller(aapsLogger, maxIobPref, String.format(resourceHelper.gs(R.string.limitingiob), maxIobPref, resourceHelper.gs(R.string.maxvalueinpreferences)), this)
if (openAPSAMAPlugin.isEnabled(PluginType.APS)) maxIob.setIfSmaller(aapsLogger, hardLimits.maxIobAMA(), String.format(resourceHelper.gs(R.string.limitingiob), hardLimits.maxIobAMA(), resourceHelper.gs(R.string.hardlimit)), this) if (openAPSAMAPlugin.isEnabled()) maxIob.setIfSmaller(aapsLogger, hardLimits.maxIobAMA(), String.format(resourceHelper.gs(R.string.limitingiob), hardLimits.maxIobAMA(), resourceHelper.gs(R.string.hardlimit)), this)
if (openAPSSMBPlugin.isEnabled(PluginType.APS)) maxIob.setIfSmaller(aapsLogger, hardLimits.maxIobSMB(), String.format(resourceHelper.gs(R.string.limitingiob), hardLimits.maxIobSMB(), resourceHelper.gs(R.string.hardlimit)), this) if (openAPSSMBPlugin.isEnabled()) maxIob.setIfSmaller(aapsLogger, hardLimits.maxIobSMB(), String.format(resourceHelper.gs(R.string.limitingiob), hardLimits.maxIobSMB(), resourceHelper.gs(R.string.hardlimit)), this)
if (apsMode == "lgs") maxIob.setIfSmaller(aapsLogger, HardLimits.MAX_IOB_LGS, String.format(resourceHelper.gs(R.string.limitingiob), HardLimits.MAX_IOB_LGS, resourceHelper.gs(R.string.lowglucosesuspend)), this) if (apsMode == "lgs") maxIob.setIfSmaller(aapsLogger, HardLimits.MAX_IOB_LGS, String.format(resourceHelper.gs(R.string.limitingiob), HardLimits.MAX_IOB_LGS, resourceHelper.gs(R.string.lowglucosesuspend)), this)
return maxIob return maxIob
} }

View file

@ -1,6 +1,7 @@
package info.nightscout.androidaps.plugins.general.maintenance package info.nightscout.androidaps.plugins.general.maintenance
import ch.qos.logback.classic.LoggerContext import ch.qos.logback.classic.LoggerContext
import info.nightscout.androidaps.annotations.OpenForTesting
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@ -8,6 +9,7 @@ import javax.inject.Singleton
/** /**
* This class provides several methods for log-handling (eg. sending logs as emails). * This class provides several methods for log-handling (eg. sending logs as emails).
*/ */
@OpenForTesting
@Singleton @Singleton
class LoggerUtils @Inject constructor() { class LoggerUtils @Inject constructor() {

View file

@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.general.nsclient.data
import android.content.Context import android.content.Context
import info.nightscout.androidaps.interfaces.Config import info.nightscout.androidaps.interfaces.Config
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.database.entities.UserEntry
import info.nightscout.androidaps.database.entities.UserEntry.Action import info.nightscout.androidaps.database.entities.UserEntry.Action
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
@ -113,6 +114,7 @@ import javax.inject.Singleton
} }
*/ */
@Suppress("SpellCheckingInspection") @Suppress("SpellCheckingInspection")
@OpenForTesting
@Singleton @Singleton
class NSSettingsStatus @Inject constructor( class NSSettingsStatus @Inject constructor(
private val aapsLogger: AAPSLogger, private val aapsLogger: AAPSLogger,

View file

@ -13,6 +13,7 @@ import androidx.work.workDataOf
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.Constants import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.data.DetailedBolusInfo import info.nightscout.androidaps.data.DetailedBolusInfo
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.OfflineEvent import info.nightscout.androidaps.database.entities.OfflineEvent
@ -59,6 +60,7 @@ import javax.inject.Singleton
import kotlin.math.max import kotlin.math.max
import kotlin.math.min import kotlin.math.min
@OpenForTesting
@Singleton @Singleton
class SmsCommunicatorPlugin @Inject constructor( class SmsCommunicatorPlugin @Inject constructor(
injector: HasAndroidInjector, injector: HasAndroidInjector,

View file

@ -5,6 +5,7 @@ import com.eatthepath.otp.HmacOneTimePasswordGenerator
import com.google.common.io.BaseEncoding import com.google.common.io.BaseEncoding
import info.nightscout.androidaps.Constants import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP import info.nightscout.androidaps.utils.sharedPreferences.SP
@ -15,6 +16,7 @@ import javax.crypto.spec.SecretKeySpec
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@OpenForTesting
@Singleton @Singleton
class OneTimePassword @Inject constructor( class OneTimePassword @Inject constructor(
private val sp: SP, private val sp: SP,

View file

@ -8,6 +8,7 @@ import androidx.work.workDataOf
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.Constants import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.data.ProfileSealed import info.nightscout.androidaps.data.ProfileSealed
import info.nightscout.androidaps.data.PureProfile import info.nightscout.androidaps.data.PureProfile
import info.nightscout.androidaps.events.EventProfileStoreChanged import info.nightscout.androidaps.events.EventProfileStoreChanged
@ -35,6 +36,7 @@ import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
import kotlin.collections.ArrayList import kotlin.collections.ArrayList
@OpenForTesting
@Singleton @Singleton
class LocalProfilePlugin @Inject constructor( class LocalProfilePlugin @Inject constructor(
injector: HasAndroidInjector, injector: HasAndroidInjector,

View file

@ -6,6 +6,7 @@ import androidx.work.WorkerParameters
import androidx.work.workDataOf import androidx.work.workDataOf
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.GlucoseValue import info.nightscout.androidaps.database.entities.GlucoseValue
import info.nightscout.androidaps.database.transactions.CgmSourceTransaction import info.nightscout.androidaps.database.transactions.CgmSourceTransaction
@ -21,6 +22,7 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@OpenForTesting
@Singleton @Singleton
class GlimpPlugin @Inject constructor( class GlimpPlugin @Inject constructor(
injector: HasAndroidInjector, injector: HasAndroidInjector,

View file

@ -1,10 +1,12 @@
package info.nightscout.androidaps.utils package info.nightscout.androidaps.utils
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@OpenForTesting
@Singleton @Singleton
class Profiler @Inject constructor(val aapsLogger: AAPSLogger) { class Profiler @Inject constructor(val aapsLogger: AAPSLogger) {

View file

@ -4,6 +4,7 @@ import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.interfaces.GlucoseUnit import info.nightscout.androidaps.interfaces.GlucoseUnit
import info.nightscout.androidaps.interfaces.ProfileFunction import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
@ -12,6 +13,7 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@OpenForTesting
@Singleton @Singleton
class XdripCalibrations @Inject constructor( class XdripCalibrations @Inject constructor(
private val aapsLogger: AAPSLogger, private val aapsLogger: AAPSLogger,

View file

@ -1,12 +1,14 @@
package info.nightscout.androidaps.utils.buildHelper package info.nightscout.androidaps.utils.buildHelper
import info.nightscout.androidaps.BuildConfig import info.nightscout.androidaps.BuildConfig
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.interfaces.Config import info.nightscout.androidaps.interfaces.Config
import info.nightscout.androidaps.plugins.general.maintenance.PrefFileListProvider import info.nightscout.androidaps.plugins.general.maintenance.PrefFileListProvider
import java.io.File import java.io.File
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@OpenForTesting
@Singleton @Singleton
class BuildHelper @Inject constructor( class BuildHelper @Inject constructor(
private val config: Config, private val config: Config,

View file

@ -15,7 +15,6 @@ import org.junit.Before
import org.junit.Test import org.junit.Test
import org.mockito.Mock import org.mockito.Mock
import org.mockito.Mockito.`when` import org.mockito.Mockito.`when`
import org.powermock.api.mockito.PowerMockito
class QuickWizardTest : TestBase() { class QuickWizardTest : TestBase() {
@ -44,7 +43,7 @@ class QuickWizardTest : TestBase() {
@Before @Before
fun mock() { fun mock() {
PowerMockito.`when`(profileFunction.secondsFromMidnight()).thenReturn(0) `when`(profileFunction.secondsFromMidnight()).thenReturn(0)
`when`(sp.getString(R.string.key_quickwizard, "[]")).thenReturn("[]") `when`(sp.getString(R.string.key_quickwizard, "[]")).thenReturn("[]")
quickWizard = QuickWizard(sp, injector) quickWizard = QuickWizard(sp, injector)
} }

View file

@ -1,6 +1,5 @@
package info.nightscout.androidaps.interfaces package info.nightscout.androidaps.interfaces
import android.content.Context
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
@ -36,22 +35,13 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mock import org.mockito.Mock
import org.mockito.Mockito.`when` import org.mockito.Mockito.`when`
import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.junit4.PowerMockRunner
import java.util.* import java.util.*
/** /**
* Created by mike on 18.03.2018. * Created by mike on 18.03.2018.
*/ */
@RunWith(PowerMockRunner::class)
@PrepareForTest(
ConstraintChecker::class, SP::class, Context::class,
OpenAPSAMAPlugin::class, OpenAPSSMBPlugin::class,
VirtualPumpPlugin::class, DetailedBolusInfoStorage::class, TemporaryBasalStorage::class, GlimpPlugin::class, Profiler::class,
UserEntryLogger::class, PrefFileListProvider::class, AppRepository::class, InsightDatabaseDao::class)
class ConstraintsCheckerTest : TestBaseWithProfile() { class ConstraintsCheckerTest : TestBaseWithProfile() {
@Mock lateinit var activePlugin: ActivePlugin @Mock lateinit var activePlugin: ActivePlugin
@ -98,7 +88,6 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
fun prepare() { fun prepare() {
`when`(resourceHelper.gs(R.string.closed_loop_disabled_on_dev_branch)).thenReturn("Running dev version. Closed loop is disabled.") `when`(resourceHelper.gs(R.string.closed_loop_disabled_on_dev_branch)).thenReturn("Running dev version. Closed loop is disabled.")
`when`(resourceHelper.gs(R.string.closedmodedisabledinpreferences)).thenReturn("Closed loop mode disabled in preferences") `when`(resourceHelper.gs(R.string.closedmodedisabledinpreferences)).thenReturn("Closed loop mode disabled in preferences")
`when`(resourceHelper.gs(R.string.objectivenotstarted)).thenReturn("Objective %d not started")
`when`(resourceHelper.gs(R.string.novalidbasalrate)).thenReturn("No valid basal rate read from pump") `when`(resourceHelper.gs(R.string.novalidbasalrate)).thenReturn("No valid basal rate read from pump")
`when`(resourceHelper.gs(R.string.autosensdisabledinpreferences)).thenReturn("Autosens disabled in preferences") `when`(resourceHelper.gs(R.string.autosensdisabledinpreferences)).thenReturn("Autosens disabled in preferences")
`when`(resourceHelper.gs(R.string.smbdisabledinpreferences)).thenReturn("SMB disabled in preferences") `when`(resourceHelper.gs(R.string.smbdisabledinpreferences)).thenReturn("SMB disabled in preferences")
@ -125,6 +114,10 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
`when`(resourceHelper.gs(R.string.limitingbasalratio, 0.8, "pump limit")).thenReturn("") `when`(resourceHelper.gs(R.string.limitingbasalratio, 0.8, "pump limit")).thenReturn("")
`when`(resourceHelper.gs(R.string.limitingpercentrate, 200, "pump limit")).thenReturn("") `when`(resourceHelper.gs(R.string.limitingpercentrate, 200, "pump limit")).thenReturn("")
`when`(resourceHelper.gs(R.string.combo_pump_unsupported_operation)).thenReturn("Requested operation not supported by pump") `when`(resourceHelper.gs(R.string.combo_pump_unsupported_operation)).thenReturn("Requested operation not supported by pump")
`when`(resourceHelper.gs(R.string.objectivenotstarted, 9)).thenReturn("Objective 9 not started")
`when`(resourceHelper.gs(R.string.objectivenotstarted, 8)).thenReturn("Objective 8 not started")
`when`(resourceHelper.gs(R.string.objectivenotstarted, 6)).thenReturn("Objective 6 not started")
`when`(resourceHelper.gs(R.string.objectivenotstarted, 1)).thenReturn("Objective 1 not started")
// RS constructor // RS constructor
`when`(sp.getString(R.string.key_danars_address, "")).thenReturn("") `when`(sp.getString(R.string.key_danars_address, "")).thenReturn("")

View file

@ -11,14 +11,11 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mock import org.mockito.Mock
import org.powermock.modules.junit4.PowerMockRunner
import java.text.DateFormat import java.text.DateFormat
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.* import java.util.*
@RunWith(PowerMockRunner::class)
class DstHelperPluginTest : TestBase() { class DstHelperPluginTest : TestBase() {
@Mock lateinit var resourceHelper: ResourceHelper @Mock lateinit var resourceHelper: ResourceHelper

View file

@ -2,7 +2,6 @@ package info.nightscout.androidaps.plugins.constraints.objectives
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.utils.buildHelper.ConfigImpl
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.TestBase
import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.ActivePlugin
@ -10,19 +9,15 @@ import info.nightscout.androidaps.interfaces.Constraint
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective
import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.buildHelper.ConfigImpl
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP import info.nightscout.androidaps.utils.sharedPreferences.SP
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mock import org.mockito.Mock
import org.mockito.Mockito.`when` import org.mockito.Mockito.`when`
import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.junit4.PowerMockRunner
@RunWith(PowerMockRunner::class)
@PrepareForTest(UserEntryLogger::class, DateUtil::class)
class ObjectivesPluginTest : TestBase() { class ObjectivesPluginTest : TestBase() {
@Mock lateinit var resourceHelper: ResourceHelper @Mock lateinit var resourceHelper: ResourceHelper
@ -46,7 +41,10 @@ class ObjectivesPluginTest : TestBase() {
@Before fun prepareMock() { @Before fun prepareMock() {
objectivesPlugin = ObjectivesPlugin(injector, aapsLogger, resourceHelper, activePlugin, sp, ConfigImpl(), dateUtil, uel) objectivesPlugin = ObjectivesPlugin(injector, aapsLogger, resourceHelper, activePlugin, sp, ConfigImpl(), dateUtil, uel)
objectivesPlugin.onStart() objectivesPlugin.onStart()
`when`(resourceHelper.gs(R.string.objectivenotstarted)).thenReturn("Objective %1\$d not started") `when`(resourceHelper.gs(R.string.objectivenotstarted, 9)).thenReturn("Objective 9 not started")
`when`(resourceHelper.gs(R.string.objectivenotstarted, 8)).thenReturn("Objective 8 not started")
`when`(resourceHelper.gs(R.string.objectivenotstarted, 6)).thenReturn("Objective 6 not started")
`when`(resourceHelper.gs(R.string.objectivenotstarted, 1)).thenReturn("Objective 1 not started")
} }
@Test fun notStartedObjectivesShouldLimitLoopInvocation() { @Test fun notStartedObjectivesShouldLimitLoopInvocation() {
@ -78,7 +76,7 @@ class ObjectivesPluginTest : TestBase() {
objectivesPlugin.objectives[ObjectivesPlugin.SMB_OBJECTIVE].startedOn = 0 objectivesPlugin.objectives[ObjectivesPlugin.SMB_OBJECTIVE].startedOn = 0
var c = Constraint(true) var c = Constraint(true)
c = objectivesPlugin.isSMBModeEnabled(c) c = objectivesPlugin.isSMBModeEnabled(c)
Assert.assertEquals(true, c.getReasons(aapsLogger).contains("Objective 10 not started")) Assert.assertEquals(true, c.getReasons(aapsLogger).contains("Objective 9 not started"))
Assert.assertEquals(false, c.value()) Assert.assertEquals(false, c.value())
} }
} }

View file

@ -2,7 +2,6 @@ package info.nightscout.androidaps.plugins.constraints.safety
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.utils.buildHelper.ConfigImpl
import info.nightscout.androidaps.Constants import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.TestBaseWithProfile import info.nightscout.androidaps.TestBaseWithProfile
@ -18,18 +17,14 @@ import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin
import info.nightscout.androidaps.plugins.source.GlimpPlugin import info.nightscout.androidaps.plugins.source.GlimpPlugin
import info.nightscout.androidaps.utils.HardLimits import info.nightscout.androidaps.utils.HardLimits
import info.nightscout.androidaps.utils.buildHelper.BuildHelper import info.nightscout.androidaps.utils.buildHelper.BuildHelper
import info.nightscout.androidaps.utils.buildHelper.ConfigImpl
import info.nightscout.androidaps.utils.sharedPreferences.SP import info.nightscout.androidaps.utils.sharedPreferences.SP
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mock import org.mockito.Mock
import org.mockito.Mockito.`when` import org.mockito.Mockito.`when`
import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.junit4.PowerMockRunner
@RunWith(PowerMockRunner::class)
@PrepareForTest(ConstraintChecker::class, BuildHelper::class, VirtualPumpPlugin::class, GlimpPlugin::class)
class SafetyPluginTest : TestBaseWithProfile() { class SafetyPluginTest : TestBaseWithProfile() {
@Mock lateinit var sp: SP @Mock lateinit var sp: SP
@ -231,17 +226,18 @@ class SafetyPluginTest : TestBaseWithProfile() {
} }
@Test fun iobShouldBeLimited() { @Test fun iobShouldBeLimited() {
`when`(openAPSSMBPlugin.isEnabled()).thenReturn(true)
`when`(openAPSAMAPlugin.isEnabled()).thenReturn(false)
`when`(sp.getString(R.string.key_aps_mode, "open")).thenReturn("closed") `when`(sp.getString(R.string.key_aps_mode, "open")).thenReturn("closed")
`when`(sp.getDouble(R.string.key_openapsma_max_iob, 1.5)).thenReturn(1.5) `when`(sp.getDouble(R.string.key_openapsma_max_iob, 1.5)).thenReturn(1.5)
`when`(sp.getDouble(R.string.key_openapssmb_max_iob, 3.0)).thenReturn(3.0)
`when`(sp.getString(R.string.key_age, "")).thenReturn("teenage") `when`(sp.getString(R.string.key_age, "")).thenReturn("teenage")
// Apply all limits // Apply all limits
var d = Constraint(Constants.REALLYHIGHIOB) var d = Constraint(Constants.REALLYHIGHIOB)
d = safetyPlugin.applyMaxIOBConstraints(d) d = safetyPlugin.applyMaxIOBConstraints(d)
Assert.assertEquals(1.5, d.value(), 0.01) Assert.assertEquals(3.0, d.value(), 0.01)
Assert.assertEquals(""" Assert.assertEquals("Safety: Limiting IOB to 3.0 U because of max value in preferences\nSafety: Limiting IOB to 12.0 U because of hard limit", d.getReasons(aapsLogger))
Safety: Limiting IOB to 1.5 U because of max value in preferences Assert.assertEquals("Safety: Limiting IOB to 3.0 U because of max value in preferences", d.getMostLimitedReasons(aapsLogger))
""".trimIndent(), d.getReasons(aapsLogger))
Assert.assertEquals("Safety: Limiting IOB to 1.5 U because of max value in preferences", d.getMostLimitedReasons(aapsLogger))
} }
} }

View file

@ -10,14 +10,11 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mock import org.mockito.Mock
import org.mockito.Mockito.`when` import org.mockito.Mockito.`when`
import org.mockito.Mockito.anyInt import org.mockito.Mockito.anyInt
import org.mockito.Mockito.anyLong import org.mockito.Mockito.anyLong
import org.powermock.modules.junit4.PowerMockRunner
@RunWith(PowerMockRunner::class)
class StorageConstraintPluginTest : TestBase() { class StorageConstraintPluginTest : TestBase() {
@Mock lateinit var resourceHelper: ResourceHelper @Mock lateinit var resourceHelper: ResourceHelper

View file

@ -2,24 +2,19 @@ package info.nightscout.androidaps.plugins.general.maintenance
import android.content.Context import android.content.Context
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.utils.buildHelper.ConfigImpl
import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.TestBase
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus
import info.nightscout.androidaps.utils.buildHelper.BuildHelper import info.nightscout.androidaps.utils.buildHelper.BuildHelper
import info.nightscout.androidaps.utils.buildHelper.ConfigImpl
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP import info.nightscout.androidaps.utils.sharedPreferences.SP
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mock import org.mockito.Mock
import org.mockito.Mockito.`when` import org.mockito.Mockito.`when`
import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.junit4.PowerMockRunner
import java.io.File import java.io.File
@RunWith(PowerMockRunner::class)
@PrepareForTest(NSSettingsStatus::class, BuildHelper::class, LoggerUtils::class, PrefFileListProvider::class)
class MaintenancePluginTest : TestBase() { class MaintenancePluginTest : TestBase() {
@Mock lateinit var injector: HasAndroidInjector @Mock lateinit var injector: HasAndroidInjector

View file

@ -12,19 +12,13 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentMatchers.anyBoolean import org.mockito.ArgumentMatchers.anyBoolean
import org.mockito.ArgumentMatchers.anyInt import org.mockito.ArgumentMatchers.anyInt
import org.mockito.ArgumentMatchers.anyLong import org.mockito.ArgumentMatchers.anyLong
import org.mockito.ArgumentMatchers.anyString import org.mockito.ArgumentMatchers.anyString
import org.mockito.Mock import org.mockito.Mock
import org.mockito.Mockito.`when` import org.mockito.Mockito.`when`
import org.powermock.api.mockito.PowerMockito
import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.junit4.PowerMockRunner
@RunWith(PowerMockRunner::class)
@PrepareForTest(SP::class, Context::class)
class NsClientReceiverDelegateTest : TestBase() { class NsClientReceiverDelegateTest : TestBase() {
@Mock lateinit var context: Context @Mock lateinit var context: Context
@ -47,7 +41,6 @@ class NsClientReceiverDelegateTest : TestBase() {
} }
@Test fun testCalculateStatusChargingState() { @Test fun testCalculateStatusChargingState() {
PowerMockito.mockStatic(SP::class.java)
`when`(sp.getBoolean(anyInt(), anyBoolean())).thenReturn(false) `when`(sp.getBoolean(anyInt(), anyBoolean())).thenReturn(false)
var ev = EventChargingState(true, 0) var ev = EventChargingState(true, 0)
Assert.assertTrue(sut!!.calculateStatus(ev)) Assert.assertTrue(sut!!.calculateStatus(ev))
@ -61,7 +54,6 @@ class NsClientReceiverDelegateTest : TestBase() {
} }
@Test fun testCalculateStatusNetworkState() { @Test fun testCalculateStatusNetworkState() {
PowerMockito.mockStatic(SP::class.java)
// wifiOnly = false // wifiOnly = false
// allowRoaming = false as well // allowRoaming = false as well
`when`(sp.getBoolean(anyInt(), anyBoolean())).thenReturn(false) `when`(sp.getBoolean(anyInt(), anyBoolean())).thenReturn(false)

View file

@ -13,17 +13,12 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mock import org.mockito.Mock
import org.mockito.Mockito.`when` import org.mockito.Mockito.`when`
import org.mockito.Mockito.doAnswer
import org.mockito.invocation.InvocationOnMock import org.mockito.invocation.InvocationOnMock
import org.mockito.stubbing.Answer import org.mockito.stubbing.Answer
import org.powermock.api.mockito.PowerMockito
import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.junit4.PowerMockRunner
@RunWith(PowerMockRunner::class)
@PrepareForTest(SmsCommunicatorPlugin::class, DateUtil::class, OneTimePassword::class)
class AuthRequestTest : TestBase() { class AuthRequestTest : TestBase() {
@Mock lateinit var smsCommunicatorPlugin: SmsCommunicatorPlugin @Mock lateinit var smsCommunicatorPlugin: SmsCommunicatorPlugin
@ -48,7 +43,7 @@ class AuthRequestTest : TestBase() {
@Before fun prepareTests() { @Before fun prepareTests() {
`when`(resourceHelper.gs(R.string.sms_wrongcode)).thenReturn("Wrong code. Command cancelled.") `when`(resourceHelper.gs(R.string.sms_wrongcode)).thenReturn("Wrong code. Command cancelled.")
PowerMockito.doAnswer(Answer { invocation: InvocationOnMock -> doAnswer(Answer { invocation: InvocationOnMock ->
sentSms = invocation.getArgument(0) sentSms = invocation.getArgument(0)
null null
} as Answer<*>).`when`(smsCommunicatorPlugin).sendSMS(anyObject()) } as Answer<*>).`when`(smsCommunicatorPlugin).sendSMS(anyObject())
@ -87,11 +82,10 @@ class AuthRequestTest : TestBase() {
// test timed out message // test timed out message
val now: Long = 10000 val now: Long = 10000
PowerMockito.mockStatic(DateUtil::class.java) `when`(dateUtil.now()).thenReturn(now)
PowerMockito.`when`(dateUtil.now()).thenReturn(now)
authRequest = AuthRequest(injector, requester, "Request text", "ABC", action) authRequest = AuthRequest(injector, requester, "Request text", "ABC", action)
actionCalled = false actionCalled = false
PowerMockito.`when`(dateUtil.now()).thenReturn(now + T.mins(Constants.SMS_CONFIRM_TIMEOUT).msecs() + 1) `when`(dateUtil.now()).thenReturn(now + T.mins(Constants.SMS_CONFIRM_TIMEOUT).msecs() + 1)
authRequest.action("ABC") authRequest.action("ABC")
Assert.assertFalse(actionCalled) Assert.assertFalse(actionCalled)
} }

View file

@ -2,10 +2,7 @@ package info.nightscout.androidaps.plugins.general.smsCommunicator
import org.junit.Assert import org.junit.Assert
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith
import org.powermock.modules.junit4.PowerMockRunner
@RunWith(PowerMockRunner::class)
class SmsActionTest { class SmsActionTest {
var result = "" var result = ""

View file

@ -52,6 +52,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.junit4.PowerMockRunner import org.powermock.modules.junit4.PowerMockRunner
import java.util.* import java.util.*
// Powermock needed to mock SmsManager
@RunWith(PowerMockRunner::class) @RunWith(PowerMockRunner::class)
@PrepareForTest( @PrepareForTest(
ConstraintChecker::class, FabricPrivacy::class, VirtualPumpPlugin::class, XdripCalibrations::class, ConstraintChecker::class, FabricPrivacy::class, VirtualPumpPlugin::class, XdripCalibrations::class,
@ -310,7 +311,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
`when`(sp.getBoolean(R.string.key_smscommunicator_remotecommandsallowed, false)).thenReturn(true) `when`(sp.getBoolean(R.string.key_smscommunicator_remotecommandsallowed, false)).thenReturn(true)
//LOOP STATUS : disabled //LOOP STATUS : disabled
PowerMockito.`when`(loopPlugin.enabled).thenReturn(false) `when`(loopPlugin.enabled).thenReturn(false)
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
sms = Sms("1234", "LOOP STATUS") sms = Sms("1234", "LOOP STATUS")
smsCommunicatorPlugin.processSms(sms) smsCommunicatorPlugin.processSms(sms)
@ -318,9 +319,9 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
Assert.assertEquals("Loop is disabled", smsCommunicatorPlugin.messages[1].text) Assert.assertEquals("Loop is disabled", smsCommunicatorPlugin.messages[1].text)
//LOOP STATUS : suspended //LOOP STATUS : suspended
PowerMockito.`when`(loopPlugin.minutesToEndOfSuspend()).thenReturn(10) `when`(loopPlugin.minutesToEndOfSuspend()).thenReturn(10)
PowerMockito.`when`(loopPlugin.enabled).thenReturn(true) `when`(loopPlugin.enabled).thenReturn(true)
PowerMockito.`when`(loopPlugin.isSuspended).thenReturn(true) `when`(loopPlugin.isSuspended).thenReturn(true)
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
sms = Sms("1234", "LOOP STATUS") sms = Sms("1234", "LOOP STATUS")
smsCommunicatorPlugin.processSms(sms) smsCommunicatorPlugin.processSms(sms)
@ -328,8 +329,8 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
Assert.assertEquals("Suspended (10 m)", smsCommunicatorPlugin.messages[1].text) Assert.assertEquals("Suspended (10 m)", smsCommunicatorPlugin.messages[1].text)
//LOOP STATUS : enabled //LOOP STATUS : enabled
PowerMockito.`when`(loopPlugin.enabled).thenReturn(true) `when`(loopPlugin.enabled).thenReturn(true)
PowerMockito.`when`(loopPlugin.isSuspended).thenReturn(false) `when`(loopPlugin.isSuspended).thenReturn(false)
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
sms = Sms("1234", "LOOP STATUS") sms = Sms("1234", "LOOP STATUS")
smsCommunicatorPlugin.processSms(sms) smsCommunicatorPlugin.processSms(sms)
@ -338,7 +339,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
Assert.assertEquals("Loop is enabled", smsCommunicatorPlugin.messages[1].text) Assert.assertEquals("Loop is enabled", smsCommunicatorPlugin.messages[1].text)
//LOOP : wrong format //LOOP : wrong format
PowerMockito.`when`(loopPlugin.enabled).thenReturn(true) `when`(loopPlugin.enabled).thenReturn(true)
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
sms = Sms("1234", "LOOP") sms = Sms("1234", "LOOP")
smsCommunicatorPlugin.processSms(sms) smsCommunicatorPlugin.processSms(sms)
@ -347,7 +348,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.messages[1].text) Assert.assertEquals("Wrong format", smsCommunicatorPlugin.messages[1].text)
//LOOP DISABLE : already disabled //LOOP DISABLE : already disabled
PowerMockito.`when`(loopPlugin.enabled).thenReturn(false) `when`(loopPlugin.enabled).thenReturn(false)
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
sms = Sms("1234", "LOOP DISABLE") sms = Sms("1234", "LOOP DISABLE")
smsCommunicatorPlugin.processSms(sms) smsCommunicatorPlugin.processSms(sms)
@ -357,7 +358,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
//LOOP DISABLE : from enabled //LOOP DISABLE : from enabled
hasBeenRun = false hasBeenRun = false
PowerMockito.`when`(loopPlugin.enabled).thenReturn(true) `when`(loopPlugin.enabled).thenReturn(true)
// PowerMockito.doAnswer(Answer { // PowerMockito.doAnswer(Answer {
// hasBeenRun = true // hasBeenRun = true
// null // null
@ -375,7 +376,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
//Assert.assertTrue(hasBeenRun) //Assert.assertTrue(hasBeenRun)
//LOOP ENABLE : already enabled //LOOP ENABLE : already enabled
PowerMockito.`when`(loopPlugin.enabled).thenReturn(true) `when`(loopPlugin.enabled).thenReturn(true)
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
sms = Sms("1234", "LOOP ENABLE") sms = Sms("1234", "LOOP ENABLE")
smsCommunicatorPlugin.processSms(sms) smsCommunicatorPlugin.processSms(sms)
@ -385,7 +386,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
//LOOP ENABLE : from disabled //LOOP ENABLE : from disabled
hasBeenRun = false hasBeenRun = false
PowerMockito.`when`(loopPlugin.enabled).thenReturn(false) `when`(loopPlugin.enabled).thenReturn(false)
// PowerMockito.doAnswer(Answer { // PowerMockito.doAnswer(Answer {
// hasBeenRun = true // hasBeenRun = true
// null // null
@ -479,8 +480,8 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.messages[1].text) Assert.assertEquals("Wrong format", smsCommunicatorPlugin.messages[1].text)
//NSCLIENT RESTART //NSCLIENT RESTART
PowerMockito.`when`(loopPlugin.isEnabled(PluginType.LOOP)).thenReturn(true) `when`(loopPlugin.isEnabled(PluginType.LOOP)).thenReturn(true)
PowerMockito.`when`(loopPlugin.isSuspended).thenReturn(false) `when`(loopPlugin.isSuspended).thenReturn(false)
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
sms = Sms("1234", "NSCLIENT RESTART") sms = Sms("1234", "NSCLIENT RESTART")
smsCommunicatorPlugin.processSms(sms) smsCommunicatorPlugin.processSms(sms)
@ -489,8 +490,8 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
Assert.assertTrue(smsCommunicatorPlugin.messages[1].text.contains("NSCLIENT RESTART")) Assert.assertTrue(smsCommunicatorPlugin.messages[1].text.contains("NSCLIENT RESTART"))
//NSCLIENT BLA BLA //NSCLIENT BLA BLA
PowerMockito.`when`(loopPlugin.isEnabled(PluginType.LOOP)).thenReturn(true) `when`(loopPlugin.isEnabled(PluginType.LOOP)).thenReturn(true)
PowerMockito.`when`(loopPlugin.isSuspended).thenReturn(false) `when`(loopPlugin.isSuspended).thenReturn(false)
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
sms = Sms("1234", "NSCLIENT BLA BLA") sms = Sms("1234", "NSCLIENT BLA BLA")
smsCommunicatorPlugin.processSms(sms) smsCommunicatorPlugin.processSms(sms)
@ -499,8 +500,8 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.messages[1].text) Assert.assertEquals("Wrong format", smsCommunicatorPlugin.messages[1].text)
//NSCLIENT BLABLA //NSCLIENT BLABLA
PowerMockito.`when`(loopPlugin.isEnabled(PluginType.LOOP)).thenReturn(true) `when`(loopPlugin.isEnabled(PluginType.LOOP)).thenReturn(true)
PowerMockito.`when`(loopPlugin.isSuspended).thenReturn(false) `when`(loopPlugin.isSuspended).thenReturn(false)
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
sms = Sms("1234", "NSCLIENT BLABLA") sms = Sms("1234", "NSCLIENT BLABLA")
smsCommunicatorPlugin.processSms(sms) smsCommunicatorPlugin.processSms(sms)
@ -536,7 +537,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
repository.runTransactionForResult(anyObject<Transaction<CancelCurrentOfflineEventIfAnyTransaction.TransactionResult>>()) repository.runTransactionForResult(anyObject<Transaction<CancelCurrentOfflineEventIfAnyTransaction.TransactionResult>>())
).thenReturn(Single.just(CancelCurrentOfflineEventIfAnyTransaction.TransactionResult().apply { ).thenReturn(Single.just(CancelCurrentOfflineEventIfAnyTransaction.TransactionResult().apply {
})) }))
PowerMockito.`when`(loopPlugin.enabled).thenReturn(true) `when`(loopPlugin.enabled).thenReturn(true)
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
sms = Sms("1234", "PUMP CONNECT") sms = Sms("1234", "PUMP CONNECT")
smsCommunicatorPlugin.processSms(sms) smsCommunicatorPlugin.processSms(sms)
@ -902,7 +903,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
Assert.assertEquals("BOLUS", smsCommunicatorPlugin.messages[0].text) Assert.assertEquals("BOLUS", smsCommunicatorPlugin.messages[0].text)
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.messages[1].text) Assert.assertEquals("Wrong format", smsCommunicatorPlugin.messages[1].text)
`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(1.0)) `when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(1.0))
PowerMockito.`when`(dateUtilMocked.now()).thenReturn(1000L) `when`(dateUtilMocked.now()).thenReturn(1000L)
`when`(sp.getLong(R.string.key_smscommunicator_remotebolusmindistance, T.msecs(Constants.remoteBolusMinDistance).mins())).thenReturn(15L) `when`(sp.getLong(R.string.key_smscommunicator_remotebolusmindistance, T.msecs(Constants.remoteBolusMinDistance).mins())).thenReturn(15L)
//BOLUS 1 //BOLUS 1
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
@ -911,7 +912,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
Assert.assertEquals("BOLUS 1", smsCommunicatorPlugin.messages[0].text) Assert.assertEquals("BOLUS 1", smsCommunicatorPlugin.messages[0].text)
Assert.assertEquals("Remote bolus not available. Try again later.", smsCommunicatorPlugin.messages[1].text) Assert.assertEquals("Remote bolus not available. Try again later.", smsCommunicatorPlugin.messages[1].text)
`when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0)) `when`(constraintChecker.applyBolusConstraints(anyObject())).thenReturn(Constraint(0.0))
PowerMockito.`when`(dateUtilMocked.now()).thenReturn(Constants.remoteBolusMinDistance + 1002L) `when`(dateUtilMocked.now()).thenReturn(Constants.remoteBolusMinDistance + 1002L)
//BOLUS 0 //BOLUS 0
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
@ -942,13 +943,13 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
//BOLUS 1 (Suspended pump) //BOLUS 1 (Suspended pump)
smsCommunicatorPlugin.lastRemoteBolusTime = 0 smsCommunicatorPlugin.lastRemoteBolusTime = 0
PowerMockito.`when`(virtualPumpPlugin.isSuspended()).thenReturn(true) `when`(virtualPumpPlugin.isSuspended()).thenReturn(true)
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
sms = Sms("1234", "BOLUS 1") sms = Sms("1234", "BOLUS 1")
smsCommunicatorPlugin.processSms(sms) smsCommunicatorPlugin.processSms(sms)
Assert.assertEquals("BOLUS 1", smsCommunicatorPlugin.messages[0].text) Assert.assertEquals("BOLUS 1", smsCommunicatorPlugin.messages[0].text)
Assert.assertEquals("Pump suspended", smsCommunicatorPlugin.messages[1].text) Assert.assertEquals("Pump suspended", smsCommunicatorPlugin.messages[1].text)
PowerMockito.`when`(virtualPumpPlugin.isSuspended()).thenReturn(false) `when`(virtualPumpPlugin.isSuspended()).thenReturn(false)
//BOLUS 1 a //BOLUS 1 a
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
@ -993,7 +994,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
smsCommunicatorPlugin.processSms(sms) smsCommunicatorPlugin.processSms(sms)
Assert.assertEquals("CAL 0", smsCommunicatorPlugin.messages[0].text) Assert.assertEquals("CAL 0", smsCommunicatorPlugin.messages[0].text)
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.messages[1].text) Assert.assertEquals("Wrong format", smsCommunicatorPlugin.messages[1].text)
PowerMockito.`when`(xdripCalibrations.sendIntent(ArgumentMatchers.anyDouble())).thenReturn(true) `when`(xdripCalibrations.sendIntent(ArgumentMatchers.anyDouble())).thenReturn(true)
//CAL 1 //CAL 1
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()
sms = Sms("1234", "CAL 1") sms = Sms("1234", "CAL 1")
@ -1007,7 +1008,7 @@ class SmsCommunicatorPluginTest : TestBaseWithProfile() {
} }
@Test fun processCarbsTest() { @Test fun processCarbsTest() {
PowerMockito.`when`(dateUtilMocked.now()).thenReturn(1000000L) `when`(dateUtilMocked.now()).thenReturn(1000000L)
`when`(sp.getBoolean(R.string.key_smscommunicator_remotecommandsallowed, false)).thenReturn(false) `when`(sp.getBoolean(R.string.key_smscommunicator_remotecommandsallowed, false)).thenReturn(false)
//CAL //CAL
smsCommunicatorPlugin.messages = ArrayList() smsCommunicatorPlugin.messages = ArrayList()

View file

@ -4,13 +4,8 @@ import android.telephony.SmsMessage
import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.TestBase
import org.junit.Assert import org.junit.Assert
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith
import org.powermock.api.mockito.PowerMockito import org.powermock.api.mockito.PowerMockito
import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.junit4.PowerMockRunner
@RunWith(PowerMockRunner::class)
@PrepareForTest(SmsMessage::class)
class SmsTest : TestBase() { class SmsTest : TestBase() {
@Test fun doTests() { @Test fun doTests() {

View file

@ -1,7 +1,6 @@
package info.nightscout.androidaps.plugins.pump.virtual package info.nightscout.androidaps.plugins.pump.virtual
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import info.nightscout.androidaps.utils.buildHelper.ConfigImpl
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.TestBase
import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.interfaces.CommandQueueProvider
@ -12,19 +11,15 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.pump.common.defs.PumpType import info.nightscout.androidaps.plugins.pump.common.defs.PumpType
import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.buildHelper.ConfigImpl
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP import info.nightscout.androidaps.utils.sharedPreferences.SP
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mock import org.mockito.Mock
import org.powermock.api.mockito.PowerMockito import org.mockito.Mockito.`when`
import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.junit4.PowerMockRunner
@RunWith(PowerMockRunner::class)
@PrepareForTest(FabricPrivacy::class, DateUtil::class)
class VirtualPumpPluginUTest : TestBase() { class VirtualPumpPluginUTest : TestBase() {
private val rxBus = RxBusWrapper(aapsSchedulers) private val rxBus = RxBusWrapper(aapsSchedulers)
@ -46,16 +41,16 @@ class VirtualPumpPluginUTest : TestBase() {
@Test @Test
fun refreshConfiguration() { fun refreshConfiguration() {
PowerMockito.`when`(sp.getString(R.string.key_virtualpump_type, "Generic AAPS")).thenReturn("Accu-Chek Combo") `when`(sp.getString(R.string.key_virtualpump_type, "Generic AAPS")).thenReturn("Accu-Chek Combo")
virtualPumpPlugin.refreshConfiguration() virtualPumpPlugin.refreshConfiguration()
Assert.assertEquals(PumpType.ACCU_CHEK_COMBO, virtualPumpPlugin.pumpType) Assert.assertEquals(PumpType.ACCU_CHEK_COMBO, virtualPumpPlugin.pumpType)
} }
@Test @Test
fun refreshConfigurationTwice() { fun refreshConfigurationTwice() {
PowerMockito.`when`(sp.getString(R.string.key_virtualpump_type, "Generic AAPS")).thenReturn("Accu-Chek Combo") `when`(sp.getString(R.string.key_virtualpump_type, "Generic AAPS")).thenReturn("Accu-Chek Combo")
virtualPumpPlugin.refreshConfiguration() virtualPumpPlugin.refreshConfiguration()
PowerMockito.`when`(sp.getString(R.string.key_virtualpump_type, "Generic AAPS")).thenReturn("Accu-Chek Combo") `when`(sp.getString(R.string.key_virtualpump_type, "Generic AAPS")).thenReturn("Accu-Chek Combo")
virtualPumpPlugin.refreshConfiguration() virtualPumpPlugin.refreshConfiguration()
Assert.assertEquals(PumpType.ACCU_CHEK_COMBO, virtualPumpPlugin.pumpType) Assert.assertEquals(PumpType.ACCU_CHEK_COMBO, virtualPumpPlugin.pumpType)
} }

View file

@ -3,16 +3,12 @@ package info.nightscout.androidaps.plugins.source
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.TestBase
import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mock import org.mockito.Mock
import org.powermock.modules.junit4.PowerMockRunner
@RunWith(PowerMockRunner::class)
class XdripPluginTest : TestBase() { class XdripPluginTest : TestBase() {
private lateinit var xdripPlugin: XdripPlugin private lateinit var xdripPlugin: XdripPlugin

View file

@ -1,6 +1,7 @@
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-allopen'
apply plugin: 'com.hiya.jacoco-android' apply plugin: 'com.hiya.jacoco-android'
apply from: "${project.rootDir}/gradle/android_dependencies.gradle" apply from: "${project.rootDir}/gradle/android_dependencies.gradle"

View file

@ -5,6 +5,7 @@ import android.os.Handler
import android.os.HandlerThread import android.os.HandlerThread
import android.os.SystemClock import android.os.SystemClock
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.events.* import info.nightscout.androidaps.events.*
import info.nightscout.androidaps.interfaces.Config import info.nightscout.androidaps.interfaces.Config
@ -38,6 +39,7 @@ import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
import kotlin.collections.ArrayList import kotlin.collections.ArrayList
@OpenForTesting
@Singleton @Singleton
class AutomationPlugin @Inject constructor( class AutomationPlugin @Inject constructor(
injector: HasAndroidInjector, injector: HasAndroidInjector,

View file

@ -1,13 +1,11 @@
package info.nightscout.androidaps.services package info.nightscout.androidaps.services
import android.location.Location import android.location.Location
import info.nightscout.androidaps.annotations.OpenForTesting
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
/** @OpenForTesting
* Created by adrian on 2020-01-06.
*/
@Singleton @Singleton
class LastLocationDataContainer @Inject constructor() { class LastLocationDataContainer @Inject constructor() {
var lastLocation: Location? = null var lastLocation: Location? = null

View file

@ -9,11 +9,8 @@ import io.reactivex.Single
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mockito.`when` import org.mockito.Mockito.`when`
import org.powermock.modules.junit4.PowerMockRunner
@RunWith(PowerMockRunner::class)
class ActionLoopResumeTest : ActionsTestBase() { class ActionLoopResumeTest : ActionsTestBase() {
lateinit var sut: ActionLoopResume lateinit var sut: ActionLoopResume

View file

@ -6,23 +6,26 @@ import info.nightscout.androidaps.TestBase
import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.transactions.CancelCurrentTemporaryTargetIfAnyTransaction
import info.nightscout.androidaps.database.transactions.InsertAndCancelCurrentTemporaryTargetTransaction
import info.nightscout.androidaps.database.transactions.InsertTherapyEventAnnouncementTransaction
import info.nightscout.androidaps.database.transactions.Transaction
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.general.automation.elements.InputString import info.nightscout.androidaps.plugins.general.automation.elements.InputString
import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.utils.resources.ResourceHelper import info.nightscout.androidaps.utils.resources.ResourceHelper
import io.reactivex.Completable
import io.reactivex.Single
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentMatchers import org.mockito.ArgumentMatchers
import org.mockito.Mock import org.mockito.Mock
import org.mockito.Mockito import org.mockito.Mockito
import org.mockito.Mockito.`when` import org.mockito.Mockito.`when`
import org.powermock.core.classloader.annotations.PrepareForTest import org.mockito.Mockito.any
import org.powermock.modules.junit4.PowerMockRunner import org.mockito.Mockito.doNothing
@RunWith(PowerMockRunner::class)
@PrepareForTest(RxBusWrapper::class)
class ActionNotificationTest : TestBase() { class ActionNotificationTest : TestBase() {
@Mock lateinit var resourceHelper: ResourceHelper @Mock lateinit var resourceHelper: ResourceHelper
@ -47,7 +50,14 @@ class ActionNotificationTest : TestBase() {
fun setup() { fun setup() {
`when`(resourceHelper.gs(R.string.ok)).thenReturn("OK") `when`(resourceHelper.gs(R.string.ok)).thenReturn("OK")
`when`(resourceHelper.gs(R.string.notification)).thenReturn("Notification") `when`(resourceHelper.gs(R.string.notification)).thenReturn("Notification")
`when`(resourceHelper.gs(ArgumentMatchers.eq(R.string.notification_message), ArgumentMatchers.anyString())).thenReturn("Notification: %s") `when`(
resourceHelper.gs(
ArgumentMatchers.eq(R.string.notification_message),
ArgumentMatchers.anyString()
)
).thenReturn("Notification: %s")
`when`(repository.runTransaction(anyObject<Transaction<InsertTherapyEventAnnouncementTransaction.TransactionResult>>()))
.thenReturn(Completable.fromAction {})
sut = ActionNotification(injector) sut = ActionNotification(injector)
} }
@ -81,7 +91,10 @@ class ActionNotificationTest : TestBase() {
@Test fun toJSONTest() { @Test fun toJSONTest() {
sut.text = InputString("Asd") sut.text = InputString("Asd")
Assert.assertEquals("{\"data\":{\"text\":\"Asd\"},\"type\":\"info.nightscout.androidaps.plugins.general.automation.actions.ActionNotification\"}", sut.toJSON()) Assert.assertEquals(
"{\"data\":{\"text\":\"Asd\"},\"type\":\"info.nightscout.androidaps.plugins.general.automation.actions.ActionNotification\"}",
sut.toJSON()
)
} }
@Test fun fromJSONTest() { @Test fun fromJSONTest() {

View file

@ -3,10 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.elements
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTestBase import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTestBase
import org.junit.Assert import org.junit.Assert
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith
import org.powermock.modules.junit4.PowerMockRunner
@RunWith(PowerMockRunner::class)
class ComparatorConnectTest : TriggerTestBase() { class ComparatorConnectTest : TriggerTestBase() {
@Test fun labelsTest() { @Test fun labelsTest() {

View file

@ -3,10 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.elements
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTestBase import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTestBase
import org.junit.Assert import org.junit.Assert
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith
import org.powermock.modules.junit4.PowerMockRunner
@RunWith(PowerMockRunner::class)
class ComparatorExistsTest : TriggerTestBase() { class ComparatorExistsTest : TriggerTestBase() {
@Test fun labelsTest() { @Test fun labelsTest() {

View file

@ -3,10 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.elements
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTestBase import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTestBase
import org.junit.Assert import org.junit.Assert
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith
import org.powermock.modules.junit4.PowerMockRunner
@RunWith(PowerMockRunner::class)
class ComparatorTest : TriggerTestBase() { class ComparatorTest : TriggerTestBase() {
@Test @Test

View file

@ -1,16 +1,12 @@
package info.nightscout.androidaps.plugins.general.automation.elements package info.nightscout.androidaps.plugins.general.automation.elements
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.interfaces.GlucoseUnit import info.nightscout.androidaps.interfaces.GlucoseUnit
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTestBase import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTestBase
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mockito.`when` import org.mockito.Mockito.`when`
import org.powermock.modules.junit4.PowerMockRunner
@RunWith(PowerMockRunner::class)
class InputBgTest : TriggerTestBase() { class InputBgTest : TriggerTestBase() {
@Test @Test

View file

@ -3,10 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.elements
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTestBase import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTestBase
import org.junit.Assert import org.junit.Assert
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith
import org.powermock.modules.junit4.PowerMockRunner
@RunWith(PowerMockRunner::class)
class InputDurationTest : TriggerTestBase() { class InputDurationTest : TriggerTestBase() {
@Test fun setValueTest() { @Test fun setValueTest() {

View file

@ -3,10 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.elements
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTestBase import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTestBase
import org.junit.Assert import org.junit.Assert
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith
import org.powermock.modules.junit4.PowerMockRunner
@RunWith(PowerMockRunner::class)
class InputInsulinTest : TriggerTestBase() { class InputInsulinTest : TriggerTestBase() {
@Test fun setValueTest() { @Test fun setValueTest() {

View file

@ -3,10 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.elements
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTestBase import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTestBase
import org.junit.Assert import org.junit.Assert
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith
import org.powermock.modules.junit4.PowerMockRunner
@RunWith(PowerMockRunner::class)
class InputPercentTest : TriggerTestBase() { class InputPercentTest : TriggerTestBase() {
@Test fun setValueTest() { @Test fun setValueTest() {

View file

@ -3,10 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation.elements
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTestBase import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTestBase
import org.junit.Assert import org.junit.Assert
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith
import org.powermock.modules.junit4.PowerMockRunner
@RunWith(PowerMockRunner::class)
class InputStringTest : TriggerTestBase() { class InputStringTest : TriggerTestBase() {
@Test fun setValueTest() { @Test fun setValueTest() {

View file

@ -1,16 +1,10 @@
package info.nightscout.androidaps.plugins.general.automation.elements package info.nightscout.androidaps.plugins.general.automation.elements
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.interfaces.GlucoseUnit import info.nightscout.androidaps.interfaces.GlucoseUnit
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTestBase import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerTestBase
import org.junit.Assert import org.junit.Assert
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mock
import org.powermock.modules.junit4.PowerMockRunner
@RunWith(PowerMockRunner::class)
class InputTempTargetTest : TriggerTestBase() { class InputTempTargetTest : TriggerTestBase() {
@Test fun setValueTest() { @Test fun setValueTest() {

View file

@ -13,7 +13,6 @@ import org.junit.runner.RunWith
import org.mockito.ArgumentMatchers import org.mockito.ArgumentMatchers
import org.mockito.Mockito import org.mockito.Mockito
import org.mockito.Mockito.`when` import org.mockito.Mockito.`when`
import org.powermock.api.mockito.PowerMockito
import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.junit4.PowerMockRunner import org.powermock.modules.junit4.PowerMockRunner
@ -65,14 +64,14 @@ class TriggerAutosensValueTest : TriggerTestBase() {
t.autosens.value = 390.0 t.autosens.value = 390.0
t.comparator.value = Comparator.Compare.IS_EQUAL_OR_LESSER t.comparator.value = Comparator.Compare.IS_EQUAL_OR_LESSER
Assert.assertTrue(t.shouldRun()) Assert.assertTrue(t.shouldRun())
PowerMockito.`when`(autosensDataStore.getLastAutosensData(anyObject(), anyObject(), anyObject())).thenReturn(AutosensData(injector)) `when`(autosensDataStore.getLastAutosensData(anyObject(), anyObject(), anyObject())).thenReturn(AutosensData(injector))
t = TriggerAutosensValue(injector) t = TriggerAutosensValue(injector)
t.autosens.value = 80.0 t.autosens.value = 80.0
t.comparator.value = Comparator.Compare.IS_EQUAL_OR_LESSER t.comparator.value = Comparator.Compare.IS_EQUAL_OR_LESSER
Assert.assertFalse(t.shouldRun()) Assert.assertFalse(t.shouldRun())
// Test autosensData == null and Comparator == IS_NOT_AVAILABLE // Test autosensData == null and Comparator == IS_NOT_AVAILABLE
PowerMockito.`when`(autosensDataStore.getLastAutosensData(anyObject(), anyObject(), anyObject())).thenReturn(null) `when`(autosensDataStore.getLastAutosensData(anyObject(), anyObject(), anyObject())).thenReturn(null)
t = TriggerAutosensValue(injector) t = TriggerAutosensValue(injector)
t.comparator.value = Comparator.Compare.IS_NOT_AVAILABLE t.comparator.value = Comparator.Compare.IS_NOT_AVAILABLE
Assert.assertTrue(t.shouldRun()) Assert.assertTrue(t.shouldRun())
@ -114,7 +113,7 @@ class TriggerAutosensValueTest : TriggerTestBase() {
@Before @Before
fun mock() { fun mock() {
PowerMockito.`when`(dateUtil.now()).thenReturn(now) `when`(dateUtil.now()).thenReturn(now)
} }
private fun generateAutosensData(): AutosensData { private fun generateAutosensData(): AutosensData {

View file

@ -1,25 +1,17 @@
package info.nightscout.androidaps.plugins.general.automation.triggers package info.nightscout.androidaps.plugins.general.automation.triggers
import com.google.common.base.Optional import com.google.common.base.Optional
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.database.entities.GlucoseValue import info.nightscout.androidaps.database.entities.GlucoseValue
import info.nightscout.androidaps.interfaces.GlucoseUnit import info.nightscout.androidaps.interfaces.GlucoseUnit
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator import info.nightscout.androidaps.plugins.general.automation.elements.Comparator
import info.nightscout.androidaps.utils.DateUtil
import org.json.JSONObject import org.json.JSONObject
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mockito.`when` import org.mockito.Mockito.`when`
import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.junit4.PowerMockRunner
import java.util.* import java.util.*
@RunWith(PowerMockRunner::class)
@PrepareForTest(DateUtil::class, ProfileFunction::class)
class TriggerBgTest : TriggerTestBase() { class TriggerBgTest : TriggerTestBase() {
var now = 1514766900000L var now = 1514766900000L

View file

@ -4,27 +4,20 @@ import com.google.common.base.Optional
import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.database.entities.Bolus import info.nightscout.androidaps.database.entities.Bolus
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator import info.nightscout.androidaps.plugins.general.automation.elements.Comparator
import info.nightscout.androidaps.utils.DateUtil
import org.json.JSONException import org.json.JSONException
import org.json.JSONObject import org.json.JSONObject
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mockito.`when` import org.mockito.Mockito.`when`
import org.powermock.api.mockito.PowerMockito
import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.junit4.PowerMockRunner
@RunWith(PowerMockRunner::class)
@PrepareForTest(DateUtil::class)
class TriggerBolusAgoTest : TriggerTestBase() { class TriggerBolusAgoTest : TriggerTestBase() {
var now = 1514766900000L var now = 1514766900000L
@Before @Before
fun mock() { fun mock() {
PowerMockito.`when`(dateUtil.now()).thenReturn(now) `when`(dateUtil.now()).thenReturn(now)
} }
@Test @Test

View file

@ -4,31 +4,25 @@ import com.google.common.base.Optional
import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator import info.nightscout.androidaps.plugins.general.automation.elements.Comparator
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.CobInfo import info.nightscout.androidaps.plugins.iob.iobCobCalculator.CobInfo
import info.nightscout.androidaps.utils.DateUtil
import org.json.JSONObject import org.json.JSONObject
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentMatchers import org.mockito.ArgumentMatchers
import org.powermock.api.mockito.PowerMockito import org.mockito.Mockito.`when`
import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.junit4.PowerMockRunner
@RunWith(PowerMockRunner::class)
@PrepareForTest(DateUtil::class)
class TriggerCOBTest : TriggerTestBase() { class TriggerCOBTest : TriggerTestBase() {
var now = 1514766900000L var now = 1514766900000L
@Before fun mock() { @Before fun mock() {
PowerMockito.`when`(dateUtil.now()).thenReturn(now) `when`(dateUtil.now()).thenReturn(now)
PowerMockito.`when`(sp.getInt(ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt())).thenReturn(48) `when`(sp.getInt(ArgumentMatchers.anyInt(), ArgumentMatchers.anyInt())).thenReturn(48)
} }
@Test fun shouldRunTest() { @Test fun shouldRunTest() {
// COB value is 6 // COB value is 6
PowerMockito.`when`(iobCobCalculator.getCobInfo(false, "AutomationTriggerCOB")).thenReturn(CobInfo(0, 6.0, 2.0)) `when`(iobCobCalculator.getCobInfo(false, "AutomationTriggerCOB")).thenReturn(CobInfo(0, 6.0, 2.0))
var t: TriggerCOB = TriggerCOB(injector).setValue(1.0).comparator(Comparator.Compare.IS_EQUAL) var t: TriggerCOB = TriggerCOB(injector).setValue(1.0).comparator(Comparator.Compare.IS_EQUAL)
Assert.assertFalse(t.shouldRun()) Assert.assertFalse(t.shouldRun())
t = TriggerCOB(injector).setValue(6.0).comparator(Comparator.Compare.IS_EQUAL) t = TriggerCOB(injector).setValue(6.0).comparator(Comparator.Compare.IS_EQUAL)

View file

@ -1,34 +1,25 @@
package info.nightscout.androidaps.plugins.general.automation.triggers package info.nightscout.androidaps.plugins.general.automation.triggers
import com.google.common.base.Optional import com.google.common.base.Optional
import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.database.entities.GlucoseValue import info.nightscout.androidaps.database.entities.GlucoseValue
import info.nightscout.androidaps.interfaces.GlucoseUnit import info.nightscout.androidaps.interfaces.GlucoseUnit
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator import info.nightscout.androidaps.plugins.general.automation.elements.Comparator
import info.nightscout.androidaps.plugins.general.automation.elements.InputDelta.DeltaType import info.nightscout.androidaps.plugins.general.automation.elements.InputDelta.DeltaType
import info.nightscout.androidaps.utils.DateUtil
import org.json.JSONObject import org.json.JSONObject
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mockito.`when` import org.mockito.Mockito.`when`
import org.powermock.api.mockito.PowerMockito
import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.junit4.PowerMockRunner
import java.util.* import java.util.*
@RunWith(PowerMockRunner::class)
@PrepareForTest(DateUtil::class, ProfileFunction::class)
class TriggerDeltaTest : TriggerTestBase() { class TriggerDeltaTest : TriggerTestBase() {
var now = 1514766900000L var now = 1514766900000L
@Before @Before
fun mock() { fun mock() {
PowerMockito.`when`(dateUtil.now()).thenReturn(now) `when`(dateUtil.now()).thenReturn(now)
`when`(profileFunction.getUnits()).thenReturn(GlucoseUnit.MGDL) `when`(profileFunction.getUnits()).thenReturn(GlucoseUnit.MGDL)
} }

View file

@ -4,29 +4,19 @@ import android.location.Location
import com.google.common.base.Optional import com.google.common.base.Optional
import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.plugins.general.automation.elements.InputLocationMode import info.nightscout.androidaps.plugins.general.automation.elements.InputLocationMode
import info.nightscout.androidaps.services.LocationService
import info.nightscout.androidaps.utils.DateUtil
import org.json.JSONException import org.json.JSONException
import org.json.JSONObject import org.json.JSONObject
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mockito.`when` import org.mockito.Mockito.`when`
import org.powermock.api.mockito.PowerMockito
import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.junit4.PowerMockRunner
@RunWith(PowerMockRunner::class)
@PrepareForTest(DateUtil::class, LocationService::class)
class TriggerLocationTest : TriggerTestBase() { class TriggerLocationTest : TriggerTestBase() {
var now = 1514766900000L var now = 1514766900000L
@Before fun mock() { @Before fun mock() {
PowerMockito.mockStatic(LocationService::class.java)
`when`(dateUtil.now()).thenReturn(now) `when`(dateUtil.now()).thenReturn(now)
PowerMockito.spy(LocationService::class.java)
`when`(locationDataContainer.lastLocation).thenReturn(mockedLocation()) `when`(locationDataContainer.lastLocation).thenReturn(mockedLocation())
} }

View file

@ -3,27 +3,20 @@ package info.nightscout.androidaps.plugins.general.automation.triggers
import com.google.common.base.Optional import com.google.common.base.Optional
import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator import info.nightscout.androidaps.plugins.general.automation.elements.Comparator
import info.nightscout.androidaps.utils.DateUtil
import org.json.JSONException import org.json.JSONException
import org.json.JSONObject import org.json.JSONObject
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mockito.`when` import org.mockito.Mockito.`when`
import org.powermock.api.mockito.PowerMockito
import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.junit4.PowerMockRunner
@RunWith(PowerMockRunner::class)
@PrepareForTest(DateUtil::class)
class TriggerProfilePercentTest : TriggerTestBase() { class TriggerProfilePercentTest : TriggerTestBase() {
private val now = 1514766900000L private val now = 1514766900000L
@Before fun mock() { @Before fun mock() {
`when`(profileFunction.getProfile()).thenReturn(validProfile) `when`(profileFunction.getProfile()).thenReturn(validProfile)
PowerMockito.`when`(dateUtil.now()).thenReturn(now) `when`(dateUtil.now()).thenReturn(now)
} }
@Test fun shouldRunTest() { @Test fun shouldRunTest() {

View file

@ -3,25 +3,19 @@ package info.nightscout.androidaps.plugins.general.automation.triggers
import com.google.common.base.Optional import com.google.common.base.Optional
import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator import info.nightscout.androidaps.plugins.general.automation.elements.Comparator
import info.nightscout.androidaps.utils.DateUtil
import org.json.JSONObject import org.json.JSONObject
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.mockito.Mockito.`when`
import org.powermock.api.mockito.PowerMockito
import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.junit4.PowerMockRunner
@RunWith(PowerMockRunner::class)
@PrepareForTest(DateUtil::class)
class TriggerPumpLastConnectionTest : TriggerTestBase() { class TriggerPumpLastConnectionTest : TriggerTestBase() {
var now = 1514766900000L var now = 1514766900000L
@Before @Before
fun mock() { fun mock() {
PowerMockito.`when`(dateUtil.now()).thenReturn(now) `when`(dateUtil.now()).thenReturn(now)
} }
@Test @Test
@ -29,7 +23,7 @@ class TriggerPumpLastConnectionTest : TriggerTestBase() {
// System.currentTimeMillis() is always 0 // System.currentTimeMillis() is always 0
// and so is every last connection time // and so is every last connection time
Assert.assertEquals(0L, testPumpPlugin.lastDataTime()) Assert.assertEquals(0L, testPumpPlugin.lastDataTime())
PowerMockito.`when`(dateUtil.now()).thenReturn(now + 10 * 60 * 1000) // set current time to now + 10 min `when`(dateUtil.now()).thenReturn(now + 10 * 60 * 1000) // set current time to now + 10 min
var t = TriggerPumpLastConnection(injector).setValue(110).comparator(Comparator.Compare.IS_EQUAL) var t = TriggerPumpLastConnection(injector).setValue(110).comparator(Comparator.Compare.IS_EQUAL)
Assert.assertEquals(110, t.minutesAgo.value) Assert.assertEquals(110, t.minutesAgo.value)
Assert.assertEquals(Comparator.Compare.IS_EQUAL, t.comparator.value) Assert.assertEquals(Comparator.Compare.IS_EQUAL, t.comparator.value)

View file

@ -1,26 +1,20 @@
package info.nightscout.androidaps.plugins.general.automation.triggers package info.nightscout.androidaps.plugins.general.automation.triggers
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.MidnightTime import info.nightscout.androidaps.utils.MidnightTime
import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.utils.T
import org.json.JSONObject import org.json.JSONObject
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.mockito.Mockito.`when`
import org.powermock.api.mockito.PowerMockito
import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.junit4.PowerMockRunner
@RunWith(PowerMockRunner::class)
@PrepareForTest(DateUtil::class)
class TriggerRecurringTimeTest : TriggerTestBase() { class TriggerRecurringTimeTest : TriggerTestBase() {
var now : Long = 0L var now : Long = 0L
@Before fun mock() { @Before fun mock() {
now = MidnightTime.calc() + T.mins(95).msecs() // 95 min from midnight now = MidnightTime.calc() + T.mins(95).msecs() // 95 min from midnight
PowerMockito.`when`(dateUtil.now()).thenReturn(now) `when`(dateUtil.now()).thenReturn(now)
} }
@Test fun shouldRunTest() { @Test fun shouldRunTest() {

View file

@ -3,24 +3,18 @@ package info.nightscout.androidaps.plugins.general.automation.triggers
import com.google.common.base.Optional import com.google.common.base.Optional
import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.plugins.general.automation.elements.ComparatorExists import info.nightscout.androidaps.plugins.general.automation.elements.ComparatorExists
import info.nightscout.androidaps.utils.DateUtil
import org.json.JSONObject import org.json.JSONObject
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.mockito.Mockito.`when`
import org.powermock.api.mockito.PowerMockito
import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.junit4.PowerMockRunner
@RunWith(PowerMockRunner::class)
@PrepareForTest(DateUtil::class)
class TriggerTempTargetTest : TriggerTestBase() { class TriggerTempTargetTest : TriggerTestBase() {
var now = 1514766900000L var now = 1514766900000L
@Before fun mock() { @Before fun mock() {
PowerMockito.`when`(dateUtil.now()).thenReturn(now) `when`(dateUtil.now()).thenReturn(now)
} }
/* /*
@Test fun shouldRunTest() { @Test fun shouldRunTest() {
@ -29,7 +23,7 @@ class TriggerTempTargetTest : TriggerTestBase() {
Assert.assertFalse(t.shouldRun()) Assert.assertFalse(t.shouldRun())
t = TriggerTempTarget(injector).comparator(ComparatorExists.Compare.NOT_EXISTS) t = TriggerTempTarget(injector).comparator(ComparatorExists.Compare.NOT_EXISTS)
Assert.assertTrue(t.shouldRun()) Assert.assertTrue(t.shouldRun())
PowerMockito.`when`(repository.getTemporaryTargetActiveAt(anyObject())).thenReturn(TemporaryTarget(duration = 0, highTarget = 0.0, lowTarget = 0.0, reason = TemporaryTarget.Reason.CUSTOM, timestamp = 0)) `when`(repository.getTemporaryTargetActiveAt(anyObject())).thenReturn(TemporaryTarget(duration = 0, highTarget = 0.0, lowTarget = 0.0, reason = TemporaryTarget.Reason.CUSTOM, timestamp = 0))
t = TriggerTempTarget(injector).comparator(ComparatorExists.Compare.NOT_EXISTS) t = TriggerTempTarget(injector).comparator(ComparatorExists.Compare.NOT_EXISTS)
Assert.assertFalse(t.shouldRun()) Assert.assertFalse(t.shouldRun())
t = TriggerTempTarget(injector).comparator(ComparatorExists.Compare.EXISTS) t = TriggerTempTarget(injector).comparator(ComparatorExists.Compare.EXISTS)

View file

@ -3,13 +3,13 @@ package info.nightscout.androidaps.plugins.general.automation.triggers
import android.content.Context import android.content.Context
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.plugins.general.automation.TestBaseWithProfile
import info.nightscout.androidaps.TestPumpPlugin import info.nightscout.androidaps.TestPumpPlugin
import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.IobCobCalculator import info.nightscout.androidaps.interfaces.IobCobCalculator
import info.nightscout.androidaps.interfaces.PluginDescription import info.nightscout.androidaps.interfaces.PluginDescription
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin
import info.nightscout.androidaps.plugins.general.automation.TestBaseWithProfile
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensDataStore import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensDataStore
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.androidaps.receivers.ReceiverStatusStore import info.nightscout.androidaps.receivers.ReceiverStatusStore
@ -18,9 +18,7 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP
import org.junit.Before import org.junit.Before
import org.mockito.Mock import org.mockito.Mock
import org.mockito.Mockito.`when` import org.mockito.Mockito.`when`
import org.powermock.core.classloader.annotations.PrepareForTest
@PrepareForTest(LastLocationDataContainer::class, AutomationPlugin::class, AutosensDataStore::class)
open class TriggerTestBase : TestBaseWithProfile() { open class TriggerTestBase : TestBaseWithProfile() {
@Mock lateinit var sp: SP @Mock lateinit var sp: SP

View file

@ -2,19 +2,13 @@ package info.nightscout.androidaps.plugins.general.automation.triggers
import com.google.common.base.Optional import com.google.common.base.Optional
import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.MidnightTime import info.nightscout.androidaps.utils.MidnightTime
import org.json.JSONObject import org.json.JSONObject
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.mockito.Mockito.`when`
import org.powermock.api.mockito.PowerMockito
import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.junit4.PowerMockRunner
@RunWith(PowerMockRunner::class)
@PrepareForTest(DateUtil::class)
class TriggerTimeRangeTest : TriggerTestBase() { class TriggerTimeRangeTest : TriggerTestBase() {
var now = 754 // in minutes from midnight var now = 754 // in minutes from midnight
@ -23,7 +17,7 @@ class TriggerTimeRangeTest : TriggerTestBase() {
@Before @Before
fun mock() { fun mock() {
val nowMills = MidnightTime.calcPlusMinutes(now) val nowMills = MidnightTime.calcPlusMinutes(now)
PowerMockito.`when`(dateUtil.now()).thenReturn(nowMills) `when`(dateUtil.now()).thenReturn(nowMills)
} }
@Test @Test

View file

@ -10,7 +10,7 @@ import org.junit.Assert
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
import org.powermock.api.mockito.PowerMockito import org.mockito.Mockito.`when`
import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.junit4.PowerMockRunner import org.powermock.modules.junit4.PowerMockRunner
@ -21,7 +21,7 @@ class TriggerTimeTest : TriggerTestBase() {
var now = 1514766900000L var now = 1514766900000L
@Before fun mock() { @Before fun mock() {
PowerMockito.`when`(dateUtil.now()).thenReturn(now) `when`(dateUtil.now()).thenReturn(now)
} }
@Test fun shouldRunTest() { @Test fun shouldRunTest() {

View file

@ -4,27 +4,19 @@ import com.google.common.base.Optional
import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.automation.R
import info.nightscout.androidaps.events.EventNetworkChange import info.nightscout.androidaps.events.EventNetworkChange
import info.nightscout.androidaps.plugins.general.automation.elements.Comparator import info.nightscout.androidaps.plugins.general.automation.elements.Comparator
import info.nightscout.androidaps.receivers.NetworkChangeReceiver
import info.nightscout.androidaps.utils.DateUtil
import org.json.JSONException import org.json.JSONException
import org.json.JSONObject import org.json.JSONObject
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.mockito.Mockito.`when`
import org.powermock.api.mockito.PowerMockito
import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.junit4.PowerMockRunner
@RunWith(PowerMockRunner::class)
@PrepareForTest(NetworkChangeReceiver::class, DateUtil::class)
class TriggerWifiSsidTest : TriggerTestBase() { class TriggerWifiSsidTest : TriggerTestBase() {
var now = 1514766900000L var now = 1514766900000L
@Before fun mock() { @Before fun mock() {
PowerMockito.mockStatic(NetworkChangeReceiver::class.java) `when`(dateUtil.now()).thenReturn(now)
PowerMockito.`when`(dateUtil.now()).thenReturn(now)
} }
@Test fun shouldRunTest() { @Test fun shouldRunTest() {

View file

@ -1,6 +1,7 @@
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-allopen'
apply plugin: 'com.hiya.jacoco-android' apply plugin: 'com.hiya.jacoco-android'
apply from: "${project.rootDir}/gradle/android_dependencies.gradle" apply from: "${project.rootDir}/gradle/android_dependencies.gradle"

View file

@ -14,8 +14,3 @@ apply from: "${project.rootDir}/gradle/jacoco_global.gradle"
dependencies { dependencies {
implementation project(':database') implementation project(':database')
} }
allOpen {
// allows mocking for classes w/o directly opening them for release builds
annotation 'info.nightscout.androidaps.annotations.OpenForTesting'
}

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.logging package info.nightscout.androidaps.logging
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.ValueWithUnit import info.nightscout.androidaps.database.entities.ValueWithUnit
import info.nightscout.androidaps.database.entities.UserEntry.Action import info.nightscout.androidaps.database.entities.UserEntry.Action
@ -14,6 +15,7 @@ import io.reactivex.rxkotlin.subscribeBy
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@OpenForTesting
@Singleton @Singleton
class UserEntryLogger @Inject constructor( class UserEntryLogger @Inject constructor(
private val aapsLogger: AAPSLogger, private val aapsLogger: AAPSLogger,

View file

@ -1,6 +1,7 @@
package info.nightscout.androidaps.plugins.configBuilder package info.nightscout.androidaps.plugins.configBuilder
import info.nightscout.androidaps.Constants import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.interfaces.Profile import info.nightscout.androidaps.interfaces.Profile
import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.ActivePlugin
import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.interfaces.Constraint
@ -9,6 +10,7 @@ import info.nightscout.androidaps.interfaces.PluginType
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@OpenForTesting
@Singleton @Singleton
class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlugin) : Constraints { class ConstraintChecker @Inject constructor(private val activePlugin: ActivePlugin) : Constraints {

View file

@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.general.maintenance
import android.content.Context import android.content.Context
import android.os.Environment import android.os.Environment
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.core.R import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.interfaces.Config import info.nightscout.androidaps.interfaces.Config
import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtils import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtils
@ -19,6 +20,7 @@ import javax.inject.Singleton
import kotlin.math.abs import kotlin.math.abs
@Suppress("SpellCheckingInspection") @Suppress("SpellCheckingInspection")
@OpenForTesting
@Singleton @Singleton
class PrefFileListProvider @Inject constructor( class PrefFileListProvider @Inject constructor(
private val resourceHelper: ResourceHelper, private val resourceHelper: ResourceHelper,

View file

@ -1,6 +1,7 @@
package info.nightscout.androidaps.plugins.iob.iobCobCalculator package info.nightscout.androidaps.plugins.iob.iobCobCalculator
import androidx.collection.LongSparseArray import androidx.collection.LongSparseArray
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.data.InMemoryGlucoseValue import info.nightscout.androidaps.data.InMemoryGlucoseValue
import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.database.entities.GlucoseValue import info.nightscout.androidaps.database.entities.GlucoseValue
@ -14,6 +15,7 @@ import info.nightscout.androidaps.utils.T
import kotlin.math.abs import kotlin.math.abs
import kotlin.math.roundToLong import kotlin.math.roundToLong
@OpenForTesting
class AutosensDataStore { class AutosensDataStore {
private val dataLock = Any() private val dataLock = Any()

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.plugins.pump.common.bolusInfo package info.nightscout.androidaps.plugins.pump.common.bolusInfo
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.data.DetailedBolusInfo import info.nightscout.androidaps.data.DetailedBolusInfo
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
@ -9,6 +10,7 @@ import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
import kotlin.math.abs import kotlin.math.abs
@OpenForTesting
@Singleton @Singleton
class DetailedBolusInfoStorage @Inject constructor( class DetailedBolusInfoStorage @Inject constructor(
val aapsLogger: AAPSLogger val aapsLogger: AAPSLogger

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.plugins.pump.common.bolusInfo package info.nightscout.androidaps.plugins.pump.common.bolusInfo
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.interfaces.PumpSync import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
@ -9,6 +10,7 @@ import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
import kotlin.math.abs import kotlin.math.abs
@OpenForTesting
@Singleton @Singleton
class TemporaryBasalStorage @Inject constructor( class TemporaryBasalStorage @Inject constructor(
val aapsLogger: AAPSLogger val aapsLogger: AAPSLogger

View file

@ -12,20 +12,14 @@ import info.nightscout.androidaps.utils.T
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mock import org.mockito.Mock
import org.mockito.Mockito.`when` import org.mockito.Mockito.`when`
import org.powermock.api.mockito.PowerMockito
import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.junit4.PowerMockRunner
import java.util.* import java.util.*
/** /**
* Created by mike on 26.03.2018. * Created by mike on 26.03.2018.
*/ */
@Suppress("SpellCheckingInspection") @Suppress("SpellCheckingInspection")
@RunWith(PowerMockRunner::class)
@PrepareForTest(DateUtil::class, AutosensDataStore::class)
class GlucoseStatusTest : TestBase() { class GlucoseStatusTest : TestBase() {
@Mock lateinit var dateUtil: DateUtil @Mock lateinit var dateUtil: DateUtil
@ -48,7 +42,7 @@ class GlucoseStatusTest : TestBase() {
} }
@Test fun calculateValidGlucoseStatus() { @Test fun calculateValidGlucoseStatus() {
PowerMockito.`when`(autosensDataStore.getBgReadingsDataTableCopy()).thenReturn(generateValidBgData()) `when`(autosensDataStore.getBgReadingsDataTableCopy()).thenReturn(generateValidBgData())
val glucoseStatus = GlucoseStatusProvider(aapsLogger, iobCobCalculatorPlugin, dateUtil).glucoseStatusData!! val glucoseStatus = GlucoseStatusProvider(aapsLogger, iobCobCalculatorPlugin, dateUtil).glucoseStatusData!!
Assert.assertEquals(214.0, glucoseStatus.glucose, 0.001) Assert.assertEquals(214.0, glucoseStatus.glucose, 0.001)
Assert.assertEquals(-2.0, glucoseStatus.delta, 0.001) Assert.assertEquals(-2.0, glucoseStatus.delta, 0.001)
@ -58,7 +52,7 @@ class GlucoseStatusTest : TestBase() {
} }
@Test fun calculateMostRecentGlucoseStatus() { @Test fun calculateMostRecentGlucoseStatus() {
PowerMockito.`when`(autosensDataStore.getBgReadingsDataTableCopy()).thenReturn(generateMostRecentBgData()) `when`(autosensDataStore.getBgReadingsDataTableCopy()).thenReturn(generateMostRecentBgData())
val glucoseStatus: GlucoseStatus = GlucoseStatusProvider(aapsLogger, iobCobCalculatorPlugin, dateUtil).glucoseStatusData!! val glucoseStatus: GlucoseStatus = GlucoseStatusProvider(aapsLogger, iobCobCalculatorPlugin, dateUtil).glucoseStatusData!!
Assert.assertEquals(215.0, glucoseStatus.glucose, 0.001) // (214+216) / 2 Assert.assertEquals(215.0, glucoseStatus.glucose, 0.001) // (214+216) / 2
Assert.assertEquals(-1.0, glucoseStatus.delta, 0.001) Assert.assertEquals(-1.0, glucoseStatus.delta, 0.001)
@ -68,7 +62,7 @@ class GlucoseStatusTest : TestBase() {
} }
@Test fun oneRecordShouldProduceZeroDeltas() { @Test fun oneRecordShouldProduceZeroDeltas() {
PowerMockito.`when`(autosensDataStore.getBgReadingsDataTableCopy()).thenReturn(generateOneCurrentRecordBgData()) `when`(autosensDataStore.getBgReadingsDataTableCopy()).thenReturn(generateOneCurrentRecordBgData())
val glucoseStatus: GlucoseStatus = GlucoseStatusProvider(aapsLogger, iobCobCalculatorPlugin, dateUtil).glucoseStatusData!! val glucoseStatus: GlucoseStatus = GlucoseStatusProvider(aapsLogger, iobCobCalculatorPlugin, dateUtil).glucoseStatusData!!
Assert.assertEquals(214.0, glucoseStatus.glucose, 0.001) Assert.assertEquals(214.0, glucoseStatus.glucose, 0.001)
Assert.assertEquals(0.0, glucoseStatus.delta, 0.001) Assert.assertEquals(0.0, glucoseStatus.delta, 0.001)
@ -78,19 +72,19 @@ class GlucoseStatusTest : TestBase() {
} }
@Test fun insufficientDataShouldReturnNull() { @Test fun insufficientDataShouldReturnNull() {
PowerMockito.`when`(autosensDataStore.getBgReadingsDataTableCopy()).thenReturn(generateInsufficientBgData()) `when`(autosensDataStore.getBgReadingsDataTableCopy()).thenReturn(generateInsufficientBgData())
val glucoseStatus: GlucoseStatus? = GlucoseStatusProvider(aapsLogger, iobCobCalculatorPlugin, dateUtil).glucoseStatusData val glucoseStatus: GlucoseStatus? = GlucoseStatusProvider(aapsLogger, iobCobCalculatorPlugin, dateUtil).glucoseStatusData
Assert.assertEquals(null, glucoseStatus) Assert.assertEquals(null, glucoseStatus)
} }
@Test fun oldDataShouldReturnNull() { @Test fun oldDataShouldReturnNull() {
PowerMockito.`when`(autosensDataStore.getBgReadingsDataTableCopy()).thenReturn(generateOldBgData()) `when`(autosensDataStore.getBgReadingsDataTableCopy()).thenReturn(generateOldBgData())
val glucoseStatus: GlucoseStatus? = GlucoseStatusProvider(aapsLogger, iobCobCalculatorPlugin, dateUtil).glucoseStatusData val glucoseStatus: GlucoseStatus? = GlucoseStatusProvider(aapsLogger, iobCobCalculatorPlugin, dateUtil).glucoseStatusData
Assert.assertEquals(null, glucoseStatus) Assert.assertEquals(null, glucoseStatus)
} }
@Test fun returnOldDataIfAllowed() { @Test fun returnOldDataIfAllowed() {
PowerMockito.`when`(autosensDataStore.getBgReadingsDataTableCopy()).thenReturn(generateOldBgData()) `when`(autosensDataStore.getBgReadingsDataTableCopy()).thenReturn(generateOldBgData())
val glucoseStatus: GlucoseStatus? = GlucoseStatusProvider(aapsLogger, iobCobCalculatorPlugin, dateUtil).getGlucoseStatusData(true) val glucoseStatus: GlucoseStatus? = GlucoseStatusProvider(aapsLogger, iobCobCalculatorPlugin, dateUtil).getGlucoseStatusData(true)
Assert.assertNotEquals(null, glucoseStatus) Assert.assertNotEquals(null, glucoseStatus)
} }
@ -100,7 +94,7 @@ class GlucoseStatusTest : TestBase() {
} }
@Test fun calculateGlucoseStatusForLibreTestBgData() { @Test fun calculateGlucoseStatusForLibreTestBgData() {
PowerMockito.`when`(autosensDataStore.getBgReadingsDataTableCopy()).thenReturn(generateLibreTestData()) `when`(autosensDataStore.getBgReadingsDataTableCopy()).thenReturn(generateLibreTestData())
val glucoseStatus: GlucoseStatus = GlucoseStatusProvider(aapsLogger, iobCobCalculatorPlugin, dateUtil).glucoseStatusData!! val glucoseStatus: GlucoseStatus = GlucoseStatusProvider(aapsLogger, iobCobCalculatorPlugin, dateUtil).glucoseStatusData!!
Assert.assertEquals(100.0, glucoseStatus.glucose, 0.001) // Assert.assertEquals(100.0, glucoseStatus.glucose, 0.001) //
Assert.assertEquals(-10.0, glucoseStatus.delta, 0.001) Assert.assertEquals(-10.0, glucoseStatus.delta, 0.001)

View file

@ -1,6 +1,7 @@
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-allopen'
apply plugin: 'com.hiya.jacoco-android' apply plugin: 'com.hiya.jacoco-android'
apply from: "${project.rootDir}/gradle/android_dependencies.gradle" apply from: "${project.rootDir}/gradle/android_dependencies.gradle"

View file

@ -1,6 +1,7 @@
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-allopen'
apply plugin: 'com.hiya.jacoco-android' apply plugin: 'com.hiya.jacoco-android'
apply from: "${project.rootDir}/gradle/android_dependencies.gradle" apply from: "${project.rootDir}/gradle/android_dependencies.gradle"

View file

@ -1,6 +1,7 @@
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-allopen'
apply plugin: 'com.hiya.jacoco-android' apply plugin: 'com.hiya.jacoco-android'
apply from: "${project.rootDir}/gradle/android_dependencies.gradle" apply from: "${project.rootDir}/gradle/android_dependencies.gradle"

View file

@ -5,10 +5,7 @@ import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.danars.DanaRSTestBase import info.nightscout.androidaps.danars.DanaRSTestBase
import org.junit.Assert import org.junit.Assert
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith
import org.powermock.modules.junit4.PowerMockRunner
@RunWith(PowerMockRunner::class)
class DanaRsPacketHistorySuspendTest : DanaRSTestBase() { class DanaRsPacketHistorySuspendTest : DanaRSTestBase() {
private val packetInjector = HasAndroidInjector { private val packetInjector = HasAndroidInjector {

View file

@ -1,6 +1,7 @@
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-allopen'
apply from: "${project.rootDir}/gradle/android_dependencies.gradle" apply from: "${project.rootDir}/gradle/android_dependencies.gradle"
apply from: "${project.rootDir}/gradle/android_module_dependencies.gradle" apply from: "${project.rootDir}/gradle/android_module_dependencies.gradle"
@ -39,3 +40,8 @@ dependencies {
implementation "com.google.dagger:dagger-android-support:$dagger_version" implementation "com.google.dagger:dagger-android-support:$dagger_version"
api "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" api "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
} }
allOpen {
// allows mocking for classes w/o directly opening them for release builds
annotation 'info.nightscout.androidaps.annotations.OpenForTesting'
}

View file

@ -1,5 +1,6 @@
package info.nightscout.androidaps.database package info.nightscout.androidaps.database
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.androidaps.database.data.NewEntries import info.nightscout.androidaps.database.data.NewEntries
import info.nightscout.androidaps.database.entities.* import info.nightscout.androidaps.database.entities.*
import info.nightscout.androidaps.database.interfaces.DBEntry import info.nightscout.androidaps.database.interfaces.DBEntry
@ -15,6 +16,7 @@ import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
import kotlin.math.roundToInt import kotlin.math.roundToInt
@OpenForTesting
@Singleton @Singleton
open class AppRepository @Inject internal constructor( open class AppRepository @Inject internal constructor(
internal val database: AppDatabase internal val database: AppDatabase

View file

@ -1,6 +1,7 @@
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-allopen'
apply plugin: 'com.hiya.jacoco-android' apply plugin: 'com.hiya.jacoco-android'
apply from: "${project.rootDir}/gradle/android_dependencies.gradle" apply from: "${project.rootDir}/gradle/android_dependencies.gradle"

View file

@ -23,3 +23,8 @@ dependencies {
kapt "com.google.dagger:dagger-android-processor:$dagger_version" kapt "com.google.dagger:dagger-android-processor:$dagger_version"
kapt "com.google.dagger:dagger-compiler:$dagger_version" kapt "com.google.dagger:dagger-compiler:$dagger_version"
} }
allOpen {
// allows mocking for classes w/o directly opening them for release builds
annotation 'info.nightscout.androidaps.annotations.OpenForTesting'
}

View file

@ -1,6 +1,7 @@
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-allopen'
apply plugin: 'com.hiya.jacoco-android' apply plugin: 'com.hiya.jacoco-android'
apply from: "${project.rootDir}/gradle/android_dependencies.gradle" apply from: "${project.rootDir}/gradle/android_dependencies.gradle"

View file

@ -1,6 +1,7 @@
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-allopen'
apply plugin: 'com.hiya.jacoco-android' apply plugin: 'com.hiya.jacoco-android'
apply from: "${project.rootDir}/gradle/android_dependencies.gradle" apply from: "${project.rootDir}/gradle/android_dependencies.gradle"

View file

@ -2,6 +2,7 @@
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-allopen'
apply plugin: 'com.hiya.jacoco-android' apply plugin: 'com.hiya.jacoco-android'
apply from: "${project.rootDir}/gradle/android_dependencies.gradle" apply from: "${project.rootDir}/gradle/android_dependencies.gradle"

View file

@ -1,6 +1,7 @@
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-allopen'
apply plugin: 'com.hiya.jacoco-android' apply plugin: 'com.hiya.jacoco-android'
apply from: "${project.rootDir}/gradle/android_dependencies.gradle" apply from: "${project.rootDir}/gradle/android_dependencies.gradle"

View file

@ -1,6 +1,7 @@
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-allopen'
apply plugin: 'com.hiya.jacoco-android' apply plugin: 'com.hiya.jacoco-android'
apply from: "${project.rootDir}/gradle/android_dependencies.gradle" apply from: "${project.rootDir}/gradle/android_dependencies.gradle"

View file

@ -1,6 +1,7 @@
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-allopen'
apply plugin: 'com.hiya.jacoco-android' apply plugin: 'com.hiya.jacoco-android'
apply from: "${project.rootDir}/gradle/android_dependencies.gradle" apply from: "${project.rootDir}/gradle/android_dependencies.gradle"

View file

@ -1,6 +1,7 @@
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-allopen'
apply plugin: 'com.hiya.jacoco-android' apply plugin: 'com.hiya.jacoco-android'
apply from: "${project.rootDir}/gradle/android_dependencies.gradle" apply from: "${project.rootDir}/gradle/android_dependencies.gradle"

View file

@ -1,6 +1,7 @@
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-allopen'
apply plugin: 'com.hiya.jacoco-android' apply plugin: 'com.hiya.jacoco-android'
apply from: "${project.rootDir}/gradle/android_dependencies.gradle" apply from: "${project.rootDir}/gradle/android_dependencies.gradle"

View file

@ -12,6 +12,7 @@ buildscript {
} }
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'kotlin-allopen'
apply plugin: 'com.hiya.jacoco-android' apply plugin: 'com.hiya.jacoco-android'
jacoco { jacoco {

View file

@ -1,9 +1,9 @@
package info.nightscout.androidaps.testing.mockers; package info.nightscout.androidaps.testing.mockers;
import android.util.Log;
import static org.powermock.api.mockito.PowerMockito.mockStatic; import static org.powermock.api.mockito.PowerMockito.mockStatic;
import android.util.Log;
public class LogMocker { public class LogMocker {
public static void prepareMock() { public static void prepareMock() {
mockStatic(Log.class); mockStatic(Log.class);

View file

@ -1,11 +1,15 @@
package info.nightscout.androidaps.testing.mockers; package info.nightscout.androidaps.testing.mockers;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.powermock.api.mockito.PowerMockito.mockStatic;
import android.os.Bundle; import android.os.Bundle;
import com.google.android.gms.wearable.Asset; import com.google.android.gms.wearable.Asset;
import com.google.android.gms.wearable.DataMap; import com.google.android.gms.wearable.DataMap;
import org.junit.Assert;
import org.mockito.invocation.InvocationOnMock; import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer; import org.mockito.stubbing.Answer;
import org.powermock.api.mockito.PowerMockito; import org.powermock.api.mockito.PowerMockito;
@ -15,11 +19,6 @@ import java.util.ArrayList;
import info.nightscout.androidaps.interaction.utils.Constants; import info.nightscout.androidaps.interaction.utils.Constants;
import info.nightscout.androidaps.interaction.utils.WearUtil; import info.nightscout.androidaps.interaction.utils.WearUtil;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.powermock.api.mockito.PowerMockito.mockStatic;
public class WearUtilMocker { public class WearUtilMocker {
public static final long REF_NOW = 1572610530000L; public static final long REF_NOW = 1572610530000L;