unavailable data and IS_NOT_AVAILABLE case
This commit is contained in:
parent
ccd66d498c
commit
27eb11e5df
|
@ -59,7 +59,10 @@ public class TriggerAutosensValue extends Trigger {
|
|||
public synchronized boolean shouldRun() {
|
||||
AutosensData autosensData = IobCobCalculatorPlugin.getPlugin().getLastAutosensData("Automation trigger");
|
||||
if (autosensData == null)
|
||||
return false;
|
||||
if (comparator.getValue() == Comparator.Compare.IS_NOT_AVAILABLE)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
||||
if (lastRun > DateUtil.now() - T.mins(5).msecs())
|
||||
return false;
|
||||
|
@ -120,7 +123,7 @@ public class TriggerAutosensValue extends Trigger {
|
|||
|
||||
@Override
|
||||
public Optional<Integer> icon() {
|
||||
return Optional.of(R.drawable.as);
|
||||
return Optional.of(R.drawable.as);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -66,6 +66,11 @@ public class TriggerAutosensValueTest {
|
|||
t = new TriggerAutosensValue().comparator(Comparator.Compare.IS_NOT_AVAILABLE);
|
||||
Assert.assertTrue(t.shouldRun());
|
||||
|
||||
// Test autosensData == null and Comparator == IS_NOT_AVAILABLE
|
||||
when(IobCobCalculatorPlugin.getPlugin().getLastAutosensData("Automation trigger")).thenReturn(null);
|
||||
t = new TriggerAutosensValue().comparator(Comparator.Compare.IS_NOT_AVAILABLE);
|
||||
Assert.assertTrue(t.shouldRun());
|
||||
|
||||
t = new TriggerAutosensValue().setValue(214).comparator(Comparator.Compare.IS_EQUAL).lastRun(now - 1);
|
||||
Assert.assertFalse(t.shouldRun());
|
||||
|
||||
|
|
Loading…
Reference in a new issue