@@ -0,0 +1,2574 @@
+package com.novoda.downloadmanager;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.mockito.ArgumentCaptor;%0Aimport org.mockito.invocation.InvocationOnMock;%0Aimport org.mockito.stubbing.Answer;%0A%0Aimport static org.mockito.BDDMockito.given;%0Aimport static org.mockito.BDDMockito.willAnswer;%0Aimport static org.mockito.Mockito.*;%0A%0Apublic class CallbackThrottleByTimeTest %7B%0A%0A    private final Scheduler scheduler = mock(Scheduler.class);%0A    private final DownloadBatchCallback callback = mock(DownloadBatchCallback.class);%0A    private final DownloadBatchStatus downloadBatchStatus = mock(DownloadBatchStatus.class);%0A%0A    private CallbackThrottleByTime callbackThrottleByTime;%0A%0A    @Before%0A    public void setUp() %7B%0A        callbackThrottleByTime = new CallbackThrottleByTime(scheduler);%0A%0A        final ArgumentCaptor%3CScheduler.Action%3E argumentCaptor = ArgumentCaptor.forClass(Scheduler.Action.class);%0A        willAnswer(new Answer%3CVoid%3E() %7B%0A            @Override%0A            public Void answer(InvocationOnMock invocation) throws Throwable %7B%0A                argumentCaptor.getValue().perform();%0A                return null;%0A            %7D%0A        %7D).given(scheduler).schedule(argumentCaptor.capture());%0A    %7D%0A%0A    @Test%0A    public void doesNothing_whenCallbackIsAbsent() %7B%0A        callbackThrottleByTime.update(downloadBatchStatus);%0A%0A        verifyZeroInteractions(scheduler, callback, downloadBatchStatus);%0A    %7D%0A%0A    @Test%0A    public void doesNotSchedule_whenActionAlreadyScheduled() %7B%0A        given(scheduler.isScheduled(any(Scheduler.Action.class))).willReturn(true);%0A        callbackThrottleByTime.setCallback(callback);%0A%0A        callbackThrottleByTime.update(downloadBatchStatus);%0A%0A        verify(scheduler, never()).schedule(any(Scheduler.Action.class));%0A    %7D%0A%0A    @Test%0A    public void emitsStatus_whenSchedulingUniqueAction() %7B%0A        callbackThrottleByTime.setCallback(callback);%0A%0A        callbackThrottleByTime.update(downloadBatchStatus);%0A%0A        verify(callback).onUpdate(downloadBatchStatus);%0A    %7D%0A%0A    @Test%0A    public void cancelsAllScheduledActions_whenStoppingUpdates() %7B%0A        callbackThrottleByTime.stopUpdates();%0A%0A        verify(scheduler).cancelAll();%0A    %7D%0A%0A    @Test%0A    public void emitsLastStatus_whenStoppingUpdates() %7B%0A        callbackThrottleByTime.setCallback(callback);%0A%0A        callbackThrottleByTime.stopUpdates();%0A%0A        verify(scheduler).cancelAll();%0A    %7D%0A%0A    @Test%0A    public void doesNotEmitLastStatus_whenCallbackAbsent() %7B%0A        callbackThrottleByTime.stopUpdates();%0A%0A        verifyZeroInteractions(callback);%0A    %7D%0A%0A%7D%0A

Add tests for CallbackThrottleByTime.