Id { public static String build(String id, String... additionalIds) { return build(id, '-', additionalIds); } private  Id(); static String unique(); static String unique(String id, String... additionalIds); static String build(String id, String... additionalIds);  }
@Test void simple() { assertEquals("foo", Id.build("foo")); }
@Test void complex() { assertEquals("foo-bar-1-2-3", Id.build("foo", "bar", "1-2", "3")); }
@Test void emptyNull() { assertEquals("foo-bar", Id.build("foo", "", null, "", "", "bar", "")); }
@Test void illegal() { assertThrows(IllegalArgumentException.class, () -> Id.build(null)); }
@Test void build() { assertEquals("lorem-ipsum", Id.build("lorem-ipsum")); assertEquals("lorem-ipsum", Id.build("Lorem Ipsum")); assertEquals("lorem-ipsum", Id.build("Lorem", "Ipsum")); assertEquals("lorem-ipsum", Id.build(" Lorem ", " Ipsum ")); assertEquals("l0rem-ip5um", Id.build("l0rem ip5um")); assertEquals("l0rem-ip5um", Id.build("l0rem", "ip5um")); assertEquals("l0rem-ip5um", Id.build(" l0rem ", " ip5um ")); assertEquals("lorem---ipsum", Id.build("lorem §±!@#$%^&*()=_+[]{};'\\:\"|,./<>?`~ ipsum")); assertEquals("lorem---ipsum", Id.build("lorem", "§±!@#$%^&*()=_+[]{};'\\:\"|,./<>?`~", "ipsum")); }
@Test void similar() { String id1 = Id.build("foo_bar"); String id2 = Id.build("foo-bar"); String id3 = Id.build("foo bar"); assertEquals(id1, id2); assertEquals(id1, id3); assertEquals(id2, id3); String id4 = Id.build("foobar"); String id5 = Id.build("fooBar"); assertEquals(id4, id5); assertNotEquals(id1, id4); }