AMImageEntryProcessor implements DLProcessor, ImageProcessor { @Override public boolean hasImages(FileVersion fileVersion) { try { Stream<AdaptiveMedia<AMImageProcessor>> adaptiveMediaStream = _getThumbnailAdaptiveMedia(fileVersion); Optional<AdaptiveMedia<AMImageProcessor>> adaptiveMediaOptional = adaptiveMediaStream.findFirst(); if (adaptiveMediaOptional.isPresent()) { return true; } _processAMImage(fileVersion); return false; } catch (PortalException portalException) { if (_log.isWarnEnabled()) { _log.warn(portalException, portalException); } return false; } }  @Override void afterPropertiesSet(); @Override void cleanUp(FileEntry fileEntry); @Override void cleanUp(FileVersion fileVersion); @Override void copy(
		FileVersion sourceFileVersion, FileVersion destinationFileVersion); @Override void exportGeneratedFiles(
		PortletDataContext portletDataContext, FileEntry fileEntry,
		Element fileEntryElement); @Override void generateImages(
		FileVersion sourceFileVersion, FileVersion destinationFileVersion); @Override Set<String> getImageMimeTypes(); @Override InputStream getPreviewAsStream(FileVersion fileVersion); @Override long getPreviewFileSize(FileVersion fileVersion); @Override String getPreviewType(FileVersion fileVersion); @Override InputStream getThumbnailAsStream(FileVersion fileVersion, int index); @Override long getThumbnailFileSize(FileVersion fileVersion, int index); @Override String getThumbnailType(FileVersion fileVersion); @Override String getType(); @Override boolean hasImages(FileVersion fileVersion); @Override void importGeneratedFiles(
		PortletDataContext portletDataContext, FileEntry fileEntry,
		FileEntry importedFileEntry, Element fileEntryElement); @Override boolean isImageSupported(FileVersion fileVersion); @Override boolean isImageSupported(String mimeType); @Override boolean isSupported(FileVersion fileVersion); @Override boolean isSupported(String mimeType); @Override void storeThumbnail(
		long companyId, long groupId, long fileEntryId, long fileVersionId,
		long custom1ImageId, long custom2ImageId, InputStream inputStream,
		String type); @Override void trigger(
		FileVersion sourceFileVersion, FileVersion destinationFileVersion);  }
@Test public void testHasImagesDoesNotTriggerAMProcessorWhenAMImageExists() throws Exception { Mockito.when( _amImageFinder.getAdaptiveMediaStream(Mockito.any(Function.class)) ).thenAnswer( invocation -> Stream.of(_adaptiveMedia) ); _amImageEntryProcessor.hasImages(_fileVersion); Mockito.verify( _amAsyncProcessor, Mockito.never() ).triggerProcess( Mockito.any(FileVersion.class), Mockito.anyString() ); }
@Test public void testHasImagesDoesNotTriggerAMProcessorWhenInvalidSize() throws Exception { Mockito.when( _amImageFinder.getAdaptiveMediaStream(Mockito.any(Function.class)) ).thenAnswer( invocation -> Stream.empty() ); Mockito.when( _amImageMimeTypeProvider.isMimeTypeSupported(Mockito.anyString()) ).thenReturn( true ); Mockito.when( _amImageValidator.isValid(_fileVersion) ).thenReturn( false ); _amImageEntryProcessor.hasImages(_fileVersion); Mockito.verify( _amAsyncProcessor, Mockito.never() ).triggerProcess( Mockito.any(FileVersion.class), Mockito.anyString() ); }
@Test public void testHasImagesDoesNotTriggerAMProcessorWhenNotSupported() throws Exception { Mockito.when( _amImageFinder.getAdaptiveMediaStream(Mockito.any(Function.class)) ).thenAnswer( invocation -> Stream.empty() ); Mockito.when( _amImageMimeTypeProvider.isMimeTypeSupported(Mockito.anyString()) ).thenReturn( false ); _amImageEntryProcessor.hasImages(_fileVersion); Mockito.verify( _amAsyncProcessor, Mockito.never() ).triggerProcess( Mockito.any(FileVersion.class), Mockito.anyString() ); }
@Test public void testHasImagesTriggersAMProcessorWhenNoAMImageExists() throws Exception { Mockito.when( _amImageFinder.getAdaptiveMediaStream(Mockito.any(Function.class)) ).thenAnswer( invocation -> Stream.empty() ); Mockito.when( _amImageMimeTypeProvider.isMimeTypeSupported(Mockito.anyString()) ).thenReturn( true ); Mockito.when( _amImageValidator.isValid(_fileVersion) ).thenReturn( true ); _amImageEntryProcessor.hasImages(_fileVersion); Mockito.verify( _amAsyncProcessor ).triggerProcess( Mockito.any(FileVersion.class), Mockito.anyString() ); }