use of java8.util.StringJoiner in project streamsupport by stefan-zobel.
the class MergeTest method testEmptyOther.
public void testEmptyOther() {
fixesStream().forEach(fixes -> {
StringJoiner sj = new StringJoiner(",", fixes.pre0, fixes.suf0);
StringJoiner other = new StringJoiner(",", fixes.pre1, fixes.suf1);
RefStreams.of("a", "b", "c").forEachOrdered(sj::add);
sj.merge(other);
assertEquals(sj.toString(), fixes.pre0 + "a,b,c" + fixes.suf0);
other.setEmptyValue("EMPTY");
sj.merge(other);
assertEquals(sj.toString(), fixes.pre0 + "a,b,c" + fixes.suf0);
});
}
use of java8.util.StringJoiner in project streamsupport by stefan-zobel.
the class MergeTest method testDelimiter.
public void testDelimiter() {
fixesStream().forEach(fixes -> {
StringJoiner sj = new StringJoiner(",", fixes.pre0, fixes.suf0);
StringJoiner other = new StringJoiner(":", fixes.pre1, fixes.suf1);
RefStreams.of("a", "b", "c").forEachOrdered(sj::add);
RefStreams.of("d", "e", "f").forEachOrdered(other::add);
sj.merge(other);
assertEquals(sj.toString(), fixes.pre0 + "a,b,c,d:e:f" + fixes.suf0);
});
}
use of java8.util.StringJoiner in project streamsupport by stefan-zobel.
the class MergeTest method testNull.
@Test(expectedExceptions = { NullPointerException.class })
public void testNull() {
StringJoiner sj = new StringJoiner(",", "{", "}");
sj.merge(null);
}
use of java8.util.StringJoiner in project streamsupport by stefan-zobel.
the class MergeTest method testEmptyThis.
public void testEmptyThis() {
fixesStream().forEach(fixes -> {
StringJoiner sj = new StringJoiner(",", fixes.pre0, fixes.suf0);
StringJoiner other = new StringJoiner(":", fixes.pre1, fixes.suf1);
RefStreams.of("d", "e", "f").forEachOrdered(other::add);
sj.merge(other);
assertEquals(sj.toString(), fixes.pre0 + "d:e:f" + fixes.suf0);
sj = new StringJoiner(",", fixes.pre0, fixes.suf0).setEmptyValue("EMPTY");
assertEquals(sj.toString(), "EMPTY");
sj.merge(other);
assertEquals(sj.toString(), fixes.pre0 + "d:e:f" + fixes.suf0);
});
}
use of java8.util.StringJoiner in project streamsupport by stefan-zobel.
the class StringJoinerTest method addString.
public void addString() {
StringJoiner sj = new StringJoiner(DASH);
sj.add(ONE);
assertEquals(sj.toString(), ONE);
sj = new StringJoiner(DASH, "{", "}");
sj.add(ONE);
assertEquals(sj.toString(), "{" + ONE + "}");
sj.add(TWO);
assertEquals(sj.toString(), "{" + ONE + DASH + TWO + "}");
}
Aggregations