@Test public void testStart() throws Exception { List<BigDecimal> rates = Arrays.asList( BigDecimal.valueOf(44.4), BigDecimal.valueOf(1), BigDecimal.valueOf(10), null, BigDecimal.valueOf(600), null, BigDecimal.valueOf(-0.1), BigDecimal.valueOf(-0.1)); TestReceiveScheduler scheduler = new TestReceiveScheduler(rates); PendingCashRepository cashRepository = mock(PendingCashRepository.class); ReceiveCash cash = mock(ReceiveCash.class); when(cashRepository.findPending(any(Date.class), anyInt(), anyInt())).thenReturn(ImmutableList.of(cash, cash, cash, cash)); scheduler.setPendingCashRepository(cashRepository); scheduler.start(); TimeUnit.SECONDS.sleep(5); scheduler.stop(); assertThat(completeCount, greaterThan(0)); assertThat(receivedCount, greaterThan(completeCount)); assertThat(receivedCount, greaterThan(completeCount)); assertThat(receivedCount / 8, anyOf(is(completeCount / 4), is(completeCount / 4 - 1))); }
public void start() { scheduler.scheduleWithFixedDelay( new Worker(pendingCashRepository), initialDelay, period, TimeUnit.MILLISECONDS); }
ReceiveScheduler { public void start() { scheduler.scheduleWithFixedDelay( new Worker(pendingCashRepository), initialDelay, period, TimeUnit.MILLISECONDS); } }
ReceiveScheduler { public void start() { scheduler.scheduleWithFixedDelay( new Worker(pendingCashRepository), initialDelay, period, TimeUnit.MILLISECONDS); } ReceiveScheduler(); }
ReceiveScheduler { public void start() { scheduler.scheduleWithFixedDelay( new Worker(pendingCashRepository), initialDelay, period, TimeUnit.MILLISECONDS); } ReceiveScheduler(); void start(); void stop(); void setPendingCashRepository(PendingCashRepository<T> pendingRepository); }
ReceiveScheduler { public void start() { scheduler.scheduleWithFixedDelay( new Worker(pendingCashRepository), initialDelay, period, TimeUnit.MILLISECONDS); } ReceiveScheduler(); void start(); void stop(); void setPendingCashRepository(PendingCashRepository<T> pendingRepository);  }