### Question:
ParserWrapper implements Parser { @Override public <T extends Enum<T>> T getEnum(Class<T> enumClass) throws MatchbookSDKParsingException { if (isNotNullValue()) { try { String value = jsonParser.getValueAsString().toUpperCase().replace('-', '_'); try { return Enum.valueOf(enumClass, value); } catch (IllegalArgumentException iae) { return Enum.valueOf(enumClass, "UNKNOWN"); } } catch (IOException e) { throw new MatchbookSDKParsingException(e); } } return null; } ParserWrapper(JsonFactory jsonFactory, InputStream inputStream); @Override boolean hasCurrentToken(); @Override boolean isEndOfObject(); @Override boolean isEndOfArray(); @Override void moveToNextToken(); @Override void moveToNextValue(); @Override void skipChildren(); @Override String getFieldName(); @Override Boolean getBoolean(); @Override String getString(); @Override Integer getInteger(); @Override Long getLong(); @Override Double getDouble(); @Override BigDecimal getDecimal(); @Override Instant getInstant(); @Override T getEnum(Class<T> enumClass); @Override void close();  }### Answer:
@Test @DisplayName("Read enum value") void getEnumTest() throws IOException { TestEnum expectedResult = TestEnum.VALUE; when(jsonParser.getValueAsString()).thenReturn(expectedResult.name()); when(jsonParser.hasToken(JsonToken.VALUE_NULL)).thenReturn(false); TestEnum result = unit.getEnum(TestEnum.class); assertThat(result).isNotNull(); assertThat(result).isEqualTo(expectedResult); }
@Test @DisplayName("Read not known enum value") void getEnumUnknownTest() throws IOException { when(jsonParser.getValueAsString()).thenReturn("something not known"); when(jsonParser.hasToken(JsonToken.VALUE_NULL)).thenReturn(false); TestEnum result = unit.getEnum(TestEnum.class); assertThat(result).isNotNull(); assertThat(result).isEqualTo(TestEnum.UNKNOWN); }
@Test @DisplayName("Read null enum value") void getEnumNullTest() { when(jsonParser.hasToken(JsonToken.VALUE_NULL)).thenReturn(true); TestEnum result = unit.getEnum(TestEnum.class); assertThat(result).isNull(); }
@Test @DisplayName("Exception reading enum value") void getEnumFailedTest() throws IOException { doThrow(IOException.class).when(jsonParser).getValueAsString(); when(jsonParser.hasToken(JsonToken.VALUE_NULL)).thenReturn(false); assertThatExceptionOfType(MatchbookSDKParsingException.class) .isThrownBy(() -> unit.getEnum(TestEnum.class)); }