ZetaSqlIdUtils { static String escapeAndJoin(List<String> parts) { return parts.stream() .map(ZetaSqlIdUtils::escapeSpecialChars) .map(ZetaSqlIdUtils::replaceWhitespaces) .map(ZetaSqlIdUtils::backtickIfNeeded) .collect(joining(".")); }    }
@Test public void testHandlesSimpleIds() { List<String> id = Arrays.asList("aaa", "BbB", "zAzzz00"); assertEquals("aaa.BbB.zAzzz00", ZetaSqlIdUtils.escapeAndJoin(id)); }
@Test public void testHandlesMixedIds() { List<String> id = Arrays.asList("aaa", "Bb---B", "zAzzz00"); assertEquals("aaa.`Bb---B`.zAzzz00", ZetaSqlIdUtils.escapeAndJoin(id)); }
@Test public void testHandlesSpecialChars() { List<String> id = Arrays.asList("a\\a", "b`b", "c'c", "d\"d", "e?e"); assertEquals("`a\\\\a`.`b\\`b`.`c\\'c`.`d\\\"d`.`e\\?e`", ZetaSqlIdUtils.escapeAndJoin(id)); }
@Test public void testHandlesSpecialCharsInOnePart() { List<String> id = Arrays.asList("a\\ab`bc'cd\"de?e"); assertEquals("`a\\\\ab\\`bc\\'cd\\\"de\\?e`", ZetaSqlIdUtils.escapeAndJoin(id)); }
@Test public void testHandlesWhiteSpaces() { List<String> id = Arrays.asList("a\na", "b\tb", "c\rc", "d\fd"); assertEquals("`a\\na`.`b\\tb`.`c\\rc`.`d\\fd`", ZetaSqlIdUtils.escapeAndJoin(id)); }
@Test public void testHandlesWhiteSpacesInOnePart() { List<String> id = Arrays.asList("a\nab\tbc\rcd\fd"); assertEquals("`a\\nab\\tbc\\rcd\\fd`", ZetaSqlIdUtils.escapeAndJoin(id)); }