diff --git a/plugins/aps/src/test/java/info/nightscout/plugins/aps/loop/APSResultTest.kt b/plugins/aps/src/test/java/info/nightscout/plugins/aps/loop/APSResultTest.kt index 1222fd41e8..74dab48212 100644 --- a/plugins/aps/src/test/java/info/nightscout/plugins/aps/loop/APSResultTest.kt +++ b/plugins/aps/src/test/java/info/nightscout/plugins/aps/loop/APSResultTest.kt @@ -1,6 +1,7 @@ package info.nightscout.plugins.aps.loop import app.aaps.shared.tests.TestBaseWithProfile +import com.google.common.truth.Truth.assertThat import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector import info.nightscout.core.constraints.ConstraintObject @@ -11,7 +12,6 @@ import info.nightscout.interfaces.constraints.Constraint import info.nightscout.interfaces.constraints.ConstraintsChecker import info.nightscout.interfaces.pump.defs.PumpType import info.nightscout.plugins.aps.APSResultObject -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.ArgumentMatchers @@ -75,21 +75,21 @@ class APSResultTest : TestBaseWithProfile() { closedLoopEnabled.set(true) `when`(iobCobCalculator.getTempBasalIncludingConvertedExtended(ArgumentMatchers.anyLong())).thenReturn(null) apsResult.tempBasalRequested(false) - Assertions.assertEquals(false, apsResult.isChangeRequested) + assertThat(apsResult.isChangeRequested).isFalse() apsResult.tempBasalRequested(true).percent(200).duration(30) - Assertions.assertEquals(true, apsResult.isChangeRequested) + assertThat(apsResult.isChangeRequested).isTrue() // open loop closedLoopEnabled.set(false) // no change requested `when`(iobCobCalculator.getTempBasalIncludingConvertedExtended(ArgumentMatchers.anyLong())).thenReturn(null) apsResult.tempBasalRequested(false) - Assertions.assertEquals(false, apsResult.isChangeRequested) + assertThat(apsResult.isChangeRequested).isFalse() // request 100% when no temp is running `when`(iobCobCalculator.getTempBasalIncludingConvertedExtended(ArgumentMatchers.anyLong())).thenReturn(null) apsResult.tempBasalRequested(true).percent(100).duration(30) - Assertions.assertEquals(false, apsResult.isChangeRequested) + assertThat(apsResult.isChangeRequested).isFalse() // request equal temp `when`(iobCobCalculator.getTempBasalIncludingConvertedExtended(ArgumentMatchers.anyLong())).thenReturn( @@ -102,7 +102,7 @@ class APSResultTest : TestBaseWithProfile() { ) ) apsResult.tempBasalRequested(true).percent(70).duration(30) - Assertions.assertEquals(false, apsResult.isChangeRequested) + assertThat(apsResult.isChangeRequested).isFalse() // request zero temp `when`(iobCobCalculator.getTempBasalIncludingConvertedExtended(ArgumentMatchers.anyLong())).thenReturn( @@ -115,7 +115,7 @@ class APSResultTest : TestBaseWithProfile() { ) ) apsResult.tempBasalRequested(true).percent(0).duration(30) - Assertions.assertEquals(true, apsResult.isChangeRequested) + assertThat(apsResult.isChangeRequested).isTrue() // request high temp `when`(iobCobCalculator.getTempBasalIncludingConvertedExtended(ArgumentMatchers.anyLong())).thenReturn( @@ -128,7 +128,7 @@ class APSResultTest : TestBaseWithProfile() { ) ) apsResult.tempBasalRequested(true).percent(200).duration(30) - Assertions.assertEquals(true, apsResult.isChangeRequested) + assertThat(apsResult.isChangeRequested).isTrue() // request slightly different temp `when`(iobCobCalculator.getTempBasalIncludingConvertedExtended(ArgumentMatchers.anyLong())).thenReturn( @@ -141,7 +141,7 @@ class APSResultTest : TestBaseWithProfile() { ) ) apsResult.tempBasalRequested(true).percent(80).duration(30) - Assertions.assertEquals(false, apsResult.isChangeRequested) + assertThat(apsResult.isChangeRequested).isFalse() // request different temp `when`(iobCobCalculator.getTempBasalIncludingConvertedExtended(ArgumentMatchers.anyLong())).thenReturn( @@ -154,7 +154,7 @@ class APSResultTest : TestBaseWithProfile() { ) ) apsResult.tempBasalRequested(true).percent(120).duration(30) - Assertions.assertEquals(true, apsResult.isChangeRequested) + assertThat(apsResult.isChangeRequested).isTrue() // it should work with absolute temps too // request different temp @@ -168,7 +168,7 @@ class APSResultTest : TestBaseWithProfile() { ) ) apsResult.tempBasalRequested(true).percent(100).duration(30) - Assertions.assertEquals(false, apsResult.isChangeRequested) + assertThat(apsResult.isChangeRequested).isFalse() `when`(iobCobCalculator.getTempBasalIncludingConvertedExtended(ArgumentMatchers.anyLong())).thenReturn( TemporaryBasal( timestamp = 0, @@ -179,7 +179,7 @@ class APSResultTest : TestBaseWithProfile() { ) ) apsResult.tempBasalRequested(true).percent(50).duration(30) - Assertions.assertEquals(true, apsResult.isChangeRequested) + assertThat(apsResult.isChangeRequested).isTrue() // **** ABSOLUTE pump **** testPumpPlugin.pumpDescription.fillFor(PumpType.MEDTRONIC_515_715) // U/h based @@ -190,7 +190,7 @@ class APSResultTest : TestBaseWithProfile() { // request 100% when no temp is running `when`(iobCobCalculator.getTempBasalIncludingConvertedExtended(ArgumentMatchers.anyLong())).thenReturn(null) apsResult.tempBasalRequested(true).rate(1.0).duration(30) - Assertions.assertEquals(false, apsResult.isChangeRequested) + assertThat(apsResult.isChangeRequested).isFalse() // request equal temp `when`(iobCobCalculator.getTempBasalIncludingConvertedExtended(ArgumentMatchers.anyLong())).thenReturn( @@ -203,7 +203,7 @@ class APSResultTest : TestBaseWithProfile() { ) ) apsResult.tempBasalRequested(true).rate(2.0).duration(30) - Assertions.assertEquals(false, apsResult.isChangeRequested) + assertThat(apsResult.isChangeRequested).isFalse() `when`(iobCobCalculator.getTempBasalIncludingConvertedExtended(ArgumentMatchers.anyLong())).thenReturn( TemporaryBasal( timestamp = 0, @@ -214,7 +214,7 @@ class APSResultTest : TestBaseWithProfile() { ) ) apsResult.tempBasalRequested(true).rate(2.0).duration(30) - Assertions.assertEquals(false, apsResult.isChangeRequested) + assertThat(apsResult.isChangeRequested).isFalse() // request zero temp `when`(iobCobCalculator.getTempBasalIncludingConvertedExtended(ArgumentMatchers.anyLong())).thenReturn( @@ -227,7 +227,7 @@ class APSResultTest : TestBaseWithProfile() { ) ) apsResult.tempBasalRequested(true).rate(0.0).duration(30) - Assertions.assertEquals(true, apsResult.isChangeRequested) + assertThat(apsResult.isChangeRequested).isTrue() // request high temp `when`(iobCobCalculator.getTempBasalIncludingConvertedExtended(ArgumentMatchers.anyLong())).thenReturn( @@ -240,7 +240,7 @@ class APSResultTest : TestBaseWithProfile() { ) ) apsResult.tempBasalRequested(true).rate(35.0).duration(30) - Assertions.assertEquals(true, apsResult.isChangeRequested) + assertThat(apsResult.isChangeRequested).isTrue() // request slightly different temp `when`(iobCobCalculator.getTempBasalIncludingConvertedExtended(ArgumentMatchers.anyLong())).thenReturn( @@ -253,7 +253,7 @@ class APSResultTest : TestBaseWithProfile() { ) ) apsResult.tempBasalRequested(true).rate(1.2).duration(30) - Assertions.assertEquals(false, apsResult.isChangeRequested) + assertThat(apsResult.isChangeRequested).isFalse() // request different temp `when`(iobCobCalculator.getTempBasalIncludingConvertedExtended(ArgumentMatchers.anyLong())).thenReturn( @@ -266,7 +266,7 @@ class APSResultTest : TestBaseWithProfile() { ) ) apsResult.tempBasalRequested(true).rate(1.5).duration(30) - Assertions.assertEquals(true, apsResult.isChangeRequested) + assertThat(apsResult.isChangeRequested).isTrue() // it should work with percent temps too // request different temp @@ -280,7 +280,7 @@ class APSResultTest : TestBaseWithProfile() { ) ) apsResult.tempBasalRequested(true).rate(1.1).duration(30) - Assertions.assertEquals(false, apsResult.isChangeRequested) + assertThat(apsResult.isChangeRequested).isFalse() `when`(iobCobCalculator.getTempBasalIncludingConvertedExtended(ArgumentMatchers.anyLong())).thenReturn( TemporaryBasal( timestamp = 0, @@ -291,7 +291,7 @@ class APSResultTest : TestBaseWithProfile() { ) ) apsResult.tempBasalRequested(true).rate(0.5).duration(30) - Assertions.assertEquals(true, apsResult.isChangeRequested) + assertThat(apsResult.isChangeRequested).isTrue() } @Test fun cloneTest() { @@ -307,7 +307,7 @@ class APSResultTest : TestBaseWithProfile() { } apsResult.rate(10.0) val apsResult2 = apsResult.newAndClone(injector) - Assertions.assertEquals(apsResult.rate, apsResult2.rate, 0.0) + assertThat(apsResult2.rate).isEqualTo(apsResult.rate) } @Test fun jsonTest() { @@ -323,9 +323,9 @@ class APSResultTest : TestBaseWithProfile() { it.rh = rh } apsResult.rate(20.0).tempBasalRequested(true) - Assertions.assertEquals(20.0, safeGetDouble(apsResult.json(), "rate"), 0.0) + assertThat(safeGetDouble(apsResult.json(), "rate")).isEqualTo(20.0) apsResult.rate(20.0).tempBasalRequested(false) - Assertions.assertEquals(false, apsResult.json()?.has("rate")) + assertThat(apsResult.json()?.has("rate")).isFalse() } @BeforeEach @@ -335,4 +335,4 @@ class APSResultTest : TestBaseWithProfile() { `when`(sp.getDouble(ArgumentMatchers.anyInt(), ArgumentMatchers.anyDouble())).thenReturn(30.0) `when`(profileFunction.getProfile()).thenReturn(validProfile) } -} \ No newline at end of file +} diff --git a/plugins/aps/src/test/java/info/nightscout/plugins/general/autotune/AutotuneCoreTest.kt b/plugins/aps/src/test/java/info/nightscout/plugins/general/autotune/AutotuneCoreTest.kt index 50218bf598..75176253d1 100644 --- a/plugins/aps/src/test/java/info/nightscout/plugins/general/autotune/AutotuneCoreTest.kt +++ b/plugins/aps/src/test/java/info/nightscout/plugins/general/autotune/AutotuneCoreTest.kt @@ -1,6 +1,7 @@ package info.nightscout.plugins.general.autotune import app.aaps.shared.tests.TestBaseWithProfile +import com.google.common.truth.Truth.assertThat import info.nightscout.core.profile.ProfileSealed import info.nightscout.core.utils.JsonHelper import info.nightscout.database.entities.data.Block @@ -13,7 +14,6 @@ import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.T import org.json.JSONArray import org.json.JSONObject -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.Mock @@ -47,15 +47,13 @@ class AutotuneCoreTest : TestBaseWithProfile() { `when`(sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_autosens_min, 0.7)).thenReturn(autotuneMin) `when`(sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_min_5m_carbimpact, 3.0)).thenReturn(min5mCarbImpact) val oapsOutputProfileJson = File("src/test/res/autotune/test1/aapsorefprofile.json").readText() - val oapsOutputProfile = atProfileFromOapsJson(JSONObject(oapsOutputProfileJson), dateUtil) + val oapsOutputProfile = atProfileFromOapsJson(JSONObject(oapsOutputProfileJson), dateUtil)!! val outProfile = autotuneCore.tuneAllTheThings(prep, inputProfile, inputProfile) - oapsOutputProfile?.let { - Assertions.assertEquals(oapsOutputProfile.isf, outProfile.isf, 0.0) - Assertions.assertEquals(oapsOutputProfile.ic, outProfile.ic, 0.0) - for (i in 0..23) - Assertions.assertEquals(oapsOutputProfile.basal[i], outProfile.basal[i], 0.0) + assertThat(outProfile.isf).isEqualTo(oapsOutputProfile.isf) + assertThat(outProfile.ic).isEqualTo(oapsOutputProfile.ic) + for (i in 0..23) { + assertThat(outProfile.basal[i]).isEqualTo(oapsOutputProfile.basal[i]) } - ?: Assertions.fail() } @Suppress("SpellCheckingInspection") @@ -71,15 +69,13 @@ class AutotuneCoreTest : TestBaseWithProfile() { `when`(sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_autosens_min, 0.7)).thenReturn(autotuneMin) `when`(sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_min_5m_carbimpact, 3.0)).thenReturn(min5mCarbImpact) val oapsOutputProfileJson = File("src/test/res/autotune/test4/newprofile.2022-05-30.json").readText() - val oapsOutputProfile = atProfileFromOapsJson(JSONObject(oapsOutputProfileJson), dateUtil) + val oapsOutputProfile = atProfileFromOapsJson(JSONObject(oapsOutputProfileJson), dateUtil)!! val outProfile = autotuneCore.tuneAllTheThings(prep, inputProfile, pumpProfile) - oapsOutputProfile?.let { - Assertions.assertEquals(oapsOutputProfile.isf, outProfile.isf, 0.0) - Assertions.assertEquals(oapsOutputProfile.ic, outProfile.ic, 0.0) - for (i in 0..23) - Assertions.assertEquals(oapsOutputProfile.basal[i], outProfile.basal[i], 0.0) + assertThat(outProfile.isf).isEqualTo(oapsOutputProfile.isf) + assertThat(outProfile.ic).isEqualTo(oapsOutputProfile.ic) + for (i in 0..23) { + assertThat(outProfile.basal[i]).isEqualTo(oapsOutputProfile.basal[i]) } - ?: Assertions.fail() } /** diff --git a/plugins/aps/src/test/java/info/nightscout/plugins/general/autotune/AutotunePrepTest.kt b/plugins/aps/src/test/java/info/nightscout/plugins/general/autotune/AutotunePrepTest.kt index 1f10ee2dfb..21588ff3ca 100644 --- a/plugins/aps/src/test/java/info/nightscout/plugins/general/autotune/AutotunePrepTest.kt +++ b/plugins/aps/src/test/java/info/nightscout/plugins/general/autotune/AutotunePrepTest.kt @@ -1,6 +1,7 @@ package info.nightscout.plugins.general.autotune import app.aaps.shared.tests.TestBaseWithProfile +import com.google.common.truth.Truth.assertThat import info.nightscout.core.extensions.shiftBlock import info.nightscout.core.profile.ProfileSealed import info.nightscout.core.utils.JsonHelper @@ -21,7 +22,6 @@ import info.nightscout.shared.utils.DateUtil import info.nightscout.shared.utils.T import org.json.JSONArray import org.json.JSONObject -import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.mockito.Mock @@ -63,26 +63,20 @@ class AutotunePrepTest : TestBaseWithProfile() { autotuneIob.boluses = buildBoluses(oapsPreppedGlucose) //Values from oapsPrepData because linked to iob calculation method for TBR `when`(sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_min_5m_carbimpact, 3.0)).thenReturn(min5mCarbImpact) `when`(sp.getBoolean(info.nightscout.core.utils.R.string.key_autotune_categorize_uam_as_basal, false)).thenReturn(false) - val aapsPreppedGlucose = autotunePrep.categorizeBGDatums(inputProfile, inputProfile.localInsulin, false) - try { - aapsPreppedGlucose?.let { // compare all categorization calculated by aaps plugin (aapsPreppedGlucose) with categorization calculated by OpenAPS (oapsPreppedGlucose) - for (i in aapsPreppedGlucose.crData.indices) - Assertions.assertTrue(oapsPreppedGlucose.crData[i].equals(aapsPreppedGlucose.crData[i])) - for (i in aapsPreppedGlucose.csfGlucoseData.indices) - Assertions.assertTrue(oapsPreppedGlucose.csfGlucoseData[i].equals(aapsPreppedGlucose.csfGlucoseData[i])) - oapsPreppedGlucose.isfGlucoseData = oapsPreppedGlucose.isfGlucoseData.sortedBy { it.date } - aapsPreppedGlucose.isfGlucoseData = aapsPreppedGlucose.isfGlucoseData.sortedBy { it.date } - for (i in aapsPreppedGlucose.isfGlucoseData.indices) - Assertions.assertTrue(oapsPreppedGlucose.isfGlucoseData[i].equals(aapsPreppedGlucose.isfGlucoseData[i])) - oapsPreppedGlucose.basalGlucoseData = oapsPreppedGlucose.basalGlucoseData.sortedBy { it.date } - aapsPreppedGlucose.basalGlucoseData = aapsPreppedGlucose.basalGlucoseData.sortedBy { it.date } - for (i in aapsPreppedGlucose.basalGlucoseData.indices) - Assertions.assertTrue(oapsPreppedGlucose.basalGlucoseData[i].equals(aapsPreppedGlucose.basalGlucoseData[i])) - } - ?: Assertions.fail() - } catch (e: Exception) { - Assertions.fail() - } + val aapsPreppedGlucose = autotunePrep.categorizeBGDatums(inputProfile, inputProfile.localInsulin, false)!! + // compare all categorization calculated by aaps plugin (aapsPreppedGlucose) with categorization calculated by OpenAPS (oapsPreppedGlucose) + for (i in aapsPreppedGlucose.crData.indices) + assertThat(oapsPreppedGlucose.crData[i].equals(aapsPreppedGlucose.crData[i])).isTrue() + for (i in aapsPreppedGlucose.csfGlucoseData.indices) + assertThat(oapsPreppedGlucose.csfGlucoseData[i].equals(aapsPreppedGlucose.csfGlucoseData[i])).isTrue() + oapsPreppedGlucose.isfGlucoseData = oapsPreppedGlucose.isfGlucoseData.sortedBy { it.date } + aapsPreppedGlucose.isfGlucoseData = aapsPreppedGlucose.isfGlucoseData.sortedBy { it.date } + for (i in aapsPreppedGlucose.isfGlucoseData.indices) + assertThat(oapsPreppedGlucose.isfGlucoseData[i].equals(aapsPreppedGlucose.isfGlucoseData[i])).isTrue() + oapsPreppedGlucose.basalGlucoseData = oapsPreppedGlucose.basalGlucoseData.sortedBy { it.date } + aapsPreppedGlucose.basalGlucoseData = aapsPreppedGlucose.basalGlucoseData.sortedBy { it.date } + for (i in aapsPreppedGlucose.basalGlucoseData.indices) + assertThat(oapsPreppedGlucose.basalGlucoseData[i].equals(aapsPreppedGlucose.basalGlucoseData[i])).isTrue() } @Test @@ -102,26 +96,20 @@ class AutotunePrepTest : TestBaseWithProfile() { autotuneIob.boluses = buildBoluses(oapsPreppedGlucose) //Values from oapsPrepData because linked to iob calculation method for TBR `when`(sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_min_5m_carbimpact, 3.0)).thenReturn(min5mCarbImpact) `when`(sp.getBoolean(info.nightscout.core.utils.R.string.key_autotune_categorize_uam_as_basal, false)).thenReturn(false) // CategorizeUAM as Basal = False - val aapsPreppedGlucose = autotunePrep.categorizeBGDatums(inputProfile, inputProfile.localInsulin, false) - try { - aapsPreppedGlucose?.let { // compare all categorization calculated by aaps plugin (aapsPreppedGlucose) with categorization calculated by OpenAPS (oapsPreppedGlucose) - for (i in aapsPreppedGlucose.crData.indices) - Assertions.assertTrue(oapsPreppedGlucose.crData[i].equals(aapsPreppedGlucose.crData[i])) - for (i in aapsPreppedGlucose.csfGlucoseData.indices) - Assertions.assertTrue(oapsPreppedGlucose.csfGlucoseData[i].equals(aapsPreppedGlucose.csfGlucoseData[i])) - oapsPreppedGlucose.isfGlucoseData = oapsPreppedGlucose.isfGlucoseData.sortedBy { it.date } - aapsPreppedGlucose.isfGlucoseData = aapsPreppedGlucose.isfGlucoseData.sortedBy { it.date } - for (i in aapsPreppedGlucose.isfGlucoseData.indices) - Assertions.assertTrue(oapsPreppedGlucose.isfGlucoseData[i].equals(aapsPreppedGlucose.isfGlucoseData[i])) - oapsPreppedGlucose.basalGlucoseData = oapsPreppedGlucose.basalGlucoseData.sortedBy { it.date } - aapsPreppedGlucose.basalGlucoseData = aapsPreppedGlucose.basalGlucoseData.sortedBy { it.date } - for (i in aapsPreppedGlucose.basalGlucoseData.indices) - Assertions.assertTrue(oapsPreppedGlucose.basalGlucoseData[i].equals(aapsPreppedGlucose.basalGlucoseData[i])) - } - ?: Assertions.fail() - } catch (e: Exception) { - Assertions.fail() - } + val aapsPreppedGlucose = autotunePrep.categorizeBGDatums(inputProfile, inputProfile.localInsulin, false)!! + // compare all categorization calculated by aaps plugin (aapsPreppedGlucose) with categorization calculated by OpenAPS (oapsPreppedGlucose) + for (i in aapsPreppedGlucose.crData.indices) + assertThat(oapsPreppedGlucose.crData[i].equals(aapsPreppedGlucose.crData[i])).isTrue() + for (i in aapsPreppedGlucose.csfGlucoseData.indices) + assertThat(oapsPreppedGlucose.csfGlucoseData[i].equals(aapsPreppedGlucose.csfGlucoseData[i])).isTrue() + oapsPreppedGlucose.isfGlucoseData = oapsPreppedGlucose.isfGlucoseData.sortedBy { it.date } + aapsPreppedGlucose.isfGlucoseData = aapsPreppedGlucose.isfGlucoseData.sortedBy { it.date } + for (i in aapsPreppedGlucose.isfGlucoseData.indices) + assertThat(oapsPreppedGlucose.isfGlucoseData[i].equals(aapsPreppedGlucose.isfGlucoseData[i])).isTrue() + oapsPreppedGlucose.basalGlucoseData = oapsPreppedGlucose.basalGlucoseData.sortedBy { it.date } + aapsPreppedGlucose.basalGlucoseData = aapsPreppedGlucose.basalGlucoseData.sortedBy { it.date } + for (i in aapsPreppedGlucose.basalGlucoseData.indices) + assertThat(oapsPreppedGlucose.basalGlucoseData[i].equals(aapsPreppedGlucose.basalGlucoseData[i])).isTrue() } @Test @@ -141,26 +129,20 @@ class AutotunePrepTest : TestBaseWithProfile() { autotuneIob.boluses = buildBoluses(oapsPreppedGlucose) //Values from oapsPrepData because linked to iob calculation method for TBR `when`(sp.getDouble(info.nightscout.core.utils.R.string.key_openapsama_min_5m_carbimpact, 3.0)).thenReturn(min5mCarbImpact) `when`(sp.getBoolean(info.nightscout.core.utils.R.string.key_autotune_categorize_uam_as_basal, false)).thenReturn(true) // CategorizeUAM as Basal = True - val aapsPreppedGlucose = autotunePrep.categorizeBGDatums(inputProfile, inputProfile.localInsulin, false) - try { - aapsPreppedGlucose?.let { // compare all categorization calculated by aaps plugin (aapsPreppedGlucose) with categorization calculated by OpenAPS (oapsPreppedGlucose) - for (i in aapsPreppedGlucose.crData.indices) - Assertions.assertTrue(oapsPreppedGlucose.crData[i].equals(aapsPreppedGlucose.crData[i])) - for (i in aapsPreppedGlucose.csfGlucoseData.indices) - Assertions.assertTrue(oapsPreppedGlucose.csfGlucoseData[i].equals(aapsPreppedGlucose.csfGlucoseData[i])) - oapsPreppedGlucose.isfGlucoseData = oapsPreppedGlucose.isfGlucoseData.sortedBy { it.date } - aapsPreppedGlucose.isfGlucoseData = aapsPreppedGlucose.isfGlucoseData.sortedBy { it.date } - for (i in aapsPreppedGlucose.isfGlucoseData.indices) - Assertions.assertTrue(oapsPreppedGlucose.isfGlucoseData[i].equals(aapsPreppedGlucose.isfGlucoseData[i])) - oapsPreppedGlucose.basalGlucoseData = oapsPreppedGlucose.basalGlucoseData.sortedBy { it.date } - aapsPreppedGlucose.basalGlucoseData = aapsPreppedGlucose.basalGlucoseData.sortedBy { it.date } - for (i in aapsPreppedGlucose.basalGlucoseData.indices) - Assertions.assertTrue(oapsPreppedGlucose.basalGlucoseData[i].equals(aapsPreppedGlucose.basalGlucoseData[i])) - } - ?: Assertions.fail() - } catch (e: Exception) { - Assertions.fail() - } + val aapsPreppedGlucose = autotunePrep.categorizeBGDatums(inputProfile, inputProfile.localInsulin, false)!! + // compare all categorization calculated by aaps plugin (aapsPreppedGlucose) with categorization calculated by OpenAPS (oapsPreppedGlucose) + for (i in aapsPreppedGlucose.crData.indices) + assertThat(oapsPreppedGlucose.crData[i].equals(aapsPreppedGlucose.crData[i])).isTrue() + for (i in aapsPreppedGlucose.csfGlucoseData.indices) + assertThat(oapsPreppedGlucose.csfGlucoseData[i].equals(aapsPreppedGlucose.csfGlucoseData[i])).isTrue() + oapsPreppedGlucose.isfGlucoseData = oapsPreppedGlucose.isfGlucoseData.sortedBy { it.date } + aapsPreppedGlucose.isfGlucoseData = aapsPreppedGlucose.isfGlucoseData.sortedBy { it.date } + for (i in aapsPreppedGlucose.isfGlucoseData.indices) + assertThat(oapsPreppedGlucose.isfGlucoseData[i].equals(aapsPreppedGlucose.isfGlucoseData[i])).isTrue() + oapsPreppedGlucose.basalGlucoseData = oapsPreppedGlucose.basalGlucoseData.sortedBy { it.date } + aapsPreppedGlucose.basalGlucoseData = aapsPreppedGlucose.basalGlucoseData.sortedBy { it.date } + for (i in aapsPreppedGlucose.basalGlucoseData.indices) + assertThat(oapsPreppedGlucose.basalGlucoseData[i].equals(aapsPreppedGlucose.basalGlucoseData[i])).isTrue() } /************************************************************************************************************************************************************************************* diff --git a/plugins/aps/src/test/java/info/nightscout/plugins/general/autotune/PreppedGlucoseTest.kt b/plugins/aps/src/test/java/info/nightscout/plugins/general/autotune/PreppedGlucoseTest.kt index 88a0f6cb98..38237e91df 100644 --- a/plugins/aps/src/test/java/info/nightscout/plugins/general/autotune/PreppedGlucoseTest.kt +++ b/plugins/aps/src/test/java/info/nightscout/plugins/general/autotune/PreppedGlucoseTest.kt @@ -1,11 +1,11 @@ package info.nightscout.plugins.general.autotune import app.aaps.shared.tests.TestBaseWithProfile +import com.google.common.truth.Truth.assertThat 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.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import java.io.File @@ -43,10 +43,10 @@ class PreppedGlucoseTest : TestBaseWithProfile() { 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 ) - Assertions.assertEquals(3, prep1.crData.size) - Assertions.assertTrue(crData0.equals(prep1.crData[0])) - Assertions.assertTrue(csfDataEnd.equals(prep1.csfGlucoseData[prep1.csfGlucoseData.size - 1])) - Assertions.assertTrue(isfData0.equals(prep1.isfGlucoseData[0])) - Assertions.assertTrue(basalDataEnd.equals(prep1.basalGlucoseData[prep1.basalGlucoseData.size - 1])) + assertThat(prep1.crData).hasSize(3) + assertThat(crData0.equals(prep1.crData[0])).isTrue() + assertThat(csfDataEnd.equals(prep1.csfGlucoseData[prep1.csfGlucoseData.size - 1])).isTrue() + assertThat(isfData0.equals(prep1.isfGlucoseData[0])).isTrue() + assertThat(basalDataEnd.equals(prep1.basalGlucoseData[prep1.basalGlucoseData.size - 1])).isTrue() } }