fix tests

This commit is contained in:
Milos Kozak 2018-09-04 20:50:42 +02:00
parent 6f5332af0a
commit 1ede3df627
3 changed files with 8 additions and 4 deletions

View file

@ -155,15 +155,18 @@ public class AAPSMocker {
when(ConfigBuilderPlugin.getCommandQueue()).thenReturn(queue); when(ConfigBuilderPlugin.getCommandQueue()).thenReturn(queue);
} }
public static TreatmentsPlugin mockTreatmentPlugin() throws Exception { public static TreatmentsPlugin mockTreatmentPlugin() {
TreatmentService treatmentService = PowerMockito.mock(TreatmentService.class);
PowerMockito.mockStatic(TreatmentsPlugin.class); PowerMockito.mockStatic(TreatmentsPlugin.class);
TreatmentsPlugin treatmentsPlugin = PowerMockito.mock(TreatmentsPlugin.class); TreatmentsPlugin treatmentsPlugin = PowerMockito.mock(TreatmentsPlugin.class);
PowerMockito.whenNew(TreatmentService.class).withNoArguments().thenReturn(treatmentService);
when(TreatmentsPlugin.getPlugin()).thenReturn(treatmentsPlugin); when(TreatmentsPlugin.getPlugin()).thenReturn(treatmentsPlugin);
return 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() { public static Profile getValidProfile() {
try { try {
if (profile == null) if (profile == null)

View file

@ -67,7 +67,7 @@ public class NewNSTreatmentDialogTest {
AAPSMocker.mockApplicationContext(); AAPSMocker.mockApplicationContext();
AAPSMocker.mockStrings(); AAPSMocker.mockStrings();
PowerMockito.mockStatic(NSUpload.class); PowerMockito.mockStatic(NSUpload.class);
AAPSMocker.mockTreatmentPlugin(); AAPSMocker.mockTreatmentService();
AAPSMocker.mockBus(); AAPSMocker.mockBus();
AAPSMocker.mockDatabaseHelper(); AAPSMocker.mockDatabaseHelper();

View file

@ -157,6 +157,7 @@ public class APSREsultTest {
AAPSMocker.mockStrings(); AAPSMocker.mockStrings();
AAPSMocker.mockBus(); AAPSMocker.mockBus();
AAPSMocker.mockProfileFunctions(); AAPSMocker.mockProfileFunctions();
AAPSMocker.mockTreatmentService();
treatmentsPlugin = AAPSMocker.mockTreatmentPlugin(); treatmentsPlugin = AAPSMocker.mockTreatmentPlugin();
ConstraintChecker constraintChecker = AAPSMocker.mockConstraintsChecker(); ConstraintChecker constraintChecker = AAPSMocker.mockConstraintsChecker();