StringToInputStreamAdapter implements TypeAdapter<String, InputStream> { @Override public InputStream adapt(String source) { if (source == null) { return null; } try { return new StringInputStream(source); } catch (UnsupportedEncodingException e) { throw new SdkClientException(e); } }  @Override InputStream adapt(String source);  }
@Test public void nullString_ReturnsNullInputStream() { assertNull(adapter.adapt(null)); }
@Test public void emptyString_ReturnsEmptyInputStream() throws IOException { InputStream inputStream = adapter.adapt(""); assertEquals(-1, inputStream.read()); }
@Test public void nonEmptyString_ReturnsNonEmptyInputStream() throws IOException { String source = "foo"; InputStream inputStream = adapter.adapt(source); byte[] bytes = new byte[3]; inputStream.read(bytes); assertArrayEquals(bytes, source.getBytes()); }