From c283531348a5407d11c68b060ee41990453b5e2e Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 18 Mar 2020 23:09:51 +0100 Subject: [PATCH] Dana messages tests --- .../plugins/pump/danaR/comm/MessageBase.java | 2 +- .../pump/danaR/comm/MsgInitConnStatusBolus.kt | 1 + .../danaR/comm/MsgInitConnStatusOption.kt | 1 + .../comm/MsgSetAPSTempBasalStart_v2.kt | 4 +- .../comm/MsgInitConnStatusBasicTest.java | 54 ------------ .../danaR/comm/MsgInitConnStatusBasicTest.kt | 21 +++++ .../comm/MsgInitConnStatusBolusTest.java | 57 ------------- .../danaR/comm/MsgInitConnStatusBolusTest.kt | 30 +++++++ .../comm/MsgInitConnStatusOptionTest.java | 59 ------------- .../danaR/comm/MsgInitConnStatusOptionTest.kt | 34 ++++++++ .../danaR/comm/MsgInitConnStatusTimeTest.java | 62 -------------- .../danaR/comm/MsgInitConnStatusTimeTest.kt | 36 ++++++++ .../pump/danaR/comm/MsgPCCommStartTest.java | 40 --------- .../pump/danaR/comm/MsgPCCommStartTest.kt | 16 ++++ .../pump/danaR/comm/MsgPCCommStopTest.java | 40 --------- .../pump/danaR/comm/MsgPCCommStopTest.kt | 17 ++++ .../comm/MsgSetActivateBasalProfileTest.java | 43 ---------- .../comm/MsgSetActivateBasalProfileTest.kt | 18 ++++ .../danaR/comm/MsgSetBasalProfileTest.java | 52 ------------ .../pump/danaR/comm/MsgSetBasalProfileTest.kt | 23 ++++++ .../pump/danaR/comm/MsgSetCarbsEntryTest.java | 43 ---------- .../pump/danaR/comm/MsgSetCarbsEntryTest.kt | 18 ++++ .../comm/MsgSetExtendedBolusStartTest.java | 44 ---------- .../comm/MsgSetExtendedBolusStartTest.kt | 28 +++++++ .../comm/MsgSetExtendedBolusStopTest.java | 43 ---------- .../danaR/comm/MsgSetExtendedBolusStopTest.kt | 18 ++++ .../comm/MsgSetSingleBasalProfileTest.java | 51 ------------ .../comm/MsgSetSingleBasalProfileTest.kt | 23 ++++++ .../danaR/comm/MsgSetTempBasalStartTest.java | 43 ---------- .../danaR/comm/MsgSetTempBasalStartTest.kt | 18 ++++ .../danaR/comm/MsgSetTempBasalStopTest.java | 43 ---------- .../pump/danaR/comm/MsgSetTimeTest.java | 45 ---------- .../plugins/pump/danaR/comm/MsgSetTimeTest.kt | 19 +++++ .../danaR/comm/MsgSetUserOptionsTest.java | 42 ---------- .../pump/danaR/comm/MsgSetUserOptionsTest.kt | 17 ++++ .../comm/MsgSettingActiveProfileTest.java | 45 ---------- .../danaR/comm/MsgSettingActiveProfileTest.kt | 18 ++++ .../comm/MsgSettingBasalProfileAllTest.java | 40 --------- .../comm/MsgSettingBasalProfileAllTest.kt | 16 ++++ .../pump/danaR/comm/MsgSettingBasalTest.java | 46 ----------- .../pump/danaR/comm/MsgSettingBasalTest.kt | 28 +++++++ .../danaR/comm/MsgSettingGlucoseTest.java | 45 ---------- .../pump/danaR/comm/MsgSettingGlucoseTest.kt | 18 ++++ .../danaR/comm/MsgSettingMaxValuesTest.java | 45 ---------- .../danaR/comm/MsgSettingMaxValuesTest.kt | 18 ++++ .../pump/danaR/comm/MsgSettingMealTest.java | 45 ---------- .../pump/danaR/comm/MsgSettingMealTest.kt | 29 +++++++ .../comm/MsgSettingProfileRatiosAllTest.java | 46 ----------- .../comm/MsgSettingProfileRatiosAllTest.kt | 20 +++++ .../comm/MsgSettingProfileRatiosTest.java | 46 ----------- .../danaR/comm/MsgSettingProfileRatiosTest.kt | 19 +++++ .../danaR/comm/MsgSettingPumpTimeTest.java | 58 ------------- .../pump/danaR/comm/MsgSettingPumpTimeTest.kt | 29 +++++++ .../comm/MsgSettingShippingInfoTest.java | 46 ----------- .../danaR/comm/MsgSettingShippingInfoTest.kt | 19 +++++ .../danaR/comm/MsgSettingUserOptionsTest.java | 46 ----------- .../danaR/comm/MsgSettingUserOptionsTest.kt | 20 +++++ .../pump/danaR/comm/MsgStatusBasicTest.java | 44 ---------- .../pump/danaR/comm/MsgStatusBasicTest.kt | 17 ++++ .../comm/MsgStatusBolusExtendedTest.java | 53 ------------ .../danaR/comm/MsgStatusBolusExtendedTest.kt | 28 +++++++ .../pump/danaR/comm/MsgStatusProfileTest.java | 46 ----------- .../pump/danaR/comm/MsgStatusProfileTest.kt | 19 +++++ .../danaR/comm/MsgStatusTempBasalTest.java | 35 -------- .../pump/danaR/comm/MsgStatusTempBasalTest.kt | 29 +++++++ .../pump/danaR/comm/MsgStatusTest.java | 44 ---------- .../plugins/pump/danaR/comm/MsgStatusTest.kt | 17 ++++ .../comm/MsgSetAPSTempBasalStart_v2Test.java | 82 ------------------- .../comm/MsgSetAPSTempBasalStart_v2Test.kt | 51 ++++++++++++ .../comm/MsgSetHistoryEntry_v2Test.java | 62 -------------- .../danaRv2/comm/MsgSetHistoryEntry_v2Test.kt | 22 +++++ .../danaRv2/comm/MsgStatusAPS_v2Test.java | 57 ------------- .../pump/danaRv2/comm/MsgStatusAPS_v2Test.kt | 23 ++++++ .../comm/MsgStatusBolusExtended_v2Test.java | 56 ------------- .../comm/MsgStatusBolusExtended_v2Test.kt | 20 +++++ .../comm/MsgStatusTempBasal_v2Test.java | 63 -------------- .../danaRv2/comm/MsgStatusTempBasal_v2Test.kt | 21 +++++ 77 files changed, 822 insertions(+), 1814 deletions(-) delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusBasicTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusBasicTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusBolusTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusBolusTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusOptionTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusOptionTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusTimeTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusTimeTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgPCCommStartTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgPCCommStartTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgPCCommStopTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgPCCommStopTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetActivateBasalProfileTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetActivateBasalProfileTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetBasalProfileTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetBasalProfileTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetCarbsEntryTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetCarbsEntryTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetExtendedBolusStartTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetExtendedBolusStartTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetExtendedBolusStopTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetExtendedBolusStopTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetSingleBasalProfileTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetSingleBasalProfileTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetTempBasalStartTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetTempBasalStartTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetTempBasalStopTest.java delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetTimeTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetTimeTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetUserOptionsTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSetUserOptionsTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingActiveProfileTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingActiveProfileTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingBasalProfileAllTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingBasalProfileAllTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingBasalTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingBasalTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingGlucoseTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingGlucoseTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingMaxValuesTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingMaxValuesTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingMealTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingMealTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingProfileRatiosAllTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingProfileRatiosAllTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingProfileRatiosTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingProfileRatiosTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingPumpTimeTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingPumpTimeTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingShippingInfoTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingShippingInfoTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingUserOptionsTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgSettingUserOptionsTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusBasicTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusBasicTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusBolusExtendedTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusBolusExtendedTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusProfileTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusProfileTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusTempBasalTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusTempBasalTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgStatusTest.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgSetAPSTempBasalStart_v2Test.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgSetAPSTempBasalStart_v2Test.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgSetHistoryEntry_v2Test.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgSetHistoryEntry_v2Test.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgStatusAPS_v2Test.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgStatusAPS_v2Test.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgStatusBolusExtended_v2Test.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgStatusBolusExtended_v2Test.kt delete mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgStatusTempBasal_v2Test.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgStatusTempBasal_v2Test.kt diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MessageBase.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MessageBase.java index a189958d4a..f52d62d9c2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MessageBase.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MessageBase.java @@ -24,7 +24,7 @@ import info.nightscout.androidaps.utils.CRC; public class MessageBase { private static Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPCOMM); - protected byte[] buffer = new byte[512]; + public byte[] buffer = new byte[512]; private int position = 6; public boolean received = false; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusBolus.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusBolus.kt index a6c302b9e9..580df8e133 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusBolus.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusBolus.kt @@ -27,6 +27,7 @@ class MsgInitConnStatusBolus( failed = true return } + failed = false val bolusConfig = intFromBuff(bytes, 0, 1) danaRPump.isExtendedBolusEnabled = bolusConfig and 0x01 != 0 danaRPump.bolusStep = intFromBuff(bytes, 1, 1) / 100.0 diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusOption.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusOption.kt index e2a7f62bbc..ee1d26ce3f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusOption.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusOption.kt @@ -35,6 +35,7 @@ class MsgInitConnStatusOption( //val lowReservoirAlarmBoundary = intFromBuff(bytes, 7, 1) //int none = intFromBuff(bytes, 8, 1); if (bytes.size >= 21) { + failed = false danaRPump.password = intFromBuff(bytes, 9, 2) xor 0x3463 aapsLogger.debug(LTag.PUMPCOMM, "Pump password: " + danaRPump.password) } else { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgSetAPSTempBasalStart_v2.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgSetAPSTempBasalStart_v2.kt index 46e38a3dae..95d2b56b77 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgSetAPSTempBasalStart_v2.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRv2/comm/MsgSetAPSTempBasalStart_v2.kt @@ -11,8 +11,8 @@ class MsgSetAPSTempBasalStart_v2( thirtyMinutes: Boolean ) : MessageBase() { - private val PARAM30MIN = 160 - private val PARAM15MIN = 150 + val PARAM30MIN = 160 + val PARAM15MIN = 150 init { SetCommand(0xE002) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusBasicTest.java b/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusBasicTest.java deleted file mode 100644 index 959d114098..0000000000 --- a/app/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/MsgInitConnStatusBasicTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.danaR.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.*; - -/** - * 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