AuditStorageProvider implements StorageProvider { @Override public String addContent(String spaceId, String contentId, String contentMimeType, Map<String, String> userProperties, long contentSize, String contentChecksum, InputStream content) { contentChecksum = target.addContent(spaceId, contentId, contentMimeType, userProperties, contentSize, contentChecksum, content); String action = AuditTask.ActionType.ADD_CONTENT.name(); submitWriteTask(action, spaceId, contentId, contentChecksum, contentMimeType, String.valueOf(contentSize), userProperties, null, AuditTask.NA, AuditTask.NA); return contentChecksum; } AuditStorageProvider(StorageProvider target,
                                String account,
                                String storeId,
                                String storeType,
                                UserUtil userUtil,
                                TaskQueue taskQueue); @Override StorageProviderType getStorageProviderType(); @Override Iterator<String> getSpaces(); @Override Iterator<String> getSpaceContents(String spaceId, String prefix); @Override List<String> getSpaceContentsChunked(String spaceId, String prefix,
                                                long maxResults, String marker); @Override Map<String, String> getSpaceProperties(String spaceId); @Override Map<String, AclType> getSpaceACLs(String spaceId); @Override RetrievedContent getContent(String spaceId, String contentId); @Override RetrievedContent getContent(String spaceId, String contentId, String range); @Override Map<String, String> getContentProperties(String spaceId,
                                                    String contentId); @Override void createSpace(String spaceId); @Override void deleteSpace(String spaceId); @Override void setSpaceACLs(String spaceId, Map<String, AclType> spaceACLs); @Override String addContent(String spaceId,
                             String contentId,
                             String contentMimeType,
                             Map<String, String> userProperties,
                             long contentSize,
                             String contentChecksum,
                             InputStream content); @Override String copyContent(String sourceSpaceId, String sourceContentId,
                              String destSpaceId, String destContentId); @Override void deleteContent(String spaceId, String contentId); @Override void setContentProperties(String spaceId, String contentId,
                                     Map<String, String> contentProperties);  }
@Test public void testAddContent() throws Exception { Capture<Task> auditTaskCapture = mockAuditCall(); Capture<Task> logCapture = mockWriteLogCall(); Map<String, String> contentProps = new HashMap<>(); String propName = "prop-name"; String propValue = "prop-value"; contentProps.put(propName, propValue); EasyMock.expect( targetProvider.addContent(spaceId, contentId, contentMimeType, contentProps, contentSize, contentChecksum, null)) .andReturn(contentChecksum); replayAll(); provider.addContent(spaceId, contentId, contentMimeType, contentProps, contentSize, contentChecksum, null); Task auditTask = auditTaskCapture.getValue(); assertEquals(auditTask, logCapture.getValue()); Map<String, String> taskProps = verifyTask(auditTask, AuditTask.ActionType.ADD_CONTENT.name()); assertEquals(contentId, taskProps.get(AuditTask.CONTENT_ID_PROP)); assertEquals(contentMimeType, taskProps.get(AuditTask.CONTENT_MIMETYPE_PROP)); assertEquals(String.valueOf(contentSize), taskProps.get(AuditTask.CONTENT_SIZE_PROP)); assertEquals(contentChecksum, taskProps.get(AuditTask.CONTENT_CHECKSUM_PROP)); String contentPropsProp = taskProps.get(AuditTask.CONTENT_PROPERTIES_PROP); assertNotNull(contentPropsProp); assertTrue(contentPropsProp.contains(propName)); assertTrue(contentPropsProp.contains(propValue)); }