@Test
public void testGetMediaInputStream() throws Exception {

	AMImageConfigurationEntry amImageConfigurationEntry =
		new AMImageConfigurationEntryImpl(
			RandomTestUtil.randomString(), RandomTestUtil.randomString(),
			Collections.emptyMap());
	AMImageQueryBuilder.ConfigurationStatus enabledConfigurationStatus =
		AMImageQueryBuilder.ConfigurationStatus.ENABLED;
	Mockito.when(
		_amImageConfigurationHelper.getAMImageConfigurationEntries(
			_fileVersion.getCompanyId(),
			enabledConfigurationStatus.getPredicate())
	).thenReturn(
		Collections.singleton(amImageConfigurationEntry)
	);
	Mockito.when(
		_fileVersion.getFileName()
	).thenReturn(
		RandomTestUtil.randomString()
	);
	Mockito.when(
		_fileVersion.getMimeType()
	).thenReturn(
		"image/jpeg"
	);
	AMImageEntry amImageEntry = _mockImage(800, 900, 1000L);
	Mockito.when(
		_amImageEntryLocalService.fetchAMImageEntry(
			amImageConfigurationEntry.getUUID(),
			_fileVersion.getFileVersionId())
	).thenReturn(
		amImageEntry
	);
	Mockito.when(
		_amImageMimeTypeProvider.isMimeTypeSupported(Mockito.anyString())
	).thenReturn(
		true
	);
	InputStream inputStream = Mockito.mock(InputStream.class);
	Mockito.when(
		_amImageEntryLocalService.getAMImageEntryContentStream(
			amImageConfigurationEntry, _fileVersion)
	).thenReturn(
		inputStream
	);
	Stream<AdaptiveMedia<AMImageProcessor>> adaptiveMediaStream =
		_amImageFinderImpl.getAdaptiveMediaStream(
			amImageQueryBuilder -> amImageQueryBuilder.forFileVersion(
				_fileVersion
			).done());
	List<AdaptiveMedia<AMImageProcessor>> adaptiveMedias =
		adaptiveMediaStream.collect(Collectors.toList());
	Assert.assertEquals(
		adaptiveMedias.toString(), 1, adaptiveMedias.size());
	AdaptiveMedia<AMImageProcessor> adaptiveMedia = adaptiveMedias.get(0);
	Assert.assertSame(inputStream, adaptiveMedia.getInputStream());
}