### Question:
JSON { @SuppressWarnings("unchecked") public <T> T deserialize(String body, Type returnType) { try { if (isLenientOnJson) { JsonReader jsonReader = new JsonReader(new StringReader(body)); jsonReader.setLenient(true); return gson.fromJson(jsonReader, returnType); } else { return gson.fromJson(body, returnType); } } catch (JsonParseException e) { if (returnType.equals(String.class)) { return (T) body; } else { throw (e); } } } JSON(); static GsonBuilder createGson(); Gson getGson(); JSON setGson(Gson gson); JSON setLenientOnJson(boolean lenientOnJson); String serialize(Object obj); @SuppressWarnings("unchecked") T deserialize(String body, Type returnType); JSON setOffsetDateTimeFormat(DateTimeFormatter dateFormat); JSON setLocalDateFormat(DateTimeFormatter dateFormat); JSON setDateFormat(DateFormat dateFormat); JSON setSqlDateFormat(DateFormat dateFormat);  }### Answer:
@Test public void testByteArrayTypeAdapterDeserialization() { final String expectedBytesAsString = "Let's pretend this a jpg or something"; final byte[] expectedBytes = expectedBytesAsString.getBytes(StandardCharsets.UTF_8); final ByteString expectedByteString = ByteString.of(expectedBytes); final String serializedBytes = expectedByteString.base64(); final String serializedBytesWithQuotes = "\"" + serializedBytes + "\""; Type type = new TypeToken<byte[]>() { }.getType(); byte[] actualDeserializedBytes = json.deserialize(serializedBytesWithQuotes, type); assertEquals(expectedBytesAsString, new String(actualDeserializedBytes, StandardCharsets.UTF_8)); }