### Question:
YoutubeChannelDataCollector extends YoutubeDataCollector { @Override public void run() { Gson gson = new Gson(); int item_count = 0; int last_count = 0; int page_count = 0; try { int attempt = 0; YouTube.Channels.List channelLists = this.youTube.channels().list(CONTENT).setId(this.userInfo.getUserId()).setKey(this.youtubeConfig.getApiKey()); boolean tryAgain = false; do { try { List<Channel> channels = channelLists.execute().getItems(); last_count = channels.size(); for (Channel channel : channels) { String json = gson.toJson(channel); this.queue.put(new StreamsDatum(json, channel.getId())); item_count++; } if (StringUtils.isEmpty(channelLists.getPageToken())) { channelLists = null; } else { channelLists = this.youTube.channels().list(CONTENT).setId(this.userInfo.getUserId()).setOauthToken(this.youtubeConfig.getApiKey()) .setPageToken(channelLists.getPageToken()); } page_count++; } catch (GoogleJsonResponseException gjre) { LOGGER.warn("GoogleJsonResposneException caught : {}", gjre); tryAgain = backoffAndIdentifyIfRetry(gjre, this.strategy); ++attempt; } catch (Throwable throwable) { LOGGER.warn("Unable to get channel info for id : {}", this.userInfo.getUserId()); LOGGER.warn("Excpection thrown while trying to get channel info : {}", throwable); } } while ((tryAgain && attempt < MAX_ATTEMPTS) || channelLists != null); LOGGER.info("item_count: {} last_count: {} page_count: {} ", item_count, last_count, page_count); } catch (Throwable throwable) { LOGGER.warn(throwable.getMessage()); } } YoutubeChannelDataCollector(
      YouTube youTube,
      BlockingQueue<StreamsDatum> queue,
      BackOffStrategy strategy,
      UserInfo userInfo,
      YoutubeConfiguration youtubeConfig); @Override void run();  }### Answer:
@Test public void testDataCollector() throws Exception { YouTube youTube = createMockYoutube(); BlockingQueue<StreamsDatum> queue = new LinkedBlockingQueue<>(); BackOffStrategy strategy = new LinearTimeBackOffStrategy(1); UserInfo userInfo = new UserInfo(); userInfo.setUserId(ID); YoutubeConfiguration config = new YoutubeConfiguration(); config.setApiKey(ID); YoutubeChannelDataCollector collector = new YoutubeChannelDataCollector(youTube, queue, strategy, userInfo, config); collector.run(); assertEquals(1, queue.size()); StreamsDatum datum = queue.take(); assertNotNull(datum); String document = (String) datum.getDocument(); assertNotNull(document); }