Search in sources :

Example 1 with FileUploadManager

use of alfio.manager.FileUploadManager in project alf.io by alfio-event.

the class TemplateProcessorTest method assertDimensionsUnder300x150.

private void assertDimensionsUnder300x150(Pair<String, String> p) {
    Map<String, String> parameters = new HashMap<>();
    parameters.put(FileBlobMetadata.ATTR_IMG_WIDTH, p.getLeft());
    parameters.put(FileBlobMetadata.ATTR_IMG_HEIGHT, p.getRight());
    FileBlobMetadata metadata = mock(FileBlobMetadata.class);
    when(metadata.getAttributes()).thenReturn(parameters);
    Event e = mock(Event.class);
    when(e.getFileBlobIdIsPresent()).thenReturn(true);
    FileUploadManager fileUploadManager = mock(FileUploadManager.class);
    when(fileUploadManager.findMetadata(e.getFileBlobId())).thenReturn(Optional.of(metadata));
    TemplateProcessor.extractImageModel(e, fileUploadManager).ifPresent(imageData -> {
        assertTrue(imageData.getImageWidth() <= 300);
        assertTrue(imageData.getImageHeight() <= 150);
    });
}
Also used : HashMap(java.util.HashMap) FileBlobMetadata(alfio.model.FileBlobMetadata) Event(alfio.model.Event) FileUploadManager(alfio.manager.FileUploadManager)

Aggregations

FileUploadManager (alfio.manager.FileUploadManager)1 Event (alfio.model.Event)1 FileBlobMetadata (alfio.model.FileBlobMetadata)1 HashMap (java.util.HashMap)1