### Question:
ConcurrentProcessor { public List<ProcessedEntry> processEntries(final List<SyndEntry> entries) { if (!entries.isEmpty()) { final ProcessedEntry[] processedEntries = new ProcessedEntry[entries.size()]; final ExecutorService entriesExecutor = Executors.newFixedThreadPool(entries.size()); for (int i = 0; i < entries.size(); i++) { final int index = i; entriesExecutor.execute(new Runnable() { public void run() { try { processedEntries[index] = ConcurrentProcessor.this.processor.processEntry(entries.get(index)); } catch (final ProcessingException e) { ConcurrentProcessor.LOGGER.error("Failed to process a feed entry", e); } } }); } waitForTermination(entriesExecutor); final List<ProcessedEntry> resultList = new ArrayList<ProcessedEntry>(); for (int i = 0; i < processedEntries.length; i++) { if (processedEntries[i] != null) { resultList.add(processedEntries[i]); } } return resultList; } return Collections.emptyList(); } ConcurrentProcessor(EntryProcessor processor); List<ProcessedEntry> processEntries(final List<SyndEntry> entries);  }### Answer:
@Test public void processEntriesTest() { final EntryProcessor processor = new EntryProcessor() { public ProcessedEntry processEntry(SyndEntry entry) { if (entry.getUri().equals("2") || entry.getUri().equals("3")) { try { Thread.sleep(2000); } catch (final InterruptedException e) {} } return new ProcessedEntry(entry, Collections.<Files> emptyList()); } }; final ConcurrentProcessor concProc = new ConcurrentProcessor(processor); final List<SyndEntry> entries = new ArrayList<SyndEntry>(); for (int i = 0; i < 5; i++) { entries.add(getEntry(String.valueOf(i), "title" + i)); } final List<ProcessedEntry> procEntries = concProc.processEntries(entries); Assert.assertEquals(5, procEntries.size()); for (int i = 0; i < 5; i++) { Assert.assertEquals(String.valueOf(i), procEntries.get(i).getEntry().getUri()); } }
@Test public void processEntriesWithOneFailureTest() { final EntryProcessor processor = new EntryProcessor() { public ProcessedEntry processEntry(SyndEntry entry) throws ProcessingException { if (entry.getUri().equals("0")) { throw new ProcessingException("Failure"); } if (entry.getUri().equals("2") || entry.getUri().equals("3")) { try { Thread.sleep(2000); } catch (final InterruptedException e) {} } return new ProcessedEntry(entry, Collections.<Files> emptyList()); } }; final ConcurrentProcessor concProc = new ConcurrentProcessor(processor); final List<SyndEntry> entries = new ArrayList<SyndEntry>(); for (int i = 0; i < 5; i++) { entries.add(getEntry(String.valueOf(i), "title" + i)); } final List<ProcessedEntry> procEntries = concProc.processEntries(entries); Assert.assertEquals(4, procEntries.size()); Assert.assertEquals("1", procEntries.get(0).getEntry().getUri()); Assert.assertEquals("2", procEntries.get(1).getEntry().getUri()); Assert.assertEquals("3", procEntries.get(2).getEntry().getUri()); Assert.assertEquals("4", procEntries.get(3).getEntry().getUri()); }