Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 34 additions & 3 deletions src/org/labkey/test/util/AuditLogHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import static java.lang.Integer.parseInt;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.labkey.test.WebDriverWrapper.WAIT_FOR_JAVASCRIPT;
import static org.labkey.test.WebDriverWrapper.waitFor;

public class AuditLogHelper
{
Expand Down Expand Up @@ -232,10 +234,39 @@ public void checkAuditEventDiffCount(String containerPath, AuditEvent auditEvent
}
}

public Integer getLastTransactionId(String containerPath, AuditEvent auditEventName) throws IOException, CommandException
public Integer getLastTransactionId(String containerPath, AuditEvent auditEventName)
{
List<Map<String, Object>> events = getAuditLogsFromLKS(containerPath, auditEventName, List.of("TransactionId"), Collections.emptyList(), 1, ContainerFilter.CurrentAndSubfolders).getRows();
return events.size() == 1 ? (Integer) events.get(0).get("TransactionId") : null;
try
{
List<Map<String, Object>> events = getAuditLogsFromLKS(containerPath, auditEventName, List.of("TransactionId"), Collections.emptyList(), 1, ContainerFilter.CurrentAndSubfolders).getRows();
return events.size() == 1 ? (Integer) events.get(0).get("TransactionId") : null;
}
catch (Exception e)
{
throw new RuntimeException(e);
}
}

public Integer doAndWaitForTransaction(Runnable action, String containerPath, AuditEvent auditEventName)
{
int prevTransactionId;
if (action != null)
{
prevTransactionId = Objects.requireNonNullElse(getLastTransactionId(containerPath, auditEventName), -1);
action.run();
}
else
{
prevTransactionId = -1;
}

return waitFor(() -> {
Integer transactionId = getLastTransactionId(containerPath, auditEventName);
if (transactionId != null && transactionId > prevTransactionId)
return transactionId;
else
return null;
}, "Error waiting for next transactionId in " + auditEventName, WAIT_FOR_JAVASCRIPT);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/org/labkey/test/util/TestDataGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public class TestDataGenerator
public static final char WIDE_PLACEHOLDER = '\u03A0'; // 'Π' - Wide character can't be picked from the string with 'charAt'
public static final char REPEAT_PLACEHOLDER = '\u22EF'; // '⋯' - Used to indicate that the char will be repeated
public static final char ALL_CHARS_PLACEHOLDER = '\u2211'; // '∑' - Used to indicate that all characters from the charset should be used
public static final String NON_LATIN_STRING = "\u0438\uC548\u306F"; // "и안は"
public static final String NON_LATIN_STRING = "\u0438\u0418\uC548\u306F"; // "иИ안は"
// chose a Character random from this String
public static final String CHARSET_STRING = "ABCDEFG01234abcdefvxyz~!@#$%^&*()-+=_{}[]|:;\"',.<>" + NON_LATIN_STRING + WIDE_PLACEHOLDER;
public static final String ALPHANUMERIC_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvxyz";
Expand Down