### Question:
FormatJoinHelper implements Helper<Collection<?>> { @Override public Object apply(Collection<?> context, Options options) { if (context == null || context.isEmpty()) { return ""; } String separator = options.hash("sep", ","); String format = options.hash("format", null); Function<Object, String> formatter = format != null ? each -> String.format(format, each) : Object::toString; return context.stream() .map(formatter) .collect(joining(separator)); }  @Override Object apply(Collection<?> context, Options options); static final String NAME; }### Answer:
@Test public void formatsEachItem() { Collection<?> items = Arrays.asList("A", "B"); separatorIs(";"); formatStringIs("prefix:%s:suffix"); assertEquals("prefix:A:suffix;prefix:B:suffix", FormatJoinHelper.INSTANCE.apply(items, options)); }
@Test public void noSeparatorForSingleItem() { Collection<?> items = Collections.singleton("host"); separatorIs(","); formatStringIs("http: assertEquals("http: }
@Test public void emptyResultForNoItems() { assertEquals("", FormatJoinHelper.INSTANCE.apply(Collections.emptySet(), options)); }