LinkConverter { public static List<Map<String,String>> linksToJson(final Collection<Link> links) { return links .stream() .map(LinkConverter::linkToJson) .collect(toList()); } private  LinkConverter(); static Map<String, String> linkToJson(final Link link); static Link jsonToLink(final Map<String, String> json); static List<Map<String,String>> linksToJson(final Collection<Link> links); static List<Link> jsonToLinks(final Collection<Map<String,String>> json);  }
@Test public void shouldConvertLinks() { final List<Link> links = asList( new Link(create("http: new Link(create("http: ); final List<Map<String, String>> maps = linksToJson(links); assertEquals(maps.size(), 2); assertEquals(maps.get(0).get("href"), "http: assertEquals(maps.get(0).get("title"), "Foo"); assertEquals(maps.get(1).get("href"), "http: assertEquals(maps.get(1).get("title"), "Bar"); }