@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 testReturnsIdOfStreamAndFileDescriptorEncoders() {
    String streamId = "streamId";
    when(streamEncoder.getId()).thenReturn(streamId);
    String fileId = "fileId";
    when(fileDescriptorEncoder.getId()).thenReturn(fileId);

    String id = encoder.getId();

    assertThat(id).contains(streamId);
    assertThat(id).contains(fileId);
  }
  @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));
  }