From 1c2b4da16a9a8e63383e69b5a79dd150b6cde00b Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 7 Nov 2019 12:36:52 +0200 Subject: [PATCH] replaced the todos --- .../community/audit/AuditAddToHoldTests.java | 15 +++++++++----- .../community/audit/AuditCreateHoldTests.java | 2 +- .../community/audit/AuditDeleteHoldTests.java | 5 ++++- .../audit/AuditRemoveFromHoldTests.java | 20 +++++++++++-------- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditAddToHoldTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditAddToHoldTests.java index 6bebd31ddb..ed63133be4 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditAddToHoldTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditAddToHoldTests.java @@ -41,6 +41,8 @@ import static org.testng.AssertJUnit.assertTrue; import java.util.Collections; import java.util.List; +import com.google.common.collect.ImmutableMap; + import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.rm.community.base.BaseRMRestTest; import org.alfresco.rest.rm.community.model.audit.AuditEntry; @@ -174,8 +176,9 @@ public class AuditAddToHoldTests extends BaseRMRestTest holdsAPI.addItemToHold(rmAdmin.getUsername(), rmAdmin.getPassword(), nodeId, HOLD1); STEP("Check the audit log contains the entry for the add to hold event."); - rmAuditService.checkAuditLogForEvent(getAdminUser(), ADD_TO_HOLD, rmAdmin, HOLD1, Collections.emptyList()); - //TODO replace changed values + rmAuditService.checkAuditLogForEvent(getAdminUser(), ADD_TO_HOLD, rmAdmin, HOLD1, + asList(ImmutableMap.of("new", nodeName, "previous", "", "name", "Name"), + ImmutableMap.of("new", HOLD1, "previous", "", "name", "Hold Name"))); } /** @@ -211,7 +214,7 @@ public class AuditAddToHoldTests extends BaseRMRestTest { STEP("Create a new record folder with a record inside"); RecordCategoryChild notEmptyRecFolder = createRecordFolder(recordCategory.getId(), PREFIX + "notEmptyRecFolder"); - createElectronicRecord(notEmptyRecFolder.getId(), PREFIX + "record"); + Record record = createElectronicRecord(notEmptyRecFolder.getId(), PREFIX + "record"); rmAuditService.clearAuditLog(); @@ -221,8 +224,10 @@ public class AuditAddToHoldTests extends BaseRMRestTest auditEntries = rmAuditService.getAuditEntriesFilteredByEvent(getAdminUser(), ADD_TO_HOLD); STEP("Check the audit log contains only an entry for add to hold."); - assertEquals("The list of events should not contain Add to Hold entry for the record", 1, auditEntries.size()); - //TODO check content name + assertEquals("The list of events should contain only an entry", 1, auditEntries.size()); + assertTrue("The list of events should not contain Add to Hold entry for the record", + auditEntries.stream().noneMatch(entry -> entry.getChangedValues().contains( + Collections.singletonList(ImmutableMap.of("new", record.getName(), "previous", "", "name", "Name"))))); } /** diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditCreateHoldTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditCreateHoldTests.java index 6789ff11ba..a316ed2b7c 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditCreateHoldTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditCreateHoldTests.java @@ -105,7 +105,7 @@ public class AuditCreateHoldTests extends BaseRMRestTest STEP("Check the audit log contains the entry for the created hold with the hold details."); rmAuditService.checkAuditLogForEvent(getAdminUser(), CREATE_HOLD, rmAdmin, HOLD1, asList(ImmutableMap.of("new", HOLD_REASON, "previous", "", "name", "Hold Reason"), - ImmutableMap.of("new", HOLD1, "previous", "", "name", "Name"))); + ImmutableMap.of("new", HOLD1, "previous", "", "name", "Hold Name"))); } /** diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditDeleteHoldTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditDeleteHoldTests.java index 94cec954f7..bcc535410e 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditDeleteHoldTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditDeleteHoldTests.java @@ -39,6 +39,8 @@ import static org.testng.AssertJUnit.assertTrue; import java.util.Collections; +import com.google.common.collect.ImmutableMap; + import org.alfresco.rest.rm.community.base.BaseRMRestTest; import org.alfresco.rest.rm.community.model.user.UserRoles; import org.alfresco.rest.v0.HoldsAPI; @@ -106,7 +108,8 @@ public class AuditDeleteHoldTests extends BaseRMRestTest holdsAPI.deleteHold(rmAdmin.getUsername(), rmAdmin.getPassword(), HOLD2); STEP("Check the audit log contains the entry for the deleted hold with the hold details."); - rmAuditService.checkAuditLogForEvent(getAdminUser(), DELETE_HOLD, rmAdmin, HOLD2, Collections.emptyList()); + rmAuditService.checkAuditLogForEvent(getAdminUser(), DELETE_HOLD, rmAdmin, HOLD2, + Collections.singletonList(ImmutableMap.of("new", "", "previous", HOLD2, "name", "Hold Name"))); } /** diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditRemoveFromHoldTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditRemoveFromHoldTests.java index d24da88e07..c650ea5b4b 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditRemoveFromHoldTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditRemoveFromHoldTests.java @@ -41,6 +41,8 @@ import static org.testng.AssertJUnit.assertTrue; import java.util.Collections; import java.util.List; +import com.google.common.collect.ImmutableMap; + import org.alfresco.dataprep.CMISUtil; import org.alfresco.rest.rm.community.base.BaseRMRestTest; import org.alfresco.rest.rm.community.model.audit.AuditEntry; @@ -185,8 +187,9 @@ public class AuditRemoveFromHoldTests extends BaseRMRestTest holdsAPI.removeItemFromHold(rmAdmin.getUsername(), rmAdmin.getPassword(), nodeId, HOLD3); STEP("Check the audit log contains the entry for the remove from hold event."); - rmAuditService.checkAuditLogForEvent(getAdminUser(), REMOVE_FROM_HOLD, rmAdmin, HOLD3, Collections.emptyList()); - //TODO replace changed values + rmAuditService.checkAuditLogForEvent(getAdminUser(), REMOVE_FROM_HOLD, rmAdmin, HOLD3, + asList(ImmutableMap.of("new", "", "previous", nodeName, "name", "Name"), + ImmutableMap.of("new", "", "previous", HOLD3, "name", "Hold Name"))); } /** @@ -208,8 +211,8 @@ public class AuditRemoveFromHoldTests extends BaseRMRestTest STEP("Check the audit log contains the entry for the remove from hold."); rmAuditService.checkAuditLogForEvent(getAdminUser(), REMOVE_FROM_HOLD, rmAdmin, DELETED_HOLD, - Collections.emptyList()); - //TODO replace changed values + asList(ImmutableMap.of("new", "", "previous", heldContent.getName(), "name", "Name"), + ImmutableMap.of("new", "", "previous", DELETED_HOLD, "name", "Hold Name"))); } /** @@ -242,7 +245,7 @@ public class AuditRemoveFromHoldTests extends BaseRMRestTest { STEP("Create a new record folder with a record inside"); RecordCategoryChild notEmptyRecFolder = createRecordFolder(recordCategory.getId(), PREFIX + "notEmptyRecFolder"); - createElectronicRecord(notEmptyRecFolder.getId(), PREFIX + "record"); + Record record = createElectronicRecord(notEmptyRecFolder.getId(), PREFIX + "record"); STEP("Add the record folder to a hold."); holdsAPI.addItemToHold(rmAdmin.getUsername(), rmAdmin.getPassword(), notEmptyRecFolder.getId(), HOLD1); @@ -256,9 +259,10 @@ public class AuditRemoveFromHoldTests extends BaseRMRestTest auditEntries = rmAuditService.getAuditEntriesFilteredByEvent(getAdminUser(), REMOVE_FROM_HOLD); STEP("Check the audit log contains only an entry for remove from hold."); - assertEquals("The list of events should not contain Remove from Hold entry for the record", 1, - auditEntries.size()); - //TODO check content name + assertEquals("The list of events should contain only an entry", 1, auditEntries.size()); + assertTrue("The list of events should not contain Remove from Hold entry for the record", + auditEntries.stream().noneMatch(entry -> entry.getChangedValues().contains( + Collections.singletonList(ImmutableMap.of("new", "", "previous", record.getName(), "name", "Name"))))); } /**