### Question:
NameUtils { @Nonnull public static <T extends Enum<T>> T toEnumValue( @Nonnull Class<T> enumClass, @Nullable Object value ) throws IllegalArgumentException { final String stringValue = toEnumName( value ); if ( stringValue == null ) { throw new IllegalArgumentException( "Null enum values are not allowed" ); } return Enum.valueOf( enumClass, stringValue ); } private  NameUtils(); @Nullable static String toClassName( @Nullable Object value ); @Nonnull static T toEnumValue( @Nonnull Class<T> enumClass, @Nullable Object value ); @Nullable static T toEnumValue( @Nonnull Class<T> enumClass, @Nullable String value ); @Nullable static String toEnumName( @Nullable Object value );  }### Answer:
@Test public void toEnumValueNull() { Assert.assertNull( NameUtils.toEnumValue( ChronoUnit.class, null ) ); }
@Test( expected = IllegalArgumentException.class ) public void toEnumValueNullString() { NameUtils.toEnumValue( ChronoUnit.class, new Object() { @Override public String toString() { return null; } } ); }
@Test public void toEnumValueObject() { Assert.assertEquals( ChronoUnit.HALF_DAYS, NameUtils.toEnumValue( ChronoUnit.class, new Object() { @Override public String toString() { return "halfDays"; } } ) ); }
@Test public void toEnumValueDash() { Assert.assertEquals( TestEnum.XYZ, NameUtils.toEnumValue( TestEnum.class, "xy-z" ) ); }
@Test public void toEnumValueString() { Assert.assertEquals( ChronoUnit.HALF_DAYS, NameUtils.toEnumValue( ChronoUnit.class, "half-DAYS" ) ); }