FeedEntriesAtomBodyWriter implements MessageBodyWriter<List<FeedEntry>> { @Override public void writeTo(List<FeedEntry> entries, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException { List<SyndEntry> syndEntries = entries.parallelStream().map(entry -> { SyndContent description = new SyndContentImpl(); description.setType(MediaType.TEXT_PLAIN); description.setValue(entry.getDescription()); SyndEntry syndEntry = new SyndEntryImpl(); syndEntry.setTitle(entry.getTitle()); syndEntry.setLink(entry.getLink()); syndEntry.setPublishedDate(entry.getPublishDate()); syndEntry.setDescription(description); return syndEntry; }).collect(Collectors.toList()); SyndFeed feed = new SyndFeedImpl(); feed.setFeedType("atom_1.0"); feed.setTitle("Combined Feed"); feed.setDescription("Combined Feed created by a feed-combiner application"); feed.setPublishedDate(new Date()); feed.setEntries(syndEntries); writeSyndFeed(entityStream, feed); }  @Override boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override void writeTo(List<FeedEntry> entries, Class<?> type, Type genericType, Annotation[] annotations,
                        MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream); @Override long getSize(List<FeedEntry> feeds, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType);  }
@Test public void testWriteTo() throws Exception { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); testedClass.writeTo(feedEntries(), null, null, null, null, null, outputStream); SyndFeedInput input = new SyndFeedInput(); InputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray()); SyndFeed feed = input.build(new InputSource(inputStream)); feed.setFeedType("atom_1.0"); feed.setTitle("Combined Feed"); feed.setDescription("Combined Feed created by a feed-combiner application"); assertEquals("atom_1.0", feed.getFeedType()); assertEquals("Combined Feed", feed.getTitle()); assertEquals("Combined Feed created by a feed-combiner application", feed.getDescription()); @SuppressWarnings("unchecked") List<SyndEntry> entries = feed.getEntries(); assertEquals(2, entries.size()); for (SyndEntry entry : entries) { if (TITLES[0].equals(entry.getTitle())) { assertEquals(entry.getLink(), LINKS[0]); assertEquals(entry.getTitle(), TITLES[0]); assertEquals(entry.getDescription().getValue(), DESCS[0]); assertEquals(entry.getPublishedDate().toString(), DATE.toString()); } else { assertEquals(entry.getLink(), LINKS[1]); assertEquals(entry.getTitle(), TITLES[1]); assertEquals(entry.getDescription().getValue(), DESCS[1]); assertEquals(entry.getPublishedDate().toString(), DATE.toString()); } } }