tests lints
This commit is contained in:
parent
58f69dae6e
commit
5bf99ce8fc
|
@ -9,19 +9,21 @@ import org.junit.Test
|
|||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
@Suppress("SpellCheckingInspection")
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class TriggerBTDeviceTest : TriggerTestBase() {
|
||||
|
||||
var now = 1514766900000L
|
||||
var someName = "Headset"
|
||||
var btJson = "{\"data\":{\"comparator\":\"ON_CONNECT\",\"name\":\"Headset\"},\"type\":\"info.nightscout.androidaps.plugins.general.automation.triggers.TriggerBTDevice\"}"
|
||||
private var someName = "Headset"
|
||||
private var btJson = "{\"data\":{\"comparator\":\"ON_CONNECT\",\"name\":\"Headset\"},\"type\":\"info.nightscout.androidaps.plugins.general.automation.triggers.TriggerBTDevice\"}"
|
||||
|
||||
@Test fun shouldRun() {
|
||||
val t: TriggerBTDevice = TriggerBTDevice(injector)
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
val t = TriggerBTDevice(injector)
|
||||
}
|
||||
|
||||
@Test fun toJSON() {
|
||||
val t: TriggerBTDevice = TriggerBTDevice(injector)
|
||||
val t = TriggerBTDevice(injector)
|
||||
t.btDevice.value = someName
|
||||
Assert.assertEquals(btJson, t.toJSON())
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import info.nightscout.androidaps.plugins.general.maintenance.formats.Prefs
|
|||
import info.nightscout.androidaps.testing.utils.SingleStringStorage
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import org.hamcrest.CoreMatchers
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
@ -32,9 +31,9 @@ class ClassicPrefsFormatTest : TestBase() {
|
|||
val classicFormat = ClassicPrefsFormat(resourceHelper, SingleStringStorage(test))
|
||||
val prefs = classicFormat.loadPreferences(getMockedFile(), "")
|
||||
|
||||
Assert.assertThat(prefs.values.size, CoreMatchers.`is`(2))
|
||||
Assert.assertThat(prefs.values["key1"], CoreMatchers.`is`("val1"))
|
||||
Assert.assertThat(prefs.values["keyB"], CoreMatchers.`is`("valB"))
|
||||
Assert.assertEquals(prefs.values.size, 2)
|
||||
Assert.assertEquals(prefs.values["key1"], "val1")
|
||||
Assert.assertEquals(prefs.values["keyB"], "valB")
|
||||
Assert.assertNull(prefs.values["key3"])
|
||||
}
|
||||
|
||||
|
|
|
@ -2,23 +2,22 @@ package info.nightscout.androidaps.plugins.pump.common.utils;
|
|||
|
||||
import android.util.Log;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class DateTimeUtilUTest {
|
||||
|
||||
@Test
|
||||
public void getATechDateDiferenceAsMinutes() {
|
||||
public void getATechDateDifferenceAsMinutes() {
|
||||
|
||||
long dt1 = 20191001182301L;
|
||||
long dt2 = 20191001192805L;
|
||||
|
||||
int aTechDateDiferenceAsMinutes = DateTimeUtil.getATechDateDiferenceAsMinutes(dt1, dt2);
|
||||
int aTechDateDifferenceAsMinutes = DateTimeUtil.getATechDateDiferenceAsMinutes(dt1, dt2);
|
||||
|
||||
Assert.assertEquals(65, aTechDateDiferenceAsMinutes);
|
||||
Assert.assertEquals(65, aTechDateDifferenceAsMinutes);
|
||||
|
||||
Log.d("DateTimeUtilUTest", "Time difference: " + aTechDateDiferenceAsMinutes);
|
||||
Log.d("DateTimeUtilUTest", "Time difference: " + aTechDateDifferenceAsMinutes);
|
||||
|
||||
}
|
||||
}
|
|
@ -1,158 +0,0 @@
|
|||
package info.nightscout.androidaps.testing.mocks;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class SharedPreferencesMock implements SharedPreferences {
|
||||
|
||||
private final EditorInternals editor = new EditorInternals();
|
||||
|
||||
class EditorInternals implements Editor {
|
||||
|
||||
Map<String, Object> innerMap = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public Editor putString(String k, @Nullable String v) {
|
||||
innerMap.put(k, v);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editor putStringSet(String k, @Nullable Set<String> set) {
|
||||
innerMap.put(k, set);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editor putInt(String k, int i) {
|
||||
innerMap.put(k, i);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editor putLong(String k, long l) {
|
||||
innerMap.put(k, l);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editor putFloat(String k, float v) {
|
||||
innerMap.put(k, v);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editor putBoolean(String k, boolean b) {
|
||||
innerMap.put(k, b);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editor remove(String k) {
|
||||
innerMap.remove(k);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editor clear() {
|
||||
innerMap.clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean commit() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, ?> getAll() {
|
||||
return editor.innerMap;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getString(String k, @Nullable String s) {
|
||||
if (editor.innerMap.containsKey(k)) {
|
||||
return (String) editor.innerMap.get(k);
|
||||
} else {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Set<String> getStringSet(String k, @Nullable Set<String> set) {
|
||||
if (editor.innerMap.containsKey(k)) {
|
||||
return (Set<String>) editor.innerMap.get(k);
|
||||
} else {
|
||||
return set;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(String k, int i) {
|
||||
if (editor.innerMap.containsKey(k)) {
|
||||
return (Integer) editor.innerMap.get(k);
|
||||
} else {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong(String k, long l) {
|
||||
if (editor.innerMap.containsKey(k)) {
|
||||
return (Long) editor.innerMap.get(k);
|
||||
} else {
|
||||
return l;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloat(String k, float v) {
|
||||
if (editor.innerMap.containsKey(k)) {
|
||||
return (Float) editor.innerMap.get(k);
|
||||
} else {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBoolean(String k, boolean b) {
|
||||
if (editor.innerMap.containsKey(k)) {
|
||||
return (Boolean) editor.innerMap.get(k);
|
||||
} else {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(String k) {
|
||||
return editor.innerMap.containsKey(k);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editor edit() {
|
||||
return editor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerOnSharedPreferenceChangeListener(OnSharedPreferenceChangeListener onSharedPreferenceChangeListener) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterOnSharedPreferenceChangeListener(OnSharedPreferenceChangeListener onSharedPreferenceChangeListener) {
|
||||
|
||||
}
|
||||
}
|
|
@ -2,11 +2,11 @@ package info.nightscout.androidaps.plugins.pump.danaR.comm
|
|||
|
||||
import info.nightscout.androidaps.dana.DanaPump
|
||||
import info.nightscout.androidaps.danar.comm.MsgSettingPumpTime
|
||||
import org.joda.time.DateTime
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
import java.util.*
|
||||
|
||||
@RunWith(PowerMockRunner::class)
|
||||
class MsgSettingPumpTimeTest : DanaRTestBase() {
|
||||
|
@ -16,14 +16,14 @@ class MsgSettingPumpTimeTest : DanaRTestBase() {
|
|||
danaPump.units = DanaPump.UNITS_MGDL
|
||||
// test message decoding
|
||||
val bytes = createArray(34, 7.toByte())
|
||||
val time = GregorianCalendar(
|
||||
100 + packet.intFromBuff(bytes, 5, 1),
|
||||
packet.intFromBuff(bytes, 4, 1) - 1,
|
||||
val time = DateTime(
|
||||
2000 + packet.intFromBuff(bytes, 5, 1),
|
||||
packet.intFromBuff(bytes, 4, 1),
|
||||
packet.intFromBuff(bytes, 3, 1),
|
||||
packet.intFromBuff(bytes, 2, 1),
|
||||
packet.intFromBuff(bytes, 1, 1),
|
||||
packet.intFromBuff(bytes, 0, 1)
|
||||
).time
|
||||
).millis
|
||||
packet.handleMessage(bytes)
|
||||
Assert.assertEquals(time, danaPump.getPumpTime())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue