DanaR.comm tests
This commit is contained in:
parent
3260bbfdfd
commit
3a078c4084
|
@ -48,6 +48,7 @@ public class MsgError extends MessageBase {
|
|||
MsgBolusStop.stopped = true;
|
||||
bolusingEvent.status = errorString;
|
||||
MainApp.bus().post(bolusingEvent);
|
||||
failed=true;
|
||||
}
|
||||
if (L.isEnabled(L.PUMPCOMM))
|
||||
log.debug("Error detected: " + errorString);
|
||||
|
|
|
@ -141,6 +141,9 @@ public class MsgHistoryAll extends MessageBase {
|
|||
strRecordValue = "On";
|
||||
danaRHistoryRecord.stringRecordValue = strRecordValue;
|
||||
break;
|
||||
case 17:
|
||||
failed = true;
|
||||
break;
|
||||
}
|
||||
|
||||
MainApp.getDbHelper().createOrUpdate(danaRHistoryRecord);
|
||||
|
|
|
@ -26,6 +26,7 @@ public class MsgInitConnStatusBolus extends MessageBase {
|
|||
@Override
|
||||
public void handleMessage(byte[] bytes) {
|
||||
if (bytes.length - 10 > 12) {
|
||||
failed = true;
|
||||
return;
|
||||
}
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
|
|
|
@ -39,6 +39,8 @@ public class MsgInitConnStatusOption extends MessageBase {
|
|||
DanaRPump.getInstance().password = intFromBuff(bytes, 9, 2) ^ 0x3463;
|
||||
if (L.isEnabled(L.PUMPCOMM))
|
||||
log.debug("Pump password: " + DanaRPump.getInstance().password);
|
||||
} else {
|
||||
failed = true;
|
||||
}
|
||||
|
||||
if (!DanaRPump.getInstance().isPasswordOK()) {
|
||||
|
@ -49,7 +51,8 @@ public class MsgInitConnStatusOption extends MessageBase {
|
|||
}
|
||||
|
||||
// This is last message of initial sequence
|
||||
ConfigBuilderPlugin.getPlugin().getActivePump().finishHandshaking();
|
||||
if (ConfigBuilderPlugin.getPlugin().getActivePump() != null )
|
||||
ConfigBuilderPlugin.getPlugin().getActivePump().finishHandshaking();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -50,7 +50,10 @@ public class MsgInitConnStatusTime extends MessageBase {
|
|||
MainApp.getConfigBuilder().storeSettings("ChangingDanaDriver");
|
||||
MainApp.bus().post(new EventRefreshGui());
|
||||
ConfigBuilderPlugin.getCommandQueue().readStatus("PumpDriverChange", null); // force new connection
|
||||
failed = false;
|
||||
return;
|
||||
} else {
|
||||
failed = true;
|
||||
}
|
||||
|
||||
long time = dateTimeSecFromBuff(bytes, 0);
|
||||
|
|
|
@ -22,9 +22,12 @@ public class MsgSetExtendedBolusStart extends MessageBase {
|
|||
// HARDCODED LIMITS
|
||||
if (halfhours < 1) halfhours = 1;
|
||||
if (halfhours > 16) halfhours = 16;
|
||||
amount = MainApp.getConstraintChecker().applyExtendedBolusConstraints(new Constraint<>(amount)).value();
|
||||
|
||||
AddParamInt((int) (amount * 100));
|
||||
Constraint<Double> constrainedAmount = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(amount));
|
||||
if (constrainedAmount != null) {
|
||||
AddParamInt((int) (constrainedAmount.value() * 100));
|
||||
} else {
|
||||
log.debug("constrainedAmount of insulin is null!!");
|
||||
}
|
||||
AddParamByte(halfhours);
|
||||
if (L.isEnabled(L.PUMPCOMM))
|
||||
log.debug("Set extended bolus start: " + (((int) (amount * 100)) / 100d) + "U halfhours: " + (int) halfhours);
|
||||
|
|
|
@ -26,6 +26,9 @@ public class MsgSetTime extends MessageBase {
|
|||
|
||||
public void handleMessage(byte[] bytes) {
|
||||
int result = intFromBuff(bytes, 0, 1);
|
||||
if (result != 1) {
|
||||
failed = true;
|
||||
}
|
||||
|
||||
if (L.isEnabled(L.PUMPCOMM))
|
||||
log.debug("Result of setting time: " + time + " is " + result);
|
||||
|
|
|
@ -53,17 +53,26 @@ public class MsgSettingBasalProfileAll extends MessageBase {
|
|||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
if (pump.basal48Enable) {
|
||||
for (int profile = 0; profile < 4; profile++) {
|
||||
for (int index = 0; index < 24; index++) {
|
||||
log.debug("Basal profile " + profile + ": " + String.format("%02d", index) + "h: " + pump.pumpProfiles[profile][index]);
|
||||
for (int index = 0; index < 48; index++) {
|
||||
try {
|
||||
log.debug("Basal profile " + profile + ": " + String.format("%02d", index) + "h: " + pump.pumpProfiles[profile][index]);
|
||||
} catch (Exception e){
|
||||
log.error("Unhandled exception" , e);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int profile = 0; profile < 4; profile++) {
|
||||
for (int index = 0; index < 48; index++) {
|
||||
log.debug("Basal profile " + profile + ": " +
|
||||
String.format("%02d", (index / 2)) +
|
||||
":" + String.format("%02d", (index % 2) * 30) + " : " +
|
||||
pump.pumpProfiles[profile][index]);
|
||||
for (int index = 0; index < 24; index++) {
|
||||
//this is absurd pump.pumpProfiles[profile][index] returns nullPointerException
|
||||
try {
|
||||
log.debug("Basal profile " + profile + ": " +
|
||||
String.format("%02d", (index / 2)) +
|
||||
":" + String.format("%02d", (index % 2) * 30) + " : " +
|
||||
pump.pumpProfiles[profile][index]);
|
||||
} catch (Exception e){
|
||||
log.error("Unhandled exception" , e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,10 @@ import android.support.annotation.NonNull;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||
import info.nightscout.androidaps.db.Source;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
|
@ -46,7 +48,6 @@ public class MsgStatusBolusExtended extends MessageBase {
|
|||
pump.extendedBolusAbsoluteRate = extendedBolusAbsoluteRate;
|
||||
pump.extendedBolusStart = extendedBolusStart;
|
||||
pump.extendedBolusRemainingMinutes = extendedBolusRemainingMinutes;
|
||||
|
||||
updateExtendedBolusInDB();
|
||||
|
||||
if (L.isEnabled(L.PUMPCOMM)) {
|
||||
|
|
|
@ -2,6 +2,7 @@ package info;
|
|||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
|
||||
import com.squareup.otto.Bus;
|
||||
|
||||
|
@ -25,6 +26,8 @@ import info.nightscout.androidaps.plugins.ConfigBuilder.ProfileFunctions;
|
|||
import info.nightscout.androidaps.plugins.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentService;
|
||||
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
||||
import info.nightscout.androidaps.queue.CommandQueue;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
|
@ -103,6 +106,7 @@ public class AAPSMocker {
|
|||
PowerMockito.mockStatic(MainApp.class);
|
||||
MainApp mainApp = mock(MainApp.class);
|
||||
when(MainApp.instance()).thenReturn(mainApp);
|
||||
|
||||
return mainApp;
|
||||
}
|
||||
|
||||
|
@ -135,13 +139,15 @@ public class AAPSMocker {
|
|||
when(L.isEnabled(any())).thenReturn(true);
|
||||
}
|
||||
|
||||
public static void mockNSUpload() {
|
||||
public static void mockNSUpload(){
|
||||
PowerMockito.mockStatic(NSUpload.class);
|
||||
}
|
||||
|
||||
public static void mockApplicationContext() {
|
||||
Context context = mock(Context.class);
|
||||
when(MainApp.instance().getApplicationContext()).thenReturn(context);
|
||||
Context mockedContext = mock(Context.class);
|
||||
Resources mResources = mock(Resources.class);
|
||||
when(MainApp.instance().getApplicationContext()).thenReturn(mockedContext);
|
||||
when(mockedContext.getResources()).thenReturn(mResources);
|
||||
}
|
||||
|
||||
public static DatabaseHelper mockDatabaseHelper() {
|
||||
|
@ -167,6 +173,15 @@ public class AAPSMocker {
|
|||
PowerMockito.whenNew(TreatmentService.class).withNoArguments().thenReturn(treatmentService);
|
||||
}
|
||||
|
||||
public static DanaRPlugin mockDanaRPlugin() {
|
||||
PowerMockito.mockStatic(DanaRPlugin.class);
|
||||
DanaRPlugin danaRPlugin = mock(DanaRPlugin.class);
|
||||
DanaRKoreanPlugin danaRKoreanPlugin = mock(DanaRKoreanPlugin.class);
|
||||
when(MainApp.getSpecificPlugin(DanaRPlugin.class)).thenReturn(danaRPlugin);
|
||||
when(MainApp.getSpecificPlugin(DanaRKoreanPlugin.class)).thenReturn(danaRKoreanPlugin);
|
||||
return danaRPlugin;
|
||||
}
|
||||
|
||||
public static Profile getValidProfile() {
|
||||
try {
|
||||
if (profile == null)
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/31/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MessageHashTableTest {
|
||||
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MessageHashTable messageHashTable = new MessageHashTable();
|
||||
MessageBase testMessage = messageHashTable.findMessage(0x41f2);
|
||||
assertEquals("CMD_HISTORY_ALL", testMessage.getMessageName());
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/28/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MessageOriginalNamesTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
MessageOriginalNames packet = new MessageOriginalNames();
|
||||
String testName = packet.getName(0x41f2);
|
||||
assertEquals("CMD_HISTORY_ALL", testName);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.PumpDanaRS.comm.DanaRS_Packet_Bolus_Set_Extended_Bolus;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/28/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgBolusProgressTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
AAPSMocker.mockStrings();
|
||||
AAPSMocker.mockBus();
|
||||
Treatment t = new Treatment();
|
||||
MsgBolusProgress packet = new MsgBolusProgress(3D, t);
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
|
||||
int valueRequested = (((byte) 1 << 8) + ((byte) 1 + 0));
|
||||
assertEquals(valueRequested, packet.progress,0d);
|
||||
|
||||
}
|
||||
|
||||
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,55 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/28/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgBolusStartTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgBolusStart packet = new MsgBolusStart();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
assertEquals(true, packet.failed);
|
||||
packet = new MsgBolusStart();
|
||||
packet.handleMessage(createArray(34, (byte) 2));
|
||||
assertEquals(false, packet.failed);
|
||||
}
|
||||
|
||||
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,55 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/28/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgBolusStartWithSpeedTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgBolusStartWithSpeed packet = new MsgBolusStartWithSpeed();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
assertEquals(true, packet.failed);
|
||||
packet = new MsgBolusStartWithSpeed();
|
||||
packet.handleMessage(createArray(34, (byte) 2));
|
||||
assertEquals(false, packet.failed);
|
||||
}
|
||||
|
||||
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,54 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/28/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgBolusStopTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
AAPSMocker.mockBus();
|
||||
Treatment t = new Treatment();
|
||||
MsgBolusStop packet = new MsgBolusStop(1d,t);
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
assertEquals(true, packet.stopped);
|
||||
}
|
||||
|
||||
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,58 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.androidaps.plugins.PumpDanaR.DanaRPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/28/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class, DanaRPlugin.class})
|
||||
public class MsgCheckValueTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
AAPSMocker.mockBus();
|
||||
Treatment t = new Treatment();
|
||||
MsgCheckValue packet = new MsgCheckValue();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 3));
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
assertEquals(DanaRPump.EXPORT_MODEL, pump.model);
|
||||
}
|
||||
|
||||
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.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/28/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class, NSUpload.class})
|
||||
public class MsgErrorTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
AAPSMocker.mockBus();
|
||||
AAPSMocker.mockNSUpload();
|
||||
MsgError packet = new MsgError();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
assertEquals(true, packet.failed);
|
||||
// bigger than 8 - no error
|
||||
packet = new MsgError();
|
||||
packet.handleMessage(createArray(34, (byte) 10));
|
||||
assertEquals(false, packet.failed);
|
||||
|
||||
}
|
||||
|
||||
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,35 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class, NSUpload.class})
|
||||
public class MsgHistoryAlarmTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgHistoryAlarm packet = new MsgHistoryAlarm();
|
||||
// nothing left to test
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class, NSUpload.class})
|
||||
public class MsgHistoryAllDoneTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgHistoryAllDone packet = new MsgHistoryAllDone();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
assertEquals(true, packet.received);
|
||||
|
||||
}
|
||||
|
||||
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,59 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class, NSUpload.class})
|
||||
public class MsgHistoryAllTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
AAPSMocker.mockBus();
|
||||
AAPSMocker.mockDatabaseHelper();
|
||||
MsgHistoryAll packet = new MsgHistoryAll();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
assertEquals(false, packet.failed);
|
||||
// passing an bigger number
|
||||
packet.handleMessage(createArray(34, (byte) 17));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
}
|
||||
|
||||
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,35 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class, NSUpload.class})
|
||||
public class MsgHistoryBasalHourTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgHistoryBasalHour packet = new MsgHistoryBasalHour();
|
||||
// nothing left to test
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class, NSUpload.class})
|
||||
public class MsgHistoryBolusTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgHistoryBolus packet = new MsgHistoryBolus();
|
||||
// nothing left to test
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class, NSUpload.class})
|
||||
public class MsgHistoryCarboTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgHistoryCarbo packet = new MsgHistoryCarbo();
|
||||
// nothing left to test
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class, NSUpload.class})
|
||||
public class MsgHistoryDailyInsulinTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgHistoryDailyInsulin packet = new MsgHistoryDailyInsulin();
|
||||
// nothing left to test
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class, NSUpload.class})
|
||||
public class MsgHistoryDoneTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgHistoryDone packet = new MsgHistoryDone();
|
||||
// nothing left to test
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class, NSUpload.class})
|
||||
public class MsgHistoryErrorTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgHistoryError packet = new MsgHistoryError();
|
||||
// nothing left to test
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class, NSUpload.class})
|
||||
public class MsgHistoryGlucoseTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgHistoryGlucose packet = new MsgHistoryGlucose();
|
||||
// nothing left to test
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class, NSUpload.class})
|
||||
public class MsgHistoryNewDoneTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgHistoryNewDone packet = new MsgHistoryNewDone();
|
||||
// nothing left to test
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class, NSUpload.class})
|
||||
public class MsgHistoryNewTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgHistoryNew packet = new MsgHistoryNew();
|
||||
// nothing left to test
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class, NSUpload.class})
|
||||
public class MsgHistoryRefillTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgHistoryRefill packet = new MsgHistoryRefill();
|
||||
// nothing left to test
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class, NSUpload.class})
|
||||
public class MsgHistorySuspendTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgHistorySuspend packet = new MsgHistorySuspend();
|
||||
// nothing left to test
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgInitConnStatusBasicTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgInitConnStatusBasic packet = new MsgInitConnStatusBasic();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
assertEquals(true, pump.pumpSuspended);
|
||||
|
||||
}
|
||||
|
||||
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,59 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgInitConnStatusBolusTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
AAPSMocker.mockBus();
|
||||
MsgInitConnStatusBolus packet = new MsgInitConnStatusBolus();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
// message bigger than 22
|
||||
assertEquals(true, packet.failed);
|
||||
packet.handleMessage(createArray(20, (byte) 1));
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
assertEquals(true, pump.isExtendedBolusEnabled);
|
||||
|
||||
}
|
||||
|
||||
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.PumpDanaR.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.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class, ConfigBuilderPlugin.class})
|
||||
public class MsgInitConnStatusOptionTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
AAPSMocker.mockBus();
|
||||
AAPSMocker.mockConfigBuilder();
|
||||
MsgInitConnStatusOption packet = new MsgInitConnStatusOption();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(20, (byte) 1));
|
||||
// message smaller than 21
|
||||
assertEquals(true, packet.failed);
|
||||
packet.handleMessage(createArray(22, (byte) 1));
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
assertEquals(false, pump.isPasswordOK());
|
||||
|
||||
}
|
||||
|
||||
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.PumpDanaR.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.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class, ConfigBuilderPlugin.class})
|
||||
public class MsgInitConnStatusTimeTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
AAPSMocker.mockBus();
|
||||
AAPSMocker.mockConfigBuilder();
|
||||
AAPSMocker.mockCommandQueue();
|
||||
AAPSMocker.mockDanaRPlugin();
|
||||
MsgInitConnStatusTime packet = new MsgInitConnStatusTime();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(20, (byte) 1));
|
||||
// message smaller than 10
|
||||
assertEquals(false, packet.failed);
|
||||
packet.handleMessage(createArray(15, (byte) 1));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
}
|
||||
|
||||
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,44 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgPCCommStartTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgPCCommStart packet = new MsgPCCommStart();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
|
||||
}
|
||||
|
||||
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,44 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgPCCommStopTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgPCCommStop packet = new MsgPCCommStop();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
|
||||
}
|
||||
|
||||
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,45 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSetActivateBasalProfileTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSetActivateBasalProfile packet = new MsgSetActivateBasalProfile((byte) 1);
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
}
|
||||
|
||||
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,55 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSetBasalProfileTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
AAPSMocker.mockBus();
|
||||
MsgSetBasalProfile packet = new MsgSetBasalProfile((byte) 1, createArray(24,1));
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 2));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
}
|
||||
|
||||
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,45 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSetCarbsEntryTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSetCarbsEntry packet = new MsgSetCarbsEntry(System.currentTimeMillis(), 10);
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
}
|
||||
|
||||
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,46 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSetExtendedBolusStartTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
AAPSMocker.mockConstraintsChecker();
|
||||
MsgSetExtendedBolusStart packet = new MsgSetExtendedBolusStart(2D, (byte) 2);
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
}
|
||||
|
||||
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,45 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSetExtendedBolusStopTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSetExtendedBolusStop packet = new MsgSetExtendedBolusStop();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
}
|
||||
|
||||
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,54 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSetSingleBasalProfileTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
AAPSMocker.mockBus();
|
||||
MsgSetSingleBasalProfile packet = new MsgSetSingleBasalProfile(createArray(24, 2));
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
}
|
||||
|
||||
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,45 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSetTempBasalStartTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSetTempBasalStart packet = new MsgSetTempBasalStart(250, 1);
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
}
|
||||
|
||||
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,45 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSetTempBasalStopTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSetTempBasalStop packet = new MsgSetTempBasalStop();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
}
|
||||
|
||||
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,47 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.androidaps.plugins.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSetTimeTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSetTime packet = new MsgSetTime(new Date(System.currentTimeMillis()));
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
}
|
||||
|
||||
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,45 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSetUserOptionsTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSetUserOptions packet = new MsgSetUserOptions();
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
assertEquals(true, packet.failed);
|
||||
|
||||
}
|
||||
|
||||
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,47 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSettingActiveProfileTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSettingActiveProfile packet = new MsgSettingActiveProfile();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
assertEquals(MessageBase.intFromBuff(createArray(34, (byte) 7), 0, 1), pump.activeProfile);
|
||||
|
||||
}
|
||||
|
||||
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,44 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSettingBasalProfileAllTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSettingBasalProfileAll packet = new MsgSettingBasalProfileAll();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(400, (byte) 1));
|
||||
|
||||
}
|
||||
|
||||
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.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSettingBasalTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSettingBasal packet = new MsgSettingBasal();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(100, (byte) 1));
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
int expected = MessageBase.intFromBuff(createArray(100, (byte) 1), 2 * 1, 2);
|
||||
assertEquals((double) expected/100d, pump.pumpProfiles[pump.activeProfile][1], 0);
|
||||
|
||||
}
|
||||
|
||||
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,47 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSettingGlucoseTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSettingGlucose packet = new MsgSettingGlucose();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
assertEquals(1, pump.units);
|
||||
|
||||
}
|
||||
|
||||
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,47 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSettingMaxValuesTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSettingMaxValues packet = new MsgSettingMaxValues();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
assertEquals((double) MessageBase.intFromBuff(createArray(10, (byte) 7), 0, 2) / 100d, pump.maxBolus,0);
|
||||
|
||||
}
|
||||
|
||||
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,48 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSettingMealTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
AAPSMocker.mockBus();
|
||||
MsgSettingMeal packet = new MsgSettingMeal();
|
||||
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 1));
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
assertEquals((double) MessageBase.intFromBuff(createArray(10, (byte) 1), 0, 1) / 100d, pump.bolusStep, 0);
|
||||
|
||||
}
|
||||
|
||||
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,48 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSettingProfileRatiosAllTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSettingProfileRatiosAll packet = new MsgSettingProfileRatiosAll();
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
pump.units = DanaRPump.UNITS_MGDL;
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
pump = DanaRPump.getInstance();
|
||||
assertEquals((double) MessageBase.intFromBuff(createArray(10, (byte) 7), 0, 2), pump.morningCIR,0);
|
||||
|
||||
}
|
||||
|
||||
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,48 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSettingProfileRatiosTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSettingProfileRatios packet = new MsgSettingProfileRatios();
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
pump.units = DanaRPump.UNITS_MGDL;
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
pump = DanaRPump.getInstance();
|
||||
assertEquals((double) MessageBase.intFromBuff(createArray(10, (byte) 7), 0, 2), pump.currentCIR,0);
|
||||
|
||||
}
|
||||
|
||||
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,60 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.androidaps.plugins.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSettingPumpTimeTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSettingPumpTime packet = new MsgSettingPumpTime();
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
pump.units = DanaRPump.UNITS_MGDL;
|
||||
// test message decoding
|
||||
byte[] bytes = createArray(34, (byte) 7);
|
||||
long time =
|
||||
new Date(
|
||||
100 + MessageBase.intFromBuff(bytes, 5, 1),
|
||||
MessageBase.intFromBuff(bytes, 4, 1) - 1,
|
||||
MessageBase.intFromBuff(bytes, 3, 1),
|
||||
MessageBase.intFromBuff(bytes, 2, 1),
|
||||
MessageBase.intFromBuff(bytes, 1, 1),
|
||||
MessageBase.intFromBuff(bytes, 0, 1)
|
||||
).getTime();
|
||||
packet.handleMessage(bytes);
|
||||
pump = DanaRPump.getInstance();
|
||||
assertEquals(time, pump.pumpTime);
|
||||
|
||||
}
|
||||
|
||||
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,48 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSettingShippingInfoTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSettingShippingInfo packet = new MsgSettingShippingInfo();
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
pump.units = DanaRPump.UNITS_MGDL;
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
pump = DanaRPump.getInstance();
|
||||
assertEquals(MessageBase.stringFromBuff(createArray(34, (byte) 7), 0, 10), pump.serialNumber);
|
||||
|
||||
}
|
||||
|
||||
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,48 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgSettingUserOptionsTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgSettingUserOptions packet = new MsgSettingUserOptions();
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
pump.units = DanaRPump.UNITS_MGDL;
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(48, (byte) 7));
|
||||
pump = DanaRPump.getInstance();
|
||||
assertEquals((byte) 7 & 255 , pump.lcdOnTimeSec);
|
||||
|
||||
}
|
||||
|
||||
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,46 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgStatusBasicTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgStatusBasic packet = new MsgStatusBasic();
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
assertEquals((double) MessageBase.intFromBuff(createArray(34, (byte) 7), 0, 3) / 750d, pump.dailyTotalUnits,0);
|
||||
|
||||
}
|
||||
|
||||
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,57 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgStatusBolusExtendedTest {
|
||||
@Mock
|
||||
Context context;
|
||||
@Test
|
||||
public void runTest() throws Exception{
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
try {
|
||||
AAPSMocker.mockTreatmentService();
|
||||
} catch (Exception e){
|
||||
|
||||
}
|
||||
MsgStatusBolusExtended packet = new MsgStatusBolusExtended();
|
||||
// test message decoding
|
||||
//TODO Find a way to mock treatments plugin
|
||||
// packet.handleMessage(createArray(34, (byte) 7));
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
// assertEquals((double) MessageBase.intFromBuff(createArray(10, (byte) 7), 2, 2)/100d, pump.extendedBolusAmount,0);
|
||||
|
||||
}
|
||||
|
||||
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,48 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgStatusProfileTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgStatusProfile packet = new MsgStatusProfile();
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
pump.units = DanaRPump.UNITS_MGDL;
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
pump = DanaRPump.getInstance();
|
||||
assertEquals((double) MessageBase.intFromBuff(createArray(10, (byte) 7), 0, 2), pump.currentCIR,0);
|
||||
|
||||
}
|
||||
|
||||
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,40 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/31/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgStatusTempBasalTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgStatusTempBasal packet = new MsgStatusTempBasal();
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
// test message decoding
|
||||
// Calling context.getResources() before super.onCreate() returns nullPointerException
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.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.NSClientInternal.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
import info.nightscout.androidaps.plugins.Treatments.Treatment;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/30/2018.
|
||||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
||||
public class MsgStatusTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
AAPSMocker.mockMainApp();
|
||||
AAPSMocker.mockApplicationContext();
|
||||
AAPSMocker.mockSP();
|
||||
AAPSMocker.mockL();
|
||||
MsgStatus packet = new MsgStatus();
|
||||
// test message decoding
|
||||
packet.handleMessage(createArray(34, (byte) 7));
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
assertEquals((double) MessageBase.intFromBuff(createArray(34, (byte) 7), 0, 3) / 750d, pump.dailyTotalUnits,0);
|
||||
|
||||
}
|
||||
|
||||
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,16 @@
|
|||
package info.nightscout.androidaps.plugins.PumpDanaR.comm;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by Rumen Georgiev on 8/31/2018.
|
||||
*/
|
||||
public class RecordTypesTest {
|
||||
@Test
|
||||
public void runTest() {
|
||||
RecordTypes packet = new RecordTypes();
|
||||
assertEquals((byte) 0x01, packet.RECORD_TYPE_BOLUS);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue