MotechEnumUtils { public static String toString(Set<? extends Enum> items) { StringBuilder csv = new StringBuilder(); Boolean first = true; for (Enum item : items) { if (first) { first = false; } else { csv.append(','); } csv.append(item.name()); } return csv.toString(); } private  MotechEnumUtils(); static Set<String> toStringSet(Set<? extends Enum> items); static String toString(Set<? extends Enum> items); static Set<T> toEnumSet(Class<T> enumClass, Set<String> strings); static Set<T> toEnumSet(Class<T> enumClass, String csv);  }
@Test public void shouldReturnValidString() throws Exception { String actual; actual = MotechEnumUtils.toString(ENUM_SET); Set<String> actualSet = new HashSet<>(Arrays.asList(actual.split(","))); assertEquals(actualSet, STRING_SET); }