@Test
public void testGetMediaQueryWithConfigurationStatusAttributeWithWidth()
	throws Exception {

	AMImageConfigurationEntry amImageConfigurationEntry1 =
		new AMImageConfigurationEntryImpl(
			RandomTestUtil.randomString(), "1",
			MapUtil.fromArray("max-height", "100"));
	AMImageConfigurationEntry amImageConfigurationEntry2 =
		new AMImageConfigurationEntryImpl(
			RandomTestUtil.randomString(), RandomTestUtil.randomString(),
			"2", MapUtil.fromArray("max-height", "200"), false);
	AMImageQueryBuilder.ConfigurationStatus enabledConfigurationStatus =
		AMImageQueryBuilder.ConfigurationStatus.ENABLED;
	Mockito.when(
		_amImageConfigurationHelper.getAMImageConfigurationEntries(
			_fileVersion.getCompanyId(),
			enabledConfigurationStatus.getPredicate())
	).thenReturn(
		Arrays.asList(amImageConfigurationEntry1)
	);
	AMImageQueryBuilder.ConfigurationStatus disabledConfigurationStatus =
		AMImageQueryBuilder.ConfigurationStatus.DISABLED;
	Mockito.when(
		_amImageConfigurationHelper.getAMImageConfigurationEntries(
			_fileVersion.getCompanyId(),
			disabledConfigurationStatus.getPredicate())
	).thenReturn(
		Arrays.asList(amImageConfigurationEntry2)
	);
	AMImageQueryBuilder.ConfigurationStatus allConfigurationStatus =
		AMImageQueryBuilder.ConfigurationStatus.ANY;
	Mockito.when(
		_amImageConfigurationHelper.getAMImageConfigurationEntries(
			_fileVersion.getCompanyId(),
			allConfigurationStatus.getPredicate())
	).thenReturn(
		Arrays.asList(
			amImageConfigurationEntry1, amImageConfigurationEntry2)
	);
	Mockito.when(
		_fileVersion.getFileName()
	).thenReturn(
		RandomTestUtil.randomString()
	);
	Mockito.when(
		_fileVersion.getMimeType()
	).thenReturn(
		"image/jpeg"
	);
	AMImageEntry amImageEntry1 = _mockImage(100, 1000, 1000L);
	Mockito.when(
		_amImageEntryLocalService.fetchAMImageEntry(
			amImageConfigurationEntry1.getUUID(),
			_fileVersion.getFileVersionId())
	).thenReturn(
		amImageEntry1
	);
	AMImageEntry amImageEntry2 = _mockImage(200, 1000, 1000L);
	Mockito.when(
		_amImageEntryLocalService.fetchAMImageEntry(
			amImageConfigurationEntry2.getUUID(),
			_fileVersion.getFileVersionId())
	).thenReturn(
		amImageEntry2
	);
	Mockito.when(
		_amImageMimeTypeProvider.isMimeTypeSupported(Mockito.anyString())
	).thenReturn(
		true
	);
	Stream<AdaptiveMedia<AMImageProcessor>> adaptiveMediaStream =
		_amImageFinderImpl.getAdaptiveMediaStream(
			amImageQueryBuilder -> amImageQueryBuilder.forFileVersion(
				_fileVersion
			).withConfigurationStatus(
				enabledConfigurationStatus
			).with(
				AMImageAttribute.AM_IMAGE_ATTRIBUTE_WIDTH, 100
			).done());
	List<AdaptiveMedia<AMImageProcessor>> adaptiveMedias =
		adaptiveMediaStream.collect(Collectors.toList());
	AdaptiveMedia<AMImageProcessor> adaptiveMedia0 = adaptiveMedias.get(0);
	Optional<String> adaptiveMedia0ConfigurationUuidOptional =
		adaptiveMedia0.getValueOptional(
			AMAttribute.getConfigurationUuidAMAttribute());
	Assert.assertEquals("1", adaptiveMedia0ConfigurationUuidOptional.get());
	adaptiveMediaStream = _amImageFinderImpl.getAdaptiveMediaStream(
		amImageQueryBuilder -> amImageQueryBuilder.forFileVersion(
			_fileVersion
		).withConfigurationStatus(
			disabledConfigurationStatus
		).with(
			AMImageAttribute.AM_IMAGE_ATTRIBUTE_WIDTH, 100
		).done());
	adaptiveMedias = adaptiveMediaStream.collect(Collectors.toList());
	adaptiveMedia0 = adaptiveMedias.get(0);
	adaptiveMedia0ConfigurationUuidOptional =
		adaptiveMedia0.getValueOptional(
			AMAttribute.getConfigurationUuidAMAttribute());
	Assert.assertEquals("2", adaptiveMedia0ConfigurationUuidOptional.get());
	adaptiveMediaStream = _amImageFinderImpl.getAdaptiveMediaStream(
		amImageQueryBuilder -> amImageQueryBuilder.forFileVersion(
			_fileVersion
		).withConfigurationStatus(
			allConfigurationStatus
		).with(
			AMImageAttribute.AM_IMAGE_ATTRIBUTE_WIDTH, 100
		).done());
	adaptiveMedias = adaptiveMediaStream.collect(Collectors.toList());
	adaptiveMedia0 = adaptiveMedias.get(0);
	adaptiveMedia0ConfigurationUuidOptional =
		adaptiveMedia0.getValueOptional(
			AMAttribute.getConfigurationUuidAMAttribute());
	Assert.assertEquals("1", adaptiveMedia0ConfigurationUuidOptional.get());
	AdaptiveMedia<AMImageProcessor> adaptiveMedia1 = adaptiveMedias.get(1);
	Optional<String> adaptiveMedia1ConfigurationUuidOptional =
		adaptiveMedia1.getValueOptional(
			AMAttribute.getConfigurationUuidAMAttribute());
	Assert.assertEquals("2", adaptiveMedia1ConfigurationUuidOptional.get());
}