@Test
public void testJoinWithFunction() {

    final List<FakeSpec> specs1 = Arrays.asList(
            new FakeSpec("a"),
            new FakeSpec("b"),
            new FakeSpec("c"));
    assertThat(join(specs1, ",", new Function<FakeSpec, String>() {
        @Override
        public String apply(FakeSpec fakeSpec) {
            return fakeSpec.getName();
        }
    }), is("a,b,c"));
    final List<FakeSpec> specs2 = Arrays.asList(
            new FakeSpec("a"),
            new FakeSpec("b"),
            new FakeSpec("c"));
    assertThat(join(specs2, ", ", new Function<FakeSpec, String>() {
        @Override
        public String apply(FakeSpec fakeSpec) {
            return fakeSpec.getName();
        }
    }), is("a, b, c"));
    final List<FakeSpec> specs3 = Arrays.asList(
            new FakeSpec(" a"),
            new FakeSpec("b  "),
            new FakeSpec(" c "));
    assertThat(join(specs3, ",", new Function<FakeSpec, String>() {
        @Override
        public String apply(FakeSpec fakeSpec) {
            return fakeSpec.getName();
        }
    }), is("a,b,c"));
    final List<FakeSpec> specs4 = Arrays.asList(
            new FakeSpec(" a"),
            new FakeSpec("b  "),
            new FakeSpec(" c "));
    assertThat(join(specs4, ", ", new Function<FakeSpec, String>() {
        @Override
        public String apply(FakeSpec fakeSpec) {
            return fakeSpec.getName();
        }
    }), is("a, b, c"));
}