fix NPE in Simulator
This commit is contained in:
parent
ca01fcc270
commit
2fee7f3186
|
@ -17,6 +17,7 @@ import info.nightscout.androidaps.data.ConstraintChecker;
|
|||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.queue.CommandQueue;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
|
@ -122,11 +123,17 @@ public class AAPSMocker {
|
|||
when(MainApp.getDbHelper()).thenReturn(databaseHelper);
|
||||
}
|
||||
|
||||
public static void mockCommandQueue() {
|
||||
CommandQueue queue = mock(CommandQueue.class);
|
||||
when(ConfigBuilderPlugin.getCommandQueue()).thenReturn(queue);
|
||||
}
|
||||
|
||||
public static Profile getValidProfile() {
|
||||
try {
|
||||
if (profile == null)
|
||||
profile = new Profile(new JSONObject(validProfile), Constants.MGDL);
|
||||
} catch (JSONException ignored) {}
|
||||
} catch (JSONException ignored) {
|
||||
}
|
||||
return profile;
|
||||
}
|
||||
|
||||
|
|
|
@ -257,6 +257,7 @@ public class ConstraintsCheckerTest {
|
|||
AAPSMocker.mockBus();
|
||||
AAPSMocker.mockStrings();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockCommandQueue();
|
||||
|
||||
// RS constructor
|
||||
when(SP.getString(R.string.key_danars_address, "")).thenReturn("");
|
||||
|
|
|
@ -15,12 +15,13 @@ import info.nightscout.androidaps.interfaces.Constraint;
|
|||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.Bolus;
|
||||
import info.nightscout.androidaps.queue.CommandQueue;
|
||||
import info.nightscout.utils.ToastUtils;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, ConfigBuilderPlugin.class, ToastUtils.class, Context.class})
|
||||
@PrepareForTest({MainApp.class, ConfigBuilderPlugin.class, ToastUtils.class, Context.class, CommandQueue.class})
|
||||
public class ComboPluginTest {
|
||||
|
||||
ComboPlugin comboPlugin;
|
||||
|
@ -63,6 +64,7 @@ public class ComboPluginTest {
|
|||
AAPSMocker.mockConfigBuilder();
|
||||
AAPSMocker.mockBus();
|
||||
AAPSMocker.mockStrings();
|
||||
AAPSMocker.mockCommandQueue();
|
||||
|
||||
comboPlugin = ComboPlugin.getPlugin();
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ public class DanaRPluginTest {
|
|||
AAPSMocker.mockStrings();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockCommandQueue();
|
||||
|
||||
when(SP.getString(R.string.key_danars_address, "")).thenReturn("");
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ public class DanaRSPluginTest {
|
|||
AAPSMocker.mockStrings();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockCommandQueue();
|
||||
|
||||
when(SP.getString(R.string.key_danars_address, "")).thenReturn("");
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ public class InsightPluginTest {
|
|||
AAPSMocker.mockConfigBuilder();
|
||||
AAPSMocker.mockBus();
|
||||
AAPSMocker.mockStrings();
|
||||
AAPSMocker.mockCommandQueue();
|
||||
|
||||
insightPlugin = InsightPlugin.getPlugin();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue