TriggerStrategies { public static <T extends Serializable> TriggerStrategy onChange(Supplier<T> supplier){ return onChange(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 isToBeTriggeredOnChangePositive() { TriggerStrategy strategy = onChange(booleanChannel("val")); assertTrue(strategy.getChannelIdentifiers().contains("val")); strategy.isToBeTriggered(falseValues); boolean result = strategy.isToBeTriggered(trueValues); assertTrue(result); strategy.isToBeTriggered(trueValues); boolean result2 = strategy.isToBeTriggered(falseValues); assertTrue(result2); strategy = onChange(getSupplier()); result = strategy.isToBeTriggered(nullValues); assertFalse(result); assertTrue(strategy.getChannelIdentifiers().contains("test")); }
@Test public void isToBeTriggeredOnChangeNegative() { TriggerStrategy strategy = onChange(booleanChannel("val")); assertTrue(strategy.getChannelIdentifiers().contains("val")); strategy.isToBeTriggered(falseValues); boolean result = strategy.isToBeTriggered(falseValues); assertFalse(result); strategy.isToBeTriggered(trueValues); boolean result2 = strategy.isToBeTriggered(trueValues); assertFalse(result2); }
@Test public void isToBeTriggeredOnChangeInitialValue() { TriggerStrategy strategy = onChange(booleanChannel("val"), true); assertTrue(strategy.getChannelIdentifiers().contains("val")); boolean result = strategy.isToBeTriggered(falseValues); assertTrue(result); }