JacksonUtil { public static JsonNode readTree(ObjectMapper objectMapper, byte[] bytes) { try { return objectMapper.readTree(bytes); } catch (MismatchedInputException | JsonParseException e) { throw new DataConversionException(INPUT_MISMATCH_ERROR_MESSAGE, e); } catch (IOException e) { throw new UncheckedIOException(e); } } private  JacksonUtil(); static JsonNode readTree(ObjectMapper objectMapper, byte[] bytes); static byte[] binaryValue(JsonNode jsonNode);  }
@Test void readTree_with_IOException_test() throws IOException { ObjectMapper objectMapper = mock(ObjectMapper.class); when(objectMapper.readTree((byte[]) any())).thenThrow(IOException.class); byte[] value = new byte[0]; assertThatThrownBy(()-> JacksonUtil.readTree(objectMapper, value)).isInstanceOf(UncheckedIOException.class); }
@Test void readTree_with_JsonParseException_test() throws IOException { ObjectMapper objectMapper = mock(ObjectMapper.class); when(objectMapper.readTree((byte[]) any())).thenThrow(JsonParseException.class); byte[] value = new byte[0]; assertThatThrownBy(()-> JacksonUtil.readTree(objectMapper, value)).isInstanceOf(DataConversionException.class); }