RRemove unused injection and try to fix tests...
It works for LoopPluginTest, but not for ClassicPrefsFormatTest as many other... (don't know if it's my config or not)
This commit is contained in:
parent
ffa9c04496
commit
22dfea652d
3 changed files with 7 additions and 17 deletions
|
@ -9,6 +9,7 @@ import info.nightscout.androidaps.R
|
|||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.database.AppRepository
|
||||
import info.nightscout.androidaps.interfaces.*
|
||||
import info.nightscout.androidaps.logging.UserEntryLogger
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||
import info.nightscout.androidaps.plugins.configBuilder.RunningConfiguration
|
||||
|
@ -30,7 +31,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest
|
|||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest(ConstraintChecker::class, ReceiverStatusStore::class, RunningConfiguration::class)
|
||||
@PrepareForTest(ConstraintChecker::class, ReceiverStatusStore::class, RunningConfiguration::class, UserEntryLogger::class)
|
||||
class LoopPluginTest : TestBase() {
|
||||
|
||||
@Mock lateinit var sp: SP
|
||||
|
@ -48,6 +49,7 @@ class LoopPluginTest : TestBase() {
|
|||
@Mock lateinit var receiverStatusStore: ReceiverStatusStore
|
||||
@Mock lateinit var notificationManager: NotificationManager
|
||||
@Mock lateinit var repository: AppRepository
|
||||
@Mock lateinit var uel:UserEntryLogger
|
||||
@Mock lateinit var dateUtil: DateUtil
|
||||
@Mock lateinit var runningConfiguration: RunningConfiguration
|
||||
|
||||
|
@ -56,7 +58,7 @@ class LoopPluginTest : TestBase() {
|
|||
val injector = HasAndroidInjector { AndroidInjector { } }
|
||||
@Before fun prepareMock() {
|
||||
|
||||
loopPlugin = LoopPlugin(injector, aapsLogger, aapsSchedulers, rxBus, sp, Config(), constraintChecker, resourceHelper, profileFunction, context, commandQueue, activePlugin, virtualPumpPlugin, iobCobCalculator, receiverStatusStore, fabricPrivacy, dateUtil, repository, runningConfiguration)
|
||||
loopPlugin = LoopPlugin(injector, aapsLogger, aapsSchedulers, rxBus, sp, Config(), constraintChecker, resourceHelper, profileFunction, context, commandQueue, activePlugin, virtualPumpPlugin, iobCobCalculator, receiverStatusStore, fabricPrivacy, dateUtil, uel, repository, runningConfiguration)
|
||||
`when`(activePlugin.activePump).thenReturn(virtualPumpPlugin)
|
||||
`when`(context.getSystemService(Context.NOTIFICATION_SERVICE)).thenReturn(notificationManager)
|
||||
}
|
||||
|
|
|
@ -3,9 +3,6 @@ package info.nightscout.androidaps.plugins.general.maintenance.formats
|
|||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.core.R
|
||||
import info.nightscout.androidaps.database.entities.UserEntry
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.Translator
|
||||
import info.nightscout.androidaps.utils.userEntry.UserEntryPresentationHelper
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.storage.Storage
|
||||
|
@ -18,9 +15,6 @@ import javax.inject.Singleton
|
|||
@Singleton
|
||||
class ClassicPrefsFormat @Inject constructor(
|
||||
private var resourceHelper: ResourceHelper,
|
||||
private var dateUtil: DateUtil,
|
||||
private var translator: Translator,
|
||||
private var profileFunction: ProfileFunction,
|
||||
private var userEntryPresentationHelper: UserEntryPresentationHelper,
|
||||
private var storage: Storage
|
||||
) : PrefsFormat {
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package info.nightscout.androidaps.plugins.general.maintenance.formats
|
||||
|
||||
import info.nightscout.androidaps.TestBase
|
||||
import info.nightscout.androidaps.interfaces.ProfileFunction
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.Translator
|
||||
import info.nightscout.androidaps.utils.userEntry.UserEntryPresentationHelper
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import org.junit.Assert
|
||||
|
@ -16,13 +13,10 @@ import org.powermock.modules.junit4.PowerMockRunner
|
|||
import java.io.File
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
@PrepareForTest(File::class, Translator::class)
|
||||
@PrepareForTest(File::class, UserEntryPresentationHelper::class)
|
||||
class ClassicPrefsFormatTest : TestBase() {
|
||||
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
@Mock lateinit var dateUtil: DateUtil
|
||||
@Mock lateinit var translator: Translator
|
||||
@Mock lateinit var profileFunction: ProfileFunction
|
||||
@Mock lateinit var userEntryPresentationHelper: UserEntryPresentationHelper
|
||||
@Mock lateinit var file: MockedFile
|
||||
|
||||
|
@ -30,7 +24,7 @@ class ClassicPrefsFormatTest : TestBase() {
|
|||
fun preferenceLoadingTest() {
|
||||
val test = "key1::val1\nkeyB::valB"
|
||||
|
||||
val classicFormat = ClassicPrefsFormat(resourceHelper, dateUtil, translator, profileFunction, userEntryPresentationHelper, SingleStringStorage(test))
|
||||
val classicFormat = ClassicPrefsFormat(resourceHelper, userEntryPresentationHelper, SingleStringStorage(test))
|
||||
val prefs = classicFormat.loadPreferences(getMockedFile(), "")
|
||||
|
||||
Assert.assertEquals(prefs.values.size, 2)
|
||||
|
@ -42,7 +36,7 @@ class ClassicPrefsFormatTest : TestBase() {
|
|||
@Test
|
||||
fun preferenceSavingTest() {
|
||||
val storage = SingleStringStorage("")
|
||||
val classicFormat = ClassicPrefsFormat(resourceHelper, dateUtil, translator, profileFunction, userEntryPresentationHelper, storage)
|
||||
val classicFormat = ClassicPrefsFormat(resourceHelper, userEntryPresentationHelper, storage)
|
||||
val prefs = Prefs(
|
||||
mapOf(
|
||||
"key1" to "A",
|
||||
|
|
Loading…
Reference in a new issue