ProjectAttachmentRepository { public AttachmentValue storeAttachment(AttachmentValue fileMetadata, InputStream binaryData) { GridFSFile res = gridFsOperations.store(binaryData, fileMetadata.getFilename(), fileMetadata.getContentType()); return new AttachmentValue(res.getId().toString(), res.getContentType(), res.getFilename(), res.getLength(), new DateTime(res.getUploadDate())); }  AttachmentValue storeAttachment(AttachmentValue fileMetadata, InputStream binaryData); InputStream loadAttachment(AttachmentValue attachment); void deleteAttachment(AttachmentValue attachment);  }
@Test public void storeFile_shouldInvokeGridFsOps() throws Exception { final AttachmentValue attachment = aStoringRequestAttachment(); final InputStream binaryData = mockedInputStream(); final AttachmentValue expAttachment = aPersitedAttachment(); when(gridFsOperations.store( eq(binaryData), eq(attachment.getFilename()), eq(attachment.getContentType()))) .thenReturn(mockedFsDbFileFromAttachmentValue(expAttachment)); AttachmentValue res = projectAttachmentRepository.storeAttachment(attachment, binaryData); assertThat(res, is(expAttachment)); }