DanaRS tests
This commit is contained in:
parent
130d5874a8
commit
40aa3cc60e
24 changed files with 316 additions and 667 deletions
|
@ -2,8 +2,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import com.cozmo.danar.util.BleCommandUtil
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.L
|
|
||||||
import info.nightscout.androidaps.logging.L.isEnabled
|
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
|
@ -51,13 +49,11 @@ class DanaRS_Packet_General_Get_More_Information(
|
||||||
danaRPump.lastBolusAmount = byteArrayToInt(getBytes(data, dataIndex, dataSize)).toDouble()
|
danaRPump.lastBolusAmount = byteArrayToInt(getBytes(data, dataIndex, dataSize)).toDouble()
|
||||||
// On DanaRS DailyUnits can't be more than 160
|
// On DanaRS DailyUnits can't be more than 160
|
||||||
if (danaRPump.dailyTotalUnits > 160) failed = true
|
if (danaRPump.dailyTotalUnits > 160) failed = true
|
||||||
if (isEnabled(L.PUMPCOMM)) {
|
aapsLogger.debug(LTag.PUMPCOMM, "Daily total units: " + danaRPump.dailyTotalUnits.toString() + " U")
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Daily total units: " + danaRPump.dailyTotalUnits.toString() + " U")
|
aapsLogger.debug(LTag.PUMPCOMM, "Is extended in progress: " + danaRPump.isExtendedInProgress)
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Is extended in progress: " + danaRPump.isExtendedInProgress)
|
aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus remaining minutes: " + danaRPump.extendedBolusRemainingMinutes)
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus remaining minutes: " + danaRPump.extendedBolusRemainingMinutes)
|
aapsLogger.debug(LTag.PUMPCOMM, "Last bolus time: " + DateUtil.dateAndTimeAndSecondsString(lastBolusTime.time))
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Last bolus time: " + DateUtil.dateAndTimeAndSecondsString(lastBolusTime.time))
|
aapsLogger.debug(LTag.PUMPCOMM, "Last bolus amount: " + danaRPump.lastBolusAmount)
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Last bolus amount: " + danaRPump.lastBolusAmount)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getFriendlyName(): String {
|
override fun getFriendlyName(): String {
|
||||||
|
|
|
@ -3,8 +3,6 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import com.cozmo.danar.util.BleCommandUtil
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.L
|
|
||||||
import info.nightscout.androidaps.logging.L.isEnabled
|
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
||||||
|
@ -39,11 +37,9 @@ class DanaRS_Packet_General_Get_Pump_Check(
|
||||||
dataIndex += dataSize
|
dataIndex += dataSize
|
||||||
dataSize = 1
|
dataSize = 1
|
||||||
danaRPump.productCode = byteArrayToInt(getBytes(data, dataIndex, dataSize))
|
danaRPump.productCode = byteArrayToInt(getBytes(data, dataIndex, dataSize))
|
||||||
if (isEnabled(L.PUMPCOMM)) {
|
aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.model))
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Model: " + String.format("%02X ", danaRPump.model))
|
aapsLogger.debug(LTag.PUMPCOMM, "Protocol: " + String.format("%02X ", danaRPump.protocol))
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Protocol: " + String.format("%02X ", danaRPump.protocol))
|
aapsLogger.debug(LTag.PUMPCOMM, "Product Code: " + String.format("%02X ", danaRPump.productCode))
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Product Code: " + String.format("%02X ", danaRPump.productCode))
|
|
||||||
}
|
|
||||||
if (danaRPump.productCode < 2) {
|
if (danaRPump.productCode < 2) {
|
||||||
rxBus.send(EventNewNotification(Notification(Notification.UNSUPPORTED_FIRMWARE, resourceHelper.gs(R.string.unsupportedfirmware), Notification.URGENT)))
|
rxBus.send(EventNewNotification(Notification(Notification.UNSUPPORTED_FIRMWARE, resourceHelper.gs(R.string.unsupportedfirmware), Notification.URGENT)))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,65 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.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.utils.SP;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Rumen on 08.08.2018.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
|
||||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
|
||||||
public class DanaRS_Packet_General_Get_More_InformationTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void runTest() {
|
|
||||||
AAPSMocker.mockMainApp();
|
|
||||||
AAPSMocker.mockApplicationContext();
|
|
||||||
AAPSMocker.mockSP();
|
|
||||||
AAPSMocker.mockL();
|
|
||||||
DanaRS_Packet_General_Get_More_Information packet = new DanaRS_Packet_General_Get_More_Information();
|
|
||||||
|
|
||||||
// test params
|
|
||||||
byte[] testparams = packet.getRequestParams();
|
|
||||||
assertEquals(null, packet.getRequestParams());
|
|
||||||
|
|
||||||
// test message decoding
|
|
||||||
// test for the length message
|
|
||||||
packet.handleMessage(createArray(13, (byte) 0));
|
|
||||||
assertEquals(true, packet.failed);
|
|
||||||
// everything ok :)
|
|
||||||
packet = new DanaRS_Packet_General_Get_More_Information();
|
|
||||||
packet.handleMessage(createArray(15, (byte) 0));
|
|
||||||
assertEquals(false, packet.failed);
|
|
||||||
|
|
||||||
packet.handleMessage(createArray(15, (byte) 161));
|
|
||||||
assertEquals(true, packet.failed);
|
|
||||||
|
|
||||||
assertEquals("REVIEW__GET_MORE_INFORMATION", packet.getFriendlyName());
|
|
||||||
}
|
|
||||||
|
|
||||||
byte[] createArray(int length, byte fillWith){
|
|
||||||
byte[] ret = new byte[length];
|
|
||||||
for(int i = 0; i<length; i++){
|
|
||||||
ret[i] = fillWith;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
double[] createArray(int length, double fillWith){
|
|
||||||
double[] ret = new double[length];
|
|
||||||
for(int i = 0; i<length; i++){
|
|
||||||
ret[i] = fillWith;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
|
import org.junit.Assert
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||||
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
|
@RunWith(PowerMockRunner::class)
|
||||||
|
@PrepareForTest()
|
||||||
|
class DanaRS_Packet_General_Get_More_InformationTest : DanaRSTestBase() {
|
||||||
|
|
||||||
|
@Test fun runTest() {
|
||||||
|
var packet = DanaRS_Packet_General_Get_More_Information(aapsLogger, danaRPump)
|
||||||
|
// test params
|
||||||
|
val testparams = packet.requestParams
|
||||||
|
Assert.assertEquals(null, packet.requestParams)
|
||||||
|
// test message decoding
|
||||||
|
// test for the length message
|
||||||
|
packet.handleMessage(createArray(13, 0.toByte()))
|
||||||
|
Assert.assertEquals(true, packet.failed)
|
||||||
|
// everything ok :)
|
||||||
|
packet = DanaRS_Packet_General_Get_More_Information(aapsLogger, danaRPump)
|
||||||
|
packet.handleMessage(createArray(15, 0.toByte()))
|
||||||
|
Assert.assertEquals(false, packet.failed)
|
||||||
|
packet.handleMessage(createArray(15, 161.toByte()))
|
||||||
|
Assert.assertEquals(true, packet.failed)
|
||||||
|
Assert.assertEquals("REVIEW__GET_MORE_INFORMATION", packet.friendlyName)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,66 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.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.utils.SP;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Rumen on 08.08.2018.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
|
||||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
|
||||||
public class DanaRS_Packet_General_Get_PasswordTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void runTest() {
|
|
||||||
AAPSMocker.mockMainApp();
|
|
||||||
AAPSMocker.mockApplicationContext();
|
|
||||||
AAPSMocker.mockSP();
|
|
||||||
AAPSMocker.mockL();
|
|
||||||
DanaRS_Packet_General_Get_Password packet = new DanaRS_Packet_General_Get_Password();
|
|
||||||
|
|
||||||
// test params
|
|
||||||
byte[] testparams = packet.getRequestParams();
|
|
||||||
assertEquals(null, packet.getRequestParams());
|
|
||||||
|
|
||||||
// test message decoding
|
|
||||||
// test for the length message
|
|
||||||
packet.handleMessage(createArray(1, (byte) 0));
|
|
||||||
assertEquals(true, packet.failed);
|
|
||||||
// everything ok :)
|
|
||||||
packet = new DanaRS_Packet_General_Get_Password();
|
|
||||||
packet.handleMessage(createArray(15, (byte) 0));
|
|
||||||
assertEquals(false, packet.failed);
|
|
||||||
|
|
||||||
// packet.handleMessage(createArray(15, (byte) 161));
|
|
||||||
// assertEquals(true, packet.failed);
|
|
||||||
|
|
||||||
assertEquals("REVIEW__GET_PASSWORD", packet.getFriendlyName());
|
|
||||||
}
|
|
||||||
|
|
||||||
byte[] createArray(int length, byte fillWith){
|
|
||||||
byte[] ret = new byte[length];
|
|
||||||
for(int i = 0; i<length; i++){
|
|
||||||
ret[i] = fillWith;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
double[] createArray(int length, double fillWith){
|
|
||||||
double[] ret = new double[length];
|
|
||||||
for(int i = 0; i<length; i++){
|
|
||||||
ret[i] = fillWith;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
|
import org.junit.Assert
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||||
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
|
@RunWith(PowerMockRunner::class)
|
||||||
|
@PrepareForTest()
|
||||||
|
class DanaRS_Packet_General_Get_PasswordTest : DanaRSTestBase() {
|
||||||
|
|
||||||
|
@Test fun runTest() {
|
||||||
|
var packet = DanaRS_Packet_General_Get_Password(aapsLogger, danaRPump)
|
||||||
|
// test params
|
||||||
|
val testparams = packet.requestParams
|
||||||
|
Assert.assertEquals(null, packet.requestParams)
|
||||||
|
// test message decoding
|
||||||
|
// test for the length message
|
||||||
|
packet.handleMessage(createArray(1, 0.toByte()))
|
||||||
|
Assert.assertEquals(true, packet.failed)
|
||||||
|
// everything ok :)
|
||||||
|
packet = DanaRS_Packet_General_Get_Password(aapsLogger, danaRPump)
|
||||||
|
packet.handleMessage(createArray(15, 0.toByte()))
|
||||||
|
Assert.assertEquals(false, packet.failed)
|
||||||
|
// packet.handleMessage(createArray(15, (byte) 161));
|
||||||
|
// assertEquals(true, packet.failed);
|
||||||
|
Assert.assertEquals("REVIEW__GET_PASSWORD", packet.friendlyName)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,66 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.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.utils.SP;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Rumen on 08.08.2018.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
|
||||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
|
||||||
public class DanaRS_Packet_General_Get_Pump_CheckTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void runTest() {
|
|
||||||
AAPSMocker.mockMainApp();
|
|
||||||
AAPSMocker.mockApplicationContext();
|
|
||||||
AAPSMocker.mockSP();
|
|
||||||
AAPSMocker.mockL();
|
|
||||||
DanaRS_Packet_General_Get_Pump_Check packet = new DanaRS_Packet_General_Get_Pump_Check();
|
|
||||||
|
|
||||||
// test params
|
|
||||||
byte[] testparams = packet.getRequestParams();
|
|
||||||
assertEquals(null, packet.getRequestParams());
|
|
||||||
|
|
||||||
// test message decoding
|
|
||||||
// test for the length message
|
|
||||||
packet.handleMessage(createArray(1, (byte) 0));
|
|
||||||
assertEquals(true, packet.failed);
|
|
||||||
// everything ok :)
|
|
||||||
packet = new DanaRS_Packet_General_Get_Pump_Check();
|
|
||||||
packet.handleMessage(createArray(15, (byte) 0));
|
|
||||||
assertEquals(false, packet.failed);
|
|
||||||
|
|
||||||
// packet.handleMessage(createArray(15, (byte) 161));
|
|
||||||
// assertEquals(true, packet.failed);
|
|
||||||
|
|
||||||
assertEquals("REVIEW__GET_PUMP_CHECK", packet.getFriendlyName());
|
|
||||||
}
|
|
||||||
|
|
||||||
byte[] createArray(int length, byte fillWith){
|
|
||||||
byte[] ret = new byte[length];
|
|
||||||
for(int i = 0; i<length; i++){
|
|
||||||
ret[i] = fillWith;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
double[] createArray(int length, double fillWith){
|
|
||||||
double[] ret = new double[length];
|
|
||||||
for(int i = 0; i<length; i++){
|
|
||||||
ret[i] = fillWith;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import org.junit.Assert
|
||||||
|
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
|
||||||
|
|
||||||
|
@RunWith(PowerMockRunner::class)
|
||||||
|
@PrepareForTest(RxBusWrapper::class)
|
||||||
|
class DanaRS_Packet_General_Get_Pump_CheckTest : DanaRSTestBase() {
|
||||||
|
|
||||||
|
@Mock lateinit var rxBus: RxBusWrapper
|
||||||
|
@Mock lateinit var resourceHelper: ResourceHelper
|
||||||
|
|
||||||
|
@Test fun runTest() {
|
||||||
|
var packet = DanaRS_Packet_General_Get_Pump_Check(aapsLogger, danaRPump, rxBus, resourceHelper)
|
||||||
|
// test params
|
||||||
|
val testparams = packet.requestParams
|
||||||
|
Assert.assertEquals(null, packet.requestParams)
|
||||||
|
// test message decoding
|
||||||
|
// test for the length message
|
||||||
|
packet.handleMessage(createArray(1, 0.toByte()))
|
||||||
|
Assert.assertEquals(true, packet.failed)
|
||||||
|
// everything ok :)
|
||||||
|
packet = DanaRS_Packet_General_Get_Pump_Check(aapsLogger, danaRPump, rxBus, resourceHelper)
|
||||||
|
packet.handleMessage(createArray(15, 0.toByte()))
|
||||||
|
Assert.assertEquals(false, packet.failed)
|
||||||
|
// packet.handleMessage(createArray(15, (byte) 161));
|
||||||
|
// assertEquals(true, packet.failed);
|
||||||
|
Assert.assertEquals("REVIEW__GET_PUMP_CHECK", packet.friendlyName)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,66 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.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.utils.SP;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Rumen on 08.08.2018.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
|
||||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
|
||||||
public class DanaRS_Packet_General_Get_Shipping_InformationTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void runTest() {
|
|
||||||
AAPSMocker.mockMainApp();
|
|
||||||
AAPSMocker.mockApplicationContext();
|
|
||||||
AAPSMocker.mockSP();
|
|
||||||
AAPSMocker.mockL();
|
|
||||||
DanaRS_Packet_General_Get_Shipping_Information packet = new DanaRS_Packet_General_Get_Shipping_Information();
|
|
||||||
|
|
||||||
// test params
|
|
||||||
byte[] testparams = packet.getRequestParams();
|
|
||||||
assertEquals(null, packet.getRequestParams());
|
|
||||||
|
|
||||||
// test message decoding
|
|
||||||
// test for the length message
|
|
||||||
packet.handleMessage(createArray(1, (byte) 0));
|
|
||||||
assertEquals(true, packet.failed);
|
|
||||||
// everything ok :)
|
|
||||||
packet = new DanaRS_Packet_General_Get_Shipping_Information();
|
|
||||||
packet.handleMessage(createArray(18, (byte) 0));
|
|
||||||
assertEquals(false, packet.failed);
|
|
||||||
|
|
||||||
// packet.handleMessage(createArray(15, (byte) 161));
|
|
||||||
// assertEquals(true, packet.failed);
|
|
||||||
|
|
||||||
assertEquals("REVIEW__GET_SHIPPING_INFORMATION", packet.getFriendlyName());
|
|
||||||
}
|
|
||||||
|
|
||||||
byte[] createArray(int length, byte fillWith){
|
|
||||||
byte[] ret = new byte[length];
|
|
||||||
for(int i = 0; i<length; i++){
|
|
||||||
ret[i] = fillWith;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
double[] createArray(int length, double fillWith){
|
|
||||||
double[] ret = new double[length];
|
|
||||||
for(int i = 0; i<length; i++){
|
|
||||||
ret[i] = fillWith;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp
|
||||||
|
import info.nightscout.androidaps.logging.L
|
||||||
|
import info.nightscout.androidaps.utils.SP
|
||||||
|
import org.junit.Assert
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||||
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
|
@RunWith(PowerMockRunner::class)
|
||||||
|
@PrepareForTest(MainApp::class, SP::class, L::class)
|
||||||
|
class DanaRS_Packet_General_Get_Shipping_InformationTest : DanaRSTestBase() {
|
||||||
|
|
||||||
|
@Test fun runTest() {
|
||||||
|
var packet = DanaRS_Packet_General_Get_Shipping_Information(aapsLogger, danaRPump)
|
||||||
|
// test params
|
||||||
|
val testparams = packet.requestParams
|
||||||
|
Assert.assertEquals(null, packet.requestParams)
|
||||||
|
// test message decoding
|
||||||
|
// test for the length message
|
||||||
|
packet.handleMessage(createArray(1, 0.toByte()))
|
||||||
|
Assert.assertEquals(true, packet.failed)
|
||||||
|
// everything ok :)
|
||||||
|
packet = DanaRS_Packet_General_Get_Shipping_Information(aapsLogger, danaRPump)
|
||||||
|
packet.handleMessage(createArray(18, 0.toByte()))
|
||||||
|
Assert.assertEquals(false, packet.failed)
|
||||||
|
// packet.handleMessage(createArray(15, (byte) 161));
|
||||||
|
// assertEquals(true, packet.failed);
|
||||||
|
Assert.assertEquals("REVIEW__GET_SHIPPING_INFORMATION", packet.friendlyName)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,68 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.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.pump.danaR.DanaRPump;
|
|
||||||
import info.nightscout.androidaps.utils.SP;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Rumen on 08.08.2018.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
|
||||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
|
||||||
public class DanaRS_Packet_General_Get_Today_Delivery_TotalTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void runTest() {
|
|
||||||
AAPSMocker.mockMainApp();
|
|
||||||
AAPSMocker.mockApplicationContext();
|
|
||||||
AAPSMocker.mockSP();
|
|
||||||
AAPSMocker.mockL();
|
|
||||||
DanaRS_Packet_General_Get_Today_Delivery_Total packet = new DanaRS_Packet_General_Get_Today_Delivery_Total();
|
|
||||||
|
|
||||||
// test params
|
|
||||||
byte[] testparams = packet.getRequestParams();
|
|
||||||
assertEquals(null, packet.getRequestParams());
|
|
||||||
|
|
||||||
// test message decoding
|
|
||||||
// test for the length message
|
|
||||||
packet.handleMessage(createArray(1, (byte) 0));
|
|
||||||
assertEquals(true, packet.failed);
|
|
||||||
// everything ok :)
|
|
||||||
packet = new DanaRS_Packet_General_Get_Today_Delivery_Total();
|
|
||||||
packet.handleMessage(createArray(18, (byte) 0));
|
|
||||||
assertEquals(false, packet.failed);
|
|
||||||
|
|
||||||
packet.handleMessage(createArray(15, (byte) 1));
|
|
||||||
DanaRPump pump = DanaRPump.getInstance();
|
|
||||||
assertEquals( (((1 & 0x000000FF) << 8) + (1 & 0x000000FF)) /100d, pump.dailyTotalUnits,0);
|
|
||||||
|
|
||||||
assertEquals("REVIEW__GET_TODAY_DELIVERY_TOTAL", packet.getFriendlyName());
|
|
||||||
}
|
|
||||||
|
|
||||||
byte[] createArray(int length, byte fillWith){
|
|
||||||
byte[] ret = new byte[length];
|
|
||||||
for(int i = 0; i<length; i++){
|
|
||||||
ret[i] = fillWith;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
double[] createArray(int length, double fillWith){
|
|
||||||
double[] ret = new double[length];
|
|
||||||
for(int i = 0; i<length; i++){
|
|
||||||
ret[i] = fillWith;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
|
import org.junit.Assert
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||||
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
|
@RunWith(PowerMockRunner::class)
|
||||||
|
@PrepareForTest()
|
||||||
|
class DanaRS_Packet_General_Get_Today_Delivery_TotalTest : DanaRSTestBase() {
|
||||||
|
|
||||||
|
@Test fun runTest() {
|
||||||
|
var packet = DanaRS_Packet_General_Get_Today_Delivery_Total(aapsLogger, danaRPump)
|
||||||
|
// test params
|
||||||
|
val testparams = packet.requestParams
|
||||||
|
Assert.assertEquals(null, packet.requestParams)
|
||||||
|
// test message decoding
|
||||||
|
// test for the length message
|
||||||
|
packet.handleMessage(createArray(1, 0.toByte()))
|
||||||
|
Assert.assertEquals(true, packet.failed)
|
||||||
|
// everything ok :)
|
||||||
|
packet = DanaRS_Packet_General_Get_Today_Delivery_Total(aapsLogger, danaRPump)
|
||||||
|
packet.handleMessage(createArray(18, 0.toByte()))
|
||||||
|
Assert.assertEquals(false, packet.failed)
|
||||||
|
packet.handleMessage(createArray(15, 1.toByte()))
|
||||||
|
Assert.assertEquals(((1 and 0x000000FF shl 8) + (1 and 0x000000FF)) / 100.0, danaRPump.dailyTotalUnits, 0.0)
|
||||||
|
Assert.assertEquals("REVIEW__GET_TODAY_DELIVERY_TOTAL", packet.friendlyName)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,63 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.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.utils.SP;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Rumen on 08.08.2018.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
|
||||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
|
||||||
public class DanaRS_Packet_General_Get_User_Time_Change_FlagTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void runTest() {
|
|
||||||
AAPSMocker.mockMainApp();
|
|
||||||
AAPSMocker.mockApplicationContext();
|
|
||||||
AAPSMocker.mockSP();
|
|
||||||
AAPSMocker.mockL();
|
|
||||||
DanaRS_Packet_General_Get_User_Time_Change_Flag packet = new DanaRS_Packet_General_Get_User_Time_Change_Flag();
|
|
||||||
|
|
||||||
// test params
|
|
||||||
byte[] testparams = packet.getRequestParams();
|
|
||||||
assertEquals(null, packet.getRequestParams());
|
|
||||||
|
|
||||||
// test message decoding
|
|
||||||
// test for the length message
|
|
||||||
packet.handleMessage(createArray(1, (byte) 0));
|
|
||||||
assertEquals(true, packet.failed);
|
|
||||||
// everything ok :)
|
|
||||||
packet = new DanaRS_Packet_General_Get_User_Time_Change_Flag();
|
|
||||||
packet.handleMessage(createArray(18, (byte) 0));
|
|
||||||
assertEquals(false, packet.failed);
|
|
||||||
|
|
||||||
assertEquals("REVIEW__GET_USER_TIME_CHANGE_FLAG", packet.getFriendlyName());
|
|
||||||
}
|
|
||||||
|
|
||||||
byte[] createArray(int length, byte fillWith){
|
|
||||||
byte[] ret = new byte[length];
|
|
||||||
for(int i = 0; i<length; i++){
|
|
||||||
ret[i] = fillWith;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
double[] createArray(int length, double fillWith){
|
|
||||||
double[] ret = new double[length];
|
|
||||||
for(int i = 0; i<length; i++){
|
|
||||||
ret[i] = fillWith;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
|
import org.junit.Assert
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||||
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
|
@RunWith(PowerMockRunner::class)
|
||||||
|
@PrepareForTest()
|
||||||
|
class DanaRS_Packet_General_Get_User_Time_Change_FlagTest : DanaRSTestBase() {
|
||||||
|
|
||||||
|
@Test fun runTest() {
|
||||||
|
var packet = DanaRS_Packet_General_Get_User_Time_Change_Flag(aapsLogger)
|
||||||
|
// test params
|
||||||
|
val testparams = packet.requestParams
|
||||||
|
Assert.assertEquals(null, packet.requestParams)
|
||||||
|
// test message decoding
|
||||||
|
// test for the length message
|
||||||
|
packet.handleMessage(createArray(1, 0.toByte()))
|
||||||
|
Assert.assertEquals(true, packet.failed)
|
||||||
|
// everything ok :)
|
||||||
|
packet = DanaRS_Packet_General_Get_User_Time_Change_Flag(aapsLogger)
|
||||||
|
packet.handleMessage(createArray(18, 0.toByte()))
|
||||||
|
Assert.assertEquals(false, packet.failed)
|
||||||
|
Assert.assertEquals("REVIEW__GET_USER_TIME_CHANGE_FLAG", packet.friendlyName)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,67 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.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.pump.danaR.DanaRPump;
|
|
||||||
import info.nightscout.androidaps.utils.SP;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Rumen on 08.08.2018.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
|
||||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
|
||||||
public class DanaRS_Packet_General_Initial_Screen_InformationTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void runTest() {
|
|
||||||
AAPSMocker.mockMainApp();
|
|
||||||
AAPSMocker.mockApplicationContext();
|
|
||||||
AAPSMocker.mockSP();
|
|
||||||
AAPSMocker.mockL();
|
|
||||||
DanaRS_Packet_General_Initial_Screen_Information packet = new DanaRS_Packet_General_Initial_Screen_Information();
|
|
||||||
|
|
||||||
// test params
|
|
||||||
byte[] testparams = packet.getRequestParams();
|
|
||||||
assertEquals(null, packet.getRequestParams());
|
|
||||||
|
|
||||||
// test message decoding
|
|
||||||
// test for the length message
|
|
||||||
packet.handleMessage(createArray(1, (byte) 0));
|
|
||||||
assertEquals(true, packet.failed);
|
|
||||||
// everything ok :)
|
|
||||||
packet = new DanaRS_Packet_General_Initial_Screen_Information();
|
|
||||||
packet.handleMessage(createArray(17, (byte) 1));
|
|
||||||
assertEquals(false, packet.failed);
|
|
||||||
DanaRPump pump = DanaRPump.getInstance();
|
|
||||||
assertEquals(true, pump.pumpSuspended);
|
|
||||||
|
|
||||||
|
|
||||||
assertEquals("REVIEW__INITIAL_SCREEN_INFORMATION", packet.getFriendlyName());
|
|
||||||
}
|
|
||||||
|
|
||||||
byte[] createArray(int length, byte fillWith){
|
|
||||||
byte[] ret = new byte[length];
|
|
||||||
for(int i = 0; i<length; i++){
|
|
||||||
ret[i] = fillWith;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
double[] createArray(int length, double fillWith){
|
|
||||||
double[] ret = new double[length];
|
|
||||||
for(int i = 0; i<length; i++){
|
|
||||||
ret[i] = fillWith;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
|
import org.junit.Assert
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||||
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
|
@RunWith(PowerMockRunner::class)
|
||||||
|
@PrepareForTest()
|
||||||
|
class DanaRS_Packet_General_Initial_Screen_InformationTest : DanaRSTestBase() {
|
||||||
|
|
||||||
|
@Test fun runTest() {
|
||||||
|
var packet = DanaRS_Packet_General_Initial_Screen_Information(aapsLogger, danaRPump)
|
||||||
|
// test params
|
||||||
|
val testparams = packet.requestParams
|
||||||
|
Assert.assertEquals(null, packet.requestParams)
|
||||||
|
// test message decoding
|
||||||
|
// test for the length message
|
||||||
|
packet.handleMessage(createArray(1, 0.toByte()))
|
||||||
|
Assert.assertEquals(true, packet.failed)
|
||||||
|
// everything ok :)
|
||||||
|
packet = DanaRS_Packet_General_Initial_Screen_Information(aapsLogger, danaRPump)
|
||||||
|
packet.handleMessage(createArray(17, 1.toByte()))
|
||||||
|
Assert.assertEquals(false, packet.failed)
|
||||||
|
Assert.assertEquals(true, danaRPump.pumpSuspended)
|
||||||
|
Assert.assertEquals("REVIEW__INITIAL_SCREEN_INFORMATION", packet.friendlyName)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,60 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.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.utils.SP;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Rumen on 08.08.2018.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
|
||||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
|
||||||
public class DanaRS_Packet_General_Set_History_Upload_ModeTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void runTest() {
|
|
||||||
AAPSMocker.mockMainApp();
|
|
||||||
AAPSMocker.mockApplicationContext();
|
|
||||||
AAPSMocker.mockSP();
|
|
||||||
AAPSMocker.mockL();
|
|
||||||
DanaRS_Packet_General_Set_History_Upload_Mode packet = new DanaRS_Packet_General_Set_History_Upload_Mode(1);
|
|
||||||
|
|
||||||
// test params
|
|
||||||
assertEquals(1, packet.getRequestParams()[0]);
|
|
||||||
|
|
||||||
// test message decoding
|
|
||||||
packet.handleMessage(createArray(3, (byte) 0));
|
|
||||||
assertEquals(false, packet.failed);
|
|
||||||
// everything ok :)
|
|
||||||
packet.handleMessage(createArray(17, (byte) 1));
|
|
||||||
assertEquals(true, packet.failed);
|
|
||||||
|
|
||||||
assertEquals("REVIEW__SET_HISTORY_UPLOAD_MODE", packet.getFriendlyName());
|
|
||||||
}
|
|
||||||
|
|
||||||
byte[] createArray(int length, byte fillWith){
|
|
||||||
byte[] ret = new byte[length];
|
|
||||||
for(int i = 0; i<length; i++){
|
|
||||||
ret[i] = fillWith;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
double[] createArray(int length, double fillWith){
|
|
||||||
double[] ret = new double[length];
|
|
||||||
for(int i = 0; i<length; i++){
|
|
||||||
ret[i] = fillWith;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
|
import org.junit.Assert
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||||
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
|
@RunWith(PowerMockRunner::class)
|
||||||
|
@PrepareForTest()
|
||||||
|
class DanaRS_Packet_General_Set_History_Upload_ModeTest : DanaRSTestBase() {
|
||||||
|
|
||||||
|
@Test fun runTest() {
|
||||||
|
val packet = DanaRS_Packet_General_Set_History_Upload_Mode(aapsLogger, 1)
|
||||||
|
// test params
|
||||||
|
Assert.assertEquals(1.toByte(), packet.requestParams[0])
|
||||||
|
// test message decoding
|
||||||
|
packet.handleMessage(createArray(3, 0.toByte()))
|
||||||
|
Assert.assertEquals(false, packet.failed)
|
||||||
|
// everything ok :)
|
||||||
|
packet.handleMessage(createArray(17, 1.toByte()))
|
||||||
|
Assert.assertEquals(true, packet.failed)
|
||||||
|
Assert.assertEquals("REVIEW__SET_HISTORY_UPLOAD_MODE", packet.friendlyName)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,60 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.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.utils.SP;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Rumen on 08.08.2018.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
|
||||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
|
||||||
public class DanaRS_Packet_General_Set_User_Time_Change_Flag_ClearTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void runTest() {
|
|
||||||
AAPSMocker.mockMainApp();
|
|
||||||
AAPSMocker.mockApplicationContext();
|
|
||||||
AAPSMocker.mockSP();
|
|
||||||
AAPSMocker.mockL();
|
|
||||||
DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear packet = new DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear();
|
|
||||||
|
|
||||||
// test params
|
|
||||||
assertEquals(null, packet.getRequestParams());
|
|
||||||
|
|
||||||
// test message decoding
|
|
||||||
packet.handleMessage(createArray(3, (byte) 0));
|
|
||||||
assertEquals(false, packet.failed);
|
|
||||||
// everything ok :)
|
|
||||||
packet.handleMessage(createArray(17, (byte) 1));
|
|
||||||
assertEquals(true, packet.failed);
|
|
||||||
|
|
||||||
assertEquals("REVIEW__SET_USER_TIME_CHANGE_FLAG_CLEAR", packet.getFriendlyName());
|
|
||||||
}
|
|
||||||
|
|
||||||
byte[] createArray(int length, byte fillWith){
|
|
||||||
byte[] ret = new byte[length];
|
|
||||||
for(int i = 0; i<length; i++){
|
|
||||||
ret[i] = fillWith;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
double[] createArray(int length, double fillWith){
|
|
||||||
double[] ret = new double[length];
|
|
||||||
for(int i = 0; i<length; i++){
|
|
||||||
ret[i] = fillWith;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
|
import org.junit.Assert
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||||
|
import org.powermock.modules.junit4.PowerMockRunner
|
||||||
|
|
||||||
|
@RunWith(PowerMockRunner::class)
|
||||||
|
@PrepareForTest()
|
||||||
|
class DanaRS_Packet_General_Set_User_Time_Change_Flag_ClearTest : DanaRSTestBase() {
|
||||||
|
|
||||||
|
@Test fun runTest() {
|
||||||
|
val packet = DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear(aapsLogger)
|
||||||
|
// test params
|
||||||
|
Assert.assertEquals(null, packet.requestParams)
|
||||||
|
// test message decoding
|
||||||
|
packet.handleMessage(createArray(3, 0.toByte()))
|
||||||
|
Assert.assertEquals(false, packet.failed)
|
||||||
|
// everything ok :)
|
||||||
|
packet.handleMessage(createArray(17, 1.toByte()))
|
||||||
|
Assert.assertEquals(true, packet.failed)
|
||||||
|
Assert.assertEquals("REVIEW__SET_USER_TIME_CHANGE_FLAG_CLEAR", packet.friendlyName)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,35 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.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.utils.SP;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Rumen on 09.08.2018.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
|
||||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
|
||||||
public class DanaRS_Packet_History_AlarmTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void runTest() {
|
|
||||||
AAPSMocker.mockMainApp();
|
|
||||||
AAPSMocker.mockApplicationContext();
|
|
||||||
AAPSMocker.mockSP();
|
|
||||||
AAPSMocker.mockL();
|
|
||||||
DanaRS_Packet_History_Alarm packet = new DanaRS_Packet_History_Alarm(System.currentTimeMillis());
|
|
||||||
|
|
||||||
assertEquals("REVIEW__ALARM", packet.getFriendlyName());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
import org.junit.Assert
|
||||||
|
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
|
||||||
|
|
||||||
|
@RunWith(PowerMockRunner::class)
|
||||||
|
@PrepareForTest()
|
||||||
|
class DanaRS_Packet_History_AlarmTest : DanaRSTestBase() {
|
||||||
|
|
||||||
|
@Mock lateinit var rxBus: RxBusWrapper
|
||||||
|
|
||||||
|
@Test fun runTest() {
|
||||||
|
val packet = DanaRS_Packet_History_Alarm(aapsLogger, rxBus, System.currentTimeMillis())
|
||||||
|
Assert.assertEquals("REVIEW__ALARM", packet.friendlyName)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,35 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.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.utils.SP;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by Rumen on 09.08.2018.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
|
||||||
@PrepareForTest({MainApp.class, SP.class, L.class})
|
|
||||||
public class DanaRS_Packet_History_All_HistoryTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void runTest() {
|
|
||||||
AAPSMocker.mockMainApp();
|
|
||||||
AAPSMocker.mockApplicationContext();
|
|
||||||
AAPSMocker.mockSP();
|
|
||||||
AAPSMocker.mockL();
|
|
||||||
DanaRS_Packet_History_All_History packet = new DanaRS_Packet_History_All_History(System.currentTimeMillis());
|
|
||||||
|
|
||||||
assertEquals("REVIEW__ALL_HISTORY", packet.getFriendlyName());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
import org.junit.Assert
|
||||||
|
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
|
||||||
|
|
||||||
|
@RunWith(PowerMockRunner::class)
|
||||||
|
@PrepareForTest()
|
||||||
|
class DanaRS_Packet_History_All_HistoryTest : DanaRSTestBase() {
|
||||||
|
|
||||||
|
@Mock lateinit var rxBus: RxBusWrapper
|
||||||
|
|
||||||
|
@Test fun runTest() {
|
||||||
|
val packet = DanaRS_Packet_History_All_History(aapsLogger, rxBus, System.currentTimeMillis())
|
||||||
|
Assert.assertEquals("REVIEW__ALL_HISTORY", packet.friendlyName)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue