TriggerStrategies { public static TriggerStrategy onBecomeFalse(Supplier<Boolean> supplier){ return onBecomeFalse(supplier, null); } private  TriggerStrategies(); static TriggerStrategy onTrue(Supplier<Boolean> supplier); static TriggerStrategy onFalse(Supplier<Boolean> supplier); static TriggerStrategy onBecomeTrue(Supplier<Boolean> supplier); static TriggerStrategy onBecomeTrue(Supplier<Boolean> supplier, Boolean initialValue); static TriggerStrategy onBecomeFalse(Supplier<Boolean> supplier); static TriggerStrategy onBecomeFalse(Supplier<Boolean> supplier, Boolean initialValue); static TriggerStrategy onChange(Supplier<T> supplier); static TriggerStrategy onChange(Supplier<T> supplier, T initialValue); static TriggerStrategy onNull(Supplier<T> supplier); static TriggerStrategy onNotNull(Supplier<T> supplier); static TriggerStrategy always();  }
@Test public void isToBeTriggeredOnBecomeFalsePositive() { TriggerStrategy strategy = onBecomeFalse(booleanChannel("val")); strategy.isToBeTriggered(trueValues); boolean result = strategy.isToBeTriggered(falseValues); assertTrue(result); assertTrue(strategy.getChannelIdentifiers().contains("val")); strategy = onBecomeFalse(getSupplier()); result = strategy.isToBeTriggered(nullValues); assertFalse(result); assertTrue(strategy.getChannelIdentifiers().contains("test")); }
@Test public void isToBeTriggeredOnBecomeFalseNegative() { TriggerStrategy strategy = onBecomeFalse(booleanChannel("val")); strategy.isToBeTriggered(falseValues); boolean result = strategy.isToBeTriggered(trueValues); assertFalse(result); assertTrue(strategy.getChannelIdentifiers().contains("val")); }
@Test public void isToBeTriggeredOnBecomeFalseInitialValue() { TriggerStrategy strategy = onBecomeFalse(booleanChannel("val"), true); boolean result = strategy.isToBeTriggered(falseValues); assertTrue(result); assertTrue(strategy.getChannelIdentifiers().contains("val")); }