Merge pull request #2886 from ryanhaining/assertthat_pump_medtrum
Rewrites pump/medtrum/ tests with matchers
This commit is contained in:
commit
fb5f54460d
27 changed files with 284 additions and 301 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.pump.defs.PumpType
|
||||||
import app.aaps.core.interfaces.rx.events.EventOverviewBolusProgress
|
import app.aaps.core.interfaces.rx.events.EventOverviewBolusProgress
|
||||||
import app.aaps.core.interfaces.utils.T
|
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.comm.enums.BasalType
|
||||||
import info.nightscout.pump.medtrum.util.MedtrumSnUtil
|
import info.nightscout.pump.medtrum.util.MedtrumSnUtil
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mockito
|
import org.mockito.Mockito
|
||||||
import org.mockito.Mockito.mock
|
import org.mockito.Mockito.mock
|
||||||
|
@ -43,7 +43,7 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
||||||
|
|
||||||
// Expected values
|
// 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)
|
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() {
|
@Test fun buildMedtrumProfileArrayGiveProfileWhenValuesTooHighThenReturnNull() {
|
||||||
|
@ -60,7 +60,7 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
||||||
val result = medtrumPump.buildMedtrumProfileArray(profile)
|
val result = medtrumPump.buildMedtrumProfileArray(profile)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertNull(result)
|
assertThat(result).isNull()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun getCurrentHourlyBasalFromMedtrumProfileArrayGivenProfileWhenValuesSetThenReturnCorrectValue() {
|
@Test fun getCurrentHourlyBasalFromMedtrumProfileArrayGivenProfileWhenValuesSetThenReturnCorrectValue() {
|
||||||
|
@ -88,28 +88,28 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
||||||
val zonedDateTime0399 = localDate.atTime(localTime0399).atZone(ZoneId.systemDefault())
|
val zonedDateTime0399 = localDate.atTime(localTime0399).atZone(ZoneId.systemDefault())
|
||||||
val time0399 = zonedDateTime0399.toInstant().toEpochMilli()
|
val time0399 = zonedDateTime0399.toInstant().toEpochMilli()
|
||||||
val result = medtrumPump.getHourlyBasalFromMedtrumProfileArray(profileArray!!, time0399)
|
val result = medtrumPump.getHourlyBasalFromMedtrumProfileArray(profileArray!!, time0399)
|
||||||
Assertions.assertEquals(2.1, result, 0.01)
|
assertThat(result).isWithin(0.01).of(2.1)
|
||||||
|
|
||||||
// For 22:30
|
// For 22:30
|
||||||
val localTime2230 = LocalTime.of(22, 30)
|
val localTime2230 = LocalTime.of(22, 30)
|
||||||
val zonedDateTime2230 = localDate.atTime(localTime2230).atZone(ZoneId.systemDefault())
|
val zonedDateTime2230 = localDate.atTime(localTime2230).atZone(ZoneId.systemDefault())
|
||||||
val time2230 = zonedDateTime2230.toInstant().toEpochMilli()
|
val time2230 = zonedDateTime2230.toInstant().toEpochMilli()
|
||||||
val result1 = medtrumPump.getHourlyBasalFromMedtrumProfileArray(profileArray, time2230)
|
val result1 = medtrumPump.getHourlyBasalFromMedtrumProfileArray(profileArray, time2230)
|
||||||
Assertions.assertEquals(1.7, result1, 0.01)
|
assertThat(result1).isWithin(0.01).of(1.7)
|
||||||
|
|
||||||
// For 23:59
|
// For 23:59
|
||||||
val localTime2359 = LocalTime.of(23, 59)
|
val localTime2359 = LocalTime.of(23, 59)
|
||||||
val zonedDateTime2359 = localDate.atTime(localTime2359).atZone(ZoneId.systemDefault())
|
val zonedDateTime2359 = localDate.atTime(localTime2359).atZone(ZoneId.systemDefault())
|
||||||
val time2359 = zonedDateTime2359.toInstant().toEpochMilli()
|
val time2359 = zonedDateTime2359.toInstant().toEpochMilli()
|
||||||
val result2 = medtrumPump.getHourlyBasalFromMedtrumProfileArray(profileArray, time2359)
|
val result2 = medtrumPump.getHourlyBasalFromMedtrumProfileArray(profileArray, time2359)
|
||||||
Assertions.assertEquals(2.0, result2, 0.01)
|
assertThat(result2).isWithin(0.01).of(2.0)
|
||||||
|
|
||||||
// For 00:00
|
// For 00:00
|
||||||
val localTime0000 = LocalTime.of(0, 0)
|
val localTime0000 = LocalTime.of(0, 0)
|
||||||
val zonedDateTime0000 = localDate.atTime(localTime0000).atZone(ZoneId.systemDefault())
|
val zonedDateTime0000 = localDate.atTime(localTime0000).atZone(ZoneId.systemDefault())
|
||||||
val time0000 = zonedDateTime0000.toInstant().toEpochMilli()
|
val time0000 = zonedDateTime0000.toInstant().toEpochMilli()
|
||||||
val result3 = medtrumPump.getHourlyBasalFromMedtrumProfileArray(profileArray, time0000)
|
val result3 = medtrumPump.getHourlyBasalFromMedtrumProfileArray(profileArray, time0000)
|
||||||
Assertions.assertEquals(2.1, result3, 0.01)
|
assertThat(result3).isWithin(0.01).of(2.1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleBolusStatusUpdateWhenCalledExpectNewData() {
|
@Test fun handleBolusStatusUpdateWhenCalledExpectNewData() {
|
||||||
|
@ -124,9 +124,9 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
||||||
medtrumPump.handleBolusStatusUpdate(bolusType, bolusCompleted, amount)
|
medtrumPump.handleBolusStatusUpdate(bolusType, bolusCompleted, amount)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(bolusCompleted, medtrumPump.bolusDone)
|
assertThat(medtrumPump.bolusDone).isEqualTo(bolusCompleted)
|
||||||
Assertions.assertEquals(amount, medtrumPump.bolusAmountDeliveredFlow.value, 0.01)
|
assertThat(medtrumPump.bolusAmountDeliveredFlow.value).isWithin(0.01).of(amount)
|
||||||
Assertions.assertEquals(amount, medtrumPump.bolusingTreatment!!.insulin, 0.01)
|
assertThat(medtrumPump.bolusingTreatment!!.insulin).isWithin(0.01).of(amount)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleBasalStatusUpdateWhenBasalTypeIsAbsoluteTempAndTemporaryBasalInfoThenExpectNewData() {
|
@Test fun handleBasalStatusUpdateWhenBasalTypeIsAbsoluteTempAndTemporaryBasalInfoThenExpectNewData() {
|
||||||
|
@ -174,12 +174,12 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
||||||
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
||||||
)
|
)
|
||||||
|
|
||||||
Assertions.assertEquals(basalType, medtrumPump.lastBasalType)
|
assertThat(medtrumPump.lastBasalType).isEqualTo(basalType)
|
||||||
Assertions.assertEquals(basalRate, medtrumPump.lastBasalRate, 0.01)
|
assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(basalRate)
|
||||||
Assertions.assertEquals(basalSequence, medtrumPump.lastBasalSequence)
|
assertThat(medtrumPump.lastBasalSequence).isEqualTo(basalSequence)
|
||||||
Assertions.assertEquals(basalSequence, medtrumPump.currentSequenceNumber)
|
assertThat(medtrumPump.currentSequenceNumber).isEqualTo(basalSequence)
|
||||||
Assertions.assertEquals(basalPatchId, medtrumPump.lastBasalPatchId)
|
assertThat(medtrumPump.lastBasalPatchId).isEqualTo(basalPatchId)
|
||||||
Assertions.assertEquals(basalStartTime, medtrumPump.lastBasalStartTime)
|
assertThat(medtrumPump.lastBasalStartTime).isEqualTo(basalStartTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleBasalStatusUpdateWhenBasalTypeIsAbsoluteTempAndSameExpectedTemporaryBasalInfoThenExpectNoPumpSync() {
|
@Test fun handleBasalStatusUpdateWhenBasalTypeIsAbsoluteTempAndSameExpectedTemporaryBasalInfoThenExpectNoPumpSync() {
|
||||||
|
@ -223,12 +223,12 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
||||||
)
|
)
|
||||||
|
|
||||||
// Check that other fields in medtrumPump are updated
|
// Check that other fields in medtrumPump are updated
|
||||||
Assertions.assertEquals(basalType, medtrumPump.lastBasalType)
|
assertThat(medtrumPump.lastBasalType).isEqualTo(basalType)
|
||||||
Assertions.assertEquals(basalRate, medtrumPump.lastBasalRate, 0.01)
|
assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(basalRate)
|
||||||
Assertions.assertEquals(basalSequence, medtrumPump.lastBasalSequence)
|
assertThat(medtrumPump.lastBasalSequence).isEqualTo(basalSequence)
|
||||||
Assertions.assertEquals(basalSequence, medtrumPump.currentSequenceNumber)
|
assertThat(medtrumPump.currentSequenceNumber).isEqualTo(basalSequence)
|
||||||
Assertions.assertEquals(basalPatchId, medtrumPump.lastBasalPatchId)
|
assertThat(medtrumPump.lastBasalPatchId).isEqualTo(basalPatchId)
|
||||||
Assertions.assertEquals(basalStartTime, medtrumPump.lastBasalStartTime)
|
assertThat(medtrumPump.lastBasalStartTime).isEqualTo(basalStartTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleBasalStatusUpdateWhenBasalTypeIsAbsoluteTempAndNoTemporaryBasalInfoThenExpectNewData() {
|
@Test fun handleBasalStatusUpdateWhenBasalTypeIsAbsoluteTempAndNoTemporaryBasalInfoThenExpectNewData() {
|
||||||
|
@ -274,12 +274,12 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
||||||
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
||||||
)
|
)
|
||||||
|
|
||||||
Assertions.assertEquals(basalType, medtrumPump.lastBasalType)
|
assertThat(medtrumPump.lastBasalType).isEqualTo(basalType)
|
||||||
Assertions.assertEquals(basalRate, medtrumPump.lastBasalRate, 0.01)
|
assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(basalRate)
|
||||||
Assertions.assertEquals(basalSequence, medtrumPump.lastBasalSequence)
|
assertThat(medtrumPump.lastBasalSequence).isEqualTo(basalSequence)
|
||||||
Assertions.assertEquals(basalSequence, medtrumPump.currentSequenceNumber)
|
assertThat(medtrumPump.currentSequenceNumber).isEqualTo(basalSequence)
|
||||||
Assertions.assertEquals(basalPatchId, medtrumPump.lastBasalPatchId)
|
assertThat(medtrumPump.lastBasalPatchId).isEqualTo(basalPatchId)
|
||||||
Assertions.assertEquals(basalStartTime, medtrumPump.lastBasalStartTime)
|
assertThat(medtrumPump.lastBasalStartTime).isEqualTo(basalStartTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleBasalStatusUpdateWhenBasalTypeIsRelativeTempAndTemporaryBasalInfoThenExpectNewData() {
|
@Test fun handleBasalStatusUpdateWhenBasalTypeIsRelativeTempAndTemporaryBasalInfoThenExpectNewData() {
|
||||||
|
@ -329,12 +329,12 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
||||||
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
||||||
)
|
)
|
||||||
|
|
||||||
Assertions.assertEquals(basalType, medtrumPump.lastBasalType)
|
assertThat(medtrumPump.lastBasalType).isEqualTo(basalType)
|
||||||
Assertions.assertEquals(basalRate, medtrumPump.lastBasalRate, 0.01)
|
assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(basalRate)
|
||||||
Assertions.assertEquals(basalSequence, medtrumPump.lastBasalSequence)
|
assertThat(medtrumPump.lastBasalSequence).isEqualTo(basalSequence)
|
||||||
Assertions.assertEquals(basalSequence, medtrumPump.currentSequenceNumber)
|
assertThat(medtrumPump.currentSequenceNumber).isEqualTo(basalSequence)
|
||||||
Assertions.assertEquals(basalPatchId, medtrumPump.lastBasalPatchId)
|
assertThat(medtrumPump.lastBasalPatchId).isEqualTo(basalPatchId)
|
||||||
Assertions.assertEquals(basalStartTime, medtrumPump.lastBasalStartTime)
|
assertThat(medtrumPump.lastBasalStartTime).isEqualTo(basalStartTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleBasalStatusUpdateWhenBasalTypeIsSuspendedThenExpectNewData() {
|
@Test fun handleBasalStatusUpdateWhenBasalTypeIsSuspendedThenExpectNewData() {
|
||||||
|
@ -378,12 +378,12 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
||||||
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
||||||
)
|
)
|
||||||
|
|
||||||
Assertions.assertEquals(basalType, medtrumPump.lastBasalType)
|
assertThat(medtrumPump.lastBasalType).isEqualTo(basalType)
|
||||||
Assertions.assertEquals(basalRate, medtrumPump.lastBasalRate, 0.01)
|
assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(basalRate)
|
||||||
Assertions.assertEquals(basalSequence, medtrumPump.lastBasalSequence)
|
assertThat(medtrumPump.lastBasalSequence).isEqualTo(basalSequence)
|
||||||
Assertions.assertEquals(basalSequence, medtrumPump.currentSequenceNumber)
|
assertThat(medtrumPump.currentSequenceNumber).isEqualTo(basalSequence)
|
||||||
Assertions.assertEquals(basalPatchId, medtrumPump.lastBasalPatchId)
|
assertThat(medtrumPump.lastBasalPatchId).isEqualTo(basalPatchId)
|
||||||
Assertions.assertEquals(basalStartTime, medtrumPump.lastBasalStartTime)
|
assertThat(medtrumPump.lastBasalStartTime).isEqualTo(basalStartTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleBasalStatusUpdateWhenBasalTypeIsATypeIsSuspendedAndSameExpectedTemporaryBasalInfoThenExpectNoPumpSync() {
|
@Test fun handleBasalStatusUpdateWhenBasalTypeIsATypeIsSuspendedAndSameExpectedTemporaryBasalInfoThenExpectNoPumpSync() {
|
||||||
|
@ -424,12 +424,12 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
||||||
anyOrNull()
|
anyOrNull()
|
||||||
)
|
)
|
||||||
|
|
||||||
Assertions.assertEquals(basalType, medtrumPump.lastBasalType)
|
assertThat(medtrumPump.lastBasalType).isEqualTo(basalType)
|
||||||
Assertions.assertEquals(basalRate, medtrumPump.lastBasalRate, 0.01)
|
assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(basalRate)
|
||||||
Assertions.assertEquals(basalSequence, medtrumPump.lastBasalSequence)
|
assertThat(medtrumPump.lastBasalSequence).isEqualTo(basalSequence)
|
||||||
Assertions.assertEquals(basalSequence, medtrumPump.currentSequenceNumber)
|
assertThat(medtrumPump.currentSequenceNumber).isEqualTo(basalSequence)
|
||||||
Assertions.assertEquals(basalPatchId, medtrumPump.lastBasalPatchId)
|
assertThat(medtrumPump.lastBasalPatchId).isEqualTo(basalPatchId)
|
||||||
Assertions.assertEquals(basalStartTime, medtrumPump.lastBasalStartTime)
|
assertThat(medtrumPump.lastBasalStartTime).isEqualTo(basalStartTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleBasalStatusUpdateWhenBasalTypeIsSuspendedAndNewerFakeTBRThenExpectInvalidateAndNewData() {
|
@Test fun handleBasalStatusUpdateWhenBasalTypeIsSuspendedAndNewerFakeTBRThenExpectInvalidateAndNewData() {
|
||||||
|
@ -475,12 +475,12 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
||||||
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
||||||
)
|
)
|
||||||
|
|
||||||
Assertions.assertEquals(basalType, medtrumPump.lastBasalType)
|
assertThat(medtrumPump.lastBasalType).isEqualTo(basalType)
|
||||||
Assertions.assertEquals(basalRate, medtrumPump.lastBasalRate, 0.01)
|
assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(basalRate)
|
||||||
Assertions.assertEquals(basalSequence, medtrumPump.lastBasalSequence)
|
assertThat(medtrumPump.lastBasalSequence).isEqualTo(basalSequence)
|
||||||
Assertions.assertEquals(basalSequence, medtrumPump.currentSequenceNumber)
|
assertThat(medtrumPump.currentSequenceNumber).isEqualTo(basalSequence)
|
||||||
Assertions.assertEquals(basalPatchId, medtrumPump.lastBasalPatchId)
|
assertThat(medtrumPump.lastBasalPatchId).isEqualTo(basalPatchId)
|
||||||
Assertions.assertEquals(basalStartTime, medtrumPump.lastBasalStartTime)
|
assertThat(medtrumPump.lastBasalStartTime).isEqualTo(basalStartTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleBasalStatusUpdateWhenBasalTypeIsNoneAndThenExpectFakeTBR() {
|
@Test fun handleBasalStatusUpdateWhenBasalTypeIsNoneAndThenExpectFakeTBR() {
|
||||||
|
@ -520,12 +520,12 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
||||||
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
||||||
)
|
)
|
||||||
|
|
||||||
Assertions.assertEquals(basalType, medtrumPump.lastBasalType)
|
assertThat(medtrumPump.lastBasalType).isEqualTo(basalType)
|
||||||
Assertions.assertEquals(basalRate, medtrumPump.lastBasalRate, 0.01)
|
assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(basalRate)
|
||||||
Assertions.assertEquals(basalSequence, medtrumPump.lastBasalSequence)
|
assertThat(medtrumPump.lastBasalSequence).isEqualTo(basalSequence)
|
||||||
Assertions.assertEquals(basalSequence, medtrumPump.currentSequenceNumber)
|
assertThat(medtrumPump.currentSequenceNumber).isEqualTo(basalSequence)
|
||||||
Assertions.assertEquals(basalPatchId, medtrumPump.lastBasalPatchId)
|
assertThat(medtrumPump.lastBasalPatchId).isEqualTo(basalPatchId)
|
||||||
Assertions.assertEquals(basalStartTime, medtrumPump.lastBasalStartTime)
|
assertThat(medtrumPump.lastBasalStartTime).isEqualTo(basalStartTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleBasalStatusUpdateWhenBasalTypeIsStandardAndTempBasalExpectedThenExpectSyncStop() {
|
@Test fun handleBasalStatusUpdateWhenBasalTypeIsStandardAndTempBasalExpectedThenExpectSyncStop() {
|
||||||
|
@ -564,12 +564,12 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
||||||
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
||||||
)
|
)
|
||||||
|
|
||||||
Assertions.assertEquals(basalType, medtrumPump.lastBasalType)
|
assertThat(medtrumPump.lastBasalType).isEqualTo(basalType)
|
||||||
Assertions.assertEquals(basalRate, medtrumPump.lastBasalRate, 0.01)
|
assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(basalRate)
|
||||||
Assertions.assertEquals(basalSequence, medtrumPump.lastBasalSequence)
|
assertThat(medtrumPump.lastBasalSequence).isEqualTo(basalSequence)
|
||||||
Assertions.assertEquals(basalSequence, medtrumPump.currentSequenceNumber)
|
assertThat(medtrumPump.currentSequenceNumber).isEqualTo(basalSequence)
|
||||||
Assertions.assertEquals(basalPatchId, medtrumPump.lastBasalPatchId)
|
assertThat(medtrumPump.lastBasalPatchId).isEqualTo(basalPatchId)
|
||||||
Assertions.assertEquals(basalStartTime, medtrumPump.lastBasalStartTime)
|
assertThat(medtrumPump.lastBasalStartTime).isEqualTo(basalStartTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleBasalStatusUpdateWhenBasalTypeIsStandardAndNoTempBasalExpectedThenExpectNoSyncStop() {
|
@Test fun handleBasalStatusUpdateWhenBasalTypeIsStandardAndNoTempBasalExpectedThenExpectNoSyncStop() {
|
||||||
|
@ -605,12 +605,12 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
||||||
anyOrNull()
|
anyOrNull()
|
||||||
)
|
)
|
||||||
|
|
||||||
Assertions.assertEquals(basalType, medtrumPump.lastBasalType)
|
assertThat(medtrumPump.lastBasalType).isEqualTo(basalType)
|
||||||
Assertions.assertEquals(basalRate, medtrumPump.lastBasalRate, 0.01)
|
assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(basalRate)
|
||||||
Assertions.assertEquals(basalSequence, medtrumPump.lastBasalSequence)
|
assertThat(medtrumPump.lastBasalSequence).isEqualTo(basalSequence)
|
||||||
Assertions.assertEquals(basalSequence, medtrumPump.currentSequenceNumber)
|
assertThat(medtrumPump.currentSequenceNumber).isEqualTo(basalSequence)
|
||||||
Assertions.assertEquals(basalPatchId, medtrumPump.lastBasalPatchId)
|
assertThat(medtrumPump.lastBasalPatchId).isEqualTo(basalPatchId)
|
||||||
Assertions.assertEquals(basalStartTime, medtrumPump.lastBasalStartTime)
|
assertThat(medtrumPump.lastBasalStartTime).isEqualTo(basalStartTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleNewPatchCalledWhenCalledExpectNewDataPresent() {
|
@Test fun handleNewPatchCalledWhenCalledExpectNewDataPresent() {
|
||||||
|
@ -626,10 +626,10 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
||||||
medtrumPump.handleNewPatch(newPatchId, newSequenceNumber, newStartTime)
|
medtrumPump.handleNewPatch(newPatchId, newSequenceNumber, newStartTime)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(newPatchId, medtrumPump.patchId)
|
assertThat(medtrumPump.patchId).isEqualTo(newPatchId)
|
||||||
Assertions.assertEquals(newSequenceNumber, medtrumPump.currentSequenceNumber)
|
assertThat(medtrumPump.currentSequenceNumber).isEqualTo(newSequenceNumber)
|
||||||
Assertions.assertEquals(newStartTime, medtrumPump.patchStartTime)
|
assertThat(medtrumPump.patchStartTime).isEqualTo(newStartTime)
|
||||||
Assertions.assertEquals(1, medtrumPump.syncedSequenceNumber)
|
assertThat(medtrumPump.syncedSequenceNumber).isEqualTo(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleStopStatusUpdateWhenSequenceThenExpectUpdate() {
|
@Test fun handleStopStatusUpdateWhenSequenceThenExpectUpdate() {
|
||||||
|
@ -644,8 +644,8 @@ class MedtrumPumpTest : MedtrumTestBase() {
|
||||||
medtrumPump.handleStopStatusUpdate(sequence, patchId)
|
medtrumPump.handleStopStatusUpdate(sequence, patchId)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(patchId, medtrumPump.lastStopPatchId)
|
assertThat(medtrumPump.lastStopPatchId).isEqualTo(patchId)
|
||||||
Assertions.assertEquals(sequence, medtrumPump.currentSequenceNumber)
|
assertThat(medtrumPump.currentSequenceNumber).isEqualTo(sequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun setFakeTBRIfNotSetWhenNoFakeTBRAlreadyRunningExpectPumpSync() {
|
@Test fun setFakeTBRIfNotSetWhenNoFakeTBRAlreadyRunningExpectPumpSync() {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.pump.medtrum.comm
|
package info.nightscout.pump.medtrum.comm
|
||||||
|
|
||||||
import org.junit.jupiter.api.Assertions
|
import com.google.common.truth.Truth.assertThat
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class WriteCommandPacketsTest {
|
class WriteCommandPacketsTest {
|
||||||
|
@ -8,20 +8,20 @@ class WriteCommandPacketsTest {
|
||||||
@Test
|
@Test
|
||||||
fun given14LongCommandExpectOnePacket() {
|
fun given14LongCommandExpectOnePacket() {
|
||||||
val input = byteArrayOf(5, 2, 0, 0, 0, 0, -21, 57, -122, -56)
|
val input = byteArrayOf(5, 2, 0, 0, 0, 0, -21, 57, -122, -56)
|
||||||
val expect = byteArrayOf(14, 5, 0, 0, 2, 0, 0, 0, 0, -21, 57, -122, -56, -93, 0)
|
val expected = byteArrayOf(14, 5, 0, 0, 2, 0, 0, 0, 0, -21, 57, -122, -56, -93, 0)
|
||||||
val sequence = 0
|
val sequence = 0
|
||||||
val cmdPackets = WriteCommandPackets(input, sequence)
|
val cmdPackets = WriteCommandPackets(input, sequence)
|
||||||
val output = cmdPackets.getNextPacket()
|
val output = cmdPackets.getNextPacket()
|
||||||
|
|
||||||
Assertions.assertEquals(expect.contentToString(), output.contentToString())
|
assertThat(output.contentToString()).isEqualTo(expected.contentToString())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun given41LongCommandExpectThreePackets() {
|
fun given41LongCommandExpectThreePackets() {
|
||||||
val input = byteArrayOf(18, 0, 12, 0, 3, 0, 1, 30, 32, 3, 16, 14, 0, 0, 1, 7, 0, -96, 2, -16, 96, 2, 104, 33, 2, -32, -31, 1, -64, 3, 2, -20, 36, 2, 100, -123, 2)
|
val input = byteArrayOf(18, 0, 12, 0, 3, 0, 1, 30, 32, 3, 16, 14, 0, 0, 1, 7, 0, -96, 2, -16, 96, 2, 104, 33, 2, -32, -31, 1, -64, 3, 2, -20, 36, 2, 100, -123, 2)
|
||||||
val expect1 = byteArrayOf(41, 18, 0, 1, 0, 12, 0, 3, 0, 1, 30, 32, 3, 16, 14, 0, 0, 1, 7, -121)
|
val expected1 = byteArrayOf(41, 18, 0, 1, 0, 12, 0, 3, 0, 1, 30, 32, 3, 16, 14, 0, 0, 1, 7, -121)
|
||||||
val expect2 = byteArrayOf(41, 18, 0, 2, 0, -96, 2, -16, 96, 2, 104, 33, 2, -32, -31, 1, -64, 3, 2, -3)
|
val expected2 = byteArrayOf(41, 18, 0, 2, 0, -96, 2, -16, 96, 2, 104, 33, 2, -32, -31, 1, -64, 3, 2, -3)
|
||||||
val expect3 = byteArrayOf(41, 18, 0, 3, -20, 36, 2, 100, -123, 2, -125, -89)
|
val expected3 = byteArrayOf(41, 18, 0, 3, -20, 36, 2, 100, -123, 2, -125, -89)
|
||||||
|
|
||||||
val sequence = 0
|
val sequence = 0
|
||||||
val cmdPackets = WriteCommandPackets(input, sequence)
|
val cmdPackets = WriteCommandPackets(input, sequence)
|
||||||
|
@ -31,10 +31,10 @@ class WriteCommandPacketsTest {
|
||||||
val output4 = cmdPackets.getNextPacket()
|
val output4 = cmdPackets.getNextPacket()
|
||||||
|
|
||||||
|
|
||||||
Assertions.assertEquals(expect1.contentToString(), output1.contentToString())
|
assertThat(output1.contentToString()).isEqualTo(expected1.contentToString())
|
||||||
Assertions.assertEquals(expect2.contentToString(), output2.contentToString())
|
assertThat(output2.contentToString()).isEqualTo(expected2.contentToString())
|
||||||
Assertions.assertEquals(expect3.contentToString(), output3.contentToString())
|
assertThat(output3.contentToString()).isEqualTo(expected3.contentToString())
|
||||||
Assertions.assertNull(output4)
|
assertThat(output4).isNull()
|
||||||
Assertions.assertEquals(true, cmdPackets.allPacketsConsumed())
|
assertThat(cmdPackets.allPacketsConsumed()).isTrue()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,10 @@ package info.nightscout.pump.medtrum.comm.packets
|
||||||
|
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import info.nightscout.pump.medtrum.MedtrumTestBase
|
import info.nightscout.pump.medtrum.MedtrumTestBase
|
||||||
import info.nightscout.pump.medtrum.comm.enums.AlarmSetting
|
import info.nightscout.pump.medtrum.comm.enums.AlarmSetting
|
||||||
import info.nightscout.pump.medtrum.comm.enums.BasalType
|
import info.nightscout.pump.medtrum.comm.enums.BasalType
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class ActivatePacketTest : MedtrumTestBase() {
|
class ActivatePacketTest : MedtrumTestBase() {
|
||||||
|
@ -38,7 +38,7 @@ class ActivatePacketTest : MedtrumTestBase() {
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
val expectedByteArray = byteArrayOf(18, 0, 12, 1, 6, 0, 0, 30, 32, 3, 16, 14, 0, 0, 1, 3, 16, 14, 0, 0, 1, 2, 12, 12, 12)
|
val expectedByteArray = byteArrayOf(18, 0, 12, 1, 6, 0, 0, 30, 32, 3, 16, 14, 0, 0, 1, 3, 16, 14, 0, 0, 1, 2, 12, 12, 12)
|
||||||
Assertions.assertEquals(expectedByteArray.contentToString(), result.contentToString())
|
assertThat(result.contentToString()).isEqualTo(expectedByteArray.contentToString())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() {
|
@Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() {
|
||||||
|
@ -64,15 +64,15 @@ class ActivatePacketTest : MedtrumTestBase() {
|
||||||
val expectedBasalPatchId = 41L
|
val expectedBasalPatchId = 41L
|
||||||
val expectedBasalStart = 1675605528000L
|
val expectedBasalStart = 1675605528000L
|
||||||
|
|
||||||
Assertions.assertEquals(true, result)
|
assertThat(result).isTrue()
|
||||||
Assertions.assertEquals(expectedPatchId, medtrumPump.patchId)
|
assertThat(medtrumPump.patchId).isEqualTo(expectedPatchId)
|
||||||
Assertions.assertEquals(expectedTime, medtrumPump.lastTimeReceivedFromPump)
|
assertThat(medtrumPump.lastTimeReceivedFromPump).isEqualTo(expectedTime)
|
||||||
Assertions.assertEquals(expectedBasalType, medtrumPump.lastBasalType)
|
assertThat(medtrumPump.lastBasalType).isEqualTo(expectedBasalType)
|
||||||
Assertions.assertEquals(expectedBasalRate, medtrumPump.lastBasalRate, 0.01)
|
assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(expectedBasalRate)
|
||||||
Assertions.assertEquals(expectedBasalSequence, medtrumPump.lastBasalSequence)
|
assertThat(medtrumPump.lastBasalSequence).isEqualTo(expectedBasalSequence)
|
||||||
Assertions.assertEquals(expectedBasalPatchId, medtrumPump.lastBasalPatchId)
|
assertThat(medtrumPump.lastBasalPatchId).isEqualTo(expectedBasalPatchId)
|
||||||
Assertions.assertEquals(expectedBasalStart, medtrumPump.lastBasalStartTime)
|
assertThat(medtrumPump.lastBasalStartTime).isEqualTo(expectedBasalStart)
|
||||||
Assertions.assertEquals(basalProfile, medtrumPump.actualBasalProfile)
|
assertThat(medtrumPump.actualBasalProfile).isEqualTo(basalProfile)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
||||||
|
@ -84,6 +84,6 @@ class ActivatePacketTest : MedtrumTestBase() {
|
||||||
val result = packet.handleResponse(response)
|
val result = packet.handleResponse(response)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertFalse(result)
|
assertThat(result).isFalse()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package info.nightscout.pump.medtrum.comm.packets
|
package info.nightscout.pump.medtrum.comm.packets
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.medtrum.MedtrumPump
|
import info.nightscout.pump.medtrum.MedtrumPump
|
||||||
import info.nightscout.pump.medtrum.MedtrumTestBase
|
import info.nightscout.pump.medtrum.MedtrumTestBase
|
||||||
import info.nightscout.pump.medtrum.extension.toByteArray
|
import info.nightscout.pump.medtrum.extension.toByteArray
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class AuthorizePacketTest : MedtrumTestBase() {
|
class AuthorizePacketTest : MedtrumTestBase() {
|
||||||
|
@ -37,8 +37,7 @@ class AuthorizePacketTest : MedtrumTestBase() {
|
||||||
val key = 3364239851
|
val key = 3364239851
|
||||||
val type = 2
|
val type = 2
|
||||||
val expectedByteArray = byteArrayOf(opCode.toByte()) + type.toByte() + medtrumPump.patchSessionToken.toByteArray(4) + key.toByteArray(4)
|
val expectedByteArray = byteArrayOf(opCode.toByte()) + type.toByte() + medtrumPump.patchSessionToken.toByteArray(4) + key.toByteArray(4)
|
||||||
Assertions.assertEquals(10, result.size)
|
assertThat(result).asList().containsExactlyElementsIn(expectedByteArray.toList()).inOrder()
|
||||||
Assertions.assertEquals(expectedByteArray.contentToString(), result.contentToString())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenResponseWhenMessageIsCorrectLengthThenResultTrue() {
|
@Test fun handleResponseGivenResponseWhenMessageIsCorrectLengthThenResultTrue() {
|
||||||
|
@ -57,10 +56,10 @@ class AuthorizePacketTest : MedtrumTestBase() {
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
val swString = "$swVerX.$swVerY.$swVerZ"
|
val swString = "$swVerX.$swVerY.$swVerZ"
|
||||||
Assertions.assertTrue(result)
|
assertThat(result).isTrue()
|
||||||
Assertions.assertFalse(packet.failed)
|
assertThat(packet.failed).isFalse()
|
||||||
Assertions.assertEquals(deviceType, medtrumPump.deviceType)
|
assertThat(medtrumPump.deviceType).isEqualTo(deviceType)
|
||||||
Assertions.assertEquals(swString, medtrumPump.swVersion)
|
assertThat(medtrumPump.swVersion).isEqualTo(swString)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
||||||
|
@ -75,7 +74,7 @@ class AuthorizePacketTest : MedtrumTestBase() {
|
||||||
val result = packet.handleResponse(response)
|
val result = packet.handleResponse(response)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertFalse(result)
|
assertThat(result).isFalse()
|
||||||
Assertions.assertTrue(packet.failed)
|
assertThat(packet.failed).isTrue()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package info.nightscout.pump.medtrum.comm.packets
|
package info.nightscout.pump.medtrum.comm.packets
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.medtrum.MedtrumTestBase
|
import info.nightscout.pump.medtrum.MedtrumTestBase
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class CancelBolusPacketTest : MedtrumTestBase() {
|
class CancelBolusPacketTest : MedtrumTestBase() {
|
||||||
|
@ -27,8 +27,6 @@ class CancelBolusPacketTest : MedtrumTestBase() {
|
||||||
val result = packet.getRequest()
|
val result = packet.getRequest()
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
val expectedByteArray = byteArrayOf(opCode.toByte()) + 1.toByte()
|
assertThat(result).asList().containsExactly(opCode.toByte(), 1.toByte()).inOrder()
|
||||||
Assertions.assertEquals(2, result.size)
|
|
||||||
Assertions.assertEquals(expectedByteArray.contentToString(), result.contentToString())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package info.nightscout.pump.medtrum.comm.packets
|
package info.nightscout.pump.medtrum.comm.packets
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.medtrum.MedtrumTestBase
|
import info.nightscout.pump.medtrum.MedtrumTestBase
|
||||||
import info.nightscout.pump.medtrum.comm.enums.BasalType
|
import info.nightscout.pump.medtrum.comm.enums.BasalType
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class CancelTempBasalPacketTest : MedtrumTestBase() {
|
class CancelTempBasalPacketTest : MedtrumTestBase() {
|
||||||
|
@ -30,8 +30,7 @@ class CancelTempBasalPacketTest : MedtrumTestBase() {
|
||||||
val result = packet.getRequest()
|
val result = packet.getRequest()
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(1, result.size)
|
assertThat(result).asList().containsExactly(opCode.toByte())
|
||||||
Assertions.assertEquals(opCode.toByte(), result[0])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() {
|
@Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() {
|
||||||
|
@ -49,12 +48,12 @@ class CancelTempBasalPacketTest : MedtrumTestBase() {
|
||||||
val expectedStartTime = 1679575392000L
|
val expectedStartTime = 1679575392000L
|
||||||
val expectedPatchId = 146L
|
val expectedPatchId = 146L
|
||||||
|
|
||||||
Assertions.assertTrue(result)
|
assertThat(result).isTrue()
|
||||||
Assertions.assertEquals(expectedBasalType, medtrumPump.lastBasalType)
|
assertThat(medtrumPump.lastBasalType).isEqualTo(expectedBasalType)
|
||||||
Assertions.assertEquals(expectedBasalRate, medtrumPump.lastBasalRate, 0.01)
|
assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(expectedBasalRate)
|
||||||
Assertions.assertEquals(expectedBasalSequence, medtrumPump.lastBasalSequence)
|
assertThat(medtrumPump.lastBasalSequence).isEqualTo(expectedBasalSequence)
|
||||||
Assertions.assertEquals(expectedStartTime, medtrumPump.lastBasalStartTime)
|
assertThat(medtrumPump.lastBasalStartTime).isEqualTo(expectedStartTime)
|
||||||
Assertions.assertEquals(expectedPatchId, medtrumPump.lastBasalPatchId)
|
assertThat(medtrumPump.lastBasalPatchId).isEqualTo(expectedPatchId)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
||||||
|
@ -66,7 +65,7 @@ class CancelTempBasalPacketTest : MedtrumTestBase() {
|
||||||
val result = packet.handleResponse(response)
|
val result = packet.handleResponse(response)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertFalse(result)
|
assertThat(result).isFalse()
|
||||||
Assertions.assertTrue(packet.failed)
|
assertThat(packet.failed).isTrue()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package info.nightscout.pump.medtrum.comm.packets
|
package info.nightscout.pump.medtrum.comm.packets
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.medtrum.MedtrumTestBase
|
import info.nightscout.pump.medtrum.MedtrumTestBase
|
||||||
import info.nightscout.pump.medtrum.extension.toInt
|
import info.nightscout.pump.medtrum.extension.toInt
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class ClearPumpAlarmPacketTest : MedtrumTestBase() {
|
class ClearPumpAlarmPacketTest : MedtrumTestBase() {
|
||||||
|
@ -29,8 +29,8 @@ class ClearPumpAlarmPacketTest : MedtrumTestBase() {
|
||||||
val result = packet.getRequest()
|
val result = packet.getRequest()
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(3, result.size)
|
assertThat(result).hasLength(3)
|
||||||
Assertions.assertEquals(opCode.toByte(), result[0])
|
assertThat(result[0]).isEqualTo(opCode.toByte())
|
||||||
Assertions.assertEquals(clearCode, result.copyOfRange(1, 3).toInt())
|
assertThat(result.copyOfRange(1, 3).toInt()).isEqualTo(clearCode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package info.nightscout.pump.medtrum.comm.packets
|
package info.nightscout.pump.medtrum.comm.packets
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.medtrum.MedtrumTestBase
|
import info.nightscout.pump.medtrum.MedtrumTestBase
|
||||||
import info.nightscout.pump.medtrum.extension.toByteArray
|
import info.nightscout.pump.medtrum.extension.toByteArray
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class GetDeviceTypePacketTest : MedtrumTestBase() {
|
class GetDeviceTypePacketTest : MedtrumTestBase() {
|
||||||
|
@ -28,8 +28,7 @@ class GetDeviceTypePacketTest : MedtrumTestBase() {
|
||||||
val result = packet.getRequest()
|
val result = packet.getRequest()
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(1, result.size)
|
assertThat(result).asList().containsExactly(opCode.toByte())
|
||||||
Assertions.assertEquals(opCode.toByte(), result[0])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenResponseWhenMessageIsCorrectLengthThenResultTrue() {
|
@Test fun handleResponseGivenResponseWhenMessageIsCorrectLengthThenResultTrue() {
|
||||||
|
@ -45,10 +44,10 @@ class GetDeviceTypePacketTest : MedtrumTestBase() {
|
||||||
val result = packet.handleResponse(response)
|
val result = packet.handleResponse(response)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(true, result)
|
assertThat(result).isTrue()
|
||||||
Assertions.assertEquals(false, packet.failed)
|
assertThat(packet.failed).isFalse()
|
||||||
Assertions.assertEquals(deviceType, packet.deviceType)
|
assertThat(packet.deviceType).isEqualTo(deviceType)
|
||||||
Assertions.assertEquals(deviceSN, packet.deviceSN)
|
assertThat(packet.deviceSN).isEqualTo(deviceSN)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,9 +64,9 @@ class GetDeviceTypePacketTest : MedtrumTestBase() {
|
||||||
val result = packet.handleResponse(response.sliceArray(0..response.size - 2))
|
val result = packet.handleResponse(response.sliceArray(0..response.size - 2))
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(false, result)
|
assertThat(result).isFalse()
|
||||||
Assertions.assertEquals(true, packet.failed)
|
assertThat(packet.failed).isTrue()
|
||||||
Assertions.assertEquals(0, packet.deviceType)
|
assertThat(packet.deviceType).isEqualTo(0)
|
||||||
Assertions.assertEquals(0, packet.deviceSN)
|
assertThat(packet.deviceSN).isEqualTo(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,10 @@ import app.aaps.core.interfaces.pump.DetailedBolusInfo
|
||||||
import app.aaps.core.interfaces.pump.DetailedBolusInfoStorage
|
import app.aaps.core.interfaces.pump.DetailedBolusInfoStorage
|
||||||
import app.aaps.core.interfaces.pump.PumpSync
|
import app.aaps.core.interfaces.pump.PumpSync
|
||||||
import app.aaps.core.interfaces.utils.T
|
import app.aaps.core.interfaces.utils.T
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.medtrum.MedtrumTestBase
|
import info.nightscout.pump.medtrum.MedtrumTestBase
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
import org.mockito.Mockito
|
import org.mockito.Mockito
|
||||||
|
@ -42,7 +42,7 @@ class GetRecordPacketTest : MedtrumTestBase() {
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
val expected = byteArrayOf(99, 4, 0, -110, 0)
|
val expected = byteArrayOf(99, 4, 0, -110, 0)
|
||||||
Assertions.assertEquals(expected.contentToString(), result.contentToString())
|
assertThat(result).asList().containsExactlyElementsIn(expected.toList()).inOrder()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() {
|
@Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() {
|
||||||
|
@ -54,8 +54,8 @@ class GetRecordPacketTest : MedtrumTestBase() {
|
||||||
val result = packet.handleResponse(data)
|
val result = packet.handleResponse(data)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(true, result)
|
assertThat(result).isTrue()
|
||||||
Assertions.assertEquals(false, packet.failed)
|
assertThat(packet.failed).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
||||||
|
@ -67,8 +67,8 @@ class GetRecordPacketTest : MedtrumTestBase() {
|
||||||
val result = packet.handleResponse(data)
|
val result = packet.handleResponse(data)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(false, result)
|
assertThat(result).isFalse()
|
||||||
Assertions.assertEquals(true, packet.failed)
|
assertThat(packet.failed).isTrue()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenBolusRecordWhenAndDetailedBolusInfoPresentThenExpectPumpSyncWithTempId() {
|
@Test fun handleResponseGivenBolusRecordWhenAndDetailedBolusInfoPresentThenExpectPumpSyncWithTempId() {
|
||||||
|
@ -100,10 +100,10 @@ class GetRecordPacketTest : MedtrumTestBase() {
|
||||||
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
||||||
)
|
)
|
||||||
|
|
||||||
Assertions.assertEquals(true, result)
|
assertThat(result).isTrue()
|
||||||
Assertions.assertEquals(false, packet.failed)
|
assertThat(packet.failed).isFalse()
|
||||||
Assertions.assertEquals(timestamp, medtrumPump.lastBolusTime)
|
assertThat(medtrumPump.lastBolusTime).isEqualTo(timestamp)
|
||||||
Assertions.assertEquals(amount, medtrumPump.lastBolusAmount, 0.01)
|
assertThat(medtrumPump.lastBolusAmount).isWithin(0.01).of(amount)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenBolusRecordWhenAndNoDetailedBolusInfoPresentThenExpectPumpSyncWithPumpId() {
|
@Test fun handleResponseGivenBolusRecordWhenAndNoDetailedBolusInfoPresentThenExpectPumpSyncWithPumpId() {
|
||||||
|
@ -129,10 +129,10 @@ class GetRecordPacketTest : MedtrumTestBase() {
|
||||||
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
||||||
)
|
)
|
||||||
|
|
||||||
Assertions.assertEquals(true, result)
|
assertThat(result).isTrue()
|
||||||
Assertions.assertEquals(false, packet.failed)
|
assertThat(packet.failed).isFalse()
|
||||||
Assertions.assertEquals(timestamp, medtrumPump.lastBolusTime)
|
assertThat(medtrumPump.lastBolusTime).isEqualTo(timestamp)
|
||||||
Assertions.assertEquals(amount, medtrumPump.lastBolusAmount, 0.01)
|
assertThat(medtrumPump.lastBolusAmount).isWithin(0.01).of(amount)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenExtendedBolusRecordThenExpectPumpSyncWithPumpId() {
|
@Test fun handleResponseGivenExtendedBolusRecordThenExpectPumpSyncWithPumpId() {
|
||||||
|
@ -157,8 +157,8 @@ class GetRecordPacketTest : MedtrumTestBase() {
|
||||||
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
||||||
)
|
)
|
||||||
|
|
||||||
Assertions.assertEquals(true, result)
|
assertThat(result).isTrue()
|
||||||
Assertions.assertEquals(false, packet.failed)
|
assertThat(packet.failed).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenComboBolusRecordWhenAndNoDetailedBolusInfoPresentThenExpectPumpSyncWithPumpId() {
|
@Test fun handleResponseGivenComboBolusRecordWhenAndNoDetailedBolusInfoPresentThenExpectPumpSyncWithPumpId() {
|
||||||
|
@ -195,8 +195,8 @@ class GetRecordPacketTest : MedtrumTestBase() {
|
||||||
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
||||||
)
|
)
|
||||||
|
|
||||||
Assertions.assertEquals(true, result)
|
assertThat(result).isTrue()
|
||||||
Assertions.assertEquals(false, packet.failed)
|
assertThat(packet.failed).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenBasalRecordWhenAbsoluteTempThenExpectPumpSync() {
|
@Test fun handleResponseGivenBasalRecordWhenAbsoluteTempThenExpectPumpSync() {
|
||||||
|
@ -223,8 +223,8 @@ class GetRecordPacketTest : MedtrumTestBase() {
|
||||||
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
||||||
)
|
)
|
||||||
|
|
||||||
Assertions.assertEquals(true, result)
|
assertThat(result).isTrue()
|
||||||
Assertions.assertEquals(false, packet.failed)
|
assertThat(packet.failed).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenBasalRecordWhenRelativeTempThenExpectPumpSync() {
|
@Test fun handleResponseGivenBasalRecordWhenRelativeTempThenExpectPumpSync() {
|
||||||
|
@ -251,8 +251,8 @@ class GetRecordPacketTest : MedtrumTestBase() {
|
||||||
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
||||||
)
|
)
|
||||||
|
|
||||||
Assertions.assertEquals(true, result)
|
assertThat(result).isTrue()
|
||||||
Assertions.assertEquals(false, packet.failed)
|
assertThat(packet.failed).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenBasalRecordWhenSuspendThenExpectPumpSync() {
|
@Test fun handleResponseGivenBasalRecordWhenSuspendThenExpectPumpSync() {
|
||||||
|
@ -279,8 +279,8 @@ class GetRecordPacketTest : MedtrumTestBase() {
|
||||||
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
||||||
)
|
)
|
||||||
|
|
||||||
Assertions.assertEquals(true, result)
|
assertThat(result).isTrue()
|
||||||
Assertions.assertEquals(false, packet.failed)
|
assertThat(packet.failed).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenBasalRecordWhenStandardAndSuspendEndReasonThenExpectPumpSync() {
|
@Test fun handleResponseGivenBasalRecordWhenStandardAndSuspendEndReasonThenExpectPumpSync() {
|
||||||
|
@ -315,8 +315,8 @@ class GetRecordPacketTest : MedtrumTestBase() {
|
||||||
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
||||||
)
|
)
|
||||||
|
|
||||||
Assertions.assertEquals(true, result)
|
assertThat(result).isTrue()
|
||||||
Assertions.assertEquals(false, packet.failed)
|
assertThat(packet.failed).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenBasalRecordWhenTempAndSuspendEndReasonThenExpectPumpSync() {
|
@Test fun handleResponseGivenBasalRecordWhenTempAndSuspendEndReasonThenExpectPumpSync() {
|
||||||
|
@ -351,8 +351,8 @@ class GetRecordPacketTest : MedtrumTestBase() {
|
||||||
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
||||||
)
|
)
|
||||||
|
|
||||||
Assertions.assertEquals(true, result)
|
assertThat(result).isTrue()
|
||||||
Assertions.assertEquals(false, packet.failed)
|
assertThat(packet.failed).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenBasalRecordWhenStandardAndSuspendEndReasonAndNewerExistingTBRThenExpectNoPumpSync() {
|
@Test fun handleResponseGivenBasalRecordWhenStandardAndSuspendEndReasonAndNewerExistingTBRThenExpectNoPumpSync() {
|
||||||
|
@ -391,8 +391,8 @@ class GetRecordPacketTest : MedtrumTestBase() {
|
||||||
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
||||||
)
|
)
|
||||||
|
|
||||||
Assertions.assertEquals(true, result)
|
assertThat(result).isTrue()
|
||||||
Assertions.assertEquals(false, packet.failed)
|
assertThat(packet.failed).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenTDDRecordThenExpectPumpSync() {
|
@Test fun handleResponseGivenTDDRecordThenExpectPumpSync() {
|
||||||
|
@ -421,7 +421,7 @@ class GetRecordPacketTest : MedtrumTestBase() {
|
||||||
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
pumpSerial = medtrumPump.pumpSN.toString(radix = 16)
|
||||||
)
|
)
|
||||||
|
|
||||||
Assertions.assertEquals(true, result)
|
assertThat(result).isTrue()
|
||||||
Assertions.assertEquals(false, packet.failed)
|
assertThat(packet.failed).isFalse()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package info.nightscout.pump.medtrum.comm.packets
|
package info.nightscout.pump.medtrum.comm.packets
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.medtrum.MedtrumTestBase
|
import info.nightscout.pump.medtrum.MedtrumTestBase
|
||||||
import info.nightscout.pump.medtrum.extension.toByteArray
|
import info.nightscout.pump.medtrum.extension.toByteArray
|
||||||
import info.nightscout.pump.medtrum.util.MedtrumTimeUtil
|
import info.nightscout.pump.medtrum.util.MedtrumTimeUtil
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class GetTimePacketTest : MedtrumTestBase() {
|
class GetTimePacketTest : MedtrumTestBase() {
|
||||||
|
@ -30,8 +30,7 @@ class GetTimePacketTest : MedtrumTestBase() {
|
||||||
val result = packet.getRequest()
|
val result = packet.getRequest()
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(1, result.size)
|
assertThat(result).asList().containsExactly(opCode.toByte())
|
||||||
Assertions.assertEquals(opCode.toByte(), result[0])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenResponseWhenMessageIsCorrectLengthThenResultTrue() {
|
@Test fun handleResponseGivenResponseWhenMessageIsCorrectLengthThenResultTrue() {
|
||||||
|
@ -46,9 +45,9 @@ class GetTimePacketTest : MedtrumTestBase() {
|
||||||
val result = packet.handleResponse(response)
|
val result = packet.handleResponse(response)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(true, result)
|
assertThat(result).isTrue()
|
||||||
Assertions.assertEquals(false, packet.failed)
|
assertThat(packet.failed).isFalse()
|
||||||
Assertions.assertEquals(MedtrumTimeUtil().convertPumpTimeToSystemTimeMillis(time), medtrumPump.lastTimeReceivedFromPump)
|
assertThat(medtrumPump.lastTimeReceivedFromPump).isEqualTo(MedtrumTimeUtil().convertPumpTimeToSystemTimeMillis(time))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
||||||
|
@ -63,8 +62,8 @@ class GetTimePacketTest : MedtrumTestBase() {
|
||||||
val result = packet.handleResponse(response.sliceArray(0..response.size - 2))
|
val result = packet.handleResponse(response.sliceArray(0..response.size - 2))
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(false, result)
|
assertThat(result).isFalse()
|
||||||
Assertions.assertEquals(true, packet.failed)
|
assertThat(packet.failed).isTrue()
|
||||||
Assertions.assertEquals(0, medtrumPump.lastTimeReceivedFromPump)
|
assertThat(medtrumPump.lastTimeReceivedFromPump).isEqualTo(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package info.nightscout.pump.medtrum.comm.packets
|
package info.nightscout.pump.medtrum.comm.packets
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.medtrum.MedtrumTestBase
|
import info.nightscout.pump.medtrum.MedtrumTestBase
|
||||||
import info.nightscout.pump.medtrum.extension.toByteArray
|
import info.nightscout.pump.medtrum.extension.toByteArray
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class MedtrumPacketTest : MedtrumTestBase() {
|
class MedtrumPacketTest : MedtrumTestBase() {
|
||||||
|
@ -29,8 +29,7 @@ class MedtrumPacketTest : MedtrumTestBase() {
|
||||||
val result = packet.getRequest()
|
val result = packet.getRequest()
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(result.size, 1)
|
assertThat(result).asList().containsExactly(opCode.toByte())
|
||||||
Assertions.assertEquals(result[0], opCode.toByte())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenResponseWhenOpcodeIsCorrectThenResultTrue() {
|
@Test fun handleResponseGivenResponseWhenOpcodeIsCorrectThenResultTrue() {
|
||||||
|
@ -45,8 +44,8 @@ class MedtrumPacketTest : MedtrumTestBase() {
|
||||||
val result = packet.handleResponse(response)
|
val result = packet.handleResponse(response)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(result, true)
|
assertThat(result).isTrue()
|
||||||
Assertions.assertEquals(packet.failed, false)
|
assertThat(packet.failed).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenResponseWhenOpcodeIsIncorrectThenResultFalse() {
|
@Test fun handleResponseGivenResponseWhenOpcodeIsIncorrectThenResultFalse() {
|
||||||
|
@ -61,8 +60,8 @@ class MedtrumPacketTest : MedtrumTestBase() {
|
||||||
val result = packet.handleResponse(response)
|
val result = packet.handleResponse(response)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(result, false)
|
assertThat(result).isFalse()
|
||||||
Assertions.assertEquals(packet.failed, true)
|
assertThat(packet.failed).isTrue()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenResponseWhenResponseCodeIsWaitingThenResultFalse() {
|
@Test fun handleResponseGivenResponseWhenResponseCodeIsWaitingThenResultFalse() {
|
||||||
|
@ -77,8 +76,8 @@ class MedtrumPacketTest : MedtrumTestBase() {
|
||||||
val result = packet.handleResponse(response)
|
val result = packet.handleResponse(response)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(result, false)
|
assertThat(result).isFalse()
|
||||||
Assertions.assertEquals(packet.failed, false)
|
assertThat(packet.failed).isFalse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenResponseWhenResponseCodeIsErrorThenResultFalse() {
|
@Test fun handleResponseGivenResponseWhenResponseCodeIsErrorThenResultFalse() {
|
||||||
|
@ -93,8 +92,8 @@ class MedtrumPacketTest : MedtrumTestBase() {
|
||||||
val result = packet.handleResponse(response)
|
val result = packet.handleResponse(response)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(false, result)
|
assertThat(result).isFalse()
|
||||||
Assertions.assertEquals(true, packet.failed)
|
assertThat(packet.failed).isTrue()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
||||||
|
@ -108,7 +107,7 @@ class MedtrumPacketTest : MedtrumTestBase() {
|
||||||
val result = packet.handleResponse(response)
|
val result = packet.handleResponse(response)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(false, result)
|
assertThat(result).isFalse()
|
||||||
Assertions.assertEquals(true, packet.failed)
|
assertThat(packet.failed).isTrue()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package info.nightscout.pump.medtrum.comm.packets
|
package info.nightscout.pump.medtrum.comm.packets
|
||||||
|
|
||||||
import app.aaps.core.interfaces.rx.events.EventOverviewBolusProgress
|
import app.aaps.core.interfaces.rx.events.EventOverviewBolusProgress
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.medtrum.MedtrumTestBase
|
import info.nightscout.pump.medtrum.MedtrumTestBase
|
||||||
import info.nightscout.pump.medtrum.comm.enums.BasalType
|
import info.nightscout.pump.medtrum.comm.enums.BasalType
|
||||||
import info.nightscout.pump.medtrum.comm.enums.MedtrumPumpState
|
import info.nightscout.pump.medtrum.comm.enums.MedtrumPumpState
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class NotificationPacketTest : MedtrumTestBase() {
|
class NotificationPacketTest : MedtrumTestBase() {
|
||||||
|
@ -30,7 +30,7 @@ class NotificationPacketTest : MedtrumTestBase() {
|
||||||
NotificationPacket(packetInjector).handleNotification(byteArrayOf(state))
|
NotificationPacket(packetInjector).handleNotification(byteArrayOf(state))
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(medtrumPump.pumpState, MedtrumPumpState.fromByte(state))
|
assertThat(MedtrumPumpState.fromByte(state)).isEqualTo(medtrumPump.pumpState)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleNotificationGivenBasalDataThenDataSaved() {
|
@Test fun handleNotificationGivenBasalDataThenDataSaved() {
|
||||||
|
@ -41,12 +41,12 @@ class NotificationPacketTest : MedtrumTestBase() {
|
||||||
NotificationPacket(packetInjector).handleNotification(data)
|
NotificationPacket(packetInjector).handleNotification(data)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(BasalType.ABSOLUTE_TEMP, medtrumPump.lastBasalType)
|
assertThat(medtrumPump.lastBasalType).isEqualTo(BasalType.ABSOLUTE_TEMP)
|
||||||
Assertions.assertEquals(0.85, medtrumPump.lastBasalRate, 0.01)
|
assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(0.85)
|
||||||
Assertions.assertEquals(25, medtrumPump.lastBasalSequence)
|
assertThat(medtrumPump.lastBasalSequence).isEqualTo(25)
|
||||||
Assertions.assertEquals(14, medtrumPump.lastBasalPatchId)
|
assertThat(medtrumPump.lastBasalPatchId).isEqualTo(14)
|
||||||
Assertions.assertEquals(1685126612000, medtrumPump.lastBasalStartTime)
|
assertThat(medtrumPump.lastBasalStartTime).isEqualTo(1685126612000)
|
||||||
Assertions.assertEquals(186.80, medtrumPump.reservoir, 0.01)
|
assertThat(medtrumPump.reservoir).isWithin(0.01).of(186.80)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleNotificationGivenSequenceAndOtherDataThenDataSaved() {
|
@Test fun handleNotificationGivenSequenceAndOtherDataThenDataSaved() {
|
||||||
|
@ -57,7 +57,7 @@ class NotificationPacketTest : MedtrumTestBase() {
|
||||||
NotificationPacket(packetInjector).handleNotification(data)
|
NotificationPacket(packetInjector).handleNotification(data)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(167, medtrumPump.currentSequenceNumber)
|
assertThat(medtrumPump.currentSequenceNumber).isEqualTo(167)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleNotificationGivenBolusInProgressThenDataSaved() {
|
@Test fun handleNotificationGivenBolusInProgressThenDataSaved() {
|
||||||
|
@ -69,9 +69,9 @@ class NotificationPacketTest : MedtrumTestBase() {
|
||||||
NotificationPacket(packetInjector).handleNotification(data)
|
NotificationPacket(packetInjector).handleNotification(data)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(false, medtrumPump.bolusDone)
|
assertThat(medtrumPump.bolusDone).isFalse()
|
||||||
Assertions.assertEquals(0.15, medtrumPump.bolusingTreatment!!.insulin, 0.01)
|
assertThat(medtrumPump.bolusingTreatment!!.insulin).isWithin(0.01).of(0.15)
|
||||||
Assertions.assertEquals(163.5, medtrumPump.reservoir, 0.01)
|
assertThat(medtrumPump.reservoir).isWithin(0.01).of(163.5)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleNotificationGivenBolusFinishedThenDataSaved() {
|
@Test fun handleNotificationGivenBolusFinishedThenDataSaved() {
|
||||||
|
@ -83,8 +83,8 @@ class NotificationPacketTest : MedtrumTestBase() {
|
||||||
NotificationPacket(packetInjector).handleNotification(data)
|
NotificationPacket(packetInjector).handleNotification(data)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(true, medtrumPump.bolusDone)
|
assertThat(medtrumPump.bolusDone).isTrue()
|
||||||
Assertions.assertEquals(1.65, medtrumPump.bolusingTreatment!!.insulin, 0.01)
|
assertThat(medtrumPump.bolusingTreatment!!.insulin).isWithin(0.01).of(1.65)
|
||||||
Assertions.assertEquals(161.95, medtrumPump.reservoir, 0.01)
|
assertThat(medtrumPump.reservoir).isWithin(0.01).of(161.95)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package info.nightscout.pump.medtrum.comm.packets
|
package info.nightscout.pump.medtrum.comm.packets
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.medtrum.MedtrumTestBase
|
import info.nightscout.pump.medtrum.MedtrumTestBase
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class PollPatchPacketTest : MedtrumTestBase() {
|
class PollPatchPacketTest : MedtrumTestBase() {
|
||||||
|
@ -27,7 +27,6 @@ class PollPatchPacketTest : MedtrumTestBase() {
|
||||||
val result = packet.getRequest()
|
val result = packet.getRequest()
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(1, result.size)
|
assertThat(result).asList().containsExactly(opCode.toByte())
|
||||||
Assertions.assertEquals(opCode.toByte(), result[0])
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package info.nightscout.pump.medtrum.comm.packets
|
package info.nightscout.pump.medtrum.comm.packets
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.medtrum.MedtrumTestBase
|
import info.nightscout.pump.medtrum.MedtrumTestBase
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class PrimePacketTest : MedtrumTestBase() {
|
class PrimePacketTest : MedtrumTestBase() {
|
||||||
|
@ -27,7 +27,6 @@ class PrimePacketTest : MedtrumTestBase() {
|
||||||
val result = packet.getRequest()
|
val result = packet.getRequest()
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(1, result.size)
|
assertThat(result).asList().containsExactly(opCode.toByte())
|
||||||
Assertions.assertEquals(opCode.toByte(), result[0])
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package info.nightscout.pump.medtrum.comm.packets
|
package info.nightscout.pump.medtrum.comm.packets
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.medtrum.MedtrumTestBase
|
import info.nightscout.pump.medtrum.MedtrumTestBase
|
||||||
import info.nightscout.pump.medtrum.extension.toByteArray
|
import info.nightscout.pump.medtrum.extension.toByteArray
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class ReadBolusStatePacketTest : MedtrumTestBase() {
|
class ReadBolusStatePacketTest : MedtrumTestBase() {
|
||||||
|
@ -31,9 +31,9 @@ class ReadBolusStatePacketTest : MedtrumTestBase() {
|
||||||
val result = packet.handleResponse(response)
|
val result = packet.handleResponse(response)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertTrue(result)
|
assertThat(result).isTrue()
|
||||||
Assertions.assertFalse(packet.failed)
|
assertThat(packet.failed).isFalse()
|
||||||
Assertions.assertEquals(bolusData.contentToString(), packet.bolusData.contentToString())
|
assertThat(packet.bolusData).isEqualTo(bolusData)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
||||||
|
@ -47,8 +47,8 @@ class ReadBolusStatePacketTest : MedtrumTestBase() {
|
||||||
val result = packet.handleResponse(response)
|
val result = packet.handleResponse(response)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(false, result)
|
assertThat(result).isFalse()
|
||||||
Assertions.assertEquals(true, packet.failed)
|
assertThat(packet.failed).isTrue()
|
||||||
Assertions.assertEquals(byteArrayOf().contentToString(), packet.bolusData.contentToString())
|
assertThat(packet.bolusData).isEmpty()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package info.nightscout.pump.medtrum.comm.packets
|
package info.nightscout.pump.medtrum.comm.packets
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.medtrum.MedtrumTestBase
|
import info.nightscout.pump.medtrum.MedtrumTestBase
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class ResumePumpPacketTest : MedtrumTestBase() {
|
class ResumePumpPacketTest : MedtrumTestBase() {
|
||||||
|
@ -27,7 +27,6 @@ class ResumePumpPacketTest : MedtrumTestBase() {
|
||||||
val result = packet.getRequest()
|
val result = packet.getRequest()
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(1, result.size)
|
assertThat(result).asList().containsExactly(opCode.toByte())
|
||||||
Assertions.assertEquals(opCode.toByte(), result[0])
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package info.nightscout.pump.medtrum.comm.packets
|
package info.nightscout.pump.medtrum.comm.packets
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.medtrum.MedtrumTestBase
|
import info.nightscout.pump.medtrum.MedtrumTestBase
|
||||||
import info.nightscout.pump.medtrum.comm.enums.BasalType
|
import info.nightscout.pump.medtrum.comm.enums.BasalType
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class SetBasalProfilePacketTest : MedtrumTestBase() {
|
class SetBasalProfilePacketTest : MedtrumTestBase() {
|
||||||
|
@ -31,7 +31,7 @@ class SetBasalProfilePacketTest : MedtrumTestBase() {
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
val expected = byteArrayOf(opCode.toByte()) + 1.toByte() + basalProfile
|
val expected = byteArrayOf(opCode.toByte()) + 1.toByte() + basalProfile
|
||||||
Assertions.assertEquals(expected.contentToString(), result.contentToString())
|
assertThat(result).asList().containsExactlyElementsIn(expected.toList()).inOrder()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() {
|
@Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() {
|
||||||
|
@ -50,13 +50,13 @@ class SetBasalProfilePacketTest : MedtrumTestBase() {
|
||||||
val expectedStartTime = 1679575392000L
|
val expectedStartTime = 1679575392000L
|
||||||
val expectedPatchId = 146L
|
val expectedPatchId = 146L
|
||||||
|
|
||||||
Assertions.assertTrue(result)
|
assertThat(result).isTrue()
|
||||||
Assertions.assertEquals(expectedBasalType, medtrumPump.lastBasalType)
|
assertThat(medtrumPump.lastBasalType).isEqualTo(expectedBasalType)
|
||||||
Assertions.assertEquals(expectedBasalRate, medtrumPump.lastBasalRate, 0.01)
|
assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(expectedBasalRate)
|
||||||
Assertions.assertEquals(expectedBasalSequence, medtrumPump.lastBasalSequence)
|
assertThat(medtrumPump.lastBasalSequence).isEqualTo(expectedBasalSequence)
|
||||||
Assertions.assertEquals(expectedStartTime, medtrumPump.lastBasalStartTime)
|
assertThat(medtrumPump.lastBasalStartTime).isEqualTo(expectedStartTime)
|
||||||
Assertions.assertEquals(expectedPatchId, medtrumPump.lastBasalPatchId)
|
assertThat(medtrumPump.lastBasalPatchId).isEqualTo(expectedPatchId)
|
||||||
Assertions.assertEquals(basalProfile, medtrumPump.actualBasalProfile)
|
assertThat(medtrumPump.actualBasalProfile).isEqualTo(basalProfile)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
||||||
|
@ -69,7 +69,7 @@ class SetBasalProfilePacketTest : MedtrumTestBase() {
|
||||||
val result = packet.handleResponse(response)
|
val result = packet.handleResponse(response)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertFalse(result)
|
assertThat(result).isFalse()
|
||||||
Assertions.assertTrue(packet.failed)
|
assertThat(packet.failed).isTrue()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package info.nightscout.pump.medtrum.comm.packets
|
package info.nightscout.pump.medtrum.comm.packets
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.medtrum.MedtrumTestBase
|
import info.nightscout.pump.medtrum.MedtrumTestBase
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class SetBolusMotorPacketTest : MedtrumTestBase() {
|
class SetBolusMotorPacketTest : MedtrumTestBase() {
|
||||||
|
@ -27,8 +27,6 @@ class SetBolusMotorPacketTest : MedtrumTestBase() {
|
||||||
val result = packet.getRequest()
|
val result = packet.getRequest()
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
val expectedByteArray = byteArrayOf(opCode.toByte()) + 0.toByte()
|
assertThat(result).asList().containsExactly(opCode.toByte(), 0.toByte()).inOrder()
|
||||||
Assertions.assertEquals(2, result.size)
|
|
||||||
Assertions.assertEquals(expectedByteArray.contentToString(), result.contentToString())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package info.nightscout.pump.medtrum.comm.packets
|
package info.nightscout.pump.medtrum.comm.packets
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.medtrum.MedtrumTestBase
|
import info.nightscout.pump.medtrum.MedtrumTestBase
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class SetBolusPacketTest : MedtrumTestBase() {
|
class SetBolusPacketTest : MedtrumTestBase() {
|
||||||
|
@ -28,6 +28,6 @@ class SetBolusPacketTest : MedtrumTestBase() {
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
val expected = byteArrayOf(19, 1, 47, 0, 0)
|
val expected = byteArrayOf(19, 1, 47, 0, 0)
|
||||||
Assertions.assertEquals(expected.contentToString(), result.contentToString())
|
assertThat(result).asList().containsExactlyElementsIn(expected.toList()).inOrder()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package info.nightscout.pump.medtrum.comm.packets
|
package info.nightscout.pump.medtrum.comm.packets
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.medtrum.MedtrumTestBase
|
import info.nightscout.pump.medtrum.MedtrumTestBase
|
||||||
import info.nightscout.pump.medtrum.comm.enums.AlarmSetting
|
import info.nightscout.pump.medtrum.comm.enums.AlarmSetting
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class SetPatchPacketTest : MedtrumTestBase() {
|
class SetPatchPacketTest : MedtrumTestBase() {
|
||||||
|
@ -33,6 +33,6 @@ class SetPatchPacketTest : MedtrumTestBase() {
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
val expected = byteArrayOf(35, 1, 32, 3, 16, 14, 0, 0, 12, 0, 0, 30)
|
val expected = byteArrayOf(35, 1, 32, 3, 16, 14, 0, 0, 12, 0, 0, 30)
|
||||||
Assertions.assertEquals(expected.contentToString(), result.contentToString())
|
assertThat(result).asList().containsExactlyElementsIn(expected.toList()).inOrder()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package info.nightscout.pump.medtrum.comm.packets
|
package info.nightscout.pump.medtrum.comm.packets
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.medtrum.MedtrumTestBase
|
import info.nightscout.pump.medtrum.MedtrumTestBase
|
||||||
import info.nightscout.pump.medtrum.comm.enums.BasalType
|
import info.nightscout.pump.medtrum.comm.enums.BasalType
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class SetTempBasalPacketTest : MedtrumTestBase() {
|
class SetTempBasalPacketTest : MedtrumTestBase() {
|
||||||
|
@ -31,7 +31,7 @@ class SetTempBasalPacketTest : MedtrumTestBase() {
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
val expected = byteArrayOf(24, 6, 25, 0, 60, 0)
|
val expected = byteArrayOf(24, 6, 25, 0, 60, 0)
|
||||||
Assertions.assertEquals(expected.contentToString(), result.contentToString())
|
assertThat(result.contentToString()).isEqualTo(expected.contentToString())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() {
|
@Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() {
|
||||||
|
@ -52,12 +52,12 @@ class SetTempBasalPacketTest : MedtrumTestBase() {
|
||||||
val expectedStartTime = 1679575112000L
|
val expectedStartTime = 1679575112000L
|
||||||
val expectedPatchId = 146L
|
val expectedPatchId = 146L
|
||||||
|
|
||||||
Assertions.assertTrue(result)
|
assertThat(result).isTrue()
|
||||||
Assertions.assertEquals(expectedBasalType, medtrumPump.lastBasalType)
|
assertThat(medtrumPump.lastBasalType).isEqualTo(expectedBasalType)
|
||||||
Assertions.assertEquals(expectedBasalRate, medtrumPump.lastBasalRate, 0.01)
|
assertThat(medtrumPump.lastBasalRate).isWithin(0.01).of(expectedBasalRate)
|
||||||
Assertions.assertEquals(expectedBasalSequence, medtrumPump.lastBasalSequence)
|
assertThat(medtrumPump.lastBasalSequence).isEqualTo(expectedBasalSequence)
|
||||||
Assertions.assertEquals(expectedStartTime, medtrumPump.lastBasalStartTime)
|
assertThat(medtrumPump.lastBasalStartTime).isEqualTo(expectedStartTime)
|
||||||
Assertions.assertEquals(expectedPatchId, medtrumPump.lastBasalPatchId)
|
assertThat(medtrumPump.lastBasalPatchId).isEqualTo(expectedPatchId)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
||||||
|
@ -72,6 +72,6 @@ class SetTempBasalPacketTest : MedtrumTestBase() {
|
||||||
val result = packet.handleResponse(response)
|
val result = packet.handleResponse(response)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertFalse(result)
|
assertThat(result).isFalse()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package info.nightscout.pump.medtrum.comm.packets
|
package info.nightscout.pump.medtrum.comm.packets
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.medtrum.MedtrumTestBase
|
import info.nightscout.pump.medtrum.MedtrumTestBase
|
||||||
import info.nightscout.pump.medtrum.extension.toByteArray
|
import info.nightscout.pump.medtrum.extension.toByteArray
|
||||||
import info.nightscout.pump.medtrum.util.MedtrumTimeUtil
|
import info.nightscout.pump.medtrum.util.MedtrumTimeUtil
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class SetTimePacketTest : MedtrumTestBase() {
|
class SetTimePacketTest : MedtrumTestBase() {
|
||||||
|
@ -30,8 +30,7 @@ class SetTimePacketTest : MedtrumTestBase() {
|
||||||
val result = packet.getRequest()
|
val result = packet.getRequest()
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
val expectedByteArray = byteArrayOf(opCode.toByte()) + 2.toByte() + time.toByteArray(4)
|
val expected = byteArrayOf(opCode.toByte()) + 2.toByte() + time.toByteArray(4)
|
||||||
Assertions.assertEquals(6, result.size)
|
assertThat(result).asList().containsExactlyElementsIn(expected.toList()).inOrder()
|
||||||
Assertions.assertEquals(expectedByteArray.contentToString(), result.contentToString())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package info.nightscout.pump.medtrum.comm.packets
|
package info.nightscout.pump.medtrum.comm.packets
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.medtrum.MedtrumTestBase
|
import info.nightscout.pump.medtrum.MedtrumTestBase
|
||||||
import info.nightscout.pump.medtrum.extension.toByteArray
|
import info.nightscout.pump.medtrum.extension.toByteArray
|
||||||
import info.nightscout.pump.medtrum.util.MedtrumTimeUtil
|
import info.nightscout.pump.medtrum.util.MedtrumTimeUtil
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class SetTimeZonePacketTest : MedtrumTestBase() {
|
class SetTimeZonePacketTest : MedtrumTestBase() {
|
||||||
|
@ -35,9 +35,8 @@ class SetTimeZonePacketTest : MedtrumTestBase() {
|
||||||
val result = packet.getRequest()
|
val result = packet.getRequest()
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
val expectedByteArray = byteArrayOf(opCode.toByte()) + offsetMinutes.toByteArray(2) + time.toByteArray(4)
|
val expected = byteArrayOf(opCode.toByte()) + offsetMinutes.toByteArray(2) + time.toByteArray(4)
|
||||||
Assertions.assertEquals(7, result.size)
|
assertThat(result).asList().containsExactlyElementsIn(expected.toList()).inOrder()
|
||||||
Assertions.assertEquals(expectedByteArray.contentToString(), result.contentToString())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() {
|
@Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() {
|
||||||
|
@ -50,7 +49,7 @@ class SetTimeZonePacketTest : MedtrumTestBase() {
|
||||||
val result = packet.handleResponse(response)
|
val result = packet.handleResponse(response)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertTrue(result)
|
assertThat(result).isTrue()
|
||||||
Assertions.assertEquals(offsetMinutes, medtrumPump.pumpTimeZoneOffset)
|
assertThat(medtrumPump.pumpTimeZoneOffset).isEqualTo(offsetMinutes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package info.nightscout.pump.medtrum.comm.packets
|
package info.nightscout.pump.medtrum.comm.packets
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.medtrum.MedtrumTestBase
|
import info.nightscout.pump.medtrum.MedtrumTestBase
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class StopPatchPacketTest : MedtrumTestBase() {
|
class StopPatchPacketTest : MedtrumTestBase() {
|
||||||
|
@ -28,8 +28,7 @@ class StopPatchPacketTest : MedtrumTestBase() {
|
||||||
val result = packet.getRequest()
|
val result = packet.getRequest()
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(1, result.size)
|
assertThat(result).asList().containsExactly(opCode.toByte())
|
||||||
Assertions.assertEquals(opCode.toByte(), result[0])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() {
|
@Test fun handleResponseGivenPacketWhenValuesSetThenReturnCorrectValues() {
|
||||||
|
@ -43,9 +42,9 @@ class StopPatchPacketTest : MedtrumTestBase() {
|
||||||
// Expected values
|
// Expected values
|
||||||
val expectedPatchId = 146L
|
val expectedPatchId = 146L
|
||||||
val expectedStopSequence = 23
|
val expectedStopSequence = 23
|
||||||
Assertions.assertTrue(result)
|
assertThat(result).isTrue()
|
||||||
Assertions.assertEquals(expectedPatchId, medtrumPump.lastStopPatchId)
|
assertThat(medtrumPump.lastStopPatchId).isEqualTo(expectedPatchId)
|
||||||
Assertions.assertEquals(expectedStopSequence, medtrumPump.lastStopSequence)
|
assertThat(medtrumPump.lastStopSequence).isEqualTo(expectedStopSequence)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
||||||
|
@ -57,7 +56,7 @@ class StopPatchPacketTest : MedtrumTestBase() {
|
||||||
val result = packet.handleResponse(response)
|
val result = packet.handleResponse(response)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertFalse(result)
|
assertThat(result).isFalse()
|
||||||
Assertions.assertTrue(packet.failed)
|
assertThat(packet.failed).isTrue()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package info.nightscout.pump.medtrum.comm.packets
|
package info.nightscout.pump.medtrum.comm.packets
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.medtrum.MedtrumTestBase
|
import info.nightscout.pump.medtrum.MedtrumTestBase
|
||||||
import info.nightscout.pump.medtrum.extension.toByteArray
|
import info.nightscout.pump.medtrum.extension.toByteArray
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class SubscribePacketTest : MedtrumTestBase() {
|
class SubscribePacketTest : MedtrumTestBase() {
|
||||||
|
@ -28,8 +28,7 @@ class SubscribePacketTest : MedtrumTestBase() {
|
||||||
val result = packet.getRequest()
|
val result = packet.getRequest()
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
val expectedByteArray = byteArrayOf(opCode.toByte()) + 4095.toByteArray(2)
|
val expected = byteArrayOf(opCode.toByte()) + 4095.toByteArray(2)
|
||||||
Assertions.assertEquals(3, result.size)
|
assertThat(result).asList().containsExactlyElementsIn(expected.toList()).inOrder()
|
||||||
Assertions.assertEquals(expectedByteArray.contentToString(), result.contentToString())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package info.nightscout.pump.medtrum.comm.packets
|
package info.nightscout.pump.medtrum.comm.packets
|
||||||
|
|
||||||
|
import com.google.common.truth.Truth.assertThat
|
||||||
import dagger.android.AndroidInjector
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.pump.medtrum.MedtrumTestBase
|
import info.nightscout.pump.medtrum.MedtrumTestBase
|
||||||
import info.nightscout.pump.medtrum.comm.enums.BasalType
|
import info.nightscout.pump.medtrum.comm.enums.BasalType
|
||||||
import info.nightscout.pump.medtrum.comm.enums.MedtrumPumpState
|
import info.nightscout.pump.medtrum.comm.enums.MedtrumPumpState
|
||||||
import info.nightscout.pump.medtrum.extension.toByteArray
|
import info.nightscout.pump.medtrum.extension.toByteArray
|
||||||
import org.junit.jupiter.api.Assertions
|
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class SynchronizePacketTest : MedtrumTestBase() {
|
class SynchronizePacketTest : MedtrumTestBase() {
|
||||||
|
@ -35,8 +35,7 @@ class SynchronizePacketTest : MedtrumTestBase() {
|
||||||
val result = packet.getRequest()
|
val result = packet.getRequest()
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(1, result.size)
|
assertThat(result).asList().containsExactly(opCode.toByte())
|
||||||
Assertions.assertEquals(opCode.toByte(), result[0])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenResponseWhenMessageIsCorrectLengthThenResultTrue() {
|
@Test fun handleResponseGivenResponseWhenMessageIsCorrectLengthThenResultTrue() {
|
||||||
|
@ -53,9 +52,9 @@ class SynchronizePacketTest : MedtrumTestBase() {
|
||||||
val result = packet.handleResponse(response)
|
val result = packet.handleResponse(response)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(true, result)
|
assertThat(result).isTrue()
|
||||||
Assertions.assertEquals(false, packet.failed)
|
assertThat(packet.failed).isFalse()
|
||||||
Assertions.assertEquals(state, packet.medtrumPump.pumpState.state)
|
assertThat(packet.medtrumPump.pumpState.state).isEqualTo(state)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
@Test fun handleResponseGivenResponseWhenMessageTooShortThenResultFalse() {
|
||||||
|
@ -71,13 +70,13 @@ class SynchronizePacketTest : MedtrumTestBase() {
|
||||||
val result = packet.handleResponse(response)
|
val result = packet.handleResponse(response)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(false, result)
|
assertThat(result).isFalse()
|
||||||
Assertions.assertEquals(true, packet.failed)
|
assertThat(packet.failed).isTrue()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun handleResponseContainingSyncDataThenDataSaved() {
|
@Test fun handleResponseContainingSyncDataThenDataSaved() {
|
||||||
// Inputs
|
// Inputs
|
||||||
val data =
|
val byteData =
|
||||||
byteArrayOf(
|
byteArrayOf(
|
||||||
47,
|
47,
|
||||||
3,
|
3,
|
||||||
|
@ -130,21 +129,21 @@ class SynchronizePacketTest : MedtrumTestBase() {
|
||||||
|
|
||||||
// Call
|
// Call
|
||||||
val packet = SynchronizePacket(packetInjector)
|
val packet = SynchronizePacket(packetInjector)
|
||||||
val result = packet.handleResponse(data)
|
val result = packet.handleResponse(byteData)
|
||||||
|
|
||||||
// Expected values
|
// Expected values
|
||||||
Assertions.assertEquals(true, result)
|
assertThat(result).isTrue()
|
||||||
Assertions.assertEquals(false, packet.failed)
|
assertThat(packet.failed).isFalse()
|
||||||
Assertions.assertEquals(MedtrumPumpState.ACTIVE, packet.medtrumPump.pumpState)
|
assertThat(packet.medtrumPump.pumpState).isEqualTo(MedtrumPumpState.ACTIVE)
|
||||||
Assertions.assertEquals(BasalType.ABSOLUTE_TEMP, packet.medtrumPump.lastBasalType)
|
assertThat(packet.medtrumPump.lastBasalType).isEqualTo(BasalType.ABSOLUTE_TEMP)
|
||||||
Assertions.assertEquals(0.85, packet.medtrumPump.lastBasalRate, 0.01)
|
assertThat(packet.medtrumPump.lastBasalRate).isWithin(0.01).of(0.85)
|
||||||
Assertions.assertEquals(25, packet.medtrumPump.lastBasalSequence)
|
assertThat(packet.medtrumPump.lastBasalSequence).isEqualTo(25)
|
||||||
Assertions.assertEquals(14, packet.medtrumPump.lastBasalPatchId)
|
assertThat(packet.medtrumPump.lastBasalPatchId).isEqualTo(14)
|
||||||
Assertions.assertEquals(1685126612000, packet.medtrumPump.lastBasalStartTime)
|
assertThat(packet.medtrumPump.lastBasalStartTime).isEqualTo(1685126612000)
|
||||||
Assertions.assertEquals(8123, packet.medtrumPump.patchAge)
|
assertThat(packet.medtrumPump.patchAge).isEqualTo(8123)
|
||||||
Assertions.assertEquals(186.80, packet.medtrumPump.reservoir, 0.01)
|
assertThat(packet.medtrumPump.reservoir).isWithin(0.01).of(186.80)
|
||||||
Assertions.assertEquals(1685120120000, packet.medtrumPump.patchStartTime)
|
assertThat(packet.medtrumPump.patchStartTime).isEqualTo(1685120120000)
|
||||||
Assertions.assertEquals(5.96875, packet.medtrumPump.batteryVoltage_A, 0.01)
|
assertThat(packet.medtrumPump.batteryVoltage_A).isWithin(0.01).of(5.96875)
|
||||||
Assertions.assertEquals(2.8125, packet.medtrumPump.batteryVoltage_B, 0.01)
|
assertThat(packet.medtrumPump.batteryVoltage_B).isWithin(0.01).of(2.8125)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.pump.medtrum.encryption
|
package info.nightscout.pump.medtrum.encryption
|
||||||
|
|
||||||
import org.junit.jupiter.api.Assertions
|
import com.google.common.truth.Truth.assertThat
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
class CryptTest {
|
class CryptTest {
|
||||||
|
@ -10,9 +10,9 @@ class CryptTest {
|
||||||
val crypt = Crypt()
|
val crypt = Crypt()
|
||||||
|
|
||||||
val input = 2859923929
|
val input = 2859923929
|
||||||
val expect = 3364239851
|
val expected = 3364239851L
|
||||||
val output: Long = crypt.keyGen(input)
|
val output: Long = crypt.keyGen(input)
|
||||||
Assertions.assertEquals(expect, output)
|
assertThat(output).isEqualTo(expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -20,8 +20,8 @@ class CryptTest {
|
||||||
val crypt = Crypt()
|
val crypt = Crypt()
|
||||||
|
|
||||||
val input = 2859923929
|
val input = 2859923929
|
||||||
val expect: Long = 126009121
|
val expected = 126009121L
|
||||||
val output: Long = crypt.simpleDecrypt(input)
|
val output: Long = crypt.simpleDecrypt(input)
|
||||||
Assertions.assertEquals(expect, output)
|
assertThat(output).isEqualTo(expected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue