From edcdc4c785673051a7f479dd75032a69caa9148a Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Wed, 31 Mar 2021 20:40:29 +0200 Subject: [PATCH 1/4] Revert incorrect Lint suggestion. --- .../info/nightscout/androidaps/db/DatabaseHelperProvider.java | 4 ++-- .../androidaps/interfaces/DatabaseHelperInterface.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelperProvider.java b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelperProvider.java index 6587fb6371..3b3b275506 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelperProvider.java +++ b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelperProvider.java @@ -1,10 +1,10 @@ package info.nightscout.androidaps.db; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import com.j256.ormlite.dao.CloseableIterator; -import org.jetbrains.annotations.Nullable; import org.json.JSONObject; import java.sql.SQLException; @@ -78,7 +78,7 @@ public class DatabaseHelperProvider implements DatabaseHelperInterface { return MainApp.Companion.getDbHelper().createOrUpdate(tempBasal); } - @NonNull @Override public TemporaryBasal findTempBasalByPumpId(long id) { + @Nullable @Override public TemporaryBasal findTempBasalByPumpId(long id) { return MainApp.Companion.getDbHelper().findTempBasalByPumpId(id); } diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/DatabaseHelperInterface.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/DatabaseHelperInterface.kt index 5864bd3754..0b2415260e 100644 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/DatabaseHelperInterface.kt +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/DatabaseHelperInterface.kt @@ -30,7 +30,7 @@ interface DatabaseHelperInterface { fun roundDateToSec(date: Long): Long fun createOrUpdateTDD(record: TDD) fun createOrUpdate(tempBasal: TemporaryBasal): Boolean - fun findTempBasalByPumpId(id: Long): TemporaryBasal + fun findTempBasalByPumpId(id: Long): TemporaryBasal? fun getTemporaryBasalsDataFromTime(mills: Long, ascending: Boolean): List fun getExtendedBolusDataFromTime(mills: Long, ascending: Boolean): List fun getProfileSwitchEventsFromTime(from: Long, to: Long, ascending: Boolean): List From cacf239d173b91e41d69652ee90f833a1ce46f79 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 31 Mar 2021 22:59:05 +0200 Subject: [PATCH 2/4] VirtualPump plugin remove init --- .../plugins/pump/virtual/VirtualPumpPlugin.kt | 44 +++++++++---------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt index c515fa97e6..11822e797a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.kt @@ -74,29 +74,27 @@ open class VirtualPumpPlugin @Inject constructor( var pumpType: PumpType? = null private set private var lastDataTime: Long = 0 - override val pumpDescription = PumpDescription() - - init { - pumpDescription.isBolusCapable = true - pumpDescription.bolusStep = 0.1 - pumpDescription.isExtendedBolusCapable = true - pumpDescription.extendedBolusStep = 0.05 - pumpDescription.extendedBolusDurationStep = 30.0 - pumpDescription.extendedBolusMaxDuration = 8 * 60.toDouble() - pumpDescription.isTempBasalCapable = true - pumpDescription.tempBasalStyle = PumpDescription.PERCENT or PumpDescription.ABSOLUTE - pumpDescription.maxTempPercent = 500 - pumpDescription.tempPercentStep = 10 - pumpDescription.tempDurationStep = 30 - pumpDescription.tempDurationStep15mAllowed = true - pumpDescription.tempDurationStep30mAllowed = true - pumpDescription.tempMaxDuration = 24 * 60 - pumpDescription.isSetBasalProfileCapable = true - pumpDescription.basalStep = 0.01 - pumpDescription.basalMinimumRate = 0.01 - pumpDescription.isRefillingCapable = true - pumpDescription.storesCarbInfo = false - pumpDescription.is30minBasalRatesCapable = true + override val pumpDescription = PumpDescription().also { + it.isBolusCapable = true + it.bolusStep = 0.1 + it.isExtendedBolusCapable = true + it.extendedBolusStep = 0.05 + it.extendedBolusDurationStep = 30.0 + it.extendedBolusMaxDuration = 8 * 60.toDouble() + it.isTempBasalCapable = true + it.tempBasalStyle = PumpDescription.PERCENT or PumpDescription.ABSOLUTE + it.maxTempPercent = 500 + it.tempPercentStep = 10 + it.tempDurationStep = 30 + it.tempDurationStep15mAllowed = true + it.tempDurationStep30mAllowed = true + it.tempMaxDuration = 24 * 60 + it.isSetBasalProfileCapable = true + it.basalStep = 0.01 + it.basalMinimumRate = 0.01 + it.isRefillingCapable = true + it.storesCarbInfo = false + it.is30minBasalRatesCapable = true } fun getFakingStatus(): Boolean { From 2df8c4fc7407d34698fedab57e34638fb01011e0 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 1 Apr 2021 00:03:49 +0200 Subject: [PATCH 3/4] provide Worker failure results --- .../androidaps/plugins/general/food/FoodPlugin.kt | 9 +++++---- .../general/nsclient/NSClientAddUpdateWorker.kt | 14 ++++++++------ .../plugins/general/nsclient/NSClientMbgWorker.kt | 5 +++-- .../general/nsclient/NSClientRemoveWorker.kt | 13 +++++++------ .../smsCommunicator/SmsCommunicatorPlugin.kt | 5 +++-- .../plugins/profile/ns/NSProfilePlugin.kt | 3 ++- .../androidaps/plugins/source/DexcomPlugin.kt | 11 ++++++----- .../androidaps/plugins/source/EversensePlugin.kt | 9 +++++---- .../androidaps/plugins/source/GlimpPlugin.kt | 5 +++-- .../androidaps/plugins/source/MM640gPlugin.kt | 9 +++++---- .../plugins/source/NSClientSourcePlugin.kt | 7 ++++--- .../androidaps/plugins/source/PoctechPlugin.kt | 7 ++++--- .../androidaps/plugins/source/TomatoPlugin.kt | 5 +++-- .../androidaps/plugins/source/XdripPlugin.kt | 7 ++++--- 14 files changed, 62 insertions(+), 47 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodPlugin.kt index 55a1c3a98a..34bc3a244c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/food/FoodPlugin.kt @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.general.food import android.content.Context import androidx.work.Worker import androidx.work.WorkerParameters +import androidx.work.workDataOf import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R import info.nightscout.androidaps.database.AppRepository @@ -55,7 +56,7 @@ class FoodPlugin @Inject constructor( override fun doWork(): Result { val foods = dataWorker.pickupJSONArray(inputData.getLong(DataWorker.STORE_KEY, -1)) - ?: return Result.failure() + ?: return Result.failure(workDataOf("Error" to "missing input data")) aapsLogger.debug(LTag.DATABASE, "Received Food Data: $foods") var ret = Result.success() @@ -77,7 +78,7 @@ class FoodPlugin @Inject constructor( repository.runTransactionForResult(SyncNsFoodTransaction(delFood)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while removing food", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { @@ -91,7 +92,7 @@ class FoodPlugin @Inject constructor( repository.runTransactionForResult(SyncNsFoodTransaction(food)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while adding/updating food", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { result -> @@ -101,7 +102,7 @@ class FoodPlugin @Inject constructor( } } else { aapsLogger.error(LTag.DATABASE, "Error parsing food", jsonFood.toString()) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to "Error parsing food")) } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddUpdateWorker.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddUpdateWorker.kt index 8264e8ed63..ae90713332 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddUpdateWorker.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientAddUpdateWorker.kt @@ -1,8 +1,10 @@ package info.nightscout.androidaps.plugins.general.nsclient import android.content.Context +import androidx.work.Data import androidx.work.Worker import androidx.work.WorkerParameters +import androidx.work.workDataOf import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R import info.nightscout.androidaps.database.AppRepository @@ -52,10 +54,10 @@ class NSClientAddUpdateWorker( override fun doWork(): Result { val acceptNSData = !sp.getBoolean(R.string.key_ns_upload_only, true) && buildHelper.isEngineeringMode() || config.NSCLIENT - if (!acceptNSData) return Result.failure() + if (!acceptNSData) return Result.success() val treatments = dataWorker.pickupJSONArray(inputData.getLong(DataWorker.STORE_KEY, -1)) - ?: return Result.failure() + ?: return Result.failure(workDataOf("Error" to "missing input data")) var ret = Result.success() var latestDateInReceivedData = 0L @@ -81,7 +83,7 @@ class NSClientAddUpdateWorker( repository.runTransactionForResult(SyncNsBolusTransaction(bolus)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while saving bolus", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { result -> @@ -105,7 +107,7 @@ class NSClientAddUpdateWorker( repository.runTransactionForResult(SyncNsCarbsTransaction(carb)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while saving carbs", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { result -> @@ -131,7 +133,7 @@ class NSClientAddUpdateWorker( repository.runTransactionForResult(SyncNsTemporaryTargetTransaction(temporaryTarget)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while saving temporary target", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { result -> @@ -175,7 +177,7 @@ class NSClientAddUpdateWorker( repository.runTransactionForResult(SyncNsTherapyEventTransaction(therapyEvent)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { result -> diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientMbgWorker.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientMbgWorker.kt index a2639ddd45..8ba3813be2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientMbgWorker.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientMbgWorker.kt @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.general.nsclient import android.content.Context import androidx.work.Worker import androidx.work.WorkerParameters +import androidx.work.workDataOf import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R import info.nightscout.androidaps.database.AppRepository @@ -36,14 +37,14 @@ class NSClientMbgWorker( if (!acceptNSData) return ret val mbgArray = dataWorker.pickupJSONArray(inputData.getLong(DataWorker.STORE_KEY, -1)) - ?: return Result.failure() + ?: return Result.failure(workDataOf("Error" to "missing input data")) for (i in 0 until mbgArray.length()) { val nsMbg = NSMbg(mbgArray.getJSONObject(i)) if (!nsMbg.isValid()) continue repository.runTransactionForResult(SyncNsTherapyEventTransaction(therapyEventFromNsMbg(nsMbg))) .doOnError { aapsLogger.error("Error while saving therapy event", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientRemoveWorker.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientRemoveWorker.kt index 2c932dc086..0687be4f52 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientRemoveWorker.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/nsclient/NSClientRemoveWorker.kt @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.general.nsclient import android.content.Context import androidx.work.Worker import androidx.work.WorkerParameters +import androidx.work.workDataOf import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R import info.nightscout.androidaps.database.AppRepository @@ -48,12 +49,12 @@ class NSClientRemoveWorker( override fun doWork(): Result { val acceptNSData = !sp.getBoolean(R.string.key_ns_upload_only, true) && buildHelper.isEngineeringMode() || config.NSCLIENT - if (!acceptNSData) return Result.failure() + if (!acceptNSData) return Result.success() var ret = Result.success() val treatments = dataWorker.pickupJSONArray(inputData.getLong(DataWorker.STORE_KEY, -1)) - ?: return Result.failure() + ?: return Result.failure(workDataOf("Error" to "missing input data")) for (i in 0 until treatments.length()) { val json = treatments.getJSONObject(i) @@ -64,7 +65,7 @@ class NSClientRemoveWorker( repository.runTransactionForResult(SyncNsTemporaryTargetTransaction(temporaryTarget)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while invalidating temporary target", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { result -> @@ -84,7 +85,7 @@ class NSClientRemoveWorker( repository.runTransactionForResult(SyncNsTherapyEventTransaction(therapyEvent)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while invalidating therapy event", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { result -> @@ -101,7 +102,7 @@ class NSClientRemoveWorker( repository.runTransactionForResult(SyncNsBolusTransaction(bolus)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while invalidating bolus", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { result -> @@ -118,7 +119,7 @@ class NSClientRemoveWorker( repository.runTransactionForResult(SyncNsCarbsTransaction(carbs)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while invalidating carbs", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { result -> diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt index 49d7a813bf..15e5825901 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt @@ -9,6 +9,7 @@ import androidx.preference.Preference import androidx.preference.PreferenceFragmentCompat import androidx.work.Worker import androidx.work.WorkerParameters +import androidx.work.workDataOf import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Config import info.nightscout.androidaps.Constants @@ -180,8 +181,8 @@ class SmsCommunicatorPlugin @Inject constructor( @Suppress("SpellCheckingInspection") override fun doWork(): Result { val bundle = dataWorker.pickupBundle(inputData.getLong(DataWorker.STORE_KEY, -1)) - ?: return Result.failure() - val format = bundle.getString("format") ?: return Result.failure() + ?: return Result.failure(workDataOf("Error" to "missing input data")) + val format = bundle.getString("format") ?: return Result.failure(workDataOf("Error" to "missing format in input data")) val pdus = bundle["pdus"] as Array<*> for (pdu in pdus) { val message = SmsMessage.createFromPdu(pdu as ByteArray, format) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfilePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfilePlugin.kt index e2c3c56608..15ca109728 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfilePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/ns/NSProfilePlugin.kt @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.profile.ns import android.content.Context import androidx.work.Worker import androidx.work.WorkerParameters +import androidx.work.workDataOf import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Config import info.nightscout.androidaps.R @@ -96,7 +97,7 @@ class NSProfilePlugin @Inject constructor( override fun doWork(): Result { val profileString = dataWorker.pickupJSONObject(inputData.getLong(DataWorker.STORE_KEY, -1)) - ?: return Result.failure() + ?: return Result.failure(workDataOf("Error" to "missing input data")) nsProfilePlugin.profile = ProfileStore(injector, profileString) nsProfilePlugin.storeNSProfile() if (nsProfilePlugin.isEnabled()) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt index 2c6a331fac..1614a1aa61 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/DexcomPlugin.kt @@ -6,6 +6,7 @@ import android.content.pm.PackageManager import androidx.core.content.ContextCompat import androidx.work.Worker import androidx.work.WorkerParameters +import androidx.work.workDataOf import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Config import info.nightscout.androidaps.R @@ -97,9 +98,9 @@ class DexcomPlugin @Inject constructor( override fun doWork(): Result { var ret = Result.success() - if (!dexcomPlugin.isEnabled(PluginType.BGSOURCE)) return Result.failure() + if (!dexcomPlugin.isEnabled(PluginType.BGSOURCE)) return Result.success() val bundle = dataWorker.pickupBundle(inputData.getLong(DataWorker.STORE_KEY, -1)) - ?: return Result.failure() + ?: return Result.failure(workDataOf("Error" to "missing input data")) try { val sourceSensor = when (bundle.getString("sensorType") ?: "") { "G6" -> GlucoseValue.SourceSensor.DEXCOM_G6_NATIVE @@ -107,7 +108,7 @@ class DexcomPlugin @Inject constructor( else -> GlucoseValue.SourceSensor.DEXCOM_NATIVE_UNKNOWN } val glucoseValuesBundle = bundle.getBundle("glucoseValues") - ?: return Result.failure() + ?: return Result.failure(workDataOf("Error" to "missing glucoseValues")) val glucoseValues = mutableListOf() for (i in 0 until glucoseValuesBundle.size()) { val glucoseValueBundle = glucoseValuesBundle.getBundle(i.toString())!! @@ -144,7 +145,7 @@ class DexcomPlugin @Inject constructor( repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, calibrations, sensorStartTime)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while saving values from Dexcom App", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { result -> @@ -161,7 +162,7 @@ class DexcomPlugin @Inject constructor( } } catch (e: Exception) { aapsLogger.error("Error while processing intent from Dexcom App", e) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to e)) } return ret } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt index 0a5fbeb500..876fe8d0db 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/EversensePlugin.kt @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.source import android.content.Context import androidx.work.Worker import androidx.work.WorkerParameters +import androidx.work.workDataOf import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R import info.nightscout.androidaps.database.AppRepository @@ -68,9 +69,9 @@ class EversensePlugin @Inject constructor( override fun doWork(): Result { var ret = Result.success() - if (!eversensePlugin.isEnabled(PluginType.BGSOURCE)) return Result.failure() + if (!eversensePlugin.isEnabled(PluginType.BGSOURCE)) return Result.success() val bundle = dataWorker.pickupBundle(inputData.getLong(DataWorker.STORE_KEY, -1)) - ?: return Result.failure() + ?: return Result.failure(workDataOf("Error" to "missing input data")) if (bundle.containsKey("currentCalibrationPhase")) aapsLogger.debug(LTag.BGSOURCE, "currentCalibrationPhase: " + bundle.getString("currentCalibrationPhase")) if (bundle.containsKey("placementModeInProgress")) aapsLogger.debug(LTag.BGSOURCE, "placementModeInProgress: " + bundle.getBoolean("placementModeInProgress")) if (bundle.containsKey("glucoseLevel")) aapsLogger.debug(LTag.BGSOURCE, "glucoseLevel: " + bundle.getInt("glucoseLevel")) @@ -111,7 +112,7 @@ class EversensePlugin @Inject constructor( repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while saving values from Eversense App", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { savedValues -> @@ -141,7 +142,7 @@ class EversensePlugin @Inject constructor( )) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while saving therapy event", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { result -> diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/GlimpPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/GlimpPlugin.kt index 8d5bcaa0ea..e6e6fa9c7c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/GlimpPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/GlimpPlugin.kt @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.source import android.content.Context import androidx.work.Worker import androidx.work.WorkerParameters +import androidx.work.workDataOf import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R import info.nightscout.androidaps.database.AppRepository @@ -55,7 +56,7 @@ class GlimpPlugin @Inject constructor( override fun doWork(): Result { var ret = Result.success() - if (!glimpPlugin.isEnabled(PluginType.BGSOURCE)) return Result.failure() + if (!glimpPlugin.isEnabled(PluginType.BGSOURCE)) return Result.success() aapsLogger.debug(LTag.BGSOURCE, "Received Glimp Data: $inputData}") val glucoseValues = mutableListOf() glucoseValues += CgmSourceTransaction.TransactionGlucoseValue( @@ -69,7 +70,7 @@ class GlimpPlugin @Inject constructor( repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while saving values from Glimp App", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { savedValues -> diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/MM640gPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/MM640gPlugin.kt index 0ecd4cde17..bf0c30e899 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/MM640gPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/MM640gPlugin.kt @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.source import android.content.Context import androidx.work.Worker import androidx.work.WorkerParameters +import androidx.work.workDataOf import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R import info.nightscout.androidaps.database.AppRepository @@ -60,8 +61,8 @@ class MM640gPlugin @Inject constructor( override fun doWork(): Result { var ret = Result.success() - if (!mM640gPlugin.isEnabled(PluginType.BGSOURCE)) return Result.failure() - val collection = inputData.getString("collection") ?: return Result.failure() + if (!mM640gPlugin.isEnabled(PluginType.BGSOURCE)) return Result.success() + val collection = inputData.getString("collection") ?: return Result.failure(workDataOf("Error" to "missing collection")) if (collection == "entries") { val data = inputData.getString("data") aapsLogger.debug(LTag.BGSOURCE, "Received MM640g Data: $data") @@ -87,7 +88,7 @@ class MM640gPlugin @Inject constructor( repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while saving values from Eversense App", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { savedValues -> @@ -98,7 +99,7 @@ class MM640gPlugin @Inject constructor( } } catch (e: JSONException) { aapsLogger.error("Exception: ", e) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to e)) } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt index 78f4f8f774..734bec03f5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/NSClientSourcePlugin.kt @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.source import android.content.Context import androidx.work.Worker import androidx.work.WorkerParameters +import androidx.work.workDataOf import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Config import info.nightscout.androidaps.R @@ -117,7 +118,7 @@ class NSClientSourcePlugin @Inject constructor( if (!nsClientSourcePlugin.isEnabled() && !sp.getBoolean(R.string.key_ns_autobackfill, true) && !dexcomPlugin.isEnabled()) return Result.success() val sgvs = dataWorker.pickupJSONArray(inputData.getLong(DataWorker.STORE_KEY, -1)) - ?: return Result.failure() + ?: return Result.failure(workDataOf("Error" to "missing input data")) try { var latestDateInReceivedData: Long = 0 @@ -141,7 +142,7 @@ class NSClientSourcePlugin @Inject constructor( repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null, !nsClientSourcePlugin.isEnabled())) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while saving values from NSClient App", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { result -> @@ -158,7 +159,7 @@ class NSClientSourcePlugin @Inject constructor( } } catch (e: Exception) { aapsLogger.error("Unhandled exception", e) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to e)) } // Objectives 0 sp.putBoolean(R.string.key_ObjectivesbgIsAvailableInNS, true) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt index 9ada30986c..b003adc13e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/PoctechPlugin.kt @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.source import android.content.Context import androidx.work.Worker import androidx.work.WorkerParameters +import androidx.work.workDataOf import dagger.android.HasAndroidInjector import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R @@ -59,7 +60,7 @@ class PoctechPlugin @Inject constructor( override fun doWork(): Result { var ret = Result.success() - if (!poctechPlugin.isEnabled(PluginType.BGSOURCE)) return Result.failure() + if (!poctechPlugin.isEnabled(PluginType.BGSOURCE)) return Result.success() aapsLogger.debug(LTag.BGSOURCE, "Received Poctech Data $inputData") try { val glucoseValues = mutableListOf() @@ -80,7 +81,7 @@ class PoctechPlugin @Inject constructor( repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while saving values from Poctech App", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { savedValues -> @@ -91,7 +92,7 @@ class PoctechPlugin @Inject constructor( } } catch (e: JSONException) { aapsLogger.error("Exception: ", e) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to e)) } return ret } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt index ce38a5e97e..92a92e7ef2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/TomatoPlugin.kt @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.source import android.content.Context import androidx.work.Worker import androidx.work.WorkerParameters +import androidx.work.workDataOf import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R import info.nightscout.androidaps.database.AppRepository @@ -60,7 +61,7 @@ class TomatoPlugin @Inject constructor( override fun doWork(): Result { var ret = Result.success() - if (!tomatoPlugin.isEnabled(PluginType.BGSOURCE)) return Result.failure() + if (!tomatoPlugin.isEnabled(PluginType.BGSOURCE)) return Result.success() val glucoseValues = mutableListOf() glucoseValues += CgmSourceTransaction.TransactionGlucoseValue( timestamp = inputData.getLong("com.fanqies.tomatofn.Extras.Time", 0), @@ -73,7 +74,7 @@ class TomatoPlugin @Inject constructor( repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while saving values from Tomato App", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { savedValues -> diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/XdripPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/XdripPlugin.kt index f07d64b876..bf5aa0b1d6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/XdripPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/XdripPlugin.kt @@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.source import android.content.Context import androidx.work.Worker import androidx.work.WorkerParameters +import androidx.work.workDataOf import dagger.android.HasAndroidInjector import info.nightscout.androidaps.R import info.nightscout.androidaps.database.AppRepository @@ -72,9 +73,9 @@ class XdripPlugin @Inject constructor( override fun doWork(): Result { var ret = Result.success() - if (!xdripPlugin.isEnabled(PluginType.BGSOURCE)) return Result.failure() + if (!xdripPlugin.isEnabled(PluginType.BGSOURCE)) return Result.success() val bundle = dataWorker.pickupBundle(inputData.getLong(DataWorker.STORE_KEY, -1)) - ?: return Result.failure() + ?: return Result.failure(workDataOf("Error" to "missing input data")) aapsLogger.debug(LTag.BGSOURCE, "Received xDrip data: $bundle") val glucoseValues = mutableListOf() @@ -90,7 +91,7 @@ class XdripPlugin @Inject constructor( repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, emptyList(), null)) .doOnError { aapsLogger.error(LTag.DATABASE, "Error while saving values from Xdrip", it) - ret = Result.failure() + ret = Result.failure(workDataOf("Error" to it)) } .blockingGet() .also { savedValues -> From 699413dd6f2ee4301ac7a88f1b3e63a929479bf1 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 1 Apr 2021 00:37:15 +0200 Subject: [PATCH 4/4] fix tests --- .../plugins/general/smsCommunicator/Sms.kt | 1 - .../nightscout/androidaps/utils/TimeListEdit.java | 1 - .../data/defaultProfile/DefaultProfileTest.kt | 0 .../androidaps/interfaces/ConstraintsCheckerTest.kt | 2 +- .../androidaps/plugins/aps/loop/LoopPluginTest.kt | 12 +++++------- .../general/automation/elements/LabelWithElement.kt | 2 -- .../utils/extensions/DeviceStatusExtension.kt | 2 +- .../info/nightscout/androidaps/data/ProfileTest.kt | 3 --- .../androidaps/plugins/pump/danaR/DanaRPluginTest.kt | 4 +++- .../plugins/pump/danaRv2/DanaRv2PluginTest.kt | 4 +++- .../pump/medtronic/data/dto/BasalProfileUTest.java | 3 +-- 11 files changed, 14 insertions(+), 20 deletions(-) rename {core => app}/src/test/java/info/nightscout/androidaps/data/defaultProfile/DefaultProfileTest.kt (100%) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/Sms.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/Sms.kt index bab25dfe3e..5952a0da66 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/Sms.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/Sms.kt @@ -1,7 +1,6 @@ package info.nightscout.androidaps.plugins.general.smsCommunicator import android.telephony.SmsMessage -import info.nightscout.androidaps.MainApp import info.nightscout.androidaps.utils.DateUtil class Sms { diff --git a/app/src/main/java/info/nightscout/androidaps/utils/TimeListEdit.java b/app/src/main/java/info/nightscout/androidaps/utils/TimeListEdit.java index af6fd3e742..33a24e3244 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/TimeListEdit.java +++ b/app/src/main/java/info/nightscout/androidaps/utils/TimeListEdit.java @@ -95,7 +95,6 @@ public class TimeListEdit { LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); llp.setMargins(0, 5, 0, 5); textlabel.setLayoutParams(llp); - //textlabel.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.linearBlockBackground)); TextViewCompat.setTextAppearance(textlabel, android.R.style.TextAppearance_Medium); layout.addView(textlabel); diff --git a/core/src/test/java/info/nightscout/androidaps/data/defaultProfile/DefaultProfileTest.kt b/app/src/test/java/info/nightscout/androidaps/data/defaultProfile/DefaultProfileTest.kt similarity index 100% rename from core/src/test/java/info/nightscout/androidaps/data/defaultProfile/DefaultProfileTest.kt rename to app/src/test/java/info/nightscout/androidaps/data/defaultProfile/DefaultProfileTest.kt diff --git a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt index 73a23cdaa1..79894eba45 100644 --- a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt @@ -143,7 +143,7 @@ class ConstraintsCheckerTest : TestBaseWithProfile() { hardLimits = HardLimits(aapsLogger, rxBus, sp, resourceHelper, context, repository) objectivesPlugin = ObjectivesPlugin(injector, aapsLogger, resourceHelper, activePlugin, sp, Config(), uel) comboPlugin = ComboPlugin(injector, aapsLogger, rxBus, resourceHelper, profileFunction, treatmentsInterface, sp, commandQueue, context, databaseHelper) - danaRPlugin = DanaRPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, resourceHelper, constraintChecker, activePlugin, sp, commandQueue, danaPump, dateUtil, fabricPrivacy) + danaRPlugin = DanaRPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, resourceHelper, constraintChecker, activePlugin, sp, commandQueue, danaPump, dateUtil, fabricPrivacy, pumpSync) danaRSPlugin = DanaRSPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, resourceHelper, constraintChecker, profileFunction, activePluginProvider, sp, commandQueue, danaPump, detailedBolusInfoStorage, fabricPrivacy, dateUtil) insightPlugin = LocalInsightPlugin(injector, aapsLogger, rxBus, resourceHelper, treatmentsInterface, sp, commandQueue, profileFunction, nsUpload, context, uploadQueue, Config(), dateUtil, databaseHelper, pumpSync) openAPSSMBPlugin = OpenAPSSMBPlugin(injector, aapsLogger, rxBus, constraintChecker, resourceHelper, profileFunction, context, activePlugin, treatmentsInterface, iobCobCalculator, hardLimits, profiler, sp, dateUtil, repository, glucoseStatusProvider) diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/aps/loop/LoopPluginTest.kt b/app/src/test/java/info/nightscout/androidaps/plugins/aps/loop/LoopPluginTest.kt index f2cef5f7bf..721d4402c8 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/aps/loop/LoopPluginTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/plugins/aps/loop/LoopPluginTest.kt @@ -8,13 +8,10 @@ import info.nightscout.androidaps.Config import info.nightscout.androidaps.R import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.database.AppRepository -import info.nightscout.androidaps.interfaces.ActivePluginProvider -import info.nightscout.androidaps.interfaces.CommandQueueProvider -import info.nightscout.androidaps.interfaces.PluginType -import info.nightscout.androidaps.interfaces.ProfileFunction -import info.nightscout.androidaps.interfaces.PumpDescription +import info.nightscout.androidaps.interfaces.* import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker +import info.nightscout.androidaps.plugins.configBuilder.RunningConfiguration import info.nightscout.androidaps.plugins.general.nsclient.NSUpload import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin @@ -34,7 +31,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest import org.powermock.modules.junit4.PowerMockRunner @RunWith(PowerMockRunner::class) -@PrepareForTest(ConstraintChecker::class, ReceiverStatusStore::class) +@PrepareForTest(ConstraintChecker::class, ReceiverStatusStore::class, RunningConfiguration::class) class LoopPluginTest : TestBase() { @Mock lateinit var sp: SP @@ -54,13 +51,14 @@ class LoopPluginTest : TestBase() { @Mock lateinit var notificationManager: NotificationManager @Mock lateinit var repository: AppRepository @Mock lateinit var dateUtil: DateUtil + @Mock lateinit var runningConfiguration: RunningConfiguration private lateinit var loopPlugin: LoopPlugin val injector = HasAndroidInjector { AndroidInjector { } } @Before fun prepareMock() { - loopPlugin = LoopPlugin(injector, aapsLogger, aapsSchedulers, rxBus, sp, Config(), constraintChecker, resourceHelper, profileFunction, context, commandQueue, activePlugin, treatmentsPlugin, virtualPumpPlugin, iobCobCalculatorPlugin, receiverStatusStore, fabricPrivacy, nsUpload, dateUtil, repository) + loopPlugin = LoopPlugin(injector, aapsLogger, aapsSchedulers, rxBus, sp, Config(), constraintChecker, resourceHelper, profileFunction, context, commandQueue, activePlugin, treatmentsPlugin, virtualPumpPlugin, iobCobCalculatorPlugin, receiverStatusStore, fabricPrivacy, nsUpload, dateUtil, repository, runningConfiguration) `when`(activePlugin.activePump).thenReturn(virtualPumpPlugin) `when`(context.getSystemService(Context.NOTIFICATION_SERVICE)).thenReturn(notificationManager) } diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/LabelWithElement.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/LabelWithElement.kt index 4ea68104f3..adc29fdb1e 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/LabelWithElement.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/LabelWithElement.kt @@ -25,7 +25,6 @@ class LabelWithElement( textViewPre.text = textPre textViewPre.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT) - //textViewPre.setWidth(MainApp.dpToPx(120)); textViewPre.setPadding(px, px, px, px) textViewPre.setTypeface(textViewPre.typeface, Typeface.BOLD) layout.addView(textViewPre) @@ -40,7 +39,6 @@ class LabelWithElement( textViewPost.text = textPost textViewPost.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT) - //textViewPost.setWidth(MainApp.dpToPx(45)); textViewPost.setPadding(px, px, px, px) textViewPost.setTypeface(textViewPost.typeface, Typeface.BOLD) layout.addView(textViewPost) diff --git a/core/src/main/java/info/nightscout/androidaps/utils/extensions/DeviceStatusExtension.kt b/core/src/main/java/info/nightscout/androidaps/utils/extensions/DeviceStatusExtension.kt index db61c992a9..97af8a73aa 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/extensions/DeviceStatusExtension.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/extensions/DeviceStatusExtension.kt @@ -37,7 +37,7 @@ fun buildDeviceStatus( version: String ): DeviceStatus? { val profile = profileFunction.getProfile() ?: return null - val profileName = profileFunction.getProfileName() ?: return null + val profileName = profileFunction.getProfileName() val lastRun = loopPlugin.lastRun var apsResult: JSONObject? = null diff --git a/core/src/test/java/info/nightscout/androidaps/data/ProfileTest.kt b/core/src/test/java/info/nightscout/androidaps/data/ProfileTest.kt index 38b85fef53..b5a0ecb3e1 100644 --- a/core/src/test/java/info/nightscout/androidaps/data/ProfileTest.kt +++ b/core/src/test/java/info/nightscout/androidaps/data/ProfileTest.kt @@ -105,7 +105,6 @@ class ProfileTest : TestBaseWithProfile() { //Test basal profile below limit p = Profile(profileInjector, JSONObject(belowLimitValidProfile), 100, 0) p.isValid("Test") - //Assert.assertEquals(true, ((AAPSMocker.MockedBus) MainApp.bus()).notificationSent); // Test profile w/o units p = Profile(profileInjector, JSONObject(noUnitsValidProfile), 100, 0) @@ -142,9 +141,7 @@ class ProfileTest : TestBaseWithProfile() { // Test hour alignment testPumpPlugin.pumpDescription.is30minBasalRatesCapable = false - //((AAPSMocker.MockedBus) MainApp.bus()).notificationSent = false; p = Profile(profileInjector, JSONObject(notAlignedBasalValidProfile), 100, 0) p.isValid("Test") - //Assert.assertEquals(true, ((AAPSMocker.MockedBus) MainApp.bus()).notificationSent); } } \ No newline at end of file diff --git a/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPluginTest.kt b/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPluginTest.kt index 834c549718..8c5daf0fa3 100644 --- a/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPluginTest.kt +++ b/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/DanaRPluginTest.kt @@ -11,6 +11,7 @@ import info.nightscout.androidaps.danar.R import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.interfaces.PluginType +import info.nightscout.androidaps.interfaces.PumpSync import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.utils.sharedPreferences.SP import org.junit.Assert @@ -30,6 +31,7 @@ class DanaRPluginTest : TestBaseWithProfile() { @Mock lateinit var constraintChecker: ConstraintChecker @Mock lateinit var sp: SP @Mock lateinit var commandQueue: CommandQueueProvider + @Mock lateinit var pumpSync: PumpSync lateinit var danaPump: DanaPump @@ -46,7 +48,7 @@ class DanaRPluginTest : TestBaseWithProfile() { `when`(resourceHelper.gs(R.string.limitingbasalratio)).thenReturn("Limiting max basal rate to %1\$.2f U/h because of %2\$s") `when`(resourceHelper.gs(R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s") danaPump = DanaPump(aapsLogger, sp, injector) - danaRPlugin = DanaRPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, resourceHelper, constraintChecker, activePluginProvider, sp, commandQueue, danaPump, dateUtil, fabricPrivacy) + danaRPlugin = DanaRPlugin(injector, aapsLogger, aapsSchedulers, rxBus, context, resourceHelper, constraintChecker, activePluginProvider, sp, commandQueue, danaPump, dateUtil, fabricPrivacy, pumpSync) } @Test @Throws(Exception::class) diff --git a/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2PluginTest.kt b/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2PluginTest.kt index 2e0cee2135..471071290b 100644 --- a/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2PluginTest.kt +++ b/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaRv2/DanaRv2PluginTest.kt @@ -11,6 +11,7 @@ import info.nightscout.androidaps.danar.R import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.interfaces.Constraint import info.nightscout.androidaps.interfaces.PluginType +import info.nightscout.androidaps.interfaces.PumpSync import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage import org.junit.Before @@ -30,6 +31,7 @@ class DanaRv2PluginTest : TestBaseWithProfile() { @Mock lateinit var sp: info.nightscout.androidaps.utils.sharedPreferences.SP @Mock lateinit var commandQueue: CommandQueueProvider @Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage + @Mock lateinit var pumpSync: PumpSync lateinit var danaPump: DanaPump @@ -46,7 +48,7 @@ class DanaRv2PluginTest : TestBaseWithProfile() { `when`(resourceHelper.gs(R.string.limitingbasalratio)).thenReturn("Limiting max basal rate to %1\$.2f U/h because of %2\$s") `when`(resourceHelper.gs(R.string.limitingpercentrate)).thenReturn("Limiting max percent rate to %1\$d%% because of %2\$s") danaPump = DanaPump(aapsLogger, sp, injector) - danaRv2Plugin = DanaRv2Plugin(injector, aapsLogger, aapsSchedulers, rxBus, context, danaPump, resourceHelper, constraintChecker, activePluginProvider, sp, commandQueue, detailedBolusInfoStorage, dateUtil, fabricPrivacy) + danaRv2Plugin = DanaRv2Plugin(injector, aapsLogger, aapsSchedulers, rxBus, context, danaPump, resourceHelper, constraintChecker, activePluginProvider, sp, commandQueue, detailedBolusInfoStorage, dateUtil, fabricPrivacy, pumpSync) } @Test diff --git a/medtronic/src/test/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/BasalProfileUTest.java b/medtronic/src/test/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/BasalProfileUTest.java index 8b2eaa3e7e..7564a9edc2 100644 --- a/medtronic/src/test/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/BasalProfileUTest.java +++ b/medtronic/src/test/java/info/nightscout/androidaps/plugins/pump/medtronic/data/dto/BasalProfileUTest.java @@ -9,11 +9,10 @@ import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil; * Created by andy on 6/16/18. */ //@RunWith(PowerMockRunner.class) -//@PrepareForTest({ MainApp.class, DatabaseHelper.class, DateUtil.class, SP.class }) +//@PrepareForTest({ DatabaseHelper.class, DateUtil.class, SP.class }) @Ignore public class BasalProfileUTest { /* - // MainApp mainApp = new MainApp(); @Before public void initMocking() {