diff --git a/app/src/androidTest/java/info/nightscout/androidaps/RealPumpTest.kt b/app/src/androidTest/java/info/nightscout/androidaps/RealPumpTest.kt index 724419e135..75ae0caa20 100644 --- a/app/src/androidTest/java/info/nightscout/androidaps/RealPumpTest.kt +++ b/app/src/androidTest/java/info/nightscout/androidaps/RealPumpTest.kt @@ -1,35 +1,8 @@ package info.nightscout.androidaps -import android.os.SystemClock import androidx.test.ext.junit.runners.AndroidJUnit4 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 javax.inject.Inject @LargeTest @RunWith(AndroidJUnit4::class) diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.kt b/app/src/main/java/info/nightscout/androidaps/MainApp.kt index b994405383..5a12b40c54 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.kt +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.kt @@ -18,11 +18,11 @@ import info.nightscout.androidaps.db.CompatDBHelper import info.nightscout.androidaps.db.DatabaseHelper import info.nightscout.androidaps.db.StaticInjector import info.nightscout.androidaps.dependencyInjection.DaggerAppComponent +import info.nightscout.androidaps.interfaces.ConfigBuilder import info.nightscout.androidaps.interfaces.PluginBase import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.LTag 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.constraints.versionChecker.VersionCheckerUtils import info.nightscout.androidaps.receivers.BTReceiver @@ -49,7 +49,7 @@ class MainApp : DaggerApplication() { @Inject lateinit var versionCheckersUtils: VersionCheckerUtils @Inject lateinit var sp: SP @Inject lateinit var config: Config - @Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin + @Inject lateinit var configBuilder: ConfigBuilder @Inject lateinit var keepAliveManager: KeepAliveManager @Inject lateinit var plugins: List<@JvmSuppressWildcards PluginBase> @Inject lateinit var compatDBHelper: CompatDBHelper @@ -85,7 +85,7 @@ class MainApp : DaggerApplication() { // Register all tabs in app here pluginStore.plugins = plugins - configBuilderPlugin.initialize() + configBuilder.initialize() keepAliveManager.setAlarm(this) doMigrations() uel.log(UserEntry.Action.START_AAPS, UserEntry.Sources.Aaps) diff --git a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt index d73bf3f094..e467f4f9bb 100644 --- a/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/dependencyInjection/AppModule.kt @@ -78,7 +78,7 @@ open class AppModule { @Binds fun bindActivePluginProvider(pluginStore: PluginStore): ActivePluginProvider @Binds fun bindCommandQueueProvider(commandQueue: CommandQueue): CommandQueueProvider @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 bindDatabaseHelperInterface(databaseHelperProvider: DatabaseHelperProvider): DatabaseHelperInterface @Binds fun bindNotificationHolderInterface(notificationHolder: NotificationHolder): NotificationHolderInterface diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt index a93409a1d9..3973b03491 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/LoopDialog.kt @@ -23,7 +23,6 @@ import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin 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.queue.Callback import info.nightscout.androidaps.utils.FabricPrivacy @@ -47,7 +46,7 @@ class LoopDialog : DaggerDialogFragment() { @Inject lateinit var activePlugin: ActivePluginProvider @Inject lateinit var constraintChecker: ConstraintChecker @Inject lateinit var commandQueue: CommandQueueProvider - @Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin + @Inject lateinit var configBuilder: ConfigBuilder @Inject lateinit var uel: UserEntryLogger private var showOkCancel: Boolean = true @@ -265,7 +264,7 @@ class LoopDialog : DaggerDialogFragment() { uel.log(Action.LOOP_DISABLED, Sources.LoopDialog) loopPlugin.setPluginEnabled(PluginType.LOOP, false) loopPlugin.setFragmentVisible(PluginType.LOOP, false) - configBuilderPlugin.storeSettings("DisablingLoop") + configBuilder.storeSettings("DisablingLoop") rxBus.send(EventRefreshOverview("suspendmenu")) commandQueue.cancelTempBasal(true, object : Callback() { override fun run() { @@ -282,7 +281,7 @@ class LoopDialog : DaggerDialogFragment() { uel.log(Action.LOOP_ENABLED, Sources.LoopDialog) loopPlugin.setPluginEnabled(PluginType.LOOP, true) loopPlugin.setFragmentVisible(PluginType.LOOP, true) - configBuilderPlugin.storeSettings("EnablingLoop") + configBuilder.storeSettings("EnablingLoop") rxBus.send(EventRefreshOverview("suspendmenu")) loopPlugin.createOfflineEvent(0) return true diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt index e50f820091..ef26bbdc56 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/configBuilder/ConfigBuilderPlugin.kt @@ -43,9 +43,9 @@ class ConfigBuilderPlugin @Inject constructor( .shortName(R.string.configbuilder_shortname) .description(R.string.description_config_builder), aapsLogger, resourceHelper, injector -), ConfigBuilderInterface { +), ConfigBuilder { - fun initialize() { + override fun initialize() { (activePlugin as PluginStore).loadDefaults() loadSettings() setAlwaysEnabledPluginsEnabled() diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt index 8862ba6474..d298ca7e06 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt @@ -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.events.EventNewOpenLoopNotification 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.general.nsclient.data.NSDeviceStatus 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 nsDeviceStatus: NSDeviceStatus @Inject lateinit var loopPlugin: LoopPlugin - @Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin @Inject lateinit var activePlugin: ActivePluginProvider @Inject lateinit var treatmentsPlugin: TreatmentsPlugin @Inject lateinit var iobCobCalculator: IobCobCalculator 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 5c15fa88d9..e5401721a6 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 @@ -152,7 +152,7 @@ open class VirtualPumpPlugin @Inject constructor( override fun setNewBasalProfile(profile: Profile): PumpEnactResult { 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) result.success = true val notification = Notification(Notification.PROFILE_SET_OK, resourceHelper.gs(R.string.profile_set_ok), Notification.INFO, 60) diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt index 600a4842e3..f694754bd3 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.kt @@ -12,14 +12,9 @@ import info.nightscout.androidaps.Constants import info.nightscout.androidaps.R import info.nightscout.androidaps.dialogs.ProfileSwitchDialog import info.nightscout.androidaps.events.EventPumpStatusChanged -import info.nightscout.androidaps.interfaces.ActivePluginProvider -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.interfaces.* import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin 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.ObjectivesPlugin import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin @@ -55,7 +50,7 @@ class SWDefinition @Inject constructor( private val activePlugin: ActivePluginProvider, private val commandQueue: CommandQueueProvider, private val objectivesPlugin: ObjectivesPlugin, - private val configBuilderPlugin: ConfigBuilderPlugin, + private val configBuilder: ConfigBuilder, private val loopPlugin: LoopPlugin, private val nsClientPlugin: NSClientPlugin, private val nsProfilePlugin: NSProfilePlugin, @@ -174,7 +169,7 @@ class SWDefinition @Inject constructor( .add(SWButton(injector) .text(R.string.enable_nsclient) .action { - configBuilderPlugin.performPluginSwitch(nsClientPlugin, true, PluginType.GENERAL) + configBuilder.performPluginSwitch(nsClientPlugin, true, PluginType.GENERAL) rxBus.send(EventSWUpdate(true)) } .visibility { !nsClientPlugin.isEnabled(PluginType.GENERAL) }) @@ -360,7 +355,7 @@ class SWDefinition @Inject constructor( .add(SWButton(injector) .text(R.string.enableloop) .action { - configBuilderPlugin.performPluginSwitch(loopPlugin, true, PluginType.LOOP) + configBuilder.performPluginSwitch(loopPlugin, true, PluginType.LOOP) rxBus.send(EventSWUpdate(true)) } .visibility { !loopPlugin.isEnabled(PluginType.LOOP) }) 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 e6ed7f5a5a..02acb99121 100644 --- a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt +++ b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.kt @@ -14,7 +14,6 @@ import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin 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.constraints.objectives.ObjectivesPlugin import info.nightscout.androidaps.plugins.constraints.objectives.objectives.Objective @@ -50,7 +49,7 @@ import java.util.* */ @RunWith(PowerMockRunner::class) @PrepareForTest( - ConfigBuilderPlugin::class, ConstraintChecker::class, SP::class, Context::class, + ConstraintChecker::class, SP::class, Context::class, OpenAPSAMAPlugin::class, OpenAPSSMBPlugin::class, TreatmentsPlugin::class, TreatmentService::class, VirtualPumpPlugin::class, DetailedBolusInfoStorage::class, TemporaryBasalStorage::class, GlimpPlugin::class, Profiler::class, UserEntryLogger::class, LoggerUtils::class, AppRepository::class) diff --git a/app/src/test/java/info/nightscout/androidaps/utils/PercentageSplitterTest.java b/app/src/test/java/info/nightscout/androidaps/utils/PercentageSplitterTest.java deleted file mode 100644 index 37f94c1f2d..0000000000 --- a/app/src/test/java/info/nightscout/androidaps/utils/PercentageSplitterTest.java +++ /dev/null @@ -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)")); - } -} diff --git a/app/src/test/java/info/nightscout/androidaps/utils/PercentageSplitterTest.kt b/app/src/test/java/info/nightscout/androidaps/utils/PercentageSplitterTest.kt new file mode 100644 index 0000000000..89f0e9b903 --- /dev/null +++ b/app/src/test/java/info/nightscout/androidaps/utils/PercentageSplitterTest.kt @@ -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)")) + } +} \ No newline at end of file diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopDisable.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopDisable.kt index 21da41d170..848dc3c3b4 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopDisable.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopDisable.kt @@ -8,7 +8,7 @@ import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.database.entities.UserEntry.Sources import info.nightscout.androidaps.events.EventRefreshOverview 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.PluginBase import info.nightscout.androidaps.interfaces.PluginType @@ -21,7 +21,7 @@ import javax.inject.Inject class ActionLoopDisable(injector: HasAndroidInjector) : Action(injector) { @Inject lateinit var loopPlugin: LoopInterface @Inject lateinit var resourceHelper: ResourceHelper - @Inject lateinit var configBuilderPlugin: ConfigBuilderInterface + @Inject lateinit var configBuilder: ConfigBuilder @Inject lateinit var commandQueue: CommandQueueProvider @Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var uel: UserEntryLogger @@ -33,7 +33,7 @@ class ActionLoopDisable(injector: HasAndroidInjector) : Action(injector) { override fun doAction(callback: Callback) { if ((loopPlugin as PluginBase).isEnabled()) { (loopPlugin as PluginBase).setPluginEnabled(PluginType.LOOP, false) - configBuilderPlugin.storeSettings("ActionLoopDisable") + configBuilder.storeSettings("ActionLoopDisable") uel.log(UserEntry.Action.LOOP_DISABLED, Sources.Automation, title) commandQueue.cancelTempBasal(true, object : Callback() { override fun run() { diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopEnable.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopEnable.kt index 438911d7e1..d9c99ab41b 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopEnable.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopEnable.kt @@ -7,7 +7,7 @@ import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.database.entities.UserEntry.Sources 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.PluginBase import info.nightscout.androidaps.interfaces.PluginType @@ -21,7 +21,7 @@ class ActionLoopEnable(injector: HasAndroidInjector) : Action(injector) { @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var loopPlugin: LoopInterface - @Inject lateinit var configBuilderPlugin: ConfigBuilderInterface + @Inject lateinit var configBuilder: ConfigBuilder @Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var uel: UserEntryLogger @@ -32,7 +32,7 @@ class ActionLoopEnable(injector: HasAndroidInjector) : Action(injector) { override fun doAction(callback: Callback) { if (!(loopPlugin as PluginBase).isEnabled()) { (loopPlugin as PluginBase).setPluginEnabled(PluginType.LOOP, true) - configBuilderPlugin.storeSettings("ActionLoopEnable") + configBuilder.storeSettings("ActionLoopEnable") rxBus.send(EventRefreshOverview("ActionLoopEnable")) uel.log(UserEntry.Action.LOOP_ENABLED, Sources.Automation, title) callback.result(PumpEnactResult(injector).success(true).comment(R.string.ok))?.run() diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopResume.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopResume.kt index 1957bd2beb..a113a84506 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopResume.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopResume.kt @@ -7,7 +7,7 @@ import info.nightscout.androidaps.data.PumpEnactResult import info.nightscout.androidaps.database.entities.UserEntry import info.nightscout.androidaps.database.entities.UserEntry.Sources 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.logging.UserEntryLogger import info.nightscout.androidaps.plugins.bus.RxBusWrapper @@ -18,7 +18,7 @@ import javax.inject.Inject class ActionLoopResume(injector: HasAndroidInjector) : Action(injector) { @Inject lateinit var resourceHelper: ResourceHelper @Inject lateinit var loopPlugin: LoopInterface - @Inject lateinit var configBuilderPlugin: ConfigBuilderInterface + @Inject lateinit var configBuilder: ConfigBuilder @Inject lateinit var rxBus: RxBusWrapper @Inject lateinit var uel: UserEntryLogger @@ -29,7 +29,7 @@ class ActionLoopResume(injector: HasAndroidInjector) : Action(injector) { override fun doAction(callback: Callback) { if (loopPlugin.isSuspended) { loopPlugin.suspendTo(0) - configBuilderPlugin.storeSettings("ActionLoopResume") + configBuilder.storeSettings("ActionLoopResume") loopPlugin.createOfflineEvent(0) rxBus.send(EventRefreshOverview("ActionLoopResume")) uel.log(UserEntry.Action.RESUME, Sources.Automation, title) diff --git a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/AutomationEventTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/AutomationEventTest.kt index 0e5bf8eedc..6c0087b86b 100644 --- a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/AutomationEventTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/AutomationEventTest.kt @@ -3,7 +3,7 @@ package info.nightscout.androidaps.plugins.general.automation import dagger.android.AndroidInjector import dagger.android.HasAndroidInjector 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.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.general.automation.actions.ActionLoopEnable @@ -22,7 +22,7 @@ class AutomationEventTest : TestBase() { @Mock lateinit var loopPlugin: LoopInterface @Mock lateinit var resourceHelper: ResourceHelper - @Mock lateinit var configBuilderPlugin: ConfigBuilderInterface + @Mock lateinit var configBuilder: ConfigBuilder var injector: HasAndroidInjector = HasAndroidInjector { AndroidInjector { @@ -32,7 +32,7 @@ class AutomationEventTest : TestBase() { if (it is ActionLoopEnable) { it.loopPlugin = loopPlugin it.resourceHelper = resourceHelper - it.configBuilderPlugin = configBuilderPlugin + it.configBuilder = configBuilder it.rxBus = RxBusWrapper(aapsSchedulers) } } diff --git a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopDisableTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopDisableTest.kt index ececed86fd..0a0aa4db2b 100644 --- a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopDisableTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopDisableTest.kt @@ -51,7 +51,7 @@ class ActionLoopDisableTest : ActionsTestBase() { override fun run() {} }) 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()) `when`(loopPlugin.isEnabled()).thenReturn(false) @@ -61,7 +61,7 @@ class ActionLoopDisableTest : ActionsTestBase() { override fun run() {} }) 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()) } } \ No newline at end of file diff --git a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopEnableTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopEnableTest.kt index 9851c7b25f..21cc20b448 100644 --- a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopEnableTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopEnableTest.kt @@ -45,7 +45,7 @@ class ActionLoopEnableTest : ActionsTestBase() { override fun run() {} }) 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) @@ -54,6 +54,6 @@ class ActionLoopEnableTest : ActionsTestBase() { override fun run() {} }) 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") } } \ No newline at end of file diff --git a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopResumeTest.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopResumeTest.kt index f3f1a0f480..b24aef178c 100644 --- a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopResumeTest.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionLoopResumeTest.kt @@ -42,7 +42,7 @@ class ActionLoopResumeTest : ActionsTestBase() { override fun run() {} }) 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) // another call should keep it resumed, , no new invocation @@ -51,7 +51,7 @@ class ActionLoopResumeTest : ActionsTestBase() { override fun run() {} }) 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) } } \ No newline at end of file diff --git a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionsTestBase.kt b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionsTestBase.kt index b920cc453f..d03c0fa8d2 100644 --- a/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionsTestBase.kt +++ b/automation/src/test/java/info/nightscout/androidaps/plugins/general/automation/actions/ActionsTestBase.kt @@ -40,7 +40,7 @@ open class ActionsTestBase : TestBaseWithProfile() { @Mock lateinit var sp: SP @Mock lateinit var commandQueue: CommandQueueProvider - @Mock lateinit var configBuilderPlugin: ConfigBuilderInterface + @Mock lateinit var configBuilder: ConfigBuilder @Mock lateinit var activePlugin: ActivePluginProvider @Mock lateinit var profilePlugin: ProfileInterface @Mock lateinit var smsCommunicatorPlugin: SmsCommunicatorInterface @@ -99,21 +99,21 @@ open class ActionsTestBase : TestBaseWithProfile() { if (it is ActionLoopResume) { it.loopPlugin = loopPlugin it.resourceHelper = resourceHelper - it.configBuilderPlugin = configBuilderPlugin + it.configBuilder = configBuilder it.rxBus = rxBus it.uel = uel } if (it is ActionLoopEnable) { it.loopPlugin = loopPlugin it.resourceHelper = resourceHelper - it.configBuilderPlugin = configBuilderPlugin + it.configBuilder = configBuilder it.rxBus = rxBus it.uel = uel } if (it is ActionLoopDisable) { it.loopPlugin = loopPlugin it.resourceHelper = resourceHelper - it.configBuilderPlugin = configBuilderPlugin + it.configBuilder = configBuilder it.commandQueue = commandQueue it.rxBus = rxBus it.uel = uel diff --git a/core/src/main/java/info/nightscout/androidaps/interfaces/ConfigBuilderInterface.kt b/core/src/main/java/info/nightscout/androidaps/interfaces/ConfigBuilder.kt similarity index 78% rename from core/src/main/java/info/nightscout/androidaps/interfaces/ConfigBuilderInterface.kt rename to core/src/main/java/info/nightscout/androidaps/interfaces/ConfigBuilder.kt index 6b248fd7dc..2c7c9583d6 100644 --- a/core/src/main/java/info/nightscout/androidaps/interfaces/ConfigBuilderInterface.kt +++ b/core/src/main/java/info/nightscout/androidaps/interfaces/ConfigBuilder.kt @@ -1,6 +1,7 @@ package info.nightscout.androidaps.interfaces -interface ConfigBuilderInterface { +interface ConfigBuilder { + fun initialize() fun storeSettings(from: String) fun performPluginSwitch(changedPlugin: PluginBase, enabled: Boolean, type: PluginType) } \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/RunningConfiguration.kt b/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/RunningConfiguration.kt index 269be3f30b..9e809c42db 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/RunningConfiguration.kt +++ b/core/src/main/java/info/nightscout/androidaps/plugins/configBuilder/RunningConfiguration.kt @@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.configBuilder import info.nightscout.androidaps.core.R 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.PluginType import info.nightscout.androidaps.interfaces.SensitivityInterface @@ -19,7 +19,7 @@ import javax.inject.Singleton @Singleton class RunningConfiguration @Inject constructor( private val activePlugin: ActivePluginProvider, - private val configBuilder: ConfigBuilderInterface, + private val configBuilder: ConfigBuilder, private val sp: SP, private val aapsLogger: AAPSLogger ) { diff --git a/danar/src/main/java/info/nightscout/androidaps/danar/comm/MessageBase.java b/danar/src/main/java/info/nightscout/androidaps/danar/comm/MessageBase.java index df769ce431..39115103a9 100644 --- a/danar/src/main/java/info/nightscout/androidaps/danar/comm/MessageBase.java +++ b/danar/src/main/java/info/nightscout/androidaps/danar/comm/MessageBase.java @@ -19,7 +19,7 @@ import info.nightscout.androidaps.danaRv2.DanaRv2Plugin; import info.nightscout.androidaps.danar.DanaRPlugin; import info.nightscout.androidaps.interfaces.ActivePluginProvider; 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.PumpSync; import info.nightscout.androidaps.logging.AAPSLogger; @@ -48,7 +48,7 @@ public class MessageBase { @Inject public RxBusWrapper rxBus; @Inject public ResourceHelper resourceHelper; @Inject public ActivePluginProvider activePlugin; - @Inject public ConfigBuilderInterface configBuilder; + @Inject public ConfigBuilder configBuilder; @Inject public CommandQueueProvider commandQueue; @Inject public DetailedBolusInfoStorage detailedBolusInfoStorage; @Inject public TemporaryBasalStorage temporaryBasalStorage; diff --git a/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/DanaRTestBase.kt b/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/DanaRTestBase.kt index b237d26f12..9677e10d73 100644 --- a/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/DanaRTestBase.kt +++ b/danar/src/test/java/info/nightscout/androidaps/plugins/pump/danaR/comm/DanaRTestBase.kt @@ -36,7 +36,7 @@ open class DanaRTestBase : TestBase() { @Mock lateinit var danaRKoreanPlugin: DanaRKoreanPlugin @Mock lateinit var danaRv2Plugin: DanaRv2Plugin @Mock lateinit var resourceHelper: ResourceHelper - @Mock lateinit var configBuilder: ConfigBuilderInterface + @Mock lateinit var configBuilder: ConfigBuilder @Mock lateinit var commandQueue: CommandQueueProvider @Mock lateinit var detailedBolusInfoStorage: DetailedBolusInfoStorage @Mock lateinit var constraintChecker: ConstraintChecker