PathParamHelper { public static <T extends Enum<?>> T toEnum(String value, Class<T> valueClass) { try { return JSON.fromEnumValue(valueClass, value); } catch (IllegalArgumentException e) { throw new BadRequestException(format("failed to parse enum, enumClass={}, value={}", valueClass.getCanonicalName(), value), "INVALID_HTTP_REQUEST", e); } }  static T toEnum(String value, Class<T> valueClass); static Long toLong(String value); static Integer toInt(String value); static String toString(String value); static String toString(Number value); static String toString(T enumValue);  }
@Test void parseEnum() { assertThat(PathParamHelper.toEnum("V1", TestEnum.class)).isEqualTo(TestEnum.VALUE); assertThatThrownBy(() -> PathParamHelper.toEnum("V2", TestEnum.class)) .isInstanceOf(BadRequestException.class) .hasMessageContaining("failed to parse enum"); }