From 80861dae5c6d64a66b9376111152d13ea713a712 Mon Sep 17 00:00:00 2001 From: labkey-danield Date: Thu, 9 Jul 2026 15:30:39 -0700 Subject: [PATCH] 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)