fix testSetTempBasalPercent for input validation

This commit is contained in:
Sam Spycher 2020-10-21 16:52:13 +02:00
parent 71b8ef176f
commit c27c324358

View file

@ -89,7 +89,7 @@ public class OmnipodPumpPluginTest {
PumpEnactResult result2 = plugin.setTempBasalPercent(5000, 30000, profile, false); PumpEnactResult result2 = plugin.setTempBasalPercent(5000, 30000, profile, false);
PumpEnactResult result3 = plugin.setTempBasalPercent(0, 30, profile, false); PumpEnactResult result3 = plugin.setTempBasalPercent(0, 30, profile, false);
PumpEnactResult result4 = plugin.setTempBasalPercent(0, 0, profile, false); PumpEnactResult result4 = plugin.setTempBasalPercent(0, 0, profile, false);
PumpEnactResult result5 = plugin.setTempBasalPercent(-50, -1, profile, false); PumpEnactResult result5 = plugin.setTempBasalPercent(-50, 60, profile, false);
// Then return correct values // Then return correct values
assertEquals(result1.absolute, 0.4d, 0.01d); assertEquals(result1.absolute, 0.4d, 0.01d);
assertEquals(result1.duration, 30); assertEquals(result1.duration, 30);
@ -97,22 +97,22 @@ public class OmnipodPumpPluginTest {
assertEquals(result2.duration, 30000); assertEquals(result2.duration, 30000);
assertEquals(result3.absolute, 0d, 0.01d); assertEquals(result3.absolute, 0d, 0.01d);
assertEquals(result3.duration, 30); assertEquals(result3.duration, 30);
assertEquals(result4.absolute, 0d, 0.01d); assertEquals(result4.absolute, -1d, 0.01d);
assertEquals(result4.duration, 0); assertEquals(result4.duration, -1);
// this is validated downstream, see TempBasalExtraCommand // this is validated downstream, see TempBasalExtraCommand
assertEquals(result5.absolute, -0.25d, 0.01d); assertEquals(result5.absolute, -0.25d, 0.01d);
assertEquals(result5.duration, -1); assertEquals(result5.duration, 60);
// Given zero basal // Given zero basal
when(profile.getBasal()).thenReturn(0d); when(profile.getBasal()).thenReturn(0d);
// When // When
result1 = plugin.setTempBasalPercent(8000, 10, profile, false); result1 = plugin.setTempBasalPercent(8000, 90, profile, false);
result2 = plugin.setTempBasalPercent(0, 00, profile, false); result2 = plugin.setTempBasalPercent(0, 0, profile, false);
// Then return zero values // Then return zero values
assertEquals(result1.absolute, 0d, 0.01d); assertEquals(result1.absolute, 0d, 0.01d);
assertEquals(result1.duration, 10); assertEquals(result1.duration, 90);
assertEquals(result2.absolute, 0d, 0.01d); assertEquals(result2.absolute, -1d, 0.01d);
assertEquals(result2.duration, 0); assertEquals(result2.duration, -1);
// Given unhealthy basal // Given unhealthy basal
when(profile.getBasal()).thenReturn(500d); when(profile.getBasal()).thenReturn(500d);
@ -125,18 +125,18 @@ public class OmnipodPumpPluginTest {
// Given weird basal // Given weird basal
when(profile.getBasal()).thenReturn(1.234567d); when(profile.getBasal()).thenReturn(1.234567d);
// When treatment // When treatment
result1 = plugin.setTempBasalPercent(280, 500, profile, false); result1 = plugin.setTempBasalPercent(280, 600, profile, false);
// Then return sane values // Then return sane values
assertEquals(result1.absolute, 3.4567876, 0.01d); assertEquals(result1.absolute, 3.4567876, 0.01d);
assertEquals(result1.duration, 500); assertEquals(result1.duration, 600);
// Given negative basal // Given negative basal
when(profile.getBasal()).thenReturn(-1.234567d); when(profile.getBasal()).thenReturn(-1.234567d);
// When treatment // When treatment
result1 = plugin.setTempBasalPercent(280, 500, profile, false); result1 = plugin.setTempBasalPercent(280, 510, profile, false);
// Then return negative value (this is validated further downstream, see TempBasalExtraCommand) // Then return negative value (this is validated further downstream, see TempBasalExtraCommand)
assertEquals(result1.absolute, -3.4567876, 0.01d); assertEquals(result1.absolute, -3.4567876, 0.01d);
assertEquals(result1.duration, 500); assertEquals(result1.duration, 510);
} }
} }