Enums { public static void checkAllEnumeratedIgnoreCase(Class<? extends Enum<?>> type, String ...explicitValues) { checkAllEnumeratedIgnoreCase(JavaClassNames.simpleClassName(type), values(type), explicitValues); }  static Function<Enum<?>,String> nameFunction(); static Function<String,T> fromStringFunction(Class<T> type); @SuppressWarnings("unchecked") static T[] values(Class<T> type); static void checkAllEnumeratedIgnoreCase(Class<? extends Enum<?>> type, String ...explicitValues); static void checkAllEnumeratedIgnoreCase(String contextMessage, Enum<?>[] enumValues, String ...explicitValues); static Maybe<T> valueOfIgnoreCase(Class<T> type, String givenValue); static Maybe<T> valueOfIgnoreCase(String contextMessage, T[] enumValues, String givenValue);  }
@Test public static void testAllValuesEnumerated() { Enums.checkAllEnumeratedIgnoreCase(SomeENum.class, "e_300", "E_624", "WORD_UP", "aliceTheCamel"); }
@Test(expectedExceptions=IllegalStateException.class, expectedExceptionsMessageRegExp = ".*leftover values.*vitamin.*") public static void testAllValuesEnumeratedExtra() { Enums.checkAllEnumeratedIgnoreCase(SomeENum.class, "e_300", "E_624", "Vitamin C", "wordUp", "alice_the_camel"); }
@Test(expectedExceptions=IllegalStateException.class, expectedExceptionsMessageRegExp = ".*leftover enums.*E_624.*leftover values.*") public static void testAllValuesEnumeratedMissing() { Enums.checkAllEnumeratedIgnoreCase(SomeENum.class, "e_300", "word_UP", "aliceTheCamel"); }
@Test(expectedExceptions=IllegalStateException.class, expectedExceptionsMessageRegExp = ".*leftover enums.*E_624.*leftover values.*msg.*") public static void testAllValuesEnumeratedMissingAndExtra() { Enums.checkAllEnumeratedIgnoreCase(SomeENum.class, "e_300", "MSG", "WORD_UP", "aliceTheCamel"); }
@Test(expectedExceptions=IllegalStateException.class, expectedExceptionsMessageRegExp = ".*leftover enums.*\\[aliceTheCamel\\].*leftover values.*alice_thecamel.*") public static void testAllValuesEnumeratedNoMatchBadCamel() { Enums.checkAllEnumeratedIgnoreCase(SomeENum.class, "e_300", "E_624", "WORD_UP", "alice_TheCamel"); }