diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/audit/AuditEntry.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/audit/AuditEntry.java index e09d7d71f3..7138819c0a 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/audit/AuditEntry.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/audit/AuditEntry.java @@ -34,13 +34,17 @@ import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; -import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import org.alfresco.utility.model.TestModel; +/** + * POJO for audit entry + * + * @author Rodica Sutu + * @since 2.7 + */ @Builder @Data -@EqualsAndHashCode (callSuper = true) @NoArgsConstructor @AllArgsConstructor @JsonIgnoreProperties (ignoreUnknown = true) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/audit/AuditEvents.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/audit/AuditEvents.java index 3e305085a2..144520abd4 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/audit/AuditEvents.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/audit/AuditEvents.java @@ -28,6 +28,7 @@ package org.alfresco.rest.rm.community.model.audit; /** * Enumerates the list of events audited + * * @author Rodica Sutu * @since 2.7 * @@ -36,6 +37,7 @@ public enum AuditEvents { CREATE_PERSON("Create Person","Create User"), DELETE_PERSON("Delete Person","Delete User"); + /** event audited */ public final String event; diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/PojoUtility.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/PojoUtility.java index 344947d363..e3bb8c8860 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/PojoUtility.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/PojoUtility.java @@ -101,10 +101,10 @@ public class PojoUtility } /** - * Converting json to object + * Converting json to java object * - * @param json The json object to convert - * @param classz Class (or interface) whose annotations to effectively override + * @param json The json object to convert + * @param classz Class for the java object * @return The converted java object * @throws JsonProcessingException Throws exceptions if the given object doesn't match to the POJO class model */ @@ -126,6 +126,14 @@ public class PojoUtility return (T) obj; } + /** + * Converting json array into a list of java objects + * + * @param json The json array to convert + * @param classz Class for the java object + * @return The list of converted java objects + * @throws JsonProcessingException Throws exceptions if the given object doesn't match to the POJO class model + */ public static List jsonToObject(JSONArray json, Class classz) { diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMAuditAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMAuditAPI.java index e2f54a12fb..4bc5b4d21b 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMAuditAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMAuditAPI.java @@ -43,20 +43,18 @@ import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; /** - * The v0 REST API for copy-to (which supports multi-item copy). + * The v0 REST API for rm audit logs * - * @author Tom Page - * @since 2.6 + * @author Rodica Sutu + * @since 2.7 */ @Component public class RMAuditAPI extends BaseAPI { /** Logger for the class. */ private static final Logger LOGGER = LoggerFactory.getLogger(RMAuditAPI.class); + /** The URI for the audit API. */ - /** - * The URI for the copy-to API. - */ private static final String RM_AUDIT_API = "{0}rma/admin/rmauditlog"; private static final String RM_AUDIT_LOG_API = RM_AUDIT_API + "?{1}"; @@ -66,8 +64,8 @@ public class RMAuditAPI extends BaseAPI * @param user The username of the user to use. * @param password The password of the user. * @param size Maximum number of log entries to return - * @param event Only return log entries matching this event - * @return return the A + * @param event The name of audit event to be retrieved + * @return return Only return log entries matching this event */ public List getRMAuditLog(String user, String password, final int size, final String event) { @@ -89,9 +87,9 @@ public class RMAuditAPI extends BaseAPI /** * Clear the list of audit entries audit of Records Management events. . * - * @param username The username of the user to use. + * @param username The username of the user to use. * @param password The password of the user. - * @throws AssertionError If the API call didn't return a 200 response. + * @throws AssertionError If the API call didn't clear the audit log. */ public void clearAuditLog(String username, String password) { diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditUserEventsTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditUserEventsTests.java index 0636c36606..33af49b2c9 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditUserEventsTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditUserEventsTests.java @@ -28,6 +28,7 @@ package org.alfresco.rest.rm.community.audit; import static org.alfresco.rest.rm.community.model.audit.AuditEvents.CREATE_PERSON; import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix; +import static org.alfresco.utility.report.log.Step.STEP; import static org.testng.AssertJUnit.assertTrue; import java.util.List; @@ -67,12 +68,15 @@ public class AuditUserEventsTests extends BaseRMRestTest @AlfrescoTest(jira = "RM-6223") public void createUserEventIsAudited() throws Exception { + STEP("Create a new user."); String userName = "auditCreateUser" + PREFIX; - createUser = getDataUser().createUser(userName); + + STEP("Get the list of audit entries for the create person event."); List auditEntries = rmAuditAPI.getRMAuditLog(getAdminUser().getPassword(), getAdminUser().getPassword(), 100, CREATE_PERSON.event); + STEP("Check the audit log contains only the entries for the created user."); assertTrue("The list of events is not filtered by " + CREATE_PERSON.event, auditEntries.stream().allMatch(auditEntry -> auditEntry.getEvent().equals(CREATE_PERSON.eventDisplayName)));