parent
85532a0332
commit
4d7897dace
1 changed files with 76 additions and 76 deletions
|
@ -7,10 +7,10 @@ import app.aaps.core.interfaces.pump.PumpSync
|
|||
import app.aaps.core.interfaces.pump.defs.PumpType
|
||||
import app.aaps.core.interfaces.rx.events.EventOverviewBolusProgress
|
||||
import app.aaps.core.interfaces.utils.T
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import info.nightscout.pump.medtrum.comm.enums.BasalType
|
||||
import info.nightscout.pump.medtrum.util.MedtrumSnUtil
|
||||
import org.json.JSONObject
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.mockito.Mockito
|
||||
import org.mockito.Mockito.mock
|
||||
|
@ -43,7 +43,7 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
|||
|
||||
// Expected values
|
||||
val expectedByteArray = byteArrayOf(7, 0, -96, 2, -16, 96, 2, 104, 33, 2, -32, -31, 1, -64, 3, 2, -20, 36, 2, 100, -123, 2)
|
||||
Assertions.assertEquals(expectedByteArray.contentToString(), result?.contentToString())
|
||||
assertThat(result!!.contentToString()).isEqualTo(expectedByteArray.contentToString())
|
||||
}
|
||||
|
||||
@Test fun buildMedtrumProfileArrayGiveProfileWhenValuesTooHighThenReturnNull() {
|
||||
|
@ -60,7 +60,7 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
|||
val result = medtrumPump.buildMedtrumProfileArray(profile)
|
||||
|
||||
// Expected values
|
||||
Assertions.assertNull(result)
|
||||
assertThat(result).isNull()
|
||||
}
|
||||
|
||||
@Test fun getCurrentHourlyBasalFromMedtrumProfileArrayGivenProfileWhenValuesSetThenReturnCorrectValue() {
|
||||
|
@ -88,28 +88,28 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
|||
val zonedDateTime0399 = localDate.atTime(localTime0399).atZone(ZoneId.systemDefault())
|
||||
val time0399 = zonedDateTime0399.toInstant().toEpochMilli()
|
||||
val result = medtrumPump.getHourlyBasalFromMedtrumProfileArray(profileArray!!, time0399)
|
||||
Assertions.assertEquals(2.1, result, 0.01)
|
||||
assertThat(result).isWithin(0.01).of(2.1)
|
||||
|
||||
// For 22:30
|
||||
val localTime2230 = LocalTime.of(22, 30)
|
||||
val zonedDateTime2230 = localDate.atTime(localTime2230).atZone(ZoneId.systemDefault())
|
||||
val time2230 = zonedDateTime2230.toInstant().toEpochMilli()
|
||||
val result1 = medtrumPump.getHourlyBasalFromMedtrumProfileArray(profileArray, time2230)
|
||||
Assertions.assertEquals(1.7, result1, 0.01)
|
||||
assertThat(result1).isWithin(0.01).of(1.7)
|
||||
|
||||
// For 23:59
|
||||
val localTime2359 = LocalTime.of(23, 59)
|
||||
val zonedDateTime2359 = localDate.atTime(localTime2359).atZone(ZoneId.systemDefault())
|
||||
val time2359 = zonedDateTime2359.toInstant().toEpochMilli()
|
||||
val result2 = medtrumPump.getHourlyBasalFromMedtrumProfileArray(profileArray, time2359)
|
||||
Assertions.assertEquals(2.0, result2, 0.01)
|
||||
assertThat(result2).isWithin(0.01).of(2.0)
|
||||
|
||||
// For 00:00
|
||||
val localTime0000 = LocalTime.of(0, 0)
|
||||
val zonedDateTime0000 = localDate.atTime(localTime0000).atZone(ZoneId.systemDefault())
|
||||
val time0000 = zonedDateTime0000.toInstant().toEpochMilli()
|
||||
val result3 = medtrumPump.getHourlyBasalFromMedtrumProfileArray(profileArray, time0000)
|
||||
Assertions.assertEquals(2.1, result3, 0.01)
|
||||
assertThat(result3).isWithin(0.01).of(2.1)
|
||||
}
|
||||
|
||||
@Test fun handleBolusStatusUpdateWhenCalledExpectNewData() {
|
||||
|
@ -124,9 +124,9 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
|||
medtrumPump.handleBolusStatusUpdate(bolusType, bolusCompleted, amount)
|
||||
|
||||
// Expected values
|
||||
Assertions.assertEquals(bolusCompleted, medtrumPump.bolusDone)
|
||||
Assertions.assertEquals(amount, medtrumPump.bolusAmountDeliveredFlow.value, 0.01)
|
||||
Assertions.assertEquals(amount, medtrumPump.bolusingTreatment!!.insulin, 0.01)
|
||||
assertThat(medtrumPump.bolusDone).isEqualTo(bolusCompleted)
|
||||
assertThat(medtrumPump.bolusAmountDeliveredFlow.value).isWithin(0.01).of(amount)
|
||||
assertThat(medtrumPump.bolusingTreatment!!.insulin).isWithin(0.01).of(amount)
|
||||
}
|
||||
|
||||
@Test fun handleBasalStatusUpdateWhenBasalTypeIsAbsoluteTempAndTemporaryBasalInfoThenExpectNewData() {
|
||||
|
@ -174,12 +174,12 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
|||
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
||||
)
|
||||
|
||||
Assertions.assertEquals(basalType, medtrumPump.lastBasalType)
|
||||
Assertions.assertEquals(basalRate, medtrumPump.lastBasalRate, 0.01)
|
||||
Assertions.assertEquals(basalSequence, medtrumPump.lastBasalSequence)
|
||||
Assertions.assertEquals(basalSequence, medtrumPump.currentSequenceNumber)
|
||||
Assertions.assertEquals(basalPatchId, medtrumPump.lastBasalPatchId)
|
||||
Assertions.assertEquals(basalStartTime, medtrumPump.lastBasalStartTime)
|
||||
assertThat(medtrumPump.lastBasalType).isEqualTo(basalType)
|
||||
assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(basalRate)
|
||||
assertThat(medtrumPump.lastBasalSequence).isEqualTo(basalSequence)
|
||||
assertThat(medtrumPump.currentSequenceNumber).isEqualTo(basalSequence)
|
||||
assertThat(medtrumPump.lastBasalPatchId).isEqualTo(basalPatchId)
|
||||
assertThat(medtrumPump.lastBasalStartTime).isEqualTo(basalStartTime)
|
||||
}
|
||||
|
||||
@Test fun handleBasalStatusUpdateWhenBasalTypeIsAbsoluteTempAndSameExpectedTemporaryBasalInfoThenExpectNoPumpSync() {
|
||||
|
@ -223,12 +223,12 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
|||
)
|
||||
|
||||
// Check that other fields in medtrumPump are updated
|
||||
Assertions.assertEquals(basalType, medtrumPump.lastBasalType)
|
||||
Assertions.assertEquals(basalRate, medtrumPump.lastBasalRate, 0.01)
|
||||
Assertions.assertEquals(basalSequence, medtrumPump.lastBasalSequence)
|
||||
Assertions.assertEquals(basalSequence, medtrumPump.currentSequenceNumber)
|
||||
Assertions.assertEquals(basalPatchId, medtrumPump.lastBasalPatchId)
|
||||
Assertions.assertEquals(basalStartTime, medtrumPump.lastBasalStartTime)
|
||||
assertThat(medtrumPump.lastBasalType).isEqualTo(basalType)
|
||||
assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(basalRate)
|
||||
assertThat(medtrumPump.lastBasalSequence).isEqualTo(basalSequence)
|
||||
assertThat(medtrumPump.currentSequenceNumber).isEqualTo(basalSequence)
|
||||
assertThat(medtrumPump.lastBasalPatchId).isEqualTo(basalPatchId)
|
||||
assertThat(medtrumPump.lastBasalStartTime).isEqualTo(basalStartTime)
|
||||
}
|
||||
|
||||
@Test fun handleBasalStatusUpdateWhenBasalTypeIsAbsoluteTempAndNoTemporaryBasalInfoThenExpectNewData() {
|
||||
|
@ -274,12 +274,12 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
|||
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
||||
)
|
||||
|
||||
Assertions.assertEquals(basalType, medtrumPump.lastBasalType)
|
||||
Assertions.assertEquals(basalRate, medtrumPump.lastBasalRate, 0.01)
|
||||
Assertions.assertEquals(basalSequence, medtrumPump.lastBasalSequence)
|
||||
Assertions.assertEquals(basalSequence, medtrumPump.currentSequenceNumber)
|
||||
Assertions.assertEquals(basalPatchId, medtrumPump.lastBasalPatchId)
|
||||
Assertions.assertEquals(basalStartTime, medtrumPump.lastBasalStartTime)
|
||||
assertThat(medtrumPump.lastBasalType).isEqualTo(basalType)
|
||||
assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(basalRate)
|
||||
assertThat(medtrumPump.lastBasalSequence).isEqualTo(basalSequence)
|
||||
assertThat(medtrumPump.currentSequenceNumber).isEqualTo(basalSequence)
|
||||
assertThat(medtrumPump.lastBasalPatchId).isEqualTo(basalPatchId)
|
||||
assertThat(medtrumPump.lastBasalStartTime).isEqualTo(basalStartTime)
|
||||
}
|
||||
|
||||
@Test fun handleBasalStatusUpdateWhenBasalTypeIsRelativeTempAndTemporaryBasalInfoThenExpectNewData() {
|
||||
|
@ -329,12 +329,12 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
|||
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
||||
)
|
||||
|
||||
Assertions.assertEquals(basalType, medtrumPump.lastBasalType)
|
||||
Assertions.assertEquals(basalRate, medtrumPump.lastBasalRate, 0.01)
|
||||
Assertions.assertEquals(basalSequence, medtrumPump.lastBasalSequence)
|
||||
Assertions.assertEquals(basalSequence, medtrumPump.currentSequenceNumber)
|
||||
Assertions.assertEquals(basalPatchId, medtrumPump.lastBasalPatchId)
|
||||
Assertions.assertEquals(basalStartTime, medtrumPump.lastBasalStartTime)
|
||||
assertThat(medtrumPump.lastBasalType).isEqualTo(basalType)
|
||||
assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(basalRate)
|
||||
assertThat(medtrumPump.lastBasalSequence).isEqualTo(basalSequence)
|
||||
assertThat(medtrumPump.currentSequenceNumber).isEqualTo(basalSequence)
|
||||
assertThat(medtrumPump.lastBasalPatchId).isEqualTo(basalPatchId)
|
||||
assertThat(medtrumPump.lastBasalStartTime).isEqualTo(basalStartTime)
|
||||
}
|
||||
|
||||
@Test fun handleBasalStatusUpdateWhenBasalTypeIsSuspendedThenExpectNewData() {
|
||||
|
@ -378,12 +378,12 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
|||
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
||||
)
|
||||
|
||||
Assertions.assertEquals(basalType, medtrumPump.lastBasalType)
|
||||
Assertions.assertEquals(basalRate, medtrumPump.lastBasalRate, 0.01)
|
||||
Assertions.assertEquals(basalSequence, medtrumPump.lastBasalSequence)
|
||||
Assertions.assertEquals(basalSequence, medtrumPump.currentSequenceNumber)
|
||||
Assertions.assertEquals(basalPatchId, medtrumPump.lastBasalPatchId)
|
||||
Assertions.assertEquals(basalStartTime, medtrumPump.lastBasalStartTime)
|
||||
assertThat(medtrumPump.lastBasalType).isEqualTo(basalType)
|
||||
assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(basalRate)
|
||||
assertThat(medtrumPump.lastBasalSequence).isEqualTo(basalSequence)
|
||||
assertThat(medtrumPump.currentSequenceNumber).isEqualTo(basalSequence)
|
||||
assertThat(medtrumPump.lastBasalPatchId).isEqualTo(basalPatchId)
|
||||
assertThat(medtrumPump.lastBasalStartTime).isEqualTo(basalStartTime)
|
||||
}
|
||||
|
||||
@Test fun handleBasalStatusUpdateWhenBasalTypeIsATypeIsSuspendedAndSameExpectedTemporaryBasalInfoThenExpectNoPumpSync() {
|
||||
|
@ -424,12 +424,12 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
|||
anyOrNull()
|
||||
)
|
||||
|
||||
Assertions.assertEquals(basalType, medtrumPump.lastBasalType)
|
||||
Assertions.assertEquals(basalRate, medtrumPump.lastBasalRate, 0.01)
|
||||
Assertions.assertEquals(basalSequence, medtrumPump.lastBasalSequence)
|
||||
Assertions.assertEquals(basalSequence, medtrumPump.currentSequenceNumber)
|
||||
Assertions.assertEquals(basalPatchId, medtrumPump.lastBasalPatchId)
|
||||
Assertions.assertEquals(basalStartTime, medtrumPump.lastBasalStartTime)
|
||||
assertThat(medtrumPump.lastBasalType).isEqualTo(basalType)
|
||||
assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(basalRate)
|
||||
assertThat(medtrumPump.lastBasalSequence).isEqualTo(basalSequence)
|
||||
assertThat(medtrumPump.currentSequenceNumber).isEqualTo(basalSequence)
|
||||
assertThat(medtrumPump.lastBasalPatchId).isEqualTo(basalPatchId)
|
||||
assertThat(medtrumPump.lastBasalStartTime).isEqualTo(basalStartTime)
|
||||
}
|
||||
|
||||
@Test fun handleBasalStatusUpdateWhenBasalTypeIsSuspendedAndNewerFakeTBRThenExpectInvalidateAndNewData() {
|
||||
|
@ -475,12 +475,12 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
|||
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
||||
)
|
||||
|
||||
Assertions.assertEquals(basalType, medtrumPump.lastBasalType)
|
||||
Assertions.assertEquals(basalRate, medtrumPump.lastBasalRate, 0.01)
|
||||
Assertions.assertEquals(basalSequence, medtrumPump.lastBasalSequence)
|
||||
Assertions.assertEquals(basalSequence, medtrumPump.currentSequenceNumber)
|
||||
Assertions.assertEquals(basalPatchId, medtrumPump.lastBasalPatchId)
|
||||
Assertions.assertEquals(basalStartTime, medtrumPump.lastBasalStartTime)
|
||||
assertThat(medtrumPump.lastBasalType).isEqualTo(basalType)
|
||||
assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(basalRate)
|
||||
assertThat(medtrumPump.lastBasalSequence).isEqualTo(basalSequence)
|
||||
assertThat(medtrumPump.currentSequenceNumber).isEqualTo(basalSequence)
|
||||
assertThat(medtrumPump.lastBasalPatchId).isEqualTo(basalPatchId)
|
||||
assertThat(medtrumPump.lastBasalStartTime).isEqualTo(basalStartTime)
|
||||
}
|
||||
|
||||
@Test fun handleBasalStatusUpdateWhenBasalTypeIsNoneAndThenExpectFakeTBR() {
|
||||
|
@ -520,12 +520,12 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
|||
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
||||
)
|
||||
|
||||
Assertions.assertEquals(basalType, medtrumPump.lastBasalType)
|
||||
Assertions.assertEquals(basalRate, medtrumPump.lastBasalRate, 0.01)
|
||||
Assertions.assertEquals(basalSequence, medtrumPump.lastBasalSequence)
|
||||
Assertions.assertEquals(basalSequence, medtrumPump.currentSequenceNumber)
|
||||
Assertions.assertEquals(basalPatchId, medtrumPump.lastBasalPatchId)
|
||||
Assertions.assertEquals(basalStartTime, medtrumPump.lastBasalStartTime)
|
||||
assertThat(medtrumPump.lastBasalType).isEqualTo(basalType)
|
||||
assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(basalRate)
|
||||
assertThat(medtrumPump.lastBasalSequence).isEqualTo(basalSequence)
|
||||
assertThat(medtrumPump.currentSequenceNumber).isEqualTo(basalSequence)
|
||||
assertThat(medtrumPump.lastBasalPatchId).isEqualTo(basalPatchId)
|
||||
assertThat(medtrumPump.lastBasalStartTime).isEqualTo(basalStartTime)
|
||||
}
|
||||
|
||||
@Test fun handleBasalStatusUpdateWhenBasalTypeIsStandardAndTempBasalExpectedThenExpectSyncStop() {
|
||||
|
@ -564,12 +564,12 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
|||
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
||||
)
|
||||
|
||||
Assertions.assertEquals(basalType, medtrumPump.lastBasalType)
|
||||
Assertions.assertEquals(basalRate, medtrumPump.lastBasalRate, 0.01)
|
||||
Assertions.assertEquals(basalSequence, medtrumPump.lastBasalSequence)
|
||||
Assertions.assertEquals(basalSequence, medtrumPump.currentSequenceNumber)
|
||||
Assertions.assertEquals(basalPatchId, medtrumPump.lastBasalPatchId)
|
||||
Assertions.assertEquals(basalStartTime, medtrumPump.lastBasalStartTime)
|
||||
assertThat(medtrumPump.lastBasalType).isEqualTo(basalType)
|
||||
assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(basalRate)
|
||||
assertThat(medtrumPump.lastBasalSequence).isEqualTo(basalSequence)
|
||||
assertThat(medtrumPump.currentSequenceNumber).isEqualTo(basalSequence)
|
||||
assertThat(medtrumPump.lastBasalPatchId).isEqualTo(basalPatchId)
|
||||
assertThat(medtrumPump.lastBasalStartTime).isEqualTo(basalStartTime)
|
||||
}
|
||||
|
||||
@Test fun handleBasalStatusUpdateWhenBasalTypeIsStandardAndNoTempBasalExpectedThenExpectNoSyncStop() {
|
||||
|
@ -605,12 +605,12 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
|||
anyOrNull()
|
||||
)
|
||||
|
||||
Assertions.assertEquals(basalType, medtrumPump.lastBasalType)
|
||||
Assertions.assertEquals(basalRate, medtrumPump.lastBasalRate, 0.01)
|
||||
Assertions.assertEquals(basalSequence, medtrumPump.lastBasalSequence)
|
||||
Assertions.assertEquals(basalSequence, medtrumPump.currentSequenceNumber)
|
||||
Assertions.assertEquals(basalPatchId, medtrumPump.lastBasalPatchId)
|
||||
Assertions.assertEquals(basalStartTime, medtrumPump.lastBasalStartTime)
|
||||
assertThat(medtrumPump.lastBasalType).isEqualTo(basalType)
|
||||
assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(basalRate)
|
||||
assertThat(medtrumPump.lastBasalSequence).isEqualTo(basalSequence)
|
||||
assertThat(medtrumPump.currentSequenceNumber).isEqualTo(basalSequence)
|
||||
assertThat(medtrumPump.lastBasalPatchId).isEqualTo(basalPatchId)
|
||||
assertThat(medtrumPump.lastBasalStartTime).isEqualTo(basalStartTime)
|
||||
}
|
||||
|
||||
@Test fun handleNewPatchCalledWhenCalledExpectNewDataPresent() {
|
||||
|
@ -626,10 +626,10 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
|||
medtrumPump.handleNewPatch(newPatchId, newSequenceNumber, newStartTime)
|
||||
|
||||
// Expected values
|
||||
Assertions.assertEquals(newPatchId, medtrumPump.patchId)
|
||||
Assertions.assertEquals(newSequenceNumber, medtrumPump.currentSequenceNumber)
|
||||
Assertions.assertEquals(newStartTime, medtrumPump.patchStartTime)
|
||||
Assertions.assertEquals(1, medtrumPump.syncedSequenceNumber)
|
||||
assertThat(medtrumPump.patchId).isEqualTo(newPatchId)
|
||||
assertThat(medtrumPump.currentSequenceNumber).isEqualTo(newSequenceNumber)
|
||||
assertThat(medtrumPump.patchStartTime).isEqualTo(newStartTime)
|
||||
assertThat(medtrumPump.syncedSequenceNumber).isEqualTo(1)
|
||||
}
|
||||
|
||||
@Test fun handleStopStatusUpdateWhenSequenceThenExpectUpdate() {
|
||||
|
@ -644,8 +644,8 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
|||
medtrumPump.handleStopStatusUpdate(sequence, patchId)
|
||||
|
||||
// Expected values
|
||||
Assertions.assertEquals(patchId, medtrumPump.lastStopPatchId)
|
||||
Assertions.assertEquals(sequence, medtrumPump.currentSequenceNumber)
|
||||
assertThat(medtrumPump.lastStopPatchId).isEqualTo(patchId)
|
||||
assertThat(medtrumPump.currentSequenceNumber).isEqualTo(sequence)
|
||||
}
|
||||
|
||||
@Test fun setFakeTBRIfNotSetWhenNoFakeTBRAlreadyRunningExpectPumpSync() {
|
||||
|
|
Loading…
Reference in a new issue