@Test public void test_deserialize_type_wrong() { exception.expect(IllegalArgumentException.class); exception.expectMessage("Target type must be assignable from String"); assertThat(codec.deserialize("", getClass()), is(equalTo(""))); }
@Override public <T> T deserialize(String response, Class<T> target) throws DiagnosticCodecException { requireNonNull(response); requireNonNull(target); if (target.isAssignableFrom(String.class)) { return target.cast(new String(Base64.getDecoder().decode(requireNonNull(response)), UTF_8)); } if (target.isAssignableFrom(byte[].class)) { return target.cast(Base64.getDecoder().decode(requireNonNull(response))); } throw new IllegalArgumentException("Target type must be assignable from String or byte[]"); }
Base64DiagnosticCodec extends DiagnosticCodecSkeleton<String> { @Override public <T> T deserialize(String response, Class<T> target) throws DiagnosticCodecException { requireNonNull(response); requireNonNull(target); if (target.isAssignableFrom(String.class)) { return target.cast(new String(Base64.getDecoder().decode(requireNonNull(response)), UTF_8)); } if (target.isAssignableFrom(byte[].class)) { return target.cast(Base64.getDecoder().decode(requireNonNull(response))); } throw new IllegalArgumentException("Target type must be assignable from String or byte[]"); } }
Base64DiagnosticCodec extends DiagnosticCodecSkeleton<String> { @Override public <T> T deserialize(String response, Class<T> target) throws DiagnosticCodecException { requireNonNull(response); requireNonNull(target); if (target.isAssignableFrom(String.class)) { return target.cast(new String(Base64.getDecoder().decode(requireNonNull(response)), UTF_8)); } if (target.isAssignableFrom(byte[].class)) { return target.cast(Base64.getDecoder().decode(requireNonNull(response))); } throw new IllegalArgumentException("Target type must be assignable from String or byte[]"); } Base64DiagnosticCodec(); }
Base64DiagnosticCodec extends DiagnosticCodecSkeleton<String> { @Override public <T> T deserialize(String response, Class<T> target) throws DiagnosticCodecException { requireNonNull(response); requireNonNull(target); if (target.isAssignableFrom(String.class)) { return target.cast(new String(Base64.getDecoder().decode(requireNonNull(response)), UTF_8)); } if (target.isAssignableFrom(byte[].class)) { return target.cast(Base64.getDecoder().decode(requireNonNull(response))); } throw new IllegalArgumentException("Target type must be assignable from String or byte[]"); } Base64DiagnosticCodec(); @Override String serialize(Object o); @Override T deserialize(String response, Class<T> target); @Override String toString(); }
Base64DiagnosticCodec extends DiagnosticCodecSkeleton<String> { @Override public <T> T deserialize(String response, Class<T> target) throws DiagnosticCodecException { requireNonNull(response); requireNonNull(target); if (target.isAssignableFrom(String.class)) { return target.cast(new String(Base64.getDecoder().decode(requireNonNull(response)), UTF_8)); } if (target.isAssignableFrom(byte[].class)) { return target.cast(Base64.getDecoder().decode(requireNonNull(response))); } throw new IllegalArgumentException("Target type must be assignable from String or byte[]"); } Base64DiagnosticCodec(); @Override String serialize(Object o); @Override T deserialize(String response, Class<T> target); @Override String toString();  }