ConfigBuilderInterface rename

This commit is contained in:
Milos Kozak 2021-04-13 23:27:55 +02:00
parent 05bfb957ec
commit 3aa38d46bb
23 changed files with 67 additions and 109 deletions

View file

@ -1,35 +1,8 @@
package info.nightscout.androidaps package info.nightscout.androidaps
import android.os.SystemClock
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest import androidx.test.filters.LargeTest
import androidx.test.rule.ActivityTestRule
import androidx.test.rule.GrantPermissionRule
import info.nightscout.androidaps.data.Profile
import info.nightscout.androidaps.interfaces.PluginBase
import info.nightscout.androidaps.interfaces.PluginType
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugin
import info.nightscout.androidaps.plugins.general.actions.ActionsPlugin
import info.nightscout.androidaps.plugins.insulin.InsulinOrefUltraRapidActingPlugin
import info.nightscout.androidaps.plugins.profile.local.LocalProfilePlugin
import info.nightscout.androidaps.danaRv2.DanaRv2Plugin
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin
import info.nightscout.androidaps.plugins.source.RandomBgPlugin
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
import info.nightscout.androidaps.utils.DateUtil
import info.nightscout.androidaps.utils.extensions.isRunningTest
import info.nightscout.androidaps.utils.sharedPreferences.SP
import org.json.JSONObject
import org.junit.Assert
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
import javax.inject.Inject
@LargeTest @LargeTest
@RunWith(AndroidJUnit4::class) @RunWith(AndroidJUnit4::class)

View file

