Fix tests
This commit is contained in:
parent
04574d759f
commit
75d0bd9761
5 changed files with 33 additions and 8 deletions
|
@ -58,6 +58,18 @@ public class TriggerBg extends Trigger {
|
||||||
threshold = triggerBg.threshold;
|
threshold = triggerBg.threshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getThreshold() {
|
||||||
|
return threshold;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Comparator getComparator() {
|
||||||
|
return comparator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUnits() {
|
||||||
|
return units;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized boolean shouldRun() {
|
public synchronized boolean shouldRun() {
|
||||||
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
||||||
|
|
|
@ -132,6 +132,18 @@ public class TriggerTime extends Trigger {
|
||||||
return weekdays[day.ordinal()];
|
return weekdays[day.ordinal()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getLastRun() {
|
||||||
|
return lastRun;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getRunAt() {
|
||||||
|
return runAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRecurring() {
|
||||||
|
return recurring;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldRun() {
|
public boolean shouldRun() {
|
||||||
if (recurring) {
|
if (recurring) {
|
||||||
|
|
|
@ -17,9 +17,7 @@ public class DummyTrigger extends Trigger {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
String toJSON() {
|
public String toJSON() { return null; }
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
Trigger fromJSON(String data) {
|
Trigger fromJSON(String data) {
|
||||||
|
@ -35,4 +33,7 @@ public class DummyTrigger extends Trigger {
|
||||||
public String friendlyDescription() {
|
public String friendlyDescription() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Trigger duplicate() { return new DummyTrigger(result); }
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,9 +75,9 @@ public class TriggerBgTest {
|
||||||
TriggerBg t = new TriggerBg().units(Constants.MMOL).threshold(4.1d).comparator(Trigger.Comparator.IS_EQUAL);
|
TriggerBg t = new TriggerBg().units(Constants.MMOL).threshold(4.1d).comparator(Trigger.Comparator.IS_EQUAL);
|
||||||
|
|
||||||
TriggerBg t2 = (TriggerBg) Trigger.instantiate(new JSONObject(t.toJSON()));
|
TriggerBg t2 = (TriggerBg) Trigger.instantiate(new JSONObject(t.toJSON()));
|
||||||
Assert.assertEquals(Trigger.Comparator.IS_EQUAL, t2.comparator);
|
Assert.assertEquals(Trigger.Comparator.IS_EQUAL, t2.getComparator());
|
||||||
Assert.assertEquals(4.1d, t2.threshold, 0.01d);
|
Assert.assertEquals(4.1d, t2.getThreshold(), 0.01d);
|
||||||
Assert.assertEquals(Constants.MMOL, t2.units);
|
Assert.assertEquals(Constants.MMOL, t2.getUnits());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
|
|
@ -70,8 +70,8 @@ public class TriggerTimeTest {
|
||||||
TriggerTime t = new TriggerTime().runAt(now - T.mins(1).msecs());
|
TriggerTime t = new TriggerTime().runAt(now - T.mins(1).msecs());
|
||||||
|
|
||||||
TriggerTime t2 = (TriggerTime) Trigger.instantiate(new JSONObject(t.toJSON()));
|
TriggerTime t2 = (TriggerTime) Trigger.instantiate(new JSONObject(t.toJSON()));
|
||||||
Assert.assertEquals(now - T.mins(1).msecs(), t2.runAt);
|
Assert.assertEquals(now - T.mins(1).msecs(), t2.getRunAt());
|
||||||
Assert.assertEquals(false, t2.recurring);
|
Assert.assertEquals(false, t2.isRecurring());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
|
Loading…
Reference in a new issue