### Question:
DownloadingProcessor implements EntryProcessor { public ProcessedEntry processEntry(SyndEntry entry) throws ProcessingException { final String enclosureUrl = FeedsTools.extractEnclosureUrl(entry); if (enclosureUrl == null) { throw new ProcessingException("No available enclosure found"); } TmpFile file = null; try { file = new DownloadTask(this.probesGroup, enclosureUrl).execute(); final ContentType theFileType; if (DownloadingProcessor.FAAD_MATCHER.matcher(enclosureUrl).matches()) { theFileType = ContentType.AAC; } else { theFileType = ContentType.MP3; } final Files theFiles = FilesManagerFactory.FILE_MANAGER.post(file, theFileType, ContentType.MP3_32, Files.CATEGORIES.PODCAST, false, false, MimeType.MIME_TYPES.A_MPEG); return new ProcessedEntry(entry, Collections.singletonList(theFiles), enclosureUrl); } catch (final Exception e) { throw new ProcessingException(e); } finally { if (file != null) { file.delete(); } } } DownloadingProcessor(boolean probesGroup); ProcessedEntry processEntry(SyndEntry entry);  }### Answer:
@Test public void downloadWithValidEnclosureTest() throws ProcessingException { final SyndEntry entry = new SyndEntryImpl(); entry.setTitle("my entry"); final SyndEnclosure enclosure = new SyndEnclosureImpl(); enclosure.setUrl("http: enclosure.setType("audio/mpeg"); entry.setEnclosures(Collections.singletonList(enclosure)); final DownloadingProcessor processor = new DownloadingProcessor(true); final ProcessedEntry result = processor.processEntry(entry); Assert.assertNotNull(result); Assert.assertEquals(entry, result.getEntry()); final List<Files> contents = result.getContents(); Assert.assertEquals(1, contents.size()); }
@Test(expected = ProcessingException.class) public void downloadWithInvalidFormatTest() throws ProcessingException { final SyndEntry entry = new SyndEntryImpl(); entry.setTitle("my entry"); final SyndEnclosure invalidEnclosure = new SyndEnclosureImpl(); invalidEnclosure.setUrl("http: invalidEnclosure.setType("audio/mpeg"); entry.setEnclosures(Arrays.asList(invalidEnclosure)); final DownloadingProcessor processor = new DownloadingProcessor(true); processor.processEntry(entry); }
@Test(expected = ProcessingException.class) public void downloadWithInvalidTypeTest() throws ProcessingException { final SyndEntry entry = new SyndEntryImpl(); entry.setTitle("my entry"); final SyndEnclosure invalidEnclosure = new SyndEnclosureImpl(); invalidEnclosure.setUrl("http: invalidEnclosure.setType("video/avi"); entry.setEnclosures(Arrays.asList(invalidEnclosure)); final DownloadingProcessor processor = new DownloadingProcessor(true); processor.processEntry(entry); }
@Test public void downloadWithValidAndInvalidEnclosuresTest() throws ProcessingException { final SyndEntry entry = new SyndEntryImpl(); entry.setTitle("my entry"); final SyndEnclosure invalidEnclosure = new SyndEnclosureImpl(); invalidEnclosure.setUrl("http: invalidEnclosure.setType("audio/mpeg"); final SyndEnclosure validEnclosure = new SyndEnclosureImpl(); validEnclosure.setUrl("http: validEnclosure.setType("audio/mpeg"); entry.setEnclosures(Arrays.asList(invalidEnclosure, validEnclosure)); final DownloadingProcessor processor = new DownloadingProcessor(true); final ProcessedEntry result = processor.processEntry(entry); Assert.assertNotNull(result); Assert.assertEquals(entry, result.getEntry()); final List<Files> contents = result.getContents(); Assert.assertEquals(1, contents.size()); }