AbstractUploadFileCacheService implements UploadFileCacheService { @Override @CachePut(key = "#timestamp") public UploadedFile addUploadedFile(long timestamp, MultipartFile file, String encodedFilename) throws IOException { final UploadedFile uploadedFile = new UploadedFile(); setFilename(encodedFilename, uploadedFile); setFileContents(file, uploadedFile); uploadedFile.setTimestamp(timestamp); return uploadedFile; }  @Override @CachePut(key = "#timestamp") UploadedFile addUploadedFile(long timestamp, MultipartFile file, String encodedFilename); @Override @Cacheable(key = "#timestamp") UploadedFile getUploadedFile(long timestamp); @Override @CacheEvict(key = "#timestamp") void deleteUploadedFile(long timestamp);  }
@Test public void uploadFileWithNameRandomTxtWillReturnFilename() throws Exception { final MockMultipartFile file = createFile(); final UploadedFile uploadedFile = fileUploadService.addUploadedFile(timestamp, file, encodedFilename); assertThat(uploadedFile.getFilename()).contains(encodedFilename); assertThat(uploadedFile.getTimestamp()).isEqualTo(timestamp); }
@Test public void uploadFileWhenNullGiven() throws Exception { final UploadedFile uploadedFile = fileUploadService.addUploadedFile(timestamp, null, ""); assertThat(uploadedFile.getFilename()).isEqualTo(""); }