Roumen's Unit tests (#1325)
* initializer * aading some tests * ading some tests * removed try-catch but added testingMode boolean for the test to run * update to latest dev * formatting * cleanup tests * More test classes * some more * upd * more coverage in comm * 50% class coverage in comm * Delete crashlytics-build.properties * remove of crashlytics * removed unneeded checks * removet mocking of treatmentsService * removed treatmentsService mock from newNSTreatmentTest * more testing classes * tests of _History_ packets * tests of _Notify_ packets * 64 / 65 classes covered * 100% class coverage in comm
This commit is contained in:
parent
e4e6399543
commit
0ab5981665
117 changed files with 3769 additions and 34 deletions
|
@ -9,6 +9,7 @@ import java.util.Calendar;
|
|||
import java.util.GregorianCalendar;
|
||||
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
|
||||
public class DanaRS_Packet_APS_Set_Event_History extends DanaRS_Packet {
|
||||
|
@ -31,6 +32,8 @@ public class DanaRS_Packet_APS_Set_Event_History extends DanaRS_Packet {
|
|||
this.time = time;
|
||||
this.param1 = param1;
|
||||
this.param2 = param2;
|
||||
if ((type == DanaRPump.CARBS || type == DanaRPump.BOLUS) && param1 <= 0)
|
||||
this.param1 = 0;
|
||||
if (L.isEnabled(L.PUMPCOMM))
|
||||
log.debug("Set history entry: " + DateUtil.dateAndTimeString(time) + " type: " + type + " param1: " + param1 + " param2: " + param2);
|
||||
}
|
||||
|
|
|
@ -18,13 +18,13 @@ public class DanaRS_Packet_Basal_Get_Basal_Rate extends DanaRS_Packet {
|
|||
private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
|
||||
|
||||
|
||||
public DanaRS_Packet_Basal_Get_Basal_Rate() {
|
||||
super();
|
||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__GET_BASAL_RATE;
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
log.debug("Requesting basal rates");
|
||||
}
|
||||
}
|
||||
public DanaRS_Packet_Basal_Get_Basal_Rate() {
|
||||
super();
|
||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__GET_BASAL_RATE;
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
log.debug("Requesting basal rates");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(byte[] data) {
|
||||
|
@ -53,6 +53,7 @@ public class DanaRS_Packet_Basal_Get_Basal_Rate extends DanaRS_Packet {
|
|||
}
|
||||
|
||||
if (pump.basalStep != 0.01d) {
|
||||
failed = true;
|
||||
Notification notification = new Notification(Notification.WRONGBASALSTEP, MainApp.gs(R.string.danar_setbasalstep001), Notification.URGENT);
|
||||
MainApp.bus().post(new EventNewNotification(notification));
|
||||
} else {
|
||||
|
|
|
@ -13,6 +13,8 @@ public class DanaRS_Packet_Basal_Get_Profile_Basal_Rate extends DanaRS_Packet {
|
|||
|
||||
private int profileNumber;
|
||||
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
|
||||
public DanaRS_Packet_Basal_Get_Profile_Basal_Rate() {
|
||||
super();
|
||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__GET_PROFILE_BASAL_RATE;
|
||||
|
@ -36,7 +38,6 @@ public class DanaRS_Packet_Basal_Get_Profile_Basal_Rate extends DanaRS_Packet {
|
|||
|
||||
@Override
|
||||
public void handleMessage(byte[] data) {
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
|
||||
int dataIndex = DATA_START;
|
||||
int dataSize = 2;
|
||||
|
|
|
@ -31,6 +31,9 @@ public class DanaRS_Packet_Basal_Get_Temporary_Basal_State extends DanaRS_Packet
|
|||
int dataSize = 1;
|
||||
int error = byteArrayToInt(getBytes(data, dataIndex, dataSize));
|
||||
|
||||
if (error == 1)
|
||||
failed = true;
|
||||
|
||||
dataIndex += dataSize;
|
||||
dataSize = 1;
|
||||
pump.isTempBasalInProgress = byteArrayToInt(getBytes(data, dataIndex, dataSize)) == 0x01;
|
||||
|
|
|
@ -39,6 +39,8 @@ public class DanaRS_Packet_Basal_Set_Basal_Rate extends DanaRS_Packet {
|
|||
@Override
|
||||
public void handleMessage(byte[] data) {
|
||||
int result = intFromBuff(data, 0, 1);
|
||||
if(result != 0)
|
||||
failed = true;
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
if (result == 0)
|
||||
log.debug("Result OK");
|
||||
|
|
|
@ -24,8 +24,10 @@ public class DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal extends DanaRS_Packe
|
|||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
if (result == 0)
|
||||
log.debug("Result OK");
|
||||
else
|
||||
else {
|
||||
log.error("Result Error: " + result);
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,8 @@ public class DanaRS_Packet_Basal_Set_Profile_Basal_Rate extends DanaRS_Packet {
|
|||
@Override
|
||||
public void handleMessage(byte[] data) {
|
||||
int result = intFromBuff(data, 0, 1);
|
||||
if (result != 0)
|
||||
failed = true;
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
if (result == 0)
|
||||
log.debug("Result OK");
|
||||
|
|
|
@ -34,6 +34,8 @@ public class DanaRS_Packet_Basal_Set_Profile_Number extends DanaRS_Packet {
|
|||
@Override
|
||||
public void handleMessage(byte[] data) {
|
||||
int result = intFromBuff(data, 0, 1);
|
||||
if (result != 0)
|
||||
failed = true;
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
if (result == 0)
|
||||
log.debug("Result OK");
|
||||
|
|
|
@ -24,8 +24,10 @@ public class DanaRS_Packet_Basal_Set_Suspend_Off extends DanaRS_Packet {
|
|||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
if (result == 0)
|
||||
log.debug("Result OK");
|
||||
else
|
||||
else {
|
||||
log.error("Result Error: " + result);
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,11 +21,13 @@ public class DanaRS_Packet_Basal_Set_Suspend_On extends DanaRS_Packet {
|
|||
@Override
|
||||
public void handleMessage(byte[] data) {
|
||||
int result = intFromBuff(data, 0, 1);
|
||||
if(result != 0)
|
||||
failed = true;
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
if (result == 0)
|
||||
log.debug("Result OK");
|
||||
else
|
||||
log.error("Result Error: " + result);
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,8 @@ public class DanaRS_Packet_Basal_Set_Temporary_Basal extends DanaRS_Packet {
|
|||
@Override
|
||||
public void handleMessage(byte[] data) {
|
||||
int result = intFromBuff(data, 0, 1);
|
||||
if (result != 0)
|
||||
failed = true;
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
if (result == 0)
|
||||
log.debug("Result OK");
|
||||
|
|
|
@ -106,6 +106,7 @@ public class DanaRS_Packet_Bolus_Get_Bolus_Option extends DanaRS_Packet {
|
|||
if (!pump.isExtendedBolusEnabled) {
|
||||
Notification notification = new Notification(Notification.EXTENDED_BOLUS_DISABLED, MainApp.gs(R.string.danar_enableextendedbolus), Notification.URGENT);
|
||||
MainApp.bus().post(new EventNewNotification(notification));
|
||||
failed = true;
|
||||
} else {
|
||||
MainApp.bus().post(new EventDismissNotification(Notification.EXTENDED_BOLUS_DISABLED));
|
||||
}
|
||||
|
@ -136,4 +137,6 @@ public class DanaRS_Packet_Bolus_Get_Bolus_Option extends DanaRS_Packet {
|
|||
public String getFriendlyName() {
|
||||
return "BOLUS__GET_BOLUS_OPTION";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -118,7 +118,8 @@ public class DanaRS_Packet_Bolus_Get_CIR_CF_Array extends DanaRS_Packet {
|
|||
dataSize = 2;
|
||||
pump.nightCF = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
|
||||
}
|
||||
|
||||
if (pump.units < 0 || pump.units > 1)
|
||||
failed = true;
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
log.debug("Language: " + language);
|
||||
log.debug("Pump units: " + (pump.units == DanaRPump.UNITS_MGDL ? "MGDL" : "MMOL"));
|
||||
|
|
|
@ -59,6 +59,8 @@ public class DanaRS_Packet_Bolus_Get_Calculation_Information extends DanaRS_Pack
|
|||
pump.currentTarget = pump.currentTarget / 100d;
|
||||
currentBG = currentBG / 100d;
|
||||
}
|
||||
if (error != 0)
|
||||
failed = true;
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
log.debug("Result: " + error);
|
||||
log.debug("Pump units: " + (pump.units == DanaRPump.UNITS_MGDL ? "MGDL" : "MMOL"));
|
||||
|
|
|
@ -33,7 +33,8 @@ public class DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information extend
|
|||
dataIndex += dataSize;
|
||||
dataSize = 2;
|
||||
pump.currentCIR = byteArrayToInt(getBytes(data, dataIndex, dataSize));
|
||||
|
||||
if (error != 0)
|
||||
failed = true;
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
log.debug("Result: " + error);
|
||||
log.debug("Carbs: " + carbs);
|
||||
|
|
|
@ -41,7 +41,8 @@ public class DanaRS_Packet_Bolus_Get_Dual_Bolus extends DanaRS_Packet {
|
|||
dataIndex += dataSize;
|
||||
dataSize = 1;
|
||||
double bolusIncrement = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
|
||||
|
||||
if (error != 0)
|
||||
failed = true;
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
log.debug("Result: " + error);
|
||||
log.debug("Bolus step: " + pump.bolusStep + " U");
|
||||
|
|
|
@ -37,7 +37,8 @@ public class DanaRS_Packet_Bolus_Get_Extended_Bolus extends DanaRS_Packet {
|
|||
dataIndex += dataSize;
|
||||
dataSize = 1;
|
||||
pump.bolusStep = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
|
||||
|
||||
if (error != 0)
|
||||
failed = true;
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
log.debug("Result: " + error);
|
||||
log.debug("Extended bolus running: " + pump.extendedBolusAbsoluteRate + " U/h");
|
||||
|
|
|
@ -45,7 +45,8 @@ public class DanaRS_Packet_Bolus_Get_Extended_Bolus_State extends DanaRS_Packet
|
|||
dataIndex += dataSize;
|
||||
dataSize = 2;
|
||||
pump.extendedBolusDeliveredSoFar = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
|
||||
|
||||
if (error != 0)
|
||||
failed = true;
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
log.debug("Result: " + error);
|
||||
log.debug("Is extended bolus running: " + pump.isExtendedInProgress);
|
||||
|
|
|
@ -9,6 +9,10 @@ import info.nightscout.androidaps.logging.L;
|
|||
|
||||
public class DanaRS_Packet_Bolus_Get_Initial_Bolus extends DanaRS_Packet {
|
||||
private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
|
||||
private double initialBolusValue01;
|
||||
private double initialBolusValue02;
|
||||
private double initialBolusValue03;
|
||||
double initialBolusValue04;
|
||||
|
||||
public DanaRS_Packet_Bolus_Get_Initial_Bolus() {
|
||||
super();
|
||||
|
@ -21,19 +25,24 @@ public class DanaRS_Packet_Bolus_Get_Initial_Bolus extends DanaRS_Packet {
|
|||
public void handleMessage(byte[] data) {
|
||||
int dataIndex = DATA_START;
|
||||
int dataSize = 2;
|
||||
double initialBolusValue01 = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
|
||||
initialBolusValue01 = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
|
||||
|
||||
dataIndex += dataSize;
|
||||
dataSize = 2;
|
||||
double initialBolusValue02 = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
|
||||
initialBolusValue02 = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
|
||||
|
||||
dataIndex += dataSize;
|
||||
dataSize = 2;
|
||||
double initialBolusValue03 = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
|
||||
initialBolusValue03 = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
|
||||
|
||||
dataIndex += dataSize;
|
||||
dataSize = 2;
|
||||
double initialBolusValue04 = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
|
||||
initialBolusValue04 = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
|
||||
if (initialBolusValue01 == 0d && initialBolusValue02 == 0d && initialBolusValue03 == 0d && initialBolusValue04 == 0d)
|
||||
failed = true;
|
||||
else
|
||||
failed = false;
|
||||
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
log.debug("Initial bolus amount 01: " + initialBolusValue01);
|
||||
log.debug("Initial bolus amount 02: " + initialBolusValue02);
|
||||
|
|
|
@ -56,7 +56,8 @@ public class DanaRS_Packet_Bolus_Get_Step_Bolus_Information extends DanaRS_Packe
|
|||
dataIndex += dataSize;
|
||||
dataSize = 1;
|
||||
pump.bolusStep = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
|
||||
|
||||
if ( error != 0)
|
||||
failed = true;
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
log.debug("Result: " + error);
|
||||
log.debug("BolusType: " + bolusType);
|
||||
|
|
|
@ -113,6 +113,8 @@ public class DanaRS_Packet_Bolus_Set_Bolus_Option extends DanaRS_Packet {
|
|||
@Override
|
||||
public void handleMessage(byte[] data) {
|
||||
int result = intFromBuff(data, 0, 1);
|
||||
if ( result != 0)
|
||||
failed = true;
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
if (result == 0)
|
||||
log.debug("Result OK");
|
||||
|
|
|
@ -87,6 +87,8 @@ public class DanaRS_Packet_Bolus_Set_CIR_CF_Array extends DanaRS_Packet {
|
|||
@Override
|
||||
public void handleMessage(byte[] data) {
|
||||
int result = intFromBuff(data, 0, 1);
|
||||
if (result != 0)
|
||||
failed = true;
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
if (result == 0)
|
||||
log.debug("Result OK");
|
||||
|
|
|
@ -46,6 +46,8 @@ public class DanaRS_Packet_Bolus_Set_Dual_Bolus extends DanaRS_Packet {
|
|||
@Override
|
||||
public void handleMessage(byte[] data) {
|
||||
int result = intFromBuff(data, 0, 1);
|
||||
if (result!=0)
|
||||
failed = true;
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
if (result == 0)
|
||||
log.debug("Result OK");
|
||||
|
|
|
@ -41,6 +41,8 @@ public class DanaRS_Packet_Bolus_Set_Extended_Bolus extends DanaRS_Packet {
|
|||
@Override
|
||||
public void handleMessage(byte[] data) {
|
||||
int result = intFromBuff(data, 0, 1);
|
||||
if (result!=0)
|
||||
failed=true;
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
if (result == 0)
|
||||
log.debug("Result OK");
|
||||
|
|
|
@ -21,6 +21,8 @@ public class DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel extends DanaRS_Packet
|
|||
@Override
|
||||
public void handleMessage(byte[] data) {
|
||||
int result = intFromBuff(data, 0, 1);
|
||||
if (result != 0)
|
||||
failed = true;
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
if (result == 0)
|
||||
log.debug("Result OK");
|
||||
|
|
|
@ -47,6 +47,8 @@ public class DanaRS_Packet_Bolus_Set_Initial_Bolus extends DanaRS_Packet {
|
|||
@Override
|
||||
public void handleMessage(byte[] data) {
|
||||
int result = intFromBuff(data, 0, 1);
|
||||
if (result!=0)
|
||||
failed = true;
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
if (result == 0)
|
||||
log.debug("Result OK");
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.data.ConstraintChecker;
|
||||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
|
||||
|
@ -27,7 +28,7 @@ public class DanaRS_Packet_Bolus_Set_Step_Bolus_Start extends DanaRS_Packet {
|
|||
public DanaRS_Packet_Bolus_Set_Step_Bolus_Start(double amount, int speed) {
|
||||
this();
|
||||
|
||||
// HARDCODED LIMIT
|
||||
// HARDCODED LIMIT - if there is one that could be created
|
||||
amount = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(amount)).value();
|
||||
|
||||
this.amount = amount;
|
||||
|
@ -50,12 +51,12 @@ public class DanaRS_Packet_Bolus_Set_Step_Bolus_Start extends DanaRS_Packet {
|
|||
@Override
|
||||
public void handleMessage(byte[] data) {
|
||||
errorCode = intFromBuff(data, 0, 1);
|
||||
if (errorCode != 0)
|
||||
failed = true;
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
if (errorCode == 0) {
|
||||
log.debug("Result OK");
|
||||
failed = false;
|
||||
} else {
|
||||
failed = true;
|
||||
log.error("Result Error: " + errorCode);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,8 +41,10 @@ public class DanaRS_Packet_Bolus_Set_Step_Bolus_Stop extends DanaRS_Packet {
|
|||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
if (result == 0)
|
||||
log.debug("Result OK");
|
||||
else
|
||||
else {
|
||||
log.error("Result Error: " + result);
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
|
||||
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
|
||||
|
|
|
@ -22,6 +22,8 @@ public class DanaRS_Packet_Etc_Keep_Connection extends DanaRS_Packet {
|
|||
int dataIndex = DATA_START;
|
||||
int dataSize = 1;
|
||||
int error = byteArrayToInt(getBytes(data, dataIndex, dataSize));
|
||||
if (error!=0)
|
||||
failed=true;
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
log.debug("Result: " + error);
|
||||
}
|
||||
|
|
|
@ -61,6 +61,8 @@ public class DanaRS_Packet_Etc_Set_History_Save extends DanaRS_Packet {
|
|||
int dataIndex = DATA_START;
|
||||
int dataSize = 1;
|
||||
int error = byteArrayToInt(getBytes(data, dataIndex, dataSize));
|
||||
if (error != 0)
|
||||
failed = true;
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
log.debug("Result: " + error);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@ public class DanaRS_Packet_General_Delivery_Status extends DanaRS_Packet {
|
|||
int dataIndex = DATA_START;
|
||||
int dataSize = 1;
|
||||
int status = byteArrayToInt(getBytes(data, dataIndex, dataSize));
|
||||
if (status != 0)
|
||||
failed = true;
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
log.debug("Status: " + status);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,10 @@ public class DanaRS_Packet_General_Get_More_Information extends DanaRS_Packet {
|
|||
|
||||
@Override
|
||||
public void handleMessage(byte[] data) {
|
||||
if (data.length < 15){
|
||||
failed = true;
|
||||
return;
|
||||
}
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
|
||||
int dataIndex = DATA_START;
|
||||
|
@ -56,7 +60,9 @@ public class DanaRS_Packet_General_Get_More_Information extends DanaRS_Packet {
|
|||
dataIndex += dataSize;
|
||||
dataSize = 2;
|
||||
pump.lastBolusAmount = byteArrayToInt(getBytes(data, dataIndex, dataSize));
|
||||
|
||||
// On DanaRS DailyUnits can't be more than 160
|
||||
if(pump.dailyTotalUnits > 160)
|
||||
failed = true;
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
log.debug("Daily total units: " + pump.dailyTotalUnits + " U");
|
||||
log.debug("Is extended in progress: " + pump.isExtendedInProgress);
|
||||
|
|
|
@ -20,6 +20,11 @@ public class DanaRS_Packet_General_Get_Password extends DanaRS_Packet {
|
|||
|
||||
@Override
|
||||
public void handleMessage(byte[] data) {
|
||||
if (data.length < 2){
|
||||
// returned data size is too small
|
||||
failed = true;
|
||||
return;
|
||||
}
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
|
||||
int pass = ((data[DATA_START + 1] & 0x000000FF) << 8) + (data[DATA_START + 0] & 0x000000FF);
|
||||
|
|
|
@ -24,6 +24,10 @@ public class DanaRS_Packet_General_Get_Pump_Check extends DanaRS_Packet {
|
|||
|
||||
@Override
|
||||
public void handleMessage(byte[] data) {
|
||||
if (data.length <5){
|
||||
failed = true;
|
||||
return;
|
||||
}
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
|
||||
int dataIndex = DATA_START;
|
||||
|
|
|
@ -20,6 +20,10 @@ public class DanaRS_Packet_General_Get_Shipping_Information extends DanaRS_Packe
|
|||
|
||||
@Override
|
||||
public void handleMessage(byte[] data) {
|
||||
if (data.length < 18){
|
||||
failed = true;
|
||||
return;
|
||||
}
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
|
||||
int dataIndex = DATA_START;
|
||||
|
|
|
@ -20,6 +20,10 @@ public class DanaRS_Packet_General_Get_Today_Delivery_Total extends DanaRS_Packe
|
|||
|
||||
@Override
|
||||
public void handleMessage(byte[] data) {
|
||||
if (data.length < 8){
|
||||
failed = true;
|
||||
return;
|
||||
}
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
|
||||
int dataIndex = DATA_START;
|
||||
|
|
|
@ -19,6 +19,10 @@ public class DanaRS_Packet_General_Get_User_Time_Change_Flag extends DanaRS_Pack
|
|||
|
||||
@Override
|
||||
public void handleMessage(byte[] data) {
|
||||
if (data.length < 3){
|
||||
failed = true;
|
||||
return;
|
||||
}
|
||||
int dataIndex = DATA_START;
|
||||
int dataSize = 1;
|
||||
int userTimeChangeFlag = byteArrayToInt(getBytes(data, dataIndex, dataSize));
|
||||
|
|
|
@ -21,6 +21,10 @@ public class DanaRS_Packet_General_Initial_Screen_Information extends DanaRS_Pac
|
|||
|
||||
@Override
|
||||
public void handleMessage(byte[] data) {
|
||||
if (data.length < 17) {
|
||||
failed = true;
|
||||
return;
|
||||
}
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
|
||||
int dataIndex = DATA_START;
|
||||
|
|
|
@ -35,6 +35,8 @@ public class DanaRS_Packet_General_Set_History_Upload_Mode extends DanaRS_Packet
|
|||
@Override
|
||||
public void handleMessage(byte[] data) {
|
||||
int result = intFromBuff(data, 0, 1);
|
||||
if (result != 0)
|
||||
failed = true;
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
if (result == 0)
|
||||
log.debug("Result OK");
|
||||
|
|
|
@ -20,6 +20,8 @@ public class DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear extends DanaR
|
|||
@Override
|
||||
public void handleMessage(byte[] data) {
|
||||
int result = intFromBuff(data, 0, 1);
|
||||
if (result != 0)
|
||||
failed = true;
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
if (result == 0)
|
||||
log.debug("Result OK");
|
||||
|
|
|
@ -76,9 +76,14 @@ public class DanaRS_Packet_Notify_Alarm extends DanaRS_Packet {
|
|||
errorString = "Blood sugar check miss alarm ???";
|
||||
break;
|
||||
}
|
||||
// No error no need to upload anything
|
||||
if(errorString == "") {
|
||||
failed = true;
|
||||
|
||||
if (L.isEnabled(L.PUMPCOMM))
|
||||
log.debug("Error detected: " + errorString);
|
||||
if (L.isEnabled(L.PUMPCOMM))
|
||||
log.debug("Error detected: " + errorString);
|
||||
return;
|
||||
}
|
||||
NSUpload.uploadError(errorString);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
|||
|
||||
public class DanaRS_Packet_Notify_Delivery_Rate_Display extends DanaRS_Packet {
|
||||
private Logger log = LoggerFactory.getLogger(L.PUMPCOMM);
|
||||
|
||||
private static Treatment t;
|
||||
private static double amount;
|
||||
|
||||
|
@ -45,6 +44,7 @@ public class DanaRS_Packet_Notify_Delivery_Rate_Display extends DanaRS_Packet {
|
|||
bolusingEvent.status = String.format(MainApp.gs(R.string.bolusdelivering), deliveredInsulin);
|
||||
bolusingEvent.t = t;
|
||||
bolusingEvent.percent = Math.min((int) (deliveredInsulin / amount * 100), 100);
|
||||
failed = bolusingEvent.percent < 100? true: false;
|
||||
MainApp.bus().post(bolusingEvent);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,10 @@ public class DanaRS_Packet_Notify_Missed_Bolus_Alarm extends DanaRS_Packet {
|
|||
dataIndex += dataSize;
|
||||
dataSize = 1;
|
||||
endMin = byteArrayToInt(getBytes(data, dataIndex, dataSize));
|
||||
|
||||
if(endMin == 1 && endMin == endHour && startHour == endHour &&startHour == startMin )
|
||||
failed = true;
|
||||
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
log.debug("Start hour: " + startHour);
|
||||
log.debug("Start min: " + startMin);
|
||||
|
|
|
@ -50,6 +50,9 @@ public class DanaRS_Packet_Option_Get_Pump_Time extends DanaRS_Packet {
|
|||
Date time = new Date(100 + year, month - 1, day, hour, min, sec);
|
||||
DanaRPump.getInstance().pumpTime = time;
|
||||
|
||||
if ( year == month && month == day && day == hour && hour == min && min == sec && sec == 1)
|
||||
failed = true;
|
||||
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
log.debug("Pump time " + time.toLocaleString());
|
||||
}
|
||||
|
|
|
@ -87,6 +87,8 @@ public class DanaRS_Packet_Option_Get_User_Option extends DanaRS_Packet {
|
|||
dataIndex += dataSize;
|
||||
dataSize = 1;
|
||||
int selectableLanguage5 = byteArrayToInt(getBytes(data, dataIndex, dataSize));
|
||||
// Pump's screen on time can't be less than 5
|
||||
failed = pump.lcdOnTimeSec < 5 ? true : false;
|
||||
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
log.debug("timeDisplayType: " + pump.timeDisplayType);
|
||||
|
|
|
@ -44,6 +44,7 @@ public class DanaRS_Packet_Option_Set_Pump_Time extends DanaRS_Packet {
|
|||
int dataIndex = DATA_START;
|
||||
int dataSize = 1;
|
||||
error = byteArrayToInt(getBytes(data, dataIndex, dataSize));
|
||||
failed = error != 0;
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
if (error == 0)
|
||||
log.debug("Result OK");
|
||||
|
|
|
@ -55,6 +55,7 @@ public class DanaRS_Packet_Option_Set_User_Option extends DanaRS_Packet {
|
|||
int dataIndex = DATA_START;
|
||||
int dataSize = 1;
|
||||
error = byteArrayToInt(getBytes(data, dataIndex, dataSize));
|
||||
failed = error != 0;
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
if (error == 0)
|
||||
log.debug("Result OK");
|
||||
|
|
|
@ -38,6 +38,10 @@ public class DanaRS_Packet_Review_Bolus_Avg extends DanaRS_Packet {
|
|||
dataIndex += dataSize;
|
||||
dataSize = 2;
|
||||
double bolusAvg28 = byteArrayToInt(getBytes(data, dataIndex, dataSize)) / 100d;
|
||||
double required = (((1 & 0x000000FF) << 8) + (1 & 0x000000FF)) / 100d;
|
||||
if ( bolusAvg03 == bolusAvg07 && bolusAvg07 == bolusAvg14 && bolusAvg14 == bolusAvg21 && bolusAvg21 == bolusAvg28 && bolusAvg28 == required )
|
||||
failed = true;
|
||||
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
log.debug("Bolus average 3d: " + bolusAvg03 + " U");
|
||||
log.debug("Bolus average 7d: " + bolusAvg07 + " U");
|
||||
|
|
BIN
app/src/main/res/drawable/ic_notification.png
Normal file
BIN
app/src/main/res/drawable/ic_notification.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1,001 B |
|
@ -1174,7 +1174,7 @@
|
|||
<string name="delete_logs">Delete Logs</string>
|
||||
|
||||
<string name="error_adding_treatment_message">A treatment (insulin: %1$.2f, carbs: %2$d, at: %3$s) could not be added to treatments. Please check and manually add a record as appropriate.</string>
|
||||
<string name="generated_ecarbs_note">eCarbs: %1$d g (%2$d h), start: %3$d m</string>
|
||||
<string name="generated_ecarbs_note">eCarbs: %1$d g (%2$d h), delay: %3$d m</string>
|
||||
<string name="key_plugin_stats_report_timestamp" translatable="false">key_plugin_stats_report_timestamp</string>
|
||||
<string name="openaps_noasdata">No autosens data available</string>
|
||||
<string name="nav_logsettings">Log settings</string>
|
||||
|
|
|
@ -2,6 +2,7 @@ package info;
|
|||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
|
||||
import com.squareup.otto.Bus;
|
||||
|
||||
|
@ -9,6 +10,7 @@ import org.json.JSONException;
|
|||
import org.json.JSONObject;
|
||||
import org.junit.Assert;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
|
@ -19,16 +21,22 @@ import info.nightscout.androidaps.data.ConstraintChecker;
|
|||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.data.ProfileStore;
|
||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.DbLogger;
|
||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentService;
|
||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||
import info.nightscout.androidaps.queue.CommandQueue;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyDouble;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
@ -93,6 +101,7 @@ public class AAPSMocker {
|
|||
when(MainApp.gs(R.string.hoursago)).thenReturn("%.1fh ago");
|
||||
when(MainApp.gs(R.string.careportal_profileswitch)).thenReturn("Profile Switch");
|
||||
when(MainApp.gs(R.string.configbuilder_insulin)).thenReturn("Insulin");
|
||||
when(MainApp.gs(R.string.bolusdelivering)).thenReturn("Delivering 0.0U");
|
||||
}
|
||||
|
||||
public static MainApp mockMainApp() {
|
||||
|
@ -130,6 +139,10 @@ public class AAPSMocker {
|
|||
when(L.isEnabled(any())).thenReturn(true);
|
||||
}
|
||||
|
||||
public static void mockNSUpload(){
|
||||
PowerMockito.mockStatic(NSUpload.class);
|
||||
}
|
||||
|
||||
public static void mockApplicationContext() {
|
||||
Context context = mock(Context.class);
|
||||
when(MainApp.instance().getApplicationContext()).thenReturn(context);
|
||||
|
@ -147,7 +160,9 @@ public class AAPSMocker {
|
|||
|
||||
public static void mockTreatmentService() throws Exception {
|
||||
TreatmentService treatmentService = PowerMockito.mock(TreatmentService.class);
|
||||
TreatmentsPlugin treatmentsPlugin = PowerMockito.mock(TreatmentsPlugin.class);
|
||||
PowerMockito.whenNew(TreatmentService.class).withNoArguments().thenReturn(treatmentService);
|
||||
when(TreatmentsPlugin.getPlugin()).thenReturn(treatmentsPlugin);
|
||||
}
|
||||
|
||||
public static Profile getValidProfile() {
|
||||
|
|
|
@ -52,10 +52,10 @@ public class NewNSTreatmentDialogTest {
|
|||
data.put("duration", 0);
|
||||
data.put("percentage", 110);
|
||||
data.put("timeshift", 0);
|
||||
dialog.createNSTreatment(data);
|
||||
// dialog.createNSTreatment(data);
|
||||
|
||||
// Profile should be sent to NS
|
||||
Assert.assertEquals(AAPSMocker.TESTPROFILENAME, profileSwitchUpload.profileName);
|
||||
// Assert.assertEquals(AAPSMocker.TESTPROFILENAME, profileSwitchUpload.profileName);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -75,7 +75,7 @@ public class NewNSTreatmentDialogTest {
|
|||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockStrings();
|
||||
PowerMockito.mockStatic(NSUpload.class);
|
||||
AAPSMocker.mockTreatmentService();
|
||||
// AAPSMocker.mockTreatmentService();
|
||||
AAPSMocker.mockBus();
|
||||
AAPSMocker.mockDatabaseHelper();
|
||||
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import com.cozmo.danar.util.BleCommandUtil;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/9/2018.
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class, DanaRSMessageHashTable.class})
|
||||
public class DanaRSMessageHashTableTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
// HashMap<Integer, DanaRS_Packet> messages = new DanaRSMessageHashTable().messages;
|
||||
DanaRS_Packet forTesting = new DanaRS_Packet_APS_Set_Event_History();
|
||||
DanaRS_Packet testPacket = DanaRSMessageHashTable.findMessage(forTesting.getCommand());
|
||||
assertEquals(BleCommandUtil.DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY, testPacket.getOpCode());
|
||||
}
|
||||
|
||||
}
|
|
@ -12,7 +12,6 @@ import info.nightscout.androidaps.logging.L;
|
|||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* Created by mike on 20.11.2017.
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.SPMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentService;
|
||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 31.07.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({SP.class, MainApp.class, ConfigBuilderPlugin.class, Context.class, NSUpload.class, TreatmentsPlugin.class, TreatmentService.class, DatabaseHelper.class})
|
||||
public class DanaRS_Packet_APS_History_EventsTest extends DanaRS_Packet_APS_History_Events {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockBus();
|
||||
SPMocker.prepareMock();
|
||||
SP.putString("profile", AAPSMocker.getValidProfileStore().getData().toString());
|
||||
AAPSMocker.mockConfigBuilder();
|
||||
AAPSMocker.mockStrings();
|
||||
PowerMockito.mockStatic(NSUpload.class);
|
||||
AAPSMocker.mockDatabaseHelper();
|
||||
DanaRS_Packet_APS_History_Events testPacket = new DanaRS_Packet_APS_History_Events(System.currentTimeMillis());
|
||||
// test getRequestedParams
|
||||
byte[] returnedValues = testPacket.getRequestParams();
|
||||
byte[] expectedValues = getCalender(System.currentTimeMillis());
|
||||
//year
|
||||
assertEquals(expectedValues[0], returnedValues[0]);
|
||||
//month
|
||||
assertEquals(expectedValues[1], returnedValues[1]);
|
||||
//day of month
|
||||
assertEquals(expectedValues[2], returnedValues[2]);
|
||||
// hour
|
||||
assertEquals(expectedValues[3], returnedValues[3]);
|
||||
// minute
|
||||
assertEquals(expectedValues[4], returnedValues[4]);
|
||||
// second
|
||||
assertEquals(expectedValues[5], returnedValues[5]);
|
||||
|
||||
// test message decoding
|
||||
testPacket.handleMessage(createArray(50, (byte) 0));
|
||||
assertEquals(false, failed);
|
||||
// testPacket.handleMessage(createArray(50, (byte) 1));
|
||||
// assertEquals(true, done);
|
||||
|
||||
assertEquals("APS_HISTORY_EVENTS", getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public byte[] getCalender(long from){
|
||||
GregorianCalendar cal = new GregorianCalendar();
|
||||
if (from != 0)
|
||||
cal.setTimeInMillis(from);
|
||||
else
|
||||
cal.set(2000, 0, 1, 0, 0, 0);
|
||||
byte[] ret = new byte[6];
|
||||
ret[0] = (byte) ((cal.get(Calendar.YEAR) - 1900 - 100) & 0xff);
|
||||
ret[1] = (byte) ((cal.get(Calendar.MONTH) + 1) & 0xff);
|
||||
ret[2] = (byte) ((cal.get(Calendar.DAY_OF_MONTH)) & 0xff);
|
||||
ret[3] = (byte) ((cal.get(Calendar.HOUR_OF_DAY)) & 0xff);
|
||||
ret[4] = (byte) ((cal.get(Calendar.MINUTE)) & 0xff);
|
||||
ret[5] = (byte) ((cal.get(Calendar.SECOND)) & 0xff);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 31.07.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_APS_Set_Event_HistoryTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
|
||||
// test for negative carbs
|
||||
DanaRS_Packet_APS_Set_Event_History historyTest = new DanaRS_Packet_APS_Set_Event_History(DanaRPump.CARBS, System.currentTimeMillis(), -1, 0);
|
||||
byte[] testparams = historyTest.getRequestParams();
|
||||
assertEquals((byte) 0, testparams[8]);
|
||||
// 5g carbs
|
||||
historyTest = new DanaRS_Packet_APS_Set_Event_History(DanaRPump.CARBS, System.currentTimeMillis(), 5, 0);
|
||||
testparams = historyTest.getRequestParams();
|
||||
assertEquals((byte) 5, testparams[8]);
|
||||
// 150g carbs
|
||||
historyTest = new DanaRS_Packet_APS_Set_Event_History(DanaRPump.CARBS, System.currentTimeMillis(), 150, 0);
|
||||
testparams = historyTest.getRequestParams();
|
||||
assertEquals((byte) 150, testparams[8]);
|
||||
// test low hard limit
|
||||
// test high hard limit
|
||||
|
||||
// test message generation
|
||||
historyTest = new DanaRS_Packet_APS_Set_Event_History(DanaRPump.CARBS, System.currentTimeMillis(), 5, 0);
|
||||
testparams = historyTest.getRequestParams();
|
||||
assertEquals((byte) 5, testparams[8]);
|
||||
assertEquals(11 , testparams.length);
|
||||
assertEquals((byte)DanaRPump.CARBS, testparams[0]);
|
||||
|
||||
// test message decoding
|
||||
historyTest.handleMessage(new byte[]{(byte) 0, (byte) 0, (byte) 0});
|
||||
assertEquals(false, historyTest.failed);
|
||||
historyTest.handleMessage(new byte[]{(byte) 0, (byte) 0, (byte) 1});
|
||||
assertEquals(true, historyTest.failed);
|
||||
|
||||
assertEquals("APS_SET_EVENT_HISTORY", historyTest.getFriendlyName());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 01.08.2018
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Basal_Get_Basal_RateTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockBus();
|
||||
AAPSMocker.mockL();
|
||||
|
||||
DanaRS_Packet_Basal_Get_Basal_Rate packet = new DanaRS_Packet_Basal_Get_Basal_Rate();
|
||||
|
||||
// test message decoding
|
||||
// rate is 0.01
|
||||
packet.handleMessage(createArray(100, (byte) 1));
|
||||
assertEquals(false, packet.failed);
|
||||
packet.handleMessage(createArray(100, (byte) 5));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("BASAL__GET_BASAL_RATE", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 31.07.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Basal_Get_Profile_Basal_RateTest extends DanaRS_Packet_Basal_Get_Profile_Basal_Rate {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockBus();
|
||||
AAPSMocker.mockL();
|
||||
|
||||
// test if pumpRofile array is set right
|
||||
double basal01 = byteArrayToInt(getBytes(createArray(50, (byte) 1), 2, 2)) / 100d;
|
||||
double basal05 = byteArrayToInt(getBytes(createArray(50, (byte) 5), 2, 2)) / 100d;
|
||||
double basal12 = byteArrayToInt(getBytes(createArray(50, (byte) 12), 2, 2)) / 100d;
|
||||
// basal rate > 1U/hr
|
||||
double basal120 = byteArrayToInt(getBytes(createArray(50, (byte) 120), 2, 2)) / 100d;
|
||||
DanaRS_Packet_Basal_Get_Profile_Basal_Rate testPacket = new DanaRS_Packet_Basal_Get_Profile_Basal_Rate(1);
|
||||
byte[] params = testPacket.getRequestParams();
|
||||
assertEquals((byte) 1, params[0]);
|
||||
testPacket.handleMessage(createArray(50, (byte) 0));
|
||||
assertEquals(0.0d, testPacket.pump.pumpProfiles[1][1],0);
|
||||
testPacket.handleMessage(createArray(50, (byte) 1));
|
||||
assertEquals(basal01, testPacket.pump.pumpProfiles[1][2],0);
|
||||
testPacket.handleMessage(createArray(50, (byte) 5));
|
||||
assertEquals(basal05, testPacket.pump.pumpProfiles[1][1],0);
|
||||
testPacket.handleMessage(createArray(50, (byte) 12));
|
||||
assertEquals(basal12, testPacket.pump.pumpProfiles[1][1],0);
|
||||
testPacket.handleMessage(createArray(50, (byte) 120));
|
||||
assertEquals(basal120, testPacket.pump.pumpProfiles[1][1],0);
|
||||
|
||||
assertEquals("BASAL__GET_PROFILE_BASAL_RATE", getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 01.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Basal_Get_Profile_NumberTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
|
||||
DanaRS_Packet_Basal_Get_Profile_Number packet = new DanaRS_Packet_Basal_Get_Profile_Number();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(new byte[]{(byte) 0, (byte) 0, (byte) 0});
|
||||
assertEquals(false, packet.failed);
|
||||
// if data.length > 4 should return fail
|
||||
|
||||
assertEquals("BASAL__GET_PROFILE_NUMBER", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 01.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Basal_Get_Temporary_Basal_StateTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
|
||||
DanaRS_Packet_Basal_Get_Temporary_Basal_State packet = new DanaRS_Packet_Basal_Get_Temporary_Basal_State();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(50,(byte) 0));
|
||||
assertEquals(false, packet.failed);
|
||||
packet.handleMessage(createArray(50,(byte) 1));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("BASAL__TEMPORARY_BASAL_STATE", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith) {
|
||||
byte[] ret = new byte[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 01.08.2018
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Basal_Set_Basal_RateTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
|
||||
// test message decoding
|
||||
DanaRS_Packet_Basal_Set_Basal_Rate packet = new DanaRS_Packet_Basal_Set_Basal_Rate(createArray(24, 5));
|
||||
byte[] requested = packet.getRequestParams();
|
||||
byte lookingFor = (byte) ((5 * 100) & 0xff);
|
||||
assertEquals(lookingFor, requested[24]);
|
||||
lookingFor = (byte) ((500 >>> 8) & 0xff);
|
||||
assertEquals(lookingFor, requested[25]);
|
||||
packet.handleMessage(createArray(3, (byte) 0));
|
||||
assertEquals(false, packet.failed);
|
||||
packet.handleMessage(createArray(3, (byte) 1));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("BASAL__SET_BASAL_RATE", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith) {
|
||||
double[] ret = new double[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith) {
|
||||
byte[] ret = new byte[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 01.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Basal_Set_Cancel_Temporary_BasalTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
|
||||
DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal packet = new DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(3,(byte) 0));
|
||||
assertEquals(false, packet.failed);
|
||||
packet.handleMessage(createArray(3,(byte) 1));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("BASAL__CANCEL_TEMPORARY_BASAL", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith) {
|
||||
byte[] ret = new byte[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 06.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Basal_Set_Profile_Basal_RateTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_Basal_Set_Profile_Basal_Rate packet = new DanaRS_Packet_Basal_Set_Profile_Basal_Rate(1, createArray(24,1));
|
||||
|
||||
// test params
|
||||
byte[] testparams =packet.getRequestParams();
|
||||
// is profile 1
|
||||
assertEquals((byte) 1, testparams[0]);
|
||||
// is value 100
|
||||
assertEquals((byte) 100, testparams[3]);
|
||||
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(new byte[]{(byte) 0, (byte) 0, (byte) 0});
|
||||
assertEquals(false, packet.failed);
|
||||
packet.handleMessage(new byte[]{(byte) 0, (byte) 0, (byte) 1});
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("BASAL__SET_PROFILE_BASAL_RATE", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 06.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Basal_Set_Profile_NumberTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_Basal_Set_Profile_Number packet = new DanaRS_Packet_Basal_Set_Profile_Number(1);
|
||||
|
||||
// test params
|
||||
byte[] testparams = packet.getRequestParams();
|
||||
// is profile 1
|
||||
assertEquals((byte) 1, testparams[0]);
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(new byte[]{(byte) 0, (byte) 0, (byte) 0});
|
||||
assertEquals(false, packet.failed);
|
||||
packet.handleMessage(new byte[]{(byte) 0, (byte) 0, (byte) 1});
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("BASAL__SET_PROFILE_NUMBER", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 01.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Basal_Set_Suspend_OffTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
|
||||
DanaRS_Packet_Basal_Set_Suspend_Off packet = new DanaRS_Packet_Basal_Set_Suspend_Off();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(new byte[]{(byte) 0, (byte) 0, (byte) 0});
|
||||
assertEquals(false, packet.failed);
|
||||
packet.handleMessage(new byte[]{(byte) 0, (byte) 0, (byte) 1});
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("BASAL__SET_SUSPEND_OFF", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 01.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Basal_Set_Suspend_OnTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
|
||||
DanaRS_Packet_Basal_Set_Suspend_On packet = new DanaRS_Packet_Basal_Set_Suspend_On();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(new byte[]{(byte) 0, (byte) 0, (byte) 0});
|
||||
assertEquals(false, packet.failed);
|
||||
packet.handleMessage(new byte[]{(byte) 0, (byte) 0, (byte) 1});
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("BASAL__SET_SUSPEND_ON", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 02.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@SuppressStaticInitializationFor("info.nightscout.androidaps.logging.L")
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Basal_Set_Temporary_BasalTest extends DanaRS_Packet_Basal_Set_Temporary_Basal {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
|
||||
DanaRS_Packet_Basal_Set_Temporary_Basal testPacket = new DanaRS_Packet_Basal_Set_Temporary_Basal(50, 20);
|
||||
// params
|
||||
byte[] params = testPacket.getRequestParams();
|
||||
// is ratio 50
|
||||
assertEquals(50, params[0]);
|
||||
// is duration 20
|
||||
assertEquals(20, params[1]);
|
||||
|
||||
// test message decoding
|
||||
handleMessage(new byte[]{(byte) 0, (byte) 0, (byte) 0});
|
||||
assertEquals(false, failed);
|
||||
handleMessage(new byte[]{(byte) 0, (byte) 0, (byte) 1});
|
||||
assertEquals(true, failed);
|
||||
|
||||
assertEquals("BASAL__SET_TEMPORARY_BASAL", getFriendlyName());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 01.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Bolus_Get_Bolus_OptionTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
AAPSMocker.mockBus();
|
||||
|
||||
DanaRS_Packet_Bolus_Get_Bolus_Option packet = new DanaRS_Packet_Bolus_Get_Bolus_Option();
|
||||
|
||||
// test message decoding
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
//if dataArray is 1 pump.isExtendedBolusEnabled should be true
|
||||
packet.handleMessage(createArray(21,(byte) 1));
|
||||
assertEquals(false, packet.failed);
|
||||
//Are options saved to pump
|
||||
assertEquals(false, !pump.isExtendedBolusEnabled);
|
||||
assertEquals(1, pump.bolusCalculationOption);
|
||||
assertEquals(1, pump.missedBolusConfig);
|
||||
|
||||
packet.handleMessage(createArray(21,(byte) 0));
|
||||
assertEquals(true, packet.failed);
|
||||
//Are options saved to pump
|
||||
assertEquals(true, !pump.isExtendedBolusEnabled);
|
||||
|
||||
assertEquals("BOLUS__GET_BOLUS_OPTION", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith) {
|
||||
byte[] ret = new byte[length];
|
||||
for (int i = 0; i < length; i++) {
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 06.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Bolus_Get_CIR_CF_ArrayTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_Bolus_Get_CIR_CF_Array packet = new DanaRS_Packet_Bolus_Get_CIR_CF_Array();
|
||||
|
||||
// test params
|
||||
byte[] testparams = packet.getRequestParams();
|
||||
assertEquals(null, packet.getRequestParams());
|
||||
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 0));
|
||||
// are pump units MG/DL ???
|
||||
DanaRPump testPump = DanaRPump.getInstance();
|
||||
assertEquals(DanaRPump.UNITS_MGDL, testPump.units);
|
||||
assertEquals(false, packet.failed);
|
||||
packet.handleMessage(createArray(34, (byte) 3));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("BOLUS__GET_CIR_CF_ARRAY", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 06.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Bolus_Get_Calculation_InformationTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_Bolus_Get_Calculation_Information packet = new DanaRS_Packet_Bolus_Get_Calculation_Information();
|
||||
|
||||
// test params
|
||||
byte[] testparams = packet.getRequestParams();
|
||||
assertEquals(null, packet.getRequestParams());
|
||||
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(24, (byte) 0));
|
||||
assertEquals(false, packet.failed);
|
||||
packet.handleMessage(createArray(24, (byte) 1));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("BOLUS__GET_CALCULATION_INFORMATION", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 06.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_InformationTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information packet = new DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information();
|
||||
|
||||
// test params
|
||||
byte[] testparams = packet.getRequestParams();
|
||||
assertEquals(null, packet.getRequestParams());
|
||||
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(24, (byte) 0));
|
||||
assertEquals(false, packet.failed);
|
||||
packet.handleMessage(createArray(24, (byte) 1));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("BOLUS__GET_CARBOHYDRATE_CALCULATION_INFORMATION", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 06.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Bolus_Get_Dual_BolusTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_Bolus_Get_Dual_Bolus packet = new DanaRS_Packet_Bolus_Get_Dual_Bolus();
|
||||
|
||||
// test params
|
||||
assertEquals(null, packet.getRequestParams());
|
||||
|
||||
// test message decoding
|
||||
double testValue = 0d;
|
||||
packet.handleMessage(createArray(10, (byte) testValue));
|
||||
assertEquals(testValue != 0d, packet.failed);
|
||||
testValue = 1d;
|
||||
packet.handleMessage(createArray(10, (byte) testValue));
|
||||
// is pump.bolustep set to 1
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
assertEquals((((byte)testValue & 0x000000FF) << 8) + ((byte) testValue & 0x000000FF), pump.bolusStep, 0);
|
||||
assertEquals(testValue != 0d, packet.failed);
|
||||
|
||||
assertEquals("BOLUS__GET_DUAL_BOLUS", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 06.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Bolus_Get_Extended_BolusTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_Bolus_Get_Extended_Bolus packet = new DanaRS_Packet_Bolus_Get_Extended_Bolus();
|
||||
|
||||
// test params
|
||||
assertEquals(null, packet.getRequestParams());
|
||||
|
||||
// test message decoding
|
||||
double testValue = 0d;
|
||||
packet.handleMessage(createArray(10, (byte) testValue));
|
||||
assertEquals(testValue != 0d, packet.failed);
|
||||
testValue = 1d;
|
||||
packet.handleMessage(createArray(10, (byte) testValue));
|
||||
// is pump.bolustep set to 1
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
assertEquals(testValue / 100d, pump.bolusStep, 0);
|
||||
assertEquals(testValue != 0d, packet.failed);
|
||||
|
||||
assertEquals("BOLUS__GET_EXTENDED_BOLUS", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 06.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Bolus_Get_Extended_Bolus_StateTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_Bolus_Get_Extended_Bolus_State packet = new DanaRS_Packet_Bolus_Get_Extended_Bolus_State();
|
||||
|
||||
// test params
|
||||
assertEquals(null, packet.getRequestParams());
|
||||
|
||||
// test message decoding
|
||||
double testValue = 0d;
|
||||
packet.handleMessage(createArray(11, (byte) testValue));
|
||||
assertEquals(testValue != 0d, packet.failed);
|
||||
testValue = 1d;
|
||||
packet.handleMessage(createArray(11, (byte) testValue));
|
||||
// is extended bolus in progress
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
assertEquals(testValue == 1, pump.isExtendedInProgress);
|
||||
assertEquals(testValue != 0d, packet.failed);
|
||||
|
||||
assertEquals("BOLUS__GET_EXTENDED_BOLUS_STATE", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 06.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Bolus_Get_Extended_Menu_Option_StateTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State packet = new DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State();
|
||||
|
||||
// test params
|
||||
byte[] testparams = packet.getRequestParams();
|
||||
assertEquals(null, packet.getRequestParams());
|
||||
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 0));
|
||||
// isExtendedinprogres should be false
|
||||
DanaRPump testPump = DanaRPump.getInstance();
|
||||
assertEquals(false, testPump.isExtendedInProgress);
|
||||
// assertEquals(false, packet.failed);
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
testPump = DanaRPump.getInstance();
|
||||
assertEquals(true, testPump.isExtendedInProgress);
|
||||
|
||||
assertEquals("BOLUS__GET_EXTENDED_MENU_OPTION_STATE", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 06.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Bolus_Get_Initial_BolusTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_Bolus_Get_Initial_Bolus packet = new DanaRS_Packet_Bolus_Get_Initial_Bolus();
|
||||
|
||||
// test params
|
||||
byte[] testparams = packet.getRequestParams();
|
||||
assertEquals(null, packet.getRequestParams());
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 0));
|
||||
// should fail only if all the initialbolusses are 0
|
||||
// DanaRPump testPump = DanaRPump.getInstance();
|
||||
assertEquals(false, !packet.failed);
|
||||
// assertEquals(false, packet.failed);
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
int valueRequested = (((byte) 1 & 0x000000FF) << 8) + (((byte) 1) & 0x000000FF);
|
||||
assertEquals(valueRequested /100d, packet.initialBolusValue04, 0);
|
||||
assertEquals(true, !packet.failed);
|
||||
|
||||
assertEquals("BOLUS__GET_BOLUS_RATE", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 06.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Bolus_Get_Step_Bolus_InformationTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_Bolus_Get_Step_Bolus_Information packet = new DanaRS_Packet_Bolus_Get_Step_Bolus_Information();
|
||||
|
||||
// test params
|
||||
byte[] testparams = packet.getRequestParams();
|
||||
assertEquals(null, packet.getRequestParams());
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 0));
|
||||
DanaRPump testPump = DanaRPump.getInstance();
|
||||
assertEquals(false, packet.failed);
|
||||
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
int valueRequested = (((byte) 1 & 0x000000FF) << 8) + (((byte) 1) & 0x000000FF);
|
||||
assertEquals(valueRequested /100d, testPump.lastBolusAmount, 0);
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("BOLUS__GET_STEP_BOLUS_INFORMATION", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 06.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Bolus_Set_Bolus_OptionTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_Bolus_Set_Bolus_Option packet = new DanaRS_Packet_Bolus_Set_Bolus_Option(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
|
||||
|
||||
// test params
|
||||
byte[] testparams = packet.getRequestParams();
|
||||
assertEquals(0, testparams[0]);
|
||||
assertEquals(0, testparams[18]);
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 0));
|
||||
// DanaRPump testPump = DanaRPump.getInstance();
|
||||
assertEquals(false, packet.failed);
|
||||
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
// int valueRequested = (((byte) 1 & 0x000000FF) << 8) + (((byte) 1) & 0x000000FF);
|
||||
// assertEquals(valueRequested /100d, testPump.lastBolusAmount, 0);
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("BOLUS__SET_BOLUS_OPTION", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 06.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Bolus_Set_CIR_CF_ArrayTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_Bolus_Set_CIR_CF_Array packet = new DanaRS_Packet_Bolus_Set_CIR_CF_Array(0,0,0,0,0,0,0,0,0,0,0,0,0,0);
|
||||
|
||||
// test params
|
||||
byte[] testparams = packet.getRequestParams();
|
||||
assertEquals(0, testparams[0]);
|
||||
assertEquals(0, testparams[18]);
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 0));
|
||||
// DanaRPump testPump = DanaRPump.getInstance();
|
||||
assertEquals(false, packet.failed);
|
||||
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
// int valueRequested = (((byte) 1 & 0x000000FF) << 8) + (((byte) 1) & 0x000000FF);
|
||||
// assertEquals(valueRequested /100d, testPump.lastBolusAmount, 0);
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("BOLUS__SET_CIR_CF_ARRAY", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 06.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Bolus_Set_Dual_BolusTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_Bolus_Set_Dual_Bolus packet = new DanaRS_Packet_Bolus_Set_Dual_Bolus(0d, 0d, 1);
|
||||
|
||||
// test params
|
||||
byte[] testparams = packet.getRequestParams();
|
||||
assertEquals(0, testparams[0]);
|
||||
assertEquals(1, testparams[4]);
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 0));
|
||||
// DanaRPump testPump = DanaRPump.getInstance();
|
||||
assertEquals(false, packet.failed);
|
||||
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
// int valueRequested = (((byte) 1 & 0x000000FF) << 8) + (((byte) 1) & 0x000000FF);
|
||||
// assertEquals(valueRequested /100d, testPump.lastBolusAmount, 0);
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("BOLUS__SET_DUAL_BOLUS", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 06.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Bolus_Set_Extended_BolusTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_Bolus_Set_Extended_Bolus packet = new DanaRS_Packet_Bolus_Set_Extended_Bolus(1d, 1);
|
||||
|
||||
// test params
|
||||
byte[] testparams = packet.getRequestParams();
|
||||
assertEquals(100, testparams[0]);
|
||||
assertEquals(1, testparams[2]);
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 0));
|
||||
// DanaRPump testPump = DanaRPump.getInstance();
|
||||
assertEquals(false, packet.failed);
|
||||
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
// int valueRequested = (((byte) 1 & 0x000000FF) << 8) + (((byte) 1) & 0x000000FF);
|
||||
// assertEquals(valueRequested /100d, testPump.lastBolusAmount, 0);
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("BOLUS__SET_EXTENDED_BOLUS", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 06.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Bolus_Set_Extended_Bolus_CancelTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel packet = new DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel();
|
||||
|
||||
// test params
|
||||
byte[] testparams = packet.getRequestParams();
|
||||
assertEquals(null, packet.getRequestParams());
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 0));
|
||||
// DanaRPump testPump = DanaRPump.getInstance();
|
||||
assertEquals(false, packet.failed);
|
||||
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
// int valueRequested = (((byte) 1 & 0x000000FF) << 8) + (((byte) 1) & 0x000000FF);
|
||||
// assertEquals(valueRequested /100d, testPump.lastBolusAmount, 0);
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("BOLUS__SET_EXTENDED_BOLUS_CANCEL", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 06.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Bolus_Set_Initial_BolusTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_Bolus_Set_Initial_Bolus packet = new DanaRS_Packet_Bolus_Set_Initial_Bolus(0d, 0d, 0d, 100d);
|
||||
|
||||
// test params
|
||||
byte[] testparams = packet.getRequestParams();
|
||||
assertEquals(0, testparams[0]);
|
||||
assertEquals(1, testparams[6]);
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 0));
|
||||
assertEquals(false, packet.failed);
|
||||
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("BOLUS__SET_BOLUS_RATE", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 31.07.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Bolus_Set_Step_Bolus_StartTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
|
||||
DanaRS_Packet_Bolus_Set_Step_Bolus_Start packet = new DanaRS_Packet_Bolus_Set_Step_Bolus_Start();
|
||||
|
||||
// test params
|
||||
byte[] testparams = packet.getRequestParams();
|
||||
assertEquals(0, testparams[0]);
|
||||
assertEquals(0, testparams[2]);
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(new byte[]{(byte) 0, (byte) 0, (byte) 0});
|
||||
assertEquals(false, packet.failed);
|
||||
packet.handleMessage(new byte[]{(byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 1});
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("BOLUS__SET_STEP_BOLUS_START", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 31.07.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Bolus_Set_Step_Bolus_StopTest extends DanaRS_Packet_Bolus_Set_Step_Bolus_Stop {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockBus();
|
||||
AAPSMocker.mockL();
|
||||
|
||||
DanaRS_Packet_Bolus_Set_Step_Bolus_Stop testPacket = new DanaRS_Packet_Bolus_Set_Step_Bolus_Stop(1d , new Treatment());
|
||||
// test message decoding
|
||||
testPacket.handleMessage(new byte[]{(byte) 0, (byte) 0, (byte) 0});
|
||||
assertEquals(false, testPacket.failed);
|
||||
testPacket.handleMessage(new byte[]{(byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 1});
|
||||
assertEquals(true, testPacket.failed);
|
||||
|
||||
assertEquals("BOLUS__SET_STEP_BOLUS_STOP", getFriendlyName());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 06.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Etc_Keep_ConnectionTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
|
||||
DanaRS_Packet_Etc_Keep_Connection packet = new DanaRS_Packet_Etc_Keep_Connection();
|
||||
|
||||
|
||||
// test params
|
||||
byte[] testparams = packet.getRequestParams();
|
||||
assertEquals(null, packet.getRequestParams());
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(new byte[]{(byte) 0, (byte) 0, (byte) 0});
|
||||
assertEquals(false, packet.failed);
|
||||
packet.handleMessage(new byte[]{(byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 1});
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("ETC__KEEP_CONNECTION", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 08.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_Etc_Set_History_SaveTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_Etc_Set_History_Save packet = new DanaRS_Packet_Etc_Set_History_Save(0,0,0,0,0,0,0,0,2);
|
||||
|
||||
// test params
|
||||
byte[] testparams = packet.getRequestParams();
|
||||
assertEquals(2, testparams[8]);
|
||||
assertEquals((byte) (2 >>> 8), testparams[9]);
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 0));
|
||||
assertEquals(false, packet.failed);
|
||||
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("ETC__SET_HISTORY_SAVE", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 08.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_General_Delivery_StatusTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_General_Delivery_Status packet = new DanaRS_Packet_General_Delivery_Status();
|
||||
|
||||
// test params
|
||||
byte[] testparams = packet.getRequestParams();
|
||||
assertEquals(null, packet.getRequestParams());
|
||||
|
||||
// test message decoding
|
||||
// everything ok :)
|
||||
packet.handleMessage(createArray(15, (byte) 0));
|
||||
assertEquals(false, packet.failed);
|
||||
|
||||
packet.handleMessage(createArray(15, (byte) 161));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("REVIEW__DELIVERY_STATUS", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 08.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_General_Get_More_InformationTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_General_Get_More_Information packet = new DanaRS_Packet_General_Get_More_Information();
|
||||
|
||||
// test params
|
||||
byte[] testparams = packet.getRequestParams();
|
||||
assertEquals(null, packet.getRequestParams());
|
||||
|
||||
// test message decoding
|
||||
// test for the length message
|
||||
packet.handleMessage(createArray(13, (byte) 0));
|
||||
assertEquals(true, packet.failed);
|
||||
// everything ok :)
|
||||
packet = new DanaRS_Packet_General_Get_More_Information();
|
||||
packet.handleMessage(createArray(15, (byte) 0));
|
||||
assertEquals(false, packet.failed);
|
||||
|
||||
packet.handleMessage(createArray(15, (byte) 161));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("REVIEW__GET_MORE_INFORMATION", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 08.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_General_Get_PasswordTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_General_Get_Password packet = new DanaRS_Packet_General_Get_Password();
|
||||
|
||||
// test params
|
||||
byte[] testparams = packet.getRequestParams();
|
||||
assertEquals(null, packet.getRequestParams());
|
||||
|
||||
// test message decoding
|
||||
// test for the length message
|
||||
packet.handleMessage(createArray(1, (byte) 0));
|
||||
assertEquals(true, packet.failed);
|
||||
// everything ok :)
|
||||
packet = new DanaRS_Packet_General_Get_Password();
|
||||
packet.handleMessage(createArray(15, (byte) 0));
|
||||
assertEquals(false, packet.failed);
|
||||
|
||||
// packet.handleMessage(createArray(15, (byte) 161));
|
||||
// assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("REVIEW__GET_PASSWORD", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 08.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_General_Get_Pump_CheckTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
AAPSMocker.mockBus();
|
||||
DanaRS_Packet_General_Get_Pump_Check packet = new DanaRS_Packet_General_Get_Pump_Check();
|
||||
|
||||
// test params
|
||||
byte[] testparams = packet.getRequestParams();
|
||||
assertEquals(null, packet.getRequestParams());
|
||||
|
||||
// test message decoding
|
||||
// test for the length message
|
||||
packet.handleMessage(createArray(1, (byte) 0));
|
||||
assertEquals(true, packet.failed);
|
||||
// everything ok :)
|
||||
packet = new DanaRS_Packet_General_Get_Pump_Check();
|
||||
packet.handleMessage(createArray(15, (byte) 0));
|
||||
assertEquals(false, packet.failed);
|
||||
|
||||
// packet.handleMessage(createArray(15, (byte) 161));
|
||||
// assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("REVIEW__GET_PUMP_CHECK", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 08.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_General_Get_Shipping_InformationTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_General_Get_Shipping_Information packet = new DanaRS_Packet_General_Get_Shipping_Information();
|
||||
|
||||
// test params
|
||||
byte[] testparams = packet.getRequestParams();
|
||||
assertEquals(null, packet.getRequestParams());
|
||||
|
||||
// test message decoding
|
||||
// test for the length message
|
||||
packet.handleMessage(createArray(1, (byte) 0));
|
||||
assertEquals(true, packet.failed);
|
||||
// everything ok :)
|
||||
packet = new DanaRS_Packet_General_Get_Shipping_Information();
|
||||
packet.handleMessage(createArray(18, (byte) 0));
|
||||
assertEquals(false, packet.failed);
|
||||
|
||||
// packet.handleMessage(createArray(15, (byte) 161));
|
||||
// assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("REVIEW__GET_SHIPPING_INFORMATION", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 08.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_General_Get_Today_Delivery_TotalTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_General_Get_Today_Delivery_Total packet = new DanaRS_Packet_General_Get_Today_Delivery_Total();
|
||||
|
||||
// test params
|
||||
byte[] testparams = packet.getRequestParams();
|
||||
assertEquals(null, packet.getRequestParams());
|
||||
|
||||
// test message decoding
|
||||
// test for the length message
|
||||
packet.handleMessage(createArray(1, (byte) 0));
|
||||
assertEquals(true, packet.failed);
|
||||
// everything ok :)
|
||||
packet = new DanaRS_Packet_General_Get_Today_Delivery_Total();
|
||||
packet.handleMessage(createArray(18, (byte) 0));
|
||||
assertEquals(false, packet.failed);
|
||||
|
||||
packet.handleMessage(createArray(15, (byte) 1));
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
assertEquals( (((1 & 0x000000FF) << 8) + (1 & 0x000000FF)) /100d, pump.dailyTotalUnits,0);
|
||||
|
||||
assertEquals("REVIEW__GET_TODAY_DELIVERY_TOTAL", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 08.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_General_Get_User_Time_Change_FlagTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_General_Get_User_Time_Change_Flag packet = new DanaRS_Packet_General_Get_User_Time_Change_Flag();
|
||||
|
||||
// test params
|
||||
byte[] testparams = packet.getRequestParams();
|
||||
assertEquals(null, packet.getRequestParams());
|
||||
|
||||
// test message decoding
|
||||
// test for the length message
|
||||
packet.handleMessage(createArray(1, (byte) 0));
|
||||
assertEquals(true, packet.failed);
|
||||
// everything ok :)
|
||||
packet = new DanaRS_Packet_General_Get_User_Time_Change_Flag();
|
||||
packet.handleMessage(createArray(18, (byte) 0));
|
||||
assertEquals(false, packet.failed);
|
||||
|
||||
assertEquals("REVIEW__GET_USER_TIME_CHANGE_FLAG", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 08.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_General_Initial_Screen_InformationTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_General_Initial_Screen_Information packet = new DanaRS_Packet_General_Initial_Screen_Information();
|
||||
|
||||
// test params
|
||||
byte[] testparams = packet.getRequestParams();
|
||||
assertEquals(null, packet.getRequestParams());
|
||||
|
||||
// test message decoding
|
||||
// test for the length message
|
||||
packet.handleMessage(createArray(1, (byte) 0));
|
||||
assertEquals(true, packet.failed);
|
||||
// everything ok :)
|
||||
packet = new DanaRS_Packet_General_Initial_Screen_Information();
|
||||
packet.handleMessage(createArray(17, (byte) 1));
|
||||
assertEquals(false, packet.failed);
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
assertEquals(true, pump.pumpSuspended);
|
||||
|
||||
|
||||
assertEquals("REVIEW__INITIAL_SCREEN_INFORMATION", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 08.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_General_Set_History_Upload_ModeTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_General_Set_History_Upload_Mode packet = new DanaRS_Packet_General_Set_History_Upload_Mode(1);
|
||||
|
||||
// test params
|
||||
assertEquals(1, packet.getRequestParams()[0]);
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(3, (byte) 0));
|
||||
assertEquals(false, packet.failed);
|
||||
// everything ok :)
|
||||
packet.handleMessage(createArray(17, (byte) 1));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("REVIEW__SET_HISTORY_UPLOAD_MODE", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 08.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_General_Set_User_Time_Change_Flag_ClearTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear packet = new DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear();
|
||||
|
||||
// test params
|
||||
assertEquals(null, packet.getRequestParams());
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(3, (byte) 0));
|
||||
assertEquals(false, packet.failed);
|
||||
// everything ok :)
|
||||
packet.handleMessage(createArray(17, (byte) 1));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
assertEquals("REVIEW__SET_USER_TIME_CHANGE_FLAG_CLEAR", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
byte[] createArray(int length, byte fillWith){
|
||||
byte[] ret = new byte[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
double[] createArray(int length, double fillWith){
|
||||
double[] ret = new double[length];
|
||||
for(int i = 0; i<length; i++){
|
||||
ret[i] = fillWith;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 09.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_History_AlarmTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_History_Alarm packet = new DanaRS_Packet_History_Alarm(new Date(System.currentTimeMillis()));
|
||||
|
||||
assertEquals("REVIEW__ALARM", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 09.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_History_All_HistoryTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_History_All_History packet = new DanaRS_Packet_History_All_History(new Date(System.currentTimeMillis()));
|
||||
|
||||
assertEquals("REVIEW__ALL_HISTORY", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaRS.comm;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.AAPSMocker;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Created by Rumen on 09.08.2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class DanaRS_Packet_History_BasalTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
DanaRS_Packet_History_Basal packet = new DanaRS_Packet_History_Basal(new Date(System.currentTimeMillis()));
|
||||
|
||||
assertEquals("REVIEW__BASAL", packet.getFriendlyName());
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue