DataServiceVisitorJsBuilder extends AbstractDataServiceVisitor { String stringJoinAndDecorate(final List<String> list, final String sep, StringDecorator decorator) { if (decorator == null) { decorator = new NothingDecorator(); } StringBuilder sb = new StringBuilder(); if (list != null) { boolean first = true; for (String argument : list) { if (!first) { sb.append(sep); } sb.append(decorator.decorate(argument)); first = false; } } return sb.toString(); } DataServiceVisitorJsBuilder(ProcessingEnvironment environment, FwkWriter fwk);   }
@Test public void testComputeArgumentsFromListAndDecorateWith() { List<String> list = Arrays.asList("a", "b", "c", "d"); String result = instance.stringJoinAndDecorate(null, ",", null); assertThat(result).isEqualTo(""); result = instance.stringJoinAndDecorate(list, ",", null); assertThat(result).isEqualTo("a,b,c,d"); result = instance.stringJoinAndDecorate(list, " ", null); assertThat(result).isEqualTo("a b c d"); result = instance.stringJoinAndDecorate(list, ",", new UnderscoreDecorator()); assertThat(result).isEqualTo("_a_,_b_,_c_,_d_"); }