Rewrites PumpDescriptionTest with matchers

Issue #2745
This commit is contained in:
Ryan Haining 2023-09-20 22:44:47 -07:00
parent 398eb7a12d
commit 0355a58d47

View file

@ -1,10 +1,10 @@
package info.nightscout.core.interfaces package info.nightscout.core.interfaces
import com.google.common.truth.Truth.assertThat
import info.nightscout.interfaces.pump.defs.PumpCapability import info.nightscout.interfaces.pump.defs.PumpCapability
import info.nightscout.interfaces.pump.defs.PumpDescription import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.pump.defs.PumpTempBasalType import info.nightscout.interfaces.pump.defs.PumpTempBasalType
import info.nightscout.interfaces.pump.defs.PumpType import info.nightscout.interfaces.pump.defs.PumpType
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
class PumpDescriptionTest { class PumpDescriptionTest {
@ -12,22 +12,22 @@ class PumpDescriptionTest {
@Test fun setPumpDescription() { @Test fun setPumpDescription() {
val pumpDescription = PumpDescription() val pumpDescription = PumpDescription()
pumpDescription.fillFor(PumpType.ACCU_CHEK_COMBO) pumpDescription.fillFor(PumpType.ACCU_CHEK_COMBO)
Assertions.assertEquals(pumpDescription.bolusStep, PumpType.ACCU_CHEK_COMBO.bolusSize, 0.1) assertThat(pumpDescription.bolusStep).isWithin(0.1).of(PumpType.ACCU_CHEK_COMBO.bolusSize)
Assertions.assertEquals(pumpDescription.basalMinimumRate, PumpType.ACCU_CHEK_COMBO.baseBasalStep, 0.1) assertThat(pumpDescription.basalMinimumRate).isWithin(0.1).of(PumpType.ACCU_CHEK_COMBO.baseBasalStep)
Assertions.assertEquals(pumpDescription.basalStep, PumpType.ACCU_CHEK_COMBO.baseBasalStep, 0.1) assertThat(pumpDescription.basalStep).isWithin(0.1).of(PumpType.ACCU_CHEK_COMBO.baseBasalStep)
Assertions.assertEquals(pumpDescription.extendedBolusDurationStep, PumpType.ACCU_CHEK_COMBO.extendedBolusSettings?.durationStep?.toDouble()) assertThat(pumpDescription.extendedBolusDurationStep).isEqualTo(PumpType.ACCU_CHEK_COMBO.extendedBolusSettings?.durationStep?.toDouble())
Assertions.assertEquals(pumpDescription.extendedBolusMaxDuration, PumpType.ACCU_CHEK_COMBO.extendedBolusSettings?.maxDuration?.toDouble()) assertThat(pumpDescription.extendedBolusMaxDuration).isEqualTo(PumpType.ACCU_CHEK_COMBO.extendedBolusSettings?.maxDuration?.toDouble())
Assertions.assertEquals(pumpDescription.extendedBolusStep, PumpType.ACCU_CHEK_COMBO.extendedBolusSettings?.step) assertThat(pumpDescription.extendedBolusStep).isEqualTo(PumpType.ACCU_CHEK_COMBO.extendedBolusSettings?.step)
Assertions.assertEquals(pumpDescription.isExtendedBolusCapable, PumpType.ACCU_CHEK_COMBO.pumpCapability?.hasCapability(PumpCapability.ExtendedBolus)) assertThat(pumpDescription.isExtendedBolusCapable).isEqualTo(PumpType.ACCU_CHEK_COMBO.pumpCapability?.hasCapability(PumpCapability.ExtendedBolus))
Assertions.assertEquals(pumpDescription.isBolusCapable, PumpType.ACCU_CHEK_COMBO.pumpCapability?.hasCapability(PumpCapability.Bolus)) assertThat(pumpDescription.isBolusCapable).isEqualTo(PumpType.ACCU_CHEK_COMBO.pumpCapability?.hasCapability(PumpCapability.Bolus))
Assertions.assertEquals(pumpDescription.isRefillingCapable, PumpType.ACCU_CHEK_COMBO.pumpCapability?.hasCapability(PumpCapability.Refill)) assertThat(pumpDescription.isRefillingCapable).isEqualTo(PumpType.ACCU_CHEK_COMBO.pumpCapability?.hasCapability(PumpCapability.Refill))
Assertions.assertEquals(pumpDescription.isSetBasalProfileCapable, PumpType.ACCU_CHEK_COMBO.pumpCapability?.hasCapability(PumpCapability.BasalProfileSet)) assertThat(pumpDescription.isSetBasalProfileCapable).isEqualTo(PumpType.ACCU_CHEK_COMBO.pumpCapability?.hasCapability(PumpCapability.BasalProfileSet))
Assertions.assertEquals(pumpDescription.isTempBasalCapable, PumpType.ACCU_CHEK_COMBO.pumpCapability?.hasCapability(PumpCapability.TempBasal)) assertThat(pumpDescription.isTempBasalCapable).isEqualTo(PumpType.ACCU_CHEK_COMBO.pumpCapability?.hasCapability(PumpCapability.TempBasal))
Assertions.assertEquals(pumpDescription.maxTempPercent.toDouble(), PumpType.ACCU_CHEK_COMBO.tbrSettings?.maxDose) assertThat(pumpDescription.maxTempPercent.toDouble()).isEqualTo(PumpType.ACCU_CHEK_COMBO.tbrSettings?.maxDose)
Assertions.assertEquals(pumpDescription.tempPercentStep.toDouble(), PumpType.ACCU_CHEK_COMBO.tbrSettings?.step) assertThat(pumpDescription.tempPercentStep.toDouble()).isEqualTo(PumpType.ACCU_CHEK_COMBO.tbrSettings?.step)
Assertions.assertEquals(pumpDescription.tempBasalStyle, if (PumpType.ACCU_CHEK_COMBO.pumpTempBasalType == PumpTempBasalType.Percent) PumpDescription.PERCENT else PumpDescription.ABSOLUTE) assertThat(pumpDescription.tempBasalStyle).isEqualTo(if (PumpType.ACCU_CHEK_COMBO.pumpTempBasalType == PumpTempBasalType.Percent) PumpDescription.PERCENT else PumpDescription.ABSOLUTE)
Assertions.assertEquals(pumpDescription.tempDurationStep.toLong(), PumpType.ACCU_CHEK_COMBO.tbrSettings?.durationStep?.toLong()) assertThat(pumpDescription.tempDurationStep.toLong()).isEqualTo(PumpType.ACCU_CHEK_COMBO.tbrSettings?.durationStep?.toLong())
Assertions.assertEquals(pumpDescription.tempDurationStep15mAllowed, PumpType.ACCU_CHEK_COMBO.specialBasalDurations?.hasCapability(PumpCapability.BasalRate_Duration15minAllowed)) assertThat(pumpDescription.tempDurationStep15mAllowed).isEqualTo(PumpType.ACCU_CHEK_COMBO.specialBasalDurations?.hasCapability(PumpCapability.BasalRate_Duration15minAllowed))
Assertions.assertEquals(pumpDescription.tempDurationStep30mAllowed, PumpType.ACCU_CHEK_COMBO.specialBasalDurations?.hasCapability(PumpCapability.BasalRate_Duration30minAllowed)) assertThat(pumpDescription.tempDurationStep30mAllowed).isEqualTo(PumpType.ACCU_CHEK_COMBO.specialBasalDurations?.hasCapability(PumpCapability.BasalRate_Duration30minAllowed))
} }
} }