315316317318319320321322
private AtomicLong accumulator = new AtomicLong(); @Test public void canMonitorARunnable() { final Runnable monitor = Spies.monitor(new Slacker(), accumulator); Assert.assertNotNull(monitor); }
294295296297298299300301
Assert.assertNotNull(ignoring); } @Test public void canIgnoreParameterForRunnable() { final Action<O> ignoring = Dispatching.ignore(new Slacker(), O.class); Assert.assertNotNull(ignoring); }
16171819202122
new MonitoringRunnable(null, new AtomicLong()); } @Test(expected = IllegalArgumentException.class) public void creatingMonitorWithNullAtomicLongYieldsException() { new MonitoringRunnable(new Slacker(), null); }
222324252627282930
} @Test public void callingIncrementsTheAtomicLong() { final AtomicLong state = new AtomicLong(); final Runnable spy = new MonitoringRunnable(new Slacker(), state); spy.run(); Assert.assertEquals(1l, state.get()); }
5758596061626364
Assert.assertNotNull(adapted); } @Test public void canAdaptRunnableToProvider() { final Provider<Void> adapted = Dispatching.provider(new Slacker()); Assert.assertNotNull(adapted); }