Skip to content

Commit d5a1a37

Browse files
committed
Try using bulk delete again
1 parent 1cf1eb1 commit d5a1a37

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/org/labkey/test/util/APIUserHelper.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package org.labkey.test.util;
1717

18+
import org.apache.commons.lang3.ArrayUtils;
1819
import org.apache.hc.client5.http.classic.methods.HttpPost;
1920
import org.apache.hc.client5.http.entity.UrlEncodedFormEntity;
2021
import org.apache.hc.core5.http.message.BasicNameValuePair;
@@ -239,15 +240,17 @@ private void deleteUser(@NotNull Integer userId)
239240
protected void _deleteUsers(boolean failIfNotFound, String... userEmails)
240241
{
241242
Map<String, Integer> userIds = getUserIds(Arrays.asList(userEmails), true);
242-
// TODO: instead of calling deleteUser() one-by-one, should build an array of userIds and call deleteUsers(int...)
243+
List<Integer> validUserIds = new ArrayList<>();
243244
for (String userEmail : new HashSet<>(Arrays.asList(userEmails)))
244245
{
245246
Integer userId = userIds.get(userEmail);
246247
if (failIfNotFound)
247248
assertNotNull(userEmail + " was not present", userId);
248249
if (userId != null)
249-
deleteUser(userId);
250+
validUserIds.add(userId);
250251
}
252+
if (!validUserIds.isEmpty())
253+
deleteUsers(ArrayUtils.toPrimitive(validUserIds.toArray(new Integer[0])));
251254
}
252255

253256
private static final Pattern regEmailVerification = Pattern.compile("verification=([A-Za-z0-9]+)");

0 commit comments

Comments
 (0)