Package org.jtalks.jcommune.service.exceptions

Examples of org.jtalks.jcommune.service.exceptions.ImageSizeException


    public void validateImageSize(byte[] bytes) throws ImageSizeException {
        Validate.notNull(bytes, "Incoming byte array cannot be null");
        int maxSize = imageSizeProperty.intValue();
        if (bytes.length > maxSize) {
            LOGGER.debug("File has too big size. Must be less than {} bytes", maxSize);
            throw new ImageSizeException(maxSize);
        }
    }
View Full Code Here


    @Test
    public void userSetIncorrectAvatarShouldGetDefaultAvatar() throws ImageProcessException, NotFoundException {
        //ARRANGE
        byte[] avatar = new byte[10];
        doThrow(new ImageFormatException("test")).when(imageService).validateImageFormat(any(byte[].class));
        doThrow(new ImageSizeException(1)).when(imageService).validateImageSize(any(byte[].class));
        //ACT
        defaultAvatarEditor.setAsText(String.valueOf(avatar));
        //ASSERT
        verify(imageService, times(1)).getDefaultImage();
    }
View Full Code Here

    }

    @Test
    public void handleImageSizeExceptionShouldReturnValidationErrorAndErrorMessage() {
        int maxSize = 1000;
        ImageSizeException exception = new ImageSizeException(maxSize);
        Locale locale = Locale.ENGLISH;//it's not matter
        String expectedMessage = "a message " + maxSize;
        //
        when(messageSource.getMessage(
                Matchers.anyString(),
View Full Code Here

TOP

Related Classes of org.jtalks.jcommune.service.exceptions.ImageSizeException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.