@Test
 public void testGetPodcastById()
     throws IOException, ParserConfigurationException, InvalidRssFeedException,
         InvalidDateFormatException, SAXException, NotFoundException {
   Feed actualFeed = rssFeedService.getRssFeedPodcastById("3", false);
   assertNotNull("Feed Object should not be null ", actualFeed);
   assertEquals(1, actualFeed.getPodcasts().size());
   assertEquals("3", actualFeed.getPodcasts().get(0).getId());
 }
 @Test
 public void testGetMostRecentPodcast()
     throws IOException, ParserConfigurationException, InvalidRssFeedException,
         InvalidDateFormatException, SAXException, NotFoundException {
   Feed actualFeed = rssFeedService.getRssFeedPodcasts(true);
   assertNotNull("Feed Object should not be null ", actualFeed);
   assertEquals(1, actualFeed.getPodcasts().size());
   String actualMostRecentDate =
       DateUtils.convertDateToGMTString(actualFeed.getPodcasts().get(0).getPubDate());
   assertEquals(ACTUAL_MOST_RECENT_DATE, actualMostRecentDate);
 }
  @Test
  public void testGetPodcastAlternateTrue()
      throws NotFoundException, InvalidRssFeedException, SAXException, InvalidDateFormatException,
          ParserConfigurationException, IOException {
    Feed actualFeed = rssFeedService.getRssFeedPodcastById("3", true);

    assertNotNull("Feed Object should not be null ", actualFeed);
    assertEquals(4, actualFeed.getPodcasts().size());
    boolean isPresent = false;
    for (int i = 0; i < actualFeed.getPodcasts().size(); i++) {
      if (actualFeed.getPodcasts().get(i).getId().equals("3")) isPresent = true;
    }
    assertFalse("podcast with id=3 should not be included in the result", isPresent);
  }
  private Feed getExpectedFeed() throws ParseException {
    Feed feed = new Feed();
    List<Podcast> podcasts = new ArrayList<>();

    feed.setTitle(CHANNEL_TITLE);
    feed.setLink(CHANNEL_LINK);
    feed.setDescription(CHANNEL_DESCRIPTION);
    feed.setLanguage(CHANNEL_LANGUAGE);
    feed.setCopyright(CHANNEL_COPYRIGHT);

    Itune itune = new Itune();
    itune.setSubtitle(CHANNEL_ITUNES_SUBTITLE);
    itune.setAuthor(CHANNEL_ITUNES_AUTHOR);
    itune.setSummary(CHANNEL_ITUNES_SUMMARY);
    itune.setImage(CHANNEL_ITUNES_IMAGE);
    itune.setIsExplicit(CHANNEL_ITUNES_EXPICIT);
    itune.setNewFeedUrl(CHANNEL_ITUNES_NEW_FEED_URL);
    itune.setOwner(new Owner(CHANNEL_ITUNES_OWNER_NAME, CHANNEL_ITUNES_OWNER_EMAIL));
    itune.setCategory(CHANNEL_ITUNES_CATEGORY);
    feed.setItune(itune);

    for (int i = 0; i < 5; i++) {
      String id = String.valueOf(i + 1);
      Podcast p = new Podcast();
      p.setId(id);
      p.setAuthor(ITEM_AUTHOR + id);
      p.setTitle(ITEM_TITLE + id);
      p.setDescription(ITEM_DESCRIPTION + id);
      Date d = getNewDate(i);
      p.setPubDate(getNewDate(i));
      p.setEnclosure(
          new Enclosure(ITEM_ENCLOSURE_URL + id, ITEM_ENCLOSURE_TYPE, ITEM_ENCLOSURE_LENGHT));

      Itune it = new Itune();
      it.setSubtitle(ITEM_ITUNE_SUBTITLE + id);
      it.setIsExplicit(ITEM_ITUNE_EXPLICIT);
      it.setSummary(ITEM_ITUNE_SUMMARY + id);
      it.setDuration(ITEM_ITUNE_DURATION);
      p.setItune(it);
      podcasts.add(p);
    }
    feed.setPodcasts(podcasts);
    return feed;
  }