@ -18,11 +18,11 @@ import info.nightscout.androidaps.db.CompatDBHelper
import info.nightscout.androidaps.db.DatabaseHelper import info.nightscout.androidaps.db.DatabaseHelper
import info.nightscout.androidaps.db.StaticInjector import info.nightscout.androidaps.db.StaticInjector
import info.nightscout.androidaps.dependencyInjection.DaggerAppComponent import info.nightscout.androidaps.dependencyInjection.DaggerAppComponent
import info.nightscout.androidaps.interfaces.ConfigBuilder
import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.interfaces.PluginBase
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
import info.nightscout.androidaps.plugins.configBuilder.PluginStore import info.nightscout.androidaps.plugins.configBuilder.PluginStore
import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtils import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionCheckerUtils
import info.nightscout.androidaps.receivers.BTReceiver import info.nightscout.androidaps.receivers.BTReceiver
@ -49,7 +49,7 @@ class MainApp : DaggerApplication() {
@Inject lateinit var versionCheckersUtils: VersionCheckerUtils @Inject lateinit var versionCheckersUtils: VersionCheckerUtils
@Inject lateinit var sp: SP @Inject lateinit var sp: SP
@Inject lateinit var config: Config @Inject lateinit var config: Config
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin @Inject lateinit var configBuilder: ConfigBuilder
@Inject lateinit var keepAliveManager: KeepAliveManager @Inject lateinit var keepAliveManager: KeepAliveManager
@Inject lateinit var plugins: List<@JvmSuppressWildcards PluginBase> @Inject lateinit var plugins: List<@JvmSuppressWildcards PluginBase>
@Inject lateinit var compatDBHelper: CompatDBHelper @Inject lateinit var compatDBHelper: CompatDBHelper
@ -85,7 +85,7 @@ class MainApp : DaggerApplication() {
// Register all tabs in app here // Register all tabs in app here
pluginStore.plugins = plugins pluginStore.plugins = plugins
configBuilderPlugin.initialize() configBuilder.initialize()
keepAliveManager.setAlarm(this) keepAliveManager.setAlarm(this)
doMigrations() doMigrations()
uel.log(UserEntry.Action.START_AAPS, UserEntry.Sources.Aaps) uel.log(UserEntry.Action.START_AAPS, UserEntry.Sources.Aaps)

View file

@ -78,7 +78,7 @@ open class AppModule {
@Binds fun bindActivePluginProvider(pluginStore: PluginStore): ActivePluginProvider @Binds fun bindActivePluginProvider(pluginStore: PluginStore): ActivePluginProvider
@Binds fun bindCommandQueueProvider(commandQueue: CommandQueue): CommandQueueProvider @Binds fun bindCommandQueueProvider(commandQueue: CommandQueue): CommandQueueProvider
@Binds fun bindConfigInterface(config: Config): ConfigInterface @Binds fun bindConfigInterface(config: Config): ConfigInterface
@Binds fun bindConfigBuilderInterface(configBuilderPlugin: ConfigBuilderPlugin): ConfigBuilderInterface @Binds fun bindConfigBuilderInterface(configBuilderPlugin: ConfigBuilderPlugin): ConfigBuilder
@Binds fun bindTreatmentsInterface(treatmentsPlugin: TreatmentsPlugin): TreatmentsInterface @Binds fun bindTreatmentsInterface(treatmentsPlugin: TreatmentsPlugin): TreatmentsInterface
@Binds fun bindDatabaseHelperInterface(databaseHelperProvider: DatabaseHelperProvider): DatabaseHelperInterface @Binds fun bindDatabaseHelperInterface(databaseHelperProvider: DatabaseHelperProvider): DatabaseHelperInterface
@Binds fun bindNotificationHolderInterface(notificationHolder: NotificationHolder): NotificationHolderInterface @Binds fun bindNotificationHolderInterface(notificationHolder: NotificationHolder): NotificationHolderInterface

View file

@ -23,7 +23,6 @@ import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.FabricPrivacy
@ -47,7 +46,7 @@ class LoopDialog : DaggerDialogFragment() {
@Inject lateinit var activePlugin: ActivePluginProvider @Inject lateinit var activePlugin: ActivePluginProvider
@Inject lateinit var constraintChecker: ConstraintChecker @Inject lateinit var constraintChecker: ConstraintChecker
@Inject lateinit var commandQueue: CommandQueueProvider @Inject lateinit var commandQueue: CommandQueueProvider
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin @Inject lateinit var configBuilder: ConfigBuilder
@Inject lateinit var uel: UserEntryLogger @Inject lateinit var uel: UserEntryLogger
private var showOkCancel: Boolean = true private var showOkCancel: Boolean = true
@ -265,7 +264,7 @@ class LoopDialog : DaggerDialogFragment() {
uel.log(Action.LOOP_DISABLED, Sources.LoopDialog) uel.log(Action.LOOP_DISABLED, Sources.LoopDialog)
loopPlugin.setPluginEnabled(PluginType.LOOP, false) loopPlugin.setPluginEnabled(PluginType.LOOP, false)
loopPlugin.setFragmentVisible(PluginType.LOOP, false) loopPlugin.setFragmentVisible(PluginType.LOOP, false)
configBuilderPlugin.storeSettings("DisablingLoop") configBuilder.storeSettings("DisablingLoop")
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
commandQueue.cancelTempBasal(true, object : Callback() { commandQueue.cancelTempBasal(true, object : Callback() {
override fun run() { override fun run() {
@ -282,7 +281,7 @@ class LoopDialog : DaggerDialogFragment() {
uel.log(Action.LOOP_ENABLED, Sources.LoopDialog) uel.log(Action.LOOP_ENABLED, Sources.LoopDialog)
loopPlugin.setPluginEnabled(PluginType.LOOP, true) loopPlugin.setPluginEnabled(PluginType.LOOP, true)
loopPlugin.setFragmentVisible(PluginType.LOOP, true) loopPlugin.setFragmentVisible(PluginType.LOOP, true)
configBuilderPlugin.storeSettings("EnablingLoop") configBuilder.storeSettings("EnablingLoop")
rxBus.send(EventRefreshOverview("suspendmenu")) rxBus.send(EventRefreshOverview("suspendmenu"))
loopPlugin.createOfflineEvent(0) loopPlugin.createOfflineEvent(0)
return true return true

View file

@ -43,9 +43,9 @@ class ConfigBuilderPlugin @Inject constructor(
.shortName(R.string.configbuilder_shortname) .shortName(R.string.configbuilder_shortname)
.description(R.string.description_config_builder), .description(R.string.description_config_builder),
aapsLogger, resourceHelper, injector aapsLogger, resourceHelper, injector
), ConfigBuilderInterface { ), ConfigBuilder {
fun initialize() { override fun initialize() {
(activePlugin as PluginStore).loadDefaults() (activePlugin as PluginStore).loadDefaults()
loadSettings() loadSettings()
setAlwaysEnabledPluginsEnabled() setAlwaysEnabledPluginsEnabled()

View file

@ -44,7 +44,6 @@ import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
import info.nightscout.androidaps.plugins.aps.loop.events.EventNewOpenLoopNotification import info.nightscout.androidaps.plugins.aps.loop.events.EventNewOpenLoopNotification
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
import info.nightscout.androidaps.plugins.general.nsclient.data.NSDeviceStatus import info.nightscout.androidaps.plugins.general.nsclient.data.NSDeviceStatus
import info.nightscout.androidaps.plugins.general.overview.activities.QuickWizardListActivity import info.nightscout.androidaps.plugins.general.overview.activities.QuickWizardListActivity
@ -96,7 +95,6 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
@Inject lateinit var statusLightHandler: StatusLightHandler @Inject lateinit var statusLightHandler: StatusLightHandler
@Inject lateinit var nsDeviceStatus: NSDeviceStatus @Inject lateinit var nsDeviceStatus: NSDeviceStatus
@Inject lateinit var loopPlugin: LoopPlugin @Inject lateinit var loopPlugin: LoopPlugin
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin
@Inject lateinit var activePlugin: ActivePluginProvider @Inject lateinit var activePlugin: ActivePluginProvider
@Inject lateinit var treatmentsPlugin: TreatmentsPlugin @Inject lateinit var treatmentsPlugin: TreatmentsPlugin
@Inject lateinit var iobCobCalculator: IobCobCalculator @Inject lateinit var iobCobCalculator: IobCobCalculator

View file

@ -152,7 +152,7 @@ open class VirtualPumpPlugin @Inject constructor(
override fun setNewBasalProfile(profile: Profile): PumpEnactResult { override fun setNewBasalProfile(profile: Profile): PumpEnactResult {
lastDataTime = System.currentTimeMillis() lastDataTime = System.currentTimeMillis()
// Do nothing here. we are using ConfigBuilderPlugin.getPlugin().getActiveProfile().getProfile(); // Do nothing here. we are using database profile
val result = PumpEnactResult(injector) val result = PumpEnactResult(injector)
result.success = true result.success = true
val notification = Notification(Notification.PROFILE_SET_OK, resourceHelper.gs(R.string.profile_set_ok), Notification.INFO, 60) val notification = Notification(Notification.PROFILE_SET_OK, resourceHelper.gs(R.string.profile_set_ok), Notification.INFO, 60)

View file

@ -12,14 +12,9 @@ import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.R import info.nightscout.androidaps.R
import info.nightscout.androidaps.dialogs.ProfileSwitchDialog import info.nightscout.androidaps.dialogs.ProfileSwitchDialog
import info.nightscout.androidaps.events.EventPumpStatusChanged import info.nightscout.androidaps.events.EventPumpStatusChanged
import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.*
import info.nightscout.androidaps.interfaces.CommandQueueProvider
import info.nightscout.androidaps.interfaces.ImportExportPrefsInterface
import info.nightscout.androidaps.interfaces.PluginType
import info.nightscout.androidaps.interfaces.ProfileFunction
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesFragment import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesFragment
import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugin import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugin
import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin
@ -55,7 +50,7 @@ class SWDefinition @Inject constructor(
private val activePlugin: ActivePluginProvider, private val activePlugin: ActivePluginProvider,
private val commandQueue: CommandQueueProvider, private val commandQueue: CommandQueueProvider,
private val objectivesPlugin: ObjectivesPlugin, private val objectivesPlugin: ObjectivesPlugin,
private val configBuilderPlugin: ConfigBuilderPlugin, private val configBuilder: ConfigBuilder,
private val loopPlugin: LoopPlugin, private val loopPlugin: LoopPlugin,
private val nsClientPlugin: NSClientPlugin, private val nsClientPlugin: NSClientPlugin,
private val nsProfilePlugin: NSProfilePlugin, private val nsProfilePlugin: NSProfilePlugin,
@ -174,7 +169,7 @@ class SWDefinition @Inject constructor(
.add(SWButton(injector) .add(SWButton(injector)
.text(R.string.enable_nsclient) .text(R.string.enable_nsclient)
.action { .action {
configBuilderPlugin.performPluginSwitch(nsClientPlugin, true, PluginType.GENERAL) configBuilder.performPluginSwitch(nsClientPlugin, true, PluginType.GENERAL)
rxBus.send(EventSWUpdate(true)) rxBus.send(EventSWUpdate(true))
} }
.visibility { !nsClientPlugin.isEnabled(PluginType.GENERAL) }) .visibility { !nsClientPlugin.isEnabled(PluginType.GENERAL) })
@ -360,7 +355,7 @@ class SWDefinition @Inject constructor(
.add(SWButton(injector) .add(SWButton(injector)
.text(R.string.enableloop) .text(R.string.enableloop)
.action { .action {
configBuilderPlugin.performPluginSwitch(loopPlugin, true, PluginType.LOOP) configBuilder.performPluginSwitch(loopPlugin, true, PluginType.LOOP)
rxBus.send(EventSWUpdate(true)) rxBus.send(EventSWUpdate(true))
} }
.visibility { !loopPlugin.isEnabled(PluginType.LOOP) }) .visibility { !loopPlugin.isEnabled(PluginType.LOOP) })

View file

@ -14,7 +14,6 @@ import info.nightscout.androidaps.database.AppRepository
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin
import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugin import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugin
import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective
@ -50,7 +49,7 @@ import java.util.*
*/ */
@RunWith(PowerMockRunner::class) @RunWith(PowerMockRunner::class)
@PrepareForTest( @PrepareForTest(
ConfigBuilderPlugin::class, ConstraintChecker::class, SP::class, Context::class, ConstraintChecker::class, SP::class, Context::class,
OpenAPSAMAPlugin::class, OpenAPSSMBPlugin::class, TreatmentsPlugin::class, TreatmentService::class, OpenAPSAMAPlugin::class, OpenAPSSMBPlugin::class, TreatmentsPlugin::class, TreatmentService::class,
VirtualPumpPlugin::class, DetailedBolusInfoStorage::class, TemporaryBasalStorage::class, GlimpPlugin::class, Profiler::class, VirtualPumpPlugin::class, DetailedBolusInfoStorage::class, TemporaryBasalStorage::class, GlimpPlugin::class, Profiler::class,
UserEntryLogger::class, LoggerUtils::class, AppRepository::class) UserEntryLogger::class, LoggerUtils::class, AppRepository::class)

View file

@ -1,30 +0,0 @@
package info.nightscout.androidaps.utils;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* Created by mike on 22.12.2017.
*/
public class PercentageSplitterTest {
public PercentageSplitterTest() {
super();
}
@Test
public void pureNameTestPercentageOnly() {
assertEquals("Fiasp", PercentageSplitter.pureName("Fiasp(101%)"));
}
@Test
public void pureNameTestPercentageAndPositiveTimeShift() {
assertEquals("Fiasp", PercentageSplitter.pureName("Fiasp (101%,2h)"));
}
@Test
public void pureNameTestPercentageAndNegtiveTimeShift() {
assertEquals("Fiasp", PercentageSplitter.pureName("Fiasp (50%,-2h)"));
}
}

View file

@ -0,0 +1,23 @@
package info.nightscout.androidaps.utils
import info.nightscout.androidaps.utils.PercentageSplitter.pureName
import org.junit.Assert
import org.junit.Test
/**
* Created by mike on 22.12.2017.
*/
class PercentageSplitterTest {
@Test fun pureNameTestPercentageOnly() {
Assert.assertEquals("Fiasp", pureName("Fiasp(101%)"))
}
@Test fun pureNameTestPercentageAndPositiveTimeShift() {
Assert.assertEquals("Fiasp", pureName("Fiasp (101%,2h)"))
}
@Test fun pureNameTestPercentageAndNegtiveTimeShift() {
Assert.assertEquals("Fiasp", pureName("Fiasp (50%,-2h)"))
}
}

View file

@ -8,7 +8,7 @@ import info.nightscout.androidaps.database.entities.UserEntry
import info.nightscout.androidaps.database.entities.UserEntry.Sources import info.nightscout.androidaps.database.entities.UserEntry.Sources
import info.nightscout.androidaps.events.EventRefreshOverview import info.nightscout.androidaps.events.EventRefreshOverview
import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.interfaces.CommandQueueProvider
import info.nightscout.androidaps.interfaces.ConfigBuilderInterface import info.nightscout.androidaps.interfaces.ConfigBuilder
import info.nightscout.androidaps.interfaces.LoopInterface import info.nightscout.androidaps.interfaces.LoopInterface
import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.interfaces.PluginBase
import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.interfaces.PluginType
@ -21,7 +21,7 @@ import javax.inject.Inject
class ActionLoopDisable(injector: HasAndroidInjector) : Action(injector) { class ActionLoopDisable(injector: HasAndroidInjector) : Action(injector) {
@Inject lateinit var loopPlugin: LoopInterface @Inject lateinit var loopPlugin: LoopInterface
@Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var configBuilderPlugin: ConfigBuilderInterface @Inject lateinit var configBuilder: ConfigBuilder
@Inject lateinit var commandQueue: CommandQueueProvider @Inject lateinit var commandQueue: CommandQueueProvider
@Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var rxBus: RxBusWrapper
@Inject lateinit var uel: UserEntryLogger @Inject lateinit var uel: UserEntryLogger
@ -33,7 +33,7 @@ class ActionLoopDisable(injector: HasAndroidInjector) : Action(injector) {
override fun doAction(callback: Callback) { override fun doAction(callback: Callback) {
if ((loopPlugin as PluginBase).isEnabled()) { if ((loopPlugin as PluginBase).isEnabled()) {
(loopPlugin as PluginBase).setPluginEnabled(PluginType.LOOP, false) (loopPlugin as PluginBase).setPluginEnabled(PluginType.LOOP, false)
configBuilderPlugin.storeSettings("ActionLoopDisable") configBuilder.storeSettings("ActionLoopDisable")
uel.log(UserEntry.Action.LOOP_DISABLED, Sources.Automation, title) uel.log(UserEntry.Action.LOOP_DISABLED, Sources.Automation, title)
commandQueue.cancelTempBasal(true, object : Callback() { commandQueue.cancelTempBasal(true, object : Callback() {
override fun run() { override fun run() {

View file

@ -7,7 +7,7 @@ import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.database.entities.UserEntry
import info.nightscout.androidaps.database.entities.UserEntry.Sources import info.nightscout.androidaps.database.entities.UserEntry.Sources
import info.nightscout.androidaps.events.EventRefreshOverview import info.nightscout.androidaps.events.EventRefreshOverview
import info.nightscout.androidaps.interfaces.ConfigBuilderInterface import info.nightscout.androidaps.interfaces.ConfigBuilder
import info.nightscout.androidaps.interfaces.LoopInterface import info.nightscout.androidaps.interfaces.LoopInterface
import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.interfaces.PluginBase
import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.interfaces.PluginType
@ -21,7 +21,7 @@ class ActionLoopEnable(injector: HasAndroidInjector) : Action(injector) {
@Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var loopPlugin: LoopInterface @Inject lateinit var loopPlugin: LoopInterface
@Inject lateinit var configBuilderPlugin: ConfigBuilderInterface @Inject lateinit var configBuilder: ConfigBuilder
@Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var rxBus: RxBusWrapper
@Inject lateinit var uel: UserEntryLogger @Inject lateinit var uel: UserEntryLogger
@ -32,7 +32,7 @@ class ActionLoopEnable(injector: HasAndroidInjector) : Action(injector) {
override fun doAction(callback: Callback) { override fun doAction(callback: Callback) {
if (!(loopPlugin as PluginBase).isEnabled()) { if (!(loopPlugin as PluginBase).isEnabled()) {
(loopPlugin as PluginBase).setPluginEnabled(PluginType.LOOP, true) (loopPlugin as PluginBase).setPluginEnabled(PluginType.LOOP, true)
configBuilderPlugin.storeSettings("ActionLoopEnable") configBuilder.storeSettings("ActionLoopEnable")
rxBus.send(EventRefreshOverview("ActionLoopEnable")) rxBus.send(EventRefreshOverview("ActionLoopEnable"))
uel.log(UserEntry.Action.LOOP_ENABLED, Sources.Automation, title) uel.log(UserEntry.Action.LOOP_ENABLED, Sources.Automation, title)
callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run() callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run()

View file

@ -7,7 +7,7 @@ import info.nightscout.androidaps.data.PumpEnactResult
import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.database.entities.UserEntry
import info.nightscout.androidaps.database.entities.UserEntry.Sources import info.nightscout.androidaps.database.entities.UserEntry.Sources
import info.nightscout.androidaps.events.EventRefreshOverview import info.nightscout.androidaps.events.EventRefreshOverview
import info.nightscout.androidaps.interfaces.ConfigBuilderInterface import info.nightscout.androidaps.interfaces.ConfigBuilder
import info.nightscout.androidaps.interfaces.LoopInterface import info.nightscout.androidaps.interfaces.LoopInterface
import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.logging.UserEntryLogger
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
@ -18,7 +18,7 @@ import javax.inject.Inject
class ActionLoopResume(injector: HasAndroidInjector) : Action(injector) { class ActionLoopResume(injector: HasAndroidInjector) : Action(injector) {
@Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var resourceHelper: ResourceHelper
@Inject lateinit var loopPlugin: LoopInterface @Inject lateinit var loopPlugin: LoopInterface
@Inject lateinit var configBuilderPlugin: ConfigBuilderInterface @Inject lateinit var configBuilder: ConfigBuilder
@Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var rxBus: RxBusWrapper
@Inject lateinit var uel: UserEntryLogger @Inject lateinit var uel: UserEntryLogger
@ -29,7 +29,7 @@ class ActionLoopResume(injector: HasAndroidInjector) : Action(injector) {
override fun doAction(callback: Callback) { override fun doAction(callback: Callback) {
if (loopPlugin.isSuspended) { if (loopPlugin.isSuspended) {
loopPlugin.suspendTo(0) loopPlugin.suspendTo(0)
configBuilderPlugin.storeSettings("ActionLoopResume") configBuilder.storeSettings("ActionLoopResume")
loopPlugin.createOfflineEvent(0) loopPlugin.createOfflineEvent(0)
rxBus.send(EventRefreshOverview("ActionLoopResume")) rxBus.send(EventRefreshOverview("ActionLoopResume"))
uel.log(UserEntry.Action.RESUME, Sources.Automation, title) uel.log(UserEntry.Action.RESUME, Sources.Automation, title)

View file

@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation
import dagger.android.AndroidInjector import dagger.android.AndroidInjector
import dagger.android.HasAndroidInjector import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.TestBase import info.nightscout.androidaps.TestBase
import info.nightscout.androidaps.interfaces.ConfigBuilderInterface import info.nightscout.androidaps.interfaces.ConfigBuilder
import info.nightscout.androidaps.interfaces.LoopInterface import info.nightscout.androidaps.interfaces.LoopInterface
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.general.automation.actions.ActionLoopEnable import info.nightscout.androidaps.plugins.general.automation.actions.ActionLoopEnable
@ -22,7 +22,7 @@ class AutomationEventTest : TestBase() {
@Mock lateinit var loopPlugin: LoopInterface @Mock lateinit var loopPlugin: LoopInterface
@Mock lateinit var resourceHelper: ResourceHelper @Mock lateinit var resourceHelper: ResourceHelper
@Mock lateinit var configBuilderPlugin: ConfigBuilderInterface @Mock lateinit var configBuilder: ConfigBuilder
var injector: HasAndroidInjector = HasAndroidInjector { var injector: HasAndroidInjector = HasAndroidInjector {
AndroidInjector { AndroidInjector {
@ -32,7 +32,7 @@ class AutomationEventTest : TestBase() {
if (it is ActionLoopEnable) { if (it is ActionLoopEnable) {
it.loopPlugin = loopPlugin it.loopPlugin = loopPlugin
it.resourceHelper = resourceHelper it.resourceHelper = resourceHelper
it.configBuilderPlugin = configBuilderPlugin it.configBuilder = configBuilder
it.rxBus = RxBusWrapper(aapsSchedulers) it.rxBus = RxBusWrapper(aapsSchedulers)
} }
} }

View file

@ -51,7 +51,7 @@ class ActionLoopDisableTest : ActionsTestBase() {
override fun run() {} override fun run() {}
}) })
Mockito.verify(loopPlugin, Mockito.times(1)).setPluginEnabled(PluginType.LOOP, false) Mockito.verify(loopPlugin, Mockito.times(1)).setPluginEnabled(PluginType.LOOP, false)
Mockito.verify(configBuilderPlugin, Mockito.times(1)).storeSettings("ActionLoopDisable") Mockito.verify(configBuilder, Mockito.times(1)).storeSettings("ActionLoopDisable")
Mockito.verify(commandQueue, Mockito.times(1)).cancelTempBasal(eq(true), anyObject()) Mockito.verify(commandQueue, Mockito.times(1)).cancelTempBasal(eq(true), anyObject())
`when`(loopPlugin.isEnabled()).thenReturn(false) `when`(loopPlugin.isEnabled()).thenReturn(false)
@ -61,7 +61,7 @@ class ActionLoopDisableTest : ActionsTestBase() {
override fun run() {} override fun run() {}
}) })
Mockito.verify(loopPlugin, Mockito.times(1)).setPluginEnabled(PluginType.LOOP, false) Mockito.verify(loopPlugin, Mockito.times(1)).setPluginEnabled(PluginType.LOOP, false)
Mockito.verify(configBuilderPlugin, Mockito.times(1)).storeSettings("ActionLoopDisable") Mockito.verify(configBuilder, Mockito.times(1)).storeSettings("ActionLoopDisable")
Mockito.verify(commandQueue, Mockito.times(1)).cancelTempBasal(eq(true), anyObject()) Mockito.verify(commandQueue, Mockito.times(1)).cancelTempBasal(eq(true), anyObject())
} }
} }

View file

@ -45,7 +45,7 @@ class ActionLoopEnableTest : ActionsTestBase() {
override fun run() {} override fun run() {}
}) })
Mockito.verify(loopPlugin, Mockito.times(1)).setPluginEnabled(PluginType.LOOP, true) Mockito.verify(loopPlugin, Mockito.times(1)).setPluginEnabled(PluginType.LOOP, true)
Mockito.verify(configBuilderPlugin, Mockito.times(1)).storeSettings("ActionLoopEnable") Mockito.verify(configBuilder, Mockito.times(1)).storeSettings("ActionLoopEnable")
`when`(loopPlugin.isEnabled()).thenReturn(true) `when`(loopPlugin.isEnabled()).thenReturn(true)
@ -54,6 +54,6 @@ class ActionLoopEnableTest : ActionsTestBase() {
override fun run() {} override fun run() {}
}) })
Mockito.verify(loopPlugin, Mockito.times(1)).setPluginEnabled(PluginType.LOOP, true) Mockito.verify(loopPlugin, Mockito.times(1)).setPluginEnabled(PluginType.LOOP, true)
Mockito.verify(configBuilderPlugin, Mockito.times(1)).storeSettings("ActionLoopEnable") Mockito.verify(configBuilder, Mockito.times(1)).storeSettings("ActionLoopEnable")
} }
} }

View file

@ -42,7 +42,7 @@ class ActionLoopResumeTest : ActionsTestBase() {
override fun run() {} override fun run() {}
}) })
Mockito.verify(loopPlugin, Mockito.times(1)).suspendTo(0) Mockito.verify(loopPlugin, Mockito.times(1)).suspendTo(0)
Mockito.verify(configBuilderPlugin, Mockito.times(1)).storeSettings("ActionLoopResume") Mockito.verify(configBuilder, Mockito.times(1)).storeSettings("ActionLoopResume")
Mockito.verify(loopPlugin, Mockito.times(1)).createOfflineEvent(0) Mockito.verify(loopPlugin, Mockito.times(1)).createOfflineEvent(0)
// another call should keep it resumed, , no new invocation // another call should keep it resumed, , no new invocation
@ -51,7 +51,7 @@ class ActionLoopResumeTest : ActionsTestBase() {
override fun run() {} override fun run() {}
}) })
Mockito.verify(loopPlugin, Mockito.times(1)).suspendTo(0) Mockito.verify(loopPlugin, Mockito.times(1)).suspendTo(0)
Mockito.verify(configBuilderPlugin, Mockito.times(1)).storeSettings("ActionLoopResume") Mockito.verify(configBuilder, Mockito.times(1)).storeSettings("ActionLoopResume")
Mockito.verify(loopPlugin, Mockito.times(1)).createOfflineEvent(0) Mockito.verify(loopPlugin, Mockito.times(1)).createOfflineEvent(0)
} }
} }

View file

@ -40,7 +40,7 @@ open class ActionsTestBase : TestBaseWithProfile() {
@Mock lateinit var sp: SP @Mock lateinit var sp: SP
@Mock lateinit var commandQueue: CommandQueueProvider @Mock lateinit var commandQueue: CommandQueueProvider
@Mock lateinit var configBuilderPlugin: ConfigBuilderInterface @Mock lateinit var configBuilder: ConfigBuilder
@Mock lateinit var activePlugin: ActivePluginProvider @Mock lateinit var activePlugin: ActivePluginProvider
@Mock lateinit var profilePlugin: ProfileInterface @Mock lateinit var profilePlugin: ProfileInterface
@Mock lateinit var smsCommunicatorPlugin: SmsCommunicatorInterface @Mock lateinit var smsCommunicatorPlugin: SmsCommunicatorInterface
@ -99,21 +99,21 @@ open class ActionsTestBase : TestBaseWithProfile() {
if (it is ActionLoopResume) { if (it is ActionLoopResume) {
it.loopPlugin = loopPlugin it.loopPlugin = loopPlugin
it.resourceHelper = resourceHelper it.resourceHelper = resourceHelper
it.configBuilderPlugin = configBuilderPlugin it.configBuilder = configBuilder
it.rxBus = rxBus it.rxBus = rxBus
it.uel = uel it.uel = uel
} }
if (it is ActionLoopEnable) { if (it is ActionLoopEnable) {
it.loopPlugin = loopPlugin it.loopPlugin = loopPlugin
it.resourceHelper = resourceHelper it.resourceHelper = resourceHelper
it.configBuilderPlugin = configBuilderPlugin it.configBuilder = configBuilder
it.rxBus = rxBus it.rxBus = rxBus
it.uel = uel it.uel = uel
} }
if (it is ActionLoopDisable) { if (it is ActionLoopDisable) {
it.loopPlugin = loopPlugin it.loopPlugin = loopPlugin
it.resourceHelper = resourceHelper it.resourceHelper = resourceHelper
it.configBuilderPlugin = configBuilderPlugin it.configBuilder = configBuilder
it.commandQueue = commandQueue it.commandQueue = commandQueue
it.rxBus = rxBus it.rxBus = rxBus
it.uel = uel it.uel = uel

View file

@ -1,6 +1,7 @@
package info.nightscout.androidaps.interfaces package info.nightscout.androidaps.interfaces
interface ConfigBuilderInterface { interface ConfigBuilder {
fun initialize()
fun storeSettings(from: String) fun storeSettings(from: String)
fun performPluginSwitch(changedPlugin: PluginBase, enabled: Boolean, type: PluginType) fun performPluginSwitch(changedPlugin: PluginBase, enabled: Boolean, type: PluginType)
} }

View file

@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.configBuilder
import info.nightscout.androidaps.core.R import info.nightscout.androidaps.core.R
import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.interfaces.ConfigBuilderInterface import info.nightscout.androidaps.interfaces.ConfigBuilder
import info.nightscout.androidaps.interfaces.InsulinInterface import info.nightscout.androidaps.interfaces.InsulinInterface
import info.nightscout.androidaps.interfaces.PluginType import info.nightscout.androidaps.interfaces.PluginType
import info.nightscout.androidaps.interfaces.SensitivityInterface import info.nightscout.androidaps.interfaces.SensitivityInterface
@ -19,7 +19,7 @@ import javax.inject.Singleton
@Singleton @Singleton
class RunningConfiguration @Inject constructor( class RunningConfiguration @Inject constructor(
private val activePlugin: ActivePluginProvider, private val activePlugin: ActivePluginProvider,
private val configBuilder: ConfigBuilderInterface, private val configBuilder: ConfigBuilder,
private val sp: SP, private val sp: SP,
private val aapsLogger: AAPSLogger private val aapsLogger: AAPSLogger
) { ) {

View file

@ -19,7 +19,7 @@ import info.nightscout.androidaps.danaRv2.DanaRv2Plugin;
import info.nightscout.androidaps.danar.DanaRPlugin; import info.nightscout.androidaps.danar.DanaRPlugin;
import info.nightscout.androidaps.interfaces.ActivePluginProvider; import info.nightscout.androidaps.interfaces.ActivePluginProvider;
import info.nightscout.androidaps.interfaces.CommandQueueProvider; import info.nightscout.androidaps.interfaces.CommandQueueProvider;
import info.nightscout.androidaps.interfaces.ConfigBuilderInterface; import info.nightscout.androidaps.interfaces.ConfigBuilder;
import info.nightscout.androidaps.interfaces.DatabaseHelperInterface; import info.nightscout.androidaps.interfaces.DatabaseHelperInterface;
import info.nightscout.androidaps.interfaces.PumpSync; import info.nightscout.androidaps.interfaces.PumpSync;
import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.AAPSLogger;
@ -48,7 +48,7 @@ public class MessageBase {
@Inject public RxBusWrapper rxBus; @Inject public RxBusWrapper rxBus;
@Inject public ResourceHelper resourceHelper; @Inject public ResourceHelper resourceHelper;
@Inject public ActivePluginProvider activePlugin; @Inject public ActivePluginProvider activePlugin;
@Inject public ConfigBuilderInterface configBuilder; @Inject public ConfigBuilder configBuilder;
@Inject public CommandQueueProvider commandQueue; @Inject public CommandQueueProvider commandQueue;
@Inject public DetailedBolusInfoStorage detailedBolusInfoStorage; @Inject public DetailedBolusInfoStorage detailedBolusInfoStorage;
@Inject public TemporaryBasalStorage temporaryBasalStorage; @Inject public TemporaryBasalStorage temporaryBasalStorage;

View file

@ -36,7 +36,7 @@ open class DanaRTestBase : TestBase() {
@Mock lateinit var danaRKoreanPlugin: DanaRKoreanPlugin @Mock lateinit var danaRKoreanPlugin: DanaRKoreanPlugin
@Mock lateinit var danaRv2Plugin: DanaRv2Plugin @Mock lateinit var danaRv2Plugin: DanaRv2Plugin
@Mock lateinit var resourceHelper: ResourceHelper @Mock lateinit var resourceHelper: ResourceHelper
@Mock lateinit var configBuilder: ConfigBuilderInterface @Mock lateinit var configBuilder: ConfigBuilder
@Mock lateinit var commandQueue: CommandQueueProvider @Mock lateinit var commandQueue: CommandQueueProvider
@Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage @Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage
@Mock lateinit var constraintChecker: ConstraintChecker @Mock lateinit var constraintChecker: ConstraintChecker