mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-17 13:19:52 +01:00
Don't crash when creating test data with 0 contacts
If no contacts exist, at least one will be created
This commit is contained in:
@@ -116,9 +116,6 @@ public class TestDataCreatorImpl implements TestDataCreator {
|
|||||||
@Override
|
@Override
|
||||||
public void createTestData(int numContacts, int numPrivateMsgs,
|
public void createTestData(int numContacts, int numPrivateMsgs,
|
||||||
int numBlogPosts, int numForums, int numForumPosts) {
|
int numBlogPosts, int numForums, int numForumPosts) {
|
||||||
if (numContacts == 0)
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"Number of contacts must be >= 1");
|
|
||||||
ioExecutor.execute(() -> {
|
ioExecutor.execute(() -> {
|
||||||
try {
|
try {
|
||||||
createTestDataOnIoExecutor(numContacts, numPrivateMsgs,
|
createTestDataOnIoExecutor(numContacts, numPrivateMsgs,
|
||||||
@@ -133,7 +130,13 @@ public class TestDataCreatorImpl implements TestDataCreator {
|
|||||||
private void createTestDataOnIoExecutor(int numContacts, int numPrivateMsgs,
|
private void createTestDataOnIoExecutor(int numContacts, int numPrivateMsgs,
|
||||||
int numBlogPosts, int numForums, int numForumPosts)
|
int numBlogPosts, int numForums, int numForumPosts)
|
||||||
throws DbException {
|
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);
|
createPrivateMessages(contacts, numPrivateMsgs);
|
||||||
createBlogPosts(contacts, numBlogPosts);
|
createBlogPosts(contacts, numBlogPosts);
|
||||||
List<Forum> forums = createForums(contacts, numForums, numForumPosts);
|
List<Forum> forums = createForums(contacts, numForums, numForumPosts);
|
||||||
|
|||||||
Reference in New Issue
Block a user