@Test public void doWork_whenTrackersReturned_shouldMakeTrackingRequests() { List<VastTracker> testTrackers = new ArrayList<VastTracker>(); testTrackers.add(new VastAbsoluteProgressTracker("http: testTrackers.add(new VastAbsoluteProgressTracker("http: when(mockVastVideoViewController.getUntriggeredTrackersBefore(eq(3000), eq(4000))) .thenReturn(testTrackers); when(mockVastVideoViewController.getCurrentPosition()).thenReturn(3000); when(mockVastVideoViewController.getDuration()).thenReturn(4000); when(mockVastVideoViewController.getContext()).thenReturn(mockContext); subject.doWork(); verify(mockVastVideoViewController).getUntriggeredTrackersBefore(eq(3000), eq(4000)); verify(mockVastVideoViewController).getCurrentPosition(); verify(mockVastVideoViewController).getDuration(); verify(mockVastVideoViewController).getContext(); verify(mockRequestQueue, times(2)).add(requestCaptor.capture()); final List<TrackingRequest> allValues = requestCaptor.getAllValues(); assertThat(allValues).hasSize(2); assertThat(allValues.get(0).getUrl()).isEqualTo("http: assertThat(allValues.get(1).getUrl()).isEqualTo("http: verifyNoMoreInteractions(mockVastVideoViewController, mockRequestQueue); }
@Override public void doWork() { int videoLength = mVideoViewController.getDuration(); int currentPosition = mVideoViewController.getCurrentPosition(); if (videoLength > 0) { final List<VastTracker> trackersToTrack = mVideoViewController.getUntriggeredTrackersBefore(currentPosition, videoLength); if (!trackersToTrack.isEmpty()) { final List<String> trackUrls = new ArrayList<String>(); for (VastTracker tracker : trackersToTrack) { trackUrls.add(tracker.getTrackingUrl()); tracker.setTracked(); } TrackingRequest.makeTrackingHttpRequest(trackUrls, mVideoViewController.getContext()); } } }
VastVideoViewProgressRunnable extends RepeatingHandlerRunnable { @Override public void doWork() { int videoLength = mVideoViewController.getDuration(); int currentPosition = mVideoViewController.getCurrentPosition(); if (videoLength > 0) { final List<VastTracker> trackersToTrack = mVideoViewController.getUntriggeredTrackersBefore(currentPosition, videoLength); if (!trackersToTrack.isEmpty()) { final List<String> trackUrls = new ArrayList<String>(); for (VastTracker tracker : trackersToTrack) { trackUrls.add(tracker.getTrackingUrl()); tracker.setTracked(); } TrackingRequest.makeTrackingHttpRequest(trackUrls, mVideoViewController.getContext()); } } } }
VastVideoViewProgressRunnable extends RepeatingHandlerRunnable { @Override public void doWork() { int videoLength = mVideoViewController.getDuration(); int currentPosition = mVideoViewController.getCurrentPosition(); if (videoLength > 0) { final List<VastTracker> trackersToTrack = mVideoViewController.getUntriggeredTrackersBefore(currentPosition, videoLength); if (!trackersToTrack.isEmpty()) { final List<String> trackUrls = new ArrayList<String>(); for (VastTracker tracker : trackersToTrack) { trackUrls.add(tracker.getTrackingUrl()); tracker.setTracked(); } TrackingRequest.makeTrackingHttpRequest(trackUrls, mVideoViewController.getContext()); } } } VastVideoViewProgressRunnable(@NonNull VastVideoViewController videoViewController,
            @NonNull Handler handler); }
VastVideoViewProgressRunnable extends RepeatingHandlerRunnable { @Override public void doWork() { int videoLength = mVideoViewController.getDuration(); int currentPosition = mVideoViewController.getCurrentPosition(); if (videoLength > 0) { final List<VastTracker> trackersToTrack = mVideoViewController.getUntriggeredTrackersBefore(currentPosition, videoLength); if (!trackersToTrack.isEmpty()) { final List<String> trackUrls = new ArrayList<String>(); for (VastTracker tracker : trackersToTrack) { trackUrls.add(tracker.getTrackingUrl()); tracker.setTracked(); } TrackingRequest.makeTrackingHttpRequest(trackUrls, mVideoViewController.getContext()); } } } VastVideoViewProgressRunnable(@NonNull VastVideoViewController videoViewController,
            @NonNull Handler handler); @Override void doWork(); }
VastVideoViewProgressRunnable extends RepeatingHandlerRunnable { @Override public void doWork() { int videoLength = mVideoViewController.getDuration(); int currentPosition = mVideoViewController.getCurrentPosition(); if (videoLength > 0) { final List<VastTracker> trackersToTrack = mVideoViewController.getUntriggeredTrackersBefore(currentPosition, videoLength); if (!trackersToTrack.isEmpty()) { final List<String> trackUrls = new ArrayList<String>(); for (VastTracker tracker : trackersToTrack) { trackUrls.add(tracker.getTrackingUrl()); tracker.setTracked(); } TrackingRequest.makeTrackingHttpRequest(trackUrls, mVideoViewController.getContext()); } } } VastVideoViewProgressRunnable(@NonNull VastVideoViewController videoViewController,
            @NonNull Handler handler); @Override void doWork();  }