Fix tests

This commit is contained in:
Nico Schmitz 2018-10-29 21:34:03 +01:00
parent 04574d759f
commit 75d0bd9761
5 changed files with 33 additions and 8 deletions

View file

@ -58,6 +58,18 @@ public class TriggerBg extends Trigger {
threshold = triggerBg.threshold;
}
public double getThreshold() {
return threshold;
}
public Comparator getComparator() {
return comparator;
}
public String getUnits() {
return units;
}
@Override
public synchronized boolean shouldRun() {
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();

View file

@ -132,6 +132,18 @@ public class TriggerTime extends Trigger {
return weekdays[day.ordinal()];
}
public long getLastRun() {
return lastRun;
}
public long getRunAt() {
return runAt;
}
public boolean isRecurring() {
return recurring;
}
@Override
public boolean shouldRun() {
if (recurring) {

View file

@ -17,9 +17,7 @@ public class DummyTrigger extends Trigger {
}
@Override
String toJSON() {
return null;
}
public String toJSON() { return null; }
@Override
Trigger fromJSON(String data) {
@ -35,4 +33,7 @@ public class DummyTrigger extends Trigger {
public String friendlyDescription() {
return null;
}
@Override
public Trigger duplicate() { return new DummyTrigger(result); }
}

View file

@ -75,9 +75,9 @@ public class TriggerBgTest {
TriggerBg t = new TriggerBg().units(Constants.MMOL).threshold(4.1d).comparator(Trigger.Comparator.IS_EQUAL);
TriggerBg t2 = (TriggerBg) Trigger.instantiate(new JSONObject(t.toJSON()));
Assert.assertEquals(Trigger.Comparator.IS_EQUAL, t2.comparator);
Assert.assertEquals(4.1d, t2.threshold, 0.01d);
Assert.assertEquals(Constants.MMOL, t2.units);
Assert.assertEquals(Trigger.Comparator.IS_EQUAL, t2.getComparator());
Assert.assertEquals(4.1d, t2.getThreshold(), 0.01d);
Assert.assertEquals(Constants.MMOL, t2.getUnits());
}
@Before

View file

@ -70,8 +70,8 @@ public class TriggerTimeTest {
TriggerTime t = new TriggerTime().runAt(now - T.mins(1).msecs());
TriggerTime t2 = (TriggerTime) Trigger.instantiate(new JSONObject(t.toJSON()));
Assert.assertEquals(now - T.mins(1).msecs(), t2.runAt);
Assert.assertEquals(false, t2.recurring);
Assert.assertEquals(now - T.mins(1).msecs(), t2.getRunAt());
Assert.assertEquals(false, t2.isRecurring());
}
@Before