Merge remote-tracking branch 'Nightscout/dev' into Autotune/TuneWeekDaysClean

This commit is contained in:
Philoul 2022-11-30 22:29:55 +01:00
commit 909f30a44b
374 changed files with 986 additions and 961 deletions

View file

@ -1,7 +1,7 @@
package info.nightscout.shared
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.jupiter.api.Test
@Suppress("SpellCheckingInspection")
class SafeParseTest {

View file

@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH" tools:remove="android:maxSdkVersion" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />

View file

@ -213,6 +213,8 @@ class MainApp : DaggerApplication() {
}
if (!sp.contains(R.string.key_ns_log_app_started_event))
sp.putBoolean(R.string.key_ns_log_app_started_event, config.APS)
if (sp.getString(R.string.key_maintenance_logs_email, "") == "logs@androidaps.org")
sp.putString(R.string.key_maintenance_logs_email, "logs@aaps.app")
}
override fun applicationInjector(): AndroidInjector<out DaggerApplication> {

View file

@ -3,24 +3,22 @@ package info.nightscout.androidaps
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.TestAapsSchedulers
import info.nightscout.rx.logging.AAPSLoggerTest
import org.junit.Before
import org.junit.Rule
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.extension.ExtendWith
import org.mockito.Mockito
import org.mockito.junit.MockitoJUnit
import org.mockito.junit.MockitoRule
import java.util.*
import org.mockito.junit.jupiter.MockitoExtension
import org.mockito.junit.jupiter.MockitoSettings
import org.mockito.quality.Strictness
import java.util.Locale
@ExtendWith(MockitoExtension::class)
@MockitoSettings(strictness = Strictness.LENIENT)
open class TestBase {
val aapsLogger = AAPSLoggerTest()
val aapsSchedulers: AapsSchedulers = TestAapsSchedulers()
// Add a JUnit rule that will setup the @Mock annotated vars and log.
// Another possibility would be to add `MockitoAnnotations.initMocks(this) to the setup method.
@get:Rule
val mockitoRule: MockitoRule = MockitoJUnit.rule()
@Before
@BeforeEach
fun setupLocale() {
Locale.setDefault(Locale.ENGLISH)
System.setProperty("disableFirebase", "true")

View file

@ -18,7 +18,7 @@ import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil
import org.json.JSONObject
import org.junit.Before
import org.junit.jupiter.api.BeforeEach
import org.mockito.ArgumentMatchers.anyDouble
import org.mockito.ArgumentMatchers.anyInt
import org.mockito.ArgumentMatchers.anyString
@ -49,7 +49,7 @@ open class TestBaseWithProfile : TestBase() {
@Suppress("PropertyName") val TESTPROFILENAME = "someProfile"
@Before
@BeforeEach
fun prepareMock() {
validProfileJSON = "{\"dia\":\"5\",\"carbratio\":[{\"time\":\"00:00\",\"value\":\"30\"}],\"carbs_hr\":\"20\",\"delay\":\"20\",\"sens\":[{\"time\":\"00:00\",\"value\":\"3\"}," +
"{\"time\":\"2:00\",\"value\":\"3.4\"}],\"timezone\":\"UTC\",\"basal\":[{\"time\":\"00:00\",\"value\":\"1\"}],\"target_low\":[{\"time\":\"00:00\",\"value\":\"4.5\"}]," +

View file

@ -11,8 +11,8 @@ import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.shared.sharedPreferences.SP
import org.json.JSONArray
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mock
import org.mockito.Mockito.`when`
@ -47,7 +47,7 @@ class QuickWizardTest : TestBase() {
private lateinit var quickWizard: QuickWizard
@Before
@BeforeEach
fun mock() {
`when`(sp.getString(R.string.key_quickwizard, "[]")).thenReturn("[]")

View file

@ -10,8 +10,8 @@ import info.nightscout.androidaps.implementations.ConfigImpl
import info.nightscout.androidaps.insight.database.InsightDatabase
import info.nightscout.androidaps.insight.database.InsightDatabaseDao
import info.nightscout.androidaps.insight.database.InsightDbHelper
import info.nightscout.core.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin
import info.nightscout.core.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.database.impl.AppRepository
import info.nightscout.implementation.constraints.ConstraintsImpl
import info.nightscout.interfaces.constraints.Constraint
@ -45,8 +45,8 @@ import info.nightscout.pump.dana.DanaPump
import info.nightscout.pump.dana.database.DanaHistoryDatabase
import info.nightscout.shared.sharedPreferences.SP
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mock
import org.mockito.Mockito.`when`
@ -99,7 +99,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() {
}
}
@Before
@BeforeEach
fun prepare() {
`when`(rh.gs(R.string.closed_loop_disabled_on_dev_branch)).thenReturn("Running dev version. Closed loop is disabled.")
`when`(rh.gs(R.string.closedmodedisabledinpreferences)).thenReturn("Closed loop mode disabled in preferences")

View file

@ -6,30 +6,30 @@ import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.R
import info.nightscout.androidaps.TestBase
import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.configBuilder.RunningConfiguration
import info.nightscout.interfaces.constraints.Constraints
import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.plugins.aps.loop.LoopFragment
import info.nightscout.plugins.aps.loop.LoopPlugin
import info.nightscout.interfaces.configBuilder.RunningConfiguration
import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin
import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mock
import org.mockito.Mockito.`when`
@ -58,7 +58,7 @@ class LoopPluginTest : TestBase() {
private lateinit var loopPlugin: LoopPlugin
val injector = HasAndroidInjector { AndroidInjector { } }
@Before fun prepareMock() {
@BeforeEach fun prepareMock() {
loopPlugin = LoopPlugin(injector, aapsLogger, aapsSchedulers, rxBus, sp, config,
constraintChecker, rh, profileFunction, context, commandQueue, activePlugin, virtualPumpPlugin, iobCobCalculator, receiverStatusStore, fabricPrivacy, dateUtil, uel,

View file

@ -3,15 +3,15 @@ package info.nightscout.androidaps.plugins.configBuilder
import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBase
import info.nightscout.configuration.configBuilder.ConfigBuilderPlugin
import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.configuration.configBuilder.ConfigBuilderPlugin
import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mock
class ConfigBuilderPluginTest : TestBase() {
@ -31,7 +31,7 @@ class ConfigBuilderPluginTest : TestBase() {
}
@Before
@BeforeEach
fun prepareMock() {
configBuilderPlugin = ConfigBuilderPlugin(injector, aapsLogger, rh, sp, RxBus(aapsSchedulers, aapsLogger), activePlugin, uel, pumpSync)
}

View file

@ -11,8 +11,8 @@ import info.nightscout.interfaces.nsclient.NSSettingsStatus
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mock
import org.mockito.Mockito.`when`
import java.io.File
@ -30,7 +30,7 @@ class MaintenancePluginTest : TestBase() {
private lateinit var sut: MaintenancePlugin
@Before
@BeforeEach
fun mock() {
sut = MaintenancePlugin(injector, context, rh, sp, nsSettingsStatus, aapsLogger, config, fileListProvider, loggerUtils)
`when`(loggerUtils.suffix).thenReturn(".log.zip")

View file

@ -22,8 +22,8 @@ import info.nightscout.plugins.pump.virtual.VirtualPumpPlugin
import info.nightscout.plugins.source.GlimpPlugin
import info.nightscout.shared.sharedPreferences.SP
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mock
import org.mockito.Mockito.`when`
@ -46,7 +46,7 @@ class SafetyPluginTest : TestBaseWithProfile() {
private val injector = HasAndroidInjector { AndroidInjector { } }
private val pumpDescription = PumpDescription()
@Before
@BeforeEach
fun prepare() {
`when`(rh.gs(R.string.hardlimit)).thenReturn("hard limit")
`when`(rh.gs(R.string.itmustbepositivevalue)).thenReturn("it must be positive value")

View file

@ -13,7 +13,7 @@ import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP
import org.json.JSONObject
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Test
import org.mockito.Mock
class AbstractSensitivityPluginTest : TestBase() {

View file

@ -11,8 +11,8 @@ import info.nightscout.plugins.extensions.toText
import info.nightscout.plugins.sync.nsShared.extensions.log
import org.json.JSONObject
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mockito.`when`
import org.skyscreamer.jsonassert.JSONAssert
@ -26,7 +26,7 @@ class PumpEnactResultTest : TestBaseWithProfile() {
}
}
@Before
@BeforeEach
fun mock() {
`when`(rh.gs(R.string.success)).thenReturn("Success")
`when`(rh.gs(R.string.enacted)).thenReturn("Enacted")

View file

@ -2,7 +2,7 @@
buildscript {
ext {
kotlin_version = '1.7.21'
kotlin_version = '1.7.22'
core_version = '1.9.0'
rxjava_version = '3.1.5'
rxandroid_version = '3.0.2'
@ -32,20 +32,21 @@ buildscript {
swipe_version = '1.1.0'
junit_version = '4.13.2'
mockito_version = '4.4.0'
junit_jupiter_version = '5.7.0'
mockito_version = '4.6.1'
dexmaker_version = '1.2'
retrofit2_version = '2.9.0'
okhttp3_version = '4.10.0'
byteBuddy_version = '1.12.8'
androidx_junit_version = '1.1.3'
androidx_rules_version = '1.4.0'
androidx_junit_version = '1.1.4'
androidx_rules_version = '1.5.0'
rxandroidble_version = '1.12.1'
replayshare_version = '2.2.0'
wearable_version = '2.9.0'
play_services_wearable_version = '17.1.0'
play_services_wearable_version = '18.0.0'
play_services_location_version = '21.0.1'
kotlinx_datetime_version = '0.4.0'

View file

@ -1,6 +1,7 @@
package info.nightscout.core.iob.iobCobCalculator
import dagger.Reusable
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.core.iob.asRounded
import info.nightscout.core.iob.log
import info.nightscout.interfaces.iob.GlucoseStatus
@ -12,6 +13,7 @@ import javax.inject.Inject
import kotlin.math.roundToLong
@Reusable
@OpenForTesting
class GlucoseStatusProvider @Inject constructor(
private val aapsLogger: AAPSLogger,
private val iobCobCalculator: IobCobCalculator,

View file

@ -4,23 +4,21 @@ import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.TestAapsSchedulers
import info.nightscout.rx.logging.AAPSLoggerTest
import org.junit.Before
import org.junit.Rule
import org.junit.jupiter.api.extension.ExtendWith
import org.mockito.Mockito
import org.mockito.junit.MockitoJUnit
import org.mockito.junit.MockitoRule
import java.util.*
import org.mockito.junit.jupiter.MockitoExtension
import org.mockito.junit.jupiter.MockitoSettings
import org.mockito.quality.Strictness
import java.util.Locale
@Suppress("SpellCheckingInspection")
@ExtendWith(MockitoExtension::class)
@MockitoSettings(strictness = Strictness.LENIENT)
open class TestBase {
val aapsLogger = AAPSLoggerTest()
val aapsSchedulers: AapsSchedulers = TestAapsSchedulers()
// Add a JUnit rule that will setup the @Mock annotated vars and log.
// Another possibility would be to add `MockitoAnnotations.initMocks(this) to the setup method.
@get:Rule
val mockitoRule: MockitoRule = MockitoJUnit.rule()
@Before
fun setupLocale() {
Locale.setDefault(Locale.ENGLISH)

View file

@ -17,7 +17,7 @@ import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil
import org.json.JSONObject
import org.junit.Before
import org.junit.jupiter.api.BeforeEach
import org.mockito.Mock
import org.mockito.Mockito.`when`
@ -57,7 +57,7 @@ open class TestBaseWithProfile : TestBase() {
lateinit var invalidProfile: Profile
@Suppress("PropertyName") val TESTPROFILENAME = "someProfile"
@Before
@BeforeEach
fun prepareMock() {
invalidProfileJSON = "{\"dia\":\"1\",\"carbratio\":[{\"time\":\"00:00\",\"value\":\"30\"}],\"carbs_hr\":\"20\",\"delay\":\"20\",\"sens\":[{\"time\":\"00:00\",\"value\":\"3\"}," +
"{\"time\":\"2:00\",\"value\":\"3.4\"}],\"timezone\":\"UTC\",\"basal\":[{\"time\":\"00:00\",\"value\":\"1\"}],\"target_low\":[{\"time\":\"00:00\",\"value\":\"4.5\"}]," +

View file

@ -3,8 +3,8 @@ package info.nightscout.androidaps.data
import info.nightscout.androidaps.TestBase
import info.nightscout.interfaces.constraints.Constraint
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
/**
* Created by mike on 19.03.2018.
@ -49,7 +49,7 @@ class ConstraintTest : TestBase() {
Assert.assertEquals(10.0, d.originalValue(), 0.01)
}
@Before
@BeforeEach
fun prepareMock() {
}
}

View file

@ -9,7 +9,7 @@ import info.nightscout.database.entities.TherapyEvent
import info.nightscout.interfaces.pump.DetailedBolusInfo
import org.apache.commons.lang3.builder.EqualsBuilder
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Test
import org.mockito.Mock
class DetailedBolusInfoTest : TestBase() {

View file

@ -2,7 +2,7 @@ package info.nightscout.androidaps.data
import info.nightscout.interfaces.iob.Iob
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Test
class IobTest {

View file

@ -11,8 +11,8 @@ import info.nightscout.core.iob.round
import info.nightscout.interfaces.iob.IobTotal
import info.nightscout.shared.utils.DateUtil
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mock
@Suppress("SpellCheckingInspection")
@ -23,7 +23,7 @@ class IobTotalTest : TestBase() {
private lateinit var dateUtil: DateUtil
private var now = 0L
@Before
@BeforeEach
fun prepare() {
dateUtil = DateUtil(context)
now = dateUtil.now()

View file

@ -2,7 +2,7 @@ package info.nightscout.androidaps.data
import info.nightscout.interfaces.iob.MealData
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Test
class MealDataTest {

View file

@ -20,8 +20,8 @@ import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil
import org.json.JSONObject
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mock
import org.mockito.Mockito.anyInt
import org.mockito.Mockito.anyString
@ -59,7 +59,7 @@ class ProfileTest : TestBase() {
//String profileStore = "{\"defaultProfile\":\"Default\",\"store\":{\"Default\":" + validProfile + "}}";
@Before
@BeforeEach
fun prepare() {
testPumpPlugin = TestPumpPlugin { AndroidInjector { } }
dateUtil = DateUtil(context)
@ -159,7 +159,7 @@ class ProfileTest : TestBase() {
00:00 6.2 mmol/U
01:00 6.0 mmol/U
03:00 6.2 mmol/U
""".trimIndent(), p.getIsfList(rh, dateUtil)
""".trimIndent(), p.getIsfList(rh, dateUtil).replace(',', '.')
)
// Test hour alignment

View file

@ -12,7 +12,7 @@ import info.nightscout.database.entities.data.checkSanity
import info.nightscout.shared.utils.T
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Test
class BlockExtensionKtTest {

View file

@ -4,7 +4,7 @@ import androidx.fragment.app.Fragment
import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Test
class PluginDescriptionTest {

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.interfaces
import info.nightscout.androidaps.TestBaseWithProfile
import info.nightscout.interfaces.profile.PureProfile
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Test
internal class ProfileStoreTest : TestBaseWithProfile() {

View file

@ -5,7 +5,7 @@ import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.pump.defs.PumpTempBasalType
import info.nightscout.interfaces.pump.defs.PumpType
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Test
class PumpDescriptionTest {

View file

@ -12,8 +12,8 @@ import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.interfaces.pump.defs.PumpType
import info.nightscout.interfaces.utils.JsonHelper.safeGetDouble
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.ArgumentMatchers
import org.mockito.Mock
import org.mockito.Mockito.`when`
@ -329,7 +329,7 @@ class APSResultTest : TestBaseWithProfile() {
Assert.assertEquals(false, apsResult.json()?.has("rate"))
}
@Before
@BeforeEach
fun prepare() {
`when`(constraints.isClosedLoopAllowed(anyObject())).thenReturn(closedLoopEnabled)
`when`(activePluginProvider.activePump).thenReturn(testPumpPlugin)

View file

@ -1,8 +1,8 @@
package info.nightscout.androidaps.plugins.iob.iobCalculator
import info.nightscout.androidaps.TestBase
import info.nightscout.core.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.core.iob.asRounded
import info.nightscout.core.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.core.iob.log
import info.nightscout.database.entities.GlucoseValue
import info.nightscout.interfaces.aps.AutosensDataStore
@ -11,8 +11,8 @@ import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mock
import org.mockito.Mockito.`when`
@ -26,7 +26,7 @@ class GlucoseStatusTest : TestBase() {
@Mock lateinit var iobCobCalculatorPlugin: IobCobCalculator
@Mock lateinit var autosensDataStore: AutosensDataStore
@Before
@BeforeEach
fun prepare() {
`when`(iobCobCalculatorPlugin.ads).thenReturn(autosensDataStore)
}
@ -103,7 +103,7 @@ class GlucoseStatusTest : TestBase() {
Assert.assertEquals(1514766900000L, glucoseStatus.date) // latest date
}
@Before
@BeforeEach
fun initMocking() {
`when`(dateUtil.now()).thenReturn(1514766900000L + T.mins(1).msecs())
`when`(iobCobCalculatorPlugin.ads).thenReturn(autosensDataStore)

View file

@ -7,8 +7,8 @@ import info.nightscout.database.entities.GlucoseValue
import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mock
class AutosensDataStoreTest : TestBase() {
@ -19,7 +19,7 @@ class AutosensDataStoreTest : TestBase() {
private val autosensDataStore = AutosensDataStoreObject()
@Before
@BeforeEach
fun mock() {
dateUtil = DateUtil(context)
}

View file

@ -1,7 +1,7 @@
package info.nightscout.androidaps.pump.common.utils;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import info.nightscout.core.utils.DateTimeUtil;

View file

@ -6,7 +6,7 @@ import org.hamcrest.CoreMatchers.containsString
import org.hamcrest.CoreMatchers.not
import org.junit.Assert
import org.junit.Assume.assumeThat
import org.junit.Test
import org.junit.jupiter.api.Test
// https://stackoverflow.com/questions/52344522/joseexception-couldnt-create-aes-gcm-nopadding-cipher-illegal-key-size
// https://stackoverflow.com/questions/47708951/can-aes-256-work-on-android-devices-with-api-level-26

View file

@ -7,10 +7,10 @@ import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Test
import org.mockito.Mock
import org.mockito.Mockito.`when`
import java.util.*
import java.util.Date
class DateUtilTest : TestBase() {

View file

@ -2,7 +2,7 @@ package info.nightscout.androidaps.utils
import info.nightscout.interfaces.utils.DecimalFormatter
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Test
class DecimalFormatterTest {

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.utils
import info.nightscout.interfaces.utils.JsonHelper
import org.json.JSONObject
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Test
@Suppress("SpellCheckingInspection")
class JsonHelperTest {

View file

@ -2,8 +2,8 @@ package info.nightscout.androidaps.utils
import info.nightscout.interfaces.utils.MidnightTime
import org.junit.Assert
import org.junit.Test
import java.util.*
import org.junit.jupiter.api.Test
import java.util.Calendar
class MidnightTimeTest {

View file

@ -2,7 +2,7 @@ package info.nightscout.androidaps.utils
import info.nightscout.interfaces.utils.Round
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Test
class RoundTest {

View file

@ -2,7 +2,7 @@ package info.nightscout.androidaps.utils
import info.nightscout.core.utils.receivers.StringUtils
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Test
class StringUtilsTest {

View file

@ -2,7 +2,7 @@ package info.nightscout.androidaps.utils
import info.nightscout.shared.utils.T
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Test
import kotlin.math.abs
@Suppress("SpellCheckingInspection")

View file

@ -22,7 +22,7 @@ import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Test
import org.mockito.Mock
import org.mockito.Mockito
import org.mockito.Mockito.`when`

View file

@ -1,14 +1,17 @@
dependencies {
testImplementation "junit:junit:$junit_version"
//testImplementation "junit:junit:$junit_version"
testImplementation "org.junit.jupiter:junit-jupiter:$junit_jupiter_version"
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_jupiter_version"
testImplementation "org.json:json:$json_version"
testImplementation "org.mockito:mockito-core:$mockito_version"
testImplementation "org.mockito:mockito-inline:$mockito_version"
testImplementation "org.mockito:mockito-junit-jupiter:$mockito_version"
testImplementation "org.mockito.kotlin:mockito-kotlin:4.1.0"
//testImplementation "org.mockito:mockito-inline:$mockito_version"
testImplementation "joda-time:joda-time:$jodatime_version"
testImplementation "com.google.truth:truth:1.1.3"
testImplementation "org.skyscreamer:jsonassert:1.5.0"
testImplementation "org.hamcrest:hamcrest-all:1.3"
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
androidTestImplementation "androidx.test.ext:junit-ktx:$androidx_junit_version"
androidTestImplementation "androidx.test:rules:$androidx_rules_version"
@ -20,6 +23,7 @@ tasks.matching { it instanceof Test }.all {
// use to display stdout in travis
testLogging.events = ["failed", "skipped", "started", "standard_out"]
testLogging.exceptionFormat = "full"
useJUnitPlatform()
}
android {

View file

@ -71,7 +71,7 @@ abstract class PluginBase(
* So far plugin can have it's main type + ConstraintInterface
* ConstraintInterface is enabled if main plugin is enabled
*/
fun setPluginEnabled(type: PluginType, newState: Boolean) {
open fun setPluginEnabled(type: PluginType, newState: Boolean) {
if (type == pluginDescription.mainType) {
if (newState) { // enabling plugin
if (state != State.ENABLED) {
@ -91,7 +91,7 @@ abstract class PluginBase(
}
}
fun setFragmentVisible(type: PluginType, fragmentVisible: Boolean) {
open fun setFragmentVisible(type: PluginType, fragmentVisible: Boolean) {
if (type == pluginDescription.mainType) {
this.fragmentVisible = fragmentVisible && specialEnableCondition()
}

View file

@ -0,0 +1,4 @@
package info.nightscout.interfaces.source
interface DoingOwnUploadSource {
}

View file

@ -3,11 +3,13 @@ package info.nightscout.interfaces.utils
import android.content.Context
import android.content.Intent
import android.provider.AlarmClock
import info.nightscout.androidaps.annotations.OpenForTesting
import javax.inject.Inject
import javax.inject.Singleton
@OpenForTesting
@Singleton
class TimerUtil @Inject constructor(
open class TimerUtil @Inject constructor(
private val context: Context
) {

View file

@ -1,23 +0,0 @@
package info.nightscout.core.validators
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("info.nightscout.core.validators.test", appContext.packageName)
}
}

View file

@ -1,17 +0,0 @@
package info.nightscout.core.validators
import org.junit.Assert.assertEquals
import org.junit.Test
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}

View file

@ -127,7 +127,7 @@ import kotlin.math.roundToInt
return ret.toString()
}
fun clearCachedData(from: Long) {
fun clearCachedTddData(from: Long) {
database.totalDailyDoseDao.deleteNewerThan(from, InterfaceIDs.PumpType.CACHE)
}
@ -863,7 +863,7 @@ import kotlin.math.roundToInt
.subscribeOn(Schedulers.io())
.toWrappedSingle()
fun createTotalDailyDose(tdd: TotalDailyDose) {
fun insertTotalDailyDose(tdd: TotalDailyDose) {
database.totalDailyDoseDao.insert(tdd)
}

View file

@ -41,7 +41,7 @@ class TddCalculatorImpl @Inject constructor(
override fun calculate(days: Long): LongSparseArray<TotalDailyDose> {
var startTime = MidnightTime.calc(dateUtil.now() - T.days(days).msecs())
val endTime = MidnightTime.calc(dateUtil.now())
val stepSize = T.hours(24).msecs()
//val stepSize = T.hours(24).msecs() // this is not true on DST change
val result = LongSparseArray<TotalDailyDose>()
// Try to load cached values
@ -49,21 +49,24 @@ class TddCalculatorImpl @Inject constructor(
val tdd = repository.getCalculatedTotalDailyDose(startTime).blockingGet()
if (tdd is ValueWrapper.Existing) result.put(startTime, tdd.value)
else break
startTime += stepSize
//startTime += stepSize
startTime = MidnightTime.calc(startTime + T.hours(27).msecs()) // be sure we find correct midnight
}
if (endTime > startTime) {
for (midnight in startTime until endTime step stepSize) {
val tdd = calculate(midnight, midnight + stepSize)
var midnight = startTime
while (midnight < endTime) {
val tdd = calculate(midnight, midnight + T.hours(24).msecs())
result.put(midnight, tdd)
midnight = MidnightTime.calc(midnight + T.hours(27).msecs()) // be sure we find correct midnight
}
}
for (i in 0 until result.size()) {
val tdd = result.valueAt(i)
if (tdd.interfaceIDs.pumpType != InterfaceIDs.PumpType.CACHE) {
tdd.interfaceIDs.pumpType = InterfaceIDs.PumpType.CACHE
aapsLogger.debug(LTag.CORE, "Storing TDD $tdd")
repository.createTotalDailyDose(tdd)
aapsLogger.debug(LTag.CORE, "Storing TDD ${tdd.timestamp}")
repository.insertTotalDailyDose(tdd)
}
}
return result

View file

@ -5,8 +5,8 @@ import android.content.Context
import android.view.Gravity
import android.widget.TableRow
import android.widget.TextView
import info.nightscout.core.main.R
import info.nightscout.database.entities.TotalDailyDose
import info.nightscout.implementation.R
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil
@ -27,7 +27,7 @@ fun TotalDailyDose.Companion.toTableRowHeader(context: Context, rh: ResourceHelp
header.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 3; weight = 1f }; text = rh.gs(R.string.basal) })
header.addView(TextView(context).apply { gravity = Gravity.CENTER_HORIZONTAL; layoutParams = lp.apply { column = 4; weight = 1f }; text = rh.gs(R.string.basalpct) })
if (includeCarbs)
header.addView(TextView(context).apply { layoutParams = lp.apply { column = 5; weight = 1f }; text = rh.gs(R.string.carbs) })
header.addView(TextView(context).apply { layoutParams = lp.apply { column = 5; weight = 1f }; text = rh.gs(R.string.carbs_short) })
}
fun TotalDailyDose.toTableRow(context: Context, rh: ResourceHelper, dateUtil: DateUtil, includeCarbs: Boolean): TableRow =

View file

@ -27,5 +27,6 @@
<string name="detailed_14_days">Detailed 14 days</string>
<string name="day_tir">Day TIR</string>
<string name="night_tir">Night TIR</string>
<string name="carbs_short" comment="max 6 characters">Carbs</string>
</resources>

View file

@ -3,24 +3,22 @@ package info.nightscout.androidaps
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.TestAapsSchedulers
import info.nightscout.rx.logging.AAPSLoggerTest
import org.junit.Before
import org.junit.Rule
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.extension.ExtendWith
import org.mockito.Mockito
import org.mockito.junit.MockitoJUnit
import org.mockito.junit.MockitoRule
import org.mockito.junit.jupiter.MockitoExtension
import org.mockito.junit.jupiter.MockitoSettings
import org.mockito.quality.Strictness
import java.util.Locale
@ExtendWith(MockitoExtension::class)
@MockitoSettings(strictness = Strictness.LENIENT)
open class TestBase {
val aapsLogger = AAPSLoggerTest()
val aapsSchedulers: AapsSchedulers = TestAapsSchedulers()
// Add a JUnit rule that will setup the @Mock annotated vars and log.
// Another possibility would be to add `MockitoAnnotations.initMocks(this) to the setup method.
@get:Rule
val mockitoRule: MockitoRule = MockitoJUnit.rule()
@Before
@BeforeEach
fun setupLocale() {
Locale.setDefault(Locale.ENGLISH)
System.setProperty("disableFirebase", "true")

View file

@ -18,7 +18,7 @@ import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil
import org.json.JSONObject
import org.junit.Before
import org.junit.jupiter.api.BeforeEach
import org.mockito.ArgumentMatchers.anyDouble
import org.mockito.ArgumentMatchers.anyInt
import org.mockito.ArgumentMatchers.anyString
@ -49,7 +49,7 @@ open class TestBaseWithProfile : TestBase() {
@Suppress("PropertyName") val TESTPROFILENAME = "someProfile"
@Before
@BeforeEach
fun prepareMock() {
validProfileJSON = "{\"dia\":\"5\",\"carbratio\":[{\"time\":\"00:00\",\"value\":\"30\"}],\"carbs_hr\":\"20\",\"delay\":\"20\",\"sens\":[{\"time\":\"00:00\",\"value\":\"3\"}," +
"{\"time\":\"2:00\",\"value\":\"3.4\"}],\"timezone\":\"UTC\",\"basal\":[{\"time\":\"00:00\",\"value\":\"1\"}],\"target_low\":[{\"time\":\"00:00\",\"value\":\"4.5\"}]," +

View file

@ -1,6 +1,7 @@
package info.nightscout.androidaps
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.pump.Pump
@ -13,6 +14,7 @@ import info.nightscout.interfaces.utils.TimeChangeType
import org.json.JSONObject
@Suppress("MemberVisibilityCanBePrivate")
@OpenForTesting
class TestPumpPlugin(val injector: HasAndroidInjector) : Pump {
var connected = false

View file

@ -19,8 +19,8 @@ import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mock
import org.mockito.Mockito.anyInt
import org.mockito.Mockito.`when`
@ -52,7 +52,7 @@ class BolusTimerImplTest : TestBase() {
private lateinit var automationPlugin: AutomationPlugin
private lateinit var sut: BolusTimerImpl
@Before
@BeforeEach
fun init() {
`when`(rh.gs(anyInt())).thenReturn("")
`when`(profileFunction.getUnits()).thenReturn(GlucoseUnit.MGDL)

View file

@ -20,10 +20,11 @@ import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mock
import org.mockito.Mockito
import org.mockito.Mockito.any
import org.mockito.Mockito.anyInt
import org.mockito.Mockito.`when`
@ -40,7 +41,6 @@ class CarbTimerImplTest : TestBase() {
@Mock lateinit var locationServiceHelper: LocationServiceHelper
@Mock lateinit var activePlugin: ActivePlugin
@Mock lateinit var profileFunction: ProfileFunction
@Mock lateinit var timerUtil: TimerUtil
private val injector = HasAndroidInjector {
AndroidInjector {
@ -51,15 +51,17 @@ class CarbTimerImplTest : TestBase() {
}
}
private lateinit var dateUtil: DateUtil
private lateinit var timerUtil: TimerUtil
private lateinit var automationPlugin: AutomationPlugin
private lateinit var sut: CarbTimerImpl
@Before
@BeforeEach
fun init() {
`when`(rh.gs(anyInt())).thenReturn("")
`when`(profileFunction.getUnits()).thenReturn(GlucoseUnit.MGDL)
dateUtil = DateUtil(context)
timerUtil = TimerUtil(context)
automationPlugin = AutomationPlugin(injector, rh, context, sp, fabricPrivacy, loop, rxBus, constraintChecker, aapsLogger, aapsSchedulers, config, locationServiceHelper, dateUtil, activePlugin)
sut = CarbTimerImpl(injector, rh, automationPlugin, timerUtil)
}
@ -73,6 +75,6 @@ class CarbTimerImplTest : TestBase() {
Assert.assertEquals(0, automationPlugin.size())
sut.scheduleTimeToEatReminder(1)
Mockito.verify(timerUtil, Mockito.times(1)).scheduleReminder(1, "")
Mockito.verify(context, Mockito.times(1)).startActivity(any())
}
}

View file

@ -4,8 +4,8 @@ import info.nightscout.androidaps.TestBase
import info.nightscout.interfaces.pump.DetailedBolusInfo
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
class DetailedBolusInfoStorageTest : TestBase() {
@ -24,7 +24,7 @@ class DetailedBolusInfoStorageTest : TestBase() {
info3.insulin = 5.0
}
@Before
@BeforeEach
fun prepare() {
detailedBolusInfoStorage = DetailedBolusInfoStorageImpl(aapsLogger)
}

View file

@ -1,12 +1,11 @@
package info.nightscout.implementation.pump
import info.nightscout.androidaps.TestBase
import info.nightscout.interfaces.pump.TemporaryBasalStorage
import info.nightscout.interfaces.pump.PumpSync
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
class TemporaryBasalStorageTest : TestBase() {
@ -16,7 +15,7 @@ class TemporaryBasalStorageTest : TestBase() {
private lateinit var temporaryBasalStorage: TemporaryBasalStorageImpl
@Before
@BeforeEach
fun prepare() {
temporaryBasalStorage = TemporaryBasalStorageImpl(aapsLogger)
}

View file

@ -39,8 +39,8 @@ import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil
import io.reactivex.rxjava3.core.Single
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mock
import org.mockito.Mockito.anyLong
import org.mockito.Mockito.mock
@ -118,7 +118,7 @@ class CommandQueueImplementationTest : TestBaseWithProfile() {
private lateinit var commandQueue: CommandQueueImplementation
private lateinit var testPumpPlugin: TestPumpPlugin
@Before
@BeforeEach
fun prepare() {
commandQueue = CommandQueueMocked(
injector, aapsLogger, rxBus, aapsSchedulers, rh,

View file

@ -20,8 +20,8 @@ import info.nightscout.interfaces.queue.Command
import info.nightscout.interfaces.ui.UiInteraction
import info.nightscout.shared.sharedPreferences.SP
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.ArgumentMatchers
import org.mockito.Mock
import org.mockito.Mockito
@ -54,7 +54,7 @@ class QueueThreadTest : TestBaseWithProfile() {
private lateinit var commandQueue: CommandQueueImplementation
private lateinit var sut: QueueThread
@Before
@BeforeEach
fun prepare() {
pumpPlugin = TestPumpPlugin(injector)
commandQueue = CommandQueueImplementation(

View file

@ -1,5 +1,6 @@
package info.nightscout.plugins.general.autotune
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.interfaces.logging.LoggerUtils
import info.nightscout.plugins.aps.R
import info.nightscout.plugins.general.autotune.data.ATProfile
@ -23,6 +24,7 @@ import javax.inject.Inject
import javax.inject.Singleton
@Singleton
@OpenForTesting
class AutotuneFS @Inject constructor(
private val rh: ResourceHelper,
private val loggerUtils: LoggerUtils

View file

@ -3,24 +3,22 @@ package info.nightscout.androidaps
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.TestAapsSchedulers
import info.nightscout.rx.logging.AAPSLoggerTest
import org.junit.Before
import org.junit.Rule
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.extension.ExtendWith
import org.mockito.Mockito
import org.mockito.junit.MockitoJUnit
import org.mockito.junit.MockitoRule
import org.mockito.junit.jupiter.MockitoExtension
import org.mockito.junit.jupiter.MockitoSettings
import org.mockito.quality.Strictness
import java.util.Locale
@ExtendWith(MockitoExtension::class)
@MockitoSettings(strictness = Strictness.LENIENT)
open class TestBase {
val aapsLogger = AAPSLoggerTest()
val aapsSchedulers: AapsSchedulers = TestAapsSchedulers()
// Add a JUnit rule that will setup the @Mock annotated vars and log.
// Another possibility would be to add `MockitoAnnotations.initMocks(this) to the setup method.
@get:Rule
val mockitoRule: MockitoRule = MockitoJUnit.rule()
@Before
@BeforeEach
fun setupLocale() {
Locale.setDefault(Locale.ENGLISH)
System.setProperty("disableFirebase", "true")

View file

@ -17,7 +17,7 @@ import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil
import org.json.JSONObject
import org.junit.Before
import org.junit.jupiter.api.BeforeEach
import org.mockito.ArgumentMatchers.anyDouble
import org.mockito.ArgumentMatchers.anyInt
import org.mockito.ArgumentMatchers.anyString
@ -48,7 +48,7 @@ open class TestBaseWithProfile : TestBase() {
@Suppress("PropertyName") val TESTPROFILENAME = "someProfile"
@Before
@BeforeEach
fun prepareMock() {
validProfileJSON = "{\"dia\":\"5\",\"carbratio\":[{\"time\":\"00:00\",\"value\":\"30\"}],\"carbs_hr\":\"20\",\"delay\":\"20\",\"sens\":[{\"time\":\"00:00\",\"value\":\"3\"}," +
"{\"time\":\"2:00\",\"value\":\"3.4\"}],\"timezone\":\"UTC\",\"basal\":[{\"time\":\"00:00\",\"value\":\"1\"}],\"target_low\":[{\"time\":\"00:00\",\"value\":\"4.5\"}]," +

View file

@ -16,8 +16,8 @@ import info.nightscout.shared.utils.T
import org.json.JSONArray
import org.json.JSONObject
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mock
import org.mockito.Mockito.`when`
import java.io.File
@ -33,7 +33,7 @@ class AutotuneCoreTest : TestBaseWithProfile() {
private var autotuneMin = 0.0
private var autotuneMax = 0.0
@Before
@BeforeEach
fun initData() {
autotuneCore = AutotuneCore(sp, autotuneFS)
TimeZone.setDefault(TimeZone.getTimeZone("GMT+2"))

View file

@ -24,8 +24,8 @@ import info.nightscout.shared.utils.T
import org.json.JSONArray
import org.json.JSONObject
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mock
import org.mockito.Mockito.`when`
import java.io.File
@ -45,7 +45,7 @@ class AutotunePrepTest : TestBaseWithProfile() {
private var autotuneMax = 0.0
private var startDayTime = 0L
@Before
@BeforeEach
fun initData() {
ts = T.msecs(TimeZone.getDefault().getOffset(System.currentTimeMillis()).toLong()).hours().toInt() - 2
}

View file

@ -1,11 +1,13 @@
package info.nightscout.plugins.general.autotune
import info.nightscout.androidaps.TestBaseWithProfile
import info.nightscout.plugins.general.autotune.data.BGDatum
import info.nightscout.plugins.general.autotune.data.CRDatum
import info.nightscout.plugins.general.autotune.data.PreppedGlucose
import org.json.JSONObject
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import java.io.File
class PreppedGlucoseTest : TestBaseWithProfile() {
@ -13,7 +15,7 @@ class PreppedGlucoseTest : TestBaseWithProfile() {
private lateinit var prep1: PreppedGlucose
private lateinit var prepJson1: String
@Before
@BeforeEach
fun initData() {
prepJson1 = File("src/test/res/autotune/test1/autotune.2022-05-21.json").readText()
prep1 = PreppedGlucose(JSONObject(prepJson1), dateUtil)
@ -22,22 +24,22 @@ class PreppedGlucoseTest : TestBaseWithProfile() {
@Test
fun preppedGlucoseLoadTest() { // Test if load from file of OpenAPS categorisation is Ok
val crData0 =
info.nightscout.plugins.general.autotune.data.CRDatum(
CRDatum(
JSONObject("{\"CRInitialIOB\":13.594,\"CRInitialBG\":123,\"CRInitialCarbTime\":\"2022-05-21T07:54:09.000Z\",\"CREndIOB\":-0.155,\"CREndBG\":98,\"CREndTime\":\"2022-05-21T11:19:08.000Z\",\"CRCarbs\":70,\"CRInsulin\":-2.13}"),
dateUtil
)
val csfDataEnd =
info.nightscout.plugins.general.autotune.data.BGDatum(
BGDatum(
JSONObject("{\"device\":\"AndroidAPS-DexcomG6\",\"date\":1653176050000,\"dateString\":\"2022-05-21T23:34:10.000Z\",\"isValid\":true,\"sgv\":127,\"direction\":\"Flat\",\"type\":\"sgv\",\"_id\":\"6289771371a363000480abc1\",\"glucose\":127,\"avgDelta\":\"2.50\",\"BGI\":-2.93,\"deviation\":\"5.43\",\"mealCarbs\":0,\"mealAbsorption\":\"end\"}"),
dateUtil
)
val isfData0 =
info.nightscout.plugins.general.autotune.data.BGDatum(
BGDatum(
JSONObject("{\"device\":\"AndroidAPS-DexcomG6\",\"date\":1653108249000,\"dateString\":\"2022-05-21T04:44:09.000Z\",\"isValid\":true,\"sgv\":123,\"direction\":\"FortyFiveDown\",\"type\":\"sgv\",\"_id\":\"62886e2919e2e60004989bba\",\"glucose\":123,\"avgDelta\":\"-7.50\",\"BGI\":-7.59,\"deviation\":\"0.09\"}"),
dateUtil
)
val basalDataEnd =
info.nightscout.plugins.general.autotune.data.BGDatum(
BGDatum(
JSONObject("{\"device\":\"AndroidAPS-DexcomG6\",\"date\":1653180549000,\"dateString\":\"2022-05-22T00:49:09.000Z\",\"isValid\":true,\"sgv\":121,\"direction\":\"FortyFiveDown\",\"type\":\"sgv\",\"_id\":\"628988a3da46aa0004d1e0f5\",\"glucose\":121,\"avgDelta\":\"-5.25\",\"BGI\":-3.32,\"deviation\":\"-1.93\"}"),
dateUtil
)

View file

@ -5,6 +5,7 @@ import android.content.Context
import android.content.Intent
import android.content.ServiceConnection
import android.os.IBinder
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.interfaces.NotificationHolder
import javax.inject.Inject
import javax.inject.Singleton
@ -19,6 +20,7 @@ import javax.inject.Singleton
*/
@Singleton
@OpenForTesting
class LocationServiceHelper @Inject constructor(
private val notificationHolder: NotificationHolder
) {

View file

@ -3,26 +3,24 @@ package info.nightscout.androidaps
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.TestAapsSchedulers
import info.nightscout.rx.logging.AAPSLoggerTest
import org.junit.Before
import org.junit.Rule
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.extension.ExtendWith
import org.mockito.ArgumentMatcher
import org.mockito.Mockito
import org.mockito.junit.MockitoJUnit
import org.mockito.junit.MockitoRule
import org.mockito.junit.jupiter.MockitoExtension
import org.mockito.junit.jupiter.MockitoSettings
import org.mockito.quality.Strictness
import java.util.Locale
@Suppress("SpellCheckingInspection")
@ExtendWith(MockitoExtension::class)
@MockitoSettings(strictness = Strictness.LENIENT)
open class TestBase {
val aapsLogger = AAPSLoggerTest()
val aapsSchedulers: AapsSchedulers = TestAapsSchedulers()
// Add a JUnit rule that will setup the @Mock annotated vars and log.
// Another possibility would be to add `MockitoAnnotations.initMocks(this) to the setup method.
@get:Rule
val mockitoRule: MockitoRule = MockitoJUnit.rule()
@Before
@BeforeEach
fun setupLocale() {
Locale.setDefault(Locale.ENGLISH)
System.setProperty("disableFirebase", "true")

View file

@ -16,7 +16,7 @@ import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil
import org.json.JSONObject
import org.junit.Before
import org.junit.jupiter.api.BeforeEach
import org.mockito.Mock
@Suppress("SpellCheckingInspection")
@ -42,7 +42,7 @@ open class TestBaseWithProfile : TestBase() {
lateinit var validProfile: Profile
@Suppress("PropertyName") val TESTPROFILENAME = "someProfile"
@Before
@BeforeEach
fun prepareMock() {
validProfileJSON = "{\"dia\":\"5\",\"carbratio\":[{\"time\":\"00:00\",\"value\":\"30\"}],\"carbs_hr\":\"20\",\"delay\":\"20\",\"sens\":[{\"time\":\"00:00\",\"value\":\"3\"}," +
"{\"time\":\"2:00\",\"value\":\"3.4\"}],\"timezone\":\"UTC\",\"basal\":[{\"time\":\"00:00\",\"value\":\"1\"}],\"target_low\":[{\"time\":\"00:00\",\"value\":\"4.5\"}]," +

View file

@ -15,7 +15,7 @@ import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.interfaces.ResourceHelper
import org.json.JSONObject
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Test
import org.mockito.Mock
class AutomationEventTest : TestBase() {

View file

@ -7,7 +7,7 @@ import info.nightscout.automation.triggers.Trigger
import info.nightscout.automation.triggers.TriggerConnector
import info.nightscout.automation.triggers.TriggerDummy
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Test
class ComposeTriggerTest : TestBase() {

View file

@ -14,8 +14,8 @@ import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.ArgumentMatchers
import org.mockito.Mock
import org.mockito.Mockito.`when`
@ -25,10 +25,10 @@ class ActionAlarmTest : TestBase() {
@Mock lateinit var rh: ResourceHelper
@Mock lateinit var rxBus: RxBus
@Mock lateinit var context: Context
@Mock lateinit var timerUtil: TimerUtil
@Mock lateinit var dateUtil: DateUtil
@Mock lateinit var config: Config
private lateinit var timerUtil: TimerUtil
private lateinit var sut: ActionAlarm
var injector: HasAndroidInjector = HasAndroidInjector {
AndroidInjector {
@ -46,12 +46,12 @@ class ActionAlarmTest : TestBase() {
}
}
@Before
@BeforeEach
fun setup() {
`when`(context.getString(info.nightscout.core.main.R.string.ok)).thenReturn("OK")
`when`(context.getString(info.nightscout.core.main.R.string.alarm)).thenReturn("Alarm")
`when`(rh.gs(ArgumentMatchers.eq(R.string.alarm_message), ArgumentMatchers.anyString())).thenReturn("Alarm: %s")
timerUtil = TimerUtil(context)
sut = ActionAlarm(injector)
}
@ -69,6 +69,7 @@ class ActionAlarmTest : TestBase() {
}
@Test fun doActionTest() {
sut.text = InputString("Asd")
sut.doAction(object : Callback() {
override fun run() {
Assert.assertTrue(result.success)

View file

@ -1,16 +1,16 @@
package info.nightscout.automation.actions
import info.nightscout.automation.elements.InputCarePortalMenu
import info.nightscout.automation.elements.InputDuration
import info.nightscout.automation.elements.InputString
import info.nightscout.database.impl.transactions.InsertIfNewByTimestampTherapyEventTransaction
import info.nightscout.database.impl.transactions.Transaction
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.queue.Callback
import info.nightscout.automation.elements.InputCarePortalMenu
import info.nightscout.automation.elements.InputDuration
import info.nightscout.automation.elements.InputString
import io.reactivex.rxjava3.core.Single
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.ArgumentMatchers
import org.mockito.Mockito.`when`
@ -18,7 +18,7 @@ class ActionCarePortalEventTest : ActionsTestBase() {
private lateinit var sut: ActionCarePortalEvent
@Before
@BeforeEach
fun setup() {
`when`(sp.getString(ArgumentMatchers.anyString(), ArgumentMatchers.anyString())).thenReturn("AAPS")
`when`(

View file

@ -2,7 +2,7 @@ package info.nightscout.automation.actions
import org.json.JSONObject
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Test
class ActionDummyTest : ActionsTestBase() {

View file

@ -4,8 +4,8 @@ import info.nightscout.automation.R
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.queue.Callback
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.ArgumentMatchers.eq
import org.mockito.Mockito
import org.mockito.Mockito.`when`
@ -14,7 +14,7 @@ class ActionLoopDisableTest : ActionsTestBase() {
lateinit var sut: ActionLoopDisable
@Before
@BeforeEach
fun setup() {
testPumpPlugin.pumpDescription.isTempBasalCapable = true

View file

@ -4,8 +4,8 @@ import info.nightscout.automation.R
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.queue.Callback
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mockito
import org.mockito.Mockito.`when`
@ -13,7 +13,7 @@ class ActionLoopEnableTest : ActionsTestBase() {
lateinit var sut: ActionLoopEnable
@Before
@BeforeEach
fun setup() {
testPumpPlugin.pumpDescription.isTempBasalCapable = true

View file

@ -7,15 +7,15 @@ import info.nightscout.database.impl.transactions.Transaction
import info.nightscout.interfaces.queue.Callback
import io.reactivex.rxjava3.core.Single
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mockito.`when`
class ActionLoopResumeTest : ActionsTestBase() {
lateinit var sut: ActionLoopResume
@Before
@BeforeEach
fun setup() {
`when`(rh.gs(info.nightscout.core.main.R.string.resumeloop)).thenReturn("Resume loop")

View file

@ -4,8 +4,8 @@ import info.nightscout.automation.R
import info.nightscout.automation.elements.InputDuration
import info.nightscout.interfaces.queue.Callback
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.ArgumentMatchers
import org.mockito.Mockito
import org.mockito.Mockito.`when`
@ -14,7 +14,7 @@ class ActionLoopSuspendTest : ActionsTestBase() {
lateinit var sut: ActionLoopSuspend
@Before
@BeforeEach
fun setup() {
`when`(context.getString(info.nightscout.core.main.R.string.suspendloop)).thenReturn("Suspend loop")

View file

@ -15,8 +15,8 @@ import info.nightscout.rx.bus.RxBus
import info.nightscout.shared.interfaces.ResourceHelper
import io.reactivex.rxjava3.core.Completable
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.ArgumentMatchers
import org.mockito.Mock
import org.mockito.Mockito
@ -43,7 +43,7 @@ class ActionNotificationTest : TestBase() {
}
}
@Before
@BeforeEach
fun setup() {
`when`(context.getString(info.nightscout.core.main.R.string.ok)).thenReturn("OK")
`when`(rh.gs(info.nightscout.core.main.R.string.notification)).thenReturn("Notification")

View file

@ -1,12 +1,12 @@
package info.nightscout.automation.actions
import info.nightscout.interfaces.queue.Callback
import info.nightscout.automation.R
import info.nightscout.automation.elements.InputDuration
import info.nightscout.automation.elements.InputPercent
import info.nightscout.interfaces.queue.Callback
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mockito
import org.mockito.Mockito.`when`
@ -14,7 +14,7 @@ class ActionProfileSwitchPercentTest : ActionsTestBase() {
private lateinit var sut: ActionProfileSwitchPercent
@Before
@BeforeEach
fun setup() {
`when`(rh.gs(R.string.startprofileforever)).thenReturn("Start profile %d%%")

View file

@ -4,8 +4,8 @@ import info.nightscout.automation.R
import info.nightscout.automation.elements.InputProfileName
import info.nightscout.interfaces.queue.Callback
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.ArgumentMatchers
import org.mockito.ArgumentMatchers.anyLong
import org.mockito.Mockito
@ -19,7 +19,7 @@ class ActionProfileSwitchTest : ActionsTestBase() {
private val stringJson = "{\"data\":{\"profileToSwitchTo\":\"Test\"},\"type\":\"ActionProfileSwitch\"}"
@Before fun setUp() {
@BeforeEach fun setUp() {
`when`(rh.gs(R.string.profilename)).thenReturn("Change profile to")
`when`(rh.gs(ArgumentMatchers.eq(R.string.changengetoprofilename), ArgumentMatchers.anyString())).thenReturn("Change profile to %s")
`when`(context.getString(R.string.alreadyset)).thenReturn("Already set")

View file

@ -1,11 +1,11 @@
package info.nightscout.automation.actions
import info.nightscout.interfaces.queue.Callback
import info.nightscout.automation.R
import info.nightscout.automation.elements.InputString
import info.nightscout.interfaces.queue.Callback
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.ArgumentMatchers.anyString
import org.mockito.ArgumentMatchers.eq
import org.mockito.Mockito.`when`
@ -14,7 +14,7 @@ class ActionSendSMSTest : ActionsTestBase() {
private lateinit var sut: ActionSendSMS
@Before
@BeforeEach
fun setup() {
`when`(rh.gs(eq(R.string.sendsmsactionlabel), anyString())).thenReturn("Send SMS: %s")

View file

@ -1,17 +1,17 @@
package info.nightscout.automation.actions
import info.nightscout.database.impl.transactions.InsertAndCancelCurrentTemporaryTargetTransaction
import info.nightscout.database.impl.transactions.Transaction
import info.nightscout.automation.R
import info.nightscout.automation.elements.InputDuration
import info.nightscout.automation.elements.InputTempTarget
import info.nightscout.database.entities.TemporaryTarget
import info.nightscout.database.impl.transactions.InsertAndCancelCurrentTemporaryTargetTransaction
import info.nightscout.database.impl.transactions.Transaction
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.queue.Callback
import io.reactivex.rxjava3.core.Single
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mockito
import org.mockito.Mockito.`when`
@ -19,7 +19,7 @@ class ActionStartTempTargetTest : ActionsTestBase() {
private lateinit var sut: ActionStartTempTarget
@Before
@BeforeEach
fun setup() {
`when`(rh.gs(R.string.starttemptarget)).thenReturn("Start temp target")

View file

@ -1,17 +1,17 @@
package info.nightscout.automation.actions
import info.nightscout.interfaces.queue.Callback
import info.nightscout.automation.R
import info.nightscout.interfaces.queue.Callback
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mockito.`when`
class ActionStopProcessingTest : ActionsTestBase() {
lateinit var sut: ActionStopProcessing
@Before
@BeforeEach
fun setup() {
`when`(rh.gs(R.string.stop_processing)).thenReturn("Stop processing")

View file

@ -1,14 +1,14 @@
package info.nightscout.automation.actions
import info.nightscout.database.impl.transactions.CancelCurrentTemporaryTargetIfAnyTransaction
import info.nightscout.database.impl.transactions.Transaction
import info.nightscout.automation.R
import info.nightscout.database.entities.TemporaryTarget
import info.nightscout.database.impl.transactions.CancelCurrentTemporaryTargetIfAnyTransaction
import info.nightscout.database.impl.transactions.Transaction
import info.nightscout.interfaces.queue.Callback
import io.reactivex.rxjava3.core.Single
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mockito
import org.mockito.Mockito.`when`
@ -16,7 +16,7 @@ class ActionStopTempTargetTest : ActionsTestBase() {
private lateinit var sut: ActionStopTempTarget
@Before
@BeforeEach
fun setup() {
`when`(rh.gs(R.string.stoptemptarget)).thenReturn("Stop temp target")

View file

@ -5,7 +5,6 @@ import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBaseWithProfile
import info.nightscout.androidaps.TestPumpPlugin
import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.automation.triggers.Trigger
import info.nightscout.database.entities.DeviceStatus
import info.nightscout.database.entities.OfflineEvent
@ -15,9 +14,11 @@ import info.nightscout.interfaces.aps.Loop
import info.nightscout.interfaces.configBuilder.RunningConfiguration
import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.plugin.PluginDescription
import info.nightscout.interfaces.plugin.PluginType
import info.nightscout.interfaces.profile.Profile
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.profile.ProfileSource
@ -30,7 +31,7 @@ import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil
import org.junit.Before
import org.junit.jupiter.api.BeforeEach
import org.mockito.Mock
import org.mockito.Mockito.`when`
@ -74,6 +75,7 @@ ActionsTestBase : TestBaseWithProfile() {
runningConfiguration: RunningConfiguration,
version: String
): DeviceStatus? = null
override fun setPluginEnabled(type: PluginType, newState: Boolean) {}
}
@Mock lateinit var sp: SP
@ -191,7 +193,7 @@ ActionsTestBase : TestBaseWithProfile() {
}
}
@Before
@BeforeEach
fun mock() {
testPumpPlugin = TestPumpPlugin(pluginDescription, aapsLogger, rh, injector)
`when`(activePlugin.activePump).thenReturn(testPumpPlugin)

View file

@ -2,7 +2,7 @@ package info.nightscout.automation.elements
import info.nightscout.automation.triggers.TriggerTestBase
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Test
class ComparatorConnectTest : TriggerTestBase() {

View file

@ -2,7 +2,7 @@ package info.nightscout.automation.elements
import info.nightscout.automation.triggers.TriggerTestBase
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Test
class ComparatorExistsTest : TriggerTestBase() {

View file

@ -2,7 +2,7 @@ package info.nightscout.automation.elements
import info.nightscout.automation.triggers.TriggerTestBase
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Test
class ComparatorTest : TriggerTestBase() {

View file

@ -1,10 +1,10 @@
package info.nightscout.automation.elements
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.automation.triggers.TriggerTestBase
import info.nightscout.interfaces.GlucoseUnit
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.Mockito.`when`
class InputBgTest : TriggerTestBase() {
@ -20,7 +20,7 @@ class InputBgTest : TriggerTestBase() {
Assert.assertEquals(GlucoseUnit.MGDL, i.units)
}
@Before
@BeforeEach
fun prepare() {
`when`(profileFunction.getUnits()).thenReturn(GlucoseUnit.MGDL)
}

View file

@ -2,7 +2,7 @@ package info.nightscout.automation.elements
import info.nightscout.automation.triggers.TriggerTestBase
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Test
class InputCarePortalEventTest : TriggerTestBase() {

View file

@ -2,7 +2,7 @@ package info.nightscout.automation.elements
import info.nightscout.automation.triggers.TriggerTestBase
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Test
class InputDurationTest : TriggerTestBase() {

View file

@ -2,7 +2,7 @@ package info.nightscout.automation.elements
import info.nightscout.automation.triggers.TriggerTestBase
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Test
class InputInsulinTest : TriggerTestBase() {

View file

@ -2,7 +2,7 @@ package info.nightscout.automation.elements
import info.nightscout.automation.triggers.TriggerTestBase
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Test
class InputPercentTest : TriggerTestBase() {

View file

@ -2,7 +2,7 @@ package info.nightscout.automation.elements
import info.nightscout.automation.triggers.TriggerTestBase
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Test
class InputProfileNameTest : TriggerTestBase() {

View file

@ -2,7 +2,7 @@ package info.nightscout.automation.elements
import info.nightscout.automation.triggers.TriggerTestBase
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Test
class InputStringTest : TriggerTestBase() {

View file

@ -1,9 +1,9 @@
package info.nightscout.automation.elements
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.automation.triggers.TriggerTestBase
import info.nightscout.interfaces.GlucoseUnit
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Test
class InputTempTargetTest : TriggerTestBase() {

View file

@ -2,7 +2,7 @@ package info.nightscout.automation.elements
import info.nightscout.automation.triggers.TriggerTestBase
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Test
class LabelWithElementTest : TriggerTestBase() {

View file

@ -4,7 +4,7 @@ import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBase
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Test
class LayoutBuilderTest : TestBase() {

View file

@ -3,7 +3,7 @@ package info.nightscout.automation.elements
import info.nightscout.automation.triggers.TriggerDummy
import info.nightscout.automation.triggers.TriggerTestBase
import org.junit.Assert
import org.junit.Test
import org.junit.jupiter.api.Test
import org.mockito.Mockito.`when`
class StaticLabelTest : TriggerTestBase() {

View file

@ -1,13 +1,13 @@
package info.nightscout.automation.triggers
import com.google.common.base.Optional
import info.nightscout.core.iob.iobCobCalculator.data.AutosensDataObject
import info.nightscout.automation.R
import info.nightscout.automation.elements.Comparator
import info.nightscout.core.iob.iobCobCalculator.data.AutosensDataObject
import org.json.JSONObject
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.ArgumentMatchers
import org.mockito.Mockito
import org.mockito.Mockito.`when`
@ -105,7 +105,7 @@ class TriggerAutosensValueTest : TriggerTestBase() {
Assert.assertEquals(Optional.of(R.drawable.ic_as), TriggerAutosensValue(injector).icon())
}
@Before
@BeforeEach
fun mock() {
`when`(dateUtil.now()).thenReturn(now)
}

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