make tests compile
This commit is contained in:
parent
4b86961235
commit
8b88e2d270
|
@ -14,13 +14,13 @@ import java.util.Locale;
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.ProfileStore;
|
import info.nightscout.androidaps.data.ProfileStore;
|
||||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||||
|
@ -34,7 +34,6 @@ import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import static org.mockito.ArgumentMatchers.anyLong;
|
import static org.mockito.ArgumentMatchers.anyLong;
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.Mockito.doReturn;
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@ -184,8 +183,10 @@ public class AAPSMocker {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConstraintChecker mockConstraintsChecker() {
|
public static ConstraintChecker mockConstraintsChecker() {
|
||||||
|
PowerMockito.mockStatic(ConstraintChecker.class);
|
||||||
constraintChecker = mock(ConstraintChecker.class);
|
constraintChecker = mock(ConstraintChecker.class);
|
||||||
when(MainApp.getConstraintChecker()).thenReturn(constraintChecker);
|
when(ConstraintChecker.getInstance())
|
||||||
|
.thenReturn(constraintChecker);
|
||||||
return constraintChecker;
|
return constraintChecker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -287,7 +287,7 @@ public class ConstraintsCheckerTest {
|
||||||
//SafetyPlugin
|
//SafetyPlugin
|
||||||
when(ConfigBuilderPlugin.getPlugin().getActivePump()).thenReturn(pump);
|
when(ConfigBuilderPlugin.getPlugin().getActivePump()).thenReturn(pump);
|
||||||
|
|
||||||
constraintChecker = new ConstraintChecker();
|
constraintChecker = ConstraintChecker.getInstance();
|
||||||
|
|
||||||
safetyPlugin = SafetyPlugin.getPlugin();
|
safetyPlugin = SafetyPlugin.getPlugin();
|
||||||
objectivesPlugin = ObjectivesPlugin.INSTANCE;
|
objectivesPlugin = ObjectivesPlugin.INSTANCE;
|
||||||
|
|
|
@ -30,7 +30,7 @@ import static org.mockito.ArgumentMatchers.anyLong;
|
||||||
import static org.powermock.api.mockito.PowerMockito.when;
|
import static org.powermock.api.mockito.PowerMockito.when;
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({MainApp.class, ConfigBuilderPlugin.class, SP.class, Context.class, ProfileFunctions.class, TreatmentsPlugin.class, L.class})
|
@PrepareForTest({MainApp.class, ConfigBuilderPlugin.class, SP.class, Context.class, ProfileFunctions.class, TreatmentsPlugin.class, L.class, ConstraintChecker.class})
|
||||||
public class APSResultTest {
|
public class APSResultTest {
|
||||||
VirtualPumpPlugin virtualPumpPlugin;
|
VirtualPumpPlugin virtualPumpPlugin;
|
||||||
TreatmentsPlugin treatmentsPlugin;
|
TreatmentsPlugin treatmentsPlugin;
|
||||||
|
@ -183,13 +183,13 @@ public class APSResultTest {
|
||||||
AAPSMocker.mockTreatmentService();
|
AAPSMocker.mockTreatmentService();
|
||||||
AAPSMocker.mockL();
|
AAPSMocker.mockL();
|
||||||
treatmentsPlugin = AAPSMocker.mockTreatmentPlugin();
|
treatmentsPlugin = AAPSMocker.mockTreatmentPlugin();
|
||||||
ConstraintChecker constraintChecker = AAPSMocker.mockConstraintsChecker();
|
AAPSMocker.mockConstraintsChecker();
|
||||||
|
when(ConstraintChecker.getInstance().isClosedLoopAllowed()).thenReturn(closedLoopEnabled);
|
||||||
|
|
||||||
|
|
||||||
virtualPumpPlugin = VirtualPumpPlugin.getPlugin();
|
virtualPumpPlugin = VirtualPumpPlugin.getPlugin();
|
||||||
when(ConfigBuilderPlugin.getPlugin().getActivePump()).thenReturn(virtualPumpPlugin);
|
when(ConfigBuilderPlugin.getPlugin().getActivePump()).thenReturn(virtualPumpPlugin);
|
||||||
|
|
||||||
when(constraintChecker.isClosedLoopAllowed()).thenReturn(closedLoopEnabled);
|
|
||||||
|
|
||||||
Mockito.when(SP.getDouble(anyInt(), anyDouble())).thenReturn(30d);
|
Mockito.when(SP.getDouble(anyInt(), anyDouble())).thenReturn(30d);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin;
|
import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin;
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.OpenAPSMAPlugin;
|
import info.nightscout.androidaps.plugins.aps.openAPSMA.OpenAPSMAPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
||||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin;
|
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin;
|
||||||
import info.nightscout.androidaps.plugins.source.SourceGlimpPlugin;
|
import info.nightscout.androidaps.plugins.source.SourceGlimpPlugin;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
|
|
@ -43,6 +43,7 @@ import info.nightscout.androidaps.queue.CommandQueue;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
import info.nightscout.androidaps.utils.XdripCalibrations;
|
import info.nightscout.androidaps.utils.XdripCalibrations;
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelperImplementation;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||||
|
@ -889,7 +890,7 @@ public class SmsCommunicatorPluginTest {
|
||||||
AAPSMocker.mockConfigBuilder();
|
AAPSMocker.mockConfigBuilder();
|
||||||
AAPSMocker.mockCommandQueue();
|
AAPSMocker.mockCommandQueue();
|
||||||
AAPSMocker.mockNSUpload();
|
AAPSMocker.mockNSUpload();
|
||||||
AAPSMocker.mockConstraintsChecker();
|
ConstraintChecker constraintChecker = AAPSMocker.mockConstraintsChecker();
|
||||||
|
|
||||||
BgReading reading = new BgReading();
|
BgReading reading = new BgReading();
|
||||||
reading.value = 100;
|
reading.value = 100;
|
||||||
|
@ -907,7 +908,8 @@ public class SmsCommunicatorPluginTest {
|
||||||
when(SP.getString(R.string.key_smscommunicator_allowednumbers, "")).thenReturn("1234;5678");
|
when(SP.getString(R.string.key_smscommunicator_allowednumbers, "")).thenReturn("1234;5678");
|
||||||
Lazy<InsulinOrefRapidActingPlugin> insulinOrefRapidActingPlugin = InsulinOrefRapidActingPlugin::new;
|
Lazy<InsulinOrefRapidActingPlugin> insulinOrefRapidActingPlugin = InsulinOrefRapidActingPlugin::new;
|
||||||
ConfigBuilderPlugin configBuilderPlugin = new ConfigBuilderPlugin(insulinOrefRapidActingPlugin);
|
ConfigBuilderPlugin configBuilderPlugin = new ConfigBuilderPlugin(insulinOrefRapidActingPlugin);
|
||||||
smsCommunicatorPlugin = new SmsCommunicatorPlugin(configBuilderPlugin);
|
ResourceHelperImplementation resourceHelperImplementation = mock(ResourceHelperImplementation.class);
|
||||||
|
smsCommunicatorPlugin = new SmsCommunicatorPlugin(configBuilderPlugin, resourceHelperImplementation, constraintChecker);
|
||||||
smsCommunicatorPlugin.setPluginEnabled(PluginType.GENERAL, true);
|
smsCommunicatorPlugin.setPluginEnabled(PluginType.GENERAL, true);
|
||||||
|
|
||||||
mockStatic(LoopPlugin.class);
|
mockStatic(LoopPlugin.class);
|
||||||
|
|
|
@ -113,6 +113,7 @@ public class CommandQueueTest extends CommandQueue {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void prepareMock(Double insulin, Integer carbs) throws Exception {
|
private void prepareMock(Double insulin, Integer carbs) throws Exception {
|
||||||
|
PowerMockito.mockStatic(ConstraintChecker.class);
|
||||||
ConstraintChecker constraintChecker = mock(ConstraintChecker.class);
|
ConstraintChecker constraintChecker = mock(ConstraintChecker.class);
|
||||||
|
|
||||||
AAPSMocker.mockMainApp();
|
AAPSMocker.mockMainApp();
|
||||||
|
@ -120,7 +121,7 @@ public class CommandQueueTest extends CommandQueue {
|
||||||
PumpInterface pump = VirtualPumpPlugin.getPlugin();
|
PumpInterface pump = VirtualPumpPlugin.getPlugin();
|
||||||
when(ConfigBuilderPlugin.getPlugin().getActivePump()).thenReturn(pump);
|
when(ConfigBuilderPlugin.getPlugin().getActivePump()).thenReturn(pump);
|
||||||
|
|
||||||
when(MainApp.getConstraintChecker()).thenReturn(constraintChecker);
|
when(ConstraintChecker.getInstance()).thenReturn(constraintChecker);
|
||||||
when(MainApp.isEngineeringModeOrRelease()).thenReturn(true);
|
when(MainApp.isEngineeringModeOrRelease()).thenReturn(true);
|
||||||
Constraint<Double> bolusConstraint = new Constraint<>(0d);
|
Constraint<Double> bolusConstraint = new Constraint<>(0d);
|
||||||
when(ConstraintChecker.getInstance().applyBolusConstraints(any())).thenReturn(bolusConstraint);
|
when(ConstraintChecker.getInstance().applyBolusConstraints(any())).thenReturn(bolusConstraint);
|
||||||
|
|
Loading…
Reference in a new issue