commit
d213c512fd
9 changed files with 89 additions and 76 deletions
|
@ -113,18 +113,7 @@ class VersionCheckerUtils @Inject constructor() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(replaceWith = ReplaceWith("numericVersionPart()"), message = "Will not work if RCs have another index number in it.")
|
|
||||||
fun String.versionStrip() = this.mapNotNull {
|
|
||||||
when (it) {
|
|
||||||
in '0'..'9' -> it
|
|
||||||
'.' -> it
|
|
||||||
else -> null
|
|
||||||
}
|
|
||||||
}.joinToString(separator = "")
|
|
||||||
|
|
||||||
private fun String.numericVersionPart(): String =
|
|
||||||
"(((\\d+)\\.)+(\\d+))(\\D(.*))?".toRegex().matchEntire(this)?.groupValues?.getOrNull(1)
|
|
||||||
?: ""
|
|
||||||
|
|
||||||
private fun String?.toNumberList() =
|
private fun String?.toNumberList() =
|
||||||
this?.numericVersionPart().takeIf { !it.isNullOrBlank() }?.split(".")?.map { it.toInt() }
|
this?.numericVersionPart().takeIf { !it.isNullOrBlank() }?.split(".")?.map { it.toInt() }
|
||||||
|
@ -138,4 +127,22 @@ class VersionCheckerUtils @Inject constructor() {
|
||||||
private val CHECK_EVERY = TimeUnit.DAYS.toMillis(1)
|
private val CHECK_EVERY = TimeUnit.DAYS.toMillis(1)
|
||||||
private val WARN_EVERY = TimeUnit.DAYS.toMillis(1)
|
private val WARN_EVERY = TimeUnit.DAYS.toMillis(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun String.numericVersionPart(): String =
|
||||||
|
"(((\\d+)\\.)+(\\d+))(\\D(.*))?".toRegex().matchEntire(this)?.groupValues?.getOrNull(1)
|
||||||
|
?: ""
|
||||||
|
|
||||||
|
fun findVersion(file: String?): String? {
|
||||||
|
val regex = "(.*)version(.*)\"(((\\d+)\\.)+(\\d+))\"(.*)".toRegex()
|
||||||
|
return file?.lines()?.filter { regex.matches(it) }?.mapNotNull { regex.matchEntire(it)?.groupValues?.getOrNull(3) }?.firstOrNull()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated(replaceWith = ReplaceWith("numericVersionPart()"), message = "Will not work if RCs have another index number in it.")
|
||||||
|
fun String.versionStrip() = this.mapNotNull {
|
||||||
|
when (it) {
|
||||||
|
in '0'..'9' -> it
|
||||||
|
'.' -> it
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}.joinToString(separator = "")
|
|
@ -36,10 +36,10 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
|
||||||
@DatabaseTable(tableName = Treatment.TABLE_TREATMENTS)
|
@DatabaseTable(tableName = Treatment.TABLE_TREATMENTS)
|
||||||
public class Treatment implements DataPointWithLabelInterface, DbObjectBase {
|
public class Treatment implements DataPointWithLabelInterface, DbObjectBase {
|
||||||
@Inject DefaultValueHelper defaultValueHelper;
|
@Inject public DefaultValueHelper defaultValueHelper;
|
||||||
@Inject ResourceHelper resourceHelper;
|
@Inject public ResourceHelper resourceHelper;
|
||||||
@Inject ProfileFunction profileFunction;
|
@Inject public ProfileFunction profileFunction;
|
||||||
@Inject ConfigBuilderPlugin configBuilderPlugin;
|
@Inject public ConfigBuilderPlugin configBuilderPlugin;
|
||||||
|
|
||||||
public static final String TABLE_TREATMENTS = "Treatments";
|
public static final String TABLE_TREATMENTS = "Treatments";
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
package info.nightscout.androidaps.plugins.constraints.signatureVerifier
|
package info.nightscout.androidaps.plugins.constraints.signatureVerifier
|
||||||
|
|
||||||
|
import org.junit.Assert.fail
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
import org.junit.Assert.*
|
|
||||||
|
|
||||||
class SignatureVerifierPluginTest {
|
class SignatureVerifierPluginTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun singleCharUnMapTest() {
|
fun singleCharUnMapTest() {
|
||||||
val key = "2ΙšÄΠΒϨÒÇeЄtЄЗž-*Ж*ZcHijЊÄœ<|x\"Ε"
|
val key = "2ΙšÄΠΒϨÒÇeЄtЄЗž-*Ж*ZcHijЊÄœ<|x\"Ε"
|
||||||
val unmapped = SignatureVerifierPlugin.getPlugin().singleCharUnMap(key)
|
fail() // TODO fix test
|
||||||
assertEquals("32:99:61:C4:A0:92:E8:D2:C7:65:04:74:04:17:7E:2D:2A:16:2A:5A:63:48:69:6A:0A:C4:53:3C:7C:78:22:95", unmapped)
|
//val unmapped = SignatureVerifierPlugin.getPlugin().singleCharUnMap(key)
|
||||||
|
// assertEquals("32:99:61:C4:A0:92:E8:D2:C7:65:04:74:04:17:7E:2D:2A:16:2A:5A:63:48:69:6A:0A:C4:53:3C:7C:78:22:95", unmapped)
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,6 +9,7 @@ import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.utils.SP
|
import info.nightscout.androidaps.utils.SP
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Assert.fail
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
|
@ -1,50 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.general.automation.triggers;
|
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
|
||||||
|
|
||||||
public class DummyTrigger extends Trigger {
|
|
||||||
private boolean result;
|
|
||||||
|
|
||||||
public DummyTrigger() {
|
|
||||||
this.result = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DummyTrigger(boolean result) {
|
|
||||||
this.result = result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldRun() {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toJSON() { return null; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
Trigger fromJSON(String data) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int friendlyName() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String friendlyDescription() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<Integer> icon() {
|
|
||||||
return Optional.absent();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void executed(long time) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Trigger duplicate() { return new DummyTrigger(result); }
|
|
||||||
}
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package info.nightscout.androidaps.plugins.general.automation.triggers
|
||||||
|
|
||||||
|
import com.google.common.base.Optional
|
||||||
|
import dagger.android.AndroidInjector
|
||||||
|
import dagger.android.HasAndroidInjector
|
||||||
|
|
||||||
|
class DummyTrigger(var result: Boolean) : Trigger(HasAndroidInjector { AndroidInjector { } }) {
|
||||||
|
|
||||||
|
override fun shouldRun(): Boolean {
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun toJSON(): String {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun fromJSON(data: String): Trigger {
|
||||||
|
return DummyTrigger(result)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun friendlyName(): Int {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun friendlyDescription(): String {
|
||||||
|
return " "
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun icon(): Optional<Int?> {
|
||||||
|
return Optional.absent()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun duplicate(): Trigger {
|
||||||
|
return DummyTrigger(result)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,13 +1,15 @@
|
||||||
package info.nightscout.androidaps.plugins.insulin
|
package info.nightscout.androidaps.plugins.insulin
|
||||||
|
|
||||||
|
import dagger.android.AndroidInjector
|
||||||
import dagger.android.HasAndroidInjector
|
import dagger.android.HasAndroidInjector
|
||||||
import info.nightscout.androidaps.MainApp
|
|
||||||
import info.nightscout.androidaps.data.Iob
|
import info.nightscout.androidaps.data.Iob
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
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.ProfileFunction
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||||
import info.nightscout.androidaps.plugins.insulin.InsulinOrefBasePlugin.Companion.MIN_DIA
|
import info.nightscout.androidaps.plugins.insulin.InsulinOrefBasePlugin.Companion.MIN_DIA
|
||||||
import info.nightscout.androidaps.plugins.treatments.Treatment
|
import info.nightscout.androidaps.plugins.treatments.Treatment
|
||||||
|
import info.nightscout.androidaps.utils.DefaultValueHelper
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
|
@ -16,7 +18,6 @@ import org.junit.Test
|
||||||
import org.mockito.Mock
|
import org.mockito.Mock
|
||||||
import org.mockito.junit.MockitoJUnit
|
import org.mockito.junit.MockitoJUnit
|
||||||
import org.mockito.junit.MockitoRule
|
import org.mockito.junit.MockitoRule
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
|
||||||
|
|
||||||
class InsulinOrefBasePluginTest {
|
class InsulinOrefBasePluginTest {
|
||||||
|
|
||||||
|
@ -53,12 +54,23 @@ class InsulinOrefBasePluginTest {
|
||||||
|
|
||||||
lateinit var sut: InsulinBaseTest
|
lateinit var sut: InsulinBaseTest
|
||||||
|
|
||||||
|
@Mock lateinit var defaultValueHelper: DefaultValueHelper
|
||||||
@Mock lateinit var resourceHelper: ResourceHelper
|
@Mock lateinit var resourceHelper: ResourceHelper
|
||||||
@Mock lateinit var profileFunction: ProfileFunction
|
@Mock lateinit var profileFunction: ProfileFunction
|
||||||
@Mock lateinit var rxBus: RxBusWrapper
|
@Mock lateinit var rxBus: RxBusWrapper
|
||||||
@Mock lateinit var aapsLogger: AAPSLogger
|
@Mock lateinit var aapsLogger: AAPSLogger
|
||||||
|
@Mock lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
||||||
|
|
||||||
@Mock lateinit var injector: HasAndroidInjector
|
var treatmentInjector: HasAndroidInjector = HasAndroidInjector {
|
||||||
|
AndroidInjector {
|
||||||
|
if (it is Treatment) {
|
||||||
|
it.defaultValueHelper = defaultValueHelper
|
||||||
|
it.resourceHelper = resourceHelper
|
||||||
|
it.profileFunction = profileFunction
|
||||||
|
it.configBuilderPlugin = configBuilderPlugin
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setUp() {
|
fun setUp() {
|
||||||
|
@ -77,7 +89,7 @@ class InsulinOrefBasePluginTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testIobCalcForTreatment() {
|
fun testIobCalcForTreatment() {
|
||||||
val treatment = Treatment(injector)
|
val treatment = Treatment(treatmentInjector) //TODO: this should be a separate sut. I'd prefer a separate class.
|
||||||
val expected = Iob()
|
val expected = Iob()
|
||||||
Assert.assertEquals(expected, sut.iobCalcForTreatment(treatment, 0, 0.0))
|
Assert.assertEquals(expected, sut.iobCalcForTreatment(treatment, 0, 0.0))
|
||||||
testPeak = 30
|
testPeak = 30
|
||||||
|
|
|
@ -41,7 +41,11 @@ class InsulinOrefFreePeakPluginTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
sut = InsulinOrefFreePeakPlugin(sp, resourceHelper, profileFunction, rxBus, aapsLogger)
|
sut = InsulinOrefFreePeakPlugin(sp = sp,
|
||||||
|
resourceHelper = resourceHelper,
|
||||||
|
rxBus = rxBus,
|
||||||
|
profileFunction = profileFunction,
|
||||||
|
aapsLogger = aapsLogger)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.source
|
package info.nightscout.androidaps.plugins.source
|
||||||
|
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
|
@ -17,9 +18,11 @@ class GlimpPluginTest {
|
||||||
|
|
||||||
@Mock lateinit var aapsLogger: AAPSLogger
|
@Mock lateinit var aapsLogger: AAPSLogger
|
||||||
|
|
||||||
|
@Mock lateinit var resourceHelper: ResourceHelper
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
glimpPlugin = GlimpPlugin(aapsLogger)
|
glimpPlugin = GlimpPlugin(resourceHelper, aapsLogger)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test fun advancedFilteringSupported() {
|
@Test fun advancedFilteringSupported() {
|
||||||
|
|
Loading…
Reference in a new issue