@Test
  public void testEncodesWithStreamEncoderIfInputStreamIsNotNull() {
    InputStream expected = new ByteArrayInputStream(new byte[2]);
    ImageVideoWrapper data = mock(ImageVideoWrapper.class);
    when(data.getStream()).thenReturn(expected);

    OutputStream os = new ByteArrayOutputStream();
    when(streamEncoder.encode(eq(expected), eq(os))).thenReturn(true);
    assertTrue(encoder.encode(data, os));

    verify(streamEncoder).encode(eq(expected), eq(os));
  }
  @Test
  public void testEncodesWithFileDescriptorEncoderIfFileDescriptorIsNotNullAndStreamIs()
      throws IOException {
    ParcelFileDescriptor expected = ParcelFileDescriptor.dup(FileDescriptor.err);
    ImageVideoWrapper data = mock(ImageVideoWrapper.class);
    when(data.getStream()).thenReturn(null);
    when(data.getFileDescriptor()).thenReturn(expected);

    OutputStream os = new ByteArrayOutputStream();
    when(fileDescriptorEncoder.encode(eq(expected), eq(os))).thenReturn(true);
    assertTrue(encoder.encode(data, os));

    verify(fileDescriptorEncoder).encode(eq(expected), eq(os));
  }