From 80861dae5c6d64a66b9376111152d13ea713a712 Mon Sep 17 00:00:00 2001 From: labkey-danield Date: Thu, 9 Jul 2026 15:30:39 -0700 Subject: [PATCH 1/2] Modify AuditLogHelper.checkAuditEventValuesForTransactionId to do a set comparison and not a list comparison. --- src/org/labkey/test/util/AuditLogHelper.java | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/org/labkey/test/util/AuditLogHelper.java b/src/org/labkey/test/util/AuditLogHelper.java index 74c8a45114..898b1ba253 100644 --- a/src/org/labkey/test/util/AuditLogHelper.java +++ b/src/org/labkey/test/util/AuditLogHelper.java @@ -31,6 +31,7 @@ import java.util.Map; import java.util.Objects; import java.util.Set; +import java.util.stream.Collectors; import static java.lang.Integer.parseInt; import static org.junit.Assert.assertEquals; @@ -261,19 +262,24 @@ public void checkAuditEventValuesForTransactionId(String containerPath, AuditEve public void checkAuditEventValuesForTransactionId(String containerPath, AuditEvent auditEventName, Integer transactionId, List> expectedValues) throws IOException, CommandException { - List columnNames = expectedValues.get(0).keySet().stream().map(Object::toString).toList(); + List columnNames = expectedValues.getFirst().keySet().stream().map(Object::toString).toList(); checkAuditEventValuesForTransactionId(containerPath, auditEventName, columnNames, transactionId, expectedValues); } public void checkAuditEventValuesForTransactionId(String containerPath, AuditEvent auditEventName, List columnNames, Integer transactionId, List> expectedValues) throws IOException, CommandException { List> events = getAuditLogsForTransactionId(containerPath, auditEventName, columnNames, transactionId, ContainerFilter.CurrentAndSubfolders); - assertEquals("Unexpected number of events for transactionId " + transactionId, expectedValues.size(), events.size()); - for (int i = 0; i < expectedValues.size(); i++) - { - for (String key : expectedValues.get(i).keySet()) - assertEquals("Event " + i + " value for " + key + " not as expected", expectedValues.get(i).get(key), events.get(i).get(key)); - } + + Set keysOfInterest = expectedValues.getFirst().keySet(); + List> actualFiltered = events.stream() + .map(row -> row.entrySet().stream() + .filter(e -> keysOfInterest.contains(e.getKey())) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))) + .toList(); + + assertEquals("Lists do not contain the same entries", + new HashSet<>(actualFiltered), new HashSet<>(expectedValues)); + } public Map getTransactionAuditLogDetails(Integer transactionAuditId) From 8df14583e1a5ad764424d8bb887d92a5948f45e9 Mon Sep 17 00:00:00 2001 From: labkey-danield Date: Mon, 13 Jul 2026 11:57:38 -0700 Subject: [PATCH 2/2] Update AuditLogHelper.checkAuditEventValuesForTransactionId to be a set comparison and not a list comparison. Also update it to be flexible for different fields per record. --- src/org/labkey/test/util/AuditLogHelper.java | 22 ++++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/org/labkey/test/util/AuditLogHelper.java b/src/org/labkey/test/util/AuditLogHelper.java index 898b1ba253..7c99a3af18 100644 --- a/src/org/labkey/test/util/AuditLogHelper.java +++ b/src/org/labkey/test/util/AuditLogHelper.java @@ -31,7 +31,6 @@ import java.util.Map; import java.util.Objects; import java.util.Set; -import java.util.stream.Collectors; import static java.lang.Integer.parseInt; import static org.junit.Assert.assertEquals; @@ -270,16 +269,21 @@ public void checkAuditEventValuesForTransactionId(String containerPath, AuditEve { List> events = getAuditLogsForTransactionId(containerPath, auditEventName, columnNames, transactionId, ContainerFilter.CurrentAndSubfolders); - Set keysOfInterest = expectedValues.getFirst().keySet(); - List> actualFiltered = events.stream() - .map(row -> row.entrySet().stream() - .filter(e -> keysOfInterest.contains(e.getKey())) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))) + List> unmatched = expectedValues.stream() + .filter(expectedRow -> { + Set keysOfInterest = expectedRow.keySet(); + return events.stream().noneMatch(actualRow -> { + Map actualFiltered = actualRow.entrySet().stream() + .filter(e -> keysOfInterest.contains(e.getKey())) + .collect(HashMap::new, + (m, e) -> m.put(e.getKey(), e.getValue()), + HashMap::putAll); + return actualFiltered.equals(expectedRow); + }); + }) .toList(); - assertEquals("Lists do not contain the same entries", - new HashSet<>(actualFiltered), new HashSet<>(expectedValues)); - + assertTrue("Expected rows with no match in actual: " + unmatched, unmatched.isEmpty()); } public Map getTransactionAuditLogDetails(Integer transactionAuditId)