title: JUnit and Mockito unit test for stream.mark(stream.available) when doing S3 putObject
body: <p>I have a method which puts InputStream in s3 bucket.</p>
  <pre><code>@Override
      public String putObject(@NonNull String s3BucketName, @NonNull String s3Key, @NonNull String content,
                              @NonNull ObjectMetadata metadataRequest) {
          InputStream stream = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8));
          try {
              stream.mark(stream.available());
          } catch (IOException e) {
              String errorMessage = String.format(&quot;Runtime error while marking stream.&quot;,
                      s3BucketName, s3Key);
              throw new RuntimeException(errorMessage, e);
          }
          PutObjectRequest request = new PutObjectRequest(s3BucketName, s3Key, stream, metadataRequest);
          return putObject(request);
      }
  </code></pre>
  <p>I want to make the method cause IOException and then throw RuntimeException and I have written the unit test for the same.</p>
  <pre><code>@Test
      public void putObjectTest_withStringContent_withMetadataRequest_IOError() {
          ObjectMetadata metadataRequest = new ObjectMetadata();
          metadataRequest.addUserMetadata(TEST_METADATA_KEY, TEST_METADATA_VALUE);
          InputStream mockStream = Mockito.mock(InputStream.class);
          Mockito.when(mockStream.mark(mockStream.available())).thenThrow(IOException.class);
  
          assertThrows(RuntimeException.class, () -&gt; s3Accessor.putObject
                  (TEST_S3BUCKET, TEST_S3OBJECT, TEST_STRING, metadataRequest));
      }
  </code></pre>
  <p>This is what I have tried but this is showing error in editor</p>
  <pre><code>Required type:
  T
  Provided:
  void
  reason: no instance(s) of type variable(s) T exist so that void conforms to T
  </code></pre>
  <p>How can I make the method throw IOException?</p>