diff --git a/app/src/test/java/info/AAPSMocker.java b/app/src/test/java/info/AAPSMocker.java index d2e7c02e17..15bab41e2b 100644 --- a/app/src/test/java/info/AAPSMocker.java +++ b/app/src/test/java/info/AAPSMocker.java @@ -155,15 +155,18 @@ public class AAPSMocker { when(ConfigBuilderPlugin.getCommandQueue()).thenReturn(queue); } - public static TreatmentsPlugin mockTreatmentPlugin() throws Exception { - TreatmentService treatmentService = PowerMockito.mock(TreatmentService.class); + public static TreatmentsPlugin mockTreatmentPlugin() { PowerMockito.mockStatic(TreatmentsPlugin.class); TreatmentsPlugin treatmentsPlugin = PowerMockito.mock(TreatmentsPlugin.class); - PowerMockito.whenNew(TreatmentService.class).withNoArguments().thenReturn(treatmentService); when(TreatmentsPlugin.getPlugin()).thenReturn(treatmentsPlugin); return treatmentsPlugin; } + public static void mockTreatmentService() throws Exception { + TreatmentService treatmentService = PowerMockito.mock(TreatmentService.class); + PowerMockito.whenNew(TreatmentService.class).withNoArguments().thenReturn(treatmentService); + } + public static Profile getValidProfile() { try { if (profile == null) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialogTest.java b/app/src/test/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialogTest.java index 8a11b51667..23be73838a 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialogTest.java +++ b/app/src/test/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialogTest.java @@ -67,7 +67,7 @@ public class NewNSTreatmentDialogTest { AAPSMocker.mockApplicationContext(); AAPSMocker.mockStrings(); PowerMockito.mockStatic(NSUpload.class); - AAPSMocker.mockTreatmentPlugin(); + AAPSMocker.mockTreatmentService(); AAPSMocker.mockBus(); AAPSMocker.mockDatabaseHelper(); diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/Loop/APSREsultTest.java b/app/src/test/java/info/nightscout/androidaps/plugins/Loop/APSREsultTest.java index d134b71e79..83a8e6a69a 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/Loop/APSREsultTest.java +++ b/app/src/test/java/info/nightscout/androidaps/plugins/Loop/APSREsultTest.java @@ -157,6 +157,7 @@ public class APSREsultTest { AAPSMocker.mockStrings(); AAPSMocker.mockBus(); AAPSMocker.mockProfileFunctions(); + AAPSMocker.mockTreatmentService(); treatmentsPlugin = AAPSMocker.mockTreatmentPlugin(); ConstraintChecker constraintChecker = AAPSMocker.mockConstraintsChecker();