@Test public void validateShouldNotThrowFileValidationExceptionWhenOriginalFileNameIsValidPdf() throws FileValidationException { MultipartFile multipartFile = MultipartFileCreatorTestHelper .createMultipartFile(ORIGINAL_FILENAME_IS_VALID_PDF, FILE_SIZE_FIVE_MB); fileValidator.validate(multipartFile); }
@Override public void validate(MultipartFile file) throws FileValidationException { Assert.notNull(file); if (isMissingFile(file)) { throw new FileIsMissingValidationException(); } if (isEmptyFile(file)) { throw new FileIsEmptyValidationException(); } if (isGreaterFileSizeThanTheMaximumFileSize(file)) { throw new FileIsTooLargeValidationException(); } if (isFileInWrongExtension(file)) { throw new FileIsInWrongExtensionValidationException(); } if (isFileContainsNotOnlyValidCharacters(file)) { throw new FileContainsInvalidCharacterValidationException(); } }
FileValidatorImpl implements FileValidator { @Override public void validate(MultipartFile file) throws FileValidationException { Assert.notNull(file); if (isMissingFile(file)) { throw new FileIsMissingValidationException(); } if (isEmptyFile(file)) { throw new FileIsEmptyValidationException(); } if (isGreaterFileSizeThanTheMaximumFileSize(file)) { throw new FileIsTooLargeValidationException(); } if (isFileInWrongExtension(file)) { throw new FileIsInWrongExtensionValidationException(); } if (isFileContainsNotOnlyValidCharacters(file)) { throw new FileContainsInvalidCharacterValidationException(); } } }
FileValidatorImpl implements FileValidator { @Override public void validate(MultipartFile file) throws FileValidationException { Assert.notNull(file); if (isMissingFile(file)) { throw new FileIsMissingValidationException(); } if (isEmptyFile(file)) { throw new FileIsEmptyValidationException(); } if (isGreaterFileSizeThanTheMaximumFileSize(file)) { throw new FileIsTooLargeValidationException(); } if (isFileInWrongExtension(file)) { throw new FileIsInWrongExtensionValidationException(); } if (isFileContainsNotOnlyValidCharacters(file)) { throw new FileContainsInvalidCharacterValidationException(); } }  }
FileValidatorImpl implements FileValidator { @Override public void validate(MultipartFile file) throws FileValidationException { Assert.notNull(file); if (isMissingFile(file)) { throw new FileIsMissingValidationException(); } if (isEmptyFile(file)) { throw new FileIsEmptyValidationException(); } if (isGreaterFileSizeThanTheMaximumFileSize(file)) { throw new FileIsTooLargeValidationException(); } if (isFileInWrongExtension(file)) { throw new FileIsInWrongExtensionValidationException(); } if (isFileContainsNotOnlyValidCharacters(file)) { throw new FileContainsInvalidCharacterValidationException(); } }  @Override void validate(MultipartFile file); }
FileValidatorImpl implements FileValidator { @Override public void validate(MultipartFile file) throws FileValidationException { Assert.notNull(file); if (isMissingFile(file)) { throw new FileIsMissingValidationException(); } if (isEmptyFile(file)) { throw new FileIsEmptyValidationException(); } if (isGreaterFileSizeThanTheMaximumFileSize(file)) { throw new FileIsTooLargeValidationException(); } if (isFileInWrongExtension(file)) { throw new FileIsInWrongExtensionValidationException(); } if (isFileContainsNotOnlyValidCharacters(file)) { throw new FileContainsInvalidCharacterValidationException(); } }  @Override void validate(MultipartFile file);  }