diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStartTempTarget.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStartTempTarget.java index f033e3b679..29004f5b72 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStartTempTarget.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionStartTempTarget.java @@ -53,7 +53,7 @@ public class ActionStartTempTarget extends Action { int unitResId = value.getUnits().equals(Constants.MGDL) ? R.string.mgdl : R.string.mmol; new LayoutBuilder() - .add(new Label(MainApp.gs(R.string.careportal_newnstreatment_percentage_label), MainApp.gs(unitResId), value)) + .add(new Label(MainApp.gs(R.string.careportal_temporarytarget), MainApp.gs(unitResId), value)) .add(new Label(MainApp.gs(R.string.careportal_newnstreatment_duration_min_label), "min", duration)) .build(root); } diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBgTest.java b/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBgTest.java index d1d95b1ae6..1d3a513f29 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBgTest.java +++ b/app/src/test/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerBgTest.java @@ -18,9 +18,11 @@ import java.util.List; import info.AAPSMocker; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.data.GlucoseStatus; import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions; import info.nightscout.androidaps.plugins.general.nsclient.data.NSSgv; +import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.utils.DateUtil; import info.nightscout.androidaps.utils.T; @@ -29,12 +31,12 @@ import static org.mockito.ArgumentMatchers.anyLong; import static org.powermock.api.mockito.PowerMockito.when; @RunWith(PowerMockRunner.class) -@PrepareForTest({MainApp.class, Bus.class, ProfileFunctions.class, DateUtil.class}) +@PrepareForTest({MainApp.class, Bus.class, ProfileFunctions.class, DateUtil.class, IobCobCalculatorPlugin.class}) public class TriggerBgTest { @Test public void shouldRunTest() { - when(MainApp.getDbHelper().getBgreadingsDataFromTime(anyLong(), anyBoolean())).thenReturn(generateOneCurrentRecordBgData()); + when(IobCobCalculatorPlugin.getPlugin().getBgReadings()).thenReturn(generateOneCurrentRecordBgData()); TriggerBg t = new TriggerBg().units(Constants.MMOL).threshold(4.1d).comparator(Trigger.Comparator.IS_EQUAL); Assert.assertFalse(t.shouldRun()); @@ -42,21 +44,21 @@ public class TriggerBgTest { Assert.assertTrue(t.shouldRun()); t = new TriggerBg().units(Constants.MGDL).threshold(214).comparator(Trigger.Comparator.IS_EQUAL_OR_GREATER); Assert.assertTrue(t.shouldRun()); - t = new TriggerBg().units(Constants.MGDL).threshold(214).comparator(Trigger.Comparator.IS_EQUAL_OR_LOWER); + t = new TriggerBg().units(Constants.MGDL).threshold(214).comparator(Trigger.Comparator.IS_EQUAL_OR_LESSER); Assert.assertTrue(t.shouldRun()); t = new TriggerBg().units(Constants.MGDL).threshold(215).comparator(Trigger.Comparator.IS_EQUAL); Assert.assertFalse(t.shouldRun()); - t = new TriggerBg().units(Constants.MGDL).threshold(215).comparator(Trigger.Comparator.IS_EQUAL_OR_LOWER); + t = new TriggerBg().units(Constants.MGDL).threshold(215).comparator(Trigger.Comparator.IS_EQUAL_OR_LESSER); Assert.assertTrue(t.shouldRun()); t = new TriggerBg().units(Constants.MGDL).threshold(215).comparator(Trigger.Comparator.IS_EQUAL_OR_GREATER); Assert.assertFalse(t.shouldRun()); t = new TriggerBg().units(Constants.MGDL).threshold(213).comparator(Trigger.Comparator.IS_EQUAL_OR_GREATER); Assert.assertTrue(t.shouldRun()); - t = new TriggerBg().units(Constants.MGDL).threshold(213).comparator(Trigger.Comparator.IS_EQUAL_OR_LOWER); + t = new TriggerBg().units(Constants.MGDL).threshold(213).comparator(Trigger.Comparator.IS_EQUAL_OR_LESSER); Assert.assertFalse(t.shouldRun()); - when(MainApp.getDbHelper().getBgreadingsDataFromTime(anyLong(), anyBoolean())).thenReturn(new ArrayList<>()); - t = new TriggerBg().units(Constants.MGDL).threshold(213).comparator(Trigger.Comparator.IS_EQUAL_OR_LOWER); + when(IobCobCalculatorPlugin.getPlugin().getBgReadings()).thenReturn(new ArrayList<>()); + t = new TriggerBg().units(Constants.MGDL).threshold(213).comparator(Trigger.Comparator.IS_EQUAL_OR_LESSER); Assert.assertFalse(t.shouldRun()); t = new TriggerBg().comparator(Trigger.Comparator.IS_NOT_AVAILABLE); Assert.assertTrue(t.shouldRun()); @@ -84,7 +86,7 @@ public class TriggerBgTest { public void mock() { AAPSMocker.mockMainApp(); AAPSMocker.mockBus(); - AAPSMocker.mockDatabaseHelper(); + AAPSMocker.mockIobCobCalculatorPlugin(); AAPSMocker.mockProfileFunctions(); PowerMockito.mockStatic(DateUtil.class);