### Question:
StringUtils { public static <E extends Enum<E>> E fromValue(final Class<E> enumClass, final String value) { for (final E enumConstant : enumClass.getEnumConstants()) { if (enumConstant.toString().equals(value)) { return enumConstant; } } throw new IllegalArgumentException( String.format("Unknown value %s for enum class %s", value, enumClass.getName())); }  static String replaceSubstring(final String s, final int startIndex, final int endIndex,
            final String replacement); static List<E> parseListEnums(final String s, final Class<E> enumClass); static E parseEnum(final String s, final Class<E> enumClass); static E fromValue(final Class<E> enumClass, final String value); static String join(final List<String> substrings, final String join); static String join(final List<String> substrings); static boolean containsPattern(final String string, final String pattern); static boolean containsPattern(final String string, final Pattern pattern);  }### Answer:
@Test public void shouldReturnEnumConstantFromValue_withStringValue() { final String s = "Second"; final Class<TestEnum> enumClass = TestEnum.class; final TestEnum result = StringUtils.fromValue(enumClass, s); assertEquals(TestEnum.VALUE_TWO, result); }
@Test public void shouldNotReturnEnumConstantFromValue_withUnknownStringValue() { final String s = "unknown"; final Class<TestEnum> enumClass = TestEnum.class; IllegalArgumentException thrownException = null; try { StringUtils.fromValue(enumClass, s); } catch (final IllegalArgumentException e) { thrownException = e; } assertNotNull(thrownException); }