diff --git a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintTest.java b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintTest.java index b2b86047b8..e21e09cfb4 100644 --- a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintTest.java +++ b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintTest.java @@ -30,13 +30,13 @@ public class ConstraintTest { Constraint d = new Constraint<>(10d); d.set(5d, "Set 5d"); - Assert.assertEquals(5d, b.value()); - Assert.assertEquals("Set 5d", b.getReasons()); + Assert.assertEquals(5d, d.value()); + Assert.assertEquals("Set 5d", d.getReasons()); d.setIfSmaller(6d, "Set 6d"); - Assert.assertEquals(5d, b.value()); - Assert.assertEquals("Set 5d", b.getReasons()); + Assert.assertEquals(5d, d.value()); + Assert.assertEquals("Set 5d\nSet 6d", d.getReasons()); d.setIfSmaller(4d, "Set 4d"); - Assert.assertEquals(4d, b.value()); - Assert.assertEquals("Set 5d\nSet 4d", b.getReasons()); + Assert.assertEquals(4d, d.value()); + Assert.assertEquals("Set 5d\nSet 6d\nSet 4d", d.getReasons()); } } diff --git a/app/src/test/java/info/nightscout/androidaps/queue/CommandQueueTest.java b/app/src/test/java/info/nightscout/androidaps/queue/CommandQueueTest.java index 009a834c86..14892464d4 100644 --- a/app/src/test/java/info/nightscout/androidaps/queue/CommandQueueTest.java +++ b/app/src/test/java/info/nightscout/androidaps/queue/CommandQueueTest.java @@ -20,12 +20,14 @@ import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.data.ConstraintChecker; import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.data.Profile; +import info.nightscout.androidaps.interfaces.Constraint; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.PumpMDI.MDIPlugin; import info.nightscout.androidaps.queue.commands.Command; import info.nightscout.utils.ToastUtils; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -125,6 +127,8 @@ public class CommandQueueTest extends CommandQueue { when(MainApp.instance()).thenReturn(mainApp); when(MainApp.getConstraintChecker().applyBolusConstraints(insulin)).thenReturn(insulin); when(MainApp.getConstraintChecker().applyCarbsConstraints(carbs)).thenReturn(carbs); + Constraint rateConstraint = new Constraint<>(0d); + when(MainApp.getConstraintChecker().applyBasalConstraints(any(), any())).thenReturn(rateConstraint); PowerMockito.mockStatic(ToastUtils.class); Context context = mock(Context.class);