private static String toString(Object... args) { if (args.length == 0) { return ""; } return "[" + CollectionUtil.joinAsString(args, ", ") + "]"; }
public String name() { return joinAsString(toArray(filter(keywords(), new NotBlank())), " "); }
@Test public void testJoinsElementsOfArrayToFormAStringRepresentation() { String[] values = { "This", "is", "a", "string" }; assertEquals("This is a string", CollectionUtil.joinAsString(values, " ")); }
@Test public void testOperationsCanBeCombined() { String filePath = joinAsString(toArray("c:", "path", "to", "dir", "sub dir", "my file.html"), File.separator); String dirPath = joinAsString(toArray("c:", "path", "to"), File.separator); assertEquals("dir-sub dir-my file.html", flatten(relativize(dirPath, filePath))); }
@Test public void testRawNormalizesPathSeparators() { assertEquals("c:/path/to/my_file.html", raw(joinAsString(toArray("c:", "path", "to", "my_file.html"), File.separator))); }
@Test public void testDecodedNormalizesPathSeparators() { assertEquals("c:/path/to/my_file.html", decoded(joinAsString(toArray("c:", "path", "to", "my_file.html"), File.separator))); }
@Test public void testFlatteningReplacesPathSeparatorsWithDashes() { assertEquals("path-to-my_file", flatten(joinAsString(toArray("path", "to", "my_file"), File.separator))); }