### Question:
AttachmentFileManager { public Attachment uploadAttachment(InputStream attachmentInputStream, String fileName) { String systemDataStorageName = preferenceManager.getPreference( SystemPreferences.DATA_STORAGE_SYSTEM_DATA_STORAGE_NAME); Assert.notNull(systemDataStorageName, messageHelper.getMessage( MessageConstants.ERROR_ATTACHMENT_SYSTEM_DATA_STORAGE_NOT_CONFIGURED)); AbstractDataStorage attachmentStorage = dataStorageManager.loadByNameOrId(systemDataStorageName); UUID uuid = UUID.randomUUID(); String uniqueName = uuid.toString() + "-" + fileName; DataStorageFile uploadedFile = dataStorageManager.createDataStorageFile(attachmentStorage.getId(), ATTACHMENTS_DIRECTORY, uniqueName, attachmentInputStream); Attachment attachment = new Attachment(); attachment.setPath(uploadedFile.getPath()); attachment.setName(fileName); attachment.setCreatedDate(DateUtils.now()); attachment.setOwner(authManager.getAuthorizedUser()); attachmentManager.create(attachment); return attachment; } @Autowired  AttachmentFileManager(DataStorageManager dataStorageManager, PreferenceManager preferenceManager,
                                 AttachmentManager attachmentManager, MessageHelper messageHelper,
                                 AuthManager authManager); Attachment uploadAttachment(InputStream attachmentInputStream, String fileName); DataStorageStreamingContent downloadAttachment(long attachmentId); void deleteAttachments(List<Attachment> attachments); @Transactional(propagation = Propagation.REQUIRED) void deleteAttachment(long attachmentId);  }### Answer:
@Test public void testUploadAttachment() { Attachment attachment = attachmentFileManager.uploadAttachment(new ByteArrayInputStream(new byte[]{1}), TEST_ATTACHMENT_NAME); Assert.assertNotNull(attachment.getPath()); Assert.assertTrue(attachment.getPath().startsWith("attachments/")); Assert.assertTrue(attachment.getPath().endsWith(TEST_ATTACHMENT_NAME)); Assert.assertEquals(TEST_ATTACHMENT_NAME, attachment.getName()); verify(dataStorageManager).loadByNameOrId(TEST_SYSTEM_DATA_STORAGE); verify(dataStorageManager).createDataStorageFile(eq(testSystemDataStorage.getId()), eq("attachments"), Mockito.endsWith(TEST_ATTACHMENT_NAME), Mockito.any(InputStream.class)); ArgumentCaptor<Attachment> attachmentCaptor = ArgumentCaptor.forClass(Attachment.class); verify(attachmentManager).create(attachmentCaptor.capture()); Assert.assertEquals(TEST_USER, attachmentCaptor.getValue().getOwner()); }