remove unused tests

This commit is contained in:
Milos Kozak 2020-04-26 17:01:31 +02:00
parent 2eb0122dd6
commit c0f6f1a5e9
5 changed files with 54 additions and 63 deletions

View file

@ -52,17 +52,17 @@ public abstract class PumpStatus {
public int tempBasalRatio = 0;
public int tempBasalRemainMin = 0;
public Date tempBasalStart;
protected PumpDescription pumpDescription;
//protected PumpDescription pumpDescription;
public PumpStatus(PumpDescription pumpDescription) {
this.pumpDescription = pumpDescription;
public PumpStatus() {
// public PumpStatus(PumpDescription pumpDescription) {
// this.pumpDescription = pumpDescription;
this.initSettings();
// this.initSettings();
}
public abstract void initSettings();
public void setLastCommunicationToNow() {

View file

@ -138,7 +138,8 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
.fragmentClass(MedtronicFragment.class.getName()) //
.pluginName(R.string.medtronic_name) //
.shortName(R.string.medtronic_name_short) //
.preferencesId(R.xml.pref_medtronic).description(R.string.description_pump_medtronic), //
.preferencesId(R.xml.pref_medtronic)
.description(R.string.description_pump_medtronic), //
PumpType.Medtronic_522_722, // we default to most basic model, correct model from config is loaded later
injector, resourceHelper, aapsLogger, commandQueue, rxBus, activePlugin, sp, context, fabricPrivacy
);
@ -609,17 +610,16 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
@Override
public boolean isThisProfileSet(Profile profile) {
MedtronicPumpStatus mdtPumpStatus = medtronicPumpStatus;
aapsLogger.debug(LTag.PUMP, "isThisProfileSet: basalInitalized=" + mdtPumpStatus.basalProfileStatus);
aapsLogger.debug(LTag.PUMP, "isThisProfileSet: basalInitalized=" + medtronicPumpStatus.basalProfileStatus);
if (!isInitialized)
return true;
if (mdtPumpStatus.basalProfileStatus == BasalProfileStatus.NotInitialized) {
if (medtronicPumpStatus.basalProfileStatus == BasalProfileStatus.NotInitialized) {
// this shouldn't happen, but if there was problem we try again
getBasalProfiles();
return isProfileSame(profile);
} else if (mdtPumpStatus.basalProfileStatus == BasalProfileStatus.ProfileChanged) {
} else if (medtronicPumpStatus.basalProfileStatus == BasalProfileStatus.ProfileChanged) {
return false;
} else {
@ -674,7 +674,6 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
@Override
public long lastDataTime() {
medtronicPumpStatus;
if (medtronicPumpStatus.lastConnection != 0) {
return medtronicPumpStatus.lastConnection;
@ -778,14 +777,12 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
setRefreshButtonEnabled(false);
MedtronicPumpStatus mdtPumpStatus = medtronicPumpStatus;
if (detailedBolusInfo.insulin > mdtPumpStatus.reservoirRemainingUnits) {
if (detailedBolusInfo.insulin > medtronicPumpStatus.reservoirRemainingUnits) {
return new PumpEnactResult(getInjector()) //
.success(false) //
.enacted(false) //
.comment(getResourceHelper().gs(R.string.medtronic_cmd_bolus_could_not_be_delivered_no_insulin,
mdtPumpStatus.reservoirRemainingUnits,
medtronicPumpStatus.reservoirRemainingUnits,
detailedBolusInfo.insulin));
}
@ -1447,14 +1444,12 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
StringBuilder stringBuilder = new StringBuilder();
MedtronicPumpStatus pumpStatus = medtronicPumpStatus;
if (pumpStatus.maxBasal == null)
if (medtronicPumpStatus.maxBasal == null)
return null;
for (BasalProfileEntry profileEntry : basalProfile.getEntries()) {
if (profileEntry.rate > pumpStatus.maxBasal) {
if (profileEntry.rate > medtronicPumpStatus.maxBasal) {
stringBuilder.append(profileEntry.startTime.toString("HH:mm"));
stringBuilder.append("=");
stringBuilder.append(profileEntry.rate);
@ -1468,8 +1463,6 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
@NonNull
private BasalProfile convertProfileToMedtronicProfile(Profile profile) {
MedtronicPumpStatus pumpStatus = medtronicPumpStatus;
PumpType pumpType = pumpStatus.pumpType;
BasalProfile basalProfile = new BasalProfile();

View file

@ -11,9 +11,7 @@ import java.util.Map;
import javax.inject.Inject;
import javax.inject.Singleton;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus;
@ -24,6 +22,7 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.Rile
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkTargetFrequency;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError;
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState;
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
import info.nightscout.androidaps.plugins.pump.medtronic.data.MedtronicHistoryData;
import info.nightscout.androidaps.plugins.pump.medtronic.defs.BasalProfileStatus;
import info.nightscout.androidaps.plugins.pump.medtronic.defs.BatteryType;
@ -31,8 +30,8 @@ import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceTyp
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst;
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
import info.nightscout.androidaps.utils.SP;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
import info.nightscout.androidaps.utils.sharedPreferences.SP;
/**
* Created by andy on 4/28/18.
@ -43,6 +42,7 @@ public class MedtronicPumpStatus extends PumpStatus {
private final AAPSLogger aapsLogger;
private final ResourceHelper resourceHelper;
private final SP sp;
public String errorDescription = null;
public String serialNumber;
@ -50,7 +50,7 @@ public class MedtronicPumpStatus extends PumpStatus {
public String rileyLinkAddress = null;
public Double maxBolus;
public Double maxBasal;
public boolean inPreInit = true;
private boolean inPreInit = true;
// statuses
public RileyLinkServiceState rileyLinkServiceState = RileyLinkServiceState.NotStarted;
@ -89,16 +89,17 @@ public class MedtronicPumpStatus extends PumpStatus {
public MedtronicPumpStatus(
AAPSLogger aapsLogger,
ResourceHelper resourceHelper,
PumpDescription pumpDescription
SP sp
) {
super(pumpDescription);
super();
this.aapsLogger = aapsLogger;
this.resourceHelper = resourceHelper;
this.sp = sp;
initSettings();
}
@Override
public void initSettings() {
private void initSettings() {
this.activeProfileName = "STD";
this.reservoirRemainingUnits = 75d;
@ -110,7 +111,7 @@ public class MedtronicPumpStatus extends PumpStatus {
if (this.medtronicDeviceTypeMap == null)
createMedtronicDeviceTypeMap();
this.lastConnection = SP.getLong(MedtronicConst.Statistics.LastGoodPumpCommunicationTime, 0L);
this.lastConnection = sp.getLong(MedtronicConst.Statistics.LastGoodPumpCommunicationTime, 0L);
this.lastDataTime = new LocalDateTime(this.lastConnection);
}
@ -147,8 +148,8 @@ public class MedtronicPumpStatus extends PumpStatus {
medtronicPumpMap.put("754", PumpType.Medtronic_554_754_Veo);
frequencies = new String[2];
frequencies[0] = MainApp.gs(R.string.key_medtronic_pump_frequency_us_ca);
frequencies[1] = MainApp.gs(R.string.key_medtronic_pump_frequency_worldwide);
frequencies[0] = resourceHelper.gs(R.string.key_medtronic_pump_frequency_us_ca);
frequencies[1] = resourceHelper.gs(R.string.key_medtronic_pump_frequency_worldwide);
}
@ -164,14 +165,14 @@ public class MedtronicPumpStatus extends PumpStatus {
this.errorDescription = "-";
String serialNr = SP.getString(MedtronicConst.Prefs.PumpSerial, null);
String serialNr = sp.getStringOrNull(MedtronicConst.Prefs.PumpSerial, null);
if (serialNr == null) {
this.errorDescription = MainApp.gs(R.string.medtronic_error_serial_not_set);
this.errorDescription = resourceHelper.gs(R.string.medtronic_error_serial_not_set);
return false;
} else {
if (!serialNr.matches(regexSN)) {
this.errorDescription = MainApp.gs(R.string.medtronic_error_serial_invalid);
this.errorDescription = resourceHelper.gs(R.string.medtronic_error_serial_invalid);
return false;
} else {
if (!serialNr.equals(this.serialNumber)) {
@ -181,21 +182,21 @@ public class MedtronicPumpStatus extends PumpStatus {
}
}
String pumpType = SP.getString(MedtronicConst.Prefs.PumpType, null);
String pumpType = sp.getStringOrNull(MedtronicConst.Prefs.PumpType, null);
if (pumpType == null) {
this.errorDescription = MainApp.gs(R.string.medtronic_error_pump_type_not_set);
this.errorDescription = resourceHelper.gs(R.string.medtronic_error_pump_type_not_set);
return false;
} else {
String pumpTypePart = pumpType.substring(0, 3);
if (!pumpTypePart.matches("[0-9]{3}")) {
this.errorDescription = MainApp.gs(R.string.medtronic_error_pump_type_invalid);
this.errorDescription = resourceHelper.gs(R.string.medtronic_error_pump_type_invalid);
return false;
} else {
this.pumpType = medtronicPumpMap.get(pumpTypePart);
this.medtronicDeviceType = medtronicDeviceTypeMap.get(pumpTypePart);
this.pumpDescription.setPumpDescription(this.pumpType);
MedtronicPumpPlugin.getPlugin().getPumpDescription().setPumpDescription(this.pumpType);
if (pumpTypePart.startsWith("7"))
this.reservoirFullUnits = 300;
@ -204,14 +205,14 @@ public class MedtronicPumpStatus extends PumpStatus {
}
}
String pumpFrequency = SP.getString(MedtronicConst.Prefs.PumpFrequency, null);
String pumpFrequency = sp.getStringOrNull(MedtronicConst.Prefs.PumpFrequency, null);
if (pumpFrequency == null) {
this.errorDescription = MainApp.gs(R.string.medtronic_error_pump_frequency_not_set);
this.errorDescription = resourceHelper.gs(R.string.medtronic_error_pump_frequency_not_set);
return false;
} else {
if (!pumpFrequency.equals(frequencies[0]) && !pumpFrequency.equals(frequencies[1])) {
this.errorDescription = MainApp.gs(R.string.medtronic_error_pump_frequency_invalid);
this.errorDescription = resourceHelper.gs(R.string.medtronic_error_pump_frequency_invalid);
return false;
} else {
this.pumpFrequency = pumpFrequency;
@ -230,15 +231,15 @@ public class MedtronicPumpStatus extends PumpStatus {
}
}
String rileyLinkAddress = SP.getString(RileyLinkConst.Prefs.RileyLinkAddress, null);
String rileyLinkAddress = sp.getStringOrNull(RileyLinkConst.Prefs.RileyLinkAddress, null);
if (rileyLinkAddress == null) {
aapsLogger.debug(LTag.PUMP, "RileyLink address invalid: null");
this.errorDescription = MainApp.gs(R.string.medtronic_error_rileylink_address_invalid);
this.errorDescription = resourceHelper.gs(R.string.medtronic_error_rileylink_address_invalid);
return false;
} else {
if (!rileyLinkAddress.matches(regexMac)) {
this.errorDescription = MainApp.gs(R.string.medtronic_error_rileylink_address_invalid);
this.errorDescription = resourceHelper.gs(R.string.medtronic_error_rileylink_address_invalid);
aapsLogger.debug(LTag.PUMP, "RileyLink address invalid: {}", rileyLinkAddress);
} else {
if (!rileyLinkAddress.equals(this.rileyLinkAddress)) {
@ -265,7 +266,7 @@ public class MedtronicPumpStatus extends PumpStatus {
}
String encodingTypeStr = SP.getString(MedtronicConst.Prefs.Encoding, null);
String encodingTypeStr = sp.getStringOrNull(MedtronicConst.Prefs.Encoding, null);
if (encodingTypeStr == null) {
return false;
@ -280,7 +281,7 @@ public class MedtronicPumpStatus extends PumpStatus {
this.encodingChanged = true;
}
String batteryTypeStr = SP.getString(MedtronicConst.Prefs.BatteryType, null);
String batteryTypeStr = sp.getStringOrNull(MedtronicConst.Prefs.BatteryType, null);
if (batteryTypeStr == null)
return false;
@ -292,9 +293,9 @@ public class MedtronicPumpStatus extends PumpStatus {
MedtronicUtil.getInstance().setBatteryType(this.batteryType);
}
String bolusDebugEnabled = SP.getString(MedtronicConst.Prefs.BolusDebugEnabled, null);
String bolusDebugEnabled = sp.getStringOrNull(MedtronicConst.Prefs.BolusDebugEnabled, null);
boolean bolusDebug = bolusDebugEnabled != null && bolusDebugEnabled.equals(MainApp.gs(R.string.common_on));
boolean bolusDebug = bolusDebugEnabled != null && bolusDebugEnabled.equals(resourceHelper.gs(R.string.common_on));
MedtronicHistoryData.doubleBolusDebug = bolusDebug;
@ -344,7 +345,7 @@ public class MedtronicPumpStatus extends PumpStatus {
private double checkParameterValue(int key, String defaultValue, double defaultValueDouble) {
double val = 0.0d;
String value = SP.getString(key, defaultValue);
String value = sp.getString(key, defaultValue);
try {
val = Double.parseDouble(value);
@ -354,7 +355,7 @@ public class MedtronicPumpStatus extends PumpStatus {
}
if (val > defaultValueDouble) {
SP.putString(key, defaultValue);
sp.putString(key, defaultValue);
val = defaultValueDouble;
}
@ -394,13 +395,13 @@ public class MedtronicPumpStatus extends PumpStatus {
}
// Battery type
Map<String, BatteryType> mapByDescription;
private Map<String, BatteryType> mapByDescription;
public BatteryType getBatteryTypeByDescription(String batteryTypeStr) {
private BatteryType getBatteryTypeByDescription(String batteryTypeStr) {
if (mapByDescription == null) {
mapByDescription = new HashMap<>();
for (BatteryType value : BatteryType.values()) {
mapByDescription.put(MainApp.gs(value.description), value);
mapByDescription.put(resourceHelper.gs(value.description), value);
}
}
if (mapByDescription.containsKey(batteryTypeStr)) {

View file

@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.pump.medtronic.comm;
import java.util.Map;
import org.junit.Ignore;
import org.junit.Test;
import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil;
@ -13,8 +14,9 @@ import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
/**
* Created by andy on 1/30/19.
*/
@Ignore
public class MedtronicConverterUTest {
/*
MedtronicConverter converter = new MedtronicConverter();
@ -35,5 +37,5 @@ public class MedtronicConverterUTest {
// byte[] data = new byte[] { 00 03 00 05 01 00 C8 00 A0 01 01 00 01 00 00 64 01 05 00 14 00 64 01 00 00 };
}
*/
}

View file

@ -23,15 +23,10 @@ import static org.mockito.Mockito.when;
//@PrepareForTest({ MainApp.class, DatabaseHelper.class, DateUtil.class, SP.class })
@Ignore
public class BasalProfileUTest {
/*
// MainApp mainApp = new MainApp();
@Before
public void initMocking() {
// AAPSMocker.mockMainApp();
// AAPSMocker.mockStrings();
// AAPSMocker.mockDatabaseHelper();
// SPMocker.prepareMock();
PowerMockito.mockStatic(DateUtil.class);
when(DateUtil.now()).thenReturn(1514766900000L + T.mins(1).msecs());
@ -161,5 +156,5 @@ public class BasalProfileUTest {
// 1.800 1.600 1.400 1.450 1.450 1.450 1.250 1.250 0.950 0.950 1.150 1.150 1.250 0.950 0.950 0.950 0.650 0.650
// 0.650 0.650 0.650 0.500 0.500 0.500
}
*/
}