TextDeSerializer implements SerDeserializer { @SuppressWarnings("unchecked") @Override public final <T> T unmarshal(final Object data, final SerializedDataType type, final EnhancedMimeType mimeType) { if (data instanceof byte[]) { return (T) new String((byte[]) data, mimeType.getEncoding()); } if (data instanceof String) { return (T) data; } throw new IllegalArgumentException( "This deserializer only supports input of type 'String' and 'byte[]', but was: " + data); } TextDeSerializer();  TextDeSerializer(final Charset encoding); @Override final EnhancedMimeType getMimeType(); @Override final byte[] marshal(final Object obj, final SerializedDataType type); @SuppressWarnings("unchecked") @Override final T unmarshal(final Object data, final SerializedDataType type, final EnhancedMimeType mimeType);  }
@Test public void testUnmarshalString() { final SerializedDataType type = new SerializedDataType("AType"); final String original = "Whatever"; final String copy = testee.unmarshal(original, type, EnhancedMimeType.create("text/plain; encoding=" + CHARSET)); assertThat(copy).isEqualTo(original); }