Don't crash when creating test data with 0 contacts

If no contacts exist, at least one will be created
parent da3cb951
......@@ -116,9 +116,6 @@ public class TestDataCreatorImpl implements TestDataCreator {
@Override
public void createTestData(int numContacts, int numPrivateMsgs,
int numBlogPosts, int numForums, int numForumPosts) {
if (numContacts == 0)
throw new IllegalArgumentException(
"Number of contacts must be >= 1");
ioExecutor.execute(() -> {
try {
createTestDataOnIoExecutor(numContacts, numPrivateMsgs,
......@@ -133,7 +130,13 @@ public class TestDataCreatorImpl implements TestDataCreator {
private void createTestDataOnIoExecutor(int numContacts, int numPrivateMsgs,
int numBlogPosts, int numForums, int numForumPosts)
throws DbException {
List<Contact> contacts = createContacts(numContacts);
List<Contact> contacts;
if (numContacts == 0) {
contacts = new ArrayList<>(contactManager.getActiveContacts());
if (contacts.isEmpty()) contacts = createContacts(1);
} else {
contacts = createContacts(numContacts);
}
createPrivateMessages(contacts, numPrivateMsgs);
createBlogPosts(contacts, numBlogPosts);
List<Forum> forums = createForums(contacts, numForums, numForumPosts);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment