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() =
|
||||
this?.numericVersionPart().takeIf { !it.isNullOrBlank() }?.split(".")?.map { it.toInt() }
|
||||
|
@ -139,3 +128,21 @@ class VersionCheckerUtils @Inject constructor() {
|
|||
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)
|
||||
public class Treatment implements DataPointWithLabelInterface, DbObjectBase {
|
||||
@Inject DefaultValueHelper defaultValueHelper;
|
||||
@Inject ResourceHelper resourceHelper;
|
||||
@Inject ProfileFunction profileFunction;
|
||||
@Inject ConfigBuilderPlugin configBuilderPlugin;
|
||||
@Inject public DefaultValueHelper defaultValueHelper;
|
||||
@Inject public ResourceHelper resourceHelper;
|
||||
@Inject public ProfileFunction profileFunction;
|
||||
@Inject public ConfigBuilderPlugin configBuilderPlugin;
|
||||
|
||||
public static final String TABLE_TREATMENTS = "Treatments";
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package info.nightscout.androidaps.plugins.constraints.signatureVerifier
|
||||
|
||||
import org.junit.Assert.fail
|
||||
import org.junit.Test
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
class SignatureVerifierPluginTest {
|
||||
|
||||
@Test
|
||||
fun singleCharUnMapTest() {
|
||||
val key = "2ΙšÄΠΒϨÒÇeЄtЄЗž-*Ж*ZcHijЊÄœ<|x\"Ε"
|
||||
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)
|
||||
fail() // TODO fix test
|
||||
//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.resources.ResourceHelper
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.fail
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
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
|
||||
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.data.Iob
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
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.insulin.InsulinOrefBasePlugin.Companion.MIN_DIA
|
||||
import info.nightscout.androidaps.plugins.treatments.Treatment
|
||||
import info.nightscout.androidaps.utils.DefaultValueHelper
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
|
@ -16,7 +18,6 @@ import org.junit.Test
|
|||
import org.mockito.Mock
|
||||
import org.mockito.junit.MockitoJUnit
|
||||
import org.mockito.junit.MockitoRule
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
|
||||
class InsulinOrefBasePluginTest {
|
||||
|
||||
|
@ -53,12 +54,23 @@ class InsulinOrefBasePluginTest {
|
|||
|
||||
lateinit var sut: InsulinBaseTest
|
||||
|
||||
@Mock lateinit var defaultValueHelper: DefaultValueHelper
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
@Mock lateinit var profileFunction: ProfileFunction
|
||||
@Mock lateinit var rxBus: RxBusWrapper
|
||||
@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
|
||||
fun setUp() {
|
||||
|
@ -77,7 +89,7 @@ class InsulinOrefBasePluginTest {
|
|||
|
||||
@Test
|
||||
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()
|
||||
Assert.assertEquals(expected, sut.iobCalcForTreatment(treatment, 0, 0.0))
|
||||
testPeak = 30
|
||||
|
|
|
@ -41,7 +41,11 @@ class InsulinOrefFreePeakPluginTest {
|
|||
|
||||
@Before
|
||||
fun setup() {
|
||||
sut = InsulinOrefFreePeakPlugin(sp, resourceHelper, profileFunction, rxBus, aapsLogger)
|
||||
sut = InsulinOrefFreePeakPlugin(sp = sp,
|
||||
resourceHelper = resourceHelper,
|
||||
rxBus = rxBus,
|
||||
profileFunction = profileFunction,
|
||||
aapsLogger = aapsLogger)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package info.nightscout.androidaps.plugins.source
|
||||
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
|
@ -17,9 +18,11 @@ class GlimpPluginTest {
|
|||
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
glimpPlugin = GlimpPlugin(aapsLogger)
|
||||
glimpPlugin = GlimpPlugin(resourceHelper, aapsLogger)
|
||||
}
|
||||
|
||||
@Test fun advancedFilteringSupported() {
|
||||
|
|
Loading…
Reference in a new issue